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