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