Skip to content

Commit

Permalink
fix add new mesh face with undo
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec committed Apr 26, 2023
1 parent 26469a5 commit 01d7cb1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/app/mesh/qgsmaptooleditmeshframe.cpp
Expand Up @@ -1438,6 +1438,7 @@ void QgsMapToolEditMeshFrame::setCurrentLayer( QgsMapLayer *layer )
{
disconnect( mCurrentLayer, &QgsMeshLayer::editingStarted, this, &QgsMapToolEditMeshFrame::onEditingStarted );
disconnect( mCurrentLayer, &QgsMeshLayer::editingStopped, this, &QgsMapToolEditMeshFrame::onEditingStopped );
disconnect( mCurrentLayer->undoStack(), &QUndoStack::indexChanged, this, &QgsMapToolEditMeshFrame::onUndoRedo );
}

mCurrentLayer = meshLayer;
Expand All @@ -1454,6 +1455,7 @@ void QgsMapToolEditMeshFrame::setCurrentLayer( QgsMapLayer *layer )
{
connect( mCurrentLayer, &QgsMeshLayer::editingStarted, this, &QgsMapToolEditMeshFrame::onEditingStarted );
connect( mCurrentLayer, &QgsMeshLayer::editingStopped, this, &QgsMapToolEditMeshFrame::onEditingStopped );
connect( mCurrentLayer->undoStack(), &QUndoStack::indexChanged, this, &QgsMapToolEditMeshFrame::onUndoRedo );

if ( mCurrentLayer->isEditable() )
{
Expand Down Expand Up @@ -1926,6 +1928,33 @@ void QgsMapToolEditMeshFrame::reindexMesh()
mCurrentLayer->reindex( transform, true );
}

void QgsMapToolEditMeshFrame::onUndoRedo()
{
switch ( mCurrentState )
{
case Digitizing:
break;
case AddingNewFace:
mNewFaceBand->reset( Qgis::GeometryType::Polygon );
mNewFaceCandidate.clear();
mNewVerticesForNewFaceCandidate.clear();
mCurrentState = Digitizing;
break;
case MovingSelection:
mCurrentState = Digitizing;
mMovingEdgesRubberband->reset( Qgis::GeometryType::Line );
mMovingFacesRubberband->reset( Qgis::GeometryType::Polygon );
mMovingFreeVertexRubberband->reset( Qgis::GeometryType::Point );
mCadDockWidget->setEnabledZ( mCadDockWidget->cadEnabled() );
break;
case ForceByLines:
break;
case Selecting:
case SelectingByPolygon:
break;
}
}

void QgsMapToolEditMeshFrame::selectByGeometry( const QgsGeometry &geometry, Qt::KeyboardModifiers modifiers )
{
if ( mCurrentLayer.isNull() || !mCurrentLayer->triangularMesh() || mCurrentEditor.isNull() )
Expand Down
1 change: 1 addition & 0 deletions src/app/mesh/qgsmaptooleditmeshframe.h
Expand Up @@ -165,6 +165,7 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing
void selectByExpression( const QString &textExpression, Qgis::SelectBehavior behavior, QgsMesh::ElementType elementType );
void onZoomToSelected();
void reindexMesh();
void onUndoRedo();

private:

Expand Down

0 comments on commit 01d7cb1

Please sign in to comment.