From dbd9b5e49e687930b7d785ba267de40e4670acd2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 18 Jun 2016 11:37:36 +0200 Subject: [PATCH] Gerbview: minor code cleanup. --- gerbview/clear_gbr_drawlayers.cpp | 4 ++-- .../dialogs/dialog_layers_select_to_pcb_base.cpp | 5 ++--- .../dialogs/dialog_layers_select_to_pcb_base.fbp | 7 +++++-- gerbview/dialogs/dialog_layers_select_to_pcb_base.h | 6 +++--- gerbview/locate.cpp | 7 +++---- gerbview/onleftclick.cpp | 3 +-- gerbview/onrightclick.cpp | 12 ++++++------ gerbview/readgerb.cpp | 4 ++-- gerbview/select_layers_to_pcb.cpp | 7 +------ gerbview/select_layers_to_pcb.h | 1 - gerbview/toolbars_gerber.cpp | 3 +-- 11 files changed, 26 insertions(+), 33 deletions(-) diff --git a/gerbview/clear_gbr_drawlayers.cpp b/gerbview/clear_gbr_drawlayers.cpp index 44154b6a66..ea92d0883a 100644 --- a/gerbview/clear_gbr_drawlayers.cpp +++ b/gerbview/clear_gbr_drawlayers.cpp @@ -47,7 +47,7 @@ bool GERBVIEW_FRAME::Clear_DrawLayers( bool query ) return false; } - GetGerberLayout()->GetImagesList()->DeleteAllImages(); + GetImagesList()->DeleteAllImages(); GetGerberLayout()->SetBoundingBox( EDA_RECT() ); @@ -70,7 +70,7 @@ void GERBVIEW_FRAME::Erase_Current_DrawLayer( bool query ) SetCurItem( NULL ); - GetGerberLayout()->GetImagesList()->DeleteImage( layer ); + GetImagesList()->DeleteImage( layer ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp b/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp index 068d992f7e..74ac942b7d 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp +++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -14,7 +14,6 @@ BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG_BASE, DIALOG_SHIM ) EVT_BUTTON( ID_STORE_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnStoreSetup ) EVT_BUTTON( ID_GET_PREVIOUS_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnGetSetup ) EVT_BUTTON( ID_RESET_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnResetClick ) - EVT_BUTTON( wxID_CANCEL, LAYERS_MAP_DIALOG_BASE::_wxFB_OnCancelClick ) EVT_BUTTON( wxID_OK, LAYERS_MAP_DIALOG_BASE::_wxFB_OnOkClick ) END_EVENT_TABLE() @@ -41,7 +40,7 @@ LAYERS_MAP_DIALOG_BASE::LAYERS_MAP_DIALOG_BASE( wxWindow* parent, wxWindowID id, sbSizerLayersTable->Add( m_flexLeftColumnBoxSizer, 1, wxEXPAND, 5 ); - m_staticlineSep = new wxStaticLine( this, ID_M_STATICLINESEP, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); + m_staticlineSep = new wxStaticLine( sbSizerLayersTable->GetStaticBox(), ID_M_STATICLINESEP, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); sbSizerLayersTable->Add( m_staticlineSep, 0, wxEXPAND | wxALL, 5 ); diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp index 2969fb1af2..e43855a2b9 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp +++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 1 0 @@ -110,6 +112,7 @@ sbSizerLayersTable wxHORIZONTAL + 1 protected @@ -794,7 +797,7 @@ m_sdbSizerButtons protected - OnCancelClick + diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.h b/gerbview/dialogs/dialog_layers_select_to_pcb_base.h index c5cfba6356..462a08d5c0 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.h +++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,6 +11,8 @@ #include #include #include +class DIALOG_SHIM; + #include "dialog_shim.h" #include #include @@ -40,7 +42,6 @@ class LAYERS_MAP_DIALOG_BASE : public DIALOG_SHIM void _wxFB_OnStoreSetup( wxCommandEvent& event ){ OnStoreSetup( event ); } void _wxFB_OnGetSetup( wxCommandEvent& event ){ OnGetSetup( event ); } void _wxFB_OnResetClick( wxCommandEvent& event ){ OnResetClick( event ); } - void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); } void _wxFB_OnOkClick( wxCommandEvent& event ){ OnOkClick( event ); } @@ -74,7 +75,6 @@ class LAYERS_MAP_DIALOG_BASE : public DIALOG_SHIM virtual void OnStoreSetup( wxCommandEvent& event ) { event.Skip(); } virtual void OnGetSetup( wxCommandEvent& event ) { event.Skip(); } virtual void OnResetClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index b0267c9c7f..e662a67792 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -49,8 +49,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc ref = GetNearestGridPosition( ref ); int layer = getActiveLayer(); - GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); - GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer ); + GERBER_FILE_IMAGE* gerber = GetGbrImage( layer ); // Search first on active layer GERBER_DRAW_ITEM* gerb_item = NULL; @@ -69,9 +68,9 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc if( !found ) // Search on all layers { - for( layer = 0; layer < (int)images->ImagesMaxCount(); ++layer ) + for( layer = 0; layer < (int)ImagesMaxCount(); ++layer ) { - gerber = images->GetGbrImage( layer ); + gerber = GetGbrImage( layer ); if( gerber == NULL ) // Graphic layer not yet used continue; diff --git a/gerbview/onleftclick.cpp b/gerbview/onleftclick.cpp index 3dfe6f6004..e5462a675b 100644 --- a/gerbview/onleftclick.cpp +++ b/gerbview/onleftclick.cpp @@ -42,8 +42,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) if( DrawStruct == NULL ) { - GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); - GERBER_FILE_IMAGE* gerber = images->GetGbrImage( getActiveLayer() ); + GERBER_FILE_IMAGE* gerber = GetGbrImage( getActiveLayer() ); if( gerber ) gerber->DisplayImageInfo( this ); diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp index 8f5cfe33b0..0a684bf752 100644 --- a/gerbview/onrightclick.cpp +++ b/gerbview/onrightclick.cpp @@ -36,10 +36,10 @@ */ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) { - GERBER_DRAW_ITEM* DrawStruct = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem(); + GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem(); wxString msg; bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle(); - bool busy = DrawStruct && DrawStruct->GetFlags(); + bool busy = currItem && currItem->GetFlags(); // Do not initiate a start block validation on menu. m_canvas->SetCanStartBlock( -1 ); @@ -47,8 +47,8 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) // Simple location of elements where possible. if( !busy ) { - DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE ); - busy = DrawStruct && DrawStruct->GetFlags(); + currItem = Locate( aPosition, CURSEUR_OFF_GRILLE ); + busy = currItem && currItem->GetFlags(); } // If command in progress, end command. @@ -88,8 +88,8 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) if( BlockActive ) return true; - if( DrawStruct ) - GetScreen()->SetCurItem( DrawStruct ); + if( currItem ) + GetScreen()->SetCurItem( currItem ); return true; } diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 38ecae5b68..d9b2493b04 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -41,8 +41,8 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName ) wxString msg; int layer = getActiveLayer(); - GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); - GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer ); + GERBER_FILE_IMAGE_LIST* images = GetImagesList(); + GERBER_FILE_IMAGE* gerber = GetGbrImage( layer ); if( gerber == NULL ) { diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp index 80871e8bbf..1ce133e5e6 100644 --- a/gerbview/select_layers_to_pcb.cpp +++ b/gerbview/select_layers_to_pcb.cpp @@ -395,12 +395,6 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event ) } -void LAYERS_MAP_DIALOG::OnCancelClick( wxCommandEvent& event ) -{ - EndModal( wxID_CANCEL ); -} - - void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event ) { /* Make some test about copper layers: @@ -427,5 +421,6 @@ void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event ) _("The exported board has not enough copper layers to handle selected inner layers") ); return; } + EndModal( wxID_OK ); } diff --git a/gerbview/select_layers_to_pcb.h b/gerbview/select_layers_to_pcb.h index e9a6edacd3..e27ee592bf 100644 --- a/gerbview/select_layers_to_pcb.h +++ b/gerbview/select_layers_to_pcb.h @@ -60,7 +60,6 @@ private: void OnBrdLayersCountSelection( wxCommandEvent& event ); void OnSelectLayer( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ); void OnStoreSetup( wxCommandEvent& event ); void OnGetSetup( wxCommandEvent& event ); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index ab15448543..e1f6f86ea7 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -307,8 +307,7 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ) void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ) { int layer = getActiveLayer(); - GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); - GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer ); + GERBER_FILE_IMAGE* gerber = GetGbrImage( layer ); int selected = ( gerber ) ? gerber->m_Selected_Tool : 0; if( m_DCodeSelector && m_DCodeSelector->GetSelectedDCodeId() != selected )