HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG( SCH_EDIT_FRAME* aParent, const wxPoint& aPos ) : DIALOG_SHIM( aParent, wxID_ANY, _( "Navigator" ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { wxASSERT( dynamic_cast< SCH_EDIT_FRAME* >( aParent ) ); m_SchFrameEditor = aParent; m_currSheet = aParent->GetCurrentSheet(); m_Tree = new HIERARCHY_TREE( this ); m_nbsheets = 1; // root is the link to the main sheet. wxTreeItemId root; root = m_Tree->AddRoot( _( "Root" ), 0, 1 ); m_Tree->SetItemBold( root, true ); SCH_SHEET_PATH list; list.push_back( g_RootSheet ); m_Tree->SetItemData( root, new TreeItemData( list ) ); if( m_SchFrameEditor->GetCurrentSheet().Last() == g_RootSheet ) m_Tree->SelectItem( root ); buildHierarchyTree( &list, &root ); m_Tree->ExpandAll(); // This bloc gives a good size to the dialog, better than the default "best" size, // the first time the dialog is opened, during a session wxRect itemrect; wxSize tree_size; m_Tree->GetBoundingRect( root, itemrect ); // Set dialog window size to be large enough tree_size.x = itemrect.GetWidth() + 20; tree_size.x = std::max( tree_size.x, 250 ); // Readjust the size of the frame to an optimal value. tree_size.y = m_nbsheets * itemrect.GetHeight(); if( m_nbsheets < 2 ) tree_size.y += 10; // gives a better look for small trees SetClientSize( tree_size ); // manage the ESC key to close the dialog, because thre is no Cancel button // in dialog m_Tree->Connect( wxEVT_CHAR, wxKeyEventHandler( HIERARCHY_TREE::onChar ) ); // Manage double click on a selection, or the enter key: Bind( wxEVT_TREE_ITEM_ACTIVATED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this ); // Manage a simple click on a selection, if the selection changes Bind( wxEVT_TREE_SEL_CHANGED, &HIERARCHY_NAVIG_DLG::onSelectSheetPath, this ); }
void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { SCH_SHEET_PATH sheetPath = *aSheetPath; sheetPath.push_back( this ); for( size_t i = 0; i < m_pins.size(); i++ ) { NETLIST_OBJECT* item = new NETLIST_OBJECT(); item->m_SheetPathInclude = sheetPath; item->m_SheetPath = *aSheetPath; item->m_Comp = &m_pins[i]; item->m_Link = this; item->m_Type = NET_SHEETLABEL; item->m_Label = m_pins[i].GetText(); item->m_Start = item->m_End = m_pins[i].GetPosition(); aNetListItems.push_back( item ); if( IsBusLabel( m_pins[i].GetText() ) ) item->ConvertBusToNetListItems( aNetListItems ); } }