]> Shamusworld >> Repos - architektonas/blob - src/structs.h
More polyline upgrading: points and arcs are now editable with the GUI.
[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 ctr, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid);
75         Arc(Vector ctr, double r, Point p1, Point p2, float th = 1.0, uint32_t c = 0, int l = LSSolid);
76         Rect Bounds(void);
77 };
78
79 struct Dimension {
80         OBJECT_COMMON;
81         int subtype;
82         double offset;
83         Point lp[2];            // Line point, the actual dimension line
84         Object * obj[2];        // Pointer to attached objects (circle, lines for angle)
85
86         Dimension();
87         Dimension(Vector pt1, Vector pt2, DimensionType dt = DTLinear, double offs = 0, float th = 1.0, uint32_t c = 0x0000FF, int l = LSSolid);
88 };
89
90 struct Text {
91         OBJECT_COMMON;
92         Rect extents;
93         bool measured;
94         std::string s;
95
96         Text();
97         Text(Vector pt1, const char * str, float th = 10.0, uint32_t c = 0);
98 };
99
100 struct Polyline {
101         OBJECT_COMMON;
102         std::vector<Point> points;
103 //      bool closed; //need this?  could just repeat the endpoint as well...
104 //      Object * clicked;
105         int ptNum;
106
107         Polyline(float th = 1.0, uint32_t c = 0, int l = LSSolid);
108         Polyline(std::vector<Point>, float th = 1.0, uint32_t c = 0, int l = LSSolid);
109         void Add(Point);
110         void Add(std::vector<Point>);
111         Rect Bounds(void);
112         void Translate(Point);
113 };
114
115 struct Spline {
116         OBJECT_COMMON;
117
118         Spline();
119 };
120
121 struct Container {
122         OBJECT_COMMON;
123         VPVector objects;
124         double scale;
125         bool topLevel;
126         Object * clicked;
127
128         int baseUnit;            // Type of BasicUnit as seen above
129         int unitStyle;           // 0 = decimal, 1 = fractional
130         int decimalPrecision;    // 0-5, which, +1, is # of decimal places
131         int fractionalPrecision; // 0-5, which, +1, is 1/(2^n)
132
133         Container(bool tl = false);
134         void Add(void * obj);
135         void Add(VPVector objs);
136 };
137
138 #endif  // __STRUCTS_H__