From c0445ed857bbfb4194d76df08b52767645090613 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 13 Jun 2023 11:05:16 +0100 Subject: [PATCH] Reset session drawing props after Board Setup. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14932 (cherry picked from commit 9ed2458f00240cf27ebe86e29da949ef981f0ce7) --- pcbnew/tools/drawing_tool.cpp | 32 +++++++++++++++++++++----------- pcbnew/tools/drawing_tool.h | 3 --- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 5d4a76eef0..1c51e2b650 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -272,6 +272,23 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason ) m_board = getModel(); m_frame = getEditFrame(); + // Re-initialize session attributes + const BOARD_DESIGN_SETTINGS& bds = m_frame->GetDesignSettings(); + + m_layer = m_frame->GetActiveLayer(); + m_stroke.SetWidth( bds.GetLineThickness( m_layer ) ); + m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); + m_stroke.SetColor( COLOR4D::UNSPECIFIED ); + + m_textAttrs.m_Size = bds.GetTextSize( m_layer ); + m_textAttrs.m_StrokeWidth = bds.GetTextThickness( m_layer ); + InferBold( &m_textAttrs ); + m_textAttrs.m_Italic = bds.GetTextItalic( m_layer ); + m_textAttrs.m_KeepUpright = bds.GetTextUpright( m_layer ); + m_textAttrs.m_Mirrored = IsBackLayer( m_layer ); + m_textAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT; + m_textAttrs.m_Valign = GR_TEXT_V_ALIGN_TOP; + UpdateStatusBar(); } @@ -1813,7 +1830,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, if( m_layer != m_frame->GetActiveLayer() ) { m_layer = m_frame->GetActiveLayer(); - m_stroke.SetWidth( getSegmentWidth( m_layer ) ); + m_stroke.SetWidth( bds.GetLineThickness( m_layer ) ); m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); m_stroke.SetColor( COLOR4D::UNSPECIFIED ); @@ -1928,7 +1945,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, if( m_layer != m_frame->GetActiveLayer() ) { m_layer = m_frame->GetActiveLayer(); - m_stroke.SetWidth( getSegmentWidth( m_layer ) ); + m_stroke.SetWidth( bds.GetLineThickness( m_layer ) ); m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); m_stroke.SetColor( COLOR4D::UNSPECIFIED ); @@ -2206,7 +2223,7 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, if( m_layer != m_frame->GetActiveLayer() ) { m_layer = m_frame->GetActiveLayer(); - m_stroke.SetWidth( getSegmentWidth( m_layer ) ); + m_stroke.SetWidth( m_frame->GetDesignSettings().GetLineThickness( m_layer ) ); m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); m_stroke.SetColor( COLOR4D::UNSPECIFIED ); } @@ -2345,7 +2362,7 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, if( m_layer != m_frame->GetActiveLayer() ) { m_layer = m_frame->GetActiveLayer(); - m_stroke.SetWidth( getSegmentWidth( m_layer ) ); + m_stroke.SetWidth( m_frame->GetDesignSettings().GetLineThickness( m_layer ) ); m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); m_stroke.SetColor( COLOR4D::UNSPECIFIED ); } @@ -3266,13 +3283,6 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) } -int DRAWING_TOOL::getSegmentWidth( PCB_LAYER_ID aLayer ) const -{ - assert( m_board ); - return m_board->GetDesignSettings().GetLineThickness( aLayer ); -} - - const unsigned int DRAWING_TOOL::WIDTH_STEP = pcbIUScale.mmToIU( 0.1 ); diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index fd3b716e45..95eb7cb761 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -333,9 +333,6 @@ private: return aOrigin + VECTOR2I( int( xDiff ), int( yDiff ) ); } - ///< Return the appropriate width for a segment depending on the settings. - int getSegmentWidth( PCB_LAYER_ID aLayer ) const; - KIGFX::VIEW* m_view; KIGFX::VIEW_CONTROLS* m_controls; BOARD* m_board;