]> Shamusworld >> Repos - architektonas/blob - src/structs.h
398cfa773fd4390c1cb4e83e2afba75ed046eaac
[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, OTLine, OTCircle, OTEllipse, OTArc, OTDimension, OTSpline, OTText, OTContainer };
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, 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
31 struct Line {
32         OBJECT_COMMON;
33
34         Line(): type(OTLine), id(Global::objectID++) {}
35         Line(Vector pt1, Vector pt2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
36                 type(OTLine), id(Global::objectID++), layer(0), color(c), thickness(th),
37                 style(l), selected(false), hovered(false), hitObject(false) { p[0] = pt1; p[1] = pt2; }
38 };
39
40 struct Circle {
41         OBJECT_COMMON;
42         double radius;
43
44         Circle(): type(OTCircle), id(Global::objectID++) {}
45         Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = LSSolid):
46                 type(OTCircle), id(Global::objectID++), layer(0), color(c), thickness(th),
47                 style(l), selected(false), hovered(false), hitObject(false), radius(r) { p[0] = pt1; }
48 };
49
50 struct Ellipse {
51         OBJECT_COMMON;
52         double radius1;
53         double radius2;
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), radius1(r1), radius2(r2) { p[0] = pt1; p[1] = pt2; }
59 };
60
61 struct Arc {
62         OBJECT_COMMON;
63         double radius;
64         double angle1;
65         double angle2;
66
67         Arc(): type(OTArc), id(Global::objectID++) {}
68         Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
69                 type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th),
70                 style(l), selected(false), hovered(false), hitObject(false), radius(r), angle1(a1), angle2(a2) { p[0] = pt1; }
71 };
72
73 struct Dimension {
74         OBJECT_COMMON;
75         int subtype;
76         double offset;
77
78         Dimension(): type(OTDimension), id(Global::objectID++) {}
79         Dimension(Vector pt1, Vector pt2, DimensionType dt = DTLinear, float th = 1.0, uint32_t c = 0x0000FF, int l = LSSolid):
80                 type(OTDimension), id(Global::objectID++), layer(0), color(c), thickness(th),
81                 style(l), selected(false), hovered(false), hitObject(false), subtype(dt) { p[0] = pt1; p[1] = pt2; }
82 };
83
84 struct Text {
85         OBJECT_COMMON;
86         std::string s;
87
88         Text(): type(OTText), id(Global::objectID++) {}
89         Text(Vector pt1, char * str, float th = 10.0, uint32_t c = 0):
90                 type(OTText), id(Global::objectID++), layer(0), color(c), thickness(th),
91                 style(LSSolid), selected(false), hovered(false), hitObject(false), s(str) { p[0] = pt1; }
92 };
93
94 struct Container {
95         OBJECT_COMMON;
96         std::vector<void *> objects;
97         double angle;
98         double scale;
99
100         Container(): type(OTContainer), id(Global::objectID++), selected(false), hovered(false), hitObject(false) {}
101 };
102
103 struct Object {
104         OBJECT_COMMON;
105 };
106
107
108 #endif  // __STRUCTS_H__
109