# HG changeset patch # User Teemu Piippo # Date 1443966330 -10800 # Node ID 74cb432812d3d1def3e708c54a8c562c25124cf7 # Parent a6b462051ae03bacd4d58055ce55ee12c89d881d Fixed circle, rectangle and line path modes not working anymore. Add blip coordinates to curve and line path modes. Circle mode for now only can show the coordinates of the initial blip diff -r a6b462051ae0 -r 74cb432812d3 src/editmodes/abstractEditMode.cpp --- a/src/editmodes/abstractEditMode.cpp Sun Oct 04 14:08:51 2015 +0300 +++ b/src/editmodes/abstractEditMode.cpp Sun Oct 04 16:45:30 2015 +0300 @@ -154,7 +154,7 @@ if (data.releasedButtons & Qt::LeftButton) { - if (m_drawedVerts.size() >= maxVertices()) + if (maxVertices() and m_drawedVerts.size() >= maxVertices()) { endDraw(); return true; @@ -214,13 +214,8 @@ // Draw vertex blips for (int i = 0; i < poly3d.size(); ++i) { - QPoint& blip = poly[i]; - painter.setPen (renderer()->linePen()); - renderer()->drawBlip (painter, blip); - - // Draw their coordinates - painter.setPen (renderer()->textPen()); - painter.drawText (blip.x(), blip.y() - 8, poly3d[i].toString (true)); + renderer()->drawBlip (painter, poly[i]); + renderer()->drawBlipCoordinates (painter, poly3d[i], poly[i]); } // Draw line lenghts and angle info if appropriate diff -r a6b462051ae0 -r 74cb432812d3 src/editmodes/circleMode.cpp --- a/src/editmodes/circleMode.cpp Sun Oct 04 14:08:51 2015 +0300 +++ b/src/editmodes/circleMode.cpp Sun Oct 04 16:45:30 2015 +0300 @@ -205,7 +205,9 @@ // If we have not specified the center point of the circle yet, preview it on the screen. if (m_drawedVerts.isEmpty()) { - renderer()->drawBlip (painter, renderer()->convert3dTo2d (renderer()->position3D())); + QPoint pos2d = renderer()->convert3dTo2d (renderer()->position3D()); + renderer()->drawBlip (painter, pos2d); + renderer()->drawBlipCoordinates (painter, renderer()->position3D(), pos2d); return; } @@ -273,7 +275,7 @@ lines << QLineF (innerverts2d[i], innerverts2d[i + 1]); } - // Draw a green blips at where the points are + // Draw green blips at where the points are for (QPointF const& point : innerverts2d + outerverts2d) renderer()->drawBlip (painter, point); diff -r a6b462051ae0 -r 74cb432812d3 src/editmodes/curvemode.cpp --- a/src/editmodes/curvemode.cpp Sun Oct 04 14:08:51 2015 +0300 +++ b/src/editmodes/curvemode.cpp Sun Oct 04 16:45:30 2015 +0300 @@ -47,7 +47,12 @@ for (int i = 0; i < countof(curve); ++i) curve2d[i] = renderer()->convert3dTo2d (curve[i]); - painter.setPen (renderer()->linePen()); + painter.setPen (QColor (0, 112, 112)); + if (m_drawedVerts.size() >= 2) + painter.drawLine (curve2d[0], curve2d[2]); + + if (m_drawedVerts.size() >= 3) + painter.drawLine (curve2d[1], curve2d[3]); for (int i = 0; i < qMin (countof(curve), m_drawedVerts.size() + 1); ++i) { @@ -55,7 +60,8 @@ renderer()->drawBlip (painter, curve2d[i]); else // Give control points a different color - renderer()->drawBlip (painter, curve2d[i], QColor (0, 96, 96)); + renderer()->drawBlip (painter, curve2d[i], QColor (0, 112, 112)); + renderer()->drawBlipCoordinates (painter, curve[i], curve2d[i]); } QPainterPath path (curve2d[0]); @@ -65,8 +71,9 @@ else { // Even if we have nothing, still draw the vertex at the cursor - painter.setPen (renderer()->linePen()); - renderer()->drawBlip (painter, renderer()->convert3dTo2d (getCursorVertex())); + QPoint vertex2d = renderer()->convert3dTo2d (getCursorVertex()); + renderer()->drawBlip (painter, vertex2d); + renderer()->drawBlipCoordinates (painter, getCursorVertex(), vertex2d); } } diff -r a6b462051ae0 -r 74cb432812d3 src/editmodes/linePathMode.cpp --- a/src/editmodes/linePathMode.cpp Sun Oct 04 14:08:51 2015 +0300 +++ b/src/editmodes/linePathMode.cpp Sun Oct 04 16:45:30 2015 +0300 @@ -27,7 +27,7 @@ void LinePathMode::render (QPainter& painter) const { QVector points; - QList points3d (m_drawedVerts); + QList points3d = m_drawedVerts; points3d << renderer()->position3D(); for (Vertex const& vrt : points3d) @@ -43,8 +43,12 @@ drawLength (painter, points3d[i], points3d[i + 1], points[i], points[i + 1]); } - for (QPointF const& point : points) + for (int i = 0; i < points.size(); ++i) + { + const QPointF& point = points[i]; renderer()->drawBlip (painter, point); + renderer()->drawBlipCoordinates (painter, points3d[i], point); + } } } @@ -64,7 +68,7 @@ bool LinePathMode::preAddVertex (Vertex const& pos) { - // If we picked an the last vertex, stop drawing + // If we picked the vertex we last drew, stop drawing if (not m_drawedVerts.isEmpty() and pos == m_drawedVerts.last()) { endDraw(); diff -r a6b462051ae0 -r 74cb432812d3 src/glRenderer.cpp --- a/src/glRenderer.cpp Sun Oct 04 14:08:51 2015 +0300 +++ b/src/glRenderer.cpp Sun Oct 04 16:45:30 2015 +0300 @@ -633,7 +633,7 @@ #ifndef RELEASE if (not isPicking()) { - QString text = format ("Rotation: (%1, %2, %3)\nPanning: (%4, %5), Zoom: %6", + QString text = format ("Rotation: (%1°, %2°, %3°)\nPanning: (%4, %5), Zoom: %6", rotation(X), rotation(Y), rotation(Z), panning(X), panning(Y), zoom()); QRect textSize = metrics.boundingRect (0, 0, m_width, m_height, Qt::AlignCenter, text); paint.setPen (textPen()); @@ -721,14 +721,25 @@ // ============================================================================= // -void GLRenderer::drawBlip (QPainter& paint, QPointF pos, QColor color) const +void GLRenderer::drawBlip (QPainter& painter, QPointF pos, QColor color) const { QPen pen = m_thinBorderPen; const int blipsize = 8; pen.setWidth (1); - paint.setPen (pen); - paint.setBrush (color); - paint.drawEllipse (pos.x() - blipsize / 2, pos.y() - blipsize / 2, blipsize, blipsize); + painter.setPen (pen); + painter.setBrush (color); + painter.drawEllipse (pos.x() - blipsize / 2, pos.y() - blipsize / 2, blipsize, blipsize); +} + +void GLRenderer::drawBlipCoordinates (QPainter& painter, const Vertex& pos3d) +{ + drawBlipCoordinates (painter, pos3d, convert3dTo2d (pos3d)); +} + +void GLRenderer::drawBlipCoordinates (QPainter& painter, const Vertex& pos3d, QPointF pos) +{ + painter.setPen (textPen()); + painter.drawText (pos.x(), pos.y() - 8, pos3d.toString (true)); } // ============================================================================= diff -r a6b462051ae0 -r 74cb432812d3 src/glRenderer.h --- a/src/glRenderer.h Sun Oct 04 14:08:51 2015 +0300 +++ b/src/glRenderer.h Sun Oct 04 16:45:30 2015 +0300 @@ -151,7 +151,9 @@ EditModeType currentEditModeType() const; int depthNegateFactor() const; LDDocument* document() const; - void drawBlip (QPainter& paint, QPointF pos, QColor color = QColor (64, 192, 0)) const; + void drawBlip (QPainter& painter, QPointF pos, QColor color = QColor (64, 192, 0)) const; + void drawBlipCoordinates (QPainter& painter, const Vertex& pos3d); + void drawBlipCoordinates (QPainter& painter, const Vertex& pos3d, QPointF pos); void drawGLScene(); void forgetObject (LDObject* obj); Axis getCameraAxis (bool y, ECamera camid = (ECamera) -1); diff -r a6b462051ae0 -r 74cb432812d3 src/ldObject.cpp --- a/src/ldObject.cpp Sun Oct 04 14:08:51 2015 +0300 +++ b/src/ldObject.cpp Sun Oct 04 16:45:30 2015 +0300 @@ -157,7 +157,7 @@ QString LDBezierCurve::asText() const { QString result = format ("0 !LDFORGE BEZIER_CURVE %1", color()); - + // Add the coordinates for (int i = 0; i < 4; ++i) result += format (" %1", vertex (i));