24 #include <ModelAPI_Attribute.h>
25 #include <ModelAPI_AttributeBoolean.h>
26 #include <ModelAPI_AttributeDocRef.h>
27 #include <ModelAPI_AttributeDouble.h>
28 #include <ModelAPI_AttributeInteger.h>
29 #include <ModelAPI_AttributeRefAttr.h>
30 #include <ModelAPI_AttributeReference.h>
31 #include <ModelAPI_AttributeRefList.h>
32 #include <ModelAPI_AttributeRefAttrList.h>
33 #include <ModelAPI_AttributeString.h>
34 #include <ModelAPI_AttributeStringArray.h>
35 #include <ModelAPI_AttributeIntArray.h>
36 #include <ModelAPI_AttributeImage.h>
37 #include <ModelAPI_Data.h>
38 #include <ModelAPI_Feature.h>
39 #include <ModelAPI_Folder.h>
40 #include <ModelAPI_Object.h>
42 #include <TDF_Label.hxx>
43 #include <TDataStd_BooleanArray.hxx>
63 typedef std::map<std::string, std::pair<std::shared_ptr<ModelAPI_Attribute>,
int> > AttributeMap;
70 Handle(TDataStd_BooleanArray) myFlags;
76 std::set<AttributePtr> myRefsToMe;
78 bool mySendAttributeUpdated;
80 std::list<ModelAPI_Attribute*> myWasChangedButBlocked;
98 friend class Model_SelectionNaming;
107 MODEL_EXPORT
virtual std::wstring
name();
109 MODEL_EXPORT
virtual std::wstring
name(std::shared_ptr<GeomAPI_Shape> theSubShape);
111 MODEL_EXPORT
virtual void setName(
const std::wstring& theName);
115 MODEL_EXPORT
virtual std::string
version();
117 MODEL_EXPORT
virtual void setVersion(
const std::string& theVersion);
119 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeDocRef>
document(
const std::string& theID);
121 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeDouble>
real(
const std::string& theID);
124 std::shared_ptr<ModelAPI_AttributeDoubleArray>
realArray(
const std::string& theID);
126 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeInteger>
127 integer(
const std::string& theID);
129 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeReference>
132 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeSelection>
135 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeSelectionList>
138 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeRefAttr>
139 refattr(
const std::string& theID);
141 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeRefList>
142 reflist(
const std::string& theID);
145 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeRefAttrList>
148 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeBoolean>
149 boolean(
const std::string& theID);
151 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeString>
152 string(
const std::string& theID);
154 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeIntArray>
157 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeStringArray>
160 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeTables>
161 tables(
const std::string& theID);
163 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_AttributeImage>
164 image(
const std::string& theID);
168 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_Attribute>
attribute(
const std::string& theID);
171 MODEL_EXPORT
virtual std::list<std::shared_ptr<ModelAPI_Attribute> >
175 MODEL_EXPORT
virtual std::list<std::string>
attributesIDs(
const std::string& theType);
179 MODEL_EXPORT
virtual const std::string&
id(
const std::shared_ptr<ModelAPI_Attribute>& theAttr);
181 MODEL_EXPORT
virtual bool isEqual(
const std::shared_ptr<ModelAPI_Data>& theData);
183 MODEL_EXPORT
virtual bool isValid();
188 return myLab.IsNull() ? myLab : myLab.Father().FindChild(2);
198 MODEL_EXPORT
virtual AttributePtr
199 addAttribute(
const std::string& theID,
const std::string theAttrType,
const int theIndex = -1);
205 MODEL_EXPORT
virtual AttributePtr
207 const std::string& theGroup);
210 MODEL_EXPORT
virtual void allGroups(std::list<std::string>& theGroups);
214 std::list<std::shared_ptr<ModelAPI_Attribute> >& theAttrs);
229 const bool theBlock,
const bool theSendMessage =
true);
232 MODEL_EXPORT
void setLabel(TDF_Label theLab);
235 MODEL_EXPORT
virtual void setObject(ObjectPtr theObject)
237 myObject = theObject;
241 MODEL_EXPORT
virtual void erase();
244 MODEL_EXPORT
virtual void execState(
const ModelAPI_ExecState theState);
247 MODEL_EXPORT
virtual ModelAPI_ExecState
execState();
250 MODEL_EXPORT
virtual void setError(
const std::string& theError,
bool theSend =
true);
256 MODEL_EXPORT
virtual std::string
error()
const;
259 MODEL_EXPORT
virtual int featureId()
const;
262 MODEL_EXPORT
virtual const std::set<AttributePtr>&
refsToMe() {
return myRefsToMe;}
268 std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
271 MODEL_EXPORT
virtual void copyTo(std::shared_ptr<ModelAPI_Data> theTarget);
274 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_Data>
invalidPtr();
277 static std::shared_ptr<ModelAPI_Data>
invalidData();
280 MODEL_EXPORT
virtual int updateID();
284 MODEL_EXPORT
virtual void setUpdateID(
const int theID);
288 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_Object>
owner();
301 MODEL_EXPORT
virtual void setIsDeleted(
const bool theFlag);
310 void removeBackReference(ObjectPtr theObject, std::string theAttrID);
313 void removeBackReference(AttributePtr theAttr);
318 void addBackReference(FeaturePtr theFeature, std::string theAttrID,
319 const bool theApplyConcealment =
true);
323 void addBackReference(ObjectPtr theObject, std::string theAttrID);
326 MODEL_EXPORT
virtual void updateConcealmentFlag();
331 MODEL_EXPORT
virtual bool isDisplayed();
335 MODEL_EXPORT
virtual void setDisplayed(
const bool theDisplay);
338 MODEL_EXPORT
virtual bool isPrecedingAttribute(
const std::string& theAttribute1,
339 const std::string& theAttribute2)
const;
345 #define ADD_BACK_REF(TARGET) \
346 if (TARGET.get() != NULL) { \
347 std::shared_ptr<Model_Data> aTargetData = \
348 std::dynamic_pointer_cast<Model_Data>((TARGET)->data()); \
349 FeaturePtr anAttributeOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner()); \
350 if (anAttributeOwnerFeature.get()) \
351 aTargetData->addBackReference(anAttributeOwnerFeature, id(), false); \
353 FolderPtr anAttributeOwnerFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(owner()); \
354 if (anAttributeOwnerFolder.get()) \
355 aTargetData->addBackReference(ObjectPtr(anAttributeOwnerFolder), id()); \
361 #define REMOVE_BACK_REF(TARGET) \
362 if (TARGET.get() != NULL) { \
363 std::shared_ptr<Model_Data> aTargetData = \
364 std::dynamic_pointer_cast<Model_Data>((TARGET)->data()); \
365 FeaturePtr anAttOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner()); \
366 if (anAttOwnerFeature.get()) \
367 aTargetData->removeBackReference(anAttOwnerFeature, id()); \
369 FolderPtr anAttributeOwnerFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(owner()); \
370 if (anAttributeOwnerFolder.get()) \
371 aTargetData->removeBackReference(ObjectPtr(anAttributeOwnerFolder), id()); \
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
General object of the application that allows to get/set attributes from the document and compute res...
Definition: ModelAPI_Data.h:73
Attribute that contains list of references to features (located in the same document) or references t...
Definition: Model_AttributeRefAttrList.h:38
Attribute that contains reference to an attribute of a feature (located in the same document).
Definition: Model_AttributeRefAttr.h:36
Attribute that contains list of references to features, may be located in different documents.
Definition: Model_AttributeRefList.h:37
Attribute that contains reference to feature (located in the same document).
Definition: Model_AttributeReference.h:35
Attribute that contains list of references to the sub-shapes with possibility to manage them.
Definition: Model_AttributeSelectionList.h:38
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: Model_AttributeSelection.h:40
General object of the application that allows to get/set attributes from the document and compute res...
Definition: Model_Data.h:62
Model_Data()
The simplest constructor. "setLabel" must be called just after to initialize correctly.
Definition: Model_Data.cpp:95
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeDocRef > document(const std::string &theID)
Returns the attribute that references to another document.
Definition: Model_Data.cpp:392
virtual MODEL_EXPORT void setName(const std::wstring &theName)
Defines the name of the feature visible by the user in the object browser.
Definition: Model_Data.cpp:150
virtual MODEL_EXPORT void copyTo(std::shared_ptr< ModelAPI_Data > theTarget)
Copies all attributes content into theTarget data.
Definition: Model_Data.cpp:860
virtual MODEL_EXPORT void setUpdateID(const int theID)
Identifier of the transaction when object (feature or result) was updated last time.
Definition: Model_Data.cpp:597
virtual MODEL_EXPORT void setObject(ObjectPtr theObject)
Sets the object of this data.
Definition: Model_Data.h:235
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeRefList > reflist(const std::string &theID)
Returns the attribute that contains list of references to features.
Definition: Model_Data.cpp:402
virtual MODEL_EXPORT void setError(const std::string &theError, bool theSend=true)
Registers error during the execution, causes the ExecutionFailed state.
Definition: Model_Data.cpp:602
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_Attribute > attribute(const std::string &theID)
Returns the generic attribute by identifier.
Definition: Model_Data.cpp:409
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_Object > owner()
Returns true if the given object is owner of this data (needed for correct erase of object with dupli...
Definition: Model_Data.cpp:925
virtual MODEL_EXPORT AttributePtr addAttribute(const std::string &theID, const std::string theAttrType, const int theIndex=-1)
Initializes object by the attributes: must be called just after the object is created for each attrib...
Definition: Model_Data.cpp:211
virtual MODEL_EXPORT bool isDeleted()
Returns true if the object is deleted, but some data is still kept in memory.
Definition: Model_Data.cpp:880
virtual MODEL_EXPORT int updateID()
Identifier of the transaction when object (feature or result) was updated last time.
Definition: Model_Data.cpp:592
virtual MODEL_EXPORT void removeAttributes(const std::string &theGroup)
Remove all attributes of the given group.
Definition: Model_Data.cpp:354
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeBoolean > boolean(const std::string &theID)
Returns the attribute that contains boolean value.
Definition: Model_Data.cpp:395
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeSelectionList > selectionList(const std::string &theID)
Returns the attribute that contains selection to a shape.
Definition: Model_Data.cpp:400
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeRefAttr > refattr(const std::string &theID)
Returns the attribute that contains reference to an attribute of a feature.
Definition: Model_Data.cpp:401
virtual MODEL_EXPORT std::list< std::shared_ptr< ModelAPI_Attribute > > attributes(const std::string &theType)
Returns all attributes of the feature of the given type or all attributes if "theType" is empty.
Definition: Model_Data.cpp:442
virtual MODEL_EXPORT AttributePtr addFloatingAttribute(const std::string &theID, const std::string theAttrType, const std::string &theGroup)
Adds a floating attribute (that may be added/removed during the data life)
Definition: Model_Data.cpp:290
virtual MODEL_EXPORT std::string error() const
Registers error during the execution, causes the ExecutionFailed state.
Definition: Model_Data.cpp:616
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeImage > image(const std::string &theID)
Returns the attribute that contains image.
Definition: Model_Data.cpp:407
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeTables > tables(const std::string &theID)
Returns the attribute that contains string values array.
Definition: Model_Data.cpp:406
virtual MODEL_EXPORT const std::set< AttributePtr > & refsToMe()
returns all objects referenced to this
Definition: Model_Data.h:262
virtual MODEL_EXPORT int featureId() const
Returns the identifier of feature-owner, unique in this document.
Definition: Model_Data.cpp:625
void eraseErrorString()
Erases the error string if it is not empty.
Definition: Model_Data.cpp:611
virtual MODEL_EXPORT bool isEqual(const std::shared_ptr< ModelAPI_Data > &theData)
Returns true if data belongs to same features.
Definition: Model_Data.cpp:429
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeIntArray > intArray(const std::string &theID)
Returns the attribute that contains integer values array.
Definition: Model_Data.cpp:404
void clearAttributes()
Erases all attributes from myAttrs, but keeping them in the data structure.
Definition: Model_Data.cpp:374
virtual MODEL_EXPORT bool hasUserDefinedName() const
Return true if the object has been renamed by the user.
Definition: Model_Data.cpp:188
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeDouble > real(const std::string &theID)
Returns the attribute that contains real value with double precision.
Definition: Model_Data.cpp:393
virtual MODEL_EXPORT std::list< std::string > attributesIDs(const std::string &theType)
Returns all attributes ids of the feature of the given type or all attributes if "theType" is empty.
Definition: Model_Data.cpp:455
virtual MODEL_EXPORT void erase()
Erases all the data from the data model.
Definition: Model_Data.cpp:535
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeDoubleArray > realArray(const std::string &theID)
Returns the attribute that contains double values array.
Definition: Model_Data.cpp:405
static std::shared_ptr< ModelAPI_Data > invalidData()
Returns the invalid data pointer: static method.
Definition: Model_Data.cpp:920
virtual MODEL_EXPORT void setIsDeleted(const bool theFlag)
Sets true if the object is deleted, but some data is still kept in memory.
Definition: Model_Data.cpp:885
virtual MODEL_EXPORT void sendAttributeUpdated(ModelAPI_Attribute *theAttr)
Useful method for "set" methods of the attributes: sends an UPDATE event and makes attribute initiali...
Definition: Model_Data.cpp:468
MODEL_EXPORT void setLabel(TDF_Label theLab)
Puts feature to the document data sub-structure.
Definition: Model_Data.cpp:99
virtual MODEL_EXPORT bool isInHistory()
Returns true if "is in history" custom behaviors is defined for the feature.
Definition: Model_Data.cpp:870
virtual MODEL_EXPORT void setIsInHistory(const bool theFlag)
Defines the custom "is in history" behavior.
Definition: Model_Data.cpp:875
virtual MODEL_EXPORT void allGroups(std::list< std::string > &theGroups)
Returns all groups of this data (ordered).
Definition: Model_Data.cpp:326
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_Data > invalidPtr()
Returns the invalid data pointer (to avoid working with NULL shared pointers in swig)
Definition: Model_Data.cpp:915
virtual MODEL_EXPORT void setVersion(const std::string &theVersion)
Initialize the version of the feature.
Definition: Model_Data.cpp:202
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeReference > reference(const std::string &theID)
Returns the attribute that contains reference to a feature.
Definition: Model_Data.cpp:398
virtual MODEL_EXPORT void referencesToObjects(std::list< std::pair< std::string, std::list< ObjectPtr > > > &theRefs)
returns all references by attributes of this data
Definition: Model_Data.cpp:751
virtual MODEL_EXPORT std::wstring name()
Returns the name of the feature visible by the user in the object browser.
Definition: Model_Data.cpp:112
TDF_Label shapeLab() const
Returns the label where the shape must be stored (used in ResultBody)
Definition: Model_Data.h:186
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeInteger > integer(const std::string &theID)
Returns the attribute that contains integer value.
Definition: Model_Data.cpp:394
virtual MODEL_EXPORT void attributesOfGroup(const std::string &theGroup, std::list< std::shared_ptr< ModelAPI_Attribute > > &theAttrs)
Returns an ordered list of attributes that belong to the given group.
Definition: Model_Data.cpp:339
virtual MODEL_EXPORT std::string version()
Returns version of the feature (empty string if not applicable)
Definition: Model_Data.cpp:193
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeSelection > selection(const std::string &theID)
Returns the attribute that contains selection to a shape.
Definition: Model_Data.cpp:399
virtual MODEL_EXPORT bool isValid()
Returns true if it is correctly connected to the data model.
Definition: Model_Data.cpp:437
virtual MODEL_EXPORT const std::string & id(const std::shared_ptr< ModelAPI_Attribute > &theAttr)
Identifier by the id (not fast, iteration by map)
Definition: Model_Data.cpp:417
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeString > string(const std::string &theID)
Returns the attribute that contains real value with double precision.
Definition: Model_Data.cpp:396
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeStringArray > stringArray(const std::string &theID)
Returns the attribute that contains string values array.
Definition: Model_Data.cpp:397
virtual MODEL_EXPORT bool blockSendAttributeUpdated(const bool theBlock, const bool theSendMessage=true)
Blocks sending "attribute updated" if theBlock is true.
Definition: Model_Data.cpp:502
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeRefAttrList > refattrlist(const std::string &theID)
Returns the attribute that contains list of references to features or reference to an attribute of a ...
Definition: Model_Data.cpp:403
virtual MODEL_EXPORT ModelAPI_ExecState execState()
Returns the state of the latest execution of the feature.
Definition: Model_Data.cpp:587
Document for internal data structure of any object storage.
Definition: Model_Document.h:45
Manager of objects of the document.
Definition: Model_Objects.h:46
The body (shape) result of a feature.
Definition: Model_ResultBody.h:40
The construction element result of a feature.
Definition: Model_ResultConstruction.h:38
Updates the results of features when it is needed.
Definition: Model_Update.h:40
Manages the registered validators.
Definition: Model_Validator.h:41