From a2bb176b68518a17b423b7fedbb351160237fa45 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 31 Jul 2021 11:30:31 +0200 Subject: [PATCH] Gerbview: fix mismatch between shown layers and visibility indicator in layers manager, after loading (or reloading) files. Remove also not used code. Fixes #8847 https://gitlab.com/kicad/code/kicad/issues/8847 --- gerbview/gerbview_frame.h | 10 +- gerbview/widgets/gerbview_layer_widget.cpp | 6 +- gerbview/widgets/layer_widget.cpp | 143 +-------------------- 3 files changed, 11 insertions(+), 148 deletions(-) diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 319e12a101..b87a45265f 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -297,15 +297,15 @@ public: bool unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter = nullptr ); /** - * Load a photoplot (Gerber) file or many files. + * Load a given Gerber file or selected file(s), if the filename is empty. * - * @param aFileName - void string or file name with full path to open or empty string to - * open a new file. In this case one one file is loaded - * if void string: user will be prompted for filename(s) + * @param aFileName - file name with full path to open or empty string. + * if empty string: a dialog will be opened to select one or + * a set of files * @return true if file was opened successfully. */ bool LoadGerberFiles( const wxString& aFileName ); - bool Read_GERBER_File( const wxString& GERBER_FullFileName ); + bool Read_GERBER_File( const wxString& GERBER_FullFileName ); /** * Load a drill (EXCELLON) file or many files. diff --git a/gerbview/widgets/gerbview_layer_widget.cpp b/gerbview/widgets/gerbview_layer_widget.cpp index 3b808dadc0..13ec3e9d52 100644 --- a/gerbview/widgets/gerbview_layer_widget.cpp +++ b/gerbview/widgets/gerbview_layer_widget.cpp @@ -217,7 +217,8 @@ void GERBER_LAYER_WIDGET::ReFill() int aRow = findLayerRow( layer ); bool visible = true; COLOR4D color = m_frame->GetLayerColor( GERBER_DRAW_LAYER( layer ) ); - wxString msg = GetImagesList()->GetDisplayName( layer, /* include layer number */ false, + wxString msg = GetImagesList()->GetDisplayName( layer, + /* include layer number */ false, /* Get the full name */ true ); if( m_frame->GetCanvas() ) @@ -226,7 +227,10 @@ void GERBER_LAYER_WIDGET::ReFill() visible = m_frame->IsLayerVisible( layer ); if( aRow >= 0 ) + { updateLayerRow( findLayerRow( layer ), msg ); + SetLayerVisible( layer, visible ); + } else AppendLayerRow( LAYER_WIDGET::ROW( msg, layer, color, wxEmptyString, visible, true ) ); } diff --git a/gerbview/widgets/layer_widget.cpp b/gerbview/widgets/layer_widget.cpp index cddf53115b..7e3e6bca32 100644 --- a/gerbview/widgets/layer_widget.cpp +++ b/gerbview/widgets/layer_widget.cpp @@ -3,7 +3,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2010-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2010-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -862,144 +862,3 @@ void LAYER_WIDGET::UpdateLayerIcons() } } } - - -#if defined(STAND_ALONE) - -#include - - -/** - * A test class here to exercise the LAYER_WIDGET and explore use cases. - * - * @see http://www.kirix.com/labs/wxaui/screenshots.html for ideas. - */ -class MYFRAME : public wxFrame -{ - // example of how to derive from LAYER_WIDGET in order to provide the - // abstract methods. - class MYLAYERS : public LAYER_WIDGET - { - public: - // your constructor could take a BOARD argument. here I leave it - // out because this source module wants to know nothing of BOARDs - // to maximize re-use. - MYLAYERS( wxWindow* aParent ) : - LAYER_WIDGET( aParent, aParent ) - { - } - - void OnLayerColorChange( int aLayer, const COLOR4D& aColor ) - { - /* a test trigger only - if( aLayer == 2 ) - { - ClearLayerRows(); - } - */ - } - - bool OnLayerSelect( LAYER_NUM aLayer ) - { - return true; - } - - void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal ) - { - } - - void OnRenderColorChange( int aId, const COLOR4D& aColor ) - { - } - - void OnRenderEnable( int aId, bool isEnabled ) - { - } - }; - - -public: - MYFRAME( wxWindow * parent ) : - wxFrame( parent, -1, wxT( "wxAUI Test" ), wxDefaultPosition, - wxSize( 800, 600 ), wxDEFAULT_FRAME_STYLE ) - { - // notify wxAUI which frame to use - m_mgr.SetManagedWindow( this ); - - MYLAYERS* lw = new MYLAYERS( this ); - - // add some layer rows - static const LAYER_WIDGET::ROW layerRows[] = { - LAYER_WIDGET::ROW( wxT( "layer 1" ), 0, RED, wxT( "RED" ), false ), - LAYER_WIDGET::ROW( wxT( "layer 2" ), 1, GREEN, wxT( "GREEN" ), true ), - LAYER_WIDGET::ROW( wxT( "brown_layer" ), 2, BROWN, wxT( "BROWN" ), true ), - LAYER_WIDGET::ROW( wxT( "layer_4_you" ), 3, BLUE, wxT( "BLUE" ), false ), - }; - - lw->AppendLayerRows( layerRows, arrayDim(layerRows) ); - - // add some render rows - static const LAYER_WIDGET::ROW renderRows[] = { - LAYER_WIDGET::ROW( wxT( "With Very Large Ears" ), 0, COLOR4D::UNSPECIFIED, - wxT( "Spock here" ) ), - LAYER_WIDGET::ROW( wxT( "With Legs" ), 1, YELLOW ), - LAYER_WIDGET::ROW( wxT( "With Oval Eyes" ), 1, BROWN, wxT( "My eyes are upon you" ) ), - }; - - lw->AppendRenderRows( renderRows, arrayDim(renderRows) ); - - lw->SelectLayerRow( 1 ); - - wxAuiPaneInfo li; - li.MinSize( lw->GetBestSize() ); - li.BestSize( lw->GetBestSize() ); - li.Left(); - li.CloseButton( false ); - li.Caption( wxT( "Layers" ) ); - m_mgr.AddPane( lw, li ); - - - wxTextCtrl* text2 = new wxTextCtrl( this, -1, wxT( "Pane 2 - sample text" ), - wxDefaultPosition, wxSize( 200, 150 ), - wxNO_BORDER | wxTE_MULTILINE ); - m_mgr.AddPane( text2, wxBOTTOM, wxT( "Pane Number Two" ) ); - - wxTextCtrl* text3 = new wxTextCtrl( this, -1, wxT( "Main content window" ), - wxDefaultPosition, wxSize( 200, 150 ), - wxNO_BORDER | wxTE_MULTILINE ); - m_mgr.AddPane( text3, wxCENTER ); - - // tell the manager to "commit" all the changes just made - m_mgr.Update(); - } - - ~MYFRAME() - { - // deinitialize the frame manager - m_mgr.UnInit(); - } - -private: - wxAuiManager m_mgr; -}; - - -// our normal wxApp-derived class, as usual -class MyApp : public wxApp -{ -public: - - bool OnInit() - { - wxFrame* frame = new MYFRAME( nullptr ); - - SetTopWindow( frame ); - frame->Show(); - return true; - } -}; - -DECLARE_APP( MyApp ); -IMPLEMENT_APP( MyApp ); - -#endif // STAND_ALONE