From e884d8b11e3cde0d41d80bb39e3108f4725c3917 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 4 Jun 2014 14:07:49 +0400 Subject: [PATCH] It replaces direct names of constraints to the specific kind. --- src/PartSet/PartSet_Module.cpp | 2 +- src/PartSet/PartSet_OperationConstraint.h | 5 ++++- src/PartSet/PartSet_OperationSketchLine.cpp | 3 ++- src/PartSet/PartSet_Presentation.cpp | 3 ++- src/SketchPlugin/SketchPlugin_Arc.h | 5 ++++- src/SketchPlugin/SketchPlugin_Constraint.h | 4 ---- .../SketchPlugin_ConstraintCoincidence.h | 4 +++- .../SketchPlugin_ConstraintDistance.h | 4 +++- .../SketchPlugin_ConstraintLength.h | 4 +++- .../SketchPlugin_ConstraintParallel.h | 4 +++- .../SketchPlugin_ConstraintPerpendicular.h | 4 +++- .../SketchPlugin_ConstraintRadius.h | 5 ++++- src/SketchPlugin/SketchPlugin_Plugin.cpp | 12 ++++++------ src/SketchSolver/SketchSolver_Constraint.cpp | 18 ++++++++++++------ .../SketchSolver_ConstraintGroup.cpp | 8 +++++--- .../SketchSolver_ConstraintManager.cpp | 2 +- 16 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 149c5d8e8..aa63b63e7 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -404,7 +404,7 @@ void PartSet_Module::visualizePreview(boost::shared_ptr theFea aDisplayer->getAISObject(theFeature)); int aSelectionMode = -1; - if (theFeature->getKind() == "SketchConstraintLength") { + if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) { aSelectionMode = AIS_DSM_Text; } aDisplayer->redisplay(theFeature, anAIS, aSelectionMode, false); diff --git a/src/PartSet/PartSet_OperationConstraint.h b/src/PartSet/PartSet_OperationConstraint.h index 6fc31b709..0925b4fe0 100644 --- a/src/PartSet/PartSet_OperationConstraint.h +++ b/src/PartSet/PartSet_OperationConstraint.h @@ -8,6 +8,9 @@ #include "PartSet.h" #include + +#include + #include /*! @@ -20,7 +23,7 @@ class PARTSET_EXPORT PartSet_OperationConstraint : public PartSet_OperationSketc public: /// Returns the operation type key - static std::string Type() { return "SketchConstraintLength"; } + static std::string Type() { return SKETCH_CONSTRAINT_LENGTH_KIND; } public: /// Constructor diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 46534645d..cd7e1497a 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -9,6 +9,7 @@ #include #include +#include #include @@ -303,7 +304,7 @@ void PartSet_OperationSketchLine::createConstraint(boost::shared_ptr thePoint2) { boost::shared_ptr aDoc = document(); - boost::shared_ptr aFeature = aDoc->addFeature("SketchConstraintCoincidence"); + boost::shared_ptr aFeature = aDoc->addFeature(SKETCH_CONSTRAINT_COINCIDENCE_KIND); if (sketch()) { boost::shared_ptr aSketch = diff --git a/src/PartSet/PartSet_Presentation.cpp b/src/PartSet/PartSet_Presentation.cpp index e37e869d9..78d47b58e 100644 --- a/src/PartSet/PartSet_Presentation.cpp +++ b/src/PartSet/PartSet_Presentation.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,7 @@ Handle(AIS_InteractiveObject) PartSet_Presentation::createPresentation( { Handle(AIS_InteractiveObject) anAIS; - if (theFeature->getKind() == "SketchConstraintLength") + if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) anAIS = createSketchConstraintLength(theFeature, theSketch, thePrevPrs); else { anAIS = createFeature(theFeature, theShape, thePrevPrs); diff --git a/src/SketchPlugin/SketchPlugin_Arc.h b/src/SketchPlugin/SketchPlugin_Arc.h index f5f2fa23a..3286cff42 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.h +++ b/src/SketchPlugin/SketchPlugin_Arc.h @@ -9,6 +9,9 @@ #include #include +/// Arc feature kind +const std::string SKETCH_ARC_KIND("SketchArc"); + /// Central 2D point of the circle which contains the arc const std::string ARC_ATTR_CENTER("ArcCenter"); /// Start 2D point of the arc @@ -25,7 +28,7 @@ class SketchPlugin_Arc: public SketchPlugin_Feature public: /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchArc"; return MY_KIND;} + {static std::string MY_KIND = SKETCH_ARC_KIND; return MY_KIND;} /// Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/SketchPlugin/SketchPlugin_Constraint.h b/src/SketchPlugin/SketchPlugin_Constraint.h index bfa5db79e..dcb0a3c79 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.h +++ b/src/SketchPlugin/SketchPlugin_Constraint.h @@ -49,10 +49,6 @@ const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = class SketchPlugin_Constraint: public SketchPlugin_Feature { public: - /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraint"; return MY_KIND;} - /// \brief Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;} diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index ac075b770..5da46cf88 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@ -10,6 +10,8 @@ #include #include +/// Coincidence constraint kind +const std::string SKETCH_CONSTRAINT_COINCIDENCE_KIND("SketchConstraintCoincidence"); /** \class SketchPlugin_ConstraintCoincidence * \ingroup DataModel @@ -23,7 +25,7 @@ class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint public: /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraintCoincidence"; return MY_KIND;} + {static std::string MY_KIND = SKETCH_CONSTRAINT_COINCIDENCE_KIND; return MY_KIND;} /// \brief Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 9e9874400..1a90e2dd3 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -10,6 +10,8 @@ #include #include +/// Distance constraint kind +const std::string SKETCH_CONSTRAINT_DISTANCE_KIND("SketchConstraintDistance"); /** \class SketchPlugin_ConstraintDistance * \ingroup DataModel @@ -24,7 +26,7 @@ class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint public: /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraintDistance"; return MY_KIND;} + {static std::string MY_KIND = SKETCH_CONSTRAINT_DISTANCE_KIND; return MY_KIND;} /// \brief Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.h b/src/SketchPlugin/SketchPlugin_ConstraintLength.h index 8bd6eb8f2..bc614e137 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@ -10,6 +10,8 @@ #include #include +/// Length constraint kind +const std::string SKETCH_CONSTRAINT_LENGTH_KIND("SketchConstraintLength"); /** \class SketchPlugin_ConstraintLength * \ingroup DataModel @@ -23,7 +25,7 @@ class SketchPlugin_ConstraintLength: public SketchPlugin_Constraint public: /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraintLength"; return MY_KIND;} + {static std::string MY_KIND = SKETCH_CONSTRAINT_LENGTH_KIND; return MY_KIND;} /// \brief Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h index ed45ba7bf..ac209b68f 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h @@ -9,6 +9,8 @@ #include #include "SketchPlugin_Constraint.h" +/// Parallel constraint kind +const std::string SKETCH_CONSTRAINT_PARALLEL_KIND("SketchConstraintParallel"); /** \class SketchPlugin_ConstraintParallel * \ingroup DataModel @@ -22,7 +24,7 @@ class SketchPlugin_ConstraintParallel: public SketchPlugin_Constraint public: /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraintParallel"; return MY_KIND;} + {static std::string MY_KIND = SKETCH_CONSTRAINT_PARALLEL_KIND; return MY_KIND;} /// \brief Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h index b5cc31ccb..475c33084 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h @@ -9,6 +9,8 @@ #include #include "SketchPlugin_Constraint.h" +/// Perpendicular constraint kind +const std::string SKETCH_CONSTRAINT_PERPENDICULAR_KIND("SketchConstraintPerpendicular"); /** \class SketchPlugin_ConstraintPerpendicular * \ingroup DataModel @@ -22,7 +24,7 @@ class SketchPlugin_ConstraintPerpendicular: public SketchPlugin_Constraint public: /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraintPerpendicular"; return MY_KIND;} + {static std::string MY_KIND = SKETCH_CONSTRAINT_PERPENDICULAR_KIND; return MY_KIND;} /// \brief Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h index d292712b8..bdfaa4297 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h @@ -9,6 +9,9 @@ #include #include "SketchPlugin_Constraint.h" +/// Radius constraint kind +const std::string SKETCH_CONSTRAINT_RADIUS_KIND("SketchConstraintRadius"); + /** \class SketchPlugin_ConstraintRadius * \ingroup DataModel @@ -23,7 +26,7 @@ class SketchPlugin_ConstraintRadius: public SketchPlugin_Constraint public: /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "SketchConstraintRadius"; return MY_KIND;} + {static std::string MY_KIND = SKETCH_CONSTRAINT_RADIUS_KIND; return MY_KIND;} /// \brief Returns to which group in the document must be added feature SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 1eec19937..7f75377f2 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -38,22 +38,22 @@ boost::shared_ptr SketchPlugin_Plugin::createFeature(string th else if (theFeatureID == SKETCH_CIRCLE_KIND) { return boost::shared_ptr(new SketchPlugin_Circle); } - else if (theFeatureID == "SketchConstraintCoincidence") { + else if (theFeatureID == SKETCH_CONSTRAINT_COINCIDENCE_KIND) { return boost::shared_ptr(new SketchPlugin_ConstraintCoincidence); } - else if (theFeatureID == "SketchConstraintDistance") { + else if (theFeatureID == SKETCH_CONSTRAINT_DISTANCE_KIND) { return boost::shared_ptr(new SketchPlugin_ConstraintDistance); } - else if (theFeatureID == "SketchConstraintLength") { + else if (theFeatureID == SKETCH_CONSTRAINT_LENGTH_KIND) { return boost::shared_ptr(new SketchPlugin_ConstraintLength); } - else if (theFeatureID == "SketchConstraintParallel") { + else if (theFeatureID == SKETCH_CONSTRAINT_PARALLEL_KIND) { return boost::shared_ptr(new SketchPlugin_ConstraintParallel); } - else if (theFeatureID == "SketchConstraintPerpendicular") { + else if (theFeatureID == SKETCH_CONSTRAINT_PERPENDICULAR_KIND) { return boost::shared_ptr(new SketchPlugin_ConstraintPerpendicular); } - else if (theFeatureID == "SketchConstraintRadius") { + else if (theFeatureID == SKETCH_CONSTRAINT_RADIUS_KIND) { return boost::shared_ptr(new SketchPlugin_ConstraintRadius); } // feature of such kind is not found diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index e03c64655..d4f55e00d 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -8,6 +8,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -87,7 +93,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptrisFeature()) continue; const std::string& aKind = anAttr->feature()->getKind(); - if (aKind.compare(SKETCH_CIRCLE_KIND) == 0 || aKind.compare("SketchArc") == 0) + if (aKind.compare(SKETCH_CIRCLE_KIND) == 0 || aKind.compare(SKETCH_ARC_KIND) == 0) { myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr]; continue; diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index ab8e64ea2..d349e78b9 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -15,6 +15,8 @@ #include #include +#include +#include #include #include @@ -186,7 +188,7 @@ bool SketchSolver_ConstraintGroup::changeConstraint( if (!aConstrAttr) continue; // For the length constraint the start and end points of the line should be added to the entities list instead of line - if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare("SketchConstraintLength") == 0) + if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SKETCH_CONSTRAINT_LENGTH_KIND) == 0) { boost::shared_ptr aData = aConstrAttr->feature()->data(); aConstrEnt[indAttr] = changeEntity(aData->attribute(LINE_ATTR_START)); @@ -362,7 +364,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( return aCircleEntity.h; } // Arc - else if (aFeatureKind.compare("SketchArc") == 0) + else if (aFeatureKind.compare(SKETCH_ARC_KIND) == 0) { Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(ARC_ATTR_CENTER)); Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(ARC_ATTR_START)); @@ -744,7 +746,7 @@ bool SketchSolver_ConstraintGroup::updateGroup() { if (!aConstrIter->first->data()->isValid()) { - if (aConstrIter->first->getKind().compare("SketchConstraintCoincidence") == 0) + if (aConstrIter->first->getKind().compare(SKETCH_CONSTRAINT_COINCIDENCE_KIND) == 0) isCCRemoved = true; std::map, Slvs_hConstraint>::reverse_iterator aCopyIter = aConstrIter++; diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 538f5f9cf..dd71f00f1 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -271,7 +271,7 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr