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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2019 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 
26 #include <fctsys.h>
27 #include <kiface_i.h>
28 #include <pgm_base.h>
29 #include <sch_view.h>
30 #include <msgpanel.h>
31 #include <bitmaps.h>
32 #include <eeschema_id.h>
33 #include <viewlib_frame.h>
34 #include <symbol_lib_table.h>
35 #include <dialog_helpers.h>
36 #include <class_libentry.h>
37 #include <class_library.h>
38 #include <view/view_controls.h>
39 #include <sch_painter.h>
40 #include <confirm.h>
41 #include <tool/tool_manager.h>
42 #include <tool/action_toolbar.h>
43 #include <tool/tool_dispatcher.h>
44 #include <tool/common_tools.h>
45 #include <tool/common_control.h>
46 #include <tool/zoom_tool.h>
47 #include <tools/ee_actions.h>
48 #include <tools/lib_control.h>
50 
51 // Save previous component library viewer state.
54 
57 
58 
59 BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
60  // Window events
62  EVT_SIZE( LIB_VIEW_FRAME::OnSize )
63  EVT_ACTIVATE( LIB_VIEW_FRAME::OnActivate )
64 
65  // Toolbar events
70 
71  // listbox events
75 
76  // Menu (and/or hotkey) events
77  EVT_MENU( wxID_CLOSE, LIB_VIEW_FRAME::CloseLibraryViewer )
79 
81 
82 END_EVENT_TABLE()
83 
84 
85 #define LIB_VIEW_NAME "ViewlibFrame"
86 #define LIB_VIEW_NAME_MODAL "ViewlibFrameModal"
87 
88 #define LIB_VIEW_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
89 #define LIB_VIEW_STYLE_MODAL ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
90 
91 
92 LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
93  const wxString& aLibraryName ) :
94  SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Symbol Library Browser" ),
95  wxDefaultPosition, wxDefaultSize,
98  m_libList( nullptr ), m_cmpList( nullptr ), m_previewItem( nullptr )
99 {
100  wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL );
101 
102  if( aFrameType == FRAME_SCH_VIEWER_MODAL )
103  SetModal( true );
104 
105  m_AboutTitle = "Symbol Library Viewer";
106 
107  // Force the frame name used in config. the lib viewer frame has a name
108  // depending on aFrameType (needed to identify the frame by wxWidgets),
109  // but only one configuration is preferable.
111 
112  // Give an icon
113  wxIcon icon;
114  icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) );
115  SetIcon( icon );
116 
117  m_libListWidth = 200;
118  m_cmpListWidth = 300;
119  m_listPowerCmpOnly = false;
120 
121  // Initialize grid id to the default value (50 mils):
123 
124  SetScreen( new SCH_SCREEN( aKiway ) );
125  GetScreen()->m_Center = true; // Axis origin centered on screen.
126  LoadSettings( config() );
127 
128  // Synchronize some draw options
129  SetShowElectricalType( true );
130  // Ensure axis are always drawn (initial default display was not drawn)
132  gal_opts.m_axesEnabled = true;
133  GetCanvas()->GetGAL()->SetAxesEnabled( true );
136 
137  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
138 
139  setupTools();
140  ReCreateMenuBar();
143 
144  m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
145  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
146 
147  m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxDefaultPosition, wxDefaultSize,
148  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
149 
150  if( aLibraryName.empty() )
151  {
152  ReCreateListLib();
153  }
154  else
155  {
156  m_libraryName = aLibraryName;
157  m_entryName.Clear();
158  m_unit = 1;
159  m_convert = 1;
160  }
161 
162  m_selection_changed = false;
163 
164  DisplayLibInfos();
165 
166  m_auimgr.SetManagedWindow( this );
167 
168  // Manage main toolbar
169  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
170  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
171 
172  m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(3)
173  .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_libListWidth, -1 ) );
174  m_auimgr.AddPane( m_cmpList, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
175  .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_cmpListWidth, -1 ) );
176 
177  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
178 
179  m_auimgr.GetPane( m_libList ).Show( aLibraryName.empty() );
180 
181  m_auimgr.Update();
182 
184 
185  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
186  {
187  Raise();
188  Show( true );
189  }
190 
191  SyncView();
192  GetCanvas()->GetViewControls()->SetSnapping( true );
193  GetCanvas()->SetCanFocus( false );
194 
195  // Set the working/draw area size to display a symbol to a reasonable value:
196  // A 450mm x 450mm with a origin at the area center looks like a large working area
197  double max_size_x = Millimeter2iu( 450 );
198  double max_size_y = Millimeter2iu( 450 );
199  BOX2D bbox;
200  bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
201  bbox.SetSize( max_size_x, max_size_y );
202  GetCanvas()->GetView()->SetBoundary( bbox );
204 }
205 
206 
208 {
209  if( m_previewItem )
211 }
212 
213 
215 {
216  // Create the manager and dispatcher & route draw panel events to the dispatcher
219  GetCanvas()->GetViewControls(), this );
220  m_actions = new EE_ACTIONS();
222 
223  // Register tools
227  m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet
228  m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu
230 
232 
233  // Run the selection tool, it is supposed to be always active
234  // It also manages the mouse right click to show the context menu
235  m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
236 
238 }
239 
240 
241 void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
242 {
243  m_unit = aUnit > 0 ? aUnit : 1;
244  m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
245  m_selection_changed = false;
246 
248 }
249 
250 
252 {
253  LIB_PART* symbol = nullptr;
254 
255  if( !m_libraryName.IsEmpty() && !m_entryName.IsEmpty() )
256  symbol = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
257 
258  return symbol;
259 }
260 
261 
263 {
264  LIB_PART* symbol = GetSelectedSymbol();
265  KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
266 
267  if( m_previewItem )
268  {
269  view->Remove( m_previewItem );
270  m_previewItem = nullptr;
271  }
272 
273  ClearMsgPanel();
274 
275  if( symbol )
276  {
279 
280  m_previewItem = symbol;
281  view->Add( m_previewItem );
282 
283  wxString parentName = _( "<none>" );
284  std::shared_ptr< LIB_PART > parent = m_previewItem->GetParent().lock();
285 
286  if( parent )
287  parentName = parent->GetName();
288 
289  AppendMsgPanel( _( "Name" ), m_previewItem->GetName(), BLUE, 6 );
290  AppendMsgPanel( _( "Parent" ), parentName, RED, 6 );
291  AppendMsgPanel( _( "Description" ), m_previewItem->GetDescription(), CYAN, 6 );
292  AppendMsgPanel( _( "Key words" ), m_previewItem->GetKeyWords(), DARKDARKGRAY );
293  }
294 
295  GetCanvas()->ForceRefresh();
296 }
297 
298 
299 bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
300 {
301  if( aSymbol && !aSymbol->IsEmpty() )
302  {
303  wxString msg;
304  LIB_TABLE* libTable = Prj().SchSymbolLibTable();
305  LIB_ID libid;
306 
307  libid.Parse( *aSymbol, LIB_ID::ID_SCH, true );
308 
309  if( libid.IsValid() )
310  {
311  wxString nickname = libid.GetLibNickname();
312 
313  if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
314  {
315  msg.sprintf( _( "The current configuration does not include a library with the\n"
316  "nickname \"%s\". Use Manage Symbol Libraries\n"
317  "to edit the configuration." ), nickname );
318  DisplayErrorMessage( aParent, _( "Symbol library not found." ), msg );
319  }
320  else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
321  {
322  msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
323  "in the current configuration. Use Manage Symbol Libraries to\n"
324  "edit the configuration." ), nickname );
325  DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
326  }
327  else
328  {
331  }
332  }
333  }
334 
335  return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
336 }
337 
338 
339 void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
340 {
341  GetCanvas()->StopDrawing();
342 
343  if( !IsModal() )
344  {
345  Destroy();
346  }
347  else if( !IsDismissed() )
348  {
349  // only dismiss modal frame if not already dismissed.
350  DismissModal( false );
351 
352  // Modal frame will be destroyed by the calling function.
353  }
354 }
355 
356 
357 void LIB_VIEW_FRAME::OnSize( wxSizeEvent& SizeEv )
358 {
359  if( m_auimgr.GetManagedWindow() )
360  m_auimgr.Update();
361 
362  SizeEv.Skip();
363 }
364 
365 
366 void LIB_VIEW_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
367 {
368  LIB_PART* part = GetSelectedSymbol();
369 
370  int unit_count = 1;
371 
372  if( part )
373  unit_count = std::max( part->GetUnitCount(), 1 );
374 
375  m_unitChoice->Enable( unit_count > 1 );
376 
377  if( unit_count > 1 )
378  {
379  // rebuild the unit list if it is not suitable (after a new selection for instance)
380  if( unit_count != (int)m_unitChoice->GetCount() )
381  {
382  m_unitChoice->Clear();
383 
384  for( int ii = 0; ii < unit_count; ii++ )
385  m_unitChoice->Append( wxString::Format( _( "Unit %c" ), 'A' + ii ) );
386 
387  }
388 
389  if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) )
390  m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) );
391  }
392  else if( m_unitChoice->GetCount() )
393  m_unitChoice->Clear();
394 }
395 
396 
398 {
399  if( !m_libList )
400  return false;
401 
402  m_libList->Clear();
403 
404  std::vector< wxString > libs = Prj().SchSymbolLibTable()->GetLogicalLibs();
405 
406  // Remove not allowed libs from main list, if the allowed lib list is not empty
407  if( m_allowedLibs.GetCount() )
408  {
409  for( unsigned ii = 0; ii < libs.size(); )
410  {
411  if( m_allowedLibs.Index( libs[ii] ) == wxNOT_FOUND )
412  libs.erase( libs.begin() + ii );
413  else
414  ii++;
415  }
416  }
417 
418  // Remove libs which have no power components, if this filter is activated
419  if( m_listPowerCmpOnly )
420  {
421  for( unsigned ii = 0; ii < libs.size(); )
422  {
423  wxArrayString aliasNames;
424 
425  Prj().SchSymbolLibTable()->EnumerateSymbolLib( libs[ii], aliasNames, true );
426 
427  if( aliasNames.IsEmpty() )
428  libs.erase( libs.begin() + ii );
429  else
430  ii++;
431  }
432  }
433 
434  if( libs.empty() )
435  return true;
436 
437  wxArrayString libNames;
438 
439  for( const auto& name : libs )
440  libNames.Add( name );
441 
442  m_libList->Append( libNames );
443 
444  // Search for a previous selection:
445  int index = m_libList->FindString( m_libraryName );
446 
447  if( index != wxNOT_FOUND )
448  {
449  m_libList->SetSelection( index, true );
450  }
451  else
452  {
453  // If not found, clear current library selection because it can be
454  // deleted after a config change.
455  m_libraryName = libs[0];
456  m_entryName = wxEmptyString;
457  m_unit = 1;
458  m_convert = LIB_ITEM::LIB_CONVERT::BASE;
459  }
460 
461  bool cmp_changed = ReCreateListCmp();
462  DisplayLibInfos();
463  GetCanvas()->Refresh();
464 
465  return cmp_changed;
466 }
467 
468 
470 {
471  if( m_cmpList == NULL )
472  return false;
473 
474  wxArrayString aliasNames;
475 
476  try
477  {
478  Prj().SchSymbolLibTable()->EnumerateSymbolLib( m_libraryName, aliasNames,
480  }
481  catch( const IO_ERROR& ) {} // ignore, it is handled below
482 
483  m_cmpList->Clear();
484 
485  if( aliasNames.IsEmpty() )
486  {
487  m_libraryName = wxEmptyString;
488  m_entryName = wxEmptyString;
489  m_convert = LIB_ITEM::LIB_CONVERT::BASE;
490  m_unit = 1;
491  return true;
492  }
493 
494  m_cmpList->Append( aliasNames );
495 
496  int index = m_cmpList->FindString( m_entryName );
497  bool changed = false;
498 
499  if( index == wxNOT_FOUND )
500  {
501  // Select the first library entry when the previous entry name does not exist in
502  // the current library.
503  m_convert = LIB_ITEM::LIB_CONVERT::BASE;
504  m_unit = 1;
505  index = 0;
506  changed = true;
507  m_entryName = wxEmptyString;
508  }
509 
510  m_cmpList->SetSelection( index, true );
511 
512  wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST );
513  ProcessEvent( evt );
514 
515  return changed;
516 }
517 
518 
519 void LIB_VIEW_FRAME::ClickOnLibList( wxCommandEvent& event )
520 {
521  int ii = m_libList->GetSelection();
522 
523  if( ii < 0 )
524  return;
525 
526  m_selection_changed = true;
527 
528  SetSelectedLibrary( m_libList->GetString( ii ) );
529 }
530 
531 
532 void LIB_VIEW_FRAME::SetSelectedLibrary( const wxString& aLibraryName )
533 {
534  if( m_libraryName == aLibraryName )
535  return;
536 
537  m_libraryName = aLibraryName;
538  ReCreateListCmp();
539  GetCanvas()->Refresh();
540  DisplayLibInfos();
541 
542  // Ensure the corresponding line in m_libList is selected
543  // (which is not necessary the case if SetSelectedLibrary is called
544  // by another caller than ClickOnLibList.
545  m_libList->SetStringSelection( m_libraryName, true );
546  m_libList->SetFocus();
547 }
548 
549 
550 void LIB_VIEW_FRAME::ClickOnCmpList( wxCommandEvent& event )
551 {
552  int ii = m_cmpList->GetSelection();
553 
554  if( ii < 0 )
555  return;
556 
557  m_selection_changed = true;
558 
559  SetSelectedComponent( m_cmpList->GetString( ii ) );
560  m_cmpList->SetFocus();
561 }
562 
563 
564 void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
565 {
566  if( m_entryName != aComponentName )
567  {
568  m_entryName = aComponentName;
569 
570  // Ensure the corresponding line in m_cmpList is selected
571  // (which is not necessarily the case if SetSelectedComponent is called
572  // by another caller than ClickOnCmpList.
573  m_cmpList->SetStringSelection( aComponentName, true );
574  DisplayLibInfos();
575 
576  if( m_selection_changed )
577  {
578  m_unit = 1;
579  m_convert = LIB_ITEM::LIB_CONVERT::BASE;
580  m_selection_changed = false;
581  }
582 
585  }
586 }
587 
588 
589 void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
590 {
592 }
593 
594 
595 #define LIBLIST_WIDTH_KEY "ViewLiblistWidth"
596 #define CMPLIST_WIDTH_KEY "ViewCmplistWidth"
597 #define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY "ViewCmpShowPinElectricalType"
598 
599 
600 void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
601 {
603 
604  // Fetch display settings from Symbol Editor as the Symbol Viewer
605  // doesn't have its own config
606  wxString symbolEditor = LIB_EDIT_FRAME_NAME;
607  bool btmp;
608  COLOR4D wtmp;
609 
610  if( aCfg->Read( symbolEditor + ShowGridEntryKeyword, &btmp ) )
611  SetGridVisibility( btmp );
612 
613  if( wtmp.SetFromWxString( aCfg->Read( symbolEditor + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
614  SetGridColor( wtmp );
615 
616  // Grid shape, etc.
617  GetGalDisplayOptions().ReadAppConfig( *aCfg, symbolEditor );
618 
619  aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 );
620  aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 );
622 
623  // Set parameters to a reasonable value.
624  if( m_libListWidth > m_FrameSize.x/2 )
626 
627  if( m_cmpListWidth > m_FrameSize.x/2 )
629 }
630 
631 
632 void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
633 {
635 
636  if( m_libListWidth && m_libList )
637  {
638  m_libListWidth = m_libList->GetSize().x;
639  aCfg->Write( LIBLIST_WIDTH_KEY, m_libListWidth );
640  }
641 
642  m_cmpListWidth = m_cmpList->GetSize().x;
643  aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth );
644 
646 }
647 
648 
649 void LIB_VIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
650 {
651  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
652 
653  if( aEnvVarsChanged )
654  ReCreateListLib();
655 }
656 
657 
658 void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event )
659 {
660  if( event.GetActive() )
661  {
662  bool changed = m_libList ? ReCreateListLib() : false;
663 
664  if (changed)
665  m_selection_changed = true;
666 
668 
669  DisplayLibInfos();
670  }
671 
672  event.Skip(); // required under wxMAC
673 }
674 
675 
676 void LIB_VIEW_FRAME::CloseLibraryViewer( wxCommandEvent& event )
677 {
678  Close();
679 }
680 
681 
683 {
684  m_listPowerCmpOnly = false;
685  m_allowedLibs.Clear();
686 
687  if( aFilter )
688  {
689  m_allowedLibs = aFilter->GetAllowedLibList();
691  }
692 
693  ReCreateListLib();
694 }
695 
696 
698 {
699  LIB_PART* part = GetSelectedSymbol();
700 
701  if( !part )
702  {
703  return BOX2I( VECTOR2I(-200, -200), VECTOR2I( 400, 400 ) );
704  }
705  else
706  {
707  std::shared_ptr< LIB_PART > tmp;
708 
709  tmp = ( part->IsAlias() ) ? part->GetParent().lock() : part->SharedPtr();
710 
711  wxCHECK( tmp, BOX2I( VECTOR2I(-200, -200), VECTOR2I( 400, 400 ) ) );
712 
713  EDA_RECT bbox = tmp->GetUnitBoundingBox( m_unit, m_convert );
714  return BOX2I( bbox.GetOrigin(), VECTOR2I( bbox.GetWidth(), bbox.GetHeight() ) );
715  }
716 }
717 
718 
720 {
721  if( m_cmpList->GetSelection() >= 0 )
722  DismissModal( true, m_libraryName + ':' + m_cmpList->GetStringSelection() );
723  else
724  DismissModal( false );
725 
726  Close( true );
727 }
728 
Definition: colors.h:57
static int m_unit
void SetScreen(BASE_SCREEN *aScreen) override
static int m_convert
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void SetFilter(const SCHLIB_FILTER *aFilter)
Set a filter to display only libraries and/or components which match the filter.
LIB_PART * GetSelectedSymbol() const
static wxString m_entryName
BOX2< VECTOR2I > BOX2I
Definition: box2.h:520
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
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,...
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:249
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
bool ShowModal(wxString *aSymbol, wxWindow *aParent) override
Function ShowModal.
wxString GetName() const override
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
This file is part of the common library.
TOOL_DISPATCHER * m_toolDispatcher
bool IsDismissed()
Function IsDismissed returns false only if both the frame is acting in modal mode and it has not been...
VIEW_CONTROLS class definition.
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 onSelectPreviousSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:101
virtual bool IsGridVisible() const
void OnCloseWindow(wxCloseEvent &Event)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
ACTIONS * m_actions
int GetWidth() const
Definition: eda_rect.h:119
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
wxString m_AboutTitle
wxListBox * m_cmpList
virtual wxConfigBase * config()
Returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void SetSize(const Vec &size)
Definition: box2.h:210
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
wxArrayString m_allowedLibs
void SetShowElectricalType(bool aShow)
wxAuiManager m_auimgr
static wxString m_libraryName
ACTION_TOOLBAR * m_mainToolBar
wxString GetKeyWords() const
virtual void SetGridColor(COLOR4D aColor)
#define LIBLIST_WIDTH_KEY
LIB_PART * m_previewItem
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
The base class for create windows for drawing purpose.
bool IsValid() const
Definition: lib_id.h:171
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
void SetSelectedComponent(const wxString &aComponentName)
Set the selected component.
Symbol library viewer main window.
Definition: viewlib_frame.h:42
bool m_axesEnabled
Whether or not to draw the coordinate system axes
Class LIB_CONTROL.
Definition: lib_control.h:39
#define LIB_EDIT_FRAME_NAME
Class TOOL_MANAGER.
Definition: tool_manager.h:50
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
void OnSelectSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:42
static TOOL_ACTION gridPreset
Definition: actions.h:131
int GetUnitCount() const override
For items with units, return the number of units.
LIB_VIEW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aLibraryName=wxEmptyString)
Constructor.
void ReCreateMenuBar() override
Recreates the menu bar.
bool m_Center
Center on screen.
Definition: base_screen.h:121
void SyncView()
Mark all items for refresh.
EDA_MSG_PANEL * m_messagePanel
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
Class LIB_PIN definition.
void onUpdateUnitChoice(wxUpdateUIEvent &aEvent)
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void CloseLibraryViewer(wxCommandEvent &event)
PART_SPTR SharedPtr()
Definition: colors.h:59
PART_REF & GetParent()
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:274
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
Definition: colors.h:60
wxString GetDescription() override
static TOOL_ACTION addSymbolToSchematic
Definition: ee_actions.h:162
bool IsModal()
Definition: kiway_player.h:163
Class COMMON_CONTROL.
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
bool m_showPinElectricalTypeName
const BOX2I GetDocumentExtents() const override
bool ReCreateListCmp()
Create or recreate the list of components in the currently selected library.
#define _(s)
bool GetFilterPowerParts() const
Specialization of the wxAuiPaneInfo class for KiCad panels.
void ReadAppConfig(wxConfigBase &aCfg, const wxString &aBaseName)
Read GAL config options from applicaton-level config.
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
int GetHeight() const
Definition: eda_rect.h:120
#define LIB_VIEW_NAME
void DisplayLibInfos()
Definition: viewlibs.cpp:128
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Class EESCHEMA_ACTIONS.
Definition: ee_actions.h:43
Class COMMON_TOOLS.
Definition: common_tools.h:38
Class TOOL_DISPATCHER.
void SetModal(bool aIsModal)
Definition: kiway_player.h:164
void ClickOnLibList(wxCommandEvent &event)
void onSelectNextSymbol(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:87
#define LIB_VIEW_NAME_MODAL
#define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
void updatePreviewSymbol()
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
see class PGM_BASE
const char * name
Definition: DXF_plotter.cpp:61
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
void DismissModal(bool aRetVal, const wxString &aResult=wxEmptyString)
#define max(a, b)
Definition: auxiliary.h:86
#define LIB_VIEW_STYLE_MODAL
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
wxListBox * m_libList
void FinishModal()
Send the selected symbol back to the caller.
#define ShowGridEntryKeyword
Nonzero to show grid (suffix)
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
bool IsAlias() const
#define LIB_VIEW_STYLE
void SetOrigin(const Vec &pos)
Definition: box2.h:208
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void ClickOnCmpList(wxCommandEvent &event)
const wxArrayString & GetAllowedLibList() const
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void OnGridSettings(wxCommandEvent &aEvent) override
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void OnActivate(wxActivateEvent &event)
Called when the frame is activated to reload the libraries and component lists that can be changed by...
wxChoice * m_unitChoice
virtual void SetGridVisibility(bool aVisible)
void ReCreateVToolbar() override
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void onSelectSymbolUnit(wxCommandEvent &aEvent)
Definition: viewlibs.cpp:115
TOOL_MANAGER * m_toolManager
void InitTools()
Function InitTools() Initializes all registered tools.
Definition for part library class.
void SetBoundary(const BOX2D &aBoundary)
Function SetBoundary() Sets limits for view area.
Definition: view.h:267
void DClickOnCmpList(wxCommandEvent &event)
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
Message panel definition file.
bool ReCreateListLib()
Creates or recreates a sorted list of currently loaded libraries.
#define GridColorEntryKeyword
Grid color ID (suffix)
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
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
virtual bool ShowModal(wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxF...
#define CMPLIST_WIDTH_KEY
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
wxString m_configName
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
void SetSelectedLibrary(const wxString &aLibName)
Set the selected library in the library window.
bool GetShowElectricalType()
Allow some frames to show/hide pin electrical type names.
void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.