11 enum ObjectType { OTNone = 0, OTLine, OTCircle, OTEllipse, OTArc, OTPolygon, OTDimension, OTSpline, OTText, OTContainer, OTPolyline, OTCount };
13 enum DimensionType { DTLinear = 0, DTLinearVert, DTLinearHorz, DTRadial, DTDiametric, DTCircumferential, DTAngular, DTLeader, DTCount };
15 enum ToolType { TTNone, TTLine, TTCircle, TTEllipse, TTArc, TTDimension, TTText, TTPolygon, TTSpline, TTRotate, TTMirror, TTTrim, TTTriangulate, TTDelete, TTParallel };
17 enum ToolState { TSNone, TSPoint1, TSPoint2, TSPoint3, TSPoint4, TSDone };
19 enum BasicUnit { BUInch = 0, BUFoot, BUYard, BUMile, BUMM, BUCM, BUM, BUKM, BUCount };
21 const char objName[OTCount][16] = {
22 "None", "Line", "Circle", "Ellipse", "Arc", "Polygon", "Dimension",
23 "Spline", "Text", "Container"
25 const char dimName[DTCount][32] = {
26 "Linear", "Vertical", "Horizontal", "Radial", "Diametric",
27 "Circumferential", "Angular", "Leader"
30 const char buShortName[BUCount][8] = {
31 "in", "ft", "yd", "mi", "mm", "cm", "m", "km"
34 const double buInInches[BUCount] = { 1.0, 12.0, 36.0, 1.0/25.4, 1.0/2.54, 1.0/0.0254, 1.0/0.0000254 };
36 #define OBJECT_COMMON \
59 Line(): type(OTLine), id(Global::objectID++), selected(false), hovered(false), hitObject(false) { hitPoint[0] = hitPoint[1] = false; }
60 Line(Vector pt1, Vector pt2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
61 type(OTLine), id(Global::objectID++), layer(0), color(c), thickness(th),
62 style(l), selected(false), hovered(false), hitObject(false) { p[0] = pt1; p[1] = pt2; hitPoint[0] = hitPoint[1] = false; }
68 Circle(): type(OTCircle), id(Global::objectID++) {}
69 Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = LSSolid):
70 type(OTCircle), id(Global::objectID++), layer(0), color(c), thickness(th),
71 style(l), selected(false), hovered(false), hitObject(false)
72 { p[0] = pt1; radius[0] = r; hitPoint[0] = hitPoint[1] = false; }
78 Ellipse(): type(OTEllipse), id(Global::objectID++) {}
79 Ellipse(Vector pt1, Vector pt2, double r1, double r2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
80 type(OTEllipse), id(Global::objectID++), layer(0), color(c), thickness(th),
81 style(l), selected(false), hovered(false), hitObject(false)
82 { p[0] = pt1; p[1] = pt2; radius[0] = r1; radius[1] = r2; hitPoint[0] = hitPoint[1] = false; }
88 Arc(): type(OTArc), id(Global::objectID++) {}
89 Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
90 type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th),
91 style(l), selected(false), hovered(false), hitObject(false)
92 { p[0] = pt1; radius[0] = r; angle[0] = a1, angle[1] = a2; hitPoint[0] = hitPoint[1] = hitPoint[2] = false; }
99 Point lp[2]; // Line point, the actual dimension line
100 Object * obj[2]; // Pointer to attached objects (circle, lines for angle)
102 Dimension(): type(OTDimension), id(Global::objectID++), selected(false),
103 hovered(false), hitObject(false)
104 { hitPoint[0] = hitPoint[1] = hitPoint[2] = hitPoint[3] = hitPoint[4] = false; }
105 Dimension(Vector pt1, Vector pt2, DimensionType dt = DTLinear, double offs = 0, float th = 1.0, uint32_t c = 0x0000FF, int l = LSSolid):
106 type(OTDimension), id(Global::objectID++), layer(0), color(c),
107 thickness(th), style(l), selected(false), hovered(false),
108 hitObject(false), subtype(dt), offset(offs)
109 { p[0] = pt1; p[1] = pt2; hitPoint[0] = hitPoint[1] = hitPoint[2] = hitPoint[3] = hitPoint[4] = false; }
118 Text(): type(OTText), id(Global::objectID++) {}
119 Text(Vector pt1, char * str, float th = 10.0, uint32_t c = 0):
120 type(OTText), id(Global::objectID++), layer(0), color(c), thickness(th),
121 style(LSSolid), selected(false), hovered(false), hitObject(false),
122 measured(false), s(str) { p[0] = pt1; angle[0] = 0; }
129 Polygon(): type(OTPolygon), id(Global::objectID++) {}
138 Polyline(): type(OTPolyline), id(Global::objectID++), selected(false), hovered(false), hitObject(false), clicked(NULL) {}
139 void Add(void * obj) { objects.push_back(obj); }
140 void Add(VPVector objs) { objects.insert(objects.end(), objs.begin(), objs.end()); }
146 Spline(): type(OTSpline), id(Global::objectID++) {}
156 Container(bool tl = false): type(OTContainer), id(Global::objectID++), selected(false), hovered(false), hitObject(false), topLevel(tl), clicked(NULL) {}
157 void Add(void * obj) { objects.push_back(obj); }
158 void Add(VPVector objs) { objects.insert(objects.end(), objs.begin(), objs.end()); }
159 // void DeleteContents(void) {}
160 /* void DeleteContents(Container * c)
162 std::vector<void *>::iterator i;
164 for(i=c->objects.begin(); i!=c->objects.end(); i++)
166 Object * obj = (Object *)(*i);
168 if (obj->type == OTContainer)
169 DeleteContainer((Container *)obj);
176 #endif // __STRUCTS_H__