KiCad PCB EDA Suite
dialog_choose_component.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
5  * Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
26 
27 #include <algorithm>
28 #include <set>
29 #include <wx/utils.h>
30 
31 #include <wx/button.h>
32 #include <wx/dataview.h>
33 #include <wx/panel.h>
34 #include <wx/sizer.h>
35 #include <wx/splitter.h>
36 #include <wx/timer.h>
37 #include <wx/utils.h>
38 
39 #include <class_library.h>
40 #include <sch_base_frame.h>
41 #include <template_fieldnames.h>
42 #include <symbol_lib_table.h>
43 #include <widgets/lib_tree.h>
46 
47 
51 
53 
54 
57  int aDeMorganConvert, bool aAllowFieldEdits,
58  bool aShowFootprints, bool aAllowBrowser )
59  : DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
60  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
61  m_browser_button( nullptr ),
62  m_hsplitter( nullptr ),
63  m_vsplitter( nullptr ),
64  m_fp_sel_ctrl( nullptr ),
65  m_fp_preview( nullptr ),
66  m_parent( aParent ),
67  m_deMorganConvert( aDeMorganConvert >= 0 ? aDeMorganConvert : 0 ),
68  m_allow_field_edits( aAllowFieldEdits ),
69  m_show_footprints( aShowFootprints ),
70  m_external_browser_requested( false )
71 {
72  auto sizer = new wxBoxSizer( wxVERTICAL );
73  wxHtmlWindow* details = nullptr;
74 
75  // Use a slightly different layout, with a details pane spanning the entire window,
76  // if we're not showing footprints.
77  if( aShowFootprints )
78  {
79  m_hsplitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
80  wxSP_LIVE_UPDATE );
81 
82  //Avoid the splitter window being assigned as the Parent to additional windows
83  m_hsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
84 
85  sizer->Add( m_hsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
86  }
87  else
88  {
89  m_vsplitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
90  wxSP_LIVE_UPDATE );
91 
92  m_hsplitter = new wxSplitterWindow( m_vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize,
93  wxSP_LIVE_UPDATE );
94 
95  //Avoid the splitter window being assigned as the Parent to additional windows
96  m_hsplitter->SetExtraStyle( wxWS_EX_TRANSIENT );
97 
98  auto detailsPanel = new wxPanel( m_vsplitter );
99  auto detailsSizer = new wxBoxSizer( wxVERTICAL );
100  detailsPanel->SetSizer( detailsSizer );
101 
102  details = new wxHtmlWindow( detailsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
103  wxHW_SCROLLBAR_AUTO );
104  detailsSizer->Add( details, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
105  detailsPanel->Layout();
106  detailsSizer->Fit( detailsPanel );
107 
108  m_vsplitter->SetSashGravity( 0.5 );
109  m_vsplitter->SetMinimumPaneSize( 20 );
110  m_vsplitter->SplitHorizontally( m_hsplitter, detailsPanel );
111 
112  sizer->Add( m_vsplitter, 1, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
113  }
114 
115  m_tree = new LIB_TREE( m_hsplitter, Prj().SchSymbolLibTable(), aAdapter,
116  LIB_TREE::WIDGETS::ALL, details );
117 
118  m_hsplitter->SetSashGravity( 0.8 );
119  m_hsplitter->SetMinimumPaneSize( 20 );
120  m_hsplitter->SplitVertically( m_tree, ConstructRightPanel( m_hsplitter ) );
121 
122  m_dbl_click_timer = new wxTimer( this );
123 
124  auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
125 
126  if( aAllowBrowser )
127  {
128  m_browser_button = new wxButton( this, wxID_ANY, _( "Select with Browser" ) );
129  buttonsSizer->Add( m_browser_button, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
130  }
131 
132  auto sdbSizer = new wxStdDialogButtonSizer();
133  auto okButton = new wxButton( this, wxID_OK );
134  auto cancelButton = new wxButton( this, wxID_CANCEL );
135  sdbSizer->AddButton( okButton );
136  sdbSizer->AddButton( cancelButton );
137  sdbSizer->Realize();
138 
139  buttonsSizer->Add( sdbSizer, 1, wxALL, 5 );
140 
141  sizer->Add( buttonsSizer, 0, wxEXPAND | wxLEFT, 5 );
142  SetSizer( sizer );
143 
144  Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this );
145  Bind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this, m_dbl_click_timer->GetId() );
146  Bind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentPreselected, this );
147  Bind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this );
149 
150  if( m_browser_button )
151  m_browser_button->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
153 
154  if( m_fp_sel_ctrl )
155  m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED,
157 
158  Layout();
159 
160  // We specify the width of the right window (m_symbol_view_panel), because specify
161  // the width of the left window does not work as expected when SetSashGravity() is called
162  m_hsplitter->SetSashPosition( m_h_sash_pos ? m_h_sash_pos : HorizPixelsFromDU( 240 ) );
163 
164  if( m_vsplitter )
165  m_vsplitter->SetSashPosition( m_v_sash_pos ? m_v_sash_pos : VertPixelsFromDU( 170 ) );
166 
167  if( m_last_dlg_size == wxSize( -1, -1 ) )
168  SetSizeInDU( 360, 280 );
169  else
170  SetSize( m_last_dlg_size );
171 
173  okButton->SetDefault();
174 }
175 
176 
178 {
179  Unbind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this );
180  Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this );
181  Unbind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentPreselected, this );
182  Unbind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this );
184 
185  if( m_browser_button )
186  m_browser_button->Unbind( wxEVT_COMMAND_BUTTON_CLICKED,
188 
189  if( m_fp_sel_ctrl )
190  m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED,
192 
193  // I am not sure the following two lines are necessary,
194  // but they will not hurt anyone
195  m_dbl_click_timer->Stop();
196  delete m_dbl_click_timer;
197 
198  m_last_dlg_size = GetSize();
199  m_h_sash_pos = m_hsplitter->GetSashPosition();
200 
201  if( m_vsplitter )
202  m_v_sash_pos = m_vsplitter->GetSashPosition();
203 }
204 
205 
206 wxPanel* DIALOG_CHOOSE_COMPONENT::ConstructRightPanel( wxWindow* aParent )
207 {
208  auto panel = new wxPanel( aParent );
209  auto sizer = new wxBoxSizer( wxVERTICAL );
210 
211  m_symbol_preview = new wxPanel( panel, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
212  wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL );
213  m_symbol_preview->SetLayoutDirection( wxLayout_LeftToRight );
214 
215  if( m_show_footprints )
216  {
218 
219  if( m_allow_field_edits )
220  m_fp_sel_ctrl = new FOOTPRINT_SELECT_WIDGET( panel, fp_list, true );
221 
222  m_fp_preview = new FOOTPRINT_PREVIEW_WIDGET( panel, Kiway() );
223 
224 
225  sizer->Add( m_symbol_preview, 1, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, 5 );
226 
227  if( m_fp_sel_ctrl )
228  sizer->Add( m_fp_sel_ctrl, 0, wxEXPAND | wxBOTTOM | wxTOP | wxRIGHT, 5 );
229 
230  sizer->Add( m_fp_preview, 1, wxEXPAND | wxBOTTOM | wxRIGHT, 5 );
231  }
232  else
233  {
234  sizer->Add( m_symbol_preview, 1, wxEXPAND | wxTOP | wxRIGHT, 5 );
235  }
236 
237  panel->SetSizer( sizer );
238  panel->Layout();
239  sizer->Fit( panel );
240 
241  return panel;
242 }
243 
244 
245 void DIALOG_CHOOSE_COMPONENT::OnInitDialog( wxInitDialogEvent& aEvent )
246 {
248  {
249  // This hides the GAL panel and shows the status label
250  m_fp_preview->SetStatusText( wxEmptyString );
251  }
252 
253  if( m_fp_sel_ctrl )
254  m_fp_sel_ctrl->Load( Kiway(), Prj() );
255 }
256 
257 
259 {
260  return m_tree->GetSelectedLibId( aUnit );
261 }
262 
263 
264 void DIALOG_CHOOSE_COMPONENT::OnUseBrowser( wxCommandEvent& aEvent )
265 {
267  EndQuasiModal( wxID_OK );
268 }
269 
270 
271 void DIALOG_CHOOSE_COMPONENT::OnCloseTimer( wxTimerEvent& aEvent )
272 {
273  // Hack handler because of eaten MouseUp event. See
274  // DIALOG_CHOOSE_COMPONENT::OnComponentSelected for the beginning
275  // of this spaghetti noodle.
276 
277  auto state = wxGetMouseState();
278 
279  if( state.LeftIsDown() )
280  {
281  // Mouse hasn't been raised yet, so fire the timer again. Otherwise the
282  // purpose of this timer is defeated.
284  }
285  else
286  {
287  EndQuasiModal( wxID_OK );
288  }
289 }
290 
291 
293 {
295  return;
296 
297  LIB_ALIAS* alias = nullptr;
298 
299  try
300  {
301  alias = Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
302  }
303  catch( const IO_ERROR& ioe )
304  {
305  wxLogError( wxString::Format( _( "Error occurred loading symbol %s from library %s."
306  "\n\n%s" ),
307  aLibId.GetLibItemName().wx_str(),
308  aLibId.GetLibNickname().wx_str(),
309  ioe.What() ) );
310  }
311 
312  if( !alias )
313  return;
314 
315  LIB_FIELD* fp_field = alias->GetPart()->GetField( FOOTPRINT );
316  wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
317 
318  ShowFootprint( fp_name );
319 }
320 
321 
322 void DIALOG_CHOOSE_COMPONENT::ShowFootprint( wxString const& aName )
323 {
325  return;
326 
327  if( aName == wxEmptyString )
328  {
329  m_fp_preview->SetStatusText( _( "No footprint specified" ) );
330  }
331  else
332  {
333  LIB_ID lib_id;
334 
335  if( lib_id.Parse( aName, LIB_ID::ID_PCB ) == -1 && lib_id.IsValid() )
336  {
338  m_fp_preview->CacheFootprint( lib_id );
339  m_fp_preview->DisplayFootprint( lib_id );
340  }
341  else
342  {
343  m_fp_preview->SetStatusText( _( "Invalid footprint specified" ) );
344  }
345  }
346 }
347 
348 
350 {
351  if( !m_fp_sel_ctrl )
352  return;
353 
355 
356  LIB_ALIAS* alias = nullptr;
357 
358  if( aLibId.IsValid() )
359  {
360  try
361  {
362  alias = Prj().SchSymbolLibTable()->LoadSymbol( aLibId );
363  }
364  catch( const IO_ERROR& ioe )
365  {
366  wxLogError( wxString::Format( _( "Error occurred loading symbol %s from library %s."
367  "\n\n%s" ),
368  aLibId.GetLibItemName().wx_str(),
369  aLibId.GetLibNickname().wx_str(),
370  ioe.What() ) );
371  }
372  }
373 
374  if( alias != nullptr )
375  {
376  LIB_PINS temp_pins;
377  LIB_FIELD* fp_field = alias->GetPart()->GetField( FOOTPRINT );
378  wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
379 
380  alias->GetPart()->GetPins( temp_pins );
381 
382  m_fp_sel_ctrl->FilterByPinCount( temp_pins.size() );
387  }
388  else
389  {
391  m_fp_sel_ctrl->Disable();
392  }
393 }
394 
395 
397 {
398  int unit = 0;
399  LIB_ID id = m_tree->GetSelectedLibId( &unit );
400 
401  if( !id.IsValid() )
402  {
403  // No symbol to show, display a tooltip
404  RenderPreview( nullptr, unit );
405  return;
406  }
407 
408  LIB_ALIAS* alias = nullptr;
409 
410  try
411  {
412  alias = Prj().SchSymbolLibTable()->LoadSymbol( id );
413  }
414  catch( const IO_ERROR& ioe )
415  {
416  wxLogError( wxString::Format( _( "Error occurred loading symbol %s from library %s."
417  "\n\n%s" ),
418  id.GetLibItemName().wx_str(),
419  id.GetLibNickname().wx_str(),
420  ioe.What() ) );
421  }
422 
423  if( !alias )
424  return;
425 
426  LIB_PART* part = alias->GetPart();
427 
428  // Don't draw if we don't have a part to show, just display a tooltip
429  if( !part )
430  {
431  RenderPreview( nullptr, unit );
432  return;
433  }
434 
435  if( alias->IsRoot() )
436  {
437  // just show the part directly
438  RenderPreview( part, unit );
439  }
440  else
441  {
442  // switch out the name temporarily for the alias name
443  wxString tmp( part->GetName() );
444  part->SetName( alias->GetName() );
445 
446  RenderPreview( part, unit );
447 
448  part->SetName( tmp );
449  }
450 }
451 
452 
453 void DIALOG_CHOOSE_COMPONENT::OnFootprintSelected( wxCommandEvent& aEvent )
454 {
455  m_fp_override = aEvent.GetString();
456 
457  m_field_edits.erase(
458  std::remove_if( m_field_edits.begin(), m_field_edits.end(),
459  []( std::pair<int, wxString> const& i ) { return i.first == FOOTPRINT; } ),
460  m_field_edits.end() );
461 
462  m_field_edits.push_back( std::make_pair( FOOTPRINT, m_fp_override ) );
463 
465 }
466 
467 
469 {
470  int unit = 0;
471 
472  LIB_ID id = m_tree->GetSelectedLibId( &unit );
473 
474  m_symbol_preview->Refresh();
475 
476  if( id.IsValid() )
477  {
478  ShowFootprintFor( id );
480  }
481  else
482  {
484  m_fp_preview->SetStatusText( wxEmptyString );
485 
487  }
488 }
489 
490 
491 void DIALOG_CHOOSE_COMPONENT::OnComponentSelected( wxCommandEvent& aEvent )
492 {
493  if( m_tree->GetSelectedLibId().IsValid() )
494  {
495  // Got a selection. We can't just end the modal dialog here, because
496  // wx leaks some events back to the parent window (in particular, the
497  // MouseUp following a double click).
498  //
499  // NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp.
500  // This isn't really feasible to bypass without a fully custom
501  // wxDataViewCtrl implementation, and even then might not be fully
502  // possible (docs are vague). To get around this, we use a one-shot
503  // timer to schedule the dialog close.
504  //
505  // See DIALOG_CHOOSE_COMPONENT::OnCloseTimer for the other end of this
506  // spaghetti noodle.
508  }
509 }
510 
511 
512 void DIALOG_CHOOSE_COMPONENT::RenderPreview( LIB_PART* aComponent, int aUnit )
513 {
514  wxPaintDC dc( m_symbol_preview );
515 
516  const wxSize dc_size = dc.GetSize();
517 
518  // Avoid rendering when either dimension is zero
519  if( dc_size.x == 0 || dc_size.y == 0 )
520  return;
521 
522  GRResetPenAndBrush( &dc );
523 
524  COLOR4D bgColor = m_parent->GetDrawBgColor();
525 
526  dc.SetBackground( wxBrush( bgColor.ToColour() ) );
527  dc.Clear();
528 
529  if( !aComponent ) // display a tooltip
530  {
531  wxString tooltip = _( "No symbol selected" );
532  GRDrawWrappedText( dc, tooltip );
533  return;
534  }
535 
536  int unit = aUnit > 0 ? aUnit : 1;
537  int convert = m_deMorganConvert > 0 ? m_deMorganConvert : 1;
538 
539  dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
540 
541  // Find joint bounding box for everything we are about to draw.
542  EDA_RECT bBox = aComponent->GetUnitBoundingBox( unit, convert );
543  const double xscale = (double) dc_size.x / bBox.GetWidth();
544  const double yscale = (double) dc_size.y / bBox.GetHeight();
545  const double scale = std::min( xscale, yscale ) * 0.85;
546 
547  dc.SetUserScale( scale, scale );
548 
549  wxPoint offset = -bBox.Centre();
550 
551  auto opts = PART_DRAW_OPTIONS::Default();
552  opts.draw_hidden_fields = false;
553  aComponent->Draw( nullptr, &dc, offset, unit, convert, opts );
554 }
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
bool IsValid() const
Definition: lib_id.h:171
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:218
LIB_FIELD * GetField(int aId)
Return pointer to the requested field.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDc, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Draw part.
const EDA_RECT GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
Part library alias object definition.
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
void FilterByFootprintFilters(wxArrayString const &aFilters, bool aZeroFilters)
Filter by footprint filter list.
std::vector< std::pair< int, wxString > > m_field_edits
void PopulateFootprintSelector(LIB_ID const &aLibId)
Populate the footprint selector for a given alias.
void GRDrawWrappedText(wxDC &aDC, wxString const &aText)
Draw text centered on a wxDC with wrapping.
Definition: gr_basic.cpp:1302
void OnFootprintSelected(wxCommandEvent &aEvent)
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetDefaultFootprint(wxString const &aFp)
Set the default footprint for a part.
void ShowFootprint(wxString const &aFootprint)
Display the given footprint by name.
int GetHeight() const
Definition: eda_rect.h:118
void OnSymbolPreviewPaint(wxPaintEvent &aEvent)
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:53
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:356
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:86
Field Name Module PCB, i.e. "16DIP300".
void OnComponentPreselected(wxCommandEvent &aEvent)
void ClearFilters()
Clear all filters.
bool UpdateList()
Update the contents of the list to match the filters.
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
bool IsRoot() const override
For symbols having aliases, IsRoot() indicates the principal item.
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
wxString wx_str() const
Definition: utf8.cpp:48
DIALOG_CHOOSE_COMPONENT(SCH_BASE_FRAME *aParent, const wxString &aTitle, SYMBOL_TREE_MODEL_ADAPTER::PTR &aAdapter, int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints, bool aAllowBrowser)
Create dialog to choose component.
void OnInitDialog(wxInitDialogEvent &aEvent)
void ClearStatus()
Clear the contents of the status label and hide it.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit components, if the user selects the component itself rather than picking an individual...
Definition: lib_tree.cpp:144
void SetSizeInDU(int x, int y)
Set the dialog to the given dimensions in "dialog units".
Define a library symbol object.
void OnCloseTimer(wxTimerEvent &aEvent)
virtual bool Enable(bool aEnable=true) override
Enable or disable the control for input.
wxPanel * ConstructRightPanel(wxWindow *aParent)
Definition: hash_eda.h:46
wxPoint Centre() const
Definition: eda_rect.h:60
static PART_DRAW_OPTIONS Default()
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
COLOR4D GetDrawBgColor() const override
void OnUseBrowser(wxCommandEvent &aEvent)
wxArrayString & GetFootprints()
int VertPixelsFromDU(int y)
Convert an integer number of dialog units to pixels, vertically.
LIB_PART * GetPart() const
Get the shared LIB_PART.
void EndQuasiModal(int retCode)
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:60
const int scale
void CacheFootprint(const LIB_ID &aFPID)
Preload a footprint into the cache.
const wxString & GetName() const override
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
bool IsInitialized() const
Return whether the widget initialized properly.
void DisplayFootprint(const LIB_ID &aFPID)
Set the currently displayed footprint.
static constexpr int DblClickDelay
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
int GetWidth() const
Definition: eda_rect.h:117
const wxString & GetName() const
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
virtual void SetName(const wxString &aName)
void Load(KIWAY &aKiway, PROJECT &aProject)
Start loading.
int HorizPixelsFromDU(int x)
Convert an integer number of dialog units to pixels, horizontally.
void ShowFootprintFor(LIB_ID const &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > PTR
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE.
Definition for part library class.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
int Parse(const UTF8 &aId, LIB_ID_TYPE aType, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.
void OnComponentSelected(wxCommandEvent &aEvent)
Handle the selection of an item.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
void FilterByPinCount(int aPinCount)
Filter by pin count.
#define min(a, b)
Definition: auxiliary.h:85
Widget displaying a tree of components with optional search text control and description panel...
Definition: lib_tree.h:42
void RenderPreview(LIB_PART *aComponent, int aUnit)
Display a given symbol into the schematic symbol preview.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39