#ifndef __DRAWINGVIEW_H__
#define __DRAWINGVIEW_H__
-#include <QtGui>
+#include <QtWidgets>
#include <stdint.h>
-#include "action.h"
-#include "container.h"
+#include "rect.h"
+#include "structs.h"
+
+enum { ToolMouseDown, ToolMouseMove, ToolMouseUp, ToolKeyDown, ToolKeyUp, ToolCleanup };
+
+class Painter;
class DrawingView: public QWidget
{
DrawingView(QWidget * parent = NULL);
public:
- void SetRotateToolActive(bool state = true);
- void SetAddLineToolActive(bool state = true);
+ void DrawBackground(Painter *);
+ Point SnapPointToGrid(Point);
+ Point SnapPointToAngle(Point);
+ void RenderObjects(Painter *, VPVector &, int, bool ignoreLayer = false);
+ void HandleSelectionClick(VPVector &);
+ VPVector GetSelection(void);
+ VPVector GetHovered(bool exclude = false);
+ void MoveSelectedToLayer(int);
+ void ToolHandler(int, Point);
+ void ToolDraw(Painter *);
+ void LineHandler(int, Point);
+ void CircleHandler(int, Point);
+ void ArcHandler(int, Point);
+ void RotateHandler(int, Point);
+ void MirrorHandler(int, Point);
+ void DimensionHandler(int, Point);
+ void DeleteHandler(int, Point);
+ void TriangulateHandler(int, Point);
+ void TrimHandler(int, Point);
+ void ParallelHandler(int, Point);
+ Rect GetObjectExtents(Object *);
+ void CheckObjectBounds(void);
+ bool HitTestObjects(Point);
+ bool HitTest(Object *, Point);
+ bool HandleObjectClicked(void);
+ void HandleObjectMovement(Point);
+ void AddDimensionTo(void * obj);
public slots:
- void AddNewObjectToDocument(Object *);
+ void DeleteCurrentLayer(int);
+ void HandleLayerToggle(void);
+ void HandleLayerSwap(int, int);
+ void HandleLayerSwap(int, int, VPVector &);
+ void HandlePenStamp(QAction *);
+ void HandlePenDropper(QAction *);
+
+ signals:
+ void ObjectHovered(Object *);
+ void ObjectSelected(Object *);
+ void NeedZoomUpdate(void);
protected:
+ void focusOutEvent(QFocusEvent * event);
+ void focusInEvent(QFocusEvent * event);
void paintEvent(QPaintEvent * event);
+ void resizeEvent(QResizeEvent * event);
void mousePressEvent(QMouseEvent * event);
void mouseMoveEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent * event);
+ void wheelEvent(QWheelEvent * event);
+ void keyPressEvent(QKeyEvent * event);
+ void keyReleaseEvent(QKeyEvent * event);
private:
+ void DrawSubGrid(Painter *, uint32_t, double, Vector, Vector);
QPoint GetAdjustedMousePosition(QMouseEvent * event);
QPoint GetAdjustedClientPosition(int x, int y);
public:
bool useAntialiasing;
+ uint32_t numHovered;
+ bool shiftDown;
+ bool ctrlDown;
+ bool altDown;
private:
- double scale; // Window scaling factor
- int32_t offsetX, offsetY; // Window offsets
+ QPixmap gridBackground;
+ double scale; // Window scaling factor
+ int32_t offsetX, offsetY; // Window offsets
+ bool supressSelected;
+ QCursor curMarker;
+ QCursor curDropper;
+ uint32_t currentSelect;
+ public:
Container document;
- double gridSpacing;
+ uint32_t gridPixels; // Grid size in pixels
+ double gridPixelsF; // Grid size in pixels (float)
bool collided;
-//Should this go into Object's class variables???
- bool rotateTool;
- double rx, ry;
bool scrollDrag;
Vector oldPoint;
- bool addLineTool;
- Action * toolAction;
-/* QSize minimumSizeHint() const;
- QSize sizeHint() const;
-
- private:
- void CreateCursors(void);
- QPoint GetAdjustedMousePosition(QMouseEvent * event);
- QPoint GetAdjustedClientPosition(int x, int y);
+ Vector oldScrollPoint;
+ QString informativeText;
- QImage image;
- QPoint pt, ptOffset, ptPrevious;
- ToolType tool; // Current tool
- GlyphPoints pts; // Glyph point structure
- int32 ptHighlight, oldPtHighlight, ptNextHighlight, oldPtNextHighlight;
- bool polyFirstPoint;
-
- ToolWindow * toolPalette;
- QCursor cur[8];
-*/
+ public:
+ VPVector select;
+ VPVector toolObjects;
+ std::vector<Object> toolScratch;
+ VPVector toolScratch2;
+ VPVector oldHover;
+ Point toolPoint[32];
+ Object * toolObj[32];
+ double toolParam[32];
+ Point intersectionPoint;
+ Point hoverPoint;
+ bool hoverPointValid;
+ bool hoveringIntersection;
+ Object * dragged;
+ bool draggingObject;
+ bool angleSnap;
+ bool dirty;
+ bool scrollWheelSeen;
};
#endif // __DRAWINGVIEW_H__