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 )
229 std::set<SCH_SHEET_PATH> expandedNodes;
231 std::function<void(
const wxTreeItemId& )> getExpandedNodes =
232 [&](
const wxTreeItemId& id )
234 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
241 wxTreeItemIdValue cookie;
242 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
244 while( child.IsOk() )
246 getExpandedNodes( child );
247 child =
m_tree->GetNextChild(
id, cookie );
252 getExpandedNodes(
m_tree->GetRootItem() );
265 if( !expandedNodes.empty() )
267 std::function<void(
const wxTreeItemId& )> expandNodes =
268 [&](
const wxTreeItemId& id )
270 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
275 if( expandedNodes.find( itemData->
m_SheetPath ) != expandedNodes.end() )
278 wxTreeItemIdValue cookie;
279 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
281 while( child.IsOk() )
283 expandNodes( child );
284 child =
m_tree->GetNextChild(
id, cookie );
288 expandNodes(
m_tree->GetRootItem() );
290 else if(
m_tree->ItemHasChildren( root ) )
295 if( eventsWereBound )
311 wxTreeItemId itemSel =
m_tree->GetSelection();
313 if( !itemSel.IsOk() )
321 SetCursor( wxCURSOR_ARROWWAIT );
324 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 );
381 aItem =
m_tree->GetSelection();
390 if(
m_tree->GetRootItem() != aItem.GetID() )
392 ctxMenu.Append(
RENAME,
_(
"Rename" ),
_(
"Change name of this sheet" ) );
395 ctxMenu.AppendSeparator();
401 int selected = GetPopupMenuSelectionFromUser( ctxMenu );
411 msg.Printf(
_(
"Enter page number for sheet path %s" ),
412 ( sheetPath.Length() > 20 ) ? wxS(
" \n" ) + sheetPath + wxT(
": " )
413 : sheetPath + wxT(
": " ) );
415 wxTextEntryDialog dlg(
m_frame, msg,
_(
"Edit Sheet Page Number" ), pageNumber );
417 dlg.SetTextValidator( wxFILTER_ALPHANUMERIC );
435 commit.
Push( wxS(
"Change sheet page number." ) );
450 m_tree->EditLabel( aItem );
460 wxString newName =
event.GetLabel();
462 if( !newName.IsEmpty() )
481 if( !commit.
Empty() )
482 commit.
Push(
_(
"Renaming sheet" ) );
503 int hotkey = aKeyStroke.GetKeyCode();
505 if( aKeyStroke.GetModifiers() & wxMOD_CONTROL )
508 if( aKeyStroke.GetModifiers() & wxMOD_ALT )
511 if( aKeyStroke.GetModifiers() & wxMOD_SHIFT )
545 return aName + wxT(
" " ) + wxString::Format(
_(
"(page %s)" ), aPage );
550 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
552 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
558 wxFont font =
m_tree->GetItemFont(
id );
559 font.SetUnderlined( highLighted );
560 m_tree->SetItemFont(
id, font );
563 wxTreeItemIdValue cookie;
564 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
566 while( child.IsOk() )
569 child =
m_tree->GetNextChild(
id, cookie );
579 std::function<void(
const wxTreeItemId& )>
recursiveDescent = [&](
const wxTreeItemId& id )
581 wxCHECK_RET(
id.IsOk(), wxT(
"Invalid tree item" ) );
604 wxTreeItemIdValue cookie;
605 wxTreeItemId child =
m_tree->GetFirstChild(
id, cookie );
607 while( child.IsOk() )
610 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)
Modify a given item in the model.
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
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
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,...
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.
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.