]> Shamusworld >> Repos - architektonas/blob - src/object.cpp
Preliminary Add Line tool work...
[architektonas] / src / object.cpp
1 //
2 // object.cpp: Base class for all CAD objects
3 //
4 // Part of the Architektonas Project
5 // (C) 2011 Underground Software
6 // See the README and GPLv3 files for licensing and warranty information
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // WHO  WHEN        WHAT
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)
16 //
17
18 #include "object.h"
19
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
28
29 Object::Object(): position(Vector(0, 0)), parent(0), state(OSInactive), oldState(OSInactive),
30         needUpdate(false), attachedDimension(0)
31 {
32 }
33
34 Object::Object(Vector v,  Object * passedInParent/*= 0*/): position(v), parent(passedInParent),
35         state(OSInactive), oldState(OSInactive), needUpdate(false), attachedDimension(0)
36 {
37 }
38
39 Object::~Object()
40 {
41 }
42
43 /*virtual*/ void Object::Draw(Painter *)
44 {
45 }
46
47 /*virtual*/ Vector Object::Center(void)
48 {
49         return Vector();
50 }
51
52 /*virtual*/ bool Object::Collided(Vector)
53 {
54         return false;
55 }
56
57 /*virtual*/ void Object::PointerMoved(Vector)
58 {
59 }
60
61 /*virtual*/ void Object::PointerReleased(void)
62 {
63 }
64
65 /*virtual*/ bool Object::NeedsUpdate(void)
66 {
67         return needUpdate;
68 }
69
70 // This is intended to be overridden by the Container class, for object morphing
71 /*virtual*/ void Object::Transmute(Object *, Object *)
72 {
73 }
74
75 /*virtual*/ Object * Object::GetParent(void)
76 {
77         return parent;
78 }
79
80 /*virtual*/ void Object::Add(Object *)
81 {
82 }
83
84 ObjectState Object::GetState(void)
85 {
86         return state;
87 }
88
89 void Object::Reparent(Object * newParent)
90 {
91         parent = newParent;
92 }
93
94 // Class methods...
95
96 void Object::SetFixedAngle(bool state/*= true*/)
97 {
98         fixedAngle = state;
99 }
100
101 void Object::SetFixedLength(bool state/*= true*/)
102 {
103         fixedLength = state;
104 }
105
106 void Object::SetFont(QFont * f)
107 {
108         font = f;
109 }
110
111 void Object::SetViewportHeight(int height)
112 {
113         viewportHeight = height;
114 }
115
116 void Object::SetDeleteActive(bool state/*= true*/)
117 {
118         deleteActive = state;
119 }
120
121 void Object::SetDimensionActive(bool state/*= true*/)
122 {
123         dimensionActive = state;
124 }