KiCad PCB EDA Suite
libedit.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <kiway.h>
33 #include <gr_basic.h>
34 #include <macros.h>
35 #include <pgm_base.h>
36 #include <class_drawpanel.h>
37 #include <confirm.h>
38 #include <gestfich.h>
39 #include <class_sch_screen.h>
40 
41 #include <eeschema_id.h>
42 #include <general.h>
43 #include <libeditframe.h>
44 #include <class_library.h>
45 #include <template_fieldnames.h>
47 #include <schframe.h>
48 #include <symbol_lib_table.h>
49 
51 #include <cmp_tree_model_adapter.h>
52 
54 
55 
57 {
58  wxString lib = GetCurLib();
59  wxString title = _( "Symbol Library Editor - " );
60 
61  if( !lib.empty() && Prj().SchSymbolLibTable()->HasLibrary( lib ) )
62  {
63  wxString fileName = Prj().SchSymbolLibTable()->GetFullURI( lib );
64 
65  title += lib + " (" + fileName + ")";
66 
67  if( !wxFileName::IsFileWritable( fileName ) )
68  title += " " + _( "[Read Only]" );
69  }
70  else
71  title += _( "no library selected" );
72 
73  SetTitle( title );
74 }
75 
76 
77 void LIB_EDIT_FRAME::SelectActiveLibrary( const wxString& aLibrary )
78 {
79  wxString selectedLib = aLibrary;
80 
81  if( selectedLib.empty() )
82  selectedLib = SelectLibraryFromList();
83 
84  if( !selectedLib.empty() )
85  SetCurLib( selectedLib );
86 
88 }
89 
90 
92 {
93  if( GetScreen()->IsModify()
94  && !IsOK( this, _( "The current symbol is not saved.\n\nDiscard current changes?" ) ) )
95  return false;
96 
99 }
100 
101 
102 bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( const wxString& aAliasName, int aUnit,
103  int aConvert )
104 {
105  LIB_ALIAS* alias = nullptr;
106 
107  try
108  {
109  alias = Prj().SchSymbolLibTable()->LoadSymbol( GetCurLib(), aAliasName );
110  }
111  catch( const IO_ERROR& ioe )
112  {
113  wxString msg;
114 
115  msg.Printf( _( "Error occurred loading symbol '%s' from library '%s'." ),
116  aAliasName, GetCurLib() );
117  DisplayErrorMessage( this, msg, ioe.What() );
118  return false;
119  }
120 
121  if( !alias || !LoadOneLibraryPartAux( alias, GetCurLib() ) )
122  return false;
123 
124  if( aUnit > 0 )
125  m_unit = aUnit;
126 
127  if( aConvert > 0 )
128  m_convert = aConvert;
129 
130  m_editPinsPerPartOrConvert = GetCurPart()->UnitsLocked() ? true : false;
131 
133  Zoom_Automatique( false );
134  SetShowDeMorgan( GetCurPart()->HasConversion() );
135 
136  if( aUnit > 0 )
138 
139  return true;
140 }
141 
142 
143 void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
144 {
146 
147  if( GetScreen()->IsModify()
148  && !IsOK( this, _( "The current symbol is not saved.\n\nDiscard current changes?" ) ) )
149  return;
150 
151  wxString lib = GetCurLib();
152 
153  // No current lib, ask user for the library to use.
154  if( lib.empty() )
155  {
157 
158  lib = GetCurLib();
159 
160  if( lib.empty() )
161  return;
162  }
163 
164  // Get the name of the current part to preselect it
165  LIB_PART* current_part = GetCurPart();
166  LIB_ID id;
167 
168  if( current_part )
169  id = current_part->GetLibId();
170 
171  SCH_BASE_FRAME::HISTORY_LIST dummyHistoryList;
172  SCHLIB_FILTER filter;
173  filter.LoadFrom( lib );
174  auto sel = SelectComponentFromLibrary( &filter, dummyHistoryList, true, 0, 0, &id, false );
175 
176  if( sel.LibId.GetLibItemName().empty() )
177  return;
178 
179  GetScreen()->ClrModify();
180  m_lastDrawItem = m_drawItem = NULL;
181 
182  // Delete previous library symbol, if any
183  SetCurPart( NULL );
184  m_aliasName.Empty();
185 
186  // Load the new library symbol
187  LoadComponentFromCurrentLib( sel.LibId.GetLibItemName(), sel.Unit, sel.Convert );
188 }
189 
190 
191 bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& aLibrary )
192 {
193  wxString msg, rootName;
194 
195  if( !aEntry || aLibrary.empty() )
196  return false;
197 
198  if( aEntry->GetName().IsEmpty() )
199  {
200  wxLogWarning( "Symbol in library '%s' has empty name field.", aLibrary );
201  return false;
202  }
203 
204  wxString cmpName = m_aliasName = aEntry->GetName();
205 
206  LIB_PART* lib_part = aEntry->GetPart();
207 
208  wxASSERT( lib_part );
209 
210  LIB_PART* part = new LIB_PART( *lib_part ); // clone it and own it.
211  SetCurPart( part );
212  m_aliasName = aEntry->GetName();
213 
214  m_unit = 1;
215  m_convert = 1;
216 
217  m_showDeMorgan = false;
218 
219  if( part->HasConversion() )
220  m_showDeMorgan = true;
221 
222  GetScreen()->ClrModify();
223  DisplayLibInfos();
226 
227  // Display the document information based on the entry selected just in
228  // case the entry is an alias.
229  DisplayCmpDoc();
230 
231  return true;
232 }
233 
234 
235 void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset )
236 {
237  LIB_PART* part = GetCurPart();
238 
239  if( part )
240  {
241  // display reference like in schematic (a reference U is shown U? or U?A)
242  // although it is stored without ? and part id.
243  // So temporary change the reference by a schematic like reference
244  LIB_FIELD* field = part->GetField( REFERENCE );
245  wxString fieldText = field->GetText();
246  wxString fieldfullText = field->GetFullText( m_unit );
247 
248  field->EDA_TEXT::SetText( fieldfullText ); // change the field text string only
249  auto opts = PART_DRAW_OPTIONS::Default();
250  opts.show_elec_type = GetShowElectricalType();
251  part->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, opts );
252  field->EDA_TEXT::SetText( fieldText ); // restore the field text string
253  }
254 }
255 
256 
257 void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
258 {
259  if( GetScreen() == NULL )
260  return;
261 
262  m_canvas->DrawBackGround( DC );
263 
264  RedrawComponent( DC, wxPoint( 0, 0 ) );
265 
266 #ifdef USE_WX_OVERLAY
267  if( IsShown() )
268  {
269  m_overlay.Reset();
270  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC );
271  overlaydc.Clear();
272  }
273 #endif
274 
275  if( m_canvas->IsMouseCaptured() )
276  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
277 
278  m_canvas->DrawCrossHair( DC );
279 
280  DisplayLibInfos();
281  UpdateStatusBar();
282 }
283 
284 
285 void LIB_EDIT_FRAME::OnSaveActiveLibrary( wxCommandEvent& event )
286 {
288 }
289 
290 
292 {
293  wxFileName fn;
294  wxString msg;
295  PROJECT& prj = Prj();
296 
298 
299  wxString lib = GetCurLib();
300 
301  if( !newFile && ( lib.empty() || !prj.SchSymbolLibTable()->HasLibrary( lib ) ) )
302  {
303  DisplayError( this, _( "No library specified." ) );
304  return false;
305  }
306 
307  if( GetScreen()->IsModify() && !IsOK( this, _( "Include current symbol changes?" ) ) )
308  return false;
309 
310  if( newFile )
311  {
312  SEARCH_STACK* search = prj.SchSearchS();
313 
314  // Get a new name for the library
315  wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
316 
317  if( !default_path )
318  default_path = search->LastVisitedPath();
319 
320  wxFileDialog dlg( this, _( "Symbol Library Name" ), default_path,
321  wxEmptyString, SchematicLibraryFileWildcard(),
322  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
323 
324  if( dlg.ShowModal() == wxID_CANCEL )
325  return false;
326 
327  fn = dlg.GetPath();
328 
329  // The GTK file chooser doesn't return the file extension added to
330  // file name so add it here.
331  if( fn.GetExt().IsEmpty() )
332  fn.SetExt( SchematicLibraryFileExtension );
333 
334  prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() );
335  }
336  else
337  {
338  fn = prj.SchSymbolLibTable()->GetFullURI( lib );
339 
340  msg.Printf( _( "Modify symbol library file '%s' ?" ), fn.GetFullPath() );
341 
342  if( !IsOK( this, msg ) )
343  return false;
344  }
345 
346  // Verify the user has write privileges before attempting to save the library file.
347  if( !IsWritable( fn ) )
348  return false;
349 
350  ClearMsgPanel();
351 
352  wxFileName libFileName = fn;
353  wxFileName backupFileName = fn;
354 
355  // Copy .lib file to .bak.
356  if( libFileName.FileExists() )
357  {
358  backupFileName.SetExt( "bak" );
359 
360  if( backupFileName.FileExists() )
361  wxRemoveFile( backupFileName.GetFullPath() );
362 
363  if( !wxCopyFile( libFileName.GetFullPath(), backupFileName.GetFullPath() ) )
364  {
365  libFileName.MakeAbsolute();
366  msg.Printf( _( "Failed to rename old symbol library to file '%s'" ),
367  backupFileName.GetFullPath() );
368  DisplayError( this, msg );
369  return false;
370  }
371  }
372 
373  wxFileName docFileName = libFileName;
374 
375  docFileName.SetExt( DOC_EXT );
376 
377  // Copy .dcm file to .bck.
378  if( docFileName.FileExists() )
379  {
380  backupFileName.SetExt( "bck" );
381 
382  if( backupFileName.FileExists() )
383  wxRemoveFile( backupFileName.GetFullPath() );
384 
385  if( !wxCopyFile( docFileName.GetFullPath(), backupFileName.GetFullPath() ) )
386  {
387  msg.Printf( _( "Failed to save old library document to file '%s'" ),
388  backupFileName.GetFullPath() );
389  DisplayError( this, msg );
390  return false;
391  }
392  }
393 
394  // Copy the library and document files to the new destination library files.
395  if( newFile )
396  {
397  wxFileName src = prj.SchSymbolLibTable()->GetFullURI( GetCurLib() );
398 
399  if( !wxCopyFile( src.GetFullPath(), libFileName.GetFullPath() ) )
400  {
401  msg.Printf( _( "Failed to copy symbol library file '%s'" ), libFileName.GetFullPath() );
402  DisplayError( this, msg );
403  return false;
404  }
405 
406  src.SetExt( DOC_EXT );
407 
408  if( !wxCopyFile( src.GetFullPath(), docFileName.GetFullPath() ) )
409  {
410  msg.Printf( _( "Failed to copy symbol library document file '%s'" ),
411  docFileName.GetFullPath() );
412  DisplayError( this, msg );
413  return false;
414  }
415  }
416 
417  // Update symbol changes in library.
418  if( GetScreen()->IsModify() )
419  {
420  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
421 
422  try
423  {
424  pi->SaveSymbol( fn.GetFullPath(), new LIB_PART( *GetCurPart() ) );
425  }
426  catch( const IO_ERROR& ioe )
427  {
428  msg.Printf( _( "Failed to save changes to symbol library file '%s'" ),
429  libFileName.GetFullPath() );
430  DisplayErrorMessage( this, msg, ioe.What() );
431  return false;
432  }
433 
434  GetScreen()->ClrModify();
435  }
436 
437  msg.Printf( _( "Symbol library file '%s' saved" ), libFileName.GetFullPath() );
438  wxString msg1;
439  msg1.Printf( _( "Symbol library documentation file '%s' saved" ), docFileName.GetFullPath() );
440  AppendMsgPanel( msg, msg1, BLUE );
444 
445  return true;
446 }
447 
448 
450 {
451  LIB_ALIAS* alias;
452  LIB_PART* part = GetCurPart();
453 
454  ClearMsgPanel();
455 
456  if( !part )
457  return;
458 
459  wxString msg = part->GetName();
460 
461  AppendMsgPanel( _( "Name" ), msg, BLUE, 8 );
462 
463  if( m_aliasName == part->GetName() )
464  msg = _( "None" );
465  else
466  msg = m_aliasName;
467 
468  alias = part->GetAlias( m_aliasName );
469 
470  wxCHECK_RET( alias != NULL, "Alias not found in symbol." );
471 
472  AppendMsgPanel( _( "Alias" ), msg, RED, 8 );
473 
474  static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
475  msg = UnitLetter[m_unit];
476 
477  AppendMsgPanel( _( "Unit" ), msg, BROWN, 8 );
478 
479  if( m_convert > 1 )
480  msg = _( "Convert" );
481  else
482  msg = _( "Normal" );
483 
484  AppendMsgPanel( _( "Body" ), msg, GREEN, 8 );
485 
486  if( part->IsPower() )
487  msg = _( "Power Symbol" );
488  else
489  msg = _( "Part" );
490 
491  AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 );
492  AppendMsgPanel( _( "Description" ), alias->GetDescription(), CYAN, 8 );
493  AppendMsgPanel( _( "Key words" ), alias->GetKeyWords(), DARKDARKGRAY );
494  AppendMsgPanel( _( "Datasheet" ), alias->GetDocFileName(), DARKDARKGRAY );
495 }
496 
497 
498 void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
499 {
500  wxString cmp_name;
501  wxArrayString nameList;
502  wxString msg;
503 
505 
506  m_lastDrawItem = NULL;
507  m_drawItem = NULL;
508 
509  LIB_PART *part = GetCurPart();
510  wxString lib = GetCurLib();
511 
512  if( lib.empty() )
513  {
515 
516  lib = GetCurLib();
517 
518  if( !lib )
519  {
520  DisplayError( this, _( "Please select a symbol library." ) );
521  return;
522  }
523  }
524 
525  auto adapter( CMP_TREE_MODEL_ADAPTER::Create( Prj().SchSymbolLibTable() ) );
526 
527  wxString name = part ? part->GetName() : wxString( wxEmptyString );
528  adapter->SetPreselectNode( name, /* aUnit */ 0 );
529  adapter->ShowUnits( false );
530  adapter->AddLibrary( lib );
531 
532  wxString dialogTitle;
533  dialogTitle.Printf( _( "Delete Symbol (%u items loaded)" ), adapter->GetComponentsCount() );
534 
535  DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, m_convert, false );
536 
537  if( dlg.ShowQuasiModal() == wxID_CANCEL )
538  {
539  return;
540  }
541 
542  LIB_ID id;
543 
544  id = dlg.GetSelectedLibId();
545 
546  if( !id.IsValid() )
547  return;
548 
549  LIB_ALIAS* alias = Prj().SchSymbolLibTable()->LoadSymbol( id );
550 
551  if( !alias )
552  return;
553 
554  msg.Printf( _( "Delete symbol '%s' from library '%s'?" ),
555  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
556 
557  if( !IsOK( this, msg ) )
558  return;
559 
560  part = GetCurPart();
561 
562  if( !part || !part->HasAlias( id.GetLibItemName() ) )
563  {
564  Prj().SchSymbolLibTable()->DeleteAlias( id.GetLibNickname(), id.GetLibItemName() );
565  m_canvas->Refresh();
566  return;
567  }
568 
569  // If deleting the current entry or removing one of the aliases for
570  // the current entry, sync the changes in the current entry as well.
571 
572  if( GetScreen()->IsModify() && !IsOK( this, _(
573  "The symbol being deleted has been modified."
574  " All changes will be lost. Discard changes?" ) ) )
575  {
576  return;
577  }
578 
579  try
580  {
581  Prj().SchSymbolLibTable()->DeleteAlias( id.GetLibNickname(), id.GetLibItemName() );
582  }
583  catch( ... /* IO_ERROR ioe */ )
584  {
585  msg.Printf( _( "Error occurred deleting symbol '%s' from library '%s'" ),
586  id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
587  DisplayError( this, msg );
588  return;
589  }
590 
591  SetCurPart( NULL ); // delete CurPart
592  m_aliasName.Empty();
593  m_canvas->Refresh();
594 }
595 
596 
597 void LIB_EDIT_FRAME::CreateNewLibraryPart( wxCommandEvent& event )
598 {
599  wxString name;
600 
601  if( GetCurPart() && GetScreen()->IsModify() && !IsOK( this, _(
602  "All changes to the current symbol will be lost!\n\n"
603  "Clear the current symbol from the screen?" ) ) )
604  {
605  return;
606  }
607 
609 
610  m_drawItem = NULL;
611 
612  DIALOG_LIB_NEW_COMPONENT dlg( this );
613 
614  dlg.SetMinSize( dlg.GetSize() );
615 
616  if( dlg.ShowModal() == wxID_CANCEL )
617  return;
618 
619  if( dlg.GetName().IsEmpty() )
620  {
621  wxMessageBox( _( "This new symbol has no name and cannot be created." ) );
622  return;
623  }
624 
625  name = dlg.GetName();
626  name.Replace( " ", "_" );
627 
628  wxString lib = GetCurLib();
629 
630  // Test if there a component with this name already.
631  if( !lib.empty() && Prj().SchSymbolLibTable()->LoadSymbol( lib, name ) != NULL )
632  {
633  wxString msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'" ),
634  name, lib );
635  DisplayError( this, msg );
636  return;
637  }
638 
639  LIB_PART* new_part = new LIB_PART( name );
640 
641  SetCurPart( new_part );
642  m_aliasName = new_part->GetName();
643 
644  new_part->GetReferenceField().SetText( dlg.GetReference() );
645  new_part->SetUnitCount( dlg.GetUnitCount() );
646 
647  // Initialize new_part->m_TextInside member:
648  // if 0, pin text is outside the body (on the pin)
649  // if > 0, pin text is inside the body
650  new_part->SetConversion( dlg.GetAlternateBodyStyle() );
652 
653  if( dlg.GetPinNameInside() )
654  {
655  new_part->SetPinNameOffset( dlg.GetPinTextPosition() );
656 
657  if( new_part->GetPinNameOffset() == 0 )
658  new_part->SetPinNameOffset( 1 );
659  }
660  else
661  {
662  new_part->SetPinNameOffset( 0 );
663  }
664 
665  ( dlg.GetPowerSymbol() ) ? new_part->SetPower() : new_part->SetNormal();
666  new_part->SetShowPinNumbers( dlg.GetShowPinNumber() );
667  new_part->SetShowPinNames( dlg.GetShowPinName() );
668  new_part->LockUnits( dlg.GetLockItems() );
669 
670  if( dlg.GetUnitCount() < 2 )
671  new_part->LockUnits( false );
672 
673  m_unit = 1;
674  m_convert = 1;
675 
676  DisplayLibInfos();
677  DisplayCmpDoc();
680 
681  m_editPinsPerPartOrConvert = new_part->UnitsLocked() ? true : false;
682  m_lastDrawItem = NULL;
683 
685  OnModify();
686 
687  m_canvas->Refresh();
688  m_mainToolBar->Refresh();
689 }
Definition: colors.h:57
bool UnitsLocked() const
LIB_FIELD * GetField(int aId)
Return pointer to the requested field.
static PTR Create(SYMBOL_LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDc, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Draw part.
Part library alias object definition.
void SetConversion(bool aSetConvert)
Set or clear the alternate body style (DeMorgan) for the part.
void SetPower()
bool LoadComponentFromCurrentLib(const wxString &aAliasName, int aUnit=0, int aConvert=0)
Loads a symbol from the current active library, optionally setting the selected unit and convert...
Definition: libedit.cpp:102
Class PROJECT holds project specific data.
Definition: project.h:56
int GetPinNameOffset()
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
static int m_convert
Definition: libeditframe.h:100
This file is part of the common library TODO brief description.
bool IsPower() const
LIB_ALIAS * GetAlias(size_t aIndex)
wxString SelectLibraryFromList()
Dispaly a list of loaded libraries in the symbol library and allows the user to select a library...
Definition: selpart.cpp:76
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
This file is part of the common library.
bool SaveActiveLibrary(bool newFile)
Saves the changes to the current library.
Definition: libedit.cpp:291
static LIB_ITEM * m_drawItem
Definition: libeditframe.h:92
void OnSaveActiveLibrary(wxCommandEvent &event)
The command event handler to save the changes to the current library.
Definition: libedit.cpp:285
Definition: colors.h:61
Class LIB_FIELD is used in symbol libraries.
Definition: lib_field.h:60
void DrawCrossHair(wxDC *aDC, COLOR4D aColor=COLOR4D::WHITE)
Function DrawCrossHair draws the user cross hair.
Definition: draw_panel.cpp:215
void LoadFrom(const wxString &aLibName)
add a lib name to the allowed libraries
void SelectActiveLibrary(const wxString &aLibrary=wxEmptyString)
Set the current active library to aLibrary.
Definition: libedit.cpp:77
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
bool HasAlias(const wxString &aName) const
Test if alias aName is in part alias list.
wxString SchematicLibraryFileWildcard()
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
const LIB_ID & GetLibId() const
std::vector< COMPONENT_SELECTION > HISTORY_LIST
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen...
Definition: libeditframe.h:352
bool IsModify() const
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:529
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:553
Class LIB_ID.
Definition: lib_id.h:56
void UpdateAliasSelectList()
Field Reference of part, i.e. "IC21".
void SetShowDeMorgan(bool show)
Definition: libeditframe.h:388
This file contains miscellaneous commonly used macros and functions.
void DisplayLibInfos()
Updates the main window title bar with the current library name and read only status of the library...
Definition: libedit.cpp:56
Dialog class to select a component from the libraries.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:77
Subclass of DIALOG_LIB_NEW_COMPONENT, which is generated by wxFormBuilder.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:85
void DeleteOnePart(wxCommandEvent &event)
Delete a symbol from the current library.
Definition: libedit.cpp:498
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:675
void SetUnitCount(int count)
Set the units per part count.
void LoadOneLibraryPart(wxCommandEvent &event)
Loads a symbol from the currently selected library.
Definition: libedit.cpp:143
bool IsMouseCaptured() const
Definitions for the Eeschema program SCH_SCREEN class.
const wxString & GetName() const
const UTF8 & GetLibItemName() const
Function GetLibItemName.
Definition: lib_id.h:129
int ShowQuasiModal()
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
wxString GetDescription() const
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
Definition: colors.h:59
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
Class LIB_PART defines a library part object.
The common library.
#define DOC_EXT
Definition: class_library.h:50
Definition: colors.h:60
wxString GetName(void) const override
static LIB_ITEM * m_lastDrawItem
Definition: libeditframe.h:91
static PART_DRAW_OPTIONS Default()
void CreateNewLibraryPart(wxCommandEvent &event)
Create a new library symbol.
Definition: libedit.cpp:597
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
void DisplayCmpDoc()
Display the documentation of the selected component.
Definition: libedit.cpp:449
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:173
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:513
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:764
wxString GetDocFileName() 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:188
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
bool LoadOneLibraryPartAux(LIB_ALIAS *aLibEntry, const wxString &aLibrary)
Create a copy of aLibEntry into memory.
Definition: libedit.cpp:191
Definition: colors.h:58
see class PGM_BASE
static wxString m_aliasName
Definition: libeditframe.h:93
static int m_unit
Definition: libeditframe.h:96
const wxString & GetName() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
void SetCurPart(LIB_PART *aPart)
Take ownership of aPart and notes that it is the one currently being edited.
void RedrawComponent(wxDC *aDC, wxPoint aOffset)
Redraw the current component loaded in library editor Display reference like in schematic (a referenc...
Definition: libedit.cpp:235
const wxString LastVisitedPath(const wxString &aSubPathToSearch=wxEmptyString)
Function LastVisitedPath is a quirky function inherited from old code that seems to serve particular ...
LIB_PART * GetCurPart()
Return the current part being edited or NULL if none selected.
const char * name
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
Implementing DIALOG_LIB_NEW_COMPONENT.
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_PART *aSymbol, const PROPERTIES *aProperties=NULL)
Write aSymbol to an existing library located at aLibraryPath.
Definition: sch_plugin.cpp:102
wxString SetCurLib(const wxString &aLibNickname)
Sets the current library nickname and returns the old library nickname.
void DrawBackGround(wxDC *DC)
Function DrawBackGround.
Definition: draw_panel.cpp:665
bool LoadComponentAndSelectLib(const LIB_ID &aLibId)
Selects the currently active library and loads the symbol from aLibId.
Definition: libedit.cpp:91
Definition for part library class.
static bool m_showDeMorgan
Definition: libeditframe.h:107
const UTF8 & GetLibNickname() const
Function GetLibNickname.
Definition: lib_id.h:108
wxString GetCurLib()
The nickname of the current library being edited and empty string if none.
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
Redraw the current component loaded in library editor, an axes Display reference like in schematic (a...
Definition: libedit.cpp:257
int GetDefaultCursor() const
Function GetDefaultCursor.
const wxString SchematicLibraryFileExtension
COMPONENT_SELECTION SelectComponentFromLibrary(const SCHLIB_FILTER *aFilter, std::vector< COMPONENT_SELECTION > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Function SelectComponentFromLib Calls the library viewer to select component to import into schematic...
Definition: getpart.cpp:102
wxString GetKeyWords() const
bool m_editPinsPerPartOrConvert
Set to true to not synchronize pins at the same position when editing components with multiple parts ...
Definition: libeditframe.h:78
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:129
void UpdatePartSelectList()
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:775
Definition of class LIB_EDIT_FRAME.
bool GetShowElectricalType()
Definition: libeditframe.h:390
void LockUnits(bool aLockUnits)
void SetNormal()
Definition: colors.h:62