void FeaturesPlugin_Extrusion::execute()
{
boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
if (!aFaceRef)
return;
- FeaturePtr aFaceFeature = aFaceRef->value();
- if (!aFaceFeature)
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceRef->value());
+ if (!aConstr)
return;
- boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
+ boost::shared_ptr<GeomAPI_Shape> 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<ModelAPI_ResultBody> aResult = document()->createBody(data());
+ aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
+ setResult(aResult);
}
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();
}
}
- 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<ModelAPI_Document> 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<Model_Data> 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.
std::set<std::string>::const_iterator anIt = aGroups.begin(), aLast = aGroups.end();
for (; anIt != aLast; anIt++) {
std::string aGroup = *anIt;
- if (aGroup.compare(SKETCH_KIND) == 0) { // Update only Sketch group
+ if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group
- myModule->workshop()->displayer()->eraseDeletedFeatures();
+ myModule->workshop()->displayer()->eraseDeletedResults();
myModule->updateCurrentPreview(aGroup);
}
}
if (!aData->isValid())
return std::list<FeaturePtr>();
boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
- return aRefList->list();
+ std::list<ObjectPtr> aList = aRefList->list();
+ std::list<ObjectPtr>::iterator aIt;
+ std::list<FeaturePtr> aFeaList;
+ for (aIt = aList.begin(); aIt != aList.end(); ++aIt) {
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
+ if (aFeature)
+ aFeaList.push_back(aFeature);
+ }
+ return aFeaList;
}
void PartSet_OperationSketch::stopOperation()
{
theContext->MoveTo(10, 10, theView);
theContext->Select();
--}
++}
// the constraint is created between the feature point and the found sketch point
boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
- std::list<FeaturePtr > aFeatures = aRefList->list();
- std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ std::list<ObjectPtr > aFeatures = aRefList->list();
+ std::list<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes;
boost::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = boost::shared_ptr<GeomAPI_Pnt2d>
(new GeomAPI_Pnt2d(theClickedX, theClickedY));
boost::shared_ptr<PartSetPlugin_Part> aSource; // searching for source document attribute
for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
aSource = boost::dynamic_pointer_cast<PartSetPlugin_Part>(
- 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<ModelAPI_Document> 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);
}
}
}
boost::shared_ptr<ModelAPI_Document> aCurrent;
boost::shared_ptr<PartSetPlugin_Part> a;
for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
- FeaturePtr aFeature = aRoot->feature(getGroup(), a, true);
+ 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);
}
}
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
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();
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();
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
if (anAttr)
- aFeature = anAttr->feature();
+ 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());
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();
void SketchPlugin_ConstraintLength::execute()
{
- if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
- !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
+ if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() &&
+ !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = aRef->feature();
+ ObjectPtr aFeature = aRef->object();
if (aFeature) {
// set length value
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
if (!anAttr)
return thePrevious;
- FeaturePtr aFeature = anAttr->feature();
+ 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 =
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();
boost::shared_ptr<ModelAPI_Data> aData = data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
- if (!anAttr1 || !anAttr1->isFeature() ||
- !anAttr2 || !anAttr2->isFeature())
+ if (!anAttr1 || !anAttr1->isObject() ||
+ !anAttr2 || !anAttr2->isObject())
return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
if (!aLine1Feature || !aLine2Feature)
return thePrevious;
boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
- boost::shared_ptr<GeomAPI_Shape> aLine1 = aLine1Feature->preview();
- boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
+ boost::shared_ptr<GeomAPI_Shape> aLine1, aLine2;
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConst1 =
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aLine1Feature->firstResult());
+ if (aConst1) aLine1 = aConst1->shape();
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConst2 =
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aLine1Feature->firstResult());
+ 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;
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();
boost::shared_ptr<ModelAPI_Data> aData = data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
- if (!anAttr1 || !anAttr1->isFeature() ||
- !anAttr2 || !anAttr2->isFeature())
+ if (!anAttr1 || !anAttr1->isObject() ||
+ !anAttr2 || !anAttr2->isObject())
return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
if (!aLine1Feature || !aLine2Feature)
return thePrevious;
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();
void SketchPlugin_ConstraintRadius::execute()
{
- if (data()->attribute(CONSTRAINT_ATTR_ENTITY_A)->isInitialized() &&
- !data()->attribute(CONSTRAINT_ATTR_VALUE)->isInitialized()) {
+ if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() &&
+ !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = aRef->feature();
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
if (aFeature) {
double aRadius = 0;
boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
boost::shared_ptr<ModelAPI_Data> aData = data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
if (!anAttr)
return thePrevious;
- FeaturePtr aFeature = anAttr->feature();
+ 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
return;
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = aRef->feature();
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
if (!aFeature)
return;
std::string aCenterAttrName;
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();
int aSketches = document()->size("Construction");
for(int a = 0; a < aSketches && !mySketch; a++) {
boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
- dynamic_pointer_cast<SketchPlugin_Sketch>(document()->feature("Construction", a, true));
+ dynamic_pointer_cast<SketchPlugin_Sketch>(document()->object("Construction", a));
if (aSketch) {
- std::list<FeaturePtr > aList =
- 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<FeaturePtr >::iterator aSub = aList.begin();
+ std::list<ObjectPtr>::iterator aSub = aList.begin();
for(; aSub != aList.end(); aSub++) {
if ((*aSub)->data()->isEqual(data())) {
mySketch = aSketch.get();
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();
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();
if (!data()->isValid())
return ;
boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SKETCH_ATTR_FEATURES));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SKETCH_ATTR_ORIGIN));
+ boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
boost::shared_ptr<GeomDataAPI_Dir> aDirX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRX));
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
boost::shared_ptr<GeomDataAPI_Dir> aDirY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRY));
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
boost::shared_ptr<GeomDataAPI_Dir> aNorm =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
- std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
+ std::list<ObjectPtr> aFeatures = aRefList->list();
if (aFeatures.empty())
return ;
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();
{
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+ theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
);
if (!anAttr) continue;
- if (anAttr->isFeature() && anAttr->feature())
+ if (anAttr->isObject() && anAttr->object())
{ // verify posiible entities
- const std::string& aKind = anAttr->feature()->getKind();
+ 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;
}
{
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+ theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
);
if (!anAttr) continue;
- if (anAttr->isFeature() && anAttr->feature() &&
- anAttr->feature()->getKind().compare(SketchPlugin_Line::ID()) == 0)
+ 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;
}
}
{
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+ theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
);
- if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
- const std::string& aKind = anAttr->feature()->getKind();
+ if (!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;
}
}
{
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
+ theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr))
);
- if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
- const std::string& aKind = anAttr->feature()->getKind();
+ if (!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;
}
}
{
boost::shared_ptr<ModelAPI_AttributeRefAttr> aCAttrRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[i])
+ theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(i))
);
if (!aCAttrRef) continue;
- if (!aCAttrRef->isFeature() &&
+ 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<ModelAPI_Feature>(aCAttrRef->object()))
+ != myEntityFeatMap.end())
return true;
}
if (!aConstrAttr) continue;
// For the length constraint the start and end points of the line should be added to the entities list instead of line
- if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SKETCH_CONSTRAINT_LENGTH_KIND) == 0)
+ if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SketchPlugin_ConstraintLength::ID()) == 0)
{
- boost::shared_ptr<ModelAPI_Data> aData = aConstrAttr->feature()->data();
+ 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()));
- 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<ModelAPI_Feature>(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<ModelAPI_Feature>(aConstrAttr->object()));
else
aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr());
}
// ============================================================================
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<const ModelAPI_FeatureUpdatedMessage*>(theMessage);
- std::set< FeaturePtr > aFeatures = anUpdateMsg->features();
+ const ModelAPI_ObjectUpdatedMessage* anUpdateMsg =
+ dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(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<ModelAPI_Feature>(*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<SketchPlugin_Feature> aSketch =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
if (aSketch)
changeWorkplane(aSketch);
continue;
// 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<const ModelAPI_FeatureDeletedMessage*>(theMessage);
+ const ModelAPI_ObjectDeletedMessage* aDeleteMsg =
+ 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())
continue;
boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SKETCH_ATTR_FEATURES));
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
- std::list< FeaturePtr > aFeaturesList = aWPFeatures->list();
- std::list< FeaturePtr >::const_iterator anIter;
+ 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
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;
}