mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
fix snapping indicator when advance digitizing tools is enabled
This commit is contained in:
parent
443afcd0bf
commit
f002a9c43d
@ -242,6 +242,10 @@ Constraint on the Y coordinate
|
||||
bool commonAngleConstraint() const;
|
||||
%Docstring
|
||||
Constraint on a common angle
|
||||
%End
|
||||
QgsPointLocator::Match mapPointMatch() const;
|
||||
%Docstring
|
||||
SnapMatch for indicator
|
||||
%End
|
||||
|
||||
void clearPoints();
|
||||
|
@ -28,6 +28,7 @@ QgsAdvancedDigitizingCanvasItem::QgsAdvancedDigitizingCanvasItem( QgsMapCanvas *
|
||||
, mSnapPen( QPen( QColor( 127, 0, 0, 150 ), 1 ) )
|
||||
, mSnapLinePen( QPen( QColor( 127, 0, 0, 150 ), 1, Qt::DashLine ) )
|
||||
, mCursorPen( QPen( QColor( 127, 127, 127, 255 ), 1 ) )
|
||||
, mSnapIndicator( qgis::make_unique< QgsSnapIndicator>( canvas ) )
|
||||
, mAdvancedDigitizingDockWidget( cadDockWidget )
|
||||
{
|
||||
}
|
||||
@ -236,7 +237,16 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
|
||||
curPointPix + QPointF( +5, +5 ) );
|
||||
painter->drawLine( curPointPix + QPointF( -5, +5 ),
|
||||
curPointPix + QPointF( +5, -5 ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
QgsPointLocator::Match match = mAdvancedDigitizingDockWidget->mapPointMatch();
|
||||
if ( match.isValid() )
|
||||
{
|
||||
mSnapIndicator->setMatch( match );
|
||||
mSnapIndicator->setVisible( true );
|
||||
}
|
||||
else
|
||||
mSnapIndicator->setVisible( false );
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "qgsmapcanvasitem.h"
|
||||
#include "qgis_gui.h"
|
||||
#include "qgssnapindicator.h"
|
||||
|
||||
class QgsAdvancedDigitizingDockWidget;
|
||||
|
||||
@ -41,6 +42,8 @@ class GUI_EXPORT QgsAdvancedDigitizingCanvasItem : public QgsMapCanvasItem
|
||||
QPen mSnapPen;
|
||||
QPen mSnapLinePen;
|
||||
QPen mCursorPen;
|
||||
//! Snapping indicators
|
||||
std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
|
||||
|
||||
private:
|
||||
QgsAdvancedDigitizingDockWidget *mAdvancedDigitizingDockWidget = nullptr;
|
||||
|
@ -557,6 +557,8 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e )
|
||||
// set the point coordinates in the map event
|
||||
e->setMapPoint( point );
|
||||
|
||||
mSnapMatch = context.snappingUtils->snapToMap( point );
|
||||
|
||||
// update the point list
|
||||
updateCurrentPoint( point );
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "qgsdockwidget.h"
|
||||
#include "qgsmessagebaritem.h"
|
||||
#include "qgspointxy.h"
|
||||
#include "qgspointlocator.h"
|
||||
|
||||
|
||||
class QgsAdvancedDigitizingCanvasItem;
|
||||
@ -255,6 +256,8 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
|
||||
const CadConstraint *constraintY() const { return mYConstraint.get(); }
|
||||
//! Constraint on a common angle
|
||||
bool commonAngleConstraint() const { return !qgsDoubleNear( mCommonAngleConstraint, 0.0 ); }
|
||||
//! SnapMatch for indicator
|
||||
QgsPointLocator::Match mapPointMatch() const { return mSnapMatch; }
|
||||
|
||||
/**
|
||||
* Removes all points from the CAD point list
|
||||
@ -485,6 +488,9 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
|
||||
QAction *mEnableAction = nullptr;
|
||||
QMap< QAction *, double > mCommonAngleActions; // map the common angle actions with their angle values
|
||||
|
||||
// Snap indicator
|
||||
|
||||
QgsPointLocator::Match mSnapMatch;
|
||||
private:
|
||||
#ifdef SIP_RUN
|
||||
//! event filter for line edits in the dock UI (angle/distance/x/y line edits)
|
||||
|
@ -30,7 +30,6 @@ QgsSnapIndicator::QgsSnapIndicator( QgsMapCanvas *canvas )
|
||||
|
||||
QgsSnapIndicator::~QgsSnapIndicator() = default;
|
||||
|
||||
|
||||
void QgsSnapIndicator::setMatch( const QgsPointLocator::Match &match )
|
||||
{
|
||||
mMatch = match;
|
||||
@ -65,6 +64,7 @@ void QgsSnapIndicator::setMatch( const QgsPointLocator::Match &match )
|
||||
{
|
||||
iconType = QgsVertexMarker::ICON_DOUBLE_TRIANGLE;
|
||||
}
|
||||
|
||||
mSnappingMarker->setIconType( iconType );
|
||||
|
||||
mSnappingMarker->setCenter( match.point() );
|
||||
@ -83,10 +83,14 @@ void QgsSnapIndicator::setMatch( const QgsPointLocator::Match &match )
|
||||
|
||||
void QgsSnapIndicator::setVisible( bool visible )
|
||||
{
|
||||
mSnappingMarker->setVisible( visible );
|
||||
if ( mSnappingMarker )
|
||||
mSnappingMarker->setVisible( visible );
|
||||
}
|
||||
|
||||
bool QgsSnapIndicator::isVisible() const
|
||||
{
|
||||
return mSnappingMarker->isVisible();
|
||||
if ( mSnappingMarker )
|
||||
return mSnappingMarker->isVisible();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user