mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
use qreal overloads of painter methods in advanced digitizing canvas item (#7967)
* use qreal overloads of painter methods in advanced digitizing canvas item * better use of existing variables
This commit is contained in:
parent
f208191824
commit
7b5afb953f
@ -93,18 +93,12 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
|
||||
if ( hasSnappedSegment && !snappedToVertex )
|
||||
{
|
||||
painter->setPen( mSnapPen );
|
||||
painter->drawLine( snapSegmentPix1.x(),
|
||||
snapSegmentPix1.y(),
|
||||
snapSegmentPix2.x(),
|
||||
snapSegmentPix2.y() );
|
||||
painter->drawLine( snapSegmentPix1, snapSegmentPix2 );
|
||||
|
||||
if ( curPointExist )
|
||||
{
|
||||
painter->setPen( mSnapLinePen );
|
||||
painter->drawLine( snapSegmentPix1.x(),
|
||||
snapSegmentPix1.y(),
|
||||
curPointPix.x(),
|
||||
curPointPix.y() );
|
||||
painter->drawLine( snapSegmentPix1, curPointPix );
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,10 +106,7 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
|
||||
if ( mAdvancedDigitizingDockWidget->additionalConstraint() != QgsAdvancedDigitizingDockWidget::NoConstraint && hasSnappedSegment )
|
||||
{
|
||||
painter->setPen( mConstruction2Pen );
|
||||
painter->drawLine( snapSegmentPix1.x(),
|
||||
snapSegmentPix1.y(),
|
||||
snapSegmentPix2.x(),
|
||||
snapSegmentPix2.y() );
|
||||
painter->drawLine( snapSegmentPix1, snapSegmentPix2 );
|
||||
}
|
||||
|
||||
// Draw angle
|
||||
@ -139,24 +130,21 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
|
||||
a = std::atan2( -( curPoint.y() - prevPoint.y() ), curPoint.x() - prevPoint.x() );
|
||||
}
|
||||
painter->setPen( mConstruction2Pen );
|
||||
painter->drawArc( prevPointPix.x() - 20,
|
||||
prevPointPix.y() - 20,
|
||||
40, 40,
|
||||
16 * -a0 * 180 / M_PI,
|
||||
16 * ( a0 - a ) * 180 / M_PI );
|
||||
painter->drawLine( prevPointPix.x(),
|
||||
prevPointPix.y(),
|
||||
prevPointPix.x() + 60 * std::cos( a0 ),
|
||||
prevPointPix.y() + 60 * std::sin( a0 ) );
|
||||
painter->drawArc( QRectF( prevPointPix.x() - 20,
|
||||
prevPointPix.y() - 20,
|
||||
40, 40 ),
|
||||
static_cast<int>( 16 * -a0 * 180 / M_PI ),
|
||||
static_cast<int>( 16 * ( a0 - a ) * 180 / M_PI ) );
|
||||
painter->drawLine( prevPointPix,
|
||||
prevPointPix + 60 * QPointF( std::cos( a0 ), std::sin( a0 ) ) );
|
||||
|
||||
|
||||
if ( mAdvancedDigitizingDockWidget->constraintAngle()->isLocked() )
|
||||
{
|
||||
painter->setPen( mLockedPen );
|
||||
double d = std::max( boundingRect().width(), boundingRect().height() );
|
||||
painter->drawLine( prevPointPix.x() - d * std::cos( a ),
|
||||
prevPointPix.y() - d * std::sin( a ),
|
||||
prevPointPix.x() + d * std::cos( a ),
|
||||
prevPointPix.y() + d * std::sin( a ) );
|
||||
painter->drawLine( prevPointPix - d * QPointF( std::cos( a ), std::sin( a ) ),
|
||||
prevPointPix + d * QPointF( std::cos( a ), std::sin( a ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,10 +179,8 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
|
||||
}
|
||||
if ( draw )
|
||||
{
|
||||
painter->drawLine( x,
|
||||
0,
|
||||
x,
|
||||
boundingRect().height() );
|
||||
painter->drawLine( QPointF( x, 0 ),
|
||||
QPointF( x, boundingRect().height() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,33 +221,24 @@ void QgsAdvancedDigitizingCanvasItem::paint( QPainter *painter )
|
||||
if ( curPointExist && previousPointExist )
|
||||
{
|
||||
painter->setPen( mConstruction2Pen );
|
||||
painter->drawLine( prevPointPix.x(),
|
||||
prevPointPix.y(),
|
||||
curPointPix.x(),
|
||||
curPointPix.y() );
|
||||
painter->drawLine( prevPointPix, curPointPix );
|
||||
}
|
||||
|
||||
if ( previousPointExist && penulPointExist )
|
||||
{
|
||||
painter->setPen( mConstruction1Pen );
|
||||
painter->drawLine( penulPointPix.x(),
|
||||
penulPointPix.y(),
|
||||
prevPointPix.x(),
|
||||
prevPointPix.y() );
|
||||
painter->drawLine( penulPointPix, prevPointPix );
|
||||
}
|
||||
}
|
||||
|
||||
if ( curPointExist )
|
||||
{
|
||||
painter->setPen( mCursorPen );
|
||||
painter->drawLine( curPointPix.x() - 5,
|
||||
curPointPix.y() - 5,
|
||||
curPointPix.x() + 5,
|
||||
curPointPix.y() + 5 );
|
||||
painter->drawLine( curPointPix.x() - 5,
|
||||
curPointPix.y() + 5,
|
||||
curPointPix.x() + 5,
|
||||
curPointPix.y() - 5 );
|
||||
painter->drawLine( curPointPix + QPointF( -5, -5 ),
|
||||
curPointPix + QPointF( +5, +5 ) );
|
||||
painter->drawLine( curPointPix + QPointF( -5, +5 ),
|
||||
curPointPix + QPointF( +5, -5 ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user