Arc preview: Add guide circle

When drawing an arc, show a guide circle that indicates the
radius of the arc at the current cursor. This can be useful
as a guide for seeing where the arc will reach once the radius
is fixed by the second click.

Fixes lp:1796158
* https://bugs.launchpad.net/kicad/+bug/1796158
This commit is contained in:
John Beard 2018-10-04 16:18:48 +01:00
parent 6f27ef7f66
commit 041c52c369
1 changed files with 19 additions and 0 deletions

View File

@ -119,6 +119,8 @@ static void drawArcWithHilight( KIGFX::VIEW *aView,
if( angleIsSpecial( aStartAngle - aEndAngle ) )
color = rs->IsBackgroundDark() ? COLOR4D( 0.5, 1.0, 0.5, 1.0 ) : COLOR4D( 0.0, 0.7, 0.0, 1.0 ) ;
gal->SetIsStroke( true );
gal->SetIsFill( true );
gal->SetStrokeColor( color );
gal->SetFillColor( color.WithAlpha( 0.2 ) );
@ -127,6 +129,20 @@ static void drawArcWithHilight( KIGFX::VIEW *aView,
}
static void drawCircleGuide( KIGFX::VIEW* aView, const VECTOR2I& aOrigin, double aRad )
{
auto gal = aView->GetGAL();
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
auto color = rs->GetLayerColor( LAYER_AUX_ITEMS );
gal->SetStrokeColor( color.WithAlpha( PreviewOverlayDeemphAlpha( true ) ) );
gal->SetIsStroke( true );
gal->SetIsFill( false );
gal->DrawCircle( aOrigin, aRad );
}
void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{
auto& gal = *aView->GetGAL();
@ -171,6 +187,9 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
// draw the angle reference arc
drawArcWithHilight( aView, origin, innerRad, initAngle, 0.0 );
// draw the radius guide circle
drawCircleGuide( aView, origin, m_constructMan.GetRadius() );
double degs = getNormDeciDegFromRad( initAngle );
cursorStrings.push_back( DimensionLabel( "r", m_constructMan.GetRadius(), m_units ) );