Skip to content

Commit

Permalink
fix add new mesh with cad tool
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec committed Apr 26, 2023
1 parent 0f0aa2b commit 4126061
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Expand Up @@ -356,9 +356,16 @@ Adds point to the CAD point list

void removePreviousPoint();
%Docstring
Remove previous point in the CAD point list
Removes previous point in the CAD point list

.. versionadded:: 3.8
%End

void updateCurrentPoint( const QgsPointXY &point );
%Docstring
Updates the current ``point`` in the CAD point list

.. versionadded:: 3.30.2
%End

void setPoints( const QList<QgsPointXY> &points );
Expand Down
14 changes: 10 additions & 4 deletions src/app/mesh/qgsmaptooleditmeshframe.cpp
Expand Up @@ -946,8 +946,12 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
if ( mCurrentVertexIndex != -1 )
{
addVertexToFaceCanditate( mCurrentVertexIndex );
const QgsPointXY currentPoint = mapVertexXY( mCurrentVertexIndex );
cadDockWidget()->setPoints( QList<QgsPointXY>() << currentPoint << currentPoint );
// Advanced digitizing base class adds a point at map point not at vertex position
// so we need to replace it by the position of the vertex
const QgsPointXY &currentPoint = mapVertexXY( mCurrentVertexIndex );
cadDockWidget()->updateCurrentPoint( currentPoint );
cadDockWidget()->removePreviousPoint();
cadDockWidget()->addPoint( currentPoint );
}
else
{
Expand All @@ -962,8 +966,6 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
if ( acceptPoint )
{
addVertexToFaceCanditate( mapPoint );
const QgsPointXY currentPoint( mapPoint );
cadDockWidget()->setPoints( QList<QgsPointXY>() << currentPoint << currentPoint );
}
}
}
Expand Down Expand Up @@ -1224,6 +1226,8 @@ void QgsMapToolEditMeshFrame::keyPressEvent( QKeyEvent *e )
if ( mNewFaceCandidate.isEmpty() )
mCurrentState = Digitizing;

mCadDockWidget->removePreviousPoint();

consumned = true;
}

Expand Down Expand Up @@ -1939,13 +1943,15 @@ void QgsMapToolEditMeshFrame::onUndoRedo()
mNewFaceCandidate.clear();
mNewVerticesForNewFaceCandidate.clear();
mCurrentState = Digitizing;
mCadDockWidget->clearPoints();
break;
case MovingSelection:
mCurrentState = Digitizing;
mMovingEdgesRubberband->reset( Qgis::GeometryType::Line );
mMovingFacesRubberband->reset( Qgis::GeometryType::Polygon );
mMovingFreeVertexRubberband->reset( Qgis::GeometryType::Point );
mCadDockWidget->setEnabledZ( mCadDockWidget->cadEnabled() );
mCadDockWidget->clearPoints();
break;
case ForceByLines:
case Selecting:
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsadvanceddigitizingdockwidget.cpp
Expand Up @@ -1745,6 +1745,11 @@ void QgsAdvancedDigitizingDockWidget::updateCurrentPoint( const QgsPoint &point
updateCadPaintItem();
}

void QgsAdvancedDigitizingDockWidget::updateCurrentPoint( const QgsPointXY &point )
{
updateCurrentPoint( QgsPoint( point ) );
}


void QgsAdvancedDigitizingDockWidget::CadConstraint::setLockMode( LockMode mode )
{
Expand Down
8 changes: 7 additions & 1 deletion src/gui/qgsadvanceddigitizingdockwidget.h
Expand Up @@ -356,11 +356,17 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
void addPoint( const QgsPointXY &point );

/**
* Remove previous point in the CAD point list
* Removes previous point in the CAD point list
* \since QGIS 3.8
*/
void removePreviousPoint();

/**
* Updates the current \a point in the CAD point list
* \since QGIS 3.30.2
*/
void updateCurrentPoint( const QgsPointXY &point );

/**
* Configures list of current CAD points
*
Expand Down

0 comments on commit 4126061

Please sign in to comment.