]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2929: Make possible enable/disable additional highlighting on mouse moving
authorvsv <vsv@opencascade.com>
Tue, 18 Jun 2019 13:10:57 +0000 (16:10 +0300)
committervsv <vsv@opencascade.com>
Tue, 18 Jun 2019 13:10:57 +0000 (16:10 +0300)
src/SHAPERGUI/SHAPERGUI.cpp
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index 8a961e01a95ee3e3eaa086615401cda99bbbf5c5..209e9542f23d5e9a00d374560b44a3c8222bd335 100644 (file)
@@ -780,6 +780,14 @@ void SHAPERGUI::createPreferences()
                 ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
   pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
                 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
+
+  int highlightGroup = pref->addItem(tr("Additional highlighting"), viewTab);
+  pref->setItemProperty("columns", 2, highlightGroup);
+  pref->addItem(tr("In 3d mode"), highlightGroup,
+    SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d");
+  pref->addItem(tr("In 2d mode"), highlightGroup,
+    SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d");
+
   pref->retrieve();
 }
 
index 10abc57549e48e7e3b6bdaaeea2561ff8fde6ded..6a33fefb14548d7c92370101b149e305c662a50d 100644 (file)
@@ -178,10 +178,10 @@ void XGUI_ViewerProxy::connectToViewer()
     this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
 
   connect(aViewer, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)),
-    this, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)));
+    this, SLOT(onKeyPress(ModuleBase_IViewWindow*, QKeyEvent*)));
 
   connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
-    this, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
+    this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
 
   connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
 
@@ -525,9 +525,38 @@ void XGUI_ViewerProxy::updateHighlight()
 #ifdef HAVE_SALOME
 void XGUI_ViewerProxy::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
-  updateHighlight();
+  if (myIs2dMode) {
+    bool aHighlight2d =
+      ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "highlighting-2d", true);
+    if (aHighlight2d || myShowHighlight)
+      updateHighlight();
+    else
+      eraseHighlight();
+  }
+  else {
+    bool aHighlight3d =
+      ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "highlighting-3d", false);
+    if (aHighlight3d || myShowHighlight)
+      updateHighlight();
+    else
+      eraseHighlight();
+  }
   emit mouseMove(theWnd, theEvent);
 }
+
+void XGUI_ViewerProxy::onKeyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
+{
+  myShowHighlight = theEvent->key() == Qt::Key_H;
+  emit keyPress(theWnd, theEvent);
+}
+
+void XGUI_ViewerProxy::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
+{
+  if (theEvent->key() == Qt::Key_H) {
+    myShowHighlight = false;
+  }
+  emit keyRelease(theWnd, theEvent);
+}
 #endif
 
 //***************************************
index e250d0356557f0ec11ce85fed18c73219f85c53d..cf73432d85f13954f662c43405b331fc60242891 100644 (file)
@@ -155,6 +155,8 @@ private slots:
   void onViewTransformed(AppElements_ViewWindow::OperationType);
 #else
   void onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*);
+  void onKeyPress(ModuleBase_IViewWindow*, QKeyEvent*);
+  void onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*);
 #endif
 
  private: