diff --git a/eeschema/net_navigator.cpp b/eeschema/net_navigator.cpp index 50bb2c1f76..cab9068c2e 100644 --- a/eeschema/net_navigator.cpp +++ b/eeschema/net_navigator.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,7 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, SCH_SYMBOL* symbol = pin->GetParentSymbol(); wxCHECK( symbol, retv ); - retv.Printf( _( "Symbol %s pin %s" ), symbol->GetRef( &aSheetPath, true ), + retv.Printf( _( "Symbol '%s' pin '%s'" ), symbol->GetRef( &aSheetPath, true ), pin->GetNumber() ); break; } @@ -92,7 +93,7 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, SCH_SHEET* sheet = pin->GetParent(); wxCHECK( sheet, retv ); - retv.Printf( _( "Sheet %s pin %s" ), sheet->GetName(), pin->GetText() ); + retv.Printf( _( "Sheet '%s' pin '%s'" ), sheet->GetName(), pin->GetText() ); break; } case SCH_LABEL_T: @@ -100,7 +101,7 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, const SCH_LABEL* label = static_cast( aItem ); wxCHECK( label, retv ); - retv.Printf( _( "Label %s at %s, %s" ), label->GetText(), + retv.Printf( _( "Label '%s' at %s, %s" ), label->GetText(), aUnitsProvider->MessageTextFromValue( label->GetPosition().x ), aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) ); break; @@ -110,7 +111,7 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, const SCH_GLOBALLABEL* label = static_cast( aItem ); wxCHECK( label, retv ); - retv.Printf( _( "Global label %s at %s, %s" ), label->GetText(), + retv.Printf( _( "Global label '%s' at %s, %s" ), label->GetText(), aUnitsProvider->MessageTextFromValue( label->GetPosition().x ), aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) ); break; @@ -120,7 +121,7 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, const SCH_HIERLABEL* label = static_cast( aItem ); wxCHECK( label, retv ); - retv.Printf( _( "Hierarchical label %s at %s, %s" ), label->GetText(), + retv.Printf( _( "Hierarchical label '%s' at %s, %s" ), label->GetText(), aUnitsProvider->MessageTextFromValue( label->GetPosition().x ), aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) ); break; @@ -135,6 +136,30 @@ static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem, aUnitsProvider->MessageTextFromValue( junction->GetPosition().y ) ); break; } + case SCH_BUS_WIRE_ENTRY_T: + { + const SCH_BUS_WIRE_ENTRY* entry = static_cast( aItem ); + wxCHECK( entry, retv ); + + retv.Printf( _( "Bus to wire entry from %s, %s to %s, %s" ), + aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ), + aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ), + aUnitsProvider->MessageTextFromValue( entry->GetEnd().x ), + aUnitsProvider->MessageTextFromValue( entry->GetEnd().y ) ); + break; + } + case SCH_BUS_BUS_ENTRY_T: + { + const SCH_BUS_BUS_ENTRY* entry = static_cast( aItem ); + wxCHECK( entry, retv ); + + retv.Printf( _( "Bus to bus entry from %s, %s to %s, %s" ), + aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ), + aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ), + aUnitsProvider->MessageTextFromValue( entry->GetEnd().x ), + aUnitsProvider->MessageTextFromValue( entry->GetEnd().y ) ); + break; + } default: retv.Printf( _( "Unhandled item type %d" ), aItem->Type() ); } @@ -164,7 +189,10 @@ void SCH_EDIT_FRAME::MakeNetNavigatorNode( const wxString& aNetName, wxTreeItemI NET_NAVIGATOR_ITEM_DATA* itemData = nullptr; SCH_SHEET_PATH sheetPath = subGraph->GetSheet(); - wxCHECK2( sheetPath.Last(), continue ); + wxCHECK2( subGraph && sheetPath.Last(), continue ); + + if( subGraph->GetItems().empty() ) + continue; itemData = new NET_NAVIGATOR_ITEM_DATA( sheetPath, nullptr ); @@ -224,7 +252,7 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect wxTreeItemId rootId = m_netNavigator->AddRoot( m_highlightedConn, 0 ); - MakeNetNavigatorNode( m_highlightedConn, rootId ); + MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection ); } else { @@ -298,6 +326,25 @@ void SCH_EDIT_FRAME::SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSel } +const SCH_ITEM* SCH_EDIT_FRAME::GetSelectedNetNavigatorItem() const +{ + if( m_netNavigator ) + return nullptr; + + wxTreeItemId id = m_netNavigator->GetSelection(); + + if( !id.IsOk() ) + return nullptr; + + NET_NAVIGATOR_ITEM_DATA* itemData = + dynamic_cast( m_netNavigator->GetItemData( id ) ); + + wxCHECK( itemData, nullptr ); + + return itemData->GetItem(); +} + + void SCH_EDIT_FRAME::onNetNavigatorSelection( wxTreeEvent& aEvent ) { wxCHECK( m_netNavigator, /* void */ ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 5965f20b9e..9038c05868 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -834,6 +834,8 @@ public: wxTreeCtrl* GetNetNavigator() { return m_netNavigator; } + const SCH_ITEM* GetSelectedNetNavigatorItem() const; + /** * @return the name of the wxAuiPaneInfo managing the Hierarchy Navigator panel */ diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index a385d0c428..def67d8c45 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -802,7 +802,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) wxString connectionName = ( conn ) ? conn->Name() : wxString( wxS( "" ) ); - if( !conn || connectionName == editFrame->GetHighlightedConnection() ) + if( !conn ) { editFrame->SetStatusText( wxT( "" ) ); editFrame->SendCrossProbeClearHighlight(); @@ -811,8 +811,16 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) else { NET_NAVIGATOR_ITEM_DATA itemData( editFrame->GetCurrentSheet(), item ); - editFrame->SetCrossProbeConnection( conn ); - editFrame->SetHighlightedConnection( connectionName, &itemData ); + + if( connectionName != editFrame->GetHighlightedConnection() ) + { + editFrame->SetCrossProbeConnection( conn ); + editFrame->SetHighlightedConnection( connectionName, &itemData ); + } + else if( item != editFrame->GetSelectedNetNavigatorItem() ) + { + editFrame->SelectNetNavigatorItem( &itemData ); + } } editFrame->UpdateNetHighlightStatus();