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)
35 Object::Object(Vector v, Object * passedInParent/*= 0*/): position(v), parent(passedInParent),
36 state(OSInactive), oldState(OSInactive), needUpdate(false), attachedDimension(0)
44 /*virtual*/ void Object::Draw(Painter *)
48 /*virtual*/ Vector Object::Center(void)
53 /*virtual*/ bool Object::Collided(Vector)
58 /*virtual*/ void Object::PointerMoved(Vector)
62 /*virtual*/ void Object::PointerReleased(void)
66 /*virtual*/ bool Object::NeedsUpdate(void)
71 // This is intended to be overridden by the Container class, for object morphing
72 /*virtual*/ void Object::Transmute(Object *, Object *)
76 /*virtual*/ Object * Object::GetParent(void)
81 /*virtual*/ void Object::Add(Object *)
85 // This returns a pointer to the point passed in, if it coincides. Otherwise returns NULL.
86 /*virtual*/ Vector * Object::GetPointAt(Vector)
91 ObjectState Object::GetState(void)
96 void Object::Reparent(Object * newParent)
101 Dimension * Object::GetAttachedDimension(void)
103 return attachedDimension;
108 void Object::SetFixedAngle(bool state/*= true*/)
113 void Object::SetFixedLength(bool state/*= true*/)
118 void Object::SetFont(QFont * f)
123 void Object::SetViewportHeight(int height)
125 viewportHeight = height;
128 void Object::SetDeleteActive(bool state/*= true*/)
130 deleteActive = state;
133 void Object::SetDimensionActive(bool state/*= true*/)
135 dimensionActive = state;
138 void Object::SetSnapMode(bool state/*= true*/)