From: sbh Date: Tue, 15 Jul 2014 13:17:22 +0000 (+0400) Subject: Merge branch 'master' of newgeom:newgeom.git X-Git-Tag: V_0.4.4~185^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3985b767e74385e51d1b503d2c97d3bb1e3f6faa;p=modules%2Fshaper.git Merge branch 'master' of newgeom:newgeom.git 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 --- 3985b767e74385e51d1b503d2c97d3bb1e3f6faa diff --cc src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 0e8fc0b13,0b2f2906b..b232f18e7 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@@ -28,18 -30,21 +30,21 @@@ void FeaturesPlugin_Extrusion::initAttr void FeaturesPlugin_Extrusion::execute() { boost::shared_ptr aFaceRef = - boost::dynamic_pointer_cast(data()->attribute(EXTRUSION_FACE)); + boost::dynamic_pointer_cast(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID())); if (!aFaceRef) return; - FeaturePtr aFaceFeature = aFaceRef->value(); - if (!aFaceFeature) + boost::shared_ptr aConstr = + boost::dynamic_pointer_cast(aFaceRef->value()); + if (!aConstr) return; - boost::shared_ptr aFace = aFaceFeature->data()->shape(); + boost::shared_ptr aFace = aConstr->shape(); if (!aFace) return; - double aSize = data()->real(EXTRUSION_SIZE)->value(); - if (data()->boolean(EXTRUSION_REVERSE)->value()) + double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value(); + if (data()->boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value()) aSize = -aSize; - data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize)); + boost::shared_ptr aResult = document()->createBody(data()); + aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize)); + setResult(aResult); } diff --cc src/FeaturesPlugin/FeaturesPlugin_Extrusion.h index cac857f15,01cb4fe3a..c83bead92 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@@ -11,39 -11,23 +11,35 @@@ class FeaturesPlugin_Extrusion: public ModelAPI_Feature { public: + /// Extrusion kind + inline static const std::string& ID() + { + static const std::string MY_EXTRUSION_ID("Extrusion"); + return MY_EXTRUSION_ID; + } + /// attribute name of referenced face + inline static const std::string& FACE_ID() + { + static const std::string MY_FACE_ID("FeaturesPlugin_Extrusion::FACE_ID()"); + return MY_FACE_ID; + } + /// attribute name of extrusion size + inline static const std::string& SIZE_ID() + { + static const std::string MY_SIZE_ID("FeaturesPlugin_Extrusion::SIZE_ID()"); + return MY_SIZE_ID; + } + /// attribute name of reverse direction + inline static const std::string& REVERSE_ID() + { + static const std::string MY_REVERSE_ID("FeaturesPlugin_Extrusion::REVERSE_ID()"); + return MY_REVERSE_ID; + } + /// Returns the kind of a feature FEATURESPLUGIN_EXPORT virtual const std::string& getKind() - { static std::string MY_KIND = FEATURES_EXTRUSION_KIND; return MY_KIND; } + { static std::string MY_KIND = FeaturesPlugin_Extrusion::ID(); return MY_KIND; } - /// Returns to which group in the document must be added feature - FEATURESPLUGIN_EXPORT virtual const std::string& getGroup() - { static std::string MY_GROUP = "Construction"; return MY_GROUP; } - /// Creates a new part document if needed FEATURESPLUGIN_EXPORT virtual void execute(); diff --cc src/Model/Model_Document.cpp index 1c7015389,79406ba8c..df5c06b23 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@@ -348,45 -344,34 +344,33 @@@ static void AddToRefArray(TDF_Label& th } } - void Model_Document::addFeature(const FeaturePtr theFeature) - + FeaturePtr Model_Document::addFeature(std::string theID) { - if (theFeature->isAction()) return; // do not add action to the data model - - boost::shared_ptr aThis = - Model_Application::getApplication()->getDocument(myID); - TDF_Label aFeaturesLab = groupLabel(ModelAPI_Document::FEATURES_GROUP()); - TDF_Label aFeatureLab = aFeaturesLab.NewChild(); - - // organize feature and data objects - boost::shared_ptr aData(new Model_Data); - aData->setFeature(theFeature); - aData->setLabel(aFeatureLab); - theFeature->setDoc(aThis); - theFeature->setData(aData); - setUniqueName(theFeature); - theFeature->initAttributes(); - - // keep the feature ID to restore document later correctly - TDataStd_Comment::Set(aFeatureLab, theFeature->getKind().c_str()); - myFeatures.push_back(theFeature); - // store feature in the history of features array - if (theFeature->isInHistory()) { - AddToRefArray(aFeaturesLab, aFeatureLab); + TDF_Label anEmptyLab; + FeaturePtr anEmptyFeature; + FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID); + if (aFeature) { + TDF_Label aFeatureLab; + if (!aFeature->isAction()) {// do not add action to the data model + TDF_Label aFeaturesLab = groupLabel(ModelAPI_Feature::group()); + aFeatureLab = aFeaturesLab.NewChild(); + initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS); + // keep the feature ID to restore document later correctly + TDataStd_Comment::Set(aFeatureLab, aFeature->getKind().c_str()); + setUniqueName(aFeature); + myObjs[ModelAPI_Feature::group()].push_back(aFeature); + // store feature in the history of features array + if (aFeature->isInHistory()) { + AddToRefArray(aFeaturesLab, aFeatureLab); + } + } + if (!aFeature->isAction()) {// do not add action to the data model + // event: feature is added + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); + ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); + } } - // add featue to the group - const std::string& aGroup = theFeature->getGroup(); - TDF_Label aGroupLab = groupLabel(aGroup); - AddToRefArray(aGroupLab, aFeatureLab); - // new name of this feature object by default equal to name of feature - TDF_Label anObjLab = aGroupLab.NewChild(); - TCollection_ExtendedString aName(theFeature->data()->getName().c_str()); - TDataStd_Name::Set(anObjLab, aName); - TDF_Label aGrLabChild = aGroupLab.FindChild(1); - AddToRefArray(aGrLabChild, anObjLab); // reference to names is on the first sub - - // event: feature is added - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED); - ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent); + return aFeature; } /// Appenad to the array of references a new referenced label. diff --cc src/PartSet/PartSet_Listener.cpp index 7b642812d,efbc1a706..f94e6c24f --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@@ -65,8 -68,8 +68,8 @@@ void PartSet_Listener::processEvent(con std::set::const_iterator anIt = aGroups.begin(), aLast = aGroups.end(); for (; anIt != aLast; anIt++) { std::string aGroup = *anIt; - if (aGroup.compare(SKETCH_KIND) == 0) { // Update only Sketch group + if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group - myModule->workshop()->displayer()->eraseDeletedFeatures(); + myModule->workshop()->displayer()->eraseDeletedResults(); myModule->updateCurrentPreview(aGroup); } } diff --cc src/PartSet/PartSet_OperationSketch.cpp index df4408dd5,2cccb18a2..c3391efb9 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@@ -143,9 -144,17 +144,17 @@@ std::list PartSet_Operation if (!aData->isValid()) return std::list(); boost::shared_ptr aRefList = - boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_FEATURES)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::FEATURES_ID())); - return aRefList->list(); + std::list aList = aRefList->list(); + std::list::iterator aIt; + std::list aFeaList; + for (aIt = aList.begin(); aIt != aList.end(); ++aIt) { + FeaturePtr aFeature = boost::dynamic_pointer_cast(*aIt); + if (aFeature) + aFeaList.push_back(aFeature); + } + return aFeaList; } void PartSet_OperationSketch::stopOperation() diff --cc src/PartSet/PartSet_TestOCC.cpp index aaa3c3c59,c8b1e0186..df5567aee --- a/src/PartSet/PartSet_TestOCC.cpp +++ b/src/PartSet/PartSet_TestOCC.cpp @@@ -226,4 -227,4 +227,4 @@@ void PartSet_TestOCC::moveMouse(Handle( { theContext->MoveTo(10, 10, theView); theContext->Select(); --} ++} diff --cc src/PartSet/PartSet_Tools.cpp index eb07e5baa,e2c6d3ccc..d0097bd4d --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@@ -275,10 -275,10 +275,10 @@@ void PartSet_Tools::setConstraints(Feat // the constraint is created between the feature point and the found sketch point boost::shared_ptr aData = theSketch->data(); boost::shared_ptr aRefList = - boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_FEATURES)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::FEATURES_ID())); - std::list aFeatures = aRefList->list(); - std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + std::list aFeatures = aRefList->list(); + std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); std::list > anAttiributes; boost::shared_ptr aClickedPoint = boost::shared_ptr (new GeomAPI_Pnt2d(theClickedX, theClickedY)); diff --cc src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 726f6487b,3526f9db1..d1032abf8 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@@ -26,15 -26,15 +26,15 @@@ void PartSetPlugin_Duplicate::initAttri boost::shared_ptr aSource; // searching for source document attribute for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { aSource = boost::dynamic_pointer_cast( - aRoot->feature(getGroup(), a, true)); + 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 aCopy = - aPManager->copy(aSource->data()->docRef(PartSetPlugin_Part::DOC_REF())->value(), data()->getName()); - aRef->setFeature(aSource); - 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); } } } diff --cc src/PartSetPlugin/PartSetPlugin_Remove.cpp index 2aea700f2,d6f2bb23b..ca3173728 --- a/src/PartSetPlugin/PartSetPlugin_Remove.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Remove.cpp @@@ -15,13 -15,14 +15,14 @@@ void PartSetPlugin_Remove::execute( boost::shared_ptr aCurrent; boost::shared_ptr a; for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { - FeaturePtr aFeature = aRoot->feature(getGroup(), a, true); + FeaturePtr aFeature = + boost::dynamic_pointer_cast(aRoot->object(ModelAPI_Feature::group(), a)); - if (aFeature->getKind() == PARTSET_PART_KIND) { + if (aFeature->getKind() == PartSetPlugin_Part::ID()) { boost::shared_ptr aPart = boost::static_pointer_cast(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); } } diff --cc src/SketchPlugin/SketchPlugin_Arc.h index cf57516a5,4603dd922..df87c1e3c --- a/src/SketchPlugin/SketchPlugin_Arc.h +++ b/src/SketchPlugin/SketchPlugin_Arc.h @@@ -16,41 -26,11 +16,37 @@@ class SketchPlugin_Arc: public SketchPlugin_Feature { public: + /// Arc feature kind + inline static const std::string& ID() + { + static const std::string MY_SKETCH_ARC_ID("SketchArc"); + return MY_SKETCH_ARC_ID; + } + + /// Central 2D point of the circle which contains the arc + inline static const std::string& CENTER_ID() + { + static const std::string MY_CENTER_ID = "ArcCenter"; + return MY_CENTER_ID; + } + /// Start 2D point of the arc + inline static const std::string& START_ID() + { + static const std::string MY_START_ID = "ArcStartPoint"; + return MY_START_ID; + } + /// End 2D point of the arc + inline static const std::string& END_ID() + { + static const std::string MY_END_ID = "ArcEndPoint"; + return MY_END_ID; + } + /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_ARC_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_Arc::ID(); return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - - /// Creates a new part document if needed + /// Creates an arc-shape SKETCHPLUGIN_EXPORT virtual void execute(); /// Request for initialization of data model of the feature: adding all attributes diff --cc src/SketchPlugin/SketchPlugin_Circle.h index cf7de0330,c02c79e21..43c2c982a --- a/src/SketchPlugin/SketchPlugin_Circle.h +++ b/src/SketchPlugin/SketchPlugin_Circle.h @@@ -16,35 -24,10 +16,31 @@@ class SketchPlugin_Circle: public SketchPlugin_Feature { public: + /// Circle feature kind + inline static const std::string& ID() + { + static const std::string MY_CIRCLE_ID("SketchCircle"); + return MY_CIRCLE_ID; + } + + /// 2D point - center of the circle + inline static const std::string& CENTER_ID() + { + static const std::string MY_CIRCLE_CENTER_ID("CircleCenter"); + return MY_CIRCLE_CENTER_ID; + } + + /// Radius of the circle + inline static const std::string& RADIUS_ID() + { + static const std::string MY_CIRCLE_RADIUS_ID("CircleRadius"); + return MY_CIRCLE_RADIUS_ID; + } + /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_CIRCLE_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_Circle::ID(); return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index 3a5c2c31d,3af35adfe..3670b45ed --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@@ -20,20 -23,10 +20,16 @@@ class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint { public: + /// Parallel constraint kind + inline static const std::string& ID() + { + static const std::string MY_CONSTRAINT_COINCIDENCE_ID("SketchConstraintCoincidence"); + return MY_CONSTRAINT_COINCIDENCE_ID; + } /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_CONSTRAINT_COINCIDENCE_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_ConstraintCoincidence::ID(); return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 2896843c5,fb5b37b4c..4818f6608 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@@ -104,11 -104,11 +104,11 @@@ boost::shared_ptr boost::shared_ptr anAttr = boost::dynamic_pointer_cast(theData->attribute(theAttribute)); if (anAttr) - aFeature = anAttr->feature(); + aFeature = boost::dynamic_pointer_cast(anAttr->object()); - if (aFeature && aFeature->getKind() == SKETCH_POINT_KIND) + if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) aPointAttr = boost::dynamic_pointer_cast - (aFeature->data()->attribute(POINT_ATTR_COORD)); + (aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); else { if (anAttr->attr()) aPointAttr = boost::dynamic_pointer_cast(anAttr->attr()); diff --cc src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 9a538ab4a,bb324f75b..456ff0569 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@@ -21,21 -24,10 +21,17 @@@ class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint { public: + /// Distance constraint kind + inline static const std::string& ID() + { + static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance"); + return MY_CONSTRAINT_DISTANCE_ID; + } + /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_CONSTRAINT_DISTANCE_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID(); return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 1953add2b,a2f84ae1b..f21aa9979 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@@ -28,12 -28,12 +28,12 @@@ void SketchPlugin_ConstraintLength::ini 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 aRef = - boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - FeaturePtr aFeature = aRef->feature(); + ObjectPtr aFeature = aRef->object(); if (aFeature) { // set length value boost::shared_ptr aPoint1 = @@@ -59,11 -59,11 +59,11 @@@ boost::shared_ptr Sk boost::shared_ptr aPlane = sketch()->plane(); boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); if (!anAttr) return thePrevious; - FeaturePtr aFeature = anAttr->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(anAttr->object()); - if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND) + if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID()) return thePrevious; boost::shared_ptr aFlyOutAttr = diff --cc src/SketchPlugin/SketchPlugin_ConstraintLength.h index 237dc8e86,8e8cd5a47..342bdf1f5 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@@ -21,20 -24,10 +21,16 @@@ class SketchPlugin_ConstraintLength: public SketchPlugin_Constraint { public: + /// Length constraint kind + inline static const std::string& ID() + { + static const std::string MY_CONSTRAINT_LENGTH_ID("SketchConstraintLength"); + return MY_CONSTRAINT_LENGTH_ID; + } /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_CONSTRAINT_LENGTH_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_ConstraintLength::ID(); return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index 15cc861ad,450e0c668..aba3df370 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@@ -44,25 -38,30 +38,30 @@@ boost::shared_ptr Sk boost::shared_ptr aData = data(); boost::shared_ptr anAttr1 = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); boost::shared_ptr anAttr2 = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_B)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); - if (!anAttr1 || !anAttr1->isFeature() || - !anAttr2 || !anAttr2->isFeature()) + if (!anAttr1 || !anAttr1->isObject() || + !anAttr2 || !anAttr2->isObject()) return thePrevious; boost::shared_ptr aLine1Feature = - boost::dynamic_pointer_cast(anAttr1->feature()); + boost::dynamic_pointer_cast(anAttr1->object()); boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(anAttr2->feature()); + boost::dynamic_pointer_cast(anAttr2->object()); if (!aLine1Feature || !aLine2Feature) return thePrevious; boost::shared_ptr aPlane = sketch()->plane(); - boost::shared_ptr aLine1 = aLine1Feature->preview(); - boost::shared_ptr aLine2 = aLine2Feature->preview(); + boost::shared_ptr aLine1, aLine2; + boost::shared_ptr aConst1 = + boost::dynamic_pointer_cast(aLine1Feature->firstResult()); + if (aConst1) aLine1 = aConst1->shape(); + boost::shared_ptr aConst2 = + boost::dynamic_pointer_cast(aLine1Feature->firstResult()); + if (aConst2) aLine2 = aConst2->shape(); boost::shared_ptr aFlyoutAttr = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); boost::shared_ptr aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y()); boost::shared_ptr anAIS = thePrevious; diff --cc src/SketchPlugin/SketchPlugin_ConstraintParallel.h index 52e68fcd0,651016248..acfab864f --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h @@@ -19,20 -22,10 +19,16 @@@ class SketchPlugin_ConstraintParallel: public SketchPlugin_Constraint { public: + /// Parallel constraint kind + inline static const std::string& ID() + { + static const std::string MY_CONSTRAINT_PARALLEL_ID("SketchConstraintParallel"); + return MY_CONSTRAINT_PARALLEL_ID; + } /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_CONSTRAINT_PARALLEL_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_ConstraintParallel::ID(); return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index 012220231,f9764c90b..3f8281208 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@@ -43,16 -38,16 +38,16 @@@ boost::shared_ptr Sk boost::shared_ptr aData = data(); boost::shared_ptr anAttr1 = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); boost::shared_ptr anAttr2 = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_B)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); - if (!anAttr1 || !anAttr1->isFeature() || - !anAttr2 || !anAttr2->isFeature()) + if (!anAttr1 || !anAttr1->isObject() || + !anAttr2 || !anAttr2->isObject()) return thePrevious; boost::shared_ptr aLine1Feature = - boost::dynamic_pointer_cast(anAttr1->feature()); + boost::dynamic_pointer_cast(anAttr1->object()); boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(anAttr2->feature()); + boost::dynamic_pointer_cast(anAttr2->object()); if (!aLine1Feature || !aLine2Feature) return thePrevious; diff --cc src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h index f6970a895,231be4699..eb82abd6f --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h @@@ -19,20 -22,10 +19,16 @@@ class SketchPlugin_ConstraintPerpendicular: public SketchPlugin_Constraint { public: + /// Perpendicular constraint kind + inline static const std::string& ID() + { + static const std::string MY_CONSTRAINT_PERPENDICULAR_ID("SketchConstraintPerpendicular"); + return MY_CONSTRAINT_PERPENDICULAR_ID; + } /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_CONSTRAINT_PERPENDICULAR_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_ConstraintPerpendicular::ID(); return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index 0b4cd5a9b,8dcb9393b..9b412d1c6 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@@ -32,12 -32,12 +32,12 @@@ void SketchPlugin_ConstraintRadius::ini 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 aRef = - boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - FeaturePtr aFeature = aRef->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); if (aFeature) { double aRadius = 0; boost::shared_ptr aData = aFeature->data(); @@@ -70,12 -70,12 +70,12 @@@ boost::shared_ptr Sk boost::shared_ptr aData = data(); boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); if (!anAttr) return thePrevious; - FeaturePtr aFeature = anAttr->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(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 @@@ -129,8 -129,8 +129,8 @@@ void SketchPlugin_ConstraintRadius::mov return; boost::shared_ptr aRef = - boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - FeaturePtr aFeature = aRef->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); if (!aFeature) return; std::string aCenterAttrName; diff --cc src/SketchPlugin/SketchPlugin_ConstraintRadius.h index a3a85d878,26642a49f..a604ef120 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h @@@ -20,19 -23,10 +20,15 @@@ class SketchPlugin_ConstraintRadius: public SketchPlugin_Constraint { public: + /// Radius constraint kind + inline static const std::string& ID() { + static const std::string MY_CONSTRAINT_RADIUS_ID("SketchConstraintRadius"); + return MY_CONSTRAINT_RADIUS_ID; + } /// \brief Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_CONSTRAINT_RADIUS_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_ConstraintRadius::ID(); return MY_KIND;} - /// \brief Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_Feature.cpp index d264007e3,e00ffdd35..ee292a645 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@@ -27,11 -18,11 +18,11 @@@ SketchPlugin_Sketch* SketchPlugin_Featu int aSketches = document()->size("Construction"); for(int a = 0; a < aSketches && !mySketch; a++) { boost::shared_ptr aSketch = boost:: - dynamic_pointer_cast(document()->feature("Construction", a, true)); + dynamic_pointer_cast(document()->object("Construction", a)); if (aSketch) { - std::list aList = - std::list aList = - aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list(); ++ std::list aList = + aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list(); - std::list::iterator aSub = aList.begin(); + std::list::iterator aSub = aList.begin(); for(; aSub != aList.end(); aSub++) { if ((*aSub)->data()->isEqual(data())) { mySketch = aSketch.get(); diff --cc src/SketchPlugin/SketchPlugin_Line.h index 2adb9a833,cce6a25eb..ae301f82f --- a/src/SketchPlugin/SketchPlugin_Line.h +++ b/src/SketchPlugin/SketchPlugin_Line.h @@@ -17,33 -25,10 +17,29 @@@ class SketchPlugin_Line: public SketchPlugin_Feature { public: + /// Arc feature kind + inline static const std::string& ID() + { + static const std::string SKETCH_LINE_ID("SketchLine"); + return SKETCH_LINE_ID; + } + /// Start 2D point of the line + inline static const std::string& START_ID() + { + static const std::string MY_START_ID("StartPoint"); + return MY_START_ID; + } + /// End 2D point of the line + inline static const std::string& END_ID() + { + static const std::string MY_END_ID("EndPoint"); + return MY_END_ID; + } + /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_LINE_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_Line::ID(); return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_Point.h index f4bf4f6a7,4efb76d7c..33ec0467e --- a/src/SketchPlugin/SketchPlugin_Point.h +++ b/src/SketchPlugin/SketchPlugin_Point.h @@@ -17,26 -23,10 +17,22 @@@ class SketchPlugin_Point: public SketchPlugin_Feature { public: + /// Point feature kind + inline static const std::string& ID() + { + static const std::string MY_POINT_ID("SketchPoint"); + return MY_POINT_ID; + } + /// Coordinates of the point + inline static const std::string& COORD_ID() + { + static const std::string MY_COORD_ID("PointCoordindates"); + return MY_COORD_ID; + } /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_POINT_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_Point::ID(); return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = SketchPlugin_Sketch::ID(); return MY_GROUP;} - /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchPlugin/SketchPlugin_Sketch.cpp index b0bf6e9f6,d5e208d5f..dbfb24782 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@@ -40,18 -54,18 +54,18 @@@ void SketchPlugin_Sketch::execute( if (!data()->isValid()) return ; boost::shared_ptr aRefList = - boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_FEATURES)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); boost::shared_ptr anOrigin = - boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_ORIGIN)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); boost::shared_ptr aDirX = - boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_DIRX)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::DIRX_ID())); boost::shared_ptr aDirY = - boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_DIRY)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::DIRY_ID())); boost::shared_ptr aNorm = - boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_NORM)); + boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::NORM_ID())); - std::list > aFeatures = aRefList->list(); + std::list aFeatures = aRefList->list(); if (aFeatures.empty()) return ; diff --cc src/SketchPlugin/SketchPlugin_Sketch.h index 5cde6adad,c1dd3ecc1..5fcab3c8b --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@@ -18,51 -32,10 +18,47 @@@ class SketchPlugin_Sketch: public SketchPlugin_Feature { public: + /// Sketch feature kind + inline static const std::string& ID() + { + static const std::string MY_SKETCH_ID("Sketch"); + return MY_SKETCH_ID; + } + /// Origin point of the sketcher in 3D space + inline static const std::string& ORIGIN_ID() + { + static const std::string MY_ORIGIN_ID("Origin"); + return MY_ORIGIN_ID; + } + /// Vector X inside of the sketch plane + inline static const std::string& DIRX_ID() + { + static const std::string MY_DIRX_ID("DirX"); + return MY_DIRX_ID; + } + /// Vector Y inside of the sketch plane + inline static const std::string& DIRY_ID() + { + static const std::string MY_DIRY_ID("DirY"); + return MY_DIRY_ID; + } + /// Vector Z, normal to the sketch plane + inline static const std::string& NORM_ID() + { + static const std::string MY_NORM_ID("Norm"); + return MY_NORM_ID; + } + /// All features of this sketch (list of references) + inline static const std::string& FEATURES_ID() + { + static const std::string MY_FEATURES_ID("Features"); + return MY_FEATURES_ID; + } + /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SKETCH_KIND; return MY_KIND;} + {static std::string MY_KIND = SketchPlugin_Sketch::ID(); return MY_KIND;} - /// Returns to which group in the document must be added feature - SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = "Construction"; return MY_GROUP;} - /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --cc src/SketchSolver/SketchSolver_Constraint.cpp index 18bd68e2b,1490a091c..05f261a69 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@@ -101,21 -101,22 +101,22 @@@ const int& SketchSolver_Constraint::get { boost::shared_ptr anAttr = boost::dynamic_pointer_cast( - theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr]) + theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)) ); if (!anAttr) continue; - if (anAttr->isFeature() && anAttr->feature()) + if (anAttr->isObject() && anAttr->object()) { // verify posiible entities - const std::string& aKind = anAttr->feature()->getKind(); + const std::string& aKind = boost::dynamic_pointer_cast + (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; } @@@ -156,13 -157,14 +157,14 @@@ { boost::shared_ptr anAttr = boost::dynamic_pointer_cast( - theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr]) + theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)) ); if (!anAttr) continue; - if (anAttr->isFeature() && anAttr->feature() && - anAttr->feature()->getKind().compare(SketchPlugin_Line::ID()) == 0) + if (anAttr->isObject() && anAttr->object() && + boost::dynamic_pointer_cast(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; } } @@@ -181,13 -183,14 +183,14 @@@ { boost::shared_ptr anAttr = boost::dynamic_pointer_cast( - theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr]) + theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)) ); - if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue; - const std::string& aKind = anAttr->feature()->getKind(); + if (!anAttr || !anAttr->isObject() || !anAttr->object()) continue; + const std::string& aKind = boost::dynamic_pointer_cast + (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; } } @@@ -204,13 -207,14 +207,14 @@@ { boost::shared_ptr anAttr = boost::dynamic_pointer_cast( - theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr]) + theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)) ); - if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue; - const std::string& aKind = anAttr->feature()->getKind(); + if (!anAttr || !anAttr->isObject() || !anAttr->object()) continue; + const std::string& aKind = boost::dynamic_pointer_cast + (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; } } diff --cc src/SketchSolver/SketchSolver_ConstraintGroup.cpp index d2f1dcc42,954c6c596..7a06355f4 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@@ -131,14 -118,15 +131,15 @@@ bool SketchSolver_ConstraintGroup::isIn { boost::shared_ptr aCAttrRef = boost::dynamic_pointer_cast( - theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[i]) + theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(i)) ); if (!aCAttrRef) continue; - if (!aCAttrRef->isFeature() && + if (!aCAttrRef->isObject() && myEntityAttrMap.find(aCAttrRef->attr()) != myEntityAttrMap.end()) return true; - if (aCAttrRef->isFeature() && - myEntityFeatMap.find(aCAttrRef->feature()) != myEntityFeatMap.end()) + if (aCAttrRef->isObject() && + myEntityFeatMap.find(boost::dynamic_pointer_cast(aCAttrRef->object())) + != myEntityFeatMap.end()) return true; } @@@ -204,16 -192,17 +205,17 @@@ bool SketchSolver_ConstraintGroup::chan 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 aData = aConstrAttr->feature()->data(); + boost::shared_ptr 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())); - myEntityFeatMap[aConstrAttr->feature()] = 0; // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group + // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group + myEntityFeatMap[boost::dynamic_pointer_cast(aConstrAttr->object())] = 0; break; // there should be no other entities } - else if (aConstrAttr->isFeature()) - aConstrEnt[indAttr] = changeEntity(aConstrAttr->feature()); + else if (aConstrAttr->isObject()) + aConstrEnt[indAttr] = changeEntity(boost::dynamic_pointer_cast(aConstrAttr->object())); else aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr()); } diff --cc src/SketchSolver/SketchSolver_ConstraintManager.cpp index 2976eca8f,3bc8bb085..dbdc7b927 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@@ -59,27 -59,29 +59,29 @@@ SketchSolver_ConstraintManager::~Sketch // ============================================================================ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessage) { - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED) || - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED) || - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED)) + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) || + theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED) || + theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) { - const ModelAPI_FeatureUpdatedMessage* anUpdateMsg = - dynamic_cast(theMessage); - std::set< FeaturePtr > aFeatures = anUpdateMsg->features(); + const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = + dynamic_cast(theMessage); + std::set< ObjectPtr > aFeatures = anUpdateMsg->features(); bool isModifiedEvt = - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED); + theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED); if (!isModifiedEvt) { - std::set< FeaturePtr >::iterator aFeatIter; + std::set< ObjectPtr >::iterator aFeatIter; for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) { + FeaturePtr aFeature = boost::dynamic_pointer_cast(*aFeatIter); + if (!aFeature) continue; // Only sketches and constraints can be added by Create event - const std::string& aFeatureKind = (*aFeatIter)->getKind(); + const std::string& aFeatureKind = aFeature->getKind(); - if (aFeatureKind.compare(SKETCH_KIND) == 0) + if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) { boost::shared_ptr aSketch = - boost::dynamic_pointer_cast(*aFeatIter); + boost::dynamic_pointer_cast(aFeature); if (aSketch) changeWorkplane(aSketch); continue; @@@ -102,16 -104,16 +104,16 @@@ // Solve the set of constraints resolveConstraints(); } - else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) + else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { - const ModelAPI_FeatureDeletedMessage* aDeleteMsg = - dynamic_cast(theMessage); + const ModelAPI_ObjectDeletedMessage* aDeleteMsg = + dynamic_cast(theMessage); const std::set& 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::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()) @@@ -350,9 -352,9 +352,9 @@@ boost::shared_ptr aWPFeatures = - boost::dynamic_pointer_cast(aWP->data()->attribute(SKETCH_ATTR_FEATURES)); + boost::dynamic_pointer_cast(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); - std::list< FeaturePtr > aFeaturesList = aWPFeatures->list(); - std::list< FeaturePtr >::const_iterator anIter; + std::list< ObjectPtr >& aFeaturesList = aWPFeatures->list(); + std::list< ObjectPtr >::const_iterator anIter; for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++) if (*anIter == theConstraint) return aWP; // workplane is found diff --cc src/XGUI/XGUI_PartDataModel.cpp index 82dcc8532,b77297f54..521e193c2 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@@ -97,11 -102,11 +102,10 @@@ int XGUI_TopDataModel::rowCount(const Q DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); if (theParent.internalId() == ParamsFolder) - return aRootDoc->size(ModelAPI_Document::PARAMETERS_GROUP()); + return aRootDoc->size(ModelAPI_ResultParameters::group()); if (theParent.internalId() == ConstructFolder) - return aRootDoc->size(ModelAPI_Document::CONSTRUCTIONS_GROUP()); - + return aRootDoc->size(ModelAPI_ResultConstruction::group()); - return 0; }