QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RMemoryStorage.h
Go to the documentation of this file.
1 
20 #ifndef RMEMORYSTORAGE_H_
21 #define RMEMORYSTORAGE_H_
22 
23 #include "core_global.h"
24 
25 #include <QSharedPointer>
26 
27 #include "RStorage.h"
28 #include "RBlockReferenceEntity.h"
29 
37 public:
39  virtual ~RMemoryStorage();
40 
41  virtual void clear();
42 
43  virtual void setCurrentBlock(RBlock::Id blockId);
44 
45  virtual void beginTransaction();
46  virtual void commitTransaction();
47  virtual void rollbackTransaction();
48 
49  //virtual QList<REntity::Id> orderBackToFront(const QSet<REntity::Id>& entityIds);
50 
51  virtual QSet<RObject::Id> queryAllObjects();
52  virtual QSet<REntity::Id> queryAllEntities(bool undone = false, bool allBlocks = false);
53  virtual QSet<RUcs::Id> queryAllUcs();
54  virtual QSet<RLayer::Id> queryAllLayers(bool undone = false);
55  virtual QSet<RBlock::Id> queryAllBlocks(bool undone = false);
56  virtual QSet<RView::Id> queryAllViews(bool undone = false);
57  virtual QSet<RLinetype::Id> queryAllLinetypes();
58  virtual QSet<REntity::Id> querySelectedEntities();
59 
60  virtual QSet<REntity::Id> queryLayerEntities(RLayer::Id layerId, bool allBlocks = false);
61  virtual QSet<REntity::Id> queryBlockEntities(RBlock::Id blockId);
62  virtual QSet<REntity::Id> queryChildEntities(REntity::Id parentId, RS::EntityType type = RS::EntityAll);
63  virtual bool hasChildEntities(REntity::Id parentId);
64  virtual QSet<REntity::Id> queryBlockReferences(RBlock::Id blockId);
65  virtual QSet<REntity::Id> queryAllBlockReferences();
66  //virtual QSet<REntity::Id> queryViewEntities(RView::Id viewId);
67 
68  virtual QSharedPointer<RObject> queryObject(RObject::Id objectId) const;
69  virtual QSharedPointer<RObject> queryObjectByHandle(RObject::Handle objectHandle) const;
70  virtual QSharedPointer<REntity> queryEntity(REntity::Id objectId) const;
71  virtual QSharedPointer<RLayer> queryLayer(RLayer::Id layerId) const;
72  virtual QSharedPointer<RLayer> queryLayer(const QString& layerName) const;
73  virtual QSharedPointer<RBlock> queryBlock(RBlock::Id blockId) const;
74  virtual QSharedPointer<RBlock> queryBlock(const QString& blockName) const;
75  virtual QSharedPointer<RView> queryView(RView::Id viewId) const;
76  virtual QSharedPointer<RView> queryView(const QString& viewName) const;
77  virtual QSharedPointer<RUcs> queryUcs(RUcs::Id ucsId) const;
78  virtual QSharedPointer<RUcs> queryUcs(const QString& ucsName) const;
79  virtual QSharedPointer<RLinetype> queryLinetype(RLinetype::Id linetypeId) const;
80  virtual QSharedPointer<RLinetype> queryLinetype(const QString& linetypeName) const;
81 
82  virtual void clearEntitySelection(QSet<REntity::Id>* affectedEntities = NULL);
83  virtual void selectAllEntites(QSet<REntity::Id>* affectedEntities = NULL);
84  virtual void selectEntity(REntity::Id entityId, bool add = false,
85  QSet<REntity::Id>* affectedEntities = NULL);
86  virtual void deselectEntity(REntity::Id entityId,
87  QSet<REntity::Id>* affectedEntities=NULL);
88  virtual void selectEntities(const QSet<REntity::Id>& entityIds,
89  bool add = false,
90  QSet<REntity::Id>* affectedEntities = NULL);
91  virtual void deselectEntities(const QSet<REntity::Id>& entityIds,
92  QSet<REntity::Id>* affectedEntities = NULL);
93  void setEntitySelected(QSharedPointer<REntity> entity, bool on,
94  QSet<REntity::Id>* affectedEntities = NULL, bool onlyDescend = false);
95  virtual bool isSelected(REntity::Id entityId);
96 
97  virtual bool hasSelection() const;
98 
99  virtual RBox getBoundingBox(bool includeHiddenLayer = true);
100  virtual RBox getSelectionBox();
101 
102  virtual bool removeObject(QSharedPointer<RObject> object);
103  virtual bool saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion = true, bool keepHandles = false);
104  bool checkRecursion(
105  RBlock::Id blockId, RBlock::Id potentialChildBlockId
106  );
107  virtual bool deleteObject(RObject::Id objectId);
108  virtual void saveTransaction(RTransaction& transaction);
109  virtual void deleteTransactionsFrom(int transactionId);
110  virtual RTransaction getTransaction(int transactionId);
111 
112  virtual void resetTransactionStack();
113 
114  virtual void toggleUndoStatus(QSet<RObject::Id>& objects);
115  virtual void toggleUndoStatus(RObject::Id object);
116  virtual bool setUndoStatus(RObject::Id objectId, bool status);
117  //virtual bool getUndoStatus(RObject::Id objectId) const;
118  virtual int getMaxTransactionId();
119 
120  virtual QStringList getVariables() const;
121  virtual void setVariable(const QString& key, const QVariant& value, bool overwrite = true);
122  virtual QVariant getVariable(const QString& key) const;
123 
124  virtual void setKnownVariable(RS::KnownVariable key, const QVariant& value);
125  virtual QVariant getKnownVariable(RS::KnownVariable key) const;
126 
127  virtual QString getLayerName(RLayer::Id layerId) const;
128  virtual QSet<QString> getLayerNames() const;
129  virtual RLayer::Id getLayerId(const QString& layerName) const;
130 
131  virtual QString getBlockName(RBlock::Id blockId) const;
132  virtual QSet<QString> getBlockNames() const;
133  virtual RBlock::Id getBlockId(const QString& blockName) const;
134 
135  virtual QString getViewName(RView::Id viewId) const;
136  virtual QSet<QString> getViewNames() const;
137  virtual RView::Id getViewId(const QString& viewName) const;
138 
139  virtual QString getLinetypeName(RLinetype::Id linetypeId) const;
140  virtual QSet<QString> getLinetypeNames() const;
141  virtual RLinetype::Id getLinetypeId(const QString& linetypeName) const;
142 
143  virtual QSharedPointer<RObject> queryObjectDirect(RObject::Id objectId) const;
144  virtual QSharedPointer<REntity> queryEntityDirect(REntity::Id objectId) const;
145  virtual QSharedPointer<RUcs> queryUcsDirect(RUcs::Id ucsId) const;
146  virtual QSharedPointer<RLayer> queryLayerDirect(RLayer::Id layerId) const;
147  virtual QSharedPointer<RBlock> queryBlockDirect(RBlock::Id blockId) const;
148 
149  virtual void setLastTransactionId(int transactionId);
150 
152 
153  virtual void setUnit(RS::Unit unit);
154  virtual RS::Unit getUnit() const;
155 
156  virtual void setLinetypeScale(double v);
157  virtual double getLinetypeScale() const;
158 
159 protected:
164  QHash<RObject::Id, QSharedPointer<RObject> > objectMap;
165  QHash<REntity::Id, QSharedPointer<REntity> > entityMap;
166  QMultiHash<RBlock::Id, QSharedPointer<REntity> > blockEntityMap;
167  QHash<RBlock::Id, QSharedPointer<RBlock> > blockMap;
168  QHash<RLayer::Id, QSharedPointer<RLayer> > layerMap;
169  QHash<int, RTransaction> transactionMap;
170  QHash<QString, QVariant> variables;
171  QMap<QString, QString> variableCaseMap;
172  QHash<RS::KnownVariable, QVariant> knownVariables;
175 };
176 
178 
179 #endif /* RMEMORYSTOARGE_H_ */