]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Refactoring: static constants are replaced by inline functions in:
authorsbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 12:11:05 +0000 (16:11 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 12:11:05 +0000 (16:11 +0400)
Affected headers:
* ModelAPI_Document.h
* SketchPlugin_Arc.h
* SketchPlugin_Line.h
* SketchPlugin_Circle.h
* SketchPlugin_Constraint.h
* SketchPlugin_ConstraintDistance.h
* SketchPlugin_ConstraintParallel.h
* SketchPlugin_ConstraintLength.h
* SketchPlugin_ConstraintRadius.h
* SketchPlugin_ConstraintPerpendicular.h
* SketchPlugin_ConstraintCoincidence.h
* PartSetPlugin_Part.h
* PartSetPlugin_Duplicate.h
* SketchPlugin_Sketch.h
* SketchPlugin_Point.h

54 files changed:
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/Model/Model_Document.cpp
src/Model/Model_Object.h
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_Document.h
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_TestOCC.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.h
src/PartSetPlugin/PartSetPlugin_Part.cpp
src/PartSetPlugin/PartSetPlugin_Part.h
src/PartSetPlugin/PartSetPlugin_Plugin.cpp
src/PartSetPlugin/PartSetPlugin_Remove.cpp
src/PartSetPlugin/PartSetPlugin_Remove.h
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_Workshop.cpp

index 328dde5f0e5f85aa35807be05e49c2fc86d5b460..0e8fc0b13b19950298c51601d272d41ae547b4e3 100644 (file)
@@ -20,15 +20,15 @@ FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
 
 void FeaturesPlugin_Extrusion::initAttributes()
 {
-  data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type());
-  data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type());
-  data()->addAttribute(EXTRUSION_REVERSE, ModelAPI_AttributeBoolean::type());
+  data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeReference::type());
+  data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::type());
+  data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
 }
 
 void FeaturesPlugin_Extrusion::execute()
 {
   boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
   if (!aFaceRef)
     return;
   FeaturePtr aFaceFeature = aFaceRef->value();
@@ -38,8 +38,8 @@ void FeaturesPlugin_Extrusion::execute()
   if (!aFace)
     return;
 
-  double aSize = data()->real(EXTRUSION_SIZE)->value();
-  if (data()->boolean(EXTRUSION_REVERSE)->value())
+  double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
+  if (data()->boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value())
     aSize = -aSize;
   data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
 }
index 95c8f98ae844b07233b136ac88f02c6fa9c2c292..cac857f15052ab652ee56ec593453286fca8519f 100644 (file)
@@ -8,25 +8,37 @@
 #include "FeaturesPlugin.h"
 #include <ModelAPI_Feature.h>
 
-/// Extrusion kind
-const std::string FEATURES_EXTRUSION_KIND("Extrusion");
-
-/// attribute name of referenced face
-const std::string EXTRUSION_FACE = "extrusion_face";
-
-/// attribute name of extrusion size
-const std::string EXTRUSION_SIZE = "extrusion_size";
-
-/// attribute name of reverse direction
-const std::string EXTRUSION_REVERSE = "extrusion_reverse";
-
-
 class FeaturesPlugin_Extrusion: public ModelAPI_Feature
 {
 public:
+  /// Extrusion kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_EXTRUSION_ID("Extrusion");
+    return MY_EXTRUSION_ID;
+  }
+  /// attribute name of referenced face
+  inline static const std::string& FACE_ID()
+  {
+    static const std::string MY_FACE_ID("FeaturesPlugin_Extrusion::FACE_ID()");
+    return MY_FACE_ID;
+  }
+  /// attribute name of extrusion size
+  inline static const std::string& SIZE_ID()
+  {
+    static const std::string MY_SIZE_ID("FeaturesPlugin_Extrusion::SIZE_ID()");
+    return MY_SIZE_ID;
+  }
+    /// attribute name of reverse direction
+  inline static const std::string& REVERSE_ID()
+  {
+    static const std::string MY_REVERSE_ID("FeaturesPlugin_Extrusion::REVERSE_ID()");
+    return MY_REVERSE_ID;
+  }
+
   /// Returns the kind of a feature
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind() 
-  { static std::string MY_KIND = FEATURES_EXTRUSION_KIND; return MY_KIND; }
+  { static std::string MY_KIND = FeaturesPlugin_Extrusion::ID(); return MY_KIND; }
 
   /// Returns to which group in the document must be added feature
   FEATURESPLUGIN_EXPORT virtual const std::string& getGroup() 
index 1c9273d5f18b6a37ccfa75889ba47f18745c6310..1ae9381cd9253ab3b3bb5792bd65b1bd8384a9fa 100644 (file)
@@ -17,7 +17,7 @@ FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
 
 FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
 {
-  if (theFeatureID == FEATURES_EXTRUSION_KIND) {
+  if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
     return FeaturePtr(new FeaturesPlugin_Extrusion);
   }
   // feature of such kind is not found
index 95cc5a9d1a348a8220f6794db21279fe3d04ac2a..1c70153892a95e891c58a31590a38bc7f4556d7c 100644 (file)
@@ -354,7 +354,7 @@ void Model_Document::addFeature(const FeaturePtr theFeature)
 
   boost::shared_ptr<ModelAPI_Document> aThis = 
     Model_Application::getApplication()->getDocument(myID);
-  TDF_Label aFeaturesLab = groupLabel(FEATURES_GROUP);
+  TDF_Label aFeaturesLab = groupLabel(ModelAPI_Document::FEATURES_GROUP());
   TDF_Label aFeatureLab = aFeaturesLab.NewChild();
 
   // organize feature and data objects
@@ -440,7 +440,7 @@ void Model_Document::removeFeature(FeaturePtr theFeature)
   // erase all attributes under the label of feature
   aFeatureLabel.ForgetAllAttributes();
   // remove it from the references array
-  RemoveFromRefArray(groupLabel(FEATURES_GROUP), aData->label());
+  RemoveFromRefArray(groupLabel(ModelAPI_Document::FEATURES_GROUP()), aData->label());
 
   // event: feature is added
   ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), theFeature->getGroup());
@@ -477,7 +477,7 @@ FeaturePtr Model_Document::feature(
       TDF_Label aFeatureLab = aRefs->Value(theIndex);
       FeaturePtr aFeature = feature(aFeatureLab);
 
-      if (theGroupID == FEATURES_GROUP || isOperation) { // just returns the feature from the history
+      if (theGroupID == ModelAPI_Document::FEATURES_GROUP() || isOperation) { // just returns the feature from the history
         return aFeature;
       } else { // create a new object from the group to return it
         Handle(TDataStd_Name) aName; // name of the object
@@ -537,7 +537,7 @@ void Model_Document::setUniqueName(FeaturePtr theFeature)
   string aName; // result
   // iterate all features but also iterate group of this feature if object is not in history
   list<string> aGroups;
-  aGroups.push_back(FEATURES_GROUP);
+  aGroups.push_back(ModelAPI_Document::FEATURES_GROUP());
   if (!theFeature->isInHistory()) {
     aGroups.push_back(theFeature->getGroup());
   }
@@ -588,7 +588,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
   // update features
   vector<FeaturePtr >::iterator aFIter = myFeatures.begin();
   // and in parallel iterate labels of features
-  TDF_ChildIDIterator aFLabIter(groupLabel(FEATURES_GROUP), TDataStd_Comment::GetID());
+  TDF_ChildIDIterator aFLabIter(groupLabel(ModelAPI_Document::FEATURES_GROUP()), TDataStd_Comment::GetID());
   while(aFIter != myFeatures.end() || aFLabIter.More()) {
     static const int INFINITE_TAG = INT_MAX; // no label means that it exists somwhere in infinite
     int aFeatureTag = INFINITE_TAG; 
@@ -605,7 +605,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
       aFIter = myFeatures.erase(aFIter);
       // event: model is updated
       if (aFeature->isInHistory()) {
-        ModelAPI_EventCreator::get()->sendDeleted(aThis, FEATURES_GROUP);
+        ModelAPI_EventCreator::get()->sendDeleted(aThis, ModelAPI_Document::FEATURES_GROUP());
       }
       ModelAPI_EventCreator::get()->sendDeleted(aThis, aFeature->getGroup());
     } else if (aDSTag < aFeatureTag) { // a new feature is inserted
index 73975bc28e24dc91130eca9172c0bd5ad0ee707d..1de923837a7444b5aec92c3148e3ee7a5fee3a9e 100644 (file)
@@ -35,7 +35,7 @@ public:
   MODEL_EXPORT virtual const std::string& getKind() {return myRef->getKind();}
 
   /// Returns to which group in the document must be added feature
-  MODEL_EXPORT virtual const std::string& getGroup() {return FEATURES_GROUP;}
+  MODEL_EXPORT virtual const std::string& getGroup() {return ModelAPI_Document::FEATURES_GROUP();}
 
   /// Returns document this feature belongs to
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
index 6c8bd6431d3d9a085d069f5791f9209105f176b2..2db098aea0193d9af8a0fef4dda8c50478eb6f1f 100644 (file)
@@ -34,9 +34,9 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   // iterate all features of features-documents to update them
   set<boost::shared_ptr<ModelAPI_Document> >::iterator aDIter = aDocs.begin();
   for(; aDIter != aDocs.end(); aDIter++) {
-    int aNbFeatures = (*aDIter)->size(FEATURES_GROUP);
+    int aNbFeatures = (*aDIter)->size(ModelAPI_Document::FEATURES_GROUP());
     for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = (*aDIter)->feature(FEATURES_GROUP, aFIndex);
+      boost::shared_ptr<ModelAPI_Feature> aFeature = (*aDIter)->feature(ModelAPI_Document::FEATURES_GROUP(), aFIndex);
       if (aFeature)
         updateFeature(aFeature);
     }
index 9070718b48974151d3b0a4ea2332f65438340f71..42ee9c3acd0859b54831af8e61a5caf6bf8128b6 100644 (file)
 
 class ModelAPI_Feature;
 
-/// Common groups identifiers
-/// Group of parameters
-static const std::string PARAMETERS_GROUP = "Parameters";
-/// Group of constructions
-static const std::string CONSTRUCTIONS_GROUP = "Construction";
-/// Group of parts
-static const std::string PARTS_GROUP = "Parts";
-/// All created fetaures of the document (a history)
-static const std::string FEATURES_GROUP = "Features";
-
 /**\class Model_Document
  * \ingroup DataModel
  * \brief Document for internal data structure of any object storage.
@@ -31,6 +21,32 @@ static const std::string FEATURES_GROUP = "Features";
 class ModelAPI_Document
 {
 public:
+  //! Common groups identifiers
+  //! Group of parameters
+  inline static const std::string& PARAMETERS_GROUP()
+  {
+    static const std::string MY_PARAMETERS_GROUP = "Parameters";
+    return MY_PARAMETERS_GROUP;
+  }
+  //! Group of constructions
+  inline static const std::string& CONSTRUCTIONS_GROUP()
+  {
+    static const std::string MY_CONSTRUCTIONS_GROUP = "Construction";
+    return MY_CONSTRUCTIONS_GROUP;
+  }
+  //! Group of parts
+  inline static const std::string& PARTS_GROUP()
+  {
+    static const std::string MY_PARTS_GROUP = "Parts";
+    return MY_PARTS_GROUP;
+  }
+  //! All created fetaures of the document (a history)
+  inline static const std::string& FEATURES_GROUP()
+  {
+    static const std::string MY_FEATURES_GROUP = "Features";
+    return MY_FEATURES_GROUP;
+  }
+
   //! Loads the OCAF document from the file.
   //! \param theFileName full name of the file to load
   //! \param theStudyID identifier of the SALOME study to associate with loaded file
index f9229d38324340d5935cf40df2893d900b73a91d..7b642812d32b10da0fc42a46b29a67afc4fd7125 100644 (file)
@@ -65,7 +65,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
     std::set<std::string>::const_iterator anIt = aGroups.begin(), aLast = aGroups.end();
     for (; anIt != aLast; anIt++) {
       std::string aGroup = *anIt;
-      if (aGroup.compare(SKETCH_KIND) == 0) { // Update only Sketch group
+      if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group
         myModule->workshop()->displayer()->eraseDeletedFeatures();
         myModule->updateCurrentPreview(aGroup);
       }
index 2824363e1d4d8b3a9c3f7039774e30b880546eb3..5f903b0eded4d0f8adf70a9ecf6eccd4dc385ae7 100644 (file)
@@ -510,7 +510,7 @@ void PartSet_Module::editFeature(FeaturePtr theFeature)
   if (!theFeature)
     return;
 
-//  if (theFeature->getKind() == SKETCH_KIND) {
+//  if (theFeature->getKind() == SketchPlugin_Sketch::ID()) {
     FeaturePtr aFeature = theFeature;
     if (XGUI_Tools::isModelObject(aFeature)) {
       ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
index d1d5d409b42d33d6fef7bc2c638862227450ed61..9b7039ae33c7ce34acbd1fca91ac388d1ea95135 100644 (file)
@@ -54,15 +54,15 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
 
 bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
 {
-  return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND ||
-         theId == SKETCH_CIRCLE_KIND ||
-         theId == SKETCH_ARC_KIND ||
-         theId == SKETCH_CONSTRAINT_DISTANCE_KIND ||
-         theId == SKETCH_CONSTRAINT_LENGTH_KIND ||
-         theId == SKETCH_CONSTRAINT_RADIUS_KIND ||
-         theId == SKETCH_CONSTRAINT_PARALLEL_KIND ||
-         theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND ||
-         theId == SKETCH_CONSTRAINT_COINCIDENCE_KIND;
+  return theId == SketchPlugin_Line::ID() || theId == SketchPlugin_Point::ID() ||
+         theId == SketchPlugin_Circle::ID() ||
+         theId == SketchPlugin_Arc::ID() ||
+         theId == SketchPlugin_ConstraintDistance::ID() ||
+         theId == SketchPlugin_ConstraintLength::ID() ||
+         theId == SketchPlugin_ConstraintRadius::ID() ||
+         theId == SketchPlugin_ConstraintParallel::ID() ||
+         theId == SketchPlugin_ConstraintPerpendicular::ID() ||
+         theId == SketchPlugin_ConstraintCoincidence::ID();
 }
 
 bool PartSet_OperationFeatureCreate::canBeCommitted() const
@@ -138,7 +138,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
       {
         PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
         // move to selected line
-        if (feature()->getKind() == SKETCH_LINE_KIND) {
+        if (feature()->getKind() == SketchPlugin_Line::ID()) {
           //FeaturePtr aFeature = aPrs.feature();
           //projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
         }
index c6ad6130ecb2902f917ec9247192110e79d12a93..5782ca1ba5d974b38d26410b77c32d19e694f500 100644 (file)
@@ -142,9 +142,9 @@ void PartSet_OperationFeatureEdit::mouseDoubleClick(QMouseEvent* theEvent, Handl
       Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aFeaturePrs.owner());
       if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
         bool isValid;
-        double aValue = PartSet_Tools::featureValue(feature(), CONSTRAINT_ATTR_VALUE, isValid);
+        double aValue = PartSet_Tools::featureValue(feature(), SketchPlugin_Constraint::VALUE(), isValid);
         if (isValid) {
-          ModuleBase_WidgetEditor::editFeatureValue(feature(), CONSTRAINT_ATTR_VALUE);
+          ModuleBase_WidgetEditor::editFeatureValue(feature(), SketchPlugin_Constraint::VALUE());
           flushUpdated();
         }
       }
index 563caf21ca286697d7714ca8ac94f12cfcc2e13e..df4408dd58f345353a3b325464e3aa1a8c1a150c 100644 (file)
@@ -143,7 +143,7 @@ std::list<FeaturePtr> PartSet_OperationSketch::subFeatures() const
   if (!aData->isValid())
     return std::list<FeaturePtr>();
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
 
   return aRefList->list();
 }
@@ -175,7 +175,7 @@ bool PartSet_OperationSketch::hasSketchPlane() const
     boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
     AttributeDoublePtr anAttr;
     boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+      boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
     aHasPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
   }
   return aHasPlane;
@@ -212,16 +212,16 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
   boost::shared_ptr<GeomAPI_Dir> aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir)));
 
   boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   anOrigin->setValue(anOrigPnt);
   boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
   aNormal->setValue(aNormDir);
   boost::shared_ptr<GeomDataAPI_Dir> aDirX = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
   aDirX->setValue(aXDir);
   boost::shared_ptr<GeomDataAPI_Dir> aDirY = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
   aDirY->setValue(aYDir);
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
 
index eb0c8477542a5aaeb8e295da6ed4d3f8ced79c9a..bf8694bb580f7fc90747cf9fe39a3effbe16418b 100644 (file)
@@ -24,7 +24,7 @@ class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBas
   Q_OBJECT
 public:
   /// Returns the operation type key
-  static std::string Type() { return SKETCH_KIND; }
+  static std::string Type() { return SketchPlugin_Sketch::ID(); }
 
 public:
   /// Constructor
index f447f59660f3a1bd4894326893b3271874e5d482..aaa3c3c590a9b777ce65361c8e9571c080bf216e 100644 (file)
@@ -132,7 +132,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
   if (aPreviewOp) {
     // create a line
     boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
-    FeaturePtr aFeature = aDoc->addFeature(SKETCH_LINE_KIND);
+    FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_Line::ID());
     if (aFeature) // TODO: generate an error if feature was not created
       aFeature->execute();
 
@@ -140,8 +140,8 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
                         boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPreviewOp->sketch());
     aSketch->addSub(aFeature);
 
-    PartSet_Tools::setFeaturePoint(aFeature, 100, 100, LINE_ATTR_START);
-    PartSet_Tools::setFeaturePoint(aFeature, 150, 300, LINE_ATTR_END);
+    PartSet_Tools::setFeaturePoint(aFeature, 100, 100, SketchPlugin_Line::START_ID());
+    PartSet_Tools::setFeaturePoint(aFeature, 150, 300, SketchPlugin_Line::END_ID());
 
     boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
 
@@ -163,8 +163,8 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
     /*double aDelta = -200;
     for (int i = 0; i < 20; i++) {
       aDelta = aDelta - i*2;
-      PartSet_Tools::setFeaturePoint(aFeature, 100+aDelta, 200+aDelta, LINE_ATTR_START);
-      PartSet_Tools::setFeaturePoint(aFeature, 300+aDelta, 500+aDelta, LINE_ATTR_END);
+      PartSet_Tools::setFeaturePoint(aFeature, 100+aDelta, 200+aDelta, SketchPlugin_Line::START_ID());
+      PartSet_Tools::setFeaturePoint(aFeature, 300+aDelta, 500+aDelta, SketchPlugin_Line::END_ID());
 
       boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
       Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
@@ -199,8 +199,8 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
 
   myTestDelta = myTestDelta - 50;
   double aDelta = myTestDelta;
-  PartSet_Tools::setFeaturePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, LINE_ATTR_START);
-  PartSet_Tools::setFeaturePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, LINE_ATTR_END);
+  PartSet_Tools::setFeaturePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, SketchPlugin_Line::START_ID());
+  PartSet_Tools::setFeaturePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, SketchPlugin_Line::END_ID());
   boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
 
   boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
index aa3ac235adbfa32483ccfc0b404d306195136c0b..eb07e5baa11d0f0bd7e15eaaa5490e2726b058c1 100644 (file)
@@ -77,12 +77,12 @@ void PartSet_Tools::convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch,
   boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
 
   boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
 
   boost::shared_ptr<GeomDataAPI_Dir> aX = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> anY = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
 
   gp_Pnt anOriginPnt(anOrigin->x(), anOrigin->y(), anOrigin->z());
   gp_Vec aVec(anOriginPnt, thePoint);
@@ -100,7 +100,7 @@ void PartSet_Tools::convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch,
     anEyeVec.Normalize();
 
     boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
-                  boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+                  boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
     gp_Vec aNormalVec(aNormal->x(), aNormal->y(), aNormal->z());
 
     double aDen = anEyeVec * aNormalVec;
@@ -123,11 +123,11 @@ void PartSet_Tools::convertTo3D(const double theX, const double theY,
   boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
 
   boost::shared_ptr<GeomDataAPI_Point> aC = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aX = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aY = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
 
   boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(
     aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY));
@@ -238,7 +238,7 @@ void PartSet_Tools::createConstraint(FeaturePtr theSketch,
                                      boost::shared_ptr<GeomDataAPI_Point2D> thePoint2)
 {
   boost::shared_ptr<ModelAPI_Document> aDoc = document();
-  FeaturePtr aFeature = aDoc->addFeature(SKETCH_CONSTRAINT_COINCIDENCE_KIND);
+  FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_ConstraintCoincidence::ID());
 
   if (theSketch) {
     boost::shared_ptr<SketchPlugin_Feature> aSketch = 
@@ -249,11 +249,11 @@ void PartSet_Tools::createConstraint(FeaturePtr theSketch,
   boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
 
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   aRef1->setAttr(thePoint1);
 
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
   aRef2->setAttr(thePoint2);
 
   if (aFeature) // TODO: generate an error if feature was not created
@@ -275,7 +275,7 @@ void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
   // the constraint is created between the feature point and the found sketch point
   boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
 
   std::list<FeaturePtr > aFeatures = aRefList->list();
   std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
@@ -308,9 +308,9 @@ boost::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(FeaturePtr theSketch)
 
   boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
   boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
   aA = aNormal->x();
   aB = aNormal->y();
   aC = aNormal->z();
@@ -329,18 +329,18 @@ boost::shared_ptr<GeomAPI_Pnt> PartSet_Tools::point3D(
     return aPoint;
 
   boost::shared_ptr<GeomDataAPI_Point> aC = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(theSketch->data()->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aX = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theSketch->data()->attribute(SKETCH_ATTR_DIRX));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aY = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theSketch->data()->attribute(SKETCH_ATTR_DIRY));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
 
   return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir());
 }
 
 bool PartSet_Tools::isConstraintFeature(const std::string& theKind)
 {
-  return theKind == SKETCH_CONSTRAINT_DISTANCE_KIND ||
-         theKind == SKETCH_CONSTRAINT_LENGTH_KIND ||
-         theKind == SKETCH_CONSTRAINT_RADIUS_KIND;
+  return theKind == SketchPlugin_ConstraintDistance::ID() ||
+         theKind == SketchPlugin_ConstraintLength::ID() ||
+         theKind == SketchPlugin_ConstraintRadius::ID();
 }
index 9b6a47e162bf23a009d2b01782f5de71d035678c..726f6487b7a1d8810b02219b4885fb3efd9669aa 100644 (file)
@@ -17,9 +17,9 @@ PartSetPlugin_Duplicate::PartSetPlugin_Duplicate()
 void PartSetPlugin_Duplicate::initAttributes()
 {
   PartSetPlugin_Part::initAttributes();
-  data()->addAttribute(PART_DUPLICATE_ATTR_REF, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(PartSetPlugin_Duplicate::DOC_REF(), ModelAPI_AttributeRefAttr::type());
 
-  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = data()->refattr(PART_DUPLICATE_ATTR_REF);
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = data()->refattr(PartSetPlugin_Duplicate::DOC_REF());
   if (!aRef->attr()) { // create a copy: if not created yet attribute is not initialized
     boost::shared_ptr<ModelAPI_PluginManager> aPManager = ModelAPI_PluginManager::get();
     boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
@@ -27,13 +27,13 @@ void PartSetPlugin_Duplicate::initAttributes()
     for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
       aSource = boost::dynamic_pointer_cast<PartSetPlugin_Part>(
         aRoot->feature(getGroup(), a, true));
-      if (aSource->data()->docRef(PART_ATTR_DOC_REF)->value() == aPManager->currentDocument())
+      if (aSource->data()->docRef(PartSetPlugin_Part::DOC_REF())->value() == aPManager->currentDocument())
         break;
       aSource.reset();
     }
     if (aSource) {
       boost::shared_ptr<ModelAPI_Document> aCopy = 
-        aPManager->copy(aSource->data()->docRef(PART_ATTR_DOC_REF)->value(), data()->getName());
+        aPManager->copy(aSource->data()->docRef(PartSetPlugin_Part::DOC_REF())->value(), data()->getName());
       aRef->setFeature(aSource);
     }
   }
index 9bab4d63e4e117e89f5ffd0d01b14e489f4ca4ff..dc64d2aec9a0e8665189403d0705eacd1c7189f6 100644 (file)
@@ -7,9 +7,6 @@
 
 #include "PartSetPlugin_Part.h"
 
-/// the reference to copy: reference to the attribute
-const std::string PART_DUPLICATE_ATTR_REF = "Origin";
-
 /**\class PartSetPlugin_Duplicate
  * \ingroup DataModel
  * \brief Duplicates the active part (not root). Creates a new "part" feature.
@@ -17,6 +14,12 @@ const std::string PART_DUPLICATE_ATTR_REF = "Origin";
 class PartSetPlugin_Duplicate: public PartSetPlugin_Part
 {
 public:
+  /// the reference to copy: reference to the attribute
+  inline static const std::string& DOC_REF()
+  {
+    static const std::string MY_DUPLICATE_ID("Origin");
+    return MY_DUPLICATE_ID;
+  }
   /// Makes a new part, copy of active
   PartSetPlugin_Duplicate();
 
index 628435a95aa198edd6fa76fe20186162afef5880..4fff734b89a53bcd5832e695875be50f8718a726 100644 (file)
@@ -16,12 +16,12 @@ PartSetPlugin_Part::PartSetPlugin_Part()
 
 void PartSetPlugin_Part::initAttributes()
 {
-  data()->addAttribute(PART_ATTR_DOC_REF, ModelAPI_AttributeDocRef::type());
+  data()->addAttribute(PartSetPlugin_Part::DOC_REF(), ModelAPI_AttributeDocRef::type());
 }
 
 void PartSetPlugin_Part::execute() 
 {
-  boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(PART_ATTR_DOC_REF);
+  boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(PartSetPlugin_Part::DOC_REF());
   if (!aDocRef->value()) { // create a document if not yet created
     boost::shared_ptr<ModelAPI_Document> aPartSetDoc = 
       ModelAPI_PluginManager::get()->rootDocument();
index 0f921727129f03036314e6d9531f8d53df209728..cd656b18e76fa9c3a6f98ae849cfde264936abd6 100644 (file)
@@ -8,12 +8,6 @@
 #include "PartSetPlugin.h"
 #include <ModelAPI_Feature.h>
 
-/// Part kind
-const std::string PARTSET_PART_KIND("Part");
-
-/// part reference attribute
-const std::string PART_ATTR_DOC_REF = "PartDocument";
-
 /**\class PartSetPlugin_Part
  * \ingroup DataModel
  * \brief Feature for creation of the new part in PartSet.
@@ -21,9 +15,21 @@ const std::string PART_ATTR_DOC_REF = "PartDocument";
 class PartSetPlugin_Part: public ModelAPI_Feature
 {
 public:
+  /// Part kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_PART_KIND("Part");
+    return MY_PART_KIND;
+  }
+  /// part reference attribute
+  inline static const std::string& DOC_REF()
+  {
+    static const std::string MY_DOC_REF("PartDocument");
+    return MY_DOC_REF;
+  }
   /// Returns the kind of a feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = PARTSET_PART_KIND; return MY_KIND;}
+  {static std::string MY_KIND = PartSetPlugin_Part::ID(); return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() 
index 4ba7fa5cac1e2e1b8193232b6f06d39cd4107486..dc384608e6552ca7701115cbfd68d0c1889cd376 100644 (file)
@@ -18,7 +18,7 @@ PartSetPlugin_Plugin::PartSetPlugin_Plugin()
 
 FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID)
 {
-  if (theFeatureID == PARTSET_PART_KIND) {
+  if (theFeatureID == PartSetPlugin_Part::ID()) {
     return FeaturePtr(new PartSetPlugin_Part);
   }
   if (theFeatureID == "duplicate") {
index 0e09f3a607b7e440cbfe3a49fbfffd25cdbf440a..2aea700f2a61f4a3e0fdaad6f2d9e485f20dee29 100644 (file)
@@ -16,12 +16,12 @@ void PartSetPlugin_Remove::execute()
   boost::shared_ptr<PartSetPlugin_Part> a;
   for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
     FeaturePtr aFeature = aRoot->feature(getGroup(), a, true);
-    if (aFeature->getKind() == PARTSET_PART_KIND) {
+    if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
       boost::shared_ptr<PartSetPlugin_Part> aPart = 
         boost::static_pointer_cast<PartSetPlugin_Part>(aFeature);
-      if (aPart->data()->docRef(PART_ATTR_DOC_REF)->value() == aPManager->currentDocument()) {
+      if (aPart->data()->docRef(PartSetPlugin_Part::DOC_REF())->value() == aPManager->currentDocument()) {
         // do remove
-        aPart->data()->docRef(PART_ATTR_DOC_REF)->value()->close();
+        aPart->data()->docRef(PartSetPlugin_Part::DOC_REF())->value()->close();
         aRoot->removeFeature(aPart);
       }
     }
index 87b7e258ce768a0524cdddb9cd9caa1e50e7dcd9..a24cc263281e9092616e2ba5cd4309629f8e0063 100644 (file)
@@ -8,9 +8,6 @@
 #include "PartSetPlugin.h"
 #include <ModelAPI_Feature.h>
 
-/// Extrusion kind
-const std::string PARTSET_REMOVE_KIND("Remove");
-
 /**\class PartSetPlugin_Remove
  * \ingroup DataModel
  * \brief Feature for creation of the new part in PartSet.
@@ -18,9 +15,15 @@ const std::string PARTSET_REMOVE_KIND("Remove");
 class PartSetPlugin_Remove: public ModelAPI_Feature
 {
 public:
+  /// Remove kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_REMOVE_KIND("Remove");
+    return MY_REMOVE_KIND;
+  }
   /// Returns the kind of a feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = PARTSET_REMOVE_KIND; return MY_KIND;}
+  {static std::string MY_KIND = PartSetPlugin_Remove::ID(); return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() 
index e166608d14d5c0347845dad6aa07d0c79ab6a376..89e2185de2fb6031e8dc48730987cd049b364dbd 100644 (file)
@@ -25,9 +25,9 @@ SketchPlugin_Arc::SketchPlugin_Arc()
 
 void SketchPlugin_Arc::initAttributes()
 {
-  data()->addAttribute(ARC_ATTR_CENTER, GeomDataAPI_Point2D::type());
-  data()->addAttribute(ARC_ATTR_START,  GeomDataAPI_Point2D::type());
-  data()->addAttribute(ARC_ATTR_END,    GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Arc::START_ID(),  GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Arc::END_ID(),    GeomDataAPI_Point2D::type());
 }
 
 void SketchPlugin_Arc::execute() 
@@ -42,10 +42,10 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
 
     // compute a circle point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ARC_ATTR_CENTER));
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::CENTER_ID()));
       // compute the arc start point
       boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ARC_ATTR_START));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::START_ID()));
       if (aCenterAttr->isInitialized() && aStartAttr->isInitialized()) {
       boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
       // make a visible point
@@ -54,7 +54,7 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
 
       // make a visible circle
       boost::shared_ptr<GeomDataAPI_Dir> aNDir = 
-        boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SKETCH_ATTR_NORM));
+        boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
       bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
       if (aHasPlane) {
         boost::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
@@ -62,7 +62,7 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Arc::preview()
 
         // compute and change the arc end point
         boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(ARC_ATTR_END));
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::END_ID()));
         if (anEndAttr->isInitialized())
         {
           boost::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
@@ -98,15 +98,15 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
   aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
   aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_END));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::END_ID()));
   aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY);
 }
 
@@ -116,17 +116,17 @@ double SketchPlugin_Arc::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>&
   boost::shared_ptr<ModelAPI_Data> aData = data();
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
   aDelta = aPoint1->pnt()->distance(thePoint);
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
   double aDistance = aPoint2->pnt()->distance(thePoint);
   if (aDelta < aDistance)
     aDelta = aDistance;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_END));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::END_ID()));
   aDistance = aPoint3->pnt()->distance(thePoint);
   if (aDelta < aDistance)
     aDelta = aDistance;
index 94660779572dff92f9044b4d74d06a056b68d7bb..cf57516a598a2811b877a2a33ab9731223529524 100644 (file)
@@ -9,16 +9,6 @@
 #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
-const std::string ARC_ATTR_START("ArcStartPoint");
-/// End 2D point of the arc
-const std::string ARC_ATTR_END("ArcEndPoint");
-
 /**\class SketchPlugin_Arc
  * \ingroup DataModel
  * \brief Feature for creation of the new arc of circle in PartSet.
@@ -26,13 +16,39 @@ const std::string ARC_ATTR_END("ArcEndPoint");
 class SketchPlugin_Arc: public SketchPlugin_Feature
 {
 public:
+  /// Arc feature kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_SKETCH_ARC_ID("SketchArc");
+    return MY_SKETCH_ARC_ID;
+  }
+
+  /// Central 2D point of the circle which contains the arc
+  inline static const std::string& CENTER_ID()
+  {
+    static const std::string MY_CENTER_ID = "ArcCenter";
+    return MY_CENTER_ID;
+  }
+  /// Start 2D point of the arc
+  inline static const std::string& START_ID()
+  {
+    static const std::string MY_START_ID = "ArcStartPoint";
+    return MY_START_ID;
+  }
+  /// End 2D point of the arc
+  inline static const std::string& END_ID()
+  {
+    static const std::string MY_END_ID = "ArcEndPoint";
+    return MY_END_ID;
+  }
+
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
-  {static std::string MY_KIND = SKETCH_ARC_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_Arc::ID(); return MY_KIND;}
 
   /// 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 593716ed9f2c6cea4cebf9eb3719950cdabbef1e..5438c216de51425caa7ee45c6d9671a92e709aae 100644 (file)
@@ -24,8 +24,8 @@ SketchPlugin_Circle::SketchPlugin_Circle()
 
 void SketchPlugin_Circle::initAttributes()
 {
-  data()->addAttribute(CIRCLE_ATTR_CENTER, GeomDataAPI_Point2D::type());
-  data()->addAttribute(CIRCLE_ATTR_RADIUS, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(SketchPlugin_Circle::CENTER_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Circle::RADIUS_ID(), ModelAPI_AttributeDouble::type());
 }
 
 void SketchPlugin_Circle::execute()
@@ -40,9 +40,9 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
 
     // compute a circle point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CIRCLE_ATTR_CENTER));
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Circle::CENTER_ID()));
     AttributeDoublePtr aRadiusAttr = 
-      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CIRCLE_ATTR_RADIUS));
+      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
     if (aCenterAttr->isInitialized() && aRadiusAttr->isInitialized()) {
       boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
       // make a visible point
@@ -51,7 +51,7 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Circle::preview()
 
       // make a visible circle
       boost::shared_ptr<GeomDataAPI_Dir> aNDir = 
-        boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SKETCH_ATTR_NORM));
+        boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
       bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
       if (aHasPlane) {
         boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
@@ -82,7 +82,7 @@ void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Circle::CENTER_ID()));
   aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
 }
 
@@ -90,7 +90,7 @@ double SketchPlugin_Circle::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Circle::CENTER_ID()));
 
   return aPoint->pnt()->distance(thePoint);
 }
index bb47c214de03db6987bb77b26d0346aa1ddbc172..cf7de0330075a5167f17e752fba1ba1ba36ec4c6 100644 (file)
@@ -9,14 +9,6 @@
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
 
-/// Circle feature kind
-const std::string SKETCH_CIRCLE_KIND("SketchCircle");
-
-/// 2D point - center of the circle
-const std::string CIRCLE_ATTR_CENTER("CircleCenter");
-/// Radius of the circle
-const std::string CIRCLE_ATTR_RADIUS("CircleRadius");
-
 /**\class SketchPlugin_Circle
  * \ingroup DataModel
  * \brief Feature for creation of the new circle in PartSet.
@@ -24,13 +16,34 @@ const std::string CIRCLE_ATTR_RADIUS("CircleRadius");
 class SketchPlugin_Circle: public SketchPlugin_Feature
 {
 public:
+  /// Circle feature kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CIRCLE_ID("SketchCircle");
+    return MY_CIRCLE_ID;
+  }
+
+  /// 2D point - center of the circle
+  inline static const std::string& CENTER_ID()
+  {
+    static const std::string MY_CIRCLE_CENTER_ID("CircleCenter");
+    return MY_CIRCLE_CENTER_ID;
+  }
+
+  /// Radius of the circle
+  inline static const std::string& RADIUS_ID()
+  {
+    static const std::string MY_CIRCLE_RADIUS_ID("CircleRadius");
+    return MY_CIRCLE_RADIUS_ID;
+  }
+
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_CIRCLE_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_Circle::ID(); return MY_KIND;}
 
   /// 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 5db923562970fa009ed3939fc100e20c5d53c083..b46214fb8c8985a03bb66e4383f2d052e3905161 100644 (file)
  *
  *    Also the list of possible attributes is provided to simplify assignment.
  */
-/// The value parameter for the constraint
-const std::string CONSTRAINT_ATTR_VALUE("ConstraintValue");
-/// The 2D value parameter for the constraint
-const std::string CONSTRAINT_ATTR_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
-/// First entity for the constraint
-const std::string CONSTRAINT_ATTR_ENTITY_A("ConstraintEntityA");
-/// Second entity for the constraint
-const std::string CONSTRAINT_ATTR_ENTITY_B("ConstraintEntityB");
-/// Third entity for the constraint
-const std::string CONSTRAINT_ATTR_ENTITY_C("ConstraintEntityC");
-/// Fourth entity for the constraint
-const std::string CONSTRAINT_ATTR_ENTITY_D("ConstraintEntityD");
-/// List of constraint attributes
-const unsigned int CONSTRAINT_ATTR_SIZE = 4;
-const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] = 
-                      {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B, 
-                       CONSTRAINT_ATTR_ENTITY_C, CONSTRAINT_ATTR_ENTITY_D};
 
+/// Size of the list of constraint attributes
+const unsigned int CONSTRAINT_ATTR_SIZE = 4;
 
 /** \class SketchPlugin_Constraint
  *  \ingroup DataModel
@@ -52,9 +37,59 @@ const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] =
 class SketchPlugin_Constraint: public SketchPlugin_Feature
 {
 public:
+  /// The value parameter for the constraint
+  inline static const std::string& VALUE()
+  {
+    static const std::string MY_CONSTRAINT_VALUE("ConstraintValue");
+    return MY_CONSTRAINT_VALUE;
+  }
+  /// The 2D value parameter for the constraint
+  inline static const std::string& FLYOUT_VALUE_PNT()
+  {
+    static const std::string MY_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
+    return MY_FLYOUT_VALUE_PNT;
+  }
+  /// First entity for the constraint
+  inline static const std::string& ENTITY_A()
+  {
+    static const std::string MY_ENTITY_A("ConstraintEntityA");
+    return MY_ENTITY_A;
+  }
+  /// Second entity for the constraint
+  inline static const std::string& ENTITY_B()
+  {
+    static const std::string MY_ENTITY_B("ConstraintEntityB");
+    return MY_ENTITY_B;
+  }
+  /// Third entity for the constraint
+  inline static const std::string& ENTITY_C()
+  {
+    static const std::string MY_ENTITY_C("ConstraintEntityC");
+    return MY_ENTITY_C;
+  }
+  /// Fourth entity for the constraint
+  inline static const std::string& ENTITY_D()
+  {
+    static const std::string MY_ENTITY_D("ConstraintEntityD");
+    return MY_ENTITY_D;
+  }
+
+  /// List of constraint attributes
+  inline static const std::string& ATTRIBUTE(const int theNumber) {
+    switch (theNumber) {
+      case 0: return ENTITY_A();
+      case 1: return ENTITY_B();
+      case 2: return ENTITY_C();
+      case 3: return ENTITY_D();
+      default: break;
+    }
+    static const std::string EMPTY_STRING("");
+    return EMPTY_STRING;
+  }
+
   /// \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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch)
    *  \param theFeature sub-feature
index e052d1acee3838ab90e0b28e60d8ce68018a0238..fe63928257371a02f9b8f2f6ec4a1257438ff1c7 100644 (file)
@@ -14,8 +14,8 @@ SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence()
 
 void SketchPlugin_ConstraintCoincidence::initAttributes()
 {
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
 }
 
 void SketchPlugin_ConstraintCoincidence::execute()
index 9ed0e9653b6811c249e2f59ad7a7af9ef6c4c46a..3a5c2c31daecc9cee3a6005eaec32bc4aeb64855 100644 (file)
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
-/// Coincidence constraint kind
-const std::string SKETCH_CONSTRAINT_COINCIDENCE_KIND("SketchConstraintCoincidence");
-
 /** \class SketchPlugin_ConstraintCoincidence
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines equivalence of two points
  *
  *  These constraint has two attributes:
- *  CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ *  SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
 class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint
 {
 public:
+  /// Parallel constraint kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CONSTRAINT_COINCIDENCE_ID("SketchConstraintCoincidence");
+    return MY_CONSTRAINT_COINCIDENCE_ID;
+  }
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_CONSTRAINT_COINCIDENCE_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_ConstraintCoincidence::ID(); 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index faa2d7b62270e966b31fd6b295149e2111d4628d..2896843c5a9a386bd773ef03cde6c43911b10fd1 100644 (file)
@@ -24,21 +24,21 @@ SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
 
 void SketchPlugin_ConstraintDistance::initAttributes()
 {
-  data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
-  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::type());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
 }
 
 void SketchPlugin_ConstraintDistance::execute()
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
 
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, CONSTRAINT_ATTR_ENTITY_A);
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, CONSTRAINT_ATTR_ENTITY_B);
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B());
   if (aPoint_A && aPoint_B) {
     AttributeDoublePtr anAttr_Value =
-      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
 
     if (!anAttr_Value->isInitialized()) {
       anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
@@ -55,13 +55,13 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObje
   boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
 
   DataPtr aData = data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, CONSTRAINT_ATTR_ENTITY_A);
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, CONSTRAINT_ATTR_ENTITY_B);
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B());
   if (!aPoint_A || !aPoint_B)
     return thePrevious;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
 
   boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPoint_A->x(), aPoint_A->y());
   boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPoint_B->x(), aPoint_B->y());
@@ -71,7 +71,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObje
 
   // value calculation
   boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
   double aValue = aValueAttr->value();
 
   boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
@@ -88,7 +88,7 @@ void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
 }
 
@@ -106,9 +106,9 @@ boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
   if (anAttr)
     aFeature = anAttr->feature();
 
-  if (aFeature && aFeature->getKind() == SKETCH_POINT_KIND)
+  if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
     aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
-                                           (aFeature->data()->attribute(POINT_ATTR_COORD));
+                                           (aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
   else {
     if (anAttr->attr())
       aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
index 4350e3cb4b528c82d279c6e9d0801e875ff0621c..9a538ab4a9f9619fe19e0cadd0cdbeb945bbcfd3 100644 (file)
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
-/// Distance constraint kind
-const std::string SKETCH_CONSTRAINT_DISTANCE_KIND("SketchConstraintDistance");
-
 /** \class SketchPlugin_ConstraintDistance
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines a distance
  *         between a point and another feature (point, line, plane or face)
  *
  *  These constraint has three attributes:
- *  CONSTRAINT_ATTR_VALUE, CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
 class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
 {
 public:
+  /// Distance constraint kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
+    return MY_CONSTRAINT_DISTANCE_ID;
+  }
+
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_CONSTRAINT_DISTANCE_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID(); 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 71a35c4f189624649c2501a7f66d36799a437ad2..1953add2b2477ddb974d8a800d5a8d954379fb44 100644 (file)
@@ -21,30 +21,30 @@ SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
 
 void SketchPlugin_ConstraintLength::initAttributes()
 {
-  data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
-  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::type());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
 }
 
 void SketchPlugin_ConstraintLength::execute()
 {
-  if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
-      !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
+  if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() &&
+      !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
-      boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+      boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
     FeaturePtr aFeature = aRef->feature();
     if (aFeature) {
       // set length value
       boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_START));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
       boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(LINE_ATTR_END));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
 
       double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
 
       boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
-        boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_VALUE));
+        boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
       aValueAttr->setValue(aLenght);
     }
   }
@@ -59,21 +59,21 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
   boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
 
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
     return thePrevious;
   FeaturePtr aFeature = anAttr->feature();
-  if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
+  if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
     return thePrevious;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
 
   DataPtr aData = aFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
-    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
   boost::shared_ptr<GeomDataAPI_Point2D> anEndPoint =
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
 
   boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aStartPoint->x(), aStartPoint->y());
   boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(anEndPoint->x(),  anEndPoint->y());
@@ -83,7 +83,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
 
   // value calculation
   boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_VALUE));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
   double aValue = aValueAttr->value();
 
   boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
@@ -100,7 +100,7 @@ void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
 }
 
index 3d07ce186929081c2db4997500e57c724e5ebec2..237dc8e86c539e607a2bd163c0f924542da3a2f9 100644 (file)
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
-/// Length constraint kind
-const std::string SKETCH_CONSTRAINT_LENGTH_KIND("SketchConstraintLength");
-
 /** \class SketchPlugin_ConstraintLength
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines a length of a line segment
  *
  *  These constraint has two attributes:
- *  CONSTRAINT_ATTR_VALUE (length) and CONSTRAINT_ATTR_ENTITY_A (segment),
- *  CONSTRAINT_ATTR_FLYOUT_VALUE_PNT (distance of a constraints handle)
+ *  SketchPlugin_Constraint::VALUE() (length) and SketchPlugin_Constraint::ENTITY_A() (segment),
+ *  SketchPlugin_Constraint::FLYOUT_VALUE_PNT() (distance of a constraints handle)
  */
 class SketchPlugin_ConstraintLength: public SketchPlugin_Constraint
 {
 public:
+  /// Length constraint kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CONSTRAINT_LENGTH_ID("SketchConstraintLength");
+    return MY_CONSTRAINT_LENGTH_ID;
+  }
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_CONSTRAINT_LENGTH_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_ConstraintLength::ID(); 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index e45980582cfeb4eee9aa8817d17dd31ef3ee4f24..15cc861adfcdc6874905818d2d48d5b69926050d 100644 (file)
@@ -20,9 +20,9 @@ SketchPlugin_ConstraintParallel::SketchPlugin_ConstraintParallel()
 
 void SketchPlugin_ConstraintParallel::initAttributes()
 {
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
 }
 
 void SketchPlugin_ConstraintParallel::execute()
@@ -44,9 +44,9 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
 
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
   if (!anAttr1 || !anAttr1->isFeature() || 
       !anAttr2 || !anAttr2->isFeature())
     return thePrevious;
@@ -62,7 +62,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
   boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
 
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
 
   boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
@@ -79,7 +79,7 @@ void SketchPlugin_ConstraintParallel::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
 }
 
index 7f92e2e568c8202e24321684490b3ec965d43298..52e68fcd01cabea396019da5e03519f59aacd424 100644 (file)
@@ -9,26 +9,29 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
-/// Parallel constraint kind
-const std::string SKETCH_CONSTRAINT_PARALLEL_KIND("SketchConstraintParallel");
-
 /** \class SketchPlugin_ConstraintParallel
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint parallelism of two lines
  *
  *  These constraint has two attributes:
- *  CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ *  SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
 class SketchPlugin_ConstraintParallel: public SketchPlugin_Constraint
 {
 public:
+  /// Parallel constraint kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CONSTRAINT_PARALLEL_ID("SketchConstraintParallel");
+    return MY_CONSTRAINT_PARALLEL_ID;
+  }
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_CONSTRAINT_PARALLEL_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_ConstraintParallel::ID(); 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index d4d73b0030663c7297aceef84687864f7606666b..0122202319de359e0ac029aece8f3ab9b5233b60 100644 (file)
@@ -20,9 +20,9 @@ SketchPlugin_ConstraintPerpendicular::SketchPlugin_ConstraintPerpendicular()
 
 void SketchPlugin_ConstraintPerpendicular::initAttributes()
 {
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
 }
 
 void SketchPlugin_ConstraintPerpendicular::execute()
@@ -43,9 +43,9 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
 
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
   if (!anAttr1 || !anAttr1->isFeature() || 
       !anAttr2 || !anAttr2->isFeature())
     return thePrevious;
@@ -74,7 +74,7 @@ void SketchPlugin_ConstraintPerpendicular::move(double theDeltaX, double theDelt
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
 }
 
index 2bb4a7b63fed77fdbed361b65d058502ce284c94..f6970a8952475241c9056875fe38b788fa29c252 100644 (file)
@@ -9,26 +9,29 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
-/// Perpendicular constraint kind
-const std::string SKETCH_CONSTRAINT_PERPENDICULAR_KIND("SketchConstraintPerpendicular");
-
 /** \class SketchPlugin_ConstraintPerpendicular
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint for perpendicularity of two lines
  *
  *  These constraint has two attributes:
- *  CONSTRAINT_ATTR_ENTITY_A and CONSTRAINT_ATTR_ENTITY_B
+ *  SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
 class SketchPlugin_ConstraintPerpendicular: public SketchPlugin_Constraint
 {
 public:
+  /// Perpendicular constraint kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CONSTRAINT_PERPENDICULAR_ID("SketchConstraintPerpendicular");
+    return MY_CONSTRAINT_PERPENDICULAR_ID;
+  }
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_CONSTRAINT_PERPENDICULAR_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_ConstraintPerpendicular::ID(); 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 65ab125b5474f361543530bdc5dd2a79539e0ac0..0b4cd5a9b072899ebc69a792d9aeac7344906a27 100644 (file)
@@ -25,38 +25,38 @@ SketchPlugin_ConstraintRadius::SketchPlugin_ConstraintRadius()
 
 void SketchPlugin_ConstraintRadius::initAttributes()
 {
-  data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
 }
 
 void SketchPlugin_ConstraintRadius::execute()
 {
-  if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
-      !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
+  if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() &&
+      !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
-      boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+      boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
     FeaturePtr aFeature = aRef->feature();
     if (aFeature) {
       double aRadius = 0;
       boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
-      if (aFeature->getKind() == SKETCH_CIRCLE_KIND) {
+      if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
         AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>
-                                            (aData->attribute(CIRCLE_ATTR_RADIUS));
+                                            (aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
         if (anAttribute)
           aRadius = anAttribute->value();
       }
-      else if (aFeature->getKind() == SKETCH_ARC_KIND) {
+      else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
         boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
         boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
         if (aCenterAttr && aStartAttr)
           aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
       }
       boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
-        boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CONSTRAINT_ATTR_VALUE));
+        boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
       aValueAttr->setValue(aRadius);
     }
   }
@@ -70,17 +70,17 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject
 
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
     return thePrevious;
   FeaturePtr aFeature = anAttr->feature();
   std::string aKind = aFeature ? aFeature->getKind() : "";
-  if (aKind != SKETCH_CIRCLE_KIND && aKind != SKETCH_ARC_KIND)
+  if (aKind != SketchPlugin_Circle::ID() && aKind != SketchPlugin_Arc::ID())
     return thePrevious;
 
   // Flyout point
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   if (!aFlyoutAttr->isInitialized())
     return thePrevious;
   boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
@@ -89,28 +89,28 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject
   aData = aFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
   double aRadius;
-  if (aKind == SKETCH_CIRCLE_KIND) {
-    aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
+  if (aKind == SketchPlugin_Circle::ID()) {
+    aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Circle::CENTER_ID()));
     AttributeDoublePtr aCircRadius = 
-      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CIRCLE_ATTR_RADIUS));
+      boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
     aRadius = aCircRadius->value();
   }
-  else if (aKind == SKETCH_ARC_KIND) {
-    aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
+  else if (aKind == SketchPlugin_Arc::ID()) {
+    aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
     boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
     aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
   }
 
   boost::shared_ptr<GeomAPI_Pnt> aCenter = sketch()->to3D(aCenterAttr->x(), aCenterAttr->y());
   boost::shared_ptr<GeomDataAPI_Dir> aNDir = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(sketch()->data()->attribute(SKETCH_ATTR_NORM));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(sketch()->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
   boost::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
   boost::shared_ptr<GeomAPI_Circ> aCircle(new GeomAPI_Circ(aCenter, aNormal, aRadius));
 
   // Value
   boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
   double aValue = aRadius;
   if (aValueAttr && aValueAttr->isInitialized())
    aValue = aValueAttr->value();
@@ -129,15 +129,15 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
   FeaturePtr aFeature = aRef->feature();
   if (!aFeature)
     return;
   std::string aCenterAttrName;
-  if (aFeature->getKind() == SKETCH_CIRCLE_KIND)
-    aCenterAttrName = CIRCLE_ATTR_CENTER;
-  else if (aFeature->getKind() == SKETCH_ARC_KIND)
-    aCenterAttrName = ARC_ATTR_CENTER;
+  if (aFeature->getKind() == SketchPlugin_Circle::ID())
+    aCenterAttrName = SketchPlugin_Circle::CENTER_ID();
+  else if (aFeature->getKind() == SketchPlugin_Arc::ID())
+    aCenterAttrName = SketchPlugin_Arc::CENTER_ID();
   boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(aCenterAttrName));
   boost::shared_ptr<GeomAPI_Pnt2d> aCenter = aCenterAttr->pnt();
@@ -145,11 +145,11 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
   // The specified delta applied on the circle curve, 
   // so it will be scaled due to distance between flyout and center points
   boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
-    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   boost::shared_ptr<GeomAPI_Pnt2d> aFlyout = aFlyoutAttr->pnt();
 
   boost::shared_ptr<ModelAPI_AttributeDouble> aRadius =
-    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
   double aScale = aFlyout->distance(aCenter) / aRadius->value();
 
   boost::shared_ptr<GeomAPI_Circ2d> aCircle(new GeomAPI_Circ2d(aCenter, aFlyout));
index a2e9abad84379c431137fe3d4cbc4ebe3cdcb08d..a3a85d8782c3f92c1cbd50c206464ea803b9c99f 100644 (file)
@@ -9,27 +9,29 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
-/// Radius constraint kind
-const std::string SKETCH_CONSTRAINT_RADIUS_KIND("SketchConstraintRadius");
-
 /** \class SketchPlugin_ConstraintRadius
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines 
  *         a radius of a circle or an arc of circle
  *
  *  These constraint has two attributes:
- *  CONSTRAINT_ATTR_VALUE (radius), CONSTRAINT_ATTR_ENTITY_A (a circle)
+ *  SketchPlugin_Constraint::VALUE() (radius), SketchPlugin_Constraint::ENTITY_A() (a circle)
  */
 class SketchPlugin_ConstraintRadius: public SketchPlugin_Constraint
 {
 public:
+  /// Radius constraint kind
+  inline static const std::string& ID() {
+    static const std::string MY_CONSTRAINT_RADIUS_ID("SketchConstraintRadius");
+    return MY_CONSTRAINT_RADIUS_ID;
+  }
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_CONSTRAINT_RADIUS_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_ConstraintRadius::ID(); 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 4404ea1b80cb0fa5947abf5c718c5d99037bcfaf..d264007e3a6ff69b69530145a37b7c8fd73e5228 100644 (file)
@@ -30,7 +30,7 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
         dynamic_pointer_cast<SketchPlugin_Sketch>(document()->feature("Construction", a, true));
       if (aSketch) {
         std::list<FeaturePtr > aList = 
-          aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list();
+          aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
         std::list<FeaturePtr >::iterator aSub = aList.begin();
         for(; aSub != aList.end(); aSub++) {
           if ((*aSub)->data()->isEqual(data())) {
index 3175ac13f0cb7277a3d33776028d43519f01ac3f..db0e86c86ada9afae4129ce96ef0f17579f1bb19 100644 (file)
@@ -25,8 +25,8 @@ SketchPlugin_Line::SketchPlugin_Line()
 
 void SketchPlugin_Line::initAttributes()
 {
-  data()->addAttribute(LINE_ATTR_START, GeomDataAPI_Point2D::type());
-  data()->addAttribute(LINE_ATTR_END, GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Line::START_ID(), GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Line::END_ID(), GeomDataAPI_Point2D::type());
 }
 
 void SketchPlugin_Line::execute() 
@@ -39,10 +39,10 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
   if (aSketch) {
     // compute a start point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(LINE_ATTR_START));
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::START_ID()));
     // compute an end point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(LINE_ATTR_END));
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::END_ID()));
     if (aStartAttr->isInitialized() && anEndAttr->isInitialized()) {
       boost::shared_ptr<GeomAPI_Pnt> aStart(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
       boost::shared_ptr<GeomAPI_Pnt> anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
@@ -68,11 +68,11 @@ void SketchPlugin_Line::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
   aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
   aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
 }
 
@@ -82,9 +82,9 @@ double SketchPlugin_Line::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>
 
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
 
   GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y());
 
index f440bac1dfa0b3d6d479a159701484187897939e..2adb9a83320140d9cecb62921a9c1160a05b2124 100644 (file)
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
-/// Line feature kind
-const std::string SKETCH_LINE_KIND("SketchLine");
-
-/// Start 2D point of the line
-const std::string LINE_ATTR_START("StartPoint");
-/// End 2D point of the line
-const std::string LINE_ATTR_END("EndPoint");
-
 /**\class SketchPlugin_Line
  * \ingroup DataModel
  * \brief Feature for creation of the new part in PartSet.
@@ -25,13 +17,32 @@ const std::string LINE_ATTR_END("EndPoint");
 class SketchPlugin_Line: public SketchPlugin_Feature
 {
 public:
+  /// Arc feature kind
+  inline static const std::string& ID()
+  {
+    static const std::string SKETCH_LINE_ID("SketchLine");
+    return SKETCH_LINE_ID;
+  }
+  /// Start 2D point of the line
+  inline static const std::string& START_ID()
+  {
+    static const std::string MY_START_ID("StartPoint");
+    return MY_START_ID;
+  }
+    /// End 2D point of the line
+  inline static const std::string& END_ID()
+  {
+    static const std::string MY_END_ID("EndPoint");
+    return MY_END_ID;
+  }
+
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_LINE_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_Line::ID(); return MY_KIND;}
 
   /// 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index d494a63790a8cc9558e97ca2cda6a995d2b97514..9c0da3f592d8e5b530c74bf82dc45f1acdd841c1 100644 (file)
@@ -26,37 +26,37 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
 
 FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID)
 {
-  if (theFeatureID == SKETCH_KIND) {
+  if (theFeatureID == SketchPlugin_Sketch::ID()) {
     return FeaturePtr(new SketchPlugin_Sketch);
   }
-  else if (theFeatureID == SKETCH_POINT_KIND) {
+  else if (theFeatureID == SketchPlugin_Point::ID()) {
     return FeaturePtr(new SketchPlugin_Point);
   }
-  else if (theFeatureID == SKETCH_LINE_KIND) {
+  else if (theFeatureID == SketchPlugin_Line::ID()) {
     return FeaturePtr(new SketchPlugin_Line);
   }
-  else if (theFeatureID == SKETCH_CIRCLE_KIND) {
+  else if (theFeatureID == SketchPlugin_Circle::ID()) {
     return FeaturePtr(new SketchPlugin_Circle);
   }
-  else if (theFeatureID == SKETCH_ARC_KIND) {
+  else if (theFeatureID == SketchPlugin_Arc::ID()) {
     return FeaturePtr(new SketchPlugin_Arc);
   }
-  else if (theFeatureID == SKETCH_CONSTRAINT_COINCIDENCE_KIND) {
+  else if (theFeatureID == SketchPlugin_ConstraintCoincidence::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintCoincidence);
   }
-  else if (theFeatureID == SKETCH_CONSTRAINT_DISTANCE_KIND) {
+  else if (theFeatureID == SketchPlugin_ConstraintDistance::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintDistance);
   }
-  else if (theFeatureID == SKETCH_CONSTRAINT_LENGTH_KIND) {
+  else if (theFeatureID == SketchPlugin_ConstraintLength::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintLength);
   }
-  else if (theFeatureID == SKETCH_CONSTRAINT_PARALLEL_KIND) {
+  else if (theFeatureID == SketchPlugin_ConstraintParallel::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintParallel);
   }
-  else if (theFeatureID == SKETCH_CONSTRAINT_PERPENDICULAR_KIND) {
+  else if (theFeatureID == SketchPlugin_ConstraintPerpendicular::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintPerpendicular);
   }
-  else if (theFeatureID == SKETCH_CONSTRAINT_RADIUS_KIND) {
+  else if (theFeatureID == SketchPlugin_ConstraintRadius::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintRadius);
   }
   // feature of such kind is not found
index 984d98919a8b6c7fc323f7350e2a3e351804080f..fd60230de19c55fc1a343770269b42ec745afe05 100644 (file)
@@ -20,7 +20,7 @@ SketchPlugin_Point::SketchPlugin_Point()
 
 void SketchPlugin_Point::initAttributes()
 {
-  data()->addAttribute(POINT_ATTR_COORD, GeomDataAPI_Point2D::type());
+  data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type());
 }
 
 void SketchPlugin_Point::execute() 
@@ -33,7 +33,7 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Point::preview()
   if (aSketch) {
     // compute a point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> aPoint = 
-      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(POINT_ATTR_COORD));
+      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Point::COORD_ID()));
     boost::shared_ptr<GeomAPI_Pnt> aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y()));
     // make a visible point
     boost::shared_ptr<GeomAPI_Shape> aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D);
@@ -55,7 +55,7 @@ void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
     return;
 
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Point::COORD_ID()));
   aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
 }
 
@@ -63,7 +63,7 @@ double SketchPlugin_Point::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d
 {
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Point::COORD_ID()));
 
   return aPoint->pnt()->distance(thePoint);
 }
index 31fad0ea488fa7a703bb490b1a938e8d250e3f5d..f4bf4f6a7d93c79723f8769ff5a77783ea363dc1 100644 (file)
 #include "SketchPlugin_Feature.h"
 #include <list>
 
-/// Point feature kind
-const std::string SKETCH_POINT_KIND("SketchPoint");
-
-/// Coordinates of the point
-const std::string POINT_ATTR_COORD("PointCoordindates");
-
 /**\class SketchPlugin_Point
  * \ingroup DataModel
  * \brief Feature for creation of a new point.
@@ -23,13 +17,25 @@ const std::string POINT_ATTR_COORD("PointCoordindates");
 class SketchPlugin_Point: public SketchPlugin_Feature
 {
 public:
+  /// Point feature kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_POINT_ID("SketchPoint");
+    return MY_POINT_ID;
+  }
+  /// Coordinates of the point
+  inline static const std::string& COORD_ID()
+  {
+    static const std::string MY_COORD_ID("PointCoordindates");
+    return MY_COORD_ID;
+  }
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_POINT_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_Point::ID(); return MY_KIND;}
 
   /// 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;}
+  {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 7bc0ec60084671eb3367d3baf5f3986fecbec408..b0bf6e9f6f9f75fe3d8572f2312045263c2fdd80 100644 (file)
@@ -28,11 +28,11 @@ SketchPlugin_Sketch::SketchPlugin_Sketch()
 
 void SketchPlugin_Sketch::initAttributes()
 {
-  data()->addAttribute(SKETCH_ATTR_ORIGIN, GeomDataAPI_Point::type());
-  data()->addAttribute(SKETCH_ATTR_DIRX, GeomDataAPI_Dir::type());
-  data()->addAttribute(SKETCH_ATTR_DIRY, GeomDataAPI_Dir::type());
-  data()->addAttribute(SKETCH_ATTR_NORM, GeomDataAPI_Dir::type());
-  data()->addAttribute(SKETCH_ATTR_FEATURES, ModelAPI_AttributeRefList::type());
+  data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::type());
+  data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::type());
+  data()->addAttribute(SketchPlugin_Sketch::DIRY_ID(), GeomDataAPI_Dir::type());
+  data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::type());
+  data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type());
 }
 
 void SketchPlugin_Sketch::execute() 
@@ -40,16 +40,16 @@ void SketchPlugin_Sketch::execute()
   if (!data()->isValid())
     return ;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
-    boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SKETCH_ATTR_FEATURES));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
 
   boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aDirX = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRX));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aDirY = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRY));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aNorm = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
 
   std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
   if (aFeatures.empty())
@@ -109,7 +109,7 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
 const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
 {
   boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);
-  data()->reflist(SKETCH_ATTR_FEATURES)->append(theFeature);
+  data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->append(theFeature);
 }
 
 void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
@@ -125,11 +125,11 @@ void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
 boost::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, const double theY)
 {
   boost::shared_ptr<GeomDataAPI_Point> aC = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aX = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRX));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aY = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRY));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
 
   boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(
     aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY));
@@ -140,7 +140,7 @@ boost::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, cons
 bool SketchPlugin_Sketch::isPlaneSet()
 {
   boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
 
   return aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
 }
@@ -148,9 +148,9 @@ bool SketchPlugin_Sketch::isPlaneSet()
 boost::shared_ptr<GeomAPI_Pln> SketchPlugin_Sketch::plane()
 {
   boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SKETCH_ATTR_ORIGIN));
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   boost::shared_ptr<GeomDataAPI_Dir> aNorm = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
 
   if (!anOrigin || !aNorm)
     return boost::shared_ptr<GeomAPI_Pln>();
index d88267bed29d83b43bec9b3c963ca73bfedb039e..5cde6adadcb174fe0b8541fd21655b02262c615e 100644 (file)
 #include <GeomAPI_Pln.h>
 #include <list>
 
-/// Sketch feature kind
-const std::string SKETCH_KIND("Sketch");
-
-/// Origin point of the sketcher in 3D space
-const std::string SKETCH_ATTR_ORIGIN("Origin");
-/// Vector X inside of the sketch plane
-const std::string SKETCH_ATTR_DIRX("DirX");
-/// Vector Y inside of the sketch plane
-const std::string SKETCH_ATTR_DIRY("DirY");
-/// Vector Z, normal to the sketch plane
-const std::string SKETCH_ATTR_NORM("Norm");
-/// All features of this sketch (list of references)
-const std::string SKETCH_ATTR_FEATURES("Features");
-
 /**\class SketchPlugin_Sketch
  * \ingroup DataModel
  * \brief Feature for creation of the new part in PartSet.
@@ -32,9 +18,46 @@ const std::string SKETCH_ATTR_FEATURES("Features");
 class SketchPlugin_Sketch: public SketchPlugin_Feature
 {
 public:
+  /// Sketch feature kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_SKETCH_ID("Sketch");
+    return MY_SKETCH_ID;
+  }
+  /// Origin point of the sketcher in 3D space
+  inline static const std::string& ORIGIN_ID()
+  {
+    static const std::string MY_ORIGIN_ID("Origin");
+    return MY_ORIGIN_ID;
+  }
+  /// Vector X inside of the sketch plane
+  inline static const std::string& DIRX_ID()
+  {
+    static const std::string MY_DIRX_ID("DirX");
+    return MY_DIRX_ID;
+  }
+  /// Vector Y inside of the sketch plane
+  inline static const std::string& DIRY_ID()
+  {
+    static const std::string MY_DIRY_ID("DirY");
+    return MY_DIRY_ID;
+  }
+  /// Vector Z, normal to the sketch plane
+  inline static const std::string& NORM_ID()
+  {
+    static const std::string MY_NORM_ID("Norm");
+    return MY_NORM_ID;
+  }
+  /// All features of this sketch (list of references)
+  inline static const std::string& FEATURES_ID()
+  {
+    static const std::string MY_FEATURES_ID("Features");
+    return MY_FEATURES_ID;
+  }
+
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = SKETCH_KIND; return MY_KIND;}
+  {static std::string MY_KIND = SketchPlugin_Sketch::ID(); return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
index 67a177038088fffb546b35af925fa8483aab67e6..18bd68e2b4bffc73bdd0cc0264d44c91f3364619 100644 (file)
@@ -60,7 +60,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
     {
       boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-          theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+          theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
       if (!anAttr) continue;
       // Verify the attribute is a 2D point
@@ -69,7 +69,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
       if (aPoint2D)
       {
         aPt2d |= (1 << indAttr);
-        myAttributesList[anAttrPos++] = CONSTRAINT_ATTRIBUTES[indAttr];
+        myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
         continue;
       }
       // Verify the attribute is a 3D point
@@ -78,7 +78,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
       if (aPoint3D)
       {
         aPt3d |= (1 << indAttr);
-        myAttributesList[anAttrPos++] = CONSTRAINT_ATTRIBUTES[indAttr];
+        myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
         continue;
       }
       // Attribute neither 2D nor 3D point is not supported by this type of constraint
@@ -93,7 +93,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for distance between point and another entity
-  if (aConstraintKind.compare(SKETCH_CONSTRAINT_DISTANCE_KIND) == 0)
+  if (aConstraintKind.compare(SketchPlugin_ConstraintDistance::ID()) == 0)
   {
     int aNbPoints = 0;
     int aNbEntities = 0;
@@ -101,21 +101,21 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
     {
       boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-          theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+          theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
       if (!anAttr) continue;
       if (anAttr->isFeature() && anAttr->feature())
       { // verify posiible entities
         const std::string& aKind = anAttr->feature()->getKind();
-        if (aKind.compare(SKETCH_POINT_KIND) == 0)
+        if (aKind.compare(SketchPlugin_Point::ID()) == 0)
         {
-          myAttributesList[aNbPoints++] = CONSTRAINT_ATTRIBUTES[indAttr];
+          myAttributesList[aNbPoints++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
           continue;
         }
-        else if(aKind.compare(SKETCH_LINE_KIND) == 0)
+        else if(aKind.compare(SketchPlugin_Line::ID()) == 0)
         {
-          // entities are placed starting from CONSTRAINT_ATTR_ENTITY_C attribute
-          myAttributesList[2 + aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
+          // entities are placed starting from SketchPlugin_Constraint::ENTITY_C() attribute
+          myAttributesList[2 + aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
           myType = SLVS_C_PT_LINE_DISTANCE;
           continue;
         }
@@ -127,7 +127,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
         if (aPoint2D)
         {
-          myAttributesList[aNbPoints++] = CONSTRAINT_ATTRIBUTES[indAttr];
+          myAttributesList[aNbPoints++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
           continue;
         }
         // Verify the attribute is a 3D point
@@ -135,7 +135,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           boost::dynamic_pointer_cast<GeomDataAPI_Point>(anAttr->attr());
         if (aPoint3D)
         {
-          myAttributesList[aNbPoints++] = CONSTRAINT_ATTRIBUTES[indAttr];
+          myAttributesList[aNbPoints++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
           continue;
         }
       }
@@ -149,20 +149,20 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for the given length of a line
-  if (aConstraintKind.compare(SKETCH_CONSTRAINT_LENGTH_KIND) == 0)
+  if (aConstraintKind.compare(SketchPlugin_ConstraintLength::ID()) == 0)
   {
     int aNbLines = 0;
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
     {
       boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-          theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+          theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
       if (!anAttr) continue;
       if (anAttr->isFeature() && anAttr->feature() &&
-          anAttr->feature()->getKind().compare(SKETCH_LINE_KIND) == 0)
+          anAttr->feature()->getKind().compare(SketchPlugin_Line::ID()) == 0)
       {
-        myAttributesList[aNbLines++] = CONSTRAINT_ATTRIBUTES[indAttr];
+        myAttributesList[aNbLines++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
         break;
       }
     }
@@ -172,22 +172,22 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for two parallel/perpendicular lines
-  bool isParallel = (aConstraintKind.compare(SKETCH_CONSTRAINT_PARALLEL_KIND) == 0);
-  bool isPerpendicular = (aConstraintKind.compare(SKETCH_CONSTRAINT_PERPENDICULAR_KIND) == 0);
+  bool isParallel = (aConstraintKind.compare(SketchPlugin_ConstraintParallel::ID()) == 0);
+  bool isPerpendicular = (aConstraintKind.compare(SketchPlugin_ConstraintPerpendicular::ID()) == 0);
   if (isParallel || isPerpendicular)
   {
-    int aNbEntities = 2; // lines in SolveSpace constraints should started from CONSTRAINT_ATTR_ENTITY_C attribute
+    int aNbEntities = 2; // lines in SolveSpace constraints should started from SketchPlugin_Constraint::ENTITY_C() attribute
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
     {
       boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-          theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+          theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
       if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
       const std::string& aKind = anAttr->feature()->getKind();
-      if (aKind.compare(SKETCH_LINE_KIND) == 0)
+      if (aKind.compare(SketchPlugin_Line::ID()) == 0)
       {
-        myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
+        myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
         continue;
       }
     }
@@ -197,20 +197,20 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for radius of a circle or an arc of circle
-  if (aConstraintKind.compare(SKETCH_CONSTRAINT_RADIUS_KIND) == 0)
+  if (aConstraintKind.compare(SketchPlugin_ConstraintRadius::ID()) == 0)
   {
-    int aNbEntities = 2; // lines in SolveSpace constraints should started from CONSTRAINT_ATTR_ENTITY_C attribute
+    int aNbEntities = 2; // lines in SolveSpace constraints should started from SketchPlugin_Constraint::ENTITY_C() attribute
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
     {
       boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-          theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+          theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
         );
       if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
       const std::string& aKind = anAttr->feature()->getKind();
-      if (aKind.compare(SKETCH_CIRCLE_KIND) == 0 || aKind.compare(SKETCH_ARC_KIND) == 0)
+      if (aKind.compare(SketchPlugin_Circle::ID()) == 0 || aKind.compare(SketchPlugin_Arc::ID()) == 0)
       {
-        myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
+        myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
         continue;
       }
     }
index 2f7931f9b59c87b53491a52b3ad251fab1737ffb..d2f1dcc424774f93882a28074cf94c6ad11294b9 100644 (file)
 /// Tolerance for value of parameters
 const double tolerance = 1.e-10;
 
-const std::string ERROR_SOLVE_CONSTRAINTS = "Conflicting constraints";
+/*
+ * Collects all sketch solver error' codes
+ * as inline static functions
+ * TODO: Move this class into a separate file
+ */
+class SketchSolver_Error {
+public:
+  /// The value parameter for the constraint
+  inline static const std::string& CONSTRAINTS()
+  {
+    static const std::string MY_ERROR_VALUE("Conflicting constraints");
+    return MY_ERROR_VALUE;
+  }
+};
 
 /// This value is used to give unique index to the groups
 static Slvs_hGroup myGroupIndexer = 0;
@@ -118,7 +131,7 @@ bool SketchSolver_ConstraintGroup::isInteract(
   {
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aCAttrRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-        theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[i])
+        theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(i))
       );
     if (!aCAttrRef) continue;
     if (!aCAttrRef->isFeature() && 
@@ -166,7 +179,7 @@ bool SketchSolver_ConstraintGroup::changeConstraint(
   // Create constraint parameters
   double aDistance = 0.0; // scalar value of the constraint
   AttributeDoublePtr aDistAttr =
-    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theConstraint->data()->attribute(CONSTRAINT_ATTR_VALUE));
+    boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theConstraint->data()->attribute(SketchPlugin_Constraint::VALUE()));
   if (aDistAttr)
   {
     aDistance = aDistAttr->value();
@@ -191,11 +204,11 @@ 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(SKETCH_CONSTRAINT_LENGTH_KIND) == 0)
+    if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SketchPlugin_ConstraintLength::ID()) == 0)
     {
       boost::shared_ptr<ModelAPI_Data> aData = aConstrAttr->feature()->data();
-      aConstrEnt[indAttr]   = changeEntity(aData->attribute(LINE_ATTR_START));
-      aConstrEnt[indAttr+1] = changeEntity(aData->attribute(LINE_ATTR_END));
+      aConstrEnt[indAttr]   = changeEntity(aData->attribute(SketchPlugin_Line::START_ID()));
+      aConstrEnt[indAttr+1] = changeEntity(aData->attribute(SketchPlugin_Line::END_ID()));
       myEntityFeatMap[aConstrAttr->feature()] = 0; // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group
       break; // there should be no other entities
     }
@@ -343,10 +356,10 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
     const std::string& aFeatureKind = aFeature->getKind();
 
     // Line
-    if (aFeatureKind.compare(SKETCH_LINE_KIND) == 0)
+    if (aFeatureKind.compare(SketchPlugin_Line::ID()) == 0)
     {
-      Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(LINE_ATTR_START));
-      Slvs_hEntity aEnd   = changeEntity(aFeature->data()->attribute(LINE_ATTR_END));
+      Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+      Slvs_hEntity aEnd   = changeEntity(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
 
       if (isEntExists)
         return aEntIter->second;
@@ -358,10 +371,10 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
       return aLineEntity.h;
     }
     // Circle
-    else if (aFeatureKind.compare(SKETCH_CIRCLE_KIND) == 0)
+    else if (aFeatureKind.compare(SketchPlugin_Circle::ID()) == 0)
     {
-      Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(CIRCLE_ATTR_CENTER));
-      Slvs_hEntity aRadius = changeEntity(aFeature->data()->attribute(CIRCLE_ATTR_RADIUS));
+      Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
+      Slvs_hEntity aRadius = changeEntity(aFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
 
       if (isEntExists)
         return aEntIter->second;
@@ -374,11 +387,11 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
       return aCircleEntity.h;
     }
     // Arc
-    else if (aFeatureKind.compare(SKETCH_ARC_KIND) == 0)
+    else if (aFeatureKind.compare(SketchPlugin_Arc::ID()) == 0)
     {
-      Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(ARC_ATTR_CENTER));
-      Slvs_hEntity aStart  = changeEntity(aFeature->data()->attribute(ARC_ATTR_START));
-      Slvs_hEntity aEnd    = changeEntity(aFeature->data()->attribute(ARC_ATTR_END));
+      Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID()));
+      Slvs_hEntity aStart  = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::START_ID()));
+      Slvs_hEntity aEnd    = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::END_ID()));
 
       if (isEntExists)
         return aEntIter->second;
@@ -390,9 +403,9 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
       return anArcEntity.h;
     }
     // Point (it has low probability to be an attribute of constraint, so it is checked at the end)
-    else if (aFeatureKind.compare(SKETCH_POINT_KIND) == 0)
+    else if (aFeatureKind.compare(SketchPlugin_Point::ID()) == 0)
     {
-      Slvs_hEntity aPoint = changeEntity(aFeature->data()->attribute(POINT_ATTR_COORD));
+      Slvs_hEntity aPoint = changeEntity(aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
 
       if (isEntExists)
         return aEntIter->second;
@@ -473,7 +486,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal(
 bool SketchSolver_ConstraintGroup::addWorkplane(
                 boost::shared_ptr<SketchPlugin_Feature> theSketch)
 {
-  if (myWorkplane.h || theSketch->getKind().compare(SKETCH_KIND) != 0)
+  if (myWorkplane.h || theSketch->getKind().compare(SketchPlugin_Sketch::ID()) != 0)
     return false; // the workplane already exists or the function parameter is not Sketch
 
   mySketch = theSketch;
@@ -489,10 +502,10 @@ bool SketchSolver_ConstraintGroup::addWorkplane(
 bool SketchSolver_ConstraintGroup::updateWorkplane()
 {
   // Get parameters of workplane
-  boost::shared_ptr<ModelAPI_Attribute> aDirX    = mySketch->data()->attribute(SKETCH_ATTR_DIRX);
-  boost::shared_ptr<ModelAPI_Attribute> aDirY    = mySketch->data()->attribute(SKETCH_ATTR_DIRY);
-  boost::shared_ptr<ModelAPI_Attribute> aNorm    = mySketch->data()->attribute(SKETCH_ATTR_NORM);
-  boost::shared_ptr<ModelAPI_Attribute> anOrigin = mySketch->data()->attribute(SKETCH_ATTR_ORIGIN);
+  boost::shared_ptr<ModelAPI_Attribute> aDirX    = mySketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID());
+  boost::shared_ptr<ModelAPI_Attribute> aDirY    = mySketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID());
+  boost::shared_ptr<ModelAPI_Attribute> aNorm    = mySketch->data()->attribute(SketchPlugin_Sketch::NORM_ID());
+  boost::shared_ptr<ModelAPI_Attribute> anOrigin = mySketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID());
   // Transform them into SolveSpace format
   Slvs_hEntity aNormalWP = changeNormal(aDirX, aDirY, aNorm);
   if (!aNormalWP) return false;
@@ -570,7 +583,7 @@ void SketchSolver_ConstraintGroup::resolveConstraints()
         updateRelatedConstraints(anEntIter->first);
   }
   else if (!myConstraints.empty())
-    Events_Error::send(ERROR_SOLVE_CONSTRAINTS, this);
+    Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);
 
   removeTemporaryConstraints();
   myNeedToSolve = false;
@@ -758,7 +771,7 @@ bool SketchSolver_ConstraintGroup::updateGroup()
   {
     if (!aConstrIter->first->data()->isValid())
     {
-      if (aConstrIter->first->getKind().compare(SKETCH_CONSTRAINT_COINCIDENCE_KIND) == 0)
+      if (aConstrIter->first->getKind().compare(SketchPlugin_ConstraintCoincidence::ID()) == 0)
         isCCRemoved = true;
       std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::reverse_iterator
         aCopyIter = aConstrIter++;
index ff571878b964b567331ea2949d5efdb6fe9c38fd..2976eca8f3ea7a35745adef7d4520c763fc0cb74 100644 (file)
@@ -76,7 +76,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
       {
         // Only sketches and constraints can be added by Create event
         const std::string& aFeatureKind = (*aFeatIter)->getKind();
-        if (aFeatureKind.compare(SKETCH_KIND) == 0)
+        if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0)
         {
           boost::shared_ptr<SketchPlugin_Feature> aSketch =
             boost::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
@@ -108,10 +108,10 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
       dynamic_cast<const ModelAPI_FeatureDeletedMessage*>(theMessage);
     const std::set<std::string>& aFeatureGroups = aDeleteMsg->groups();
 
-    // Find SKETCH_KIND in groups. The constraint groups should be updated when an object removed from Sketch
+    // Find SketchPlugin_Sketch::ID() in groups. The constraint groups should be updated when an object removed from Sketch
     std::set<std::string>::const_iterator aFGrIter;
     for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++)
-      if (aFGrIter->compare(SKETCH_KIND) == 0)
+      if (aFGrIter->compare(SketchPlugin_Sketch::ID()) == 0)
         break;
     
     if (aFGrIter != aFeatureGroups.end())
@@ -259,26 +259,26 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin
   std::vector<std::string> anAttrList;
   const std::string& aFeatureKind = theFeature->getKind();
   // Point
-  if (aFeatureKind.compare(SKETCH_POINT_KIND) == 0)
-    anAttrList.push_back(POINT_ATTR_COORD);
+  if (aFeatureKind.compare(SketchPlugin_Point::ID()) == 0)
+    anAttrList.push_back(SketchPlugin_Point::COORD_ID());
   // Line
-  else if (aFeatureKind.compare(SKETCH_LINE_KIND) == 0)
+  else if (aFeatureKind.compare(SketchPlugin_Line::ID()) == 0)
   {
-    anAttrList.push_back(LINE_ATTR_START);
-    anAttrList.push_back(LINE_ATTR_END);
+    anAttrList.push_back(SketchPlugin_Line::START_ID());
+    anAttrList.push_back(SketchPlugin_Line::END_ID());
   }
   // Circle
-  else if (aFeatureKind.compare(SKETCH_CIRCLE_KIND) == 0)
+  else if (aFeatureKind.compare(SketchPlugin_Circle::ID()) == 0)
   {
-    anAttrList.push_back(CIRCLE_ATTR_CENTER);
-    anAttrList.push_back(CIRCLE_ATTR_RADIUS);
+    anAttrList.push_back(SketchPlugin_Circle::CENTER_ID());
+    anAttrList.push_back(SketchPlugin_Circle::RADIUS_ID());
   }
   // Arc
-  else if (aFeatureKind.compare(SKETCH_ARC_KIND) == 0)
+  else if (aFeatureKind.compare(SketchPlugin_Arc::ID()) == 0)
   {
-    anAttrList.push_back(ARC_ATTR_CENTER);
-    anAttrList.push_back(ARC_ATTR_START);
-    anAttrList.push_back(ARC_ATTR_END);
+    anAttrList.push_back(SketchPlugin_Arc::CENTER_ID());
+    anAttrList.push_back(SketchPlugin_Arc::START_ID());
+    anAttrList.push_back(SketchPlugin_Arc::END_ID());
   }
   /// \todo Other types of features should be implemented
 
@@ -350,7 +350,7 @@ boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWork
       continue;
 
     boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
-      boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SKETCH_ATTR_FEATURES));
+      boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
     std::list< FeaturePtr > aFeaturesList = aWPFeatures->list();
     std::list< FeaturePtr >::const_iterator anIter;
     for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++)
index 8ecb179b3d1b77a46503126208ead9d91469b882..58fb6809077b7559d4530428749cca2dcf8e7a4a 100644 (file)
@@ -105,7 +105,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
     FeaturePtr aFeature = aFeatures.first();
     //Process Feature
     if (aFeature) {
-      if (aFeature->getKind() == PARTSET_PART_KIND) {
+      if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
         ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
         DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
         if (aMgr->currentDocument() == aFeaDoc)
index b4cc62c0c9f4d5f8bc6a6fba6cd41dffd6301903..a7d6c3c8b46bd9a87204bcc99e0a146ed87a4320 100644 (file)
@@ -56,7 +56,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
       FeaturePtr aFeature = (*aIt);
       DocumentPtr aDoc = aFeature->document();
       if (aDoc == aRootDoc) {  // If root objects
-        if (aFeature->getGroup().compare(PARTS_GROUP) == 0) { // Update only Parts group
+        if (aFeature->getGroup().compare(ModelAPI_Document::PARTS_GROUP()) == 0) { // Update only Parts group
           // Add a new part
           int aStart = myPartModels.size();
           XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this);
@@ -96,7 +96,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
     for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) {
       std::string aGroup = (*aIt);
       if (aDoc == aRootDoc) {  // If root objects
-        if (aGroup.compare(PARTS_GROUP) == 0) { // Updsate only Parts group
+        if (aGroup.compare(ModelAPI_Document::PARTS_GROUP()) == 0) { // Updsate only Parts group
           int aStart = myPartModels.size() - 1;
           removeSubModel(aStart);
           removeRow(aStart, partFolderNode());
@@ -151,7 +151,7 @@ void XGUI_DocumentDataModel::rebuildDataTree()
   beginResetModel();
   clearModelIndexes();
 
-  int aNbParts = aRootDoc->size(PARTS_GROUP);
+  int aNbParts = aRootDoc->size(ModelAPI_Document::PARTS_GROUP());
   if (myPartModels.size() != aNbParts) { // resize internal models
     while (myPartModels.size() > aNbParts) {
       delete myPartModels.last();
@@ -192,7 +192,7 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole)
     {
       int aOffset = historyOffset();
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      FeaturePtr aFeature = aRootDoc->feature(FEATURES_GROUP, theIndex.row() - aOffset);
+      FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - aOffset);
       if (!aFeature)
         return QVariant();
       switch (theRole) {
@@ -236,7 +236,7 @@ int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const
     // Size of external models
     int aVal = historyOffset();
     // Plus history size
-    aVal += aRootDoc->size(FEATURES_GROUP);
+    aVal += aRootDoc->size(ModelAPI_Document::FEATURES_GROUP());
     return aVal;
   }
   if (theParent.internalId() == PartsFolder) {
@@ -364,7 +364,7 @@ FeaturePtr XGUI_DocumentDataModel::feature(const QModelIndex& theIndex) const
   if (theIndex.internalId() == HistoryNode) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
     int aOffset = historyOffset();
-    return aRootDoc->feature(FEATURES_GROUP, theIndex.row() - aOffset);
+    return aRootDoc->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - aOffset);
   }
   QModelIndex* aIndex = toSourceModelIndex(theIndex);
   if (!isSubModel(aIndex->model())) 
@@ -527,8 +527,8 @@ QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) co
     // This feature belongs to histrory or top model
     if (theFeature->isInHistory()) {
       int aId;
-      for (aId = 0; aId < aRootDoc->size(FEATURES_GROUP); aId++) {
-        if (theFeature == aRootDoc->feature(FEATURES_GROUP, aId))
+      for (aId = 0; aId < aRootDoc->size(ModelAPI_Document::FEATURES_GROUP()); aId++) {
+        if (theFeature == aRootDoc->feature(ModelAPI_Document::FEATURES_GROUP(), aId))
           break;
       }
       return index(aId + historyOffset(), 0, QModelIndex());
@@ -554,4 +554,4 @@ QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) co
     }
   }
   return QModelIndex();
-}
\ No newline at end of file
+}
index ced60958b38a5855824c27001d6c39c258c155c2..82dcc853209a70dcd63ecdac56af5df14c182336 100644 (file)
@@ -42,7 +42,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ParamObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(PARAMETERS_GROUP, theIndex.row());
+        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
         if (aFeature)
           return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
       } 
@@ -51,7 +51,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ConstructObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
         if (aFeature)
           return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
       }
@@ -68,7 +68,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ConstructObject:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
         if (aFeature)
           return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
       }
@@ -97,10 +97,10 @@ int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const
 
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
   if (theParent.internalId() == ParamsFolder)
-    return aRootDoc->size(PARAMETERS_GROUP);
+    return aRootDoc->size(ModelAPI_Document::PARAMETERS_GROUP());
 
   if (theParent.internalId() == ConstructFolder)
-    return aRootDoc->size(CONSTRUCTIONS_GROUP);
+    return aRootDoc->size(ModelAPI_Document::CONSTRUCTIONS_GROUP());
 
   return 0;
 }
@@ -158,12 +158,12 @@ FeaturePtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
   case ParamObject:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(PARAMETERS_GROUP, theIndex.row());
+      return aRootDoc->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
     }
   case ConstructObject:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+      return aRootDoc->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
     }
   }
   return FeaturePtr();
@@ -177,9 +177,9 @@ QModelIndex XGUI_TopDataModel::findParent(const FeaturePtr& theFeature) const
 
 QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup.compare(PARAMETERS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_Document::PARAMETERS_GROUP()) == 0)
     return createIndex(0, 0, (qint32) ParamsFolder);
-  if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_Document::CONSTRUCTIONS_GROUP()) == 0)
     return createIndex(1, 0, (qint32) ConstructFolder);
   return QModelIndex();
 }
@@ -199,9 +199,9 @@ QModelIndex XGUI_TopDataModel::featureIndex(const FeaturePtr& theFeature) const
       }
     }
     if (aRow != -1) {
-      if (aGroup.compare(PARAMETERS_GROUP) == 0)
+      if (aGroup.compare(ModelAPI_Document::PARAMETERS_GROUP()) == 0)
         return createIndex(aRow, 0, (qint32) ParamObject);
-      if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+      if (aGroup.compare(ModelAPI_Document::CONSTRUCTIONS_GROUP()) == 0)
         return createIndex(aRow, 0, (qint32) ConstructObject);
     }
   }
@@ -232,7 +232,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
     case MyRoot:
       {
         DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-        FeaturePtr aFeature = aRootDoc->feature(PARTS_GROUP, myId);
+        FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId);
         if (aFeature)
           return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
       }
@@ -244,19 +244,19 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex));
     case ParamObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
         if (aFeature)
           return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
       }
     case ConstructObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
         if (aFeature)
           return boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature)->getName().c_str();
       }
     case HistoryObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - 3);
         if (aFeature)
           return aFeature->data()->getName().c_str();
       }
@@ -274,13 +274,13 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       return QIcon(":pictures/constr_folder.png");
     case ConstructObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
         if (aFeature)
           return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
       }
     case HistoryObject:
       {
-        FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+        FeaturePtr aFeature = featureDocument()->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - 3);
         if (aFeature)
           return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
       }
@@ -305,18 +305,18 @@ int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const
 {
   if (!parent.isValid()) {
     DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-    if (aRootDoc->feature(PARTS_GROUP, myId))
+    if (aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId))
       return 1;
     else 
       return 0;
   }
   switch (parent.internalId()) {
   case MyRoot:
-    return 3 + featureDocument()->size(FEATURES_GROUP);
+    return 3 + featureDocument()->size(ModelAPI_Document::FEATURES_GROUP());
   case ParamsFolder:
-    return featureDocument()->size(PARAMETERS_GROUP);
+    return featureDocument()->size(ModelAPI_Document::PARAMETERS_GROUP());
   case ConstructFolder:
-    return featureDocument()->size(CONSTRUCTIONS_GROUP);
+    return featureDocument()->size(ModelAPI_Document::CONSTRUCTIONS_GROUP());
   case BodiesFolder:
     return 0;
   }
@@ -383,7 +383,7 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const
 DocumentPtr XGUI_PartDataModel::featureDocument() const
 {
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-  FeaturePtr aFeature = aRootDoc->feature(PARTS_GROUP, myId, true);
+  FeaturePtr aFeature = aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId, true);
   return aFeature->data()->docRef("PartDocument")->value();
 }
  
@@ -393,20 +393,20 @@ FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
   case MyRoot:
     {
       DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-      return aRootDoc->feature(PARTS_GROUP, myId);
+      return aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId);
     }
   case ParamsFolder:
   case ConstructFolder:
   case BodiesFolder:
     return FeaturePtr();
   case ParamObject:
-    return featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+    return featureDocument()->feature(ModelAPI_Document::PARAMETERS_GROUP(), theIndex.row());
   case ConstructObject:
-    return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+    return featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
   //case BodiesObject:
-  //  return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+  //  return featureDocument()->feature(ModelAPI_Document::CONSTRUCTIONS_GROUP(), theIndex.row());
   case HistoryObject:
-    return featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3); 
+    return featureDocument()->feature(ModelAPI_Document::FEATURES_GROUP(), theIndex.row() - 3);
   }
   return FeaturePtr();
 }
@@ -424,9 +424,9 @@ QModelIndex XGUI_PartDataModel::findParent(const FeaturePtr& theFeature) const
 
 QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup.compare(PARAMETERS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_Document::PARAMETERS_GROUP()) == 0)
     return createIndex(0, 0, (qint32) ParamsFolder);
-  if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+  if (theGroup.compare(ModelAPI_Document::CONSTRUCTIONS_GROUP()) == 0)
     return createIndex(1, 0, (qint32) ConstructFolder);
   return QModelIndex();
 }
@@ -434,7 +434,7 @@ QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
 FeaturePtr XGUI_PartDataModel::part() const
 {
   DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
-  return aRootDoc->feature(PARTS_GROUP, myId, true);
+  return aRootDoc->feature(ModelAPI_Document::PARTS_GROUP(), myId, true);
 }
 
 QModelIndex XGUI_PartDataModel::featureIndex(const FeaturePtr& theFeature) const
@@ -446,10 +446,10 @@ QModelIndex XGUI_PartDataModel::featureIndex(const FeaturePtr& theFeature) const
 
     //std::string aGroup = theFeature->getGroup();
     DocumentPtr aDoc = theFeature->document();
-    int aNb = aDoc->size(FEATURES_GROUP);
+    int aNb = aDoc->size(ModelAPI_Document::FEATURES_GROUP());
     int aRow = -1;
     for (int i = 0; i < aNb; i++) {
-      if (aDoc->feature(FEATURES_GROUP, i) == theFeature) {
+      if (aDoc->feature(ModelAPI_Document::FEATURES_GROUP(), i) == theFeature) {
         aRow = i;
         break;
       }
index b5b0b5f6baeeb50b95d9cd621859c12dd4d9cfdf..1044a403aba85a059ed1f3e5c5a9a13a9d38c333 100644 (file)
@@ -296,7 +296,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* the
   bool isDisplayed = false;
   for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
     FeaturePtr aFeature = (*aIt);
-    if (aFeature->getKind() != PARTSET_PART_KIND) {
+    if (aFeature->getKind() != PartSetPlugin_Part::ID()) {
       isDisplayed = myDisplayer->redisplay(aFeature, false);
     }
   }
@@ -314,7 +314,7 @@ void XGUI_Workshop::onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMs
   bool isDisplayed = false;
   for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
     FeaturePtr aFeature = (*aIt);
-    if (aFeature->getKind() == PARTSET_PART_KIND) {
+    if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
       aHasPart = true;
       //break;
     } else {
@@ -903,7 +903,8 @@ void XGUI_Workshop::activateLastPart()
 {
   PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
   DocumentPtr aDoc = aMgr->rootDocument();
-  FeaturePtr aLastPart = aDoc->feature(PARTS_GROUP, aDoc->size(PARTS_GROUP) - 1, true);
+  FeaturePtr aLastPart = aDoc->feature(ModelAPI_Document::PARTS_GROUP(),
+                                       aDoc->size(ModelAPI_Document::PARTS_GROUP()) - 1, true);
   activatePart(aLastPart);
 }
 
@@ -918,7 +919,7 @@ void XGUI_Workshop::deleteFeatures(QFeatureList theList)
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
     aMgr->rootDocument()->startOperation();
     foreach (FeaturePtr aFeature, theList) {
-      if (aFeature->getKind() == PARTSET_PART_KIND) {
+      if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
         DocumentPtr aDoc;
         if (!XGUI_Tools::isModelObject(aFeature)) {
           aDoc = aFeature->data()->docRef("PartDocument")->value();