]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3233:Resize thrihedron arrows on zooming to avoid "big arrows".
authorvsv <vsv@opencascade.com>
Mon, 25 May 2020 16:30:00 +0000 (19:30 +0300)
committervsv <vsv@opencascade.com>
Mon, 25 May 2020 16:30:00 +0000 (19:30 +0300)
doc/gui/Introduction.rst
doc/gui/images/visualization_preferences.png
src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h
src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp
src/SHAPERGUI/SHAPERGUI_SalomeViewer.h

index c1f42514cd912d2b3b3c4d6abdf56619f722e536..1d435f881d9df93548d9d0393b2b8f5044b1d0c4 100644 (file)
@@ -540,6 +540,8 @@ This tab defines presentation of objects displayed in OCC 3D viewer.
 - **Sketch auxiliary entity color** selects default color for sketch auxiliary objects;\r
 - **Sketch overconstraint color** selects default color for a sketch with redundant constraints;\r
 - **Sketch fully constraint color** selects default color for a sketch with zero degrees of freedom.\r
+- **Zoom trihedron arrows** if this control is checked then arrows of a view trihedron will be scaled according to current view scale\r
+- **Axis arrow size** relative size of trihedron arrows. It has effect only in case if **Zoom trihedron arrows** is On.\r
   \r
 To redefine any color click on the corresponding line to access **Select color** dialog box\r
 \r
index 6a1b50983008c62b27def8079e615cf49c2e9738..5328894f6e9e909dc6b628db7c13f705cff0efbd 100755 (executable)
Binary files a/doc/gui/images/visualization_preferences.png and b/doc/gui/images/visualization_preferences.png differ
index 963070788e390a26d96e8c9f394b29aa97597dc2..0aa1f39eb7a38eab7ef27a99784da119d4476d6b 100644 (file)
@@ -421,6 +421,10 @@ public slots:
   /// \param theAIS a presentation object
   virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) {}
 
+  /// Called on transformation in current viewer
+  /// \param theTrsfType type of tranformation
+  virtual void onViewTransformed(int theTrsfType = 2) {}
+
 protected slots:
   /// Called on selection changed event
   virtual void onSelectionChanged() {}
index 8dfec292f04d56fb463bed339aef3065c7424737..7ac26dd9c76e9b5d6e9a808614b7482216724235 100644 (file)
@@ -236,6 +236,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
                                    "Hidden faces transparency",
                                    Config_Prop::DblSpin,
                                    "0.8");
+
   std::ostringstream aStream;
   aStream << SketcherPrs_Tools::getDefaultArrowSize();
   Config_PropManager::registerProp("Visualization", "dimension_arrow_size",
@@ -258,6 +259,12 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
     "Feature items in Object Browser",
     Config_Prop::Color, FEATURE_ITEM_COLOR);
 
+  Config_PropManager::registerProp("Visualization", "zoom_trihedron_arrows",
+    "Zoom trihedron arrows", Config_Prop::Boolean, "false");
+
+  Config_PropManager::registerProp("Visualization", "axis_arrow_size",
+    "Axis arrow size", Config_Prop::IntSpin, "10");
+
   Config_PropManager::registerProp("Shortcuts", "add_parameter_shortcut",
     "Add parameter in parameters manager dialog",
     Config_Prop::Shortcut, "Ctrl+A");
@@ -1156,13 +1163,13 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
     return;
 
   bool isModified = false;
+  double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
   ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
   if (aCurrentOperation &&
     (PartSet_SketcherMgr::isSketchOperation(aCurrentOperation) ||
      sketchMgr()->isNestedSketchOperation(aCurrentOperation) ||
      (aCurrentOperation->id() == "Measurement")))
   {
-    double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
 
     double aPrevLen = SketcherPrs_Tools::getArrowSize();
     SketcherPrs_Tools::setArrowSize(aLen);
@@ -1183,10 +1190,24 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
         isModified = true;
       }
     }
-    if (isModified)
-      aDisplayer->updateViewer();
   }
 
+  // Manage trihedron arrows
+  if (Config_PropManager::boolean("Visualization", "zoom_trihedron_arrows")) {
+    Handle(AIS_Trihedron) aTrihedron = aViewer->trihedron();
+    if (!aTrihedron.IsNull()) {
+      double aAxLen =
+        aView->Convert(Config_PropManager::integer("Visualization", "axis_arrow_size"));
+      Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+      double aAxisLen = aDatumAspect->AxisLength(Prs3d_DP_XAxis);
+      aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, aAxLen / aAxisLen);
+      aTrihedron->Attributes()->SetDatumAspect(aDatumAspect);
+      aContext->Redisplay(aTrihedron, false);
+      isModified = true;
+    }
+  }
+  if (isModified)
+    aDisplayer->updateViewer();
 }
 
 //******************************************************
index bd91508616f0262bbe80aa3802e9b88f28b29ecf..7567f40a2912468cf2f5af1b023a5b2e8a539d87 100644 (file)
@@ -412,7 +412,7 @@ public slots:
 
   /// Called on transformation in current viewer
   /// \param theTrsfType type of tranformation
-  void onViewTransformed(int theTrsfType = 2);
+  virtual void onViewTransformed(int theTrsfType = 2);
 
 protected slots:
   /// Called when previous operation is finished
index 941258cf1d123224eaeb7e4c82cd786eb25c74c8..32633baa1e518d1facf3063adeb9fbf3d590c644 100644 (file)
@@ -136,7 +136,8 @@ private:
 SHAPERGUI::SHAPERGUI()
     : LightApp_Module("SHAPER"),
       mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
-  myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false)
+  myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false),
+  myAxisArrowRate(-1)
 {
   myWorkshop = new XGUI_Workshop(this);
   connect(myWorkshop, SIGNAL(commandStatusUpdated()),
@@ -328,11 +329,6 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
     XGUI_Displayer* aDisp = myWorkshop->displayer();
     QObjectPtrList aObjList = aDisp->displayedObjects();
 
-    //if (myHighlightPointAspect.IsNull()) {
-    //  Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
-    //  myHighlightPointAspect =
-    //    new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*());
-    //}
     if (myOldSelectionColor.size() == 0)
       myOldSelectionColor = aDisp->selectionColor();
 
@@ -419,11 +415,14 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
   }
   // Delete selector because it has to be redefined on next activation
   if (mySelector) {
-    //if (!myHighlightPointAspect.IsNull()) {
-    //  Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
-    //  aTrihedron->getHighlightPointAspect()->SetAspect(myHighlightPointAspect);
-    //  myHighlightPointAspect.Nullify();
-    //}
+    // Restore size of arrows of trihedron
+    if (myAxisArrowRate > 0) {
+      Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
+      Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+      aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, myAxisArrowRate);
+      Handle(AIS_InteractiveContext) aContext = mySelector->viewer()->getAISContext();
+      aContext->Redisplay(aTrihedron, false);
+    }
     myWorkshop->displayer()->setSelectionColor(myOldSelectionColor);
     myProxyViewer->setSelector(0);
 
@@ -571,11 +570,11 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
   if (theMgr->getType() == OCCViewer_Viewer::Type()) {
     OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
 
-    //if (myHighlightPointAspect.IsNull()) {
-    //  Handle(AIS_Trihedron) aTrihedron = aViewer->getTrihedron();
-    //  myHighlightPointAspect =
-    //    new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*());
-    //}
+    // Remember current length of arrow of axis
+    Handle(AIS_Trihedron) aTrihedron = aViewer->getTrihedron();
+    Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+    myAxisArrowRate = aDatumAspect->Attribute(Prs3d_DP_ShadingConeLengthPercent);
+
     SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
                                                                  getApp()->selectionMgr());
 #ifdef SALOME_PATCH_FOR_CTRL_WHEEL
@@ -595,6 +594,10 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
 
     std::vector<int> aColor = Config_PropManager::color("Visualization", "selection_color");
     myWorkshop->displayer()->setSelectionColor(aColor);
+
+    // Cause scaling of arrows of axis and dimensions
+    myWorkshop->module()->onViewTransformed();
+
     return aSelector;
   }
   return 0;
index 61cbc0339d99805f0f5af909c4eda7e506769dcc..bf2941d21ed6a241d6feb52e143bf3db2cc24345 100644 (file)
@@ -284,6 +284,8 @@ private slots:
 
   std::vector<int> myOldSelectionColor;
   Handle(Graphic3d_AspectMarker3d) myHighlightPointAspect;
+
+  double myAxisArrowRate;
 };
 
 #endif
index 12776d98c79d7330680358749e708f6daa7be148..f9416eb079e3d11e3a7f8c06447f1e30cc021f59 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <QMouseEvent>
 #include <QContextMenuEvent>
+#include <QTimer>
 
 #if OCC_VERSION_HEX < 0x070400
   #define SALOME_PATCH_FOR_CTRL_WHEEL
@@ -279,11 +280,19 @@ void SHAPERGUI_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
   myWindowScale.insert(aView->getViewPort()->getView(),
                        aView->getViewPort()->getView()->Camera()->Scale());
 
-  emit viewCreated(myView);
+  QTimer::singleShot(10, this, SLOT(onAfterViewCreated()));
 
+  emit viewCreated(myView);
+}
 
+//**********************************************
+void SHAPERGUI_SalomeViewer::onAfterViewCreated()
+{
+  // Update trihedron and dimension arrows
+  emit onViewTransformed(OCCViewer_ViewWindow::ZOOMVIEW);
 }
 
+
 //**********************************************
 void SHAPERGUI_SalomeViewer::onActivated(SUIT_ViewManager* theMgr)
 {
index 97df56cdc392016221cfcc1c3599cab622aab4d5..68bd1b72914311c97fa6af8b81e0d4ed583dfc2d 100644 (file)
@@ -235,6 +235,9 @@ Q_OBJECT
   /// It is necessary to activate the viewer trihedron in the current selection mode
   void onViewPortMapped();
 
+  /// Signal called in order to apdate viewer transformed objects
+  void onAfterViewCreated();
+
  private:
   SHAPERGUI_OCCSelector* mySelector;
   SHAPERGUI_SalomeView* myView;