From c80433161ac210b9ca8746371e3c5c2b23f8e91d 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. --- common/preview_items/arc_assistant.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/preview_items/arc_assistant.cpp b/common/preview_items/arc_assistant.cpp index 0f9f3aaef..ae3e83b14 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,21 @@ 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 +188,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 ) ); -- 2.19.0