20 #ifndef Model_Objects_H_
21 #define Model_Objects_H_
24 #include <ModelAPI_Document.h>
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Folder.h>
27 #include <ModelAPI_Result.h>
28 #include <ModelAPI_ResultParameter.h>
30 #include <NCollection_DataMap.hxx>
31 #include <TDF_Label.hxx>
32 #include <TDF_LabelList.hxx>
37 extern int kUNDEFINED_FEATURE_INDEX;
52 void addFeature(FeaturePtr theFeature,
const FeaturePtr theAfterThis);
59 std::set<FeaturePtr>& theRefs,
60 const bool isSendError =
true);
67 void moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis);
71 FeaturePtr
feature(TDF_Label theLabel)
const;
75 ObjectPtr
object(TDF_Label theLabel);
82 const std::string& theGroupID,
const std::wstring& theName);
85 ResultPtr
findByName(
const std::wstring theName);
92 const int index(std::shared_ptr<ModelAPI_Object> theObject,
93 const bool theAllowFolder =
false);
99 ObjectPtr
object(
const std::string& theGroupID,
101 const bool theAllowFolder =
false);
106 int size(
const std::string& theGroupID,
const bool theAllowFolder =
false);
110 std::shared_ptr<ModelAPI_Object>
parent(
const std::shared_ptr<ModelAPI_Object> theChild);
114 void allResults(
const std::string& theGroupID, std::list<ResultPtr>& theResults);
123 const std::shared_ptr<ModelAPI_Data>& theFeatureData,
const int theIndex = 0);
125 std::shared_ptr<ModelAPI_ResultBody>
createBody(
126 const std::shared_ptr<ModelAPI_Data>& theFeatureData,
const int theIndex = 0,
127 const std::wstring& theNameShape = L
"");
129 std::shared_ptr<ModelAPI_ResultPart>
createPart(
130 const std::shared_ptr<ModelAPI_Data>& theFeatureData,
const int theIndex = 0);
132 std::shared_ptr<ModelAPI_ResultPart>
copyPart(
133 const std::shared_ptr<ModelAPI_ResultPart>& theOrigin,
134 const std::shared_ptr<ModelAPI_Data>& theFeatureData,
const int theIndex = 0);
137 const std::shared_ptr<ModelAPI_Data>& theFeatureData,
const int theIndex = 0);
140 const std::shared_ptr<ModelAPI_Data>& theFeatureData,
const int theIndex = 0);
143 const std::shared_ptr<ModelAPI_Data>& theFeatureData,
const int theIndex = 0);
146 std::shared_ptr<ModelAPI_Feature>
147 feature(
const std::shared_ptr<ModelAPI_Result>& theResult);
151 const std::shared_ptr<ModelAPI_Feature>& theBeforeThis);
153 void removeFolder(std::shared_ptr<ModelAPI_Folder> theFolder);
160 const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
161 const bool theBelow);
168 const std::shared_ptr<ModelAPI_Feature>& theFeature,
169 int& theIndexInFolder);
173 bool moveToFolder(
const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
174 const std::shared_ptr<ModelAPI_Folder>& theFolder);
181 bool removeFromFolder(
const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
182 const bool theBefore =
true);
213 const bool theOpen,
const bool theExecuteFeatures,
const bool theFlush);
221 void initData(ObjectPtr theObj, TDF_Label theLab,
const int theTag);
225 void storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
226 std::shared_ptr<ModelAPI_Result> theResult,
227 const int theResultIndex = 0,
228 const std::wstring& theNameShape = L
"");
231 TDF_Label
resultLabel(
const std::shared_ptr<ModelAPI_Data>& theFeatureData,
232 const int theResultIndex);
236 void updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& theProcessed);
239 void updateHistory(
const std::shared_ptr<ModelAPI_Object> theObject);
254 FeaturePtr
nextFeature(FeaturePtr theCurrent,
int& theIndex,
const bool theReverse =
false);
260 bool isLater(FeaturePtr theLater, FeaturePtr theCurrent)
const;
265 TDF_Label
nextLabel(TDF_Label theCurrent,
int& theIndex,
const bool theReverse =
false);
273 std::list<std::shared_ptr<ModelAPI_Feature> >
allFeatures();
277 std::list<std::shared_ptr<ModelAPI_Object> >
allObjects();
281 const std::set<std::shared_ptr<ModelAPI_Attribute>>& theNewRefs, ObjectPtr theObject);
288 bool hasCustomName(DataPtr theFeatureData,
291 std::wstring& theParentName)
const;
294 const ObjectPtr&
folder(TDF_Label theLabel)
const;
303 NCollection_DataMap<TDF_Label, FeaturePtr> myFeatures;
306 NCollection_DataMap<TDF_Label, ObjectPtr> myFolders;
310 std::map<std::string, std::vector<ObjectPtr> > myHistory;
319 friend class Model_SelectionNaming;
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 reference to the sub-shape of some result, the selected shape.
Definition: Model_AttributeSelection.h:40
Document for internal data structure of any object storage.
Definition: Model_Document.h:44
Manager of objects of the document.
Definition: Model_Objects.h:46
void removeFolder(std::shared_ptr< ModelAPI_Folder > theFolder)
Removes the folder from the document (all features in the folder will be kept).
Definition: Model_Objects.cpp:1416
std::shared_ptr< ModelAPI_Folder > findFolder(const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures, const bool theBelow)
Search a folder applicable for the list of features (it means the list of features stored in the fold...
Definition: Model_Objects.cpp:1464
TDF_Label resultLabel(const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theResultIndex)
returns the label of result by index; creates this label if it was not created before
Definition: Model_Objects.cpp:1182
void synchronizeFeatures(const TDF_LabelList &theUpdated, const bool theUpdateReferences, const bool theOpen, const bool theExecuteFeatures, const bool theFlush)
Synchronizes myFeatures list with the updated document.
Definition: Model_Objects.cpp:806
void storeResult(std::shared_ptr< ModelAPI_Data > theFeatureData, std::shared_ptr< ModelAPI_Result > theResult, const int theResultIndex=0, const std::wstring &theNameShape=L"")
Allows to store the result in the data tree of the document (attaches 'data' of result to tree)
Definition: Model_Objects.cpp:1227
TDF_Label nextLabel(TDF_Label theCurrent, int &theIndex, const bool theReverse=false)
Returns the next or previous label.
Definition: Model_Objects.cpp:1977
std::list< std::shared_ptr< ModelAPI_Feature > > allFeatures()
Returns all features of the document including the hidden features which are not in history.
Definition: Model_Objects.cpp:2083
void moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
Moves the feature to make it after the given one in the history.
Definition: Model_Objects.cpp:379
std::shared_ptr< ModelAPI_ResultPart > copyPart(const std::shared_ptr< ModelAPI_ResultPart > &theOrigin, const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
Copies a part result, keeping the reference to origin.
Definition: Model_Objects.cpp:1312
DocumentPtr owner()
Returns the owner of this manager.
Definition: Model_Objects.h:188
FeaturePtr feature(TDF_Label theLabel) const
Returns the existing feature by the label.
Definition: Model_Objects.cpp:557
std::shared_ptr< ModelAPI_Feature > internalFeature(const int theIndex)
Returns the feature by zero-based index: features in the history or not.
Definition: Model_Objects.cpp:2106
bool removeFromFolder(const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures, const bool theBefore=true)
Remove features from the folder.
Definition: Model_Objects.cpp:1663
std::shared_ptr< ModelAPI_Folder > createFolder(const std::shared_ptr< ModelAPI_Feature > &theBeforeThis)
Creates a folder (group of the features in the object browser)
Definition: Model_Objects.cpp:1372
void addFeature(FeaturePtr theFeature, const FeaturePtr theAfterThis)
Registers the feature in the data structure.
Definition: Model_Objects.cpp:179
FeaturePtr nextFeature(FeaturePtr theCurrent, int &theIndex, const bool theReverse=false)
Returns the next (from the history point of view) feature, any: invisible or disabled.
Definition: Model_Objects.cpp:1997
void removeFeature(FeaturePtr theFeature)
Removes the feature from the document (with result)
Definition: Model_Objects.cpp:311
std::shared_ptr< ModelAPI_Object > objectByName(const std::string &theGroupID, const std::wstring &theName)
Returns the first found object in the group by the object name.
Definition: Model_Objects.cpp:631
void refsToFeature(FeaturePtr theFeature, std::set< FeaturePtr > &theRefs, const bool isSendError=true)
Return a list of features, which refers to the feature.
Definition: Model_Objects.cpp:270
int numInternalFeatures()
Returns the number of all features: in the history or not.
Definition: Model_Objects.cpp:2097
virtual ~Model_Objects()
Deletes all managed features with emitting of corresponded signal.
Definition: Model_Objects.cpp:112
void setOwner(DocumentPtr theDoc)
Sets the owner of this manager.
Definition: Model_Objects.cpp:103
const int index(std::shared_ptr< ModelAPI_Object > theObject, const bool theAllowFolder=false)
Returns the object index in the group.
Definition: Model_Objects.cpp:662
std::shared_ptr< ModelAPI_Folder > findContainingFolder(const std::shared_ptr< ModelAPI_Feature > &theFeature, int &theIndexInFolder)
Search a folder containing the given feature.
Definition: Model_Objects.cpp:1745
void clearHistory(ObjectPtr theObj)
Clears the history arrays related to this object.
Definition: Model_Objects.cpp:434
Model_Objects(TDF_Label theMainLab)
Creates manager on the OCAF document main label.
Definition: Model_Objects.cpp:99
FeaturePtr firstFeature()
Returns to the first (from the history point of view) feature, any: invisible or disabled.
Definition: Model_Objects.cpp:2016
ResultPtr findByName(const std::wstring theName)
Returns the result by the result name.
Definition: Model_Objects.cpp:1950
bool isLater(FeaturePtr theLater, FeaturePtr theCurrent) const
Returns true if theLater is in history of features creation later than theCurrent.
Definition: Model_Objects.cpp:2040
int size(const std::string &theGroupID, const bool theAllowFolder=false)
Returns the number of features in the group.
Definition: Model_Objects.cpp:685
void synchronizeBackRefsForObject(const std::set< std::shared_ptr< ModelAPI_Attribute >> &theNewRefs, ObjectPtr theObject)
synchronizes back references for the given object basing on the collected data
Definition: Model_Objects.cpp:1011
void updateResults(FeaturePtr theFeature, std::set< FeaturePtr > &theProcessed)
Updates the results list of the feature basing on the current data tree theProcessed is used to avoid...
Definition: Model_Objects.cpp:1846
void setUniqueName(FeaturePtr theFeature)
Initializes feature with a unique name in this group (unique name is generated as feature type + "_" ...
Definition: Model_Objects.cpp:743
void updateHistory(const std::shared_ptr< ModelAPI_Object > theObject)
Internally makes document know that feature was removed or added in history after creation.
Definition: Model_Objects.cpp:531
virtual void eraseAllFeatures()
Just removes all features without touching the document data (to be able undo)
Definition: Model_Objects.cpp:351
void createHistory(const std::string &theGroupID)
Creates the history: up to date with the current state.
Definition: Model_Objects.cpp:453
void synchronizeBackRefs()
Synchronizes the BackReferences list in Data of Features and Results.
Definition: Model_Objects.cpp:1122
std::shared_ptr< ModelAPI_ResultGroup > createGroup(const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
Creates a group result.
Definition: Model_Objects.cpp:1321
std::shared_ptr< ModelAPI_Object > parent(const std::shared_ptr< ModelAPI_Object > theChild)
Returns the parent object of this child.
Definition: Model_Objects.cpp:692
void allResults(const std::string &theGroupID, std::list< ResultPtr > &theResults)
Returns all (and disabled) results of the given type.
Definition: Model_Objects.cpp:707
TDF_Label featuresLabel() const
Returns (creates if needed) the features label.
Definition: Model_Objects.cpp:731
FeaturePtr lastFeature()
Returns to the last (from the history point of view) feature, any: invisible or disabled.
Definition: Model_Objects.cpp:2025
std::shared_ptr< ModelAPI_ResultParameter > createParameter(const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
Creates a parameter result.
Definition: Model_Objects.cpp:1355
std::shared_ptr< ModelAPI_ResultPart > createPart(const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
Creates a part result.
Definition: Model_Objects.cpp:1295
bool moveToFolder(const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures, const std::shared_ptr< ModelAPI_Folder > &theFolder)
Add a list of features to the folder.
Definition: Model_Objects.cpp:1568
ObjectPtr object(TDF_Label theLabel)
Returns the existing object: result or feature.
Definition: Model_Objects.cpp:564
std::shared_ptr< ModelAPI_ResultBody > createBody(const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0, const std::wstring &theNameShape=L"")
Creates a body result.
Definition: Model_Objects.cpp:1276
void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag)
Initializes the data fields of the feature.
Definition: Model_Objects.cpp:788
std::shared_ptr< ModelAPI_ResultConstruction > createConstruction(const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
Creates a construction result.
Definition: Model_Objects.cpp:1259
std::string featureResultGroup(FeaturePtr theFeature)
Returns the result group identifier of the given feature (for this at least one result must be create...
Definition: Model_Objects.cpp:1830
const ObjectPtr & folder(TDF_Label theLabel) const
Return object representing a folder or empty pointer.
Definition: Model_Objects.cpp:549
std::shared_ptr< ModelAPI_ResultField > createField(const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
Creates a field result.
Definition: Model_Objects.cpp:1338
std::list< std::shared_ptr< ModelAPI_Object > > allObjects()
Returns all objects of the document including the hidden features which are not in history.
Definition: Model_Objects.cpp:2067
Object that knows (from the initial XML file) which plugin contains which feature,...
Definition: Model_Session.h:43
Updates the results of features when it is needed.
Definition: Model_Update.h:40