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-2017 Wayne Stambaugh <stambaughw@verizon.net>
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 
50 #include <cmp_tree_model_adapter.h>
51 
53 
54 
56 {
57  PART_LIB* lib = GetCurLib();
58  wxString title = wxString::Format( _( "Part Library Editor -- %s %s" ),
59  lib ? lib->GetFullFileName() : _( "no library selected" ),
60  lib && lib->IsReadOnly() ? _( "[Read Only]") : wxString( wxEmptyString ) );
61 
62  SetTitle( title );
63 }
64 
65 
67 {
68  if( !aLibrary )
69  aLibrary = SelectLibraryFromList();
70 
71  if( aLibrary )
72  {
73  SetCurLib( aLibrary );
74  }
75 
77 }
78 
79 
81 {
82  if( GetScreen()->IsModify()
83  && !IsOK( this, _( "The current component is not saved.\n\nDiscard current changes?" ) ) )
84  return false;
85 
86  SelectActiveLibrary( aLibrary );
87  return LoadComponentFromCurrentLib( aLibEntry );
88 }
89 
90 
91 bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry, int aUnit, int aConvert )
92 {
93  if( !LoadOneLibraryPartAux( aLibEntry, GetCurLib() ) )
94  return false;
95 
96  if( aUnit > 0 )
97  m_unit = aUnit;
98 
99  if( aConvert > 0 )
100  m_convert = aConvert;
101 
102  m_editPinsPerPartOrConvert = GetCurPart()->UnitsLocked() ? true : false;
103 
105  Zoom_Automatique( false );
106  SetShowDeMorgan( GetCurPart()->HasConversion() );
107 
108  if( aUnit > 0 )
110 
111  return true;
112 }
113 
114 
115 void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
116 {
117  LIB_ALIAS* libEntry = NULL;
118 
120 
121  if( GetScreen()->IsModify()
122  && !IsOK( this, _( "The current component is not saved.\n\nDiscard current changes?" ) ) )
123  return;
124 
125  PART_LIB* lib = GetCurLib();
126 
127  // No current lib, ask user for the library to use.
128  if( !lib )
129  {
131  lib = GetCurLib();
132 
133  if( !lib )
134  return;
135  }
136 
137  // Get the name of the current part to preselect it
138  LIB_PART* current_part = GetCurPart();
139  wxString part_name = current_part ? current_part->GetName() : wxString( wxEmptyString );
140 
141  SCH_BASE_FRAME::HISTORY_LIST dummyHistoryList;
142  SCHLIB_FILTER filter;
143  filter.LoadFrom( lib->GetName() );
144  auto sel = SelectComponentFromLibrary( &filter, dummyHistoryList,
145  true, 0, 0, part_name, false );
146 
147  if( sel.Name.IsEmpty() )
148  return;
149 
150  GetScreen()->ClrModify();
151  m_lastDrawItem = m_drawItem = NULL;
152 
153  // Delete previous library component, if any
154  SetCurPart( NULL );
155  m_aliasName.Empty();
156 
157  // Load the new library component
158  libEntry = lib->FindAlias( sel.Name );
159  PART_LIB* searchLib = lib;
160 
161  if( !libEntry )
162  {
163  // Not found in the active library: search inside the full list
164  // (can happen when using Viewlib to load a component)
165  libEntry = Prj().SchLibs()->FindLibraryAlias( LIB_ID( wxEmptyString, sel.Name ) );
166 
167  if( libEntry )
168  {
169  searchLib = libEntry->GetLib();
170 
171  // The entry to load is not in the active lib
172  // Ask for a new active lib
173  wxString msg = _( "The selected component is not in the active library." );
174  msg += "\n\n";
175  msg += _( "Do you want to change the active library?" );
176 
177  if( IsOK( this, msg ) )
178  SelectActiveLibrary( searchLib );
179  }
180  }
181 
182  if( !libEntry )
183  {
184  wxString msg = wxString::Format( _( "Part name '%s' not found in library '%s'" ),
185  GetChars( sel.Name ),
186  GetChars( searchLib->GetName() ) );
187  DisplayError( this, msg );
188  return;
189  }
190 
191  PART_LIB* old = SetCurLib( searchLib );
192 
193  LoadComponentFromCurrentLib( libEntry, sel.Unit, sel.Convert );
194 
195  SetCurLib( old );
196 
197  DisplayLibInfos();
198 }
199 
200 
202 {
203  wxString msg, rootName;
204 
205  if( !aEntry || !aLibrary )
206  return false;
207 
208  if( aEntry->GetName().IsEmpty() )
209  {
210  wxLogWarning( "Entry in library <%s> has empty name field.",
211  GetChars( aLibrary->GetName() ) );
212  return false;
213  }
214 
215  wxString cmpName = m_aliasName = aEntry->GetName();
216 
217  LIB_PART* lib_part = aEntry->GetPart();
218 
219  wxASSERT( lib_part );
220 
221  wxLogDebug( "\"<%s>\" is alias of \"<%s>\"",
222  GetChars( cmpName ),
223  GetChars( lib_part->GetName() ) );
224 
225  LIB_PART* part = new LIB_PART( *lib_part ); // clone it and own it.
226  SetCurPart( part );
227  m_aliasName = aEntry->GetName();
228 
229  m_unit = 1;
230  m_convert = 1;
231 
232  m_showDeMorgan = false;
233 
234  if( part->HasConversion() )
235  m_showDeMorgan = true;
236 
237  GetScreen()->ClrModify();
238  DisplayLibInfos();
241 
242  // Display the document information based on the entry selected just in
243  // case the entry is an alias.
244  DisplayCmpDoc();
245 
246  return true;
247 }
248 
249 
250 void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset )
251 {
252  LIB_PART* part = GetCurPart();
253 
254  if( part )
255  {
256  // display reference like in schematic (a reference U is shown U? or U?A)
257  // although it is stored without ? and part id.
258  // So temporary change the reference by a schematic like reference
259  LIB_FIELD* field = part->GetField( REFERENCE );
260  wxString fieldText = field->GetText();
261  wxString fieldfullText = field->GetFullText( m_unit );
262 
263  field->EDA_TEXT::SetText( fieldfullText ); // change the field text string only
264  auto opts = PART_DRAW_OPTIONS::Default();
265  opts.show_elec_type = GetShowElectricalType();
266  part->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, opts );
267  field->EDA_TEXT::SetText( fieldText ); // restore the field text string
268  }
269 }
270 
271 
272 void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
273 {
274  if( GetScreen() == NULL )
275  return;
276 
277  m_canvas->DrawBackGround( DC );
278 
279  RedrawComponent( DC, wxPoint( 0, 0 ) );
280 
281 #ifdef USE_WX_OVERLAY
282  if( IsShown() )
283  {
284  m_overlay.Reset();
285  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC );
286  overlaydc.Clear();
287  }
288 #endif
289 
290  if( m_canvas->IsMouseCaptured() )
291  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
292 
293  m_canvas->DrawCrossHair( DC );
294 
295  DisplayLibInfos();
296  UpdateStatusBar();
297 }
298 
299 
300 void LIB_EDIT_FRAME::OnSaveActiveLibrary( wxCommandEvent& event )
301 {
302  bool newFile = false;
303 
304  if( event.GetId() == ID_LIBEDIT_SAVE_CURRENT_LIB_AS )
305  newFile = true;
306 
307  SaveActiveLibrary( newFile );
308 }
309 
310 
312 {
313  wxFileName fn;
314  wxString msg;
315 
317 
318  PART_LIB* lib = GetCurLib();
319 
320  if( !lib )
321  {
322  DisplayError( this, _( "No library specified." ) );
323  return false;
324  }
325 
326  // Just in case the library hasn't been cached yet.
327  lib->GetCount();
328 
329  wxString oldFileName = lib->GetFullFileName();
330 
331  if( GetScreen()->IsModify() )
332  {
333  if( IsOK( this, _( "Include last component changes?" ) ) )
334  {
335  lib->EnableBuffering();
336 
337  try
338  {
339  SaveOnePart( lib, false );
340  }
341  catch( ... )
342  {
343  lib->EnableBuffering( false );
344  msg.Printf( _( "Unexpected error occured saving part to '%s' symbol library." ),
345  lib->GetName() );
346  DisplayError( this, msg );
347  return false;
348  }
349 
350  lib->EnableBuffering( false );
351  }
352  }
353 
354  if( newFile )
355  {
356  PROJECT& prj = Prj();
357  SEARCH_STACK* search = prj.SchSearchS();
358 
359  // Get a new name for the library
360  wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
361 
362  if( !default_path )
363  default_path = search->LastVisitedPath();
364 
365  wxFileDialog dlg( this, _( "Part Library Name:" ), default_path,
366  wxEmptyString, SchematicLibraryFileWildcard,
367  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
368 
369  if( dlg.ShowModal() == wxID_CANCEL )
370  return false;
371 
372  fn = dlg.GetPath();
373 
374  // The GTK file chooser doesn't return the file extension added to
375  // file name so add it here.
376  if( fn.GetExt().IsEmpty() )
377  fn.SetExt( SchematicLibraryFileExtension );
378 
379  prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() );
380  }
381  else
382  {
383  fn = wxFileName( lib->GetFullFileName() );
384 
385  msg.Printf( _( "Modify library file '%s' ?" ), GetChars( fn.GetFullPath() ) );
386 
387  if( !IsOK( this, msg ) )
388  return false;
389  }
390 
391  // Verify the user has write privileges before attempting to save the library file.
392  if( !IsWritable( fn ) )
393  return false;
394 
395  ClearMsgPanel();
396 
397  wxFileName libFileName = fn;
398  wxFileName backupFileName = fn;
399 
400  // Rename the old .lib file to .bak.
401  if( libFileName.FileExists() )
402  {
403  backupFileName.SetExt( "bak" );
404 
405  if( backupFileName.FileExists() )
406  wxRemoveFile( backupFileName.GetFullPath() );
407 
408  if( !wxRenameFile( libFileName.GetFullPath(), backupFileName.GetFullPath() ) )
409  {
410  libFileName.MakeAbsolute();
411  msg = _( "Failed to rename old component library file " ) +
412  backupFileName.GetFullPath();
413  DisplayError( this, msg );
414  }
415  }
416 
417  wxFileName docFileName = libFileName;
418 
419  docFileName.SetExt( DOC_EXT );
420 
421  // Rename .doc file to .bck.
422  if( docFileName.FileExists() )
423  {
424  backupFileName.SetExt( "bck" );
425 
426  if( backupFileName.FileExists() )
427  wxRemoveFile( backupFileName.GetFullPath() );
428 
429  if( !wxRenameFile( docFileName.GetFullPath(), backupFileName.GetFullPath() ) )
430  {
431  msg = _( "Failed to save old library document file " ) + backupFileName.GetFullPath();
432  DisplayError( this, msg );
433  }
434  }
435 
436  try
437  {
438  lib->SetFileName( fn.GetFullPath() );
439  lib->Save();
440  }
441  catch( ... /* IO_ERROR ioe */ )
442  {
443  lib->SetFileName( oldFileName );
444  msg.Printf( _( "Failed to create symbol library file '%s'" ),
445  GetChars( docFileName.GetFullPath() ) );
446  DisplayError( this, msg );
447  return false;
448  }
449 
450  lib->SetFileName( oldFileName );
451  msg.Printf( _( "Library file '%s' saved" ), GetChars( fn.GetFullPath() ) );
452  fn.SetExt( DOC_EXT );
453  wxString msg1;
454  msg1.Printf( _( "Documentation file '%s' saved" ), GetChars( fn.GetFullPath() ) );
455  AppendMsgPanel( msg, msg1, BLUE );
459 
460  return true;
461 }
462 
463 
465 {
466  LIB_ALIAS* alias;
467  PART_LIB* lib = GetCurLib();
468  LIB_PART* part = GetCurPart();
469 
470  ClearMsgPanel();
471 
472  if( !lib || !part )
473  return;
474 
475  wxString msg = part->GetName();
476 
477  AppendMsgPanel( _( "Name" ), msg, BLUE, 8 );
478 
479  if( m_aliasName == part->GetName() )
480  msg = _( "None" );
481  else
482  msg = m_aliasName;
483 
484  alias = part->GetAlias( m_aliasName );
485 
486  wxCHECK_RET( alias != NULL, "Alias not found in component." );
487 
488  AppendMsgPanel( _( "Alias" ), msg, RED, 8 );
489 
490  static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
491  msg = UnitLetter[m_unit];
492 
493  AppendMsgPanel( _( "Unit" ), msg, BROWN, 8 );
494 
495  if( m_convert > 1 )
496  msg = _( "Convert" );
497  else
498  msg = _( "Normal" );
499 
500  AppendMsgPanel( _( "Body" ), msg, GREEN, 8 );
501 
502  if( part->IsPower() )
503  msg = _( "Power Symbol" );
504  else
505  msg = _( "Part" );
506 
507  AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 );
508  AppendMsgPanel( _( "Description" ), alias->GetDescription(), CYAN, 8 );
509  AppendMsgPanel( _( "Key words" ), alias->GetKeyWords(), DARKDARKGRAY );
510  AppendMsgPanel( _( "Datasheet" ), alias->GetDocFileName(), DARKDARKGRAY );
511 }
512 
513 
514 void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
515 {
516  wxString cmp_name;
517  LIB_ALIAS* libEntry;
518  wxArrayString nameList;
519  wxString msg;
520 
522 
523  m_lastDrawItem = NULL;
524  m_drawItem = NULL;
525 
526  LIB_PART *part = GetCurPart();
527  PART_LIB* lib = GetCurLib();
528 
529  if( !lib )
530  {
532 
533  lib = GetCurLib();
534  if( !lib )
535  {
536  DisplayError( this, _( "Please select a component library." ) );
537  return;
538  }
539  }
540 
541  auto adapter( CMP_TREE_MODEL_ADAPTER::Create( Prj().SchLibs() ) );
542 
543  wxString name = part ? part->GetName() : wxString( wxEmptyString );
544  adapter->SetPreselectNode( name, /* aUnit */ 0 );
545  adapter->ShowUnits( false );
546  adapter->AddLibrary( *lib );
547 
548  wxString dialogTitle;
549  dialogTitle.Printf( _( "Delete Component (%u items loaded)" ), adapter->GetComponentsCount() );
550 
551  DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, m_convert, false );
552 
553  if( dlg.ShowQuasiModal() == wxID_CANCEL )
554  {
555  return;
556  }
557 
558  libEntry = dlg.GetSelectedAlias( NULL );
559 
560  if( !libEntry )
561  {
562  return;
563  }
564 
565  msg.Printf( _( "Delete component '%s' from library '%s' ?" ),
566  GetChars( libEntry->GetName() ),
567  GetChars( lib->GetName() ) );
568 
569  if( !IsOK( this, msg ) )
570  return;
571 
572  part = GetCurPart();
573 
574  if( !part || !part->HasAlias( libEntry->GetName() ) )
575  {
576  lib->RemoveAlias( libEntry );
577  m_canvas->Refresh();
578  return;
579  }
580 
581  // If deleting the current entry or removing one of the aliases for
582  // the current entry, sync the changes in the current entry as well.
583 
584  if( GetScreen()->IsModify() && !IsOK( this, _(
585  "The component being deleted has been modified."
586  " All changes will be lost. Discard changes?" ) ) )
587  {
588  return;
589  }
590 
591  LIB_ALIAS* nextEntry = lib->RemoveAlias( libEntry );
592 
593  if( nextEntry != NULL )
594  {
595  if( LoadOneLibraryPartAux( nextEntry, lib ) )
596  Zoom_Automatique( false );
597  }
598  else
599  {
600  SetCurPart( NULL ); // delete CurPart
601  m_aliasName.Empty();
602  }
603 
604  m_canvas->Refresh();
605 }
606 
607 
608 void LIB_EDIT_FRAME::CreateNewLibraryPart( wxCommandEvent& event )
609 {
610  wxString name;
611 
612  if( GetCurPart() && GetScreen()->IsModify() && !IsOK( this, _(
613  "All changes to the current component will be lost!\n\n"
614  "Clear the current component from the screen?" ) ) )
615  {
616  return;
617  }
618 
620 
621  m_drawItem = NULL;
622 
623  DIALOG_LIB_NEW_COMPONENT dlg( this );
624 
625  dlg.SetMinSize( dlg.GetSize() );
626 
627  if( dlg.ShowModal() == wxID_CANCEL )
628  return;
629 
630  if( dlg.GetName().IsEmpty() )
631  {
632  wxMessageBox( _( "This new component has no name and cannot be created. Aborted" ) );
633  return;
634  }
635 
636  name = dlg.GetName();
637  name.Replace( " ", "_" );
638 
639  PART_LIB* lib = GetCurLib();
640 
641  // Test if there a component with this name already.
642  if( lib && lib->FindAlias( name ) )
643  {
644  wxString msg = wxString::Format( _(
645  "Part '%s' already exists in library '%s'" ),
646  GetChars( name ),
647  GetChars( lib->GetName() )
648  );
649  DisplayError( this, msg );
650  return;
651  }
652 
653  LIB_PART* new_part = new LIB_PART( name );
654 
655  SetCurPart( new_part );
656  m_aliasName = new_part->GetName();
657 
658  new_part->GetReferenceField().SetText( dlg.GetReference() );
659  new_part->SetUnitCount( dlg.GetUnitCount() );
660 
661  // Initialize new_part->m_TextInside member:
662  // if 0, pin text is outside the body (on the pin)
663  // if > 0, pin text is inside the body
664  new_part->SetConversion( dlg.GetAlternateBodyStyle() );
666 
667  if( dlg.GetPinNameInside() )
668  {
669  new_part->SetPinNameOffset( dlg.GetPinTextPosition() );
670 
671  if( new_part->GetPinNameOffset() == 0 )
672  new_part->SetPinNameOffset( 1 );
673  }
674  else
675  {
676  new_part->SetPinNameOffset( 0 );
677  }
678 
679  ( dlg.GetPowerSymbol() ) ? new_part->SetPower() : new_part->SetNormal();
680  new_part->SetShowPinNumbers( dlg.GetShowPinNumber() );
681  new_part->SetShowPinNames( dlg.GetShowPinName() );
682  new_part->LockUnits( dlg.GetLockItems() );
683 
684  if( dlg.GetUnitCount() < 2 )
685  new_part->LockUnits( false );
686 
687  m_unit = 1;
688  m_convert = 1;
689 
690  DisplayLibInfos();
691  DisplayCmpDoc();
694 
695  m_editPinsPerPartOrConvert = new_part->UnitsLocked() ? true : false;
696  m_lastDrawItem = NULL;
697 
699  OnModify();
700 
701  m_canvas->Refresh();
702  m_mainToolBar->Refresh();
703 }
704 
705 
706 bool LIB_EDIT_FRAME::SaveOnePart( PART_LIB* aLib, bool aPromptUser )
707 {
708  wxString msg;
709  LIB_PART* part = GetCurPart();
710  LIB_PART* old_part = NULL;
711 
712  GetScreen()->ClrModify();
713 
714  if( !wxFileName::FileExists( aLib->GetFullFileName() ) )
715  {
716  aLib->Create();
717  }
718  else
719  {
720  old_part = aLib->FindPart( part->GetName() );
721 
722  if( old_part && aPromptUser )
723  {
724  msg.Printf( _( "Part '%s' already exists. Change it?" ),
725  GetChars( part->GetName() ) );
726 
727  if( !IsOK( this, msg ) )
728  return false;
729  }
730  }
731 
732  m_drawItem = m_lastDrawItem = NULL;
733 
734  if( old_part )
735  aLib->ReplacePart( old_part, part );
736  else
737  aLib->AddPart( part );
738 
739  msg.Printf( _( "Part '%s' saved in library '%s'" ),
740  GetChars( part->GetName() ),
741  GetChars( aLib->GetName() ) );
742 
743  SetStatusText( msg );
744 
745  return true;
746 }
Definition: colors.h:57
const wxString SchematicLibraryFileWildcard
bool UnitsLocked() const
LIB_FIELD * GetField(int aId)
Return pointer to the requested field.
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.
LIB_PART * ReplacePart(LIB_PART *aOldPart, LIB_PART *aNewPart)
Replace an existing part entry in the library.
void SetConversion(bool aSetConvert)
Set or clear the alternate body style (DeMorgan) for the part.
void SetPower()
Class PROJECT holds project specific data.
Definition: project.h:56
PART_LIB * GetCurLib()
The current library being edited, or NULL if none.
int GetPinNameOffset()
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
static int m_convert
Definition: libeditframe.h:99
This file is part of the common library TODO brief description.
bool IsPower() const
LIB_ALIAS * GetAlias(size_t aIndex)
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
void Save(bool aSaveDocFile=true)
This file is part of the common library.
bool SaveActiveLibrary(bool newFile)
Function SaveActiveLibrary saves the changes to the current library.
Definition: libedit.cpp:311
static LIB_ITEM * m_drawItem
Definition: libeditframe.h:91
wxString GetFullFileName()
Function GetFullFileName returns the full file library name with path and extension.
void OnSaveActiveLibrary(wxCommandEvent &event)
Function OnSaveActiveLibrary it the command event handler to save the changes to the current library...
Definition: libedit.cpp:300
Definition: colors.h:61
LIB_ALIAS * RemoveAlias(LIB_ALIAS *aEntry)
Safely remove aEntry from the library and return the next entry.
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
bool LoadOneLibraryPartAux(LIB_ALIAS *aLibEntry, PART_LIB *aLibrary)
Function LoadOneLibraryPartAux loads a copy of aLibEntry from aLibrary into memory.
Definition: libedit.cpp:201
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.
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
std::vector< COMPONENT_SELECTION > HISTORY_LIST
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: libeditframe.h:369
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:533
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:534
Class LIB_ID.
Definition: lib_id.h:56
PART_LIB * GetLib()
bool LoadComponentAndSelectLib(LIB_ALIAS *aLibEntry, PART_LIB *aLibrary)
Function LoadComponentAndSelectLib selects the current active library.
Definition: libedit.cpp:80
void UpdateAliasSelectList()
void SelectActiveLibrary(PART_LIB *aLibrary=NULL)
Function SelectActiveLibrary sets the current active library to aLibrary.
Definition: libedit.cpp:66
Field Reference of part, i.e. "IC21".
void SetShowDeMorgan(bool show)
Definition: libeditframe.h:405
This file contains miscellaneous commonly used macros and functions.
static PTR Create(PART_LIBS *aLibs)
Factory function: create a model adapter in a reference-counting container.
void DisplayLibInfos()
Function DisplayLibInfos updates the main window title bar with the current library name and read onl...
Definition: libedit.cpp:55
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 EnableBuffering(bool aEnable=true)
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 DeleteOnePart(wxCommandEvent &event)
Function DeleteOnePart is the command event handler to delete an entry from the current library...
Definition: libedit.cpp:514
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:679
void SetUnitCount(int count)
Set the units per part count.
void LoadOneLibraryPart(wxCommandEvent &event)
Function LoadOneLibraryPart loads a library component from the currently selected library...
Definition: libedit.cpp:115
bool IsMouseCaptured() const
Definitions for the Eeschema program SCH_SCREEN class.
const wxString & GetName() const
int ShowQuasiModal()
LIB_ALIAS * GetSelectedAlias(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
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.
const wxString GetName() const
Return the file name without path or extension.
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:90
PART_LIB * SelectLibraryFromList()
Function SelectLibraryFromList displays a list of current loaded libraries, and allows the user to se...
Definition: selpart.cpp:58
static PART_DRAW_OPTIONS Default()
bool SaveOnePart(PART_LIB *aLib, bool aPromptUser=true)
Function SaveOnePart saves the current LIB_PART into the provided PART_LIB.
Definition: libedit.cpp:706
void CreateNewLibraryPart(wxCommandEvent &event)
Function CreateNewLibraryPart is the command event handler to create a new library component...
Definition: libedit.cpp:608
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:140
void DisplayCmpDoc()
Function DisplayCmpDoc displays the documentation of the selected component.
Definition: libedit.cpp:464
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:162
const wxString SchematicLibraryFileExtension
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
void AddPart(LIB_PART *aPart)
Add aPart entry to library.
bool LoadComponentFromCurrentLib(LIB_ALIAS *aLibEntry, int aUnit=0, int aConvert=0)
Function LoadComponentFromCurrentLib loads a component from the current active library, optionally setting the selected unit and convert.
Definition: libedit.cpp:91
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:753
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:177
PART_LIB * SetCurLib(PART_LIB *aLib)
Sets the current library and return the old.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
Definition: colors.h:58
see class PGM_BASE
static wxString m_aliasName
Definition: libeditframe.h:92
static int m_unit
Definition: libeditframe.h:95
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)
Function SetCurPart takes ownership over aPart and notes that it is the one currently being edited...
void RedrawComponent(wxDC *aDC, wxPoint aOffset)
Function RedrawComponent Redraw the current component loaded in library editor Display reference like...
Definition: libedit.cpp:250
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()
Function GetCurPart returns the current part being edited, or NULL if none selected.
const char * name
Implementing DIALOG_LIB_NEW_COMPONENT.
void DrawBackGround(wxDC *DC)
Function DrawBackGround.
Definition: draw_panel.cpp:665
bool IsReadOnly() const
Function IsReadOnly.
COMPONENT_SELECTION SelectComponentFromLibrary(const SCHLIB_FILTER *aFilter, std::vector< COMPONENT_SELECTION > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, const wxString &aHighlight=wxEmptyString, bool aAllowFields=true)
Function SelectComponentFromLib Calls the library viewer to select component to import into schematic...
Definition: getpart.cpp:94
Definition for part library class.
static bool m_showDeMorgan
Definition: libeditframe.h:106
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
void SetFileName(const wxString &aFileName)
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
Function RedrawActiveWindow Redraw the current component loaded in library editor, an axes Display reference like in schematic (a reference U is shown U? or U?A) update status bar and info shown in the bottom of the window.
Definition: libedit.cpp:272
void Create(const wxString &aFileName=wxEmptyString)
int GetDefaultCursor() const
Function GetDefaultCursor.
Class PART_LIB is used to load, save, search, and otherwise manipulate part library files...
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:77
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
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:764
LIB_ALIAS * FindAlias(const wxString &aName)
Find LIB_ALIAS by aName.
Definition of class LIB_EDIT_FRAME.
int GetCount() const
Function GetCount returns the number of entries in the library.
bool GetShowElectricalType()
Definition: libeditframe.h:407
LIB_PART * FindPart(const wxString &aName)
Find part by aName.
void LockUnits(bool aLockUnits)
void SetNormal()
Definition: colors.h:62