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