From: vsv Date: Mon, 3 Jun 2019 14:48:42 +0000 (+0300) Subject: Update dimensions on current plane of sketcher X-Git-Tag: VEDF2019Lot4~114^2~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ce291e8f0b7c7dd9a904ff2d49f969722bd42c86;p=modules%2Fshaper.git Update dimensions on current plane of sketcher --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp index d25a80842..2bfd5c34b 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp @@ -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; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 04dca6ac8..16a0451d4 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -93,7 +93,7 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi return thePrevious; AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, - sketch()->coordinatePlane(), + sketch(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistanceAlongDir.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistanceAlongDir.cpp index 35def2323..3357d5819 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistanceAlongDir.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistanceAlongDir.cpp @@ -82,7 +82,7 @@ AISObjectPtr SketchPlugin_ConstraintDistanceAlongDir::getAISObject(AISObjectPtr return thePrevious; AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, - sketch()->coordinatePlane(), + sketch(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 289548b34..1ba4aa081 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -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; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index c2f363b73..b27190e0a 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -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; } diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index a7f366dd9..3a876982b 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -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& 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 (aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); std::shared_ptr aFlyoutPnt = - mySketcherPlane->to3D(aFlyoutAttr->x(), aFlyoutAttr->y()); + plane()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y()); myFlyOutPoint = aFlyoutPnt->impl(); } @@ -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(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()))); return aDot < 0; } diff --git a/src/SketcherPrs/SketcherPrs_Angle.h b/src/SketcherPrs/SketcherPrs_Angle.h index 98f70d403..75d0c37d8 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.h +++ b/src/SketcherPrs/SketcherPrs_Angle.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -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& 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& thePlane); + + /// Returns sketcher plane + Standard_EXPORT std::shared_ptr 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 mySketcherPlane; + /// A current sketcher + SketchPlugin_Sketch* mySketcher; Handle(Prs3d_DimensionAspect) myAspect; diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index ebbe5b6bf..553ea9cf9 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -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& thePlane, \ - AISObjectPtr thePrevious) \ -{ \ - std::shared_ptr 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, diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h index e9413fc09..6d324d43c 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -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& 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 diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index 01c0659db..2eecd66c1 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -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& 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(), true); + SetDirection(plane()->dirX()->impl(), true); else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID()) - SetDirection(mySketcherPlane->dirY()->impl(), true); + SetDirection(plane()->dirY()->impl(), 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()); + myPlane = gp_Pln(plane()->impl()); DataPtr aData = myConstraint->data(); AttributeDoublePtr anAttributeValue; diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.h b/src/SketcherPrs/SketcherPrs_LengthDimension.h index e67b44efa..469a63c3d 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.h +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -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& 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& thePlane); + + /// Returns sketcher plane + Standard_EXPORT std::shared_ptr 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 mySketcherPlane; + /// A current sketcher + SketchPlugin_Sketch* mySketcher; //Handle(Prs3d_DimensionAspect) myAspect; diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index f57a08db0..8d3355d77 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -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& 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; diff --git a/src/SketcherPrs/SketcherPrs_Radius.h b/src/SketcherPrs/SketcherPrs_Radius.h index b4cf70e5e..a6fbe75e9 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.h +++ b/src/SketcherPrs/SketcherPrs_Radius.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -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& 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& thePlane); + + /// Returns sketcher plane + Standard_EXPORT std::shared_ptr 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 mySketcherPlane; + /// A current sketcher + SketchPlugin_Sketch* mySketcher; /// Listener to update dimension visualization style SketcherPrs_DimensionStyleListener* myStyleListener; diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index ad5a5ddde..a08d98b56 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -70,7 +70,10 @@ public: const Handle(SelectMgr_EntityOwner)& theOwner); /// Returns sketcher plane - Standard_EXPORT std::shared_ptr plane() const { return mySketcher->coordinatePlane(); } + Standard_EXPORT std::shared_ptr plane() const + { + return mySketcher->coordinatePlane(); + } /// Returns feature object Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; }