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 
24 
25 #include <wx/tooltip.h>
26 #include <wx/hyperlink.h>
27 #include <wx/url.h>
28 
29 #include <fctsys.h>
30 #include <pgm_base.h>
31 #include <kiway.h>
32 #include <gr_basic.h>
33 #include <class_drawpanel.h>
34 #include <confirm.h>
35 #include <class_sch_screen.h>
36 #include <schframe.h>
37 #include <base_units.h>
38 
39 #include <general.h>
40 #include <sch_base_frame.h>
41 #include <class_library.h>
42 #include <sch_component.h>
43 #include <dialog_helpers.h>
44 #include <sch_validators.h>
45 
46 #include <bitmaps.h>
47 
49 #ifdef KICAD_SPICE
50 #include <dialog_spice_model.h>
52 #endif /* KICAD_SPICE */
53 
54 #include "common.h"
55 
56 
64 {
65 public:
67  DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* aParent );
68 
74  void InitBuffers( SCH_COMPONENT* aComponent );
75 
76 private:
77 
78  friend class SCH_EDIT_FRAME;
79 
84 
85  static int s_SelectedRow;
86 
89 
90  void setSelectedFieldNdx( int aFieldNdx );
91 
92  int getSelectedFieldNdx();
93 
100 
101 
110 
111  void copyOptionsToPanel();
112 
113  void copyPanelToOptions();
114 
115  void setRowItem( int aFieldNdx, const wxString& aName, const wxString& aValue );
116 
117  void setRowItem( int aFieldNdx, const SCH_FIELD& aField )
118  {
119  setRowItem( aFieldNdx, aField.GetName( false ), aField.GetText() );
120  }
121 
122  // event handlers
123  void OnCloseDialog( wxCloseEvent& event ) override;
124  void OnListItemDeselected( wxListEvent& event ) override;
125  void OnListItemSelected( wxListEvent& event ) override;
126  void OnCancelButtonClick( wxCommandEvent& event ) override;
127  void OnOKButtonClick( wxCommandEvent& event ) override;
128  void SetInitCmp( wxCommandEvent& event ) override;
129  void addFieldButtonHandler( wxCommandEvent& event ) override;
130  void deleteFieldButtonHandler( wxCommandEvent& event ) override;
131  void moveUpButtonHandler( wxCommandEvent& event ) override;
132  void moveDownButtonHandler( 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  // Configure button logos
227  addFieldButton->SetBitmap( KiBitmap( plus_xpm ) );
228  deleteFieldButton->SetBitmap( KiBitmap( minus_xpm ) );
229  moveUpButton->SetBitmap( KiBitmap( go_up_xpm ) );
230  moveDownButton->SetBitmap( KiBitmap( go_down_xpm ) );
231 
232  Fit();
233 }
234 
235 
237 {
238  if( !m_skipCopyFromPanel )
239  {
240  if( !copyPanelToSelectedField() )
241  event.Skip(); // do not go to the next row
242  }
243 }
244 
246 {
247  wxString partname = chipnameTextCtrl->GetValue();
248  LIB_PART* entry = Prj().SchLibs()->FindLibPart( partname );
249 
250  wxString msg;
251 
252  if( entry )
253  {
254  msg.Printf( _( "Component '%s' found in library '%s'" ),
255  GetChars( partname ), GetChars( entry->GetLibraryName() ) );
256  wxMessageBox( msg );
257  return;
258  }
259 
260  msg.Printf( _( "Component '%s' not found in any library" ), GetChars( partname ) );
261 
262  // Try to find components which have a name "near" the current chip name,
263  // i.e. the same name when the comparison is case insensitive.
264  // Could be helpful for old designs when lower cases and upper case were
265  // equivalent.
266  std::vector<LIB_ALIAS*> candidates;
267  Prj().SchLibs()->FindLibraryNearEntries( candidates, partname );
268 
269  if( candidates.size() == 0 )
270  {
271  wxMessageBox( msg );
272  return;
273  }
274 
275  // Some candidates are found. Show them:
276  msg << wxT("\n") << _( "However, some candidates are found:" );
277 
278  // add candidate names:
279  for( unsigned ii = 0; ii < candidates.size(); ii++ )
280  {
281  msg << wxT("\n") <<
282  wxString::Format( _( "'%s' found in library '%s'" ),
283  GetChars( candidates[ii]->GetName() ),
284  GetChars( candidates[ii]->GetLibraryName() ) );
285  }
286 
287  wxMessageBox( msg );
288 }
289 
290 
292 {
294 
295  auto sel = m_parent->SelectComponentFromLibrary( NULL, dummy, true, 0, 0 );
296 
297  if( sel.Name.IsEmpty() )
298  return;
299 
300  chipnameTextCtrl->SetValue( sel.Name );
301 }
302 
303 
305 {
306 #ifdef KICAD_SPICE
307  setSelectedFieldNdx( 0 );
308  DIALOG_SPICE_MODEL dialog( this, *m_cmp, m_FieldsBuf );
309 
310  if( dialog.ShowModal() == wxID_OK )
311  updateDisplay();
312 #endif /* KICAD_SPICE */
313 }
314 
315 
317 {
318  DBG( printf( "OnListItemSelected()\n" ); )
319 
320  // remember the selected row, statically
321  s_SelectedRow = event.GetIndex();
322 
324 }
325 
326 
328 {
329  // On wxWidgets 2.8, and on Linux, calling EndQuasiModal here is mandatory
330  // Otherwise, the main event loop is never restored, and Eeschema does not
331  // respond to any event, because the DIALOG_SHIM destructor is never called.
332  // On wxWidgets 3.0, or on Windows, the DIALOG_SHIM destructor is called,
333  // and calls EndQuasiModal.
334  // therefore calling EndQuasiModal here is not always mandatory but it creates no issues
335  EndQuasiModal( wxID_CANCEL );
336 }
337 
338 
340 {
341  EndQuasiModal( wxID_CANCEL );
342 }
343 
344 
346 {
347  LIB_ID id;
348  wxString tmp = chipnameTextCtrl->GetValue();
349 
350  tmp.Replace( wxT( " " ), wxT( "_" ) );
351 
352  id.SetLibItemName( tmp, false );
353 
354  // Save current flags which could be modified by next change settings
355  STATUS_FLAGS flags = m_cmp->GetFlags();
356 
357  if( id.empty() )
358  {
359  DisplayError( NULL, _( "No Component Name!" ) );
360  }
361  else if( id != m_cmp->GetLibId() )
362  {
363  PART_LIBS* libs = Prj().SchLibs();
364 
365  if( libs->FindLibraryAlias( id ) == NULL )
366  {
367  wxString msg = wxString::Format( _( "Component '%s' not found!" ),
368  GetChars( id.Format() ) );
369  DisplayError( this, msg );
370  }
371  else // Change component from lib!
372  {
373  m_cmp->SetLibId( id, libs );
374  }
375  }
376 
377  // For components with multiple shapes (De Morgan representation) Set the selected shape:
378  if( convertCheckBox->IsEnabled() )
379  {
380  m_cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
381  }
382 
383  //Set the part selection in multiple part per package
384  if( m_cmp->GetUnit() )
385  {
386  int unit_selection = unitChoice->GetCurrentSelection() + 1;
387 
388  m_cmp->SetUnitSelection( &m_parent->GetCurrentSheet(), unit_selection );
389  m_cmp->SetUnit( unit_selection );
390  }
391 
392  switch( orientationRadioBox->GetSelection() )
393  {
394  case 0:
396  break;
397 
398  case 1:
400  break;
401 
402  case 2:
404  break;
405 
406  case 3:
408  break;
409  }
410 
411  int mirror = mirrorRadioBox->GetSelection();
412 
413  switch( mirror )
414  {
415  case 0:
416  break;
417 
418  case 1:
420  break;
421 
422  case 2:
424  break;
425  }
426 
427  // Restore m_Flag modified by SetUnit() and other change settings
428  m_cmp->ClearFlags();
429  m_cmp->SetFlags( flags );
430 }
431 
432 
434 {
435  bool removeRemainingFields = false;
436 
437  if( !copyPanelToSelectedField() )
438  return;
439 
441  {
442  DisplayError( NULL, _( "Illegal reference. A reference must start with a letter" ) );
443  return;
444  }
445 
446  // save old cmp in undo list if not already in edit, or moving ...
447  // or the component to be edited is part of a block
448  if( m_cmp->GetFlags() == 0
451 
453 
454  // Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
455  for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); )
456  {
457  if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() )
458  {
459  // If a field has no value and is not it the field template list, warn the user
460  // that it will be remove from the component. This gives the user a chance to
461  // correct the problem before removing the undefined fields. It should also
462  // resolve most of the bug reports and questions regarding missing fields.
463  if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty()
464  && !m_parent->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) )
465  && !removeRemainingFields )
466  {
467  wxString msg = wxString::Format(
468  _( "The field name <%s> does not have a value and is not defined in "
469  "the field template list. Empty field values are invalid an will "
470  "be removed from the component. Do you wish to remove this and "
471  "all remaining undefined fields?" ),
472  GetChars( m_FieldsBuf[i].GetName( false ) )
473  );
474 
475  wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT );
476 
477  if( dlg.ShowModal() == wxID_NO )
478  return;
479 
480  removeRemainingFields = true;
481  }
482 
483  m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
484  continue;
485  }
486 
487  ++i;
488  }
489 
490  // change all field positions from relative to absolute
491  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
492  {
493  m_FieldsBuf[i].Offset( m_cmp->m_Pos );
494  }
495 
496  LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() );
497 
498  if( entry && entry->IsPower() )
499  m_FieldsBuf[VALUE].SetText( m_cmp->GetLibId().GetLibItemName() );
500 
501  // copy all the fields back, and change the length of m_Fields.
503 
504  // Reference has a specific initialization, depending on the current active sheet
505  // because for a given component, in a complex hierarchy, there are more than one
506  // reference.
508 
509  m_parent->OnModify();
511 
512  EndQuasiModal( wxID_OK );
513 }
514 
515 
517 {
518  // in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
519  // screen contents.
520  if( !copyPanelToSelectedField() )
521  return;
522 
523  unsigned fieldNdx = m_FieldsBuf.size();
524 
525  SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp );
526 
527  blank.SetTextAngle( m_FieldsBuf[REFERENCE].GetTextAngle() );
528 
529  m_FieldsBuf.push_back( blank );
530  m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
531 
532  m_skipCopyFromPanel = true;
533  setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
534 
535  setSelectedFieldNdx( fieldNdx );
536  m_skipCopyFromPanel = false;
537 }
538 
539 
541 {
542  unsigned fieldNdx = getSelectedFieldNdx();
543 
544  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
545  return;
546 
547  if( fieldNdx < MANDATORY_FIELDS )
548  {
549  wxBell();
550  return;
551  }
552 
553  m_skipCopyFromPanel = true;
554  m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
555  fieldListCtrl->DeleteItem( fieldNdx );
556 
557  if( fieldNdx >= m_FieldsBuf.size() )
558  --fieldNdx;
559 
560  updateDisplay();
561 
562  setSelectedFieldNdx( fieldNdx );
563  m_skipCopyFromPanel = false;
564 }
565 
566 static wxString resolveUriByEnvVars( const wxString& aUri )
567 {
568  // URL-like URI: return as is.
569  wxURL url( aUri );
570  if( url.GetError() == wxURL_NOERR )
571  {
572  return aUri;
573  }
574  // Otherwise, the path points to a local file. Resolve environment
575  // variables if any.
576  return ExpandEnvVarSubstitutions( aUri );
577 }
578 
580 {
581  unsigned fieldNdx = getSelectedFieldNdx();
582 
583  if( fieldNdx == DATASHEET )
584  {
585  wxString datasheet_uri = fieldValueTextCtrl->GetValue();
586  datasheet_uri = resolveUriByEnvVars( datasheet_uri );
587  ::wxLaunchDefaultBrowser( datasheet_uri );
588  }
589  else if( fieldNdx == FOOTPRINT )
590  {
591  // pick a footprint using the footprint picker.
592  wxString fpid;
593 
595 
596  if( frame->ShowModal( &fpid, this ) )
597  {
598  // DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
599  fieldValueTextCtrl->SetValue( fpid );
600 
601  setRowItem( fieldNdx, m_FieldsBuf[fieldNdx].GetName( false ), fpid );
602  }
603 
604  frame->Destroy();
605  }
606 }
607 
608 
610 {
611  unsigned fieldNdx = getSelectedFieldNdx();
612 
613  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
614  return;
615 
616  if( fieldNdx <= MANDATORY_FIELDS )
617  {
618  wxBell();
619  return;
620  }
621 
622  if( !copyPanelToSelectedField() )
623  return;
624 
625  // swap the fieldNdx field with the one before it, in both the vector
626  // and in the fieldListCtrl
627  SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
628 
629  DBG( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
630  TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); )
631 
632  m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
633  setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
634 
635  m_FieldsBuf[fieldNdx] = tmp;
636  setRowItem( fieldNdx, tmp );
637 
638  updateDisplay();
639 
640  m_skipCopyFromPanel = true;
641  setSelectedFieldNdx( fieldNdx - 1 );
642  m_skipCopyFromPanel = false;
643 }
644 
645 
647 {
648  unsigned fieldNdx = getSelectedFieldNdx();
649 
650  // Ensure there is at least one field after this one
651  if( fieldNdx >= ( m_FieldsBuf.size() - 1 ) )
652  {
653  return;
654  }
655 
656  // The first field which can be moved up is the second user field
657  // so any field which id < MANDATORY_FIELDS cannot be moved down
658  if( fieldNdx < MANDATORY_FIELDS )
659  return;
660 
661  if( !copyPanelToSelectedField() )
662  return;
663 
664  // swap the fieldNdx field with the one before it, in both the vector
665  // and in the fieldListCtrl
666  SCH_FIELD tmp = m_FieldsBuf[fieldNdx + 1];
667 
668  m_FieldsBuf[fieldNdx + 1] = m_FieldsBuf[fieldNdx];
669  setRowItem( fieldNdx + 1, m_FieldsBuf[fieldNdx] );
670  m_FieldsBuf[fieldNdx + 1].SetId( fieldNdx + 1 );
671 
672  m_FieldsBuf[fieldNdx] = tmp;
673  setRowItem( fieldNdx, tmp );
674  m_FieldsBuf[fieldNdx].SetId( fieldNdx );
675 
676  updateDisplay( );
677 
678  m_skipCopyFromPanel = true;
679  setSelectedFieldNdx( fieldNdx + 1 );
680  m_skipCopyFromPanel = false;
681 }
682 
683 
685 {
686  /* deselect old selection, but I think this is done by single selection
687  * flag within fieldListCtrl.
688  * fieldListCtrl->SetItemState( s_SelectedRow, 0,
689  * wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
690  */
691 
692  if( aFieldNdx >= (int) m_FieldsBuf.size() )
693  aFieldNdx = m_FieldsBuf.size() - 1;
694 
695  if( aFieldNdx < 0 )
696  aFieldNdx = 0;
697 
698  fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
699  fieldListCtrl->EnsureVisible( aFieldNdx );
700 
701  s_SelectedRow = aFieldNdx;
702 }
703 
704 
706 {
707  return s_SelectedRow;
708 }
709 
710 
712 {
713  for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
714  {
715  if( aFieldName == m_FieldsBuf[i].GetName( false ) )
716  return &m_FieldsBuf[i];
717  }
718 
719  return NULL;
720 }
721 
722 
724 {
725  m_cmp = aComponent;
726 
727  /* We have 3 component related field lists to be aware of: 1) UI
728  presentation, 2) fields in component ram copy, and 3) fields recorded
729  with component on disk. m_FieldsBuf is the list of UI fields, and this
730  list is not the same as the list which is in the component, which is
731  also not the same as the list on disk. All 3 lists are potentially
732  different. In the UI we choose to preserve the order of the first
733  MANDATORY_FIELDS which are sometimes called fixed fields. Then we append
734  the template fieldnames in the exact same order as the template
735  fieldname editor shows them. Then we append any user defined fieldnames
736  which came from the component.
737  */
738 
739  m_part = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() );
740 
741 #if 0 && defined(DEBUG)
742  for( int i = 0; i<aComponent->GetFieldCount(); ++i )
743  {
744  printf( "Orig[%d] (x=%d, y=%d)\n", i,
745  aComponent->m_Fields[i].GetTextPos().x,
746  aComponent->m_Fields[i].GetTextPos().y );
747  }
748 
749 #endif
750 
751  // When this code was written, all field constructors ensure that the fixed fields
752  // are all present within a component. So we can knowingly copy them over
753  // in the normal order. Copy only the fixed fields at first.
754  // Please do not break the field constructors.
755 
756  m_FieldsBuf.clear();
757 
758  for( int i=0; i<MANDATORY_FIELDS; ++i )
759  {
760  m_FieldsBuf.push_back( aComponent->m_Fields[i] );
761 
762  // make the editable field position relative to the component
763  m_FieldsBuf[i].Offset( -m_cmp->m_Pos );
764  }
765 
766  // Add template fieldnames:
767  // Now copy in the template fields, in the order that they are present in the
768  // template field editor UI.
770 
771  for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
772  {
773  // add a new field unconditionally to the UI only
774  SCH_FIELD fld( wxPoint(0,0), -1 /* id is a relic */, m_cmp, it->m_Name );
775 
776  // See if field by same name already exists in component.
777  SCH_FIELD* schField = aComponent->FindField( it->m_Name );
778 
779  // If the field does not already exist in the component, then we
780  // use defaults from the template fieldname, otherwise the original
781  // values from the component will be set.
782  if( !schField )
783  {
784  if( !it->m_Visible )
785  fld.SetVisible( false );
786  else
787  fld.SetVisible( true );
788 
789  fld.SetText( it->m_Value ); // empty? ok too.
790  }
791  else
792  {
793  fld = *schField;
794 
795  // make the editable field position relative to the component
796  fld.Offset( -m_cmp->m_Pos );
797  }
798 
799  m_FieldsBuf.push_back( fld );
800  }
801 
802  // Lastly, append any original fields from the component which were not added
803  // from the set of fixed fields nor from the set of template fields.
804  for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i )
805  {
806  SCH_FIELD* cmp = &aComponent->m_Fields[i];
807  SCH_FIELD* buf = findField( cmp->GetName( false ) );
808 
809  if( !buf )
810  {
811  int newNdx = m_FieldsBuf.size();
812  m_FieldsBuf.push_back( *cmp );
813 
814  // make the editable field position relative to the component
815  m_FieldsBuf[newNdx].Offset( -m_cmp->m_Pos );
816  }
817  }
818 
819 
820 #if 0 && defined(DEBUG)
821  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
822  {
823  printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
824  m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) );
825  }
826 #endif
827 
829 
830  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
831  {
832  setRowItem( i, m_FieldsBuf[i] );
833  }
834 
835 #if 0 && defined(DEBUG)
836  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
837  {
838  printf( "after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
839  m_FieldsBuf[i].m_Pos.y );
840  }
841 
842 #endif
843 
845 
846  // disable some options inside the edit dialog
847  // which can cause problems while dragging
848  if( m_cmp->IsDragging() )
849  {
850  orientationRadioBox->Disable();
851  mirrorRadioBox->Disable();
852  chipnameTextCtrl->Disable();
853  }
854 
855  // put focus on the list ctrl
856  fieldListCtrl->SetFocus();
857 
858  // resume editing at the last row edited, last time dialog was up.
860 
862 }
863 
864 
865 void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const wxString& aName, const wxString& aValue )
866 {
867  wxASSERT( aFieldNdx >= 0 );
868 
869  // insert blanks if aFieldNdx is referencing a "yet to be defined" row
870  while( aFieldNdx >= fieldListCtrl->GetItemCount() )
871  {
872  long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
873 
874  wxASSERT( ndx >= 0 );
875 
876  fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
877  }
878 
879  fieldListCtrl->SetItem( aFieldNdx, 0, aName );
880  fieldListCtrl->SetItem( aFieldNdx, 1, aValue );
881 
882  // recompute the column widths here, after setting texts
883  fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
884  fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
885 }
886 
887 
889 {
890  wxCHECK_RET( m_cmp != NULL, wxT( "Component pointer not initialized." ) );
891 
892  unsigned fieldNdx = getSelectedFieldNdx();
893 
894  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
895  return;
896 
897  SCH_FIELD& field = m_FieldsBuf[fieldNdx];
898 
899  showCheckBox->SetValue( field.IsVisible() );
900 
901  rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
902 
903  int style = 0;
904 
905  if( field.IsItalic() )
906  style = 1;
907 
908  if( field.IsBold() )
909  style |= 2;
910 
911  m_StyleRadioBox->SetSelection( style );
912 
913  // Select the right text justification
914  if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
915  m_FieldHJustifyCtrl->SetSelection( 0 );
916  else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
917  m_FieldHJustifyCtrl->SetSelection( 2 );
918  else
919  m_FieldHJustifyCtrl->SetSelection( 1 );
920 
921  if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
922  m_FieldVJustifyCtrl->SetSelection( 0 );
923  else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
924  m_FieldVJustifyCtrl->SetSelection( 2 );
925  else
926  m_FieldVJustifyCtrl->SetSelection( 1 );
927 
928 
929  fieldNameTextCtrl->SetValue( field.GetName( false ) );
930 
931  // the names of the fixed fields are not editable, others are.
932  fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS );
933  fieldNameTextCtrl->SetEditable( fieldNdx >= MANDATORY_FIELDS );
934 
935  // only user defined fields may be moved, and not the top most user defined
936  // field since it would be moving up into the fixed fields, > not >=
937  moveUpButton->Enable( fieldNdx > MANDATORY_FIELDS );
938 
939  // may only delete user defined fields
940  deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
941 
942  fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( false, field.GetId() ) );
943  fieldValueTextCtrl->SetValue( field.GetText() );
944 
945  m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
946 
947  if( fieldNdx == DATASHEET )
948  {
949  m_show_datasheet_button->SetLabel( _( "Show Datasheet" ) );
950  m_show_datasheet_button->SetToolTip(
951  _("If your datasheet is given as an http:// link,"
952  " then pressing this button should bring it up in your webbrowser.") );
953  }
954  else if( fieldNdx == FOOTPRINT )
955  {
956  m_show_datasheet_button->SetLabel( _( "Browse Footprints" ) );
957  m_show_datasheet_button->SetToolTip(
958  _("Open the footprint browser to choose a footprint and assign it.") );
959  }
960  else
961  {
962  m_show_datasheet_button->SetLabel( wxEmptyString );
963  m_show_datasheet_button->SetToolTip(
964  _("Used only for fields Footprint and Datasheet.") );
965  }
966 
967  // For power symbols, the value is NOR editable, because value and pin
968  // name must be same and can be edited only in library editor
969  if( fieldNdx == VALUE && m_part && m_part->IsPower() )
970  fieldValueTextCtrl->Enable( false );
971  else
972  fieldValueTextCtrl->Enable( true );
973 
975 
976  wxPoint coord = field.GetTextPos();
977  wxPoint zero = -m_cmp->m_Pos; // relative zero
978 
979  // If the field value is empty and the position is at relative zero, we
980  // set the initial position as a small offset from the ref field, and
981  // orient it the same as the ref field. That is likely to put it at least
982  // close to the desired position.
983  if( coord == zero && field.GetText().IsEmpty() )
984  {
985  rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT );
986 
987  coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x
988  + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
989 
990  coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y
991  + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
992 
993  // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
994  // That is ok, we basically don't want all the new empty fields on
995  // top of each other.
996  }
997 
998  wxString coordText = StringFromValue( g_UserUnit, coord.x );
999  posXTextCtrl->SetValue( coordText );
1000 
1001  coordText = StringFromValue( g_UserUnit, coord.y );
1002  posYTextCtrl->SetValue( coordText );
1003 }
1004 
1005 
1007 {
1008  unsigned fieldNdx = getSelectedFieldNdx();
1009 
1010  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
1011  return true;
1012 
1013  // Check for illegal field text.
1014  if( fieldValueTextCtrl->GetValidator()
1015  && !fieldValueTextCtrl->GetValidator()->Validate( this ) )
1016  return false;
1017 
1018  SCH_FIELD& field = m_FieldsBuf[fieldNdx];
1019 
1020  field.SetVisible( showCheckBox->GetValue() );
1021 
1022  if( rotateCheckBox->GetValue() )
1023  field.SetTextAngle( TEXT_ANGLE_VERT );
1024  else
1025  field.SetTextAngle( TEXT_ANGLE_HORIZ );
1026 
1027  rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
1028 
1029  // Copy the text justification
1030  static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
1034  };
1035 
1036  static const EDA_TEXT_VJUSTIFY_T vjustify[] = {
1040  };
1041 
1042  field.SetHorizJustify( hjustify[m_FieldHJustifyCtrl->GetSelection()] );
1043  field.SetVertJustify( vjustify[m_FieldVJustifyCtrl->GetSelection()] );
1044 
1045  field.SetName( fieldNameTextCtrl->GetValue() );
1046 
1047  /* Void fields texts for REFERENCE and VALUE (value is the name of the
1048  * component in lib ! ) are not allowed
1049  * change them only for a new non void value
1050  * When void, usually netlists are broken
1051  */
1052  if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
1053  field.SetText( fieldValueTextCtrl->GetValue() );
1054 
1055  setRowItem( fieldNdx, field ); // update fieldListCtrl
1056 
1058  field.SetTextSize( wxSize( tmp, tmp ) );
1059  int style = m_StyleRadioBox->GetSelection();
1060 
1061  field.SetItalic( (style & 1 ) != 0 );
1062  field.SetBold( (style & 2 ) != 0 );
1063 
1064  wxPoint pos;
1065  pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
1066  pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
1067  field.SetTextPos( pos );
1068 
1069  return true;
1070 }
1071 
1072 
1074 {
1075  // Remove non existing choices (choiceCount must be <= number for parts)
1076  int unitcount = m_part ? m_part->GetUnitCount() : 1;
1077 
1078  if( unitcount < 1 )
1079  unitcount = 1;
1080 
1081  unitChoice->Clear();
1082 
1083  for( int ii = 1; ii <= unitcount; ii++ )
1084  {
1085  unitChoice->Append( LIB_PART::SubReference( ii, false ) );
1086  }
1087 
1088  // For components with multiple parts per package, set the unit selection
1089  if( m_cmp->GetUnit() <= (int)unitChoice->GetCount() )
1090  unitChoice->SetSelection( m_cmp->GetUnit() - 1 );
1091 
1092  // Disable unit selection if only one unit exists:
1093  if( m_cmp->GetUnitCount() <= 1 )
1094  {
1095  unitChoice->Enable( false );
1096  unitsInterchageableLabel->Show( false );
1097  unitsInterchageableText->Show( false );
1098  }
1099  else
1100  {
1101  // Show the "Units are not interchangeable" message option?
1102  if( !m_part || !m_part->UnitsLocked() )
1103  unitsInterchageableLabel->SetLabel( _( "Yes" ) );
1104  else
1105  unitsInterchageableLabel->SetLabel( _( "No" ) );
1106  }
1107 
1108  int orientation = m_cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y );
1109 
1110  if( orientation == CMP_ORIENT_90 )
1111  orientationRadioBox->SetSelection( 1 );
1112  else if( orientation == CMP_ORIENT_180 )
1113  orientationRadioBox->SetSelection( 2 );
1114  else if( orientation == CMP_ORIENT_270 )
1115  orientationRadioBox->SetSelection( 3 );
1116  else
1117  orientationRadioBox->SetSelection( 0 );
1118 
1119  int mirror = m_cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
1120 
1121  if( mirror == CMP_MIRROR_X )
1122  {
1123  mirrorRadioBox->SetSelection( 1 );
1124  DBG( printf( "mirror=X,1\n" ); )
1125  }
1126  else if( mirror == CMP_MIRROR_Y )
1127  {
1128  mirrorRadioBox->SetSelection( 2 );
1129  DBG( printf( "mirror=Y,2\n" ); )
1130  }
1131  else
1132  mirrorRadioBox->SetSelection( 0 );
1133 
1134  // Activate/Desactivate the normal/convert option ? (activated only if
1135  // the component has more than one shape)
1136  if( m_cmp->GetConvert() > 1 )
1137  convertCheckBox->SetValue( true );
1138 
1139  if( m_part == NULL || !m_part->HasConversion() )
1140  convertCheckBox->Enable( false );
1141 
1142  // Set the component's library name.
1143  chipnameTextCtrl->SetValue( m_cmp->GetLibId().Format() );
1144 
1145  // Set the component's unique ID time stamp.
1146  m_textCtrlTimeStamp->SetValue( wxString::Format( wxT( "%8.8lX" ),
1147  (unsigned long) m_cmp->GetTimeStamp() ) );
1148 }
1149 
1150 
1151 #include <kicad_device_context.h>
1152 
1153 
1155 {
1156  if( !m_cmp )
1157  return;
1158 
1159  if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() ) )
1160  {
1161  // save old cmp in undo list if not already in edit, or moving ...
1162  if( m_cmp->GetFlags() == 0 )
1164 
1166  m_cmp->Draw( m_parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
1167 
1168  // Initialize fixed field values to default values found in library
1169  // Note: the field texts are not modified because they are set in schematic,
1170  // the text from libraries is most of time a dummy text
1171  // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
1172  LIB_FIELD& refField = part->GetReferenceField();
1173 
1174  m_cmp->GetField( REFERENCE )->ImportValues( refField );
1175  m_cmp->GetField( REFERENCE )->SetTextPos( refField.GetTextPos() + m_cmp->m_Pos );
1176 
1177  LIB_FIELD& valField = part->GetValueField();
1178 
1179  m_cmp->GetField( VALUE )->ImportValues( valField );
1180  m_cmp->GetField( VALUE )->SetTextPos( valField.GetTextPos() + m_cmp->m_Pos );
1181 
1182  LIB_FIELD* field = part->GetField(FOOTPRINT);
1183 
1184  if( field && m_cmp->GetField( FOOTPRINT ) )
1185  {
1186  m_cmp->GetField( FOOTPRINT )->ImportValues( *field );
1187  m_cmp->GetField( FOOTPRINT )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
1188  }
1189 
1190  field = part->GetField(DATASHEET);
1191 
1192  if( field && m_cmp->GetField( DATASHEET ) )
1193  {
1194  m_cmp->GetField( DATASHEET )->ImportValues( *field );
1195  m_cmp->GetField( DATASHEET )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
1196  }
1197 
1199 
1200  m_parent->OnModify();
1201 
1202  m_cmp->Draw( m_parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
1203 
1204  EndQuasiModal( wxID_OK );
1205  }
1206 }
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:212
#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)
Autoplace fields only if correct to do so automatically.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:269
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)
Search for a SCH_FIELD with aFieldName.
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
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
void moveDownButtonHandler(wxCommandEvent &event) override
int GetOrientation()
Get the display symbol orientation.
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
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
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:304
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:769
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...
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
Return the number of units per package of the symbol.
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:347
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:528
#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.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
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:267
void SetFields(const SCH_FIELDS &aFields)
Set multiple schematic fields.
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
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:573
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:158
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
void SetUnit(int aUnit)
Change the unit number to aUnit.
int GetUnit() const
void OnListItemSelected(wxListEvent &event) override
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
bool m_autoplaceFields
automatically place component fields
Definition: schframe.h:154
const wxString GetLibraryName()
time_t GetTimeStamp() const
Definition: base_struct.h:218
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 SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void EndQuasiModal(int retCode)
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
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
Return the number of fields in this symbol.
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:915
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
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:268
#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:94
class SCH_FILED_VALIDATOR
Definition for part library class.
void showButtonHandler(wxCommandEvent &event) override
static bool IsReferenceStringValid(const wxString &aReferenceString)
Tests for an acceptable reference string.
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:71
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)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
bool IsDragging() const
Definition: base_struct.h:233