Classes | Public Member Functions | List of all members
DgnModel Struct Referenceabstract

A DgnModel represents a DgnModel in memory. More...

#include <DgnModel.h>

Inheritance diagram for DgnModel:
DgnModelRef

Classes

struct  ElementRefIterator
 Iterator over the elements in a DgnModel. More...
 
struct  ElementsCollection
 Collection of all elements in a model. More...
 

Public Member Functions

IDgnComponentDefinitionHandlerP GetDgnComponentDefinitionHandler ()
 
DgnModelStatus SetModelInfo (ModelInfoR modelInfo)
 Sets ModelInfo to new one if possible. More...
 
UInt32 GetControlElmStart ()
 Get the FilePos of the first Control Element for this DgnModel. More...
 
UInt32 GetGraphicElmStart ()
 Get the FilePos of the first Graphic Element for this DgnModel. More...
 
UpdateSequenceListP GetUpdateSequence ()
 Get the update sequence for this models references. This is a list of DgnAttachment element ids. More...
 
void SetUpdateSequence (UpdateSequenceListP list)
 Set the update sequence for this models references. This is a list of DgnAttachment element ids. More...
 
Filling
StatusInt FillSections (DgnModelSections sectionsToFill, DgnModelFillContextP fillContext=0)
 Read elements from the physical file into this model. More...
 
void Empty (bool evenIfDirty=false, bool andFree=false)
 Empty the contents of this model. More...
 
DgnModelSections IsFilled (DgnModelSections sections) const
 Determine whether this model has been "filled" from disk or not. More...
 
UInt32 GetElementCount (DgnModelSections sections)
 Get the number of elements in this model. More...
 
FileLevelCacheR GetFileLevelCacheR ()
 Get access to levels defined in the DgnFile associated with this DgnModel. More...
 
FileLevelCacheCR GetFileLevelCache () const
 Get read-only access to levels defined in the DgnFile associated with this DgnModel. More...
 
bool IsDictionaryModel () const
 Determine whether this model is a dictionary model. More...
 
Finding Elements
PersistentElementRefListGetControlElementsP ()
 Get the list of control elements in this model. More...
 
PersistentElementRefListGetGraphicElementsP ()
 Get the list of graphic elements in this model. More...
 
int AddRef ()
 Increment the reference count of this model. More...
 
int Release ()
 Decrement the reference count of this model. More...
 
ElementsCollection GetElementsCollection () const
 Get the collection of all elements in the model, including both control and graphics elements. More...
 
PersistentElementRefP FindElementByID (ElementId id) const
 Find an ElementRefP in this model by ElementId. More...
 
Properties
ModelId GetModelId () const
 Get the ModelId for this model. More...
 
ModelInfoCR GetModelInfo () const
 Get the ModelInfo for this model. More...
 
StatusInt SaveModelSettings ()
 Save the settings for this DgnModel's ModelInfo. More...
 
WCharCP GetModelName () const
 Shortcut for querying the model name for this model. More...
 
bool IsReadOnly () const
 Determine whether this is a readonly DgnModel or not. More...
 
DgnFileP GetDgnFileP () const
 Get the file that contains this model. More...
 
StatusInt GetRange (ScanRangeR range)
 Get the spatial extent of all elements in this model. More...
 
StatusInt GetRange (DRange3dR range)
 
DgnModelAppData
StatusInt AddAppData (DgnModelAppData::Key const &key, DgnModelAppData *appData)
 Add (or replace) appData to this model. More...
 
StatusInt DropAppData (DgnModelAppData::Key const &key)
 Remove appData from this model. More...
 
DgnModelAppDataFindAppData (DgnModelAppData::Key const &key) const
 Search for appData on this model that was added with the specified key. More...
 
Attachments
ReferencedByArrayCR GetReferencedBy ()
 Get the list of Bentley::DgnPlatform::DgnAttachments that reference this model. More...
 
- Public Member Functions inherited from DgnModelRef
StatusInt CreateDgnAttachment (DgnAttachmentP &attachment, DgnDocumentMonikerR moniker, WCharCP modelName, bool loadCache=true)
 Attach the specified model in the specified file to this model. More...
 
StatusInt DeleteDgnAttachment (DgnAttachmentP &attachment)
 Remove the specified attachment from this model. More...
 
DgnAttachmentArrayP GetDgnAttachmentsP () const
 Get the attachments contained in this model. More...
 
DgnAttachmentArrayCP GetDgnAttachmentsCP () const
 Get the attachments contained in this model. More...
 
ReachableModelRefCollection GetReachableModelRefs (ReachableModelRefOptionsP=0)
 Get an iterable collection of modelRefs that includes 'this' modelRef, its attachments and all nested attachments. More...
 
ReachableElementCollection GetReachableElements (ReachableElementOptionsP=0)
 Get an iterable collection of elements reachable from this modelRef. More...
 
DgnAttachmentP FindDgnAttachmentByElementId (ElementId attachmentID)
 Gets the Bentley::DgnPlatform::DgnAttachment structure that for a reference given the element ID of its attachment element. More...
 
StatusInt ReadAndLoadDgnAttachments (DgnAttachmentLoadOptions const &)
 Detects attachments in this model, creates a Bentley::DgnPlatform::DgnAttachment for each, and then loads the attached models. More...
 
DgnModelRefP GetParentModelRefP () const
 Query the parent of an attachment, if any. More...
 
DgnModelP GetDgnModelP () const
 Get the model that is the target of this reference. More...
 
DgnFileP GetDgnFileP () const
 Get the file that this references. More...
 
ModelInfoCP GetModelInfoCP () const
 Get information about this model that this references. More...
 
bool IsDgnAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment. This function is equivalent to testing the result of AsDgnAttachmentCP. More...
 
bool IsDirectDgnAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment that is itself a direct attachment. More...
 
bool IsNestedDgnAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment that is itself an attachment owned by another DgnAttachment. More...
 
bool IsDwgStyleAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment that is a DWG style attachment. More...
 
bool IsDefault () const
 Query if this references the default model in its file. More...
 
DgnModelRefType GetModelRefType () const
 Query if this model is an attachment and if so what type of attachment. More...
 
DgnModelCP AsDgnModelCP () const
 Cast this to a DgnModel. More...
 
DgnModelP AsDgnModelP ()
 Cast this to a DgnModel. More...
 
DgnAttachmentCP AsDgnAttachmentCP () const
 Cast this to a Bentley::DgnPlatform::DgnAttachment. More...
 
DgnAttachmentP AsDgnAttachmentP ()
 Cast this to a Bentley::DgnPlatform::DgnAttachment. More...
 
LevelCacheR GetLevelCacheR ()
 Get the level cache for this model reference. More...
 
LevelCacheCR GetLevelCache () const
 Get the level cache for this model reference. More...
 
FileLevelCacheP GetFileLevelCacheP ()
 Get the level cache for the file containing this model. More...
 
FileLevelCacheCP GetFileLevelCacheCP () const
 Get the level cache for the file containing this model. More...
 
bool Is3d () const
 Query if this is a 3D model. More...
 
bool TreatAs3d () const
 Query if this model should be treated as a 3D model for user interface purposes. It is true if the model is 3D and not a sheet model. More...
 
DgnFileP GetSymbologySourceDgnFileP () const
 Get the source file for this modelRef. This is the same as GetDgnFile unless the modelRef is a DgnAttachment that is being displayed by proxy (CVE) - in this case the symbology source will be the root. More...
 

Detailed Description

A DgnModel represents a DgnModel in memory.

It holds all of the elements that belong to the model.

A DgnModel is part of a Bentley::DgnPlatform::DgnFile. A DgnModel belongs to one and only one DgnFile.

Filling

Opening a DgnFile does not cause it to load any element data. Likewise, model look-up functions such as Bentley::DgnPlatform::DgnFile::LoadModelById do not load element data. In order to access elements, you must get a DgnModel and then "fill" it.

Model Properties

A MicroStation Model has a name, a type, units, and several other properties.

Note: You do not have to fill a model in order to access its properties.

Note: You can get information about the models in a DgnFile without loading them by using the file's model index. See Bentley::DgnPlatform::DgnFile::GetModelIndex.

Accessing Elements

See Collections below. See Element Handles.

Adding, Updating, and Deleting Elements

See Transaction Manager

Collections and Iterators

A DgnModel contains two DgnElmLists of elements: the ControlElm list holds only elements that are non-displayable (their "isGraphic" flag is off) and the GraphicElm list holds all displayable elements. Each of these lists is a collection. If you need to scan only non-graphic elements, the most efficient way is to call GetControlElementsP and then iterate. If you need to scan only graphic elements, the most efficient way is to call GetGraphicElementsP and then iterate.

Remarks
Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib

Member Function Documentation

StatusInt AddAppData ( DgnModelAppData::Key const &  key,
DgnModelAppData appData 
)

Add (or replace) appData to this model.

Returns
SUCCESS if appData was successfully added. Note that it is illegal to add or remove AppData from within any of the AppData "_On" methods. If an entry with key already exists, it will be dropped and replaced with appData.
int AddRef ( )

Increment the reference count of this model.

Returns
the new reference count
StatusInt DropAppData ( DgnModelAppData::Key const &  key)

Remove appData from this model.

Returns
SUCCESS if appData with key is found and was dropped.
Remarks
Calls the app data object's _OnCleanup method.
void Empty ( bool  evenIfDirty = false,
bool  andFree = false 
)

Empty the contents of this model.

Parameters
[in]evenIfDirtyIf false, the DgnModel will not be emptied if there are unsaved changes.
[in]andFreeIf true, the DgnModel will not be able to be reloaded again.
StatusInt FillSections ( DgnModelSections  sectionsToFill,
DgnModelFillContextP  fillContext = 0 
)

Read elements from the physical file into this model.

Parameters
[in]sectionsToFillThe sections of this model to fill. The Control and Graphic elements can be loaded independently, but are usually filled together.
[in]fillContextMicroStation internal only.
Note
Whenever the first section of any DgnModel is filled for a Bentley::DgnPlatform::DgnFile, the Dictionary model for that file is filled as well.
DgnModelAppData* FindAppData ( DgnModelAppData::Key const &  key) const

Search for appData on this model that was added with the specified key.

Returns
the DgnModelAppData with key, or NULL.
PersistentElementRefP FindElementByID ( ElementId  id) const

Find an ElementRefP in this model by ElementId.

Returns
ElementRefP of element with id, or NULL.
PersistentElementRefList* GetControlElementsP ( )

Get the list of control elements in this model.

Example:

for (PersistentElementRefP const& elemRef: *model.GetControlElementsP ())
{
//...
}
UInt32 GetControlElmStart ( )

Get the FilePos of the first Control Element for this DgnModel.

IDgnComponentDefinitionHandlerP GetDgnComponentDefinitionHandler ( )
DgnFileP GetDgnFileP ( ) const

Get the file that contains this model.

Returns
the DgnFile that contains this model or NULL.

Referenced by ElementHandle::GetDgnFileP().

UInt32 GetElementCount ( DgnModelSections  sections)

Get the number of elements in this model.

Parameters
[in]sectionsthe DgnModel sections to include in the count.
Returns
the number of elements in the requested sections of this model.
Note
The model must be filled before calling this method. The count only includes elements from filled sections.
The element count includes deleted elements.
See also
FillSections
ElementsCollection GetElementsCollection ( ) const

Get the collection of all elements in the model, including both control and graphics elements.

Example:

for (PersistentElementRefP const& elemRef: model.GetElementsCollection ())
{
//...
}
See also
GetControlElementsP
GetGraphicElementsP
FileLevelCacheCR GetFileLevelCache ( ) const

Get read-only access to levels defined in the DgnFile associated with this DgnModel.

Returns
a const reference to the FileLevelCache of the DgnFile associated with this DgnModel.
Note
Since a DgnModel always has an open DgnFile (in contrast to a DgnModelRef, which can be a DgnAttachment for which the DgnFile is not resolved or not loaded), it is always possible to obtain the FileLevelCache, so this method can return a reference rather than a pointer.
FileLevelCacheR GetFileLevelCacheR ( )

Get access to levels defined in the DgnFile associated with this DgnModel.

Returns
the FileLevelCache of the DgnFile associated with this DgnModel.
Note
Since a DgnModel always has an open DgnFile (in contrast to a DgnModelRef, which can be a DgnAttachment for which the DgnFile is not resolved or not loaded), it is always possible to obtain the FileLevelCache, so this method can return a reference rather than a pointer.
PersistentElementRefList* GetGraphicElementsP ( )

Get the list of graphic elements in this model.

Example:

if (NULL != model.GetGraphicElementsP())
{
for (PersistentElementRefP const& elemRef: *model.GetGraphicElementsP ())
{
//...
}
}
UInt32 GetGraphicElmStart ( )

Get the FilePos of the first Graphic Element for this DgnModel.

ModelId GetModelId ( ) const

Get the ModelId for this model.

ModelInfoCR GetModelInfo ( ) const

Get the ModelInfo for this model.

Remarks
To modify the modelinfo you must create a copy of the returned one, modify it, and call SetModelInfo () with the changed version.
See also
ModelInfo::MakeCopy
SetModelInfo
WCharCP GetModelName ( ) const

Shortcut for querying the model name for this model.

StatusInt GetRange ( ScanRangeR  range)

Get the spatial extent of all elements in this model.

Parameters
[out]rangeFilled with the union of all of the ranges of the elements in model.
StatusInt GetRange ( DRange3dR  range)
ReferencedByArrayCR GetReferencedBy ( )

Get the list of Bentley::DgnPlatform::DgnAttachments that reference this model.

UpdateSequenceListP GetUpdateSequence ( )

Get the update sequence for this models references. This is a list of DgnAttachment element ids.

bool IsDictionaryModel ( ) const

Determine whether this model is a dictionary model.

DgnModelSections IsFilled ( DgnModelSections  sections) const

Determine whether this model has been "filled" from disk or not.

Parameters
[in]sectionsthe DgnModelSections to test.
Returns
the mask of the DgnModelSections that have been filled.
bool IsReadOnly ( ) const

Determine whether this is a readonly DgnModel or not.

int Release ( )

Decrement the reference count of this model.

Returns
the new reference count
StatusInt SaveModelSettings ( )

Save the settings for this DgnModel's ModelInfo.

DgnModelStatus SetModelInfo ( ModelInfoR  modelInfo)

Sets ModelInfo to new one if possible.

Fails if New ModelInfo is incompatible with current model. If successful, the ModelInfo will be updated to reflect any changes done internally.

  • Cannot change 2d/3d property.
  • Cannot modify properties of a locked ModelInfo unless unlocking.
  • Cannot modify properties of a read-only DgnModel.
  • Cannot change to/from DgnModelType::Extraction_Deprecated. Returns DGNMODEL_STATUS_InvalidModelTypeSwitch. If ModelType is Sheet or Drawing, this propagates the background color out to other models of the same type. If BorderAttachmentId on the ModelInfo's SheetDef has changed, the SheetDef's properties will be updated to be in sync with the BorderAttachment. Applies ModelInfo changes to TxnManager and sends out pre/post change notifications.
    Returns
    DGNMODEL_STATUS_Success if no different than current ModelInfo or if new one is used.
void SetUpdateSequence ( UpdateSequenceListP  list)

Set the update sequence for this models references. This is a list of DgnAttachment element ids.


The documentation for this struct was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.