]> Shamusworld >> Repos - architektonas/blob - src/drawingview.h
0c6cc46cf76d18390d908dd8447e7b4661355ac9
[architektonas] / src / drawingview.h
1 #ifndef __DRAWINGVIEW_H__
2 #define __DRAWINGVIEW_H__
3
4 #include <QtWidgets>
5 #include <stdint.h>
6 #include "rect.h"
7 #include "structs.h"
8
9 enum { ToolMouseDown, ToolMouseMove, ToolMouseUp, ToolKeyDown, ToolKeyUp, ToolCleanup };
10
11 class Painter;
12
13 class DrawingView: public QWidget
14 {
15         Q_OBJECT
16
17         public:
18                 DrawingView(QWidget * parent = NULL);
19
20         public:
21                 void DrawBackground(Painter *);
22 //              void SetGridSize(uint32_t);
23 //              void SetGridSize(double);
24 //              void UpdateGridBackground(void);
25 //              void UpdateGridBackgroundF(void);
26                 Point SnapPointToGrid(Point);
27                 Point SnapPointToAngle(Point);
28                 void RenderObjects(Painter *, VPVector &, int, bool ignoreLayer = false);
29                 void AddHoveredToSelection(void);
30                 VPVector GetSelection(void);
31                 VPVector GetHovered(void);
32                 void ToolHandler(int, Point);
33                 void ToolDraw(Painter *);
34                 void LineHandler(int, Point);
35                 void CircleHandler(int, Point);
36                 void ArcHandler(int, Point);
37                 void RotateHandler(int, Point);
38                 void MirrorHandler(int, Point);
39                 void DimensionHandler(int, Point);
40                 void TriangulateHandler(int, Point);
41                 void TrimHandler(int, Point);
42                 void ParallelHandler(int, Point);
43                 Rect GetObjectExtents(Object *);
44                 void CheckObjectBounds(void);
45                 bool HitTestObjects(Point);
46                 bool HitTest(Object *, Point);
47                 bool HandleObjectClicked(void);
48                 void HandleObjectMovement(Point);
49                 void AddDimensionTo(void * obj);
50
51         public slots:
52                 void DeleteCurrentLayer(int);
53                 void HandleLayerToggle(void);
54                 void HandleLayerSwap(int, int);
55                 void HandlePenWidth(float);
56                 void HandlePenStyle(int);
57                 void HandlePenColor(uint32_t);
58                 void HandlePenStamp(QAction *);
59                 void HandlePenDropper(QAction *);
60
61         signals:
62                 void ObjectHovered(Object *);
63                 void ObjectSelected(Object *);
64                 void NeedZoomUpdate(void);
65
66         protected:
67                 void focusOutEvent(QFocusEvent * event);
68                 void focusInEvent(QFocusEvent * event);
69                 void paintEvent(QPaintEvent * event);
70                 void resizeEvent(QResizeEvent * event);
71                 void mousePressEvent(QMouseEvent * event);
72                 void mouseMoveEvent(QMouseEvent * event);
73                 void mouseReleaseEvent(QMouseEvent * event);
74                 void wheelEvent(QWheelEvent * event);
75                 void keyPressEvent(QKeyEvent * event);
76                 void keyReleaseEvent(QKeyEvent * event);
77
78         private:
79                 void HandleLayerSwap(int, int, VPVector &);
80                 void DrawSubGrid(Painter *, uint32_t, double, Vector, Vector);
81                 QPoint GetAdjustedMousePosition(QMouseEvent * event);
82                 QPoint GetAdjustedClientPosition(int x, int y);
83
84         public:
85                 bool useAntialiasing;
86                 uint32_t numHovered;
87                 bool shiftDown;
88                 bool ctrlDown;
89                 bool altDown;
90
91         private:
92                 QPixmap gridBackground;
93                 double scale;                                                   // Window scaling factor
94                 int32_t offsetX, offsetY;                               // Window offsets
95                 bool supressSelected;
96                 QCursor curMarker;
97                 QCursor curDropper;
98         public:
99                 Container document;
100                 uint32_t gridPixels;                                    // Grid size in pixels
101                 double gridPixelsF;                                             // Grid size in pixels (float)
102 //      private:
103         public:
104                 bool collided;
105                 bool scrollDrag;
106                 Vector oldPoint;
107                 Vector oldScrollPoint;
108                 QString informativeText;
109
110         public:
111                 VPVector select;
112                 VPVector toolObjects;
113                 std::vector<Object> toolScratch;
114                 VPVector toolScratch2;
115                 Point toolPoint[32];
116                 Object * toolObj[32];
117                 Point intersectionPoint;
118                 Point hoverPoint;
119                 bool hoverPointValid;
120                 bool hoveringIntersection;
121                 Object * dragged;
122                 bool draggingObject;
123                 bool angleSnap;
124                 bool dirty;
125                 bool scrollWheelSeen;
126 };
127
128 #endif  // __DRAWINGVIEW_H__
129