]> Shamusworld >> Repos - architektonas/blob - src/base/rs_graphic.h
Initial import
[architektonas] / src / base / rs_graphic.h
1 #ifndef RS_GRAPHIC_H
2 #define RS_GRAPHIC_H
3
4 #include "rs_blocklist.h"
5 #include "rs_layerlist.h"
6 #include "rs_variabledict.h"
7 #include "rs_document.h"
8 #ifdef RS_CAM
9 #include "rs_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 RS_Graphic: public RS_Document
20 {
21 public:
22     RS_Graphic(RS_EntityContainer * parent = NULL);
23     virtual ~RS_Graphic();
24
25     virtual RS2::EntityType rtti() const;
26     virtual unsigned long int countLayerEntities(RS_Layer * layer);
27     virtual RS_LayerList * getLayerList();
28     virtual RS_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     RS_Layer * layerAt(uint i);
38     void activateLayer(const QString & name);
39     void activateLayer(RS_Layer * layer);
40     RS_Layer * getActiveLayer();
41     virtual void addLayer(RS_Layer * layer);
42     virtual void removeLayer(RS_Layer * layer);
43     virtual void editLayer(RS_Layer * layer, const RS_Layer & source);
44     RS_Layer * findLayer(const QString & name);
45     void toggleLayer(const QString & name);
46     void toggleLayer(RS_Layer * layer);
47     void toggleLayerLock(RS_Layer * layer);
48     void freezeAllLayers(bool freeze);
49     void addLayerListListener(RS_LayerListListener * listener);
50     void removeLayerListListener(RS_LayerListListener * listener);
51
52         // Wrapper for block functions:
53     void clearBlocks();
54     uint countBlocks();
55     RS_Block * blockAt(uint i);
56     void activateBlock(const QString & name);
57     void activateBlock(RS_Block * block);
58     RS_Block * getActiveBlock();
59     virtual bool addBlock(RS_Block * block, bool notify = true);
60     virtual void addBlockNotification();
61     virtual void removeBlock(RS_Block * block);
62     RS_Block * findBlock(const QString & name);
63     QString newBlockName();
64     void toggleBlock(const QString & name);
65     void toggleBlock(RS_Block * block);
66     void freezeAllBlocks(bool freeze);
67     void addBlockListListener(RS_BlockListListener * listener);
68     void removeBlockListListener(RS_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<RS_Variable> & getVariableDict();
83         QMultiHash<QString, RS_Variable *> & getVariableDict();
84
85         RS2::LinearFormat getLinearFormat();
86         int getLinearPrecision();
87         RS2::AngleFormat getAngleFormat();
88         int getAnglePrecision();
89
90         Vector getPaperSize();
91         void setPaperSize(const Vector & s);
92
93         Vector getPaperInsertionBase();
94         void setPaperInsertionBase(const Vector & p);
95
96         RS2::PaperFormat getPaperFormat(bool * landscape);
97         void setPaperFormat(RS2::PaperFormat f, bool landscape);
98
99         double getPaperScale();
100         void setPaperScale(double s);
101
102     virtual void setUnit(RS2::Unit u);
103     virtual RS2::Unit getUnit();
104
105         bool isGridOn();
106         void setGridOn(bool on);
107
108         bool isDraftOn();
109         void setDraftOn(bool on);
110
111         void centerToPage();
112         void fitToPage();
113     virtual bool isModified() const;
114         virtual void setModified(bool m);
115
116 #ifdef RS_CAM
117         RS_CamData & getCamData();
118         void setCamData(const RS_CamData & d);
119 #endif
120
121     friend std::ostream & operator<<(std::ostream & os, RS_Graphic & g);
122
123 private:
124         RS_LayerList layerList;
125         RS_BlockList blockList;
126         RS_VariableDict variableDict;
127 #ifdef RS_CAM
128         RS_CamData camData;
129 #endif
130 };
131
132 #endif