]> Shamusworld >> Repos - architektonas/blob - src/drawingview.h
Fixes for grid background drawing of arbitrary size.
[architektonas] / src / drawingview.h
1 #ifndef __DRAWINGVIEW_H__
2 #define __DRAWINGVIEW_H__
3
4 #include <QtGui>
5 #include <stdint.h>
6 #include "action.h"
7 #include "container.h"
8
9 class DrawingView: public QWidget
10 {
11         Q_OBJECT
12
13         public:
14                 DrawingView(QWidget * parent = NULL);
15
16         public:
17                 void SetRotateToolActive(bool state = true);
18                 void SetAddLineToolActive(bool state = true);
19                 void SetAddCircleToolActive(bool state = true);
20                 void SetAddDimensionToolActive(bool state = true);
21                 void SetGridSize(uint32_t);
22                 void UpdateGridBackground(void);
23
24         public slots:
25                 void AddNewObjectToDocument(Object *);
26
27         protected:
28                 void paintEvent(QPaintEvent * event);
29                 void resizeEvent(QResizeEvent * event);
30                 void mousePressEvent(QMouseEvent * event);
31                 void mouseMoveEvent(QMouseEvent * event);
32                 void mouseReleaseEvent(QMouseEvent * event);
33
34         private:
35                 QPoint GetAdjustedMousePosition(QMouseEvent * event);
36                 QPoint GetAdjustedClientPosition(int x, int y);
37
38         public:
39                 bool useAntialiasing;
40
41         private:
42 //              QBrush * backgroundBrush;
43                 QPixmap gridBackground;
44                 double scale;                                                   // Window scaling factor
45                 int32_t offsetX, offsetY;                               // Window offsets
46         public:
47                 Container document;
48                 double gridSpacing;                                             // Grid spacing in base units
49                 uint32_t gridPixels;                                    // Grid size in pixels
50 //              double gridBaseUnits;                                   // Grid size in base units
51         private:
52                 bool collided;
53 //Should this go into Object's class variables???
54                 bool rotateTool;
55                 double rx, ry;
56                 bool scrollDrag;
57                 Vector oldPoint;
58                 bool addLineTool;
59                 bool addCircleTool;
60                 bool addDimensionTool;
61 //              bool selectionInProgress;
62 //              QRectF selection;
63
64         public:
65                 Action * toolAction;
66 };
67
68 #endif  // __DRAWINGVIEW_H__