]> Shamusworld >> Repos - architektonas/blob - src/object.cpp
Fix for missing ampersand in QApplication.
[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 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 bool Object::snapToGrid = true;
28
29
30 Object::Object(): position(Vector(0, 0)), parent(0), state(OSInactive), oldState(OSInactive),
31         needUpdate(false), attachedDimension(0)
32 {
33 }
34
35 Object::Object(Vector v,  Object * passedInParent/*= 0*/): position(v), parent(passedInParent),
36         state(OSInactive), oldState(OSInactive), needUpdate(false), attachedDimension(0)
37 {
38 }
39
40 Object::~Object()
41 {
42 }
43
44 /*virtual*/ void Object::Draw(Painter *)
45 {
46 }
47
48 /*virtual*/ Vector Object::Center(void)
49 {
50         return Vector();
51 }
52
53 /*virtual*/ bool Object::Collided(Vector)
54 {
55         return false;
56 }
57
58 /*virtual*/ void Object::PointerMoved(Vector)
59 {
60 }
61
62 /*virtual*/ void Object::PointerReleased(void)
63 {
64 }
65
66 /*virtual*/ bool Object::NeedsUpdate(void)
67 {
68         return needUpdate;
69 }
70
71 // This is intended to be overridden by the Container class, for object morphing
72 /*virtual*/ void Object::Transmute(Object *, Object *)
73 {
74 }
75
76 /*virtual*/ Object * Object::GetParent(void)
77 {
78         return parent;
79 }
80
81 /*virtual*/ void Object::Add(Object *)
82 {
83 }
84
85 // This returns a pointer to the point passed in, if it coincides. Otherwise returns NULL.
86 /*virtual*/ Vector * Object::GetPointAt(Vector)
87 {
88         return 0;
89 }
90
91 ObjectState Object::GetState(void)
92 {
93         return state;
94 }
95
96 void Object::Reparent(Object * newParent)
97 {
98         parent = newParent;
99 }
100
101 Dimension * Object::GetAttachedDimension(void)
102 {
103         return attachedDimension;
104 }
105
106 // Class methods...
107
108 void Object::SetFixedAngle(bool state/*= true*/)
109 {
110         fixedAngle = state;
111 }
112
113 void Object::SetFixedLength(bool state/*= true*/)
114 {
115         fixedLength = state;
116 }
117
118 void Object::SetFont(QFont * f)
119 {
120         font = f;
121 }
122
123 void Object::SetViewportHeight(int height)
124 {
125         viewportHeight = height;
126 }
127
128 void Object::SetDeleteActive(bool state/*= true*/)
129 {
130         deleteActive = state;
131 }
132
133 void Object::SetDimensionActive(bool state/*= true*/)
134 {
135         dimensionActive = state;
136 }
137
138 void Object::SetSnapMode(bool state/*= true*/)
139 {
140         snapToGrid = state;
141 }