SHAPER  9.12.0
Model_Data Class Reference

General object of the application that allows to get/set attributes from the document and compute result of an operation. More...

Inheritance diagram for Model_Data:
Inheritance graph

Public Member Functions

 Model_Data ()
 The simplest constructor. "setLabel" must be called just after to initialize correctly. More...
 
virtual MODEL_EXPORT std::wstring name ()
 Returns the name of the feature visible by the user in the object browser. More...
 
virtual MODEL_EXPORT void setName (const std::wstring &theName)
 Defines the name of the feature visible by the user in the object browser. More...
 
virtual MODEL_EXPORT bool hasUserDefinedName () const
 Return true if the object has been renamed by the user. More...
 
virtual MODEL_EXPORT std::string version ()
 Returns version of the feature (empty string if not applicable) More...
 
virtual MODEL_EXPORT void setVersion (const std::string &theVersion)
 Initialize the version of the feature. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeDocRefdocument (const std::string &theID)
 Returns the attribute that references to another document. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeDoublereal (const std::string &theID)
 Returns the attribute that contains real value with double precision. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeDoubleArrayrealArray (const std::string &theID)
 Returns the attribute that contains double values array. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeIntegerinteger (const std::string &theID)
 Returns the attribute that contains integer value. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeReferencereference (const std::string &theID)
 Returns the attribute that contains reference to a feature. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeSelectionselection (const std::string &theID)
 Returns the attribute that contains selection to a shape. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeSelectionListselectionList (const std::string &theID)
 Returns the attribute that contains selection to a shape. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeRefAttrrefattr (const std::string &theID)
 Returns the attribute that contains reference to an attribute of a feature. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeRefListreflist (const std::string &theID)
 Returns the attribute that contains list of references to features. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeRefAttrListrefattrlist (const std::string &theID)
 Returns the attribute that contains list of references to features or reference to an attribute of a feature. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeBooleanboolean (const std::string &theID)
 Returns the attribute that contains boolean value. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeStringstring (const std::string &theID)
 Returns the attribute that contains real value with double precision. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeIntArrayintArray (const std::string &theID)
 Returns the attribute that contains integer values array. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeStringArraystringArray (const std::string &theID)
 Returns the attribute that contains string values array. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeTablestables (const std::string &theID)
 Returns the attribute that contains string values array. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_AttributeImageimage (const std::string &theID)
 Returns the attribute that contains image. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_Attributeattribute (const std::string &theID)
 Returns the generic attribute by identifier. More...
 
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. More...
 
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. More...
 
virtual MODEL_EXPORT const std::string & id (const std::shared_ptr< ModelAPI_Attribute > &theAttr)
 Identifier by the id (not fast, iteration by map) More...
 
virtual MODEL_EXPORT bool isEqual (const std::shared_ptr< ModelAPI_Data > &theData)
 Returns true if data belongs to same features. More...
 
virtual MODEL_EXPORT bool isValid ()
 Returns true if it is correctly connected to the data model. More...
 
TDF_Label shapeLab () const
 Returns the label where the shape must be stored (used in ResultBody) More...
 
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 attribute of the object. More...
 
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) More...
 
virtual MODEL_EXPORT void allGroups (std::list< std::string > &theGroups)
 Returns all groups of this data (ordered). More...
 
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. More...
 
virtual MODEL_EXPORT void removeAttributes (const std::string &theGroup)
 Remove all attributes of the given group. More...
 
virtual MODEL_EXPORT void sendAttributeUpdated (ModelAPI_Attribute *theAttr)
 Useful method for "set" methods of the attributes: sends an UPDATE event and makes attribute initialized. More...
 
virtual MODEL_EXPORT bool blockSendAttributeUpdated (const bool theBlock, const bool theSendMessage=true)
 Blocks sending "attribute updated" if theBlock is true. More...
 
MODEL_EXPORT void setLabel (TDF_Label theLab)
 Puts feature to the document data sub-structure. More...
 
virtual MODEL_EXPORT void setObject (ObjectPtr theObject)
 Sets the object of this data. More...
 
virtual MODEL_EXPORT void erase ()
 Erases all the data from the data model. More...
 
virtual MODEL_EXPORT void execState (const ModelAPI_ExecState theState)
 Stores the state of the object to execute it later accordingly. More...
 
virtual MODEL_EXPORT ModelAPI_ExecState execState ()
 Returns the state of the latest execution of the feature. More...
 
virtual MODEL_EXPORT void setError (const std::string &theError, bool theSend=true)
 Registers error during the execution, causes the ExecutionFailed state. More...
 
void eraseErrorString ()
 Erases the error string if it is not empty. More...
 
virtual MODEL_EXPORT std::string error () const
 Registers error during the execution, causes the ExecutionFailed state. More...
 
virtual MODEL_EXPORT int featureId () const
 Returns the identifier of feature-owner, unique in this document. More...
 
virtual MODEL_EXPORT const std::set< AttributePtr > & refsToMe ()
 returns all objects referenced to this More...
 
virtual MODEL_EXPORT void referencesToObjects (std::list< std::pair< std::string, std::list< ObjectPtr > > > &theRefs)
 returns all references by attributes of this data More...
 
virtual MODEL_EXPORT void copyTo (std::shared_ptr< ModelAPI_Data > theTarget)
 Copies all attributes content into theTarget data. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_DatainvalidPtr ()
 Returns the invalid data pointer (to avoid working with NULL shared pointers in swig) More...
 
virtual MODEL_EXPORT int updateID ()
 Identifier of the transaction when object (feature or result) was updated last time. More...
 
virtual MODEL_EXPORT void setUpdateID (const int theID)
 Identifier of the transaction when object (feature or result) was updated last time. More...
 
virtual MODEL_EXPORT std::shared_ptr< ModelAPI_Objectowner ()
 Returns true if the given object is owner of this data (needed for correct erase of object with duplicated data) More...
 

Static Public Member Functions

static std::shared_ptr< ModelAPI_DatainvalidData ()
 Returns the invalid data pointer: static method. More...
 

Protected Member Functions

virtual MODEL_EXPORT bool isInHistory ()
 Returns true if "is in history" custom behaviors is defined for the feature. More...
 
virtual MODEL_EXPORT void setIsInHistory (const bool theFlag)
 Defines the custom "is in history" behavior. More...
 
virtual MODEL_EXPORT bool isDeleted ()
 Returns true if the object is deleted, but some data is still kept in memory. More...
 
virtual MODEL_EXPORT void setIsDeleted (const bool theFlag)
 Sets true if the object is deleted, but some data is still kept in memory. More...
 
void clearAttributes ()
 Erases all attributes from myAttrs, but keeping them in the data structure. More...
 

Friends

class Model_Document
 
class Model_Objects
 
class Model_Update
 
class Model_AttributeReference
 
class Model_AttributeRefAttr
 
class Model_AttributeRefList
 
class Model_AttributeRefAttrList
 
class Model_AttributeSelection
 
class Model_AttributeSelectionList
 
class Model_ValidatorsFactory
 
class Model_SelectionNaming
 
class Model_ResultConstruction
 
class Model_ResultBody
 
class Model_Tools
 

Detailed Description

General object of the application that allows to get/set attributes from the document and compute result of an operation.

Constructor & Destructor Documentation

◆ Model_Data()

Model_Data::Model_Data ( )

The simplest constructor. "setLabel" must be called just after to initialize correctly.

Member Function Documentation

◆ name()

std::wstring Model_Data::name ( )
virtual

Returns the name of the feature visible by the user in the object browser.

Implements ModelAPI_Data.

◆ setName()

void Model_Data::setName ( const std::wstring &  theName)
virtual

Defines the name of the feature visible by the user in the object browser.

Implements ModelAPI_Data.

◆ hasUserDefinedName()

bool Model_Data::hasUserDefinedName ( ) const
virtual

Return true if the object has been renamed by the user.

Implements ModelAPI_Data.

◆ version()

std::string Model_Data::version ( )
virtual

Returns version of the feature (empty string if not applicable)

Implements ModelAPI_Data.

◆ setVersion()

void Model_Data::setVersion ( const std::string &  theVersion)
virtual

Initialize the version of the feature.

Implements ModelAPI_Data.

◆ document()

std::shared_ptr< ModelAPI_AttributeDocRef > Model_Data::document ( const std::string &  theID)
virtual

Returns the attribute that references to another document.

Implements ModelAPI_Data.

◆ real()

std::shared_ptr< ModelAPI_AttributeDouble > Model_Data::real ( const std::string &  theID)
virtual

Returns the attribute that contains real value with double precision.

Implements ModelAPI_Data.

◆ realArray()

std::shared_ptr< ModelAPI_AttributeDoubleArray > Model_Data::realArray ( const std::string &  theID)
virtual

Returns the attribute that contains double values array.

Implements ModelAPI_Data.

◆ integer()

std::shared_ptr< ModelAPI_AttributeInteger > Model_Data::integer ( const std::string &  theID)
virtual

Returns the attribute that contains integer value.

Implements ModelAPI_Data.

◆ reference()

std::shared_ptr< ModelAPI_AttributeReference > Model_Data::reference ( const std::string &  theID)
virtual

Returns the attribute that contains reference to a feature.

Implements ModelAPI_Data.

◆ selection()

std::shared_ptr< ModelAPI_AttributeSelection > Model_Data::selection ( const std::string &  theID)
virtual

Returns the attribute that contains selection to a shape.

Implements ModelAPI_Data.

◆ selectionList()

std::shared_ptr< ModelAPI_AttributeSelectionList > Model_Data::selectionList ( const std::string &  theID)
virtual

Returns the attribute that contains selection to a shape.

Implements ModelAPI_Data.

◆ refattr()

std::shared_ptr< ModelAPI_AttributeRefAttr > Model_Data::refattr ( const std::string &  theID)
virtual

Returns the attribute that contains reference to an attribute of a feature.

Implements ModelAPI_Data.

◆ reflist()

std::shared_ptr< ModelAPI_AttributeRefList > Model_Data::reflist ( const std::string &  theID)
virtual

Returns the attribute that contains list of references to features.

Implements ModelAPI_Data.

◆ refattrlist()

std::shared_ptr< ModelAPI_AttributeRefAttrList > Model_Data::refattrlist ( const std::string &  theID)
virtual

Returns the attribute that contains list of references to features or reference to an attribute of a feature.

Implements ModelAPI_Data.

◆ boolean()

std::shared_ptr< ModelAPI_AttributeBoolean > Model_Data::boolean ( const std::string &  theID)
virtual

Returns the attribute that contains boolean value.

Implements ModelAPI_Data.

◆ string()

std::shared_ptr< ModelAPI_AttributeString > Model_Data::string ( const std::string &  theID)
virtual

Returns the attribute that contains real value with double precision.

Implements ModelAPI_Data.

◆ intArray()

std::shared_ptr< ModelAPI_AttributeIntArray > Model_Data::intArray ( const std::string &  theID)
virtual

Returns the attribute that contains integer values array.

Implements ModelAPI_Data.

◆ stringArray()

std::shared_ptr< ModelAPI_AttributeStringArray > Model_Data::stringArray ( const std::string &  theID)
virtual

Returns the attribute that contains string values array.

Implements ModelAPI_Data.

◆ tables()

std::shared_ptr< ModelAPI_AttributeTables > Model_Data::tables ( const std::string &  theID)
virtual

Returns the attribute that contains string values array.

Implements ModelAPI_Data.

◆ image()

std::shared_ptr< ModelAPI_AttributeImage > Model_Data::image ( const std::string &  theID)
virtual

Returns the attribute that contains image.

Implements ModelAPI_Data.

◆ attribute()

std::shared_ptr< ModelAPI_Attribute > Model_Data::attribute ( const std::string &  theID)
virtual

Returns the generic attribute by identifier.

Parameters
theIDidentifier of the attribute

Implements ModelAPI_Data.

◆ attributes()

std::list< std::shared_ptr< ModelAPI_Attribute > > Model_Data::attributes ( const std::string &  theType)
virtual

Returns all attributes of the feature of the given type or all attributes if "theType" is empty.

Implements ModelAPI_Data.

◆ attributesIDs()

std::list< std::string > Model_Data::attributesIDs ( const std::string &  theType)
virtual

Returns all attributes ids of the feature of the given type or all attributes if "theType" is empty.

Implements ModelAPI_Data.

◆ id()

const std::string & Model_Data::id ( const std::shared_ptr< ModelAPI_Attribute > &  theAttr)
virtual

Identifier by the id (not fast, iteration by map)

Parameters
theAttrattribute already created in this data

Implements ModelAPI_Data.

◆ isEqual()

bool Model_Data::isEqual ( const std::shared_ptr< ModelAPI_Data > &  theData)
virtual

Returns true if data belongs to same features.

Implements ModelAPI_Data.

◆ isValid()

bool Model_Data::isValid ( )
virtual

Returns true if it is correctly connected to the data model.

Implements ModelAPI_Data.

◆ shapeLab()

TDF_Label Model_Data::shapeLab ( ) const
inline

Returns the label where the shape must be stored (used in ResultBody)

◆ addAttribute()

AttributePtr Model_Data::addAttribute ( const std::string &  theID,
const std::string  theAttrType,
const int  theIndex = -1 
)
virtual

Initializes object by the attributes: must be called just after the object is created for each attribute of the object.

Parameters
theIDidentifier of the attribute that can be referenced by this ID later
theAttrTypetype of the created attribute (received from the type method)
theIndexindex of the attribute in the internal data structure, for not-floating attributes it is -1 to let it automatically be added
Returns
the just created attribute

Implements ModelAPI_Data.

◆ addFloatingAttribute()

AttributePtr Model_Data::addFloatingAttribute ( const std::string &  theID,
const std::string  theAttrType,
const std::string &  theGroup 
)
virtual

Adds a floating attribute (that may be added/removed during the data life)

Parameters
theIDidentifier of the attribute that can be referenced by this ID later
theAttrTypetype of the created attribute (received from the type method)
theGroupidentifier of the group this attribute belongs to, may be an empty string

Implements ModelAPI_Data.

◆ allGroups()

void Model_Data::allGroups ( std::list< std::string > &  theGroups)
virtual

Returns all groups of this data (ordered).

Implements ModelAPI_Data.

◆ attributesOfGroup()

void Model_Data::attributesOfGroup ( const std::string &  theGroup,
std::list< std::shared_ptr< ModelAPI_Attribute > > &  theAttrs 
)
virtual

Returns an ordered list of attributes that belong to the given group.

Implements ModelAPI_Data.

◆ removeAttributes()

void Model_Data::removeAttributes ( const std::string &  theGroup)
virtual

Remove all attributes of the given group.

Implements ModelAPI_Data.

◆ sendAttributeUpdated()

void Model_Data::sendAttributeUpdated ( ModelAPI_Attribute theAttr)
virtual

Useful method for "set" methods of the attributes: sends an UPDATE event and makes attribute initialized.

Implements ModelAPI_Data.

◆ blockSendAttributeUpdated()

bool Model_Data::blockSendAttributeUpdated ( const bool  theBlock,
const bool  theSendMessage = true 
)
virtual

Blocks sending "attribute updated" if theBlock is true.

Parameters
theBlockallows switching on/off the blocking state
theSendMessageif false, it does not send the update message even if something is changed (normally is it used in attributeChanged because this message will be sent anyway)
Returns
the previous state of block

Implements ModelAPI_Data.

◆ setLabel()

void Model_Data::setLabel ( TDF_Label  theLab)

Puts feature to the document data sub-structure.

◆ setObject()

virtual MODEL_EXPORT void Model_Data::setObject ( ObjectPtr  theObject)
inlinevirtual

Sets the object of this data.

◆ erase()

void Model_Data::erase ( )
virtual

Erases all the data from the data model.

Implements ModelAPI_Data.

◆ execState() [1/2]

void Model_Data::execState ( const ModelAPI_ExecState  theState)
virtual

Stores the state of the object to execute it later accordingly.

Implements ModelAPI_Data.

◆ execState() [2/2]

ModelAPI_ExecState Model_Data::execState ( )
virtual

Returns the state of the latest execution of the feature.

Implements ModelAPI_Data.

◆ setError()

void Model_Data::setError ( const std::string &  theError,
bool  theSend = true 
)
virtual

Registers error during the execution, causes the ExecutionFailed state.

Implements ModelAPI_Data.

◆ eraseErrorString()

void Model_Data::eraseErrorString ( )

Erases the error string if it is not empty.

◆ error()

std::string Model_Data::error ( ) const
virtual

Registers error during the execution, causes the ExecutionFailed state.

Implements ModelAPI_Data.

◆ featureId()

int Model_Data::featureId ( ) const
virtual

Returns the identifier of feature-owner, unique in this document.

Implements ModelAPI_Data.

◆ refsToMe()

virtual MODEL_EXPORT const std::set<AttributePtr>& Model_Data::refsToMe ( )
inlinevirtual

returns all objects referenced to this

Implements ModelAPI_Data.

◆ referencesToObjects()

void Model_Data::referencesToObjects ( std::list< std::pair< std::string, std::list< ObjectPtr > > > &  theRefs)
virtual

returns all references by attributes of this data

Parameters
theRefsreturned list of pairs: id of referenced attribute and list of referenced objects

Implements ModelAPI_Data.

◆ copyTo()

void Model_Data::copyTo ( std::shared_ptr< ModelAPI_Data theTarget)
virtual

Copies all attributes content into theTarget data.

Implements ModelAPI_Data.

◆ invalidPtr()

std::shared_ptr< ModelAPI_Data > Model_Data::invalidPtr ( )
virtual

Returns the invalid data pointer (to avoid working with NULL shared pointers in swig)

Implements ModelAPI_Data.

◆ invalidData()

std::shared_ptr< ModelAPI_Data > Model_Data::invalidData ( )
static

Returns the invalid data pointer: static method.

◆ updateID()

int Model_Data::updateID ( )
virtual

Identifier of the transaction when object (feature or result) was updated last time.

Implements ModelAPI_Data.

◆ setUpdateID()

void Model_Data::setUpdateID ( const int  theID)
virtual

Identifier of the transaction when object (feature or result) was updated last time.

This method is called by the updater.

Implements ModelAPI_Data.

◆ owner()

std::shared_ptr< ModelAPI_Object > Model_Data::owner ( )
virtual

Returns true if the given object is owner of this data (needed for correct erase of object with duplicated data)

Implements ModelAPI_Data.

◆ isInHistory()

bool Model_Data::isInHistory ( )
protectedvirtual

Returns true if "is in history" custom behaviors is defined for the feature.

Implements ModelAPI_Data.

◆ setIsInHistory()

void Model_Data::setIsInHistory ( const bool  theFlag)
protectedvirtual

Defines the custom "is in history" behavior.

Implements ModelAPI_Data.

◆ isDeleted()

bool Model_Data::isDeleted ( )
protectedvirtual

Returns true if the object is deleted, but some data is still kept in memory.

Implements ModelAPI_Data.

◆ setIsDeleted()

void Model_Data::setIsDeleted ( const bool  theFlag)
protectedvirtual

Sets true if the object is deleted, but some data is still kept in memory.

Implements ModelAPI_Data.

◆ clearAttributes()

void Model_Data::clearAttributes ( )
protected

Erases all attributes from myAttrs, but keeping them in the data structure.