KiCad PCB EDA Suite
lib_edit_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) 2013 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 <pgm_base.h>
28 #include <kiface_i.h>
29 #include <kiway_express.h>
30 #include <sch_draw_panel.h>
31 #include <base_screen.h>
32 #include <confirm.h>
33 #include <eda_doc.h>
34 #include <sch_edit_frame.h>
35 #include <msgpanel.h>
36 #include <confirm.h>
37 #include <eda_dockart.h>
38 
39 #include <general.h>
40 #include <eeschema_id.h>
41 #include <lib_edit_frame.h>
42 #include <class_library.h>
43 
44 #include <lib_manager.h>
46 #include <widgets/lib_tree.h>
47 #include <symbol_lib_table.h>
48 #include <kicad_device_context.h>
49 #include <ee_hotkeys.h>
50 #include <eeschema_config.h>
52 #include <wx/progdlg.h>
53 #include <tool/tool_manager.h>
54 #include <tool/tool_dispatcher.h>
55 #include <tool/action_menu.h>
56 #include <tool/common_tools.h>
57 #include <tool/zoom_tool.h>
58 #include <tools/ee_actions.h>
60 #include <tools/ee_picker_tool.h>
62 #include <tools/lib_pin_tool.h>
63 #include <tools/lib_edit_tool.h>
64 #include <tools/lib_move_tool.h>
66 #include <tools/lib_control.h>
67 #include <tools/ee_point_editor.h>
68 #include <sch_view.h>
69 #include <sch_painter.h>
70 
71 
72 bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
73 int LIB_EDIT_FRAME:: g_LastTextSize = -1;
74 double LIB_EDIT_FRAME:: g_LastTextAngle = TEXT_ANGLE_HORIZ;
75 int LIB_EDIT_FRAME:: g_LastLineWidth = 0;
76 
77 // these values are overridden when reading the config
78 int LIB_EDIT_FRAME:: m_textPinNumDefaultSize = DEFAULTPINNUMSIZE;
79 int LIB_EDIT_FRAME:: m_textPinNameDefaultSize = DEFAULTPINNAMESIZE;
80 int LIB_EDIT_FRAME:: m_defaultPinLength = DEFAULTPINLENGTH;
81 
82 FILL_T LIB_EDIT_FRAME:: g_LastFillStyle = NO_FILL;
83 
84 
85 BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
87  EVT_SIZE( LIB_EDIT_FRAME::OnSize )
88  EVT_ACTIVATE( LIB_EDIT_FRAME::OnActivate )
89 
90  // Actions
106 
107  // Main horizontal toolbar.
115 
117 
118  // Right vertical toolbar.
121 
122  // menubar commands
133 
135 
137 
138  // Update user interface elements.
151  LIB_EDIT_FRAME::OnUpdateEditingPart )
152  EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, LIB_EDIT_FRAME::OnUpdateSwitchCanvas )
153  EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, LIB_EDIT_FRAME::OnUpdateSwitchCanvas )
154 
155 END_EVENT_TABLE()
156 
157 LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
158  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
159  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME )
160 {
161  m_showAxis = true; // true to draw axis
162  SetShowDeMorgan( false );
163  m_DrawSpecificConvert = true;
164  m_DrawSpecificUnit = false;
165  m_hotkeysDescrList = g_Libedit_Hotkeys_Descr;
166  m_SyncPinEdit = false;
167  m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN;
168  SetShowElectricalType( true );
169  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
170 
171  m_my_part = NULL;
172  m_treePane = nullptr;
173  m_libMgr = nullptr;
174  m_unit = 1;
175  m_convert = 1;
176  m_AboutTitle = "LibEdit";
177 
178  // Delayed initialization
179  if( g_LastTextSize == -1 )
180  g_LastTextSize = GetDefaultTextSize();
181 
182  // Initialize grid id to the default value 50 mils:
184 
185  wxIcon icon;
186  icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) );
187  SetIcon( icon );
188 
189  LoadSettings( config() );
190 
191  m_dummyScreen = new SCH_SCREEN( aKiway );
192  SetScreen( m_dummyScreen );
193  GetScreen()->m_Center = true;
194  GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
195 
196  SetCrossHairPosition( wxPoint( 0, 0 ) );
197 
198  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
199 
200  if( m_canvas )
201  m_canvas->SetEnableBlockCommands( true );
202 
203  m_libMgr = new LIB_MANAGER( *this );
204  SyncLibraries( true );
205  m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
206 
207  setupTools();
208  ReCreateMenuBar();
209  ReCreateHToolbar();
210  ReCreateVToolbar();
211  ReCreateOptToolbar();
212 
213  updateTitle();
214  DisplayCmpDoc();
215  RebuildSymbolUnitsList();
216 
217  m_auimgr.SetManagedWindow( this );
218  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
219 
220  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
221  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
222 
223  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
224  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "ComponentTree" ).Left().Layer(1)
225  .Caption( _( "Libraries" ) ).MinSize( 250, -1 )
226  .BestSize( m_defaultLibWidth, -1 ).Resizable() );
227  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
228 
229  m_auimgr.AddPane( m_canvas->GetWindow(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
230 
231  m_auimgr.Update();
232 
233  GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
234 
235  Raise();
236  Show( true );
237 
238  Bind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnConfigurePaths, this,
240 
241  Bind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnEditSymbolLibTable, this,
243 
244  m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
245 
246  SyncView();
247  GetGalCanvas()->GetViewControls()->SetSnapping( true );
248  GetGalCanvas()->GetView()->UseDrawPriority( true );
249  GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
250  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
251 
252  // Set the working/draw area size to display a symbol to a reasonable value:
253  // A 600mm x 600mm with a origin at the area center looks like a large working area
254  double max_size_x = Millimeter2iu( 600 );
255  double max_size_y = Millimeter2iu( 600 );
256  BOX2D bbox;
257  bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
258  bbox.SetSize( max_size_x, max_size_y );
259  GetCanvas()->GetView()->SetBoundary( bbox );
260 }
261 
262 
264 {
265  Unbind( wxEVT_COMMAND_MENU_SELECTED, &LIB_EDIT_FRAME::OnEditSymbolLibTable, this,
267 
268  // current screen is destroyed in EDA_DRAW_FRAME
270 
271  delete m_libMgr;
272  delete m_my_part;
273 }
274 
275 
277 {
278  // Create the manager and dispatcher & route draw panel events to the dispatcher
281  GetCanvas()->GetViewControls(), this );
282  m_actions = new EE_ACTIONS();
284 
285  // Register tools
298 
299  // Run the selection tool, it is supposed to be always active
300  m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
301 
303 }
304 
305 
306 void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
307 {
308  if( saveAllLibraries( true ) )
309  Destroy();
310  else
311  Event.Veto();
312 }
313 
314 
316 {
317  LIB_PART* part = GetCurPart();
318  double defaultLibraryZoom = 7.33;
319 
320  if( !part )
321  {
322  SetScrollCenterPosition( wxPoint( 0, 0 ) );
323  return defaultLibraryZoom;
324  }
325 
327 
328  double sizeX = (double) boundingBox.GetWidth();
329  double sizeY = (double) boundingBox.GetHeight();
330  wxPoint centre = boundingBox.Centre();
331 
332  // Reserve a 20% margin around component bounding box.
333  double margin_scale_factor = 1.2;
334 
335  return bestZoom( sizeX, sizeY, margin_scale_factor, centre);
336 }
337 
338 
340 {
341  if( m_partSelectBox == NULL )
342  return;
343 
344  if( m_partSelectBox->GetCount() != 0 )
345  m_partSelectBox->Clear();
346 
347  LIB_PART* part = GetCurPart();
348 
349  if( !part || part->GetUnitCount() <= 1 )
350  {
351  m_unit = 1;
352  m_partSelectBox->Append( wxEmptyString );
353  }
354  else
355  {
356  for( int i = 0; i < part->GetUnitCount(); i++ )
357  {
358  wxString sub = LIB_PART::SubReference( i+1, false );
359  wxString unit = wxString::Format( _( "Unit %s" ), GetChars( sub ) );
360  m_partSelectBox->Append( unit );
361  }
362  }
363 
364  // Ensure the current selected unit is compatible with
365  // the number of units of the current part:
366  if( part && part->GetUnitCount() < m_unit )
367  m_unit = 1;
368 
369  m_partSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
370 }
371 
372 
373 void LIB_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event )
374 {
375  auto& treePane = m_auimgr.GetPane( m_treePane );
376  treePane.Show( !IsSearchTreeShown() );
377  m_auimgr.Update();
378 }
379 
380 
381 void LIB_EDIT_FRAME::OnEditSymbolLibTable( wxCommandEvent& aEvent )
382 {
383  m_libMgr->GetAdapter()->Freeze();
384 
386  SyncLibraries( true );
387 
388  m_libMgr->GetAdapter()->Thaw();
389 }
390 
391 
393 {
394  return m_auimgr.GetPane( m_treePane ).IsShown();
395 }
396 
397 
399 {
401 }
402 
403 
404 void LIB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
405 {
406  LIB_ID libId = getTargetLibId();
407  const wxString& libName = libId.GetLibNickname();
408  const wxString& partName = libId.GetLibItemName();
409  bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
410 
411  if( partName.IsEmpty() )
412  aEvent.Enable( !readOnly && m_libMgr->IsLibraryModified( libName ) );
413  else
414  aEvent.Enable( !readOnly && m_libMgr->IsPartModified( partName, libName ) );
415 }
416 
417 
418 void LIB_EDIT_FRAME::OnUpdateRevert( wxUpdateUIEvent& aEvent )
419 {
420  LIB_ID libId = getTargetLibId();
421  const wxString& libName = libId.GetLibNickname();
422  const wxString& partName = libId.GetLibItemName();
423 
424  if( partName.IsEmpty() )
425  aEvent.Enable( !libName.IsEmpty() && m_libMgr->IsLibraryModified( libName ) );
426  else
427  aEvent.Enable( !libName.IsEmpty() && m_libMgr->IsPartModified( partName, libName ) );
428 }
429 
430 
431 void LIB_EDIT_FRAME::OnUpdateHavePart( wxUpdateUIEvent& aEvent )
432 {
433  aEvent.Enable( getTargetLibId().IsValid() );
434 }
435 
436 
437 void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
438 {
439  LIB_PART* part = GetCurPart();
440 
441  aEvent.Enable( part != NULL );
442 
443  if( part && aEvent.GetEventObject() == m_drawToolBar )
444  aEvent.Check( GetToolId() == aEvent.GetId() );
445 }
446 
447 
448 void LIB_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
449 {
450  event.Enable( m_clipboard.GetCount() > 0 );
451 }
452 
453 
454 void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event )
455 {
456  LIB_PART* part = GetCurPart();
457  event.Enable( part && part->IsMulti() && !part->UnitsLocked() );
458  event.Check( m_SyncPinEdit );
459 }
460 
461 
462 void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
463 {
464  if( m_partSelectBox == NULL )
465  return;
466 
467  LIB_PART* part = GetCurPart();
468 
469  // Using the typical event.Enable() call doesn't seem to work with wxGTK
470  // so use the pointer to alias combobox to directly enable or disable.
471  m_partSelectBox->Enable( part && part->GetUnitCount() > 1 );
472 }
473 
474 
475 void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
476 {
477  LIB_PART* part = GetCurPart();
478 
479  event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
480  event.Check( m_convert <= 1 );
481 }
482 
483 
484 void LIB_EDIT_FRAME::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
485 {
486  LIB_PART* part = GetCurPart();
487 
488  event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
489  event.Check( m_convert > 1 );
490 }
491 
492 
493 void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
494 {
495  int i = event.GetSelection();
496 
497  if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
498  return;
499 
502 
503  m_unit = i + 1;
504 
506  RebuildView();
507 }
508 
509 
510 void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
511 {
512  LIB_PART* part = GetCurPart();
513 
514  if( !part )
515  return;
516 
517  wxString filename;
518 
519  if( part->GetAliasCount() > 1 )
520  {
521  ACTION_MENU popup;
522  wxString msg;
523  int id = 0;
524 
525  for( LIB_ALIAS* alias : part->GetAliases() )
526  {
527  msg.Printf( wxT( "%s (%s)" ), alias->GetName(), alias->GetDocFileName() );
528  popup.Append( id++, msg );
529  }
530 
531  PopupMenu( &popup );
532 
533  if( popup.GetSelected() >= 0 )
534  filename = part->GetAlias( (unsigned) popup.GetSelected() )->GetDocFileName();
535  }
536  else
537  filename = part->GetAlias( 0 )->GetDocFileName();
538 
539  if( !filename.IsEmpty() && filename != wxT( "~" ) )
540  {
541  SEARCH_STACK* lib_search = Prj().SchSearchS();
542 
543  GetAssociatedDocument( this, filename, lib_search );
544  }
545 }
546 
547 
548 void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
549 {
552 
553  m_convert = event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ? 1 : 2;
554 
556  RebuildView();
557 }
558 
559 
560 void LIB_EDIT_FRAME::OnSyncPinEditClick( wxCommandEvent& event )
561 {
563 }
564 
565 
566 void LIB_EDIT_FRAME::OnActivate( wxActivateEvent& event )
567 {
569 }
570 
571 
573 {
574  wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
575 
576  if( !libNickname.empty() )
577  {
578  if( !Prj().SchSymbolLibTable()->HasLibrary( libNickname ) )
579  {
580  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
581  libNickname = wxEmptyString;
582  }
583  }
584 
585  return libNickname;
586 }
587 
588 
589 wxString LIB_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
590 {
591  wxString old = GetCurLib();
592 
593  if( aLibNickname.empty() || !Prj().SchSymbolLibTable()->HasLibrary( aLibNickname ) )
594  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
595  else
596  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname );
597 
598  m_libMgr->SetCurrentLib( aLibNickname );
599 
600  return old;
601 }
602 
603 
605 {
606  if( !aPart && !m_my_part )
607  return;
608 
610  GetScreen()->SetCurItem( nullptr );
611 
612  if( m_my_part != aPart )
613  {
614  if( m_my_part )
615  delete m_my_part;
616 
617  m_my_part = aPart;
618  }
619 
620  // select the current component in the tree widget
621  if( aPart )
622  m_treePane->GetLibTree()->SelectLibId( aPart->GetLibId() );
623 
624  wxString partName = aPart ? aPart->GetName() : wxString();
625  m_libMgr->SetCurrentPart( partName );
626 
627  // retain in case this wxFrame is re-opened later on the same PROJECT
629 
630  // Ensure synchronized pin edit can be enabled only symbols with interchangeable units
631  m_SyncPinEdit = aPart && aPart->IsMulti() && !aPart->UnitsLocked();
632 
634  RebuildView();
635 }
636 
637 
638 void LIB_EDIT_FRAME::OnImportBody( wxCommandEvent& aEvent )
639 {
641  SetToolID( ID_LIBEDIT_IMPORT_BODY_BUTT, GetGalCanvas()->GetDefaultCursor(), _( "Import" ) );
642  LoadOneSymbol();
644  m_canvas->SetIgnoreMouseEvents( false );
645 }
646 
647 
648 void LIB_EDIT_FRAME::OnExportBody( wxCommandEvent& aEvent )
649 {
651  SetToolID( ID_LIBEDIT_EXPORT_BODY_BUTT, GetGalCanvas()->GetDefaultCursor(), _( "Export" ) );
652  SaveOneSymbol();
654  m_canvas->SetIgnoreMouseEvents( false );
655 }
656 
657 
659 {
660  GetScreen()->SetModify();
662 
663  m_treePane->GetLibTree()->Refresh();
664 }
665 
666 
668 {
669  LIB_PART* part = GetCurPart();
670 
671  return m_SyncPinEdit && part && part->IsMulti() && !part->UnitsLocked();
672 }
673 
674 
675 void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event )
676 {
677  if( GetCurPart() )
678  {
679  SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
680 
681  if( schframe == NULL ) // happens when the schematic editor is not active (or closed)
682  {
683  DisplayErrorMessage( this, _( "No schematic currently open." ) );
684  return;
685  }
686 
687  SCH_COMPONENT* component = new SCH_COMPONENT( *GetCurPart(), GetCurPart()->GetLibId(),
689 
690  // Be sure the link to the corresponding LIB_PART is OK:
691  component->Resolve( *Prj().SchSymbolLibTable() );
692 
693  if( schframe->GetAutoplaceFields() )
694  component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
695 
696  schframe->Raise();
697  schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component );
698  }
699 }
700 
701 
703 {
704  // There may be no parent window so use KIWAY message to refresh the schematic editor
705  // in case any symbols have changed.
706  std::string dummyPayload;
707  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_REFRESH, dummyPayload, this );
708 }
709 
710 
711 bool LIB_EDIT_FRAME::addLibraryFile( bool aCreateNew )
712 {
713  wxFileName fn = m_libMgr->GetUniqueLibraryName();
714 
715  if( !LibraryFileBrowser( !aCreateNew, fn, SchematicLibraryFileWildcard(),
717  {
718  return false;
719  }
720 
721  wxString libName = fn.GetName();
722 
723  if( libName.IsEmpty() )
724  return false;
725 
726  if( m_libMgr->LibraryExists( libName ) )
727  {
728  DisplayError( this, wxString::Format( _( "Library \"%s\" already exists" ), libName ) );
729  return false;
730  }
731 
732  // Select the target library table (global/project)
733  SYMBOL_LIB_TABLE* libTable = selectSymLibTable();
734 
735  if( !libTable )
736  return false;
737 
738  if( aCreateNew )
739  {
740  if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
741  {
742  DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
743  "Check write permission." ),
744  fn.GetFullPath() ) );
745  return false;
746  }
747  }
748  else
749  {
750  if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
751  {
752  DisplayError( this, _( "Could not open the library file." ) );
753  return false;
754  }
755  }
756 
757  bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
758  saveSymbolLibTables( globalTable, !globalTable );
759 
760  return true;
761 }
762 
763 
765 {
766  LIB_ALIAS* alias = nullptr;
767 
769  {
771  alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
772  }
773  else if( LIB_PART* part = GetCurPart() )
774  {
775  alias = part->GetAlias( 0 );
776  }
777 
778  return alias ? alias->GetPart() : nullptr;
779 }
780 
781 
783 {
785  wxString nickname = id.GetLibNickname();
786 
787  if( nickname.IsEmpty() && GetCurPart() )
788  id = GetCurPart()->GetLibId();
789 
790  return id;
791 }
792 
793 
795 {
796  return getTargetLibId().GetLibNickname();
797 }
798 
799 
800 void LIB_EDIT_FRAME::SyncLibraries( bool aShowProgress )
801 {
802  LIB_ID selected;
803 
804  if( m_treePane )
805  selected = m_treePane->GetLibTree()->GetSelectedLibId();
806 
807  if( aShowProgress )
808  {
809  wxProgressDialog progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
810  m_libMgr->GetAdapter()->GetLibrariesCount(), this );
811 
812  m_libMgr->Sync( true, [&]( int progress, int max, const wxString& libName )
813  {
814  progressDlg.Update( progress, wxString::Format( _( "Loading library \"%s\"" ), libName ) );
815  } );
816  }
817  else
818  {
819  m_libMgr->Sync( true );
820  }
821 
822  if( m_treePane )
823  {
824  wxDataViewItem found;
825 
826  if( selected.IsValid() )
827  {
828  // Check if the previously selected item is still valid,
829  // if not - it has to be unselected to prevent crash
830  found = m_libMgr->GetAdapter()->FindItem( selected );
831 
832  if( !found )
834  }
835 
837 
838  // Try to select the parent library, in case the part is not found
839  if( !found && selected.IsValid() )
840  {
841  selected.SetLibItemName( "" );
842  found = m_libMgr->GetAdapter()->FindItem( selected );
843 
844  if( found )
845  m_treePane->GetLibTree()->SelectLibId( selected );
846  }
847 
848  // If no selection, see if there's a current part to centre
849  if( !selected.IsValid() && GetCurPart() )
850  {
851  LIB_ID current( GetCurLib(), GetCurPart()->GetName() );
852  m_treePane->GetLibTree()->CenterLibId( current );
853  }
854  }
855 }
856 
857 
859 {
860  wxArrayString libTableNames;
861  libTableNames.Add( _( "Global" ) );
862  libTableNames.Add( _( "Project" ) );
863 
864  wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
865  _( "Add To Library Table" ), libTableNames );
866 
867  if( aOptional )
868  {
869  dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
870  dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
871  }
872 
873  if( dlg.ShowModal() != wxID_OK )
874  return nullptr;
875 
876  switch( dlg.GetSelection() )
877  {
878  case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
879  case 1: return Prj().SchSymbolLibTable();
880  default: return nullptr;
881  }
882 }
883 
884 
885 bool LIB_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
886 {
887  if( aOriginalFile.FileExists() )
888  {
889  wxFileName backupFileName( aOriginalFile );
890  backupFileName.SetExt( "bck" );
891 
892  if( backupFileName.FileExists() )
893  wxRemoveFile( backupFileName.GetFullPath() );
894 
895  if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
896  {
897  DisplayError( this, wxString::Format( _( "Failed to save backup to \"%s\"" ),
898  backupFileName.GetFullPath() ) );
899  return false;
900  }
901  }
902 
903  return true;
904 }
905 
906 
908 {
909  if( m_my_part && !GetCurLib().IsEmpty() && GetScreen()->IsModify() )
910  m_libMgr->UpdatePart( m_my_part, GetCurLib() ); // UpdatePart() makes a copy
911 }
912 
913 
914 bool LIB_EDIT_FRAME::isCurrentPart( const LIB_ID& aLibId ) const
915 {
916  // This will return the root part of any alias
917  LIB_PART* part = m_libMgr->GetBufferedPart( aLibId.GetLibItemName(), aLibId.GetLibNickname() );
918  // Now we can compare the libId of the current part and the root part
919  return ( part && GetCurPart() && part->GetLibId() == GetCurPart()->GetLibId() );
920 }
921 
922 
924 {
925  SetCurLib( wxEmptyString );
926  SetCurPart( nullptr );
929  m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
930  Refresh();
931 }
932 
933 
935 {
937 
941  Layout();
942  SendSizeEvent();
943 }
944 
945 
947 {
948  // call my base class
950 
951  // tooltips in toolbars
955 
956  // status bar
957  UpdateMsgPanel();
958 }
959 
960 
962 {
963  SCH_BASE_FRAME::SetScreen( aScreen );
964 }
965 
966 
968 {
972 
975 
976  GetCanvas()->Refresh();
977 }
978 
979 
981 {
982  SyncLibraries( true );
983  RebuildView();
984 }
985 
986 
988 {
989  LIB_PART* part = GetCurPart();
990 
991  if( !part )
992  {
993  return BOX2I( VECTOR2I(-100, -100), VECTOR2I( 200, 200 ) );
994  }
995  else
996  {
999  }
1000 }
1001 
1002 
1004 {
1005  const std::string& payload = mail.GetPayload();
1006 
1007  switch( mail.Command() )
1008  {
1009  case MAIL_LIB_EDIT:
1010  if( !payload.empty() )
1011  {
1012  wxString libFileName( payload );
1013  wxString libNickname;
1014  wxString msg;
1015 
1016  SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
1017  const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName );
1018 
1019  if( !libTableRow )
1020  {
1021  msg.Printf( _( "The current configuration does not include the symbol library\n"
1022  "\"%s\".\nUse Manage Symbol Libraries to edit the configuration." ),
1023  libFileName );
1024  DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
1025  break;
1026  }
1027 
1028  libNickname = libTableRow->GetNickName();
1029 
1030  if( !libTable->HasLibrary( libNickname, true ) )
1031  {
1032  msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n"
1033  "in the current configuration. Use Manage Symbol Libraries to\n"
1034  "edit the configuration." ), libNickname );
1035  DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
1036  break;
1037  }
1038 
1039  SetCurLib( libNickname );
1040 
1041  if( m_treePane )
1042  {
1043  LIB_ID id( libNickname, wxEmptyString );
1044  m_treePane->GetLibTree()->ExpandLibId( id );
1045  m_treePane->GetLibTree()->CenterLibId( id );
1046  }
1047  }
1048 
1049  break;
1050 
1051  default:
1052  ;
1053  }
1054 }
1055 
1056 
1057 void LIB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
1058 {
1059  // switches currently used canvas ( Cairo / OpenGL):
1061 
1062  // Set options specific to symbol editor (axies are always enabled):
1063  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
1064 }
1065 
1066 
1067 bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
1068 {
1069  bool keyHandled = false;
1070  wxPoint pos = aPosition;
1071 
1072  // Filter out the 'fake' mouse motion after a keyboard movement
1073  if( !aHotKey && m_movingCursorWithKeyboard )
1074  {
1076  return false;
1077  }
1078 
1079  if( aHotKey )
1080  keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
1081 
1082  if( GetToolId() == ID_NO_TOOL_SELECTED )
1083  m_canvas->CrossHairOff( aDC );
1084  else
1085  m_canvas->CrossHairOn( aDC );
1086 
1087  GetGalCanvas()->GetViewControls()->SetSnapping( false );
1088  SetCrossHairPosition( pos, false );
1089 
1090  if( m_canvas->IsMouseCaptured() )
1091  m_canvas->CallMouseCapture( aDC, aPosition, true );
1092 
1093  if( aHotKey && OnHotKey( aDC, aHotKey, aPosition, NULL ) )
1094  keyHandled = true;
1095 
1096  // Make sure current-part highlighting doesn't get lost in seleciton highlighting
1098 
1099  UpdateStatusBar();
1100 
1101  return keyHandled;
1102 }
1103 
void OnViewEntryDoc(wxCommandEvent &event)
#define TEXT_ANGLE_HORIZ
void SetScreen(BASE_SCREEN *aScreen) override
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:130
void Sync(bool aForce=false, std::function< void(int, int, const wxString &)> aProgressCallback=[](int, int, const wxString &){})
Updates the LIB_MANAGER data to synchronize with Symbol Library Table.
Definition: lib_manager.cpp:47
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
void OnToggleSearchTree(wxCommandEvent &event)
void OnCheckComponent(wxCommandEvent &event)
Definition: symbedit.cpp:230
void OnSaveAll(wxCommandEvent &aEvent)
Saves all modified parts and libraries.
Definition: libedit.cpp:320
int GetUnitCount() const
void OnUpdateEditingPart(wxUpdateUIEvent &event)
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
void OnUpdatePartNumber(wxUpdateUIEvent &event)
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: base_screen.h:231
void OnAddPartToSchematic(wxCommandEvent &event)
Add the current part to the schematic.
#define DEFAULTPINLENGTH
The default pin number size when creating pins(can be changed in preference menu)
Definition: general.h:64
void CommonSettingsChanged() override
Notification event that some of the common (suite-wide) settings have changed.
BOX2< VECTOR2I > BOX2I
Definition: box2.h:520
void SaveOneSymbol()
Saves the current symbol to a symbol file.
Definition: symbedit.cpp:151
Class KIWAY_EXPRESS carries a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
Part library alias object definition.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
#define LIB_EDIT_FRAME_NAME
Definition: draw_frame.h:50
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:61
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:179
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.
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Definition: ee_hotkeys.cpp:530
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
virtual void OnEditSymbolLibTable(wxCommandEvent &aEvent)
void OnOpenLibraryViewer(wxCommandEvent &event)
Open the library viewer only to browse library contents.
void OnExportPart(wxCommandEvent &event)
Creates a new library and backup the current component in this library or exports the component of th...
Definition: lib_export.cpp:100
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:258
LIB_ALIAS * GetAlias(size_t aIndex)
Model changes (required full reload)
Definition: tool_base.h:83
void OnCreateNewPart(wxCommandEvent &aEvent)
Creates a new part in the selected library.
Definition: libedit.cpp:328
Class ACTION_MENU.
Definition: action_menu.h:43
This file is part of the common library.
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:131
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
void OnEditSymbolLibTable(wxCommandEvent &aEvent) override
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
double BestZoom() override
Return the zoom level which displays the full page on screen.
This file is part of the common library.
void OnConfigurePaths(wxCommandEvent &aEvent)
Class LIB_DRAWING_TOOLS.
void CommonSettingsChanged() override
Called after the preferences dialog is run.
void OnUpdateSyncPinEdit(wxUpdateUIEvent &event)
bool Resolve(PART_LIBS *aLibs)
Assigns the current LIB_PART from aLibs which this symbol is based on.
void SetScrollCenterPosition(const wxPoint &aPoint)
void ClearSearchTreeSelection()
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Function KiwayMailIn receives KIWAY_EXPRESS messages from other players.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
EVT_TOOL(ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE, PCB_EDIT_FRAME::OnSelectOptionToolbar) EVT_TOOL_RANGE(ID_TB_OPTIONS_SHOW_ZONES
void OnImportBody(wxCommandEvent &aEvent)
virtual void OnActivate(wxActivateEvent &event) override
Called when the frame is activated.
void OnCloseWindow(wxCloseEvent &Event)
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Creates an empty library and adds it to the library table.
Definition: lib_manager.h:91
void OnImportPart(wxCommandEvent &event)
Routine to read one part.
Definition: lib_export.cpp:39
LIB_MANAGER * m_libMgr
manager taking care of temporary modificatoins
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int GetSelected() const
Function GetSelected() Returns the position of selected item.
Definition: action_menu.h:121
static TOOL_ACTION zoomFitScreen
Definition: actions.h:63
wxString SchematicLibraryFileWildcard()
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:125
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_DRAW_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void Process_Config(wxCommandEvent &event)
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:87
void SetSize(const Vec &size)
Definition: box2.h:210
void OnSelectBodyStyle(wxCommandEvent &event)
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
void OnUpdateDeMorganNormal(wxUpdateUIEvent &event)
void LoadOneSymbol()
Read a component symbol file (*.sym ) and add graphic items to the current component.
Definition: symbedit.cpp:44
Schematic editor (Eeschema) main window.
bool IsMenuActive() const
Returns the status of right-click context menu.
Definition: lib_tree.h:106
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
#define DEFAULT_REPEAT_OFFSET_PIN
the default value (overwritten by the eeschema config)
Definition: general.h:52
wxAuiManager m_auimgr
bool isCurrentPart(const LIB_ID &aLibId) const
Returns true if aLibId is an alias for the editor screen part.
bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0) override
Perform application specific control using aDC at aPosition in logical units.
ACTION_TOOLBAR * m_mainToolBar
Definition: draw_frame.h:156
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...
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.
Definition: draw_frame.h:82
void OnUpdateSave(wxUpdateUIEvent &aEvent)
bool IsValid() const
Definition: lib_id.h:171
void OnUpdatePaste(wxUpdateUIEvent &event)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
bool GetAutoplaceFields() const
void CloseWindow(wxCommandEvent &event)
Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
void OnUpdateDeMorganConvert(wxUpdateUIEvent &event)
LIB_ALIAS * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Returns either an alias of a working LIB_PART copy, or alias of the original part if there is no work...
void OnUpdateRevert(wxUpdateUIEvent &aEvent)
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
LIB_PART * m_my_part
a part I own, it is not in any library, but a copy could be.
void OnAddLibrary(wxCommandEvent &aEvent)
Adds an existing library.
const wxString & GetDocFileName() const
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
void GetKicadHelp(wxCommandEvent &event)
Library Editor pane with component tree and symbol library table selector.
bool GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Handle the common part of GeneralControl dedicated to global cursor keys (i.e.
void OnExportBody(wxCommandEvent &aEvent)
Class LIB_CONTROL.
Definition: lib_control.h:38
void OnPreferencesOptions(wxCommandEvent &event)
void OnSave(wxCommandEvent &aEvent)
Saves the selected part or library.
Definition: libedit.cpp:414
BOX2I boundingBox(T aObject)
boundingBox template method
Definition: shape_index.h:59
Class TOOL_MANAGER.
Definition: tool_manager.h:49
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
const wxString & GetNickName() const
void HideWorksheet()
Definition: sch_view.cpp:186
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Adds an existing library.
Definition: lib_manager.h:99
a helper to handle the real device context used in KiCad
virtual const BOX2I GetDocumentExtents() const override
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:321
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
wxString GetUniqueLibraryName() const
Returns a library name that is not currently in use.
void OnPasteDuplicatePart(wxCommandEvent &aEvent)
Definition: libedit.cpp:635
const std::string SchematicLibraryFileExtension
virtual void CrossHairOn(wxDC *DC=nullptr)
bool IsPartModified(const wxString &aAlias, const wxString &aLibrary) const
Returns true if part has unsaved modifications.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
const LIB_TABLE_ROW * FindRowByURI(const wxString &aURI)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
coord_type GetWidth() const
Definition: box2.h:195
TOOL_MANAGER * GetToolManager() const override
Return the tool manager instance, if any.
Definition: draw_frame.h:937
SCH_DRAW_PANEL * GetCanvas() const override
wxComboBox * m_partSelectBox
a Box to select a part to edit (if any)
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:147
const LIB_ID & GetLibId() const
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
void OnRemovePart(wxCommandEvent &aEvent)
Removes a part from the working copy of a library.
Definition: libedit.cpp:586
bool addLibraryFile(bool aCreateNew)
Creates or adds an existing library to the symbol library table.
Define a library symbol object.
void GetKicadAbout(wxCommandEvent &event)
Definition of file extensions used in Kicad.
void OnPlotCurrentComponent(wxCommandEvent &event)
Plot the current symbol in SVG or PNG format.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:177
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false)
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Saves Symbol Library Tables to disk.
virtual void CrossHairOff(wxDC *DC=nullptr)
uint32_t EDA_KEY
Definition: common.h:71
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
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
void SetCurrentLib(const wxString &aLibrary)
Sets the currently modified library name.
Definition: lib_manager.h:248
LIB_PART * GetPart() const
Get the shared LIB_PART.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:78
void SetCurrentPart(const wxString &aPart)
Sets the currently modified part name.
Definition: lib_manager.h:264
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
The the schematic editor to refresh the display.
Definition: mail_type.h:46
Specialization of the wxAuiPaneInfo class for KiCad panels.
void OnSyncPinEditClick(wxCommandEvent &event)
void RebuildSymbolUnitsList()
int SetLibItemName(const UTF8 &aLibItemName, bool aTestForRev=true)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:206
Class EESCHEMA_ACTIONS.
Definition: ee_actions.h:42
Class COMMON_TOOLS.
Definition: common_tools.h:38
void emptyScreen()
Restores the empty editor screen, without any part or library selected.
Class TOOL_DISPATCHER.
KIGFX::SCH_VIEW * GetView() const
bool UpdatePart(LIB_PART *aPart, const wxString &aLibrary)
Updates the part buffer with a new version of the part.
VTBL_ENTRY void SetRString(RSTRING_T aStringId, const wxString &aString)
Function SetRString stores a "retained string", which is any session and project specific string iden...
Definition: project.cpp:171
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar EVT_MENU(ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences) EVT_MENU(ID_PCB_LIB_TABLE_EDIT
Class to handle modifications to the symbol libraries.
Definition: lib_manager.h:49
void ExpandLibId(const LIB_ID &aLibId)
Expand and item i the tree widget.
Definition: lib_tree.cpp:182
void UpdateStatusBar() override
Update the status bar information.
void OnSaveAs(wxCommandEvent &aEvent)
Saves the selected part or library to a new name and/or location.
Definition: libedit.cpp:436
void storeCurrentPart()
Stores the currently modified part in the library manager buffer.
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:407
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
bool backupFile(const wxFileName &aOriginalFile, const wxString &aBackupExt)
Creates a backup copy of a file with requested extension
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:128
void SyncLibraries(bool aShowProgress)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
struct EDA_HOTKEY_CONFIG g_Libedit_Hotkeys_Descr[]
Definition: ee_hotkeys.cpp:407
VTBL_ENTRY const wxString & GetRString(RSTRING_T aStringId)
Function GetRString returns a "retained string", which is any session and project specific string ide...
Definition: project.cpp:186
LIB_PART * GetBufferedPart(const wxString &aAlias, const wxString &aLibrary)
Returns the part copy from the buffer.
The symbol library editor main window.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:100
BLOCK_SELECTOR m_clipboard
Clipboard buffer storing LIB_ITEMs
see class PGM_BASE
void ReCreateHToolbar() override
bool m_SyncPinEdit
Set to true to not synchronize pins at the same position when editing symbols with multiple units or ...
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Automatically orient all the fields in the component.
bool GetShowDeMorgan()
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
Vec Centre() const
Definition: box2.h:77
bool saveAllLibraries(bool aRequireConfirmation)
Definition: libedit.cpp:883
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 OnRevert(wxCommandEvent &aEvent)
Reverts unsaved changes in a part, restoring to the last saved state.
Definition: libedit.cpp:719
void OnEditPart(wxCommandEvent &aEvent)
Opens the selected part for editing.
Definition: libedit.cpp:406
void OnCopyCutPart(wxCommandEvent &aEvent)
Definition: libedit.cpp:607
void GetKicadContribute(wxCommandEvent &event)
void SetCurPart(LIB_PART *aPart)
Take ownership of aPart and notes that it is the one currently being edited.
#define max(a, b)
Definition: auxiliary.h:86
const wxString & GetName() const
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Returns true if library exists.
Class SCH_POINT_EDITOR.
void OnCreateNewLibrary(wxCommandEvent &aEvent)
Creates a new library.
virtual void SetScreen(BASE_SCREEN *aScreen) override
size_t i
Definition: json11.cpp:597
void SetIgnoreMouseEvents(bool aIgnore)
const EDA_RECT GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
void SetOrigin(const Vec &pos)
Definition: box2.h:208
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
LIB_ID getTargetLibId() const
Returns either the part selected in the component tree, if context menu is active or the currently mo...
coord_type GetHeight() const
Definition: box2.h:196
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void OnSelectUnit(wxCommandEvent &event)
bool IsMulti() const
#define DEFAULTPINNAMESIZE
The default library pane width.
Definition: general.h:70
LIB_PART * getTargetPart() const
Returns currently edited part.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:54
unsigned GetCount() const
bool IsLibraryModified(const wxString &aLibrary) const
Returns true if library has unsaved modifications.
void OnGridSettings(wxCommandEvent &aEvent) override
bool SynchronizePins()
Pin editing (add, delete, move...) can be synchronized between units when units are interchangeable b...
EVT_UPDATE_UI_RANGE(ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT, LIB_EDIT_FRAME::OnUpdateEditingPart) LIB_EDIT_FRAME
SCH_SCREEN * m_dummyScreen
Helper screen used when no part is loaded
void OnUpdateHavePart(wxUpdateUIEvent &aEvent)
wxString SetCurLib(const wxString &aLibNickname)
Sets the current library nickname and returns the old library nickname.
size_t GetAliasCount() const
SYMBOL_LIB_TABLE * selectSymLibTable(bool aOptional=false)
Displays a dialog asking the user to select a symbol library table.
void OnSwitchCanvas(wxCommandEvent &aEvent) override
switches currently used canvas ( Cairo / OpenGL).
void InitTools()
Function InitTools() Initializes all registered tools.
Definition for part library class.
const Vec & GetOrigin() const
Definition: box2.h:191
#define DEFAULTPINNUMSIZE
The default pin name size when creating pins(can be changed in preference menu)
Definition: general.h:67
void SetModify()
Definition: base_screen.h:324
MAIL_T Command()
Function Command returns the MAIL_T associated with this mail.
Definition: kiway_express.h:52
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
LIB_TREE * GetLibTree() const
SYMBOL_TREE_PANE * m_treePane
component search tree widget
BASE_SCREEN class implementation.
Message panel definition file.
ACTIONS * m_actions
Definition: draw_frame.h:132
LIB_TREE_MODEL_ADAPTER::PTR & GetAdapter()
Returns the adapter object that provides the stored data.
Definition: lib_manager.h:235
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:244
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
virtual void OnActivate(wxActivateEvent &event)
Called when activating the frame.
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:179
void DisplayComponent(const LIB_PART *aComponent)
std::string & GetPayload()
Function Payload returns the payload, which can be any text but it typicall self identifying s-expres...
Definition: kiway_express.h:62
bool IsLibraryReadOnly(const wxString &aLibrary) const
Returns true if the library is stored in a read-only file.
bool UnitsLocked() const
Check whether part units are interchangeable.
void Regenerate()
Updates the component tree
virtual void OnSwitchCanvas(wxCommandEvent &aEvent)
switches currently used canvas ( Cairo / OpenGL).
int GetToolId() const
Definition: draw_frame.h:524
wxString getTargetLib() const
Returns either the library selected in the component tree, if context menu is active or the library t...
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
int GetDefaultTextSize()
Default size for text in general.
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferrably centered).
Definition: lib_tree.cpp:171
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:165
virtual void UpdateMsgPanel()
Redraw the message panel.
ACTION_TOOLBAR * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:163
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
void ReCreateVToolbar() override
LIB_ALIASES GetAliases() const