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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user