Salome HOME
It replaces direct names of constraints to the specific kind.
authornds <natalia.donis@opencascade.com>
Wed, 4 Jun 2014 10:07:49 +0000 (14:07 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 4 Jun 2014 10:07:49 +0000 (14:07 +0400)
16 files changed:
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationConstraint.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_Presentation.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index 149c5d8e8acfee249ccac3bfa1ed843b505252c5..aa63b63e75c2ccbbfcdb3099f6fba354b5f420ef 100644 (file)
@@ -404,7 +404,7 @@ void PartSet_Module::visualizePreview(boost::shared_ptr<ModelAPI_Feature> 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);
index 6fc31b709573ae84597c99322e96bb8a4537eee0..0925b4fe0e5ccc9bfd9cf405df7c5feffe653960 100644 (file)
@@ -8,6 +8,9 @@
 #include "PartSet.h"
 
 #include <PartSet_OperationSketchBase.h>
+
+#include <SketchPlugin_ConstraintLength.h>
+
 #include <QObject>
 
 /*!
@@ -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
index 46534645da19c882761505243ea0c81149eeb772..cd7e1497a926926f16fc37200eb542e726215a14 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
 
 #include <GeomDataAPI_Point2D.h>
 
@@ -303,7 +304,7 @@ void PartSet_OperationSketchLine::createConstraint(boost::shared_ptr<GeomDataAPI
                                                    boost::shared_ptr<GeomDataAPI_Point2D> thePoint2)
 {
   boost::shared_ptr<ModelAPI_Document> aDoc = document();
-  boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature("SketchConstraintCoincidence");
+  boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature(SKETCH_CONSTRAINT_COINCIDENCE_KIND);
 
   if (sketch()) {
     boost::shared_ptr<SketchPlugin_Feature> aSketch = 
index e37e869d988fe2a602c42921769e9dd979af8dec..78d47b58e4bf227904557d6d0c2dbd07f151a188 100644 (file)
@@ -15,6 +15,7 @@
 #include <SketchPlugin_Sketch.h>
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Constraint.h>
+#include <SketchPlugin_ConstraintLength.h>
 
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_LengthDimension.hxx>
@@ -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);
index f5f2fa23abaf1e234001286f331970cf3d2574c0..3286cff4218506c53690ae23699c9022221cb905 100644 (file)
@@ -9,6 +9,9 @@
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
 
+/// 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()
index bfa5db79e61597ffb19171d5ad34f41ac40a9862..dcb0a3c792e4d9a160110fa0c0ff227b79589ca7 100644 (file)
@@ -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;}
index ac075b770349d380f819e58e30685ccb2ad1a62c..5da46cf8801ae0f1e8f1b3b9d0b32a5e957bd57c 100644 (file)
@@ -10,6 +10,8 @@
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
+/// 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() 
index 9e9874400a39f365e57059d7440e08049126a6b9..1a90e2dd3c5516c3cb585036c0b284d3d074c2cb 100644 (file)
@@ -10,6 +10,8 @@
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
+/// 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() 
index 8bd6eb8f2bdf39c1d386da56e0b0e0802e5d79e5..bc614e137ad3bf22c24931359d5763635e762cf4 100644 (file)
@@ -10,6 +10,8 @@
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
+/// 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() 
index ed45ba7bf20f5c9f823643feaa15ea55852cde5e..ac209b68fd75988661bfdccae9418d0e18234a30 100644 (file)
@@ -9,6 +9,8 @@
 #include <SketchPlugin_Sketch.h>
 #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() 
index b5cc31ccb66554c73c628120ac0c592bf9362f25..475c330849c3c35095878230876cc22493e2cd16 100644 (file)
@@ -9,6 +9,8 @@
 #include <SketchPlugin_Sketch.h>
 #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() 
index d292712b8f57177f8570bf07a2ed11815c58bb24..bdfaa42974ee3885a7d44b6890c4e3f74b2eea99 100644 (file)
@@ -9,6 +9,9 @@
 #include <SketchPlugin_Sketch.h>
 #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() 
index 1eec1993796fa34d38ebf35161b79c189b93523f..7f75377f2af0d507a8ffcb8df389e672844d7cac 100644 (file)
@@ -38,22 +38,22 @@ boost::shared_ptr<ModelAPI_Feature> SketchPlugin_Plugin::createFeature(string th
   else if (theFeatureID == SKETCH_CIRCLE_KIND) {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Circle);
   }
-  else if (theFeatureID == "SketchConstraintCoincidence") {
+  else if (theFeatureID == SKETCH_CONSTRAINT_COINCIDENCE_KIND) {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintCoincidence);
   }
-  else if (theFeatureID == "SketchConstraintDistance") {
+  else if (theFeatureID == SKETCH_CONSTRAINT_DISTANCE_KIND) {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintDistance);
   }
-  else if (theFeatureID == "SketchConstraintLength") {
+  else if (theFeatureID == SKETCH_CONSTRAINT_LENGTH_KIND) {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintLength);
   }
-  else if (theFeatureID == "SketchConstraintParallel") {
+  else if (theFeatureID == SKETCH_CONSTRAINT_PARALLEL_KIND) {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintParallel);
   }
-  else if (theFeatureID == "SketchConstraintPerpendicular") {
+  else if (theFeatureID == SKETCH_CONSTRAINT_PERPENDICULAR_KIND) {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintPerpendicular);
   }
-  else if (theFeatureID == "SketchConstraintRadius") {
+  else if (theFeatureID == SKETCH_CONSTRAINT_RADIUS_KIND) {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintRadius);
   }
   // feature of such kind is not found
index e03c64655435d1ee428e86843993110de1f3ede7..d4f55e00d1ac4db93bdfe0c516ae0b49316849e0 100644 (file)
@@ -8,6 +8,12 @@
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintRadius.h>
 
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_Data.h>
@@ -87,7 +93,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for distance between point and another entity
-  if (aConstraintKind.compare("SketchConstraintDistance") == 0)
+  if (aConstraintKind.compare(SKETCH_CONSTRAINT_DISTANCE_KIND) == 0)
   {
     int aNbPoints = 0;
     int aNbEntities = 0;
@@ -143,7 +149,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for the given length of a line
-  if (aConstraintKind.compare("SketchConstraintLength") == 0)
+  if (aConstraintKind.compare(SKETCH_CONSTRAINT_LENGTH_KIND) == 0)
   {
     int aNbLines = 0;
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
@@ -166,8 +172,8 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for two parallel/perpendicular lines
-  bool isParallel = (aConstraintKind.compare("SketchConstraintParallel") == 0);
-  bool isPerpendicular = (aConstraintKind.compare("SketchConstraintPerpendicular") == 0);
+  bool isParallel = (aConstraintKind.compare(SKETCH_CONSTRAINT_PARALLEL_KIND) == 0);
+  bool isPerpendicular = (aConstraintKind.compare(SKETCH_CONSTRAINT_PERPENDICULAR_KIND) == 0);
   if (isParallel || isPerpendicular)
   {
     int aNbEntities = 2; // lines in SolveSpace constraints should started from CONSTRAINT_ATTR_ENTITY_C attribute
@@ -191,7 +197,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for radius of a circle or an arc of circle
-  if (aConstraintKind.compare("SketchConstraintRadius") == 0)
+  if (aConstraintKind.compare(SKETCH_CONSTRAINT_RADIUS_KIND) == 0)
   {
     int aNbEntities = 2; // lines in SolveSpace constraints should started from CONSTRAINT_ATTR_ENTITY_C attribute
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
@@ -202,7 +208,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         );
       if (!anAttr || !anAttr->isFeature()) 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;
index ab8e64ea20383e8f639cc236fcd05f2f01fa98aa..d349e78b97049fbd22fd6bf8238dfadd85e6a8cb 100644 (file)
@@ -15,6 +15,8 @@
 #include <Model_Events.h>
 
 #include <SketchPlugin_Constraint.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
 
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_Circle.h>
@@ -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<ModelAPI_Data> 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<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::reverse_iterator
         aCopyIter = aConstrIter++;
index 538f5f9cff5a4f9b226bc06d1cbd9d41af015148..dd71f00f193afa2de0616169d35ca282bcfc5945 100644 (file)
@@ -271,7 +271,7 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin
     anAttrList.push_back(CIRCLE_ATTR_RADIUS);
   }
   // Arc
-  else if (aFeatureKind.compare("SketchArc") == 0)
+  else if (aFeatureKind.compare(SKETCH_ARC_KIND) == 0)
   {
     anAttrList.push_back(ARC_ATTR_CENTER);
     anAttrList.push_back(ARC_ATTR_START);