]> Shamusworld >> Repos - architektonas/blob - src/base/drawing.h
Bugfixes related to removing Snapper class.
[architektonas] / src / base / drawing.h
1 #ifndef __GRAPHIC_H__
2 #define __GRAPHIC_H__
3
4 #include "blocklist.h"
5 #include "layerlist.h"
6 #include "variabledict.h"
7 #include "document.h"
8 #ifdef RS_CAM
9 #include "camdata.h"
10 #endif
11
12 //class RS_CamData;
13
14 /**
15  * A graphic document which can contain entities layers and blocks.
16  *
17  * @author Andrew Mustun
18  */
19 class Drawing: public Document
20 {
21         public:
22                 Drawing(EntityContainer * parent = NULL);
23                 virtual ~Drawing();
24
25                 virtual RS2::EntityType rtti() const;
26                 virtual unsigned long int countLayerEntities(Layer * layer);
27                 virtual LayerList * getLayerList();
28                 virtual BlockList * getBlockList();
29                 virtual void newDoc();
30                 virtual bool save();
31                 virtual bool saveAs(const QString& filename, RS2::FormatType type);
32                 virtual bool open(const QString& filename, RS2::FormatType type);
33
34                 // Wrappers for Layer functions:
35                 void clearLayers();
36                 uint countLayers() const;
37                 Layer * layerAt(uint i);
38                 void activateLayer(const QString & name);
39                 void activateLayer(Layer * layer);
40                 Layer * getActiveLayer();
41                 virtual void addLayer(Layer * layer);
42                 virtual void removeLayer(Layer * layer);
43                 virtual void editLayer(Layer * layer, const Layer & source);
44                 Layer * findLayer(const QString & name);
45                 void toggleLayer(const QString & name);
46                 void toggleLayer(Layer * layer);
47                 void toggleLayerLock(Layer * layer);
48                 void freezeAllLayers(bool freeze);
49 //          void addLayerListListener(LayerListListener * listener);
50 //          void removeLayerListListener(LayerListListener * listener);
51
52                 // Wrapper for block functions:
53                 void clearBlocks();
54                 uint countBlocks();
55                 Block * blockAt(uint i);
56                 void activateBlock(const QString & name);
57                 void activateBlock(Block * block);
58                 Block * getActiveBlock();
59                 virtual bool addBlock(Block * block, bool notify = true);
60                 virtual void addBlockNotification();
61                 virtual void removeBlock(Block * block);
62                 Block * findBlock(const QString & name);
63                 QString newBlockName();
64                 void toggleBlock(const QString & name);
65                 void toggleBlock(Block * block);
66                 void freezeAllBlocks(bool freeze);
67 //          void addBlockListListener(BlockListListener * listener);
68 //          void removeBlockListListener(BlockListListener * listener);
69
70                 // Wrappers for variable functions:
71                 void clearVariables();
72                 int countVariables();
73                 void addVariable(const QString & key, const Vector & value, int code);
74                 void addVariable(const QString & key, const QString & value, int code);
75                 void addVariable(const QString & key, int value, int code);
76                 void addVariable(const QString & key, double value, int code);
77                 Vector getVariableVector(const QString & key, const Vector & def);
78                 QString getVariableString(const QString & key, const QString & def);
79                 int getVariableInt(const QString & key, int def);
80                 double getVariableDouble(const QString & key, double def);
81                 void removeVariable(const QString & key);
82         //      Q3Dict<Variable> & getVariableDict();
83                 QMultiHash<QString, Variable *> & getVariableDict();
84
85                 RS2::LinearFormat getLinearFormat();
86                 int getLinearPrecision();
87                 RS2::AngleFormat getAngleFormat();
88                 int getAnglePrecision();
89                 Vector getPaperSize();
90                 void setPaperSize(const Vector & s);
91                 Vector getPaperInsertionBase();
92                 void setPaperInsertionBase(const Vector & p);
93                 RS2::PaperFormat getPaperFormat(bool * landscape);
94                 void setPaperFormat(RS2::PaperFormat f, bool landscape);
95                 double getPaperScale();
96                 void setPaperScale(double s);
97                 virtual void setUnit(RS2::Unit u);
98                 virtual RS2::Unit getUnit();
99                 bool isGridOn();
100                 void setGridOn(bool on);
101                 bool isDraftOn();
102                 void setDraftOn(bool on);
103                 void centerToPage();
104                 void fitToPage();
105                 virtual bool isModified() const;
106                 virtual void setModified(bool m);
107 #ifdef RS_CAM
108                 RS_CamData & getCamData();
109                 void setCamData(const RS_CamData & d);
110 #endif
111
112                 friend std::ostream & operator<<(std::ostream & os, Drawing & g);
113
114         private:
115                 LayerList layerList;
116                 BlockList blockList;
117                 VariableDict variableDict;
118 #ifdef RS_CAM
119                 RS_CamData camData;
120 #endif
121 };
122
123 #endif