24#include <wx/srchctrl.h>
25#include <wx/wupdlock.h>
42#include <wx/filename.h>
44#include <wx/clntdata.h>
55 wxCHECK( aItem && aUnitsProvider, retv );
57 switch( aItem->
Type() )
65 retv.Printf(
_(
"Wire from (%s, %s) to (%s, %s)" ),
73 retv.Printf(
_(
"Bus from (%s, %s) to (%s, %s)" ),
81 retv =
_(
"Graphic line not connectable" );
90 if(
const SYMBOL* symbol =
pin->GetParentSymbol() )
92 retv.Printf(
_(
"Symbol '%s' pin '%s'" ),
93 symbol->GetRef( &aSheetPath,
true ),
96 if( wxString pinName =
UnescapeString(
pin->GetShownName() ); !pinName.IsEmpty() )
98 retv += wxString::Format(
" (%s)", pinName );
110 retv.Printf(
_(
"Sheet '%s' pin '%s'" ),
121 retv.Printf(
_(
"Label '%s' at (%s, %s)" ),
131 retv.Printf(
_(
"Global label '%s' at (%s, %s)" ),
141 retv.Printf(
_(
"Hierarchical label '%s' at (%s, %s)" ),
151 retv.Printf(
_(
"Junction at (%s, %s)" ),
160 retv.Printf(
_(
"No-Connect at (%s, %s)" ),
169 retv.Printf(
_(
"Bus to wire entry from (%s, %s) to (%s, %s)" ),
180 retv.Printf(
_(
"Bus to bus entry from (%s, %s) to (%s, %s)" ),
191 retv.Printf(
_(
"Netclass label '%s' at (%s, %s)" ),
198 retv.Printf(
_(
"Unhandled item type %d" ), aItem->
Type() );
207 bool aSingleSheetSchematic )
209 wxCHECK( !aNetName.IsEmpty(), );
213 wxTreeItemId expandId = aParentId;
216 wxCHECK( connectionGraph, );
218 std::set<CONNECTION_SUBGRAPH*> subgraphs;
219 std::set<wxString> netNamesToSearch;
221 netNamesToSearch.insert( aNetName );
226 for(
const wxString& netName : netNamesToSearch )
228 const std::vector<CONNECTION_SUBGRAPH*>& tmp = connectionGraph->
GetAllSubgraphs( netName );
229 subgraphs.insert( tmp.begin(), tmp.end() );
234 for(
const auto& [
_, bus_sgs] : sg->GetBusParents() )
238 const std::vector<CONNECTION_SUBGRAPH*>& tmp =
240 subgraphs.insert( tmp.begin(), tmp.end() );
245 std::map<wxString, wxTreeItemId> sheetIds;
252 wxCHECK2( subGraph && sheetPath.
Last(),
continue );
254 if( subGraph->GetItems().empty() )
275 for(
unsigned i = 1; i < sheetPath.
size(); i++ )
283 wxTreeItemId sheetId;
285 if(
auto sheetIdIt = sheetIds.find( txt ); sheetIdIt != sheetIds.end() )
287 sheetId = sheetIdIt->second;
291 sheetIds[txt] =
m_netNavigator->AppendItem( aParentId, txt, -1, -1, itemData );
292 sheetId = sheetIds[txt];
295 if( aSelection && *aSelection == *itemData )
299 if( aSingleSheetSchematic )
302 for(
const SCH_ITEM* item : subGraph->GetItems() )
317 if( aSelection && *aSelection == *itemData )
344 bool singleSheetSchematic =
m_schematic->Hierarchy().size() == 1;
359 std::unique_ptr<std::regex> regexFilter;
366 if( !globFilter.Contains( wxT(
"*" ) ) && !globFilter.Contains( wxT(
"?" ) ) )
367 globFilter = wxT(
"*" ) + globFilter + wxT(
"*" );
374 regexFilter = std::make_unique<std::regex>(
376 std::regex_constants::icase | std::regex_constants::ECMAScript );
378 catch(
const std::regex_error& )
395 for(
const auto& net : netMap )
398 if( net.first.Name.IsEmpty() )
406 bool matches =
false;
408 if( useWildcard && !globFilter.IsEmpty() )
413 else if( !useWildcard && regexFilter )
418 matches = std::regex_search( displayName.ToStdString(), *regexFilter );
420 catch(
const std::regex_error& )
431 wxTreeItemId netId =
m_netNavigator->AppendItem( rootId, displayName, -1, -1 );
455 if( selection.IsOk() )
477 wxLogTrace(
traceUiProfile, wxS(
"Adding %zu nodes to net navigator took %s." ),
494 std::vector<wxTreeItemId> netItems;
495 std::list<wxTreeItemId> itemList;
496 itemList.push_back( netNode );
498 while( !itemList.empty() )
500 wxTreeItemId current = itemList.front();
501 itemList.pop_front();
503 wxTreeItemIdValue cookie;
504 wxTreeItemId child =
m_netNavigator->GetFirstChild( current, cookie );
506 while( child.IsOk() )
509 itemList.push_back( child );
511 netItems.push_back( child );
518 auto it = std::find( netItems.begin(), netItems.end(),
id );
520 if( it != netItems.end() )
525 if( it == netItems.end() )
526 it = netItems.begin();
530 if( it == netItems.begin() )
550 if( data && data->GetItem() )
573 wxTreeItemIdValue sheetCookie;
575 wxTreeItemId sheetId =
m_netNavigator->GetFirstChild( rootId, sheetCookie );
577 while( sheetId.IsOk() )
581 wxTreeItemIdValue itemCookie;
582 wxTreeItemId itemId =
m_netNavigator->GetFirstChild( sheetId, itemCookie );
584 while( itemId.IsOk() )
588 wxCHECK2( itemData,
continue );
590 if( *itemData == *aSelection )
623 wxCHECK( itemData,
nullptr );
625 return itemData->GetItem();
634 wxTreeItemId
id = aEvent.GetItem();
653 const SCH_ITEM* item = itemData->GetItem();
660 const SCH_SCREEN* screen = itemData->GetSheetPath().LastScreen();
689 netNavigatorPane.Show( !netNavigatorPane.IsShown() );
694 if( netNavigatorPane.IsShown() )
696 if( netNavigatorPane.IsFloating() )
710 if( netNavigatorPane.IsFloating() )
722 if( netNavigatorPane.IsShown() )
728 if( selection.IsOk() )
744 if( !netNavigatorPane.IsShown() )
789 if( netNavigatorPane.rect.width > 50 )
792 netNavigatorPane.best_size.x = netNavigatorPane.rect.width;
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Calculate the connectivity of a schematic and generates netlists.
const std::vector< CONNECTION_SUBGRAPH * > & GetAllSubgraphs(const wxString &aNetName) const
std::vector< wxString > GetEquivalentBusNames(const wxString &aBusName) const
Map a bus group name between its alias and expanded forms ({MIXED_BUS} <-> {FOO BAR HAM EGGS}...
A subgraph is a set of items that are electrically connected on a single sheet.
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.
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)
void MakeNetNavigatorNode(const wxString &aNetName, wxTreeItemId aParentId, const NET_NAVIGATOR_ITEM_DATA *aSelection, bool aSingleSheetSchematic)
SCHEMATIC * m_schematic
The currently loaded schematic.
SCH_SHEET_PATH & GetCurrentSheet() const
wxString m_netNavigatorFilterValue
const SCH_ITEM * GetSelectedNetNavigatorItem() const
void RefreshNetNavigator(const NET_NAVIGATOR_ITEM_DATA *aSelection=nullptr)
wxSearchCtrl * m_netNavigatorFilter
const SCH_ITEM * SelectNextPrevNetNavigatorItem(bool aNext)
wxGenericTreeCtrl * m_netNavigator
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 onNetNavigatorSelection(wxTreeEvent &aEvent)
void FindNetInInspector(const wxString &aNetName)
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
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.
const wxString & GetFileName() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const SCH_SHEET * GetSheet(unsigned aIndex) const
bool empty() const
Forwarded method from std::vector.
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
size_t size() const
Forwarded method from std::vector.
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.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
SCH_SCREEN * GetScreen() const
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.
std::unordered_map< NET_NAME_CODE_CACHE_KEY, std::vector< CONNECTION_SUBGRAPH * > > NET_MAP
Associate a #NET_CODE_NAME with all the subgraphs in that net.
bool equivalent(SIM_MODEL::DEVICE_T a, SIM_MODEL::DEVICE_T b)
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.