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 The 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_events_bound = true;
112}
113
114
116{
117 Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
118 Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
119 Unbind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
120 Unbind( wxEVT_CHAR_HOOK, &HIERARCHY_PANE::onCharHook, this );
121 m_tree->Unbind( wxEVT_TREE_END_LABEL_EDIT, &HIERARCHY_PANE::onTreeEditFinished, this );
122}
123
124
125void HIERARCHY_PANE::buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItemId& aParent )
126{
127 std::vector<SCH_ITEM*> sheetChildren;
128 aList->LastScreen()->GetSheets( &sheetChildren );
129
130 for( SCH_ITEM* aItem : sheetChildren )
131 {
132 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
133 aList->push_back( sheet );
134
135 wxString sheetNameBase = sheet->GetFields()[SHEETNAME].GetShownText( false );
136 wxString sheetName = formatPageString( sheetNameBase, aList->GetPageNumber() );
137 wxString sheetNumber = aList->GetPageNumber();
138 wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 );
139 m_tree->SetItemData( child, new TREE_ITEM_DATA( *aList ) );
140
141 buildHierarchyTree( aList, child );
142 aList->pop_back();
143 }
144
145 m_tree->SortChildren( aParent );
146}
147
148
150{
151 bool eventsWereBound = m_events_bound;
152
153 if( eventsWereBound )
154 {
155 // Disable selection events
156 Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
157 Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
158 Unbind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
159
160 m_events_bound = false;
161 }
162
163 std::function<void( const wxTreeItemId& )> recursiveDescent =
164 [&]( const wxTreeItemId& id )
165 {
166 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
167
168 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
169
170 if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
171 {
172 wxTreeItemId parent = m_tree->GetItemParent( id );
173
174 if( parent.IsOk() && !m_tree->IsExpanded( parent ) )
175 m_tree->Expand( parent );
176
177 if( !m_tree->IsVisible( id ) )
178 m_tree->EnsureVisible( id );
179
180 m_tree->SetItemBold( id, true );
181 m_tree->SetFocusedItem( id );
182 }
183 else
184 {
185 m_tree->SetItemBold( id, false );
186 }
187
188 wxTreeItemIdValue cookie;
189 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
190
191 while( child.IsOk() )
192 {
193 recursiveDescent( child );
194 child = m_tree->GetNextChild( id, cookie );
195 }
196 };
197
198 recursiveDescent( m_tree->GetRootItem() );
199
200 if( eventsWereBound )
201 {
202 // Enable selection events
203 Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
204 Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
205 Bind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
206
207 m_events_bound = true;
208 }
209}
210
211
213{
214 Freeze();
215
216 bool eventsWereBound = m_events_bound;
217
218 if( eventsWereBound )
219 {
220 // Disable selection events
221 Unbind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
222 Unbind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
223 Unbind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
224
225 m_events_bound = false;
226 }
227
228 SCH_SHEET_LIST hierarchy = m_frame->Schematic().Hierarchy();
229 std::set<SCH_SHEET_PATH> expandedNodes;
230
231 std::function<void( const wxTreeItemId& )> getExpandedNodes =
232 [&]( const wxTreeItemId& id )
233 {
234 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
235
236 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
237
238 if( m_tree->IsExpanded( id ) && hierarchy.HasPath( itemData->m_SheetPath.Path() ) )
239 expandedNodes.emplace( itemData->m_SheetPath );
240
241 wxTreeItemIdValue cookie;
242 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
243
244 while( child.IsOk() )
245 {
246 getExpandedNodes( child );
247 child = m_tree->GetNextChild( id, cookie );
248 }
249 };
250
251 // If we are clearing the tree, don't try to get expanded nodes as they
252 // might be deleted
253 if( !aClear && !m_tree->IsEmpty() )
254 getExpandedNodes( m_tree->GetRootItem() );
255
256 m_list.clear();
258
259 m_tree->DeleteAllItems();
260
261 wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
262 m_tree->SetItemData( root, new TREE_ITEM_DATA( m_list ) );
263
264 buildHierarchyTree( &m_list, root );
266
267 if( !expandedNodes.empty() )
268 {
269 std::function<void( const wxTreeItemId& )> expandNodes =
270 [&]( const wxTreeItemId& id )
271 {
272 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
273
274 TREE_ITEM_DATA* itemData =
275 static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
276
277 if( expandedNodes.find( itemData->m_SheetPath ) != expandedNodes.end() )
278 m_tree->Expand( id );
279
280 wxTreeItemIdValue cookie;
281 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
282
283 while( child.IsOk() )
284 {
285 expandNodes( child );
286 child = m_tree->GetNextChild( id, cookie );
287 }
288 };
289
290 expandNodes( m_tree->GetRootItem() );
291 }
292 else if( m_tree->ItemHasChildren( root ) )
293 {
294 m_tree->Expand( root );
295 }
296
297 if( eventsWereBound )
298 {
299 // Enable selection events
300 Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
301 Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
302 Bind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
303
304 m_events_bound = true;
305 }
306
307 Thaw();
308}
309
310
311void HIERARCHY_PANE::onSelectSheetPath( wxTreeEvent& aEvent )
312{
313 wxTreeItemId itemSel = m_tree->GetSelection();
314
315 if( !itemSel.IsOk() )
316 return;
317
318 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( itemSel ) );
319
320 if( !itemData )
321 return;
322
323 SetCursor( wxCURSOR_ARROWWAIT );
325 &itemData->m_SheetPath );
326 SetCursor( wxCURSOR_ARROW );
327}
328
329
331{
332 // Update the labels of the hierarchical tree of the schematic.
333 // Must be called only for an up to date tree, to update displayed labels after
334 // a sheet name or a sheet number change.
335
336 std::function<void( const wxTreeItemId& )> updateLabel =
337 [&]( const wxTreeItemId& id )
338 {
339 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
340 SCH_SHEET* sheet = itemData->m_SheetPath.Last();
341 wxString sheetNameLabel =
342 formatPageString( sheet->GetFields()[SHEETNAME].GetShownText( false ),
343 itemData->m_SheetPath.GetPageNumber() );
344
345 if( m_tree->GetItemText( id ) != sheetNameLabel )
346 m_tree->SetItemText( id, sheetNameLabel );
347 };
348
349 wxTreeItemId rootId = m_tree->GetRootItem();
350 updateLabel( rootId );
351
352 std::function<void( const wxTreeItemId& )> recursiveDescent =
353 [&]( const wxTreeItemId& id )
354 {
355 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
356 wxTreeItemIdValue cookie;
357 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
358
359 while( child.IsOk() )
360 {
361 updateLabel( child );
362 recursiveDescent( child );
363 child = m_tree->GetNextChild( id, cookie );
364 }
365 };
366
367 recursiveDescent( rootId );
368}
369
370
371void HIERARCHY_PANE::onTreeItemRightClick( wxTreeEvent& aEvent )
372{
373 onRightClick( aEvent.GetItem() );
374}
375
376
377void HIERARCHY_PANE::onRightClick( wxTreeItemId aItem )
378{
379 wxMenu ctxMenu;
380 TREE_ITEM_DATA* itemData = nullptr;
381
382 if( !aItem.IsOk() )
383 aItem = m_tree->GetSelection();
384
385 if( aItem.IsOk() )
386 itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( aItem ) );
387
388 if( itemData )
389 {
390 ctxMenu.Append( EDIT_PAGE_NUMBER, _( "Edit Page Number" ) );
391 // The root item cannot be renamed
392 if( m_tree->GetRootItem() != aItem.GetID() )
393 {
394 ctxMenu.Append( RENAME, _( "Rename" ), _( "Change name of this sheet" ) );
395 }
396
397 ctxMenu.AppendSeparator();
398 }
399 ctxMenu.Append( EXPAND_ALL, ACTIONS::expandAll.GetMenuItem() );
400 ctxMenu.Append( COLLAPSE_ALL, ACTIONS::collapseAll.GetMenuItem() );
401
402
403 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
404
405 switch( selected )
406 {
407 case EDIT_PAGE_NUMBER:
408 {
409 wxString msg;
410 wxString sheetPath = itemData->m_SheetPath.PathHumanReadable( false, true );
411 wxString pageNumber = itemData->m_SheetPath.GetPageNumber();
412
413 msg.Printf( _( "Enter page number for sheet path %s" ),
414 ( sheetPath.Length() > 20 ) ? wxS( " \n" ) + sheetPath + wxT( ": " )
415 : sheetPath + wxT( ": " ) );
416
417 wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
418
419 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
420
421 if( dlg.ShowModal() == wxID_OK && dlg.GetValue() != itemData->m_SheetPath.GetPageNumber() )
422 {
423 SCH_COMMIT commit( m_frame );
424 SCH_SHEET_PATH parentPath = itemData->m_SheetPath;
425 parentPath.pop_back();
426
427 commit.Modify( itemData->m_SheetPath.Last(), parentPath.LastScreen() );
428
429 itemData->m_SheetPath.SetPageNumber( dlg.GetValue() );
430
431 if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
432 {
433 m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
435 }
436
437 commit.Push( wxS( "Change sheet page number." ) );
438
440 }
441
442 break;
443 }
444 case EXPAND_ALL:
445 m_tree->ExpandAll();
446 break;
447 case COLLAPSE_ALL:
448 m_tree->CollapseAll();
449 break;
450 case RENAME:
451 m_tree->SetItemText( aItem, itemData->m_SheetPath.Last()->GetName() );
452 m_tree->EditLabel( aItem );
454 break;
455 }
456}
457
458
459void HIERARCHY_PANE::onTreeEditFinished( wxTreeEvent& event )
460{
461 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( event.GetItem() ) );
462 wxString newName = event.GetLabel();
463
464 if( !newName.IsEmpty() )
465 {
466 // The editor holds only the page name as a text, while normally
467 // the tree items displaying it suffixed with the page number
468 if( data->m_SheetPath.Last()->GetName() != newName )
469 {
470 const SCH_SHEET* parentSheet =
471 data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
472
473 if( parentSheet )
474 {
475 SCH_COMMIT commit( m_frame );
476 commit.Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
477 parentSheet->GetScreen() );
478
479 data->m_SheetPath.Last()->SetName( newName );
480
481 renameIdenticalSheets( data->m_SheetPath, newName, &commit );
482
483 if( !commit.Empty() )
484 commit.Push( _( "Renaming sheet" ) );
485
486 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
487 {
489 }
490 }
491 }
492 }
493
494 m_tree->SetItemText( event.GetItem(), formatPageString( data->m_SheetPath.Last()->GetName(),
495 data->m_SheetPath.GetPageNumber() ) );
497 // The event needs to be rejected otherwise the SetItemText call above
498 // will be ineffective (the treeview item will hold the editor's content)
499 event.Veto();
500}
501
502
503void HIERARCHY_PANE::onCharHook( wxKeyEvent& aKeyStroke )
504{
505 int hotkey = aKeyStroke.GetKeyCode();
506
507 if( aKeyStroke.GetModifiers() & wxMOD_CONTROL )
508 hotkey += MD_CTRL;
509
510 if( aKeyStroke.GetModifiers() & wxMOD_ALT )
511 hotkey += MD_ALT;
512
513 if( aKeyStroke.GetModifiers() & wxMOD_SHIFT )
514 hotkey += MD_SHIFT;
515
516 if( hotkey == ACTIONS::expandAll.GetHotKey()
517 || hotkey == ACTIONS::expandAll.GetHotKeyAlt() )
518 {
519 m_tree->ExpandAll();
520 return;
521 }
522 else if( hotkey == ACTIONS::collapseAll.GetHotKey()
523 || hotkey == ACTIONS::collapseAll.GetHotKeyAlt() )
524 {
525 m_tree->CollapseAll();
526 return;
527 }
528 else
529 {
530 aKeyStroke.Skip();
531 }
532}
533
534
536{
537 SCH_SHEET* rootSheet = &m_frame->Schematic().Root();
538 SCH_SHEET_PATH rootPath;
539 rootPath.push_back( rootSheet );
540
541 return formatPageString( rootSheet->GetShownName( false ), rootPath.GetPageNumber() );
542}
543
544
545wxString HIERARCHY_PANE::formatPageString( const wxString& aName, const wxString& aPage )
546{
547 return aName + wxT( " " ) + wxString::Format( _( "(page %s)" ), aPage );
548}
549
551{
552 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
553 {
554 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
555
556 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
557
558 if( itemData->m_SheetPath.Cmp( path ) != 0 && itemData->m_SheetPath.Last() == path.Last() )
559 {
560 wxFont font = m_tree->GetItemFont( id );
561 font.SetUnderlined( highLighted );
562 m_tree->SetItemFont( id, font );
563 }
564
565 wxTreeItemIdValue cookie;
566 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
567
568 while( child.IsOk() )
569 {
570 recursiveDescent( child );
571 child = m_tree->GetNextChild( id, cookie );
572 }
573 };
574
575 recursiveDescent( m_tree->GetRootItem() );
576}
577
579 const wxString newName, SCH_COMMIT* commit )
580{
581 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
582 {
583 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
584
585 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
586
587 const SCH_SHEET* parentSheet = data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
588
589 if( parentSheet && data->m_SheetPath.Cmp( renamedSheet ) != 0
590 && data->m_SheetPath.Last() == renamedSheet.Last() )
591 {
592 commit->Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
593 parentSheet->GetScreen() );
594
595 data->m_SheetPath.Last()->SetName( newName );
596
597 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
598 {
600 }
601
602 m_tree->SetItemText( id, formatPageString( data->m_SheetPath.Last()->GetName(),
603 data->m_SheetPath.GetPageNumber() ) );
604 }
605
606 wxTreeItemIdValue cookie;
607 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
608
609 while( child.IsOk() )
610 {
611 recursiveDescent( child );
612 child = m_tree->GetNextChild( id, cookie );
613 }
614 };
615
616 recursiveDescent( m_tree->GetRootItem() );
617}
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
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
static TOOL_ACTION expandAll
Definition: actions.h:83
static TOOL_ACTION collapseAll
Definition: actions.h:84
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Modify a given item in the model.
Definition: commit.h:108
bool Empty() const
Definition: commit.h:150
static TOOL_ACTION changeSheet
Definition: ee_actions.h:223
SCH_EDIT_FRAME * m_frame
void onRightClick(wxTreeItemId aItem)
HIERARCHY_TREE * m_tree
void UpdateHierarchyTree(bool aClear=false)
Update the hierarchical tree of the schematic.
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 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...
Navigation hierarchy tree control.
int OnCompareItems(const wxTreeItemId &item1, const wxTreeItemId &item2) override
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:224
SCH_SHEET & Root() const
Definition: schematic.h:131
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Definition: sch_commit.cpp:433
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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:167
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,...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
bool HasPath(const KIID_PATH &aPath) const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const SCH_SHEET * GetSheet(unsigned aIndex) const
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.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
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:59
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:96
wxString GetName() const
Definition: sch_sheet.h:110
void SetName(const wxString &aName)
Definition: sch_sheet.h:111
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:113
wxString GetShownName(bool aAllowExtraText) const
Definition: sch_sheet.h:106
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:145
@ MD_CTRL
Definition: tool_event.h:144
@ MD_SHIFT
Definition: tool_event.h:143