25 , mLockedPen( QPen( QColor( 0, 127, 0, 255 ), 1, Qt::DashLine ) )
26 , mConstruction1Pen( QPen( QColor( 127, 127, 127, 150 ), 1, Qt::DashLine ) )
27 , mConstruction2Pen( QPen( QColor( 127, 127, 127, 255 ), 1, Qt::DashLine ) )
28 , mSnapPen( QPen( QColor( 127, 0, 0, 150 ), 1 ) )
29 , mSnapLinePen( QPen( QColor( 127, 0, 0, 150 ), 1, Qt::DashLine ) )
30 , mCursorPen( QPen( QColor( 127, 127, 127, 255 ), 1 ) )
32 , mAdvancedDigitizingDockWidget( cadDockWidget )
38 if ( !mAdvancedDigitizingDockWidget->
cadEnabled() )
42 if (
rect() != mapRect )
45 int nPoints = mAdvancedDigitizingDockWidget->
pointsCount();
49 bool previousPointExist, penulPointExist;
53 const bool snappedToVertex = mAdvancedDigitizingDockWidget->
snappedToVertex();
54 const QList<QgsPointXY> snappedSegment = mAdvancedDigitizingDockWidget->
snappedSegment();
55 const bool hasSnappedSegment = snappedSegment.count() == 2;
57 const bool curPointExist = mapRect.
contains( curPoint );
63 QPointF curPointPix, prevPointPix, penulPointPix, snapSegmentPix1, snapSegmentPix2;
69 if ( previousPointExist )
73 if ( penulPointExist )
77 if ( hasSnappedSegment )
83 painter->setRenderHint( QPainter::Antialiasing );
84 painter->setCompositionMode( QPainter::CompositionMode_Difference );
87 if ( curPointExist && snappedToVertex )
90 painter->drawEllipse( curPointPix, 10, 10 );
94 if ( hasSnappedSegment && !snappedToVertex )
97 painter->drawLine( snapSegmentPix1, snapSegmentPix2 );
102 painter->drawLine( snapSegmentPix1, curPointPix );
110 painter->drawLine( snapSegmentPix1, snapSegmentPix2 );
119 a0 = std::atan2( -( prevPoint.
y() - penulPoint.
y() ), prevPoint.
x() - penulPoint.
x() );
131 a = std::atan2( -( curPoint.
y() - prevPoint.
y() ), curPoint.
x() - prevPoint.
x() );
134 painter->drawArc( QRectF( prevPointPix.x() - 20,
135 prevPointPix.y() - 20,
137 static_cast<int>( 16 * -a0 * 180 / M_PI ),
138 static_cast<int>( 16 * ( a0 - a ) * 180 / M_PI ) );
139 painter->drawLine( prevPointPix,
140 prevPointPix + 60 * QPointF( std::cos( a0 ), std::sin( a0 ) ) );
147 painter->drawLine( prevPointPix - d * QPointF( std::cos( a ), std::sin( a ) ),
148 prevPointPix + d * QPointF( std::cos( a ), std::sin( a ) ) );
157 painter->drawEllipse( prevPointPix, r, r );
170 x = mAdvancedDigitizingDockWidget->
constraintX()->
value() / mupp + prevPointPix.x();
183 painter->drawLine( QPointF( x, 0 ),
199 y = -mAdvancedDigitizingDockWidget->
constraintY()->
value() / mupp + prevPointPix.y();
212 painter->drawLine( QPointF( 0, y ),
220 if ( curPointExist && previousPointExist )
223 painter->drawLine( prevPointPix, curPointPix );
226 if ( previousPointExist && penulPointExist )
229 painter->drawLine( penulPointPix, prevPointPix );
236 painter->drawLine( curPointPix + QPointF( -5, -5 ),
237 curPointPix + QPointF( +5, +5 ) );
238 painter->drawLine( curPointPix + QPointF( -5, +5 ),
239 curPointPix + QPointF( +5, -5 ) );
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
A rectangle specified with double values.
QgsRectangle rect() const
returns canvas item rectangle in map units
A class to represent a 2D point.
An abstract class for items that can be placed on the map canvas.
void paint(QPainter *painter) override
function to be implemented by derived classes
Map canvas is a class for displaying all GIS data types on a canvas.
QRectF boundingRect() const override
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
double mapUnitsPerPixel() const
Returns current map units per pixel.
QgsAdvancedDigitizingCanvasItem(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
QgsMapCanvas * mMapCanvas
pointer to map canvas
Class that shows snapping marker on map canvas for the current snapping match.
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
std::unique_ptr< QgsSnapIndicator > mSnapIndicator
Snapping indicators.
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates