From 3a43f0527f300ece3c33a7b5bd3ec69ed8a8b8e1 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 21 Mar 2014 18:00:11 +0100 Subject: [PATCH] Changed void BASE_SCREEN::GetGrids( GRIDS& aList ) to const GRIDS& BASE_SCREEN::GetGrids(). Refactored: - EDA_DRAW_FRAME::SetNextGrid() & SetPrevGrid() - PCB_BASE_FRAME::SetFastGrid1() & SetFastGrid2() Removed a warning from RN_DATA::updateNet(int). --- common/base_screen.cpp | 7 ------ common/drawframe.cpp | 34 +++++++++++++++++++++++++++- eeschema/eeschema_config.cpp | 4 +--- include/class_base_screen.h | 11 +++++----- include/wxBasePcbFrame.h | 21 +++++++++++++----- include/wxstruct.h | 12 ++++++++++ pcbnew/basepcbframe.cpp | 27 +++++++++++++++++++++++ pcbnew/class_board.h | 14 +++++------- pcbnew/hotkeys_board_editor.cpp | 39 ++++----------------------------- pcbnew/ratsnest_data.cpp | 2 +- 10 files changed, 106 insertions(+), 65 deletions(-) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index a441a418d5..01a798df4a 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -175,13 +175,6 @@ void BASE_SCREEN::SetGridList( GRIDS& gridlist ) } -void BASE_SCREEN::GetGrids( GRIDS& aList ) -{ - for( size_t i = 0; i < m_grids.size(); i++ ) - aList.push_back( m_grids[ i ] ); -} - - int BASE_SCREEN::SetGrid( const wxRealPoint& size ) { wxASSERT( !m_grids.empty() ); diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 31048df82f..45913b5171 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -395,7 +395,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) if( IsGalCanvasActive() ) { GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x, - screen->GetGrid().m_Size.y ) ); + screen->GetGrid().m_Size.y ) ); GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); } @@ -532,6 +532,38 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const } +void EDA_DRAW_FRAME::SetNextGrid() +{ + if( m_gridSelectBox ) + { + m_gridSelectBox->SetSelection( ( m_gridSelectBox->GetSelection() + 1 ) % + m_gridSelectBox->GetCount() ); + + wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); + // cmd.SetEventObject( this ); + OnSelectGrid( cmd ); + } +} + + +void EDA_DRAW_FRAME::SetPrevGrid() +{ + if( m_gridSelectBox ) + { + int cnt = m_gridSelectBox->GetSelection(); + + if( --cnt < 0 ) + cnt = m_gridSelectBox->GetCount() - 1; + + m_gridSelectBox->SetSelection( cnt ); + + wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); + // cmd.SetEventObject( this ); + OnSelectGrid( cmd ); + } +} + + int EDA_DRAW_FRAME::ReturnBlockCommand( int key ) { return 0; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 43e5ec21e3..4449957e0b 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -255,9 +255,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event ) { wxArrayString units; - GRIDS grid_list; - - GetScreen()->GetGrids( grid_list ); + GRIDS grid_list = GetScreen()->GetGrids(); DIALOG_EESCHEMA_OPTIONS dlg( this ); diff --git a/include/class_base_screen.h b/include/class_base_screen.h index eed5987e39..502ab9a9e6 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -65,7 +65,7 @@ public: }; -typedef std::vector< GRID_TYPE > GRIDS; +typedef std::vector GRIDS; /** @@ -445,11 +445,12 @@ public: /** * Function GetGrids(). - * Copy the grid list to \a aList. - * - * @param aList - List to copy to. + * Returns the current list of grids. */ - void GetGrids( GRIDS& aList ); + const GRIDS& GetGrids() const + { + return m_grids; + } /** * Function GetClass diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 4306d67977..6f8c226e90 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -76,8 +76,8 @@ public: EDA_UNITS_T m_UserGridUnit; wxRealPoint m_UserGridSize; - int m_FastGrid1; - int m_FastGrid2; + int m_FastGrid1; // 1st fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox) + int m_FastGrid2; // 2nd fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox) EDA_3D_FRAME* m_Draw3DFrame; @@ -220,13 +220,10 @@ public: * Function BestZoom * @return the "best" zoom to show the entire board or footprint on the screen. */ - virtual double BestZoom(); virtual void Show3D_Frame( wxCommandEvent& event ); -public: - // Read/write functions: EDA_ITEM* ReadDrawSegmentDescr( LINE_READER* aReader ); int ReadListeSegmentDescr( LINE_READER* aReader, @@ -680,6 +677,20 @@ public: void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ); void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ); + /** + * Function SetFastGrid1() + * + * Switches grid settings to the 1st "fast" setting predefined by user. + */ + void SetFastGrid1(); + + /** + * Function SetFastGrid2() + * + * Switches grid settings to the 1st "fast" setting predefined by user. + */ + void SetFastGrid2(); + DECLARE_EVENT_TABLE() }; diff --git a/include/wxstruct.h b/include/wxstruct.h index 69a24fa7a0..5564fe6050 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -727,6 +727,18 @@ public: */ wxPoint GetGridPosition( const wxPoint& aPosition ) const; + /** + * Function SetNextGrid() + * changes the grid size settings to the next one available. + */ + virtual void SetNextGrid(); + + /** + * Function SetPrevGrid() + * changes the grid size settings to the previous one available. + */ + virtual void SetPrevGrid(); + /** * Command event handler for selecting grid sizes. * diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 0464d04683..1bccc1894a 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -914,6 +914,7 @@ void PCB_BASE_FRAME::updateGridSelectBox() } } + void PCB_BASE_FRAME::updateZoomSelectBox() { if( m_zoomSelectBox == NULL ) @@ -943,3 +944,29 @@ void PCB_BASE_FRAME::updateZoomSelectBox() m_zoomSelectBox->SetSelection( i + 1 ); } } + + +void PCB_BASE_FRAME::SetFastGrid1() +{ + if( m_gridSelectBox ) + { + m_gridSelectBox->SetSelection( m_FastGrid1 ); + + wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); + cmd.SetEventObject( this ); + OnSelectGrid( cmd ); + } +} + + +void PCB_BASE_FRAME::SetFastGrid2() +{ + if( m_gridSelectBox ) + { + m_gridSelectBox->SetSelection( m_FastGrid2 ); + + wxCommandEvent cmd( wxEVT_COMMAND_COMBOBOX_SELECTED ); + cmd.SetEventObject( this ); + OnSelectGrid( cmd ); + } +} diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 92058d0af6..0d394297b2 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -68,8 +68,6 @@ namespace KIGFX // non-owning container of item candidates when searching for items on the same track. typedef std::vector< TRACK* > TRACK_PTRS; -#define HISTORY_MAX_COUNT 8 - /** * Enum LAYER_T @@ -305,13 +303,13 @@ public: // the first value is always the value of the current NetClass // The others values are extra values - /// Vias size and drill list(max count = HISTORY_MAX_COUNT) - std::vector m_ViasDimensionsList; + // The first value is the current netclass via size // TODO verify + /// Vias size and drill list + std::vector m_ViasDimensionsList; - // The first value is the current netclass via size - // tracks widths (max count = HISTORY_MAX_COUNT) - // The first value is the current netclass track width - std::vector m_TrackWidthList; + // The first value is the current netclass track width // TODO verify + /// Track width list + std::vector m_TrackWidthList; BOARD(); diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 6364d69ba6..42ab76ac75 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -216,50 +216,19 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; case HK_SWITCH_GRID_TO_FASTGRID1: - if( m_gridSelectBox ) - { - m_gridSelectBox->SetSelection( m_FastGrid1 ); - cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED ); - OnSelectGrid( cmd ); - } - + SetFastGrid1(); break; case HK_SWITCH_GRID_TO_FASTGRID2: - if( m_gridSelectBox ) - { - m_gridSelectBox->SetSelection( m_FastGrid2 ); - cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED ); - OnSelectGrid( cmd ); - } - + SetFastGrid2(); break; case HK_SWITCH_GRID_TO_NEXT: - if( m_gridSelectBox ) - { - m_gridSelectBox->SetSelection( ( m_gridSelectBox->GetSelection() + 1 ) % - m_gridSelectBox->GetCount() ); - cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED ); - OnSelectGrid( cmd ); - } + SetNextGrid(); break; case HK_SWITCH_GRID_TO_PREVIOUS: - if( m_gridSelectBox ) - { - cnt = m_gridSelectBox->GetSelection(); - - if ( cnt == 0 ) - cnt = m_gridSelectBox->GetCount() - 1; - else - cnt--; - - m_gridSelectBox->SetSelection( cnt ); - cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED ); - OnSelectGrid( cmd ); - } - + SetPrevGrid(); break; case HK_SWITCH_LAYER_TO_PREVIOUS: diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp index 4242ea6bf1..b2bc4d5899 100644 --- a/pcbnew/ratsnest_data.cpp +++ b/pcbnew/ratsnest_data.cpp @@ -1024,7 +1024,7 @@ void RN_DATA::updateNet( int aNetCode ) { assert( aNetCode < (int) m_nets.size() ); - if( aNetCode < 1 || aNetCode > m_nets.size() ) + if( aNetCode < 1 || aNetCode > (int) m_nets.size() ) return; m_nets[aNetCode].ClearSimple();