From: vsv Date: Mon, 15 Jun 2015 13:00:40 +0000 (+0300) Subject: Set selection area of dimensions adaptive to viewer scale X-Git-Tag: V_1.3.0~237 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=085e7c5854db0bd084e0b65b79997028372736df;p=modules%2Fshaper.git Set selection area of dimensions adaptive to viewer scale --- diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index feed61ee2..b08d49e72 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -5,6 +5,7 @@ #include "ModuleBase.h" #include +#include #include #include @@ -75,6 +76,15 @@ Q_OBJECT /// Update current viewer virtual void update() = 0; + const double Scale(const Handle(V3d_View)& theView) + { + if (!myWindowScale.contains(theView)) + myWindowScale.insert(theView, theView->Camera()->Scale()); + return myWindowScale[theView]; + } + + void SetScale(const Handle(V3d_View)& theView, const double theVal) { myWindowScale[theView] = theVal; } + /// Method returns True if the viewer can process editing objects /// by mouse drugging. If this is impossible thet it has to return False. virtual bool canDragByMouse() const { return true; } @@ -122,6 +132,9 @@ signals: /// Signal emitted on transformation of view point in view window /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType) void viewTransformed(int theTransformation); + + protected: + QMap myWindowScale; }; #endif diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 8bc67c748..4539bbdbc 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -223,6 +223,8 @@ void NewGeom_SalomeViewer::onTryCloseView(SUIT_ViewWindow*) //********************************************** void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*) { + if(myWindowScale.contains(myView->v3dView())) + myWindowScale.remove(myView->v3dView()); emit deleteView(myView); } @@ -238,6 +240,8 @@ void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView) connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); + myWindowScale.insert (aView->getViewPort()->getView(), aView->getViewPort()->getView()->Camera()->Scale()); + emit viewCreated(myView); } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index a1908ff43..6939718d0 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -682,7 +682,12 @@ void PartSet_Module::onViewTransformed(int theTrsfType) return; double aLen = aView->Convert(20); + double aPrevLen = SketcherPrs_Tools::getArrowSize(); SketcherPrs_Tools::setArrowSize(aLen); + const double aPrevScale = aViewer->Scale(aViewer->activeView()); + const double aCurScale = aViewer->activeView()->Camera()->Scale(); + aViewer->SetScale(aViewer->activeView(), aCurScale); + SketcherPrs_Tools::setTextHeight (aCurScale / aPrevScale * SketcherPrs_Tools::getTextHeight()); bool isModified = false; QList aPrsList = aDisplayer->displayedPresentations(); foreach (AISObjectPtr aAIS, aPrsList) { diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index 9a4509794..39d5cfcd7 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -40,10 +40,10 @@ myConstraint(theConstraint), myPlane(thePlane) myAspect->MakeText3d(false); myAspect->MakeTextShaded(false); myAspect->MakeUnitsDisplayed(false); - myAspect->TextAspect()->SetHeight(MyTextHeight); + myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight()); myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); - SetSelToleranceForText2d(MyTextHeight); + SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight()); SetDimensionAspect(myAspect); } @@ -178,5 +178,6 @@ void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Select return; } } + SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight()); AIS_LengthDimension::ComputeSelection(aSelection, aMode); } diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index 11eec0734..c08d7ab94 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -32,11 +32,11 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint, myAspect->MakeText3d(false); myAspect->MakeTextShaded(false); myAspect->MakeUnitsDisplayed(false); - myAspect->TextAspect()->SetHeight(MyTextHeight); + myAspect->TextAspect()->SetHeight(SketcherPrs_Tools::getDefaultTextHeight()); myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); SetDimensionAspect(myAspect); - SetSelToleranceForText2d(MyTextHeight); + SetSelToleranceForText2d(SketcherPrs_Tools::getDefaultTextHeight()); } diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index 798b17007..33a363a1b 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -368,6 +368,9 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& } aGroup->UserDraw(this, true); + + // Disable frustum culling for this object by marking it as mutable + aGroup->Structure()->SetMutable(true); //aGroup->AddPrimitiveArray(myPntArray); } diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index f8891b225..f2fbe2894 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -136,6 +136,22 @@ void setArrowSize(double theSize) MyArrowSize = theSize; } +static double MyTextHeight = 20; +double getTextHeight() +{ + return MyTextHeight; +} + +void setTextHeight(double theHeight) +{ + MyTextHeight = theHeight; +} + +double getDefaultTextHeight() +{ + return 30; +} + double getFlyoutDistance(const ModelAPI_Feature* theConstraint) { std::shared_ptr aFlyoutPoint = diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index b2ed89c5b..ac014267e 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -17,7 +17,7 @@ class GeomDataAPI_Point2D; -#define MyTextHeight 20 +//#define MyTextHeight 20 namespace SketcherPrs_Tools { @@ -62,6 +62,12 @@ enum SelectionModes { SKETCHERPRS_EXPORT void setArrowSize(double theSize); + SKETCHERPRS_EXPORT void setTextHeight(double theHeight); + + SKETCHERPRS_EXPORT double getTextHeight(); + + SKETCHERPRS_EXPORT double getDefaultTextHeight(); + SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint); SKETCHERPRS_EXPORT std::shared_ptr getAnchorPoint( diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index cf300615a..2011cf6b7 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -169,6 +169,8 @@ void XGUI_ViewerProxy::onTryCloseView(AppElements_ViewWindow* theWnd) void XGUI_ViewerProxy::onDeleteView(AppElements_ViewWindow* theWnd) { + if (myWindowScale.contains(theWnd->v3dView())) + myWindowScale.remove (theWnd->v3dView()); emit deleteView(theWnd); } @@ -176,6 +178,8 @@ void XGUI_ViewerProxy::onViewCreated(ModuleBase_IViewWindow* theWnd) { theWnd->viewPort()->installEventFilter(this); + myWindowScale.insert (theWnd->v3dView(), theWnd->v3dView()->Camera()->Scale()); + emit viewCreated(theWnd); } @@ -186,6 +190,8 @@ void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd) connect(theWnd, SIGNAL(vpTransformationFinished(AppElements_ViewWindow::OperationType)), this, SLOT(onViewTransformed(AppElements_ViewWindow::OperationType))); + myWindowScale.insert (theWnd->v3dView(), theWnd->v3dView()->Camera()->Scale()); + emit viewCreated(theWnd); }