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);
186 std::shared_ptr<GeomAPI_Shape> theSubShape,
187 const std::vector<int>& theColor);
190 std::vector<int>
getSubShapeColor(std::shared_ptr<ModelAPI_Result> theResult,
191 std::shared_ptr<GeomAPI_Shape> theSubShape);
195 std::map<std::shared_ptr<GeomAPI_Shape>, std::vector<int>>& theColoredSubShapes);
220 const int theSubShapeIndex);
227 std::shared_ptr<GeomAPI_Shape> theSubShape);
244 const bool theOpen,
const bool theExecuteFeatures,
const bool theFlush);
252 void initData(ObjectPtr theObj, TDF_Label theLab,
const int theTag);
256 void storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
257 std::shared_ptr<ModelAPI_Result> theResult,
258 const int theResultIndex = 0,
259 const std::wstring& theNameShape = L
"");
262 TDF_Label
resultLabel(
const std::shared_ptr<ModelAPI_Data>& theFeatureData,
263 const int theResultIndex);
267 void updateResults(FeaturePtr theFeature, std::set<FeaturePtr>& theProcessed);
270 void updateHistory(
const std::shared_ptr<ModelAPI_Object> theObject);
285 FeaturePtr
nextFeature(FeaturePtr theCurrent,
int& theIndex,
const bool theReverse =
false);
291 bool isLater(FeaturePtr theLater, FeaturePtr theCurrent)
const;
296 TDF_Label
nextLabel(TDF_Label theCurrent,
int& theIndex,
const bool theReverse =
false);
304 std::list<std::shared_ptr<ModelAPI_Feature> >
allFeatures();
308 std::list<std::shared_ptr<ModelAPI_Object> >
allObjects();
312 const std::set<std::shared_ptr<ModelAPI_Attribute>>& theNewRefs, ObjectPtr theObject);
319 bool hasCustomName(DataPtr theFeatureData,
322 std::wstring& theParentName)
const;
325 const ObjectPtr&
folder(TDF_Label theLabel)
const;
334 NCollection_DataMap<TDF_Label, FeaturePtr> myFeatures;
337 NCollection_DataMap<TDF_Label, ObjectPtr> myFolders;
341 std::map<std::string, std::vector<ObjectPtr> > myHistory;
350 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:45
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:1588
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:1636
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:1354
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:978
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:1399
TDF_Label nextLabel(TDF_Label theCurrent, int &theIndex, const bool theReverse=false)
Returns the next or previous label.
Definition: Model_Objects.cpp:2156
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:2262
void moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis)
Moves the feature to make it after the given one in the history.
Definition: Model_Objects.cpp:396
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:1484
DocumentPtr owner()
Returns the owner of this manager.
Definition: Model_Objects.h:204
FeaturePtr feature(TDF_Label theLabel) const
Returns the existing feature by the label.
Definition: Model_Objects.cpp:574
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:2285
bool removeFromFolder(const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures, const bool theBefore=true)
Remove features from the folder.
Definition: Model_Objects.cpp:1835
void getColoredSubShapes(const std::shared_ptr< ModelAPI_Result > theResult, std::map< std::shared_ptr< GeomAPI_Shape >, std::vector< int >> &theColoredSubShapes)
Get colored subshapes from result.
Definition: Model_Objects.cpp:862
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:1544
const int coloredSubShapeIndex(std::shared_ptr< ModelAPI_Result > theResult, std::shared_ptr< GeomAPI_Shape > theSubShape)
Returns the index of the colored subshape in the result.
Definition: Model_Objects.cpp:766
void addFeature(FeaturePtr theFeature, const FeaturePtr theAfterThis)
Registers the feature in the data structure.
Definition: Model_Objects.cpp:196
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:2176
void removeFeature(FeaturePtr theFeature)
Removes the feature from the document (with result)
Definition: Model_Objects.cpp:328
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:648
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:287
int numInternalFeatures()
Returns the number of all features: in the history or not.
Definition: Model_Objects.cpp:2276
TDF_Label coloredSubShapeLabel(TDF_Label &theSubShapesLabel, const int theSubShapeIndex)
Returns (creates if needed) the label of colored subshape by index.
Definition: Model_Objects.cpp:760
virtual ~Model_Objects()
Deletes all managed features with emitting of corresponded signal.
Definition: Model_Objects.cpp:129
void removeSubShapeColors(const std::shared_ptr< ModelAPI_Result > theResult)
Forget subshape colors.
Definition: Model_Objects.cpp:892
void storeSubShapeWithColor(std::shared_ptr< ModelAPI_Result > theResult, std::shared_ptr< GeomAPI_Shape > theSubShape, const std::vector< int > &theColor)
Store theSubShape in theResult, set color attribute to theSubShape.
Definition: Model_Objects.cpp:786
void setOwner(DocumentPtr theDoc)
Sets the owner of this manager.
Definition: Model_Objects.cpp:120
const int index(std::shared_ptr< ModelAPI_Object > theObject, const bool theAllowFolder=false)
Returns the object index in the group.
Definition: Model_Objects.cpp:679
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:1917
void clearHistory(ObjectPtr theObj)
Clears the history arrays related to this object.
Definition: Model_Objects.cpp:451
Model_Objects(TDF_Label theMainLab)
Creates manager on the OCAF document main label.
Definition: Model_Objects.cpp:116
FeaturePtr firstFeature()
Returns to the first (from the history point of view) feature, any: invisible or disabled.
Definition: Model_Objects.cpp:2195
ResultPtr findByName(const std::wstring theName)
Returns the result by the result name.
Definition: Model_Objects.cpp:2122
bool isLater(FeaturePtr theLater, FeaturePtr theCurrent) const
Returns true if theLater is in history of features creation later than theCurrent.
Definition: Model_Objects.cpp:2219
int size(const std::string &theGroupID, const bool theAllowFolder=false)
Returns the number of features in the group.
Definition: Model_Objects.cpp:702
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:1183
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:2018
void setUniqueName(FeaturePtr theFeature)
Initializes feature with a unique name in this group (unique name is generated as feature type + "_" ...
Definition: Model_Objects.cpp:915
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:548
virtual void eraseAllFeatures()
Just removes all features without touching the document data (to be able undo)
Definition: Model_Objects.cpp:368
void createHistory(const std::string &theGroupID)
Creates the history: up to date with the current state.
Definition: Model_Objects.cpp:470
void synchronizeBackRefs()
Synchronizes the BackReferences list in Data of Features and Results.
Definition: Model_Objects.cpp:1294
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:1493
std::shared_ptr< ModelAPI_Object > parent(const std::shared_ptr< ModelAPI_Object > theChild)
Returns the parent object of this child.
Definition: Model_Objects.cpp:709
void allResults(const std::string &theGroupID, std::list< ResultPtr > &theResults)
Returns all (and disabled) results of the given type.
Definition: Model_Objects.cpp:724
TDF_Label featuresLabel() const
Returns (creates if needed) the features label.
Definition: Model_Objects.cpp:748
TDF_Label coloredSubShapesLabel(std::shared_ptr< ModelAPI_Result > theResult) const
Returns (creates if needed) the label of colored subshapes of the result.
Definition: Model_Objects.cpp:753
FeaturePtr lastFeature()
Returns to the last (from the history point of view) feature, any: invisible or disabled.
Definition: Model_Objects.cpp:2204
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:1527
std::vector< int > getSubShapeColor(std::shared_ptr< ModelAPI_Result > theResult, std::shared_ptr< GeomAPI_Shape > theSubShape)
Get color of subshape.
Definition: Model_Objects.cpp:836
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:1467
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:1740
ObjectPtr object(TDF_Label theLabel)
Returns the existing object: result or feature.
Definition: Model_Objects.cpp:581
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:1448
void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag)
Initializes the data fields of the feature.
Definition: Model_Objects.cpp:960
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:1431
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:2002
const ObjectPtr & folder(TDF_Label theLabel) const
Return object representing a folder or empty pointer.
Definition: Model_Objects.cpp:566
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:1510
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:2246
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