|
@@ -154,7 +154,7 @@ static void glfw_window_size(GLFWwindow* window, int width, int height)
|
|
int w = width*highdpi;
|
|
int w = width*highdpi;
|
|
int h = height*highdpi;
|
|
int h = height*highdpi;
|
|
|
|
|
|
- __viewer->resize(w, h);
|
|
|
|
|
|
+ __viewer->post_resize(w, h);
|
|
|
|
|
|
// TODO: repositioning of the nanogui
|
|
// TODO: repositioning of the nanogui
|
|
}
|
|
}
|
|
@@ -278,6 +278,8 @@ namespace viewer
|
|
|
|
|
|
IGL_INLINE Viewer::Viewer()
|
|
IGL_INLINE Viewer::Viewer()
|
|
{
|
|
{
|
|
|
|
+ window = nullptr;
|
|
|
|
+
|
|
#ifdef IGL_VIEWER_WITH_NANOGUI
|
|
#ifdef IGL_VIEWER_WITH_NANOGUI
|
|
ngui = nullptr;
|
|
ngui = nullptr;
|
|
screen = nullptr;
|
|
screen = nullptr;
|
|
@@ -322,8 +324,8 @@ namespace viewer
|
|
O,o Toggle orthographic/perspective projection
|
|
O,o Toggle orthographic/perspective projection
|
|
T,t Toggle filled faces
|
|
T,t Toggle filled faces
|
|
Z Snap to canonical view
|
|
Z Snap to canonical view
|
|
- [,] Toggle between rotation control types (e.g. trackball, two-axis
|
|
|
|
- valuator with fixed up))"
|
|
|
|
|
|
+ [,] Toggle between rotation control types (trackball, two-axis
|
|
|
|
+ valuator with fixed up, 2D mode with no rotation))"
|
|
#ifdef IGL_VIEWER_WITH_NANOGUI
|
|
#ifdef IGL_VIEWER_WITH_NANOGUI
|
|
R"(
|
|
R"(
|
|
; Toggle vertex labels
|
|
; Toggle vertex labels
|
|
@@ -537,13 +539,12 @@ namespace viewer
|
|
case ']':
|
|
case ']':
|
|
{
|
|
{
|
|
if(core.rotation_type == ViewerCore::ROTATION_TYPE_TRACKBALL)
|
|
if(core.rotation_type == ViewerCore::ROTATION_TYPE_TRACKBALL)
|
|
- {
|
|
|
|
- core.set_rotation_type(
|
|
|
|
- ViewerCore::ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP);
|
|
|
|
- }else
|
|
|
|
- {
|
|
|
|
|
|
+ core.set_rotation_type(ViewerCore::ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP);
|
|
|
|
+ else if (core.rotation_type == ViewerCore::ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
|
|
|
|
+ core.set_rotation_type(ViewerCore::ROTATION_TYPE_NO_ROTATION);
|
|
|
|
+ else
|
|
core.set_rotation_type(ViewerCore::ROTATION_TYPE_TRACKBALL);
|
|
core.set_rotation_type(ViewerCore::ROTATION_TYPE_TRACKBALL);
|
|
- }
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
#ifdef IGL_VIEWER_WITH_NANOGUI
|
|
#ifdef IGL_VIEWER_WITH_NANOGUI
|
|
@@ -626,7 +627,11 @@ namespace viewer
|
|
switch (button)
|
|
switch (button)
|
|
{
|
|
{
|
|
case MouseButton::Left:
|
|
case MouseButton::Left:
|
|
- mouse_mode = MouseMode::Rotation;
|
|
|
|
|
|
+ if (core.rotation_type == ViewerCore::ROTATION_TYPE_NO_ROTATION) {
|
|
|
|
+ mouse_mode = MouseMode::Translation;
|
|
|
|
+ } else {
|
|
|
|
+ mouse_mode = MouseMode::Rotation;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
|
|
|
|
case MouseButton::Right:
|
|
case MouseButton::Right:
|
|
@@ -687,6 +692,8 @@ namespace viewer
|
|
{
|
|
{
|
|
default:
|
|
default:
|
|
assert(false && "Unknown rotation type");
|
|
assert(false && "Unknown rotation type");
|
|
|
|
+ case ViewerCore::ROTATION_TYPE_NO_ROTATION:
|
|
|
|
+ break;
|
|
case ViewerCore::ROTATION_TYPE_TRACKBALL:
|
|
case ViewerCore::ROTATION_TYPE_TRACKBALL:
|
|
igl::trackball(
|
|
igl::trackball(
|
|
core.viewport(2),
|
|
core.viewport(2),
|
|
@@ -841,8 +848,21 @@ namespace viewer
|
|
}
|
|
}
|
|
|
|
|
|
IGL_INLINE void Viewer::resize(int w,int h)
|
|
IGL_INLINE void Viewer::resize(int w,int h)
|
|
|
|
+ {
|
|
|
|
+ if (window) {
|
|
|
|
+ glfwSetWindowSize(window, w/highdpi, h/highdpi);
|
|
|
|
+ } else {
|
|
|
|
+ post_resize(w, h);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ IGL_INLINE void Viewer::post_resize(int w,int h)
|
|
{
|
|
{
|
|
core.viewport = Eigen::Vector4f(0,0,w,h);
|
|
core.viewport = Eigen::Vector4f(0,0,w,h);
|
|
|
|
+ for (unsigned int i = 0; i<plugins.size(); ++i)
|
|
|
|
+ {
|
|
|
|
+ plugins[i]->post_resize(w, h);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
IGL_INLINE void Viewer::snap_to_canonical_quaternion()
|
|
IGL_INLINE void Viewer::snap_to_canonical_quaternion()
|
|
@@ -895,7 +915,11 @@ namespace viewer
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- window = glfwCreateWindow(1280,800,"libigl viewer",nullptr,nullptr);
|
|
|
|
|
|
+ if (core.viewport.tail<2>().any()) {
|
|
|
|
+ window = glfwCreateWindow(core.viewport(2),core.viewport(3),"libigl viewer",nullptr,nullptr);
|
|
|
|
+ } else {
|
|
|
|
+ window = glfwCreateWindow(1280,800,"libigl viewer",nullptr,nullptr);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (!window)
|
|
if (!window)
|