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-2020 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 <base_screen.h>
27 #include <class_library.h>
28 #include <confirm.h>
29 #include <eeschema_id.h>
30 #include <eeschema_settings.h>
31 #include <fctsys.h>
32 #include <general.h>
33 #include <kiface_i.h>
34 #include <kiplatform/app.h>
35 #include <kiway_express.h>
36 #include <lib_edit_frame.h>
37 #include <lib_manager.h>
38 #include <lib_text.h>
39 #include <libedit_settings.h>
40 #include <pgm_base.h>
41 #include <sch_draw_panel.h>
42 #include <sch_painter.h>
43 #include <sch_view.h>
45 #include <symbol_lib_table.h>
46 #include <tool/action_manager.h>
47 #include <tool/action_toolbar.h>
48 #include <tool/common_control.h>
49 #include <tool/common_tools.h>
50 #include <tool/editor_conditions.h>
51 #include <tool/picker_tool.h>
52 #include <tool/selection.h>
53 #include <tool/tool_dispatcher.h>
54 #include <tool/tool_manager.h>
55 #include <tool/zoom_tool.h>
56 #include <tools/ee_actions.h>
58 #include <tools/ee_point_editor.h>
60 #include <tools/lib_control.h>
62 #include <tools/lib_edit_tool.h>
63 #include <tools/lib_move_tool.h>
64 #include <tools/lib_pin_tool.h>
66 #include <widgets/infobar.h>
67 #include <widgets/lib_tree.h>
70 
71 
72 bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
73 
74 
75 BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
76  EVT_SIZE( LIB_EDIT_FRAME::OnSize )
77 
79 
80  // Right vertical toolbar.
83 
84  // menubar commands
85  EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::OnExitKiCad )
86  EVT_MENU( wxID_CLOSE, LIB_EDIT_FRAME::CloseWindow )
88 
89  // Update user interface elements.
91 
92 END_EVENT_TABLE()
93 
94 
95 LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
96  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
97  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
99  m_unitSelectBox( nullptr ),
100  m_isSymbolFromSchematic( false )
101 {
102  SetShowDeMorgan( false );
103  m_SyncPinEdit = false;
104 
105  m_my_part = nullptr;
106  m_treePane = nullptr;
107  m_libMgr = nullptr;
108  m_unit = 1;
109  m_convert = 1;
110  m_AboutTitle = "LibEdit";
111 
112  wxIcon icon;
113  icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) );
114  SetIcon( icon );
115 
116  m_settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
117  LoadSettings( m_settings );
118 
119  // Ensure axis are always drawn
120  KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
121  gal_opts.m_axesEnabled = true;
122 
123  m_dummyScreen = new SCH_SCREEN();
124  SetScreen( m_dummyScreen );
125  GetScreen()->m_Center = true;
126 
127  GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
128 
129  GetRenderSettings()->LoadColors( GetColorSettings() );
130 
131  setupTools();
132  setupUIConditions();
133 
134  m_libMgr = new LIB_MANAGER( *this );
135  SyncLibraries( true );
136  m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
137 
138  ReCreateMenuBar();
139  ReCreateHToolbar();
140  ReCreateVToolbar();
141  ReCreateOptToolbar();
142  InitExitKey();
143 
144  updateTitle();
145  DisplayCmpDoc();
146  RebuildSymbolUnitsList();
147 
148  // Create the infobar
149  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
150 
151  m_auimgr.SetManagedWindow( this );
152 
153  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
154  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
155 
156  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
157  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "ComponentTree" ).Left().Layer(2)
158  .Caption( _( "Libraries" ) ).MinSize( 250, -1 )
159  .BestSize( m_settings->m_LibWidth, -1 ).Resizable() );
160  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
161  m_auimgr.AddPane( m_infoBar,
162  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
163 
164  m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
165 
166  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
167  // hidding it.
168  m_auimgr.Update();
169 
170  // We don't want the infobar displayed right away
171  m_auimgr.GetPane( "InfoBar" ).Hide();
172  m_auimgr.Update();
173 
174  Raise();
175  Show( true );
176 
177  SyncView();
178  GetCanvas()->GetView()->UseDrawPriority( true );
179  GetCanvas()->GetGAL()->SetAxesEnabled( true );
180 
181  // Set the working/draw area size to display a symbol to a reasonable value:
182  // A 600mm x 600mm with a origin at the area center looks like a large working area
183  double max_size_x = Millimeter2iu( 600 );
184  double max_size_y = Millimeter2iu( 600 );
185  BOX2D bbox;
186  bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
187  bbox.SetSize( max_size_x, max_size_y );
188  GetCanvas()->GetView()->SetBoundary( bbox );
189 
190  m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
191 
192  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Library changes are unsaved" ) );
193 
194  // Ensure the window is on top
195  Raise();
196 }
197 
198 
200 {
201  // Shutdown all running tools
202  if( m_toolManager )
204 
205  if( IsSymbolFromSchematic() )
206  {
207  delete m_my_part;
208  m_my_part = nullptr;
209 
210  SCH_SCREEN* screen = GetScreen();
211  delete screen;
212  m_isSymbolFromSchematic = false;
213  }
214  // current screen is destroyed in EDA_DRAW_FRAME
216 
217  auto libedit = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
218  Pgm().GetSettingsManager().Save( libedit );
219 
220  delete m_libMgr;
221 }
222 
223 
225 {
226  wxCHECK_RET( m_settings, "Call to LIB_EDIT_FRAME::LoadSettings with null m_settings" );
227 
229 
231 
232  // Hidden elements must be editable
236 }
237 
238 
240 {
241  wxCHECK_RET( m_settings, "Call to LIB_EDIT_FRAME::LoadSettings with null m_settings" );
242 
244 
246  m_settings->m_LibWidth = m_treePane->GetSize().x;
247 }
248 
249 
251 {
252  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
253 
254  if( GetSettings()->m_UseEeschemaColorSettings )
256  else
257  return mgr.GetColorSettings( GetSettings()->m_ColorTheme );
258 }
259 
260 
262 {
263  // Create the manager and dispatcher & route draw panel events to the dispatcher
266  GetCanvas()->GetViewControls(), config(), this );
267  m_actions = new EE_ACTIONS();
269 
270  // Register tools
284 
285  // Run the selection tool, it is supposed to be always active
286  m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
287 
289 }
290 
291 
293 {
295 
297  EDITOR_CONDITIONS cond( this );
298 
299  wxASSERT( mgr );
300 
301 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
302 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
303 
304  auto haveSymbolCond =
305  [this] ( const SELECTION& )
306  {
307  return m_my_part;
308  };
309 
310  auto libMgrModifiedCond =
311  [this] ( const SELECTION& )
312  {
313  if( IsSymbolFromSchematic() )
314  return GetScreen() && GetScreen()->IsModify();
315  else
316  return m_libMgr->HasModifications();
317  };
318 
319  auto modifiedDocumentCondition =
320  [this] ( const SELECTION& sel )
321  {
322  LIB_ID libId = getTargetLibId();
323  const wxString& libName = libId.GetLibNickname();
324  const wxString& partName = libId.GetLibItemName();
325 
326  bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
327 
328  if( partName.IsEmpty() )
329  return ( !readOnly && m_libMgr->IsLibraryModified( libName ) );
330  else
331  return ( !readOnly && m_libMgr->IsPartModified( partName, libName ) );
332  };
333 
334  mgr->SetConditions( ACTIONS::saveAll, ENABLE( libMgrModifiedCond ) );
335  mgr->SetConditions( ACTIONS::save, ENABLE( haveSymbolCond && modifiedDocumentCondition ) );
336  mgr->SetConditions( EE_ACTIONS::saveInSchematic, ENABLE( libMgrModifiedCond ) );
337  mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) );
338  mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) );
339  mgr->SetConditions( ACTIONS::revert, ENABLE( haveSymbolCond && modifiedDocumentCondition ) );
340 
347 
348  mgr->SetConditions( ACTIONS::cut, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) );
350  mgr->SetConditions( ACTIONS::paste, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::Idle ) );
353  mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
354 
357 
358  auto pinTypeCond =
359  [this] ( const SELECTION& )
360  {
362  };
363 
364  auto showCompTreeCond =
365  [this] ( const SELECTION& )
366  {
367  return IsSearchTreeShown();
368  };
369 
370  mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) );
371  mgr->SetConditions( EE_ACTIONS::showComponentTree, CHECK( showCompTreeCond ) );
372 
373  auto isEditableCond =
374  [this] ( const SELECTION& )
375  {
376  // Only root symbols are editable
377  return m_my_part && m_my_part->IsRoot();
378  };
379 
380  auto demorganCond =
381  [this] ( const SELECTION& )
382  {
383  return GetShowDeMorgan();
384  };
385 
386  auto demorganStandardCond =
387  [this] ( const SELECTION& )
388  {
389  return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
390  };
391 
392  auto demorganAlternateCond =
393  [this] ( const SELECTION& )
394  {
395  return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
396  };
397 
398  auto multiUnitModeCond =
399  [this] ( const SELECTION& )
400  {
401  return m_my_part && m_my_part->IsMulti() && !m_my_part->UnitsLocked();
402  };
403 
404  auto syncedPinsModeCond =
405  [this] ( const SELECTION& )
406  {
407  return m_SyncPinEdit;
408  };
409 
410  auto haveDatasheetCond =
411  [this] ( const SELECTION& )
412  {
413  return m_my_part && !m_my_part->GetDatasheetField().GetText().IsEmpty();
414  };
415 
416  mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
417  mgr->SetConditions( EE_ACTIONS::symbolProperties, ENABLE( haveSymbolCond ) );
418  mgr->SetConditions( EE_ACTIONS::runERC, ENABLE( isEditableCond) );
419  mgr->SetConditions( EE_ACTIONS::pinTable, ENABLE( isEditableCond) );
420 
422  ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
424  ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
426  ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) );
427 
428 // Only enable a tool if the part is edtable
429 #define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) )
430 
439 
442 
443 #undef CHECK
444 #undef ENABLE
445 #undef EDIT_TOOL
446 }
447 
448 
449 bool LIB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
450 {
451  // Shutdown blocks must be determined and vetoed as early as possible
452  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
453  && IsContentModified() )
454  {
455  return false;
456  }
457 
458  if( !saveAllLibraries( true ) )
459  {
460  return false;
461  }
462 
463  return true;
464 }
465 
466 
468 {
469  Destroy();
470 }
471 
472 
474 {
475  if( !m_unitSelectBox )
476  return;
477 
478  if( m_unitSelectBox->GetCount() != 0 )
479  m_unitSelectBox->Clear();
480 
481  if( !m_my_part || m_my_part->GetUnitCount() <= 1 )
482  {
483  m_unit = 1;
484  m_unitSelectBox->Append( wxEmptyString );
485  }
486  else
487  {
488  for( int i = 0; i < m_my_part->GetUnitCount(); i++ )
489  {
490  wxString sub = LIB_PART::SubReference( i+1, false );
491  wxString unit = wxString::Format( _( "Unit %s" ), GetChars( sub ) );
492  m_unitSelectBox->Append( unit );
493  }
494  }
495 
496  // Ensure the selected unit is compatible with the number of units of the current part:
497  if( m_my_part && m_my_part->GetUnitCount() < m_unit )
498  m_unit = 1;
499 
500  m_unitSelectBox->SetSelection(( m_unit > 0 ) ? m_unit - 1 : 0 );
501 }
502 
503 
504 void LIB_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event )
505 {
506  auto& treePane = m_auimgr.GetPane( m_treePane );
507  treePane.Show( !IsSearchTreeShown() );
508  m_auimgr.Update();
509 }
510 
511 
513 {
514  return m_auimgr.GetPane( m_treePane ).IsShown();
515 }
516 
517 
519 {
520  m_libMgr->GetAdapter()->Freeze();
521 }
522 
523 
525 {
526  m_libMgr->GetAdapter()->Thaw();
527 }
528 
529 
530 void LIB_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
531 {
532  Kiway().OnKiCadExit();
533 }
534 
535 
536 void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
537 {
538  if( !m_unitSelectBox )
539  return;
540 
541  // Using the typical event.Enable() call doesn't seem to work with wxGTK
542  // so use the pointer to alias combobox to directly enable or disable.
543  m_unitSelectBox->Enable( m_my_part && m_my_part->GetUnitCount() > 1 );
544 }
545 
546 
547 void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
548 {
549  int i = event.GetSelection();
550 
551  if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
552  return;
553 
556 
557  m_unit = i + 1;
558 
560  RebuildView();
561 }
562 
563 
565 {
566  wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
567 
568  if( !libNickname.empty() )
569  {
570  if( !Prj().SchSymbolLibTable()->HasLibrary( libNickname ) )
571  {
572  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
573  libNickname = wxEmptyString;
574  }
575  }
576 
577  return libNickname;
578 }
579 
580 
581 wxString LIB_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
582 {
583  wxString old = GetCurLib();
584 
585  if( aLibNickname.empty() || !Prj().SchSymbolLibTable()->HasLibrary( aLibNickname ) )
586  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
587  else
588  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname );
589 
590  m_libMgr->SetCurrentLib( aLibNickname );
591 
592  return old;
593 }
594 
595 
597 {
599 
600  delete m_my_part;
601  m_my_part = aPart;
602 
603  // select the current component in the tree widget
604  if( !IsSymbolFromSchematic() && m_my_part )
605  {
607  }
608  else
609  {
611  m_libMgr->SetCurrentLib( wxEmptyString );
612  m_libMgr->SetCurrentPart( wxEmptyString );
613  }
614 
615  wxString partName = m_my_part ? m_my_part->GetName() : wxString();
616 
617  // retain in case this wxFrame is re-opened later on the same PROJECT
619 
620  // Ensure synchronized pin edit can be enabled only symbols with interchangeable units
621  m_SyncPinEdit = aPart && aPart->IsRoot() && aPart->IsMulti() && !aPart->UnitsLocked();
622 
623  if( IsSymbolFromSchematic() )
624  {
625  wxString msg;
626  msg.Printf( _( "Editing symbol %s from schematic. Saving will update the schematic "
627  "only." ), m_reference );
628 
630  GetInfoBar()->ShowMessage( msg, wxICON_INFORMATION );
631  }
632 
634  RebuildView();
635 }
636 
637 
639 {
640  wxASSERT( m_libMgr );
641  return *m_libMgr;
642 }
643 
644 
645 void LIB_EDIT_FRAME::OnImportBody( wxCommandEvent& aEvent )
646 {
648  LoadOneSymbol();
649  m_drawToolBar->ToggleTool( ID_LIBEDIT_IMPORT_BODY_BUTT, false );
650 }
651 
652 
653 void LIB_EDIT_FRAME::OnExportBody( wxCommandEvent& aEvent )
654 {
656  SaveOneSymbol();
657  m_drawToolBar->ToggleTool( ID_LIBEDIT_EXPORT_BODY_BUTT, false );
658 }
659 
660 
662 {
663  GetScreen()->SetModify();
665 
667 }
668 
669 
671 {
673 }
674 
675 
677 {
678  // There may be no parent window so use KIWAY message to refresh the schematic editor
679  // in case any symbols have changed.
680  std::string dummyPayload;
681  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_REFRESH, dummyPayload, this );
682 }
683 
684 
685 bool LIB_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
686 {
687  wxFileName fn = m_libMgr->GetUniqueLibraryName();
688 
689  if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(),
690  KiCadSymbolLibFileExtension, false ) )
691  {
692  return false;
693  }
694 
695  wxString libName = fn.GetName();
696 
697  if( libName.IsEmpty() )
698  return false;
699 
700  if( m_libMgr->LibraryExists( libName ) )
701  {
702  DisplayError( this, wxString::Format( _( "Library \"%s\" already exists" ), libName ) );
703  return false;
704  }
705 
706  // Select the target library table (global/project)
707  SYMBOL_LIB_TABLE* libTable = selectSymLibTable();
708 
709  if( !libTable )
710  return false;
711 
712  if( aCreateNew )
713  {
714  if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
715  {
716  DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
717  "Check write permission." ),
718  fn.GetFullPath() ) );
719  return false;
720  }
721  }
722  else
723  {
724  if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
725  {
726  DisplayError( this, _( "Could not open the library file." ) );
727  return false;
728  }
729  }
730 
731  bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
732  saveSymbolLibTables( globalTable, !globalTable );
733 
734  return true;
735 }
736 
737 
739 {
740  return m_treePane->GetLibTree()->GetSelectedLibId( aUnit );
741 }
742 
743 
745 {
746  LIB_ID libId = GetTreeLIBID();
747 
748  if( libId.IsValid() )
749  {
750  LIB_PART* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
751  return alias;
752  }
753 
754  return m_my_part;
755 }
756 
757 
759 {
760  LIB_ID id = GetTreeLIBID();
761 
762  if( id.GetLibNickname().empty() && m_my_part )
763  id = m_my_part->GetLibId();
764 
765  return id;
766 }
767 
768 
770 {
772 }
773 
774 
776 {
777  return getTargetLibId().GetLibNickname();
778 }
779 
780 
781 void LIB_EDIT_FRAME::SyncLibraries( bool aShowProgress )
782 {
783  LIB_ID selected;
784 
785  if( m_treePane )
786  selected = m_treePane->GetLibTree()->GetSelectedLibId();
787 
788  if( aShowProgress )
789  {
790  APP_PROGRESS_DIALOG progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
791  m_libMgr->GetAdapter()->GetLibrariesCount(), this );
792 
793  m_libMgr->Sync( true, [&]( int progress, int max, const wxString& libName )
794  {
795  progressDlg.Update( progress, wxString::Format( _( "Loading library \"%s\"" ),
796  libName ) );
797  } );
798  }
799  else
800  {
801  m_libMgr->Sync( true );
802  }
803 
804  if( m_treePane )
805  {
806  wxDataViewItem found;
807 
808  if( selected.IsValid() )
809  {
810  // Check if the previously selected item is still valid,
811  // if not - it has to be unselected to prevent crash
812  found = m_libMgr->GetAdapter()->FindItem( selected );
813 
814  if( !found )
816  }
817 
818  m_treePane->GetLibTree()->Regenerate( true );
819 
820  // Try to select the parent library, in case the part is not found
821  if( !found && selected.IsValid() )
822  {
823  selected.SetLibItemName( "" );
824  found = m_libMgr->GetAdapter()->FindItem( selected );
825 
826  if( found )
827  m_treePane->GetLibTree()->SelectLibId( selected );
828  }
829 
830  // If no selection, see if there's a current part to centre
831  if( !selected.IsValid() && m_my_part )
832  {
833  LIB_ID current( GetCurLib(), m_my_part->GetName() );
834  m_treePane->GetLibTree()->CenterLibId( current );
835  }
836  }
837 }
838 
839 
841 {
842  LIB_ID target = getTargetLibId();
843 
844  m_treePane->GetLibTree()->Regenerate( true );
845 
846  if( target.IsValid() )
847  m_treePane->GetLibTree()->CenterLibId( target );
848 }
849 
850 
852 {
853  // If no project is loaded, always work with the global table
854  if( Prj().IsNullProject() )
855  {
857 
858  if( aOptional )
859  {
860  wxMessageDialog dlg( this, _( "Add the library to the global library table?" ),
861  _( "Add To Global Library Table" ), wxYES_NO );
862 
863  if( dlg.ShowModal() != wxID_OK )
864  ret = nullptr;
865  }
866 
867  return ret;
868  }
869 
870  wxArrayString libTableNames;
871  libTableNames.Add( _( "Global" ) );
872  libTableNames.Add( _( "Project" ) );
873 
874  wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
875  _( "Add To Library Table" ), libTableNames );
876 
877  if( aOptional )
878  {
879  dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
880  dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
881  }
882 
883  if( dlg.ShowModal() != wxID_OK )
884  return nullptr;
885 
886  switch( dlg.GetSelection() )
887  {
888  case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
889  case 1: return Prj().SchSymbolLibTable();
890  default: return nullptr;
891  }
892 }
893 
894 
895 bool LIB_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
896 {
897  if( aOriginalFile.FileExists() )
898  {
899  wxFileName backupFileName( aOriginalFile );
900  backupFileName.SetExt( aBackupExt );
901 
902  if( backupFileName.FileExists() )
903  wxRemoveFile( backupFileName.GetFullPath() );
904 
905  if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
906  {
907  DisplayError( this, wxString::Format( _( "Failed to save backup to \"%s\"" ),
908  backupFileName.GetFullPath() ) );
909  return false;
910  }
911  }
912 
913  return true;
914 }
915 
916 
918 {
919  if( m_my_part && !GetCurLib().IsEmpty() && GetScreen()->IsModify() )
920  m_libMgr->UpdatePart( m_my_part, GetCurLib() ); // UpdatePart() makes a copy
921 }
922 
923 
924 bool LIB_EDIT_FRAME::isCurrentPart( const LIB_ID& aLibId ) const
925 {
926  // This will return the root part of any alias
927  LIB_PART* part = m_libMgr->GetBufferedPart( aLibId.GetLibItemName(), aLibId.GetLibNickname() );
928  // Now we can compare the libId of the current part and the root part
929  return ( part && m_my_part && part->GetLibId() == m_my_part->GetLibId() );
930 }
931 
932 
934 {
936  SetCurLib( wxEmptyString );
937  SetCurPart( nullptr );
941  Refresh();
942 }
943 
944 
945 void LIB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
946 {
947  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
948 
950 
952 
953  if( aEnvVarsChanged )
954  SyncLibraries( true );
955 
956  Layout();
957  SendSizeEvent();
958 }
959 
960 
962 {
963  // call my base class
965 
966  // tooltips in toolbars
968 
969  // status bar
970  UpdateMsgPanel();
971 }
972 
973 
975 {
976  SCH_BASE_FRAME::SetScreen( aScreen );
977 }
978 
979 
981 {
988 
989  GetCanvas()->Refresh();
990 }
991 
992 
994 {
995  SyncLibraries( true );
996 
997  if( m_my_part )
998  {
1000  EE_SELECTION& selection = selectionTool->GetSelection();
1001 
1002  for( LIB_ITEM& item : m_my_part->GetDrawItems() )
1003  {
1004  if( std::find( selection.begin(), selection.end(), &item ) == selection.end() )
1005  item.ClearSelected();
1006  else
1007  item.SetSelected();
1008  }
1009  }
1010 
1011  RebuildView();
1012 }
1013 
1014 
1016 {
1017  if( !m_my_part )
1018  {
1019  return BOX2I( VECTOR2I( Mils2iu( -100 ), Mils2iu( -100 ) ),
1020  VECTOR2I( Mils2iu( 200 ), Mils2iu( 200 ) ) );
1021  }
1022  else
1023  {
1024  EDA_RECT boundingBox = m_my_part->Flatten()->GetUnitBoundingBox( m_unit, m_convert );
1026  boundingBox.GetHeight() ) );
1027  }
1028 }
1029 
1030 
1032 {
1033  const std::string& payload = mail.GetPayload();
1034 
1035  switch( mail.Command() )
1036  {
1037  case MAIL_LIB_EDIT:
1038  if( !payload.empty() )
1039  {
1040  wxString libFileName( payload );
1041  wxString libNickname;
1042  wxString msg;
1043 
1044  SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
1045  const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName );
1046 
1047  if( !libTableRow )
1048  {
1049  msg.Printf( _( "The current configuration does not include the symbol library\n"
1050  "\"%s\".\nUse Manage Symbol Libraries to edit the configuration." ),
1051  libFileName );
1052  DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
1053  break;
1054  }
1055 
1056  libNickname = libTableRow->GetNickName();
1057 
1058  if( !libTable->HasLibrary( libNickname, true ) )
1059  {
1060  msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n"
1061  "in the current configuration. Use Manage Symbol Libraries to\n"
1062  "edit the configuration." ), libNickname );
1063  DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
1064  break;
1065  }
1066 
1067  SetCurLib( libNickname );
1068 
1069  if( m_treePane )
1070  {
1071  LIB_ID id( libNickname, wxEmptyString );
1072  m_treePane->GetLibTree()->ExpandLibId( id );
1073  m_treePane->GetLibTree()->CenterLibId( id );
1074  }
1075  }
1076 
1077  break;
1078 
1079  default:
1080  ;
1081  }
1082 }
1083 
1084 
1086 {
1087  // switches currently used canvas ( Cairo / OpenGL):
1088  SCH_BASE_FRAME::SwitchCanvas( aCanvasType );
1089 
1090  // Set options specific to symbol editor (axies are always enabled):
1091  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1093 }
1094 
1095 
1097 {
1098  wxCHECK( m_libMgr, false );
1099 
1100  return m_libMgr->HasModifications();
1101 }
1102 
1103 
1105 {
1106  wxCHECK( m_libMgr, false );
1107 
1108  // Test if the currently edited part is modified
1109  if( GetScreen() && GetScreen()->IsModify() && GetCurPart() )
1110  return true;
1111 
1112  // Test if any library has been modified
1113  for( const auto& libNickname : m_libMgr->GetLibraryNames() )
1114  {
1115  if( m_libMgr->IsLibraryModified( libNickname )
1116  && !m_libMgr->IsLibraryReadOnly( libNickname ) )
1117  return true;
1118  }
1119 
1120  return false;
1121 }
1122 
1123 
1124 void LIB_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
1125 {
1126  if( aItemCount == 0 )
1127  return;
1128 
1129  UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
1130 
1131  for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
1132  {
1133  command->ClearListAndDeleteItems();
1134  delete command;
1135  }
1136 
1137  list.m_CommandsList.clear();
1138 }
1139 
1140 
1142 {
1143  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1144 }
1145 
1146 
1147 void LIB_EDIT_FRAME::LoadSymbolFromSchematic( const std::unique_ptr<LIB_PART>& aSymbol,
1148  const wxString& aReference, int aUnit, int aConvert )
1149 {
1150  std::unique_ptr<LIB_PART> symbol = aSymbol->Flatten();
1151  wxCHECK( symbol, /* void */ );
1152 
1153  if( m_my_part )
1154  SetCurPart( nullptr );
1155 
1156  m_isSymbolFromSchematic = true;
1157  m_reference = aReference;
1158  m_unit = aUnit > 0 ? aUnit : 1;
1159  m_convert = aConvert > 0 ? aConvert : 1;
1160 
1161  // The buffered screen for the part
1162  SCH_SCREEN* tmpScreen = new SCH_SCREEN();
1163 
1164  SetScreen( tmpScreen );
1165  SetCurPart( symbol.release() );
1166 
1168  ReCreateMenuBar();
1169  ReCreateHToolbar();
1170 
1171  if( IsSearchTreeShown() )
1172  {
1173  wxCommandEvent evt;
1174  OnToggleSearchTree( evt );
1175  }
1176 
1177  updateTitle();
1179  SetShowDeMorgan( GetCurPart()->HasConversion() );
1180  DisplayCmpDoc();
1181  Refresh();
1182 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
void doCloseWindow() override
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
static TOOL_ACTION pinTable
Definition: ee_actions.h:146
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:49
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:119
void OnToggleSearchTree(wxCommandEvent &event)
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
void OnUpdatePartNumber(wxUpdateUIEvent &event)
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:140
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:102
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:106
BOX2< VECTOR2I > BOX2I
Definition: box2.h:522
void SaveOneSymbol()
Saves the current symbol to a symbol file.
Definition: symbedit.cpp:143
KIWAY_EXPRESS carries a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
void OnKiCadExit()
Definition: kiway.cpp:585
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:191
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
LIB_ID GetLibId() const override
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
int m_convert
Flag if the symbol being edited was loaded directly from a schematic.
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
wxString GetName() const override
Model changes (required full reload)
Definition: tool_base.h:82
static TOOL_ACTION runERC
Definition: ee_actions.h:141
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:75
SELECTION_CONDITION FullscreenCursor()
Creates a functor testing if the cursor is full screen in a frame.
virtual void SetScreen(BASE_SCREEN *aScreen)
UNDO_REDO_CONTAINER m_undoList
#define ENABLE(x)
static TOOL_ACTION zoomTool
Definition: actions.h:97
LIB_DRAWING_TOOLS.
LIBEDIT_SETTINGS * m_settings
static bool Idle(const SELECTION &aSelection)
Tests if there no items selected or being edited.
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Function KiwayMailIn receives KIWAY_EXPRESS messages from other players.
void OnImportBody(wxCommandEvent &aEvent)
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Creates an empty library and adds it to the library table.
Definition: lib_manager.h:138
LIB_MANAGER * m_libMgr
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Creates a functor testing if the specified tool is the current active tool in the frame.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:94
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of ckeck tools.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
static TOOL_ACTION standardGraphics
Definition: actions.h:162
virtual void RegisterUIUpdateHandler(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions) override
Register an action's update conditions with the UI layer to allow the UI to appropriately display the...
void SetSize(const Vec &size)
Definition: box2.h:212
SELECTION_CONDITION CanvasType(EDA_DRAW_PANEL_GAL::GAL_TYPE aType)
Creates a functor testing if the specified canvas is active in the frame.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
void LoadSymbolFromSchematic(const std::unique_ptr< LIB_PART > &aSymbol, const wxString &aReference, int aUnit, int aConvert)
Load a symbol from the schematic to edit in place.
void LoadOneSymbol()
Read a component symbol file (*.sym ) and add graphic items to the current component.
Definition: symbedit.cpp:43
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
switches currently used canvas ( Cairo / OpenGL).
LIB_PART * GetCurPart()
Return the current part being edited or NULL if none selected.
SELECTION_CONDITION RedoAvailable()
Creates a functor that tests if there are any items in the redo queue.
wxAuiManager m_auimgr
bool isCurrentPart(const LIB_ID &aLibId) const
Returns true if aLibId is an alias for the editor screen part.
wxString m_reference
The reference of the symbol.
static TOOL_ACTION showComponentTree
Definition: ee_actions.h:202
ACTION_MANAGER.
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:594
void CloseWindow(wxCommandEvent &event)
Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:128
#define EDIT_TOOL(tool)
static TOOL_ACTION imperialUnits
Definition: actions.h:142
static bool NotEmpty(const SELECTION &aSelection)
Tests if there are any items selected.
Class that groups generic conditions for editor states.
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
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
void SetShowDeMorgan(bool show)
static TOOL_ACTION drawSymbolRectangle
Definition: ee_actions.h:103
bool m_axesEnabled
Whether or not to draw the coordinate system axes
#define CHECK(x)
Library Editor pane with component tree and symbol library table selector.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void OnExportBody(wxCommandEvent &aEvent)
Handle actions for the various symbol editor and viewers.
Definition: lib_control.h:37
LIB_PART * 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...
#define LIB_EDIT_FRAME_NAME
EE_SELECTION & GetSelection()
Function GetSelection()
bool AddLibraryFile(bool aCreateNew)
Creates or adds an existing library to the symbol library table.
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:51
BOX2I boundingBox(T aObject)
boundingBox template method
Definition: shape_index.h:60
TOOL_MANAGER.
Definition: tool_manager.h:51
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
UNDO_REDO_CONTAINER is a holder to handle alist of undo (or redo) command.
static TOOL_ACTION copy
Definition: actions.h:70
const wxString & GetNickName() const
void HideWorksheet()
Definition: sch_view.cpp:198
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:101
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Adds an existing library.
Definition: lib_manager.h:146
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
const BOX2I GetDocumentExtents() const override
SELECTION_CONDITION GridVisible()
Creates a functor testing if the grid is visible in a frame.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
int GetUnitCount() const override
For items with units, return the number of units.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
bool GetShowDeMorgan() const
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:168
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from aList element.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Creates a functor that tests if the frame has the specified units.
void ReCreateMenuBar() override
Recreates the menu bar.
wxString GetUniqueLibraryName() const
Returns a library name that is not currently in use.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
static TOOL_ACTION toggleGrid
Definition: actions.h:138
bool IsPartModified(const wxString &aAlias, const wxString &aLibrary) const
Returns true if part has unsaved modifications.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
const LIB_TABLE_ROW * FindRowByURI(const wxString &aURI)
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:43
coord_type GetWidth() const
Definition: box2.h:197
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:145
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
bool IsSymbolFromSchematic() const
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:150
ACTIONS * m_actions
Definition: tools_holder.h:51
static TOOL_ACTION cut
Definition: actions.h:69
static TOOL_ACTION drawSymbolCircle
Definition: ee_actions.h:104
Define a library symbol object.
void Regenerate(bool aKeepState)
Regenerates the tree.
Definition: lib_tree.cpp:202
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:191
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)
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Saves Symbol Library Tables to disk.
wxArrayString GetLibraryNames() const
Returns the array of library names.
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
AppSettings * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
wxString KiCadSymbolLibFileWildcard()
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:40
#define KICAD_DEFAULT_DRAWFRAME_STYLE
bool IsModify() const
Definition: base_screen.h:104
void SetCurrentLib(const wxString &aLibrary)
Definition: lib_manager.h:282
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void SetCurrentPart(const wxString &aPart)
Definition: lib_manager.h:288
PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
COMMON_CONTROL.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:220
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
Specialization of the wxAuiPaneInfo class for KiCad panels.
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:127
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:201
UNDO_REDO_CONTAINER m_redoList
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:212
void RebuildSymbolUnitsList()
static TOOL_ACTION saveInSchematic
Definition: ee_actions.h:181
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...
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
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:52
EESCHEMA_ACTIONS.
Definition: ee_actions.h:41
COMMON_TOOLS.
Definition: common_tools.h:38
void emptyScreen()
Restores the empty editor screen, without any part or library selected.
COLOR_SETTINGS * m_colorSettings
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
bool UpdatePart(LIB_PART *aPart, const wxString &aLibrary)
Updates the part buffer with a new version of the part.
void DisplayCmpDoc()
Display the documentation of the selected component.
Definition: symbedit.cpp:204
void updateTitle()
Updates the main window title bar with the current library name and read only status of the library.
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:214
bool IsContentModified() override
Get if any parts or libraries have been modified but not saved.
UNDO_REDO_LIST
Function ClearUndoORRedoList (virtual).
Class to handle modifications to the symbol libraries.
Definition: lib_manager.h:99
void ExpandLibId(const LIB_ID &aLibId)
Expand and item i the tree widget.
Definition: lib_tree.cpp:196
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
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:437
bool backupFile(const wxFileName &aOriginalFile, const wxString &aBackupExt)
Creates a backup copy of a file with requested extension
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
static TOOL_ACTION metricUnits
Definition: actions.h:143
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
void SyncLibraries(bool aShowProgress)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
static TOOL_ACTION redo
Definition: actions.h:68
const BITMAP_OPAQUE icon_libedit_xpm[1]
COLOR4D GetColor(int aLayer) const
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:229
LIB_PART * GetBufferedPart(const wxString &aAlias, const wxString &aLibrary)
Returns the part copy from the buffer.
The symbol library editor main window.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:50
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:153
see class PGM_BASE
void ReCreateHToolbar() override
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
bool HasLibModifications() const
Check if any pending libraries have been modified.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
bool saveAllLibraries(bool aRequireConfirmation)
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:201
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
void SetCurPart(LIB_PART *aPart)
Take ownership of aPart and notes that it is the one currently being edited.
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:199
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Returns true if library exists.
EE_POINT_EDITOR.
SELECTION_CONDITION UndoAvailable()
Creates a functor that tests if there are any items in the undo queue.
bool m_isSymbolFromSchematic
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
void SetScreen(BASE_SCREEN *aScreen) override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:161
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnToggleShowLayerManager GERBVIEW_FRAME::OnSelectHighlightChoice EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnUpdateLayerSelectBox) EVT_UPDATE_UI_RANGE(ID_TB_OPTIONS_SHOW_GBR_MODE_0
bool IsAlias() const
void SetOrigin(const Vec &pos)
Definition: box2.h:210
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static wxString SubReference(int aUnit, bool aAddSeparator=true)
wxProgressDialog with the option to also update the application progress on the taskbar
LIB_ID getTargetLibId() const
Returns either the part selected in the component tree, if context menu is active or the currently mo...
static bool empty(const wxTextEntryBase *aCtrl)
static TOOL_ACTION drawSymbolArc
Definition: ee_actions.h:105
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
coord_type GetHeight() const
Definition: box2.h:198
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
LIBEDIT_SETTINGS * GetSettings()
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
bool HasModifications() const
Definition: lib_manager.cpp:66
LIB_PART * getTargetPart() const
Returns currently edited part.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool IsLibraryModified(const wxString &aLibrary) const
Returns true if library has unsaved modifications.
Color settings are a bit different than most of the settings objects in that there can be more than o...
WX_INFOBAR * GetInfoBar()
SCH_SCREEN * m_dummyScreen
Helper screen used when no part is loaded
static TOOL_ACTION deleteTool
Definition: actions.h:76
wxString SetCurLib(const wxString &aLibNickname)
Sets the current library nickname and returns the old library nickname.
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:195
static TOOL_ACTION undo
Definition: actions.h:67
void OnGridSettings(wxCommandEvent &event)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:100
static TOOL_ACTION saveAll
Definition: actions.h:57
SYMBOL_LIB_TABLE * selectSymLibTable(bool aOptional=false)
Displays a dialog asking the user to select a symbol library table.
void InitTools()
Function InitTools() Initializes all registered tools.
COLOR_SETTINGS * GetColorSettings() override
Returns a pointer to the active color theme settings.
Definition for part library class.
const Vec & GetOrigin() const
Definition: box2.h:193
wxComboBox * m_unitSelectBox
void SetModify()
Definition: base_screen.h:100
MAIL_T Command()
Function Command returns the MAIL_T associated with this mail.
Definition: kiway_express.h:52
LIB_TREE * GetLibTree() const
SYMBOL_TREE_PANE * m_treePane
LIB_MANAGER & GetLibManager()
BASE_SCREEN class implementation.
LIB_TREE_NODE * GetCurrentTreeNode() const
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
LIB_TREE_MODEL_ADAPTER::PTR & GetAdapter()
Returns the adapter object that provides the stored data.
Definition: lib_manager.h:276
static constexpr int Millimeter2iu(double mm)
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
static TOOL_ACTION selectAll
Definition: actions.h:73
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
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
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
static TOOL_ACTION paste
Definition: actions.h:71
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.
~LIB_EDIT_FRAME() override
static TOOL_ACTION duplicate
Definition: actions.h:74
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:107
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
static TOOL_ACTION revert
Definition: actions.h:58
static TOOL_ACTION selectionTool
Definition: actions.h:149
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.
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferrably centered).
Definition: lib_tree.cpp:185
void OnExitKiCad(wxCommandEvent &event)
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:179
virtual void UpdateMsgPanel()
Redraw the message panel.
const std::string KiCadSymbolLibFileExtension
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:174
ACTION_TOOLBAR * m_drawToolBar