]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 13:17:22 +0000 (17:17 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 15 Jul 2014 13:17:22 +0000 (17:17 +0400)
Conflicts:
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_TestOCC.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/PartSetPlugin/PartSetPlugin_Remove.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
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.h
src/SketchPlugin/SketchPlugin_Point.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

54 files changed:
src/Config/Config_WidgetReader.cpp
src/Config/Config_WidgetReader.h
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.h
src/ConstructionPlugin/plugin-Construction.xml
src/ConstructionPlugin/point_widget.xml
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/Model/Model_Document.cpp
src/PartSet/PartSet_Listener.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_DocumentDataModel.cpp
src/XGUI/XGUI_PartDataModel.cpp

index 7ce67a2e7ddc98141d8fb185db846342c0d036ab..f0214657bb339201c81a8ee1d5fda147189b4838 100644 (file)
@@ -14,6 +14,8 @@
 #include <libxml/xpath.h>
 #include <libxml/xmlstring.h>
 
+#include <list>
+
 #ifdef _DEBUG
 #include <iostream>
 #endif
@@ -43,9 +45,9 @@ std::string Config_WidgetReader::featureDescription(const std::string& theFeatur
 void Config_WidgetReader::processNode(xmlNodePtr theNode)
 {
   if (isNode(theNode, NODE_FEATURE, NULL)) {
-    std::string aNodeName = getProperty(theNode, _ID);
-    myWidgetCache[aNodeName] = dumpNode(theNode);
-    myDescriptionCache[aNodeName] = getProperty(theNode, FEATURE_TEXT);
+    myCurrentFeature = getProperty(theNode, _ID);
+    myWidgetCache[myCurrentFeature] = dumpNode(theNode);
+    myDescriptionCache[myCurrentFeature] = getProperty(theNode, FEATURE_TEXT);
   }
   //Process SOURCE nodes.
   Config_XMLReader::processNode(theNode);
@@ -53,7 +55,38 @@ void Config_WidgetReader::processNode(xmlNodePtr theNode)
 
 bool Config_WidgetReader::processChildren(xmlNodePtr theNode)
 {
-  return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
+  //Read all nodes recursively, source and validator nodes have no children
+  return !isNode(theNode, NODE_VALIDATOR, NODE_SOURCE, NULL);
+}
+
+void Config_WidgetReader::resolveSourceNodes(xmlNodePtr theNode)
+{
+  xmlNodePtr aNode = xmlFirstElementChild(theNode);
+  std::list<xmlNodePtr> aSourceNodes;
+  while(aNode != NULL) {
+    if (isNode(aNode, NODE_SOURCE, NULL)) {
+      Config_XMLReader aSourceReader = Config_XMLReader(getProperty(aNode, SOURCE_FILE));
+      xmlNodePtr aSourceRoot = aSourceReader.findRoot();
+      if (!aSourceRoot) {
+        continue;
+      }
+      xmlNodePtr aSourceNode = xmlFirstElementChild(aSourceRoot);
+      xmlNodePtr aTargetNode = xmlDocCopyNodeList(aNode->doc, aSourceNode);
+      while(aTargetNode != NULL) {
+        xmlNodePtr aNextNode = xmlNextElementSibling(aTargetNode);
+        xmlAddPrevSibling(aNode, aTargetNode);
+        aTargetNode = aNextNode;
+      }
+      aSourceNodes.push_back(aNode);
+    }
+    aNode = xmlNextElementSibling(aNode);
+  }
+  //Remove "SOURCE" node.
+  std::list<xmlNodePtr>::iterator it = aSourceNodes.begin();
+  for(; it != aSourceNodes.end(); it++) {
+    xmlUnlinkNode(*it);
+    xmlFreeNode(*it);
+  }
 }
 
 std::string Config_WidgetReader::dumpNode(xmlNodePtr theNode)
@@ -62,19 +95,11 @@ std::string Config_WidgetReader::dumpNode(xmlNodePtr theNode)
   if (!hasChild(theNode)) {
     return result;
   }
-  xmlNodePtr aChildrenNode = xmlFirstElementChild(theNode);
+  //Replace all "source" nodes with content;
+  resolveSourceNodes(theNode);
   xmlBufferPtr buffer = xmlBufferCreate();
-  if (isNode(aChildrenNode, NODE_SOURCE, NULL)) {
-    Config_XMLReader aSourceReader = 
-      Config_XMLReader(getProperty(aChildrenNode, SOURCE_FILE));
-    //Register all validators in the sourced xml
-    aSourceReader.readAll();
-    //Dump!
-    xmlNodePtr aSourceRoot = aSourceReader.findRoot();
-    int size = xmlNodeDump(buffer, aSourceRoot->doc, aSourceRoot, 0, 1);
-  } else {
-    int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
-  }
+  int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 0);
   result = std::string((char*) (buffer->content));
+  xmlBufferFree(buffer);
   return result;
 }
index 96f35ac19a062a46a70075bab2150b115c9a2b1f..c9c2f060267d353e9356dcdfaf6794190abde845 100644 (file)
@@ -28,6 +28,7 @@ protected:
   void processNode(xmlNodePtr theNode);
   bool processChildren(xmlNodePtr theNode);
   std::string dumpNode(xmlNodePtr theNode);
+  void resolveSourceNodes(xmlNodePtr theNode);
 
 private:
   std::map<std::string, std::string> myWidgetCache;
index a9bf87dc617c560383505840f9a2a9f5402cbaf1..8d618b102f0731f9e5d424808d8e67f0aab52719 100644 (file)
@@ -123,9 +123,10 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent)
   xmlNodePtr aNode = theParent->xmlChildrenNode;
   for(; aNode; aNode = aNode->next) {
     //Still no text processing in features...
-    if(isElementNode(aNode)) {
-      processNode(aNode);
+    if(!isElementNode(aNode)) {
+      continue;
     }
+    processNode(aNode);
     if (processChildren(aNode)) {
       readRecursively(aNode);
     }
@@ -163,12 +164,12 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode)
   getValidatorInfo(theNode, aValidatorId, aValidatorParameters);
   aMessage.setValidatorId(aValidatorId);
   aMessage.setValidatorParameters(aValidatorParameters);
-  if(isNode(theNode->parent, NODE_FEATURE, NULL)) {
-    aMessage.setFeatureId(getProperty(theNode->parent, _ID));
+  xmlNodePtr aFeatureOrWdgNode = theNode->parent;
+  if(isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+    aMessage.setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
   } else {
-    xmlNodePtr aWdgNode = theNode->parent;
-    aMessage.setAttributeId(getProperty(aWdgNode, _ID));
-    aMessage.setFeatureId(getProperty(aWdgNode->parent, _ID));
+    aMessage.setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+    aMessage.setFeatureId(myCurrentFeature);
   }
   aEvLoop->send(aMessage);
 }
index 47fc97b7b0d997d17b7ea4c8ce04959d9d37729d..3a8219cdae749d348877a38e552c232edd38b828 100644 (file)
@@ -51,6 +51,9 @@ protected:
   std::string getProperty(xmlNodePtr theNode, const char* property);
   void processValidator(xmlNodePtr theNode);
 
+protected:
+  std::string myCurrentFeature;
+
 protected:
   std::string myDocumentPath;
   xmlDocPtr   myXmlDoc;
index b3fdc4608c6ae1054cff9a91c7201cdf2412605b..0918dc9cda6e82bd48fb23a400b314ce95c1c888 100644 (file)
@@ -2,9 +2,12 @@
   <workbench id="Construction">
     <group id="Basic">
       <feature id="Point" title="Point" tooltip="Create a new point" icon=":icons/point.png">
+        <validator id="test" parameters="x,y,z"/>
         <source path="point_widget.xml"/>
       </feature>
-      <feature id="Axis" title="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true"/>
+      <feature id="Axis" title="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true">
+        <validator id="inside" parameters="a,b"/> 
+      </feature>
       <feature id="Plane" title="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
     </group>
 </workbench>  
index 920d8e0a57cf816450bc972e2e61a0b37445b30c..35397224fd39560d15d452003f5c72c4e8d6cae4 100644 (file)
@@ -1,5 +1,7 @@
 <source>
-  <doublevalue id="x" label="X:" max="50" step="1.0" default="0" icon=":pictures/x_point.png" tooltip="Set X"/>
+  <doublevalue id="x" label="X:" max="50" step="1.0" default="0" icon=":pictures/x_point.png" tooltip="Set X">
+    <validator id="between" parameters="a,b"/> 
+  </doublevalue>
   <doublevalue id="y" label="Y:" min="x" default="1" icon=":pictures/y_point.png" tooltip="Set Y"/>
   <doublevalue id="z" label="Z:" min="-20" step="0.1" default="2" icon=":pictures/z_point.png" tooltip="Set Z"/>
 </source>
index 0b2f2906b9c8892ebf607da60e03cad720c3c3c2..b232f18e7bd732b7f9d0fa8307654beb1b12e3c6 100644 (file)
@@ -22,15 +22,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;
   boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
@@ -41,8 +41,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;
   boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
   aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
index 01cb4fe3a10a0ed63f7703c67759f975995d6aa7..c83bead92edebeb6d6bcdcbbdbb03ea4f46c31a5 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; }
 
   /// Creates a new part document if needed
   FEATURESPLUGIN_EXPORT virtual void execute();
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 79406ba8cd6033bfa359da0c7c8c30aee3d01ddc..df5c06b23c880db1f6284de52ab2f5b87b783f9b 100644 (file)
@@ -344,7 +344,6 @@ static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) {
   }
 }
 
-
 FeaturePtr Model_Document::addFeature(std::string theID)
 {
   TDF_Label anEmptyLab;
index efbc1a706fc661971401aaef2e6a6abc997f6991..f94e6c24f45d7f0b1ac7e90db35ee94e807899e7 100644 (file)
@@ -68,7 +68,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()->eraseDeletedResults();
         myModule->updateCurrentPreview(aGroup);
       }
index 8326bfcbd490833c7b4d9c08da62994c912daac0..f08d83972f67e4fd554625036240b6962221400a 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 e767208aacda5b6c8b2fad5ae62b6f54ed5b2e8a..f3b27594e6362b6cc24dc16c30bd6fac8a940657 100644 (file)
@@ -144,9 +144,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 2cccb18a2fbecd5fa61d3b1ead427b7962009951..c3391efb91641d8bd248b15d0b24e16ba7f12c45 100644 (file)
@@ -144,7 +144,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()));
 
   std::list<ObjectPtr> aList = aRefList->list();
   std::list<ObjectPtr>::iterator aIt;
@@ -184,7 +184,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;
@@ -221,16 +221,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 c8b1e0186e08845add527191753c8a94badbf421..df5567aee9e6ffc55b1d4dd64b3d3cc4678ead72 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(
@@ -227,4 +227,4 @@ void PartSet_TestOCC::moveMouse(Handle(AIS_InteractiveContext) theContext, Handl
 {
   theContext->MoveTo(10, 10, theView);
   theContext->Select();
-}
\ No newline at end of file
+}
index e2c6d3cccf9ef89e77d1ecd7b09789733f5489b2..d0097bd4dedf3036aec6e942ef4894ea3175b513 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<ObjectPtr > aFeatures = aRefList->list();
   std::list<ObjectPtr >::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 3526f9db125b0f78fc45fd7dc6847071fdb76b9b..d1032abf8a29e9c792adbb9cb842f903923c093f 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->object(ModelAPI_Feature::group(), a));
-      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()->name());
+        aPManager->copy(aSource->data()->docRef(PartSetPlugin_Part::DOC_REF())->value(), data()->name());
       aRef->setObject(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 362841fb7fa28d31b0b03b481f716c6a042b1d1b..c8beaeac9bf40be39d76146398cc72cc0a0848fa 100644 (file)
@@ -17,12 +17,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 d6f2bb23b92009610bd83b03cf35ae68130033be..ca31737285e7b2c7b83ad9342b57fe4a7d2db1c9 100644 (file)
@@ -17,12 +17,12 @@ void PartSetPlugin_Remove::execute()
   for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
     FeaturePtr aFeature = 
       boost::dynamic_pointer_cast<ModelAPI_Feature>(aRoot->object(ModelAPI_Feature::group(), a));
-    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 7e2e10979ac1588b777acc982ffc7e602c9007b9..e5eb1f301197d75ec6452a0acc4a73849004dbfb 100644 (file)
@@ -24,9 +24,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() 
@@ -37,10 +37,10 @@ void SketchPlugin_Arc::execute()
 
     // 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
@@ -49,7 +49,7 @@ void SketchPlugin_Arc::execute()
 
       // 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();
@@ -57,7 +57,7 @@ void SketchPlugin_Arc::execute()
 
         // 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(
@@ -90,15 +90,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);
 }
 
@@ -108,17 +108,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 4603dd922012eac6d05b427dedba5e20b748f84c..df87c1e3c2b616895a1ddcdaaa9acda36ba5fad4 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,9 +16,35 @@ 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;}
 
   /// Creates an arc-shape
   SKETCHPLUGIN_EXPORT virtual void execute();
index 0d8b5516bf37bcc87ac0d8e7558c0281f966c7ef..60fd29daf7d9cf6714576c5d08aa4f5cf68af642 100644 (file)
@@ -22,8 +22,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()
@@ -34,9 +34,9 @@ void SketchPlugin_Circle::execute()
 
     // 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
@@ -45,7 +45,7 @@ void SketchPlugin_Circle::execute()
 
       // 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()));
@@ -73,7 +73,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);
 }
 
@@ -81,7 +81,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 c02c79e21941ce1838c581b9c9f69be80abd55bd..43c2c982acb95976e9aa555b4badfd9a173c9439 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,9 +16,30 @@ 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;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 9b6878b33e5f2e0e86e83e3195e868ac5015c4b7..d0a76b1cfd6a7d51fb2fdad963c809d051481147 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,6 +37,60 @@ 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 = 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 3af35adfe9b8c3a6101ccde868025ab0bcee28e6..3670b45ed41c8e5858ea9bccaae22bce112528d3 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 Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index fb5b37b4c448bd1ba7294f4e94633fe34274986f..4818f6608be77bf57e34471bd414b73c520edb16 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 = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
 
-  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 bb324f75b263707ac6b31827412b8189f65ea10d..456ff056943eebb5946a8277da84dd386d724a84 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 Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index a2f84ae1b9e0427db63d888428fe5cc106f65475..f21aa9979389169d7ad90477c555952b0cf1403a 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()));
     ObjectPtr aFeature = aRef->object();
     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 = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
-  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 8e8cd5a478a16104a6a6687018e561031052ecd0..342bdf1f56e631da377950fb5800d14f02575bb0 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 Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 450e0c6682f2ce6fde8f8bd6e6b695a18a6880d0..aba3df37071afd63ec6d27605cb2c4a730ac0351 100644 (file)
@@ -21,9 +21,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()
@@ -38,9 +38,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->isObject() || 
       !anAttr2 || !anAttr2->isObject())
     return thePrevious;
@@ -61,7 +61,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
   if (aConst2) aLine2 = aConst2->shape();
 
   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;
@@ -78,7 +78,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 651016248b8d87aac9c164e6dd0cb847c640397b..acfab864f1c5d93aacbd95cb0aa6ac3318fe7bad 100644 (file)
@@ -9,22 +9,25 @@
 #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 Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index f9764c90bfc0b061a256af5dd3a01af9220f72ba..3f8281208ac998a224fcb6a31633ef40fe6262b1 100644 (file)
@@ -21,9 +21,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()
@@ -38,9 +38,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->isObject() || 
       !anAttr2 || !anAttr2->isObject())
     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 231be46996814081d83328f8bb69a3412796e64f..eb82abd6fc700ebad7a4300b8e92c7786568585c 100644 (file)
@@ -9,22 +9,25 @@
 #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 Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 8dcb9393b2770acf9da1749e7d42c0cdddd7d575..9b412d1c615e44c882f756f091e073903ad43c0a 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 = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
     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 = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
   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 = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
   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 26642a49fd43178a50d1920687930565cfc35577..a604ef1202de0fae5442817ab734e7b9cb4f6321 100644 (file)
@@ -9,23 +9,25 @@
 #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 Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index e00ffdd351c81b1aaeb9aba55ebced4d3ef57745..ee292a645dd5e1b5e6cd9d35cea28db66c262c2d 100644 (file)
@@ -20,8 +20,8 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
       boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
         dynamic_pointer_cast<SketchPlugin_Sketch>(document()->object("Construction", a));
       if (aSketch) {
-        std::list<ObjectPtr> aList = 
-          aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list();
+        std::list<ObjectPtr> aList =
+          aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
         std::list<ObjectPtr>::iterator aSub = aList.begin();
         for(; aSub != aList.end(); aSub++) {
           if ((*aSub)->data()->isEqual(data())) {
index 08289d7de79ee5a32697aae24085e599d7ad794c..63577ef08b4605525090f6ce1e6e7641c17d0dc7 100644 (file)
@@ -26,8 +26,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() 
@@ -36,10 +36,10 @@ void SketchPlugin_Line::execute()
   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()));
@@ -61,11 +61,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);
 }
 
@@ -75,9 +75,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 cce6a25eb781049a404f602b7a9b2ef560fefc32..ae301f82feb38f55a4fe3de2cfa27a8dac8d2f66 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,9 +17,28 @@ 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;}
 
   /// 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 cf57a6c33884bc8d699aaca4435bd3d09f31306b..5143b20a56626beb11434220a8cfa3509f4cbbfc 100644 (file)
@@ -21,7 +21,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() 
@@ -30,7 +30,7 @@ void SketchPlugin_Point::execute()
   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);
@@ -47,7 +47,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);
 }
 
@@ -55,7 +55,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 4efb76d7c7d980cad1f7b58690feb4899ee9478c..33ec0467e244f3ceabf491f40194f3dceed103ca 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,9 +17,21 @@ 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;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index d5e208d5ffbff72e01cfa9500b3d584737c9912f..dbfb247824c0f6c6fed9a1ab6e5cb5edd8fe1721 100644 (file)
@@ -29,11 +29,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() 
@@ -54,16 +54,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<ObjectPtr> aFeatures = aRefList->list();
   if (aFeatures.empty())
@@ -110,7 +110,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
 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,
@@ -126,11 +126,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));
@@ -141,7 +141,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);
 }
@@ -149,9 +149,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 c1dd3ecc1489fb78cb83a6fab472a924589c87d3..5fcab3c8b826ab83255979e70b7f4028acbf0124 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;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 1490a091cc6403b7bde5b41d86ca58c4666fc316..05f261a69f11f1033e8773ceb0b81b496260f8cd 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,22 +101,22 @@ 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->isObject() && anAttr->object())
       { // verify posiible entities
         const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
           (anAttr->object())->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;
         }
@@ -128,7 +128,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
@@ -136,7 +136,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;
         }
       }
@@ -150,21 +150,21 @@ 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->isObject() && anAttr->object() &&
         boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object())->getKind().
-        compare(SKETCH_LINE_KIND) == 0)
+        compare(SketchPlugin_Line::ID()) == 0)
       {
-        myAttributesList[aNbLines++] = CONSTRAINT_ATTRIBUTES[indAttr];
+        myAttributesList[aNbLines++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
         break;
       }
     }
@@ -174,23 +174,23 @@ 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->isObject() || !anAttr->object()) continue;
       const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
         (anAttr->object())->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;
       }
     }
@@ -200,21 +200,21 @@ 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->isObject() || !anAttr->object()) continue;
       const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
         (anAttr->object())->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 954c6c5963fb779fba5116bbe9132eab4e6cba89..7a06355f46a8675171b9cfe72d6652bf602b2cb4 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->isObject() && 
@@ -167,7 +180,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();
@@ -192,11 +205,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->object()->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()));
        // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group
       myEntityFeatMap[boost::dynamic_pointer_cast<ModelAPI_Feature>(aConstrAttr->object())] = 0;
       break; // there should be no other entities
@@ -345,10 +358,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;
@@ -360,10 +373,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;
@@ -376,11 +389,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;
@@ -392,9 +405,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;
@@ -475,7 +488,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;
@@ -491,10 +504,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;
@@ -572,7 +585,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;
@@ -760,7 +773,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 3bc8bb0859573ddd7bb96c1905b0533fa1dc52d8..dbdc7b92791f83a88e3cc7484a2395c8eac8b4fe 100644 (file)
@@ -78,7 +78,7 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
         if (!aFeature) continue;
         // Only sketches and constraints can be added by Create event
         const std::string& aFeatureKind = aFeature->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>(aFeature);
@@ -110,10 +110,10 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
       dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(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())
@@ -261,26 +261,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
 
@@ -352,7 +352,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< ObjectPtr >& aFeaturesList = aWPFeatures->list();
     std::list< ObjectPtr >::const_iterator anIter;
     for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++)
index 24b422421bc2564f4457de2d04670d16b9907cc2..1e62ae84e367d05021044188d12ad1cb2d6a232c 100644 (file)
@@ -554,4 +554,4 @@ QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const
     }
   }
   return QModelIndex();
-}
\ No newline at end of file
+}
index b77297f54b6e8690c8b3e6e2cd83ae50a8387ebb..521e193c21e966ab5ff64ba9049d996fe981535f 100644 (file)
@@ -106,7 +106,6 @@ int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const
 
   if (theParent.internalId() == ConstructFolder)
     return aRootDoc->size(ModelAPI_ResultConstruction::group());
-
   return 0;
 }