KiCad PCB EDA Suite
Loading...
Searching...
No Matches
hierarchy_pane.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) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <bitmaps.h>
27#include <sch_edit_frame.h>
28#include <sch_sheet.h>
29#include <sch_sheet_path.h>
30#include <sch_commit.h>
31#include <schematic.h>
32#include <tool/tool_manager.h>
33#include <tools/ee_actions.h>
34
35#include <hierarchy_pane.h>
36#include <kiface_base.h>
37#include <eeschema_settings.h>
38
39#include <wx/object.h>
40#include <wx/generic/textdlgg.h>
41#include <wx/menu.h>
42
46class TREE_ITEM_DATA : public wxTreeItemData
47{
48public:
50
51 TREE_ITEM_DATA( SCH_SHEET_PATH& sheet ) : wxTreeItemData(), m_SheetPath( sheet ) {}
52};
53
54
55// Need to use wxRTTI macros in order for OnCompareItems to work properly
56// See: https://docs.wxwidgets.org/3.1/classwx_tree_ctrl.html#ab90a465793c291ca7aa827a576b7d146
58
59
60int HIERARCHY_TREE::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
61{
62 SCH_SHEET_PATH* item1Path = &static_cast<TREE_ITEM_DATA*>( GetItemData( item1 ) )->m_SheetPath;
63 SCH_SHEET_PATH* item2Path = &static_cast<TREE_ITEM_DATA*>( GetItemData( item2 ) )->m_SheetPath;
64
65 return item1Path->ComparePageNum( *item2Path );
66}
67
68
70 WX_PANEL( aParent )
71{
72 wxASSERT( dynamic_cast<SCH_EDIT_FRAME*>( aParent ) );
73
74 m_frame = aParent;
75
76 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
77 SetSizer( sizer );
78 m_tree = new HIERARCHY_TREE( this );
79
80#ifdef __WXMAC__
81 // HiDPI-aware API; will be generally available in wxWidgets 3.4
82 wxVector<wxBitmapBundle> images;
83 images.push_back( KiBitmapBundle( BITMAPS::tree_nosel ) );
84 images.push_back( KiBitmapBundle( BITMAPS::tree_sel ) );
85 m_tree->SetImages( images );
86#else
87 // Make an image list containing small icons
88 // All icons are expected having the same size.
89 wxBitmap tree_nosel_bm( KiBitmap( BITMAPS::tree_nosel ) );
90 wxImageList* imageList = new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(),
91 true, 2 );
92
93 imageList->Add( tree_nosel_bm );
94 imageList->Add( KiBitmap( BITMAPS::tree_sel ) );
95
96 m_tree->AssignImageList( imageList );
97#endif
98
99 sizer->Add( m_tree, 1, wxEXPAND, wxBORDER_NONE );
100
101 m_events_bound = false;
102
104
105 // Enable selection events
106 Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
107 Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
108 Bind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
109 Bind( wxEVT_CHAR_HOOK, &HIERARCHY_PANE::onCharHook, this );
110 m_tree->Bind( wxEVT_TREE_END_LABEL_EDIT, &HIERARCHY_PANE::onTreeEditFinished, this );
111 m_tree->Bind( wxEVT_RIGHT_UP, &HIERARCHY_PANE::onRightClick, this );
112 m_events_bound = true;
113}
114
115
117{
118 Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
119 Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
120 Unbind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
121 Unbind( wxEVT_CHAR_HOOK, &HIERARCHY_PANE::onCharHook, this );
122 m_tree->Unbind( wxEVT_TREE_END_LABEL_EDIT, &HIERARCHY_PANE::onTreeEditFinished, this );
123 m_tree->Unbind( wxEVT_RIGHT_UP, &HIERARCHY_PANE::onRightClick, this );
124}
125
126
127void HIERARCHY_PANE::buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItemId& aParent )
128{
129 std::vector<SCH_ITEM*> sheetChildren;
130 aList->LastScreen()->GetSheets( &sheetChildren );
131
132 for( SCH_ITEM* aItem : sheetChildren )
133 {
134 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
135 aList->push_back( sheet );
136
137 wxString sheetNameBase = sheet->GetFields()[SHEETNAME].GetShownText( false );
138 wxString sheetName = formatPageString( sheetNameBase, aList->GetPageNumber() );
139 wxString sheetNumber = aList->GetPageNumber();
140 wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 );
141 m_tree->SetItemData( child, new TREE_ITEM_DATA( *aList ) );
142
143 buildHierarchyTree( aList, child );
144 aList->pop_back();
145 }
146
147 m_tree->SortChildren( aParent );
148}
149
150
152{
153 bool eventsWereBound = m_events_bound;
154
155 if( eventsWereBound )
156 {
157 // Disable selection events
158 Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
159 Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
160 Unbind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
161
162 m_events_bound = false;
163 }
164
165 std::function<void( const wxTreeItemId& )> recursiveDescent =
166 [&]( const wxTreeItemId& id )
167 {
168 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
169
170 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
171
172 if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
173 {
174 wxTreeItemId parent = m_tree->GetItemParent( id );
175
176 if( parent.IsOk() && !m_tree->IsExpanded( parent ) )
177 m_tree->Expand( parent );
178
179 if( !m_tree->IsVisible( id ) )
180 m_tree->EnsureVisible( id );
181
182 m_tree->SetItemBold( id, true );
183 m_tree->SetFocusedItem( id );
184 }
185 else
186 {
187 m_tree->SetItemBold( id, false );
188 }
189
190 wxTreeItemIdValue cookie;
191 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
192
193 while( child.IsOk() )
194 {
195 recursiveDescent( child );
196 child = m_tree->GetNextChild( id, cookie );
197 }
198 };
199
200 recursiveDescent( m_tree->GetRootItem() );
201
202 if( eventsWereBound )
203 {
204 // Enable selection events
205 Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
206 Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
207 Bind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
208
209 m_events_bound = true;
210 }
211}
212
213
215{
216 Freeze();
217
218 bool eventsWereBound = m_events_bound;
219
220 if( eventsWereBound )
221 {
222 // Disable selection events
223 Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
224 Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
225 Unbind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
226
227 m_events_bound = false;
228 }
229
230 std::set<SCH_SHEET_PATH> expandedNodes;
231
232 std::function<void( const wxTreeItemId& )> getExpandedNodes =
233 [&]( const wxTreeItemId& id )
234 {
235 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
236
237 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
238
239 if( m_tree->IsExpanded( id ) )
240 expandedNodes.emplace( itemData->m_SheetPath );
241
242 wxTreeItemIdValue cookie;
243 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
244
245 while( child.IsOk() )
246 {
247 getExpandedNodes( child );
248 child = m_tree->GetNextChild( id, cookie );
249 }
250 };
251
252 if( !m_tree->IsEmpty() )
253 getExpandedNodes( m_tree->GetRootItem() );
254
255 m_list.clear();
257
258 m_tree->DeleteAllItems();
259
260 wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
261 m_tree->SetItemData( root, new TREE_ITEM_DATA( m_list ) );
262
263 buildHierarchyTree( &m_list, root );
265
266 if( !expandedNodes.empty() )
267 {
268 std::function<void( const wxTreeItemId& )> expandNodes =
269 [&]( const wxTreeItemId& id )
270 {
271 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
272
273 TREE_ITEM_DATA* itemData =
274 static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
275
276 if( expandedNodes.find( itemData->m_SheetPath ) != expandedNodes.end() )
277 m_tree->Expand( id );
278
279 wxTreeItemIdValue cookie;
280 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
281
282 while( child.IsOk() )
283 {
284 expandNodes( child );
285 child = m_tree->GetNextChild( id, cookie );
286 }
287 };
288
289 expandNodes( m_tree->GetRootItem() );
290 }
291 else if( m_tree->ItemHasChildren( root ) )
292 {
293 m_tree->Expand( root );
294 }
295
296 if( eventsWereBound )
297 {
298 // Enable selection events
299 Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
300 Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
301 Bind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
302
303 m_events_bound = true;
304 }
305
306 Thaw();
307}
308
309
310void HIERARCHY_PANE::onSelectSheetPath( wxTreeEvent& aEvent )
311{
312 wxTreeItemId itemSel = m_tree->GetSelection();
313
314 if( !itemSel.IsOk() )
315 return;
316
317 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( itemSel ) );
318
319 if( !itemData )
320 return;
321
322 SetCursor( wxCURSOR_ARROWWAIT );
324 &itemData->m_SheetPath );
325 SetCursor( wxCURSOR_ARROW );
326}
327
329{
330 // Update the labels of the hierarchical tree of the schematic.
331 // Must be called only for an up to date tree, to update displayed labels after
332 // a sheet name or a sheet number change.
333
334 std::function<void( const wxTreeItemId& )> updateLabel =
335 [&]( const wxTreeItemId& id )
336 {
337 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
338 SCH_SHEET* sheet = itemData->m_SheetPath.Last();
339 wxString sheetNameLabel =
340 formatPageString( sheet->GetFields()[SHEETNAME].GetShownText( false ),
341 itemData->m_SheetPath.GetPageNumber() );
342
343 if( m_tree->GetItemText( id ) != sheetNameLabel )
344 m_tree->SetItemText( id, sheetNameLabel );
345 };
346
347 wxTreeItemId rootId = m_tree->GetRootItem();
348 updateLabel( rootId );
349
350 std::function<void( const wxTreeItemId& )> recursiveDescent =
351 [&]( const wxTreeItemId& id )
352 {
353 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
354 wxTreeItemIdValue cookie;
355 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
356
357 while( child.IsOk() )
358 {
359 updateLabel( child );
360 recursiveDescent( child );
361 child = m_tree->GetNextChild( id, cookie );
362 }
363 };
364
365 recursiveDescent( rootId );
366}
367
368
369void HIERARCHY_PANE::onTreeItemRightClick( wxTreeEvent& aEvent )
370{
371 onRightClick( aEvent.GetItem() );
372}
373
374
375void HIERARCHY_PANE::onRightClick( wxMouseEvent& aEvent )
376{
377 onRightClick( wxTreeItemId() );
378}
379
380
381void HIERARCHY_PANE::onRightClick( wxTreeItemId aItem )
382{
383 wxMenu ctxMenu;
384 TREE_ITEM_DATA* itemData = nullptr;
385
386 if( !aItem.IsOk() )
387 aItem = m_tree->GetSelection();
388
389 if( aItem.IsOk() )
390 itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( aItem ) );
391
392 if( itemData )
393 {
394 ctxMenu.Append( EDIT_PAGE_NUMBER, _( "Edit Page Number" ) );
395 // The root item cannot be renamed
396 if( m_tree->GetRootItem() != aItem.GetID() )
397 {
398 ctxMenu.Append( RENAME, _( "Rename" ), _( "Change name of this sheet" ) );
399 }
400
401 ctxMenu.AppendSeparator();
402 }
403 ctxMenu.Append( EXPAND_ALL, ACTIONS::expandAll.GetMenuItem() );
404 ctxMenu.Append( COLLAPSE_ALL, ACTIONS::collapseAll.GetMenuItem() );
405
406
407 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
408
409 switch( selected )
410 {
411 case EDIT_PAGE_NUMBER:
412 {
413 wxString msg;
414 wxString sheetPath = itemData->m_SheetPath.PathHumanReadable( false, true );
415 wxString pageNumber = itemData->m_SheetPath.GetPageNumber();
416
417 msg.Printf( _( "Enter page number for sheet path %s" ),
418 ( sheetPath.Length() > 20 ) ? wxS( " \n" ) + sheetPath + wxT( ": " )
419 : sheetPath + wxT( ": " ) );
420
421 wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
422
423 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
424
425 if( dlg.ShowModal() == wxID_OK && dlg.GetValue() != itemData->m_SheetPath.GetPageNumber() )
426 {
427 SCH_SHEET_PATH parentPath = itemData->m_SheetPath;
428 parentPath.pop_back();
429
430 m_frame->SaveCopyInUndoList( parentPath.LastScreen(), itemData->m_SheetPath.Last(),
431 UNDO_REDO::CHANGED, false );
432
433 itemData->m_SheetPath.SetPageNumber( dlg.GetValue() );
434
435 if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
436 {
437 m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
439 }
440
441 m_frame->OnModify();
442
444 }
445
446 break;
447 }
448 case EXPAND_ALL:
449 m_tree->ExpandAll();
450 break;
451 case COLLAPSE_ALL:
452 m_tree->CollapseAll();
453 break;
454 case RENAME:
455 m_tree->SetItemText( aItem, itemData->m_SheetPath.Last()->GetName() );
456 m_tree->EditLabel( aItem );
458 break;
459 }
460}
461
462
463void HIERARCHY_PANE::onTreeEditFinished( wxTreeEvent& event )
464{
465 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( event.GetItem() ) );
466 wxString newName = event.GetLabel();
467
468 if( !newName.IsEmpty() )
469 {
470 // The editor holds only the page name as a text, while normally
471 // the tree items displaying it suffixed with the page number
472 if( data->m_SheetPath.Last()->GetName() != newName )
473 {
474 const SCH_SHEET* parentSheet =
475 data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
476
477 if( parentSheet )
478 {
479 SCH_COMMIT commit( m_frame );
480 commit.Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
481 parentSheet->GetScreen() );
482
483 data->m_SheetPath.Last()->SetName( newName );
484
485 renameIdenticalSheets( data->m_SheetPath, newName, &commit );
486
487 if( !commit.Empty() )
488 commit.Push( _( "Renaming sheet" ) );
489
490 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
491 {
493 }
494 }
495 }
496 }
497
498 m_tree->SetItemText( event.GetItem(), formatPageString( data->m_SheetPath.Last()->GetName(),
499 data->m_SheetPath.GetPageNumber() ) );
501 // The event needs to be rejected otherwise the SetItemText call above
502 // will be ineffective (the treeview item will hold the editor's content)
503 event.Veto();
504}
505
506
507void HIERARCHY_PANE::onCharHook( wxKeyEvent& aKeyStroke )
508{
509 int hotkey = aKeyStroke.GetKeyCode();
510
511 if( aKeyStroke.GetModifiers() & wxMOD_CONTROL )
512 hotkey += MD_CTRL;
513
514 if( aKeyStroke.GetModifiers() & wxMOD_ALT )
515 hotkey += MD_ALT;
516
517 if( aKeyStroke.GetModifiers() & wxMOD_SHIFT )
518 hotkey += MD_SHIFT;
519
520 if( hotkey == ACTIONS::expandAll.GetHotKey()
521 || hotkey == ACTIONS::expandAll.GetHotKeyAlt() )
522 {
523 m_tree->ExpandAll();
524 return;
525 }
526 else if( hotkey == ACTIONS::collapseAll.GetHotKey()
527 || hotkey == ACTIONS::collapseAll.GetHotKeyAlt() )
528 {
529 m_tree->CollapseAll();
530 return;
531 }
532 else
533 {
534 aKeyStroke.Skip();
535 }
536}
537
538
540{
541 SCH_SHEET* rootSheet = &m_frame->Schematic().Root();
542 SCH_SHEET_PATH rootPath;
543 rootPath.push_back( rootSheet );
544
545 return formatPageString( rootSheet->GetShownName( false ), rootPath.GetPageNumber() );
546}
547
548
549wxString HIERARCHY_PANE::formatPageString( const wxString& aName, const wxString& aPage )
550{
551 return aName + wxT( " " ) + wxString::Format( _( "(page %s)" ), aPage );
552}
553
555{
556 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
557 {
558 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
559
560 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
561
562 if( itemData->m_SheetPath.Cmp( path ) != 0 && itemData->m_SheetPath.Last() == path.Last() )
563 {
564 wxFont font = m_tree->GetItemFont( id );
565 font.SetUnderlined( highLighted );
566 m_tree->SetItemFont( id, font );
567 }
568
569 wxTreeItemIdValue cookie;
570 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
571
572 while( child.IsOk() )
573 {
574 recursiveDescent( child );
575 child = m_tree->GetNextChild( id, cookie );
576 }
577 };
578
579 recursiveDescent( m_tree->GetRootItem() );
580}
581
583 const wxString newName, SCH_COMMIT* commit )
584{
585 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
586 {
587 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
588
589 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
590
591 const SCH_SHEET* parentSheet = data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
592
593 if( parentSheet && data->m_SheetPath.Cmp( renamedSheet ) != 0
594 && data->m_SheetPath.Last() == renamedSheet.Last() )
595 {
596 commit->Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
597 parentSheet->GetScreen() );
598
599 data->m_SheetPath.Last()->SetName( newName );
600
601 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
602 {
604 }
605
606 m_tree->SetItemText( id, formatPageString( data->m_SheetPath.Last()->GetName(),
607 data->m_SheetPath.GetPageNumber() ) );
608 }
609
610 wxTreeItemIdValue cookie;
611 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
612
613 while( child.IsOk() )
614 {
615 recursiveDescent( child );
616 child = m_tree->GetNextChild( id, cookie );
617 }
618 };
619
620 recursiveDescent( m_tree->GetRootItem() );
621}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
static TOOL_ACTION expandAll
Definition: actions.h:80
static TOOL_ACTION collapseAll
Definition: actions.h:81
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
bool Empty() const
Returns status of an item.
Definition: commit.h:144
static TOOL_ACTION changeSheet
Definition: ee_actions.h:218
SCH_EDIT_FRAME * m_frame
HIERARCHY_TREE * m_tree
void onSelectSheetPath(wxTreeEvent &aEvent)
Open the selected sheet and display the corresponding screen when a tree item is selected.
void UpdateLabelsHierarchyTree()
Update the labels of the hierarchical tree of the schematic.
wxString formatPageString(const wxString &aName, const wxString &aPage)
wxString getRootString()
SCH_SHEET_PATH m_list
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
HIERARCHY_PANE(SCH_EDIT_FRAME *aParent)
void onCharHook(wxKeyEvent &aKeyStroke)
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
void renameIdenticalSheets(const SCH_SHEET_PATH &renamedSheet, const wxString newName, SCH_COMMIT *commit)
Rename all sheets in a hierarchial desing which has the same source renamed sheet.
void buildHierarchyTree(SCH_SHEET_PATH *aList, const wxTreeItemId &aParent)
Create the hierarchical tree of the schematic.
void onTreeItemRightClick(wxTreeEvent &aEvent)
void onTreeEditFinished(wxTreeEvent &event)
void setIdenticalSheetsHighlighted(const SCH_SHEET_PATH &path, bool highLighted=true)
When renaming the sheets in tree it is helpful to highlight the identical sheets which got renamed by...
void onRightClick(wxMouseEvent &aEvent)
Navigation hierarchy tree control.
int OnCompareItems(const wxTreeItemId &item1, const wxTreeItemId &item2) override
SCH_SHEET & Root() const
Definition: schematic.h:105
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:405
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void OnPageSettingsChange() override
Called when modifying the page settings.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
void GetSheets(std::vector< SCH_ITEM * > *aItems) const
Similar to Items().OfType( SCH_SHEET_T ), but return the sheets in a deterministic order (L-R,...
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
int ComparePageNum(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare sheets by their page number.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
SCH_SCREEN * LastScreen()
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare if this is the same sheet path as aSheetPathToTest.
wxString GetPageNumber() const
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void clear()
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
wxString GetName() const
Definition: sch_sheet.h:107
void SetName(const wxString &aName)
Definition: sch_sheet.h:108
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:110
wxString GetShownName(bool aAllowExtraText) const
Definition: sch_sheet.h:103
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
Store an SCH_SHEET_PATH of each sheet in hierarchy.
SCH_SHEET_PATH m_SheetPath
TREE_ITEM_DATA(SCH_SHEET_PATH &sheet)
static void recursiveDescent(wxSizer *aSizer, std::map< int, wxString > &aLabels)
#define _(s)
wxIMPLEMENT_ABSTRACT_CLASS(HIERARCHY_TREE, wxTreeCtrl)
@ SHEETNAME
Definition: sch_sheet.h:45
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ MD_ALT
Definition: tool_event.h:144
@ MD_CTRL
Definition: tool_event.h:143
@ MD_SHIFT
Definition: tool_event.h:142