From: vsv Date: Mon, 25 May 2020 16:30:00 +0000 (+0300) Subject: Issue #3233:Resize thrihedron arrows on zooming to avoid "big arrows". X-Git-Tag: V9_6_0a1~60^2~67 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fb3f5a45802f9374a9dcd0f4c7b656dca4118545;p=modules%2Fshaper.git Issue #3233:Resize thrihedron arrows on zooming to avoid "big arrows". --- diff --git a/doc/gui/Introduction.rst b/doc/gui/Introduction.rst index c1f42514c..1d435f881 100644 --- a/doc/gui/Introduction.rst +++ b/doc/gui/Introduction.rst @@ -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; - **Sketch overconstraint color** selects default color for a sketch with redundant constraints; - **Sketch fully constraint color** selects default color for a sketch with zero degrees of freedom. +- **Zoom trihedron arrows** if this control is checked then arrows of a view trihedron will be scaled according to current view scale +- **Axis arrow size** relative size of trihedron arrows. It has effect only in case if **Zoom trihedron arrows** is On. To redefine any color click on the corresponding line to access **Select color** dialog box diff --git a/doc/gui/images/visualization_preferences.png b/doc/gui/images/visualization_preferences.png index 6a1b50983..5328894f6 100755 Binary files a/doc/gui/images/visualization_preferences.png and b/doc/gui/images/visualization_preferences.png differ diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 963070788..0aa1f39eb 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -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() {} diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 8dfec292f..7ac26dd9c 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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(); } //****************************************************** diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index bd9150861..7567f40a2 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -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 diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 941258cf1..32633baa1 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -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(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 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; diff --git a/src/SHAPERGUI/SHAPERGUI.h b/src/SHAPERGUI/SHAPERGUI.h index 61cbc0339..bf2941d21 100644 --- a/src/SHAPERGUI/SHAPERGUI.h +++ b/src/SHAPERGUI/SHAPERGUI.h @@ -284,6 +284,8 @@ private slots: std::vector myOldSelectionColor; Handle(Graphic3d_AspectMarker3d) myHighlightPointAspect; + + double myAxisArrowRate; }; #endif diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp index 12776d98c..f9416eb07 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp @@ -32,6 +32,7 @@ #include #include +#include #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) { diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h index 97df56cdc..68bd1b729 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.h @@ -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;