From 0952393413a8f0e070dff765ade7ff43cefd3a0d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 7 Apr 2011 21:17:51 +0200 Subject: [PATCH] Pcbnew, Gerbview: Fix a minor issue in layer manager: In Render, colors shown were the default colors, not the selected colors, when starting Pcbnew or Gerbview, because colors were not updated after reading the config. --- eeschema/viewlib_frame.cpp | 6 +- gerbview/class_gerbview_layer_widget.cpp | 61 ++++++++------- gerbview/class_gerbview_layer_widget.h | 6 ++ gerbview/gerbview_frame.cpp | 3 +- pcbnew/class_pcb_layer_widget.cpp | 94 +++++++++++++----------- pcbnew/class_pcb_layer_widget.h | 6 ++ pcbnew/pcbframe.cpp | 3 +- 7 files changed, 105 insertions(+), 74 deletions(-) diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index f95df4c926..dae3a27e90 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -83,7 +83,8 @@ static wxAcceleratorEntry accels[] = LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaphore* semaphore ) : - EDA_DRAW_FRAME( father, VIEWER_FRAME, _( "Library browser" ), wxDefaultPosition, wxDefaultSize ) + EDA_DRAW_FRAME( father, VIEWER_FRAME, _( "Library browser" ), + wxDefaultPosition, wxDefaultSize ) { wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); @@ -99,6 +100,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph m_LibListWindow = NULL; m_CmpListWindow = NULL; m_Semaphore = semaphore; + m_exportToEeschemaCmpName.Empty(); if( m_Semaphore ) SetWindowStyle( GetWindowStyle() | wxSTAY_ON_TOP ); @@ -149,8 +151,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph m_LibListSize.x = 0; } - m_exportToEeschemaCmpName.Clear(); - // Creates the component window display m_CmpListSize.y = size.y; win_pos.x = m_LibListSize.x; diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index 4a1b6bc410..0efc0faa30 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -50,32 +50,7 @@ GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFo LAYER_WIDGET( aParent, aFocusOwner, aPointSize ), myframe( aParent ) { - BOARD* board = myframe->GetBoard(); - - // Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color - // is changed before appending to the LAYER_WIDGET. This is an automatic variable - // not a static variable, change the color & state after copying from code to renderRows - // on the stack. - LAYER_WIDGET::ROW renderRows[2] = { - -#define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width - - // text id color tooltip checked - RR( _( "Grid" ), GERBER_GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ), - RR( _( "DCodes" ), DCODES_VISIBLE, WHITE, _( "Show DCodes identification" ) ), - }; - - for( unsigned row=0; rowGetVisibleElementColor( renderRows[row].id ); - } - renderRows[row].state = board->IsElementVisible( renderRows[row].id ); - } - - AppendRenderRows( renderRows, DIM(renderRows) ); + ReFillRender(); // Update default tabs labels for gerbview SetLayersManagerTabsText( ); @@ -105,6 +80,40 @@ void GERBER_LAYER_WIDGET::SetLayersManagerTabsText( ) m_notebook->SetPageText(1, _("Render") ); } +/** + * Function ReFillRender + * Rebuild Render for instance after the config is read + */ +void GERBER_LAYER_WIDGET::ReFillRender() +{ + BOARD* board = myframe->GetBoard(); + ClearRenderRows(); + + // Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color + // is changed before appending to the LAYER_WIDGET. This is an automatic variable + // not a static variable, change the color & state after copying from code to renderRows + // on the stack. + LAYER_WIDGET::ROW renderRows[2] = { + +#define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width + + // text id color tooltip checked + RR( _( "Grid" ), GERBER_GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ), + RR( _( "DCodes" ), DCODES_VISIBLE, WHITE, _( "Show DCodes identification" ) ), + }; + + for( unsigned row=0; rowGetVisibleElementColor( renderRows[row].id ); + } + renderRows[row].state = board->IsElementVisible( renderRows[row].id ); + } + + AppendRenderRows( renderRows, DIM(renderRows) ); +} void GERBER_LAYER_WIDGET::installRightLayerClickHandler() { diff --git a/gerbview/class_gerbview_layer_widget.h b/gerbview/class_gerbview_layer_widget.h index ff8c4697b1..fba4d8b4fd 100644 --- a/gerbview/class_gerbview_layer_widget.h +++ b/gerbview/class_gerbview_layer_widget.h @@ -80,6 +80,12 @@ public: void ReFill(); + /** + * Function ReFillRender + * Rebuild Render for instance after the config is read + */ + void ReFillRender(); + //---------------- void OnLayerColorChange( int aLayer, int aColor ); bool OnLayerSelect( int aLayer ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 7c60dd85e8..fed60701b6 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -128,7 +128,8 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, m_auimgr.AddPane( MsgPanel, wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); - ReFillLayerWidget(); // this is near end because contents establish size + ReFillLayerWidget(); // this is near end because contents establish size + m_LayersManager->ReFillRender(); // Update colors in Render after the config is read m_auimgr.Update(); } diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 6ea8be05d6..6d8b92cb96 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -55,49 +55,7 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwn LAYER_WIDGET( aParent, aFocusOwner, aPointSize ), myframe( aParent ) { - BOARD* board = myframe->GetBoard(); - - // Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color - // is changed before appending to the LAYER_WIDGET. This is an automatic variable - // not a static variable, change the color & state after copying from code to renderRows - // on the stack. - LAYER_WIDGET::ROW renderRows[16] = { - -#define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width - - // text id color tooltip checked - RR( _( "Through Via" ), VIA_THROUGH_VISIBLE, WHITE, _( "Show through vias" ) ), - RR( _( "Bl/Buried Via" ), VIA_BBLIND_VISIBLE, WHITE, _( "Show blind or buried vias" ) ), - RR( _( "Micro Via" ), VIA_MICROVIA_VISIBLE, WHITE, _( "Show micro vias") ), - RR( _( "Ratsnest" ), RATSNEST_VISIBLE, WHITE, _( "Show unconnected nets as a ratsnest") ), - - RR( _( "Pads Front" ), PAD_FR_VISIBLE, WHITE, _( "Show footprint pads on board's front" ) ), - RR( _( "Pads Back" ), PAD_BK_VISIBLE, WHITE, _( "Show footprint pads on board's back" ) ), - - RR( _( "Text Front" ), MOD_TEXT_FR_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ), - RR( _( "Text Back" ), MOD_TEXT_BK_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ), - RR( _( "Hidden Text" ), MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ), - - RR( _( "Anchors" ), ANCHOR_VISIBLE, WHITE, _( "Show footprint and text origins as a cross" ) ), - RR( _( "Grid" ), GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ), - RR( _( "No-Connects" ), NO_CONNECTS_VISIBLE, -1, _( "Show a marker on pads which have no net connected" ) ), - RR( _( "Modules Front" ), MOD_FR_VISIBLE, -1, _( "Show footprints that are on board's front") ), - RR( _( "Modules Back" ), MOD_BK_VISIBLE, -1, _( "Show footprints that are on board's back") ), - RR( _( "Values" ), MOD_VALUES_VISIBLE, -1, _( "Show footprint's values") ), - RR( _( "References" ), MOD_REFERENCES_VISIBLE, -1, _( "Show footprint's references") ), - }; - - for( unsigned row=0; rowGetVisibleElementColor( renderRows[row].id ); - } - renderRows[row].state = board->IsElementVisible( renderRows[row].id ); - } - - AppendRenderRows( renderRows, DIM(renderRows) ); + ReFillRender(); // Update default tabs labels for gerbview SetLayersManagerTabsText( ); @@ -210,6 +168,56 @@ void PCB_LAYER_WIDGET::SetLayersManagerTabsText( ) m_notebook->SetPageText(1, _("Render") ); } +/** + * Function ReFillRender + * Rebuild Render for instance after the config is read + */ +void PCB_LAYER_WIDGET::ReFillRender() +{ + BOARD* board = myframe->GetBoard(); + ClearRenderRows(); + // Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color + // is changed before appending to the LAYER_WIDGET. This is an automatic variable + // not a static variable, change the color & state after copying from code to renderRows + // on the stack. + LAYER_WIDGET::ROW renderRows[16] = { + +#define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width + + // text id color tooltip checked + RR( _( "Through Via" ), VIA_THROUGH_VISIBLE, WHITE, _( "Show through vias" ) ), + RR( _( "Bl/Buried Via" ), VIA_BBLIND_VISIBLE, WHITE, _( "Show blind or buried vias" ) ), + RR( _( "Micro Via" ), VIA_MICROVIA_VISIBLE, WHITE, _( "Show micro vias") ), + RR( _( "Ratsnest" ), RATSNEST_VISIBLE, WHITE, _( "Show unconnected nets as a ratsnest") ), + + RR( _( "Pads Front" ), PAD_FR_VISIBLE, WHITE, _( "Show footprint pads on board's front" ) ), + RR( _( "Pads Back" ), PAD_BK_VISIBLE, WHITE, _( "Show footprint pads on board's back" ) ), + + RR( _( "Text Front" ), MOD_TEXT_FR_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ), + RR( _( "Text Back" ), MOD_TEXT_BK_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ), + RR( _( "Hidden Text" ), MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ), + + RR( _( "Anchors" ), ANCHOR_VISIBLE, WHITE, _( "Show footprint and text origins as a cross" ) ), + RR( _( "Grid" ), GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ), + RR( _( "No-Connects" ), NO_CONNECTS_VISIBLE, -1, _( "Show a marker on pads which have no net connected" ) ), + RR( _( "Modules Front" ), MOD_FR_VISIBLE, -1, _( "Show footprints that are on board's front") ), + RR( _( "Modules Back" ), MOD_BK_VISIBLE, -1, _( "Show footprints that are on board's back") ), + RR( _( "Values" ), MOD_VALUES_VISIBLE, -1, _( "Show footprint's values") ), + RR( _( "References" ), MOD_REFERENCES_VISIBLE, -1, _( "Show footprint's references") ), + }; + + for( unsigned row=0; rowGetVisibleElementColor( renderRows[row].id ); + } + renderRows[row].state = board->IsElementVisible( renderRows[row].id ); + } + + AppendRenderRows( renderRows, DIM(renderRows) ); +} void PCB_LAYER_WIDGET::ReFill() { diff --git a/pcbnew/class_pcb_layer_widget.h b/pcbnew/class_pcb_layer_widget.h index a6a29e5540..c861ca10a2 100644 --- a/pcbnew/class_pcb_layer_widget.h +++ b/pcbnew/class_pcb_layer_widget.h @@ -71,6 +71,12 @@ public: void ReFill(); + /** + * Function ReFillRender + * Rebuild Render for instance after the config is read + */ + void ReFillRender(); + //---------------- void OnLayerColorChange( int aLayer, int aColor ); bool OnLayerSelect( int aLayer ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 282606c4c7..eb1611565f 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -400,7 +400,8 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_auimgr.AddPane( MsgPanel, wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() ); - ReFillLayerWidget(); // this is near end because contents establish size + ReFillLayerWidget(); // this is near end because contents establish size + m_Layers->ReFillRender(); // Update colors in Render after the config is read syncLayerWidget(); m_auimgr.Update();