]> Shamusworld >> Repos - architektonas/blob - src/structs.h
e7e7b30643ffa82465922fe2fdc3fead7d6a61cb
[architektonas] / src / structs.h
1 #ifndef __STRUCTS_H__
2 #define __STRUCTS_H__
3
4 #include <stdint.h>
5 #include <string>
6 #include <vector>
7 #include "global.h"
8 #include "rect.h"
9 #include "vector.h"
10
11 enum ObjectType { OTNone = 0, OTLine, OTCircle, OTEllipse, OTArc, OTDimension, OTPolyline, OTSpline, OTText, OTContainer, OTCount };
12
13 enum DimensionType { DTLinear = 0, DTLinearVert, DTLinearHorz, DTRadial, DTDiametric, DTCircumferential, DTAngular, DTLeader, DTCount };
14
15 enum ToolType { TTNone, TTLine, TTCircle, TTEllipse, TTArc, TTDimension, TTText, TTPolygon, TTSpline, TTRotate, TTMirror, TTTrim, TTTriangulate, TTDelete, TTParallel };
16
17 enum ToolState { TSNone, TSPoint1, TSPoint2, TSPoint3, TSPoint4, TSDone };
18
19 enum BasicUnit { BUInch = 0, BUFoot, BUYard, BUMile, BUMM, BUCM, BUM, BUKM, BUCount };
20
21 extern const char objName[OTCount][16];
22 extern const char dimName[DTCount][32];
23 extern const char buShortName[BUCount][8];
24 extern const double buInInches[BUCount];
25
26 #define OBJECT_COMMON \
27         int type;         \
28         uint32_t id;      \
29         int layer;        \
30         uint32_t color;   \
31         float thickness;  \
32         int style;        \
33         bool selected;    \
34         bool hovered;     \
35         bool hitPoint[5]; \
36         bool hitObject;   \
37         Point p[5];       \
38         double angle[3];  \
39         double radius[2]; \
40         double length;
41
42 struct Object {
43         OBJECT_COMMON;
44 };
45
46 struct Line {
47         OBJECT_COMMON;
48
49         Line();
50         Line(Vector pt1, Vector pt2, float th = 1.0, uint32_t c = 0, int l = LSSolid);
51         Vector Vect(void);
52         Vector Unit(void);
53         double Length(void);
54 };
55
56 struct Circle {
57         OBJECT_COMMON;
58
59         Circle();
60         Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = LSSolid);
61 };
62
63 struct Ellipse {
64         OBJECT_COMMON;
65
66         Ellipse();
67         Ellipse(Vector pt1, Vector pt2, double r1, double r2, float th = 1.0, uint32_t c = 0, int l = LSSolid);
68 };
69
70 struct Arc {
71         OBJECT_COMMON;
72
73         Arc();
74         Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid);
75         Rect Bounds(void);
76 };
77
78 struct Dimension {
79         OBJECT_COMMON;
80         int subtype;
81         double offset;
82         Point lp[2];            // Line point, the actual dimension line
83         Object * obj[2];        // Pointer to attached objects (circle, lines for angle)
84
85         Dimension();
86         Dimension(Vector pt1, Vector pt2, DimensionType dt = DTLinear, double offs = 0, float th = 1.0, uint32_t c = 0x0000FF, int l = LSSolid);
87 };
88
89 struct Text {
90         OBJECT_COMMON;
91         Rect extents;
92         bool measured;
93         std::string s;
94
95         Text();
96         Text(Vector pt1, const char * str, float th = 10.0, uint32_t c = 0);
97 };
98
99 struct Polyline {
100         OBJECT_COMMON;
101         std::vector<Point> points;
102 //      bool closed; //need this?  could just repeat the endpoint as well...
103 //      Object * clicked;
104         int ptNum;
105
106         Polyline(float th = 1.0, uint32_t c = 0, int l = LSSolid);
107         Polyline(std::vector<Point>, float th = 1.0, uint32_t c = 0, int l = LSSolid);
108         void Add(Point);
109         void Add(std::vector<Point>);
110         Rect Bounds(void);
111         void Translate(Point);
112 };
113
114 struct Spline {
115         OBJECT_COMMON;
116
117         Spline();
118 };
119
120 struct Container {
121         OBJECT_COMMON;
122         VPVector objects;
123         double scale;
124         bool topLevel;
125         Object * clicked;
126
127         int baseUnit;            // Type of BasicUnit as seen above
128         int unitStyle;           // 0 = decimal, 1 = fractional
129         int decimalPrecision;    // 0-5, which, +1, is # of decimal places
130         int fractionalPrecision; // 0-5, which, +1, is 1/(2^n)
131
132         Container(bool tl = false);
133         void Add(void * obj);
134         void Add(VPVector objs);
135 };
136
137 #endif  // __STRUCTS_H__