KiCad PCB EDA Suite
dialog_edit_component_in_schematic.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) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
28 #include <wx/tooltip.h>
29 #include <wx/hyperlink.h>
30 #include <wx/url.h>
31 
32 #include <fctsys.h>
33 #include <pgm_base.h>
34 #include <kiway.h>
35 #include <gr_basic.h>
36 #include <class_drawpanel.h>
37 #include <confirm.h>
38 #include <class_sch_screen.h>
39 #include <schframe.h>
40 #include <base_units.h>
41 
42 #include <general.h>
43 #include <sch_base_frame.h>
44 #include <class_library.h>
45 #include <sch_component.h>
46 #include <dialog_helpers.h>
47 #include <sch_validators.h>
48 
50 #ifdef KICAD_SPICE
51 #include <dialog_spice_model.h>
53 #endif /* KICAD_SPICE */
54 
55 #include "common.h"
56 
57 
65 {
66 public:
68  DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* aParent );
69 
75  void InitBuffers( SCH_COMPONENT* aComponent );
76 
77 private:
78 
79  friend class SCH_EDIT_FRAME;
80 
85 
86  static int s_SelectedRow;
87 
90 
91  void setSelectedFieldNdx( int aFieldNdx );
92 
93  int getSelectedFieldNdx();
94 
101 
102 
111 
112  void copyOptionsToPanel();
113 
114  void copyPanelToOptions();
115 
116  void setRowItem( int aFieldNdx, const wxString& aName, const wxString& aValue );
117 
118  void setRowItem( int aFieldNdx, const SCH_FIELD& aField )
119  {
120  setRowItem( aFieldNdx, aField.GetName( false ), aField.GetText() );
121  }
122 
123  // event handlers
124  void OnCloseDialog( wxCloseEvent& event ) override;
125  void OnListItemDeselected( wxListEvent& event ) override;
126  void OnListItemSelected( wxListEvent& event ) override;
127  void OnCancelButtonClick( wxCommandEvent& event ) override;
128  void OnOKButtonClick( wxCommandEvent& event ) override;
129  void SetInitCmp( wxCommandEvent& event ) override;
130  void addFieldButtonHandler( wxCommandEvent& event ) override;
131  void deleteFieldButtonHandler( wxCommandEvent& event ) override;
132  void moveUpButtonHandler( wxCommandEvent& event ) override;
133  void showButtonHandler( wxCommandEvent& event ) override;
134  void OnTestChipName( wxCommandEvent& event ) override;
135  void OnSelectChipName( wxCommandEvent& event ) override;
136  void OnInitDlg( wxInitDialogEvent& event ) override
137  {
138  TransferDataToWindow();
139 
140  // Now all widgets have the size fixed, call FinishDialogSettings
142  }
143 
144  void EditSpiceModel( wxCommandEvent& event ) override;
145 
146  SCH_FIELD* findField( const wxString& aFieldName );
147 
154  {
155  for( unsigned ii = FIELD1; ii<m_FieldsBuf.size(); ii++ )
156  setRowItem( ii, m_FieldsBuf[ii] );
157  }
158 };
159 
160 
162 
163 
165 {
166  wxCHECK_RET( aComponent != NULL && aComponent->Type() == SCH_COMPONENT_T,
167  wxT( "Invalid component object pointer. Bad Programmer!" ) );
168 
170 
172 
173  dlg->InitBuffers( aComponent );
174 
175  // make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
177 
178  // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
179  // frame. Therefore this dialog as a modal frame parent, MUST be run under
180  // quasimodal mode for the quasimodal frame support to work. So don't use
181  // the QUASIMODAL macros here.
182  int ret = dlg->ShowQuasiModal();
183 
184  if( m_autoplaceFields )
185  aComponent->AutoAutoplaceFields( GetScreen() );
186 
187  m_canvas->SetIgnoreMouseEvents( false );
189  dlg->Destroy();
190 
191  if( ret == wxID_OK )
192  GetCanvas()->Refresh();
193 }
194 
195 
198 {
199 #ifndef KICAD_SPICE
200  spiceFieldsButton->Hide();
201 #endif /* not KICAD_SPICE */
202 
203  m_parent = (SCH_EDIT_FRAME*) aParent;
204 
205  m_cmp = NULL;
206  m_part = NULL;
207  m_skipCopyFromPanel = false;
208 
209  wxListItem columnLabel;
210 
211  columnLabel.SetImage( -1 );
212 
213  columnLabel.SetText( _( "Name" ) );
214  fieldListCtrl->InsertColumn( 0, columnLabel );
215 
216  columnLabel.SetText( _( "Value" ) );
217  fieldListCtrl->InsertColumn( 1, columnLabel );
218 
222 
223  wxToolTip::Enable( true );
224  stdDialogButtonSizerOK->SetDefault();
225 
226  Fit();
227 }
228 
229 
231 {
232  if( !m_skipCopyFromPanel )
233  {
234  if( !copyPanelToSelectedField() )
235  event.Skip(); // do not go to the next row
236  }
237 }
238 
240 {
241  wxString partname = chipnameTextCtrl->GetValue();
242  LIB_PART* entry = Prj().SchLibs()->FindLibPart( partname );
243 
244  wxString msg;
245 
246  if( entry )
247  {
248  msg.Printf( _( "Component '%s' found in library '%s'" ),
249  GetChars( partname ), GetChars( entry->GetLibraryName() ) );
250  wxMessageBox( msg );
251  return;
252  }
253 
254  msg.Printf( _( "Component '%s' not found in any library" ), GetChars( partname ) );
255 
256  // Try to find components which have a name "near" the current chip name,
257  // i.e. the same name when the comparison is case insensitive.
258  // Could be helpful for old designs when lower cases and upper case were
259  // equivalent.
260  std::vector<LIB_ALIAS*> candidates;
261  Prj().SchLibs()->FindLibraryNearEntries( candidates, partname );
262 
263  if( candidates.size() == 0 )
264  {
265  wxMessageBox( msg );
266  return;
267  }
268 
269  // Some candidates are found. Show them:
270  msg << wxT("\n") << _( "However, some candidates are found:" );
271 
272  // add candidate names:
273  for( unsigned ii = 0; ii < candidates.size(); ii++ )
274  {
275  msg << wxT("\n") <<
276  wxString::Format( _( "'%s' found in library '%s'" ),
277  GetChars( candidates[ii]->GetName() ),
278  GetChars( candidates[ii]->GetLibraryName() ) );
279  }
280 
281  wxMessageBox( msg );
282 }
283 
284 
286 {
288 
289  auto sel = m_parent->SelectComponentFromLibrary( NULL, dummy, true, 0, 0 );
290 
291  if( sel.Name.IsEmpty() )
292  return;
293 
294  chipnameTextCtrl->SetValue( sel.Name );
295 }
296 
297 
299 {
300 #ifdef KICAD_SPICE
301  setSelectedFieldNdx( 0 );
302  DIALOG_SPICE_MODEL dialog( this, *m_cmp, m_FieldsBuf );
303 
304  if( dialog.ShowModal() == wxID_OK )
305  updateDisplay();
306 #endif /* KICAD_SPICE */
307 }
308 
309 
311 {
312  DBG( printf( "OnListItemSelected()\n" ); )
313 
314  // remember the selected row, statically
315  s_SelectedRow = event.GetIndex();
316 
318 }
319 
320 
322 {
323  // On wxWidgets 2.8, and on Linux, calling EndQuasiModal here is mandatory
324  // Otherwise, the main event loop is never restored, and Eeschema does not
325  // respond to any event, because the DIALOG_SHIM destructor is never called.
326  // On wxWidgets 3.0, or on Windows, the DIALOG_SHIM destructor is called,
327  // and calls EndQuasiModal.
328  // therefore calling EndQuasiModal here is not always mandatory but it creates no issues
329  EndQuasiModal( wxID_CANCEL );
330 }
331 
332 
334 {
335  EndQuasiModal( wxID_CANCEL );
336 }
337 
338 
340 {
341  LIB_ID id;
342  wxString tmp = chipnameTextCtrl->GetValue();
343 
344  tmp.Replace( wxT( " " ), wxT( "_" ) );
345 
346  id.SetLibItemName( TO_UTF8( tmp ), false );
347 
348  // Save current flags which could be modified by next change settings
349  STATUS_FLAGS flags = m_cmp->GetFlags();
350 
351  if( id.empty() )
352  {
353  DisplayError( NULL, _( "No Component Name!" ) );
354  }
355  else if( id != m_cmp->GetLibId() )
356  {
357  PART_LIBS* libs = Prj().SchLibs();
358 
359  if( libs->FindLibraryAlias( id ) == NULL )
360  {
361  wxString msg = wxString::Format( _( "Component '%s' not found!" ),
362  GetChars( FROM_UTF8( id.Format() ) ) );
363  DisplayError( this, msg );
364  }
365  else // Change component from lib!
366  {
367  m_cmp->SetLibId( id, libs );
368  }
369  }
370 
371  // For components with multiple shapes (De Morgan representation) Set the selected shape:
372  if( convertCheckBox->IsEnabled() )
373  {
374  m_cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
375  }
376 
377  //Set the part selection in multiple part per package
378  if( m_cmp->GetUnit() )
379  {
380  int unit_selection = unitChoice->GetCurrentSelection() + 1;
381 
382  m_cmp->SetUnitSelection( &m_parent->GetCurrentSheet(), unit_selection );
383  m_cmp->SetUnit( unit_selection );
384  }
385 
386  switch( orientationRadioBox->GetSelection() )
387  {
388  case 0:
390  break;
391 
392  case 1:
394  break;
395 
396  case 2:
398  break;
399 
400  case 3:
402  break;
403  }
404 
405  int mirror = mirrorRadioBox->GetSelection();
406 
407  switch( mirror )
408  {
409  case 0:
410  break;
411 
412  case 1:
414  break;
415 
416  case 2:
418  break;
419  }
420 
421  // Restore m_Flag modified by SetUnit() and other change settings
422  m_cmp->ClearFlags();
423  m_cmp->SetFlags( flags );
424 }
425 
426 
428 {
429  bool removeRemainingFields = false;
430 
431  if( !copyPanelToSelectedField() )
432  return;
433 
435  {
436  DisplayError( NULL, _( "Illegal reference. A reference must start with a letter" ) );
437  return;
438  }
439 
440  // save old cmp in undo list if not already in edit, or moving ...
441  // or the component to be edited is part of a block
442  if( m_cmp->GetFlags() == 0
445 
447 
448  // Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
449  for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); )
450  {
451  if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() )
452  {
453  // If a field has no value and is not it the field template list, warn the user
454  // that it will be remove from the component. This gives the user a chance to
455  // correct the problem before removing the undefined fields. It should also
456  // resolve most of the bug reports and questions regarding missing fields.
457  if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty()
458  && !m_parent->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) )
459  && !removeRemainingFields )
460  {
461  wxString msg = wxString::Format(
462  _( "The field name <%s> does not have a value and is not defined in "
463  "the field template list. Empty field values are invalid an will "
464  "be removed from the component. Do you wish to remove this and "
465  "all remaining undefined fields?" ),
466  GetChars( m_FieldsBuf[i].GetName( false ) )
467  );
468 
469  wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT );
470 
471  if( dlg.ShowModal() == wxID_NO )
472  return;
473 
474  removeRemainingFields = true;
475  }
476 
477  m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
478  continue;
479  }
480 
481  ++i;
482  }
483 
484  // change all field positions from relative to absolute
485  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
486  {
487  m_FieldsBuf[i].Offset( m_cmp->m_Pos );
488  }
489 
490  LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() );
491 
492  if( entry && entry->IsPower() )
493  m_FieldsBuf[VALUE].SetText( m_cmp->GetLibId().GetLibItemName() );
494 
495  // copy all the fields back, and change the length of m_Fields.
497 
498  // Reference has a specific initialization, depending on the current active sheet
499  // because for a given component, in a complex hierarchy, there are more than one
500  // reference.
502 
503  m_parent->OnModify();
505 
506  EndQuasiModal( wxID_OK );
507 }
508 
509 
511 {
512  // in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
513  // screen contents.
514  if( !copyPanelToSelectedField() )
515  return;
516 
517  unsigned fieldNdx = m_FieldsBuf.size();
518 
519  SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp );
520 
521  blank.SetTextAngle( m_FieldsBuf[REFERENCE].GetTextAngle() );
522 
523  m_FieldsBuf.push_back( blank );
524  m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
525 
526  m_skipCopyFromPanel = true;
527  setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
528 
529  setSelectedFieldNdx( fieldNdx );
530  m_skipCopyFromPanel = false;
531 }
532 
533 
535 {
536  unsigned fieldNdx = getSelectedFieldNdx();
537 
538  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
539  return;
540 
541  if( fieldNdx < MANDATORY_FIELDS )
542  {
543  wxBell();
544  return;
545  }
546 
547  m_skipCopyFromPanel = true;
548  m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
549  fieldListCtrl->DeleteItem( fieldNdx );
550 
551  if( fieldNdx >= m_FieldsBuf.size() )
552  --fieldNdx;
553 
554  updateDisplay();
555 
556  setSelectedFieldNdx( fieldNdx );
557  m_skipCopyFromPanel = false;
558 }
559 
560 static wxString resolveUriByEnvVars( const wxString& aUri )
561 {
562  // URL-like URI: return as is.
563  wxURL url( aUri );
564  if( url.GetError() == wxURL_NOERR )
565  {
566  return aUri;
567  }
568  // Otherwise, the path points to a local file. Resolve environment
569  // variables if any.
570  return ExpandEnvVarSubstitutions( aUri );
571 }
572 
574 {
575  unsigned fieldNdx = getSelectedFieldNdx();
576 
577  if( fieldNdx == DATASHEET )
578  {
579  wxString datasheet_uri = fieldValueTextCtrl->GetValue();
580  datasheet_uri = resolveUriByEnvVars( datasheet_uri );
581  ::wxLaunchDefaultBrowser( datasheet_uri );
582  }
583  else if( fieldNdx == FOOTPRINT )
584  {
585  // pick a footprint using the footprint picker.
586  wxString fpid;
587 
589 
590  if( frame->ShowModal( &fpid, this ) )
591  {
592  // DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
593  fieldValueTextCtrl->SetValue( fpid );
594 
595  setRowItem( fieldNdx, m_FieldsBuf[fieldNdx].GetName( false ), fpid );
596  }
597 
598  frame->Destroy();
599  }
600 }
601 
602 
604 {
605  unsigned fieldNdx = getSelectedFieldNdx();
606 
607  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
608  return;
609 
610  if( fieldNdx <= MANDATORY_FIELDS )
611  {
612  wxBell();
613  return;
614  }
615 
616  if( !copyPanelToSelectedField() )
617  return;
618 
619  // swap the fieldNdx field with the one before it, in both the vector
620  // and in the fieldListCtrl
621  SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
622 
623  DBG( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
624  TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); )
625 
626  m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
627  setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
628 
629  m_FieldsBuf[fieldNdx] = tmp;
630  setRowItem( fieldNdx, tmp );
631 
632  updateDisplay();
633 
634  m_skipCopyFromPanel = true;
635  setSelectedFieldNdx( fieldNdx - 1 );
636  m_skipCopyFromPanel = false;
637 }
638 
639 
641 {
642  /* deselect old selection, but I think this is done by single selection
643  * flag within fieldListCtrl.
644  * fieldListCtrl->SetItemState( s_SelectedRow, 0,
645  * wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
646  */
647 
648  if( aFieldNdx >= (int) m_FieldsBuf.size() )
649  aFieldNdx = m_FieldsBuf.size() - 1;
650 
651  if( aFieldNdx < 0 )
652  aFieldNdx = 0;
653 
654  fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
655  fieldListCtrl->EnsureVisible( aFieldNdx );
656 
657  s_SelectedRow = aFieldNdx;
658 }
659 
660 
662 {
663  return s_SelectedRow;
664 }
665 
666 
668 {
669  for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
670  {
671  if( aFieldName == m_FieldsBuf[i].GetName( false ) )
672  return &m_FieldsBuf[i];
673  }
674 
675  return NULL;
676 }
677 
678 
680 {
681  m_cmp = aComponent;
682 
683  /* We have 3 component related field lists to be aware of: 1) UI
684  presentation, 2) fields in component ram copy, and 3) fields recorded
685  with component on disk. m_FieldsBuf is the list of UI fields, and this
686  list is not the same as the list which is in the component, which is
687  also not the same as the list on disk. All 3 lists are potentially
688  different. In the UI we choose to preserve the order of the first
689  MANDATORY_FIELDS which are sometimes called fixed fields. Then we append
690  the template fieldnames in the exact same order as the template
691  fieldname editor shows them. Then we append any user defined fieldnames
692  which came from the component.
693  */
694 
695  m_part = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() );
696 
697 #if 0 && defined(DEBUG)
698  for( int i = 0; i<aComponent->GetFieldCount(); ++i )
699  {
700  printf( "Orig[%d] (x=%d, y=%d)\n", i,
701  aComponent->m_Fields[i].GetTextPos().x,
702  aComponent->m_Fields[i].GetTextPos().y );
703  }
704 
705 #endif
706 
707  // When this code was written, all field constructors ensure that the fixed fields
708  // are all present within a component. So we can knowingly copy them over
709  // in the normal order. Copy only the fixed fields at first.
710  // Please do not break the field constructors.
711 
712  m_FieldsBuf.clear();
713 
714  for( int i=0; i<MANDATORY_FIELDS; ++i )
715  {
716  m_FieldsBuf.push_back( aComponent->m_Fields[i] );
717 
718  // make the editable field position relative to the component
719  m_FieldsBuf[i].Offset( -m_cmp->m_Pos );
720  }
721 
722  // Add template fieldnames:
723  // Now copy in the template fields, in the order that they are present in the
724  // template field editor UI.
726 
727  for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
728  {
729  // add a new field unconditionally to the UI only
730  SCH_FIELD fld( wxPoint(0,0), -1 /* id is a relic */, m_cmp, it->m_Name );
731 
732  // See if field by same name already exists in component.
733  SCH_FIELD* schField = aComponent->FindField( it->m_Name );
734 
735  // If the field does not already exist in the component, then we
736  // use defaults from the template fieldname, otherwise the original
737  // values from the component will be set.
738  if( !schField )
739  {
740  if( !it->m_Visible )
741  fld.SetVisible( false );
742  else
743  fld.SetVisible( true );
744 
745  fld.SetText( it->m_Value ); // empty? ok too.
746  }
747  else
748  {
749  fld = *schField;
750 
751  // make the editable field position relative to the component
752  fld.Offset( -m_cmp->m_Pos );
753  }
754 
755  m_FieldsBuf.push_back( fld );
756  }
757 
758  // Lastly, append any original fields from the component which were not added
759  // from the set of fixed fields nor from the set of template fields.
760  for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i )
761  {
762  SCH_FIELD* cmp = &aComponent->m_Fields[i];
763  SCH_FIELD* buf = findField( cmp->GetName( false ) );
764 
765  if( !buf )
766  {
767  int newNdx = m_FieldsBuf.size();
768  m_FieldsBuf.push_back( *cmp );
769 
770  // make the editable field position relative to the component
771  m_FieldsBuf[newNdx].Offset( -m_cmp->m_Pos );
772  }
773  }
774 
775 
776 #if 0 && defined(DEBUG)
777  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
778  {
779  printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
780  m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) );
781  }
782 #endif
783 
785 
786  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
787  {
788  setRowItem( i, m_FieldsBuf[i] );
789  }
790 
791 #if 0 && defined(DEBUG)
792  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
793  {
794  printf( "after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
795  m_FieldsBuf[i].m_Pos.y );
796  }
797 
798 #endif
799 
801 
802  // disable some options inside the edit dialog
803  // which can cause problems while dragging
804  if( m_cmp->IsDragging() )
805  {
806  orientationRadioBox->Disable();
807  mirrorRadioBox->Disable();
808  chipnameTextCtrl->Disable();
809  }
810 
811  // put focus on the list ctrl
812  fieldListCtrl->SetFocus();
813 
814  // resume editing at the last row edited, last time dialog was up.
816 
818 }
819 
820 
821 void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const wxString& aName, const wxString& aValue )
822 {
823  wxASSERT( aFieldNdx >= 0 );
824 
825  // insert blanks if aFieldNdx is referencing a "yet to be defined" row
826  while( aFieldNdx >= fieldListCtrl->GetItemCount() )
827  {
828  long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
829 
830  wxASSERT( ndx >= 0 );
831 
832  fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
833  }
834 
835  fieldListCtrl->SetItem( aFieldNdx, 0, aName );
836  fieldListCtrl->SetItem( aFieldNdx, 1, aValue );
837 
838  // recompute the column widths here, after setting texts
839  fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
840  fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
841 }
842 
843 
845 {
846  wxCHECK_RET( m_cmp != NULL, wxT( "Component pointer not initialized." ) );
847 
848  unsigned fieldNdx = getSelectedFieldNdx();
849 
850  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
851  return;
852 
853  SCH_FIELD& field = m_FieldsBuf[fieldNdx];
854 
855  showCheckBox->SetValue( field.IsVisible() );
856 
857  rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
858 
859  int style = 0;
860 
861  if( field.IsItalic() )
862  style = 1;
863 
864  if( field.IsBold() )
865  style |= 2;
866 
867  m_StyleRadioBox->SetSelection( style );
868 
869  // Select the right text justification
870  if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
871  m_FieldHJustifyCtrl->SetSelection( 0 );
872  else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
873  m_FieldHJustifyCtrl->SetSelection( 2 );
874  else
875  m_FieldHJustifyCtrl->SetSelection( 1 );
876 
877  if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
878  m_FieldVJustifyCtrl->SetSelection( 0 );
879  else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
880  m_FieldVJustifyCtrl->SetSelection( 2 );
881  else
882  m_FieldVJustifyCtrl->SetSelection( 1 );
883 
884 
885  fieldNameTextCtrl->SetValue( field.GetName( false ) );
886 
887  // the names of the fixed fields are not editable, others are.
888  fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS );
889  fieldNameTextCtrl->SetEditable( fieldNdx >= MANDATORY_FIELDS );
890 
891  // only user defined fields may be moved, and not the top most user defined
892  // field since it would be moving up into the fixed fields, > not >=
893  moveUpButton->Enable( fieldNdx > MANDATORY_FIELDS );
894 
895  // may only delete user defined fields
896  deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
897 
898  fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( false, field.GetId() ) );
899  fieldValueTextCtrl->SetValue( field.GetText() );
900 
901  m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
902 
903  if( fieldNdx == DATASHEET )
904  {
905  m_show_datasheet_button->SetLabel( _( "Show Datasheet" ) );
906  m_show_datasheet_button->SetToolTip(
907  _("If your datasheet is given as an http:// link,"
908  " then pressing this button should bring it up in your webbrowser.") );
909  }
910  else if( fieldNdx == FOOTPRINT )
911  {
912  m_show_datasheet_button->SetLabel( _( "Browse Footprints" ) );
913  m_show_datasheet_button->SetToolTip(
914  _("Open the footprint browser to choose a footprint and assign it.") );
915  }
916  else
917  {
918  m_show_datasheet_button->SetLabel( wxEmptyString );
919  m_show_datasheet_button->SetToolTip(
920  _("Used only for fields Footprint and Datasheet.") );
921  }
922 
923  // For power symbols, the value is NOR editable, because value and pin
924  // name must be same and can be edited only in library editor
925  if( fieldNdx == VALUE && m_part && m_part->IsPower() )
926  fieldValueTextCtrl->Enable( false );
927  else
928  fieldValueTextCtrl->Enable( true );
929 
931 
932  wxPoint coord = field.GetTextPos();
933  wxPoint zero = -m_cmp->m_Pos; // relative zero
934 
935  // If the field value is empty and the position is at relative zero, we
936  // set the initial position as a small offset from the ref field, and
937  // orient it the same as the ref field. That is likely to put it at least
938  // close to the desired position.
939  if( coord == zero && field.GetText().IsEmpty() )
940  {
941  rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT );
942 
943  coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x
944  + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
945 
946  coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y
947  + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
948 
949  // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
950  // That is ok, we basically don't want all the new empty fields on
951  // top of each other.
952  }
953 
954  wxString coordText = StringFromValue( g_UserUnit, coord.x );
955  posXTextCtrl->SetValue( coordText );
956 
957  coordText = StringFromValue( g_UserUnit, coord.y );
958  posYTextCtrl->SetValue( coordText );
959 }
960 
961 
963 {
964  unsigned fieldNdx = getSelectedFieldNdx();
965 
966  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
967  return true;
968 
969  // Check for illegal field text.
970  if( fieldValueTextCtrl->GetValidator()
971  && !fieldValueTextCtrl->GetValidator()->Validate( this ) )
972  return false;
973 
974  SCH_FIELD& field = m_FieldsBuf[fieldNdx];
975 
976  field.SetVisible( showCheckBox->GetValue() );
977 
978  if( rotateCheckBox->GetValue() )
979  field.SetTextAngle( TEXT_ANGLE_VERT );
980  else
982 
983  rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
984 
985  // Copy the text justification
986  static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
990  };
991 
992  static const EDA_TEXT_VJUSTIFY_T vjustify[] = {
996  };
997 
998  field.SetHorizJustify( hjustify[m_FieldHJustifyCtrl->GetSelection()] );
999  field.SetVertJustify( vjustify[m_FieldVJustifyCtrl->GetSelection()] );
1000 
1001  field.SetName( fieldNameTextCtrl->GetValue() );
1002 
1003  /* Void fields texts for REFERENCE and VALUE (value is the name of the
1004  * component in lib ! ) are not allowed
1005  * change them only for a new non void value
1006  * When void, usually netlists are broken
1007  */
1008  if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
1009  field.SetText( fieldValueTextCtrl->GetValue() );
1010 
1011  setRowItem( fieldNdx, field ); // update fieldListCtrl
1012 
1014  field.SetTextSize( wxSize( tmp, tmp ) );
1015  int style = m_StyleRadioBox->GetSelection();
1016 
1017  field.SetItalic( (style & 1 ) != 0 );
1018  field.SetBold( (style & 2 ) != 0 );
1019 
1020  wxPoint pos;
1021  pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
1022  pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
1023  field.SetTextPos( pos );
1024 
1025  return true;
1026 }
1027 
1028 
1030 {
1031  // Remove non existing choices (choiceCount must be <= number for parts)
1032  int unitcount = m_part ? m_part->GetUnitCount() : 1;
1033 
1034  if( unitcount < 1 )
1035  unitcount = 1;
1036 
1037  unitChoice->Clear();
1038 
1039  for( int ii = 1; ii <= unitcount; ii++ )
1040  {
1041  unitChoice->Append( LIB_PART::SubReference( ii, false ) );
1042  }
1043 
1044  // For components with multiple parts per package, set the unit selection
1045  if( m_cmp->GetUnit() <= (int)unitChoice->GetCount() )
1046  unitChoice->SetSelection( m_cmp->GetUnit() - 1 );
1047 
1048  // Disable unit selection if only one unit exists:
1049  if( m_cmp->GetUnitCount() <= 1 )
1050  {
1051  unitChoice->Enable( false );
1052  unitsInterchageableLabel->Show( false );
1053  unitsInterchageableText->Show( false );
1054  }
1055  else
1056  {
1057  // Show the "Units are not interchangeable" message option?
1058  if( !m_part || !m_part->UnitsLocked() )
1059  unitsInterchageableLabel->SetLabel( _( "Yes" ) );
1060  else
1061  unitsInterchageableLabel->SetLabel( _( "No" ) );
1062  }
1063 
1064  int orientation = m_cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y );
1065 
1066  if( orientation == CMP_ORIENT_90 )
1067  orientationRadioBox->SetSelection( 1 );
1068  else if( orientation == CMP_ORIENT_180 )
1069  orientationRadioBox->SetSelection( 2 );
1070  else if( orientation == CMP_ORIENT_270 )
1071  orientationRadioBox->SetSelection( 3 );
1072  else
1073  orientationRadioBox->SetSelection( 0 );
1074 
1075  int mirror = m_cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
1076 
1077  if( mirror == CMP_MIRROR_X )
1078  {
1079  mirrorRadioBox->SetSelection( 1 );
1080  DBG( printf( "mirror=X,1\n" ); )
1081  }
1082  else if( mirror == CMP_MIRROR_Y )
1083  {
1084  mirrorRadioBox->SetSelection( 2 );
1085  DBG( printf( "mirror=Y,2\n" ); )
1086  }
1087  else
1088  mirrorRadioBox->SetSelection( 0 );
1089 
1090  // Activate/Desactivate the normal/convert option ? (activated only if
1091  // the component has more than one shape)
1092  if( m_cmp->GetConvert() > 1 )
1093  convertCheckBox->SetValue( true );
1094 
1095  if( m_part == NULL || !m_part->HasConversion() )
1096  convertCheckBox->Enable( false );
1097 
1098  // Set the component's library name.
1099  chipnameTextCtrl->SetValue( FROM_UTF8( m_cmp->GetLibId().Format() ) );
1100 
1101  // Set the component's unique ID time stamp.
1102  m_textCtrlTimeStamp->SetValue( wxString::Format( wxT( "%8.8lX" ),
1103  (unsigned long) m_cmp->GetTimeStamp() ) );
1104 }
1105 
1106 
1107 #include <kicad_device_context.h>
1108 
1109 
1111 {
1112  if( !m_cmp )
1113  return;
1114 
1115  if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() ) )
1116  {
1117  // save old cmp in undo list if not already in edit, or moving ...
1118  if( m_cmp->GetFlags() == 0 )
1120 
1122  m_cmp->Draw( m_parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
1123 
1124  // Initialize fixed field values to default values found in library
1125  // Note: the field texts are not modified because they are set in schematic,
1126  // the text from libraries is most of time a dummy text
1127  // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
1128  LIB_FIELD& refField = part->GetReferenceField();
1129 
1130  m_cmp->GetField( REFERENCE )->ImportValues( refField );
1131  m_cmp->GetField( REFERENCE )->SetTextPos( refField.GetTextPos() + m_cmp->m_Pos );
1132 
1133  LIB_FIELD& valField = part->GetValueField();
1134 
1135  m_cmp->GetField( VALUE )->ImportValues( valField );
1136  m_cmp->GetField( VALUE )->SetTextPos( valField.GetTextPos() + m_cmp->m_Pos );
1137 
1138  LIB_FIELD* field = part->GetField(FOOTPRINT);
1139 
1140  if( field && m_cmp->GetField( FOOTPRINT ) )
1141  {
1142  m_cmp->GetField( FOOTPRINT )->ImportValues( *field );
1143  m_cmp->GetField( FOOTPRINT )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
1144  }
1145 
1146  field = part->GetField(DATASHEET);
1147 
1148  if( field && m_cmp->GetField( DATASHEET ) )
1149  {
1150  m_cmp->GetField( DATASHEET )->ImportValues( *field );
1151  m_cmp->GetField( DATASHEET )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
1152  }
1153 
1155 
1156  m_parent->OnModify();
1157 
1158  m_cmp->Draw( m_parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
1159 
1160  EndQuasiModal( wxID_OK );
1161  }
1162 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:156
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:91
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:229
bool UnitsLocked() const
void EditComponent(SCH_COMPONENT *aComponent)
Function EditComponent displays the edit component dialog to edit the parameters of aComponent...
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Function AutoAutoplaceFields Autoplace fields only if correct to do so automatically.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:255
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
bool copyPanelToSelectedField()
Function copyPanelToSelectedField copies the values displayed on the panel fields to the currently se...
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Function FindField searches for SCH_FIELD with aFieldName and returns it if found, else NULL.
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:473
const TEMPLATES & GetTemplates()
Function GetTemplates returns the field names template for read only access.
Definition: schframe.h:336
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
name of datasheet
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
int GetOrientation()
Function GetOrientation Used to display component orientation (in dialog editor or info) ...
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
SCH_FIELD * findField(const wxString &aFieldName)
bool IsItalic() const
Definition: eda_text.h:170
bool IsPower() const
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))
Function SaveCopyInUndoList.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
void OnOKButtonClick(wxCommandEvent &event) override
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:762
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
int GetId() const
Definition: sch_field.h:87
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:221
void addFieldButtonHandler(wxCommandEvent &event) override
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:203
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void SetItalic(bool isItalic)
Definition: eda_text.h:169
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
void OnInitDlg(wxInitDialogEvent &event) override
Class LIB_FIELD is used in symbol libraries.
Definition: lib_field.h:60
int GetTextWidth() const
Definition: eda_text.h:218
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void SetVisible(bool aVisible)
Definition: eda_text.h:175
void OnCancelButtonClick(wxCommandEvent &event) override
static int ParseSize(const wxString &sizeText, EDA_UNITS_T user_unit)
Definition: wxwineda.cpp:123
std::vector< COMPONENT_SELECTION > HISTORY_LIST
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
void SetRef(const SCH_SHEET_PATH *sheet, const wxString &ref)
Set the reference, for the given sheet path.
Schematic editor (Eeschema) main window.
Definition: schframe.h:117
void SetUnitSelection(SCH_SHEET_PATH *aSheet, int aUnitSelection)
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
int GetUnitCount() const
Function GetUnitCount returns the number of parts per package of the component.
void deleteFieldButtonHandler(wxCommandEvent &event) override
Class LIB_ID.
Definition: lib_id.h:56
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:348
LIB_ALIAS * FindLibraryAlias(const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
Function FindLibraryEntry searches all libraries in the list for an entry.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
#define TEXT_ANGLE_VERT
Definition: common.h:92
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
bool IsBold() const
Definition: eda_text.h:173
double GetTextAngle() const
Definition: eda_text.h:164
void SetConvert(int aConvert)
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:521
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
void setRowItem(int aFieldNdx, const wxString &aName, const wxString &aValue)
int GetConvert() const
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void SetLibId(const LIB_ID &aName, PART_LIBS *aLibs=NULL)
void OnTestChipName(wxCommandEvent &event) override
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
a helper to handle the real device context used in KiCad
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString)
Function EnsureTextCtrlWidth sets the minimum pixel width on a text control in order to make a text s...
Definition: common.cpp:108
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
void SetFields(const SCH_FIELDS &aFields)
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
const wxString ExpandEnvVarSubstitutions(const wxString &aString)
Function ExpandEnvVarSubstitutions replaces any environment variable references with their values...
Definition: common.cpp:254
Definitions for the Eeschema program SCH_SCREEN class.
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
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_component.h:53
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit)
Definition: base_units.cpp:479
Defintions of control validators for schematic dialogs.
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:566
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:368
Class LIB_PART defines a library part object.
void OnListItemDeselected(wxListEvent &event) override
Helper dialog and control classes.
unsigned STATUS_FLAGS
Definition: base_struct.h:144
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
void SetUnit(int aUnit)
change the unit id to aUnit has maening only for multiple parts per package Also set the modified fla...
int GetUnit() const
void OnListItemSelected(wxListEvent &event) override
bool m_autoplaceFields
automatically place component fields
Definition: schframe.h:154
const wxString GetLibraryName()
time_t GetTimeStamp() const
Definition: base_struct.h:204
static wxString resolveUriByEnvVars(const wxString &aUri)
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
int GetUnitCount() const
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
void OnSelectChipName(wxCommandEvent &event) override
Class PART_LIBS is a collection of PART_LIBs.
Field Value of part, i.e. "3.3K".
void moveUpButtonHandler(wxCommandEvent &event) override
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
void EndQuasiModal(int retCode)
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
const wxString GetRef(const SCH_SHEET_PATH *sheet)
Function GetRef returns the reference, for the given sheet path.
Definition the SCH_COMPONENT class for Eeschema.
Class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.
bool HasFieldName(const wxString &aName) const
Function HasFieldName checks for aName in the the template field name list.
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
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Function GetTemplateFieldName returns a template field names list for read only access.
Definition: schframe.h:326
see class PGM_BASE
void updateDisplay()
Function updateDisplay update the listbox showing fields, according to the fields texts must be calle...
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
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
BLOCK_STATE_T GetState() const
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
#define INSTALL_UNBUFFERED_DC(name, parent)
bool IsVisible() const
Definition: eda_text.h:176
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC(wxWindow *aParent)
Constructor.
bool TestDanglingEnds()
Function TestDanglingEnds tests all of the connectible objects in the schematic for unused connection...
Definition: sch_screen.cpp:911
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Virtual function, from the base class SCH_ITEM::Draw.
class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMA...
void SetIgnoreMouseEvents(bool aIgnore)
void SetName(const wxString &aName)
Definition: sch_field.h:85
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Function SubReference.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
static bool empty(const wxTextEntryBase *aCtrl)
void EditSpiceModel(wxCommandEvent &event) override
const LIB_ID & GetLibId() const
The common library.
void copySelectedFieldToPanel()
Function copySelectedFieldToPanel sets the values displayed on the panel according to the currently s...
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
#define DBG(x)
Definition: fctsys.h:33
void InitBuffers(SCH_COMPONENT *aComponent)
Function InitBuffers sets up to edit the given component.
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
class SCH_FILED_VALIDATOR
Definition for part library class.
void showButtonHandler(wxCommandEvent &event) override
static bool IsReferenceStringValid(const wxString &aReferenceString)
Function IsReferenceStringValid (static) Tests for an acceptable reference string An acceptable refer...
void setRowItem(int aFieldNdx, const SCH_FIELD &aField)
void SetBold(bool aBold)
Definition: eda_text.h:172
static wxString FormatSize(EDA_UNITS_T user_unit, int textSize)
Function FormatSize formats a string containing the size in the desired units.
Definition: wxwineda.cpp:84
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
VTBL_ENTRY bool ShowModal(wxString *aResult=NULL, wxWindow *aResultantFocusWindow=NULL)
Function ShowModal puts up this wxFrame as if it were a modal dialog, with all other instantiated wxF...
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
bool IsDragging() const
Definition: base_struct.h:219