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 );
127 std::vector<SCH_ITEM*> sheetChildren;
130 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 )
218 if( eventsWereBound )
228 std::set<SCH_SHEET_PATH> expandedNodes;
230 std::function<void(
const wxTreeItemId& )> getExpandedNodes =
231 [&](
const wxTreeItemId& id )
233 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
237 if(
m_tree->IsExpanded(
id ) )
240 wxTreeItemIdValue cookie;
241 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
243 while( child.IsOk() )
245 getExpandedNodes( child );
246 child =
m_tree->GetNextChild(
id, cookie );
251 getExpandedNodes(
m_tree->GetRootItem() );
264 if( !expandedNodes.empty() )
266 std::function<void(
const wxTreeItemId& )> expandNodes =
267 [&](
const wxTreeItemId& id )
269 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
274 if( expandedNodes.find( itemData->
m_SheetPath ) != expandedNodes.end() )
277 wxTreeItemIdValue cookie;
278 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
280 while( child.IsOk() )
282 expandNodes( child );
283 child =
m_tree->GetNextChild(
id, cookie );
287 expandNodes(
m_tree->GetRootItem() );
289 else if(
m_tree->ItemHasChildren( root ) )
294 if( eventsWereBound )
310 wxTreeItemId itemSel =
m_tree->GetSelection();
312 if( !itemSel.IsOk() )
320 SetCursor( wxCURSOR_ARROWWAIT );
323 SetCursor( wxCURSOR_ARROW );
333 std::function<void(
const wxTreeItemId& )> updateLabel =
334 [&](
const wxTreeItemId& id )
338 wxString sheetNameLabel =
342 if(
m_tree->GetItemText(
id ) != sheetNameLabel )
343 m_tree->SetItemText(
id, sheetNameLabel );
346 wxTreeItemId rootId =
m_tree->GetRootItem();
347 updateLabel( rootId );
350 [&](
const wxTreeItemId& id )
352 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
353 wxTreeItemIdValue cookie;
354 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
356 while( child.IsOk() )
358 updateLabel( child );
360 child =
m_tree->GetNextChild(
id, cookie );
380 aItem =
m_tree->GetSelection();
389 if(
m_tree->GetRootItem() != aItem.GetID() )
391 ctxMenu.Append(
RENAME,
_(
"Rename" ),
_(
"Change name of this sheet" ) );
394 ctxMenu.AppendSeparator();
400 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
410 msg.Printf(
_(
"Enter page number for sheet path %s" ),
411 ( sheetPath.Length() > 20 ) ? wxS(
" \n" ) + sheetPath + wxT(
": " )
412 : sheetPath + wxT(
": " ) );
414 wxTextEntryDialog dlg(
m_frame, msg,
_(
"Edit Sheet Page Number" ), pageNumber );
416 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC );
434 commit.
Push( wxS(
"Change sheet page number." ) );
449 m_tree->EditLabel( aItem );
459 wxString newName =
event.GetLabel();
461 if( !newName.IsEmpty() )
480 if( !commit.
Empty() )
481 commit.
Push(
_(
"Renaming sheet" ) );
502 int hotkey = aKeyStroke.GetKeyCode();
504 if( aKeyStroke.GetModifiers() & wxMOD_CONTROL )
507 if( aKeyStroke.GetModifiers() & wxMOD_ALT )
510 if( aKeyStroke.GetModifiers() & wxMOD_SHIFT )
544 return aName + wxT(
" " ) + wxString::Format(
_(
"(page %s)" ), aPage );
549 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
551 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
557 wxFont font =
m_tree->GetItemFont(
id );
558 font.SetUnderlined( highLighted );
559 m_tree->SetItemFont(
id, font );
562 wxTreeItemIdValue cookie;
563 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
565 while( child.IsOk() )
568 child =
m_tree->GetNextChild(
id, cookie );
578 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
580 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
603 wxTreeItemIdValue cookie;
604 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
606 while( child.IsOk() )
609 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 onRightClick(wxTreeItemId aItem)
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...
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.
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,...
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.