Skip to content

RDocument

Class in Core Module
Header: #include <src/core/RDocument.h>
Inherits: RRequireHeap, RNonCopyable (private)

A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.

Every document maintains a spatial index for fast entity lookups. Documents also handle transactions through a RTransactionStack. A document is backed by an RStorage implementation to store the document for the duration of the document’s lifetime.

Scriptable: This class is available in script environments.

RDocument(RStorage &storage, RSpatialIndex &spatialIndex, bool beforeLoad=false)
Creates a new document with the given storage as back-end.
virtual ~RDocument()
QString addAutoVariable(double value)
Adds an automatically named variable with the given value.
bool addBlockToSpatialIndex(RObject::Id blockId, RObject::Id ignoreBlockId)
Add block references that point to blockId, unless they also point to ignoreBlockId.
void addToSpatialIndex(QSharedPointer< REntity > entity)
Adds an entity to the spatial index using its current bounding boxes.
bool blockContainsReferences(RObject::Id blockId, RObject::Id referencedBlockId)
Checks if a block contains references to another block (directly or indirectly).
void clear(bool beforeLoad=false)
Resets this document to its initial, empty state.
void clearSelection(QSet< RObject::Id > *affectedEntities=NULL)
void clearSpatialIndices()
Clears all spatial indices for this document and its blocks.
void copyVariablesFrom(const RDocument &other)
Copies all document variables from another document to this one.
int countSelectedEntities() const
int deselectEntities(const QSet< RObject::Id > &entityId, QSet< RObject::Id > *affectedEntities=NULL)
void deselectEntity(RObject::Id entityId, QSet< RObject::Id > *affectedEntities=NULL)
Deselects the entity with the given ID.
void dump()
Dumps document information to qDebug for debugging purposes.
double eval(const QString &expression, bool *ok=NULL)
Evaluates a mathematical expression, substituting auto variables with their values.
QString formatAngle(double value)
Formats an angle value according to this document’s settings.
QString formatLinear(double value)
Formats a linear value according to this document’s settings.
RS::AngleFormat getAngleFormat()
int getAnglePrecision()
bool getAutoTransactionGroup() const
QStringList getAutoVariables() const
RObject::Id getBlockId(const QString &blockName) const
RObject::Id getBlockIdAuto(const QString &blockLayoutName) const
QString getBlockName(RObject::Id blockId) const
QString getBlockNameFromHandle(RObject::Handle blockHandle) const
QString getBlockNameFromLayout(const QString &layoutName) const
QString getBlockNameFromLayout(RObject::Id layoutId) const
QSet< QString > getBlockNames(const QString &rxStr=RDEFAULT_QSTRING, bool undone=false) const
RBox getBoundingBox(bool ignoreHiddenLayers=true, bool ignoreEmpty=false) const
RObject::Id getCurrentBlockId() const
QString getCurrentBlockName() const
RColor getCurrentColor() const
RObject::Id getCurrentLayerId() const
QString getCurrentLayerName() const
RObject::Id getCurrentLinetypeId() const
RLinetypePattern getCurrentLinetypePattern() const
RLineweight::Lineweight getCurrentLineweight() const
RObject::Id getCurrentViewId() const
RObject::Id getCurrentViewportId()
char getDecimalSeparator()
QList< QSharedPointer< RObject > > getDefaultLinetypes()
QString getDimensionFont() const
RBox getEntitiesBox(QSet< RObject::Id > &ids) const
QString getFileName() const
QString getFileVersion() const
QVariant getKnownVariable(RS::KnownVariable key, const QVariant &defaultValue=RDEFAULT_QVARIANT) const
QString getLastModified() const
QDateTime getLastModifiedDateTime() const
RObject::Id getLayer0Id() const
RObject::Id getLayerId(const QString &layerName) const
QString getLayerName(RObject::Id layerId) const
QSet< QString > getLayerNames(const QString &rxStr=RDEFAULT_QSTRING) const
RObject::Id getLayerStateId(const QString &layerStateName) const
QString getLayerStateName(RObject::Id layerStateId) const
QSet< QString > getLayerStateNames(const QString &rxStr=RDEFAULT_QSTRING) const
QString getLayoutName(RObject::Id layoutId) const
RS::LinearFormat getLinearFormat() const
int getLinearPrecision()
RObject::Id getLinetypeByBlockId() const
RObject::Id getLinetypeByLayerId() const
QString getLinetypeDescription(RObject::Id linetypeId) const
RObject::Id getLinetypeId(const QString &linetypeName) const
QString getLinetypeLabel(RObject::Id linetypeId) const
QString getLinetypeName(RObject::Id linetypeId) const
QSet< QString > getLinetypeNames() const
QList< RLinetypePattern > getLinetypePatterns() const
double getLinetypeScale() const
RLineweight::Lineweight getMaxLineweight() const
RS::Measurement getMeasurement() const
RObject::Id getModelSpaceBlockId() const
bool getNotifyListeners() const
RBox getSelectionBox() const
RSpatialIndex & getSpatialIndex()
const RSpatialIndex & getSpatialIndex() const
RSpatialIndex * getSpatialIndexForBlock(RObject::Id blockId) const
Gets or creates the spatial index for a specific block.
RSpatialIndex * getSpatialIndexForCurrentBlock() const
RStorage & getStorage()
const RStorage & getStorage() const
QString getTempBlockName() const
int getTransactionGroup() const
RTransactionStack & getTransactionStack()
QString getUniqueBlockName(const QString &currentName, const QStringList &usedBlockNames=RDEFAULT_QSTRINGLIST) const
Generates a unique block name based on the given name.
RS::Unit getUnit() const
QVariant getVariable(const QString &key, const QVariant &defaultValue=RDEFAULT_QVARIANT, bool useSettings=false) const
QStringList getVariables() const
QSet< QString > getViewNames() const
bool hasBlock(const QString &blockName) const
bool hasBlockEntities(RObject::Id blockId) const
bool hasChildEntities(RObject::Id parentId) const
bool hasCurrentViewport()
bool hasLayer(const QString &layerName) const
bool hasLayerState(const QString &layerStateName) const
bool hasLayerStates() const
bool hasLayout(const QString &layoutName) const
bool hasLinetype(const QString &linetypeName) const
bool hasSelection() const
bool hasVariable(const QString &key) const
bool hasView(const QString &viewName) const
void init(bool beforeLoad=false)
Initializes this document with default settings, layers, and linetypes.
void initLinetypes(RTransaction *transaction=NULL)
Initializes or updates the document’s linetypes based on the current unit setting.
bool isBlockFrozen(RObject::Id blockId) const
bool isByBlock(RObject::Id linetypeId) const
bool isByLayer(RObject::Id linetypeId) const
bool isEditingWorkingSet() const
bool isEntity(RObject::Id objectId) const
Checks if the given object ID refers to an entity.
bool isEntityEditable(RObject::Id entityId) const
Checks if the entity with the given ID is editable.
bool isEntityLayerFrozen(RObject::Id entityId) const
Checks if the layer of the entity with the given ID is frozen.
bool isEntityVisible(const REntity &entity, RObject::Id blockId=RObject::INVALID_ID) const
bool isLayerFrozen(const RLayer &layer) const
bool isLayerFrozen(RObject::Id layerId) const
bool isLayerLocked(const RLayer &layer) const
bool isLayerLocked(RObject::Id layerId) const
bool isLayerOff(const RLayer &layer) const
bool isLayerOff(RObject::Id layerId) const
bool isLayerOffOrFrozen(const RLayer &layer) const
bool isLayerOffOrFrozen(RObject::Id layerId) const
bool isLayerPlottable(const RLayer &layer) const
bool isLayerPlottable(RObject::Id layerId) const
bool isLayerSnappable(const RLayer &layer) const
bool isLayerSnappable(RObject::Id layerId) const
bool isLayoutBlock(RObject::Id blockId) const
bool isMetric() const
bool isModified() const
bool isParentLayerFrozen(const RLayer &layer) const
bool isParentLayerFrozen(RObject::Id layerId) const
bool isParentLayerLocked(const RLayer &layer) const
bool isParentLayerLocked(RObject::Id layerId) const
bool isParentLayerPlottable(const RLayer &layer) const
bool isParentLayerPlottable(RObject::Id layerId) const
bool isParentLayerSnappable(const RLayer &layer) const
bool isParentLayerSnappable(RObject::Id layerId) const
bool isRedoAvailable() const
bool isSelected(RObject::Id entityId)
bool isSelectedWorkingSet(RObject::Id entityId)
bool isUndoAvailable() const
QSet< RObject::Id > queryAllBlockReferences() const
QSet< RObject::Id > queryAllBlocks() const
QSet< RObject::Id > queryAllEntities(bool undone, bool allBlocks, QList< RS::EntityType > types) const
QSet< RObject::Id > queryAllEntities(bool undone=false, bool allBlocks=false, RS::EntityType type=RS::EntityAll) const
Queries all entities of this document.
QSet< RObject::Id > queryAllLayers() const
Queries all layers of this document.
QSet< RObject::Id > queryAllLayerStates() const
Queries all layer state objects of this document.
QSet< RObject::Id > queryAllLayoutBlocks(bool includeModelSpace=false) const
QSet< RObject::Id > queryAllLayouts() const
QSet< RObject::Id > queryAllLinetypes() const
QSet< RObject::Id > queryAllObjects() const
Queries all objects of this document.
QSet< RObject::Id > queryAllUcs() const
Queries all UCSs of this document.
QSet< RObject::Id > queryAllViewports() const
QSet< RObject::Id > queryAllViews() const
QSet< RObject::Id > queryAllVisibleEntities() const
QSharedPointer< RBlock > queryBlock(const QString &blockName) const
Queries the block with the given name.
QSharedPointer< RBlock > queryBlock(RObject::Id blockId) const
Queries the block with the given ID.
QSharedPointer< RBlock > queryBlockDirect(const QString &blockName) const
Queries the block with the given name direct (no cloning).
QSharedPointer< RBlock > queryBlockDirect(RObject::Id blockId) const
Queries the block with the given ID direct (no cloning).
QSet< RObject::Id > queryBlockEntities(RObject::Id blockId) const
QSet< RObject::Id > queryBlockReferences(RObject::Id blockId) const
QSet< RObject::Id > queryBlockReferencesForLayers(const QSet< RObject::Id > &layerIds) const
QSet< RObject::Id > queryChildEntities(RObject::Id parentId, RS::EntityType type=RS::EntityAll) const
RObject::Id queryClosestXY(const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE, bool includeLockedLayers=true, bool selectedOnly=false, bool snappable=false)
Queries the one entity that is closest to the given position and within the given range (2d).
RObject::Id queryClosestXY(QSet< RObject::Id > &candidates, const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE)
QPair< RObject::Id, QSet< int > > queryClosestXYWithIndices(const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE, bool includeLockedLayers=true, bool selectedOnly=false)
Queries the entity closest to the given position within range, along with the indices of the shape elements that are closest (2d).
QPair< RObject::Id, QSet< int > > queryClosestXYWithIndices(QMap< RObject::Id, QSet< int > > &candidates, const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE)
Queries the entity closest to the given position from a set of candidates, along with the indices of the shape elements that are closest (2d).
QSet< RObject::Id > queryConnectedEntities(RObject::Id entityId, double tolerance=RS::PointTolerance, RObject::Id layerId=RObject::INVALID_ID)
Queries all entities that are connected to the given entity within the specified tolerance.
QSet< RObject::Id > queryContainedEntities(const RBox &box) const
Queries all entities which are completely inside the given box.
QSet< RObject::Id > queryContainedEntitiesXY(const RBox &box) const
Queries entities that are completely contained within the given box in the XY plane.
QSharedPointer< RBlock > queryCurrentBlock()
QSharedPointer< RLayer > queryCurrentLayer()
QSharedPointer< RView > queryCurrentView()
QSharedPointer< RDimStyle > queryDimStyle() const
QSharedPointer< RDimStyle > queryDimStyleDirect() const
QSharedPointer< RDocumentVariables > queryDocumentVariables() const
QSharedPointer< RDocumentVariables > queryDocumentVariablesDirect() const
QSharedPointer< REntity > queryEntity(RObject::Id entityId) const
Queries the entity with the given ID.
QSharedPointer< REntity > queryEntityDirect(RObject::Id entityId) const
Queries the entity with the given ID.
QSet< RObject::Id > queryInfiniteEntities() const
QSet< RObject::Id > queryIntersectedEntitiesXY(const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RObject::Id blockId=RObject::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false, RObject::Id layerId=RObject::INVALID_ID, bool snappable=false) const
Queries entities that intersect with the given box in the XY plane.
QSet< RObject::Id > queryIntersectedEntitiesXYFast(const RBox &box)
Queries entities that intersect with the given box (fast approximation based on bounding boxes).
QMap< RObject::Id, QSet< int > > queryIntersectedEntitiesXYWithIndex(const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RObject::Id blockId=RObject::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false, RObject::Id layerId=RObject::INVALID_ID, bool snappable=false) const
Queries entities that intersect with the given box in the XY plane, returning both entity IDs and shape element indices.
QMap< RObject::Id, QSet< int > > queryIntersectedShapesXY(const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RObject::Id blockId=RObject::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false, RObject::Id layerId=RObject::INVALID_ID, bool snappable=false) const
Queries entity shapes that intersect with the given box in the XY plane, returning both entity IDs and shape element indices.
QSet< RObject::Id > queryIntersectedShapesXYFast(const RBox &box, bool noInfiniteEntities=false)
Queries entity shapes that intersect with the given box (fast approximation).
QSharedPointer< RLayer > queryLayer(const QString &layerName) const
Queries the layer with the given name.
QSharedPointer< RLayer > queryLayer(RObject::Id layerId) const
Queries the layer with the given ID.
QSet< RObject::Id > queryLayerBlockEntities(RObject::Id layerId, RObject::Id blockId) const
QSharedPointer< RLayer > queryLayerDirect(RObject::Id layerId) const
Queries the layer with the given ID direct (no cloning).
QSet< RObject::Id > queryLayerEntities(RObject::Id layerId, bool allBlocks=false) const
QSharedPointer< RLayerState > queryLayerState(const QString &layerStateName) const
Queries the layer state with the given name.
QSharedPointer< RLayerState > queryLayerState(RObject::Id layerStateId) const
Queries the layer state with the given ID.
QSharedPointer< RLayerState > queryLayerStateDirect(RObject::Id layerStateId) const
Queries the layer state with the given ID direct (no cloning).
QSharedPointer< RLayout > queryLayout(const QString &layoutName) const
Queries the layout with the given name.
QSharedPointer< RLayout > queryLayout(RObject::Id layoutId) const
Queries the layout with the given ID.
QSharedPointer< RLayout > queryLayoutDirect(RObject::Id layoutId) const
Queries the layout with the given ID direct (no cloning).
QSharedPointer< RLinetype > queryLinetype(const QString &linetypeName) const
Queries the linetype with the given name.
QSharedPointer< RLinetype > queryLinetype(RObject::Id linetypeId) const
Queries the linetype with the given ID.
QSharedPointer< RObject > queryObject(RObject::Id objectId) const
Queries the object with the given ID.
QSharedPointer< RObject > queryObjectByHandle(RObject::Handle objectHandle) const
Queries an object by its handle.
RObject * queryObjectCC(RObject::Id objectId) const
Queries the object with the given ID using the internal storage representation.
QSharedPointer< RObject > queryObjectDirect(RObject::Id objectId) const
Queries the object with the given ID.
QSet< RObject::Id > queryPropertyEditorObjects()
Queries all objects that should be shown in the property editor.
QSet< RObject::Id > querySelectedEntities() const
Queries all selected entities.
QSet< RObject::Id > querySelectedLayerEntities(RObject::Id layerId, bool allBlocks=false) const
QSet< RObject::Id > querySelectedLayers() const
Queries all selected objects.
QSharedPointer< RUcs > queryUcs(const QString &ucsName) const
Queries the UCS with the given name.
QSharedPointer< RUcs > queryUcs(RObject::Id ucsId) const
Queries the UCS with the given ID.
QSharedPointer< RView > queryView(const QString &viewName) const
Queries the view with the given name.
QSharedPointer< RView > queryView(RObject::Id viewId) const
Queries the view with the given ID.
QSharedPointer< REntity > queryVisibleEntityDirect(RObject::Id entityId) const
Queries a visible entity with the given ID, returning the direct instance.
QSet< RObject::Id > queryWorkingSetEntities() const
virtual void rebuildSpatialIndex()
Rebuilds the entire spatial index from scratch (e.g.
QList< RTransaction > redo()
Redoes a previously undone transaction.
void removeBlockFromSpatialIndex(RObject::Id blockId)
Removes all entities from the given block from the spatial index.
void removeFromSpatialIndex(QSharedPointer< REntity > entity)
Removes an entity from the spatial index using its current bounding boxes.
virtual void removeFromSpatialIndex(QSharedPointer< REntity > entity, const QList< RBox > &boundingBoxes)
Removes an entity from the spatial index using the given bounding boxes.
void removeVariable(const QString &key)
Removes the custom variable with the given key.
void resetTransactionStack()
Resets the transaction stack, clearing all undo and redo history.
void selectAllEntities(QSet< RObject::Id > *affectedEntities=NULL)
Selects all not selected entities.
int selectEntities(const QSet< RObject::Id > &entityId, bool add=false, QSet< RObject::Id > *affectedEntities=NULL)
void selectEntity(RObject::Id entityId, bool add=false, QSet< RObject::Id > *affectedEntities=NULL)
void setAutoTransactionGroup(bool on)
True: add all operations to the current transaction group.
void setCurrentBlock(const QString &blockName)
Sets the current block for editing by name.
void setCurrentBlock(RObject::Id blockId)
Sets the current block for editing.
void setCurrentColor(const RColor &color)
void setCurrentLayer(const QString &layerName, RTransaction *transaction=NULL)
void setCurrentLayer(RObject::Id layerId, RTransaction *transaction=NULL)
void setCurrentLinetype(const QString &name)
void setCurrentLinetype(RObject::Id ltId)
void setCurrentLinetypePattern(const RLinetypePattern &p)
void setCurrentLineweight(RLineweight::Lineweight lw)
void setCurrentView(const QString &viewName)
void setCurrentView(RObject::Id viewId)
void setCurrentViewport(RObject::Id viewportId)
Sets the current viewport for this document.
void setDimensionFont(const QString &f, RTransaction *transaction=NULL)
void setFileName(const QString &fn)
Sets the file name associated with this document.
void setFileVersion(const QString &fv)
Sets the file version string for this document.
void setIgnoreWorkingSet(bool on)
Sets whether to ignore the working set.
void setKnownVariable(RS::KnownVariable key, const QVariant &value, RTransaction *transaction=NULL)
Sets a known DXF/DWG variable for this document.
void setKnownVariable(RS::KnownVariable key, const RVector &value, RTransaction *transaction=NULL)
Sets a known DXF/DWG variable for this document.
void setLinearFormat(RS::LinearFormat f)
Sets the linear format type for this document.
void setLinetypeScale(double v, RTransaction *transaction=NULL)
Sets the global linetype scale of this document to the given value.
void setMeasurement(RS::Measurement m, RTransaction *transaction=NULL)
Sets the measurement system for this document (metric or imperial).
void setModified(bool m)
Resets the modified flag.
void setNotifyListeners(bool on)
Sets whether listeners should be notified of changes to the document.
void setUnit(RS::Unit unit, RTransaction *transaction=NULL)
Sets the unit of measurement for this document.
void setVariable(const QString &key, const QVariant &value, bool overwrite=true)
Sets a custom variable in the context of this document.
bool showLeadingZeroes()
bool showLeadingZeroesAngle()
bool showTrailingZeroes()
bool showTrailingZeroesAngle()
QList< RObject::Id > sortBlocks(const QList< RObject::Id > &blockIds) const
QList< RObject::Id > sortLayers(const QList< RObject::Id > &layerIds) const
void startTransactionGroup()
QString substituteAutoVariables(const QString &expression)
Substitutes all auto variable references in the given expression with their values.
QList< RTransaction > undo()
Undoes the last transaction.
void unsetCurrentViewport()
Unsets the current viewport for this document.
void updateAllEntities()
Updates all entities in the document (recalculates bounding boxes, etc.).
static RDocument & getClipboard()
static RDocument * clipboard
bool autoTransactionGroup
bool disableSpatialIndicesByBlock
QString fileName
QString fileVersion
RObject::Id linetypeByBlockId
RObject::Id linetypeByLayerId
RSpatialIndex & spatialIndex
QMap< RObject::Id, RSpatialIndex * > spatialIndicesByBlock
RStorage & storage
RTransactionStack transactionStack
QDebug operator<<(QDebug dbg, RDocument &d)
Stream operator for QDebug.

RDocument::RDocument(RStorage &storage, RSpatialIndex &spatialIndex, bool beforeLoad=false)

Creates a new document with the given storage as back-end.

The document takes ownership of the storage and spatial index. A new document contains one layer (“0”) and a number of default line types. The default unit is Millimeter.

virtual RDocument::~RDocument()

virtual

QString RDocument::addAutoVariable(double value)

Adds an automatically named variable with the given value.

Auto variables are named sequentially (e.g., a0, a1, a2, …).

Parameters:

  • value: The value for the auto variable.

Returns: The name of the created auto variable.

bool RDocument::addBlockToSpatialIndex(RObject::Id blockId, RObject::Id ignoreBlockId)

Add block references that point to blockId, unless they also point to ignoreBlockId.

void RDocument::addToSpatialIndex(QSharedPointer< REntity > entity)

Adds an entity to the spatial index using its current bounding boxes.

Parameters:

  • entity: The entity to add to the spatial index.

bool RDocument::blockContainsReferences(RObject::Id blockId, RObject::Id referencedBlockId)

Checks if a block contains references to another block (directly or indirectly).

This is used to detect circular references.

Parameters:

  • blockId: The ID of the block to check.
  • referencedBlockId: The ID of the potentially referenced block.

Returns: True if blockId contains references to referencedBlockId, false otherwise.

void RDocument::clear(bool beforeLoad=false)

Resets this document to its initial, empty state.

void RDocument::clearSelection(QSet< RObject::Id > *affectedEntities=NULL)

Deselectes all selected entities.

void RDocument::clearSpatialIndices()

Clears all spatial indices for this document and its blocks.

void RDocument::copyVariablesFrom(const RDocument &other)

Copies all document variables from another document to this one.

This includes known variables, custom variables, and dimension font settings.

Parameters:

  • other: The document to copy variables from.

int RDocument::countSelectedEntities() const

const

Returns: Number of selected entities.

int RDocument::deselectEntities(const QSet< RObject::Id > &entityId, QSet< RObject::Id > *affectedEntities=NULL)

Deselects all entities with the given IDs.

Parameters:

  • affected: Optional pointer to an empty set of entity IDs. After the call, this set will contain all entity IDs of entities that were affected by the call.

void RDocument::deselectEntity(RObject::Id entityId, QSet< RObject::Id > *affectedEntities=NULL)

Deselects the entity with the given ID.

Parameters:

  • affected: Optional pointer to an empty set of entity IDs. After the call, this set will contain all entity IDs of entities that were affected by the call.

void RDocument::dump()

Dumps document information to qDebug for debugging purposes.

double RDocument::eval(const QString &expression, bool *ok=NULL)

Evaluates a mathematical expression, substituting auto variables with their values.

Parameters:

  • expression: The mathematical expression to evaluate.
  • ok: Optional pointer to bool that will be set to true if evaluation succeeded.

Returns: The result of the evaluation.

QString RDocument::formatAngle(double value)

Formats an angle value according to this document’s settings.

Parameters:

  • value: The angle value to format (in radians).

Returns: The formatted string representation of the angle.

QString RDocument::formatLinear(double value)

Formats a linear value according to this document’s settings.

Parameters:

  • value: The linear value to format.

Returns: The formatted string representation of the value.

RS::AngleFormat RDocument::getAngleFormat()

Returns: The angle format type for this document. This is determined by the variable “$DIMAUNIT”.

int RDocument::getAnglePrecision()

Returns: The angular precision for this document. This is determined by the variable “$DIMADEC”.

bool RDocument::getAutoTransactionGroup() const

inline const

QStringList RDocument::getAutoVariables() const

const

Returns: List of all auto variable names in this document.

RBlock::Id RDocument::getBlockId(const QString &blockName) const

const

RBlock::Id RDocument::getBlockIdAuto(const QString &blockLayoutName) const

const

QString RDocument::getBlockName(RObject::Id blockId) const

const

QString RDocument::getBlockNameFromHandle(RObject::Handle blockHandle) const

const

QString RDocument::getBlockNameFromLayout(const QString &layoutName) const

const

QString RDocument::getBlockNameFromLayout(RObject::Id layoutId) const

const

QSet< QString > RDocument::getBlockNames(const QString &rxStr=RDEFAULT_QSTRING, bool undone=false) const

const

RBox RDocument::getBoundingBox(bool ignoreHiddenLayers=true, bool ignoreEmpty=false) const

const

Returns: The bounding box around all visible entities.

RBlock::Id RDocument::getCurrentBlockId() const

const

QString RDocument::getCurrentBlockName() const

const

Returns: The name of the current block in this document.

RColor RDocument::getCurrentColor() const

const

RLayer::Id RDocument::getCurrentLayerId() const

const

QString RDocument::getCurrentLayerName() const

const

RLinetype::Id RDocument::getCurrentLinetypeId() const

const

RLinetypePattern RDocument::getCurrentLinetypePattern() const

const

RLineweight::Lineweight RDocument::getCurrentLineweight() const

const

RObject::Id RDocument::getCurrentViewId() const

const

RObject::Id RDocument::getCurrentViewportId()

Returns: The ID of the current viewport, or INVALID_ID if no viewport is set.

char RDocument::getDecimalSeparator()

Returns: The decimal separator for this document. This is determined by the variable “$DIMDSEP”. 0 means ‘.’.

QList< QSharedPointer< RObject > > RDocument::getDefaultLinetypes()

Returns: List of default linetype objects for the current unit system. Returns metric linetypes if the document uses metric units, imperial linetypes otherwise.

QString RDocument::getDimensionFont() const

const

RBox RDocument::getEntitiesBox(QSet< RObject::Id > &ids) const

const

QString RDocument::getFileName() const

const

Returns: The file name associated with this document.

QString RDocument::getFileVersion() const

const

Returns: The file version string for this document.

QVariant RDocument::getKnownVariable(RS::KnownVariable key, const QVariant &defaultValue=RDEFAULT_QVARIANT) const

const

Returns: Value for the given DXF/DWG variable.

QString RDocument::getLastModified() const

const

QDateTime RDocument::getLastModifiedDateTime() const

const

Non-Scriptable: This function is not available in script environments.

RLayer::Id RDocument::getLayer0Id() const

const

RLayer::Id RDocument::getLayerId(const QString &layerName) const

const

QString RDocument::getLayerName(RObject::Id layerId) const

const

QSet< QString > RDocument::getLayerNames(const QString &rxStr=RDEFAULT_QSTRING) const

const

RObject::Id RDocument::getLayerStateId(const QString &layerStateName) const

const

QString RDocument::getLayerStateName(RObject::Id layerStateId) const

const

QSet< QString > RDocument::getLayerStateNames(const QString &rxStr=RDEFAULT_QSTRING) const

const

QString RDocument::getLayoutName(RObject::Id layoutId) const

const

RS::LinearFormat RDocument::getLinearFormat() const

const

Returns: The linear format type for this document. This is determined by the variable “$DIMLUNIT”.

int RDocument::getLinearPrecision()

Returns: The linear precision for this document. This is determined by the variable “$DIMDEC”.

RObject::Id RDocument::getLinetypeByBlockId() const

inline const

RObject::Id RDocument::getLinetypeByLayerId() const

inline const

QString RDocument::getLinetypeDescription(RObject::Id linetypeId) const

const

Returns: User readable description for the given linetype.

RLinetype::Id RDocument::getLinetypeId(const QString &linetypeName) const

const

Returns: Linetype ID of the given linetype name or RObject::INVALID_ID.

QString RDocument::getLinetypeLabel(RObject::Id linetypeId) const

const

Returns: User readable label for the given linetype.

QString RDocument::getLinetypeName(RObject::Id linetypeId) const

const

Returns: Linetype name of the given linetype.

QSet< QString > RDocument::getLinetypeNames() const

const

Returns: List of all available linetype pattern names in this document.

QList< RLinetypePattern > RDocument::getLinetypePatterns() const

const

Returns: List of all available linetype patterns in this document.

double RDocument::getLinetypeScale() const

const

RLineweight::Lineweight RDocument::getMaxLineweight() const

const

Returns: The maximum lineweight used in this document.

RS::Measurement RDocument::getMeasurement() const

const

RBlock::Id RDocument::getModelSpaceBlockId() const

const

bool RDocument::getNotifyListeners() const

const

Returns: True if listener notifications are enabled, false otherwise.

RBox RDocument::getSelectionBox() const

const

RSpatialIndex & RDocument::getSpatialIndex()

Returns: Reference to the spatial index.

const RSpatialIndex & RDocument::getSpatialIndex() const

const

Returns: Const reference to the spatial index.

RSpatialIndex * RDocument::getSpatialIndexForBlock(RObject::Id blockId) const

const

Gets or creates the spatial index for a specific block.

Each block maintains its own spatial index for efficient entity lookups.

Parameters:

  • blockId: The ID of the block.

Returns: Pointer to the spatial index for the specified block.

RSpatialIndex * RDocument::getSpatialIndexForCurrentBlock() const

const

Returns: Pointer to the spatial index for the current block.

RStorage & RDocument::getStorage()

Returns: Reference to storage that backs the document.

const RStorage & RDocument::getStorage() const

const

Returns: Const reference to storage that backs the document.

QString RDocument::getTempBlockName() const

const

Returns: A randomly generated temporary block name that doesn’t conflict with existing blocks. The name follows the pattern “A$C#####”.

int RDocument::getTransactionGroup() const

const

RTransactionStack & RDocument::getTransactionStack()

Returns: Reference to the transaction stack for undo/redo handling.

QString RDocument::getUniqueBlockName(const QString &currentName, const QStringList &usedBlockNames=RDEFAULT_QSTRINGLIST) const

const

Generates a unique block name based on the given name.

If the name already exists, appends a number suffix (_1, _2, etc.).

Parameters:

  • currentName: The base name to use for generating a unique name.
  • usedBlockNames: Additional block names to check against (beyond those in the document).

Returns: A unique block name.

RS::Unit RDocument::getUnit() const

const

Returns: The unit of measurement for this document.

QVariant RDocument::getVariable(const QString &key, const QVariant &defaultValue=RDEFAULT_QVARIANT, bool useSettings=false) const

const

Returns: The value of the given variable or an invalid variant if the variable does not exist.

QStringList RDocument::getVariables() const

const

Returns: List of custom variable names stored in this document.

QSet< QString > RDocument::getViewNames() const

const

bool RDocument::hasBlock(const QString &blockName) const

const

bool RDocument::hasBlockEntities(RObject::Id blockId) const

const

Returns: True if the given block contains any entities.

bool RDocument::hasChildEntities(RObject::Id parentId) const

const

bool RDocument::hasCurrentViewport()

Returns: True if a current viewport is set, false otherwise.

bool RDocument::hasLayer(const QString &layerName) const

const

bool RDocument::hasLayerState(const QString &layerStateName) const

const

bool RDocument::hasLayerStates() const

const

bool RDocument::hasLayout(const QString &layoutName) const

const

bool RDocument::hasLinetype(const QString &linetypeName) const

const

bool RDocument::hasSelection() const

const

Returns: True if at least one entity is selected in this storage.

bool RDocument::hasVariable(const QString &key) const

const

Returns: True if the given variable exists in this storage.

bool RDocument::hasView(const QString &viewName) const

const

void RDocument::init(bool beforeLoad=false)

Initializes this document with default settings, layers, and linetypes.

This method is called internally by the constructor and clear() method.

Parameters:

  • beforeLoad: True if the document is being initialized before loading from a file, false otherwise.

void RDocument::initLinetypes(RTransaction *transaction=NULL)

Initializes or updates the document’s linetypes based on the current unit setting.

Adds default linetypes (metric or imperial) to the document.

Parameters:

  • transaction: Optional transaction to use for adding linetypes. If NULL, a new transaction will be created.

bool RDocument::isBlockFrozen(RObject::Id blockId) const

const

Returns: True if the given block is frozen.

bool RDocument::isByBlock(RObject::Id linetypeId) const

const

Returns: True if the given linetype ID represents the “BYBLOCK” linetype, false otherwise.

bool RDocument::isByLayer(RObject::Id linetypeId) const

const

Returns: True if the given linetype ID represents the “BYLAYER” linetype, false otherwise.

bool RDocument::isEditingWorkingSet() const

const

Returns: True if the document is currently editing a working set, false otherwise.

bool RDocument::isEntity(RObject::Id objectId) const

const

Checks if the given object ID refers to an entity.

Parameters:

  • entityId: The object ID to check.

Returns: True if the object is an entity, false otherwise.

bool RDocument::isEntityEditable(RObject::Id entityId) const

const

Checks if the entity with the given ID is editable.

Parameters:

  • entityId: The ID of the entity to check.

Returns: True if the entity exists and is editable, false otherwise.

bool RDocument::isEntityLayerFrozen(RObject::Id entityId) const

const

Checks if the layer of the entity with the given ID is frozen.

Parameters:

  • entityId: The ID of the entity to check.

Returns: True if the entity’s layer is frozen, false otherwise.

bool RDocument::isEntityVisible(const REntity &entity, RObject::Id blockId=RObject::INVALID_ID) const

const

Returns: True if the given entity is visible in the context of the given block or the current block (default).

bool RDocument::isLayerFrozen(const RLayer &layer) const

const

Returns: True if this layer or one of its parent layers are frozen.

bool RDocument::isLayerFrozen(RObject::Id layerId) const

const

Returns: True if this layer or one of its parent layers are frozen.

bool RDocument::isLayerLocked(const RLayer &layer) const

const

bool RDocument::isLayerLocked(RObject::Id layerId) const

const

bool RDocument::isLayerOff(const RLayer &layer) const

const

Returns: True if this layer is off.

bool RDocument::isLayerOff(RObject::Id layerId) const

const

Returns: True if this layer is off.

bool RDocument::isLayerOffOrFrozen(const RLayer &layer) const

const

Returns: True if this layer is off or frozen.

bool RDocument::isLayerOffOrFrozen(RObject::Id layerId) const

const

Returns: True if this layer is off or frozen.

bool RDocument::isLayerPlottable(const RLayer &layer) const

const

Returns: True if this layer and its parent layers are plottable.

bool RDocument::isLayerPlottable(RObject::Id layerId) const

const

Returns: True if this layer and its parent layers are plottable.

bool RDocument::isLayerSnappable(const RLayer &layer) const

const

Returns: True if this layer and its parent layers are snappable.

bool RDocument::isLayerSnappable(RObject::Id layerId) const

const

Returns: True if this layer and its parent layers are snappable.

bool RDocument::isLayoutBlock(RObject::Id blockId) const

const

Returns: True if the given block is a layout block (i.e. paper space block).

bool RDocument::isMetric() const

const

Returns: True if this document uses the metric measurement system, false otherwise. If the measurement system is unknown, the unit setting is used to determine this.

bool RDocument::isModified() const

const

Returns: True if the document has unsaved changes.

bool RDocument::isParentLayerFrozen(const RLayer &layer) const

const

Returns: True if a parent layer of the given layer is frozen.

bool RDocument::isParentLayerFrozen(RObject::Id layerId) const

const

Returns: True if a parent layer of the given layer is frozen.

bool RDocument::isParentLayerLocked(const RLayer &layer) const

const

Returns: True if a parent layer of the given layer is locked.

bool RDocument::isParentLayerLocked(RObject::Id layerId) const

const

Returns: True if a parent layer of the given layer is locked.

bool RDocument::isParentLayerPlottable(const RLayer &layer) const

const

Returns: True if a parent layer of the given layer is plottable.

bool RDocument::isParentLayerPlottable(RObject::Id layerId) const

const

Returns: True if a parent layer of the given layer is plottable.

bool RDocument::isParentLayerSnappable(const RLayer &layer) const

const

Returns: True if a parent layer of the given layer is snappable.

bool RDocument::isParentLayerSnappable(RObject::Id layerId) const

const

Returns: True if a parent layer of the given layer is snappable.

bool RDocument::isRedoAvailable() const

const

Returns: True if there are transactions available for redo, false otherwise.

bool RDocument::isSelected(RObject::Id entityId)

bool RDocument::isSelectedWorkingSet(RObject::Id entityId)

bool RDocument::isUndoAvailable() const

const

Returns: True if there are transactions available for undo, false otherwise.

QSet< REntity::Id > RDocument::queryAllBlockReferences() const

const

Returns: A set of all block reference entity IDs.

QSet< RBlock::Id > RDocument::queryAllBlocks() const

const

Returns: A set of all block IDs of the document.

QSet< REntity::Id > RDocument::queryAllEntities(bool undone, bool allBlocks, QList< RS::EntityType > types) const

const

Returns: A set of all entity IDs of the document.

QSet< REntity::Id > RDocument::queryAllEntities(bool undone=false, bool allBlocks=false, RS::EntityType type=RS::EntityAll) const

const

Queries all entities of this document.

This operation can be slow, depending on the total number of entities and the storage type that is used for this document.

Returns: Set of entity IDs.

QSet< RLayer::Id > RDocument::queryAllLayers() const

const

Queries all layers of this document.

Returns: Set of layer IDs.

QSet< RObject::Id > RDocument::queryAllLayerStates() const

const

Queries all layer state objects of this document.

Returns: Set of layer state IDs.

QSet< RBlock::Id > RDocument::queryAllLayoutBlocks(bool includeModelSpace=false) const

const

Returns: A set of all block IDs of layout blocks of the document.

QSet< RLayout::Id > RDocument::queryAllLayouts() const

const

Returns: A set of all layout IDs of layouts of the document.

QSet< RLinetype::Id > RDocument::queryAllLinetypes() const

const

Returns: A set of all linetype IDs of the document.

QSet< RObject::Id > RDocument::queryAllObjects() const

const

Queries all objects of this document.

Returns: Set of object IDs.

QSet< RUcs::Id > RDocument::queryAllUcs() const

const

Queries all UCSs of this document.

Returns: Set of UCS IDs.

QSet< REntity::Id > RDocument::queryAllViewports() const

const

Returns: A set of all viewport entity IDs.

QSet< RObject::Id > RDocument::queryAllViews() const

const

Returns: A set of all view IDs of the document.

QSet< REntity::Id > RDocument::queryAllVisibleEntities() const

const

QSharedPointer< RBlock > RDocument::queryBlock(const QString &blockName) const

const

Queries the block with the given name.

Returns: Pointer to the block or NULL.

QSharedPointer< RBlock > RDocument::queryBlock(RObject::Id blockId) const

const

Queries the block with the given ID.

Returns: Pointer to the block or NULL.

QSharedPointer< RBlock > RDocument::queryBlockDirect(const QString &blockName) const

const

Queries the block with the given name direct (no cloning).

Blocks queried this way should not be modified unless undo / redo functionality is not required.

Returns: Pointer to the block or NULL.

QSharedPointer< RBlock > RDocument::queryBlockDirect(RObject::Id blockId) const

const

Queries the block with the given ID direct (no cloning).

Blocks queried this way should not be modified unless undo / redo functionality is not required.

Returns: Pointer to the block or NULL.

QSet< REntity::Id > RDocument::queryBlockEntities(RObject::Id blockId) const

const

Returns: A set of all entity IDs that are part of the given block.

QSet< REntity::Id > RDocument::queryBlockReferences(RObject::Id blockId) const

const

Returns: A set of all block reference entity IDs that reference the given block.

QSet< REntity::Id > RDocument::queryBlockReferencesForLayers(const QSet< RObject::Id > &layerIds) const

const

Returns: A set of the IDs of those block reference entities whose visual appearance may change when the visibility of the given layers changes. These are references to blocks which contain entities on one of the given layers (directly or indirectly through nested block references) and block references which are themselves on one of the given layers (the visibility of layer 0 entities in the referenced block depends on the layer of the block reference). The default implementation conservatively returns all block references.

QSet< REntity::Id > RDocument::queryChildEntities(RObject::Id parentId, RS::EntityType type=RS::EntityAll) const

const

Returns: A set of all block attributes which are not stored in the block definition but as separate entities on the same level as the block reference.

REntity::Id RDocument::queryClosestXY(const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE, bool includeLockedLayers=true, bool selectedOnly=false, bool snappable=false)

Queries the one entity that is closest to the given position and within the given range (2d).

Parameters:

  • wcsPosition: The position to which the entity has to be close (2d).
  • range: The range in which to search.

RObject::Id RDocument::queryClosestXY(QSet< RObject::Id > &candidates, const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE)

QPair< REntity::Id, QSet< int > > RDocument::queryClosestXYWithIndices(const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE, bool includeLockedLayers=true, bool selectedOnly=false)

Queries the entity closest to the given position within range, along with the indices of the shape elements that are closest (2d).

Parameters:

  • wcsPosition: The position to which the entity has to be close (2d).
  • range: The range in which to search.
  • draft: True for draft mode (faster but less accurate).
  • strictRange: The strict range for distance checking.
  • includeLockedLayers: True to include entities on locked layers.
  • selectedOnly: True to only consider selected entities.

Returns: Pair of entity ID and set of shape indices.

QPair< REntity::Id, QSet< int > > RDocument::queryClosestXYWithIndices(QMap< RObject::Id, QSet< int > > &candidates, const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE)

Queries the entity closest to the given position from a set of candidates, along with the indices of the shape elements that are closest (2d).

Parameters:

  • candidates: Map of candidate entity IDs with their shape indices.
  • wcsPosition: The position to which the entity has to be close (2d).
  • range: The range in which to search.
  • draft: True for draft mode (faster but less accurate).
  • strictRange: The strict range for distance checking.

Returns: Pair of entity ID and set of shape indices.

QSet< REntity::Id > RDocument::queryConnectedEntities(RObject::Id entityId, double tolerance=RS::PointTolerance, RObject::Id layerId=RObject::INVALID_ID)

Queries all entities that are connected to the given entity within the specified tolerance.

Two entities are considered connected if their endpoints are within tolerance distance.

Parameters:

  • entityId: The ID of the entity to find connections for.
  • tolerance: The maximum distance for considering entities connected.
  • layerId: Optional layer ID to restrict search to, or INVALID_ID for all layers.

Returns: Set of entity IDs that are connected to the given entity.

QSet< REntity::Id > RDocument::queryContainedEntities(const RBox &box) const

const

Queries all entities which are completely inside the given box.

Parameters:

  • box: Query box.
  • result: Set of IDs of entities that are completely inside the given area.

QSet< REntity::Id > RDocument::queryContainedEntitiesXY(const RBox &box) const

const

Queries entities that are completely contained within the given box in the XY plane.

Filters out undone entities, entities not on the current block, and invisible entities.

Parameters:

  • box: Query box.

Returns: Set of entity IDs that are completely contained in the box.

QSharedPointer< RBlock > RDocument::queryCurrentBlock()

QSharedPointer< RLayer > RDocument::queryCurrentLayer()

QSharedPointer< RView > RDocument::queryCurrentView()

QSharedPointer< RDimStyle > RDocument::queryDimStyle() const

const

QSharedPointer< RDimStyle > RDocument::queryDimStyleDirect() const

const

QSharedPointer< RDocumentVariables > RDocument::queryDocumentVariables() const

const

QSharedPointer< RDocumentVariables > RDocument::queryDocumentVariablesDirect() const

const

QSharedPointer< REntity > RDocument::queryEntity(RObject::Id entityId) const

const

Queries the entity with the given ID.

A clone of the actual entity is returned. Clones should always be used when modifying entities.

Returns: Pointer to the entity or NULL.

QSharedPointer< REntity > RDocument::queryEntityDirect(RObject::Id entityId) const

const

Queries the entity with the given ID.

If the storage has the entity instantiated, the instance is returned (rather than a clone). Entities queried this way should not be modified unless undo / redo functionality is not required.

Returns: Pointer to the entity or NULL.

QSet< REntity::Id > RDocument::queryInfiniteEntities() const

const

Returns: Set of entity IDs for all infinite entities (such as construction lines).

QSet< REntity::Id > RDocument::queryIntersectedEntitiesXY(const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RObject::Id blockId=RObject::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false, RObject::Id layerId=RObject::INVALID_ID, bool snappable=false) const

const

Queries entities that intersect with the given box in the XY plane.

This is a convenience wrapper around queryIntersectedEntitiesXYWithIndex.

Parameters:

  • box: Query box.
  • checkBoundingBoxOnly: If true, only checks bounding box intersection.
  • includeLockedLayers: If true, includes entities on locked layers.
  • blockId: The block to query, or INVALID_ID for current block.
  • filter: List of entity types to include, or empty for all types.
  • selectedOnly: If true, only returns selected entities.
  • layerId: Layer to filter by, or INVALID_ID for all layers.

Returns: Set of entity IDs that intersect with the box.

QSet< REntity::Id > RDocument::queryIntersectedEntitiesXYFast(const RBox &box)

Queries entities that intersect with the given box (fast approximation based on bounding boxes).

Parameters:

  • box: Query box.

Returns: Set of entity IDs that may intersect with the box.

QMap< REntity::Id, QSet< int > > RDocument::queryIntersectedEntitiesXYWithIndex(const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RObject::Id blockId=RObject::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false, RObject::Id layerId=RObject::INVALID_ID, bool snappable=false) const

const

Queries entities that intersect with the given box in the XY plane, returning both entity IDs and shape element indices.

Parameters:

  • box: Query box.
  • checkBoundingBoxOnly: If true, only checks bounding box intersection.
  • includeLockedLayers: If true, includes entities on locked layers.
  • blockId: The block to query, or INVALID_ID for current block.
  • filter: List of entity types to include, or empty for all types.
  • selectedOnly: If true, only returns selected entities.
  • layerId: Layer to filter by, or INVALID_ID for all layers.

Returns: Map of entity IDs to sets of intersecting shape element indices.

QMap< REntity::Id, QSet< int > > RDocument::queryIntersectedShapesXY(const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RObject::Id blockId=RObject::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false, RObject::Id layerId=RObject::INVALID_ID, bool snappable=false) const

const

Queries entity shapes that intersect with the given box in the XY plane, returning both entity IDs and shape element indices.

This method performs more precise intersection testing than the fast variant.

Parameters:

  • box: Query box.
  • checkBoundingBoxOnly: If true, only checks bounding box intersection.
  • includeLockedLayers: If true, includes entities on locked layers.
  • blockId: The block to query, or INVALID_ID for current block.
  • filter: List of entity types to include, or empty for all types.
  • selectedOnly: If true, only returns selected entities.
  • layerId: Layer to filter by, or INVALID_ID for all layers.

Returns: Map of entity IDs to sets of intersecting shape element indices.

QSet< REntity::Id > RDocument::queryIntersectedShapesXYFast(const RBox &box, bool noInfiniteEntities=false)

Queries entity shapes that intersect with the given box (fast approximation).

Returns only visible entities.

Parameters:

  • box: Query box.
  • noInfiniteEntities: If true, excludes infinite entities like construction lines.

Returns: Set of entity IDs whose shapes intersect with the box.

QSharedPointer< RLayer > RDocument::queryLayer(const QString &layerName) const

const

Queries the layer with the given name.

Returns: Pointer to the layer or NULL.

QSharedPointer< RLayer > RDocument::queryLayer(RObject::Id layerId) const

const

Queries the layer with the given ID.

Returns: Pointer to the layer or NULL.

QSet< REntity::Id > RDocument::queryLayerBlockEntities(RObject::Id layerId, RObject::Id blockId) const

const

QSharedPointer< RLayer > RDocument::queryLayerDirect(RObject::Id layerId) const

const

Queries the layer with the given ID direct (no cloning).

Layers queried this way should not be modified unless undo / redo functionality is not required.

Returns: Pointer to the layer or NULL.

QSet< REntity::Id > RDocument::queryLayerEntities(RObject::Id layerId, bool allBlocks=false) const

const

Returns: A set of all entity IDs on the given layer.

QSharedPointer< RLayerState > RDocument::queryLayerState(const QString &layerStateName) const

const

Queries the layer state with the given name.

Returns: Pointer to the layer state or NULL.

QSharedPointer< RLayerState > RDocument::queryLayerState(RObject::Id layerStateId) const

const

Queries the layer state with the given ID.

Returns: Pointer to the layer state or NULL.

QSharedPointer< RLayerState > RDocument::queryLayerStateDirect(RObject::Id layerStateId) const

const

Queries the layer state with the given ID direct (no cloning).

Layer states queried this way should not be modified unless undo / redo functionality is not required.

Returns: Pointer to the layer state or NULL.

QSharedPointer< RLayout > RDocument::queryLayout(const QString &layoutName) const

const

Queries the layout with the given name.

Returns: Pointer to the layout or NULL.

QSharedPointer< RLayout > RDocument::queryLayout(RObject::Id layoutId) const

const

Queries the layout with the given ID.

Returns: Pointer to the layout or NULL.

QSharedPointer< RLayout > RDocument::queryLayoutDirect(RObject::Id layoutId) const

const

Queries the layout with the given ID direct (no cloning).

Layouts queried this way should not be modified unless undo / redo functionality is not required.

Returns: Pointer to the layout or NULL.

QSharedPointer< RLinetype > RDocument::queryLinetype(const QString &linetypeName) const

const

Queries the linetype with the given name.

Returns: Pointer to the linetype or NULL.

QSharedPointer< RLinetype > RDocument::queryLinetype(RObject::Id linetypeId) const

const

Queries the linetype with the given ID.

Returns: Pointer to the linetype or NULL.

QSharedPointer< RObject > RDocument::queryObject(RObject::Id objectId) const

const

Queries the object with the given ID.

Returns: Shared pointer to the object or a null pointer.

QSharedPointer< RObject > RDocument::queryObjectByHandle(RObject::Handle objectHandle) const

const

Queries an object by its handle.

Parameters:

  • objectHandle: The handle of the object to query.

Returns: Shared pointer to the object or a null pointer.

RObject * RDocument::queryObjectCC(RObject::Id objectId) const

const

Queries the object with the given ID using the internal storage representation.

This is faster than queryObject but returns a pointer that should not be modified.

Parameters:

  • objectId: The ID of the object to query.

Returns: Raw pointer to the object or NULL.

QSharedPointer< RObject > RDocument::queryObjectDirect(RObject::Id objectId) const

const

Queries the object with the given ID.

If the storage has the object instantiated, the instance is returned (rather than a clone). Objects queried this way should not be modified unless undo / redo functionality is not required.

Returns: Pointer to the object or NULL.

QSet< RObject::Id > RDocument::queryPropertyEditorObjects()

Queries all objects that should be shown in the property editor.

If entities are selected, returns those. Otherwise returns selected layers, current block, and associated layout.

Returns: Set of object IDs for the property editor.

QSet< REntity::Id > RDocument::querySelectedEntities() const

const

Queries all selected entities.

Returns: Set of IDs of all selected entities.

QSet< REntity::Id > RDocument::querySelectedLayerEntities(RObject::Id layerId, bool allBlocks=false) const

const

Returns: A set of all entity IDs of selected entities on the given layer.

QSet< RObject::Id > RDocument::querySelectedLayers() const

const

Queries all selected objects.

Returns: Set of IDs of all selected objects.

QSharedPointer< RUcs > RDocument::queryUcs(const QString &ucsName) const

const

Queries the UCS with the given name.

Returns: Pointer to the UCS or NULL.

QSharedPointer< RUcs > RDocument::queryUcs(RObject::Id ucsId) const

const

Queries the UCS with the given ID.

Returns: Pointer to the UCS or NULL.

QSharedPointer< RView > RDocument::queryView(const QString &viewName) const

const

Queries the view with the given name.

Returns: Pointer to the view or NULL.

QSharedPointer< RView > RDocument::queryView(RObject::Id viewId) const

const

Queries the view with the given ID.

Returns: Pointer to the view or NULL.

QSharedPointer< REntity > RDocument::queryVisibleEntityDirect(RObject::Id entityId) const

const

Queries a visible entity with the given ID, returning the direct instance.

If the entity is not visible, returns a null pointer.

Parameters:

  • entityId: The ID of the entity to query.

Returns: Shared pointer to the entity or a null pointer.

QSet< REntity::Id > RDocument::queryWorkingSetEntities() const

const

Returns: A set of all entity IDs in the current working set.

virtual void RDocument::rebuildSpatialIndex()

virtual

Rebuilds the entire spatial index from scratch (e.g.

when current block is changed).

QList< RTransaction > RDocument::redo()

Redoes a previously undone transaction.

Returns: Set of affected entity IDs. Higher level callers can use this set to update scenes, views, etc accordingly.

void RDocument::removeBlockFromSpatialIndex(RObject::Id blockId)

Removes all entities from the given block from the spatial index.

This is typically done when entering a block for editing.

Parameters:

  • blockId: The ID of the block to remove from the spatial index.

void RDocument::removeFromSpatialIndex(QSharedPointer< REntity > entity)

Removes an entity from the spatial index using its current bounding boxes.

Parameters:

  • entity: The entity to remove from the spatial index.

virtual void RDocument::removeFromSpatialIndex(QSharedPointer< REntity > entity, const QList< RBox > &boundingBoxes)

virtual

Removes an entity from the spatial index using the given bounding boxes.

If no bounding boxes are provided, uses the entity’s current bounding boxes.

Parameters:

  • entity: The entity to remove from the spatial index.
  • boundingBoxes: The bounding boxes to use for removal.

void RDocument::removeVariable(const QString &key)

Removes the custom variable with the given key.

void RDocument::resetTransactionStack()

Resets the transaction stack, clearing all undo and redo history.

void RDocument::selectAllEntities(QSet< RObject::Id > *affectedEntities=NULL)

Selects all not selected entities.

int RDocument::selectEntities(const QSet< RObject::Id > &entityId, bool add=false, QSet< RObject::Id > *affectedEntities=NULL)

Selects all entities with the given IDs.

Parameters:

  • add: True to add the entities to the current selection. False to replace the current selection with the new entities.
  • affected: Optional pointer to an empty set of entity IDs. After the call, this set will contain all entity IDs of entities that were affected by the call.

void RDocument::selectEntity(RObject::Id entityId, bool add=false, QSet< RObject::Id > *affectedEntities=NULL)

Selects the entity with the given ID.

Parameters:

  • add: True to add the entity to the current selection. False to replace the current selection with the given entity.
  • affected: Optional pointer to an empty set of entity IDs. After the call, this set will contain all entity IDs of entities that were affected by the call.

void RDocument::setAutoTransactionGroup(bool on)

inline

True: add all operations to the current transaction group.

void RDocument::setCurrentBlock(const QString &blockName)

Sets the current block for editing by name.

Parameters:

  • blockName: The name of the block to set as current.

void RDocument::setCurrentBlock(RObject::Id blockId)

Sets the current block for editing.

Removes the block from the spatial index while it’s being edited and adds the previous block back to the spatial index.

Parameters:

  • blockId: The ID of the block to set as current.

void RDocument::setCurrentColor(const RColor &color)

void RDocument::setCurrentLayer(const QString &layerName, RTransaction *transaction=NULL)

void RDocument::setCurrentLayer(RObject::Id layerId, RTransaction *transaction=NULL)

void RDocument::setCurrentLinetype(const QString &name)

void RDocument::setCurrentLinetype(RObject::Id ltId)

void RDocument::setCurrentLinetypePattern(const RLinetypePattern &p)

void RDocument::setCurrentLineweight(RLineweight::Lineweight lw)

void RDocument::setCurrentView(const QString &viewName)

void RDocument::setCurrentView(RObject::Id viewId)

void RDocument::setCurrentViewport(RObject::Id viewportId)

Sets the current viewport for this document.

Parameters:

  • viewportId: The ID of the viewport to set as current.

void RDocument::setDimensionFont(const QString &f, RTransaction *transaction=NULL)

void RDocument::setFileName(const QString &fn)

Sets the file name associated with this document.

Parameters:

  • fn: The file name to set.

void RDocument::setFileVersion(const QString &fv)

Sets the file version string for this document.

Parameters:

  • fv: The file version string to set.

void RDocument::setIgnoreWorkingSet(bool on)

Sets whether to ignore the working set.

Parameters:

  • on: True to ignore the working set, false otherwise.

void RDocument::setKnownVariable(RS::KnownVariable key, const QVariant &value, RTransaction *transaction=NULL)

Sets a known DXF/DWG variable for this document.

Parameters:

  • key: Variable key (see DXF reference)
  • value: New value of the variable.
  • transaction: RTransaction to use for the change or NULL (default) to create a transaction on the fly.

void RDocument::setKnownVariable(RS::KnownVariable key, const RVector &value, RTransaction *transaction=NULL)

Sets a known DXF/DWG variable for this document.

Parameters:

  • key: Variable key (see DXF reference)
  • value: New value of the variable.
  • transaction: RTransaction to use for the change or NULL (default) to create a transaction on the fly.

void RDocument::setLinearFormat(RS::LinearFormat f)

Sets the linear format type for this document.

This updates the dimension style variable “$DIMLUNIT”.

Parameters:

  • f: The linear format type to set.

void RDocument::setLinetypeScale(double v, RTransaction *transaction=NULL)

Sets the global linetype scale of this document to the given value.

Parameters:

  • transaction: Transaction to use for the modification or NULL to create a local transaction (default).

void RDocument::setMeasurement(RS::Measurement m, RTransaction *transaction=NULL)

Sets the measurement system for this document (metric or imperial).

Also reinitializes linetypes to match the new measurement system.

Parameters:

  • m: The measurement system to set.
  • transaction: Optional transaction to use. If NULL, changes are made directly.

void RDocument::setModified(bool m)

Resets the modified flag.

Modification time is stored.

void RDocument::setNotifyListeners(bool on)

Sets whether listeners should be notified of changes to the document.

Parameters:

  • on: True to enable listener notifications, false to disable.

void RDocument::setUnit(RS::Unit unit, RTransaction *transaction=NULL)

Sets the unit of measurement for this document.

Also reinitializes linetypes to match the new unit system.

Parameters:

  • unit: The unit of measurement to set.
  • transaction: Optional transaction to use. If NULL, changes are made directly.

void RDocument::setVariable(const QString &key, const QVariant &value, bool overwrite=true)

Sets a custom variable in the context of this document.

Parameters:

  • key: Variable key (name)
  • value: Variable value
  • overwrite: True to overwrite an existing variable with the same key (default)

bool RDocument::showLeadingZeroes()

Returns: True if leading zeroes should be shown in linear dimensions, false otherwise. This is determined by the dimension style variable “$DIMZIN”.

bool RDocument::showLeadingZeroesAngle()

Returns: True if leading zeroes should be shown in angular dimensions, false otherwise. This is determined by the dimension style variable “$DIMAZIN”.

bool RDocument::showTrailingZeroes()

Returns: True if trailing zeroes should be shown in linear dimensions, false otherwise. This is determined by the dimension style variable “$DIMZIN”.

bool RDocument::showTrailingZeroesAngle()

Returns: True if trailing zeroes should be shown in angular dimensions, false otherwise. This is determined by the dimension style variable “$DIMAZIN”.

QList< RBlock::Id > RDocument::sortBlocks(const QList< RObject::Id > &blockIds) const

const

QList< RLayer::Id > RDocument::sortLayers(const QList< RObject::Id > &layerIds) const

const

void RDocument::startTransactionGroup()

QString RDocument::substituteAutoVariables(const QString &expression)

Substitutes all auto variable references in the given expression with their values.

Parameters:

  • expression: The expression containing auto variable references.

Returns: The expression with auto variables replaced by their values.

QList< RTransaction > RDocument::undo()

Undoes the last transaction.

Returns: The transaction that was undone. Higher level callers can use this set to update scenes, views, etc accordingly.

void RDocument::unsetCurrentViewport()

Unsets the current viewport for this document.

void RDocument::updateAllEntities()

Updates all entities in the document (recalculates bounding boxes, etc.).

This is typically done after changing document-level settings.

static RDocument & RDocument::getClipboard()

static

Returns: Reference to the global clipboard document. The clipboard is created on first access.

static RDocument * RDocument::clipboard = NULL

static protected

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

bool RDocument::autoTransactionGroup

private

bool RDocument::disableSpatialIndicesByBlock

private

QString RDocument::fileName

private

QString RDocument::fileVersion

private

RObject::Id RDocument::linetypeByBlockId

private

RObject::Id RDocument::linetypeByLayerId

private

RSpatialIndex& RDocument::spatialIndex

private

QMap<RObject::Id, RSpatialIndex*> RDocument::spatialIndicesByBlock

private

RStorage& RDocument::storage

private

RTransactionStack RDocument::transactionStack

private

QDebug operator<<(QDebug dbg, RDocument &d)

Stream operator for QDebug.

Non-Scriptable: This function is not available in script environments.