SHAPER  9.12.0
Model_Objects Class Reference

Manager of objects of the document. More...

Public Member Functions

void addFeature (FeaturePtr theFeature, const FeaturePtr theAfterThis)
 Registers the feature in the data structure. More...
 
void refsToFeature (FeaturePtr theFeature, std::set< FeaturePtr > &theRefs, const bool isSendError=true)
 Return a list of features, which refers to the feature. More...
 
void removeFeature (FeaturePtr theFeature)
 Removes the feature from the document (with result) More...
 
void moveFeature (FeaturePtr theMoved, FeaturePtr theAfterThis)
 Moves the feature to make it after the given one in the history. More...
 
FeaturePtr feature (TDF_Label theLabel) const
 Returns the existing feature by the label. More...
 
ObjectPtr object (TDF_Label theLabel)
 Returns the existing object: result or feature. More...
 
std::shared_ptr< ModelAPI_ObjectobjectByName (const std::string &theGroupID, const std::wstring &theName)
 Returns the first found object in the group by the object name. More...
 
ResultPtr findByName (const std::wstring theName)
 Returns the result by the result name. More...
 
const int index (std::shared_ptr< ModelAPI_Object > theObject, const bool theAllowFolder=false)
 Returns the object index in the group. More...
 
ObjectPtr object (const std::string &theGroupID, const int theIndex, const bool theAllowFolder=false)
 Returns the feature in the group by the index (started from zero) More...
 
int size (const std::string &theGroupID, const bool theAllowFolder=false)
 Returns the number of features in the group. More...
 
std::shared_ptr< ModelAPI_Objectparent (const std::shared_ptr< ModelAPI_Object > theChild)
 Returns the parent object of this child. More...
 
void allResults (const std::string &theGroupID, std::list< ResultPtr > &theResults)
 Returns all (and disabled) results of the given type. More...
 
int numInternalFeatures ()
 Returns the number of all features: in the history or not. More...
 
std::shared_ptr< ModelAPI_FeatureinternalFeature (const int theIndex)
 Returns the feature by zero-based index: features in the history or not. More...
 
std::shared_ptr< ModelAPI_ResultConstructioncreateConstruction (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
 Creates a construction result. More...
 
std::shared_ptr< ModelAPI_ResultBodycreateBody (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0, const std::wstring &theNameShape=L"")
 Creates a body result. More...
 
std::shared_ptr< ModelAPI_ResultPartcreatePart (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
 Creates a part result. More...
 
std::shared_ptr< ModelAPI_ResultPartcopyPart (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. More...
 
std::shared_ptr< ModelAPI_ResultGroupcreateGroup (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
 Creates a group result. More...
 
std::shared_ptr< ModelAPI_ResultFieldcreateField (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
 Creates a field result. More...
 
std::shared_ptr< ModelAPI_ResultParametercreateParameter (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)
 Creates a parameter result. More...
 
std::shared_ptr< ModelAPI_Featurefeature (const std::shared_ptr< ModelAPI_Result > &theResult)
 Returns a feature by result (owner of result) More...
 
std::shared_ptr< ModelAPI_FoldercreateFolder (const std::shared_ptr< ModelAPI_Feature > &theBeforeThis)
 Creates a folder (group of the features in the object browser) More...
 
void removeFolder (std::shared_ptr< ModelAPI_Folder > theFolder)
 Removes the folder from the document (all features in the folder will be kept). More...
 
std::shared_ptr< ModelAPI_FolderfindFolder (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 folder should be consequential) More...
 
std::shared_ptr< ModelAPI_FolderfindContainingFolder (const std::shared_ptr< ModelAPI_Feature > &theFeature, int &theIndexInFolder)
 Search a folder containing the given feature. More...
 
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. More...
 
bool removeFromFolder (const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures, const bool theBefore=true)
 Remove features from the folder. More...
 
void setOwner (DocumentPtr theDoc)
 Sets the owner of this manager. More...
 
DocumentPtr owner ()
 Returns the owner of this manager. More...
 
virtual ~Model_Objects ()
 Deletes all managed features with emitting of corresponded signal. More...
 

Protected Member Functions

TDF_Label featuresLabel () const
 Returns (creates if needed) the features label. More...
 
void setUniqueName (FeaturePtr theFeature)
 Initializes feature with a unique name in this group (unique name is generated as feature type + "_" + index. More...
 
void setUniqueName (FolderPtr theFolder)
 Initializes the folder with an unique name ("Folder_" + index) More...
 
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. More...
 
void synchronizeBackRefs ()
 Synchronizes the BackReferences list in Data of Features and Results. More...
 
 Model_Objects (TDF_Label theMainLab)
 Creates manager on the OCAF document main label. More...
 
void initData (ObjectPtr theObj, TDF_Label theLab, const int theTag)
 Initializes the data fields of the feature. More...
 
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) More...
 
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 More...
 
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 update twice (since the function is recursive) More...
 
void updateHistory (const std::shared_ptr< ModelAPI_Object > theObject)
 Internally makes document know that feature was removed or added in history after creation. More...
 
void updateHistory (const std::string theGroup)
 Internally makes document know that feature was removed or added in history after creation. More...
 
void clearHistory (ObjectPtr theObj)
 Clears the history arrays related to this object. More...
 
void createHistory (const std::string &theGroupID)
 Creates the history: up to date with the current state. More...
 
FeaturePtr nextFeature (FeaturePtr theCurrent, int &theIndex, const bool theReverse=false)
 Returns the next (from the history point of view) feature, any: invisible or disabled. More...
 
FeaturePtr firstFeature ()
 Returns to the first (from the history point of view) feature, any: invisible or disabled. More...
 
FeaturePtr lastFeature ()
 Returns to the last (from the history point of view) feature, any: invisible or disabled. More...
 
bool isLater (FeaturePtr theLater, FeaturePtr theCurrent) const
 Returns true if theLater is in history of features creation later than theCurrent. More...
 
TDF_Label nextLabel (TDF_Label theCurrent, int &theIndex, const bool theReverse=false)
 Returns the next or previous label. More...
 
std::string featureResultGroup (FeaturePtr theFeature)
 Returns the result group identifier of the given feature (for this at least one result must be created before) More...
 
std::list< std::shared_ptr< ModelAPI_Feature > > allFeatures ()
 Returns all features of the document including the hidden features which are not in history. More...
 
std::list< std::shared_ptr< ModelAPI_Object > > allObjects ()
 Returns all objects of the document including the hidden features which are not in history. More...
 
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 More...
 
virtual void eraseAllFeatures ()
 Just removes all features without touching the document data (to be able undo) More...
 
bool hasCustomName (DataPtr theFeatureData, ResultPtr theResult, int theResultIndex, std::wstring &theParentName) const
 
const ObjectPtr & folder (TDF_Label theLabel) const
 Return object representing a folder or empty pointer. More...
 

Friends

class Model_Document
 
class Model_Session
 
class Model_Update
 
class Model_AttributeReference
 
class Model_AttributeRefAttr
 
class Model_AttributeRefList
 
class Model_AttributeSelection
 
class Model_SelectionNaming
 

Detailed Description

Manager of objects of the document.

Normally one this class corresponds to one document and just helper to manage objects (ModelAPI_Objects) inside of the document on the level of data storage.

Constructor & Destructor Documentation

◆ ~Model_Objects()

Model_Objects::~Model_Objects ( )
virtual

Deletes all managed features with emitting of corresponded signal.

◆ Model_Objects()

Model_Objects::Model_Objects ( TDF_Label  theMainLab)
protected

Creates manager on the OCAF document main label.

0:1:2 - where features are located 0:1:2:N:1 - data of the feature N 0:1:2:N:2:K:1 - data of the K result of the feature N

Member Function Documentation

◆ addFeature()

void Model_Objects::addFeature ( FeaturePtr  theFeature,
const FeaturePtr  theAfterThis 
)

Registers the feature in the data structure.

Parameters
theFeaturefeature that must be added to the data structure
theAfterThisthe feature will be added after this feature; if it is null, the added feature will be the first

◆ refsToFeature()

void Model_Objects::refsToFeature ( FeaturePtr  theFeature,
std::set< FeaturePtr > &  theRefs,
const bool  isSendError = true 
)

Return a list of features, which refers to the feature.

Parameters
theFeaturea feature
theRefsa list of reference features
isSendErrora flag whether the error message should be send

◆ removeFeature()

void Model_Objects::removeFeature ( FeaturePtr  theFeature)

Removes the feature from the document (with result)

Parameters
theFeaturea removed feature

◆ moveFeature()

void Model_Objects::moveFeature ( FeaturePtr  theMoved,
FeaturePtr  theAfterThis 
)

Moves the feature to make it after the given one in the history.

◆ feature() [1/2]

FeaturePtr Model_Objects::feature ( TDF_Label  theLabel) const

Returns the existing feature by the label.

Parameters
theLabelbase label of the feature

◆ object() [1/2]

ObjectPtr Model_Objects::object ( TDF_Label  theLabel)

Returns the existing object: result or feature.

Parameters
theLabelbase label of the object

◆ objectByName()

std::shared_ptr< ModelAPI_Object > Model_Objects::objectByName ( const std::string &  theGroupID,
const std::wstring &  theName 
)

Returns the first found object in the group by the object name.

Parameters
theGroupIDgroup that contains an object
theNamename of the object to search
Returns
null if such object is not found

◆ findByName()

ResultPtr Model_Objects::findByName ( const std::wstring  theName)

Returns the result by the result name.

◆ index()

const int Model_Objects::index ( std::shared_ptr< ModelAPI_Object theObject,
const bool  theAllowFolder = false 
)

Returns the object index in the group.

Object must be visible. Otherwise returns -1.

Parameters
theObjectobject of this document
theAllowFoldertake into account grouping feature by folders
Returns
index started from zero, or -1 if object is invisible or belongs to another document

◆ object() [2/2]

ObjectPtr Model_Objects::object ( const std::string &  theGroupID,
const int  theIndex,
const bool  theAllowFolder = false 
)

Returns the feature in the group by the index (started from zero)

Parameters
theGroupIDgroup that contains a feature
theIndexzero-based index of feature in the group
theAllowFoldertake into account grouping feature by folders

◆ size()

int Model_Objects::size ( const std::string &  theGroupID,
const bool  theAllowFolder = false 
)

Returns the number of features in the group.

Parameters
theGroupIDgroup of objects
theAllowFoldertake into account grouping feature by folders

◆ parent()

std::shared_ptr< ModelAPI_Object > Model_Objects::parent ( const std::shared_ptr< ModelAPI_Object theChild)

Returns the parent object of this child.

This may be result or feature, parent of a top result. Fast method, that uses internal data structure specifics.

◆ allResults()

void Model_Objects::allResults ( const std::string &  theGroupID,
std::list< ResultPtr > &  theResults 
)

Returns all (and disabled) results of the given type.

Not fast method (iterates all features).

◆ numInternalFeatures()

int Model_Objects::numInternalFeatures ( )

Returns the number of all features: in the history or not.

◆ internalFeature()

std::shared_ptr< ModelAPI_Feature > Model_Objects::internalFeature ( const int  theIndex)

Returns the feature by zero-based index: features in the history or not.

◆ createConstruction()

std::shared_ptr< ModelAPI_ResultConstruction > Model_Objects::createConstruction ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0 
)

Creates a construction result.

◆ createBody()

std::shared_ptr< ModelAPI_ResultBody > Model_Objects::createBody ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0,
const std::wstring &  theNameShape = L"" 
)

Creates a body result.

◆ createPart()

std::shared_ptr< ModelAPI_ResultPart > Model_Objects::createPart ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0 
)

Creates a part result.

◆ copyPart()

std::shared_ptr< ModelAPI_ResultPart > Model_Objects::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.

◆ createGroup()

std::shared_ptr< ModelAPI_ResultGroup > Model_Objects::createGroup ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0 
)

Creates a group result.

◆ createField()

std::shared_ptr< ModelAPI_ResultField > Model_Objects::createField ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0 
)

Creates a field result.

◆ createParameter()

std::shared_ptr< ModelAPI_ResultParameter > Model_Objects::createParameter ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0 
)

Creates a parameter result.

◆ feature() [2/2]

std::shared_ptr< ModelAPI_Feature > Model_Objects::feature ( const std::shared_ptr< ModelAPI_Result > &  theResult)

Returns a feature by result (owner of result)

◆ createFolder()

std::shared_ptr< ModelAPI_Folder > Model_Objects::createFolder ( const std::shared_ptr< ModelAPI_Feature > &  theBeforeThis)

Creates a folder (group of the features in the object browser)

◆ removeFolder()

void Model_Objects::removeFolder ( std::shared_ptr< ModelAPI_Folder theFolder)

Removes the folder from the document (all features in the folder will be kept).

◆ findFolder()

std::shared_ptr< ModelAPI_Folder > Model_Objects::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 folder should be consequential)

Parameters
theFeatureslist of features to be added to folder
theBelowsearch the folder below the features (if false, search above)
Returns
Empty pointer if there is no applicable folder

◆ findContainingFolder()

FolderPtr Model_Objects::findContainingFolder ( const std::shared_ptr< ModelAPI_Feature > &  theFeature,
int &  theIndexInFolder 
)

Search a folder containing the given feature.

Additionally calculates a zero-based index of the feature in this folder.

Parameters
theFeaturefeature to search
theIndexInFolderzero-based index in the folder or -1 if the feature is top-level.
Returns
the folder containing the feature or empty pointer if the feature is top-level.

◆ moveToFolder()

bool Model_Objects::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.

The correctness of the adding is not performed (such checks have been done in corresponding find.. method).

Returns
true if the movement is successful

◆ removeFromFolder()

bool Model_Objects::removeFromFolder ( const std::list< std::shared_ptr< ModelAPI_Feature > > &  theFeatures,
const bool  theBefore = true 
)

Remove features from the folder.

Parameters
theFeatureslist of features to be removed
theBeforeextract features before the folder (this parameter is applicable only when all features in the folder are taking out, in other cases the direction is taken automatically)
Returns
true if the features have been moved out

◆ setOwner()

void Model_Objects::setOwner ( DocumentPtr  theDoc)

Sets the owner of this manager.

◆ owner()

DocumentPtr Model_Objects::owner ( )
inline

Returns the owner of this manager.

◆ featuresLabel()

TDF_Label Model_Objects::featuresLabel ( ) const
protected

Returns (creates if needed) the features label.

◆ setUniqueName() [1/2]

void Model_Objects::setUniqueName ( FeaturePtr  theFeature)
protected

Initializes feature with a unique name in this group (unique name is generated as feature type + "_" + index.

◆ setUniqueName() [2/2]

void Model_Objects::setUniqueName ( FolderPtr  theFolder)
protected

Initializes the folder with an unique name ("Folder_" + index)

◆ synchronizeFeatures()

void Model_Objects::synchronizeFeatures ( const TDF_LabelList &  theUpdated,
const bool  theUpdateReferences,
const bool  theOpen,
const bool  theExecuteFeatures,
const bool  theFlush 
)
protected

Synchronizes myFeatures list with the updated document.

Parameters
theUpdatedlist of labels that are marked as modified, so features must be also
theUpdateReferencescauses the update of back-references
theExecuteFeaturesrequires re-execute modified persistent features (not needed on undo/redo/abort/open)
theOpen- on open nothing must be re-executed, except not persistent results
theFlushmakes flush all events in the end of all modifications of this method

◆ synchronizeBackRefs()

void Model_Objects::synchronizeBackRefs ( )
protected

Synchronizes the BackReferences list in Data of Features and Results.

◆ initData()

void Model_Objects::initData ( ObjectPtr  theObj,
TDF_Label  theLab,
const int  theTag 
)
protected

Initializes the data fields of the feature.

◆ storeResult()

void Model_Objects::storeResult ( std::shared_ptr< ModelAPI_Data theFeatureData,
std::shared_ptr< ModelAPI_Result theResult,
const int  theResultIndex = 0,
const std::wstring &  theNameShape = L"" 
)
protected

Allows to store the result in the data tree of the document (attaches 'data' of result to tree)

◆ resultLabel()

TDF_Label Model_Objects::resultLabel ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theResultIndex 
)
protected

returns the label of result by index; creates this label if it was not created before

◆ updateResults()

void Model_Objects::updateResults ( FeaturePtr  theFeature,
std::set< FeaturePtr > &  theProcessed 
)
protected

Updates the results list of the feature basing on the current data tree theProcessed is used to avoid update twice (since the function is recursive)

◆ updateHistory() [1/2]

void Model_Objects::updateHistory ( const std::shared_ptr< ModelAPI_Object theObject)
protected

Internally makes document know that feature was removed or added in history after creation.

◆ updateHistory() [2/2]

void Model_Objects::updateHistory ( const std::string  theGroup)
protected

Internally makes document know that feature was removed or added in history after creation.

◆ clearHistory()

void Model_Objects::clearHistory ( ObjectPtr  theObj)
protected

Clears the history arrays related to this object.

◆ createHistory()

void Model_Objects::createHistory ( const std::string &  theGroupID)
protected

Creates the history: up to date with the current state.

◆ nextFeature()

FeaturePtr Model_Objects::nextFeature ( FeaturePtr  theCurrent,
int &  theIndex,
const bool  theReverse = false 
)
protected

Returns the next (from the history point of view) feature, any: invisible or disabled.

Parameters
theCurrentprevious to the resulting feature
theReverseif it is true, iterates in reversed order (next becomes previous)
theIndexmay be used for optimization: index of theCurrent in references array

◆ firstFeature()

FeaturePtr Model_Objects::firstFeature ( )
protected

Returns to the first (from the history point of view) feature, any: invisible or disabled.

◆ lastFeature()

FeaturePtr Model_Objects::lastFeature ( )
protected

Returns to the last (from the history point of view) feature, any: invisible or disabled.

◆ isLater()

bool Model_Objects::isLater ( FeaturePtr  theLater,
FeaturePtr  theCurrent 
) const
protected

Returns true if theLater is in history of features creation later than theCurrent.

◆ nextLabel()

TDF_Label Model_Objects::nextLabel ( TDF_Label  theCurrent,
int &  theIndex,
const bool  theReverse = false 
)
protected

Returns the next or previous label.

Parameters
theCurrentgiven label
theReverseif it is true, iterates in reversed order (next becomes previous)

◆ featureResultGroup()

std::string Model_Objects::featureResultGroup ( FeaturePtr  theFeature)
protected

Returns the result group identifier of the given feature (for this at least one result must be created before)

◆ allFeatures()

std::list< std::shared_ptr< ModelAPI_Feature > > Model_Objects::allFeatures ( )
protected

Returns all features of the document including the hidden features which are not in history.

Not very fast method, for calling once, not in big cycles.

◆ allObjects()

std::list< std::shared_ptr< ModelAPI_Object > > Model_Objects::allObjects ( )
protected

Returns all objects of the document including the hidden features which are not in history.

Not very fast method, for calling once, not in big cycles.

◆ synchronizeBackRefsForObject()

void Model_Objects::synchronizeBackRefsForObject ( const std::set< std::shared_ptr< ModelAPI_Attribute >> &  theNewRefs,
ObjectPtr  theObject 
)
protected

synchronizes back references for the given object basing on the collected data

◆ eraseAllFeatures()

void Model_Objects::eraseAllFeatures ( )
protectedvirtual

Just removes all features without touching the document data (to be able undo)

◆ folder()

const ObjectPtr & Model_Objects::folder ( TDF_Label  theLabel) const
protected

Return object representing a folder or empty pointer.