QCAD
Open Source 2D CAD
RDocument Class Reference

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

#include <RDocument.h>

Inheritance diagram for RDocument:
RRequireHeap RNonCopyable

Public Member Functions

bool addBlockToSpatialIndex (RBlock::Id blockId, RObject::Id ignoreBlockId)
 Add block references that point to blockId, unless they also point to ignoreBlockId. More...
 
void addToSpatialIndex (QSharedPointer< REntity > entity)
 
bool blockContainsReferences (RBlock::Id blockId, RBlock::Id referencedBlockId)
 
void clear ()
 Resets this document to its initial, empty state. More...
 
void clearSelection (QSet< REntity::Id > *affectedEntities=NULL)
 
void clearSpatialIndices ()
 
void copyVariablesFrom (const RDocument &other)
 
int countSelectedEntities () const
 
bool deselectEntities (const QSet< REntity::Id > &entityId, QSet< REntity::Id > *affectedEntities=NULL)
 Deselects all entities with the given IDs. More...
 
void deselectEntity (REntity::Id entityId, QSet< REntity::Id > *affectedEntities=NULL)
 Deselects the entity with the given ID. More...
 
void dump ()
 
QString formatAngle (double value)
 
QString formatLinear (double value)
 
RS::AngleFormat getAngleFormat ()
 
int getAnglePrecision ()
 
RBlock::Id getBlockId (const QString &blockName) const
 
QString getBlockName (RBlock::Id blockId) const
 
QSet< QString > getBlockNames (const QString &rxStr=RDEFAULT_QSTRING) const
 
RBox getBoundingBox (bool ignoreHiddenLayers=true, bool ignoreEmpty=false) const
 
RBlock::Id getCurrentBlockId () const
 
QString getCurrentBlockName () const
 
RColor getCurrentColor () const
 
RLayer::Id getCurrentLayerId () const
 
QString getCurrentLayerName () const
 
RLinetype::Id getCurrentLinetypeId () const
 
RLinetypePattern getCurrentLinetypePattern () const
 
RLineweight::Lineweight getCurrentLineweight () const
 
RView::Id getCurrentViewId () const
 
QChar getDecimalSeparator ()
 
QList< QSharedPointer< RObject > > getDefaultLinetypes ()
 
QString getDimensionFont () const
 
QString getFileName () const
 
QString getFileVersion () const
 
QVariant getKnownVariable (RS::KnownVariable key, const QVariant &defaultValue=RDEFAULT_QVARIANT) const
 
QString getLastModified () const
 
QDateTime getLastModifiedDateTime () const
 
RLayer::Id getLayerId (const QString &layerName) const
 
QString getLayerName (RLayer::Id layerId) const
 
QSet< QString > getLayerNames (const QString &rxStr=RDEFAULT_QSTRING) const
 
QString getLayoutName (RLayout::Id layoutId) const
 
RS::LinearFormat getLinearFormat () const
 
int getLinearPrecision ()
 
RLinetype::Id getLinetypeByBlockId () const
 
RLinetype::Id getLinetypeByLayerId () const
 
QString getLinetypeDescription (RLinetype::Id linetypeId) const
 
RLinetype::Id getLinetypeId (const QString &linetypeName) const
 
QString getLinetypeLabel (RLinetype::Id linetypeId) const
 
QString getLinetypeName (RLinetype::Id linetypeId) const
 
QSet< QString > getLinetypeNames () const
 
QList< RLinetypePatterngetLinetypePatterns () const
 
double getLinetypeScale () const
 
RLineweight::Lineweight getMaxLineweight () const
 
RS::Measurement getMeasurement () const
 
RBlock::Id getModelSpaceBlockId () const
 
RBox getSelectionBox () const
 
RSpatialIndexgetSpatialIndex ()
 
RSpatialIndexgetSpatialIndexForBlock (RBlock::Id blockId)
 
RSpatialIndexgetSpatialIndexForCurrentBlock ()
 
RStoragegetStorage ()
 
const RStoragegetStorage () const
 
QString getTempBlockName () const
 
int getTransactionGroup () const
 
RTransactionStackgetTransactionStack ()
 
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 (RBlock::Id blockId) const
 
bool hasChildEntities (REntity::Id parentId) const
 
bool hasLayer (const QString &layerName) const
 
bool hasLinetype (const QString &linetypeName) const
 
bool hasSelection () const
 
bool hasVariable (const QString &key) const
 
bool hasView (const QString &viewName) const
 
void init ()
 
void initLinetypes (RTransaction *transaction=NULL)
 
bool isBlockFrozen (RBlock::Id blockId) const
 
bool isByBlock (RLinetype::Id linetypeId) const
 
bool isByLayer (RLinetype::Id linetypeId) const
 
bool isEntityEditable (REntity::Id entityId) const
 
bool isEntityLayerFrozen (REntity::Id entityId) const
 
bool isLayerFrozen (RLayer::Id layerId) const
 
bool isLayerLocked (RLayer::Id layerId) const
 
bool isMetric () const
 
bool isModified () const
 
bool isParentLayerFrozen (RLayer::Id layerId) const
 
bool isParentLayerLocked (RLayer::Id layerId) const
 
bool isRedoAvailable () const
 
bool isSelected (REntity::Id entityId)
 
bool isUndoAvailable () const
 
QSet< REntity::IdqueryAllBlockReferences () const
 
QSet< RBlock::IdqueryAllBlocks () const
 
QSet< REntity::IdqueryAllEntities (bool undone=false, bool allBlocks=false, RS::EntityType type=RS::EntityAll) const
 Queries all entities of this document. More...
 
QSet< REntity::IdqueryAllEntities (bool undone, bool allBlocks, QList< RS::EntityType > types) const
 
QSet< RLayer::IdqueryAllLayers () const
 Queries all layers of this document. More...
 
QSet< RBlock::IdqueryAllLayoutBlocks () const
 
QSet< RLinetype::IdqueryAllLinetypes () const
 
QSet< RObject::IdqueryAllObjects () const
 Queries all objects of this document. More...
 
QSet< RUcs::IdqueryAllUcs () const
 Queries all UCSs of this document. More...
 
QSet< RView::IdqueryAllViews () const
 
QSet< REntity::IdqueryAllVisibleEntities () const
 
QSharedPointer< RBlockqueryBlock (RBlock::Id blockId) const
 Queries the block with the given ID. More...
 
QSharedPointer< RBlockqueryBlock (const QString &blockName) const
 Queries the block with the given name. More...
 
QSharedPointer< RBlockqueryBlockDirect (RBlock::Id blockId) const
 Queries the block with the given ID direct (no cloning). More...
 
QSharedPointer< RBlockqueryBlockDirect (const QString &blockName) const
 Queries the block with the given name direct (no cloning). More...
 
QSet< REntity::IdqueryBlockEntities (RBlock::Id blockId) const
 
QSet< REntity::IdqueryBlockReferences (RBlock::Id blockId) const
 
QSet< REntity::IdqueryChildEntities (REntity::Id parentId, RS::EntityType type=RS::EntityAll) const
 
REntity::Id queryClosestXY (const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE, bool includeLockedLayers=true, bool selectedOnly=false)
 Queries the one entity that is closest to the given position and within the given range (2d). More...
 
REntity::Id queryClosestXY (QSet< REntity::Id > &candidates, const RVector &wcsPosition, double range, bool draft, double strictRange=RMAXDOUBLE)
 Queries the entity that is closest to the given position wcsPosition. More...
 
QSet< REntity::IdqueryContainedEntities (const RBox &box)
 Queries all entities which are completely inside the given box. More...
 
QSet< REntity::IdqueryContainedEntitiesXY (const RBox &box)
 
QSharedPointer< RBlockqueryCurrentBlock ()
 
QSharedPointer< RLayerqueryCurrentLayer ()
 
QSharedPointer< RViewqueryCurrentView ()
 
QSharedPointer< RDocumentVariablesqueryDocumentVariables () const
 
QSharedPointer< RDocumentVariablesqueryDocumentVariablesDirect () const
 
QSharedPointer< REntityqueryEntity (REntity::Id entityId) const
 Queries the entity with the given ID. More...
 
QSharedPointer< REntityqueryEntityDirect (REntity::Id entityId) const
 Queries the entity with the given ID. More...
 
QSet< REntity::IdqueryInfiniteEntities ()
 
QSet< REntity::IdqueryIntersectedEntitiesXY (const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RBlock::Id blockId=RBlock::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false)
 
QMap< REntity::Id, QSet< int > > queryIntersectedShapesXY (const RBox &box, bool checkBoundingBoxOnly=false, bool includeLockedLayers=true, RBlock::Id blockId=RBlock::INVALID_ID, const QList< RS::EntityType > &filter=RDEFAULT_QLIST_RS_ENTITYTYPE, bool selectedOnly=false)
 
QSharedPointer< RLayerqueryLayer (RLayer::Id layerId) const
 Queries the layer with the given ID. More...
 
QSharedPointer< RLayerqueryLayer (const QString &layerName) const
 Queries the layer with the given name. More...
 
QSet< REntity::IdqueryLayerBlockEntities (RLayer::Id layerId, RBlock::Id blockId) const
 
QSharedPointer< RLayerqueryLayerDirect (RLayer::Id layerId) const
 Queries the layer with the given ID direct (no cloning). More...
 
QSet< REntity::IdqueryLayerEntities (RLayer::Id layerId, bool allBlocks=false) const
 
QSharedPointer< RLayoutqueryLayout (RLayout::Id layoutId) const
 Queries the layout with the given ID. More...
 
QSharedPointer< RLayoutqueryLayout (const QString &layoutName) const
 Queries the layout with the given name. More...
 
QSharedPointer< RLayoutqueryLayoutDirect (RLayout::Id layoutId) const
 Queries the layout with the given ID direct (no cloning). More...
 
QSharedPointer< RLinetypequeryLinetype (RLinetype::Id linetypeId) const
 Queries the linetype with the given ID. More...
 
QSharedPointer< RLinetypequeryLinetype (const QString &linetypeName) const
 Queries the linetype with the given name. More...
 
QSharedPointer< RObjectqueryObject (RObject::Id objectId) const
 Queries the object with the given ID. More...
 
QSharedPointer< RObjectqueryObjectByHandle (RObject::Handle objectHandle) const
 
QSharedPointer< RObjectqueryObjectDirect (RObject::Id objectId) const
 Queries the object with the given ID. More...
 
QSet< RObject::IdqueryPropertyEditorObjects ()
 
QSet< REntity::IdquerySelectedEntities ()
 Queries all selected entities. More...
 
QSharedPointer< RUcsqueryUcs (RUcs::Id ucsId) const
 Queries the UCS with the given ID. More...
 
QSharedPointer< RUcsqueryUcs (const QString &ucsName) const
 Queries the UCS with the given name. More...
 
QSharedPointer< RViewqueryView (RView::Id viewId) const
 Queries the view with the given ID. More...
 
QSharedPointer< RViewqueryView (const QString &viewName) const
 Queries the view with the given name. More...
 
 RDocument (RStorage &storage, RSpatialIndex &spatialIndex)
 Creates a new document with the given storage as back-end. More...
 
virtual void rebuildSpatialIndex ()
 Rebuilds the entire spatial index from scratch (e.g. More...
 
QList< RTransactionredo ()
 Redoes a previously undone transaction. More...
 
void removeBlockFromSpatialIndex (RBlock::Id blockId)
 
virtual void removeFromSpatialIndex (QSharedPointer< REntity > entity, const QList< RBox > &boundingBoxes=RDEFAULT_QLIST_RBOX)
 
void removeVariable (const QString &key)
 Removes the custom variable with the given key. More...
 
void resetTransactionStack ()
 
void selectAllEntites (QSet< REntity::Id > *affectedEntities=NULL)
 Selects all not selected entities. More...
 
void selectEntities (const QSet< REntity::Id > &entityId, bool add=false, QSet< REntity::Id > *affectedEntities=NULL)
 Selects all entities with the given IDs. More...
 
void selectEntity (REntity::Id entityId, bool add=false, QSet< REntity::Id > *affectedEntities=NULL)
 Selects the entity with the given ID. More...
 
void setCurrentBlock (RBlock::Id blockId)
 
void setCurrentBlock (const QString &blockName)
 
void setCurrentColor (const RColor &color)
 
void setCurrentLayer (RLayer::Id layerId, RTransaction *transaction=NULL)
 
void setCurrentLayer (const QString &layerName, RTransaction *transaction=NULL)
 
void setCurrentLinetype (RLinetype::Id ltId)
 
void setCurrentLinetype (const QString &name)
 
void setCurrentLinetypePattern (const RLinetypePattern &p)
 
void setCurrentLineweight (RLineweight::Lineweight lw)
 
void setCurrentView (RView::Id viewId)
 
void setCurrentView (const QString &viewName)
 
void setDimensionFont (const QString &f, RTransaction *transaction=NULL)
 
void setFileName (const QString &fn)
 
void setFileVersion (const QString &fv)
 
void setKnownVariable (RS::KnownVariable key, const QVariant &value, RTransaction *transaction=NULL)
 Sets a known DXF/DWG variable for this document. More...
 
void setKnownVariable (RS::KnownVariable key, const RVector &value, RTransaction *transaction=NULL)
 Sets a known DXF/DWG variable for this document. More...
 
void setLinearFormat (RS::LinearFormat f)
 
void setLinetypeScale (double v, RTransaction *transaction=NULL)
 Sets the global linetype scale of this document to the given value. More...
 
void setMeasurement (RS::Measurement m, RTransaction *transaction=NULL)
 
void setModified (bool m)
 Resets the modified flag. More...
 
void setUnit (RS::Unit unit, RTransaction *transaction=NULL)
 
void setVariable (const QString &key, const QVariant &value, bool overwrite=true)
 Sets a custom variable in the context of this document. More...
 
bool showLeadingZeroes ()
 
bool showLeadingZeroesAngle ()
 
bool showTrailingZeroes ()
 
bool showTrailingZeroesAngle ()
 
void startTransactionGroup ()
 
QList< RTransactionundo ()
 Undoes the last transaction. More...
 
void updateAllEntities ()
 
virtual ~RDocument ()
 
- Public Member Functions inherited from RRequireHeap
void doDelete ()
 

Static Public Member Functions

static RDocumentgetClipboard ()
 

Static Protected Attributes

static RDocumentclipboard = NULL
 Copyright (c) 2011-2016 by Andrew Mustun. More...
 

Private Attributes

bool disableSpatialIndicesByBlock
 
QString fileName
 
QString fileVersion
 
RLinetype::Id linetypeByBlockId
 
RLinetype::Id linetypeByLayerId
 
RSpatialIndexspatialIndex
 
QMap< RBlock::Id, RSpatialIndex * > spatialIndicesByBlock
 
RStoragestorage
 
RTransactionStack transactionStack
 

Friends

QDebug operator<< (QDebug dbg, RDocument &d)
 Stream operator for QDebug. More...
 

Additional Inherited Members

- Protected Member Functions inherited from RRequireHeap
virtual ~RRequireHeap ()
 
- Private Member Functions inherited from RNonCopyable
 RNonCopyable ()
 
 ~RNonCopyable ()
 

Detailed Description

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.

Constructor & Destructor Documentation

RDocument::RDocument ( RStorage storage,
RSpatialIndex spatialIndex 
)

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.

RDocument::~RDocument ( )
virtual

Member Function Documentation

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

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

void RDocument::addToSpatialIndex ( QSharedPointer< REntity entity)
bool RDocument::blockContainsReferences ( RBlock::Id  blockId,
RBlock::Id  referencedBlockId 
)
void RDocument::clear ( )

Resets this document to its initial, empty state.

void RDocument::clearSelection ( QSet< REntity::Id > *  affectedEntities = NULL)
Todo:
refactoring to operation

Deselectes all selected entities.

void RDocument::clearSpatialIndices ( )
void RDocument::copyVariablesFrom ( const RDocument other)
int RDocument::countSelectedEntities ( ) const

Returns
Number of selected entities.
bool RDocument::deselectEntities ( const QSet< REntity::Id > &  entityIds,
QSet< REntity::Id > *  affectedEntities = NULL 
)

Deselects all entities with the given IDs.

Todo:
refactoring to operation
Parameters
affectedOptional 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 ( REntity::Id  entityId,
QSet< REntity::Id > *  affectedEntities = NULL 
)

Deselects the entity with the given ID.

Parameters
affectedOptional 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 ( )
QString RDocument::formatAngle ( double  value)
QString RDocument::formatLinear ( double  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".
RBlock::Id RDocument::getBlockId ( const QString &  blockName) const

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

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

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

Returns
The bounding box around all visible entities.
RDocument & RDocument::getClipboard ( )
static
RBlock::Id RDocument::getCurrentBlockId ( ) const

QString RDocument::getCurrentBlockName ( ) const
RColor RDocument::getCurrentColor ( ) const

RLayer::Id RDocument::getCurrentLayerId ( ) const

QString RDocument::getCurrentLayerName ( ) const

RLinetype::Id RDocument::getCurrentLinetypeId ( ) const

RLinetypePattern RDocument::getCurrentLinetypePattern ( ) const

RLineweight::Lineweight RDocument::getCurrentLineweight ( ) const

RView::Id RDocument::getCurrentViewId ( ) const

QChar RDocument::getDecimalSeparator ( )
QList< QSharedPointer< RObject > > RDocument::getDefaultLinetypes ( )
QString RDocument::getDimensionFont ( ) const

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

Returns
Value for the given DXF/DWG variable.
QString RDocument::getLastModified ( ) const

QDateTime RDocument::getLastModifiedDateTime ( ) const

Non-Scriptable:
This function is not available in script environments.
RLayer::Id RDocument::getLayerId ( const QString &  layerName) const

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

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

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

RS::LinearFormat RDocument::getLinearFormat ( ) 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".
RLinetype::Id RDocument::getLinetypeByBlockId ( ) const
inline
RLinetype::Id RDocument::getLinetypeByLayerId ( ) const
inline
QString RDocument::getLinetypeDescription ( RLinetype::Id  linetypeId) const

Returns
User readable description for the given linetype.
RLinetype::Id RDocument::getLinetypeId ( const QString &  linetypeName) const

Returns
Linetype ID of the given linetype name or RObject::INVALID_ID.
QString RDocument::getLinetypeLabel ( RLinetype::Id  linetypeId) const

Returns
User readable label for the given linetype.
QString RDocument::getLinetypeName ( RLinetype::Id  linetypeId) const

Returns
Linetype name of the given linetype.
QSet< QString > RDocument::getLinetypeNames ( ) const

Returns
List of all available linetype pattern names in this document.
QList< RLinetypePattern > RDocument::getLinetypePatterns ( ) const

Returns
List of all available linetype patterns in this document.
double RDocument::getLinetypeScale ( ) const

RLineweight::Lineweight RDocument::getMaxLineweight ( ) const
RS::Measurement RDocument::getMeasurement ( ) const

RBlock::Id RDocument::getModelSpaceBlockId ( ) const

RBox RDocument::getSelectionBox ( ) const

RSpatialIndex & RDocument::getSpatialIndex ( )
Returns
Reference to the spatial index.
RSpatialIndex * RDocument::getSpatialIndexForBlock ( RBlock::Id  blockId)
RSpatialIndex * RDocument::getSpatialIndexForCurrentBlock ( )
RStorage & RDocument::getStorage ( )
Returns
Reference to storage that backs the document.
const RStorage & RDocument::getStorage ( ) const
QString RDocument::getTempBlockName ( ) const
int RDocument::getTransactionGroup ( ) const

RTransactionStack & RDocument::getTransactionStack ( )
Returns
Reference to the transaction stack for undo/redo handling.
RS::Unit RDocument::getUnit ( ) const
QVariant RDocument::getVariable ( const QString &  key,
const QVariant &  defaultValue = RDEFAULT_QVARIANT,
bool  useSettings = false 
) const

Returns
The value of the given variable or an invalid variant if the variable does not exist.
QStringList RDocument::getVariables ( ) const

Returns
List of custom variable names stored in this document.
QSet< QString > RDocument::getViewNames ( ) const

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

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

Returns
True if the given block contains any entities.
bool RDocument::hasChildEntities ( REntity::Id  parentId) const

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

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

bool RDocument::hasSelection ( ) const

Returns
True if at least one entity is selected in this storage.
bool RDocument::hasVariable ( const QString &  key) const

Returns
True if the given variable exists in this storage.
bool RDocument::hasView ( const QString &  viewName) const

void RDocument::init ( )
void RDocument::initLinetypes ( RTransaction transaction = NULL)
bool RDocument::isBlockFrozen ( RBlock::Id  blockId) const

bool RDocument::isByBlock ( RLinetype::Id  linetypeId) const
bool RDocument::isByLayer ( RLinetype::Id  linetypeId) const
bool RDocument::isEntityEditable ( REntity::Id  entityId) const
bool RDocument::isEntityLayerFrozen ( REntity::Id  entityId) const
bool RDocument::isLayerFrozen ( RLayer::Id  layerId) const

Returns
True if this layer or one of its parent layers are frozen.
bool RDocument::isLayerLocked ( RLayer::Id  layerId) const

bool RDocument::isMetric ( ) const
bool RDocument::isModified ( ) const

Returns
True if the document has unsaved changes.
bool RDocument::isParentLayerFrozen ( RLayer::Id  layerId) const

Returns
True if a parent layer of the given layer is frozen.
bool RDocument::isParentLayerLocked ( RLayer::Id  layerId) const

Returns
True if a parent layer of the given layer is locked.
bool RDocument::isRedoAvailable ( ) const
bool RDocument::isSelected ( REntity::Id  entityId)

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

Returns
A set of all block reference entity IDs.
QSet< RBlock::Id > RDocument::queryAllBlocks ( ) const

Returns
A set of all block IDs of the document.
QSet< REntity::Id > RDocument::queryAllEntities ( bool  undone = false,
bool  allBlocks = false,
RS::EntityType  type = RS::EntityAll 
) 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< REntity::Id > RDocument::queryAllEntities ( bool  undone,
bool  allBlocks,
QList< RS::EntityType types 
) const

Returns
A set of all entity IDs of the document.
QSet< RLayer::Id > RDocument::queryAllLayers ( ) const

Queries all layers of this document.

Returns
Set of layer IDs.
QSet< RBlock::Id > RDocument::queryAllLayoutBlocks ( ) const

Returns
A set of all block IDs of layout blocks of the document.
QSet< RLinetype::Id > RDocument::queryAllLinetypes ( ) const

Returns
A set of all linetype IDs of the document.
QSet< RObject::Id > RDocument::queryAllObjects ( ) const

Queries all objects of this document.

Returns
Set of object IDs.
QSet< RUcs::Id > RDocument::queryAllUcs ( ) const

Queries all UCSs of this document.

Returns
Set of UCS IDs.
QSet< RView::Id > RDocument::queryAllViews ( ) const

Returns
A set of all view IDs of the document.
QSet< REntity::Id > RDocument::queryAllVisibleEntities ( ) const

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

Queries the block with the given ID.

Returns
Pointer to the block or NULL.
QSharedPointer< RBlock > RDocument::queryBlock ( const QString &  blockName) const

Queries the block with the given name.

Returns
Pointer to the block or NULL.
QSharedPointer< RBlock > RDocument::queryBlockDirect ( RBlock::Id  blockId) 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.
QSharedPointer< RBlock > RDocument::queryBlockDirect ( const QString &  blockName) 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.
QSet< REntity::Id > RDocument::queryBlockEntities ( RBlock::Id  blockId) const

Returns
A set of all entity IDs that are part of the given block.
QSet< REntity::Id > RDocument::queryBlockReferences ( RBlock::Id  blockId) const

Returns
A set of all block reference entity IDs that reference the given block.
QSet< REntity::Id > RDocument::queryChildEntities ( REntity::Id  parentId,
RS::EntityType  type = RS::EntityAll 
) 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 
)

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

Parameters
wcsPositionThe position to which the entity has to be close (2d).
rangeThe range in which to search.
REntity::Id RDocument::queryClosestXY ( QSet< REntity::Id > &  candidates,
const RVector wcsPosition,
double  range,
bool  draft,
double  strictRange = RMAXDOUBLE 
)

Queries the entity that is closest to the given position wcsPosition.

Only entities in the given set of candidates are considered. candidates is usually the result of an approximate spatial index query.

Parameters
candidatesSets of candidates to consider.
wcsPosition
rangeMaximum distance between position and entity.
QSet< REntity::Id > RDocument::queryContainedEntities ( const RBox box)

Queries all entities which are completely inside the given box.

Parameters
boxQuery box.
resultSet of IDs of entities that are completely inside the given area.
QSet< REntity::Id > RDocument::queryContainedEntitiesXY ( const RBox box)
QSharedPointer< RBlock > RDocument::queryCurrentBlock ( )

QSharedPointer< RLayer > RDocument::queryCurrentLayer ( )

QSharedPointer< RView > RDocument::queryCurrentView ( )

QSharedPointer< RDocumentVariables > RDocument::queryDocumentVariables ( ) const
QSharedPointer< RDocumentVariables > RDocument::queryDocumentVariablesDirect ( ) const
QSharedPointer< REntity > RDocument::queryEntity ( REntity::Id  entityId) 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 ( REntity::Id  entityId) 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 ( )
QSet< REntity::Id > RDocument::queryIntersectedEntitiesXY ( const RBox box,
bool  checkBoundingBoxOnly = false,
bool  includeLockedLayers = true,
RBlock::Id  blockId = RBlock::INVALID_ID,
const QList< RS::EntityType > &  filter = RDEFAULT_QLIST_RS_ENTITYTYPE,
bool  selectedOnly = false 
)
QMap< REntity::Id, QSet< int > > RDocument::queryIntersectedShapesXY ( const RBox box,
bool  checkBoundingBoxOnly = false,
bool  includeLockedLayers = true,
RBlock::Id  blockId = RBlock::INVALID_ID,
const QList< RS::EntityType > &  filter = RDEFAULT_QLIST_RS_ENTITYTYPE,
bool  selectedOnly = false 
)
QSharedPointer< RLayer > RDocument::queryLayer ( RLayer::Id  layerId) const

Queries the layer with the given ID.

Returns
Pointer to the layer or NULL.
QSharedPointer< RLayer > RDocument::queryLayer ( const QString &  layerName) const

Queries the layer with the given name.

Returns
Pointer to the layer or NULL.
QSet< REntity::Id > RDocument::queryLayerBlockEntities ( RLayer::Id  layerId,
RBlock::Id  blockId 
) const

QSharedPointer< RLayer > RDocument::queryLayerDirect ( RLayer::Id  layerId) 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 ( RLayer::Id  layerId,
bool  allBlocks = false 
) const

Returns
A set of all entity IDs on the given layer.
QSharedPointer< RLayout > RDocument::queryLayout ( RLayout::Id  layoutId) const

Queries the layout with the given ID.

Returns
Pointer to the layout or NULL.
QSharedPointer< RLayout > RDocument::queryLayout ( const QString &  layoutName) const

Queries the layout with the given name.

Returns
Pointer to the layout or NULL.
QSharedPointer< RLayout > RDocument::queryLayoutDirect ( RLayout::Id  layoutId) 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 ( RLinetype::Id  linetypeId) const

Queries the linetype with the given ID.

Returns
Pointer to the linetype or NULL.
QSharedPointer< RLinetype > RDocument::queryLinetype ( const QString &  linetypeName) const

Queries the linetype with the given name.

Returns
Pointer to the linetype or NULL.
QSharedPointer< RObject > RDocument::queryObject ( RObject::Id  objectId) 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
QSharedPointer< RObject > RDocument::queryObjectDirect ( RObject::Id  objectId) 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 ( )
QSet< REntity::Id > RDocument::querySelectedEntities ( )

Queries all selected entities.

Returns
Set of IDs of all selected entities.
QSharedPointer< RUcs > RDocument::queryUcs ( RUcs::Id  ucsId) const

Queries the UCS with the given ID.

Returns
Pointer to the UCS or NULL.
QSharedPointer< RUcs > RDocument::queryUcs ( const QString &  ucsName) const

Queries the UCS with the given name.

Returns
Pointer to the UCS or NULL.
QSharedPointer< RView > RDocument::queryView ( RView::Id  viewId) const

Queries the view with the given ID.

Returns
Pointer to the view or NULL.
QSharedPointer< RView > RDocument::queryView ( const QString &  viewName) const

Queries the view with the given name.

Returns
Pointer to the view or NULL.
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 ( RBlock::Id  blockId)
void RDocument::removeFromSpatialIndex ( QSharedPointer< REntity entity,
const QList< RBox > &  boundingBoxes = RDEFAULT_QLIST_RBOX 
)
virtual
void RDocument::removeVariable ( const QString &  key)

Removes the custom variable with the given key.

void RDocument::resetTransactionStack ( )
void RDocument::selectAllEntites ( QSet< REntity::Id > *  affectedEntities = NULL)

Selects all not selected entities.

void RDocument::selectEntities ( const QSet< REntity::Id > &  entityIds,
bool  add = false,
QSet< REntity::Id > *  affectedEntities = NULL 
)

Selects all entities with the given IDs.

Todo:
refactoring to operation
Parameters
addTrue to add the entities to the current selection. False to replace the current selection with the new entities.
affectedOptional 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 ( REntity::Id  entityId,
bool  add = false,
QSet< REntity::Id > *  affectedEntities = NULL 
)

Selects the entity with the given ID.

Todo:
refactoring to operation
Parameters
addTrue to add the entity to the current selection. False to replace the current selection with the given entity.
affectedOptional 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::setCurrentBlock ( RBlock::Id  blockId)
void RDocument::setCurrentBlock ( const QString &  blockName)
void RDocument::setCurrentColor ( const RColor color)

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

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

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

void RDocument::setCurrentLinetype ( const QString &  name)

void RDocument::setCurrentLinetypePattern ( const RLinetypePattern p)

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

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

void RDocument::setCurrentView ( const QString &  viewName)

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

void RDocument::setFileName ( const QString &  fn)
void RDocument::setFileVersion ( const QString &  fv)
void RDocument::setKnownVariable ( RS::KnownVariable  key,
const QVariant &  value,
RTransaction transaction = NULL 
)

Sets a known DXF/DWG variable for this document.

Parameters
keyVariable key (see DXF reference)
valueNew value of the variable.
transactionRTransaction 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
keyVariable key (see DXF reference)
valueNew value of the variable.
transactionRTransaction to use for the change or NULL (default) to create a transaction on the fly.
void RDocument::setLinearFormat ( RS::LinearFormat  f)
void RDocument::setLinetypeScale ( double  v,
RTransaction transaction = NULL 
)

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

Parameters
transactionTransaction to use for the modification or NULL to create a local transaction (default).
void RDocument::setMeasurement ( RS::Measurement  m,
RTransaction transaction = NULL 
)
void RDocument::setModified ( bool  m)

Resets the modified flag.

Modification time is stored.

void RDocument::setUnit ( RS::Unit  unit,
RTransaction transaction = NULL 
)
void RDocument::setVariable ( const QString &  key,
const QVariant &  value,
bool  overwrite = true 
)

Sets a custom variable in the context of this document.

Parameters
keyVariable key (name)
valueVariable value
overwriteTrue to overwrite an existing variable with the same key (default)
bool RDocument::showLeadingZeroes ( )
bool RDocument::showLeadingZeroesAngle ( )
bool RDocument::showTrailingZeroes ( )
bool RDocument::showTrailingZeroesAngle ( )
void RDocument::startTransactionGroup ( )

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::updateAllEntities ( )

Friends And Related Function Documentation

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

Stream operator for QDebug.

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

Member Data Documentation

RDocument * RDocument::clipboard = NULL
staticprotected

Copyright (c) 2011-2016 by Andrew Mustun.

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::disableSpatialIndicesByBlock
private
QString RDocument::fileName
private
QString RDocument::fileVersion
private
RLinetype::Id RDocument::linetypeByBlockId
private
RLinetype::Id RDocument::linetypeByLayerId
private
RSpatialIndex& RDocument::spatialIndex
private
QMap<RBlock::Id, RSpatialIndex*> RDocument::spatialIndicesByBlock
private
RStorage& RDocument::storage
private
RTransactionStack RDocument::transactionStack
private

The documentation for this class was generated from the following files: