2 // object.cpp: Base class for all CAD objects
4 // Part of the Architektonas Project
5 // (C) 2011 Underground Software
6 // See the README and GPLv3 files for licensing and warranty information
8 // JLH = James Hammons <jlhamm@acm.org>
11 // --- ---------- ------------------------------------------------------------
12 // JLH 03/22/2011 Created this file
13 // JLH 04/01/2011 Added constructor to allow derived objects to have empty
14 // constructor bodies, added state querying
15 // JLH 04/02/2001 Added static methods for global states (fixed angle, etc)
20 // Initialize static variables
21 bool Object::fixedAngle = false;
22 bool Object::fixedLength = false;
23 QFont * Object::font = 0;
24 int Object::viewportHeight = 0;
25 bool Object::deleteActive = false;
26 bool Object::dimensionActive = false;
27 bool Object::snapToGrid = true;
30 Object::Object(): position(Vector(0, 0)), parent(0), state(OSInactive), oldState(OSInactive),
31 needUpdate(false), attachedDimension(0)
36 Object::Object(Vector v, Object * passedInParent/*= 0*/): position(v), parent(passedInParent),
37 state(OSInactive), oldState(OSInactive), needUpdate(false), attachedDimension(0)
47 /*virtual*/ void Object::Draw(Painter *)
52 /*virtual*/ Vector Object::Center(void)
58 /*virtual*/ bool Object::Collided(Vector)
64 /*virtual*/ void Object::PointerMoved(Vector)
69 /*virtual*/ void Object::PointerReleased(void)
74 /*virtual*/ bool Object::NeedsUpdate(void)
80 // This is intended to be overridden by the Container class, for object morphing
81 /*virtual*/ void Object::Transmute(Object *, Object *)
86 /*virtual*/ Object * Object::GetParent(void)
92 /*virtual*/ void Object::Add(Object *)
97 // This returns a pointer to the point passed in, if it coincides. Otherwise returns NULL.
98 /*virtual*/ Vector * Object::GetPointAt(Vector)
104 // This is meant for writing object data to a file.
105 /*virtual*/ void Object::Enumerate(FILE *)
110 /*virtual*/ Object * Object::Copy(void)
112 return new Object(position, parent);
116 ObjectState Object::GetState(void)
122 void Object::Reparent(Object * newParent)
128 Dimension * Object::GetAttachedDimension(void)
130 return attachedDimension;
136 void Object::SetFixedAngle(bool state/*= true*/)
142 void Object::SetFixedLength(bool state/*= true*/)
148 void Object::SetFont(QFont * f)
154 void Object::SetViewportHeight(int height)
156 viewportHeight = height;
160 void Object::SetDeleteActive(bool state/*= true*/)
162 deleteActive = state;
166 void Object::SetDimensionActive(bool state/*= true*/)
168 dimensionActive = state;
172 void Object::SetSnapMode(bool state/*= true*/)