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; }
63 Vector Vect(void) { return Vector(p[0], p[1]); }
64 Vector Unit(void) { return Vector(p[0], p[1]).Unit(); }
65 double Length(void) { return Vector(p[0], p[1]).Magnitude(); }
71 Circle(): type(OTCircle), id(Global::objectID++) {}
72 Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = LSSolid):
73 type(OTCircle), id(Global::objectID++), layer(0), color(c), thickness(th),
74 style(l), selected(false), hovered(false), hitObject(false)
75 { p[0] = pt1; radius[0] = r; hitPoint[0] = hitPoint[1] = false; }
81 Ellipse(): type(OTEllipse), id(Global::objectID++) {}
82 Ellipse(Vector pt1, Vector pt2, double r1, double r2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
83 type(OTEllipse), id(Global::objectID++), layer(0), color(c), thickness(th),
84 style(l), selected(false), hovered(false), hitObject(false)
85 { p[0] = pt1; p[1] = pt2; radius[0] = r1; radius[1] = r2; hitPoint[0] = hitPoint[1] = false; }
91 Arc(): type(OTArc), id(Global::objectID++) {}
92 Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
93 type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th),
94 style(l), selected(false), hovered(false), hitObject(false)
95 { p[0] = pt1; radius[0] = r; angle[0] = a1, angle[1] = a2; hitPoint[0] = hitPoint[1] = hitPoint[2] = false; }
102 Point lp[2]; // Line point, the actual dimension line
103 Object * obj[2]; // Pointer to attached objects (circle, lines for angle)
105 Dimension(): type(OTDimension), id(Global::objectID++), selected(false),
106 hovered(false), hitObject(false)
107 { hitPoint[0] = hitPoint[1] = hitPoint[2] = hitPoint[3] = hitPoint[4] = false; }
108 Dimension(Vector pt1, Vector pt2, DimensionType dt = DTLinear, double offs = 0, float th = 1.0, uint32_t c = 0x0000FF, int l = LSSolid):
109 type(OTDimension), id(Global::objectID++), layer(0), color(c),
110 thickness(th), style(l), selected(false), hovered(false),
111 hitObject(false), subtype(dt), offset(offs)
112 { p[0] = pt1; p[1] = pt2; hitPoint[0] = hitPoint[1] = hitPoint[2] = hitPoint[3] = hitPoint[4] = false; }
121 Text(): type(OTText), id(Global::objectID++) {}
122 Text(Vector pt1, const char * str, float th = 10.0, uint32_t c = 0):
123 type(OTText), id(Global::objectID++), layer(0), color(c), thickness(th),
124 style(LSSolid), selected(false), hovered(false), hitObject(false),
125 measured(false), s(str) { p[0] = pt1; angle[0] = 0; }
132 Polygon(): type(OTPolygon), id(Global::objectID++) {}
141 Polyline(): type(OTPolyline), id(Global::objectID++), selected(false), hovered(false), hitObject(false), clicked(NULL) {}
142 void Add(void * obj) { objects.push_back(obj); }
143 void Add(VPVector objs) { objects.insert(objects.end(), objs.begin(), objs.end()); }
149 Spline(): type(OTSpline), id(Global::objectID++) {}
159 int baseUnit; // Type of BasicUnit as seen above
160 int unitStyle; // 0 = decimal, 1 = fractional
161 int decimalPrecision; // 0-5, which, +1, is # of decimal places
162 int fractionalPrecision; // 0-5, which, +1, is 1/(2^n)
164 Container(bool tl = false): type(OTContainer), id(Global::objectID++), selected(false), hovered(false), hitObject(false), topLevel(tl), clicked(NULL), baseUnit(0), unitStyle(0), decimalPrecision(3), fractionalPrecision(4) {}
165 void Add(void * obj) { objects.push_back(obj); }
166 void Add(VPVector objs) { objects.insert(objects.end(), objs.begin(), objs.end()); }
167 // void DeleteContents(void) {}
168 /* void DeleteContents(Container * c)
170 std::vector<void *>::iterator i;
172 for(i=c->objects.begin(); i!=c->objects.end(); i++)
174 Object * obj = (Object *)(*i);
176 if (obj->type == OTContainer)
177 DeleteContainer((Container *)obj);
184 #endif // __STRUCTS_H__