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