add command line interface handler and implement convert command from pano to jpg
This commit is contained in:
@@ -170,6 +170,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="engine\action.cpp" />
|
<ClCompile Include="engine\action.cpp" />
|
||||||
<ClCompile Include="engine\app.cpp" />
|
<ClCompile Include="engine\app.cpp" />
|
||||||
|
<ClCompile Include="engine\app_commands.cpp" />
|
||||||
<ClCompile Include="engine\app_dialogs.cpp" />
|
<ClCompile Include="engine\app_dialogs.cpp" />
|
||||||
<ClCompile Include="engine\app_events.cpp" />
|
<ClCompile Include="engine\app_events.cpp" />
|
||||||
<ClCompile Include="engine\app_layout.cpp" />
|
<ClCompile Include="engine\app_layout.cpp" />
|
||||||
|
|||||||
@@ -225,6 +225,9 @@
|
|||||||
<ClCompile Include="engine\node_dialog_browse.cpp">
|
<ClCompile Include="engine\node_dialog_browse.cpp">
|
||||||
<Filter>Source Files\ui</Filter>
|
<Filter>Source Files\ui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="engine\app_commands.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="engine\app.h">
|
<ClInclude Include="engine\app.h">
|
||||||
|
|||||||
@@ -127,4 +127,6 @@ public:
|
|||||||
void dialog_export();
|
void dialog_export();
|
||||||
void dialog_layer_rename();
|
void dialog_layer_rename();
|
||||||
void brush_update();
|
void brush_update();
|
||||||
|
|
||||||
|
void cmd_convert(std::string pano_path, std::string out_path);
|
||||||
};
|
};
|
||||||
|
|||||||
16
engine/app_commands.cpp
Normal file
16
engine/app_commands.cpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "app.h"
|
||||||
|
#include "canvas.h"
|
||||||
|
|
||||||
|
void App::cmd_convert(std::string pano_path, std::string out_path)
|
||||||
|
{
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
|
||||||
|
ui::Canvas* canvas = new ui::Canvas;
|
||||||
|
canvas->create(CANVAS_RES, CANVAS_RES);
|
||||||
|
canvas->project_open_thread(pano_path);
|
||||||
|
canvas->export_equirectangular_thread(out_path);
|
||||||
|
}
|
||||||
@@ -144,7 +144,7 @@ void App::dialog_export()
|
|||||||
{
|
{
|
||||||
if (canvas)
|
if (canvas)
|
||||||
{
|
{
|
||||||
canvas->m_canvas->export_equirectangular(data_path);
|
canvas->m_canvas->export_equirectangular(data_path + "/" + doc_name + ".jpg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -790,7 +790,11 @@ void ui::Canvas::export_equirectangular_thread(std::string data_path)
|
|||||||
gl_state gl;
|
gl_state gl;
|
||||||
|
|
||||||
App::I.async_start();
|
App::I.async_start();
|
||||||
auto pb = std::make_shared<NodeProgressBar>();
|
|
||||||
|
std::shared_ptr<NodeProgressBar> pb;
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
|
pb = std::make_shared<NodeProgressBar>();
|
||||||
pb->m_manager = &App::I.layout;
|
pb->m_manager = &App::I.layout;
|
||||||
pb->init();
|
pb->init();
|
||||||
pb->create();
|
pb->create();
|
||||||
@@ -799,6 +803,7 @@ void ui::Canvas::export_equirectangular_thread(std::string data_path)
|
|||||||
pb->m_title->set_text("Export Pano Image");
|
pb->m_title->set_text("Export Pano Image");
|
||||||
App::I.layout[App::I.main_id]->add_child(pb);
|
App::I.layout[App::I.main_id]->add_child(pb);
|
||||||
App::I.async_update();
|
App::I.async_update();
|
||||||
|
}
|
||||||
|
|
||||||
// save viewport and clear color states
|
// save viewport and clear color states
|
||||||
GLint vp[4];
|
GLint vp[4];
|
||||||
@@ -861,12 +866,16 @@ void ui::Canvas::export_equirectangular_thread(std::string data_path)
|
|||||||
|
|
||||||
progress++;
|
progress++;
|
||||||
float p = (float)progress / total * 100.f;
|
float p = (float)progress / total * 100.f;
|
||||||
pb->m_progress->SetWidthP(p);
|
|
||||||
LOG("progress: %f", p);
|
LOG("progress: %f", p);
|
||||||
|
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
|
pb->m_progress->SetWidthP(p);
|
||||||
gl.save();
|
gl.save();
|
||||||
App::I.async_update();
|
App::I.async_update();
|
||||||
gl.restore();
|
gl.restore();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//auto data = std::make_unique<uint8_t[]>(m_tmp[0].bytes());
|
//auto data = std::make_unique<uint8_t[]>(m_tmp[0].bytes());
|
||||||
//for (int i = 0; i < 1; i++)
|
//for (int i = 0; i < 1; i++)
|
||||||
@@ -898,15 +907,19 @@ void ui::Canvas::export_equirectangular_thread(std::string data_path)
|
|||||||
{
|
{
|
||||||
progress++;
|
progress++;
|
||||||
float p = (float)progress / total * 100.f;
|
float p = (float)progress / total * 100.f;
|
||||||
pb->m_progress->SetWidthP(p);
|
|
||||||
LOG("progress: %f", p);
|
LOG("progress: %f", p);
|
||||||
|
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
|
pb->m_progress->SetWidthP(p);
|
||||||
gl.save();
|
gl.save();
|
||||||
App::I.async_update();
|
App::I.async_update();
|
||||||
gl.restore();
|
gl.restore();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static char name[128];
|
static char name[128];
|
||||||
sprintf(name, "%s/latlong.jpg", data_path.c_str());
|
sprintf(name, "%s", data_path.c_str());
|
||||||
LOG("writing %s", name);
|
LOG("writing %s", name);
|
||||||
jpge::params params;
|
jpge::params params;
|
||||||
params.m_quality = 100;
|
params.m_quality = 100;
|
||||||
@@ -916,12 +929,16 @@ void ui::Canvas::export_equirectangular_thread(std::string data_path)
|
|||||||
{
|
{
|
||||||
progress++;
|
progress++;
|
||||||
float p = (float)progress / total * 100.f;
|
float p = (float)progress / total * 100.f;
|
||||||
pb->m_progress->SetWidthP(p);
|
|
||||||
LOG("progress: %f", p);
|
LOG("progress: %f", p);
|
||||||
|
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
|
pb->m_progress->SetWidthP(p);
|
||||||
gl.save();
|
gl.save();
|
||||||
App::I.async_update();
|
App::I.async_update();
|
||||||
gl.restore();
|
gl.restore();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//int ret = stbi_write_png(name, m_latlong.getWidth(), m_latlong.getHeight(), 4, latlong_data.get(), m_latlong.stride());
|
//int ret = stbi_write_png(name, m_latlong.getWidth(), m_latlong.getHeight(), 4, latlong_data.get(), m_latlong.stride());
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
@@ -949,8 +966,11 @@ void ui::Canvas::export_equirectangular_thread(std::string data_path)
|
|||||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
pb->destroy();
|
pb->destroy();
|
||||||
App::I.async_update();
|
App::I.async_update();
|
||||||
|
}
|
||||||
App::I.async_end();
|
App::I.async_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1242,8 +1262,11 @@ void ui::Canvas::project_open_thread(std::string data_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gl_state gl;
|
gl_state gl;
|
||||||
|
std::shared_ptr<NodeProgressBar> pb;
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
App::I.async_start();
|
App::I.async_start();
|
||||||
auto pb = std::make_shared<NodeProgressBar>();
|
pb = std::make_shared<NodeProgressBar>();
|
||||||
pb->m_manager = &App::I.layout;
|
pb->m_manager = &App::I.layout;
|
||||||
pb->init();
|
pb->init();
|
||||||
pb->create();
|
pb->create();
|
||||||
@@ -1255,6 +1278,7 @@ void ui::Canvas::project_open_thread(std::string data_path)
|
|||||||
App::I.async_update();
|
App::I.async_update();
|
||||||
gl.restore();
|
gl.restore();
|
||||||
App::I.async_end();
|
App::I.async_end();
|
||||||
|
}
|
||||||
|
|
||||||
LOG("skip thumb");
|
LOG("skip thumb");
|
||||||
// skip thumbnail
|
// skip thumbnail
|
||||||
@@ -1315,9 +1339,13 @@ void ui::Canvas::project_open_thread(std::string data_path)
|
|||||||
std::copy(rgba, rgba + (imgw*imgh * 4), snap.image[plane_index].get());
|
std::copy(rgba, rgba + (imgw*imgh * 4), snap.image[plane_index].get());
|
||||||
delete rgba;
|
delete rgba;
|
||||||
}
|
}
|
||||||
|
|
||||||
progress++;
|
progress++;
|
||||||
float p = (float)progress / total * 100.f;
|
float p = (float)progress / total * 100.f;
|
||||||
LOG("progress: %f", p);
|
LOG("progress: %f", p);
|
||||||
|
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
App::I.async_start();
|
App::I.async_start();
|
||||||
pb->m_progress->SetWidthP(p);
|
pb->m_progress->SetWidthP(p);
|
||||||
gl.save();
|
gl.save();
|
||||||
@@ -1325,6 +1353,7 @@ void ui::Canvas::project_open_thread(std::string data_path)
|
|||||||
gl.restore();
|
gl.restore();
|
||||||
App::I.async_end();
|
App::I.async_end();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
App::I.async_start();
|
App::I.async_start();
|
||||||
m_layers.emplace_back();
|
m_layers.emplace_back();
|
||||||
@@ -1333,14 +1362,19 @@ void ui::Canvas::project_open_thread(std::string data_path)
|
|||||||
m_order.push_back(n_order);
|
m_order.push_back(n_order);
|
||||||
App::I.async_end();
|
App::I.async_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
LOG("project restore from %s", data_path.c_str());
|
LOG("project restore from %s", data_path.c_str());
|
||||||
|
|
||||||
|
if (App::I.layout.m_loaded)
|
||||||
|
{
|
||||||
App::I.async_start();
|
App::I.async_start();
|
||||||
pb->destroy();
|
pb->destroy();
|
||||||
gl.save();
|
gl.save();
|
||||||
App::I.async_update();
|
App::I.async_update();
|
||||||
gl.restore();
|
gl.restore();
|
||||||
App::I.async_end();
|
App::I.async_end();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui::Image ui::Canvas::thumbnail_generate(int w, int h)
|
ui::Image ui::Canvas::thumbnail_generate(int w, int h)
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
NS_START
|
NS_START
|
||||||
|
|
||||||
|
#define CANVAS_RES 2048
|
||||||
|
|
||||||
class Layer
|
class Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -333,10 +333,23 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If not supported, go fuck yourself we are not gonna use that shit
|
// If not supported, go fuck yourself we are not gonna support your shitty device
|
||||||
return -1; // A negative number because you are a negative one
|
return -1; // A negative number because you are a negative one
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
switch (const_hash(argv[1]))
|
||||||
|
{
|
||||||
|
case const_hash("convert"):
|
||||||
|
App::I.initShaders();
|
||||||
|
App::I.cmd_convert(argv[2], argv[3]);
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
App::I.init();
|
App::I.init();
|
||||||
|
|
||||||
ShowWindow(hWnd, SW_NORMAL);
|
ShowWindow(hWnd, SW_NORMAL);
|
||||||
@@ -402,7 +415,6 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||||
{
|
{
|
||||||
async_locker lock;
|
|
||||||
static bool leftDown = false;
|
static bool leftDown = false;
|
||||||
static DWORD lastTime;
|
static DWORD lastTime;
|
||||||
static POINT lastPoint;
|
static POINT lastPoint;
|
||||||
@@ -420,6 +432,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
auto h = (float)HIWORD(lp);
|
auto h = (float)HIWORD(lp);
|
||||||
if (h != 0)
|
if (h != 0)
|
||||||
{
|
{
|
||||||
|
async_locker lock;
|
||||||
App::I.resize(w, h);
|
App::I.resize(w, h);
|
||||||
App::I.clear();
|
App::I.clear();
|
||||||
App::I.redraw = true;
|
App::I.redraw = true;
|
||||||
@@ -439,18 +452,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
break;
|
break;
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
|
async_lock();
|
||||||
keys[wp] = true;
|
keys[wp] = true;
|
||||||
App::I.key_down(convert_key((int)wp));
|
App::I.key_down(convert_key((int)wp));
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
|
async_lock();
|
||||||
keys[wp] = false;
|
keys[wp] = false;
|
||||||
App::I.key_up(convert_key((int)wp));
|
App::I.key_up(convert_key((int)wp));
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
|
async_lock();
|
||||||
App::I.key_char((int)wp);
|
App::I.key_char((int)wp);
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
|
async_lock();
|
||||||
//TODO: find a way to check if event is mouse/stylus. For now use Mouse for all
|
//TODO: find a way to check if event is mouse/stylus. For now use Mouse for all
|
||||||
if (0 && leftDown)
|
if (0 && leftDown)
|
||||||
{
|
{
|
||||||
@@ -500,32 +520,42 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
|
|||||||
{
|
{
|
||||||
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), WacomTablet::I.get_pressure(), kEventSource::Mouse);
|
App::I.mouse_move((float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), WacomTablet::I.get_pressure(), kEventSource::Mouse);
|
||||||
}
|
}
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
//TODO: find a way to check if event is mouse/stylus. For now use Mouse for all
|
//TODO: find a way to check if event is mouse/stylus. For now use Mouse for all
|
||||||
|
async_lock();
|
||||||
leftDown = true;
|
leftDown = true;
|
||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
lastTime = GetMessageTime();
|
lastTime = GetMessageTime();
|
||||||
lastPoint = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) };
|
lastPoint = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) };
|
||||||
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), WacomTablet::I.get_pressure(), kEventSource::Mouse);
|
App::I.mouse_down(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), WacomTablet::I.get_pressure(), kEventSource::Mouse);
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
|
async_lock();
|
||||||
WacomTablet::I.reset_pressure();
|
WacomTablet::I.reset_pressure();
|
||||||
//TODO: find a way to check if event is mouse/stylus. For now use Mouse for all
|
//TODO: find a way to check if event is mouse/stylus. For now use Mouse for all
|
||||||
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
|
App::I.mouse_up(0, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
leftDown = false;
|
leftDown = false;
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
|
async_lock();
|
||||||
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, kEventSource::Mouse);
|
App::I.mouse_down(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), 1.f, kEventSource::Mouse);
|
||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
|
async_lock();
|
||||||
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
|
App::I.mouse_up(1, (float)GET_X_LPARAM(lp), (float)GET_Y_LPARAM(lp), kEventSource::Mouse);
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
|
async_unlock();
|
||||||
break;
|
break;
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
{
|
{
|
||||||
|
async_locker lock;
|
||||||
POINT pt;
|
POINT pt;
|
||||||
pt.x = GET_X_LPARAM(lp);
|
pt.x = GET_X_LPARAM(lp);
|
||||||
pt.y = GET_Y_LPARAM(lp);
|
pt.y = GET_Y_LPARAM(lp);
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "node_canvas.h"
|
#include "node_canvas.h"
|
||||||
|
|
||||||
#define RES 2048
|
|
||||||
|
|
||||||
Node* NodeCanvas::clone_instantiate() const
|
Node* NodeCanvas::clone_instantiate() const
|
||||||
{
|
{
|
||||||
return new NodeCanvas();
|
return new NodeCanvas();
|
||||||
@@ -13,7 +11,7 @@ void NodeCanvas::init()
|
|||||||
{
|
{
|
||||||
m_mouse_ignore = false;
|
m_mouse_ignore = false;
|
||||||
m_canvas = std::make_unique<ui::Canvas>();
|
m_canvas = std::make_unique<ui::Canvas>();
|
||||||
m_canvas->create(RES, RES);
|
m_canvas->create(CANVAS_RES, CANVAS_RES);
|
||||||
m_sampler.create(GL_NEAREST);
|
m_sampler.create(GL_NEAREST);
|
||||||
m_sampler_linear.create(GL_LINEAR);
|
m_sampler_linear.create(GL_LINEAR);
|
||||||
m_sampler_stencil.create(GL_LINEAR, GL_REPEAT);
|
m_sampler_stencil.create(GL_LINEAR, GL_REPEAT);
|
||||||
@@ -29,7 +27,7 @@ void NodeCanvas::init()
|
|||||||
void NodeCanvas::restore_context()
|
void NodeCanvas::restore_context()
|
||||||
{
|
{
|
||||||
Node::restore_context();
|
Node::restore_context();
|
||||||
m_canvas->create(RES, RES);
|
m_canvas->create(CANVAS_RES, CANVAS_RES);
|
||||||
m_sampler.create(GL_NEAREST);
|
m_sampler.create(GL_NEAREST);
|
||||||
m_face_plane.create<1>(2, 2);
|
m_face_plane.create<1>(2, 2);
|
||||||
m_canvas->snapshot_restore();
|
m_canvas->snapshot_restore();
|
||||||
|
|||||||
Reference in New Issue
Block a user