X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawingview.h;h=344428a804f65549c348eeb9ab3c43d612a7446f;hb=5d8c9e52606315fbfe857f2715b8f051b4f97491;hp=da1912f39312fbcc20fc6e0d60ed96553f071a5c;hpb=64482766268cddae393da1277987de31e69ffdd9;p=architektonas diff --git a/src/drawingview.h b/src/drawingview.h index da1912f..344428a 100644 --- a/src/drawingview.h +++ b/src/drawingview.h @@ -1,10 +1,14 @@ #ifndef __DRAWINGVIEW_H__ #define __DRAWINGVIEW_H__ -#include +#include #include -#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 { @@ -14,62 +18,107 @@ class DrawingView: public QWidget DrawingView(QWidget * parent = NULL); public: - void SetRotateToolActive(bool state = true); -#if 0 - void SetAddLineToolActive(bool state = true); - void SetAddCircleToolActive(bool state = true); - void SetAddArcToolActive(bool state = true); - void SetAddDimensionToolActive(bool state = true); -#endif -// void SetToolActive(Action * action, bool state = true); - void SetToolActive(Action * action);//, bool state = true); - void SetGridSize(uint32_t); - void UpdateGridBackground(void); + void DrawBackground(Painter *); + Point SnapPointToGrid(Point); + Point SnapPointToAngle(Point); + void RenderObjects(Painter *, VPVector &, int, bool ignoreLayer = false); + void AddHoveredToSelection(void); + VPVector GetSelection(void); + VPVector GetHovered(bool exclude = false); + 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 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 HandlePenWidth(float); + void HandlePenStyle(int); + void HandlePenColor(uint32_t); + 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); -// Vector SnapPointToGrid(Vector); public: bool useAntialiasing; + uint32_t numHovered; + bool shiftDown; + bool ctrlDown; + bool altDown; private: -// QBrush * backgroundBrush; QPixmap gridBackground; double scale; // Window scaling factor int32_t offsetX, offsetY; // Window offsets + bool supressSelected; + QCursor curMarker; + QCursor curDropper; public: Container document; -// double gridSpacing; // Grid spacing in base units uint32_t gridPixels; // Grid size in pixels -// double gridBaseUnits; // Grid size in base units - private: + double gridPixelsF; // Grid size in pixels (float) +// private: + public: bool collided; -//Should this go into Object's class variables??? -//maybe, maybe not... :-P - bool rotateTool; - double rx, ry; bool scrollDrag; Vector oldPoint; - bool addLineTool; - bool addCircleTool; - bool addDimensionTool; + Vector oldScrollPoint; + QString informativeText; public: - Action * toolAction; + VPVector select; + VPVector toolObjects; + std::vector toolScratch; + VPVector toolScratch2; + Point toolPoint[32]; + Object * toolObj[32]; + Point intersectionPoint; + Point hoverPoint; + bool hoverPointValid; + bool hoveringIntersection; + Object * dragged; + bool draggingObject; + bool angleSnap; + bool dirty; + bool scrollWheelSeen; }; #endif // __DRAWINGVIEW_H__