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> queryLinetypeDirect(RLinetype::Id linetypeId) const;
82  virtual QSharedPointer<RLinetype> queryLinetype(RLinetype::Id linetypeId) const;
83  virtual QSharedPointer<RLinetype> queryLinetype(const QString& linetypeName) const;
84 
85  virtual void clearEntitySelection(QSet<REntity::Id>* affectedEntities = NULL);
86  virtual void selectAllEntites(QSet<REntity::Id>* affectedEntities = NULL);
87  virtual void selectEntity(REntity::Id entityId, bool add = false,
88  QSet<REntity::Id>* affectedEntities = NULL);
89  virtual void deselectEntity(REntity::Id entityId,
90  QSet<REntity::Id>* affectedEntities=NULL);
91  virtual void selectEntities(const QSet<REntity::Id>& entityIds,
92  bool add = false,
93  QSet<REntity::Id>* affectedEntities = NULL);
94  virtual void deselectEntities(const QSet<REntity::Id>& entityIds,
95  QSet<REntity::Id>* affectedEntities = NULL);
96  void setEntitySelected(QSharedPointer<REntity> entity, bool on,
97  QSet<REntity::Id>* affectedEntities = NULL, bool onlyDescend = false);
98  virtual bool isSelected(REntity::Id entityId);
99 
100  virtual bool hasSelection() const;
101 
102  virtual RBox getBoundingBox(bool ignoreHiddenLayers = true, bool ignoreEmpty=false) const;
103  virtual RBox getSelectionBox() const;
104 
105  virtual bool removeObject(QSharedPointer<RObject> object);
106  virtual bool saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion = true, bool keepHandles = false);
107  bool checkRecursion(
108  RBlock::Id blockId, RBlock::Id potentialChildBlockId
109  );
110  virtual bool deleteObject(RObject::Id objectId);
111  virtual void saveTransaction(RTransaction& transaction);
112  virtual void deleteTransactionsFrom(int transactionId);
113  virtual RTransaction getTransaction(int transactionId);
114 
115  virtual void resetTransactionStack();
116 
117  virtual void toggleUndoStatus(QSet<RObject::Id>& objects);
118  virtual void toggleUndoStatus(RObject::Id object);
119  virtual bool setUndoStatus(RObject::Id objectId, bool status);
120  //virtual bool getUndoStatus(RObject::Id objectId) const;
121  virtual int getMaxTransactionId();
122 
123  virtual QStringList getVariables() const;
124  virtual void setVariable(const QString& key, const QVariant& value, bool overwrite = true);
125  virtual QVariant getVariable(const QString& key) const;
126 
127  virtual void setKnownVariable(RS::KnownVariable key, const QVariant& value);
128  virtual QVariant getKnownVariable(RS::KnownVariable key) const;
129 
130  virtual QString getLayerName(RLayer::Id layerId) const;
131  virtual QSet<QString> getLayerNames() const;
132  virtual RLayer::Id getLayerId(const QString& layerName) const;
133 
134  virtual QString getBlockName(RBlock::Id blockId) const;
135  virtual QSet<QString> getBlockNames() const;
136  virtual RBlock::Id getBlockId(const QString& blockName) const;
137 
138  virtual QString getViewName(RView::Id viewId) const;
139  virtual QSet<QString> getViewNames() const;
140  virtual RView::Id getViewId(const QString& viewName) const;
141 
142  virtual QString getLinetypeName(RLinetype::Id linetypeId) const;
143  virtual QString getLinetypeDescription(RLinetype::Id linetypeId) const;
144  virtual QString getLinetypeLabel(RLinetype::Id linetypeId) const;
145  virtual QSet<QString> getLinetypeNames() const;
146  virtual QList<RLinetypePattern> getLinetypePatterns() const;
147  virtual RLinetype::Id getLinetypeId(const QString& linetypeName) const;
148 
149  virtual QSharedPointer<RObject> queryObjectDirect(RObject::Id objectId) const;
150  virtual QSharedPointer<REntity> queryEntityDirect(REntity::Id objectId) const;
151  virtual QSharedPointer<RUcs> queryUcsDirect(RUcs::Id ucsId) const;
152  virtual QSharedPointer<RLayer> queryLayerDirect(RLayer::Id layerId) const;
153  virtual QSharedPointer<RBlock> queryBlockDirect(RBlock::Id blockId) const;
154 
155  virtual void setLastTransactionId(int transactionId);
156 
158 
159  virtual void setUnit(RS::Unit unit);
160  virtual RS::Unit getUnit() const;
161 
162  virtual void setDimensionFont(const QString& f);
163  virtual QString getDimensionFont() const;
164 
165  virtual void setLinetypeScale(double v);
166  virtual double getLinetypeScale() const;
167 
168 protected:
169  mutable RBox boundingBox;
171  mutable bool boundingBoxChanged;
172 
174  QHash<RObject::Id, QSharedPointer<RObject> > objectMap;
175  QHash<RObject::Handle, QSharedPointer<RObject> > objectHandleMap;
176  QHash<REntity::Id, QSharedPointer<REntity> > entityMap;
177  QMultiHash<RBlock::Id, QSharedPointer<REntity> > blockEntityMap;
178  QHash<RBlock::Id, QSharedPointer<RBlock> > blockMap;
179  QHash<RLayer::Id, QSharedPointer<RLayer> > layerMap;
180  QHash<RLayer::Id, QSharedPointer<RLinetype> > linetypeMap;
181  QHash<int, RTransaction> transactionMap;
182  QHash<QString, QVariant> variables;
183  QMap<QString, QString> variableCaseMap;
184  QHash<RS::KnownVariable, QVariant> knownVariables;
186  QString dimensionFont;
188 };
189 
191 
192 #endif /* RMEMORYSTOARGE_H_ */