]> Shamusworld >> Repos - architektonas/blob - src/object.cpp
Added gratuitous About screen.
[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 #include "object.h"
18
19 // Initialize static variables
20 bool Object::fixedAngle = false;
21 bool Object::fixedLength = false;
22 QFont * Object::font = 0;
23 int Object::viewportHeight = 0;
24 bool Object::deleteActive = false;
25 bool Object::dimensionActive = false;
26
27
28 Object::Object(): position(Vector(0, 0)), parent(0), state(OSInactive), oldState(OSInactive),
29         needUpdate(false), attachedDimension(0)
30 {
31 }
32
33 Object::Object(Vector v,  Object * passedInParent/*= 0*/): position(v), parent(passedInParent),
34         state(OSInactive), oldState(OSInactive), needUpdate(false), attachedDimension(0)
35 {
36 }
37
38 Object::~Object()
39 {
40 }
41
42 /*virtual*/ void Object::Draw(QPainter *)
43 {
44 }
45
46 /*virtual*/ Vector Object::Center(void)
47 {
48         return Vector();
49 }
50
51 /*virtual*/ bool Object::Collided(Vector)
52 {
53         return false;
54 }
55
56 /*virtual*/ void Object::PointerMoved(Vector)
57 {
58 }
59
60 /*virtual*/ void Object::PointerReleased(void)
61 {
62 }
63
64 /*virtual*/ bool Object::NeedsUpdate(void)
65 {
66         return needUpdate;
67 }
68
69 // This is intended to be overridden by the Container class, for object morphing
70 /*virtual*/ void Object::Transmute(Object *, Object *)
71 {
72 }
73
74 /*virtual*/ Object * Object::GetParent(void)
75 {
76         return parent;
77 }
78
79 /*virtual*/ void Object::Add(Object *)
80 {
81 }
82
83 ObjectState Object::GetState(void)
84 {
85         return state;
86 }
87
88 // Class methods...
89
90 void Object::SetFixedAngle(bool state/*= true*/)
91 {
92         fixedAngle = state;
93 }
94
95 void Object::SetFixedLength(bool state/*= true*/)
96 {
97         fixedLength = state;
98 }
99
100 void Object::SetFont(QFont * f)
101 {
102         font = f;
103 }
104
105 void Object::SetViewportHeight(int height)
106 {
107         viewportHeight = height;
108 }
109
110 void Object::SetDeleteActive(bool state/*= true*/)
111 {
112         deleteActive = state;
113 }
114
115 void Object::SetDimensionActive(bool state/*= true*/)
116 {
117         dimensionActive = state;
118 }