40#include <wx/generic/textdlgg.h>
76 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
82 wxVector<wxBitmapBundle> images;
85 m_tree->SetImages( images );
89 wxBitmap tree_nosel_bm(
KiBitmap( BITMAPS::tree_nosel ) );
90 wxImageList* imageList =
new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(),
93 imageList->Add( tree_nosel_bm );
94 imageList->Add(
KiBitmap( BITMAPS::tree_sel ) );
96 m_tree->AssignImageList( imageList );
99 sizer->Add(
m_tree, 1, wxEXPAND, wxBORDER_NONE );
129 std::vector<SCH_ITEM*> sheetChildren;
132 for(
SCH_ITEM* aItem : sheetChildren )
140 wxTreeItemId child =
m_tree->AppendItem( aParent, sheetName, 0, 1 );
147 m_tree->SortChildren( aParent );
155 if( eventsWereBound )
166 [&](
const wxTreeItemId& id )
168 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
174 wxTreeItemId parent =
m_tree->GetItemParent(
id );
176 if( parent.IsOk() && !
m_tree->IsExpanded( parent ) )
179 if( !
m_tree->IsVisible(
id ) )
180 m_tree->EnsureVisible(
id );
182 m_tree->SetItemBold(
id,
true );
183 m_tree->SetFocusedItem(
id );
187 m_tree->SetItemBold(
id,
false );
190 wxTreeItemIdValue cookie;
191 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
193 while( child.IsOk() )
196 child =
m_tree->GetNextChild(
id, cookie );
202 if( eventsWereBound )
220 if( eventsWereBound )
230 std::set<SCH_SHEET_PATH> expandedNodes;
232 std::function<void(
const wxTreeItemId& )> getExpandedNodes =
233 [&](
const wxTreeItemId& id )
235 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
239 if(
m_tree->IsExpanded(
id ) )
242 wxTreeItemIdValue cookie;
243 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
245 while( child.IsOk() )
247 getExpandedNodes( child );
248 child =
m_tree->GetNextChild(
id, cookie );
253 getExpandedNodes(
m_tree->GetRootItem() );
266 if( !expandedNodes.empty() )
268 std::function<void(
const wxTreeItemId& )> expandNodes =
269 [&](
const wxTreeItemId& id )
271 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
276 if( expandedNodes.find( itemData->
m_SheetPath ) != expandedNodes.end() )
279 wxTreeItemIdValue cookie;
280 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
282 while( child.IsOk() )
284 expandNodes( child );
285 child =
m_tree->GetNextChild(
id, cookie );
289 expandNodes(
m_tree->GetRootItem() );
291 else if(
m_tree->ItemHasChildren( root ) )
296 if( eventsWereBound )
312 wxTreeItemId itemSel =
m_tree->GetSelection();
314 if( !itemSel.IsOk() )
322 SetCursor( wxCURSOR_ARROWWAIT );
325 SetCursor( wxCURSOR_ARROW );
334 std::function<void(
const wxTreeItemId& )> updateLabel =
335 [&](
const wxTreeItemId& id )
339 wxString sheetNameLabel =
343 if(
m_tree->GetItemText(
id ) != sheetNameLabel )
344 m_tree->SetItemText(
id, sheetNameLabel );
347 wxTreeItemId rootId =
m_tree->GetRootItem();
348 updateLabel( rootId );
351 [&](
const wxTreeItemId& id )
353 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
354 wxTreeItemIdValue cookie;
355 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
357 while( child.IsOk() )
359 updateLabel( child );
361 child =
m_tree->GetNextChild(
id, cookie );
387 aItem =
m_tree->GetSelection();
396 if(
m_tree->GetRootItem() != aItem.GetID() )
398 ctxMenu.Append(
RENAME,
_(
"Rename" ),
_(
"Change name of this sheet" ) );
401 ctxMenu.AppendSeparator();
407 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
417 msg.Printf(
_(
"Enter page number for sheet path %s" ),
418 ( sheetPath.Length() > 20 ) ? wxS(
" \n" ) + sheetPath + wxT(
": " )
419 : sheetPath + wxT(
": " ) );
421 wxTextEntryDialog dlg(
m_frame, msg,
_(
"Edit Sheet Page Number" ), pageNumber );
423 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC );
431 UNDO_REDO::CHANGED,
false );
456 m_tree->EditLabel( aItem );
466 wxString newName =
event.GetLabel();
468 if( !newName.IsEmpty() )
487 if( !commit.
Empty() )
488 commit.
Push(
_(
"Renaming sheet" ) );
509 int hotkey = aKeyStroke.GetKeyCode();
511 if( aKeyStroke.GetModifiers() & wxMOD_CONTROL )
514 if( aKeyStroke.GetModifiers() & wxMOD_ALT )
517 if( aKeyStroke.GetModifiers() & wxMOD_SHIFT )
551 return aName + wxT(
" " ) + wxString::Format(
_(
"(page %s)" ), aPage );
556 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
558 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
564 wxFont font =
m_tree->GetItemFont(
id );
565 font.SetUnderlined( highLighted );
566 m_tree->SetItemFont(
id, font );
569 wxTreeItemIdValue cookie;
570 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
572 while( child.IsOk() )
575 child =
m_tree->GetNextChild(
id, cookie );
585 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
587 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
610 wxTreeItemIdValue cookie;
611 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
613 while( child.IsOk() )
616 child =
m_tree->GetNextChild(
id, cookie );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
static TOOL_ACTION expandAll
static TOOL_ACTION collapseAll
void SetPageNumber(const wxString &aPageNumber)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
bool Empty() const
Returns status of an item.
static TOOL_ACTION changeSheet
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)
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
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
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,...
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.
std::vector< SCH_FIELD > & GetFields()
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)
static void recursiveDescent(wxSizer *aSizer, std::map< int, wxString > &aLabels)
wxIMPLEMENT_ABSTRACT_CLASS(HIERARCHY_TREE, wxTreeCtrl)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.