boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
if (!aFaceRef)
return;
- FeaturePtr aFaceFeature = aFaceRef->value();
- if (!aFaceFeature)
- return;
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceFeature->firstResult());
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceRef->value());
if (!aConstr)
return;
boost::shared_ptr<GeomAPI_Shape> aFace = aConstr->shape();
using namespace std;
-bool Model_AttributeRefAttr::isFeature()
+bool Model_AttributeRefAttr::isObject()
{
return myID->Get().Length() == 0;
}
boost::shared_ptr<Model_Data> aData =
boost::dynamic_pointer_cast<Model_Data>(theAttr->owner()->data());
string anID = aData->id(theAttr);
- if (myIsInitialized && feature() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
+ if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
return; // nothing is changed
myRef->Set(aData->label());
boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
{
- FeaturePtr aFeature = feature();
- if (aFeature) {
+ ObjectPtr anObj = object();
+ if (anObj) {
boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(aFeature->data());
+ boost::dynamic_pointer_cast<Model_Data>(anObj->data());
return aData->attribute(TCollection_AsciiString(myID->Get()).ToCString());
}
// not initialized
return boost::shared_ptr<ModelAPI_Attribute>();
}
-void Model_AttributeRefAttr::setFeature(FeaturePtr theFeature)
+void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
{
- if (!myIsInitialized || myID->Get().Length() != 0 || feature() != theFeature) {
+ if (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject) {
boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+ boost::dynamic_pointer_cast<Model_Data>(theObject->data());
myRef->Set(aData->label());
myID->Set(""); // feature is identified by the empty ID
owner()->data()->sendAttributeUpdated(this);
}
}
-FeaturePtr Model_AttributeRefAttr::feature()
+ObjectPtr Model_AttributeRefAttr::object()
{
if (myRef->Get() != myRef->Label()) { // initialized
boost::shared_ptr<Model_Document> aDoc =
boost::dynamic_pointer_cast<Model_Document>(owner()->document());
if (aDoc) {
TDF_Label aRefLab = myRef->Get();
- TDF_Label aFeatureLab = aRefLab.Father();
- return aDoc->feature(aRefLab);
+ TDF_Label anObjLab = aRefLab.Father();
+ return aDoc->object(aRefLab);
}
}
// not initialized
- return FeaturePtr();
+ return ObjectPtr();
}
Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel)
///< ID of the referenced attirbute (empty if this is a reference to a feature)
Handle_TDataStd_Comment myID;
public:
- /// Returns true if this attribute references to a feature (not to the attribute)
- MODEL_EXPORT virtual bool isFeature();
+ /// Returns true if this attribute references to a object (not to the attribute)
+ MODEL_EXPORT virtual bool isObject();
/// Defines the reference to the attribute
MODEL_EXPORT virtual void setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr);
/// Returns attribute referenced from this attribute
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr();
- /// Defines the reference to the feature
- MODEL_EXPORT virtual void setFeature(FeaturePtr theFeature);
+ /// Defines the reference to the object
+ MODEL_EXPORT virtual void setObject(ObjectPtr theFeature);
- /// Returns feature referenced from this attribute
- MODEL_EXPORT virtual FeaturePtr feature();
+ /// Returns object referenced from this attribute
+ MODEL_EXPORT virtual ObjectPtr object();
protected:
/// Objects are created for features automatically
using namespace std;
-void Model_AttributeRefList::append(FeaturePtr theFeature)
+void Model_AttributeRefList::append(ObjectPtr theObject)
{
boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+ boost::dynamic_pointer_cast<Model_Data>(theObject->data());
myRef->Append(aData->label());
owner()->data()->sendAttributeUpdated(this);
}
-void Model_AttributeRefList::remove(FeaturePtr theFeature)
+void Model_AttributeRefList::remove(ObjectPtr theObject)
{
boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+ boost::dynamic_pointer_cast<Model_Data>(theObject->data());
myRef->Remove(aData->label());
owner()->data()->sendAttributeUpdated(this);
return myRef->Extent();
}
-list<FeaturePtr> Model_AttributeRefList::list()
+list<ObjectPtr> Model_AttributeRefList::list()
{
- std::list< FeaturePtr > aResult;
+ std::list< ObjectPtr > aResult;
boost::shared_ptr<Model_Document> aDoc =
boost::dynamic_pointer_cast<Model_Document>(owner()->document());
if (aDoc) {
const TDF_LabelList& aList = myRef->List();
for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
- aResult.push_back(aDoc->feature(aLIter.Value()));
+ aResult.push_back(aDoc->object(aLIter.Value()));
}
}
return aResult;
Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
public:
/// Appends the feature to the end of a list
- MODEL_EXPORT virtual void append(FeaturePtr theFeature);
+ MODEL_EXPORT virtual void append(ObjectPtr theObject);
/// Erases the first meet of the feature in the list
- MODEL_EXPORT virtual void remove(FeaturePtr theFeature);
+ MODEL_EXPORT virtual void remove(ObjectPtr theObject);
/// Returns number of features in the list
MODEL_EXPORT virtual int size();
/// Returns the list of features
- MODEL_EXPORT virtual std::list<FeaturePtr > list();
+ MODEL_EXPORT virtual std::list<ObjectPtr > list();
protected:
/// Objects are created for features automatically
using namespace std;
-void Model_AttributeReference::setValue(FeaturePtr theFeature)
+void Model_AttributeReference::setValue(ObjectPtr theObject)
{
- if (!myIsInitialized || value() != theFeature) {
+ if (!myIsInitialized || value() != theObject) {
boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+ boost::dynamic_pointer_cast<Model_Data>(theObject->data());
if (myRef.IsNull()) {
boost::shared_ptr<Model_Data> aMyData =
boost::dynamic_pointer_cast<Model_Data>(owner()->data());
}
}
-FeaturePtr Model_AttributeReference::value()
+ObjectPtr Model_AttributeReference::value()
{
if (!myRef.IsNull()) {
boost::shared_ptr<Model_Document> aDoc =
boost::dynamic_pointer_cast<Model_Document>(owner()->document());
if (aDoc) {
TDF_Label aRefLab = myRef->Get();
- return aDoc->feature(aRefLab);
+ return aDoc->object(aRefLab);
}
}
// not initialized
{
Handle_TDF_Reference myRef; ///< references to the feature label
public:
- /// Defines the feature referenced from this attribute
- MODEL_EXPORT virtual void setValue(FeaturePtr theFeature);
+ /// Defines the object referenced from this attribute
+ MODEL_EXPORT virtual void setValue(ObjectPtr theObject);
- /// Returns feature referenced from this attribute
- MODEL_EXPORT virtual FeaturePtr value();
+ /// Returns object referenced from this attribute
+ MODEL_EXPORT virtual ObjectPtr value();
protected:
/// Objects are created for features automatically
return FeaturePtr(); // not found
}
+ObjectPtr Model_Document::object(TDF_Label& theLabel)
+{
+ // iterate all features, may be optimized later by keeping labels-map
+ std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
+ vector<ObjectPtr>::iterator aFIter = aVec.begin();
+ for(; aFIter != aVec.end(); aFIter++) {
+ boost::shared_ptr<Model_Data> aData =
+ boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
+ if (aData->label().IsEqual(theLabel))
+ return *aFIter;
+ list<boost::shared_ptr<ModelAPI_Result> >& aResults =
+ boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
+ list<boost::shared_ptr<ModelAPI_Result> >::iterator aRIter = aResults.begin();
+ for(; aRIter != aResults.end(); aRIter++) {
+ boost::shared_ptr<Model_Data> aResData =
+ boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
+ if (aResData->label().IsEqual(theLabel))
+ return *aRIter;
+ }
+ }
+ return FeaturePtr(); // not found
+}
+
boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
{
// just store sub-document identifier here to manage it later
//! \param theLabel base label of the feature
MODEL_EXPORT virtual FeaturePtr feature(TDF_Label& theLabel);
+ //! Returns the existing object: result or feature
+ //! \param theLabel base label of the object
+ MODEL_EXPORT virtual ObjectPtr object(TDF_Label& theLabel);
+
//! Adds a new sub-document by the identifier, or returns existing one if it is already exist
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
for(; aDIter != aDocs.end(); aDIter++) {
int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group());
for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
- boost::shared_ptr<ModelAPI_Feature> aFeature =
- boost::dynamic_pointer_cast<ModelAPI_Feature>((*aDIter)->object(ModelAPI_Feature::group(), aFIndex));
+ boost::shared_ptr<ModelAPI_Object> aFeature = boost::dynamic_pointer_cast<ModelAPI_Object>
+ ((*aDIter)->object(ModelAPI_Feature::group(), aFIndex));
if (aFeature)
- updateFeature(aFeature);
+ updateObject(aFeature);
}
}
myUpdated.clear();
Events_Loop::loop()->flush(EVENT_DISP);
}
-bool Model_Update::updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
{
// check it is already processed
- if (myUpdated.find(theFeature) != myUpdated.end())
- return myUpdated[theFeature];
+ if (myUpdated.find(theObject) != myUpdated.end())
+ return myUpdated[theObject];
// check all features this feature depended on (recursive call of updateFeature)
- bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end();
- // references
- list<boost::shared_ptr<ModelAPI_Attribute> > aRefs =
- theFeature->data()->attributes(ModelAPI_AttributeReference::type());
- list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
- for(; aRefsIter != aRefs.end(); aRefsIter++) {
- boost::shared_ptr<ModelAPI_Feature> aSub =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
- if (aSub && aSub != theFeature && updateFeature(aSub))
- aMustbeUpdated = true;
- }
- // lists of references
- aRefs = theFeature->data()->attributes(ModelAPI_AttributeRefList::type());
- for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
- list<FeaturePtr> aListRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
- list<FeaturePtr>::iterator aListIter = aListRef.begin();
- for(; aListIter != aListRef.end(); aListIter++) {
- boost::shared_ptr<ModelAPI_Feature> aSub = *aListIter;
- if (aSub && updateFeature(aSub))
+ bool anExecute = myInitial.find(theObject) != myInitial.end();
+ bool aMustbeUpdated = myInitial.find(theObject) != myInitial.end();
+ FeaturePtr aRealFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ if (aRealFeature) { // only real feature contains references to other objects
+ // references
+ list<boost::shared_ptr<ModelAPI_Attribute> > aRefs =
+ theObject->data()->attributes(ModelAPI_AttributeReference::type());
+ list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
+ for(; aRefsIter != aRefs.end(); aRefsIter++) {
+ boost::shared_ptr<ModelAPI_Object> aSub =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
+ if (aSub && aSub != theObject && updateObject(aSub))
aMustbeUpdated = true;
}
+ // lists of references
+ aRefs = theObject->data()->attributes(ModelAPI_AttributeRefList::type());
+ for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+ list<ObjectPtr> aListRef =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
+ list<ObjectPtr>::iterator aListIter = aListRef.begin();
+ for(; aListIter != aListRef.end(); aListIter++) {
+ boost::shared_ptr<ModelAPI_Object> aSub = *aListIter;
+ if (aSub && updateObject(aSub))
+ aMustbeUpdated = true;
+ }
+ }
+ // execute feature if it must be updated
+ anExecute = aMustbeUpdated || anExecute;
+ if (anExecute) {
+ aRealFeature->execute();
+ static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ ModelAPI_EventCreator::get()->sendUpdated(theObject, EVENT_DISP);
+ }
}
- // execute feature if it must be updated
- bool anExecute = aMustbeUpdated || myInitial.find(theFeature) != myInitial.end();
- if (anExecute) {
- theFeature->execute();
- static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
- }
- myUpdated[theFeature] = anExecute;
+ myUpdated[theObject] = anExecute;
return anExecute;
}
MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage);
protected:
- /// Recoursively checks and updates the feature if needed
- /// Returns true if feature was updated.
- bool updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+ /// Recoursively checks and updates the object if needed
+ /// Returns true if object was updated.
+ bool updateObject(boost::shared_ptr<ModelAPI_Object> theObject);
};
#endif
class ModelAPI_AttributeRefAttr : public ModelAPI_Attribute
{
public:
- /// Returns true if this attribute references to a feature (not to the attribute)
- MODELAPI_EXPORT virtual bool isFeature() = 0;
+ /// Returns true if this attribute references to a object (not to the attribute)
+ MODELAPI_EXPORT virtual bool isObject() = 0;
/// Defines the reference to the attribute
MODELAPI_EXPORT virtual void setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr) = 0;
/// Returns attribute referenced from this attribute
MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr() = 0;
- /// Defines the reference to the feature
- MODELAPI_EXPORT virtual void setFeature(FeaturePtr theFeature) = 0;
+ /// Defines the reference to the object
+ MODELAPI_EXPORT virtual void setObject(ObjectPtr theFeature) = 0;
- /// Returns feature referenced from this attribute
- MODELAPI_EXPORT virtual FeaturePtr feature() = 0;
+ /// Returns object referenced from this attribute
+ MODELAPI_EXPORT virtual ObjectPtr object() = 0;
/// Returns the type of this class of attributes
MODELAPI_EXPORT static std::string type() {return "RefAttr";}
MODELAPI_EXPORT virtual std::string attributeType() {return type();}
/// Appends the feature to the end of a list
- MODELAPI_EXPORT virtual void append(FeaturePtr theFeature) = 0;
+ MODELAPI_EXPORT virtual void append(ObjectPtr theObject) = 0;
/// Erases the first meet of the feature in the list
- MODELAPI_EXPORT virtual void remove(FeaturePtr theFeature) = 0;
+ MODELAPI_EXPORT virtual void remove(ObjectPtr theObject) = 0;
/// Returns number of features in the list
MODELAPI_EXPORT virtual int size() = 0;
/// Returns the list of features
- MODELAPI_EXPORT virtual std::list<FeaturePtr > list() = 0;
+ MODELAPI_EXPORT virtual std::list<ObjectPtr > list() = 0;
protected:
/// Objects are created for features automatically
class ModelAPI_AttributeReference : public ModelAPI_Attribute
{
public:
- /// Defines the feature referenced from this attribute
- MODELAPI_EXPORT virtual void setValue(FeaturePtr theFeature) = 0;
+ /// Defines the object referenced from this attribute
+ MODELAPI_EXPORT virtual void setValue(ObjectPtr theObject) = 0;
- /// Returns feature referenced from this attribute
- MODELAPI_EXPORT virtual FeaturePtr value() = 0;
+ /// Returns object referenced from this attribute
+ MODELAPI_EXPORT virtual ObjectPtr value() = 0;
/// Returns the type of this class of attributes
MODELAPI_EXPORT static std::string type() {return "Reference";}
if (aSource) {
boost::shared_ptr<ModelAPI_Document> aCopy =
aPManager->copy(aSource->data()->docRef(PART_ATTR_DOC_REF)->value(), data()->name());
- aRef->setFeature(aSource);
+ aRef->setObject(aSource);
}
}
}
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)
aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
- FeaturePtr aFeature = aRef->feature();
+ ObjectPtr aFeature = aRef->object();
if (aFeature) {
// set length value
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_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)
return thePrevious;
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_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::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_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<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_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::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_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)
return thePrevious;
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
- FeaturePtr aFeature = aRef->feature();
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
if (!aFeature)
return;
std::string aCenterAttrName;
boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
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<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();
boost::shared_ptr<GeomDataAPI_Dir> aNorm =
boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
- std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
+ std::list<ObjectPtr> aFeatures = aRefList->list();
if (aFeatures.empty())
return ;
- std::list<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
- aLast = aFeatures.end();
-
+ std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
boost::shared_ptr<SketchPlugin_Feature> aFeature;
std::list< boost::shared_ptr<GeomAPI_Shape> > aFeaturesPreview;
for (; anIt != aLast; anIt++) {
theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[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)
{
myAttributesList[aNbPoints++] = CONSTRAINT_ATTRIBUTES[indAttr];
theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
);
if (!anAttr) continue;
- if (anAttr->isFeature() && anAttr->feature() &&
- anAttr->feature()->getKind().compare(SKETCH_LINE_KIND) == 0)
+ if (anAttr->isObject() && anAttr->object() &&
+ boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object())->getKind().
+ compare(SKETCH_LINE_KIND) == 0)
{
myAttributesList[aNbLines++] = CONSTRAINT_ATTRIBUTES[indAttr];
break;
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[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)
{
myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[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)
{
myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[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;
}
// 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)
{
- 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));
- 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());
}
bool isUpd = (*anAttrIter == theEntity);
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
- if (aRefAttr && !aRefAttr->isFeature() && aRefAttr->attr() == theEntity)
+ if (aRefAttr && !aRefAttr->isObject() && aRefAttr->attr() == theEntity)
isUpd = true;
if (isUpd)
{
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
- if (aRefAttr && aRefAttr->isFeature() && aRefAttr->feature() == theFeature)
+ if (aRefAttr && aRefAttr->isObject() && aRefAttr->object() == theFeature)
{
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent);
boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SKETCH_ATTR_FEATURES));
- 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