X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawingview.cpp;h=3020368913cfa3b4358df95669b1b65649523d15;hb=642cf72c11b49a9e00128ab6258a2438c785a5ab;hp=bdc3540b0442fc51b243e6096da6a94b362d2632;hpb=e8987f4028a1f9c0eeb33a45bd11b2e409b9c2c5;p=architektonas diff --git a/src/drawingview.cpp b/src/drawingview.cpp index bdc3540..3020368 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -49,8 +49,8 @@ DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent), document(Vector(0, 0)), /*gridSpacing(12.0),*/ gridPixels(0), collided(false), rotateTool(false), rx(150.0), ry(150.0), - scrollDrag(false), addLineTool(false), addCircleTool(false), - addDimensionTool(false), +// scrollDrag(false), addLineTool(false), addCircleTool(false), +// addDimensionTool(false), toolAction(NULL) { document.isTopLevelContainer = true; @@ -266,6 +266,13 @@ void DrawingView::AddNewObjectToDocument(Object * object) } +void DrawingView::SetCurrentLayer(int layer) +{ + Object::currentLayer = layer; +//printf("DrawingView::CurrentLayer = %i\n", layer); +} + + QPoint DrawingView::GetAdjustedMousePosition(QMouseEvent * event) { // This is undoing the transform, e.g. going from client coords to local coords. @@ -393,7 +400,12 @@ Now we do... :-/ update(); // Do an update if collided with at least *one* object in the document if (toolAction) + { + if (Object::snapToGrid) + point = Object::SnapPointToGrid(point); + toolAction->MouseDown(point); + } // Didn't hit any object and not using a tool, so do a selection rectangle if (!(collided || toolAction)) @@ -491,3 +503,27 @@ void DrawingView::mouseReleaseEvent(QMouseEvent * event) } } + +void DrawingView::keyPressEvent(QKeyEvent * event) +{ + if (toolAction) + { + bool needUpdate = toolAction->KeyDown(event->key()); + + if (needUpdate) + update(); + } +} + + +void DrawingView::keyReleaseEvent(QKeyEvent * event) +{ + if (toolAction) + { + bool needUpdate = toolAction->KeyReleased(event->key()); + + if (needUpdate) + update(); + } +} +