Layer fixes for PCBNew drawing tools.

1) Implement layer changes for dimension drawing tool
2) Ensure drawing layer is visible for (1) and for the text drawing
tool.

Fixes https://gitlab.com/kicad/code/kicad/issues/8106
This commit is contained in:
Jeff Young 2021-04-07 15:01:59 +01:00
parent e50b450092
commit 3fd3be9843
1 changed files with 75 additions and 22 deletions

View File

@ -577,6 +577,12 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
if( text )
{
if( !m_view->IsLayerVisible( text->GetLayer() ) )
{
m_frame->GetAppearancePanel()->SetLayerVisible( text->GetLayer(), true );
m_frame->GetCanvas()->Refresh();
}
m_controls->WarpCursor( text->GetPosition(), true );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, text );
m_view->Update( &selection() );
@ -835,6 +841,12 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
dimension->SetEnd( (wxPoint) cursorPos );
dimension->Update();
if( !m_view->IsLayerVisible( layer ) )
{
m_frame->GetAppearancePanel()->SetLayerVisible( layer, true );
m_frame->GetCanvas()->Refresh();
}
preview.Add( dimension );
frame()->SetMsgPanel( dimension );
@ -1009,6 +1021,33 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
// Show a preview of the item
m_view->Update( &preview );
}
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
{
if( dimension )
{
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
if( !m_view->IsLayerVisible( layer ) )
{
m_frame->GetAppearancePanel()->SetLayerVisible( layer, true );
m_frame->GetCanvas()->Refresh();
}
dimension->SetLayer( layer );
dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) );
dimension->Text().SetTextThickness( boardSettings.GetTextThickness( layer ) );
dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
dimension->SetLineThickness( boardSettings.GetLineThickness( layer ) );
dimension->Update();
m_view->Update( &preview );
frame()->SetMsgPanel( dimension );
}
else
{
evt->SetPassEvent();
}
}
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
{
if( step == SET_END || step == SET_HEIGHT )
@ -1413,19 +1452,26 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic,
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
{
drawingLayer = m_frame->GetActiveLayer();
m_lineWidth = getSegmentWidth( drawingLayer );
if( graphic )
{
if( !m_view->IsLayerVisible( drawingLayer ) )
{
m_frame->GetAppearancePanel()->SetLayerVisible( drawingLayer, true );
m_frame->GetCanvas()->Refresh();
}
m_lineWidth = getSegmentWidth( drawingLayer );
graphic->SetLayer( drawingLayer );
graphic->SetWidth( m_lineWidth );
m_view->Update( &preview );
frame()->SetMsgPanel( graphic );
}
else
{
evt->SetPassEvent();
}
}
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
{
if( started )
@ -1763,19 +1809,26 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
{
drawingLayer = m_frame->GetActiveLayer();
m_lineWidth = getSegmentWidth( drawingLayer );
if( graphic )
{
if( !m_view->IsLayerVisible( drawingLayer ) )
{
m_frame->GetAppearancePanel()->SetLayerVisible( drawingLayer, true );
m_frame->GetCanvas()->Refresh();
}
m_lineWidth = getSegmentWidth( drawingLayer );
graphic->SetLayer( drawingLayer );
graphic->SetWidth( m_lineWidth );
m_view->Update( &preview );
frame()->SetMsgPanel( graphic );
}
else
{
evt->SetPassEvent();
}
}
else if( evt->IsAction( &PCB_ACTIONS::properties ) )
{
if( arcManager.GetStep() == KIGFX::PREVIEW::ARC_GEOM_MANAGER::SET_START )