From: vsv Date: Mon, 30 Mar 2015 14:01:04 +0000 (+0300) Subject: Set dimensions arrows independent on zoom X-Git-Tag: V_1.1.0~72 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=60d5826edcbccd9792f24f3f8b84561ca6fe5a34;p=modules%2Fshaper.git Set dimensions arrows independent on zoom --- diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index 3cf3bc5ab..feed61ee2 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -118,6 +118,10 @@ signals: /// Signal emited on selection changed void contextMenuRequested(QContextMenuEvent*); + + /// Signal emitted on transformation of view point in view window + /// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType) + void viewTransformed(int theTransformation); }; #endif diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 486a87511..d10a13c9f 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -48,6 +48,7 @@ SET(PROJECT_LIBRARIES GeomAPI GeomValidators GeomDataAPI + SketcherPrs ${QT_LIBRARIES} ${CAS_KERNEL} ${CAS_SHAPE} @@ -78,6 +79,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI ${CMAKE_SOURCE_DIR}/src/GeomDataAPI ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI ${CMAKE_SOURCE_DIR}/src/SketchPlugin + ${CMAKE_SOURCE_DIR}/src/SketcherPrs ${CMAKE_SOURCE_DIR}/src/FeaturesPlugin ${CMAKE_SOURCE_DIR}/src/GeomAPI ${CMAKE_SOURCE_DIR}/src/GeomValidators diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 20cd41101..00b6e321f 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -57,7 +57,9 @@ #include #include #include -//#include + +#include +#include #include #include @@ -94,7 +96,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) : ModuleBase_IModule(theWshop), myRestartingMode(RM_None), myVisualLayerId(0) { - //myWorkshop = dynamic_cast(theWshop); mySketchMgr = new PartSet_SketcherMgr(this); XGUI_ModuleConnector* aConnector = dynamic_cast(theWshop); @@ -108,6 +109,8 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) ModuleBase_IViewer* aViewer = theWshop->viewer(); connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)), this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*))); + connect(aViewer, SIGNAL(viewTransformed(int)), + SLOT(onViewTransformed(int))); createActions(); } @@ -666,11 +669,48 @@ void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) { Handle(AIS_InteractiveObject) anAIS = theAIS->impl(); if (!anAIS.IsNull()) { + Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext(); Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS); if (!aDim.IsNull()) { - Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext(); aCtx->SetZLayer(aDim, myVisualLayerId); + } else { + Handle(SketcherPrs_SymbolPrs) aCons = Handle(SketcherPrs_SymbolPrs)::DownCast(anAIS); + if (!aCons.IsNull()) + aCtx->SetZLayer(aCons, myVisualLayerId); } } } +void PartSet_Module::onViewTransformed(int theTrsfType) +{ + // Set length of arrows constant in pixel size + // if the operation is panning or rotate or panglobal then do nothing + if ((theTrsfType == 1) || (theTrsfType == 3) || (theTrsfType == 4)) + return; + + ModuleBase_IViewer* aViewer = myWorkshop->viewer(); + Handle(V3d_View) aView = aViewer->activeView(); + + XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Displayer* aDisplayer = aWorkshop->displayer(); + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + + double aLen = aView->Convert(25); + + SketcherPrs_Tools::setArrowSize(aLen); + bool isModified = false; + QList aPrsList = aDisplayer->displayedPresentations(); + foreach (AISObjectPtr aAIS, aPrsList) { + Handle(AIS_InteractiveObject) aAisObj = aAIS->impl(); + + Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj); + if (!aDim.IsNull()) { + aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen); + aContext->Redisplay(aDim, false); + isModified = true; + } + } + if (isModified) + aDisplayer->updateViewer(); +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 6bacf2d77..891759c36 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -100,6 +100,7 @@ public: /// if it is a sketch operation /// \param theObject a model object virtual bool canDisplayObject(const ObjectPtr& theObject) const; + /// Add menu atems for viewer into the given menu /// \param theMenu a popup menu to be shown in the viewer virtual void addViewerItems(QMenu* theMenu) const; @@ -149,6 +150,10 @@ protected slots: /// Processing of vertex selected void onVertexSelected(); + /// Called on transformation in current viewer + /// \param theTrsfType type of tranformation + void onViewTransformed(int theTrsfType = 2); + private: /// Breaks sequense of automatically resterted operations void breakOperationSequence(); diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index 0f5d2b8f0..f3220e6b6 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -23,16 +23,11 @@ #include -const int CONSTRAINT_TEXT_HEIGHT = 20; /// the text height of the constraint -const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance - - static const gp_Pnt MyDefStart(0,0,0); static const gp_Pnt MyDefEnd(1,0,0); static const gp_Pln MyDefPln(gp_Pnt(0,0,0), gp_Dir(0,0,1)); - - +static const double MyTextHeight = 20; IMPLEMENT_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension); @@ -47,9 +42,11 @@ myConstraint(theConstraint), myPlane(thePlane) myAspect->MakeText3d(false); myAspect->MakeTextShaded(false); myAspect->MakeUnitsDisplayed(false); + myAspect->TextAspect()->SetHeight(MyTextHeight); + myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); + SetSelToleranceForText2d(MyTextHeight); SetDimensionAspect(myAspect); - SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE); } @@ -90,9 +87,6 @@ void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManage aFlyout = aDist; SetFlyout(aFlyout); - myAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT); - myAspect->ArrowAspect()->SetLength(CONSTRAINT_TEXT_HEIGHT * 2); - SetMeasuredGeometry(aPnt1, aPnt2, myPlane->impl()); AIS_LengthDimension::Compute(thePresentationManager, thePresentation, theMode); } diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index bdefd5187..bb517cc80 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -5,6 +5,7 @@ // Author: Vitaly SMETANNIKOV #include "SketcherPrs_Radius.h" +#include "SketcherPrs_Tools.h" #include #include @@ -17,10 +18,8 @@ #include #include -const int CONSTRAINT_TEXT_HEIGHT = 20; /// the text height of the constraint -const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance - -static gp_Circ MyDefCirc(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), 1); +static const gp_Circ MyDefCirc(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), 1); +static const double MyTextHeight = 20; IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension); IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Radius, AIS_RadiusDimension); @@ -34,9 +33,11 @@ SketcherPrs_Radius::SketcherPrs_Radius(SketchPlugin_Constraint* theConstraint, myAspect->MakeText3d(false); myAspect->MakeTextShaded(false); myAspect->MakeUnitsDisplayed(false); + myAspect->TextAspect()->SetHeight(MyTextHeight); + myAspect->ArrowAspect()->SetLength(SketcherPrs_Tools::getArrowSize()); SetDimensionAspect(myAspect); - SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE); + SetSelToleranceForText2d(MyTextHeight); } @@ -97,7 +98,5 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the SetMeasuredGeometry(aCircle.impl(), anAnchor->impl()); SetCustomValue(aRadius); - myAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT); - myAspect->ArrowAspect()->SetLength(CONSTRAINT_TEXT_HEIGHT * 2.); AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode); } diff --git a/src/SketcherPrs/SketcherPrs_SensitivePoint.h b/src/SketcherPrs/SketcherPrs_SensitivePoint.h index bc3628b8a..9daf62d47 100644 --- a/src/SketcherPrs/SketcherPrs_SensitivePoint.h +++ b/src/SketcherPrs/SketcherPrs_SensitivePoint.h @@ -15,6 +15,11 @@ DEFINE_STANDARD_HANDLE(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity) +/** +* \ingroup GUI +* This sensitive point is done in order to optimize process of the sinzitive area update +* It referes on point array directly and this lets to avoid procedure of the point synchronisation +*/ class SketcherPrs_SensitivePoint : public Select3D_SensitiveEntity { public: diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index 7fb7bf949..e2973e9f9 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -133,4 +133,16 @@ std::shared_ptr getProjectionPoint( return aLin2d.project(thePoint); } + +static double MyArrowSize = 40.; +double getArrowSize() +{ + return MyArrowSize; +} + +void setArrowSize(double theSize) +{ + MyArrowSize = theSize; +} + }; \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index 46f9fa4fc..da29b72bd 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -38,6 +38,9 @@ namespace SketcherPrs_Tools { SKETCHERPRS_EXPORT std::shared_ptr getFeaturePoint(DataPtr theData, const std::string& theAttribute); + SKETCHERPRS_EXPORT double getArrowSize(); + + SKETCHERPRS_EXPORT void setArrowSize(double theSize); }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index dc3dd6cba..d0153925a 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -183,6 +183,9 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// Returns list of displayed objects QObjectPtrList displayedObjects() const { return myResult2AISObjectMap.keys(); } + /// Returns list of displayed objects + QList displayedPresentations() const { return myResult2AISObjectMap.values(); } + /// Returns true if the given object can be shown in shaded mode /// \param theObject object to check bool canBeShaded(ObjectPtr theObject) const; diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 44cee80cd..c32ceab8a 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -107,6 +107,8 @@ void XGUI_ViewerProxy::connectToViewer() connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, SIGNAL(contextMenuRequested(QContextMenuEvent*))); + + // TODO: Connect to ViewTransformation signal } else { AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); @@ -180,6 +182,9 @@ void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd) { theWnd->viewPort()->installEventFilter(this); + connect(theWnd, SIGNAL(vpTransformationFinished(AppElements_ViewWindow::OperationType)), + this, SLOT(onViewTransformed(AppElements_ViewWindow::OperationType))); + emit viewCreated(theWnd); } @@ -294,3 +299,8 @@ bool XGUI_ViewerProxy::canDragByMouse() const return true; } } + +void XGUI_ViewerProxy::onViewTransformed(AppElements_ViewWindow::OperationType theType) +{ + emit viewTransformed((int) theType); +} \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 2ee3ba216..233bc5a9c 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -5,10 +5,9 @@ #include "XGUI.h" #include +#include class XGUI_Workshop; -class AppElements_ViewWindow; - /** * \ingroup GUI * Proxy class which repersents or AppElements_Viewer or Salome Viewer @@ -101,6 +100,8 @@ private slots: void onKeyPress(AppElements_ViewWindow*, QKeyEvent*); void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*); + void onViewTransformed(AppElements_ViewWindow::OperationType); + private: XGUI_Workshop* myWorkshop; };