Browse Source

visible toggle for plugin

Alec Jacobson 5 years ago
parent
commit
6cde8347be

+ 2 - 0
include/igl/opengl/glfw/imgui/ImGuizmoPlugin.cpp

@@ -13,6 +13,7 @@ IGL_INLINE void ImGuizmoPlugin::init(igl::opengl::glfw::Viewer *_viewer)
 }
 }
 IGL_INLINE bool ImGuizmoPlugin::pre_draw() 
 IGL_INLINE bool ImGuizmoPlugin::pre_draw() 
 {
 {
+  if(!visible){ return false; }
   ImGuiMenu::pre_draw();
   ImGuiMenu::pre_draw();
   ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
   ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
   ImGuizmo::BeginFrame();
   ImGuizmo::BeginFrame();
@@ -21,6 +22,7 @@ IGL_INLINE bool ImGuizmoPlugin::pre_draw()
 }
 }
 IGL_INLINE bool ImGuizmoPlugin::post_draw() 
 IGL_INLINE bool ImGuizmoPlugin::post_draw() 
 {
 {
+  if(!visible){ return false; }
   // Don't draw the Viewer's default menu: draw just the ImGuizmo
   // Don't draw the Viewer's default menu: draw just the ImGuizmo
   Eigen::Matrix4f view = (viewer->core().view / viewer->core().camera_zoom);
   Eigen::Matrix4f view = (viewer->core().view / viewer->core().camera_zoom);
   Eigen::Matrix4f proj = viewer->core().proj;
   Eigen::Matrix4f proj = viewer->core().proj;

+ 2 - 0
include/igl/opengl/glfw/imgui/ImGuizmoPlugin.h

@@ -14,6 +14,8 @@ class ImGuizmoPlugin : public igl::opengl::glfw::imgui::ImGuiMenu
 public:
 public:
   // callback(T) called when the stored transform T changes
   // callback(T) called when the stored transform T changes
   std::function<void(const Eigen::Matrix4f &)> callback;
   std::function<void(const Eigen::Matrix4f &)> callback;
+  // Whether to display
+  bool visible = true;
   // whether rotating, translating or scaling
   // whether rotating, translating or scaling
   ImGuizmo::OPERATION operation;
   ImGuizmo::OPERATION operation;
   // stored transformation
   // stored transformation

+ 1 - 0
tutorial/109_ImGuizmo/main.cpp

@@ -38,6 +38,7 @@ int main(int argc, char *argv[])
   {
   {
     switch(key)
     switch(key)
     {
     {
+      case ' ': plugin.visible = !plugin.visible; return true;
       case 'W': case 'w': plugin.operation = ImGuizmo::TRANSLATE; return true;
       case 'W': case 'w': plugin.operation = ImGuizmo::TRANSLATE; return true;
       case 'E': case 'e': plugin.operation = ImGuizmo::ROTATE;    return true;
       case 'E': case 'e': plugin.operation = ImGuizmo::ROTATE;    return true;
       case 'R': case 'r': plugin.operation = ImGuizmo::SCALE;     return true;
       case 'R': case 'r': plugin.operation = ImGuizmo::SCALE;     return true;