feat: Render active sketch tool icon at cursor position
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
#include <QPropertyAnimation>
|
||||
@@ -23,6 +24,10 @@ ViewportWidget::ViewportWidget(QWidget *parent)
|
||||
m_sketchGrid = new SketchGrid();
|
||||
m_featureBrowser = new FeatureBrowser();
|
||||
setMouseTracking(true);
|
||||
|
||||
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Line), new QSvgRenderer(QString(":/icons/line.svg"), this));
|
||||
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Rectangle), new QSvgRenderer(QString(":/icons/rectangle.svg"), this));
|
||||
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Circle), new QSvgRenderer(QString(":/icons/circle.svg"), this));
|
||||
}
|
||||
|
||||
ViewportWidget::~ViewportWidget()
|
||||
@@ -148,6 +153,17 @@ void ViewportWidget::paintGL()
|
||||
drawAxisLabels(painter, model, projection);
|
||||
}
|
||||
m_featureBrowser->paint(painter, width(), height());
|
||||
|
||||
if (m_currentPlane != SketchPlane::NONE && m_activeTool != static_cast<int>(ApplicationController::ToolType::None) && m_toolIcons.contains(m_activeTool)) {
|
||||
QSvgRenderer* renderer = m_toolIcons.value(m_activeTool);
|
||||
if (renderer && renderer->isValid()) {
|
||||
const QSize iconSize(16, 16);
|
||||
const QPoint iconPos = m_currentMousePos + QPoint(15, 15);
|
||||
const QRect iconRect(iconPos, iconSize);
|
||||
renderer->render(&painter, iconRect);
|
||||
}
|
||||
}
|
||||
|
||||
painter.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#include <QVector3D>
|
||||
#include <QRect>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <QMap>
|
||||
|
||||
class QSvgRenderer;
|
||||
class ViewCube;
|
||||
class SketchGrid;
|
||||
class Document;
|
||||
@@ -88,6 +90,8 @@ private:
|
||||
gp_Pnt m_firstLinePoint;
|
||||
QPoint m_currentMousePos;
|
||||
|
||||
QMap<int, QSvgRenderer*> m_toolIcons;
|
||||
|
||||
float m_xRot = 35.264f * 16.0f; // Default to isometric view
|
||||
float m_yRot = -45.0f * 16.0f; // Default to isometric view
|
||||
float m_zoom = -5.0f;
|
||||
|
||||
Reference in New Issue
Block a user