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, RS::EntityType type = RS::EntityAll);
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> queryInfiniteEntities();
59  virtual QSet<REntity::Id> querySelectedEntities();
60 
61  virtual QSet<REntity::Id> queryLayerEntities(RLayer::Id layerId, bool allBlocks = false);
62  virtual QSet<REntity::Id> queryBlockEntities(RBlock::Id blockId);
63  virtual QSet<REntity::Id> queryChildEntities(REntity::Id parentId, RS::EntityType type = RS::EntityAll);
64  virtual bool hasChildEntities(REntity::Id parentId);
65  virtual QSet<REntity::Id> queryBlockReferences(RBlock::Id blockId);
66  virtual QSet<REntity::Id> queryAllBlockReferences();
67  //virtual QSet<REntity::Id> queryViewEntities(RView::Id viewId);
68 
69  virtual QSharedPointer<RObject> queryObject(RObject::Id objectId) const;
70  virtual QSharedPointer<RObject> queryObjectByHandle(RObject::Handle objectHandle) const;
71  virtual QSharedPointer<RObject> queryObjectByHandleDirect(RObject::Handle objectHandle) const;
72  virtual QSharedPointer<REntity> queryEntity(REntity::Id objectId) const;
73  virtual QSharedPointer<RLayer> queryLayer(RLayer::Id layerId) const;
74  virtual QSharedPointer<RLayer> queryLayer(const QString& layerName) const;
75  virtual QSharedPointer<RBlock> queryBlock(RBlock::Id blockId) const;
76  virtual QSharedPointer<RBlock> queryBlock(const QString& blockName) const;
77  virtual QSharedPointer<RView> queryView(RView::Id viewId) const;
78  virtual QSharedPointer<RView> queryView(const QString& viewName) const;
79  virtual QSharedPointer<RUcs> queryUcs(RUcs::Id ucsId) const;
80  virtual QSharedPointer<RUcs> queryUcs(const QString& ucsName) const;
81  virtual QSharedPointer<RLinetype> queryLinetype(RLinetype::Id linetypeId) const;
82  virtual QSharedPointer<RLinetype> queryLinetype(const QString& linetypeName) const;
83 
84  virtual void clearEntitySelection(QSet<REntity::Id>* affectedEntities = NULL);
85  virtual void selectAllEntites(QSet<REntity::Id>* affectedEntities = NULL);
86  virtual void selectEntity(REntity::Id entityId, bool add = false,
87  QSet<REntity::Id>* affectedEntities = NULL);
88  virtual void deselectEntity(REntity::Id entityId,
89  QSet<REntity::Id>* affectedEntities=NULL);
90  virtual void selectEntities(const QSet<REntity::Id>& entityIds,
91  bool add = false,
92  QSet<REntity::Id>* affectedEntities = NULL);
93  virtual void deselectEntities(const QSet<REntity::Id>& entityIds,
94  QSet<REntity::Id>* affectedEntities = NULL);
95  void setEntitySelected(QSharedPointer<REntity> entity, bool on,
96  QSet<REntity::Id>* affectedEntities = NULL, bool onlyDescend = false);
97  virtual bool isSelected(REntity::Id entityId);
98 
99  virtual bool hasSelection() const;
100 
101  virtual RBox getBoundingBox(bool includeHiddenLayer = true) const;
102  virtual RBox getSelectionBox() const;
103 
104  virtual bool removeObject(QSharedPointer<RObject> object);
105  virtual bool saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion = true, bool keepHandles = false);
106  bool checkRecursion(
107  RBlock::Id blockId, RBlock::Id potentialChildBlockId
108  );
109  virtual bool deleteObject(RObject::Id objectId);
110  virtual void saveTransaction(RTransaction& transaction);
111  virtual void deleteTransactionsFrom(int transactionId);
112  virtual RTransaction getTransaction(int transactionId);
113 
114  virtual void resetTransactionStack();
115 
116  virtual void toggleUndoStatus(QSet<RObject::Id>& objects);
117  virtual void toggleUndoStatus(RObject::Id object);
118  virtual bool setUndoStatus(RObject::Id objectId, bool status);
119  //virtual bool getUndoStatus(RObject::Id objectId) const;
120  virtual int getMaxTransactionId();
121 
122  virtual QStringList getVariables() const;
123  virtual void setVariable(const QString& key, const QVariant& value, bool overwrite = true);
124  virtual QVariant getVariable(const QString& key) const;
125 
126  virtual void setKnownVariable(RS::KnownVariable key, const QVariant& value);
127  virtual QVariant getKnownVariable(RS::KnownVariable key) const;
128 
129  virtual QString getLayerName(RLayer::Id layerId) const;
130  virtual QSet<QString> getLayerNames() const;
131  virtual RLayer::Id getLayerId(const QString& layerName) const;
132 
133  virtual QString getBlockName(RBlock::Id blockId) const;
134  virtual QSet<QString> getBlockNames() const;
135  virtual RBlock::Id getBlockId(const QString& blockName) const;
136 
137  virtual QString getViewName(RView::Id viewId) const;
138  virtual QSet<QString> getViewNames() const;
139  virtual RView::Id getViewId(const QString& viewName) const;
140 
141  virtual QString getLinetypeName(RLinetype::Id linetypeId) const;
142  virtual QSet<QString> getLinetypeNames() const;
143  virtual RLinetype::Id getLinetypeId(const QString& linetypeName) const;
144 
145  virtual QSharedPointer<RObject> queryObjectDirect(RObject::Id objectId) const;
146  virtual QSharedPointer<REntity> queryEntityDirect(REntity::Id objectId) const;
147  virtual QSharedPointer<RUcs> queryUcsDirect(RUcs::Id ucsId) const;
148  virtual QSharedPointer<RLayer> queryLayerDirect(RLayer::Id layerId) const;
149  virtual QSharedPointer<RBlock> queryBlockDirect(RBlock::Id blockId) const;
150 
151  virtual void setLastTransactionId(int transactionId);
152 
154 
155  virtual void setUnit(RS::Unit unit);
156  virtual RS::Unit getUnit() const;
157 
158  virtual void setDimensionFont(const QString& f);
159  virtual QString getDimensionFont() const;
160 
161  virtual void setLinetypeScale(double v);
162  virtual double getLinetypeScale() const;
163 
164 protected:
165  mutable RBox boundingBox;
167  mutable bool boundingBoxChanged;
168 
170  QHash<RObject::Id, QSharedPointer<RObject> > objectMap;
171  QHash<RObject::Handle, QSharedPointer<RObject> > objectHandleMap;
172  QHash<REntity::Id, QSharedPointer<REntity> > entityMap;
173  QMultiHash<RBlock::Id, QSharedPointer<REntity> > blockEntityMap;
174  QHash<RBlock::Id, QSharedPointer<RBlock> > blockMap;
175  QHash<RLayer::Id, QSharedPointer<RLayer> > layerMap;
176  QHash<int, RTransaction> transactionMap;
177  QHash<QString, QVariant> variables;
178  QMap<QString, QString> variableCaseMap;
179  QHash<RS::KnownVariable, QVariant> knownVariables;
181  QString dimensionFont;
183 };
184 
186 
187 #endif /* RMEMORYSTOARGE_H_ */