Thu, 09 Feb 2017 13:13:46 +0200
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
src/canvas.cpp | file | annotate | diff | comparison | revisions | |
src/canvas.h | file | annotate | diff | comparison | revisions | |
src/glRenderer.cpp | file | annotate | diff | comparison | revisions | |
src/glRenderer.h | file | annotate | diff | comparison | revisions |
--- a/src/canvas.cpp Thu Feb 09 13:07:47 2017 +0200 +++ b/src/canvas.cpp Thu Feb 09 13:13:46 2017 +0200 @@ -175,3 +175,32 @@ { return m_position3D; } + +void Canvas::drawPoint(QPainter& painter, QPointF pos, QColor color) const +{ + int pointSize = 8; + QPen pen = thinBorderPen; + pen.setWidth(1); + painter.setPen(pen); + painter.setBrush(color); + painter.drawEllipse(pos.x() - pointSize / 2, pos.y() - pointSize / 2, pointSize, pointSize); +} + +void Canvas::drawBlipCoordinates(QPainter& painter, const Vertex& pos3d) const +{ + drawBlipCoordinates (painter, pos3d, convert3dTo2d (pos3d)); +} + +void Canvas::drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) const +{ + painter.setPen (textPen()); + painter.drawText (pos.x(), pos.y() - 8, pos3d.toString (true)); +} + +QPen Canvas::linePen() const +{ + QPen linepen = thinBorderPen; + linepen.setWidth(2); + linepen.setColor(luma(backgroundColor()) < 40 ? Qt::white : Qt::black); + return linepen; +}
--- a/src/canvas.h Thu Feb 09 13:07:47 2017 +0200 +++ b/src/canvas.h Thu Feb 09 13:13:46 2017 +0200 @@ -28,6 +28,10 @@ EditModeType currentEditModeType() const; LDDocument* document() const; + void drawPoint(QPainter& painter, QPointF pos, QColor color = QColor (64, 192, 0)) const; + void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d) const; + void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) const; + QPen linePen() const; const Vertex& position3D() const; void setEditMode(EditModeType type);
--- a/src/glRenderer.cpp Thu Feb 09 13:07:47 2017 +0200 +++ b/src/glRenderer.cpp Thu Feb 09 13:13:46 2017 +0200 @@ -64,6 +64,8 @@ ConfigOption (bool DrawEdgeLines = true) ConfigOption (bool DrawConditionalLines = true) +const QPen GLRenderer::thinBorderPen {QColor {0, 0, 0, 208}, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; + // ============================================================================= // GLRenderer::GLRenderer(Model* model, QWidget* parent) : @@ -75,8 +77,6 @@ m_compiler = new GLCompiler (this); m_toolTipTimer = new QTimer (this); m_toolTipTimer->setSingleShot (true); - m_thinBorderPen = QPen (QColor (0, 0, 0, 208), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - m_thinBorderPen.setWidth (1); setAcceptDrops (true); connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (slot_toolTipTimer())); resetAllAngles(); @@ -311,6 +311,11 @@ } } +QColor GLRenderer::backgroundColor() const +{ + return m_backgroundColor; +} + // ============================================================================= // void GLRenderer::refresh() @@ -563,14 +568,6 @@ return {m_useDarkBackground ? Qt::white : Qt::black}; } -QPen GLRenderer::linePen() const -{ - QPen linepen = m_thinBorderPen; - linepen.setWidth(2); - linepen.setColor(luma(m_backgroundColor) < 40 ? Qt::white : Qt::black); - return linepen; -} - bool GLRenderer::freeCameraAllowed() const { return true; @@ -593,7 +590,7 @@ void GLRenderer::overpaint(QPainter &painter) { // Draw a background for the selected camera - painter.setPen(m_thinBorderPen); + painter.setPen(thinBorderPen); painter.setBrush(QBrush {QColor {0, 128, 160, 128}}); painter.drawRect(m_cameraIcons[camera()].hitRect); @@ -627,29 +624,6 @@ // ============================================================================= // -void GLRenderer::drawPoint(QPainter& painter, QPointF pos, QColor color) const -{ - int pointSize = 8; - QPen pen = m_thinBorderPen; - pen.setWidth(1); - painter.setPen(pen); - painter.setBrush(color); - painter.drawEllipse(pos.x() - pointSize / 2, pos.y() - pointSize / 2, pointSize, pointSize); -} - -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)); -} - -// ============================================================================= -// void GLRenderer::mouseReleaseEvent(QMouseEvent* event) { bool wasLeft = (m_lastButtons & Qt::LeftButton) and not (event->buttons() & Qt::LeftButton);
--- a/src/glRenderer.h Thu Feb 09 13:07:47 2017 +0200 +++ b/src/glRenderer.h Thu Feb 09 13:13:46 2017 +0200 @@ -73,6 +73,7 @@ GLRenderer(Model* model, QWidget* parent = nullptr); ~GLRenderer(); + QColor backgroundColor() const; Camera camera() const; const CameraInfo& cameraInfo(Camera camera) const; QString cameraName(Camera camera) const; @@ -83,9 +84,6 @@ QPoint convert3dTo2d(const Vertex& pos3d) const; QString currentCameraName() const; int depthNegateFactor() const; - void drawPoint(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, Camera camid = (Camera) -1); @@ -98,7 +96,6 @@ bool isDrawOnly() const; bool isPicking() const; Qt::KeyboardModifiers keyboardModifiers() const; - QPen linePen() const; void makeCurrent(); bool mouseHasMoved() const; QPoint const& mousePosition() const; @@ -119,6 +116,8 @@ QPen textPen() const; void zoomNotch(bool inward); + static const QPen thinBorderPen; + protected: void contextMenuEvent(QContextMenuEvent* event); void dragEnterEvent(QDragEnterEvent* event); @@ -175,7 +174,6 @@ QPoint m_mousePosition; QPoint m_globalpos; QPointF m_mousePositionF; - QPen m_thinBorderPen; Camera m_camera; Camera m_toolTipCamera; GLuint m_axeslist;