Change movement of Qgs3DMapToolPointCloudChangeAttributePolygon

Movement of camera is possible only before selection
This commit is contained in:
Withalion 2025-03-06 10:50:35 +01:00 committed by Martin Dobias
parent ea2988f1f5
commit 231723e1c7
2 changed files with 24 additions and 37 deletions

View File

@ -36,16 +36,11 @@ Qgs3DMapToolPointCloudChangeAttributePolygon::~Qgs3DMapToolPointCloudChangeAttri
void Qgs3DMapToolPointCloudChangeAttributePolygon::mousePressEvent( QMouseEvent *event ) void Qgs3DMapToolPointCloudChangeAttributePolygon::mousePressEvent( QMouseEvent *event )
{ {
if ( !mIsMoving )
{
mClickPoint = event->pos(); mClickPoint = event->pos();
}
} }
void Qgs3DMapToolPointCloudChangeAttributePolygon::mouseMoveEvent( QMouseEvent *event ) void Qgs3DMapToolPointCloudChangeAttributePolygon::mouseMoveEvent( QMouseEvent *event )
{ {
if ( !mIsMoving )
{
if ( mToolType != Polygon && mScreenPoints.size() == 2 ) if ( mToolType != Polygon && mScreenPoints.size() == 2 )
return; return;
const QgsPoint movedPoint = Qgs3DUtils::screenPointToMapCoordinates( event->pos(), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() ); const QgsPoint movedPoint = Qgs3DUtils::screenPointToMapCoordinates( event->pos(), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() );
@ -63,7 +58,6 @@ void Qgs3DMapToolPointCloudChangeAttributePolygon::mouseMoveEvent( QMouseEvent *
mPolygonRubberBand->addPoint( movedPoint ); mPolygonRubberBand->addPoint( movedPoint );
} }
} }
}
} }
void Qgs3DMapToolPointCloudChangeAttributePolygon::keyPressEvent( QKeyEvent *event ) void Qgs3DMapToolPointCloudChangeAttributePolygon::keyPressEvent( QKeyEvent *event )
@ -90,17 +84,11 @@ void Qgs3DMapToolPointCloudChangeAttributePolygon::keyPressEvent( QKeyEvent *eve
{ {
restart(); restart();
} }
else if ( event->key() == Qt::Key_Space )
{
const bool newState = !mCanvas->cameraController()->hasInputHandlersEnabled();
mCanvas->cameraController()->setInputHandlersEnabled( newState );
mIsMoving = newState;
}
} }
void Qgs3DMapToolPointCloudChangeAttributePolygon::mouseReleaseEvent( QMouseEvent *event ) void Qgs3DMapToolPointCloudChangeAttributePolygon::mouseReleaseEvent( QMouseEvent *event )
{ {
if ( ( event->pos() - mClickPoint ).manhattanLength() > QApplication::startDragDistance() || mIsMoving ) if ( ( event->pos() - mClickPoint ).manhattanLength() > QApplication::startDragDistance() )
return; return;
const QgsPoint newPoint = Qgs3DUtils::screenPointToMapCoordinates( event->pos(), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() ); const QgsPoint newPoint = Qgs3DUtils::screenPointToMapCoordinates( event->pos(), mCanvas->size(), mCanvas->cameraController(), mCanvas->mapSettings() );

View File

@ -33,14 +33,14 @@ class Qgs3DMapToolPointCloudChangeAttributePolygon : public Qgs3DMapToolPointClo
* \since QGIS 3.44 * \since QGIS 3.44
*/ */
enum ToolType enum ToolType
{ {
//! Polygon defined by vertices //! Polygon defined by vertices
Polygon, Polygon,
//! Polygon defined by 2 vertices and canvas top edge //! Polygon defined by 2 vertices and canvas top edge
AboveLinePolygon, AboveLinePolygon,
//! Polygon defined by 2 vertices and canvas bottom edge //! Polygon defined by 2 vertices and canvas bottom edge
BelowLinePolygon, BelowLinePolygon,
}; };
Qgs3DMapToolPointCloudChangeAttributePolygon( Qgs3DMapCanvas *canvas, ToolType type ); Qgs3DMapToolPointCloudChangeAttributePolygon( Qgs3DMapCanvas *canvas, ToolType type );
~Qgs3DMapToolPointCloudChangeAttributePolygon() override; ~Qgs3DMapToolPointCloudChangeAttributePolygon() override;
@ -61,7 +61,6 @@ class Qgs3DMapToolPointCloudChangeAttributePolygon : public Qgs3DMapToolPointClo
QgsRubberBand3D *mPolygonRubberBand = nullptr; QgsRubberBand3D *mPolygonRubberBand = nullptr;
QgsRubberBand3D *mLineRubberBand = nullptr; QgsRubberBand3D *mLineRubberBand = nullptr;
QPoint mClickPoint; QPoint mClickPoint;
bool mIsMoving = false;
ToolType mToolType; ToolType mToolType;
}; };