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) 2017 Chris Pavlina <pavlina.chris@gmail.com>
6  * Copyright (C) 2016-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
27 
28 #include <algorithm>
29 #include <set>
30 #include <wx/tokenzr.h>
31 #include <wx/utils.h>
32 
33 #include <wx/artprov.h>
34 #include <wx/bitmap.h>
35 #include <wx/button.h>
36 #include <wx/choice.h>
37 #include <wx/dataview.h>
38 #include <wx/html/htmlwin.h>
39 #include <wx/panel.h>
40 #include <wx/sizer.h>
41 #include <wx/splitter.h>
42 #include <wx/statbmp.h>
43 #include <wx/textctrl.h>
44 #include <wx/timer.h>
45 #include <wx/utils.h>
46 
47 #include <class_library.h>
48 #include <generate_alias_info.h>
49 #include <sch_base_frame.h>
50 #include <template_fieldnames.h>
53 
54 // Tree navigation helpers.
55 static wxDataViewItem GetPrevItem( const wxDataViewCtrl& ctrl, const wxDataViewItem& item );
56 static wxDataViewItem GetNextItem( const wxDataViewCtrl& ctrl, const wxDataViewItem& item );
57 static wxDataViewItem GetPrevSibling( const wxDataViewCtrl& ctrl, const wxDataViewItem& item );
58 static wxDataViewItem GetNextSibling( const wxDataViewCtrl& ctrl, const wxDataViewItem& item );
59 
61 std::unique_ptr<FOOTPRINT_LIST> DIALOG_CHOOSE_COMPONENT::m_fp_list;
62 
64  CMP_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert, bool aAllowFieldEdits )
65  : DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxSize( 800, 650 ),
66  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
67  m_parent( aParent ),
68  m_adapter( aAdapter ),
69  m_deMorganConvert( aDeMorganConvert >= 0 ? aDeMorganConvert : 0 ),
70  m_allow_field_edits( aAllowFieldEdits ),
71  m_external_browser_requested( false )
72 {
73  wxBusyCursor busy_while_loading;
74 
75  auto sizer = new wxBoxSizer( wxVERTICAL );
76 
77  auto splitter = new wxSplitterWindow(
78  this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE );
79  auto left_panel = ConstructLeftPanel( splitter );
80  auto right_panel = ConstructRightPanel( splitter );
81  auto buttons = new wxStdDialogButtonSizer();
82  m_dbl_click_timer = new wxTimer( this );
83 
84  splitter->SetSashGravity( 0.9 );
85  splitter->SetMinimumPaneSize( 1 );
86  splitter->SplitVertically( left_panel, right_panel, -300 );
87 
88  buttons->AddButton( new wxButton( this, wxID_OK ) );
89  buttons->AddButton( new wxButton( this, wxID_CANCEL ) );
90  buttons->Realize();
91 
92  sizer->Add( splitter, 1, wxEXPAND | wxALL, 5 );
93  sizer->Add( buttons, 0, wxEXPAND | wxBOTTOM, 10 );
94  SetSizer( sizer );
95 
96  Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this );
97  Bind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this, m_dbl_click_timer->GetId() );
98 
99  m_query_ctrl->Bind( wxEVT_TEXT, &DIALOG_CHOOSE_COMPONENT::OnQueryText, this );
100  m_query_ctrl->Bind( wxEVT_TEXT_ENTER, &DIALOG_CHOOSE_COMPONENT::OnQueryEnter, this );
101  m_query_ctrl->Bind( wxEVT_CHAR_HOOK, &DIALOG_CHOOSE_COMPONENT::OnQueryCharHook, this );
102  m_tree_ctrl->Bind(
103  wxEVT_DATAVIEW_ITEM_ACTIVATED, &DIALOG_CHOOSE_COMPONENT::OnTreeActivate, this );
104  m_tree_ctrl->Bind(
105  wxEVT_DATAVIEW_SELECTION_CHANGED, &DIALOG_CHOOSE_COMPONENT::OnTreeSelect, this );
106  m_details_ctrl->Bind( wxEVT_HTML_LINK_CLICKED, &DIALOG_CHOOSE_COMPONENT::OnDetailsLink, this );
107  m_sch_view_ctrl->Bind( wxEVT_LEFT_DCLICK, &DIALOG_CHOOSE_COMPONENT::OnSchViewDClick, this );
108  m_sch_view_ctrl->Bind( wxEVT_PAINT, &DIALOG_CHOOSE_COMPONENT::OnSchViewPaint, this );
109 
110  if( m_fp_sel_ctrl )
111  m_fp_sel_ctrl->Bind(
112  EVT_FOOTPRINT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnFootprintSelected, this );
113 
114  Layout();
115 }
116 
117 
119 {
120  // I am not sure the following two lines are necessary,
121  // but they will not hurt anyone
122  m_dbl_click_timer->Stop();
123  Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_COMPONENT::OnCloseTimer, this );
124 
125  delete m_dbl_click_timer;
126 }
127 
128 
129 wxPanel* DIALOG_CHOOSE_COMPONENT::ConstructLeftPanel( wxWindow* aParent )
130 {
131  auto panel = new wxPanel( aParent );
132  auto sizer = new wxBoxSizer( wxVERTICAL );
133  auto search_sizer = new wxBoxSizer( wxHORIZONTAL );
134 
135  m_query_ctrl = new wxTextCtrl(
136  panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
137 
138  m_tree_ctrl =
139  new wxDataViewCtrl( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_SINGLE );
140  m_adapter->AttachTo( m_tree_ctrl );
141 
142  m_details_ctrl = new wxHtmlWindow( panel, wxID_ANY, wxDefaultPosition, wxSize( 320, 240 ),
143  wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
144 
145 // Additional visual cue for GTK, which hides the placeholder text on focus
146 #ifdef __WXGTK__
147  search_sizer->Add( new wxStaticBitmap( panel, wxID_ANY,
148  wxArtProvider::GetBitmap( wxART_FIND, wxART_FRAME_ICON ) ),
149  0, wxALIGN_CENTER | wxALL, 5 );
150 #endif
151 
152  search_sizer->Add( m_query_ctrl, 1, wxALIGN_CENTER | wxALL | wxEXPAND, 5 );
153 
154  sizer->Add( search_sizer, 0, wxEXPAND, 5 );
155  sizer->Add( m_tree_ctrl, 1, wxALL | wxEXPAND, 5 );
156  sizer->Add( m_details_ctrl, 1, wxALL | wxEXPAND, 5 );
157 
158  panel->SetSizer( sizer );
159  panel->Layout();
160  sizer->Fit( panel );
161  return panel;
162 }
163 
164 
165 wxPanel* DIALOG_CHOOSE_COMPONENT::ConstructRightPanel( wxWindow* aParent )
166 {
167  auto panel = new wxPanel( aParent );
168  auto sizer = new wxBoxSizer( wxVERTICAL );
169 
170  m_sch_view_ctrl = new wxPanel( panel, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
171  wxFULL_REPAINT_ON_RESIZE | wxSUNKEN_BORDER | wxTAB_TRAVERSAL );
172  m_sch_view_ctrl->SetLayoutDirection( wxLayout_LeftToRight );
173 
174  if( m_allow_field_edits )
176  else
177  m_fp_sel_ctrl = nullptr;
178 
180 
181 
182  sizer->Add( m_sch_view_ctrl, 1, wxEXPAND | wxALL, 5 );
183 
184  if( m_fp_sel_ctrl )
185  sizer->Add( m_fp_sel_ctrl, 0, wxEXPAND | wxALL, 5 );
186 
187  sizer->Add( m_fp_view_ctrl, 1, wxEXPAND | wxALL, 5 );
188 
189 
190  panel->SetSizer( sizer );
191  panel->Layout();
192  sizer->Fit( panel );
193 
194  return panel;
195 }
196 
197 
198 void DIALOG_CHOOSE_COMPONENT::OnInitDialog( wxInitDialogEvent& aEvent )
199 {
200  // If wxTextCtrl::SetHint() is called before binding wxEVT_TEXT, the event
201  // handler will intermittently fire.
202  m_query_ctrl->SetHint( _( "Search" ) );
203  m_query_ctrl->SetFocus();
204  m_query_ctrl->SetValue( wxEmptyString );
205 
207  {
208  // This hides the GAL panel and shows the status label
209  m_fp_view_ctrl->SetStatusText( wxEmptyString );
210  }
211 
212  if( m_fp_sel_ctrl )
213  m_fp_sel_ctrl->Load( Kiway(), Prj() );
214 
215  // There may be a part preselected in the model. Make sure it is displayed.
216  PostSelectEvent();
217 }
218 
219 
221 {
222  auto sel = m_tree_ctrl->GetSelection();
223 
224  if( aUnit )
225  *aUnit = m_adapter->GetUnitFor( sel );
226 
227  return m_adapter->GetAliasFor( sel );
228 }
229 
230 
231 std::vector<std::pair<int, wxString>> DIALOG_CHOOSE_COMPONENT::GetFields() const
232 {
233  return m_field_edits;
234 }
235 
236 
237 void DIALOG_CHOOSE_COMPONENT::OnQueryText( wxCommandEvent& aEvent )
238 {
239  m_adapter->UpdateSearchString( m_query_ctrl->GetLineText( 0 ) );
240  PostSelectEvent();
241 
242  // Required to avoid interaction with SetHint()
243  // See documentation for wxTextEntry::SetHint
244  aEvent.Skip();
245 }
246 
247 
248 void DIALOG_CHOOSE_COMPONENT::OnQueryEnter( wxCommandEvent& aEvent )
249 {
251 }
252 
253 
254 void DIALOG_CHOOSE_COMPONENT::SelectIfValid( const wxDataViewItem& aTreeId )
255 {
256  if( aTreeId.IsOk() )
257  {
258  m_tree_ctrl->EnsureVisible( aTreeId );
259  m_tree_ctrl->Select( aTreeId );
260  PostSelectEvent();
261  }
262 }
263 
264 
266 {
267  wxDataViewEvent evt( wxEVT_DATAVIEW_SELECTION_CHANGED );
268  m_tree_ctrl->GetEventHandler()->ProcessEvent( evt );
269 }
270 
271 
272 void DIALOG_CHOOSE_COMPONENT::OnQueryCharHook( wxKeyEvent& aKeyStroke )
273 {
274  auto const sel = m_tree_ctrl->GetSelection();
275 
276  switch( aKeyStroke.GetKeyCode() )
277  {
278  case WXK_UP: SelectIfValid( GetPrevItem( *m_tree_ctrl, sel ) ); break;
279 
280  case WXK_DOWN: SelectIfValid( GetNextItem( *m_tree_ctrl, sel ) ); break;
281 
282  default:
283  aKeyStroke.Skip(); // Any other key: pass on to search box directly.
284  break;
285  }
286 }
287 
288 
289 void DIALOG_CHOOSE_COMPONENT::OnTreeSelect( wxDataViewEvent& aEvent )
290 {
291  auto sel = m_tree_ctrl->GetSelection();
292  int unit = m_adapter->GetUnitFor( sel );
293  LIB_ALIAS* alias = m_adapter->GetAliasFor( sel );
294 
295  m_sch_view_ctrl->Refresh();
296 
297  if( alias )
298  {
299  m_details_ctrl->SetPage( GenerateAliasInfo( alias, unit ) );
300  ShowFootprintFor( alias );
301  PopulateFootprintSelector( alias );
302  }
303  else
304  {
305  m_details_ctrl->SetPage( wxEmptyString );
306 
308  m_fp_view_ctrl->SetStatusText( wxEmptyString );
309 
310  PopulateFootprintSelector( nullptr );
311  }
312 }
313 
314 
315 void DIALOG_CHOOSE_COMPONENT::OnTreeActivate( wxDataViewEvent& aEvent )
316 {
318 }
319 
320 
321 void DIALOG_CHOOSE_COMPONENT::OnCloseTimer( wxTimerEvent& aEvent )
322 {
323  // Hack handler because of eaten MouseUp event. See
324  // DIALOG_CHOOSE_COMPONENT::OnDoubleClickTreeActivation for the beginning
325  // of this spaghetti noodle.
326 
327  auto state = wxGetMouseState();
328 
329  if( state.LeftIsDown() )
330  {
331  // Mouse hasn't been raised yet, so fire the timer again. Otherwise the
332  // purpose of this timer is defeated.
334  }
335  else
336  {
337  EndQuasiModal( wxID_OK );
338  }
339 }
340 
341 
342 void DIALOG_CHOOSE_COMPONENT::OnSchViewDClick( wxMouseEvent& aEvent )
343 {
345  EndQuasiModal( wxID_OK );
346 }
347 
348 
350 {
351  if( !m_fp_view_ctrl->IsInitialized() )
352  return;
353 
354  LIB_FIELD* fp_field = aAlias->GetPart()->GetField( FOOTPRINT );
355  wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
356 
357  ShowFootprint( fp_name );
358 }
359 
360 
361 void DIALOG_CHOOSE_COMPONENT::ShowFootprint( wxString const& aName )
362 {
363  if( aName == wxEmptyString )
364  {
365  m_fp_view_ctrl->SetStatusText( _( "No footprint specified" ) );
366  }
367  else
368  {
369  LIB_ID lib_id( aName );
370 
372  m_fp_view_ctrl->CacheFootprint( lib_id );
373  m_fp_view_ctrl->DisplayFootprint( lib_id );
374  }
375 }
376 
377 
379 {
380  if( !m_fp_sel_ctrl )
381  return;
382 
384 
385  if( aAlias )
386  {
387  LIB_PINS temp_pins;
388  LIB_FIELD* fp_field = aAlias->GetPart()->GetField( FOOTPRINT );
389  wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
390 
391  aAlias->GetPart()->GetPins( temp_pins );
392 
393  m_fp_sel_ctrl->FilterByPinCount( temp_pins.size() );
398  }
399  else
400  {
402  m_fp_sel_ctrl->Disable();
403  }
404 }
405 
406 
407 void DIALOG_CHOOSE_COMPONENT::OnDetailsLink( wxHtmlLinkEvent& aEvent )
408 {
409  const wxHtmlLinkInfo& info = aEvent.GetLinkInfo();
410  ::wxLaunchDefaultBrowser( info.GetHref() );
411 }
412 
413 
414 void DIALOG_CHOOSE_COMPONENT::OnSchViewPaint( wxPaintEvent& aEvent )
415 {
416  auto sel = m_tree_ctrl->GetSelection();
417 
418  int unit = m_adapter->GetUnitFor( sel );
419  LIB_ALIAS* alias = m_adapter->GetAliasFor( sel );
420  LIB_PART* part = alias ? alias->GetPart() : nullptr;
421 
422  // Don't draw anything (not even the background) if we don't have
423  // a part to show
424  if( !part )
425  return;
426 
427  if( alias->IsRoot() )
428  {
429  // just show the part directly
430  RenderPreview( part, unit );
431  }
432  else
433  {
434  // switch out the name temporarily for the alias name
435  wxString tmp( part->GetName() );
436  part->SetName( alias->GetName() );
437 
438  RenderPreview( part, unit );
439 
440  part->SetName( tmp );
441  }
442 }
443 
444 
445 void DIALOG_CHOOSE_COMPONENT::OnFootprintSelected( wxCommandEvent& aEvent )
446 {
447  m_fp_override = aEvent.GetString();
448 
449  m_field_edits.erase(
450  std::remove_if( m_field_edits.begin(), m_field_edits.end(),
451  []( std::pair<int, wxString> const& i ) { return i.first == FOOTPRINT; } ),
452  m_field_edits.end() );
453 
454  m_field_edits.push_back( std::make_pair( FOOTPRINT, m_fp_override ) );
455 
457 }
458 
459 
460 void DIALOG_CHOOSE_COMPONENT::RenderPreview( LIB_PART* aComponent, int aUnit )
461 {
462  wxPaintDC dc( m_sch_view_ctrl );
463 
464  const wxSize dc_size = dc.GetSize();
465 
466  // Avoid rendering when either dimension is zero
467  if( dc_size.x == 0 || dc_size.y == 0 )
468  return;
469 
470  GRResetPenAndBrush( &dc );
471 
472  COLOR4D bgColor = m_parent->GetDrawBgColor();
473 
474  dc.SetBackground( wxBrush( bgColor.ToColour() ) );
475  dc.Clear();
476 
477  if( !aComponent )
478  return;
479 
480  if( aUnit <= 0 )
481  aUnit = 1;
482 
483  dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
484 
485  // Find joint bounding box for everything we are about to draw.
486  EDA_RECT bBox = aComponent->GetUnitBoundingBox( aUnit, m_deMorganConvert );
487  const double xscale = (double) dc_size.x / bBox.GetWidth();
488  const double yscale = (double) dc_size.y / bBox.GetHeight();
489  const double scale = std::min( xscale, yscale ) * 0.85;
490 
491  dc.SetUserScale( scale, scale );
492 
493  wxPoint offset = -bBox.Centre();
494 
495  auto opts = PART_DRAW_OPTIONS::Default();
496  opts.draw_hidden_fields = false;
497  aComponent->Draw( nullptr, &dc, offset, aUnit, m_deMorganConvert, opts );
498 }
499 
500 
502 {
503  if( m_adapter->GetAliasFor( m_tree_ctrl->GetSelection() ) )
504  {
505  // Got a selection. We can't just end the modal dialog here, because
506  // wx leaks some events back to the parent window (in particular, the
507  // MouseUp following a double click).
508  //
509  // NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp.
510  // This isn't really feasible to bypass without a fully custom
511  // wxDataViewCtrl implementation, and even then might not be fully
512  // possible (docs are vague). To get around this, we use a one-shot
513  // timer to schedule the dialog close.
514  //
515  // See DIALOG_CHOOSE_COMPONENT::OnCloseTimer for the other end of this
516  // spaghetti noodle.
518  }
519  else
520  {
521  auto const sel = m_tree_ctrl->GetSelection();
522 
523  if( m_tree_ctrl->IsExpanded( sel ) )
524  m_tree_ctrl->Collapse( sel );
525  else
526  m_tree_ctrl->Expand( sel );
527  }
528 }
529 
530 
531 static wxDataViewItem GetPrevItem( const wxDataViewCtrl& tree, const wxDataViewItem& item )
532 {
533  auto prevItem = GetPrevSibling( tree, item );
534 
535  if( !prevItem.IsOk() )
536  {
537  prevItem = tree.GetModel()->GetParent( item );
538  }
539  else if( tree.IsExpanded( prevItem ) )
540  {
541  wxDataViewItemArray children;
542  tree.GetModel()->GetChildren( prevItem, children );
543  prevItem = children[children.size() - 1];
544  }
545 
546  return prevItem;
547 }
548 
549 
550 static wxDataViewItem GetNextItem( const wxDataViewCtrl& tree, const wxDataViewItem& item )
551 {
552  wxDataViewItem nextItem;
553 
554  if( !item.IsOk() )
555  {
556  // No selection. Select the first.
557  wxDataViewItemArray children;
558  tree.GetModel()->GetChildren( item, children );
559  return children[0];
560  }
561 
562  if( tree.IsExpanded( item ) )
563  {
564  wxDataViewItemArray children;
565  tree.GetModel()->GetChildren( item, children );
566  nextItem = children[0];
567  }
568  else
569  {
570  // Walk up levels until we find one that has a next sibling.
571  for( wxDataViewItem walk = item; walk.IsOk(); walk = tree.GetModel()->GetParent( walk ) )
572  {
573  nextItem = GetNextSibling( tree, walk );
574 
575  if( nextItem.IsOk() )
576  break;
577  }
578  }
579 
580  return nextItem;
581 }
582 
583 
584 static wxDataViewItem GetPrevSibling( const wxDataViewCtrl& tree, const wxDataViewItem& item )
585 {
586  wxDataViewItemArray siblings;
587  wxDataViewItem invalid;
588  wxDataViewItem parent = tree.GetModel()->GetParent( item );
589 
590  tree.GetModel()->GetChildren( parent, siblings );
591 
592  for( size_t i = 0; i < siblings.size(); ++i )
593  {
594  if( siblings[i] == item )
595  {
596  if( i == 0 )
597  return invalid;
598  else
599  return siblings[i - 1];
600  }
601  }
602 
603  return invalid;
604 }
605 
606 
607 static wxDataViewItem GetNextSibling( const wxDataViewCtrl& tree, const wxDataViewItem& item )
608 {
609  wxDataViewItemArray siblings;
610  wxDataViewItem invalid;
611  wxDataViewItem parent = tree.GetModel()->GetParent( item );
612 
613  tree.GetModel()->GetChildren( parent, siblings );
614 
615  for( size_t i = 0; i < siblings.size(); ++i )
616  {
617  if( siblings[i] == item )
618  {
619  if( i == siblings.size() - 1 )
620  return invalid;
621  else
622  return siblings[i + 1];
623  }
624  }
625 
626  return invalid;
627 }
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
void OnTreeSelect(wxDataViewEvent &aEvent)
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:196
LIB_FIELD * GetField(int aId)
Return pointer to the requested field.
void OnQueryText(wxCommandEvent &aEvent)
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
Function GetBoundingBox.
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
static wxDataViewItem GetPrevSibling(const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
void OnTreeActivate(wxDataViewEvent &aEvent)
void OnFootprintSelected(wxCommandEvent &aEvent)
static wxDataViewItem GetPrevItem(const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
static wxDataViewItem GetNextItem(const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
Class LIB_FIELD is used in symbol libraries.
Definition: lib_field.h:60
void SetDefaultFootprint(wxString const &aFp)
Set the default footprint for a part.
int GetHeight() const
void OnQueryCharHook(wxKeyEvent &aEvent)
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
This class can be used to populate a FOOTPRINT_LIST asynchronously.
wxObjectDataPtr< CMP_TREE_MODEL_ADAPTER > PTR
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER.
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:60
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:533
static FOOTPRINT_ASYNC_LOADER m_fp_loader
Class LIB_ID.
Definition: lib_id.h:56
Field Name Module PCB, i.e. "16DIP300".
void ClearFilters()
Clear all filters.
DIALOG_CHOOSE_COMPONENT(SCH_BASE_FRAME *aParent, const wxString &aTitle, CMP_TREE_MODEL_ADAPTER::PTR &aAdapter, int aDeMorganConvert, bool aAllowFieldEdits)
Create dialog to choose component.
void OnQueryEnter(wxCommandEvent &aEvent)
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
void PostSelectEvent()
Post a wxEVT_DATAVIEW_SELECTION_CHANGED to notify the selection handler that a new part has been sele...
void OnInitDialog(wxInitDialogEvent &aEvent)
void ShowFootprint(wxString const &aName)
Display the given footprint by name.
void ClearStatus()
Clear the contents of the status label and hide it.
const wxString & GetName() const
CMP_TREE_MODEL_ADAPTER::PTR m_adapter
wxString GenerateAliasInfo(LIB_ALIAS const *aAlias, int aUnit)
Return an HTML page describing a LIB_ALIAS.
void SelectIfValid(const wxDataViewItem &aTreeId)
If a wxDataViewitem is valid, select it and post a selection event.
Class LIB_PART defines a library part object.
static std::unique_ptr< FOOTPRINT_LIST > m_fp_list
void OnCloseTimer(wxTimerEvent &aEvent)
virtual bool Enable(bool aEnable=true) override
Enable or disable the control for input.
wxPanel * ConstructRightPanel(wxWindow *aParent)
LIB_ALIAS * GetSelectedAlias(int *aUnit) const
Function GetSelectedAlias To be called after this dialog returns from ShowModal().
wxPoint Centre() const
static PART_DRAW_OPTIONS Default()
void SetStatusText(wxString const &aText)
Set the contents of the status label and display it.
COLOR4D GetDrawBgColor() const override
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
void EndQuasiModal(int retCode)
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:70
const int scale
void CacheFootprint(const LIB_ID &aFPID)
Preload a footprint into the cache.
void PopulateFootprintSelector(LIB_ALIAS *aAlias)
Populate the footprint selector for a given alias.
const wxString & GetName() const
bool IsInitialized() const
Return whether the widget initialized properly.
void DisplayFootprint(const LIB_ID &aFPID)
Set the currently displayed footprint.
static constexpr int DblClickDelay
Class EDA_RECT handles the component boundary box.
wxArrayString & GetFootPrints()
void HandleItemSelection()
Handle the selection of an item.
int GetWidth() const
void OnSchViewDClick(wxMouseEvent &aEvent)
virtual void SetName(const wxString &aName)
void Load(KIWAY &aKiway, PROJECT &aProject)
Start loading.
void OnDetailsLink(wxHtmlLinkEvent &aEvent)
FOOTPRINT_PREVIEW_WIDGET * m_fp_view_ctrl
Definition for part library class.
BITMAP_DEF GetBitmap(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:70
void OnSchViewPaint(wxPaintEvent &aEvent)
wxPanel * ConstructLeftPanel(wxWindow *aParent)
Class SCH_BASE_FRAME is a shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRA...
static wxDataViewItem GetNextSibling(const wxDataViewCtrl &ctrl, const wxDataViewItem &item)
void FilterByPinCount(int aPinCount)
Filter by pin count.
void ShowFootprintFor(LIB_ALIAS *aAlias)
Look up the footprint for a given alias and display it.
#define min(a, b)
Definition: auxiliary.h:85
void RenderPreview(LIB_PART *aComponent, int aUnit)
Display a given component into the schematic symbol preview.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39