KiCad PCB EDA Suite
HIERARCHY_NAVIG_DLG Class Reference
Inheritance diagram for HIERARCHY_NAVIG_DLG:

Public Member Functions

 HIERARCHY_NAVIG_DLG (SCH_EDIT_FRAME *aParent, const wxPoint &aPos)
 
void BuildSheetsTree (SCH_SHEET_PATH *list, wxTreeItemId *previousmenu)
 
 ~HIERARCHY_NAVIG_DLG ()
 
void OnSelect (wxTreeEvent &event)
 

Public Attributes

SCH_EDIT_FRAMEm_Parent
 
HIERARCHY_TREEm_Tree
 
int m_nbsheets
 

Private Member Functions

void OnQuit (wxCommandEvent &event)
 

Private Attributes

wxSize m_TreeSize
 
int maxposx
 

Detailed Description

Definition at line 111 of file hierarch.cpp.

Constructor & Destructor Documentation

HIERARCHY_NAVIG_DLG::HIERARCHY_NAVIG_DLG ( SCH_EDIT_FRAME aParent,
const wxPoint aPos 
)

Definition at line 150 of file hierarch.cpp.

References BuildSheetsTree(), g_RootSheet, SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET_PATH::Last(), m_nbsheets, m_Parent, m_Tree, m_TreeSize, max, and maxposx.

150  :
151  wxDialog( aParent, wxID_ANY, _( "Navigator" ), aPos, wxSize( 110, 50 ),
152  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
153 {
154  wxTreeItemId cellule;
155 
156  m_Parent = aParent;
157  m_Tree = new HIERARCHY_TREE( this );
158 
159  m_nbsheets = 1;
160 
161  cellule = m_Tree->AddRoot( _( "Root" ), 0, 1 );
162  m_Tree->SetItemBold( cellule, true );
163 
164  SCH_SHEET_PATH list;
165  list.push_back( g_RootSheet );
166  m_Tree->SetItemData( cellule, new TreeItemData( list ) );
167 
169  m_Tree->SelectItem( cellule ); //root.
170 
171  maxposx = 15;
172  BuildSheetsTree( &list, &cellule );
173 
174  m_Tree->Expand( cellule );
175 
176  wxRect itemrect;
177  m_Tree->GetBoundingRect( cellule, itemrect );
178 
179  // Set dialog window size to be large enough
180  m_TreeSize.x = itemrect.GetWidth() + 20;
181  m_TreeSize.x = std::max( m_TreeSize.x, 250 );
182 
183  // Readjust the size of the frame to an optimal value.
184  m_TreeSize.y = m_nbsheets * itemrect.GetHeight();
185  m_TreeSize.y += 10;
186 
187  SetClientSize( m_TreeSize );
188 }
void BuildSheetsTree(SCH_SHEET_PATH *list, wxTreeItemId *previousmenu)
Definition: hierarch.cpp:206
HIERARCHY_TREE * m_Tree
Definition: hierarch.cpp:115
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
SCH_EDIT_FRAME * m_Parent
Definition: hierarch.cpp:114
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:573
Class SCH_SHEET_PATH.
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
#define max(a, b)
Definition: auxiliary.h:86
HIERARCHY_NAVIG_DLG::~HIERARCHY_NAVIG_DLG ( )

Definition at line 191 of file hierarch.cpp.

192 {
193 }

Member Function Documentation

void HIERARCHY_NAVIG_DLG::BuildSheetsTree ( SCH_SHEET_PATH list,
wxTreeItemId *  previousmenu 
)

Definition at line 206 of file hierarch.cpp.

References DisplayError(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET::GetName(), SCH_SHEET_PATH::LastDrawList(), m_nbsheets, m_Parent, m_Tree, m_TreeSize, max, maxposx, NB_MAX_SHEET, SCH_ITEM::Next(), SCH_SHEET_T, and EDA_ITEM::Type().

Referenced by HIERARCHY_NAVIG_DLG().

208 {
209  wxTreeItemId menu;
210 
211  if( m_nbsheets > NB_MAX_SHEET )
212  {
213  if( m_nbsheets == (NB_MAX_SHEET + 1) )
214  {
215  wxString msg;
216  msg << wxT( "BuildSheetsTree: Error: nbsheets > " ) << NB_MAX_SHEET;
217  DisplayError( this, msg );
218  m_nbsheets++;
219  }
220 
221  return;
222  }
223 
224  maxposx += m_Tree->GetIndent();
225  SCH_ITEM* schitem = list->LastDrawList();
226 
227  while( schitem && m_nbsheets < NB_MAX_SHEET )
228  {
229  if( schitem->Type() == SCH_SHEET_T )
230  {
231  SCH_SHEET* sheet = (SCH_SHEET*) schitem;
232  m_nbsheets++;
233  menu = m_Tree->AppendItem( *previousmenu, sheet->GetName(), 0, 1 );
234  list->push_back( sheet );
235  m_Tree->SetItemData( menu, new TreeItemData( *list ) );
236  int ll = m_Tree->GetItemText( menu ).Len();
237 
238 #ifdef __WINDOWS__
239  ll *= 9; // * char width
240 #else
241  ll *= 12; // * char width
242 #endif
243  ll += maxposx + 20;
244  m_TreeSize.x = std::max( m_TreeSize.x, ll );
245  m_TreeSize.y += 1;
246 
247  if( *list == m_Parent->GetCurrentSheet() )
248  {
249  m_Tree->EnsureVisible( menu );
250  m_Tree->SelectItem( menu );
251  }
252 
253  BuildSheetsTree( list, &menu );
254  m_Tree->Expand( menu );
255  list->pop_back();
256  }
257 
258  schitem = schitem->Next();
259  }
260 
261  maxposx -= m_Tree->GetIndent();
262 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void BuildSheetsTree(SCH_SHEET_PATH *list, wxTreeItemId *previousmenu)
Definition: hierarch.cpp:206
HIERARCHY_TREE * m_Tree
Definition: hierarch.cpp:115
SCH_ITEM * Next() const
SCH_EDIT_FRAME * m_Parent
Definition: hierarch.cpp:114
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:573
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
#define max(a, b)
Definition: auxiliary.h:86
#define NB_MAX_SHEET
Max number of sheets in a hierarchy project.
wxString GetName() const
Definition: sch_sheet.h:274
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void HIERARCHY_NAVIG_DLG::OnQuit ( wxCommandEvent &  event)
private

Definition at line 196 of file hierarch.cpp.

197 {
198  // true is to force the frame to close
199  Close( true );
200 }
void HIERARCHY_NAVIG_DLG::OnSelect ( wxTreeEvent &  event)

Definition at line 268 of file hierarch.cpp.

References SCH_EDIT_FRAME::DisplayCurrentSheet(), m_Parent, m_Tree, and SCH_EDIT_FRAME::SetCurrentSheet().

270 {
271  wxTreeItemId ItemSel = m_Tree->GetSelection();
272 
273  m_Parent->SetCurrentSheet(( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetPath );
275  Close( true );
276 }
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
Definition: schframe.cpp:581
HIERARCHY_TREE * m_Tree
Definition: hierarch.cpp:115
void DisplayCurrentSheet()
Function DisplayCurrentSheet draws the current sheet on the display.
Definition: hierarch.cpp:279
SCH_EDIT_FRAME * m_Parent
Definition: hierarch.cpp:114

Member Data Documentation

int HIERARCHY_NAVIG_DLG::m_nbsheets

Definition at line 116 of file hierarch.cpp.

Referenced by BuildSheetsTree(), and HIERARCHY_NAVIG_DLG().

SCH_EDIT_FRAME* HIERARCHY_NAVIG_DLG::m_Parent

Definition at line 114 of file hierarch.cpp.

Referenced by BuildSheetsTree(), HIERARCHY_NAVIG_DLG(), and OnSelect().

HIERARCHY_TREE* HIERARCHY_NAVIG_DLG::m_Tree

Definition at line 115 of file hierarch.cpp.

Referenced by BuildSheetsTree(), HIERARCHY_NAVIG_DLG(), and OnSelect().

wxSize HIERARCHY_NAVIG_DLG::m_TreeSize
private

Definition at line 119 of file hierarch.cpp.

Referenced by BuildSheetsTree(), and HIERARCHY_NAVIG_DLG().

int HIERARCHY_NAVIG_DLG::maxposx
private

Definition at line 120 of file hierarch.cpp.

Referenced by BuildSheetsTree(), and HIERARCHY_NAVIG_DLG().


The documentation for this class was generated from the following file: