]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Set dimensions arrows independent on zoom
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 30 Mar 2015 14:01:04 +0000 (17:01 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 30 Mar 2015 14:01:04 +0000 (17:01 +0300)
12 files changed:
src/ModuleBase/ModuleBase_IViewer.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Radius.cpp
src/SketcherPrs/SketcherPrs_SensitivePoint.h
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/SketcherPrs_Tools.h
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index 3cf3bc5ab332613847b717ad872f65de38ee6f00..feed61ee2ac2adff4aed87bae1cbffe64cb72a11 100644 (file)
@@ -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
index 486a87511a898f1940ee9577138051bf1f42774d..d10a13c9f857fa9c5c978713521a59784a5e2d18 100644 (file)
@@ -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
index 20cd411016fc4806e4f402843ee6926f4f03479e..00b6e321ffb4ee6dddae30efbbf1da9dee9cad0c 100644 (file)
@@ -57,7 +57,9 @@
 #include <SketchPlugin_ConstraintParallel.h>
 #include <SketchPlugin_ConstraintPerpendicular.h>
 #include <SketchPlugin_ConstraintRadius.h>
-//#include <SketchPlugin_ConstraintRigid.h>
+
+#include <SketcherPrs_SymbolPrs.h>
+#include <SketcherPrs_Tools.h>
 
 #include <Events_Loop.h>
 #include <Config_PropManager.h>
@@ -94,7 +96,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   : ModuleBase_IModule(theWshop), 
   myRestartingMode(RM_None), myVisualLayerId(0)
 {
-  //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
   mySketchMgr = new PartSet_SketcherMgr(this);
 
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(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<Handle(AIS_InteractiveObject)>();
   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<XGUI_ModuleConnector*>(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<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
+  foreach (AISObjectPtr aAIS, aPrsList) {
+    Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
+
+    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();
+}
index 6bacf2d778dd514376b82b3ae8815396bf7d5360..891759c36b34bb51dd9071fcc0bc70a7c449d280 100644 (file)
@@ -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();
index 0f5d2b8f022cd10c309f32b29242a57896ed5758..f3220e6b6d1174476a5a4d6b1fb250ecce1bc489 100644 (file)
 #include <ModelAPI_Data.h>
 
 
-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<gp_Ax3>());
   AIS_LengthDimension::Compute(thePresentationManager, thePresentation, theMode);
 }
index bdefd51876adc095b72ea8d5ef77734844b38674..bb517cc805b98ee259f01286407a2b456ac107ca 100644 (file)
@@ -5,6 +5,7 @@
 // Author:      Vitaly SMETANNIKOV
 
 #include "SketcherPrs_Radius.h"
+#include "SketcherPrs_Tools.h"
 
 #include <SketchPlugin_ConstraintRadius.h>
 #include <SketchPlugin_Constraint.h>
 #include <GeomAPI_XYZ.h>
 #include <ModelAPI_AttributeDouble.h>
 
-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<gp_Circ>(), anAnchor->impl<gp_Pnt>());
   SetCustomValue(aRadius);
 
-  myAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
-  myAspect->ArrowAspect()->SetLength(CONSTRAINT_TEXT_HEIGHT * 2.);
   AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);
 }
index bc3628b8a256d39f1cec6b81f8d64d2efa0e4e33..9daf62d47121ade5f950a8c052b8a3c0b337c36f 100644 (file)
 
 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: 
index 7fb7bf949256501a65501797387cfe951a0e45bf..e2973e9f9429b52127e21bbbdc0d141aacd889ee 100644 (file)
@@ -133,4 +133,16 @@ std::shared_ptr<GeomAPI_Pnt2d> 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
index 46f9fa4fc023cc123722c99d717925eded2114cb..da29b72bdc3a11a4d8a38fe232f6797205d00565 100644 (file)
@@ -38,6 +38,9 @@ namespace SketcherPrs_Tools {
   SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
                                                        const std::string& theAttribute);
 
+  SKETCHERPRS_EXPORT double getArrowSize();
+
+  SKETCHERPRS_EXPORT void setArrowSize(double theSize);
 };
 
 #endif
\ No newline at end of file
index dc3dd6cba29d18d7ef282b5e29c90a3a441e5774..d0153925ad2cca11b0725bc8c61588ae5575a19f 100644 (file)
@@ -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<AISObjectPtr> 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;
index 44cee80cdc980b62a20667d057bfe53febca0944..c32ceab8a045bdd84474e6a1ee69623944c680eb 100644 (file)
@@ -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
index 2ee3ba2168b056cf93d5ab42099b0f7dcec21fde..233bc5a9c254aba2193de03018f652108580d9f3 100644 (file)
@@ -5,10 +5,9 @@
 
 #include "XGUI.h"
 #include <ModuleBase_IViewer.h>
+#include <AppElements_ViewWindow.h>
 
 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;
 };