]> Shamusworld >> Repos - architektonas/blob - src/object.cpp
4be11f55fa0961ceb78202881bcc3b2bc0ce577c
[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
26
27 Object::Object(): position(Vector(0, 0)), parent(0), state(OSInactive), oldState(OSInactive),
28         needUpdate(false), dimPoint1(0), dimPoint2(0)
29 {
30 }
31
32 Object::Object(Vector v,  Object * passedInParent/*= 0*/): position(v), parent(passedInParent),
33         state(OSInactive), oldState(OSInactive), needUpdate(false), dimPoint1(0), dimPoint2(0)
34 {
35 }
36
37 Object::~Object()
38 {
39 }
40
41 /*virtual*/ void Object::Draw(QPainter *)
42 {
43 }
44
45 /*virtual*/ Vector Object::Center(void)
46 {
47         return Vector();
48 }
49
50 /*virtual*/ bool Object::Collided(Vector)
51 {
52         return false;
53 }
54
55 /*virtual*/ void Object::PointerMoved(Vector)
56 {
57 }
58
59 /*virtual*/ void Object::PointerReleased(void)
60 {
61 }
62
63 /*virtual*/ bool Object::NeedsUpdate(void)
64 {
65         return needUpdate;
66 }
67
68 // This is intended to be overridden by the Container class, for object morphing
69 /*virtual*/ void Object::Transmute(Object *, Object *)
70 {
71 }
72
73 ObjectState Object::GetState(void)
74 {
75         return state;
76 }
77
78 // Class methods...
79
80 void Object::SetFixedAngle(bool state/*= true*/)
81 {
82         fixedAngle = state;
83 }
84
85 void Object::SetFixedLength(bool state/*= true*/)
86 {
87         fixedLength = state;
88 }
89
90 void Object::SetFont(QFont * f)
91 {
92         font = f;
93 }
94
95 void Object::SetViewportHeight(int height)
96 {
97         viewportHeight = height;
98 }
99
100 void Object::SetDeleteActive(bool state/*= true*/)
101 {
102         deleteActive = state;
103 }