From 25abe30c7217fa41ee0edb800f4622cdaef9ac58 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 18 Sep 2017 11:25:32 +0200 Subject: [PATCH] Code formatting --- eeschema/onrightclick.cpp | 4 ++-- eeschema/schedit.cpp | 25 +++++++++++++------------ pcbnew/class_board.cpp | 7 +++++-- pcbnew/class_track.h | 3 +++ pcbnew/tools/selection_tool.cpp | 4 +++- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index abcd81cfad..e84e44246a 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -763,8 +763,8 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) AddMenuItem( PopMenu, ID_SCH_DRAG_ITEM, msg, KiBitmap( drag_xpm ) ); PopMenu->AppendSeparator(); - msg = AddHotkeyName( _( "Select Items On PCB"), g_Schematic_Hokeys_Descr, HK_SELECT_ITEMS_ON_PCB ); - AddMenuItem( PopMenu, ID_POPUP_SCH_SELECT_ON_PCB, msg, KiBitmap( select_same_sheet_xpm )); + msg = AddHotkeyName( _( "Select Items On PCB" ), g_Schematic_Hokeys_Descr, HK_SELECT_ITEMS_ON_PCB ); + AddMenuItem( PopMenu, ID_POPUP_SCH_SELECT_ON_PCB, msg, KiBitmap( select_same_sheet_xpm ) ); PopMenu->AppendSeparator(); wxMenu* orientmenu = new wxMenu; diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 6f7da01126..23d4bdafa2 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -833,32 +833,33 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC ) m_canvas->Refresh(); } + void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent ) { - SCH_SCREEN* screen = GetScreen(); - SCH_ITEM* item = screen->GetCurItem(); + SCH_SCREEN* screen = GetScreen(); + SCH_ITEM* item = screen->GetCurItem(); - if( item != NULL ) - { + if( item != NULL ) + { item = LocateAndShowItem( item->GetPosition() ); - SendMessageToPCBNEW(item, NULL); - } - else - { + SendMessageToPCBNEW( item, NULL ); + } + else + { // If we didn't get here by a hot key, then something has gone wrong. if( aEvent.GetInt() == 0 ) return; + EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject(); wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) ); item = LocateAndShowItem( data->GetPosition() ); - SendMessageToPCBNEW(item, NULL); - - } - + SendMessageToPCBNEW( item, NULL ); + } } + void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent ) { SCH_SCREEN* screen = GetScreen(); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 4e0947e474..c01a43a73b 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -1564,17 +1564,20 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint ) } + std::list BOARD::GetTracksByPosition( const wxPoint& aPosition, PCB_LAYER_ID aLayer ) const { std::list tracks; - for( TRACK *track = GetFirstTrack( m_Track); track; track = GetFirstTrack( track->Next() ) ) + + for( TRACK* track = GetFirstTrack( m_Track ); track; track = GetFirstTrack( track->Next() ) ) { - if( ( ( track->GetStart() == aPosition) || track->GetEnd() == aPosition ) && + if( ( ( track->GetStart() == aPosition ) || track->GetEnd() == aPosition ) && ( track->GetState( BUSY | IS_DELETED ) == 0 ) && ( ( aLayer == UNDEFINED_LAYER ) || ( track->IsOnLayer( aLayer ) ) ) ) tracks.push_back( track ); } + return tracks; } diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 2e80714264..3535eb3618 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -498,6 +498,9 @@ inline VIA* GetFirstVia( TRACK* aTrk, const TRACK* aStopPoint = NULL ) else return NULL; } + + +/// Scan a track list for the first TRACK object. Returns NULL if not found (or NULL passed) inline TRACK* GetFirstTrack( TRACK* aTrk, const TRACK* aStopPoint = NULL ) { while( aTrk && ( aTrk != aStopPoint ) && ( aTrk->Type() != PCB_TRACE_T ) ) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 31840f61cf..786414bd7f 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -915,10 +915,12 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) // auto select trivial connections segments which are launched from the pads std::list launchTracks; + for( auto pad : padList ) { launchTracks = board()->GetTracksByPosition( pad->GetPosition() ); - for ( auto track : launchTracks ) + + for( auto track : launchTracks ) { selectAllItemsConnectedToTrack( *track ); }