KiCad PCB EDA Suite
symbol_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 <[email protected]>
6  * Copyright (C) 2004-2021 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 <bitmaps.h>
27 #include <wx/hyperlink.h>
28 #include <base_screen.h>
29 #include <symbol_library.h>
30 #include <confirm.h>
31 #include <core/kicad_algo.h>
32 #include <eeschema_id.h>
33 #include <eeschema_settings.h>
34 #include <env_paths.h>
35 #include <kiface_base.h>
36 #include <kiplatform/app.h>
37 #include <kiway_express.h>
38 #include <symbol_edit_frame.h>
39 #include <symbol_library_manager.h>
40 #include <lib_text.h>
41 #include <symbol_editor_settings.h>
42 #include <paths.h>
43 #include <pgm_base.h>
44 #include <sch_painter.h>
45 #include <sch_view.h>
47 #include <symbol_lib_table.h>
48 #include <tool/action_manager.h>
49 #include <tool/action_toolbar.h>
50 #include <tool/common_control.h>
51 #include <tool/common_tools.h>
52 #include <tool/editor_conditions.h>
53 #include <tool/picker_tool.h>
54 #include <tool/selection.h>
55 #include <tool/tool_dispatcher.h>
56 #include <tool/tool_manager.h>
57 #include <tool/zoom_tool.h>
58 #include <tools/ee_actions.h>
60 #include <tools/ee_point_editor.h>
68 #include <widgets/infobar.h>
69 #include <widgets/lib_tree.h>
73 #include <panel_sym_lib_table.h>
74 #include <wx/choicdlg.h>
75 #include <string_utils.h>
76 
77 
79 
80 
81 BEGIN_EVENT_TABLE( SYMBOL_EDIT_FRAME, EDA_DRAW_FRAME )
82  EVT_SIZE( SYMBOL_EDIT_FRAME::OnSize )
83 
85 
86  // menubar commands
87  EVT_MENU( wxID_EXIT, SYMBOL_EDIT_FRAME::OnExitKiCad )
88  EVT_MENU( wxID_CLOSE, SYMBOL_EDIT_FRAME::CloseWindow )
90 
91  // Update user interface elements.
93 
94 END_EVENT_TABLE()
95 
96 
97 SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
98  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_SYMBOL_EDITOR, _( "Library Editor" ),
99  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE,
101  m_unitSelectBox( nullptr ),
102  m_isSymbolFromSchematic( false )
103 {
104  SetShowDeMorgan( false );
105  m_SyncPinEdit = false;
106 
107  m_symbol = nullptr;
108  m_treePane = nullptr;
109  m_libMgr = nullptr;
110  m_unit = 1;
111  m_convert = 1;
112  m_aboutTitle = _( "KiCad Symbol Editor" );
113 
114  wxIcon icon;
115  wxIconBundle icon_bundle;
116 
117  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit ) );
118  icon_bundle.AddIcon( icon );
119  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_32 ) );
120  icon_bundle.AddIcon( icon );
121  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_libedit_16 ) );
122  icon_bundle.AddIcon( icon );
123 
124  SetIcons( icon_bundle );
125 
126  m_settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
127  LoadSettings( m_settings );
128 
129  m_libMgr = new SYMBOL_LIBRARY_MANAGER( *this );
130  bool loadingCancelled = false;
131 
132  {
133  // Preload libraries before using SyncLibraries the first time, as the preload is
134  // multi-threaded
135  WX_PROGRESS_REPORTER reporter( this, _( "Loading Symbol Libraries" ),
136  m_libMgr->GetLibraryCount(), true );
137  m_libMgr->Preload( reporter );
138 
139  loadingCancelled = reporter.IsCancelled();
140  wxSafeYield();
141  }
142 
143  SyncLibraries( false, loadingCancelled );
144  m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
145 
146  resolveCanvasType();
147  SwitchCanvas( m_canvasType );
148 
149  // Ensure axis are always drawn
150  KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
151  gal_opts.m_axesEnabled = true;
152 
153  m_dummyScreen = new SCH_SCREEN();
154  SetScreen( m_dummyScreen );
155  GetScreen()->m_Center = true;
156 
157  GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
158 
159  GetRenderSettings()->LoadColors( GetColorSettings() );
160  GetRenderSettings()->m_IsSymbolEditor = true;
161  GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
162 
163  setupTools();
164  setupUIConditions();
165 
166  ReCreateMenuBar();
167  ReCreateHToolbar();
168  ReCreateVToolbar();
169  ReCreateOptToolbar();
170 
171  updateTitle();
172  UpdateSymbolMsgPanelInfo();
173  RebuildSymbolUnitsList();
174 
175  m_auimgr.SetManagedWindow( this );
176 
177  CreateInfoBar();
178  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( wxT( "MainToolbar" ) )
179  .Top().Layer( 6 ) );
180  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxT( "MsgPanel" ) )
181  .Bottom().Layer( 6 ) );
182 
183  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( wxT( "OptToolbar" ) )
184  .Left().Layer( 3 ) );
185  m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( wxT( "SymbolTree" ) )
186  .Left().Layer( 2 )
187  .Caption( _( "Libraries" ) )
188  .MinSize( 250, -1 ).BestSize( 250, -1 ) );
189  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( wxT( "ToolsToolbar" ) )
190  .Right().Layer( 2 ) );
191 
192  m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( wxT( "DrawFrame" ) )
193  .CentrePane() );
194 
195  FinishAUIInitialization();
196 
197  if( m_settings->m_LibWidth > 0 )
198  {
199  wxAuiPaneInfo& treePane = m_auimgr.GetPane( wxT( "SymbolTree" ) );
200 
201  // wxAUI hack: force width by setting MinSize() and then Fixed()
202  // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
203  treePane.MinSize( m_settings->m_LibWidth, -1 );
204  treePane.Fixed();
205  m_auimgr.Update();
206 
207  // now make it resizable again
208  treePane.Resizable();
209  m_auimgr.Update();
210 
211  // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
212  // back to minimum.
213  treePane.MinSize( 250, -1 );
214  }
215 
216  Raise();
217  Show( true );
218 
219  SyncView();
220  GetCanvas()->GetView()->UseDrawPriority( true );
221  GetCanvas()->GetGAL()->SetAxesEnabled( true );
222 
223  setupUnits( m_settings );
224 
225  // Set the working/draw area size to display a symbol to a reasonable value:
226  // A 600mm x 600mm with a origin at the area center looks like a large working area
227  double max_size_x = Millimeter2iu( 600 );
228  double max_size_y = Millimeter2iu( 600 );
229  BOX2D bbox;
230  bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
231  bbox.SetSize( max_size_x, max_size_y );
232  GetCanvas()->GetView()->SetBoundary( bbox );
233 
234  m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
235 
236  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Library changes are unsaved" ) );
237 
238  // Catch unhandled accelerator command characters that were no handled by the library tree
239  // panel.
240  Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
241  Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
242 
243  // Ensure the window is on top
244  Raise();
245 
246  if( loadingCancelled )
247  ShowInfoBarWarning( _( "Symbol library loading was cancelled by user." ) );
248 }
249 
250 
252 {
253  // Shutdown all running tools
254  if( m_toolManager )
256 
257  if( IsSymbolFromSchematic() )
258  {
259  delete m_symbol;
260  m_symbol = nullptr;
261 
262  SCH_SCREEN* screen = GetScreen();
263  delete screen;
264  m_isSymbolFromSchematic = false;
265  }
266  // current screen is destroyed in EDA_DRAW_FRAME
268 
269  auto libedit = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
270  Pgm().GetSettingsManager().Save( libedit );
271 
272  delete m_libMgr;
273 }
274 
275 
277 {
278  wxCHECK_RET( m_settings, wxT( "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" ) );
279 
281 
283 
284  // Hidden elements must be editable
288 }
289 
290 
292 {
293  wxCHECK_RET( m_settings, wxT( "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" ) );
294 
296 
298 
300  m_settings->m_LibWidth = m_treePane->GetSize().x;
301 }
302 
303 
305 {
306  return static_cast<APP_SETTINGS_BASE*>( GetSettings() );
307 }
308 
309 
311 {
312  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
313 
314  if( GetSettings()->m_UseEeschemaColorSettings )
316  else
317  return mgr.GetColorSettings( GetSettings()->m_ColorTheme );
318 }
319 
320 
322 {
323  // Create the manager and dispatcher & route draw panel events to the dispatcher
326  GetCanvas()->GetViewControls(), GetSettings(), this );
327  m_actions = new EE_ACTIONS();
329 
330  // Register tools
344 
345  // Run the selection tool, it is supposed to be always active
346  m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
347 
349 }
350 
351 
353 {
355 
357  EDITOR_CONDITIONS cond( this );
358 
359  wxASSERT( mgr );
360 
361 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
362 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
363 
364  auto haveSymbolCond =
365  [this]( const SELECTION& )
366  {
367  return m_symbol;
368  };
369 
370  auto isEditableCond =
371  [this]( const SELECTION& )
372  {
373  // Only root symbols from the new s-expression libraries or the schematic
374  // are editable.
375  return IsSymbolEditable() && !IsSymbolAlias();
376  };
377 
378  auto symbolModifiedCondition =
379  [this]( const SELECTION& sel )
380  {
381  return m_libMgr->IsSymbolModified( GetTargetLibId().GetLibItemName(),
382  GetTargetLibId().GetLibNickname() );
383  };
384 
385  auto libSelectedCondition =
386  [this]( const SELECTION& sel )
387  {
388  return !GetTargetLibId().GetLibNickname().empty();
389  };
390 
391  auto canEditProperties =
392  [this]( const SELECTION& sel )
393  {
395  };
396 
397  auto saveSymbolAsCondition =
398  [this]( const SELECTION& aSel )
399  {
400  return getTargetSymbol() != nullptr;
401  };
402 
405  mgr->SetConditions( EE_ACTIONS::saveLibraryAs, ENABLE( libSelectedCondition ) );
406  mgr->SetConditions( EE_ACTIONS::saveSymbolAs, ENABLE( saveSymbolAsCondition ) );
409 
410  mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) );
411  mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) );
412  mgr->SetConditions( ACTIONS::revert, ENABLE( symbolModifiedCondition ) );
413 
419 
420  mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond ) );
421  mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond ) );
422  mgr->SetConditions( ACTIONS::paste, ENABLE( isEditableCond && SELECTION_CONDITIONS::Idle ) );
423  mgr->SetConditions( ACTIONS::doDelete, ENABLE( isEditableCond ) );
424  mgr->SetConditions( ACTIONS::duplicate, ENABLE( isEditableCond ) );
425  mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
426 
427  mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( isEditableCond ) );
428  mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( isEditableCond ) );
429  mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( isEditableCond ) );
430  mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( isEditableCond ) );
431 
434 
435  auto pinTypeCond =
436  [this]( const SELECTION& )
437  {
439  };
440 
441  auto showCompTreeCond =
442  [this]( const SELECTION& )
443  {
444  return IsSymbolTreeShown();
445  };
446 
447  mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) );
448  mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) );
449 
450  auto demorganCond =
451  [this]( const SELECTION& )
452  {
453  return GetShowDeMorgan();
454  };
455 
456  auto demorganStandardCond =
457  [this]( const SELECTION& )
458  {
459  return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
460  };
461 
462  auto demorganAlternateCond =
463  [this]( const SELECTION& )
464  {
465  return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
466  };
467 
468  auto multiUnitModeCond =
469  [this]( const SELECTION& )
470  {
471  return m_symbol && m_symbol->IsMulti() && !m_symbol->UnitsLocked();
472  };
473 
474  auto syncedPinsModeCond =
475  [this]( const SELECTION& )
476  {
477  return m_SyncPinEdit;
478  };
479 
480  auto haveDatasheetCond =
481  [this]( const SELECTION& )
482  {
483  return m_symbol && !m_symbol->GetDatasheetField().GetText().IsEmpty();
484  };
485 
486  mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
487  mgr->SetConditions( EE_ACTIONS::symbolProperties, ENABLE( canEditProperties && haveSymbolCond ) );
488  mgr->SetConditions( EE_ACTIONS::runERC, ENABLE( haveSymbolCond ) );
489  mgr->SetConditions( EE_ACTIONS::pinTable, ENABLE( isEditableCond && haveSymbolCond ) );
490 
492  ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
494  ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) );
496  ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) );
497 
498 // Only enable a tool if the symbol is edtable
499 #define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) )
500 
509 
510 #undef CHECK
511 #undef ENABLE
512 #undef EDIT_TOOL
513 }
514 
515 
517 {
518  if( IsContentModified() )
519  {
520  SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
521  wxString msg = _( "Save changes to '%s' before closing?" );
522 
523  switch( UnsavedChangesDialog( this, wxString::Format( msg, m_reference ), nullptr ) )
524  {
525  case wxID_YES:
526  if( schframe && GetCurSymbol() ) // Should be always the case
528 
529  break;
530 
531  case wxID_NO:
532  break;
533 
534  default:
535  case wxID_CANCEL:
536  return false;
537  }
538  }
539 
540  if( doClose )
541  {
542  GetInfoBar()->ShowMessageFor( wxEmptyString, 1 );
543  SetCurSymbol( nullptr, false );
544  updateTitle();
545  }
546 
547  return true;
548 }
549 
550 
551 bool SYMBOL_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
552 {
553  // Shutdown blocks must be determined and vetoed as early as possible
555  && aEvent.GetId() == wxEVT_QUERY_END_SESSION
556  && IsContentModified() )
557  {
558  return false;
559  }
560 
562  return false;
563 
564  if( !saveAllLibraries( true ) )
565  return false;
566 
567  return true;
568 }
569 
570 
572 {
573  Destroy();
574 }
575 
576 
578 {
579  if( !m_unitSelectBox )
580  return;
581 
582  if( m_unitSelectBox->GetCount() != 0 )
583  m_unitSelectBox->Clear();
584 
585  if( !m_symbol || m_symbol->GetUnitCount() <= 1 )
586  {
587  m_unit = 1;
588  m_unitSelectBox->Append( wxEmptyString );
589  }
590  else
591  {
592  for( int i = 0; i < m_symbol->GetUnitCount(); i++ )
593  {
594  wxString sub = LIB_SYMBOL::SubReference( i+1, false );
595  wxString unit = wxString::Format( _( "Unit %s" ), sub );
596  m_unitSelectBox->Append( unit );
597  }
598  }
599 
600  // Ensure the selected unit is compatible with the number of units of the current symbol:
601  if( m_symbol && m_symbol->GetUnitCount() < m_unit )
602  m_unit = 1;
603 
604  m_unitSelectBox->SetSelection(( m_unit > 0 ) ? m_unit - 1 : 0 );
605 }
606 
607 
608 void SYMBOL_EDIT_FRAME::OnToggleSymbolTree( wxCommandEvent& event )
609 {
610  auto& treePane = m_auimgr.GetPane( m_treePane );
611  treePane.Show( !IsSymbolTreeShown() );
612  m_auimgr.Update();
613 }
614 
615 
617 {
618  return const_cast<wxAuiManager&>( m_auimgr ).GetPane( m_treePane ).IsShown();
619 }
620 
621 
623 {
624  m_treePane->Freeze();
625  m_libMgr->GetAdapter()->Freeze();
626 }
627 
628 
630 {
631  m_libMgr->GetAdapter()->Thaw();
632  m_treePane->Thaw();
633 }
634 
635 
636 void SYMBOL_EDIT_FRAME::OnExitKiCad( wxCommandEvent& event )
637 {
638  Kiway().OnKiCadExit();
639 }
640 
641 
642 void SYMBOL_EDIT_FRAME::OnUpdateUnitNumber( wxUpdateUIEvent& event )
643 {
644  event.Enable( m_symbol && m_symbol->GetUnitCount() > 1 );
645 }
646 
647 
648 void SYMBOL_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
649 {
650  int i = event.GetSelection();
651 
652  if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
653  return;
654 
657 
658  m_unit = i + 1;
659 
661  RebuildView();
663 }
664 
665 
667 {
668  if( m_symbol )
669  {
671 
672  if( row && row->GetType() == SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) )
673  return true;
674  }
675 
676  return false;
677 }
678 
679 
681 {
682  wxString libNickname = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
683 
684  if( !libNickname.empty() )
685  {
686  if( !Prj().SchSymbolLibTable()->HasLibrary( libNickname ) )
687  {
688  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
689  libNickname = wxEmptyString;
690  }
691  }
692 
693  return libNickname;
694 }
695 
696 
697 wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
698 {
699  wxString old = GetCurLib();
700 
701  if( aLibNickname.empty() || !Prj().SchSymbolLibTable()->HasLibrary( aLibNickname ) )
702  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
703  else
704  Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLibNickname );
705 
706  return old;
707 }
708 
709 
710 void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
711 {
713  GetCanvas()->GetView()->Clear();
714  delete m_symbol;
715 
716  m_symbol = aSymbol;
717 
718  // select the current symbol in the tree widget
719  if( !IsSymbolFromSchematic() && m_symbol )
721  else
723 
724  wxString symbolName = m_symbol ? m_symbol->GetName() : wxString();
725 
726  // retain in case this wxFrame is re-opened later on the same PROJECT
728 
729  // Ensure synchronized pin edit can be enabled only symbols with interchangeable units
730  m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMulti() && !aSymbol->UnitsLocked();
731 
733 
741 
742  if( aUpdateZoom )
744 
745  GetCanvas()->Refresh();
746 
747  WX_INFOBAR* infobar = GetInfoBar();
748 
749  if( IsSymbolFromSchematic() )
750  {
751  wxString msg;
752  msg.Printf( _( "Editing symbol %s from schematic. Saving will update the schematic "
753  "only." ), m_reference );
754 
755  infobar->RemoveAllButtons();
756  infobar->ShowMessage( msg, wxICON_INFORMATION );
757  }
758  else if( IsSymbolFromLegacyLibrary() )
759  {
760  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
761  _( "Manage symbol libraries" ),
762  wxEmptyString );
763 
764  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
765  [&]( wxHyperlinkEvent& aEvent )
766  {
768  } ) );
769 
770  infobar->RemoveAllButtons();
771  infobar->AddButton( button );
772  infobar->ShowMessage( _( "Symbols in legacy libraries are not editable. Use Manage "
773  "Symbol Libraries to migrate to current format." ),
774  wxICON_INFORMATION );
775  }
776  else if( IsSymbolAlias() )
777  {
778  wxString parentSymbolName = m_symbol->GetParent().lock()->GetName();
779  wxString msg;
780  wxString link;
781 
782  msg.Printf( _( "Symbol %s is derived from %s. Symbol graphics will not be editable." ),
783  UnescapeString( symbolName ),
784  UnescapeString( parentSymbolName ) );
785 
786  link.Printf( _( "Open %s" ), UnescapeString( parentSymbolName ) );
787 
788  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, link, wxEmptyString );
789  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
790  [&]( wxHyperlinkEvent& aEvent )
791  {
792  LoadSymbolFromCurrentLib( m_symbol->GetParent().lock()->GetName(),
793  GetUnit(), GetConvert() );
794  } ) );
795 
796  infobar->RemoveAllButtons();
797  infobar->AddButton( button );
798  infobar->ShowMessage( msg, wxICON_INFORMATION );
799  }
800  else
801  {
802  infobar->Dismiss();
803  }
804 }
805 
806 
808 {
809  wxASSERT( m_libMgr );
810  return *m_libMgr;
811 }
812 
813 
815 {
817 
818  if( !IsSymbolFromSchematic() )
820 
822 
823  if( !GetTitle().StartsWith( wxT( "*" ) ) )
824  updateTitle();
825 }
826 
827 
829 {
831 }
832 
833 
834 bool SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew )
835 {
836  // Select the target library table (global/project)
837  SYMBOL_LIB_TABLE* libTable = selectSymLibTable();
838 
839  if( !libTable )
840  return false;
841 
842  wxFileName fn = m_libMgr->GetUniqueLibraryName();
843 
844  if( !LibraryFileBrowser( !aCreateNew, fn, KiCadSymbolLibFileWildcard(),
846  ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
848  {
849  return false;
850  }
851 
852  wxString libName = fn.GetName();
853 
854  if( libName.IsEmpty() )
855  return false;
856 
857  if( m_libMgr->LibraryExists( libName ) )
858  {
859  DisplayError( this, wxString::Format( _( "Library '%s' already exists." ), libName ) );
860  return false;
861  }
862 
863  if( aCreateNew )
864  {
865  if( !m_libMgr->CreateLibrary( fn.GetFullPath(), libTable ) )
866  {
867  DisplayError( this, wxString::Format( _( "Could not create the library file '%s'.\n"
868  "Make sure you have write permissions and try again." ),
869  fn.GetFullPath() ) );
870  return false;
871  }
872  }
873  else
874  {
875  if( !m_libMgr->AddLibrary( fn.GetFullPath(), libTable ) )
876  {
877  DisplayError( this, _( "Could not open the library file." ) );
878  return false;
879  }
880  }
881 
882  bool globalTable = ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
883  saveSymbolLibTables( globalTable, !globalTable );
884 
885  std::string packet = fn.GetFullPath().ToStdString();
887 
888  return true;
889 }
890 
891 
893 {
894  return m_treePane->GetLibTree()->GetSelectedLibId( aUnit );
895 }
896 
897 
899 {
900  LIB_ID libId = GetTreeLIBID();
901 
902  if( libId.IsValid() )
903  {
904  LIB_SYMBOL* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() );
905  return alias;
906  }
907 
908  return m_symbol;
909 }
910 
911 
913 {
914  LIB_ID id;
915 
916  if( IsSymbolTreeShown() )
917  id = GetTreeLIBID();
918 
919  if( id.GetLibNickname().empty() && m_symbol )
920  id = m_symbol->GetLibId();
921 
922  return id;
923 }
924 
925 
927 {
929 }
930 
931 
933 {
934  return GetTargetLibId().GetLibNickname();
935 }
936 
937 
938 void SYMBOL_EDIT_FRAME::SyncLibraries( bool aShowProgress, bool aPreloadCancelled,
939  const wxString& aForceRefresh )
940 {
941  LIB_ID selected;
942 
943  if( m_treePane )
944  selected = m_treePane->GetLibTree()->GetSelectedLibId();
945 
946  if( aShowProgress )
947  {
948  APP_PROGRESS_DIALOG progressDlg( _( "Loading Symbol Libraries" ), wxEmptyString,
949  m_libMgr->GetAdapter()->GetLibrariesCount(), this );
950 
951  m_libMgr->Sync( aForceRefresh,
952  [&]( int progress, int max, const wxString& libName )
953  {
954  progressDlg.Update( progress, wxString::Format( _( "Loading library '%s'..." ),
955  libName ) );
956  } );
957  }
958  else if( !aPreloadCancelled )
959  {
960  m_libMgr->Sync( aForceRefresh,
961  [&]( int progress, int max, const wxString& libName )
962  {
963  } );
964  }
965 
966  if( m_treePane )
967  {
968  wxDataViewItem found;
969 
970  if( selected.IsValid() )
971  {
972  // Check if the previously selected item is still valid,
973  // if not - it has to be unselected to prevent crash
974  found = m_libMgr->GetAdapter()->FindItem( selected );
975 
976  if( !found )
978  }
979 
980  m_treePane->GetLibTree()->Regenerate( true );
981 
982  // Try to select the parent library, in case the symbol is not found
983  if( !found && selected.IsValid() )
984  {
985  selected.SetLibItemName( wxEmptyString );
986  found = m_libMgr->GetAdapter()->FindItem( selected );
987 
988  if( found )
989  m_treePane->GetLibTree()->SelectLibId( selected );
990  }
991 
992  // If no selection, see if there's a current symbol to centre
993  if( !selected.IsValid() && m_symbol )
994  {
995  LIB_ID current( GetCurLib(), m_symbol->GetName() );
996  m_treePane->GetLibTree()->CenterLibId( current );
997  }
998  }
999 }
1000 
1001 
1003 {
1004  LIB_ID target = GetTargetLibId();
1005 
1006  m_treePane->GetLibTree()->Regenerate( true );
1007 
1008  if( target.IsValid() )
1009  m_treePane->GetLibTree()->CenterLibId( target );
1010 }
1011 
1012 
1014 {
1016 }
1017 
1018 
1020 {
1021  // If no project is loaded, always work with the global table
1022  if( Prj().IsNullProject() )
1023  {
1025 
1026  if( aOptional )
1027  {
1028  wxMessageDialog dlg( this, _( "Add the library to the global library table?" ),
1029  _( "Add To Global Library Table" ), wxYES_NO );
1030 
1031  if( dlg.ShowModal() != wxID_OK )
1032  ret = nullptr;
1033  }
1034 
1035  return ret;
1036  }
1037 
1038  wxArrayString libTableNames;
1039  libTableNames.Add( _( "Global" ) );
1040  libTableNames.Add( _( "Project" ) );
1041 
1042  wxSingleChoiceDialog dlg( this, _( "Choose the Library Table to add the library to:" ),
1043  _( "Add To Library Table" ), libTableNames );
1044 
1045  if( aOptional )
1046  {
1047  dlg.FindWindow( wxID_CANCEL )->SetLabel( _( "Skip" ) );
1048  dlg.FindWindow( wxID_OK )->SetLabel( _( "Add" ) );
1049  }
1050 
1051  if( dlg.ShowModal() != wxID_OK )
1052  return nullptr;
1053 
1054  switch( dlg.GetSelection() )
1055  {
1056  case 0: return &SYMBOL_LIB_TABLE::GetGlobalLibTable();
1057  case 1: return Prj().SchSymbolLibTable();
1058  default: return nullptr;
1059  }
1060 }
1061 
1062 
1063 bool SYMBOL_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
1064 {
1065  if( aOriginalFile.FileExists() )
1066  {
1067  wxFileName backupFileName( aOriginalFile );
1068  backupFileName.SetExt( aBackupExt );
1069 
1070  if( backupFileName.FileExists() )
1071  wxRemoveFile( backupFileName.GetFullPath() );
1072 
1073  if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
1074  {
1075  DisplayError( this, wxString::Format( _( "Failed to save backup to '%s'." ),
1076  backupFileName.GetFullPath() ) );
1077  return false;
1078  }
1079  }
1080 
1081  return true;
1082 }
1083 
1084 
1086 {
1087  if( m_symbol && !GetCurLib().IsEmpty() && GetScreen()->IsContentModified() )
1088  m_libMgr->UpdateSymbol( m_symbol, GetCurLib() ); // UpdateSymbol() makes a copy
1089 }
1090 
1091 
1092 bool SYMBOL_EDIT_FRAME::isCurrentSymbol( const LIB_ID& aLibId ) const
1093 {
1094  // This will return the root symbol of any alias
1095  LIB_SYMBOL* symbol = m_libMgr->GetBufferedSymbol( aLibId.GetLibItemName(),
1096  aLibId.GetLibNickname() );
1097 
1098  // Now we can compare the libId of the current symbol and the root symbol
1099  return ( symbol && m_symbol && symbol->GetLibId() == m_symbol->GetLibId() );
1100 }
1101 
1102 
1104 {
1106  SetCurLib( wxEmptyString );
1107  SetCurSymbol( nullptr, false );
1111  Refresh();
1112 }
1113 
1114 
1115 void SYMBOL_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1116 {
1117  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1118 
1120  GetCanvas()->GetGAL()->DrawGrid();
1121 
1123  GetCanvas()->Refresh();
1124 
1125  RecreateToolbars();
1126 
1127  if( aEnvVarsChanged )
1128  SyncLibraries( true );
1129 
1130  Layout();
1131  SendSizeEvent();
1132 }
1133 
1134 
1136 {
1137  // call my base class
1139 
1140  // tooltips in toolbars
1141  RecreateToolbars();
1142 
1143  // status bar
1144  UpdateMsgPanel();
1145 
1146  if( GetRenderSettings()->m_ShowPinsElectricalType )
1147  {
1149  GetCanvas()->Refresh();
1150  }
1151 
1152  updateTitle();
1153 }
1154 
1155 
1157 {
1158  SCH_BASE_FRAME::SetScreen( aScreen );
1159 }
1160 
1161 
1163 {
1171 
1173  GetCanvas()->Refresh();
1174 }
1175 
1176 
1178 {
1179  SyncLibraries( true );
1180 
1181  if( m_symbol )
1182  {
1184  EE_SELECTION& selection = selectionTool->GetSelection();
1185 
1186  for( LIB_ITEM& item : m_symbol->GetDrawItems() )
1187  {
1188  if( !alg::contains( selection, &item ) )
1189  item.ClearSelected();
1190  else
1191  item.SetSelected();
1192  }
1193  }
1194 
1195  RebuildView();
1196 }
1197 
1198 
1199 const BOX2I SYMBOL_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1200 {
1201  if( !m_symbol )
1202  {
1203  return BOX2I( VECTOR2I( Mils2iu( -100 ), Mils2iu( -100 ) ),
1204  VECTOR2I( Mils2iu( 200 ), Mils2iu( 200 ) ) );
1205  }
1206  else
1207  {
1208  EDA_RECT boundingBox = m_symbol->Flatten()->GetUnitBoundingBox( m_unit, m_convert );
1210  boundingBox.GetHeight() ) );
1211  }
1212 }
1213 
1214 
1216 {
1217  const std::string& payload = mail.GetPayload();
1218 
1219  switch( mail.Command() )
1220  {
1221  case MAIL_LIB_EDIT:
1222  if( !payload.empty() )
1223  {
1224  wxString libFileName( payload );
1225  wxString libNickname;
1226  wxString msg;
1227 
1228  SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
1229  const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName );
1230 
1231  if( !libTableRow )
1232  {
1233  msg.Printf( _( "The current configuration does not include the library '%s'.\n"
1234  "Use Manage Symbol Libraries to edit the configuration." ),
1235  libFileName );
1236  DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
1237  break;
1238  }
1239 
1240  libNickname = libTableRow->GetNickName();
1241 
1242  if( !libTable->HasLibrary( libNickname, true ) )
1243  {
1244  msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
1245  "Use Manage Symbol Libraries to edit the configuration." ),
1246  UnescapeString( libNickname ) );
1247  DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
1248  break;
1249  }
1250 
1251  SetCurLib( libNickname );
1252 
1253  if( m_treePane )
1254  {
1255  LIB_ID id( libNickname, wxEmptyString );
1256  m_treePane->GetLibTree()->SelectLibId( id );
1257  m_treePane->GetLibTree()->ExpandLibId( id );
1258  m_treePane->GetLibTree()->CenterLibId( id );
1259  }
1260  }
1261 
1262  break;
1263 
1264  default:
1265  ;
1266  }
1267 }
1268 
1269 
1271 {
1272  // switches currently used canvas ( Cairo / OpenGL):
1273  SCH_BASE_FRAME::SwitchCanvas( aCanvasType );
1274 
1275  // Set options specific to symbol editor (axies are always enabled):
1276  GetCanvas()->GetGAL()->SetAxesEnabled( true );
1278 }
1279 
1280 
1282 {
1283  wxCHECK( m_libMgr, false );
1284 
1285  return m_libMgr->HasModifications();
1286 }
1287 
1288 
1290 {
1291  wxCHECK( m_libMgr, false );
1292 
1293  // Test if the currently edited symbol is modified
1294  if( GetScreen() && GetScreen()->IsContentModified() && GetCurSymbol() )
1295  return true;
1296 
1297  // Test if any library has been modified
1298  for( const wxString& libName : m_libMgr->GetLibraryNames() )
1299  {
1300  if( m_libMgr->IsLibraryModified( libName ) && !m_libMgr->IsLibraryReadOnly( libName ) )
1301  return true;
1302  }
1303 
1304  return false;
1305 }
1306 
1307 
1309 {
1310  if( aItemCount == 0 )
1311  return;
1312 
1313  UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
1314 
1315  for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
1316  {
1317  command->ClearListAndDeleteItems();
1318  delete command;
1319  }
1320 
1321  list.m_CommandsList.clear();
1322 }
1323 
1324 
1326 {
1327  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1328 }
1329 
1330 
1332 {
1333  std::unique_ptr<LIB_SYMBOL> symbol = aSymbol->GetLibSymbolRef()->Flatten();
1334  wxCHECK( symbol, /* void */ );
1335 
1336  std::vector<LIB_FIELD> fullSetOfFields;
1337 
1338  for( int i = 0; i < (int) aSymbol->GetFields().size(); ++i )
1339  {
1340  const SCH_FIELD& field = aSymbol->GetFields()[i];
1341  wxPoint pos = field.GetPosition() - aSymbol->GetPosition();
1342  LIB_FIELD libField( symbol.get(), field.GetId() );
1343 
1344  if( i >= MANDATORY_FIELDS && !field.GetName( false ).IsEmpty() )
1345  libField.SetName( field.GetName( false ) );
1346 
1347  libField.SetText( field.GetText() );
1348  libField.SetEffects( field );
1349  libField.SetPosition( wxPoint( pos.x, -pos.y ) );
1350 
1351  fullSetOfFields.emplace_back( std::move( libField ) );
1352  }
1353 
1354  symbol->SetFields( fullSetOfFields );
1355 
1356  if( m_symbol )
1357  SetCurSymbol( nullptr, false );
1358 
1359  m_isSymbolFromSchematic = true;
1360  m_schematicSymbolUUID = aSymbol->m_Uuid;
1361  m_reference = symbol->GetFieldById( REFERENCE_FIELD )->GetText();
1362  m_unit = std::max( 1, aSymbol->GetUnit() );
1363  m_convert = std::max( 1, aSymbol->GetConvert() );
1364 
1365  // The buffered screen for the symbol
1366  SCH_SCREEN* tmpScreen = new SCH_SCREEN();
1367 
1368  SetScreen( tmpScreen );
1369  SetCurSymbol( symbol.release(), true );
1370 
1371  ReCreateMenuBar();
1372  ReCreateHToolbar();
1373 
1374  if( IsSymbolTreeShown() )
1375  {
1376  wxCommandEvent evt;
1377  OnToggleSymbolTree( evt );
1378  }
1379 
1380  updateTitle();
1382  SetShowDeMorgan( GetCurSymbol()->HasConversion() );
1384  Refresh();
1385 }
1386 
1387 
1388 bool SYMBOL_EDIT_FRAME::addLibTableEntry( const wxString& aLibFile, TABLE_SCOPE aScope )
1389 {
1390  wxFileName fn = aLibFile;
1391  wxFileName libTableFileName( Prj().GetProjectPath(),
1393  wxString libNickname = fn.GetName();
1394  SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
1395  const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
1396 
1397  if( libTable->HasLibrary( libNickname ) )
1398  {
1399  wxString tmp;
1400  int suffix = 1;
1401 
1402  while( libTable->HasLibrary( libNickname ) )
1403  {
1404  tmp.Printf( wxT( "%s%d" ), fn.GetName(), suffix );
1405  libNickname = tmp;
1406  suffix += 1;
1407  }
1408  }
1409 
1411  row->SetNickName( libNickname );
1412 
1413  wxString normalizedPath = NormalizePath( aLibFile, &envVars, Prj().GetProjectPath() );
1414 
1415  if( aScope == GLOBAL_LIB_TABLE )
1416  {
1418  libTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
1419 
1420  // We cannot normalize against the current project path when saving to global table.
1421  normalizedPath = NormalizePath( aLibFile, &envVars, wxEmptyString );
1422  }
1423 
1424  row->SetFullURI( normalizedPath );
1425 
1426  wxCHECK( libTable->InsertRow( row ), false );
1427 
1428  try
1429  {
1430  libTable->Save( libTableFileName.GetFullPath() );
1431  }
1432  catch( const IO_ERROR& ioe )
1433  {
1434  wxString msg = aScope == GLOBAL_LIB_TABLE ? _( "Error saving global library table." )
1435  : _( "Error saving project library table." );
1436 
1437  wxMessageDialog dlg( this, msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1438  dlg.SetExtendedMessage( ioe.What() );
1439  dlg.ShowModal();
1440 
1441  return false;
1442  }
1443 
1444  return true;
1445 }
1446 
1447 
1448 bool SYMBOL_EDIT_FRAME::replaceLibTableEntry( const wxString& aLibNickname,
1449  const wxString& aLibFile )
1450 {
1451  // Check the global library table first because checking the project library table
1452  // checks the global library table as well due to library chaining.
1453  bool isGlobalTable = true;
1454  wxFileName libTableFileName = SYMBOL_LIB_TABLE::GetGlobalTableFileName();;
1455  const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
1457  SYMBOL_LIB_TABLE_ROW* row = libTable->FindRow( aLibNickname );
1458 
1459  if( !row )
1460  {
1461  libTableFileName.SetPath( Prj().GetProjectPath() );
1462  libTableFileName.SetName( SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
1463  libTable = Prj().SchSymbolLibTable();
1464  isGlobalTable = false;
1465  row = libTable->FindRow( aLibNickname );
1466  }
1467 
1468  wxCHECK( row, false );
1469 
1470  wxString projectPath;
1471 
1472  if( !isGlobalTable )
1473  projectPath = Prj().GetProjectPath();
1474 
1475  wxString normalizedPath = NormalizePath( aLibFile, &envVars, projectPath );
1476 
1477  row->SetFullURI( normalizedPath );
1478  row->SetType( wxT( "KiCad" ) );
1479 
1480  try
1481  {
1482  libTable->Save( libTableFileName.GetFullPath() );
1483  }
1484  catch( const IO_ERROR& ioe )
1485  {
1486  wxString msg = isGlobalTable ? _( "Error saving global library table." )
1487  : _( "Error saving project library table." );
1488 
1489  wxMessageDialog dlg( this, msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1490  dlg.SetExtendedMessage( ioe.What() );
1491  dlg.ShowModal();
1492 
1493  return false;
1494  }
1495 
1496  return true;
1497 }
1498 
1499 
1501 {
1502  return m_symbol && !m_symbol->IsRoot();
1503 }
1504 
1505 
1507 {
1509 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
Field Reference of part, i.e. "IC21".
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void ShowChangedLanguage() override
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
bool IsMulti() const
Definition: lib_symbol.h:512
static TOOL_ACTION pinTable
Definition: ee_actions.h:146
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
static const wxString & GetSymbolLibTableFileName()
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:142
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:124
static TOOL_ACTION showDatasheet
Inspection and Editing.
Definition: ee_actions.h:140
int m_convert
Flag if the symbol being edited was loaded directly from a schematic.
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:102
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:106
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:38
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:245
void OnKiCadExit()
Definition: kiway.cpp:636
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:171
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
Model changes (required full reload)
Definition: tool_base.h:80
static TOOL_ACTION runERC
Definition: ee_actions.h:141
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
void OnUpdateUnitNumber(wxUpdateUIEvent &event)
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:72
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
wxString GetName() const override
Definition: lib_symbol.h:133
bool backupFile(const wxFileName &aOriginalFile, const wxString &aBackupExt)
Return currently edited symbol.
static TOOL_ACTION showSymbolTree
Definition: ee_actions.h:205
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Add an existing library.
virtual void SetScreen(BASE_SCREEN *aScreen)
UNDO_REDO_CONTAINER m_undoList
static TOOL_ACTION zoomTool
Definition: actions.h:99
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
void SetScreen(BASE_SCREEN *aScreen) override
void SetShowDeMorgan(bool show)
void SetType(const wxString &aType) override
Change the schematic plugin type represented by this row.
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
SYMBOL_EDITOR_SETTINGS * GetSettings() const
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
Definition: sch_io_mgr.cpp:79
wxPoint GetPosition() const override
Definition: sch_field.cpp:842
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
Field object used in symbol libraries.
Definition: lib_field.h:59
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
wxString GetLibNickname() const override
Definition: lib_symbol.h:138
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1482
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create 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 InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:741
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
SYMBOL_TREE_PANE * m_treePane
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch currently used canvas ( Cairo / OpenGL).
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
int GetId() const
Definition: sch_field.h:113
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void storeCurrentSymbol()
Return true if aLibId is an alias for the editor screen symbol.
void SetSize(const Vec &size)
Definition: box2.h:195
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:393
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:487
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
static bool m_showDeMorgan
Schematic editor (Eeschema) main window.
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from aList element.
wxAuiManager m_auimgr
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:128
Manage TOOL_ACTION objects.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:495
static TOOL_ACTION mirrorH
Definition: ee_actions.h:120
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
All except INITIAL_ADD.
Definition: view_item.h:53
The base class for create windows for drawing purpose.
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:416
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
Define a library symbol object.
Definition: lib_symbol.h:96
LIB_TREE_NODE * GetCurrentTreeNode() const
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
static TOOL_ACTION showDeMorganAlternate
Definition: ee_actions.h:128
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
SYMBOL_LIB_TABLE * selectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
void OnSelectUnit(wxCommandEvent &event)
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
Class that groups generic conditions for editor states.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:380
bool GetShowDeMorgan() const
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
bool IsSymbolFromSchematic() const
bool IsSymbolTreeShown() const
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:165
LIB_SYMBOL * getTargetSymbol() const
Return either the library selected in the symbol tree, if context menu is active or the library that ...
static TOOL_ACTION mirrorV
Definition: ee_actions.h:119
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
#define CHECK(x)
static TOOL_ACTION drawSymbolRectangle
Definition: ee_actions.h:103
bool m_axesEnabled
Fullscreen crosshair or small cross.
Library Editor pane with symbol tree and symbol library table selector.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
#define LIB_EDIT_FRAME_NAME
EE_SELECTION & GetSelection()
Return the set of currently selected items.
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
BOX2I boundingBox(T aObject)
Used by SHAPE_INDEX to get the bounding box of a generic T object.
Definition: shape_index.h:77
Master controller class:
Definition: tool_manager.h:54
A holder to handle a list of undo (or redo) commands.
static TOOL_ACTION copy
Definition: actions.h:67
const wxString & GetNickName() const
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:101
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
void updateTitle()
Update the main window title bar with the current library name and read only status of the library.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
wxString GetUniqueLibraryName() const
Return a library name that is not currently in use.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
LIB_TREE_NODE * GetCurrentTreeNode() const
Definition: lib_tree.cpp:179
bool IsSymbolAlias() const
Restore the empty editor screen, without any symbol or library selected.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
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)
Create a functor that tests if the frame has the specified units.
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
void Clear()
Remove all items from the view.
Definition: view.cpp:1100
static TOOL_ACTION toggleGrid
Definition: actions.h:140
LIB_ID GetLibId() const override
Definition: lib_symbol.h:135
void SyncLibraries(bool aShowProgress, bool aPreloadCancelled=false, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
Class to handle modifications to the symbol libraries.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
const LIB_TABLE_ROW * FindRowByURI(const wxString &aURI)
static TOOL_ACTION inchesUnits
Definition: actions.h:144
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
coord_type GetWidth() const
Definition: box2.h:180
static TOOL_ACTION save
Definition: actions.h:51
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:145
bool IsSymbolModified(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol has unsaved modifications.
int GetUnitCount() const override
For items with units, return the number of units.
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.
wxString getTargetLib() const
const wxString GetType() const override
Return the type of symbol library table represented by this row.
SYMBOL_LIBRARY_MANAGER & GetLibManager()
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
Definition: lib_tree.cpp:165
void HardRedraw() override
Rebuild the GAL and redraw the screen.
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:176
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
ACTIONS * m_actions
Definition: tools_holder.h:159
virtual void DrawGrid()
static TOOL_ACTION cut
Definition: actions.h:66
static TOOL_ACTION drawSymbolCircle
Definition: ee_actions.h:104
bool CanCloseSymbolFromSchematic(bool doClose)
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:213
Definition of file extensions used in Kicad.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:202
void CloseWindow(wxCommandEvent &event)
Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
void ReCreateHToolbar() override
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
Definition for symbol library class.
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
bool replaceLibTableEntry(const wxString &aLibNickname, const wxString &aLibFile)
Replace the file path of the symbol library table entry aLibNickname with aLibFile.
wxString KiCadSymbolLibFileWildcard()
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
#define KICAD_DEFAULT_DRAWFRAME_STYLE
static TOOL_ACTION importSymbol
Definition: ee_actions.h:180
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
void DisplaySymbol(LIB_SYMBOL *aSymbol)
void Sync(const wxString &aForceRefresh, std::function< void(int, int, const wxString &)> aProgressCallback)
Updates the SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table.
A holder to handle information on schematic or board items.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:108
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
void OnToggleSymbolTree(wxCommandEvent &event)
bool isCurrentSymbol(const LIB_ID &aLibId) const
Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Handle actions that are shared between different applications.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:231
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
bool HasLibModifications() const
Check if any pending libraries have been modified.
void ReCreateMenuBar() override
Recreates the menu bar.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:484
Specialization of the wxAuiPaneInfo class for KiCad panels.
static TOOL_ACTION showDeMorganStandard
Definition: ee_actions.h:127
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
bool addLibTableEntry(const wxString &aLibFile, TABLE_SCOPE aScope=GLOBAL_LIB_TABLE)
Add aLibFile to the symbol library table defined by aScope.
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...
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
static TOOL_ACTION showElectricalTypes
Definition: ee_actions.h:204
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
UNDO_REDO_CONTAINER m_redoList
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
static TOOL_ACTION milsUnits
Definition: actions.h:145
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
wxString UnescapeString(const wxString &aSource)
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
Gather all the actions that are shared by tools.
Definition: ee_actions.h:38
Handles action that are shared between different applications.
Definition: common_tools.h:37
COLOR_SETTINGS * m_colorSettings
The current canvas type.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition: lib_symbol.h:241
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
Definition: project.cpp:212
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
const KIID m_Uuid
Definition: eda_item.h:474
UNDO_REDO_LIST
Specifies whether we are interacting with the undo or redo stacks.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION newSymbol
Definition: ee_actions.h:173
wxArrayString GetLibraryNames() const
Return the array of library names.
void ExpandLibId(const LIB_ID &aLibId)
Expand and item i the tree widget.
Definition: lib_tree.cpp:207
bool LoadSymbolFromCurrentLib(const wxString &aAliasName, int aUnit=0, int aConvert=0)
Load a symbol from the current active library, optionally setting the selected unit and convert.
static TOOL_ACTION saveSymbolAs
Definition: ee_actions.h:172
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
void doCloseWindow() override
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
LIB_ID GetTargetLibId() const
static TOOL_ACTION redo
Definition: actions.h:65
COLOR4D GetColor(int aLayer) const
void HideDrawingSheet()
Definition: sch_view.cpp:178
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
Definition: project.cpp:227
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:97
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
bool IsContentModified() const override
Get if any symbols or libraries have been modified but not saved.
void RefreshLibraryTree()
Redisplay the library tree.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
see class PGM_BASE
bool IsCancelled() const override
SYMBOL_EDITOR_SETTINGS * m_settings
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
Schematic symbol object.
Definition: sch_symbol.h:78
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
bool saveAllLibraries(bool aRequireConfirmation)
Save the current symbol.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
Tool that displays edit points allowing to modify items by dragging the points.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
void SetNickName(const wxString &aNickName)
Change the logical name of this library, useful for an editor.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:678
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetOrigin(const Vec &pos)
Definition: box2.h:193
#define EDIT_TOOL(tool)
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Handle the component boundary box.
Definition: eda_rect.h:42
wxProgressDialog with the option to also update the application progress on the taskbar
static bool empty(const wxTextEntryBase *aCtrl)
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static TOOL_ACTION drawSymbolArc
Definition: ee_actions.h:105
wxPoint GetPosition() const override
Definition: sch_symbol.h:645
coord_type GetHeight() const
Definition: box2.h:181
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
LIB_SYMBOL * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
void OnExitKiCad(wxCommandEvent &event)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
Color settings are a bit different than most of the settings objects in that there can be more than o...
WX_INFOBAR * GetInfoBar()
static TOOL_ACTION deleteTool
Definition: actions.h:73
SYMBOL_LIBRARY_MANAGER * m_libMgr
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Create an empty library and adds it to the library table.
static TOOL_ACTION toggleSyncedPinsMode
Definition: ee_actions.h:198
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:171
static TOOL_ACTION undo
Definition: actions.h:64
void OnGridSettings(wxCommandEvent &event)
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
static TOOL_ACTION saveAll
Definition: actions.h:54
void InitTools()
Initializes all registered tools.
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
const Vec & GetOrigin() const
Definition: box2.h:176
bool AddLibraryFile(bool aCreateNew)
Create or add an existing library to the symbol library table.
int GetUnit() const
Definition: sch_symbol.h:196
void emptyScreen()
Return either the symbol selected in the symbol tree, if context menu is active or the currently modi...
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:49
LIB_TREE * GetLibTree() const
BASE_SCREEN class implementation.
Handle actions for the various symbol editor and viewers.
static constexpr int Millimeter2iu(double mm)
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
bool IsSymbolFromLegacyLibrary() const
int GetConvert() const
Definition: sch_symbol.h:224
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
wxString SetCurLib(const wxString &aLibNickname)
Set the current library nickname and returns the old library nickname.
static TOOL_ACTION selectAll
Definition: actions.h:70
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:57
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
static TOOL_ACTION paste
Definition: actions.h:68
#define ENABLE(x)
static TOOL_ACTION duplicate
Definition: actions.h:71
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:71
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:107
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION selectionTool
Definition: actions.h:153
static TOOL_ACTION saveLibraryAs
Definition: ee_actions.h:171
wxComboBox * m_unitSelectBox
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
Definition: lib_tree.cpp:196
SYMBOL_EDITOR_DRAWING_TOOLS.
KIID m_schematicSymbolUUID
RefDes of the symbol (only valid if symbol was loaded from schematic)
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
Definition: lib_tree.cpp:190
bool empty() const
Definition: utf8.h:103
virtual void UpdateMsgPanel()
Redraw the message panel.
const std::string KiCadSymbolLibFileExtension
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184
The symbol library editor main window.