KiCad PCB EDA Suite
viewlib_frame.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-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 
30 #include <fctsys.h>
31 #include <kiface_i.h>
32 #include <pgm_base.h>
33 #include <class_drawpanel.h>
34 #include <msgpanel.h>
35 #include <bitmaps.h>
36 
37 #include <schframe.h>
38 #include <eeschema_id.h>
39 #include <general.h>
40 #include <viewlib_frame.h>
41 #include <symbol_lib_table.h>
42 #include <sch_legacy_plugin.h>
43 #include <hotkeys.h>
44 #include <dialog_helpers.h>
45 #include <class_libentry.h>
46 #include <class_library.h>
47 
48 
49 // Save previous component library viewer state.
52 
55 
56 
57 BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
58  // Window events
59  EVT_CLOSE( LIB_VIEW_FRAME::OnCloseWindow )
60  EVT_SIZE( LIB_VIEW_FRAME::OnSize )
61  EVT_ACTIVATE( LIB_VIEW_FRAME::OnActivate )
62 
63  // Toolbar events
65  EVT_TOOL( ID_LIBVIEW_NEXT, LIB_VIEW_FRAME::onSelectNextSymbol )
66  EVT_TOOL( ID_LIBVIEW_PREVIOUS, LIB_VIEW_FRAME::onSelectPreviousSymbol )
67  EVT_TOOL( ID_LIBVIEW_VIEWDOC, LIB_VIEW_FRAME::onViewSymbolDocument )
69  LIB_VIEW_FRAME::onSelectSymbolBodyStyle )
70  EVT_TOOL( ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, LIB_VIEW_FRAME::ExportToSchematicLibraryPart )
72 
73  // listbox events
74  EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList )
75  EVT_LISTBOX( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::ClickOnCmpList )
76  EVT_LISTBOX_DCLICK( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::DClickOnCmpList )
77 
78  // Menu (and/or hotkey) events
79  EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
80  EVT_MENU( wxID_EXIT, LIB_VIEW_FRAME::CloseLibraryViewer )
81  EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
82  EVT_MENU( ID_SET_RELATIVE_OFFSET, LIB_VIEW_FRAME::OnSetRelativeOffset )
84 
85  EVT_UPDATE_UI( ID_LIBVIEW_VIEWDOC, LIB_VIEW_FRAME::onUpdateViewDoc )
86  EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton )
87  EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
88  LIB_VIEW_FRAME::onUpdateAlternateBodyStyleButton )
89  EVT_UPDATE_UI( ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, LIB_VIEW_FRAME::OnUpdateElectricalType )
90 
91 END_EVENT_TABLE()
92 
93 
94 /* Note:
95  * LIB_VIEW_FRAME can be created in "modal mode", or as a usual frame.
96  * In modal mode:
97  * a tool to export the selected symbol is shown in the toolbar
98  * the style is wxFRAME_FLOAT_ON_PARENT
99  * Note:
100  * On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
101  * its parent frame is sometimes brought to the foreground when closing the
102  * LIB_VIEW_FRAME frame.
103  * If it still happens, it could be better to use wxSTAY_ON_TOP
104  * instead of wxFRAME_FLOAT_ON_PARENT
105  */
106 #ifdef __WINDOWS__
107 #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT // could be wxSTAY_ON_TOP if issues
108 #else
109 #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT
110 #endif
111 
112 #define LIB_VIEW_FRAME_NAME "ViewlibFrame"
113 #define LIB_VIEW_FRAME_NAME_MODAL "ViewlibFrameModal"
114 
115 LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
116  const wxString& aLibraryName ) :
117  SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Library Browser" ),
118  wxDefaultPosition, wxDefaultSize,
119  aFrameType == FRAME_SCH_VIEWER_MODAL ?
121  : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP
123  aFrameType == FRAME_SCH_VIEWER_MODAL ?
125 {
126  wxASSERT( aFrameType == FRAME_SCH_VIEWER ||
127  aFrameType == FRAME_SCH_VIEWER_MODAL );
128 
129  if( aFrameType == FRAME_SCH_VIEWER_MODAL )
130  SetModal( true );
131 
132  // Force the frame name used in config. the lib viewer frame has a name
133  // depending on aFrameType (needed to identify the frame by wxWidgets),
134  // but only one configuration is preferable.
136 
137  // Give an icon
138  wxIcon icon;
139  icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) );
140  SetIcon( icon );
141 
143  m_cmpList = NULL;
144  m_libList = NULL;
145  m_listPowerCmpOnly = false;
146  SetShowElectricalType( true );
147 
148  SetScreen( new SCH_SCREEN( aKiway ) );
149  GetScreen()->m_Center = true; // Axis origin centered on screen.
150  LoadSettings( config() );
151 
152  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
153 
154  // Initialize grid id to the default value (50 mils):
156  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
157 
158  // Menu bar is not mandatory: uncomment/comment the next line
159  // to add/remove the menubar
160  ReCreateMenuBar();
163 
164  if( aLibraryName.empty() )
165  {
166  // Creates the libraries window display
167  m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST,
168  wxPoint( 0, 0 ), wxSize( m_libListWidth, -1 ),
169  0, NULL, wxLB_HSCROLL );
170  }
171  else
172  {
173  m_libraryName = aLibraryName;
174  m_entryName.Clear();
175  m_unit = 1;
176  m_convert = 1;
177  m_libListWidth = 0;
178  }
179 
180  m_selection_changed = false;
181 
182  // Creates the component window display
183  m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxPoint( 0, 0 ),
184  wxSize( m_cmpListWidth, -1 ), 0, NULL, wxLB_HSCROLL );
185 
186  if( m_libList )
187  ReCreateListLib();
188 
189  DisplayLibInfos();
190 
191  m_auimgr.SetManagedWindow( this );
192 
193  EDA_PANEINFO horiz;
194  horiz.HorizontalToolbarPane();
195 
196  EDA_PANEINFO vert;
197  vert.VerticalToolbarPane();
198 
199  EDA_PANEINFO info;
200  info.InfoToolbarPane();
201 
202  EDA_PANEINFO mesg;
203  mesg.MessageToolbarPane();
204 
205 
206  // Manage main toolbar
207  m_auimgr.AddPane( m_mainToolBar,
208  wxAuiPaneInfo( horiz ).Name( "m_mainToolBar" ).Top().Row( 0 ) );
209 
210  // Manage the left window (list of libraries)
211  if( m_libList )
212  m_auimgr.AddPane( m_libList, wxAuiPaneInfo( info ).Name( "m_libList" ).Left().Row( 0 ) );
213 
214  // Manage the list of components)
215  m_auimgr.AddPane( m_cmpList, wxAuiPaneInfo( info ).Name( "m_cmpList" ).Left().Row( 1 ) );
216 
217  // Manage the draw panel
218  m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
219 
220  // Manage the message panel
221  m_auimgr.AddPane( m_messagePanel,
222  wxAuiPaneInfo( mesg ).Name( "MsgPanel" ).Bottom().Layer( 10 ) );
223 
224  /* Now the minimum windows are fixed, set library list
225  * and component list of the previous values from last viewlib use
226  */
227  if( m_libList )
228  {
229  m_auimgr.GetPane( m_libList ).MinSize( wxSize( 80, -1 ) );
230  m_auimgr.GetPane( m_libList ).BestSize( wxSize( m_libListWidth, -1 ) );
231  }
232 
233  m_auimgr.GetPane( m_cmpList ).MinSize( wxSize( 80, -1) );
234  m_auimgr.GetPane( m_cmpList ).BestSize( wxSize( m_cmpListWidth, -1 ) );
235 
236  m_auimgr.Update();
237 
238  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
239 #ifdef USE_WX_GRAPHICS_CONTEXT
240  GetScreen()->SetZoom( BestZoom() );
241 #else
242  Zoom_Automatique( false );
243 #endif
244 
245  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
246  {
247  Raise();
248  Show( true );
249  }
250 }
251 
252 
254 {
255 }
256 
257 
258 void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
259 {
260  m_unit = aUnit > 0 ? aUnit : 1;
261  m_convert = aConvert > 0 ? aConvert : 1;
262  m_selection_changed = false;
263 }
264 
265 
267 {
268  LIB_ALIAS* alias = NULL;
269 
270  if( !m_libraryName.IsEmpty() && !m_entryName.IsEmpty() )
271  {
272  alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
273  }
274 
275  return alias;
276 }
277 
278 
280 {
281  LIB_PART* symbol = NULL;
282  LIB_ALIAS* alias = getSelectedAlias();
283 
284  if( alias )
285  symbol = alias->GetPart();
286 
287  return symbol;
288 }
289 
290 
292 {
293  LIB_PART* symbol = getSelectedSymbol();
294 
295  aEvent.Enable( symbol && symbol->HasConversion() );
296 
297  if( symbol )
298  aEvent.Check( m_convert > 1 );
299  else
300  aEvent.Check( false );
301 }
302 
303 
304 void LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent )
305 {
306  LIB_PART* symbol = getSelectedSymbol();
307 
308  aEvent.Enable( symbol && symbol->HasConversion() );
309 
310  if( symbol )
311  aEvent.Check( m_convert <= 1 );
312  else
313  aEvent.Check( true );
314 }
315 
316 
317 void LIB_VIEW_FRAME::onUpdateViewDoc( wxUpdateUIEvent& aEvent )
318 {
319  LIB_ALIAS* alias = getSelectedAlias();
320 
321  aEvent.Enable( alias && !alias->GetDocFileName().IsEmpty() );
322 }
323 
324 
325 void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
326 {
327  if( !IsModal() )
328  {
329  Destroy();
330  }
331  else if( !IsDismissed() )
332  {
333  // only dismiss modal frame if not already dismissed.
334  DismissModal( false );
335 
336  // Modal frame will be destroyed by the calling function.
337  }
338 }
339 
340 
341 void LIB_VIEW_FRAME::OnSize( wxSizeEvent& SizeEv )
342 {
343  if( m_auimgr.GetManagedWindow() )
344  m_auimgr.Update();
345 
346  SizeEv.Skip();
347 }
348 
349 
350 void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
351 {
353  UpdateStatusBar();
354 }
355 
356 
357 void LIB_VIEW_FRAME::OnShowElectricalType( wxCommandEvent& event )
358 {
360  m_canvas->Refresh();
361 }
362 
363 
364 void LIB_VIEW_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
365 {
366  aEvent.Check( GetShowElectricalType() );
367 }
368 
369 
371 {
372  /* Please, note: wxMSW before version 2.9 seems have
373  * problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
374  * edit file <wxWidgets>/src/msw/dc.cpp
375  * search for line static const int VIEWPORT_EXTENT = 1000;
376  * and replace by static const int VIEWPORT_EXTENT = 10000;
377  */
378 
379  LIB_PART* part = NULL;
380  double bestzoom = 16.0; // default value for bestzoom
381 
382  if( m_libraryName.IsEmpty() || m_entryName.IsEmpty() )
383  {
384  SetScrollCenterPosition( wxPoint( 0, 0 ) );
385  return bestzoom;
386  }
387 
388  LIB_ALIAS* alias = nullptr;
389 
390  try
391  {
392  alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
393  }
394  catch( ... )
395  {
396  }
397 
398  if( alias )
399  part = alias->GetPart();
400 
401  if( !part )
402  {
403  SetScrollCenterPosition( wxPoint( 0, 0 ) );
404  return bestzoom;
405  }
406 
407  wxSize size = m_canvas->GetClientSize();
408 
410 
411  // Reserve a 10% margin around component bounding box.
412  double margin_scale_factor = 0.8;
413  double zx =(double) boundingBox.GetWidth() / ( margin_scale_factor * (double)size.x );
414  double zy = (double) boundingBox.GetHeight() / ( margin_scale_factor * (double)size.y);
415 
416  // Calculates the best zoom
417  bestzoom = std::max( zx, zy );
418 
419  // keep it >= minimal existing zoom (can happen for very small components
420  // like small power symbols
421  if( bestzoom < GetScreen()->m_ZoomList[0] )
422  bestzoom = GetScreen()->m_ZoomList[0];
423 
424  SetScrollCenterPosition( boundingBox.Centre() );
425 
426  return bestzoom;
427 }
428 
429 
431 {
432  if( !m_libList )
433  return false;
434 
435  m_libList->Clear();
436 
437  std::vector< wxString > libs = Prj().SchSymbolLibTable()->GetLogicalLibs();
438 
439  // Remove not allowed libs from main list, if the allowed lib list is not empty
440  if( m_allowedLibs.GetCount() )
441  {
442  for( unsigned ii = 0; ii < libs.size(); )
443  {
444  if( m_allowedLibs.Index( libs[ii] ) == wxNOT_FOUND )
445  libs.erase( libs.begin() + ii );
446  else
447  ii++;
448  }
449  }
450 
451  // Remove libs which have no power components, if this filter is activated
452  if( m_listPowerCmpOnly )
453  {
454  for( unsigned ii = 0; ii < libs.size(); )
455  {
456  wxArrayString aliasNames;
457 
458  Prj().SchSymbolLibTable()->EnumerateSymbolLib( libs[ii], aliasNames, true );
459 
460  if( aliasNames.IsEmpty() )
461  libs.erase( libs.begin() + ii );
462  else
463  ii++;
464  }
465  }
466 
467  if( libs.empty() )
468  return true;
469 
470  wxArrayString libNames;
471 
472  for( auto name : libs )
473  libNames.Add( name );
474 
475  m_libList->Append( libNames );
476 
477  // Search for a previous selection:
478  int index = m_libList->FindString( m_libraryName );
479 
480  if( index != wxNOT_FOUND )
481  {
482  m_libList->SetSelection( index, true );
483  }
484  else
485  {
486  // If not found, clear current library selection because it can be
487  // deleted after a config change.
488  m_libraryName = libs[0];
489  m_entryName = wxEmptyString;
490  m_unit = 1;
491  m_convert = 1;
492  }
493 
494  bool cmp_changed = ReCreateListCmp();
496  DisplayLibInfos();
497  m_canvas->Refresh();
498 
499  return cmp_changed;
500 }
501 
502 
504 {
505  if( m_cmpList == NULL )
506  return false;
507 
508  m_cmpList->Clear();
509 
510  wxArrayString aliasNames;
511 
512  try
513  {
514  Prj().SchSymbolLibTable()->EnumerateSymbolLib( m_libraryName, aliasNames,
516  }
517  catch( const IO_ERROR& e ) {} // ignore, it is handled below
518 
519  if( aliasNames.IsEmpty() )
520  {
521  m_libraryName = wxEmptyString;
522  m_entryName = wxEmptyString;
523  m_convert = 1;
524  m_unit = 1;
525  return true;
526  }
527 
528  m_cmpList->Append( aliasNames );
529 
530  int index = m_cmpList->FindString( m_entryName );
531  bool changed = false;
532 
533  if( index == wxNOT_FOUND )
534  {
535  // Select the first library entry when the previous entry name does not exist in
536  // the current library.
537  m_convert = 1;
538  m_unit = 1;
539  index = 0;
540  changed = true;
541  m_entryName = wxEmptyString;
542  }
543 
544  m_cmpList->SetSelection( index, true );
545 
546  wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST );
547  ProcessEvent( evt );
548 
549  return changed;
550 }
551 
552 
553 void LIB_VIEW_FRAME::ClickOnLibList( wxCommandEvent& event )
554 {
555  int ii = m_libList->GetSelection();
556 
557  if( ii < 0 )
558  return;
559 
560  m_selection_changed = true;
561 
562  SetSelectedLibrary( m_libList->GetString( ii ) );
563 }
564 
565 
566 void LIB_VIEW_FRAME::SetSelectedLibrary( const wxString& aLibraryName )
567 {
568  if( m_libraryName == aLibraryName )
569  return;
570 
571  m_libraryName = aLibraryName;
572  ReCreateListCmp();
573  m_canvas->Refresh();
574  DisplayLibInfos();
576 
577  // Ensure the corresponding line in m_libList is selected
578  // (which is not necessary the case if SetSelectedLibrary is called
579  // by an other caller than ClickOnLibList.
580  m_libList->SetStringSelection( m_libraryName, true );
581 }
582 
583 
584 void LIB_VIEW_FRAME::ClickOnCmpList( wxCommandEvent& event )
585 {
586  int ii = m_cmpList->GetSelection();
587 
588  if( ii < 0 )
589  return;
590 
591  m_selection_changed = true;
592 
593  SetSelectedComponent( m_cmpList->GetString( ii ) );
594 }
595 
596 
597 void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
598 {
599  // Aren't component names case sensitive now?
600  if( m_entryName.CmpNoCase( aComponentName ) != 0 )
601  {
602  m_entryName = aComponentName;
603 
604  // Ensure the corresponding line in m_cmpList is selected
605  // (which is not necessarily the case if SetSelectedComponent is called
606  // by another caller than ClickOnCmpList.
607  m_cmpList->SetStringSelection( aComponentName, true );
608  DisplayLibInfos();
609 
610  if( m_selection_changed )
611  {
612  m_unit = 1;
613  m_convert = 1;
614  m_selection_changed = false;
615  }
616 
617  Zoom_Automatique( false );
619  m_canvas->Refresh();
620  }
621 }
622 
623 
624 void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
625 {
626  if( IsModal() )
627  {
629 
630  // The schematic editor might not be the parent of the library viewer.
631  // It could be a python window.
632  SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
633 
634  if( schframe )
635  {
636  // Prevent the double click from being as a single click in the parent
637  // window which would cause the part to be parked rather than staying
638  // in drag mode.
639  schframe->SkipNextLeftButtonReleaseEvent();
640  }
641  }
642 }
643 
644 
645 void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
646 {
647  int ii = m_cmpList->GetSelection();
648 
649  if( ii >= 0 )
650  {
651  wxString part_name = m_libraryName + ':' + m_cmpList->GetString( ii );
652 
653  // a selection was made, pass true
654  DismissModal( true, part_name );
655  }
656  else
657  {
658  // no selection was made, pass false
659  DismissModal( false );
660  }
661 
662  Close( true );
663 }
664 
665 
666 #define LIBLIST_WIDTH_KEY "ViewLiblistWidth"
667 #define CMPLIST_WIDTH_KEY "ViewCmplistWidth"
668 #define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY "ViewCmpShowPinElectricalType"
669 
670 // Currently, the library viewer has no dialog to change the background color
671 // of the draw canvas. Therefore the background color is here just
672 // in case of this option is added to some library viewer config dialog
673 #define LIBVIEW_BGCOLOR "LibviewBgColor"
674 
675 
676 void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
677 {
679 
682 
683  aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 );
684  aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 );
685  aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 );
687 
688  // Set parameters to a reasonable value.
689  if( m_libListWidth > m_FrameSize.x/2 )
691 
692  if( m_cmpListWidth > m_FrameSize.x/2 )
694 }
695 
696 
697 void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
698 {
700 
701  if( m_libListWidth && m_libList )
702  {
703  m_libListWidth = m_libList->GetSize().x;
704  aCfg->Write( LIBLIST_WIDTH_KEY, m_libListWidth );
705  }
706 
707  m_cmpListWidth = m_cmpList->GetSize().x;
708  aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth );
709 
711 }
712 
713 
714 void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event )
715 {
717 
718  bool changed = m_libList ? ReCreateListLib() : false;
719 
720  if (changed)
721  m_selection_changed = true;
722 
723  DisplayLibInfos();
724 }
725 
726 
727 void LIB_VIEW_FRAME::CloseLibraryViewer( wxCommandEvent& event )
728 {
729  Close();
730 }
731 
732 
734 {
735  m_listPowerCmpOnly = false;
736  m_allowedLibs.Clear();
737 
738  if( aFilter )
739  {
740  m_allowedLibs = aFilter->GetAllowedLibList();
742  }
743 
744  ReCreateListLib();
745 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:487
static int m_unit
static int m_convert
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
void SetFilter(const SCHLIB_FILTER *aFilter)
Set a filter to display only libraries and/or components which match the filter.
static wxString m_entryName
const EDA_RECT GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
Part library alias object definition.
#define LIB_VIEW_FRAME_NAME
void SetUnitAndConvert(int aUnit, int aConvert)
Set unit and convert, and set flag preventing them from automatically resetting to 1...
bool m_selection_changed
Updated to true if a list rewrite on GUI activation resulted in the component selection changing...
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
bool IsDismissed()
Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been...
void onUpdateViewDoc(wxUpdateUIEvent &aEvent)
virtual void OnActivate(wxActivateEvent &event) override
Called when the frame is activated to reload the libraries and component lists that can be changed by...
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:141
void SetScrollCenterPosition(const wxPoint &aPoint)
void OnCloseWindow(wxCloseEvent &Event)
void SetShowElectricalType(bool aShow)
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
int GetHeight() const
wxListBox * m_cmpList
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:380
wxArrayString m_allowedLibs
Schematic editor (Eeschema) main window.
Definition: schframe.h:118
wxAuiManager m_auimgr
Definition: wxstruct.h:149
static wxString m_libraryName
void SkipNextLeftButtonReleaseEvent()
function SkipNextLeftButtonReleaseEvent after calling this function, if the left mouse button is down...
Definition: draw_frame.cpp:286
virtual void SetGridColor(COLOR4D aColor)
Function SetGridColor() , virtual.
Definition: draw_frame.h:503
#define LIBLIST_WIDTH_KEY
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
LIB_ALIAS * getSelectedAlias()
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:746
void SetSelectedComponent(const wxString &aComponentName)
Set the selected component.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
Symbol library viewer main window.
Definition: viewlib_frame.h:49
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::Process_Config EDA_BASE_FRAME::OnSelectPreferredEditor EVT_COMBOBOX(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnSelectActiveLayer) EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE
BOX2I boundingBox(T aObject)
boundingBox template method
Definition: shape_index.h:59
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:77
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:505
bool m_showPinElectricalTypeName
the option to show the pin electrical name in the component editor
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:77
LIB_VIEW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
Constructor.
const wxArrayString & GetAllowedLibList() const
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
bool m_Center
Center on screen.
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:129
Class LIB_ITEM definition.
void CloseLibraryViewer(wxCommandEvent &event)
EVT_MENU(ID_SELECT_PREFERED_PDF_BROWSER_NAME, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser) EVT_MENU_RANGE(ID_LANGUAGE_CHOICE
LIB_PART * getSelectedSymbol()
Define a library symbol object.
Helper dialog and control classes.
void ReCreateHToolbar() override
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
wxPoint m_FramePos
Definition: wxstruct.h:139
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
Definition: wxstruct.h:142
bool GetFilterPowerParts() const
void OnSetRelativeOffset(wxCommandEvent &event)
bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
wxPoint Centre() const
bool IsModal()
Definition: kiway_player.h:259
int m_LastGridSizeId
Definition: draw_frame.h:78
EDA_PANEINFO & InfoToolbarPane()
Function InfoToolbarPane Change *this to a information panel for for KiCad.
Definition: wxstruct.h:552
bool ReCreateListCmp()
Create or recreate the list of components in the currently selected library.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
void ExportToSchematicLibraryPart(wxCommandEvent &event)
Function ExportToSchematicLibraryPart exports the current component to schematic and close the librar...
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:716
void DisplayLibInfos()
Definition: viewlibs.cpp:174
void SetModal(bool aIsModal)
Definition: kiway_player.h:260
EVT_TOOL_RANGE(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onSelectSymbolBodyStyle) EVT_UPDATE_UI(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT
LIB_PART * GetPart() const
Get the shared LIB_PART.
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
void ClickOnLibList(wxCommandEvent &event)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
#define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY
wxString GetDocFileName() const
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:524
see class PGM_BASE
void onUpdateNormalBodyStyleButton(wxUpdateUIEvent &aEvent)
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
#define max(a, b)
Definition: auxiliary.h:86
void OnUpdateElectricalType(wxUpdateUIEvent &aEvent)
struct EDA_HOTKEY_CONFIG g_Viewlib_Hokeys_Descr[]
KICAD_MANAGER_FRAME::language_change KICAD_MANAGER_FRAME::OnChangeIconsOptions EVT_UPDATE_UI(ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser) EVT_UPDATE_UI_RANGE(ID_TO_SCH
wxListBox * m_libList
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void onUpdateAlternateBodyStyleButton(wxUpdateUIEvent &aEvent)
Class EDA_RECT handles the component boundary box.
void ClickOnCmpList(wxCommandEvent &event)
#define MODAL_MODE_EXTRASTYLE
int GetWidth() const
const char * name
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void SetDrawBgColor(COLOR4D aColor) override
double BestZoom() override
Return the zoom level which displays the full page on screen.
void ReCreateVToolbar() override
bool GetShowElectricalType()
#define LIB_VIEW_FRAME_NAME_MODAL
wxSize m_FrameSize
Definition: wxstruct.h:140
Definition for part library class.
void OnShowElectricalType(wxCommandEvent &event)
void DClickOnCmpList(wxCommandEvent &event)
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
Message panel definition file.
bool ReCreateListLib()
Creates or recreates a sorted list of currently loaded libraries.
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.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
virtual void OnActivate(wxActivateEvent &event)
Function OnActivate (virtual) is called when activating the frame.
Definition: draw_frame.cpp:268
#define CMPLIST_WIDTH_KEY
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
Definition: basicframe.cpp:185
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
void SetSelectedLibrary(const wxString &aLibName)
Set the selected library in the library window.
void OnSize(wxSizeEvent &event) override
Function OnSize recalculates the size of toolbars and display panel when the frame size changes...