35#include <wx/generic/textdlgg.h>
37#include <wx/wupdlock.h>
72 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
78 wxVector<wxBitmapBundle> images;
81 m_tree->SetImages( images );
86 wxImageList* imageList =
new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(),
89 imageList->Add( tree_nosel_bm );
92 m_tree->AssignImageList( imageList );
95 sizer->Add(
m_tree, 1, wxEXPAND, wxBORDER_NONE );
128 std::vector<SCH_ITEM*> sheetChildren;
131 for(
SCH_ITEM* aItem : sheetChildren )
138 wxTreeItemId child =
m_tree->AppendItem( aParent, sheetName, 0, 1 );
145 m_tree->SortChildren( aParent );
153 if( eventsWereBound )
164 [&](
const wxTreeItemId& id )
166 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
172 wxTreeItemId parent =
m_tree->GetItemParent(
id );
174 if( parent.IsOk() && !
m_tree->IsExpanded( parent ) )
177 if( !
m_tree->IsVisible(
id ) )
178 m_tree->EnsureVisible(
id );
180 m_tree->SetItemBold(
id,
true );
181 m_tree->SetFocusedItem(
id );
185 m_tree->SetItemBold(
id,
false );
188 wxTreeItemIdValue cookie;
189 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
191 while( child.IsOk() )
194 child =
m_tree->GetNextChild(
id, cookie );
200 if( eventsWereBound )
214 wxWindowUpdateLocker updateLock(
this );
218 if( eventsWereBound )
231 std::function<void(
const wxTreeItemId& )> getCollapsedNodes =
232 [&](
const wxTreeItemId& id )
234 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
238 if(
m_tree->ItemHasChildren(
id ) && !
m_tree->IsExpanded(
id )
245 wxTreeItemIdValue cookie;
246 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
248 while( child.IsOk() )
250 getCollapsedNodes( child );
251 child =
m_tree->GetNextChild(
id, cookie );
257 if( !aClear && !
m_tree->IsEmpty() )
259 collapsedNodes.clear();
260 getCollapsedNodes(
m_tree->GetRootItem() );
276 std::function<void(
const wxTreeItemId& )> collapseNodes =
277 [&](
const wxTreeItemId& id )
279 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
291 wxTreeItemIdValue cookie;
292 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
294 while( child.IsOk() )
296 collapseNodes( child );
297 child =
m_tree->GetNextChild(
id, cookie );
301 collapseNodes( root );
304 if( eventsWereBound )
318 wxTreeItemId itemSel =
m_tree->GetSelection();
320 if( !itemSel.IsOk() )
328 SetCursor( wxCURSOR_ARROWWAIT );
330 SetCursor( wxCURSOR_ARROW );
340 std::function<void(
const wxTreeItemId& )> updateLabel =
341 [&](
const wxTreeItemId& id )
344 SCH_SHEET* sheet = itemData->m_SheetPath.Last();
347 itemData->m_SheetPath.GetPageNumber() );
349 if(
m_tree->GetItemText(
id ) != sheetName )
350 m_tree->SetItemText(
id, sheetName );
353 wxTreeItemId rootId =
m_tree->GetRootItem();
354 updateLabel( rootId );
357 [&](
const wxTreeItemId& id )
359 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
360 wxTreeItemIdValue cookie;
361 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
363 while( child.IsOk() )
365 updateLabel( child );
367 child =
m_tree->GetNextChild(
id, cookie );
377 std::vector<wxString> collapsed;
382 std::function<void(
const wxTreeItemId& )> collect =
383 [&](
const wxTreeItemId& id )
385 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
389 if(
id !=
m_tree->GetRootItem() &&
m_tree->ItemHasChildren(
id )
390 && !
m_tree->IsExpanded(
id ) )
396 wxTreeItemIdValue cookie;
397 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
399 while( child.IsOk() )
402 child =
m_tree->GetNextChild(
id, cookie );
406 collect(
m_tree->GetRootItem() );
423 aItem =
m_tree->GetSelection();
432 if(
m_tree->GetRootItem() != aItem.GetID() )
434 ctxMenu.Append(
RENAME,
_(
"Rename" ),
_(
"Change name of this sheet" ) );
437 ctxMenu.AppendSeparator();
443 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
453 msg.Printf(
_(
"Enter page number for sheet path %s" ),
454 ( sheetPath.Length() > 20 ) ? wxS(
" \n" ) + sheetPath + wxT(
": " )
455 : sheetPath + wxT(
": " ) );
457 wxTextEntryDialog dlg(
m_frame, msg,
_(
"Edit Sheet Page Number" ), pageNumber );
459 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC );
473 m_frame->GetScreen()->SetPageNumber( dlg.GetValue() );
474 m_frame->OnPageSettingsChange();
477 commit.
Push( wxS(
"Change sheet page number." ) );
492 m_tree->EditLabel( aItem );
502 wxString newName =
event.GetLabel();
506 if( !newName.IsEmpty() )
524 if( !commit.
Empty() )
525 commit.
Push(
_(
"Renaming sheet" ) );
529 m_frame->OnPageSettingsChange();
547 int hotkey = aKeyStroke.GetKeyCode();
549 int mods = aKeyStroke.GetModifiers();
554 if( wxmods & wxMOD_ALTGR )
559 if( mods & wxMOD_CONTROL )
562 if( mods & wxMOD_ALT )
566 if( mods & wxMOD_SHIFT )
570 if( mods & wxMOD_META )
575 if( mods & wxMOD_WIN )
610 return aName + wxT(
" " ) + wxString::Format(
_(
"(page %s)" ), aPage );
615 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
617 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
623 wxFont font =
m_tree->GetItemFont(
id );
624 font.SetUnderlined( highLighted );
625 m_tree->SetItemFont(
id, font );
628 wxTreeItemIdValue cookie;
629 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
631 while( child.IsOk() )
634 child =
m_tree->GetNextChild(
id, cookie );
644 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
646 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
662 m_frame->OnPageSettingsChange();
669 wxTreeItemIdValue cookie;
670 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
672 while( child.IsOk() )
675 child =
m_tree->GetNextChild(
id, cookie );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
static TOOL_ACTION expandAll
static TOOL_ACTION collapseAll
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
void onRightClick(wxTreeItemId aItem)
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)
void UpdateHierarchySelection()
Updates the tree's selection to match current page.
HIERARCHY_PANE(SCH_EDIT_FRAME *aParent)
std::set< wxString > m_collapsedPaths
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)
std::vector< wxString > GetCollapsedPaths() const
Returns a list of sheet paths for nodes that are currently collapsed.
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
The project local settings are things that are attached to a particular project, but also might be pa...
std::vector< wxString > m_SchHierarchyCollapsed
Collapsed nodes in the schematic hierarchy navigator.
static TOOL_ACTION changeSheet
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Base class for any item which can be embedded within the SCHEMATIC container class,...
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
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
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.
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.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
void SetName(const wxString &aName)
SCH_SCREEN * GetScreen() const
wxString GetShownName(bool aAllowExtraText) const
Store an SCH_SHEET_PATH of each sheet in hierarchy.
SCH_SHEET_PATH m_SheetPath
TREE_ITEM_DATA(SCH_SHEET_PATH &sheet)
WX_PANEL(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
static void recursiveDescent(wxSizer *aSizer, std::map< int, wxString > &aLabels)
wxIMPLEMENT_ABSTRACT_CLASS(HIERARCHY_TREE, wxTreeCtrl)