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 along
20 * with this program. If not, see <http://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
220 {
221 const std::vector<CONNECTION_SUBGRAPH*>& tmp = connectionGraph->GetAllSubgraphs( aNetName );
222 subgraphs.insert( tmp.begin(), tmp.end() );
223 }
224
225 for( CONNECTION_SUBGRAPH* sg : subgraphs )
226 {
227 for( const auto& [_, bus_sgs] : sg->GetBusParents() )
228 {
229 for( const CONNECTION_SUBGRAPH* bus_sg : bus_sgs )
230 {
231 const std::vector<CONNECTION_SUBGRAPH*>& tmp =
232 connectionGraph->GetAllSubgraphs( bus_sg->GetNetName() );
233 subgraphs.insert( tmp.begin(), tmp.end() );
234 }
235 }
236 }
237
238 std::map<wxString, wxTreeItemId> sheetIds;
239
240 for( const CONNECTION_SUBGRAPH* subGraph : subgraphs )
241 {
242 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
243 SCH_SHEET_PATH sheetPath = subGraph->GetSheet();
244
245 wxCHECK2( subGraph && sheetPath.Last(), continue );
246
247 if( subGraph->GetItems().empty() )
248 continue;
249
250 itemData = new NET_NAVIGATOR_ITEM_DATA( sheetPath, nullptr );
251
252 // Build path string for net navigator - include top-level sheet name to distinguish
253 // multiple top-level sheets
254 wxString txt;
255
256 if( !sheetPath.empty() && sheetPath.at( 0 )->GetScreen() )
257 {
258 // Get the top-level sheet name
259 txt = sheetPath.at( 0 )->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
260
261 if( txt.IsEmpty() )
262 {
263 wxFileName fn( sheetPath.at( 0 )->GetScreen()->GetFileName() );
264 txt = fn.GetName();
265 }
266
267 // Add sub-sheet names
268 for( unsigned i = 1; i < sheetPath.size(); i++ )
269 txt << wxS( "/" ) << sheetPath.at( i )->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
270 }
271 else
272 {
273 txt = sheetPath.PathHumanReadable( true, true );
274 }
275
276 wxTreeItemId sheetId;
277
278 if( auto sheetIdIt = sheetIds.find( txt ); sheetIdIt != sheetIds.end() )
279 {
280 sheetId = sheetIdIt->second;
281 }
282 else
283 {
284 sheetIds[txt] = m_netNavigator->AppendItem( aParentId, txt, -1, -1, itemData );
285 sheetId = sheetIds[txt];
286 }
287
288 if( aSelection && *aSelection == *itemData )
289 m_netNavigator->SelectItem( sheetId );
290
291 // If there is only one sheet in the schematic, always expand the sheet tree.
292 if( aSingleSheetSchematic )
293 expandId = sheetId;
294
295 for( const SCH_ITEM* item : subGraph->GetItems() )
296 {
297 if( item->Type() == SCH_LINE_T
298 || item->Type() == SCH_JUNCTION_T
299 || item->Type() == SCH_BUS_WIRE_ENTRY_T
300 || item->Type() == SCH_BUS_BUS_ENTRY_T )
301 {
302 continue;
303 }
304
305 itemData = new NET_NAVIGATOR_ITEM_DATA( sheetPath, item );
306 wxTreeItemId id = m_netNavigator->AppendItem( sheetId,
307 GetNetNavigatorItemText( item, sheetPath, this ),
308 -1, -1, itemData );
309
310 if( aSelection && *aSelection == *itemData )
311 {
312 expandId = sheetId;
313 m_netNavigator->EnsureVisible( id );
314 m_netNavigator->SelectItem( id );
315 }
316 }
317
318 m_netNavigator->SortChildren( sheetId );
319 }
320
321 // Sort the items in the tree control alphabetically
322 m_netNavigator->SortChildren( aParentId );
323 m_netNavigator->Expand( aParentId );
324}
325
326
328{
329 wxCHECK( m_netNavigator, /* void */ );
330
331 if( !m_netNavigator->IsShown() )
332 return;
333
335 m_netNavigatorFilter->Enable( m_highlightedConn.IsEmpty() );
336
337 bool singleSheetSchematic = m_schematic->Hierarchy().size() == 1;
338 size_t nodeCnt = 0;
339
340 wxWindowUpdateLocker updateLock( m_netNavigator );
341 PROF_TIMER timer;
342
343 wxString filter = m_highlightedConn.IsEmpty() ? m_netNavigatorFilterValue : wxString();
344
345 // Determine search mode from settings
347 bool useWildcard = cfg ? cfg->m_AuiPanels.net_nav_search_mode_wildcard : true;
348
349 // For wildcard mode, wrap filter with wildcards for substring matching by default
350 // unless user has already specified wildcards
351 wxString globFilter;
352 std::unique_ptr<std::regex> regexFilter;
353
354 if( !filter.IsEmpty() )
355 {
356 if( useWildcard )
357 {
358 globFilter = filter;
359 if( !globFilter.Contains( wxT( "*" ) ) && !globFilter.Contains( wxT( "?" ) ) )
360 globFilter = wxT( "*" ) + globFilter + wxT( "*" );
361 }
362 else
363 {
364 // Regex mode - compile the regex pattern
365 try
366 {
367 regexFilter = std::make_unique<std::regex>(
368 filter.ToStdString(),
369 std::regex_constants::icase | std::regex_constants::ECMAScript );
370 }
371 catch( const std::regex_error& )
372 {
373 // Invalid regex - no filtering
374 regexFilter.reset();
375 }
376 }
377 }
378
379 if( m_highlightedConn.IsEmpty() )
380 {
381 m_netNavigator->DeleteAllItems();
382
383 // Create a tree of all nets in the schematic.
384 wxTreeItemId rootId = m_netNavigator->AddRoot( _( "Nets" ), 0 );
385
386 const NET_MAP& netMap = m_schematic->ConnectionGraph()->GetNetMap();
387
388 for( const auto& net : netMap )
389 {
390 // Skip bus member subgraphs for the moment.
391 if( net.first.Name.IsEmpty() )
392 continue;
393
394 wxString displayName = UnescapeString( net.first.Name );
395
396 // Apply filter based on mode
397 if( !filter.IsEmpty() )
398 {
399 bool matches = false;
400
401 if( useWildcard && !globFilter.IsEmpty() )
402 {
403 // Use glob-based matching (supports * and ? wildcards), case-insensitive
404 matches = WildCompareString( globFilter, displayName, false );
405 }
406 else if( !useWildcard && regexFilter )
407 {
408 // Use regex matching
409 try
410 {
411 matches = std::regex_search( displayName.ToStdString(), *regexFilter );
412 }
413 catch( const std::regex_error& )
414 {
415 matches = false;
416 }
417 }
418
419 if( !matches )
420 continue;
421 }
422
423 nodeCnt++;
424 wxTreeItemId netId = m_netNavigator->AppendItem( rootId, displayName, -1, -1 );
425 MakeNetNavigatorNode( net.first.Name, netId, aSelection, singleSheetSchematic );
426 } m_netNavigator->Expand( rootId );
427 }
428 else if( !m_netNavigator->IsEmpty() )
429 {
430 const wxString shownNetName = m_netNavigator->GetItemText( m_netNavigator->GetRootItem() );
431
432 if( shownNetName != m_highlightedConn )
433 {
434 m_netNavigator->DeleteAllItems();
435
436 nodeCnt++;
437
438 wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ) );
439
440 MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
441 }
442 else
443 {
444 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
445
446 wxTreeItemId selection = m_netNavigator->GetSelection();
447
448 if( selection.IsOk() )
449 itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
450
451 m_netNavigator->DeleteAllItems();
452 nodeCnt++;
453
454 wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ) );
455
456 MakeNetNavigatorNode( m_highlightedConn, rootId, itemData, singleSheetSchematic );
457 }
458 }
459 else
460 {
461 nodeCnt++;
462
463 wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ) );
464
465 MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
466 }
467
468 timer.Stop();
469
470 wxLogTrace( traceUiProfile, wxS( "Adding %zu nodes to net navigator took %s." ),
471 nodeCnt, timer.to_string() );
472}
473
474
476{
477 wxCHECK( m_netNavigator, nullptr );
478
479 wxTreeItemId id = m_netNavigator->GetSelection();
480
481 if( !id.IsOk() )
482 return nullptr;
483
484 wxTreeItemId nextId;
485 wxTreeItemId netNode = m_netNavigator->GetRootItem();
486
487 std::vector<wxTreeItemId> netItems;
488 std::list<wxTreeItemId> itemList;
489 itemList.push_back( netNode );
490
491 while( !itemList.empty() )
492 {
493 wxTreeItemId current = itemList.front();
494 itemList.pop_front();
495
496 wxTreeItemIdValue cookie;
497 wxTreeItemId child = m_netNavigator->GetFirstChild( current, cookie );
498
499 while( child.IsOk() )
500 {
501 if( m_netNavigator->ItemHasChildren( child ) )
502 itemList.push_back( child );
503 else
504 netItems.push_back( child );
505
506 child = m_netNavigator->GetNextSibling( child );
507 }
508 }
509
510 // Locate current item and move forward or backward with wrap
511 auto it = std::find( netItems.begin(), netItems.end(), id );
512
513 if( it != netItems.end() )
514 {
515 if( aNext )
516 {
517 ++it;
518 if( it == netItems.end() )
519 it = netItems.begin();
520 }
521 else
522 {
523 if( it == netItems.begin() )
524 it = netItems.end();
525 --it;
526 }
527 nextId = *it;
528 }
529
530 if( nextId.IsOk() )
531 {
532 if( !m_netNavigator->IsVisible( nextId ) )
533 {
534 m_netNavigator->CollapseAll();
535 m_netNavigator->EnsureVisible( nextId );
536 }
537
538 m_netNavigator->UnselectAll();
539 m_netNavigator->SelectItem( nextId );
540
541 auto* data = static_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( nextId ) );
542
543 if( data && data->GetItem() )
544 return data->GetItem();
545 }
546
547 return nullptr;
548}
549
550
552{
553 wxCHECK( m_netNavigator, /* void */ );
554 wxCHECK( !m_netNavigator->IsFrozen(), /* void */ );
555
556 // Maybe in the future we can do something like collapse the tree for an empty selection.
557 // For now, leave the tree selection in its current state.
558 if( !aSelection )
559 return;
560
561 wxTreeItemId rootId = m_netNavigator->GetRootItem();
562
563 if( !rootId.IsOk() )
564 return;
565
566 wxTreeItemIdValue sheetCookie;
567 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
568 wxTreeItemId sheetId = m_netNavigator->GetFirstChild( rootId, sheetCookie );
569
570 while( sheetId.IsOk() )
571 {
572 if( m_netNavigator->ItemHasChildren( sheetId ) )
573 {
574 wxTreeItemIdValue itemCookie;
575 wxTreeItemId itemId = m_netNavigator->GetFirstChild( sheetId, itemCookie );
576
577 while( itemId.IsOk() )
578 {
579 itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( itemId ) );
580
581 wxCHECK2( itemData, continue );
582
583 if( *itemData == *aSelection )
584 {
585 if( !m_netNavigator->IsVisible( itemId ) )
586 {
587 m_netNavigator->CollapseAll();
588 m_netNavigator->EnsureVisible( itemId );
589 }
590
591 m_netNavigator->SelectItem( itemId );
592 return;
593 }
594
595 itemId = m_netNavigator->GetNextSibling( itemId );
596 }
597
598 sheetId = m_netNavigator->GetNextSibling( sheetId );
599 }
600 }
601}
602
603
605{
606 if( !m_netNavigator || m_netNavigator->IsFrozen() )
607 return nullptr;
608
609 wxTreeItemId id = m_netNavigator->GetSelection();
610
611 if( !id.IsOk() || ( id == m_netNavigator->GetRootItem() ) )
612 return nullptr;
613
614 auto* itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( id ) );
615
616 wxCHECK( itemData, nullptr );
617
618 return itemData->GetItem();
619}
620
621
623{
624 if( !m_netNavigator || m_netNavigator->IsFrozen() )
625 return;
626
627 wxTreeItemId id = aEvent.GetItem();
628
629 // Clicking on the root item (net name ) does nothing.
630 if( id == m_netNavigator->GetRootItem() )
631 return;
632
633 auto* itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( id ) );
634
635 // Just a net name when we have all nets displayed.
636 if( !itemData )
637 return;
638
639 if( GetCurrentSheet() != itemData->GetSheetPath() )
640 GetToolManager()->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet, &itemData->GetSheetPath() );
641
642 // Do not focus on item when a sheet tree node is selected.
643 if( m_netNavigator->GetItemParent( id ) != m_netNavigator->GetRootItem() && itemData->GetItem() )
644 {
645 // Make sure we didn't remove the item and/or the screen it resides on before we access it.
646 const SCH_ITEM* item = itemData->GetItem();
647
648 // Don't search for child items in screen r-tree.
649 item = ( item->Type() == SCH_SHEET_PIN_T || item->Type() == SCH_PIN_T )
650 ? static_cast<const SCH_ITEM*>( item->GetParent() )
651 : item;
652
653 const SCH_SCREEN* screen = itemData->GetSheetPath().LastScreen();
654
655 wxCHECK( screen, /* void */ );
656 wxCHECK( screen->Items().contains( item, true ), /* void */ );
657
658 FocusOnLocation( itemData->GetItem()->GetBoundingBox().Centre() );
659 }
660
661 GetCanvas()->Refresh();
662}
663
664
666{
667 if( !m_netNavigator || m_netNavigator->IsFrozen() )
668 return;
669
670 aEvent.Skip();
671}
672
673
675{
677
678 wxCHECK( cfg, /* void */ );
679
680 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
681
682 netNavigatorPane.Show( !netNavigatorPane.IsShown() );
684
685 cfg->m_AuiPanels.show_net_nav_panel = netNavigatorPane.IsShown();
686
687 if( netNavigatorPane.IsShown() )
688 {
689 if( netNavigatorPane.IsFloating() )
690 {
691 netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
692 m_auimgr.Update();
693 }
694 else if( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth() > 0 )
695 {
696 // SetAuiPaneSize also updates m_auimgr
697 SetAuiPaneSize( m_auimgr, netNavigatorPane,
698 cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), -1 );
699 }
700 }
701 else
702 {
703 if( netNavigatorPane.IsFloating() )
704 {
705 cfg->m_AuiPanels.net_nav_panel_float_size = netNavigatorPane.floating_size;
706 }
707 else
708 {
710 }
711
712 m_auimgr.Update();
713 }
714
715 if( netNavigatorPane.IsShown() )
716 {
717 NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
718
719 wxTreeItemId selection = m_netNavigator->GetSelection();
720
721 if( selection.IsOk() )
722 itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
723
724 RefreshNetNavigator( itemData );
725 }
726}
727
728
729void SCH_EDIT_FRAME::FindNetInInspector( const wxString& aNetName )
730{
731 if( !m_netNavigator || aNetName.IsEmpty() )
732 return;
733
734 // Ensure the net navigator is shown
735 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
736
737 if( !netNavigatorPane.IsShown() )
739
740 // Clear any net highlights
741 m_highlightedConn = wxEmptyString;
743
744 // Set the search text to the aNetName
746 m_netNavigatorFilter->SetValue( aNetName );
747
748 m_netNavigatorFilterValue = aNetName;
749
750 // Refresh the tree
752}
753
754
755void SCH_EDIT_FRAME::onResizeNetNavigator( wxSizeEvent& aEvent )
756{
757 aEvent.Skip();
758
759 // Called when resizing the Hierarchy Navigator panel
760 // Store the current pane size
761 // It allows to retrieve the last defined pane size when switching between
762 // docked and floating pane state
763 // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
764
765 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
766
767 // During deletion/cleanup operations, settings may be temporarily unavailable
768 if( !cfg )
769 return;
770
771 wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
772
773 if( m_netNavigator->IsShownOnScreen() )
774 {
775 cfg->m_AuiPanels.net_nav_panel_float_size = netNavigatorPane.floating_size;
776
777 // initialize net_nav_panel_docked_width and best size only if the netNavigatorPane
778 // width is > 0 (i.e. if its size is already set and has meaning)
779 // if it is floating, its size is not initialized (only floating_size is initialized)
780 // initializing netNavigatorPane.best_size is useful when switching to float pane and
781 // after switching to the docked pane, to retrieve the last docked pane width
782 if( netNavigatorPane.rect.width > 50 ) // 50 is a good margin
783 {
784 cfg->m_AuiPanels.net_nav_panel_docked_size.SetWidth( netNavigatorPane.rect.width );
785 netNavigatorPane.best_size.x = netNavigatorPane.rect.width;
786 }
787 }
788}
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
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:110
EDA_ITEM * GetParent() const
Definition eda_item.h:112
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
bool contains(const SCH_ITEM *aItem, bool aRobust=false) const
Determine if a given item exists in the tree.
Definition sch_rtree.h:128
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:95
Tree view item data for the net navigator.
const SCH_ITEM * GetItem() const
A small class to help profiling.
Definition profile.h:49
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition profile.h:88
std::string to_string()
Definition profile.h:155
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.
wxTreeCtrl * m_netNavigator
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)
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
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:321
VECTOR2I GetPosition() const override
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:42
VECTOR2I GetEndPoint() const
Definition sch_line.h:148
VECTOR2I GetStartPoint() const
Definition sch_line.h:139
VECTOR2I GetPosition() const override
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:117
const wxString & GetFileName() const
Definition sch_screen.h:152
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.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
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:47
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:116
VECTOR2I GetPosition() const override
Definition sch_text.h:150
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:63
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.
#define _(s)
const wxChar *const traceUiProfile
Flag to enable user interface profile tracing.
@ LAYER_WIRE
Definition layer_ids.h:452
@ LAYER_BUS
Definition layer_ids.h:453
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)
wxLogTrace helper definitions.
@ SCH_LINE_T
Definition typeinfo.h:167
@ SCH_NO_CONNECT_T
Definition typeinfo.h:164
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:175
@ SCH_LABEL_T
Definition typeinfo.h:171
@ SCH_HIER_LABEL_T
Definition typeinfo.h:173
@ SCH_BUS_BUS_ENTRY_T
Definition typeinfo.h:166
@ SCH_SHEET_PIN_T
Definition typeinfo.h:178
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:165
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:172
@ SCH_JUNCTION_T
Definition typeinfo.h:163
@ SCH_PIN_T
Definition typeinfo.h:157
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.