From 041c52c36959ba06b959a96a4153636e3c812a38 Mon Sep 17 00:00:00 2001 From: John Beard Date: Thu, 4 Oct 2018 16:18:48 +0100 Subject: [PATCH] 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 --- common/preview_items/arc_assistant.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/preview_items/arc_assistant.cpp b/common/preview_items/arc_assistant.cpp index 9f31722b61..441699bffa 100644 --- a/common/preview_items/arc_assistant.cpp +++ b/common/preview_items/arc_assistant.cpp @@ -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( 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 ) );