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