From: vsv Date: Fri, 21 Jul 2017 12:58:22 +0000 (+0300) Subject: Issue #2208: Development in progress X-Git-Tag: V_2.9.0~23^2~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ab07e66b9ed5d4e520f56bbe8a3e44312b05a89b;p=modules%2Fshaper.git Issue #2208: Development in progress --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCollinear.cpp b/src/SketchPlugin/SketchPlugin_ConstraintCollinear.cpp index ef3a7a568..484692fba 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCollinear.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintCollinear.cpp @@ -41,7 +41,7 @@ AISObjectPtr SketchPlugin_ConstraintCollinear::getAISObject(AISObjectPtr thePrev if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::collinearConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::collinearConstraint(this, sketch(), sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp b/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp index 3605f1af5..7be8935aa 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp @@ -50,7 +50,8 @@ AISObjectPtr SketchPlugin_ConstraintEqual::getAISObject(AISObjectPtr thePrevious if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::equalConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::equalConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp b/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp index 81612bc20..6ebf472e8 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp @@ -50,7 +50,8 @@ AISObjectPtr SketchPlugin_ConstraintHorizontal::getAISObject(AISObjectPtr thePre if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::horisontalConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::horisontalConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp index 06d01f8ed..620b0691a 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp @@ -41,7 +41,8 @@ AISObjectPtr SketchPlugin_ConstraintMiddle::getAISObject(AISObjectPtr thePreviou if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::middleConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::middleConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp index e4c6ed4ed..ec7be3a79 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp @@ -209,7 +209,8 @@ AISObjectPtr SketchPlugin_ConstraintMirror::getAISObject(AISObjectPtr thePreviou if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index 68f041749..9ddda85aa 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -56,7 +56,8 @@ AISObjectPtr SketchPlugin_ConstraintParallel::getAISObject(AISObjectPtr thePrevi if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::parallelConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::parallelConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index f60e3492e..258e30dc0 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -55,7 +55,7 @@ AISObjectPtr SketchPlugin_ConstraintPerpendicular::getAISObject(AISObjectPtr the if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::perpendicularConstraint(this, + AISObjectPtr anAIS = SketcherPrs_Factory::perpendicularConstraint(this, sketch(), sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index 042b2df1a..67eba8044 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -47,5 +47,6 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious { if (!sketch()) return thePrevious; - return SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane(), thePrevious); + return SketcherPrs_Factory::rigidConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); } \ No newline at end of file diff --git a/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp b/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp index 2dc22943e..37fa4e0de 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintTangent.cpp @@ -50,7 +50,8 @@ AISObjectPtr SketchPlugin_ConstraintTangent::getAISObject(AISObjectPtr thePrevio if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::tangentConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::tangentConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp b/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp index 8a03d77ef..3debcfd37 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp @@ -49,7 +49,8 @@ AISObjectPtr SketchPlugin_ConstraintVertical::getAISObject(AISObjectPtr thePrevi if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::verticalConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::verticalConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp index 8743a3c36..3fd19dc33 100755 --- a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp @@ -226,7 +226,8 @@ AISObjectPtr SketchPlugin_MultiRotation::getAISObject(AISObjectPtr thePrevious) if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::rotateConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::rotateConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp index 5fc05fc1e..b927739d1 100755 --- a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp @@ -212,7 +212,8 @@ AISObjectPtr SketchPlugin_MultiTranslation::getAISObject(AISObjectPtr thePreviou if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::translateConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::translateConstraint(this, sketch(), + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketcherPrs/SketcherPrs_Collinear.cpp b/src/SketcherPrs/SketcherPrs_Collinear.cpp index 1d8a8134c..fba498a28 100755 --- a/src/SketcherPrs/SketcherPrs_Collinear.cpp +++ b/src/SketcherPrs/SketcherPrs_Collinear.cpp @@ -33,8 +33,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Collinear, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Collinear::SketcherPrs_Collinear(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Collinear.h b/src/SketcherPrs/SketcherPrs_Collinear.h index 86f8837aa..dfa4d853e 100755 --- a/src/SketcherPrs/SketcherPrs_Collinear.h +++ b/src/SketcherPrs/SketcherPrs_Collinear.h @@ -36,8 +36,10 @@ class SketcherPrs_Collinear: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Collinear(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane); DEFINE_STANDARD_RTTIEXT(SketcherPrs_Collinear, SketcherPrs_SymbolPrs) diff --git a/src/SketcherPrs/SketcherPrs_Equal.cpp b/src/SketcherPrs/SketcherPrs_Equal.cpp index f534e27c9..7077e1a7a 100644 --- a/src/SketcherPrs/SketcherPrs_Equal.cpp +++ b/src/SketcherPrs/SketcherPrs_Equal.cpp @@ -33,8 +33,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Equal, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Equal::SketcherPrs_Equal(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Equal.h b/src/SketcherPrs/SketcherPrs_Equal.h index 8285b8145..0b2066d38 100644 --- a/src/SketcherPrs/SketcherPrs_Equal.h +++ b/src/SketcherPrs/SketcherPrs_Equal.h @@ -36,9 +36,11 @@ class SketcherPrs_Equal: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Equal(ModelAPI_Feature* theConstraint, - const std::shared_ptr& thePlane); + ModelAPI_CompositeFeature* theSketcher, + const std::shared_ptr& thePlane); DEFINE_STANDARD_RTTIEXT(SketcherPrs_Equal, SketcherPrs_SymbolPrs) /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation diff --git a/src/SketcherPrs/SketcherPrs_Factory.cpp b/src/SketcherPrs/SketcherPrs_Factory.cpp index ab8e6378c..6059e0ce0 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.cpp +++ b/src/SketcherPrs/SketcherPrs_Factory.cpp @@ -38,6 +38,7 @@ // Macros for constraint presentation definition #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \ AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \ + ModelAPI_CompositeFeature* theSketcher, \ const std::shared_ptr& thePlane, \ AISObjectPtr thePrevious) \ { \ @@ -47,28 +48,52 @@ AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \ anAISObj = thePrevious; \ else { \ anAISObj = AISObjectPtr(new GeomAPI_AISObject()); \ - Handle(CLASS) aPrs = new CLASS(theConstraint, thePlane); \ + Handle(CLASS) aPrs = new CLASS(theConstraint, theSketcher, thePlane); \ anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); \ } \ } \ return anAISObj; \ } -CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident); + CONSTRAINT_PRS_IMPL(collinearConstraint, SketcherPrs_Collinear); CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel); CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular); CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid); CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal); CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent); -CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius); -CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension); CONSTRAINT_PRS_IMPL(middleConstraint, SketcherPrs_Middle); CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror); -CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle); + + + +#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(coincidentConstraint, SketcherPrs_Coincident); +CONSTRAINT2_PRS_IMPL(angleConstraint, SketcherPrs_Angle); +CONSTRAINT2_PRS_IMPL(radiusConstraint, SketcherPrs_Radius); +CONSTRAINT2_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension); // Non-standard constraints definition AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, AISObjectPtr thePrevious) { @@ -79,7 +104,7 @@ AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theCons else { anAISObj = AISObjectPtr(new GeomAPI_AISObject()); Handle(SketcherPrs_HVDirection) aPrs = - new SketcherPrs_HVDirection(theConstraint, thePlane, true); + new SketcherPrs_HVDirection(theConstraint, theSketcher, thePlane, true); anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); } } @@ -87,6 +112,7 @@ AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theCons } AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, AISObjectPtr thePrevious) { @@ -97,7 +123,7 @@ AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstr else { anAISObj = AISObjectPtr(new GeomAPI_AISObject()); Handle(SketcherPrs_HVDirection) aPrs = - new SketcherPrs_HVDirection(theConstraint, thePlane, false); + new SketcherPrs_HVDirection(theConstraint, theSketcher, thePlane, false); anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); } } @@ -105,6 +131,7 @@ AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstr } AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, AISObjectPtr thePrevious) { @@ -115,7 +142,7 @@ AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConst else { anAISObj = AISObjectPtr(new GeomAPI_AISObject()); Handle(SketcherPrs_Transformation) aPrs = - new SketcherPrs_Transformation(theConstraint, thePlane, true); + new SketcherPrs_Transformation(theConstraint, theSketcher, thePlane, true); anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); } } @@ -123,6 +150,7 @@ AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConst } AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, AISObjectPtr thePrevious) { @@ -133,7 +161,7 @@ AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstrai else { anAISObj = AISObjectPtr(new GeomAPI_AISObject()); Handle(SketcherPrs_Transformation) aPrs = - new SketcherPrs_Transformation(theConstraint, thePlane, false); + new SketcherPrs_Transformation(theConstraint, theSketcher, thePlane, false); anAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); } } diff --git a/src/SketcherPrs/SketcherPrs_Factory.h b/src/SketcherPrs/SketcherPrs_Factory.h index ba4123cfb..f59bd0d61 100644 --- a/src/SketcherPrs/SketcherPrs_Factory.h +++ b/src/SketcherPrs/SketcherPrs_Factory.h @@ -24,12 +24,14 @@ #include "SketcherPrs.h" #include +#include #include #include #define GET_CONSTRAINT_PRS(NAME) \ static AISObjectPtr NAME(ModelAPI_Feature* theConstraint, \ + ModelAPI_CompositeFeature* theSketcher, \ const std::shared_ptr& thePlane, \ AISObjectPtr thePrevious); @@ -39,12 +41,6 @@ class SKETCHERPRS_EXPORT SketcherPrs_Factory { public: - /// Creates coincedent constraint presentation - /// \param theConstraint the constraint - /// \param thePlane the current sketch plane - /// \param thePrevious the previous presentation - GET_CONSTRAINT_PRS(coincidentConstraint) - /// Creates collinear constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane @@ -93,18 +89,6 @@ public: /// \param thePrevious the previous presentation GET_CONSTRAINT_PRS(tangentConstraint) - /// Creates radius dimension presentation - /// \param theConstraint the constraint - /// \param thePlane the current sketch plane - /// \param thePrevious the previous presentation - GET_CONSTRAINT_PRS(radiusConstraint) - - /// Creates length dimension presentation - /// \param theConstraint the constraint - /// \param thePlane the current sketch plane - /// \param thePrevious the previous presentation - GET_CONSTRAINT_PRS(lengthDimensionConstraint) - /// Creates middle constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane @@ -129,11 +113,34 @@ public: /// \param thePrevious the previous presentation GET_CONSTRAINT_PRS(rotateConstraint) +#define GET_CONSTRAINT2_PRS(NAME) \ + static AISObjectPtr NAME(ModelAPI_Feature* theConstraint, \ + const std::shared_ptr& thePlane, \ + AISObjectPtr thePrevious); + + /// Creates coincedent constraint presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + /// \param thePrevious the previous presentation + GET_CONSTRAINT2_PRS(coincidentConstraint) + /// Creates angle constraint presentation /// \param theConstraint the constraint /// \param thePlane the current sketch plane /// \param thePrevious the previous presentation - GET_CONSTRAINT_PRS(angleConstraint) + GET_CONSTRAINT2_PRS(angleConstraint) + + /// Creates length dimension presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + /// \param thePrevious the previous presentation + GET_CONSTRAINT2_PRS(lengthDimensionConstraint) + + /// Creates radius dimension presentation + /// \param theConstraint the constraint + /// \param thePlane the current sketch plane + /// \param thePrevious the previous presentation + GET_CONSTRAINT2_PRS(radiusConstraint) }; #endif diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.cpp b/src/SketcherPrs/SketcherPrs_HVDirection.cpp index a53bd64aa..d599d492c 100644 --- a/src/SketcherPrs/SketcherPrs_HVDirection.cpp +++ b/src/SketcherPrs/SketcherPrs_HVDirection.cpp @@ -33,9 +33,11 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_HVDirection::SketcherPrs_HVDirection(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, bool isHorisontal) - : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsHorisontal(isHorisontal) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane), + myIsHorisontal(isHorisontal) { } diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.h b/src/SketcherPrs/SketcherPrs_HVDirection.h index ea50c41d5..07ffa9a07 100644 --- a/src/SketcherPrs/SketcherPrs_HVDirection.h +++ b/src/SketcherPrs/SketcherPrs_HVDirection.h @@ -37,9 +37,11 @@ class SketcherPrs_HVDirection: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch /// \param isHorisontal a flag horizontal or vertical presentation Standard_EXPORT SketcherPrs_HVDirection(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, bool isHorisontal); diff --git a/src/SketcherPrs/SketcherPrs_Middle.cpp b/src/SketcherPrs/SketcherPrs_Middle.cpp index bfe35b8e5..ef272b49d 100755 --- a/src/SketcherPrs/SketcherPrs_Middle.cpp +++ b/src/SketcherPrs/SketcherPrs_Middle.cpp @@ -33,8 +33,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Middle, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Middle::SketcherPrs_Middle(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Middle.h b/src/SketcherPrs/SketcherPrs_Middle.h index 64871852e..e5fbda622 100755 --- a/src/SketcherPrs/SketcherPrs_Middle.h +++ b/src/SketcherPrs/SketcherPrs_Middle.h @@ -36,9 +36,11 @@ class SketcherPrs_Middle: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Middle(ModelAPI_Feature* theConstraint, - const std::shared_ptr& thePlane); + ModelAPI_CompositeFeature* theSketcher, + const std::shared_ptr& thePlane); DEFINE_STANDARD_RTTIEXT(SketcherPrs_Middle, SketcherPrs_SymbolPrs) /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation diff --git a/src/SketcherPrs/SketcherPrs_Mirror.cpp b/src/SketcherPrs/SketcherPrs_Mirror.cpp index 82f61923b..33a650116 100644 --- a/src/SketcherPrs/SketcherPrs_Mirror.cpp +++ b/src/SketcherPrs/SketcherPrs_Mirror.cpp @@ -35,8 +35,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Mirror, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Mirror.h b/src/SketcherPrs/SketcherPrs_Mirror.h index 758c2ba09..7857e7118 100644 --- a/src/SketcherPrs/SketcherPrs_Mirror.h +++ b/src/SketcherPrs/SketcherPrs_Mirror.h @@ -36,8 +36,10 @@ class SketcherPrs_Mirror: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Mirror(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane); DEFINE_STANDARD_RTTIEXT(SketcherPrs_Mirror, SketcherPrs_SymbolPrs) diff --git a/src/SketcherPrs/SketcherPrs_Parallel.cpp b/src/SketcherPrs/SketcherPrs_Parallel.cpp index cfdad6de9..90cdfd129 100644 --- a/src/SketcherPrs/SketcherPrs_Parallel.cpp +++ b/src/SketcherPrs/SketcherPrs_Parallel.cpp @@ -34,8 +34,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Parallel::SketcherPrs_Parallel(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Parallel.h b/src/SketcherPrs/SketcherPrs_Parallel.h index 0ce747818..d963fcc8b 100644 --- a/src/SketcherPrs/SketcherPrs_Parallel.h +++ b/src/SketcherPrs/SketcherPrs_Parallel.h @@ -36,8 +36,10 @@ class SketcherPrs_Parallel: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Parallel(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane); DEFINE_STANDARD_RTTIEXT(SketcherPrs_Parallel, SketcherPrs_SymbolPrs) diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp index 0dcb01edf..16b553100 100644 --- a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp +++ b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp @@ -37,8 +37,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.h b/src/SketcherPrs/SketcherPrs_Perpendicular.h index 5b33377f0..b075d4aa4 100644 --- a/src/SketcherPrs/SketcherPrs_Perpendicular.h +++ b/src/SketcherPrs/SketcherPrs_Perpendicular.h @@ -38,8 +38,10 @@ class SketcherPrs_Perpendicular: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Perpendicular(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane); DEFINE_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs) diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index 8897fa16e..c92f1a0ab 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -26,6 +26,9 @@ #include #include #include +#include + +#include #include #include @@ -35,6 +38,7 @@ #include #include #include +#include static SketcherPrs_PositionMgr* MyPosMgr = NULL; @@ -185,32 +189,54 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape, //***************************************************************** //! Returns curves connected to the given point -TColGeom_SequenceOfCurve getCurves(const GeomPointPtr& thePnt, const SketcherPrs_SymbolPrs* thePrs) +std::list getCurves(const GeomPointPtr& thePnt, const SketcherPrs_SymbolPrs* thePrs) { - TColGeom_SequenceOfCurve aList; - //GeomAx3Ptr aAx3 = thePrs->plane(); - //CompositeFeaturePtr aOwner = thePrs->sketcher(); - //GeomPnt2dPtr aPnt2d = thePnt->to2D(aAx3->origin(), aAx3->dirX(), aAx3->dirY()); + std::list aList; + GeomAx3Ptr aAx3 = thePrs->plane(); + ModelAPI_CompositeFeature* aOwner = thePrs->sketcher(); + GeomPnt2dPtr aPnt2d = thePnt->to2D(aAx3->origin(), aAx3->dirX(), aAx3->dirY()); + + int aNbSubs = aOwner->numberOfSubs(); + for (int i = 0; i < aNbSubs; i++) { + FeaturePtr aFeature = aOwner->subFeature(i); + if (aFeature->getKind() == SketchPlugin_Line::ID()) { + AttributePoint2DPtr aSPnt1 = std::dynamic_pointer_cast( + aFeature->data()->attribute(SketchPlugin_Line::START_ID())); + AttributePoint2DPtr aSPnt2 = std::dynamic_pointer_cast( + aFeature->data()->attribute(SketchPlugin_Line::END_ID())); - //int aNbSubs = aOwner->numberOfSubs(); - //for (int i = 0; i < aNbSubs; i++) { - // FeaturePtr aFeature = aOwner->subFeature(i); - // if (aFeature->getKind() == SketchPlugin_Line::ID()) { - // GeomPnt2dPtr aPnt1 = - // SketcherPrs_Tools::getPoint(aFeature.get(), SketchPlugin_Line::START_ID()); - // GeomPnt2dPtr aPnt2 = - // SketcherPrs_Tools::getPoint(aFeature.get(), SketchPlugin_Line::END_ID()); - // if (aPnt1->isEqual(aPnt2d) || aPnt2->isEqual(aPnt2d)) { - // GeomShapePtr aShp = SketcherPrs_Tools::getShape(aFeature->firstResult()); - // GeomCurvePtr aCurv = std::shared_ptr(new GeomAPI_Curve(aShp)); - // aList.Append(aCurv->impl()); - // } - // } else if ((aFeature->getKind() == SketchPlugin_Circle::ID()) || - // (aFeature->getKind() == SketchPlugin_Arc::ID())) { - // GeomShapePtr aShp = SketcherPrs_Tools::getShape(aFeature->firstResult()); - // GeomCurvePtr aCurv = std::shared_ptr(new GeomAPI_Curve(aShp)); - // } - //} + GeomPnt2dPtr aPnt1 = aSPnt1->pnt(); + GeomPnt2dPtr aPnt2 = aSPnt2->pnt(); + + if (aPnt1->isEqual(aPnt2d) || aPnt2->isEqual(aPnt2d)) { + GeomShapePtr aShp = SketcherPrs_Tools::getShape(aFeature->firstResult()); + GeomCurvePtr aCurv = std::shared_ptr(new GeomAPI_Curve(aShp)); + aList.push_back(aFeature->firstResult()); + } + } else if ((aFeature->getKind() == SketchPlugin_Circle::ID()) || + (aFeature->getKind() == SketchPlugin_Arc::ID())) { + GeomCurvePtr aCurve; + ObjectPtr aResObj; + std::list aResults = aFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) { + GeomShapePtr aShp = SketcherPrs_Tools::getShape((*aIt)); + if (aShp->isEdge()) { + aResObj = (*aIt); + aCurve = std::shared_ptr(new GeomAPI_Curve(aShp)); + break; + } + } + if (aCurve.get()) { + double aStart = aCurve->startParam(); + double aEnd = aCurve->endParam(); + GeomCirclePtr aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurve)); + double aParam; + if (aCircle->parameter(thePnt, 1.e-4, aParam) && (aParam >= aStart) && (aParam <= aEnd)) + aList.push_back(aResObj); + } + } + } return aList; } @@ -219,16 +245,31 @@ gp_Pnt SketcherPrs_PositionMgr::getPointPosition( ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs, double theStep, GeomPointPtr thePnt) { - TColGeom_SequenceOfCurve aCurves = getCurves(thePnt, thePrs); + std::list aCurves = getCurves(thePnt, thePrs); gp_Pnt aP = thePnt->impl(); - gp_Vec aVec1 = getVector(theLine, thePrs->plane()->dirX(), aP); + //gp_Vec aVec1 = getVector(theLine, thePrs->plane()->dirX(), aP); + std::list aVectors; + std::list::const_iterator aItCurv; + for (aItCurv = aCurves.cbegin(); aItCurv != aCurves.cend(); aItCurv++) { + ObjectPtr aObject = (*aItCurv); + gp_Vec aVec = getVector(aObject, thePrs->plane()->dirX(), aP); + aVectors.push_back(aVec); + } + gp_Vec aBase = getVector(theLine, thePrs->plane()->dirX(), aP); + std::list aAngles; + std::list::const_iterator aItVec; + for (aItVec = aVectors.cbegin(); aItVec != aVectors.cend(); aItVec++) { + gp_Vec aVec = (*aItVec); + double aAngle = aBase.Angle(aVec); + aAngles.push_back(aAngle); + } // Compute shifting vector for a one symbol - gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl()); - aShift.Normalize(); - aShift.Multiply(theStep * 1.5); - aP.Translate(aShift); + //gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl()); + //aShift.Normalize(); + //aShift.Multiply(theStep * 1.5); + //aP.Translate(aShift); return aP; } diff --git a/src/SketcherPrs/SketcherPrs_Rigid.cpp b/src/SketcherPrs/SketcherPrs_Rigid.cpp index 3ce84501c..88ad963b7 100644 --- a/src/SketcherPrs/SketcherPrs_Rigid.cpp +++ b/src/SketcherPrs/SketcherPrs_Rigid.cpp @@ -51,8 +51,9 @@ static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Rigid::SketcherPrs_Rigid(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Rigid.h b/src/SketcherPrs/SketcherPrs_Rigid.h index c1aaf2fe0..e35045ab7 100644 --- a/src/SketcherPrs/SketcherPrs_Rigid.h +++ b/src/SketcherPrs/SketcherPrs_Rigid.h @@ -38,8 +38,10 @@ class SketcherPrs_Rigid: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Rigid(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane); diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index 2f75d8519..9e91f3ff4 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -119,8 +119,11 @@ std::map SketcherPrs_SymbolPrs::myIconsM SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane), myIsCustomColor(false) + : AIS_InteractiveObject(), myConstraint(theConstraint), + myPlane(thePlane), myIsCustomColor(false), + mySketcher(theSketcher) { SetAutoHilight(Standard_False); } @@ -414,9 +417,3 @@ void SketcherPrs_SymbolPrs::BoundingBox(Bnd_Box& theBndBox) theBndBox.Update (aTmpBox.CornerMin().x(), aTmpBox.CornerMin().y(), aTmpBox.CornerMin().z(), aTmpBox.CornerMax().x(), aTmpBox.CornerMax().y(), aTmpBox.CornerMax().z()); } - -//********************************************************************************* -CompositeFeaturePtr SketcherPrs_SymbolPrs::sketcher() const -{ - return ModelAPI_Tools::compositeOwner(FeaturePtr(myConstraint)); -} \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index c1cf2b554..5d28c1dd1 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -56,6 +56,7 @@ public: /// \param theConstraint a constraint feature /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane); virtual ~SketcherPrs_SymbolPrs(); @@ -78,7 +79,7 @@ public: Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; } /// Returns Sketcher object (owner of the constraint) - Standard_EXPORT CompositeFeaturePtr sketcher() const; + Standard_EXPORT ModelAPI_CompositeFeature* sketcher() const { return mySketcher; } /// Return array of points where symbols will be placed const Handle(Graphic3d_ArrayOfPoints)& pointsArray() const { return myPntArray; } @@ -147,6 +148,9 @@ protected: /// Constraint feature ModelAPI_Feature* myConstraint; + /// Sketcher feature + ModelAPI_CompositeFeature* mySketcher; + /// Plane of the current sketcher std::shared_ptr myPlane; diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp index 017e5fc64..8e10430b3 100644 --- a/src/SketcherPrs/SketcherPrs_Tangent.cpp +++ b/src/SketcherPrs/SketcherPrs_Tangent.cpp @@ -39,8 +39,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Tangent, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Tangent::SketcherPrs_Tangent(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } diff --git a/src/SketcherPrs/SketcherPrs_Tangent.h b/src/SketcherPrs/SketcherPrs_Tangent.h index be320a54d..6da05ce52 100644 --- a/src/SketcherPrs/SketcherPrs_Tangent.h +++ b/src/SketcherPrs/SketcherPrs_Tangent.h @@ -37,8 +37,10 @@ class SketcherPrs_Tangent: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch Standard_EXPORT SketcherPrs_Tangent(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane); DEFINE_STANDARD_RTTIEXT(SketcherPrs_Tangent, SketcherPrs_SymbolPrs) diff --git a/src/SketcherPrs/SketcherPrs_Transformation.cpp b/src/SketcherPrs/SketcherPrs_Transformation.cpp index a409bcc94..ed54c1258 100644 --- a/src/SketcherPrs/SketcherPrs_Transformation.cpp +++ b/src/SketcherPrs/SketcherPrs_Transformation.cpp @@ -42,9 +42,10 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Transformation, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, bool isTranslation) - : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane), myIsTranslation(isTranslation) { } diff --git a/src/SketcherPrs/SketcherPrs_Transformation.h b/src/SketcherPrs/SketcherPrs_Transformation.h index ed733b0be..e68397ff4 100644 --- a/src/SketcherPrs/SketcherPrs_Transformation.h +++ b/src/SketcherPrs/SketcherPrs_Transformation.h @@ -37,9 +37,11 @@ class SketcherPrs_Transformation: public SketcherPrs_SymbolPrs public: /// Constructor /// \param theConstraint a constraint feature + /// \param theSketcher a sketcher object /// \param thePlane a coordinate plane of current sketch /// \param isTranslation a flag is it translation or rotation Standard_EXPORT SketcherPrs_Transformation(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane, bool isTranslation);