mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Use advanced editing for node tool
This commit is contained in:
parent
0661b2fdc4
commit
2dac139924
@ -34,13 +34,12 @@ QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas )
|
||||
: QgsMapToolEdit( canvas )
|
||||
, mSelectedFeature( 0 )
|
||||
, mNodeEditor( 0 )
|
||||
, mMoving( true )
|
||||
, mSelectAnother( false )
|
||||
, mRect( 0 )
|
||||
, mIsPoint( false )
|
||||
, mDeselectOnRelease( -1 )
|
||||
{
|
||||
mSnapper.setMapCanvas( canvas );
|
||||
mCadAllowed = true;
|
||||
mSnapOnPress = true;
|
||||
}
|
||||
|
||||
QgsMapToolNodeTool::~QgsMapToolNodeTool()
|
||||
@ -48,7 +47,7 @@ QgsMapToolNodeTool::~QgsMapToolNodeTool()
|
||||
cleanTool();
|
||||
}
|
||||
|
||||
void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
|
||||
void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
|
||||
{
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
if ( !vlayer )
|
||||
@ -66,6 +65,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
|
||||
}
|
||||
|
||||
bool hasVertexSelection = mSelectedFeature && mSelectedFeature->hasSelection();
|
||||
|
||||
if ( !mSelectedFeature || !hasVertexSelection )
|
||||
{
|
||||
//try to select feature
|
||||
@ -101,22 +101,17 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
|
||||
{
|
||||
if ( mSelectedFeature->hasSelection() && !ctrlModifier ) //move vertices
|
||||
{
|
||||
//move selected nodes and deselect all //where does 'mClosestMapVertex' come from?
|
||||
QList<QgsSnappingResult> snapResults;
|
||||
mSnapper.snapToBackgroundLayers( e->pos(), snapResults, QList<QgsPoint>() << mClosestMapVertex );
|
||||
QgsPoint targetCoords = toLayerCoordinates( vlayer, snapPointFromResults( snapResults, e->pos() ) );
|
||||
QgsPoint targetCoords = e->mapPoint();
|
||||
mSelectedFeature->moveSelectedVertexes( targetCoords - mClosestMapVertex );
|
||||
mCanvas->refresh();
|
||||
mSelectedFeature->deselectAllVertexes();
|
||||
}
|
||||
else //add vertex selection
|
||||
{
|
||||
//snap and add to selection
|
||||
QgsPoint layerCoordPoint = toLayerCoordinates( vlayer, e->pos() );
|
||||
int atVertex, beforeVertex, afterVertex;
|
||||
double dist;
|
||||
|
||||
QgsPoint closestLayerVertex = mSelectedFeature->geometry()->closestVertex( layerCoordPoint, atVertex, beforeVertex, afterVertex, dist );
|
||||
QgsPoint closestLayerVertex = mSelectedFeature->geometry()->closestVertex( e->mapPoint(), atVertex, beforeVertex, afterVertex, dist );
|
||||
mSelectedFeature->selectVertex( atVertex );
|
||||
mClosestMapVertex = toMapCoordinates( vlayer, closestLayerVertex );
|
||||
}
|
||||
@ -145,9 +140,6 @@ void QgsMapToolNodeTool::editingToggled()
|
||||
void QgsMapToolNodeTool::deactivate()
|
||||
{
|
||||
cleanTool();
|
||||
mSelectAnother = false;
|
||||
mMoving = true;
|
||||
|
||||
QgsMapTool::deactivate();
|
||||
}
|
||||
|
||||
@ -184,7 +176,6 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
|
||||
QMultiMap<double, QgsSnappingResult> currentResultList;
|
||||
|
||||
QList<QgsSnappingResult> snapResults;
|
||||
mMoving = false;
|
||||
double tol = QgsTolerance::vertexSearchRadius( vlayer, mCanvas->mapSettings() );
|
||||
mSnapper.snapToCurrentLayer( e->pos(), snapResults, QgsSnapper::SnapToSegment, tol );
|
||||
if ( snapResults.size() < 1 ||
|
||||
|
@ -36,7 +36,8 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
|
||||
|
||||
void canvasDoubleClickEvent( QMouseEvent * e );
|
||||
|
||||
void canvasPressEvent( QMouseEvent * e );
|
||||
//! mouse press event in map coordinates (eventually filtered) to be redefined in subclass
|
||||
void canvasMapPressEvent( QgsMapMouseEvent* e ) override;
|
||||
|
||||
void keyPressEvent( QKeyEvent* e );
|
||||
|
||||
@ -109,12 +110,6 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
|
||||
/** Dock widget which allows to edit vertices */
|
||||
QgsNodeEditor* mNodeEditor;
|
||||
|
||||
/** Flag if moving of vertexes is occuring */
|
||||
bool mMoving;
|
||||
|
||||
/** Flag if selection of another feature can occur */
|
||||
bool mSelectAnother;
|
||||
|
||||
/** Feature id of another feature where user clicked */
|
||||
QgsFeatureId mAnother;
|
||||
|
||||
@ -129,9 +124,6 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
|
||||
|
||||
/** Flag to tell if edition points */
|
||||
bool mIsPoint;
|
||||
|
||||
/** Vertex to deselect on release */
|
||||
int mDeselectOnRelease;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -853,8 +853,7 @@ bool QgsAdvancedDigitizingDockWidget::alignToSegment( QgsMapMouseEvent* e, CadCo
|
||||
|
||||
bool QgsAdvancedDigitizingDockWidget::canvasPressEventFilter( QgsMapMouseEvent* e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
|
||||
applyConstraints( e );
|
||||
return mCadEnabled && mConstructionMode;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user