]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update dimensions on current plane of sketcher
authorvsv <vsv@opencascade.com>
Mon, 3 Jun 2019 14:48:42 +0000 (17:48 +0300)
committervsv <vsv@opencascade.com>
Mon, 3 Jun 2019 14:48:42 +0000 (17:48 +0300)
14 files changed:
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistanceAlongDir.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketcherPrs/SketcherPrs_Angle.cpp
src/SketcherPrs/SketcherPrs_Angle.h
src/SketcherPrs/SketcherPrs_Factory.cpp
src/SketcherPrs/SketcherPrs_Factory.h
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.h
src/SketcherPrs/SketcherPrs_Radius.cpp
src/SketcherPrs/SketcherPrs_Radius.h
src/SketcherPrs/SketcherPrs_SymbolPrs.h

index d25a808429ca9c952ae3c11d816fbe5421d0528b..2bfd5c34be1cdb0a4c8a782e840b44ec01fd823e 100644 (file)
@@ -115,7 +115,7 @@ AISObjectPtr SketchPlugin_ConstraintAngle::getAISObject(AISObjectPtr thePrevious
   if (!sketch())
     return thePrevious;
 
-  AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch()->coordinatePlane(),
+  AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch(),
                                                             thePrevious);
   return anAIS;
 }
index 04dca6ac8d2aecd87971225e76d48003173c908d..16a0451d4044c1987e970bf4b56adea306ed4e8a 100644 (file)
@@ -93,7 +93,7 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi
     return thePrevious;
 
   AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
-                                                                      sketch()->coordinatePlane(),
+                                                                      sketch(),
                                                                       thePrevious);
   return anAIS;
 }
index 35def2323d07fd1537ad83e7cd2a2c3a183ed7fd..3357d5819f52c9e97f0d48dd055a097894243242 100644 (file)
@@ -82,7 +82,7 @@ AISObjectPtr SketchPlugin_ConstraintDistanceAlongDir::getAISObject(AISObjectPtr
     return thePrevious;
 
   AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
-                                                                      sketch()->coordinatePlane(),
+                                                                      sketch(),
                                                                       thePrevious);
   return anAIS;
 }
index 289548b341e534f665ed039c74d21e28b85250b5..1ba4aa081ff9e54a91a7af1b61fb40fd824aa74a 100644 (file)
@@ -170,7 +170,7 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
     return thePrevious;
 
   AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
-    sketch()->coordinatePlane(), thePrevious);
+    sketch(), thePrevious);
   return anAIS;
 }
 
index c2f363b731b7a36139765491aaf71cf368eaec76..b27190e0a556f406ca0325e778b407da433d139c 100644 (file)
@@ -175,7 +175,7 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou
   if (!sketch())
     return thePrevious;
 
-  AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch()->coordinatePlane(),
+  AISObjectPtr anAIS = SketcherPrs_Factory::radiusConstraint(this, sketch(),
                                                              thePrevious);
   return anAIS;
 }
index a7f366dd9714c0aab15eee3757b6b5c727c76221..3a876982b326ba180bdd58197b333476ed79c396 100644 (file)
@@ -54,9 +54,9 @@ extern void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect,
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Angle, AIS_AngleDimension);
 
 SketcherPrs_Angle::SketcherPrs_Angle(ModelAPI_Feature* theConstraint,
-                                     const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+  SketchPlugin_Sketch* theSketcher)
 : AIS_AngleDimension(gp_Pnt(0,0,0), gp_Pnt(1,0,0), gp_Pnt(0,1,0)), myConstraint(theConstraint),
-  mySketcherPlane(thePlane),
+  mySketcher(theSketcher),
   myFirstPoint(gp_Pnt(0,0,0)), myCenterPoint(gp_Pnt(1,0,0)), mySecondPoint(gp_Pnt(0,1,0)),
   myValue(90., false, ""), myFlyOutPoint(0, 0.5, 0)
 {
@@ -166,7 +166,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
                                 const Standard_Integer theMode)
 {
   gp_Pnt aFirstPoint, aSecondPoint, aCenterPoint;
-  bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane,
+  bool aReadyToDisplay = readyToDisplay(myConstraint, plane(),
                                         aFirstPoint, aSecondPoint, aCenterPoint);
   if (aReadyToDisplay) {
     myFirstPoint = aFirstPoint;
@@ -182,7 +182,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
                                 std::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                 (aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
     std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt =
-      mySketcherPlane->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
+      plane()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
     myFlyOutPoint = aFlyoutPnt->impl<gp_Pnt>();
   }
 
@@ -287,12 +287,12 @@ void SketcherPrs_Angle::ComputeSelection(const Handle(SelectMgr_Selection)& aSel
 bool SketcherPrs_Angle::isAnglePlaneReversedToSketchPlane()
 {
   bool aReversed = false;
-  if (!mySketcherPlane.get())
+  if (!plane().get())
     return aReversed;
 
   gp_Pln aPlane = GetPlane();
   gp_Dir aDir = aPlane.Axis().Direction();
-  double aDot = mySketcherPlane->normal()->dot(
+  double aDot = plane()->normal()->dot(
                 std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z())));
   return aDot < 0;
 }
index 98f70d403b780ac5490534aa5e82346d7dd73c71..75d0c37d81888c8d869d1555128ace51335dedc0 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <GeomAPI_Ax3.h>
 #include <ModelAPI_Feature.h>
+#include <SketchPlugin_Sketch.h>
 
 #include <AIS_AngleDimension.hxx>
 #include <Standard_DefineHandle.hxx>
@@ -41,7 +42,7 @@ public:
   /// \param theConstraint a constraint feature
   /// \param thePlane a coordinate plane of current sketch
   Standard_EXPORT SketcherPrs_Angle(ModelAPI_Feature* theConstraint,
-                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+    SketchPlugin_Sketch* theSketcher);
 
   /// Destructor
   Standard_EXPORT ~SketcherPrs_Angle();
@@ -55,6 +56,13 @@ public:
   /// \return boolean result value
   static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  /// Returns sketcher plane
+  Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+  {
+    return mySketcher->coordinatePlane();
+  }
+
 protected:
   /// Redefinition of virtual function
   Standard_EXPORT virtual void Compute(
@@ -85,8 +93,8 @@ private:
   /// Constraint feature
   ModelAPI_Feature* myConstraint;
 
-  /// Plane of the current sketcher
-  std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
+  /// A current sketcher
+  SketchPlugin_Sketch* mySketcher;
 
   Handle(Prs3d_DimensionAspect) myAspect;
 
index ebbe5b6bf3390df85755b6930d30212609fe47fd..553ea9cf95011c965d13048ee4bc2989cb0fbbaa 100644 (file)
@@ -63,31 +63,9 @@ CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
 CONSTRAINT_PRS_IMPL(middleConstraint, SketcherPrs_Middle);
 CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
 CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
-
-
-
-#define CONSTRAINT2_PRS_IMPL(NAME, CLASS) \
-AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
-                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane, \
-                                       AISObjectPtr thePrevious) \
-{ \
-  std::shared_ptr<GeomAPI_AISObject> anAISObj; \
-  if (CLASS::IsReadyToDisplay(theConstraint, thePlane)) { \
-    if (thePrevious.get()) \
-      anAISObj = thePrevious; \
-    else { \
-      anAISObj = AISObjectPtr(new GeomAPI_AISObject()); \
-      Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \
-      anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \
-    } \
-  } \
-  return anAISObj; \
-}
-
-
-CONSTRAINT2_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
-CONSTRAINT2_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
-CONSTRAINT2_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
+CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
+CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
+CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
 
 // Non-standard constraints definition
 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
index e9413fc091b60315006fda613b3cea952590308c..6d324d43c8a49fb8932b59a81b87f42d741829ad 100644 (file)
@@ -118,28 +118,23 @@ public:
   /// \param thePrevious the previous presentation
   GET_CONSTRAINT_PRS(coincidentConstraint)
 
-#define GET_CONSTRAINT2_PRS(NAME) \
-  static AISObjectPtr NAME(ModelAPI_Feature* theConstraint, \
-                           const std::shared_ptr<GeomAPI_Ax3>& thePlane, \
-                           AISObjectPtr thePrevious);
-
-  /// Creates angle constraint presentation
+  /// Creates length dimension presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   /// \param thePrevious the previous presentation
-  GET_CONSTRAINT2_PRS(angleConstraint)
+  GET_CONSTRAINT_PRS(lengthDimensionConstraint)
 
-  /// Creates length dimension presentation
+  /// Creates angle constraint presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   /// \param thePrevious the previous presentation
-  GET_CONSTRAINT2_PRS(lengthDimensionConstraint)
+  GET_CONSTRAINT_PRS(angleConstraint)
 
   /// Creates radius dimension presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   /// \param thePrevious the previous presentation
-  GET_CONSTRAINT2_PRS(radiusConstraint)
+  GET_CONSTRAINT_PRS(radiusConstraint)
 };
 
 #endif
index 01c0659db27ee1cc5b914b4bfdfef88807d08c6a..2eecd66c1e8331b9f3e1a77fab5b1640b4f3cf90 100644 (file)
@@ -109,10 +109,10 @@ static const gp_Pln MyDefPln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension);
 
 SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
-                                              const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+  SketchPlugin_Sketch* theSketcher)
 : AIS_LengthDimension(MyDefStart, MyDefEnd, MyDefPln),
   myConstraint(theConstraint),
-  mySketcherPlane(thePlane),
+  mySketcher(theSketcher),
   myFirstPoint(MyDefStart),
   mySecondPoint(MyDefEnd),
   myPlane(MyDefPln),
@@ -124,9 +124,9 @@ SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theCo
 
 #ifdef OCCT_28850_FIXED
   if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID())
-    SetDirection(mySketcherPlane->dirX()->impl<gp_Dir>(), true);
+    SetDirection(plane()->dirX()->impl<gp_Dir>(), true);
   else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
-    SetDirection(mySketcherPlane->dirY()->impl<gp_Dir>(), true);
+    SetDirection(plane()->dirY()->impl<gp_Dir>(), true);
 #endif
 }
 
@@ -148,13 +148,13 @@ void SketcherPrs_LengthDimension::Compute(
   const Standard_Integer theMode)
 {
   gp_Pnt aPnt1, aPnt2;
-  bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane, aPnt1, aPnt2);
+  bool aReadyToDisplay = readyToDisplay(myConstraint, plane(), aPnt1, aPnt2);
   if (aReadyToDisplay) {
     myFirstPoint = aPnt1;
     mySecondPoint = aPnt2;
 
     myDistance = SketcherPrs_Tools::getFlyoutDistance(myConstraint);
-    myPlane = gp_Pln(mySketcherPlane->impl<gp_Ax3>());
+    myPlane = gp_Pln(plane()->impl<gp_Ax3>());
 
     DataPtr aData = myConstraint->data();
     AttributeDoublePtr anAttributeValue;
index e67b44efa4ae37f6c1379f23cdbd9b8e1230fdb6..469a63c3d52646e88c52e36a888292a0db36b758 100644 (file)
@@ -24,6 +24,7 @@
 #include <ModelAPI_Feature.h>
 #include <AIS_LengthDimension.hxx>
 #include <Standard_DefineHandle.hxx>
+#include <SketchPlugin_Sketch.h>
 
 #include <gp_Pnt.hxx>
 #include <gp_Pln.hxx>
@@ -45,7 +46,7 @@ public:
   /// \param theConstraint a constraint feature
   /// \param thePlane a coordinate plane of current sketch
   Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
-                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+    SketchPlugin_Sketch* theSketcher);
 
   /// Destructor
   Standard_EXPORT ~SketcherPrs_LengthDimension();
@@ -59,6 +60,13 @@ public:
   /// \return boolean result value
   static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  /// Returns sketcher plane
+  Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+  {
+    return mySketcher->coordinatePlane();
+  }
+
 protected:
   /// Redefinition of virtual function
   Standard_EXPORT virtual void Compute(
@@ -78,8 +86,8 @@ private:
   /// Constraint feature
   ModelAPI_Feature* myConstraint;
 
-  /// Plane of the current sketcher
-  std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
+  /// A current sketcher
+  SketchPlugin_Sketch* mySketcher;
 
   //Handle(Prs3d_DimensionAspect) myAspect;
 
index f57a08db062d3987375907d1b1b238da14429db0..8d3355d7752c226a1d93452c584922cfc9d9474c 100644 (file)
@@ -52,8 +52,8 @@ static const gp_Circ MyDefCirc(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), 1);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Radius, AIS_RadiusDimension);
 
 SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
-                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane)
-: AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), mySketcherPlane(thePlane),
+  SketchPlugin_Sketch* theSketcher)
+: AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), mySketcher(theSketcher),
   myCircle(MyDefCirc),
   myAnchorPoint(gp_Pnt(0, 0, 2)),
   myValue(1, false, "")
@@ -147,7 +147,7 @@ void SketcherPrs_Radius::Compute(
 {
   gp_Circ aCircle;
   gp_Pnt anAnchorPoint;
-  bool aReadyToDisplay = readyToDisplay(myConstraint, mySketcherPlane, aCircle, anAnchorPoint);
+  bool aReadyToDisplay = readyToDisplay(myConstraint, plane(), aCircle, anAnchorPoint);
   if (aReadyToDisplay) {
     myCircle = aCircle;
     myAnchorPoint = anAnchorPoint;
index b4cf70e5e6f16e5515889d77b5af0be6f31e9627..a6fbe75e9227e91fac4e1954c7c8eafe368661e4 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <GeomAPI_Ax3.h>
 #include <ModelAPI_Feature.h>
+#include <SketchPlugin_Sketch.h>
 
 #include <AIS_RadiusDimension.hxx>
 #include <Standard_DefineHandle.hxx>
@@ -41,7 +42,7 @@ public:
   /// \param theConstraint a constraint feature
   /// \param thePlane a coordinate plane of current sketch
   Standard_EXPORT SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
-                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+    SketchPlugin_Sketch* theSketcher);
 
   /// Destructor
   Standard_EXPORT ~SketcherPrs_Radius();
@@ -55,6 +56,13 @@ public:
   /// \return boolean result value
   static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+
+  /// Returns sketcher plane
+  Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+  {
+    return mySketcher->coordinatePlane();
+  }
+
 private:
   /// Fills the constraint parameters by constraint and plane
   /// \param theConstraint a constraint feature
@@ -79,8 +87,8 @@ private:
   /// Constraint feature
   ModelAPI_Feature* myConstraint;
 
-  /// Plane of the current sketcher
-  std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
+  /// A current sketcher
+  SketchPlugin_Sketch* mySketcher;
 
   /// Listener to update dimension visualization style
   SketcherPrs_DimensionStyleListener* myStyleListener;
index ad5a5ddde07d61ca8acaacacad5ed4810a69d0b1..a08d98b5604e9da89deb2ece54c9c2164a07d66e 100644 (file)
@@ -70,7 +70,10 @@ public:
     const Handle(SelectMgr_EntityOwner)& theOwner);
 
   /// Returns sketcher plane
-  Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const { return mySketcher->coordinatePlane(); }
+  Standard_EXPORT std::shared_ptr<GeomAPI_Ax3> plane() const
+  {
+    return mySketcher->coordinatePlane();
+  }
 
   /// Returns feature object
   Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }