24#include <wx/srchctrl.h>
25#include <wx/wupdlock.h>
44#include <wx/filename.h>
46#include <wx/clntdata.h>
57 wxCHECK( aItem && aUnitsProvider, retv );
59 switch( aItem->
Type() )
67 retv.Printf(
_(
"Wire from (%s, %s) to (%s, %s)" ),
75 retv.Printf(
_(
"Bus from (%s, %s) to (%s, %s)" ),
83 retv =
_(
"Graphic line not connectable" );
92 if(
const SYMBOL* symbol =
pin->GetParentSymbol() )
94 retv.Printf(
_(
"Symbol '%s' pin '%s'" ),
95 symbol->GetRef( &aSheetPath,
true ),
98 if( wxString pinName =
UnescapeString(
pin->GetShownName() ); !pinName.IsEmpty() )
100 retv += wxString::Format(
" (%s)", pinName );
112 retv.Printf(
_(
"Sheet '%s' pin '%s'" ),
123 retv.Printf(
_(
"Label '%s' at (%s, %s)" ),
133 retv.Printf(
_(
"Global label '%s' at (%s, %s)" ),
143 retv.Printf(
_(
"Hierarchical label '%s' at (%s, %s)" ),
153 retv.Printf(
_(
"Junction at (%s, %s)" ),
162 retv.Printf(
_(
"No-Connect at (%s, %s)" ),
171 retv.Printf(
_(
"Bus to wire entry from (%s, %s) to (%s, %s)" ),
182 retv.Printf(
_(
"Bus to bus entry from (%s, %s) to (%s, %s)" ),
193 retv.Printf(
_(
"Netclass label '%s' at (%s, %s)" ),
200 retv.Printf(
_(
"Unhandled item type %d" ), aItem->
Type() );
211 wxCHECK( !aNetName.IsEmpty(), );
215 const auto itemsBySheet = aQuery.
NetItems( aNetName,
true );
217 for(
const auto& [sheetPath, items] : itemsBySheet )
219 wxCHECK2( sheetPath.Last(),
continue );
226 if( !sheetPath.empty() && sheetPath.at( 0 )->GetScreen() )
233 wxFileName fn( sheetPath.at( 0 )->GetScreen()->GetFileName() );
238 for(
unsigned i = 1; i < sheetPath.size(); i++ )
243 txt = sheetPath.PathHumanReadable(
true,
true );
246 wxTreeItemId sheetId =
m_netNavigator->AppendItem( aParentId, txt, -1, -1, itemData );
248 if( aSelection && *aSelection == *itemData )
266 if( aSelection && *aSelection == *itemData )
283 const std::vector<wxString>* aChangedNets )
302 if( selected.IsOk() )
311 selection = *aSelection;
312 aSelection = &selection;
332 const auto rebuildNode = [&](
const wxString&
name, wxTreeItemId node )
336 while( selected.IsOk() && selected != node )
339 const bool restoreSelection = selected == node;
341 std::set<KIID_PATH> expandedSheets;
342 wxTreeItemIdValue cookie;
344 for( wxTreeItemId sheet =
m_netNavigator->GetFirstChild( node, cookie ); sheet.IsOk();
350 expandedSheets.insert( data->GetSheetPath().PathRef() );
357 for( wxTreeItemId sheet =
m_netNavigator->GetFirstChild( node, cookie ); sheet.IsOk();
362 if( data && expandedSheets.contains( data->GetSheetPath().PathRef() ) )
379 std::unique_ptr<std::regex> regexFilter;
386 if( !globFilter.Contains( wxT(
"*" ) ) && !globFilter.Contains( wxT(
"?" ) ) )
387 globFilter = wxT(
"*" ) + globFilter + wxT(
"*" );
394 regexFilter = std::make_unique<std::regex>(
396 std::regex_constants::icase | std::regex_constants::ECMAScript );
398 catch(
const std::regex_error& )
411 const auto names = incremental ? *aChangedNets : query.
NetNames();
415 for(
const wxString& netName : names )
417 if( netName.IsEmpty() )
422 if( incremental && !
m_schematic->Connectivity().NetByName( netName ) )
438 bool matches =
false;
440 if( useWildcard && !globFilter.IsEmpty() )
445 else if( !useWildcard && regexFilter )
450 matches = std::regex_search( displayName.ToStdString(), *regexFilter );
452 catch(
const std::regex_error& )
466 rebuildNode( netName, existing->second );
470 wxTreeItemId netId =
m_netNavigator->AppendItem( rootId, displayName, -1, -1 );
473 sortRoot |= incremental;
492 else if( std::ranges::find( *aChangedNets,
m_highlightedConn ) != aChangedNets->end() )
501 wxLogTrace(
traceUiProfile, wxS(
"Adding %zu nodes to net navigator took %s." ),
518 std::vector<wxTreeItemId> netItems;
519 std::list<wxTreeItemId> itemList;
520 itemList.push_back( netNode );
522 while( !itemList.empty() )
524 wxTreeItemId current = itemList.front();
525 itemList.pop_front();
527 wxTreeItemIdValue cookie;
528 wxTreeItemId child =
m_netNavigator->GetFirstChild( current, cookie );
530 while( child.IsOk() )
533 itemList.push_back( child );
535 netItems.push_back( child );
542 auto it = std::find( netItems.begin(), netItems.end(),
id );
544 if( it != netItems.end() )
549 if( it == netItems.end() )
550 it = netItems.begin();
554 if( it == netItems.begin() )
574 if( data && data->GetItem() )
597 wxTreeItemIdValue sheetCookie;
599 wxTreeItemId sheetId =
m_netNavigator->GetFirstChild( rootId, sheetCookie );
601 while( sheetId.IsOk() )
605 wxTreeItemIdValue itemCookie;
606 wxTreeItemId itemId =
m_netNavigator->GetFirstChild( sheetId, itemCookie );
608 while( itemId.IsOk() )
612 wxCHECK2( itemData,
continue );
614 if( *itemData == *aSelection )
647 wxCHECK( itemData,
nullptr );
649 return itemData->GetItem();
675 selected = &selection;
691 wxTreeItemId
id = aEvent.GetItem();
710 const SCH_ITEM* item = itemData->GetItem();
717 const SCH_SCREEN* screen = itemData->GetSheetPath().LastScreen();
746 netNavigatorPane.Show( !netNavigatorPane.IsShown() );
751 if( netNavigatorPane.IsShown() )
753 if( netNavigatorPane.IsFloating() )
767 if( netNavigatorPane.IsFloating() )
779 if( netNavigatorPane.IsShown() )
785 if( selection.IsOk() )
801 if( !netNavigatorPane.IsShown() )
846 if( netNavigatorPane.rect.width > 50 )
849 netNavigatorPane.best_size.x = netNavigatorPane.rect.width;
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual const wxString & GetText() const
Return the string associated with the text object.
bool contains(const SCH_ITEM *aItem, bool aRobust=false) const
Determine if a given item exists in the tree.
APP_SETTINGS_BASE * KifaceSettings() const
Tree view item data for the net navigator.
const SCH_ITEM * GetItem() const
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
static TOOL_ACTION changeSheet
static TOOL_ACTION updateNetHighlighting
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EESCHEMA_SETTINGS * eeconfig() const
Class for a bus to bus entry.
VECTOR2I GetPosition() const override
Class for a wire to bus entry.
One UI operation's hierarchy index.
NET_ITEMS_BY_SHEET NetItems(const wxString &aName, bool aIncludeBusParents, bool aIncludeBusMembers=false) const
std::vector< wxString > NetNames() const
wxString m_netNavigatorConnection
void ToggleNetNavigator()
void onResizeNetNavigator(wxSizeEvent &aEvent)
void updateSelectionFilterVisbility() override
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void onNetNavigatorSelChanging(wxTreeEvent &aEvent)
NET_NAVIGATOR_TREE * m_netNavigator
void MakeNetNavigatorNode(const wxString &aNetName, wxTreeItemId aParentId, const NET_NAVIGATOR_ITEM_DATA *aSelection, const SCH_CONNECTIVITY::NAVIGATION_QUERY &aQuery)
void RefreshNetNavigator(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr, const std::vector< wxString > *aChangedNets=nullptr)
SCHEMATIC * m_schematic
The currently loaded schematic.
SCH_SHEET_PATH & GetCurrentSheet() const
wxString m_netNavigatorFilterValue
const SCH_ITEM * GetSelectedNetNavigatorItem() const
wxSearchCtrl * m_netNavigatorFilter
std::map< wxString, wxTreeItemId > m_netNavigatorNodes
const SCH_ITEM * SelectNextPrevNetNavigatorItem(bool aNext)
void SetHighlightedConnection(const wxString &aConnection, const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr, bool aForceNetNavigatorRefresh=false)
void SelectNetNavigatorItem(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
wxString m_highlightedConn
The highlighted net or bus or empty string.
static const wxString NetNavigatorPaneName()
void onNetNavigatorDPIChanged(wxDPIChangedEvent &aEvent)
void onNetNavigatorSelection(wxTreeEvent &aEvent)
void FindNetInInspector(const wxString &aNetName)
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
VECTOR2I GetPosition() const override
Segment description base class to describe items which have 2 end points (track, wire,...
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
VECTOR2I GetPosition() const override
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
VECTOR2I GetPosition() const override
A base class for LIB_SYMBOL and SCH_SYMBOL.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
This file is part of the common library.
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
const wxChar *const traceUiProfile
Flag to enable user interface profile tracing.
static wxString GetNetNavigatorItemText(const SCH_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath, UNITS_PROVIDER *aUnitsProvider)
bool WildCompareString(const wxString &pattern, const wxString &string_to_tst, bool case_sensitive)
Compare a string against wild card (* and ?) pattern using the usual rules.
wxString UnescapeString(const wxString &aSource)
bool net_nav_search_mode_wildcard
wxSize net_nav_panel_float_size
wxSize net_nav_panel_docked_size
wxLogTrace helper definitions.
Definition of file extensions used in Kicad.
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.