]> 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>
Mon, 17 Jun 2019 15:11:27 +0000 (18:11 +0300)
committervsv <vsv@opencascade.com>
Mon, 17 Jun 2019 15:11:27 +0000 (18:11 +0300)
src/ModuleBase/ModuleBase_IViewer.cpp
src/ModuleBase/ModuleBase_IViewer.h
src/ModuleBase/ModuleBase_Preferences.cpp
src/ModuleBase/ModuleBase_WidgetChoice.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/XGUI/SHAPER.xml
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index 57d5ad0f08bcfc4baaf44abe1b41e211983cc838..ef7b0b7c336084503a06e2b79df01da0006c340b 100644 (file)
@@ -21,7 +21,8 @@
 
 Handle(Prs3d_Drawer) ModuleBase_IViewer::DefaultHighlightDrawer;
 
-ModuleBase_IViewer::ModuleBase_IViewer(QObject* theParent) : QObject(theParent)
+ModuleBase_IViewer::ModuleBase_IViewer(QObject* theParent)
+  : QObject(theParent), myIs2dMode(false)
 {
 
 }
index 05104257db8f70825ffaa890251e30b1ab0d4a2a..f079bd4d93bf33ec1d50f7d58033ea69a0b67acc 100644 (file)
@@ -131,6 +131,17 @@ Q_OBJECT
   /// Show highlight for pre-highlighted sub-shape
   virtual void updateHighlight() {}
 
+  /// Set flag which indicates that viewer is used for 2d operations
+  /// \param is2d a new 2d mode state
+  void set2dMode(bool is2d) {
+    myIs2dMode = is2d;
+  }
+
+  /// Returns current state of 2d mode flag
+  bool is2dMode() const {
+    return myIs2dMode;
+  }
+
   static Handle(Prs3d_Drawer) DefaultHighlightDrawer;
 
 signals:
@@ -184,6 +195,7 @@ signals:
     /// A map for storing a scale factors dependent on view object
     QMap<Handle(V3d_View), double> myWindowScale;
 
+    bool myIs2dMode;
 };
 
 #endif
index a0706030229709d04790bebc96c7cc9274d4da9f..c616449e38ace63e69fde795373afd172ccfa179 100644 (file)
@@ -263,7 +263,7 @@ ModuleBase_PreferencesDlg::ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurc
   createEditors();
 
   myPreferences->retrieve();
-  setMinimumSize(800, 240);
+  setMinimumSize(800, 300);
 }
 
 ModuleBase_PreferencesDlg::~ModuleBase_PreferencesDlg()
@@ -333,6 +333,13 @@ void ModuleBase_PreferencesDlg::createViewerPage(int thePageId)
                          ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
   myPreferences->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
                          ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
+
+  int highlightGroup = myPreferences->addItem(tr("Additional highlighting"), viewTab);
+  myPreferences->setItemProperty("columns", 2, highlightGroup);
+  myPreferences->addItem(tr("In 3d mode"), highlightGroup,
+    SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d");
+  myPreferences->addItem(tr("In 2d mode"), highlightGroup,
+    SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d");
 }
 
 void ModuleBase_PreferencesDlg::createMenuPage(int thePageId)
index ce893667e3841abbb6daa6e28efb0d1d86c6487f..f06efdc19bf745534dff347ddb3e9823ae5c60e9 100644 (file)
@@ -31,7 +31,6 @@
 #include <QWidget>
 #include <QLayout>
 #include <QLabel>
-#include <QComboBox>
 #include <QButtonGroup>
 #include <QGroupBox>
 #include <QRadioButton>
index 7864827ba586cae5a2106056a414e970d400376d..cca6529d8668a2ea5e9c1d70973c83aa58343685 100644 (file)
@@ -1050,6 +1050,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
 
   myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
+
+  workshop()->viewer()->set2dMode(true);
 }
 
 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
@@ -1119,6 +1121,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
   }
   workshop()->selectionActivate()->updateSelectionFilters();
   workshop()->selectionActivate()->updateSelectionModes();
+  workshop()->viewer()->set2dMode(false);
 }
 
 void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
index 954153eedec246b850334db4c79a5d62a24ba24f..525736c3275472dc35b6e624668d13ae96de3f96 100644 (file)
@@ -12,6 +12,8 @@
     <parameter name="vertex-selection" value="true" />
     <parameter name="point-selection-sensitivity" value="12" />
     <parameter name="edge-selection-sensitivity" value="2" />
+    <parameter name="highlighting-3d" value="false" />
+    <parameter name="highlighting-2d" value="true" />
   </section>
   <section name="Menu" >
     <!-- Menu bar preferences -->
index e00490f8e16789f31d2ae213fe75a0857a207d2d..6a16390326fd0c6fcd3e8bcaaf05ee32936fab01 100644 (file)
@@ -684,7 +684,7 @@ bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
             aContext->HilightNextDetected(aView);
           else if ((theEvent->key() == Qt::Key_P))
             aContext->HilightPreviousDetected(aView);
-          aViewer->updateHighlight();
+          //aViewer->updateHighlight();
           isAccepted = true;
         }
       }
index 6105a6fb600a9df4cbfc6eb73aff2445314ab983..10abc57549e48e7e3b6bdaaeea2561ff8fde6ded 100644 (file)
 #endif
 
 #include <ModuleBase_IViewWindow.h>
+#include <ModuleBase_Preferences.h>
 #include <GeomAPI_Shape.h>
 #include <ModelAPI_ResultConstruction.h>
 
 #include <Config_PropManager.h>
 
+#include <SUIT_ResourceMgr.h>
 #include <AIS_Shape.hxx>
 #include <StdSelect_BRepOwner.hxx>
 
 #include <QEvent>
+#include <QKeyEvent>
 
 
 #define HIGHLIGHT_COLOR Quantity_NOC_YELLOW
 
 XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
     : ModuleBase_IViewer(theParent),
-      myWorkshop(theParent)
+      myWorkshop(theParent), myShowHighlight(false)
 {
 }
 
@@ -293,17 +296,36 @@ void XGUI_ViewerProxy::onMouseDoubleClick(AppElements_ViewWindow* theWnd, QMouse
 
 void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* 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(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
 {
+  myShowHighlight = theEvent->key() == Qt::Key_H;
   emit keyPress(theWnd, theEvent);
 }
 
 void XGUI_ViewerProxy::onKeyRelease(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
 {
+  if (theEvent->key() == Qt::Key_H) {
+    myShowHighlight = false;
+  }
   emit keyRelease(theWnd, theEvent);
 }
 
index 3e78f0c9a534318364cba1943cf829a4213cfe25..e250d0356557f0ec11ce85fed18c73219f85c53d 100644 (file)
@@ -164,6 +164,8 @@ private slots:
   XGUI_Workshop* myWorkshop;
   ResultPtr myResult;
   AIS_ListOfInteractive myHighlights;
+
+  bool myShowHighlight;
 };
 
 #endif