Skip to content

Commit

Permalink
Add more controls to paintbrush tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Withalion committed Feb 3, 2025
1 parent 35d1cb8 commit de4cda5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app/3d/qgs3dmaptoolpaintbrush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ QCursor Qgs3DMapToolPaintBrush::cursor() const
void Qgs3DMapToolPaintBrush::reset()
{
mDragPositions.clear();
mHighlighterRubberBand->reset();
mIsClicked = false;
}

void Qgs3DMapToolPaintBrush::setAttribute( const QString &attribute )
Expand Down Expand Up @@ -215,7 +217,7 @@ void Qgs3DMapToolPaintBrush::mousePressEvent( QMouseEvent *event )

void Qgs3DMapToolPaintBrush::mouseReleaseEvent( QMouseEvent *event )
{
if ( event->button() == Qt::LeftButton )
if ( mIsClicked && event->button() == Qt::LeftButton )
{
mDragPositions.append( QgsPointXY( event->x(), event->y() ) );
mHighlighterRubberBand->reset();
Expand Down Expand Up @@ -244,7 +246,7 @@ void Qgs3DMapToolPaintBrush::mouseWheelEvent( QWheelEvent *event )
{
// Change the selection circle size. Moving the wheel forward (away) from the user makes
// the circle smaller
if ( event->angleDelta().y() == 0 )
if ( event->angleDelta().y() == 0 || !event->modifiers().testFlag( Qt::ControlModifier ) )
{
event->accept();
return;
Expand All @@ -258,3 +260,11 @@ void Qgs3DMapToolPaintBrush::mouseWheelEvent( QWheelEvent *event )
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
mSelectionRubberBand->setWidth( mSelectionRubberBand->width() * zoomFactor );
}

void Qgs3DMapToolPaintBrush::keyPressEvent( QKeyEvent *event )
{
if ( mIsClicked && event->key() == Qt::Key_Escape )
{
reset();
}
}
1 change: 1 addition & 0 deletions src/app/3d/qgs3dmaptoolpaintbrush.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Qgs3DMapToolPaintBrush : public Qgs3DMapTool
void mouseReleaseEvent( QMouseEvent *event ) override;
void mouseMoveEvent( QMouseEvent *event ) override;
void mouseWheelEvent( QWheelEvent *event ) override;
void keyPressEvent( QKeyEvent *event ) override;

private:
//! Process the area selected by user
Expand Down

0 comments on commit de4cda5

Please sign in to comment.