25 , mLockedPen(
QPen(
QColor( 100, 100, 255, 255 ), .7,
Qt::DashLine ) )
26 , mConstruction1Pen(
QPen(
QColor( 100, 255, 100, 150 ), .7,
Qt::DashLine ) )
27 , mConstruction2Pen(
QPen(
QColor( 100, 255, 100, 255 ), .7,
Qt::DashLine ) )
28 , mSnapPen(
QPen(
QColor( 255, 175, 100, 150 ), 7 ) )
29 , mSnapLinePen(
QPen(
QColor( 200, 100, 50, 150 ), .7,
Qt::DashLine ) )
30 , mCursorPen(
QPen(
QColor( 100, 255, 100, 255 ), .7 ) )
31 , mAdvancedDigitizingDockWidget( cadDockWidget )
41 if ( !mAdvancedDigitizingDockWidget->
cadEnabled() )
45 if (
rect() != mapRect )
48 int nPoints = mAdvancedDigitizingDockWidget->
pointsCount();
52 bool previousPointExist, penulPointExist;
56 const bool snappedToVertex = mAdvancedDigitizingDockWidget->
snappedToVertex();
58 const bool hasSnappedSegment = snappedSegment.
count() == 2;
60 const bool curPointExist = mapRect.
contains( curPoint );
66 QPointF curPointPix, prevPointPix, penulPointPix, snapSegmentPix1, snapSegmentPix2;
72 if ( previousPointExist )
76 if ( penulPointExist )
80 if ( hasSnappedSegment )
89 if ( curPointExist && snappedToVertex )
96 if ( hasSnappedSegment && !snappedToVertex )
102 snapSegmentPix2.
y() );
121 snapSegmentPix2.
y() );
130 a0 = qAtan2( -( prevPoint.
y() - penulPoint.
y() ), prevPoint.
x() - penulPoint.
x() );
142 a = qAtan2( -( curPoint.
y() - prevPoint.
y() ), curPoint.
x() - prevPoint.
x() );
145 painter->
drawArc( prevPointPix.
x() - 20,
146 prevPointPix.
y() - 20,
148 ( int )16 * -a0 * 180 /
M_PI,
149 (
int )16 * ( a0 - a ) * 180 /
M_PI );
152 prevPointPix.
x() + 60*qCos( a0 ),
153 prevPointPix.
y() + 60*qSin( a0 ) );
159 painter->
drawLine( prevPointPix.
x() - d*qCos( a ),
160 prevPointPix.
y() - d*qSin( a ),
161 prevPointPix.
x() + d*qCos( a ),
162 prevPointPix.
y() + d*qSin( a ) );
184 x = mAdvancedDigitizingDockWidget->
constraintX()->
value() / mupp + prevPointPix.
x();
215 y = -mAdvancedDigitizingDockWidget->
constraintY()->
value() / mupp + prevPointPix.
y();
238 if ( curPointExist && previousPointExist )
247 if ( previousPointExist && penulPointExist )
263 curPointPix.
y() + 5 );
267 curPointPix.
y() - 5 );
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
A rectangle specified with double values.
QgsRectangle rect() const
returns canvas item rectangle in map units
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
void drawLine(const QLineF &line)
Map canvas is a class for displaying all GIS data types on a canvas.
double y() const
Get the y value of the point.
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
QPointF toCanvasCoordinates(const QgsPoint &point) const
transformation from map coordinates to screen coordinates
int count(const T &value) const
virtual QRectF boundingRect() const override
default implementation for canvas items
void drawArc(const QRectF &rectangle, int startAngle, int spanAngle)
void setPen(const QColor &color)
void drawEllipse(const QRectF &rectangle)
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
double mapUnitsPerPixel() const
Return current map units per pixel.
A class to represent a point.
~QgsAdvancedDigitizingCanvasItem()
void setRenderHints(QFlags< QPainter::RenderHint > hints, bool on)
QgsAdvancedDigitizingCanvasItem(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
QgsMapCanvas * mMapCanvas
pointer to map canvas
const QgsMapToPixel * getCoordinateTransform()
Get the current coordinate transform.
double x() const
Get the x value of the point.