Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix snapping with mesh editing map tool
  • Loading branch information
vcloarec authored and nyalldawson committed Oct 29, 2021
1 parent 5866c84 commit 8ac5383
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/app/mesh/qgsmaptooleditmeshframe.cpp
Expand Up @@ -901,8 +901,9 @@ void QgsMapToolEditMeshFrame::cadCanvasMoveEvent( QgsMapMouseEvent *e )
}
else if ( matchPoint.isValid() && matchPoint.layer() && QgsWkbTypes::hasZ( matchPoint.layer()->wkbType() ) )
{
mForceByLineRubberBand->movePoint( mapPoint );
if ( mZValueWidget )
mZValueWidget->setZValue( e->mapPointMatch().interpolatedPoint().z() );
mZValueWidget->setZValue( e->mapPointMatch().interpolatedPoint( mCanvas->mapSettings().destinationCrs() ).z() );
}
else
{
Expand Down Expand Up @@ -1052,8 +1053,11 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
if ( e->mapPointMatch().isValid() &&
QgsWkbTypes::hasZ( e->mapPointMatch().layer()->wkbType() ) )
{
const QgsMeshVertex mapPointInMapCoordinate =
QgsMeshVertex( mapPoint.x(), mapPoint.y(), e->mapPointMatch().interpolatedPoint( mCanvas->mapSettings().destinationCrs() ).z() );

const QgsMeshVertex &mapPointInNativeCoordinate =
mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( mapPoint.x(), mapPoint.y(), e->mapPointMatch().interpolatedPoint().z() ) );
mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( mapPointInMapCoordinate ) ;
mCurrentEditor->changeCoordinates( verticesIndexes,
QList<QgsPoint>()
<< mapPointInNativeCoordinate ) ;
Expand Down Expand Up @@ -2285,6 +2289,8 @@ void QgsMapToolEditMeshFrame::forceByLineReleaseEvent( QgsMapMouseEvent *e )

if ( e->button() == Qt::LeftButton )
{
double zValue = currentZValue();

if ( mCurrentVertexIndex != -1 )
{
const QgsPointXY currentPoint = mapVertexXY( mCurrentVertexIndex );
Expand All @@ -2294,10 +2300,16 @@ void QgsMapToolEditMeshFrame::forceByLineReleaseEvent( QgsMapMouseEvent *e )
}
else
{
if ( e->mapPointMatch().isValid() )
{
QgsPoint layerPoint = e->mapPointMatch().interpolatedPoint( mCanvas->mapSettings().destinationCrs() );
zValue = layerPoint.z();
}

mForceByLineRubberBand->addPoint( mapPoint );
}

mForcingLineZValue.append( currentZValue() );
mForcingLineZValue.append( zValue );
}
else if ( e->button() == Qt::RightButton )
{
Expand Down

0 comments on commit 8ac5383

Please sign in to comment.