SHAPER  9.12.0
ModelAPI_Document Class Referenceabstract

Document for internal data structure of any object storage. More...

Inheritance diagram for ModelAPI_Document:
Inheritance graph

Public Member Functions

virtual const std::string & kind () const =0
 Returns the kind of the document: "PartSet", "Part", or something else. More...
 
virtual void close (const bool theForever=false)=0
 Removes document data. More...
 
virtual std::shared_ptr< ModelAPI_FeatureaddFeature (std::string theID, const bool theMakeCurrent=true)=0
 Adds to the document the new feature of the given feature id. More...
 
virtual void refsToFeature (std::shared_ptr< ModelAPI_Feature > theFeature, std::set< std::shared_ptr< ModelAPI_Feature > > &theRefs, const bool isSendError=true)=0
 Return a list of features, which refers to the feature. More...
 
virtual void removeFeature (std::shared_ptr< ModelAPI_Feature > theFeature)=0
 Removes the feature from the document. More...
 
virtual void moveFeature (std::shared_ptr< ModelAPI_Feature > theMoved, std::shared_ptr< ModelAPI_Feature > theAfterThis, const bool theSplit=false)=0
 Moves the feature to make it after the given one in the history. More...
 
virtual const int id () const =0
 ! Returns the id of the document More...
 
virtual std::shared_ptr< ModelAPI_Objectobject (const std::string &theGroupID, const int theIndex, const bool theAllowFolder=false)=0
 Returns the object in the group by the index (started from zero) More...
 
virtual std::shared_ptr< ModelAPI_ObjectobjectByName (const std::string &theGroupID, const std::wstring &theName)=0
 Returns the first found object in the group by the object name. More...
 
virtual const int index (std::shared_ptr< ModelAPI_Object > theObject, const bool theAllowFolder=false)=0
 Returns the object index in the group. More...
 
virtual int size (const std::string &theGroupID, const bool theAllowFolder=false)=0
 Returns the number of objects in the group of objects. More...
 
virtual std::shared_ptr< ModelAPI_Objectparent (const std::shared_ptr< ModelAPI_Object > theChild)=0
 Returns the parent object of this child. More...
 
virtual std::shared_ptr< ModelAPI_FeaturecurrentFeature (const bool theVisible)=0
 Returns the feature that is currently edited in this document, normally this is the latest created feature. More...
 
virtual void setCurrentFeature (std::shared_ptr< ModelAPI_Feature > theCurrent, const bool theVisible)=0
 Sets the current feature: all features below will be disabled, new features will be appended after this one. More...
 
virtual void setCurrentFeatureUp ()=0
 Makes the current feature one feature upper. More...
 
virtual int numInternalFeatures ()=0
 Returns the number of all features: in the history or not. More...
 
virtual std::shared_ptr< ModelAPI_FeatureinternalFeature (const int theIndex)=0
 Returns the feature by zero-based index: features in the history or not. More...
 
virtual void synchronizeTransactions ()=0
 Performs synchronization of transactions with the module document: If some document is not active (by undo of activation) but in memory, on activation the transactions must be synchronized because all redo-s performed without this participation. More...
 
virtual ~ModelAPI_Document ()
 To virtually destroy the fields of successors. More...
 
virtual std::shared_ptr< ModelAPI_ResultConstructioncreateConstruction (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)=0
 Creates a construction result. More...
 
virtual std::shared_ptr< ModelAPI_ResultBodycreateBody (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)=0
 Creates a body result. More...
 
virtual std::shared_ptr< ModelAPI_ResultPartcreatePart (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)=0
 Creates a part result. More...
 
virtual std::shared_ptr< ModelAPI_ResultPartcopyPart (const std::shared_ptr< ModelAPI_ResultPart > &theOrigin, const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)=0
 Copies a part result, keeping the reference to the origin. More...
 
virtual std::shared_ptr< ModelAPI_ResultGroupcreateGroup (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)=0
 Creates a group result. More...
 
virtual std::shared_ptr< ModelAPI_ResultFieldcreateField (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)=0
 Creates a field result. More...
 
virtual std::shared_ptr< ModelAPI_ResultParametercreateParameter (const std::shared_ptr< ModelAPI_Data > &theFeatureData, const int theIndex=0)=0
 Creates a parameter result. More...
 
virtual std::shared_ptr< ModelAPI_Featurefeature (const std::shared_ptr< ModelAPI_Result > &theResult)=0
 Returns a feature by result (owner of result) More...
 
virtual std::list< std::shared_ptr< ModelAPI_Feature > > allFeatures ()=0
 Returns all features of the document including the hidden features which are not in history. More...
 
virtual std::list< std::shared_ptr< ModelAPI_Object > > allObjects ()=0
 Returns all objects of the document including the hidden features which are not in history. More...
 
virtual std::shared_ptr< ModelAPI_FolderaddFolder (std::shared_ptr< ModelAPI_Feature > theAddBefore=std::shared_ptr< ModelAPI_Feature >())=0
 Creates a folder (group of the features in the object browser) More...
 
virtual void removeFolder (std::shared_ptr< ModelAPI_Folder > theFolder)=0
 Removes the folder from the document (all features in the folder will be kept). More...
 
virtual std::shared_ptr< ModelAPI_FolderfindFolderAbove (const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures)=0
 Search a folder above the list of features applicable to store them (it means the list of features stored in the folder should be consequential) More...
 
virtual std::shared_ptr< ModelAPI_FolderfindFolderBelow (const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures)=0
 Search a folder below the list of features applicable to store them (it means the list of features stored in the folder should be consequential) More...
 
virtual std::shared_ptr< ModelAPI_FolderfindContainingFolder (const std::shared_ptr< ModelAPI_Feature > &theFeature, int &theIndexInFolder)=0
 Search a folder containing the given feature. More...
 
virtual bool moveToFolder (const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures, const std::shared_ptr< ModelAPI_Folder > &theFolder)=0
 Add a list of features to the folder. More...
 
virtual bool removeFromFolder (const std::list< std::shared_ptr< ModelAPI_Feature > > &theFeatures, const bool theBefore=true)=0
 Remove features from the folder. More...
 
virtual void setActive (const bool theFlag)=0
 Informs the document that it becomes active and some actions must be performed. More...
 
virtual bool isActive () const =0
 Returns true if this document is currently active. More...
 
virtual bool isOpened ()=0
 Returns true if document is opened and valid. More...
 
virtual std::shared_ptr< ModelAPI_FeatureproducedByFeature (std::shared_ptr< ModelAPI_Result > theResult, const std::shared_ptr< GeomAPI_Shape > &theShape)=0
 Returns the feature that produced the given face of the given result. More...
 
virtual bool isLater (std::shared_ptr< ModelAPI_Feature > theLater, std::shared_ptr< ModelAPI_Feature > theCurrent) const =0
 Returns true if theLater is in history of features creation later than theCurrent. More...
 
virtual void updateHistory (const std::string theGroup)=0
 Internally makes document know that feature was removed or added in history after creation. More...
 
virtual void storeNodesState (const std::list< bool > &theStates)=0
 Stores in the document boolean flags: states of the nodes in the object browser. More...
 
virtual void restoreNodesState (std::list< bool > &theStates) const =0
 Returns the stored nodes states. More...
 
virtual void eraseAllFeatures ()=0
 Just removes all features without touching the document data (to be able undo) More...
 
virtual std::shared_ptr< ModelAPI_FeaturenextFeature (std::shared_ptr< ModelAPI_Feature > theCurrent, const bool theReverse=false) const =0
 Returns the next (from the history point of view) feature, any: invisible or disabled. More...
 
virtual bool importPart (const char *theFileName, std::list< std::shared_ptr< ModelAPI_Feature > > &theImported, bool theCheckOnly=false)=0
 Loads the OCAF document from the file into the current document. More...
 
virtual bool save (const char *theFilename, const std::list< std::shared_ptr< ModelAPI_Feature > > &theExportFeatures) const =0
 Export the list of features to the file. More...
 
virtual void emptyFunction () const
 Empty function which is added for virtualiation of the interface. More...
 

Protected Member Functions

 ModelAPI_Document ()
 Only for SWIG wrapping it is here. More...
 
virtual void updateHistory (const std::shared_ptr< ModelAPI_Object > theObject)=0
 Internally makes document know that feature was removed or added in history after creation. More...
 

Friends

class ModelAPI_Object
 
class ModelAPI_Result
 

Detailed Description

Document for internal data structure of any object storage.

Document contains all data that must be stored/retrieved in the file. Also it provides access to this data: open/save, transactions management etc.

Constructor & Destructor Documentation

◆ ~ModelAPI_Document()

ModelAPI_Document::~ModelAPI_Document ( )
virtual

To virtually destroy the fields of successors.

◆ ModelAPI_Document()

ModelAPI_Document::ModelAPI_Document ( )
protected

Only for SWIG wrapping it is here.

Member Function Documentation

◆ kind()

virtual const std::string& ModelAPI_Document::kind ( ) const
pure virtual

Returns the kind of the document: "PartSet", "Part", or something else.

This kind is used for feature buttons enable/disable depending on active document (it uses workbench "document" identifier in XML configuration file for this)

Implemented in Model_Document.

◆ close()

virtual void ModelAPI_Document::close ( const bool  theForever = false)
pure virtual

Removes document data.

Parameters
theForeverif it is false, document is just hidden (to keep possibility make it back on Undo/Redo)

Implemented in Model_Document.

◆ addFeature()

virtual std::shared_ptr<ModelAPI_Feature> ModelAPI_Document::addFeature ( std::string  theID,
const bool  theMakeCurrent = true 
)
pure virtual

Adds to the document the new feature of the given feature id.

Parameters
theIDcreates feature and puts it in the document (if it is not action)
theMakeCurrentto make current this new feature in this document

Implemented in Model_Document.

◆ refsToFeature()

virtual void ModelAPI_Document::refsToFeature ( std::shared_ptr< ModelAPI_Feature theFeature,
std::set< std::shared_ptr< ModelAPI_Feature > > &  theRefs,
const bool  isSendError = true 
)
pure virtual

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

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

Implemented in Model_Document.

◆ removeFeature()

virtual void ModelAPI_Document::removeFeature ( std::shared_ptr< ModelAPI_Feature theFeature)
pure virtual

Removes the feature from the document.

Parameters
theFeaturea feature to be removed

Implemented in Model_Document.

◆ moveFeature()

virtual void ModelAPI_Document::moveFeature ( std::shared_ptr< ModelAPI_Feature theMoved,
std::shared_ptr< ModelAPI_Feature theAfterThis,
const bool  theSplit = false 
)
pure virtual

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

Implemented in Model_Document.

◆ id()

virtual const int ModelAPI_Document::id ( ) const
pure virtual

! Returns the id of the document

Implemented in Model_Document.

◆ object()

virtual std::shared_ptr<ModelAPI_Object> ModelAPI_Document::object ( const std::string &  theGroupID,
const int  theIndex,
const bool  theAllowFolder = false 
)
pure virtual

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

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

Implemented in Model_Document.

◆ objectByName()

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

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

Implemented in Model_Document.

◆ index()

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

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

Implemented in Model_Document.

◆ size()

virtual int ModelAPI_Document::size ( const std::string &  theGroupID,
const bool  theAllowFolder = false 
)
pure virtual

Returns the number of objects in the group of objects.

Parameters
theGroupIDgroup of objects
theAllowFoldertake into account grouping feature by folders

Implemented in Model_Document.

◆ parent()

virtual std::shared_ptr<ModelAPI_Object> ModelAPI_Document::parent ( const std::shared_ptr< ModelAPI_Object theChild)
pure virtual

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.

Implemented in Model_Document.

◆ currentFeature()

virtual std::shared_ptr<ModelAPI_Feature> ModelAPI_Document::currentFeature ( const bool  theVisible)
pure virtual

Returns the feature that is currently edited in this document, normally this is the latest created feature.

Parameters
theVisibleuse visible features only: flag is true for Object Browser functionality
Returns
null if next created feature must be the first

Implemented in Model_Document.

◆ setCurrentFeature()

virtual void ModelAPI_Document::setCurrentFeature ( std::shared_ptr< ModelAPI_Feature theCurrent,
const bool  theVisible 
)
pure virtual

Sets the current feature: all features below will be disabled, new features will be appended after this one.

This method does not flushes the events appeared: it will be done by the finishOperation, or direct flushes

Parameters
theCurrentthe selected feature as current: blow it everything become disabled
theVisibleuse visible features only: flag is true for Object Browser functionality

Implemented in Model_Document.

◆ setCurrentFeatureUp()

virtual void ModelAPI_Document::setCurrentFeatureUp ( )
pure virtual

Makes the current feature one feature upper.

Implemented in Model_Document.

◆ numInternalFeatures()

virtual int ModelAPI_Document::numInternalFeatures ( )
pure virtual

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

Implemented in Model_Document.

◆ internalFeature()

virtual std::shared_ptr<ModelAPI_Feature> ModelAPI_Document::internalFeature ( const int  theIndex)
pure virtual

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

Implemented in Model_Document.

◆ synchronizeTransactions()

virtual void ModelAPI_Document::synchronizeTransactions ( )
pure virtual

Performs synchronization of transactions with the module document: If some document is not active (by undo of activation) but in memory, on activation the transactions must be synchronized because all redo-s performed without this participation.

Implemented in Model_Document.

◆ createConstruction()

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

Creates a construction result.

Implemented in Model_Document.

◆ createBody()

virtual std::shared_ptr<ModelAPI_ResultBody> ModelAPI_Document::createBody ( const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0 
)
pure virtual

Creates a body result.

Implemented in Model_Document.

◆ createPart()

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

Creates a part result.

Implemented in Model_Document.

◆ copyPart()

virtual std::shared_ptr<ModelAPI_ResultPart> ModelAPI_Document::copyPart ( const std::shared_ptr< ModelAPI_ResultPart > &  theOrigin,
const std::shared_ptr< ModelAPI_Data > &  theFeatureData,
const int  theIndex = 0 
)
pure virtual

Copies a part result, keeping the reference to the origin.

Implemented in Model_Document.

◆ createGroup()

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

Creates a group result.

Implemented in Model_Document.

◆ createField()

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

Creates a field result.

Implemented in Model_Document.

◆ createParameter()

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

Creates a parameter result.

Implemented in Model_Document.

◆ feature()

virtual std::shared_ptr<ModelAPI_Feature> ModelAPI_Document::feature ( const std::shared_ptr< ModelAPI_Result > &  theResult)
pure virtual

Returns a feature by result (owner of result)

Implemented in Model_Document.

◆ allFeatures()

virtual std::list<std::shared_ptr<ModelAPI_Feature> > ModelAPI_Document::allFeatures ( )
pure virtual

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.

Implemented in Model_Document.

◆ allObjects()

virtual std::list<std::shared_ptr<ModelAPI_Object> > ModelAPI_Document::allObjects ( )
pure virtual

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.

Implemented in Model_Document.

◆ addFolder()

virtual std::shared_ptr<ModelAPI_Folder> ModelAPI_Document::addFolder ( std::shared_ptr< ModelAPI_Feature theAddBefore = std::shared_ptr< ModelAPI_Feature >())
pure virtual

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

Parameters
theAddBeforea feature, the folder is added before (if empty, the folder is added after the last feature)

Implemented in Model_Document.

◆ removeFolder()

virtual void ModelAPI_Document::removeFolder ( std::shared_ptr< ModelAPI_Folder theFolder)
pure virtual

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

Implemented in Model_Document.

◆ findFolderAbove()

virtual std::shared_ptr<ModelAPI_Folder> ModelAPI_Document::findFolderAbove ( const std::list< std::shared_ptr< ModelAPI_Feature > > &  theFeatures)
pure virtual

Search a folder above the list of features applicable to store them (it means the list of features stored in the folder should be consequential)

Returns
Empty pointer if there is no applicable folder

Implemented in Model_Document.

◆ findFolderBelow()

virtual std::shared_ptr<ModelAPI_Folder> ModelAPI_Document::findFolderBelow ( const std::list< std::shared_ptr< ModelAPI_Feature > > &  theFeatures)
pure virtual

Search a folder below the list of features applicable to store them (it means the list of features stored in the folder should be consequential)

Returns
Empty pointer if there is no applicable folder

Implemented in Model_Document.

◆ findContainingFolder()

virtual std::shared_ptr<ModelAPI_Folder> ModelAPI_Document::findContainingFolder ( const std::shared_ptr< ModelAPI_Feature > &  theFeature,
int &  theIndexInFolder 
)
pure virtual

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.

Implemented in Model_Document.

◆ moveToFolder()

virtual bool ModelAPI_Document::moveToFolder ( const std::list< std::shared_ptr< ModelAPI_Feature > > &  theFeatures,
const std::shared_ptr< ModelAPI_Folder > &  theFolder 
)
pure virtual

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

Implemented in Model_Document.

◆ removeFromFolder()

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

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

Implemented in Model_Document.

◆ setActive()

virtual void ModelAPI_Document::setActive ( const bool  theFlag)
pure virtual

Informs the document that it becomes active and some actions must be performed.

Implemented in Model_Document.

◆ isActive()

virtual bool ModelAPI_Document::isActive ( ) const
pure virtual

Returns true if this document is currently active.

Implemented in Model_Document.

◆ isOpened()

virtual bool ModelAPI_Document::isOpened ( )
pure virtual

Returns true if document is opened and valid.

Implemented in Model_Document.

◆ producedByFeature()

virtual std::shared_ptr<ModelAPI_Feature> ModelAPI_Document::producedByFeature ( std::shared_ptr< ModelAPI_Result theResult,
const std::shared_ptr< GeomAPI_Shape > &  theShape 
)
pure virtual

Returns the feature that produced the given face of the given result.

Implemented in Model_Document.

◆ isLater()

virtual bool ModelAPI_Document::isLater ( std::shared_ptr< ModelAPI_Feature theLater,
std::shared_ptr< ModelAPI_Feature theCurrent 
) const
pure virtual

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

Implemented in Model_Document.

◆ updateHistory() [1/2]

virtual void ModelAPI_Document::updateHistory ( const std::string  theGroup)
pure virtual

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

Implemented in Model_Document.

◆ storeNodesState()

virtual void ModelAPI_Document::storeNodesState ( const std::list< bool > &  theStates)
pure virtual

Stores in the document boolean flags: states of the nodes in the object browser.

Normally is called outside of the transaction, just before "save".

Implemented in Model_Document.

◆ restoreNodesState()

virtual void ModelAPI_Document::restoreNodesState ( std::list< bool > &  theStates) const
pure virtual

Returns the stored nodes states.

Normally it is calls just after "open". Appends the values to theStates list.

Implemented in Model_Document.

◆ eraseAllFeatures()

virtual void ModelAPI_Document::eraseAllFeatures ( )
pure virtual

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

Implemented in Model_Document.

◆ nextFeature()

virtual std::shared_ptr<ModelAPI_Feature> ModelAPI_Document::nextFeature ( std::shared_ptr< ModelAPI_Feature theCurrent,
const bool  theReverse = false 
) const
pure virtual

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)

Implemented in Model_Document.

◆ importPart()

virtual bool ModelAPI_Document::importPart ( const char *  theFileName,
std::list< std::shared_ptr< ModelAPI_Feature > > &  theImported,
bool  theCheckOnly = false 
)
pure virtual

Loads the OCAF document from the file into the current document.

All the features are added after the active feature.

Parameters
theFileNamename of the file to import
theImportedlist of features imported from the file
theCheckOnlyverify the document does not contain unappropriate features (useful for import to PartSet), but do not import it
Returns
true if file was loaded successfully

Implemented in Model_Document.

◆ save()

virtual bool ModelAPI_Document::save ( const char *  theFilename,
const std::list< std::shared_ptr< ModelAPI_Feature > > &  theExportFeatures 
) const
pure virtual

Export the list of features to the file.

Parameters
theFilenamepath to save the file
theExportFeatureslist of features to export

Implemented in Model_Document.

◆ updateHistory() [2/2]

virtual void ModelAPI_Document::updateHistory ( const std::shared_ptr< ModelAPI_Object theObject)
protectedpure virtual

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

Implemented in Model_Document.

◆ emptyFunction()

virtual void ModelAPI_Entity::emptyFunction ( ) const
inlinevirtualinherited

Empty function which is added for virtualiation of the interface.