Shared Cells are an efficient way to store repeated displayable geometry. More...
Classes | |
struct | SharedCellHandler |
The default type handler for the SHARED_CELL_ELM type that corresponds to the SharedCell structure. More... | |
struct | SharedCellDefHandler |
The default type handler for the SHAREDCELL_DEF_ELM type that corresponds to the SharedCellDef structure. More... | |
Functions | |
void | mdlSharedCell_addDefinitionElements (MSElementDescrP cellDscrP, RotMatrixP rotScale, Dpoint3d *rOrigin) |
Convert the cell definition element descriptor pointed to by cellDscrP to a shared cell definition and add the definition to the file. More... | |
UInt32 | mdlSharedCell_addToFile (MSElementP cellHeader, RotMatrixP rMatrix, int relativeMode, int baseLevel, DgnPlatform::AssocPoint *assocOrigin) |
Add a shared cell instance to the file and display the new shared cell. More... | |
int | mdlSharedCell_create (MSElementP newSCElm, MSElementCP existingSCElm, Dpoint3d *origin, RotMatrixP rMatrix, Dpoint3d *scale, WCharCP cellName, DgnPlatform::SCOverride *scOverride, int relativeMode, int baseLevel, DgnPlatform::AssocPoint *assocOrigin) |
Create a shared cell instance element from the parameters passed in. More... | |
int | mdlSharedCell_deleteDefinition (const WChar *cellName) |
Delete a shared cell definition from the design file. More... | |
void | mdlSharedCell_drawAllShares (WChar *cellName, int drawMode) |
Find all shared cell instances of cellName in the active model and draws these instances using the drawing mode specified by drawMode. More... | |
void | mdlSharedCell_dropOneLevel (MSElementP sharedCell, UInt32 filePos, int dispFlag) |
Drop sharedCell one nesting level. More... | |
void | mdlSharedCell_dropToNormalCell (MSElementP sharedCell, UInt32 filePos, int dispFlag, int freeze) |
Drop the sharing status of sharedCell and creates a new normal (or unshared) cell. More... | |
int | mdlSharedCell_extract (Dpoint3d *origin, Dpoint3d *shape, RotMatrixP rMatrix, Dpoint3d *scale, DgnPlatform::SCOverride *override, WChar *cellName, int bufferSize, MSElementCP sCell, DgnModelRefP modelRef) |
Extract information from a shared cell instance element or shared cell definition element. More... | |
StatusInt | mdlSharedCell_find (UInt32 *foundFilePos, DgnModelRefP *foundModelRef, const WChar *cellName, DgnModelRefP preferredModel, int allowRefs) |
Search the lists of shared cell definitions for the file position of the shared cell definition with cellName. More... | |
void | mdlSharedCell_fromCellHeader (MSElementP scElem, MSElementP cellHeader, RotMatrixP rotMatrix, int relativeMode, int baseLevel, DgnPlatform::AssocPoint *assocOrigin) |
Convert a cell header to a shared cell instance element. More... | |
int | mdlSharedCell_makeSureDefExists (MSElementP sharedCellElm) |
Check for a shared cell definition corresponding to the shared cell instance. More... | |
int | mdlSharedCell_read (MSElementDescrH scDefPP, MSElementCP sCell, bool transformToWorld, DgnModelRefP modelRef, bool expandNested) |
Read the shared cell definition for a shared cell instance. More... | |
int | mdlSharedCell_redefine (DgnFileP library, const WChar *cellName) |
Re-read the cell definition from the cell library and creates a new shared cell definition. More... | |
void | mdlSharedCell_setRange (MSElementP sharedCellElm, DgnModelRefP modelRef) |
Read the shared cell definition for the shared cell and sets its range block according to that definition. More... | |
void | mdlSharedCell_setRangeDiag (MSElementP sharedCellElm) |
Calculate the range diagonal of a shared cell definition element and store it on the shared cell instance element. More... | |
void | mdlSharedCell_setOriginAndRange (MSElementDescrP cellDP, Dpoint3d *originP) |
Update the origin and range of a shared cell definition. More... | |
int | mdlSharedCell_toNormalCell (MSElementDescrH cellDPP, MSElementP scInstanceP, DgnModelRefP modelRef) |
Create an element descriptor that is the normal (unshared) cell equivalent of a shared cell instance. More... | |
int | mdlSharedCell_toNormalCell2 (MSElementDescrH cellDPP, MSElementP scInstanceP, DgnModelRefP modelRef, bool applyByCellLevelAndSymbology) |
Create an element descriptor that is the normal (unshared) cell equivalent of a shared cell instance. More... | |
DgnModelRefP | mdlSharedCell_fileNumber (WChar *nameP, DgnModelRefP preferredFile) |
Get a reference to the model in which the shared cell definition element resides. More... | |
int | mdlSharedCell_createDefinitionElement (MSElementP elementP, WCharCP cellName, bool pointCell) |
Create a shared cell definition element for the given cell name in the buffer provided. More... | |
int | mdlSharedCell_getDefinitionId (DgnPlatform::ElementId *uniqueIdP, MSElementCP elmP) |
Get the unique ID of the definition element for a shared cell instance. More... | |
int | mdlSharedCell_setDefinitionId (MSElementP sharedCellElmP, DgnPlatform::ElementId uniqueId) |
Set the unique ID of the definition element for a shared cell instance. More... | |
bool | mdlSharedCell_isAnonymous (MSElementP sharedCellElmP, DgnModelRefP modelRef) |
Determine whether a shared cell is anonymous. More... | |
StatusInt | mdlSharedCell_addAttributesFromDefinition (MSElementDescrH tagDscrPP, MSElementDescrP pSCDscr, DgnModelRefP modelRef, bool addToFile) |
Add the tags stored within a shared cell definition to a shared cell instance. More... | |
bool | mdlSharedCell_definitionIsUsed (const WChar *cellNameP, DgnFileP fileObj) |
Check if a shared cell definition is in use by name. More... | |
Shared Cells are an efficient way to store repeated displayable geometry.
A shared cell instance is a light-weight non-complex displayable element. Multiple instances can all refer to a common shared definition that holds the complete set of geometry. A shared cell instance displays its definition through the instance's transform that can apply translation, rotation, and scaling. Each instance can also override some element properties like color and level so that these properties are taken from the instance instead of using the properties of the elements in the definition.
StatusInt mdlSharedCell_addAttributesFromDefinition | ( | MSElementDescrH | tagDscrPP, |
MSElementDescrP | pSCDscr, | ||
DgnModelRefP | modelRef, | ||
bool | addToFile | ||
) |
Add the tags stored within a shared cell definition to a shared cell instance.
Tags are stored within a shared cell definition, but are not displayed in the instance unless they are constant. These tags must be copied from the definition and added to the file.
[out] | tagDscrPP | A pointer to a location to put the resulting Element Descriptor describing the tags. NULL can be returned if the shared cell definition does not contain tags. This parameter may NULL if the caller does not need the tags immediately. |
[in] | pSCDscr | The shared cell instance element. |
[in] | modelRef | The model ref containing the shared cell instance. |
[in] | addToFile | Set this to true if the tags should be written to the file. If this parameter is false, the tags will be found and copied into tagDscrPP (if it is not NULL) and it is up to the calling application to write them to the file. |
void mdlSharedCell_addDefinitionElements | ( | MSElementDescrP | cellDscrP, |
RotMatrixP | rotScale, | ||
Dpoint3d * | rOrigin | ||
) |
Convert the cell definition element descriptor pointed to by cellDscrP to a shared cell definition and add the definition to the file.
[in] | cellDscrP | cell (rotated, scaled, etc.) |
[in] | rotScale | the rotation and scaling matrix applied to the elements of cellDscrP when they were created. |
[in] | rOrigin | translation applied to cell |
UInt32 mdlSharedCell_addToFile | ( | MSElementP | cellHeader, |
RotMatrixP | rMatrix, | ||
int | relativeMode, | ||
int | baseLevel, | ||
DgnPlatform::AssocPoint * | assocOrigin | ||
) |
Add a shared cell instance to the file and display the new shared cell.
[in] | cellHeader | a pointer to a shared cell definition element or a cell header element. |
[in] | rMatrix | a pointer to a rotation matrix. If cellHeader is a unshared cell header, then rMatrix is used as the rotation matrix for the new shared cell instance. If cellHeader is a shared cell definition, the rotation matrix from the shared cell definition is used and rMatrix can be NULL. |
[in] | relativeMode | an integer which indicates whether the levels in the new shared cell instance should be determined in relative or absolute mode. In absolute mode the levels of the components of the shared cell definition are used. In relative mode, the difference between the level of the shared cell instance and baseLevel is added to the components of the shared cell definition. |
[in] | baseLevel | an integer which specifies the base level from which component levels are calculated in relative mode. |
[in] | assocOrigin | Associative origin for shared cell instance, or NULL. |
int mdlSharedCell_create | ( | MSElementP | newSCElm, |
MSElementCP | existingSCElm, | ||
Dpoint3d * | origin, | ||
RotMatrixP | rMatrix, | ||
Dpoint3d * | scale, | ||
WCharCP | cellName, | ||
DgnPlatform::SCOverride * | scOverride, | ||
int | relativeMode, | ||
int | baseLevel, | ||
DgnPlatform::AssocPoint * | assocOrigin | ||
) |
Create a shared cell instance element from the parameters passed in.
[out] | newSCElm | The new shared cell element. |
[in] | existingSCElm | An existing shared cell instance element. If this is not NULL, it will be used as a template for all properties and attributes. |
[in] | origin | The origin of the shared cell instance. If origin is NULL, the (0, 0, 0) point of the current coordinate system is used. |
[in] | rMatrix | The rotation matrix for the shared cell instance. If rMatrix is NULL, the identity matrix is used. |
[in] | scale | Points to a Dpoint3d structure that contains the X, Y and Z scaling factors to be applied to the shared cell instance. If scale is NULL, a scale of 1.0 is used. |
[in] | cellName | The name of the shared cell instance. If cellName is NULL, the name is taken from in. |
[in] | scOverride | The override mask for the shared cell instance. |
[in] | relativeMode | Indicates whether the shared cell levels will be relative or absolute to the levels in the shared cell definition. Set this argument to 0 to place the cell in absolute mode, set it to 1 to place the cell in relative mode. |
[in] | baseLevel | The level assigned to the shared cell instance element. This level is used only if relativeMode is true. |
[in] | assocOrigin | An associative point to use for the shared cell instance origin. If assocOrigin is NULL, the origin from cellHeader is used. |
int mdlSharedCell_createDefinitionElement | ( | MSElementP | elementP, |
WCharCP | cellName, | ||
bool | pointCell | ||
) |
Create a shared cell definition element for the given cell name in the buffer provided.
[out] | elementP | A pointer to an MSElement where the shared cell definition should be stored. |
[in] | cellName | The name of the shared cell. |
[in] | pointCell | Indicates whether the shared cell definition is for a point cell. If this is true, the view independent attribute is set for the element and the snappable attribute is unset. |
bool mdlSharedCell_definitionIsUsed | ( | const WChar * | cellNameP, |
DgnFileP | fileObj | ||
) |
Check if a shared cell definition is in use by name.
Shared cell definitions may be used by shared cell instances, patterns, dimension terminators, etc.
[in] | cellNameP | The name of the shared cell to check. |
[in] | fileObj | The file to check. |
int mdlSharedCell_deleteDefinition | ( | const WChar * | cellName | ) |
Delete a shared cell definition from the design file.
[in] | cellName | The name of the shared cell definition to deleted. |
void mdlSharedCell_drawAllShares | ( | WChar * | cellName, |
int | drawMode | ||
) |
Find all shared cell instances of cellName in the active model and draws these instances using the drawing mode specified by drawMode.
[in] | cellName | name of cell |
[in] | drawMode | drawing mode; see mdlElmdscr_display for draw modes. |
void mdlSharedCell_dropOneLevel | ( | MSElementP | sharedCell, |
UInt32 | filePos, | ||
int | dispFlag | ||
) |
Drop sharedCell one nesting level.
In effect, replace the shared cell instance with the top level collection of elements in the cell. Any nested shared cell instances or nested complex components in the shared cell definition remain unchanged. If displayFlag is true, the new elements are drawn as they are added to the file.
[in] | sharedCell | shared cell instance to drop. |
[in] | filePos | file position of original instance. |
[in] | dispFlag | if true, display new cell as it is added to the file. |
void mdlSharedCell_dropToNormalCell | ( | MSElementP | sharedCell, |
UInt32 | filePos, | ||
int | dispFlag, | ||
int | freeze | ||
) |
Drop the sharing status of sharedCell and creates a new normal (or unshared) cell.
Any nested shared cell instances in the shared cell definition are dropped. If displayFlag is true, the new elements are drawn as they are added to the file.
[in] | sharedCell | Shared cell instance to drop. |
[in] | filePos | File position of the original shared cell instance. |
[in] | dispFlag | if true, display new cell |
[in] | freeze | freeze rather than delete |
int mdlSharedCell_extract | ( | Dpoint3d * | origin, |
Dpoint3d * | shape, | ||
RotMatrixP | rMatrix, | ||
Dpoint3d * | scale, | ||
DgnPlatform::SCOverride * | override, | ||
WChar * | cellName, | ||
int | bufferSize, | ||
MSElementCP | sCell, | ||
DgnModelRefP | modelRef | ||
) |
Extract information from a shared cell instance element or shared cell definition element.
If output parameters are NULL, the function does not attempt to fill them in. All parameters are returned in the current coordinate system.
[out] | origin | shared cell origin. |
[out] | shape | returns an array of eight Dpoint3ds, which constitute a box that defines the extents of the cell. This idea can be illustrated if you were to use MicroStation's element selection tool to select a cell. MicroStation places handles on the boundary which defines the cell, and these handles correlate to the eight Dpoint3ds returned. |
[out] | rMatrix | The shared cell's rotation matrix. |
[out] | scale | A pointer to Dpoint3d that holds the cell's X, Y and Z scale factors. |
[out] | override | A structure that defines the fields in the shared cell instance element. These fields override the values in the shared cell definition elements. |
[out] | cellName | The shared cell's name. |
[in] | bufferSize | If extracting cell's name, the number of widechars cellName can hold. This is ignored if cellName is NULL. |
[in] | sCell | The shared cell element. |
[in] | modelRef | The model that contains the shared cell (can be MASTERFILE for the master file). |
DgnModelRefP mdlSharedCell_fileNumber | ( | WChar * | nameP, |
DgnModelRefP | preferredFile | ||
) |
Get a reference to the model in which the shared cell definition element resides.
If preferredFile is not NULL, then it is checked first. Next the master file is checked, followed by all reference files. The function name harkens back to pre-V8 days, but the return value is a modelRef.
[in] | nameP | is the name of the cell to search for. |
[in] | preferredFile | indicates the model in which to start the search. |
StatusInt mdlSharedCell_find | ( | UInt32 * | foundFilePos, |
DgnModelRefP * | foundModelRef, | ||
const WChar * | cellName, | ||
DgnModelRefP | preferredModel, | ||
int | allowRefs | ||
) |
Search the lists of shared cell definitions for the file position of the shared cell definition with cellName.
When the shared cell definition is located, the function sets foundFilePos and foundModelRef to the file position and model where the definition is located.
[out] | foundFilePos | If found, the file position of definition. Can be NULL. |
[out] | foundModelRef | If found, the modelRef of definition. Can be NULL. |
[in] | cellName | Name of cell to search for. |
[in] | preferredModel | The model where the function will search first for the cell. This can be NULL. If allowRefs is true and the shared cell instance cannot be found in the preferred file, this function searches first the master file and, if allowRefs is true, all reference files. |
[in] | allowRefs | If true, reference files will be searched if the definition is not found in the preferred model or the master file. |
void mdlSharedCell_fromCellHeader | ( | MSElementP | scElem, |
MSElementP | cellHeader, | ||
RotMatrixP | rotMatrix, | ||
int | relativeMode, | ||
int | baseLevel, | ||
DgnPlatform::AssocPoint * | assocOrigin | ||
) |
Convert a cell header to a shared cell instance element.
If the provided cell is a shared cell definition element, the appropriate instance is created. If the cell is a normal cell then a shared cell instance is created referring to the shared cell definition of the same name. The program should call mdlSharedCell_addDefinitionElements or mdlSharedCell_makeSureDefExists to create the definition.
[out] | scElem | The shared cell instance element created. |
[in] | cellHeader | The cell header element; either a shared cell definition or unshared cell. |
[in] | rotMatrix | The non-orthogonal rotation and scaling matrix applied to the shared cell definition. |
[in] | relativeMode | If true, levels will be assigned assigned relative to baseLevel. |
[in] | baseLevel | Lowest level for relative placement. This is ignored if relativeMode is false. |
[in] | assocOrigin | An associative origin point, or NULL if it is not associated. |
int mdlSharedCell_getDefinitionId | ( | DgnPlatform::ElementId * | uniqueIdP, |
MSElementCP | elmP | ||
) |
Get the unique ID of the definition element for a shared cell instance.
This function is useful only when dealing with anonymous shared cells, which do not have unique names. If the shared cell is not anonymous, you must use mdlSharedCell_find to find the correct definition.
[out] | uniqueIdP | A pointer to an DgnPlatform::ElementId where the ID of the shared cell definition should be stored. This can be NULL to just check for existance and validity of the linkage. |
[in] | elmP | The shared cell definition element. |
bool mdlSharedCell_isAnonymous | ( | MSElementP | sharedCellElmP, |
DgnModelRefP | modelRef | ||
) |
Determine whether a shared cell is anonymous.
[in] | sharedCellElmP | The shared cell definition element. |
[in] | modelRef | The model containing the shared cell definition. |
int mdlSharedCell_makeSureDefExists | ( | MSElementP | sharedCellElm | ) |
Check for a shared cell definition corresponding to the shared cell instance.
If the shared cell definition is not found, it reads and creates one based on the first instance found by calling mdlCell_findCell.
[in] | sharedCellElm | A shared cell instance element. |
int mdlSharedCell_read | ( | MSElementDescrH | scDefPP, |
MSElementCP | sCell, | ||
bool | transformToWorld, | ||
DgnModelRefP | modelRef, | ||
bool | expandNested | ||
) |
Read the shared cell definition for a shared cell instance.
It allocates a new element descriptor and returns its address in scDefPP.
[out] | scDefPP | Shared cell definition element descriptor. |
[in] | sCell | Shared cell instance element. |
[in] | transformToWorld | If this parameter is true, the function transforms the elements of the shared cell definition to the origin, scale, and rotation of the shared cell instance. Otherwise, they remain at the origin of the world coordinate system with a scale factor of 1 and no rotation. Transformed geometry is returned as an unshared cell and not a shared cell definition. |
[in] | modelRef | Indicates the model from which sCell originated. This determines the design file in which to search for the shared cell definition. |
[in] | expandNested | If expandNested is true, this function expands any nested shared cell instances into unshared cells. Otherwise, it leaves them as shared cell instances in the element descriptor. You must also pass true for transformToWorld to use this option. |
int mdlSharedCell_redefine | ( | DgnFileP | library, |
const WChar * | cellName | ||
) |
Re-read the cell definition from the cell library and creates a new shared cell definition.
All instances of the cell are then redrawn with the new definition.
[in] | library | The library containing the cell. Typically this is gotten from mdlCell_findCell. |
[in] | cellName | Name of cell to redefine. |
int mdlSharedCell_setDefinitionId | ( | MSElementP | sharedCellElmP, |
DgnPlatform::ElementId | uniqueId | ||
) |
Set the unique ID of the definition element for a shared cell instance.
This function is useful when dealing with anonymous shared cells, which do not have unique names. If the shared cell is not anonymous, you must use mdlSharedCell_find to find the correct definition.
[in,out] | sharedCellElmP | The shared cell definition element. |
[in] | uniqueId | The DgnPlatform::ElementId of the shared cell definition. |
void mdlSharedCell_setOriginAndRange | ( | MSElementDescrP | cellDP, |
Dpoint3d * | originP | ||
) |
Update the origin and range of a shared cell definition.
If originP is NULL the origin of the cell is calculated as the midpoint between the high and low range values of the cell.
[in] | cellDP | A pointer the shared cell definition element. |
[in] | originP | The origin of the cell, or NULL. |
void mdlSharedCell_setRange | ( | MSElementP | sharedCellElm, |
DgnModelRefP | modelRef | ||
) |
Read the shared cell definition for the shared cell and sets its range block according to that definition.
It needs the model to determine which file to search first for the definition.
[in,out] | sharedCellElm | Shared cell instance element. |
[in] | modelRef | Source for shared cell. |
void mdlSharedCell_setRangeDiag | ( | MSElementP | sharedCellElm | ) |
Calculate the range diagonal of a shared cell definition element and store it on the shared cell instance element.
The range diagonal is used to place handles when selecting the shared cell instance.
[in] | sharedCellElm | A pointer to the shared cell definition element. |
int mdlSharedCell_toNormalCell | ( | MSElementDescrH | cellDPP, |
MSElementP | scInstanceP, | ||
DgnModelRefP | modelRef | ||
) |
Create an element descriptor that is the normal (unshared) cell equivalent of a shared cell instance.
[out] | cellDPP | The normal (unshared) cell element descriptor. |
[in] | scInstanceP | The shared cell instance element. |
[in] | modelRef | The model used to locate the shared cell definition for scInstanceP. |
int mdlSharedCell_toNormalCell2 | ( | MSElementDescrH | cellDPP, |
MSElementP | scInstanceP, | ||
DgnModelRefP | modelRef, | ||
bool | applyByCellLevelAndSymbology | ||
) |
Create an element descriptor that is the normal (unshared) cell equivalent of a shared cell instance.
[out] | cellDPP | The normal (unshared) cell element descriptor. |
[in] | scInstanceP | The shared cell instance element. |
[in] | applyByCellLevelAndSymbology | if nonZero the children with by cell symbology and level are overriden with the parent values. |
[in] | modelRef | The model used to locate the shared cell definition for scInstanceP. |