mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Better synchronisation between node editor and node tool
This commit is contained in:
parent
9f8aa8494a
commit
863bf88f2b
@ -90,6 +90,7 @@ void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
|
||||
mSelectedFeature = new QgsSelectedFeature( snapResults[0].snappedAtGeometry, vlayer, mCanvas );
|
||||
connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) );
|
||||
connect( mSelectedFeature, SIGNAL( destroyed() ), this, SLOT( selectedFeatureDestroyed() ) );
|
||||
connect( mSelectedFeature, SIGNAL( lastVertexChanged( const QgsPointV2& ) ), this, SLOT( changeLastVertex( const QgsPointV2& ) ) );
|
||||
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
|
||||
mIsPoint = vlayer->geometryType() == QGis::Point;
|
||||
mNodeEditor = new QgsNodeEditor( vlayer, mSelectedFeature, mCanvas );
|
||||
@ -113,7 +114,7 @@ void QgsMapToolNodeTool::canvasMapPressEvent( QgsMapMouseEvent* e )
|
||||
|
||||
QgsPoint closestLayerVertex = mSelectedFeature->geometry()->closestVertex( e->mapPoint(), atVertex, beforeVertex, afterVertex, dist );
|
||||
mSelectedFeature->selectVertex( atVertex );
|
||||
mClosestMapVertex = toMapCoordinates( vlayer, closestLayerVertex );
|
||||
//mClosestMapVertex = toMapCoordinates( vlayer, closestLayerVertex );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -309,3 +310,8 @@ int QgsMapToolNodeTool::insertSegmentVerticesForSnap( const QList<QgsSnappingRes
|
||||
|
||||
return editedLayer->insertSegmentVerticesForSnap( transformedSnapResults );
|
||||
}
|
||||
|
||||
void QgsMapToolNodeTool::changeLastVertex( const QgsPointV2& pt )
|
||||
{
|
||||
mClosestMapVertex = toMapCoordinates( currentVectorLayer(), QgsPoint( pt.x(), pt.y() ) );
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ class QgsMapToolNodeTool: public QgsMapToolEdit
|
||||
*/
|
||||
void editingToggled();
|
||||
|
||||
void changeLastVertex( const QgsPointV2& pt );
|
||||
|
||||
private:
|
||||
/**
|
||||
* Deletes the rubber band pointers and clears mRubberBands
|
||||
|
@ -225,12 +225,14 @@ void QgsNodeEditor::updateTableSelection()
|
||||
|
||||
void QgsNodeEditor::updateNodeSelection()
|
||||
{
|
||||
mSelectedFeature->blockSignals( true );
|
||||
disconnect( mSelectedFeature, SIGNAL( selectionChanged() ), this, SLOT( updateTableSelection() ) );
|
||||
|
||||
mSelectedFeature->deselectAllVertexes();
|
||||
foreach ( const QModelIndex& index, mTableWidget->selectionModel()->selectedRows() )
|
||||
{
|
||||
int nodeIdx = mTableWidget->item( index.row(), 0 )->data( Qt::DisplayRole ).toInt();
|
||||
mSelectedFeature->selectVertex( nodeIdx );
|
||||
}
|
||||
mSelectedFeature->blockSignals( false );
|
||||
|
||||
connect( mSelectedFeature, SIGNAL( selectionChanged() ), this, SLOT( updateTableSelection() ) );
|
||||
}
|
||||
|
@ -433,6 +433,7 @@ void QgsSelectedFeature::selectVertex( int vertexNr )
|
||||
entry->setSelected();
|
||||
|
||||
emit selectionChanged();
|
||||
emit lastVertexChanged( entry->point() );
|
||||
}
|
||||
|
||||
void QgsSelectedFeature::deselectVertex( int vertexNr )
|
||||
@ -442,8 +443,23 @@ void QgsSelectedFeature::deselectVertex( int vertexNr )
|
||||
|
||||
QgsVertexEntry *entry = mVertexMap[vertexNr];
|
||||
entry->setSelected( false );
|
||||
|
||||
emit selectionChanged();
|
||||
|
||||
//todo: take another selected vertex as 'lastVertexChanged'
|
||||
QList<QgsVertexEntry*>::const_iterator vIt = mVertexMap.constBegin();
|
||||
for ( ; vIt != mVertexMap.constEnd(); ++vIt )
|
||||
{
|
||||
if (( *vIt )->isSelected() )
|
||||
{
|
||||
emit lastVertexChanged(( *vIt )->point() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( vIt == mVertexMap.constEnd() )
|
||||
{
|
||||
emit lastVertexChanged( QgsPointV2() ); //no selection anymore
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSelectedFeature::deselectAllVertexes()
|
||||
@ -453,6 +469,7 @@ void QgsSelectedFeature::deselectAllVertexes()
|
||||
mVertexMap[i]->setSelected( false );
|
||||
}
|
||||
emit selectionChanged();
|
||||
emit lastVertexChanged( QgsPointV2() );
|
||||
}
|
||||
|
||||
void QgsSelectedFeature::invertVertexSelection( int vertexNr )
|
||||
@ -466,6 +483,10 @@ void QgsSelectedFeature::invertVertexSelection( int vertexNr )
|
||||
|
||||
entry->setSelected( selected );
|
||||
emit selectionChanged();
|
||||
if ( selected )
|
||||
{
|
||||
emit lastVertexChanged( entry->point() );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSelectedFeature::updateVertexMarkersPosition()
|
||||
|
@ -133,6 +133,7 @@ class QgsSelectedFeature: public QObject
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
void lastVertexChanged( const QgsPointV2& pt );
|
||||
void vertexMapChanged();
|
||||
|
||||
public slots:
|
||||
|
Loading…
x
Reference in New Issue
Block a user