]> Shamusworld >> Repos - architektonas/blob - src/structs.h
Rendering for Line, Circle, and Arc work.
[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, OTObject, OTLine, OTCircle, OTArc, OTDimension, OTEllipse, OTContainer, OTSpline };
11
12 #define OBJECT_COMMON \
13         int type;         \
14         uint32_t id;      \
15         int layer;        \
16         uint32_t color;   \
17         float thickness;  \
18         int style;        \
19         bool selected;
20
21 struct Line {
22         OBJECT_COMMON;
23         Point p1;
24         Point p2;
25
26         Line(): type(OTLine), id(Global::objectID++) {}
27         Line(Vector pt1, Vector pt2, float th = 1.0, uint32_t c = 0, int l = 0):
28                 type(OTLine), id(Global::objectID++), layer(l), color(c), thickness(th),
29                 style(0), selected(false), p1(pt1), p2(pt2) {}
30 };
31
32 struct Circle {
33         OBJECT_COMMON;
34         Point p1;
35         double radius;
36
37         Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = 0):
38                 type(OTCircle), id(Global::objectID++), layer(l), color(c), thickness(th),
39                 style(0), selected(false), p1(pt1), radius(r) {}
40 };
41
42 struct Arc {
43         OBJECT_COMMON;
44         Point p1;
45         double radius;
46         double angle1;
47         double angle2;
48
49         Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = 0):
50                 type(OTArc), id(Global::objectID++), layer(l), color(c), thickness(th),
51                 style(0), selected(false), p1(pt1), radius(r), angle1(a1), angle2(a2) {}
52 };
53
54 struct Text {
55         OBJECT_COMMON;
56         Point p1;
57         std::string s;
58 };
59
60 struct Container {
61         OBJECT_COMMON;
62         Point p1;
63         std::vector<void *> objects;
64         double angle;
65         double scale;
66 };
67
68 struct Dimension {
69         OBJECT_COMMON;
70         int subtype;
71         Point p1;
72         Point p2;
73         double offset;
74 };
75
76 struct Object {
77         OBJECT_COMMON;
78 };
79
80
81 #endif  // __STRUCTS_H__
82