]> Shamusworld >> Repos - architektonas/blob - src/object.h
Initial stab at getting Circle to respond to selection rectangle.
[architektonas] / src / object.h
1 #ifndef __OBJECT_H__
2 #define __OBJECT_H__
3
4 #include <stdio.h>
5 #include <vector>                                                       // This is a container
6 #include "vector.h"                                                     // This is the mathematical construct
7 #include "connection.h"
8 #include <QRectF>
9
10 class Painter;
11 class QFont;
12 class Dimension;
13 //class FILE;
14
15 enum ObjectState { OSInactive, OSSelected };
16 enum ObjectType { OTNone, OTObject, OTLine, OTCircle, OTArc, OTDimension, OTEllipse, OTContainer };
17
18 class Object
19 {
20         public:
21                 Object();
22                 Object(Vector, Object * passedInParent = 0);
23                 ~Object();
24
25                 virtual void Draw(Painter *);
26                 virtual Vector Center(void);
27                 virtual bool Collided(Vector);
28                 virtual void PointerMoved(Vector);
29                 virtual void PointerReleased(void);
30                 virtual bool NeedsUpdate(void);
31                 virtual void Transmute(Object *, Object *);
32                 virtual Object * GetParent(void);
33                 virtual void Add(Object *);
34                 virtual Vector * GetPointAt(Vector);
35                 virtual void Enumerate(FILE *);
36                 virtual Object * Copy(void);
37                 virtual Vector GetPointAtParameter(double parameter);
38                 virtual void Connect(Object *, double);
39                 virtual void Disconnect(Object *, double);
40                 virtual void DisconnectAll(Object *);
41                 virtual QRectF Extents(void);
42 //              virtual ObjectType Type(void);// = 0; // Pure virtual, must be implemented
43                 ObjectState GetState(void);
44                 void Reparent(Object *);
45 //              Dimension * GetAttachedDimension(void);
46 //Hm.           Object * Connect(Object *);
47
48                 // Class methods
49                 static void SetFixedAngle(bool state = true);
50                 static void SetFixedLength(bool state = true);
51                 static void SetFont(QFont *);
52                 static void SetViewportHeight(int);
53                 static void SetDeleteActive(bool state = true);
54                 static void SetDimensionActive(bool state = true);
55                 static void SetSnapMode(bool state = true);
56
57         protected:
58                 Vector position;                                        // All objects have a position (doubles as reference point)
59                 Object * parent;
60 //              Pen pen;
61 //              Fill fill;
62         public:
63                 ObjectType type;
64                 ObjectState state;
65         protected:
66                 ObjectState oldState;
67                 bool needUpdate;
68 //              Dimension * attachedDimension;
69                 std::vector<Connection> connected;
70
71                 // Class variables
72                 static QFont * font;
73                 static bool fixedAngle;
74                 static bool fixedLength;
75                 static int viewportHeight;
76                 static bool deleteActive;
77                 static bool dimensionActive;
78                 static bool snapToGrid;
79                 static bool ignoreClicks;
80                 static bool dontMove;
81         public:
82                 static bool selectionInProgress;
83                 static QRectF selection;
84 };
85
86 #endif  // __OBJECT_H__