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 ) )
31 , mAdvancedDigitizingDockWidget( cadDockWidget )
37 if ( !mAdvancedDigitizingDockWidget->
cadEnabled() )
41 if (
rect() != mapRect )
44 int nPoints = mAdvancedDigitizingDockWidget->
pointsCount();
48 bool previousPointExist, penulPointExist;
52 const bool snappedToVertex = mAdvancedDigitizingDockWidget->
snappedToVertex();
53 const QList<QgsPointXY> snappedSegment = mAdvancedDigitizingDockWidget->
snappedSegment();
54 const bool hasSnappedSegment = snappedSegment.count() == 2;
56 const bool curPointExist = mapRect.
contains( curPoint );
62 QPointF curPointPix, prevPointPix, penulPointPix, snapSegmentPix1, snapSegmentPix2;
68 if ( previousPointExist )
72 if ( penulPointExist )
76 if ( hasSnappedSegment )
82 painter->setRenderHints( QPainter::Antialiasing );
83 painter->setCompositionMode( QPainter::CompositionMode_Difference );
86 if ( curPointExist && snappedToVertex )
89 painter->drawEllipse( curPointPix, 10, 10 );
93 if ( hasSnappedSegment && !snappedToVertex )
96 painter->drawLine( snapSegmentPix1.x(),
99 snapSegmentPix2.y() );
104 painter->drawLine( snapSegmentPix1.x(),
115 painter->drawLine( snapSegmentPix1.x(),
118 snapSegmentPix2.y() );
127 a0 = std::atan2( -( prevPoint.
y() - penulPoint.
y() ), prevPoint.
x() - penulPoint.
x() );
139 a = std::atan2( -( curPoint.
y() - prevPoint.
y() ), curPoint.
x() - prevPoint.
x() );
142 painter->drawArc( prevPointPix.x() - 20,
143 prevPointPix.y() - 20,
145 ( int )16 * -a0 * 180 / M_PI,
146 (
int )16 * ( a0 - a ) * 180 / M_PI );
147 painter->drawLine( prevPointPix.x(),
149 prevPointPix.x() + 60 * std::cos( a0 ),
150 prevPointPix.y() + 60 * std::sin( a0 ) );
156 painter->drawLine( prevPointPix.x() - d * std::cos( a ),
157 prevPointPix.y() - d * std::sin( a ),
158 prevPointPix.x() + d * std::cos( a ),
159 prevPointPix.y() + d * std::sin( a ) );
168 painter->drawEllipse( prevPointPix, r, r );
181 x = mAdvancedDigitizingDockWidget->
constraintX()->
value() / mupp + prevPointPix.x();
194 painter->drawLine( x,
212 y = -mAdvancedDigitizingDockWidget->
constraintY()->
value() / mupp + prevPointPix.y();
225 painter->drawLine( 0,
235 if ( curPointExist && previousPointExist )
238 painter->drawLine( prevPointPix.x(),
244 if ( previousPointExist && penulPointExist )
247 painter->drawLine( penulPointPix.x(),
257 painter->drawLine( curPointPix.x() - 5,
260 curPointPix.y() + 5 );
261 painter->drawLine( curPointPix.x() - 5,
264 curPointPix.y() - 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
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates