]> Shamusworld >> Repos - architektonas/blob - src/structs.h
bc68adf76801316d1b790aa3d72695b879b0a3c8
[architektonas] / src / structs.h
1 #ifndef __STRUCTS_H__
2 #define __STRUCTS_H__
3
4 #include <stdint.h>
5 #include <vector>
6 #include <string>
7 #include "global.h"
8 #include "vector.h"
9
10 enum ObjectType { OTNone = 0, OTLine, OTCircle, OTEllipse, OTArc, OTPolygon, OTDimension, OTSpline, OTText, OTContainer, OTCount };
11
12 enum DimensionType { DTLinear, DTLinearVert, DTLinearHorz, DTRadial, DTDiametric, DTCircumferential, DTAngular, DTLeader };
13
14 enum ToolType { TTNone, TTLine, TTCircle, TTEllipse, TTArc, TTDimension, TTText, TTPolygon, TTSpline, TTRotate, TTMirror, TTTrim, TTTriangulate, TTDelete };
15
16 enum ToolState { TSNone, TSPoint1, TSPoint2, TSPoint3, TSPoint4, TSDone };
17
18 #define OBJECT_COMMON \
19         int type;         \
20         uint32_t id;      \
21         int layer;        \
22         uint32_t color;   \
23         float thickness;  \
24         int style;        \
25         bool selected;    \
26         bool hovered;     \
27         bool hitPoint[4]; \
28         bool hitObject;   \
29         Point p[4];       \
30         double angle[2];  \
31         double radius[2];
32
33 struct Line {
34         OBJECT_COMMON;
35
36         Line(): type(OTLine), id(Global::objectID++) {}
37         Line(Vector pt1, Vector pt2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
38                 type(OTLine), id(Global::objectID++), layer(0), color(c), thickness(th),
39                 style(l), selected(false), hovered(false), hitObject(false) { p[0] = pt1; p[1] = pt2; }
40 };
41
42 struct Circle {
43         OBJECT_COMMON;
44
45         Circle(): type(OTCircle), id(Global::objectID++) {}
46         Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = LSSolid):
47                 type(OTCircle), id(Global::objectID++), layer(0), color(c), thickness(th),
48                 style(l), selected(false), hovered(false), hitObject(false)
49                 { p[0] = pt1; radius[0] = r; }
50 };
51
52 struct Ellipse {
53         OBJECT_COMMON;
54
55         Ellipse(): type(OTEllipse), id(Global::objectID++) {}
56         Ellipse(Vector pt1, Vector pt2, double r1, double r2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
57                 type(OTEllipse), id(Global::objectID++), layer(0), color(c), thickness(th),
58                 style(l), selected(false), hovered(false), hitObject(false)
59                 { p[0] = pt1; p[1] = pt2; radius[0] = r1; radius[1] = r2; }
60 };
61
62 struct Arc {
63         OBJECT_COMMON;
64
65         Arc(): type(OTArc), id(Global::objectID++) {}
66         Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
67                 type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th),
68                 style(l), selected(false), hovered(false), hitObject(false)
69                 { p[0] = pt1; radius[0] = r; angle[0] = a1, angle[1] = a2; }
70 };
71
72 struct Dimension {
73         OBJECT_COMMON;
74         int subtype;
75         double offset;
76
77         Dimension(): type(OTDimension), id(Global::objectID++) {}
78         Dimension(Vector pt1, Vector pt2, DimensionType dt = DTLinear, float th = 1.0, uint32_t c = 0x0000FF, int l = LSSolid):
79                 type(OTDimension), id(Global::objectID++), layer(0), color(c), thickness(th),
80                 style(l), selected(false), hovered(false), hitObject(false), subtype(dt) { p[0] = pt1; p[1] = pt2; }
81 };
82
83 struct Text {
84         OBJECT_COMMON;
85         std::string s;
86
87         Text(): type(OTText), id(Global::objectID++) {}
88         Text(Vector pt1, char * str, float th = 10.0, uint32_t c = 0):
89                 type(OTText), id(Global::objectID++), layer(0), color(c), thickness(th),
90                 style(LSSolid), selected(false), hovered(false), hitObject(false), s(str) { p[0] = pt1; }
91 };
92
93 struct Polygon {
94         OBJECT_COMMON;
95
96         Polygon(): type(OTPolygon), id(Global::objectID++) {}
97 };
98
99 struct Spline {
100         OBJECT_COMMON;
101
102         Spline(): type(OTSpline), id(Global::objectID++) {}
103 };
104
105 struct Container {
106         OBJECT_COMMON;
107         std::vector<void *> objects;
108         double scale;
109         bool topLevel;
110
111         Container(bool tl = false): type(OTContainer), id(Global::objectID++), selected(false), hovered(false), hitObject(false), topLevel(tl) {}
112 //      void DeleteContents(void) {}
113 /*      void DeleteContents(Container * c)
114         {
115                 std::vector<void *>::iterator i;
116
117                 for(i=c->objects.begin(); i!=c->objects.end(); i++)
118                 {
119                         Object * obj = (Object *)(*i);
120
121                         if (obj->type == OTContainer)
122                                 DeleteContainer((Container *)obj);
123
124                         delete *i;
125                 }
126         }*/
127 };
128
129 struct Object {
130         OBJECT_COMMON;
131 };
132
133 #endif  // __STRUCTS_H__
134