26 #include <QSharedPointer>
45 #ifndef RDEFAULT_QVARIANT
46 #define RDEFAULT_QVARIANT QVariant()
49 #ifndef RDEFAULT_QLIST_RBOX
50 #define RDEFAULT_QLIST_RBOX QList<RBox>()
54 #define RDEFAULT_MIN1 -1
57 #define RDEFAULT_QLIST_RS_ENTITYTYPE QList<RS::EntityType>()
77 void init(
bool beforeLoad=
false);
79 QList<QSharedPointer<RObject> > getDefaultLinetypes();
89 void clear(
bool beforeLoad=
false);
96 bool includeLockedLayers =
true,
97 bool selectedOnly =
false
100 QSet<REntity::Id>& candidates,
107 QSet<RObject::Id> queryAllObjects()
const;
108 QSet<RObject::Id> querySelectedLayers()
const;
109 QSet<REntity::Id> queryAllVisibleEntities()
const;
111 QSet<REntity::Id> queryAllEntities(
bool undone,
bool allBlocks, QList<RS::EntityType> types)
const;
112 QSet<REntity::Id> queryWorkingSetEntities()
const;
113 QSet<RUcs::Id> queryAllUcs()
const;
114 QSet<RLayer::Id> queryAllLayers()
const;
115 QSet<RLayerState::Id> queryAllLayerStates()
const;
116 QSet<RBlock::Id> queryAllBlocks()
const;
117 QSet<RBlock::Id> queryAllLayoutBlocks(
bool includeModelSpace =
false)
const;
118 QSet<RBlock::Id> queryAllLayouts()
const;
119 QSet<RView::Id> queryAllViews()
const;
120 QSet<RLinetype::Id> queryAllLinetypes()
const;
122 QSet<REntity::Id> queryLayerEntities(
RLayer::Id layerId,
bool allBlocks =
false)
const;
123 bool hasBlockEntities(
RBlock::Id blockId)
const;
124 QSet<REntity::Id> queryBlockEntities(
RBlock::Id blockId)
const;
128 QSet<REntity::Id> queryBlockReferences(
RBlock::Id blockId)
const;
129 QSet<REntity::Id> queryAllBlockReferences()
const;
130 QSet<REntity::Id> queryAllViewports()
const;
132 QSet<REntity::Id> queryContainedEntities(
const RBox& box)
const;
134 QSet<REntity::Id> queryInfiniteEntities()
const;
136 QSet<REntity::Id> queryIntersectedEntitiesXYFast(
const RBox& box);
137 QSet<REntity::Id> queryIntersectedShapesXYFast(
const RBox& box,
bool noInfiniteEntities =
false);
139 QSet<REntity::Id> queryIntersectedEntitiesXY(
const RBox& box,
140 bool checkBoundingBoxOnly=
false,
141 bool includeLockedLayers=
true,
144 bool selectedOnly =
false,
147 QMap<REntity::Id, QSet<int> > queryIntersectedShapesXY(
const RBox& box,
148 bool checkBoundingBoxOnly=
false,
149 bool includeLockedLayers=
true,
152 bool selectedOnly =
false,
155 QSet<REntity::Id> queryContainedEntitiesXY(
const RBox& box)
const;
157 QSet<REntity::Id> querySelectedEntities()
const;
161 QSet<RObject::Id> queryPropertyEditorObjects();
163 QSharedPointer<RDocumentVariables> queryDocumentVariables()
const;
164 QSharedPointer<RDocumentVariables> queryDocumentVariablesDirect()
const;
165 QSharedPointer<RObject> queryObject(
RObject::Id objectId)
const;
166 QSharedPointer<RObject> queryObjectDirect(
RObject::Id objectId)
const;
167 QSharedPointer<RObject> queryObjectByHandle(
RObject::Handle objectHandle)
const;
168 QSharedPointer<REntity> queryEntity(
REntity::Id entityId)
const;
169 QSharedPointer<REntity> queryEntityDirect(
REntity::Id entityId)
const;
170 QSharedPointer<REntity> queryVisibleEntityDirect(
REntity::Id entityId)
const;
171 QSharedPointer<RUcs> queryUcs(
RUcs::Id ucsId)
const;
172 QSharedPointer<RUcs> queryUcs(
const QString& ucsName)
const;
173 QSharedPointer<RLayer> queryLayer(
RLayer::Id layerId)
const;
174 QSharedPointer<RLayer> queryLayerDirect(
RLayer::Id layerId)
const;
175 QSharedPointer<RLayer> queryLayer(
const QString& layerName)
const;
176 QSharedPointer<RLayerState> queryLayerState(
RLayerState::Id layerStateId)
const;
177 QSharedPointer<RLayerState> queryLayerStateDirect(
RLayerState::Id layerStateId)
const;
178 QSharedPointer<RLayerState> queryLayerState(
const QString& layerStateName)
const;
179 QSharedPointer<RLayout> queryLayout(
RLayout::Id layoutId)
const;
180 QSharedPointer<RLayout> queryLayoutDirect(
RLayout::Id layoutId)
const;
181 QSharedPointer<RLayout> queryLayout(
const QString& layoutName)
const;
182 QSharedPointer<RBlock> queryBlock(
RBlock::Id blockId)
const;
183 QSharedPointer<RBlock> queryBlockDirect(
RBlock::Id blockId)
const;
184 QSharedPointer<RBlock> queryBlockDirect(
const QString& blockName)
const;
185 QSharedPointer<RBlock> queryBlock(
const QString& blockName)
const;
186 QSharedPointer<RView> queryView(
RView::Id viewId)
const;
187 QSharedPointer<RView> queryView(
const QString& viewName)
const;
188 QSharedPointer<RLinetype> queryLinetype(
RLinetype::Id linetypeId)
const;
189 QSharedPointer<RLinetype> queryLinetype(
const QString& linetypeName)
const;
191 int countSelectedEntities()
const;
194 QSet<REntity::Id>* affectedEntities=NULL
197 void selectAllEntities(QSet<REntity::Id>* affectedEntities = NULL);
202 QSet<REntity::Id>* affectedEntities=NULL
206 QSet<REntity::Id>* affectedEntities=NULL
209 const QSet<REntity::Id>& entityId,
211 QSet<REntity::Id>* affectedEntities=NULL
213 int deselectEntities(
214 const QSet<REntity::Id>& entityId,
215 QSet<REntity::Id>* affectedEntities=NULL
220 bool isLayerLocked(
const RLayer& layer)
const;
221 bool isParentLayerLocked(
RLayer::Id layerId)
const;
222 bool isParentLayerLocked(
const RLayer& layer)
const;
228 bool isLayerOff(
const RLayer& layer)
const;
230 bool isLayerOffOrFrozen(
RLayer::Id layerId)
const;
231 bool isLayerOffOrFrozen(
const RLayer& layer)
const;
234 bool isLayerFrozen(
const RLayer& layer)
const;
235 bool isLayerPlottable(
RLayer::Id layerId)
const;
236 bool isLayerPlottable(
const RLayer& layer)
const;
237 bool isLayerSnappable(
RLayer::Id layerId)
const;
238 bool isLayerSnappable(
const RLayer& layer)
const;
239 bool isParentLayerFrozen(
RLayer::Id layerId)
const;
240 bool isParentLayerFrozen(
const RLayer& layer)
const;
243 bool isEntityLayerFrozen(
REntity::Id entityId)
const;
247 bool isParentLayerSnappable(
RLayer::Id layerId)
const;
248 bool isParentLayerSnappable(
const RLayer& layer)
const;
250 bool isParentLayerPlottable(
RLayer::Id layerId)
const;
251 bool isParentLayerPlottable(
const RLayer& layer)
const;
253 bool hasSelection()
const;
255 RBox getBoundingBox(
bool ignoreHiddenLayers =
true,
bool ignoreEmpty =
false)
const;
256 RBox getSelectionBox()
const;
257 RBox getEntitiesBox(QSet<REntity::Id>& ids)
const;
260 void clearSpatialIndices();
261 virtual void rebuildSpatialIndex();
263 void addToSpatialIndex(QSharedPointer<REntity> entity);
267 void removeBlockFromSpatialIndex(
RBlock::Id blockId);
269 virtual void removeFromSpatialIndex(QSharedPointer<REntity> entity,
const QList<RBox>& boundingBoxes =
RDEFAULT_QLIST_RBOX);
272 void updateAllEntities();
274 QList<RTransaction> undo();
275 QList<RTransaction> redo();
276 bool isUndoAvailable()
const;
277 bool isRedoAvailable()
const;
279 void startTransactionGroup();
280 int getTransactionGroup()
const;
286 autoTransactionGroup = on;
289 return autoTransactionGroup;
292 void resetTransactionStack();
294 void setFileName(
const QString& fn);
295 QString getFileName()
const;
297 void setFileVersion(
const QString& fv);
298 QString getFileVersion()
const;
300 QSharedPointer<RLayer> queryCurrentLayer();
308 QString getCurrentLayerName()
const;
311 RColor getCurrentColor()
const;
317 void setCurrentLinetype(
const QString& name);
322 QSharedPointer<RBlock> queryCurrentBlock();
324 void setCurrentBlock(
const QString& blockName);
326 QString getCurrentBlockName()
const;
330 bool hasCurrentViewport();
331 void unsetCurrentViewport();
337 QSharedPointer<RView> queryCurrentView();
339 void setCurrentView(
const QString& viewName);
342 QString getTempBlockName()
const;
343 QString getBlockName(
RBlock::Id blockId)
const;
344 QString getBlockNameFromLayout(
const QString& layoutName)
const;
345 QString getBlockNameFromLayout(
RLayout::Id layoutId)
const;
347 QList<RBlock::Id> sortBlocks(
const QList<RBlock::Id>& blockIds)
const;
348 QList<RLayer::Id> sortLayers(
const QList<RLayer::Id>& layerIds)
const;
349 QString getLayerName(
RLayer::Id layerId)
const;
352 QSet<QString> getLayerStateNames(
const QString& rxStr =
RDEFAULT_QSTRING)
const;
354 QSet<QString> getViewNames()
const;
356 bool hasLayer(
const QString& layerName)
const;
357 bool hasLayerStates()
const;
358 bool hasLayerState(
const QString& layerStateName)
const;
359 bool hasBlock(
const QString& blockName)
const;
360 bool hasLayout(
const QString& layoutName)
const;
361 bool hasView(
const QString& viewName)
const;
362 bool hasLinetype(
const QString& linetypeName)
const;
364 RLayer::Id getLayerId(
const QString& layerName)
const;
369 RBlock::Id getBlockId(
const QString& blockName)
const;
370 RBlock::Id getBlockIdAuto(
const QString& blockLayoutName)
const;
373 RLinetype::Id getLinetypeId(
const QString& linetypeName)
const;
375 return linetypeByLayerId;
378 return linetypeByBlockId;
381 QString getLinetypeDescription(
RLinetype::Id linetypeId)
const;
383 QSet<QString> getLinetypeNames()
const;
384 QList<RLinetypePattern> getLinetypePatterns()
const;
390 QStringList getVariables()
const;
391 void setVariable(
const QString& key,
const QVariant& value,
bool overwrite=
true);
392 QVariant getVariable(
const QString& key,
const QVariant& defaultValue =
RDEFAULT_QVARIANT,
bool useSettings =
false)
const;
393 bool hasVariable(
const QString& key)
const;
394 void removeVariable(
const QString& key);
406 bool isMetric()
const;
408 void setDimensionFont(
const QString& f,
RTransaction* transaction = NULL);
409 QString getDimensionFont()
const;
411 void setLinetypeScale(
double v,
RTransaction* transaction = NULL);
412 double getLinetypeScale()
const;
414 QString formatLinear(
double value);
415 QString formatAngle(
double value);
419 int getLinearPrecision();
420 bool showLeadingZeroes();
421 bool showTrailingZeroes();
422 bool showLeadingZeroesAngle();
423 bool showTrailingZeroesAngle();
425 int getAnglePrecision();
426 char getDecimalSeparator();
428 bool isModified()
const;
429 QDateTime getLastModifiedDateTime()
const;
430 QString getLastModified()
const;
431 void setModified(
bool m);
433 void copyVariablesFrom(
const RDocument& other);
435 QString addAutoVariable(
double value);
436 QStringList getAutoVariables()
const;
437 QString substituteAutoVariables(
const QString& expression);
438 double eval(
const QString& expression,
bool* ok = NULL);
440 bool isEditingWorkingSet()
const;
441 void setIgnoreWorkingSet(
bool on);