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