]> Shamusworld >> Repos - architektonas/blob - src/structs.h
f1b5ce1cf722dc06b6fd4b4050173f75f3834e17
[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
15 #define OBJECT_COMMON \
16         int type;         \
17         uint32_t id;      \
18         int layer;        \
19         uint32_t color;   \
20         float thickness;  \
21         int style;        \
22         bool selected;    \
23         bool hovered;     \
24         bool hitPoint[4]; \
25         bool hitObject;
26
27 struct Line {
28         OBJECT_COMMON;
29         Point p1;
30         Point p2;
31
32         Line(): type(OTLine), id(Global::objectID++) {}
33         Line(Vector pt1, Vector pt2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
34                 type(OTLine), id(Global::objectID++), layer(0), color(c), thickness(th),
35                 style(l), selected(false), hovered(false), p1(pt1), p2(pt2) {}
36 };
37
38 struct Circle {
39         OBJECT_COMMON;
40         Point p1;
41         double radius;
42
43         Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = LSSolid):
44                 type(OTCircle), id(Global::objectID++), layer(0), color(c), thickness(th),
45                 style(l), selected(false), hovered(false), p1(pt1), radius(r) {}
46 };
47
48 struct Ellipse {
49         OBJECT_COMMON;
50         Point p1;
51         Point p2;
52         double radius1;
53         double radius2;
54
55         Ellipse(Vector pt1, Vector pt2, double r1, double r2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
56                 type(OTEllipse), id(Global::objectID++), layer(0), color(c), thickness(th),
57                 style(l), selected(false), hovered(false), p1(pt1), p2(pt2), radius1(r1), radius2(r2) {}
58 };
59
60 struct Arc {
61         OBJECT_COMMON;
62         Point p1;
63         double radius;
64         double angle1;
65         double angle2;
66
67         Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
68                 type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th),
69                 style(l), selected(false), hovered(false), p1(pt1), radius(r), angle1(a1), angle2(a2) {}
70 };
71
72 struct Dimension {
73         OBJECT_COMMON;
74         int subtype;
75         Point p1;
76         Point p2;
77         double offset;
78
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), subtype(dt), p1(pt1), p2(pt2) {}
82 };
83
84 struct Text {
85         OBJECT_COMMON;
86         Point p1;
87         std::string s;
88
89         Text(Vector pt, 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), p1(pt), s(str) {}
92 };
93
94 struct Container {
95         OBJECT_COMMON;
96         Point p1;
97         std::vector<void *> objects;
98         double angle;
99         double scale;
100
101         Container(): type(OTContainer), id(Global::objectID++), selected(false), hovered(false) {}
102 };
103
104 struct Object {
105         OBJECT_COMMON;
106 };
107
108
109 #endif  // __STRUCTS_H__
110