KiCad PCB EDA Suite
Loading...
Searching...
No Matches
net_navigator.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 Rivos
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Wayne Stambaugh <[email protected]>
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#include <wx/log.h>
24#include <wx/srchctrl.h>
25#include <wx/wupdlock.h>
26#include <core/profile.h>
27#include <tool/tool_manager.h>
28#include <kiface_base.h>
29#include <confirm.h>
30#include <sch_edit_frame.h>
31#include <sch_bus_entry.h>
32#include <sch_line.h>
33#include <sch_junction.h>
34#include <sch_no_connect.h>
35#include <sch_sheet_pin.h>
36#include <string_utils.h>
37#include <trace_helpers.h>
38#include <connection_graph.h>
40#include <tools/sch_actions.h>
41#include <mail_type.h>
42#include <wx/filename.h>
44#include <wx/clntdata.h>
45#include <regex>
46#include <eeschema_settings.h>
47
48
49static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
50 const SCH_SHEET_PATH& aSheetPath,
51 UNITS_PROVIDER* aUnitsProvider )
52{
53 wxString retv;
54
55 wxCHECK( aItem && aUnitsProvider, retv );
56
57 switch( aItem->Type() )
58 {
59 case SCH_LINE_T:
60 {
61 const SCH_LINE* line = static_cast<const SCH_LINE*>( aItem );
62
63 if( aItem->GetLayer() == LAYER_WIRE )
64 {
65 retv.Printf( _( "Wire from (%s, %s) to (%s, %s)" ),
66 aUnitsProvider->MessageTextFromValue( line->GetStartPoint().x ),
67 aUnitsProvider->MessageTextFromValue( line->GetStartPoint().y ),
68 aUnitsProvider->MessageTextFromValue( line->GetEndPoint().x ),
69 aUnitsProvider->MessageTextFromValue( line->GetEndPoint().y ) );
70 }
71 else if( aItem->GetLayer() == LAYER_BUS )
72 {
73 retv.Printf( _( "Bus from (%s, %s) to (%s, %s)" ),
74 aUnitsProvider->MessageTextFromValue( line->GetStartPoint().x ),
75 aUnitsProvider->MessageTextFromValue( line->GetStartPoint().y ),
76 aUnitsProvider->MessageTextFromValue( line->GetEndPoint().x ),
77 aUnitsProvider->MessageTextFromValue( line->GetEndPoint().y ) );
78 }
79 else
80 {
81 retv = _( "Graphic line not connectable" );
82 }
83
84 break;
85 }
86 case SCH_PIN_T:
87 {
88 const SCH_PIN* pin = static_cast<const SCH_PIN*>( aItem );
89
90 if( const SYMBOL* symbol = pin->GetParentSymbol() )
91 {
92 retv.Printf( _( "Symbol '%s' pin '%s'" ),
93 symbol->GetRef( &aSheetPath, true ),
94 UnescapeString( pin->GetNumber() ) );
95
96 if( wxString pinName = UnescapeString( pin->GetShownName() ); !pinName.IsEmpty() )
97 {
98 retv += wxString::Format( " (%s)", pinName );
99 }
100 }
101
102 break;
103 }
104 case SCH_SHEET_PIN_T:
105 {
106 const SCH_SHEET_PIN* pin = static_cast<const SCH_SHEET_PIN*>( aItem );
107
108 if( SCH_SHEET* sheet = pin->GetParent() )
109 {
110 retv.Printf( _( "Sheet '%s' pin '%s'" ),
111 sheet->GetName(),
112 UnescapeString( pin->GetText() ) );
113 }
114
115 break;
116 }
117 case SCH_LABEL_T:
118 {
119 const SCH_LABEL* label = static_cast<const SCH_LABEL*>( aItem );
120
121 retv.Printf( _( "Label '%s' at (%s, %s)" ),
122 UnescapeString( label->GetText() ),
123 aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
124 aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) );
125 break;
126 }
128 {
129 const SCH_GLOBALLABEL* label = static_cast<const SCH_GLOBALLABEL*>( aItem );
130
131 retv.Printf( _( "Global label '%s' at (%s, %s)" ),
132 UnescapeString( label->GetText() ),
133 aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
134 aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) );
135 break;
136 }
137 case SCH_HIER_LABEL_T:
138 {
139 const SCH_HIERLABEL* label = static_cast<const SCH_HIERLABEL*>( aItem );
140
141 retv.Printf( _( "Hierarchical label '%s' at (%s, %s)" ),
142 UnescapeString( label->GetText() ),
143 aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
144 aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) );
145 break;
146 }
147 case SCH_JUNCTION_T:
148 {
149 const SCH_JUNCTION* junction = static_cast<const SCH_JUNCTION*>( aItem );
150
151 retv.Printf( _( "Junction at (%s, %s)" ),
152 aUnitsProvider->MessageTextFromValue( junction->GetPosition().x ),
153 aUnitsProvider->MessageTextFromValue( junction->GetPosition().y ) );
154 break;
155 }
156 case SCH_NO_CONNECT_T:
157 {
158 const SCH_NO_CONNECT* nc = static_cast<const SCH_NO_CONNECT*>( aItem );
159
160 retv.Printf( _( "No-Connect at (%s, %s)" ),
161 aUnitsProvider->MessageTextFromValue( nc->GetPosition().x ),
162 aUnitsProvider->MessageTextFromValue( nc->GetPosition().y ) );
163 break;
164 }
166 {
167 const SCH_BUS_WIRE_ENTRY* entry = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem );
168
169 retv.Printf( _( "Bus to wire entry from (%s, %s) to (%s, %s)" ),
170 aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
171 aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ),
172 aUnitsProvider->MessageTextFromValue( entry->GetEnd().x ),
173 aUnitsProvider->MessageTextFromValue( entry->GetEnd().y ) );
174 break;
175 }
177 {
178 const SCH_BUS_BUS_ENTRY* entry = static_cast<const SCH_BUS_BUS_ENTRY*>( aItem );
179
180 retv.Printf( _( "Bus to bus entry from (%s, %s) to (%s, %s)" ),
181 aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
182 aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ),
183 aUnitsProvider->MessageTextFromValue( entry->GetEnd().x ),
184 aUnitsProvider->MessageTextFromValue( entry->GetEnd().y ) );
185 break;
186 }
188 {
189 const SCH_DIRECTIVE_LABEL* entry = static_cast<const SCH_DIRECTIVE_LABEL*>( aItem );
190
191 retv.Printf( _( "Netclass label '%s' at (%s, %s)" ),
192 UnescapeString( entry->GetText() ),
193 aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
194 aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ) );
195 break;
196 }
197 default:
198 retv.Printf( _( "Unhandled item type %d" ), aItem->Type() );
199 }
200
201 return retv;
202}
203
204
205void SCH_EDIT_FRAME::MakeNetNavigatorNode( const wxString& aNetName, wxTreeItemId aParentId,
206 const NET_NAVIGATOR_ITEM_DATA* aSelection,
207 bool aSingleSheetSchematic )
208{
209 wxCHECK( !aNetName.IsEmpty(), /* void */ );
210 wxCHECK( m_schematic, /* void */ );
211 wxCHECK( m_netNavigator, /* void */ );
212
213 wxTreeItemId expandId = aParentId;
214 CONNECTION_GRAPH* connectionGraph = m_schematic->ConnectionGraph();
215
216 wxCHECK( connectionGraph, /* void */ );
217
218 std::set<CONNECTION_SUBGRAPH*> subgraphs;
219 std::set<wxString> netNamesToSearch;
220
221 netNamesToSearch.insert( aNetName );
222
223 for( const wxString& equivalent : connectionGraph->GetEquivalentBusNames( aNetName ) )
224 netNamesToSearch.insert( equivalent );
225
226 for( const wxString& netName : netNamesToSearch )
227 {
228 const std::vector<CONNECTION_SUBGRAPH*>& tmp = connectionGraph->GetAllSubgraphs( netName );
229 subgraphs.insert( tmp.begin(), tmp.end() );
230 }
231
232 for( CONNECTION_SUBGRAPH* sg : subgraphs )
233 {
234 for( const auto& [_, bus_sgs] : sg->GetBusParents() )
235 {
236 for( const CONNECTION_SUBGRAPH* bus_sg : bus_sgs )
237 {
238 const std::vector<CONNECTION_SUBGRAPH*>& tmp =
239 connectionGraph->GetAllSubgraphs( bus_sg->GetNetName() );
240 subgraphs.insert( tmp.begin(), tmp.end() );
241 }
242 }
243 }
244
245 std::map<wxString, wxTreeItemId> sheetIds;
246
247 for( const CONNECTION_SUBGRAPH* subGraph : subgraphs )
248 {
249 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
250 SCH_SHEET_PATH sheetPath = subGraph->GetSheet();
251
252 wxCHECK2( subGraph && sheetPath.Last(), continue );
253
254 if( subGraph->GetItems().empty() )
255 continue;
256
257 itemData = new NET_NAVIGATOR_ITEM_DATA( sheetPath, nullptr );
258
259 // Build path string for net navigator - include top-level sheet name to distinguish
260 // multiple top-level sheets
261 wxString txt;
262
263 if( !sheetPath.empty() && sheetPath.at( 0 )->GetScreen() )
264 {
265 // Get the top-level sheet name
266 txt = sheetPath.at( 0 )->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
267
268 if( txt.IsEmpty() )
269 {
270 wxFileName fn( sheetPath.at( 0 )->GetScreen()->GetFileName() );
271 txt = fn.GetName();
272 }
273
274 // Add sub-sheet names
275 for( unsigned i = 1; i < sheetPath.size(); i++ )
276 txt << wxS( "/" ) << sheetPath.at( i )->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
277 }
278 else
279 {
280 txt = sheetPath.PathHumanReadable( true, true );
281 }
282
283 wxTreeItemId sheetId;
284
285 if( auto sheetIdIt = sheetIds.find( txt ); sheetIdIt != sheetIds.end() )
286 {
287 sheetId = sheetIdIt->second;
288 }
289 else
290 {
291 sheetIds[txt] = m_netNavigator->AppendItem( aParentId, txt, -1, -1, itemData );
292 sheetId = sheetIds[txt];
293 }
294
295 if( aSelection && *aSelection == *itemData )
296 m_netNavigator->SelectItem( sheetId );
297
298 // If there is only one sheet in the schematic, always expand the sheet tree.
299 if( aSingleSheetSchematic )
300 expandId = sheetId;
301
302 for( const SCH_ITEM* item : subGraph->GetItems() )
303 {
304 if( item->Type() == SCH_LINE_T
305 || item->Type() == SCH_JUNCTION_T
306 || item->Type() == SCH_BUS_WIRE_ENTRY_T
307 || item->Type() == SCH_BUS_BUS_ENTRY_T )
308 {
309 continue;
310 }
311
312 itemData = new NET_NAVIGATOR_ITEM_DATA( sheetPath, item );
313 wxTreeItemId id = m_netNavigator->AppendItem( sheetId,
314 GetNetNavigatorItemText( item, sheetPath, this ),
315 -1, -1, itemData );
316
317 if( aSelection && *aSelection == *itemData )
318 {
319 expandId = sheetId;
320 m_netNavigator->EnsureVisible( id );
321 m_netNavigator->SelectItem( id );
322 }
323 }
324
325 m_netNavigator->SortChildren( sheetId );
326 }
327
328 // Sort the items in the tree control alphabetically
329 m_netNavigator->SortChildren( aParentId );
330 m_netNavigator->Expand( aParentId );
331}
332
333
335{
336 wxCHECK( m_netNavigator && m_schematic, /* void */ );
337
338 if( !m_netNavigator->IsShownOnScreen() || !m_schematic->HasHierarchy() )
339 return;
340
342 m_netNavigatorFilter->Enable( m_highlightedConn.IsEmpty() );
343
344 bool singleSheetSchematic = m_schematic->Hierarchy().size() == 1;
345 size_t nodeCnt = 0;
346
347 wxWindowUpdateLocker updateLock( m_netNavigator );
348 PROF_TIMER timer;
349
350 wxString filter = m_highlightedConn.IsEmpty() ? m_netNavigatorFilterValue : wxString();
351
352 // Determine search mode from settings
354 bool useWildcard = cfg ? cfg->m_AuiPanels.net_nav_search_mode_wildcard : true;
355
356 // For wildcard mode, wrap filter with wildcards for substring matching by default
357 // unless user has already specified wildcards
358 wxString globFilter;
359 std::unique_ptr<std::regex> regexFilter;
360
361 if( !filter.IsEmpty() )
362 {
363 if( useWildcard )
364 {
365 globFilter = filter;
366 if( !globFilter.Contains( wxT( "*" ) ) && !globFilter.Contains( wxT( "?" ) ) )
367 globFilter = wxT( "*" ) + globFilter + wxT( "*" );
368 }
369 else
370 {
371 // Regex mode - compile the regex pattern
372 try
373 {
374 regexFilter = std::make_unique<std::regex>(
375 filter.ToStdString(),
376 std::regex_constants::icase | std::regex_constants::ECMAScript );
377 }
378 catch( const std::regex_error& )
379 {
380 // Invalid regex - no filtering
381 regexFilter.reset();
382 }
383 }
384 }
385
386 if( m_highlightedConn.IsEmpty() )
387 {
388 m_netNavigator->DeleteAllItems();
389
390 // Create a tree of all nets in the schematic.
391 wxTreeItemId rootId = m_netNavigator->AddRoot( _( "Nets" ), 0 );
392
393 const NET_MAP& netMap = m_schematic->ConnectionGraph()->GetNetMap();
394
395 for( const auto& net : netMap )
396 {
397 // Skip bus member subgraphs for the moment.
398 if( net.first.Name.IsEmpty() )
399 continue;
400
401 wxString displayName = UnescapeString( net.first.Name );
402
403 // Apply filter based on mode
404 if( !filter.IsEmpty() )
405 {
406 bool matches = false;
407
408 if( useWildcard && !globFilter.IsEmpty() )
409 {
410 // Use glob-based matching (supports * and ? wildcards), case-insensitive
411 matches = WildCompareString( globFilter, displayName, false );
412 }
413 else if( !useWildcard && regexFilter )
414 {
415 // Use regex matching
416 try
417 {
418 matches = std::regex_search( displayName.ToStdString(), *regexFilter );
419 }
420 catch( const std::regex_error& )
421 {
422 matches = false;
423 }
424 }
425
426 if( !matches )
427 continue;
428 }
429
430 nodeCnt++;
431 wxTreeItemId netId = m_netNavigator->AppendItem( rootId, displayName, -1, -1 );
432 MakeNetNavigatorNode( net.first.Name, netId, aSelection, singleSheetSchematic );
433 } m_netNavigator->Expand( rootId );
434 }
435 else if( !m_netNavigator->IsEmpty() )
436 {
437 const wxString shownNetName = m_netNavigator->GetItemText( m_netNavigator->GetRootItem() );
438
439 if( shownNetName != m_highlightedConn )
440 {
441 m_netNavigator->DeleteAllItems();
442
443 nodeCnt++;
444
445 wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ) );
446
447 MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
448 }
449 else
450 {
451 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
452
453 wxTreeItemId selection = m_netNavigator->GetSelection();
454
455 if( selection.IsOk() )
456 itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
457
458 m_netNavigator->DeleteAllItems();
459 nodeCnt++;
460
461 wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ) );
462
463 MakeNetNavigatorNode( m_highlightedConn, rootId, itemData, singleSheetSchematic );
464 }
465 }
466 else
467 {
468 nodeCnt++;
469
470 wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ) );
471
472 MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
473 }
474
475 timer.Stop();
476
477 wxLogTrace( traceUiProfile, wxS( "Adding %zu nodes to net navigator took %s." ),
478 nodeCnt, timer.to_string() );
479}
480
481
483{
484 wxCHECK( m_netNavigator, nullptr );
485
486 wxTreeItemId id = m_netNavigator->GetSelection();
487
488 if( !id.IsOk() )
489 return nullptr;
490
491 wxTreeItemId nextId;
492 wxTreeItemId netNode = m_netNavigator->GetRootItem();
493
494 std::vector<wxTreeItemId> netItems;
495 std::list<wxTreeItemId> itemList;
496 itemList.push_back( netNode );
497
498 while( !itemList.empty() )
499 {
500 wxTreeItemId current = itemList.front();
501 itemList.pop_front();
502
503 wxTreeItemIdValue cookie;
504 wxTreeItemId child = m_netNavigator->GetFirstChild( current, cookie );
505
506 while( child.IsOk() )
507 {
508 if( m_netNavigator->ItemHasChildren( child ) )
509 itemList.push_back( child );
510 else
511 netItems.push_back( child );
512
513 child = m_netNavigator->GetNextSibling( child );
514 }
515 }
516
517 // Locate current item and move forward or backward with wrap
518 auto it = std::find( netItems.begin(), netItems.end(), id );
519
520 if( it != netItems.end() )
521 {
522 if( aNext )
523 {
524 ++it;
525 if( it == netItems.end() )
526 it = netItems.begin();
527 }
528 else
529 {
530 if( it == netItems.begin() )
531 it = netItems.end();
532 --it;
533 }
534 nextId = *it;
535 }
536
537 if( nextId.IsOk() )
538 {
539 if( !m_netNavigator->IsVisible( nextId ) )
540 {
541 m_netNavigator->CollapseAll();
542 m_netNavigator->EnsureVisible( nextId );
543 }
544
545 m_netNavigator->UnselectAll();
546 m_netNavigator->SelectItem( nextId );
547
548 auto* data = static_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( nextId ) );
549
550 if( data && data->GetItem() )
551 return data->GetItem();
552 }
553
554 return nullptr;
555}
556
557
559{
560 wxCHECK( m_netNavigator, /* void */ );
561 wxCHECK( !m_netNavigator->IsFrozen(), /* void */ );
562
563 // Maybe in the future we can do something like collapse the tree for an empty selection.
564 // For now, leave the tree selection in its current state.
565 if( !aSelection )
566 return;
567
568 wxTreeItemId rootId = m_netNavigator->GetRootItem();
569
570 if( !rootId.IsOk() )
571 return;
572
573 wxTreeItemIdValue sheetCookie;
574 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
575 wxTreeItemId sheetId = m_netNavigator->GetFirstChild( rootId, sheetCookie );
576
577 while( sheetId.IsOk() )
578 {
579 if( m_netNavigator->ItemHasChildren( sheetId ) )
580 {
581 wxTreeItemIdValue itemCookie;
582 wxTreeItemId itemId = m_netNavigator->GetFirstChild( sheetId, itemCookie );
583
584 while( itemId.IsOk() )
585 {
586 itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( itemId ) );
587
588 wxCHECK2( itemData, continue );
589
590 if( *itemData == *aSelection )
591 {
592 if( !m_netNavigator->IsVisible( itemId ) )
593 {
594 m_netNavigator->CollapseAll();
595 m_netNavigator->EnsureVisible( itemId );
596 }
597
598 m_netNavigator->SelectItem( itemId );
599 return;
600 }
601
602 itemId = m_netNavigator->GetNextSibling( itemId );
603 }
604
605 sheetId = m_netNavigator->GetNextSibling( sheetId );
606 }
607 }
608}
609
610
612{
613 if( !m_netNavigator || m_netNavigator->IsFrozen() )
614 return nullptr;
615
616 wxTreeItemId id = m_netNavigator->GetSelection();
617
618 if( !id.IsOk() || ( id == m_netNavigator->GetRootItem() ) )
619 return nullptr;
620
621 auto* itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( id ) );
622
623 wxCHECK( itemData, nullptr );
624
625 return itemData->GetItem();
626}
627
628
630{
631 if( !m_netNavigator || m_netNavigator->IsFrozen() )
632 return;
633
634 wxTreeItemId id = aEvent.GetItem();
635
636 // Clicking on the root item (net name ) does nothing.
637 if( id == m_netNavigator->GetRootItem() )
638 return;
639
640 auto* itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( id ) );
641
642 // Just a net name when we have all nets displayed.
643 if( !itemData )
644 return;
645
646 if( GetCurrentSheet() != itemData->GetSheetPath() )
647 GetToolManager()->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet, &itemData->GetSheetPath() );
648
649 // Do not focus on item when a sheet tree node is selected.
650 if( m_netNavigator->GetItemParent( id ) != m_netNavigator->GetRootItem() && itemData->GetItem() )
651 {
652 // Make sure we didn't remove the item and/or the screen it resides on before we access it.
653 const SCH_ITEM* item = itemData->GetItem();
654
655 // Don't search for child items in screen r-tree.
656 item = ( item->Type() == SCH_SHEET_PIN_T || item->Type() == SCH_PIN_T )
657 ? static_cast<const SCH_ITEM*>( item->GetParent() )
658 : item;
659
660 const SCH_SCREEN* screen = itemData->GetSheetPath().LastScreen();
661
662 wxCHECK( screen, /* void */ );
663 wxCHECK( screen->Items().contains( item, true ), /* void */ );
664
665 FocusOnLocation( itemData->GetItem()->GetBoundingBox().Centre() );
666 }
667
668 GetCanvas()->Refresh();
669}
670
671
673{
674 if( !m_netNavigator || m_netNavigator->IsFrozen() )
675 return;
676
677 aEvent.Skip();
678}
679
680
682{
684
685 wxCHECK( cfg, /* void */ );
686
687 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
688
689 netNavigatorPane.Show( !netNavigatorPane.IsShown() );
691
692 cfg->m_AuiPanels.show_net_nav_panel = netNavigatorPane.IsShown();
693
694 if( netNavigatorPane.IsShown() )
695 {
696 if( netNavigatorPane.IsFloating() )
697 {
698 netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
699 m_auimgr.Update();
700 }
701 else if( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth() > 0 )
702 {
703 // SetAuiPaneSize also updates m_auimgr
704 SetAuiPaneSize( m_auimgr, netNavigatorPane,
705 cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), -1 );
706 }
707 }
708 else
709 {
710 if( netNavigatorPane.IsFloating() )
711 {
712 cfg->m_AuiPanels.net_nav_panel_float_size = netNavigatorPane.floating_size;
713 }
714 else
715 {
717 }
718
719 m_auimgr.Update();
720 }
721
722 if( netNavigatorPane.IsShown() )
723 {
724 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
725
726 wxTreeItemId selection = m_netNavigator->GetSelection();
727
728 if( selection.IsOk() )
729 itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
730
731 RefreshNetNavigator( itemData );
732 }
733}
734
735
736void SCH_EDIT_FRAME::FindNetInInspector( const wxString& aNetName )
737{
738 if( !m_netNavigator || aNetName.IsEmpty() )
739 return;
740
741 // Ensure the net navigator is shown
742 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
743
744 if( !netNavigatorPane.IsShown() )
746
747 // Clear any net highlights
748 m_highlightedConn = wxEmptyString;
750
751 // Set the search text to the aNetName
753 m_netNavigatorFilter->SetValue( aNetName );
754
755 m_netNavigatorFilterValue = aNetName;
756
757 // Refresh the tree
759}
760
761
762void SCH_EDIT_FRAME::onResizeNetNavigator( wxSizeEvent& aEvent )
763{
764 aEvent.Skip();
765
766 // Called when resizing the Hierarchy Navigator panel
767 // Store the current pane size
768 // It allows to retrieve the last defined pane size when switching between
769 // docked and floating pane state
770 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
771
772 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
773
774 // During deletion/cleanup operations, settings may be temporarily unavailable
775 if( !cfg )
776 return;
777
778 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
779
780 if( m_netNavigator->IsShownOnScreen() )
781 {
782 cfg->m_AuiPanels.net_nav_panel_float_size = netNavigatorPane.floating_size;
783
784 // initialize net_nav_panel_docked_width and best size only if the netNavigatorPane
785 // width is > 0 (i.e. if its size is already set and has meaning)
786 // if it is floating, its size is not initialized (only floating_size is initialized)
787 // initializing netNavigatorPane.best_size is useful when switching to float pane and
788 // after switching to the docked pane, to retrieve the last docked pane width
789 if( netNavigatorPane.rect.width > 50 ) // 50 is a good margin
790 {
791 cfg->m_AuiPanels.net_nav_panel_docked_size.SetWidth( netNavigatorPane.rect.width );
792 netNavigatorPane.best_size.x = netNavigatorPane.rect.width;
793 }
794 }
795}
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.
wxAuiManager m_auimgr
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.
Definition eda_item.h:108
EDA_ITEM * GetParent() const
Definition eda_item.h:110
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
bool contains(const SCH_ITEM *aItem, bool aRobust=false) const
Determine if a given item exists in the tree.
Definition sch_rtree.h:104
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:91
Tree view item data for the net navigator.
const SCH_ITEM * GetItem() const
A small class to help profiling.
Definition profile.h:46
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition profile.h:86
std::string to_string()
Definition profile.h:153
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
VECTOR2I GetEnd() const
Class for a wire to bus entry.
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,...
Definition sch_item.h:162
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:338
VECTOR2I GetPosition() const override
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:38
VECTOR2I GetEndPoint() const
Definition sch_line.h:144
VECTOR2I GetStartPoint() const
Definition sch_line.h:135
VECTOR2I GetPosition() const override
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:115
const wxString & GetFileName() const
Definition sch_screen.h:150
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.
Definition sch_sheet.h:44
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:139
VECTOR2I GetPosition() const override
Definition sch_text.h:146
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:59
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
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)
#define _(s)
const wxChar *const traceUiProfile
Flag to enable user interface profile tracing.
@ LAYER_WIRE
Definition layer_ids.h:450
@ LAYER_BUS
Definition layer_ids.h:451
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)
KIBIS_PIN * pin
wxLogTrace helper definitions.
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_NO_CONNECT_T
Definition typeinfo.h:157
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:168
@ SCH_LABEL_T
Definition typeinfo.h:164
@ SCH_HIER_LABEL_T
Definition typeinfo.h:166
@ SCH_BUS_BUS_ENTRY_T
Definition typeinfo.h:159
@ SCH_SHEET_PIN_T
Definition typeinfo.h:171
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:158
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:165
@ SCH_JUNCTION_T
Definition typeinfo.h:156
@ SCH_PIN_T
Definition typeinfo.h:150
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.