diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index af5c33ab73..3485ad4fec 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -88,6 +88,9 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC break; case SCH_SHEET_T: + SendMessageToPCBNEW( item, nullptr ); + break; + case SCH_COMPONENT_T: component = (SCH_COMPONENT*) item; SendMessageToPCBNEW( item, component ); diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index a08ec15272..da80056d7c 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -40,6 +40,7 @@ #include #include #include +#include /** @@ -110,36 +111,34 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) } -std::string FormatProbeItem( EDA_ITEM* aComponent, SCH_COMPONENT* aPart ) +std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aPart ) { // Cross probing to Pcbnew if a pin or a component is found - switch( aComponent->Type() ) + switch( aItem->Type() ) { case SCH_FIELD_T: case LIB_FIELD_T: - { - if( !aPart ) - break; - - return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) ); - } + if( aPart ) + return StrPrintf( "$PART: %s", + TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) ); break; case SCH_COMPONENT_T: - aPart = (SCH_COMPONENT*) aComponent; + aPart = (SCH_COMPONENT*) aItem; return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) ); case SCH_SHEET_T: - aPart = (SCH_COMPONENT*)aComponent; - return StrPrintf( "$SHEET: %s", TO_UTF8( wxString::Format( wxT("%8.8lX"), - (unsigned long) aPart->GetTimeStamp() ) ) ); + { + SCH_SHEET* sheet = (SCH_SHEET*)aItem; + return StrPrintf( "$SHEET: %8.8lX", (unsigned long) sheet->GetTimeStamp() ); + } case LIB_PIN_T: { if( !aPart ) break; - LIB_PIN* pin = (LIB_PIN*) aComponent; + LIB_PIN* pin = (LIB_PIN*) aItem; if( pin->GetNumber() ) { @@ -165,17 +164,14 @@ std::string FormatProbeItem( EDA_ITEM* aComponent, SCH_COMPONENT* aPart ) } -void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aComponent, SCH_COMPONENT* aPart ) +void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aLibItem ) { -#if 1 - wxASSERT( aComponent ); // fix the caller + wxASSERT( aObjectToSync ); // fix the caller -#else // WTF? - if( !aComponent ) // caller remains eternally stupid. + if( !aObjectToSync ) return; -#endif - std::string packet = FormatProbeItem( aComponent, aPart ); + std::string packet = FormatProbeItem( aObjectToSync, aLibItem ); if( packet.size() ) { diff --git a/eeschema/schframe.h b/eeschema/schframe.h index fb58d1c49b..3562908994 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -488,15 +488,17 @@ public: /** * Function SendMessageToPcbnew * send a remote to Pcbnew via a socket connection. - * @param objectToSync Item to be located on board (footprint, pad or text) - * @param LibItem Component in library if objectToSync is a sub item of a component + * @param aObjectToSync = item to be located on board + * (footprint, pad, text or schematic sheet) + * @param aPart = component if objectToSync is a sub item of a symbol (like a pin) *

* Commands are * $PART: reference put cursor on footprint anchor * $PIN: number $PART: reference put cursor on the footprint pad + * $SHEET: time_stamp select all footprints of components is the schematic sheet path *

*/ - void SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT* LibItem ); + void SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aPart ); /** * BuildNetListBase diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index e7f63c9c47..36c4cd9484 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -45,7 +45,6 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) char line[1024]; wxString msg; wxString modName; - wxString *sheetStamp; char* idcmd; char* text; MODULE* module = NULL; @@ -81,11 +80,10 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) else if( strcmp( idcmd, "$SHEET:" ) == 0 ) { msg.Printf( _( "Selecting all from sheet '%s'" ), FROM_UTF8( text ) ); - sheetStamp = new wxString( FROM_UTF8( text ) ); + wxString sheetStamp( FROM_UTF8( text ) ); SetStatusText( msg ); - GetToolManager()->RunAction( PCB_ACTIONS::selectOnSheet, - true, - static_cast( sheetStamp ) ); + GetToolManager()->RunAction( PCB_ACTIONS::selectOnSheet, true, + static_cast( &sheetStamp ) ); return; } else if( strcmp( idcmd, "$PIN:" ) == 0 ) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index e9ab5d36c1..06efeb7a9f 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -95,18 +95,19 @@ TOOL_ACTION PCB_ACTIONS::selectOnSheet( "pcbnew.InteractiveSelection.SelectOnShe TOOL_ACTION PCB_ACTIONS::selectSameSheet( "pcbnew.InteractiveSelection.SelectSameSheet", AS_GLOBAL, 'P', - _( "Same Sheet" ), _( "Selects all modules and tracks in the same schematic sheet" ) ); + _( "Items in Same Hierarchical Sheet" ), + _( "Selects all modules and tracks in the same schematic sheet" ) ); TOOL_ACTION PCB_ACTIONS::find( "pcbnew.InteractiveSelection.Find", AS_GLOBAL, 0, //TOOL_ACTION::LegacyHotKey( HK_FIND_ITEM ), // handled by wxWidgets - _( "Find Item" ), _( "Searches the document for an item" ), find_xpm ); + _( "Find Item" ),_( "Searches the document for an item" ), find_xpm ); TOOL_ACTION PCB_ACTIONS::findMove( "pcbnew.InteractiveSelection.FindMove", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GET_AND_MOVE_FOOTPRINT ) ); TOOL_ACTION PCB_ACTIONS::filterSelection( "pcbnew.InteractiveSelection.FilterSelection", AS_GLOBAL, MD_SHIFT + 'F', - _( "Filter selection" ), _( "Filter the types of items in the selection" ), + _( "Filter Selection" ), _( "Filter the types of items in the selection" ), nullptr ); @@ -775,6 +776,8 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent ) return 0; } + + void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath ) { auto modules = board()->m_Modules.GetFirst(); @@ -901,10 +904,13 @@ int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent ) // this function currently only supports modules since they are only // on one sheet. auto item = m_selection.Front(); + if( item->Type() != PCB_MODULE_T ) return 0; + if( !item ) return 0; + auto mod = dynamic_cast( item ); clearSelection();