X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawingview.cpp;h=ab9f565fc2423bcb4f5a0c2b076eeaf63e64f500;hb=86caae9cadd6e1877a4e6226533521ef0d1c6389;hp=31aeaf028193e6fe9c43cb530a9a166d7c6befce;hpb=bb8d0671717bac2c5350e34024273381be1d8175;p=architektonas diff --git a/src/drawingview.cpp b/src/drawingview.cpp index 31aeaf0..ab9f565 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -34,10 +34,6 @@ #include "arc.h" #include "circle.h" #include "dimension.h" -#include "drawarcaction.h" -#include "drawcircleaction.h" -#include "drawdimensionaction.h" -#include "drawlineaction.h" #include "line.h" #include "painter.h" @@ -129,22 +125,7 @@ need a thickness parameter similar to the "size" param for dimensions. (And now we do! :-) */ -#if 0 - QPainter pmp(&gridBackground); - pmp.fillRect(0, 0, BACKGROUND_MAX_SIZE, BACKGROUND_MAX_SIZE, QColor(240, 240, 240)); - pmp.setPen(QPen(QColor(210, 210, 255), 2.0, Qt::SolidLine)); - - for(int i=0; i<(BACKGROUND_MAX_SIZE-1); i+=12) - { - pmp.drawLine(i, 0, i, BACKGROUND_MAX_SIZE - 1); - pmp.drawLine(0, i, BACKGROUND_MAX_SIZE - 1, i); - } - - pmp.end(); - UpdateGridBackground(); -#else SetGridSize(12); -#endif } @@ -155,56 +136,14 @@ void DrawingView::SetRotateToolActive(bool state/*= true*/) } -void DrawingView::SetAddLineToolActive(bool state/*= true*/) +void DrawingView::SetToolActive(Action * action) { - if (state) + if (action != NULL) { - toolAction = new DrawLineAction(); + toolAction = action; connect(toolAction, SIGNAL(ObjectReady(Object *)), this, SLOT(AddNewObjectToDocument(Object *))); } - - update(); -//printf("DrawingView::SetAddLineToolActive(). toolAction=%08X\n", toolAction); -} - - -void DrawingView::SetAddCircleToolActive(bool state/*= true*/) -{ - if (state) - { - toolAction = new DrawCircleAction(); - connect(toolAction, SIGNAL(ObjectReady(Object *)), this, - SLOT(AddNewObjectToDocument(Object *))); - } - - update(); -} - - -void DrawingView::SetAddArcToolActive(bool state/*= true*/) -{ - if (state) - { - toolAction = new DrawArcAction(); - connect(toolAction, SIGNAL(ObjectReady(Object *)), this, - SLOT(AddNewObjectToDocument(Object *))); - } - - update(); -} - - -void DrawingView::SetAddDimensionToolActive(bool state/*= true*/) -{ - if (state) - { - toolAction = new DrawDimensionAction(); - connect(toolAction, SIGNAL(ObjectReady(Object *)), this, - SLOT(AddNewObjectToDocument(Object *))); - } - - update(); } @@ -398,7 +337,12 @@ void DrawingView::paintEvent(QPaintEvent * /*event*/) document.Draw(&painter); if (toolAction) + { +// painter.SetPen(QPen(Qt::green, 1.0, Qt::DashLine)); + painter.SetPen(QPen(QColor(200, 100, 0, 255), 1.0, Qt::DashLine)); + painter.DrawCrosshair(oldPoint); toolAction->Draw(&painter); + } if (Object::selectionInProgress) { @@ -424,6 +368,8 @@ void DrawingView::mousePressEvent(QMouseEvent * event) { Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y())); +// Problem with this: Can't select stuff very well with the snap grid on. +// Completely screws things up. if (Object::snapToGrid) point = SnapPointToGrid(point); @@ -494,6 +440,7 @@ void DrawingView::mouseMoveEvent(QMouseEvent * event) #endif } #endif + oldPoint = point; //we should keep track of the last point here and only pass this down *if* the point //changed... document.PointerMoved(point); @@ -503,6 +450,12 @@ void DrawingView::mouseMoveEvent(QMouseEvent * event) if (toolAction) { + if (Object::snapToGrid) + { + point = SnapPointToGrid(point); + oldPoint = point; + } + toolAction->MouseMoved(point); update(); }