X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawingview.cpp;h=89c63ed429d9a95f71aa245160d09d95c6ca7e4b;hb=921bf050ffe5fc81a9ab377e634180e659ee5d5d;hp=95721178a70be35ee56600f4a492390b8f1ed44c;hpb=64482766268cddae393da1277987de31e69ffdd9;p=architektonas diff --git a/src/drawingview.cpp b/src/drawingview.cpp index 9572117..89c63ed 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -19,6 +19,7 @@ // // STILL TO BE DONE: // +// - Lots of stuff // // Uncomment this for debugging... @@ -47,10 +48,10 @@ DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent), gridBackground(BACKGROUND_MAX_SIZE, BACKGROUND_MAX_SIZE), scale(1.0), offsetX(-10), offsetY(-10), 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), + /*gridSpacing(12.0),*/ gridPixels(0), collided(false), //rotateTool(false), +// rx(150.0), ry(150.0), +// scrollDrag(false), addLineTool(false), addCircleTool(false), +// addDimensionTool(false), toolAction(NULL) { document.isTopLevelContainer = true; @@ -130,13 +131,6 @@ we do! :-) } -void DrawingView::SetRotateToolActive(bool state/*= true*/) -{ - rotateTool = state; - update(); -} - - void DrawingView::SetToolActive(Action * action) { if (action != NULL) @@ -266,6 +260,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. @@ -284,28 +285,6 @@ QPoint DrawingView::GetAdjustedClientPosition(int x, int y) } -#if 0 -// -// This looks strange, but it's really quite simple: We want a point that's -// more than half-way to the next grid point to snap there while conversely we -// want a point that's less than half-way to to the next grid point then snap -// to the one before it. So we add half of the grid spacing to the point, then -// divide by it so that we can remove the fractional part, then multiply it -// back to get back to the correct answer. -// -Vector DrawingView::SnapPointToGrid(Vector point) -{ - point += gridSpacing / 2.0; // *This* adds to Z!!! - point /= gridSpacing; - point.x = floor(point.x);//need to fix this for negative numbers... - point.y = floor(point.y); - point.z = 0; // Make *sure* Z doesn't go anywhere!!! - point *= gridSpacing; - return point; -} -#endif - - void DrawingView::paintEvent(QPaintEvent * /*event*/) { QPainter qtPainter(this); @@ -314,35 +293,18 @@ void DrawingView::paintEvent(QPaintEvent * /*event*/) if (useAntialiasing) qtPainter.setRenderHint(QPainter::Antialiasing); -// Painter::screenSize = Vector(size().width(), size().height()); Object::SetViewportHeight(size().height()); // Draw coordinate axes - painter.SetPen(QPen(Qt::blue, 1.0, Qt::DotLine)); painter.DrawLine(0, -16384, 0, 16384); painter.DrawLine(-16384, 0, 16384, 0); - // Draw supplemental (tool related) points -// NOTE that this can be done as an action! -// In that case, we would need access to the document... -// [We can do that by making the document a class object...] - if (rotateTool) - { - painter.SetPen(QPen(QColor(0, 200, 0), 2.0, Qt::SolidLine)); - painter.DrawLine(rx - 10, ry, rx + 10, ry); - painter.DrawLine(rx, ry - 10, rx, ry + 10); - } - -// Maybe we can make the grid into a background brush instead, and let Qt deal -// with it??? YES!! - // The top level document takes care of rendering for us... 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); @@ -350,9 +312,7 @@ void DrawingView::paintEvent(QPaintEvent * /*event*/) if (Object::selectionInProgress) { -// painter.SetPen(QPen(Qt::green, 1.0, Qt::SolidLine)); painter.SetPen(QPen(QColor(255, 127, 0, 255))); -// painter.SetBrush(QBrush(Qt::NoBrush)); painter.SetBrush(QBrush(QColor(255, 127, 0, 100))); painter.DrawRect(Object::selection); }