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_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 std::set<SCH_SHEET_PATH> expandedNodes;
229
230 std::function<void( const wxTreeItemId& )> getExpandedNodes =
231 [&]( const wxTreeItemId& id )
232 {
233 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
234
235 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
236
237 if( m_tree->IsExpanded( id ) )
238 expandedNodes.emplace( itemData->m_SheetPath );
239
240 wxTreeItemIdValue cookie;
241 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
242
243 while( child.IsOk() )
244 {
245 getExpandedNodes( child );
246 child = m_tree->GetNextChild( id, cookie );
247 }
248 };
249
250 if( !m_tree->IsEmpty() )
251 getExpandedNodes( m_tree->GetRootItem() );
252
253 m_list.clear();
255
256 m_tree->DeleteAllItems();
257
258 wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
259 m_tree->SetItemData( root, new TREE_ITEM_DATA( m_list ) );
260
261 buildHierarchyTree( &m_list, root );
263
264 if( !expandedNodes.empty() )
265 {
266 std::function<void( const wxTreeItemId& )> expandNodes =
267 [&]( const wxTreeItemId& id )
268 {
269 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
270
271 TREE_ITEM_DATA* itemData =
272 static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
273
274 if( expandedNodes.find( itemData->m_SheetPath ) != expandedNodes.end() )
275 m_tree->Expand( id );
276
277 wxTreeItemIdValue cookie;
278 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
279
280 while( child.IsOk() )
281 {
282 expandNodes( child );
283 child = m_tree->GetNextChild( id, cookie );
284 }
285 };
286
287 expandNodes( m_tree->GetRootItem() );
288 }
289 else if( m_tree->ItemHasChildren( root ) )
290 {
291 m_tree->Expand( root );
292 }
293
294 if( eventsWereBound )
295 {
296 // Enable selection events
297 Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_PANE::onSelectSheetPath, this );
298 Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_PANE::onSelectSheetPath, this );
299 Bind( wxEVT_TREE_ITEM_RIGHT_CLICK, &HIERARCHY_PANE::onTreeItemRightClick, this );
300
301 m_events_bound = true;
302 }
303
304 Thaw();
305}
306
307
308void HIERARCHY_PANE::onSelectSheetPath( wxTreeEvent& aEvent )
309{
310 wxTreeItemId itemSel = m_tree->GetSelection();
311
312 if( !itemSel.IsOk() )
313 return;
314
315 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( itemSel ) );
316
317 if( !itemData )
318 return;
319
320 SetCursor( wxCURSOR_ARROWWAIT );
322 &itemData->m_SheetPath );
323 SetCursor( wxCURSOR_ARROW );
324}
325
326
328{
329 // Update the labels of the hierarchical tree of the schematic.
330 // Must be called only for an up to date tree, to update displayed labels after
331 // a sheet name or a sheet number change.
332
333 std::function<void( const wxTreeItemId& )> updateLabel =
334 [&]( const wxTreeItemId& id )
335 {
336 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
337 SCH_SHEET* sheet = itemData->m_SheetPath.Last();
338 wxString sheetNameLabel =
339 formatPageString( sheet->GetFields()[SHEETNAME].GetShownText( false ),
340 itemData->m_SheetPath.GetPageNumber() );
341
342 if( m_tree->GetItemText( id ) != sheetNameLabel )
343 m_tree->SetItemText( id, sheetNameLabel );
344 };
345
346 wxTreeItemId rootId = m_tree->GetRootItem();
347 updateLabel( rootId );
348
349 std::function<void( const wxTreeItemId& )> recursiveDescent =
350 [&]( const wxTreeItemId& id )
351 {
352 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
353 wxTreeItemIdValue cookie;
354 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
355
356 while( child.IsOk() )
357 {
358 updateLabel( child );
359 recursiveDescent( child );
360 child = m_tree->GetNextChild( id, cookie );
361 }
362 };
363
364 recursiveDescent( rootId );
365}
366
367
368void HIERARCHY_PANE::onTreeItemRightClick( wxTreeEvent& aEvent )
369{
370 onRightClick( aEvent.GetItem() );
371}
372
373
374void HIERARCHY_PANE::onRightClick( wxTreeItemId aItem )
375{
376 wxMenu ctxMenu;
377 TREE_ITEM_DATA* itemData = nullptr;
378
379 if( !aItem.IsOk() )
380 aItem = m_tree->GetSelection();
381
382 if( aItem.IsOk() )
383 itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( aItem ) );
384
385 if( itemData )
386 {
387 ctxMenu.Append( EDIT_PAGE_NUMBER, _( "Edit Page Number" ) );
388 // The root item cannot be renamed
389 if( m_tree->GetRootItem() != aItem.GetID() )
390 {
391 ctxMenu.Append( RENAME, _( "Rename" ), _( "Change name of this sheet" ) );
392 }
393
394 ctxMenu.AppendSeparator();
395 }
396 ctxMenu.Append( EXPAND_ALL, ACTIONS::expandAll.GetMenuItem() );
397 ctxMenu.Append( COLLAPSE_ALL, ACTIONS::collapseAll.GetMenuItem() );
398
399
400 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
401
402 switch( selected )
403 {
404 case EDIT_PAGE_NUMBER:
405 {
406 wxString msg;
407 wxString sheetPath = itemData->m_SheetPath.PathHumanReadable( false, true );
408 wxString pageNumber = itemData->m_SheetPath.GetPageNumber();
409
410 msg.Printf( _( "Enter page number for sheet path %s" ),
411 ( sheetPath.Length() > 20 ) ? wxS( " \n" ) + sheetPath + wxT( ": " )
412 : sheetPath + wxT( ": " ) );
413
414 wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber );
415
416 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
417
418 if( dlg.ShowModal() == wxID_OK && dlg.GetValue() != itemData->m_SheetPath.GetPageNumber() )
419 {
420 SCH_SHEET_PATH parentPath = itemData->m_SheetPath;
421 parentPath.pop_back();
422
423 m_frame->SaveCopyInUndoList( parentPath.LastScreen(), itemData->m_SheetPath.Last(),
424 UNDO_REDO::CHANGED, false );
425
426 itemData->m_SheetPath.SetPageNumber( dlg.GetValue() );
427
428 if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
429 {
430 m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
432 }
433
434 m_frame->OnModify();
435
437 }
438
439 break;
440 }
441 case EXPAND_ALL:
442 m_tree->ExpandAll();
443 break;
444 case COLLAPSE_ALL:
445 m_tree->CollapseAll();
446 break;
447 case RENAME:
448 m_tree->SetItemText( aItem, itemData->m_SheetPath.Last()->GetName() );
449 m_tree->EditLabel( aItem );
451 break;
452 }
453}
454
455
456void HIERARCHY_PANE::onTreeEditFinished( wxTreeEvent& event )
457{
458 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( event.GetItem() ) );
459 wxString newName = event.GetLabel();
460
461 if( !newName.IsEmpty() )
462 {
463 // The editor holds only the page name as a text, while normally
464 // the tree items displaying it suffixed with the page number
465 if( data->m_SheetPath.Last()->GetName() != newName )
466 {
467 const SCH_SHEET* parentSheet =
468 data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
469
470 if( parentSheet )
471 {
472 SCH_COMMIT commit( m_frame );
473 commit.Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
474 parentSheet->GetScreen() );
475
476 data->m_SheetPath.Last()->SetName( newName );
477
478 renameIdenticalSheets( data->m_SheetPath, newName, &commit );
479
480 if( !commit.Empty() )
481 commit.Push( _( "Renaming sheet" ) );
482
483 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
484 {
486 }
487 }
488 }
489 }
490
491 m_tree->SetItemText( event.GetItem(), formatPageString( data->m_SheetPath.Last()->GetName(),
492 data->m_SheetPath.GetPageNumber() ) );
494 // The event needs to be rejected otherwise the SetItemText call above
495 // will be ineffective (the treeview item will hold the editor's content)
496 event.Veto();
497}
498
499
500void HIERARCHY_PANE::onCharHook( wxKeyEvent& aKeyStroke )
501{
502 int hotkey = aKeyStroke.GetKeyCode();
503
504 if( aKeyStroke.GetModifiers() & wxMOD_CONTROL )
505 hotkey += MD_CTRL;
506
507 if( aKeyStroke.GetModifiers() & wxMOD_ALT )
508 hotkey += MD_ALT;
509
510 if( aKeyStroke.GetModifiers() & wxMOD_SHIFT )
511 hotkey += MD_SHIFT;
512
513 if( hotkey == ACTIONS::expandAll.GetHotKey()
514 || hotkey == ACTIONS::expandAll.GetHotKeyAlt() )
515 {
516 m_tree->ExpandAll();
517 return;
518 }
519 else if( hotkey == ACTIONS::collapseAll.GetHotKey()
520 || hotkey == ACTIONS::collapseAll.GetHotKeyAlt() )
521 {
522 m_tree->CollapseAll();
523 return;
524 }
525 else
526 {
527 aKeyStroke.Skip();
528 }
529}
530
531
533{
534 SCH_SHEET* rootSheet = &m_frame->Schematic().Root();
535 SCH_SHEET_PATH rootPath;
536 rootPath.push_back( rootSheet );
537
538 return formatPageString( rootSheet->GetShownName( false ), rootPath.GetPageNumber() );
539}
540
541
542wxString HIERARCHY_PANE::formatPageString( const wxString& aName, const wxString& aPage )
543{
544 return aName + wxT( " " ) + wxString::Format( _( "(page %s)" ), aPage );
545}
546
548{
549 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
550 {
551 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
552
553 TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
554
555 if( itemData->m_SheetPath.Cmp( path ) != 0 && itemData->m_SheetPath.Last() == path.Last() )
556 {
557 wxFont font = m_tree->GetItemFont( id );
558 font.SetUnderlined( highLighted );
559 m_tree->SetItemFont( id, font );
560 }
561
562 wxTreeItemIdValue cookie;
563 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
564
565 while( child.IsOk() )
566 {
567 recursiveDescent( child );
568 child = m_tree->GetNextChild( id, cookie );
569 }
570 };
571
572 recursiveDescent( m_tree->GetRootItem() );
573}
574
576 const wxString newName, SCH_COMMIT* commit )
577{
578 std::function<void( const wxTreeItemId& )> recursiveDescent = [&]( const wxTreeItemId& id )
579 {
580 wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
581
582 TREE_ITEM_DATA* data = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
583
584 const SCH_SHEET* parentSheet = data->m_SheetPath.GetSheet( data->m_SheetPath.size() - 2 );
585
586 if( parentSheet && data->m_SheetPath.Cmp( renamedSheet ) != 0
587 && data->m_SheetPath.Last() == renamedSheet.Last() )
588 {
589 commit->Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
590 parentSheet->GetScreen() );
591
592 data->m_SheetPath.Last()->SetName( newName );
593
594 if( data->m_SheetPath == m_frame->GetCurrentSheet() )
595 {
597 }
598
599 m_tree->SetItemText( id, formatPageString( data->m_SheetPath.Last()->GetName(),
600 data->m_SheetPath.GetPageNumber() ) );
601 }
602
603 wxTreeItemIdValue cookie;
604 wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
605
606 while( child.IsOk() )
607 {
608 recursiveDescent( child );
609 child = m_tree->GetNextChild( id, cookie );
610 }
611 };
612
613 recursiveDescent( m_tree->GetRootItem() );
614}
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)
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: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 & Root() const
Definition: schematic.h:121
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:432
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:166
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