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( !m_tree->IsEmpty() )
252 getExpandedNodes( m_tree->GetRootItem() );
253
254 m_list.clear();
256
257 m_tree->DeleteAllItems();
258
259 wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
260 m_tree->SetItemData( root, new TREE_ITEM_DATA( m_list ) );
261
262 buildHierarchyTree( &m_list, root );
264
265 if( !expandedNodes.empty() )
266 {
267 std::function<void( const wxTreeItemId& )> expandNodes =
268 [&]( const wxTreeItemId& id )
269 {
270 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
271
272 TREE_ITEM_DATA* itemData =
273 static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
274
275 if( expandedNodes.find( itemData->m_SheetPath ) != expandedNodes.end() )
276 m_tree->Expand( id );
277
278 wxTreeItemIdValue cookie;
279 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
280
281 while( child.IsOk() )
282 {
283 expandNodes( child );
284 child = m_tree->GetNextChild( id, cookie );
285 }
286 };
287
288 expandNodes( m_tree->GetRootItem() );
289 }
290 else if( m_tree->ItemHasChildren( root ) )
291 {
292 m_tree->Expand( root );
293 }
294
295 if( eventsWereBound )
296 {
297 // Enable selection events
298 Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
299 Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
300 Bind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
301
302 m_events_bound = true;
303 }
304
305 Thaw();
306}
307
308
309void HIERARCHY_PANE::onSelectSheetPath( wxTreeEvent& aEvent )
310{
311 wxTreeItemId itemSel = m_tree->GetSelection();
312
313 if( !itemSel.IsOk() )
314 return;
315
316 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( itemSel ) );
317
318 if( !itemData )
319 return;
320
321 SetCursor( wxCURSOR_ARROWWAIT );
323 &itemData->m_SheetPath );
324 SetCursor( wxCURSOR_ARROW );
325}
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( wxTreeItemId aItem )
376{
377 wxMenu ctxMenu;
378 TREE_ITEM_DATA* itemData = nullptr;
379
380 if( !aItem.IsOk() )
381 aItem = m_tree->GetSelection();
382
383 if( aItem.IsOk() )
384 itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( aItem ) );
385
386 if( itemData )
387 {
388 ctxMenu.Append( EDIT_PAGE_NUMBER, _( "Edit Page Number" ) );
389 // The root item cannot be renamed
390 if( m_tree->GetRootItem() != aItem.GetID() )
391 {
392 ctxMenu.Append( RENAME, _( "Rename" ), _( "Change name of this sheet" ) );
393 }
394
395 ctxMenu.AppendSeparator();
396 }
397 ctxMenu.Append( EXPAND_ALL, ACTIONS::expandAll.GetMenuItem() );
398 ctxMenu.Append( COLLAPSE_ALL, ACTIONS::collapseAll.GetMenuItem() );
399
400
401 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
402
403 switch( selected )
404 {
405 case EDIT_PAGE_NUMBER:
406 {
407 wxString msg;
408 wxString sheetPath = itemData->m_SheetPath.PathHumanReadable( false, true );
409 wxString pageNumber = itemData->m_SheetPath.GetPageNumber();
410
411 msg.Printf( _( "Enter page number for sheet path %s" ),
412 ( sheetPath.Length() > 20 ) ? wxS( " \n" ) + sheetPath + wxT( ": " )
413 : sheetPath + wxT( ": " ) );
414
415 wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
416
417 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
418
419 if( dlg.ShowModal() == wxID_OK && dlg.GetValue() != itemData->m_SheetPath.GetPageNumber() )
420 {
421 SCH_COMMIT commit( m_frame );
422 SCH_SHEET_PATH parentPath = itemData->m_SheetPath;
423 parentPath.pop_back();
424
425 commit.Modify( itemData->m_SheetPath.Last(), parentPath.LastScreen() );
426
427 itemData->m_SheetPath.SetPageNumber( dlg.GetValue() );
428
429 if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
430 {
431 m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
433 }
434
435 commit.Push( wxS( "Change sheet page number." ) );
436
438 }
439
440 break;
441 }
442 case EXPAND_ALL:
443 m_tree->ExpandAll();
444 break;
445 case COLLAPSE_ALL:
446 m_tree->CollapseAll();
447 break;
448 case RENAME:
449 m_tree->SetItemText( aItem, itemData->m_SheetPath.Last()->GetName() );
450 m_tree->EditLabel( aItem );
452 break;
453 }
454}
455
456
457void HIERARCHY_PANE::onTreeEditFinished( wxTreeEvent& event )
458{
459 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( event.GetItem() ) );
460 wxString newName = event.GetLabel();
461
462 if( !newName.IsEmpty() )
463 {
464 // The editor holds only the page name as a text, while normally
465 // the tree items displaying it suffixed with the page number
466 if( data->m_SheetPath.Last()->GetName() != newName )
467 {
468 const SCH_SHEET* parentSheet =
469 data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
470
471 if( parentSheet )
472 {
473 SCH_COMMIT commit( m_frame );
474 commit.Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
475 parentSheet->GetScreen() );
476
477 data->m_SheetPath.Last()->SetName( newName );
478
479 renameIdenticalSheets( data->m_SheetPath, newName, &commit );
480
481 if( !commit.Empty() )
482 commit.Push( _( "Renaming sheet" ) );
483
484 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
485 {
487 }
488 }
489 }
490 }
491
492 m_tree->SetItemText( event.GetItem(), formatPageString( data->m_SheetPath.Last()->GetName(),
493 data->m_SheetPath.GetPageNumber() ) );
495 // The event needs to be rejected otherwise the SetItemText call above
496 // will be ineffective (the treeview item will hold the editor's content)
497 event.Veto();
498}
499
500
501void HIERARCHY_PANE::onCharHook( wxKeyEvent& aKeyStroke )
502{
503 int hotkey = aKeyStroke.GetKeyCode();
504
505 if( aKeyStroke.GetModifiers() & wxMOD_CONTROL )
506 hotkey += MD_CTRL;
507
508 if( aKeyStroke.GetModifiers() & wxMOD_ALT )
509 hotkey += MD_ALT;
510
511 if( aKeyStroke.GetModifiers() & wxMOD_SHIFT )
512 hotkey += MD_SHIFT;
513
514 if( hotkey == ACTIONS::expandAll.GetHotKey()
515 || hotkey == ACTIONS::expandAll.GetHotKeyAlt() )
516 {
517 m_tree->ExpandAll();
518 return;
519 }
520 else if( hotkey == ACTIONS::collapseAll.GetHotKey()
521 || hotkey == ACTIONS::collapseAll.GetHotKeyAlt() )
522 {
523 m_tree->CollapseAll();
524 return;
525 }
526 else
527 {
528 aKeyStroke.Skip();
529 }
530}
531
532
534{
535 SCH_SHEET* rootSheet = &m_frame->Schematic().Root();
536 SCH_SHEET_PATH rootPath;
537 rootPath.push_back( rootSheet );
538
539 return formatPageString( rootSheet->GetShownName( false ), rootPath.GetPageNumber() );
540}
541
542
543wxString HIERARCHY_PANE::formatPageString( const wxString& aName, const wxString& aPage )
544{
545 return aName + wxT( " " ) + wxString::Format( _( "(page %s)" ), aPage );
546}
547
549{
550 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
551 {
552 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
553
554 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
555
556 if( itemData->m_SheetPath.Cmp( path ) != 0 && itemData->m_SheetPath.Last() == path.Last() )
557 {
558 wxFont font = m_tree->GetItemFont( id );
559 font.SetUnderlined( highLighted );
560 m_tree->SetItemFont( id, font );
561 }
562
563 wxTreeItemIdValue cookie;
564 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
565
566 while( child.IsOk() )
567 {
568 recursiveDescent( child );
569 child = m_tree->GetNextChild( id, cookie );
570 }
571 };
572
573 recursiveDescent( m_tree->GetRootItem() );
574}
575
577 const wxString newName, SCH_COMMIT* commit )
578{
579 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
580 {
581 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
582
583 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
584
585 const SCH_SHEET* parentSheet = data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
586
587 if( parentSheet && data->m_SheetPath.Cmp( renamedSheet ) != 0
588 && data->m_SheetPath.Last() == renamedSheet.Last() )
589 {
590 commit->Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
591 parentSheet->GetScreen() );
592
593 data->m_SheetPath.Last()->SetName( newName );
594
595 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
596 {
598 }
599
600 m_tree->SetItemText( id, formatPageString( data->m_SheetPath.Last()->GetName(),
601 data->m_SheetPath.GetPageNumber() ) );
602 }
603
604 wxTreeItemIdValue cookie;
605 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
606
607 while( child.IsOk() )
608 {
609 recursiveDescent( child );
610 child = m_tree->GetNextChild( id, cookie );
611 }
612 };
613
614 recursiveDescent( m_tree->GetRootItem() );
615}
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: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:231
SCH_EDIT_FRAME * m_frame
void onRightClick(wxTreeItemId aItem)
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...
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:214
SCH_SHEET & Root() const
Definition: schematic.h:130
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Definition: sch_commit.cpp:432
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:57
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:92
wxString GetName() const
Definition: sch_sheet.h:106
void SetName(const wxString &aName)
Definition: sch_sheet.h:107
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:109
wxString GetShownName(bool aAllowExtraText) const
Definition: sch_sheet.h:102
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