From aaa1e35b6ae810abbca78d435aa360f5ef711470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= Date: Mon, 17 Jul 2017 14:55:31 +0200 Subject: [PATCH 1/3] Heirarchical sheet selection includes more. Now the heirarchical sheet selection feature includes tracks that belong to a net spanning multiple sheets, but only by doing a logical connection from the pads of the modules. This is to be able to select connections between components on the same sheet. For example if the sheet contains a star power connection or something similar, then most of the sheet local connections will now also be included. --- pcbnew/class_board.cpp | 16 ++++++++++++++++ pcbnew/class_board.h | 10 ++++++++++ pcbnew/class_track.h | 11 +++++++++++ pcbnew/tools/selection_tool.cpp | 14 +++++++++++++- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 07e7200551..4e0947e474 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -1560,6 +1561,21 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint ) } return NULL; + +} + +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() ) ) + { + 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_board.h b/pcbnew/class_board.h index 4e1a9cf194..df32977d5f 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -1151,6 +1151,16 @@ public: VIA* GetViaByPosition( const wxPoint& aPosition, PCB_LAYER_ID aLayer = PCB_LAYER_ID( -1 ) ) const; + /** + * Function GetTracksByPosition + * finds the list of tracks that starts or ends at \a aPosition on \a aLayer. + * + * @param aPosition The wxPoint to check start agains against. + * @param aLayer The layer to search. Use -1 (::UNDEFINED_LAYER) for a don't care. + * @return std::list A list of TRACK* items that can be zero if no track is found. + */ + std::list GetTracksByPosition( const wxPoint& aPosition, PCB_LAYER_ID aLayer = PCB_LAYER_ID( -1 ) ) const; + /** * Function GetPad * finds a pad \a aPosition on \a aLayer. diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 7b4602e53d..2e80714264 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -498,5 +498,16 @@ inline VIA* GetFirstVia( TRACK* aTrk, const TRACK* aStopPoint = NULL ) else return NULL; } +inline TRACK* GetFirstTrack( TRACK* aTrk, const TRACK* aStopPoint = NULL ) +{ + while( aTrk && ( aTrk != aStopPoint ) && ( aTrk->Type() != PCB_TRACE_T ) ) + aTrk = aTrk->Next(); + + // It could stop because of the stop point, not on a via + if( aTrk && ( aTrk->Type() == PCB_TRACE_T ) ) + return static_cast( aTrk ); + else + return NULL; +} #endif // CLASS_TRACK_H diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 2876361551..31840f61cf 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -897,6 +897,7 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) //Generate a list of all pads, and of all nets they belong to. std::list netcodeList; + std::list padList; for( MODULE* mmod : modList ) { for( auto pad : mmod->Pads() ) @@ -904,14 +905,25 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) if( pad->IsConnected() ) { netcodeList.push_back( pad->GetNetCode() ); + padList.push_back( pad ); } } } - // remove all duplicates netcodeList.sort(); netcodeList.unique(); + // 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 ) + { + selectAllItemsConnectedToTrack( *track ); + } + } + // now we need to find all modules that are connected to each of these nets // then we need to determine if these modules are in the list of modules // belonging to this sheet ( modList ) From 5e70810161b3fc9d86226945a225a925896115b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= Date: Mon, 24 Jul 2017 21:58:55 +0200 Subject: [PATCH 2/3] Disabled the automatic schematic-cross probing due to performance reasons. Added sheet-context menu entry for the cross-probing instead. --- bitmaps_png/CMakeLists.txt | 1 + bitmaps_png/cpp_26/select_same_sheet.cpp | 87 +++++ bitmaps_png/sources/select_same_sheet.svg | 409 ++++++++++++++++++++++ eeschema/controle.cpp | 8 +- eeschema/eeschema_id.h | 1 + eeschema/hotkeys.h | 3 +- eeschema/onrightclick.cpp | 5 + eeschema/schedit.cpp | 25 ++ eeschema/schframe.cpp | 1 + eeschema/schframe.h | 7 + include/bitmaps.h | 1 + 11 files changed, 543 insertions(+), 5 deletions(-) create mode 100644 bitmaps_png/cpp_26/select_same_sheet.cpp create mode 100644 bitmaps_png/sources/select_same_sheet.svg diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index a5db052f55..c7ec79e67a 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -469,6 +469,7 @@ set( BMAPS_MID select_grid select_layer_pair select_w_layer + select_same_sheet shape_3d sheetset simulator diff --git a/bitmaps_png/cpp_26/select_same_sheet.cpp b/bitmaps_png/cpp_26/select_same_sheet.cpp new file mode 100644 index 0000000000..0e0827c6a7 --- /dev/null +++ b/bitmaps_png/cpp_26/select_same_sheet.cpp @@ -0,0 +1,87 @@ + +/* Do not modify this file, it was automatically generated by the + * PNG2cpp CMake script, using a *.png file as input. + */ + +#include + +static const unsigned char png[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00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, 0x90, 0x7e, 0x94, 0x74, 0x76, + 0x10, 0xf2, 0x66, 0xf4, 0xe6, 0x85, 0xd3, 0xc7, 0xd4, 0xf7, 0x5b, 0x0e, 0x2f, 0x8b, 0xdc, 0x1c, + 0x08, 0xdd, 0x63, 0x91, 0x97, 0x97, 0xd7, 0x23, 0x94, 0xf0, 0x29, 0x57, 0x4b, 0x85, 0xba, 0x0b, + 0x19, 0x7e, 0xbd, 0x82, 0x88, 0xe7, 0x8d, 0xa3, 0x23, 0x28, 0xe9, 0x25, 0xe4, 0x66, 0x3b, 0x21, + 0x57, 0xda, 0x08, 0x79, 0x69, 0xeb, 0x86, 0xd9, 0x26, 0x89, 0x3b, 0x73, 0x64, 0x07, 0x9c, 0x61, + 0x33, 0xcb, 0xb1, 0x1d, 0x25, 0x27, 0x27, 0xaf, 0xba, 0x47, 0xcd, 0xba, 0xc4, 0x39, 0xe9, 0x2b, + 0x41, 0xd3, 0x7d, 0x66, 0x12, 0x4a, 0x41, 0x24, 0xe7, 0xf7, 0x43, 0x4a, 0x58, 0xf4, 0xcd, 0x81, + 0x49, 0xac, 0xae, 0xcf, 0x41, 0x01, 0x5d, 0x36, 0xe8, 0x40, 0xc2, 0xd6, 0x88, 0x3c, 0x3d, 0x3d, + 0x6f, 0x57, 0x56, 0x56, 0x46, 0x50, 0xfa, 0x74, 0x91, 0xfa, 0x9b, 0xd2, 0x2d, 0x43, 0x07, 0xf6, + 0x84, 0xcc, 0x75, 0xdc, 0x78, 0x22, 0xa1, 0x88, 0x82, 0x39, 0x86, 0xfa, 0x74, 0x18, 0x4e, 0x88, + 0x83, 0x6b, 0x90, 0x80, 0xc5, 0x2c, 0x85, 0x48, 0x90, 0x43, 0xc4, 0x1a, 0x14, 0xd0, 0x8a, 0x1c, + 0x31, 0x13, 0x45, 0x23, 0x45, 0xf4, 0x20, 0x6a, 0x65, 0xe4, 0x81, 0x16, 0x5e, 0x6f, 0x57, 0xc1, + 0x40, 0x52, 0x54, 0xc8, 0x3d, 0x73, 0x09, 0x25, 0x65, 0x3b, 0xc7, 0xf0, 0x96, 0x0c, 0xee, 0xec, + 0x93, 0xe0, 0x15, 0x67, 0x41, 0x3e, 0x28, 0xe1, 0x69, 0xab, 0x81, 0x52, 0x60, 0x68, 0x57, 0x8b, + 0x7c, 0x90, 0x3d, 0xab, 0xb2, 0x6e, 0x5e, 0x03, 0x7a, 0x77, 0x05, 0x3c, 0x78, 0x35, 0x78, 0xd3, + 0x04, 0x97, 0x2b, 0x59, 0x32, 0x47, 0xb6, 0x9b, 0x33, 0xab, 0x96, 0x81, 0x31, 0x5c, 0x02, 0x63, + 0x78, 0xe5, 0x14, 0x81, 0x9d, 0xa2, 0xb5, 0xe9, 0x0d, 0x2f, 0xc0, 0x53, 0x18, 0x92, 0x05, 0x3c, + 0x92, 0x23, 0xf9, 0x16, 0xd0, 0x02, 0xce, 0x46, 0xa4, 0xf8, 0x6b, 0xfd, 0x7f, 0xa2, 0x14, 0x70, + 0xc1, 0x93, 0xa6, 0xf1, 0x68, 0x23, 0xe2, 0x62, 0x85, 0x8d, 0xcb, 0xc8, 0xe1, 0x12, 0x2b, 0xe2, + 0x58, 0x64, 0x1f, 0x67, 0x59, 0x24, 0x07, 0x89, 0xbd, 0x22, 0x9b, 0x6d, 0xa9, 0x08, 0xb6, 0xf1, + 0x54, 0x30, 0x55, 0x96, 0x0e, 0xdf, 0xc4, 0xc4, 0xc4, 0x8c, 0x7b, 0x78, 0x78, 0xd4, 0xe3, 0xf0, + 0xa1, 0xd0, 0xd0, 0xf0, 0xa1, 0x00, 0x5f, 0xff, 0xa1, 0x14, 0x35, 0x4c, 0x56, 0x1f, 0x85, 0xcf, + 0xcc, 0x6a, 0x6d, 0x7d, 0x22, 0xfa, 0xac, 0xab, 0x52, 0xc2, 0x78, 0x8d, 0x08, 0xee, 0x30, 0x0c, + 0x43, 0x06, 0x07, 0x6f, 0x91, 0xd6, 0xd6, 0x2e, 0xc2, 0x0c, 0xcc, 0x93, 0x44, 0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, 0x28, 0xb2, 0x2c, 0x22, 0x6c, 0xf8, 0xcc, 0xd1, + 0x21, 0x6f, 0x5b, 0x19, 0xa7, 0x64, 0x22, 0x8d, 0x36, 0xfe, 0xe3, 0x23, 0x5d, 0x16, 0x63, 0xf4, + 0xbb, 0xb1, 0xe9, 0x5f, 0xd7, 0xbc, 0x43, 0xad, 0x1e, 0x70, 0x31, 0x57, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +const BITMAP_OPAQUE select_same_sheet_xpm[1] = {{ png, sizeof( png ), "select_same_sheet_xpm" }}; + +//EOF diff --git a/bitmaps_png/sources/select_same_sheet.svg b/bitmaps_png/sources/select_same_sheet.svg new file mode 100644 index 0000000000..e06c888152 --- /dev/null +++ b/bitmaps_png/sources/select_same_sheet.svg @@ -0,0 +1,409 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index cb049bb103..82f2ca0a7f 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -87,10 +87,6 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC SendMessageToPCBNEW( item, component ); break; - case SCH_SHEET_T: - SendMessageToPCBNEW( item, nullptr ); - break; - case SCH_COMPONENT_T: component = (SCH_COMPONENT*) item; SendMessageToPCBNEW( item, component ); @@ -101,6 +97,10 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC component = (SCH_COMPONENT*) LocateItem( aPosition, SCH_COLLECTOR::ComponentsOnly ); break; + /* case SCH_SHEET_T: */ + /* // This may lag on larger projects */ + /* SendMessageToPCBNEW( item, nullptr ); */ + /* break; */ default: ; } diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index f68d5edae2..d42143c3ff 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -129,6 +129,7 @@ enum id_eeschema_frm ID_POPUP_SCH_DISPLAYDOC_CMP, ID_POPUP_SCH_ENTER_SHEET, ID_POPUP_SCH_LEAVE_SHEET, + ID_POPUP_SCH_SELECT_ON_PCB, ID_POPUP_SCH_ADD_JUNCTION, ID_POPUP_SCH_ADD_LABEL, ID_POPUP_SCH_ADD_GLABEL, diff --git a/eeschema/hotkeys.h b/eeschema/hotkeys.h index aa7350ed22..c173e95c89 100644 --- a/eeschema/hotkeys.h +++ b/eeschema/hotkeys.h @@ -83,7 +83,8 @@ enum hotkey_id_commnand { HK_LEAVE_SHEET, HK_DELETE_NODE, HK_AUTOPLACE_FIELDS, - HK_UPDATE_PCB_FROM_SCH + HK_UPDATE_PCB_FROM_SCH, + HK_SELECT_ITEMS_ON_PCB }; // List of hotkey descriptors for Eeschema diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 4d2eb0555a..abcd81cfad 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -762,6 +762,11 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) msg = AddHotkeyName( _( "Drag" ), g_Schematic_Hokeys_Descr, HK_DRAG ); 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 )); + PopMenu->AppendSeparator(); + wxMenu* orientmenu = new wxMenu; msg = AddHotkeyName( _( "Rotate Clockwise" ), g_Schematic_Hokeys_Descr, HK_ROTATE ); AddMenuItem( orientmenu, ID_SCH_ROTATE_CLOCKWISE, msg, KiBitmap( rotate_cw_xpm ) ); diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index a1659b46d3..6f7da01126 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -833,6 +833,31 @@ 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(); + + if( item != NULL ) + { + item = LocateAndShowItem( item->GetPosition() ); + 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); + + } + +} void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent ) { diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 0681b9e721..0378b2ef36 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -233,6 +233,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_GEN_PLOT_SCHEMATIC, SCH_EDIT_FRAME::PlotSchematic ) EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, EDA_DRAW_FRAME::CopyToClipboard ) EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit ) + EVT_MENU( ID_POPUP_SCH_SELECT_ON_PCB, SCH_EDIT_FRAME::SelectAllFromSheet ) EVT_MENU( ID_POPUP_SCH_DUPLICATE_ITEM, SCH_EDIT_FRAME::OnCopySchematicItemRequest ) diff --git a/eeschema/schframe.h b/eeschema/schframe.h index 4bc932901c..ab07418ea2 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -812,6 +812,13 @@ private: */ void OnEditItem( wxCommandEvent& aEvent ); + /** + * Function SelectAllFromSheet + * handles the #ID_POPUP_SCH_SELECT_ON_PCB event used to select items in pcbnew + * based on the sheet they are placed on. + */ + void SelectAllFromSheet( wxCommandEvent& aEvent ); + /** * Function OnDragItem * handles the #ID_SCH_DRAG_ITEM event used to drag schematic itams. diff --git a/include/bitmaps.h b/include/bitmaps.h index dc1e4907f9..ee160f9a7c 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -437,6 +437,7 @@ EXTERN_BITMAP( save_xpm ) EXTERN_BITMAP( select_grid_xpm ) EXTERN_BITMAP( select_layer_pair_xpm ) EXTERN_BITMAP( select_w_layer_xpm ) +EXTERN_BITMAP( select_same_sheet_xpm ) EXTERN_BITMAP( sheetset_xpm ) EXTERN_BITMAP( setcolor_3d_bg_xpm ) EXTERN_BITMAP( setcolor_silkscreen_xpm ) From 25abe30c7217fa41ee0edb800f4622cdaef9ac58 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 18 Sep 2017 11:25:32 +0200 Subject: [PATCH 3/3] 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 ); }