Open Source 2D CAD
Go to the documentation of this file.
23 #include "core_global.h"
25 #include <QSharedPointer>
27 #include "RStorage.h"
28 #include "RBlockReferenceEntity.h"
29 #include "RDocumentVariables.h"
38 public:
40  virtual ~RMemoryStorage();
42  virtual void clear();
44  virtual void setCurrentBlock(RBlock::Id blockId);
46  virtual void beginTransaction();
47  virtual void commitTransaction();
48  virtual void rollbackTransaction();
50  //virtual QList<REntity::Id> orderBackToFront(const QSet<REntity::Id>& entityIds);
52  virtual QSet<RObject::Id> queryAllObjects();
53  virtual QSet<REntity::Id> queryAllEntities(bool undone = false, bool allBlocks = false, RS::EntityType type = RS::EntityAll);
54  virtual QSet<RUcs::Id> queryAllUcs();
55  virtual QSet<RLayer::Id> queryAllLayers(bool undone = false);
56  virtual QSet<RBlock::Id> queryAllBlocks(bool undone = false);
57  virtual QSet<RView::Id> queryAllViews(bool undone = false);
58  virtual QSet<RLinetype::Id> queryAllLinetypes();
59  virtual QSet<REntity::Id> queryInfiniteEntities();
60  virtual QSet<REntity::Id> querySelectedEntities() const;
62  virtual QSet<REntity::Id> queryLayerEntities(RLayer::Id layerId, bool allBlocks = false);
63  virtual QSet<REntity::Id> queryBlockEntities(RBlock::Id blockId);
64  virtual QSet<REntity::Id> queryChildEntities(REntity::Id parentId, RS::EntityType type = RS::EntityAll);
65  virtual bool hasChildEntities(REntity::Id parentId);
66  virtual QSet<REntity::Id> queryBlockReferences(RBlock::Id blockId);
67  virtual QSet<REntity::Id> queryAllBlockReferences();
68  //virtual QSet<REntity::Id> queryViewEntities(RView::Id viewId);
70  virtual QSharedPointer<RDocumentVariables> queryDocumentVariables() const;
71  virtual QSharedPointer<RDocumentVariables> queryDocumentVariablesDirect() const;
72  virtual QSharedPointer<RObject> queryObject(RObject::Id objectId) const;
73  virtual QSharedPointer<RObject> queryObjectByHandle(RObject::Handle objectHandle) const;
74  virtual QSharedPointer<RObject> queryObjectByHandleDirect(RObject::Handle objectHandle) const;
75  virtual QSharedPointer<REntity> queryEntity(REntity::Id objectId) const;
76  virtual QSharedPointer<RLayer> queryLayer(RLayer::Id layerId) const;
77  virtual QSharedPointer<RLayer> queryLayer(const QString& layerName) const;
78  virtual QSharedPointer<RBlock> queryBlock(RBlock::Id blockId) const;
79  virtual QSharedPointer<RBlock> queryBlock(const QString& blockName) const;
80  virtual QSharedPointer<RView> queryView(RView::Id viewId) const;
81  virtual QSharedPointer<RView> queryView(const QString& viewName) const;
82  virtual QSharedPointer<RUcs> queryUcs(RUcs::Id ucsId) const;
83  virtual QSharedPointer<RUcs> queryUcs(const QString& ucsName) const;
84  virtual QSharedPointer<RLinetype> queryLinetypeDirect(RLinetype::Id linetypeId) const;
85  virtual QSharedPointer<RLinetype> queryLinetype(RLinetype::Id linetypeId) const;
86  virtual QSharedPointer<RLinetype> queryLinetype(const QString& linetypeName) const;
88  virtual int countSelectedEntities() const;
89  virtual void clearEntitySelection(QSet<REntity::Id>* affectedEntities = NULL);
90  virtual void selectAllEntites(QSet<REntity::Id>* affectedEntities = NULL);
91  virtual void selectEntity(REntity::Id entityId, bool add = false,
92  QSet<REntity::Id>* affectedEntities = NULL);
93  virtual void deselectEntity(REntity::Id entityId,
94  QSet<REntity::Id>* affectedEntities=NULL);
95  virtual void selectEntities(const QSet<REntity::Id>& entityIds,
96  bool add = false,
97  QSet<REntity::Id>* affectedEntities = NULL);
98  virtual bool deselectEntities(const QSet<REntity::Id>& entityIds,
99  QSet<REntity::Id>* affectedEntities = NULL);
100  void setEntitySelected(QSharedPointer<REntity> entity, bool on,
101  QSet<REntity::Id>* affectedEntities = NULL, bool onlyDescend = false);
102  virtual bool isSelected(REntity::Id entityId);
104  virtual bool hasSelection() const;
106  virtual RBox getBoundingBox(bool ignoreHiddenLayers = true, bool ignoreEmpty=false) const;
107  virtual RBox getSelectionBox() const;
109  virtual bool removeObject(QSharedPointer<RObject> object);
110  virtual bool saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion = true, bool keepHandles = false);
111  bool checkRecursion(
112  RBlock::Id blockId, RBlock::Id potentialChildBlockId
113  );
114  virtual bool deleteObject(RObject::Id objectId);
115  virtual void saveTransaction(RTransaction& transaction);
116  virtual void deleteTransactionsFrom(int transactionId);
117  virtual RTransaction getTransaction(int transactionId);
119  virtual void resetTransactionStack();
121  virtual void toggleUndoStatus(QSet<RObject::Id>& objects);
122  virtual void toggleUndoStatus(RObject::Id object);
123  virtual bool setUndoStatus(RObject::Id objectId, bool status);
124  //virtual bool getUndoStatus(RObject::Id objectId) const;
125  virtual int getMaxTransactionId();
127  virtual QStringList getVariables() const;
128  virtual void setVariable(const QString& key, const QVariant& value, bool overwrite = true);
129  virtual QVariant getVariable(const QString& key) const;
131  virtual void setKnownVariable(RS::KnownVariable key, const QVariant& value, RTransaction* transaction = NULL);
132  virtual QVariant getKnownVariable(RS::KnownVariable key) const;
134  virtual QString getLayerName(RLayer::Id layerId) const;
135  virtual QSet<QString> getLayerNames() const;
136  virtual RLayer::Id getLayerId(const QString& layerName) const;
138  virtual QString getBlockName(RBlock::Id blockId) const;
139  virtual QSet<QString> getBlockNames() const;
140  virtual RBlock::Id getBlockId(const QString& blockName) const;
142  virtual QString getViewName(RView::Id viewId) const;
143  virtual QSet<QString> getViewNames() const;
144  virtual RView::Id getViewId(const QString& viewName) const;
146  virtual QString getLinetypeName(RLinetype::Id linetypeId) const;
147  virtual QString getLinetypeDescription(RLinetype::Id linetypeId) const;
148  virtual QString getLinetypeLabel(RLinetype::Id linetypeId) const;
149  virtual QSet<QString> getLinetypeNames() const;
150  virtual QList<RLinetypePattern> getLinetypePatterns() const;
151  virtual RLinetype::Id getLinetypeId(const QString& linetypeName) const;
153  virtual QSharedPointer<RObject> queryObjectDirect(RObject::Id objectId) const;
154  virtual QSharedPointer<REntity> queryEntityDirect(REntity::Id objectId) const;
155  virtual QSharedPointer<RUcs> queryUcsDirect(RUcs::Id ucsId) const;
156  virtual QSharedPointer<RLayer> queryLayerDirect(RLayer::Id layerId) const;
157  virtual QSharedPointer<RBlock> queryBlockDirect(RBlock::Id blockId) const;
159  virtual void setLastTransactionId(int transactionId);
163  virtual void update();
165  //virtual void setUnit(RS::Unit unit, RTransaction* transaction = NULL);
166  //virtual RS::Unit getUnit() const;
168 // virtual void setDimensionFont(const QString& f);
169 // virtual QString getDimensionFont() const;
171 // virtual void setLinetypeScale(double v, RTransaction* transaction);
172 // virtual double getLinetypeScale() const;
174 protected:
177  mutable RBox boundingBox[2][2];
178  mutable bool boundingBoxChanged;
179  //mutable bool boundingBoxIgnoreHiddenLayers;
180  //mutable bool boundingBoxIgnoreEmpty;
183  QHash<RObject::Id, QSharedPointer<RObject> > objectMap;
184  QHash<RObject::Handle, QSharedPointer<RObject> > objectHandleMap;
185  QHash<REntity::Id, QSharedPointer<REntity> > entityMap;
186  QMultiHash<RBlock::Id, QSharedPointer<REntity> > blockEntityMap;
187  QHash<RBlock::Id, QSharedPointer<RBlock> > blockMap;
188  QHash<RLayer::Id, QSharedPointer<RLayer> > layerMap;
189  QHash<RLayer::Id, QSharedPointer<RLinetype> > linetypeMap;
190  QHash<int, RTransaction> transactionMap;
192  // document wide variables are stored as custom properties in this object:
193  QSharedPointer<RDocumentVariables> documentVariables;
195  QHash<QString, QVariant> variables;
196  QMap<QString, QString> variableCaseMap;
197  //QHash<RS::KnownVariable, QVariant> knownVariables;
198  //RS::Unit unit;
199  //QString dimensionFont;
200  //double linetypeScale;
201 };
205 #endif /* RMEMORYSTOARGE_H_ */
virtual RLineweight::Lineweight getMaxLineweight() const =0
Represents a box e.g.
Definition: RBox.h:43
virtual void setVariable(const QString &key, const QVariant &value, bool overwrite=true)=0
virtual RBox getSelectionBox() const =0
virtual void saveTransaction(RTransaction &transaction)=0
Sets the ID of the last created transaction.
int Handle
Definition: RObject.h:55
virtual QSet< REntity::Id > queryInfiniteEntities()=0
virtual QSet< QString > getLayerNames() const =0
virtual bool hasSelection() const =0
virtual QSharedPointer< RObject > queryObjectDirect(RObject::Id objectId) const
Definition: RStorage.h:183
virtual bool removeObject(QSharedPointer< RObject > object)=0
virtual QSet< REntity::Id > queryAllBlockReferences()=0
virtual void selectEntities(const QSet< REntity::Id > &entityIds, bool add=false, QSet< REntity::Id > *affectedEntities=NULL)=0
Selects all entities with the given IDs.
virtual QSet< RLayer::Id > queryAllLayers(bool undone=false)=0
virtual RLinetype::Id getLinetypeId(const QString &linetypeName) const =0
virtual QList< RLinetypePattern > getLinetypePatterns() const =0
virtual QSet< RObject::Id > queryAllObjects()=0
Entity types used for property handling / filtering.
Definition: RS.h:75
virtual RBlock::Id getBlockId(const QString &blockName) const =0
virtual QSet< REntity::Id > queryBlockEntities(RBlock::Id blockId)=0
virtual RTransaction getTransaction(int transactionId)=0
virtual QVariant getKnownVariable(RS::KnownVariable key) const =0
virtual bool hasChildEntities(REntity::Id parentId)=0
virtual QString getLinetypeLabel(RLinetype::Id linetypeId) const =0
Definition: core_global.h:10
virtual QString getLinetypeDescription(RLinetype::Id linetypeId) const =0
virtual void setLastTransactionId(int transactionId)
Sets the ID of the last created transaction.
Definition: RStorage.h:513
virtual QSharedPointer< RUcs > queryUcs(RUcs::Id ucsId) const =0
virtual QSet< QString > getViewNames() const =0
virtual void deselectEntity(REntity::Id entityId, QSet< REntity::Id > *affectedEntities=NULL)=0
Deselects the entity with the given ID.
virtual QSharedPointer< RUcs > queryUcsDirect(RUcs::Id ucsId) const
Definition: RStorage.h:204
int Id
Definition: RObject.h:53
virtual QSet< REntity::Id > queryLayerEntities(RLayer::Id layerId, bool allBlocks=false)=0
QMap< QString, QString > variableCaseMap
Definition: RMemoryStorage.h:196
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RStorage.h:55
virtual QSharedPointer< RLayer > queryLayerDirect(RLayer::Id layerId) const
Definition: RStorage.h:220
Transaction implementation.
Definition: RTransaction.h:70
virtual void resetTransactionStack()=0
virtual bool setUndoStatus(RObject::Id object, bool status)=0
virtual void rollbackTransaction()=0
Rolls the current transaction back in order to cancel it.
virtual QSet< RUcs::Id > queryAllUcs()=0
virtual QSharedPointer< RObject > queryObject(RObject::Id objectId) const =0
QHash< RLayer::Id, QSharedPointer< RLinetype > > linetypeMap
Definition: RMemoryStorage.h:189
QHash< RBlock::Id, QSharedPointer< RBlock > > blockMap
Definition: RMemoryStorage.h:187
virtual bool deleteObject(RObject::Id objectId)=0
Deletes the object with the given ID.
Definition: RLineweight.h:42
bool boundingBoxChanged
Definition: RMemoryStorage.h:178
QSharedPointer< RDocumentVariables > documentVariables
Definition: RMemoryStorage.h:193
virtual RBox getBoundingBox(bool ignoreHiddenLayers=true, bool ignoreEmpty=false) const =0
QHash< RObject::Handle, QSharedPointer< RObject > > objectHandleMap
Definition: RMemoryStorage.h:184
virtual QStringList getVariables() const =0
virtual QString getLinetypeName(RLinetype::Id linetypeId) const =0
virtual int getMaxTransactionId()=0
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RMemoryStorage.h:37
virtual QSet< REntity::Id > querySelectedEntities() const =0
QHash< QString, QVariant > variables
Definition: RMemoryStorage.h:195
virtual void setKnownVariable(RS::KnownVariable key, const QVariant &value, RTransaction *transaction=NULL)=0
virtual void clear()
Resets this storage to its initial, empty state.
Definition: RStorage.cpp:40
virtual QSharedPointer< RObject > queryObjectByHandle(RObject::Handle objectHandle) const =0
virtual QSharedPointer< RView > queryView(RView::Id viewId) const =0
virtual QSharedPointer< RDocumentVariables > queryDocumentVariables() const =0
virtual bool saveObject(QSharedPointer< RObject > object, bool checkBlockRecursion=true, bool keepHandles=false)=0
Saves the given object to the storage.
virtual QSharedPointer< RBlock > queryBlock(RBlock::Id blockId) const =0
virtual void commitTransaction()=0
Commits the current transaction.
virtual QString getBlockName(RBlock::Id blockId) const =0
QHash< RObject::Id, QSharedPointer< RObject > > objectMap
Definition: RMemoryStorage.h:183
Well established document variables.
Definition: RS.h:282
virtual QSharedPointer< REntity > queryEntity(REntity::Id entityId) const =0
virtual void update()
Clear caches:
Definition: RStorage.h:632
virtual void setCurrentBlock(RBlock::Id blockId)
Definition: RStorage.h:281
virtual QSharedPointer< RDocumentVariables > queryDocumentVariablesDirect() const =0
virtual RLayer::Id getLayerId(const QString &layerName) const =0
virtual QSharedPointer< RLayer > queryLayer(RLayer::Id layerId) const =0
virtual void selectEntity(REntity::Id entityId, bool add=false, QSet< REntity::Id > *affectedEntities=NULL)=0
Selects the entity with the given ID.
virtual void toggleUndoStatus(QSet< RObject::Id > &objects)=0
Toggles the current undo status of all given objects.
virtual QSet< RLinetype::Id > queryAllLinetypes()=0
All entities (for filters)
Definition: RS.h:76
virtual QSharedPointer< REntity > queryEntityDirect(REntity::Id entityId) const
Definition: RStorage.h:194
virtual QSharedPointer< RBlock > queryBlockDirect(RBlock::Id blockId) const =0
virtual QSet< QString > getBlockNames() const =0
virtual QString getViewName(RView::Id viewId) const =0
virtual QSet< REntity::Id > queryChildEntities(REntity::Id parentId, RS::EntityType type=RS::EntityAll)=0
virtual QSet< RView::Id > queryAllViews(bool undone=false)=0
virtual void clearEntitySelection(QSet< REntity::Id > *affectedEntities=NULL)=0
Clears the selection status of all entities.
virtual QSharedPointer< RLinetype > queryLinetypeDirect(RLinetype::Id linetypeId) const =0
QMultiHash< RBlock::Id, QSharedPointer< REntity > > blockEntityMap
Definition: RMemoryStorage.h:186
virtual QSet< REntity::Id > queryAllEntities(bool undone=false, bool allBlocks=false, RS::EntityType type=RS::EntityAll)=0
virtual int countSelectedEntities() const
Definition: RStorage.h:368
virtual QSet< QString > getLinetypeNames() const =0
virtual QSet< RBlock::Id > queryAllBlocks(bool undone=false)=0
virtual QString getLayerName(RLayer::Id layerId) const =0
virtual void beginTransaction()=0
Starts a new transaction.
virtual bool isSelected(REntity::Id entityId)
Definition: RStorage.h:438
QHash< int, RTransaction > transactionMap
Definition: RMemoryStorage.h:190
QHash< REntity::Id, QSharedPointer< REntity > > entityMap
Definition: RMemoryStorage.h:185
virtual void deleteTransactionsFrom(int transactionId)=0
Deletes all transactions with IDs from transactionId (inclusive) to the maximum transaction ID...
RLineweight::Lineweight maxLineweight
Definition: RMemoryStorage.h:175
virtual QSharedPointer< RLinetype > queryLinetype(RLinetype::Id linetypeId) const =0
virtual void selectAllEntites(QSet< REntity::Id > *affectedEntities=NULL)=0
Sets the selection status of all entities.
virtual QSet< REntity::Id > queryBlockReferences(RBlock::Id blockId)=0
virtual RView::Id getViewId(const QString &viewName) const =0
QHash< RLayer::Id, QSharedPointer< RLayer > > layerMap
Definition: RMemoryStorage.h:188
virtual QVariant getVariable(const QString &key) const =0
bool inTransaction
Definition: RMemoryStorage.h:182
virtual bool deselectEntities(const QSet< REntity::Id > &entityIds, QSet< REntity::Id > *affectedEntities=NULL)=0
Deselects all entities with the given IDs.