KiCad PCB EDA Suite
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC Class Reference

class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP which is maintained by wxFormBuilder. More...

Inheritance diagram for DIALOG_EDIT_COMPONENT_IN_SCHEMATIC:
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP DIALOG_SHIM KIWAY_HOLDER

Public Member Functions

 DIALOG_EDIT_COMPONENT_IN_SCHEMATIC (wxWindow *aParent)
 Constructor. More...
 
void InitBuffers (SCH_COMPONENT *aComponent)
 Function InitBuffers sets up to edit the given component. More...
 
int ShowQuasiModal ()
 
void EndQuasiModal (int retCode)
 
bool IsQuasiModal ()
 
bool Show (bool show) override
 
bool Enable (bool enable) override
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Protected Member Functions

void FinishDialogSettings ()
 In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls. More...
 
void FixOSXCancelButtonIssue ()
 A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms. More...
 

Protected Attributes

wxStaticText * m_staticTextUnit
 
wxChoice * unitChoice
 
wxStaticText * unitsInterchageableText
 
wxStaticText * unitsInterchageableLabel
 
wxRadioBox * orientationRadioBox
 
wxRadioBox * mirrorRadioBox
 
wxCheckBox * convertCheckBox
 
wxTextCtrl * chipnameTextCtrl
 
wxButton * m_buttonTestChipName
 
wxButton * m_buttonSelectChipName
 
wxStaticText * m_staticTextTimeStamp
 
wxTextCtrl * m_textCtrlTimeStamp
 
wxStaticLine * m_staticline1
 
wxButton * spiceFieldsButton
 
wxButton * defaultsButton
 
wxListCtrl * fieldListCtrl
 
wxButton * addFieldButton
 
wxButton * deleteFieldButton
 
wxButton * moveUpButton
 
wxRadioBox * m_FieldHJustifyCtrl
 
wxRadioBox * m_FieldVJustifyCtrl
 
wxCheckBox * showCheckBox
 
wxCheckBox * rotateCheckBox
 
wxRadioBox * m_StyleRadioBox
 
wxStaticText * fieldNameLabel
 
wxTextCtrl * fieldNameTextCtrl
 
wxStaticText * fieldValueLabel
 
wxTextCtrl * fieldValueTextCtrl
 
wxButton * m_show_datasheet_button
 
wxStaticText * textSizeLabel
 
wxTextCtrl * textSizeTextCtrl
 
wxStaticText * m_staticTextUnitSize
 
wxStaticText * posXLabel
 
wxTextCtrl * posXTextCtrl
 
wxStaticText * m_staticTextUnitPosX
 
wxStaticText * posYLabel
 
wxTextCtrl * posYTextCtrl
 
wxStaticText * m_staticTextUnitPosY
 
wxStdDialogButtonSizer * stdDialogButtonSizer
 
wxButton * stdDialogButtonSizerOK
 
wxButton * stdDialogButtonSizerCancel
 
std::string m_hash_key
 
EVENT_LOOPm_qmodal_loop
 
bool m_qmodal_showing
 
WDO_ENABLE_DISABLEm_qmodal_parent_disabler
 

Private Member Functions

void setSelectedFieldNdx (int aFieldNdx)
 
int getSelectedFieldNdx ()
 
void copySelectedFieldToPanel ()
 Function copySelectedFieldToPanel sets the values displayed on the panel according to the currently selected field row. More...
 
bool copyPanelToSelectedField ()
 Function copyPanelToSelectedField copies the values displayed on the panel fields to the currently selected field. More...
 
void copyOptionsToPanel ()
 
void copyPanelToOptions ()
 
void setRowItem (int aFieldNdx, const wxString &aName, const wxString &aValue)
 
void setRowItem (int aFieldNdx, const SCH_FIELD &aField)
 
void OnCloseDialog (wxCloseEvent &event) override
 
void OnListItemDeselected (wxListEvent &event) override
 
void OnListItemSelected (wxListEvent &event) override
 
void OnCancelButtonClick (wxCommandEvent &event) override
 
void OnOKButtonClick (wxCommandEvent &event) override
 
void SetInitCmp (wxCommandEvent &event) override
 
void addFieldButtonHandler (wxCommandEvent &event) override
 
void deleteFieldButtonHandler (wxCommandEvent &event) override
 
void moveUpButtonHandler (wxCommandEvent &event) override
 
void showButtonHandler (wxCommandEvent &event) override
 
void OnTestChipName (wxCommandEvent &event) override
 
void OnSelectChipName (wxCommandEvent &event) override
 
void OnInitDlg (wxInitDialogEvent &event) override
 
void EditSpiceModel (wxCommandEvent &event) override
 
SCH_FIELDfindField (const wxString &aFieldName)
 
void updateDisplay ()
 Function updateDisplay update the listbox showing fields, according to the fields texts must be called after a text change in fields, if this change is not an edition. More...
 

Private Attributes

SCH_EDIT_FRAMEm_parent
 
SCH_COMPONENTm_cmp
 
LIB_PARTm_part
 
bool m_skipCopyFromPanel
 
SCH_FIELDS m_FieldsBuf
 a copy of the edited component's SCH_FIELDs More...
 

Static Private Attributes

static int s_SelectedRow
 

Friends

class SCH_EDIT_FRAME
 

Detailed Description

class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP which is maintained by wxFormBuilder.

Do not auto-generate this class or file, it is hand coded.

Definition at line 61 of file dialog_edit_component_in_schematic.cpp.

Constructor & Destructor Documentation

DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC ( wxWindow *  aParent)

Constructor.

Definition at line 193 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldListCtrl, g_UserUnit, GetAbbreviatedUnitsLabel(), m_cmp, m_parent, m_part, m_skipCopyFromPanel, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextUnitPosX, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextUnitPosY, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextUnitSize, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::spiceFieldsButton, and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::stdDialogButtonSizerOK.

193  :
195 {
196 #ifndef KICAD_SPICE
197  spiceFieldsButton->Hide();
198 #endif /* not KICAD_SPICE */
199 
200  m_parent = (SCH_EDIT_FRAME*) aParent;
201 
202  m_cmp = NULL;
203  m_part = NULL;
204  m_skipCopyFromPanel = false;
205 
206  wxListItem columnLabel;
207 
208  columnLabel.SetImage( -1 );
209 
210  columnLabel.SetText( _( "Name" ) );
211  fieldListCtrl->InsertColumn( 0, columnLabel );
212 
213  columnLabel.SetText( _( "Value" ) );
214  fieldListCtrl->InsertColumn( 1, columnLabel );
215 
219 
220  wxToolTip::Enable( true );
221  stdDialogButtonSizerOK->SetDefault();
222 
223  Fit();
224 }
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Component Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(928, 741), long style=wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU)
Schematic editor (Eeschema) main window.
Definition: schframe.h:117
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit)
Definition: base_units.cpp:479
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56

Member Function Documentation

void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 507 of file dialog_edit_component_in_schematic.cpp.

References copyPanelToSelectedField(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), m_cmp, m_FieldsBuf, m_skipCopyFromPanel, REFERENCE, setRowItem(), setSelectedFieldNdx(), and EDA_TEXT::SetTextAngle().

508 {
509  // in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
510  // screen contents.
511  if( !copyPanelToSelectedField() )
512  return;
513 
514  unsigned fieldNdx = m_FieldsBuf.size();
515 
516  SCH_FIELD blank( wxPoint(), fieldNdx, m_cmp );
517 
518  blank.SetTextAngle( m_FieldsBuf[REFERENCE].GetTextAngle() );
519 
520  m_FieldsBuf.push_back( blank );
521  m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
522 
523  m_skipCopyFromPanel = true;
524  setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
525 
526  setSelectedFieldNdx( fieldNdx );
527  m_skipCopyFromPanel = false;
528 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
bool copyPanelToSelectedField()
Function copyPanelToSelectedField copies the values displayed on the panel fields to the currently se...
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
Field Reference of part, i.e. "IC21".
void setRowItem(int aFieldNdx, const wxString &aName, const wxString &aValue)
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel ( )
private

Definition at line 1013 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::chipnameTextCtrl, CMP_MIRROR_X, CMP_MIRROR_Y, CMP_ORIENT_180, CMP_ORIENT_270, CMP_ORIENT_90, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::convertCheckBox, DBG, LIB_ID::Format(), Format(), FROM_UTF8(), SCH_COMPONENT::GetConvert(), SCH_COMPONENT::GetLibId(), SCH_COMPONENT::GetOrientation(), EDA_ITEM::GetTimeStamp(), SCH_COMPONENT::GetUnit(), SCH_COMPONENT::GetUnitCount(), LIB_PART::GetUnitCount(), LIB_PART::HasConversion(), m_cmp, m_part, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_textCtrlTimeStamp, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::mirrorRadioBox, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::orientationRadioBox, LIB_PART::SubReference(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::unitChoice, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::unitsInterchageableLabel, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::unitsInterchageableText, and LIB_PART::UnitsLocked().

Referenced by InitBuffers().

1014 {
1015  // Remove non existing choices (choiceCount must be <= number for parts)
1016  int unitcount = m_part ? m_part->GetUnitCount() : 1;
1017 
1018  if( unitcount < 1 )
1019  unitcount = 1;
1020 
1021  unitChoice->Clear();
1022 
1023  for( int ii = 1; ii <= unitcount; ii++ )
1024  {
1025  unitChoice->Append( LIB_PART::SubReference( ii, false ) );
1026  }
1027 
1028  // For components with multiple parts per package, set the unit selection
1029  if( m_cmp->GetUnit() <= (int)unitChoice->GetCount() )
1030  unitChoice->SetSelection( m_cmp->GetUnit() - 1 );
1031 
1032  // Disable unit selection if only one unit exists:
1033  if( m_cmp->GetUnitCount() <= 1 )
1034  {
1035  unitChoice->Enable( false );
1036  unitsInterchageableLabel->Show( false );
1037  unitsInterchageableText->Show( false );
1038  }
1039  else
1040  {
1041  // Show the "Units are not interchangeable" message option?
1042  if( !m_part || !m_part->UnitsLocked() )
1043  unitsInterchageableLabel->SetLabel( _( "Yes" ) );
1044  else
1045  unitsInterchageableLabel->SetLabel( _( "No" ) );
1046  }
1047 
1048  int orientation = m_cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y );
1049 
1050  if( orientation == CMP_ORIENT_90 )
1051  orientationRadioBox->SetSelection( 1 );
1052  else if( orientation == CMP_ORIENT_180 )
1053  orientationRadioBox->SetSelection( 2 );
1054  else if( orientation == CMP_ORIENT_270 )
1055  orientationRadioBox->SetSelection( 3 );
1056  else
1057  orientationRadioBox->SetSelection( 0 );
1058 
1059  int mirror = m_cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
1060 
1061  if( mirror == CMP_MIRROR_X )
1062  {
1063  mirrorRadioBox->SetSelection( 1 );
1064  DBG( printf( "mirror=X,1\n" ); )
1065  }
1066  else if( mirror == CMP_MIRROR_Y )
1067  {
1068  mirrorRadioBox->SetSelection( 2 );
1069  DBG( printf( "mirror=Y,2\n" ); )
1070  }
1071  else
1072  mirrorRadioBox->SetSelection( 0 );
1073 
1074  // Activate/Desactivate the normal/convert option ? (activated only if
1075  // the component has more than one shape)
1076  if( m_cmp->GetConvert() > 1 )
1077  convertCheckBox->SetValue( true );
1078 
1079  if( m_part == NULL || !m_part->HasConversion() )
1080  convertCheckBox->Enable( false );
1081 
1082  // Set the component's library name.
1083  chipnameTextCtrl->SetValue( FROM_UTF8( m_cmp->GetLibId().Format() ) );
1084 
1085  // Set the component's unique ID time stamp.
1086  m_textCtrlTimeStamp->SetValue( wxString::Format( wxT( "%8.8lX" ),
1087  (unsigned long) m_cmp->GetTimeStamp() ) );
1088 }
bool UnitsLocked() const
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).
int GetOrientation()
Function GetOrientation Used to display component orientation (in dialog editor or info) ...
int GetUnitCount() const
Function GetUnitCount returns the number of parts per package of the component.
int GetConvert() const
int GetUnit() const
time_t GetTimeStamp() const
Definition: base_struct.h:204
int GetUnitCount() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Function SubReference.
const LIB_ID & GetLibId() const
UTF8 Format() const
Function Format.
Definition: lib_id.cpp:263
#define DBG(x)
Definition: fctsys.h:33
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions ( )
private

Definition at line 336 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::chipnameTextCtrl, EDA_ITEM::ClearFlags(), CMP_MIRROR_X, CMP_MIRROR_Y, CMP_ORIENT_0, CMP_ORIENT_180, CMP_ORIENT_270, CMP_ORIENT_90, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::convertCheckBox, DisplayError(), empty(), PART_LIBS::FindLibraryAlias(), Format(), FROM_UTF8(), GetChars(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetLibId(), SCH_COMPONENT::GetUnit(), m_cmp, m_parent, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::mirrorRadioBox, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::orientationRadioBox, KIWAY_HOLDER::Prj(), SCH_COMPONENT::SetConvert(), EDA_ITEM::SetFlags(), SCH_COMPONENT::SetLibId(), SCH_COMPONENT::SetOrientation(), SCH_COMPONENT::SetUnit(), SCH_COMPONENT::SetUnitSelection(), TO_UTF8, and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::unitChoice.

Referenced by OnOKButtonClick().

337 {
338  LIB_ID id;
339  wxString tmp = chipnameTextCtrl->GetValue();
340 
341  tmp.Replace( wxT( " " ), wxT( "_" ) );
342 
343  id.SetLibItemName( TO_UTF8( tmp ), false );
344 
345  // Save current flags which could be modified by next change settings
346  STATUS_FLAGS flags = m_cmp->GetFlags();
347 
348  if( id.empty() )
349  {
350  DisplayError( NULL, _( "No Component Name!" ) );
351  }
352  else if( id != m_cmp->GetLibId() )
353  {
354  PART_LIBS* libs = Prj().SchLibs();
355 
356  if( libs->FindLibraryAlias( id ) == NULL )
357  {
358  wxString msg = wxString::Format( _( "Component '%s' not found!" ),
359  GetChars( FROM_UTF8( id.Format() ) ) );
360  DisplayError( this, msg );
361  }
362  else // Change component from lib!
363  {
364  m_cmp->SetLibId( id, libs );
365  }
366  }
367 
368  // For components with multiple shapes (De Morgan representation) Set the selected shape:
369  if( convertCheckBox->IsEnabled() )
370  {
371  m_cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
372  }
373 
374  //Set the part selection in multiple part per package
375  if( m_cmp->GetUnit() )
376  {
377  int unit_selection = unitChoice->GetCurrentSelection() + 1;
378 
379  m_cmp->SetUnitSelection( &m_parent->GetCurrentSheet(), unit_selection );
380  m_cmp->SetUnit( unit_selection );
381  }
382 
383  switch( orientationRadioBox->GetSelection() )
384  {
385  case 0:
387  break;
388 
389  case 1:
391  break;
392 
393  case 2:
395  break;
396 
397  case 3:
399  break;
400  }
401 
402  int mirror = mirrorRadioBox->GetSelection();
403 
404  switch( mirror )
405  {
406  case 0:
407  break;
408 
409  case 1:
411  break;
412 
413  case 2:
415  break;
416  }
417 
418  // Restore m_Flag modified by SetUnit() and other change settings
419  m_cmp->ClearFlags();
420  m_cmp->SetFlags( flags );
421 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:255
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
void SetUnitSelection(SCH_SHEET_PATH *aSheet, int aUnitSelection)
Class LIB_ID.
Definition: lib_id.h:56
LIB_ALIAS * FindLibraryAlias(const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
Function FindLibraryEntry searches all libraries in the list for an entry.
void SetConvert(int aConvert)
#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
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 SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:565
unsigned STATUS_FLAGS
Definition: base_struct.h:144
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
Class PART_LIBS is a collection of PART_LIBs.
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
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
static bool empty(const wxTextEntryBase *aCtrl)
const LIB_ID & GetLibId() const
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField ( )
private

Function copyPanelToSelectedField copies the values displayed on the panel fields to the currently selected field.

Returns
bool - true if all fields are OK, else false if the user has put bad data into a field, and this value can be used to deny a row change.

Definition at line 946 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldNameTextCtrl, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldValueTextCtrl, g_UserUnit, getSelectedFieldNdx(), EDA_TEXT::GetTextAngle(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_FieldHJustifyCtrl, m_FieldsBuf, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_FieldVJustifyCtrl, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_StyleRadioBox, EDA_GRAPHIC_TEXT_CTRL::ParseSize(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posXTextCtrl, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posYTextCtrl, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::rotateCheckBox, EDA_TEXT::SetBold(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), SCH_FIELD::SetName(), setRowItem(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::showCheckBox, TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::textSizeTextCtrl, VALUE, ValueFromString(), wxPoint::x, and wxPoint::y.

Referenced by addFieldButtonHandler(), moveUpButtonHandler(), OnListItemDeselected(), and OnOKButtonClick().

947 {
948  unsigned fieldNdx = getSelectedFieldNdx();
949 
950  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
951  return true;
952 
953  // Check for illegal field text.
954  if( fieldValueTextCtrl->GetValidator()
955  && !fieldValueTextCtrl->GetValidator()->Validate( this ) )
956  return false;
957 
958  SCH_FIELD& field = m_FieldsBuf[fieldNdx];
959 
960  field.SetVisible( showCheckBox->GetValue() );
961 
962  if( rotateCheckBox->GetValue() )
963  field.SetTextAngle( TEXT_ANGLE_VERT );
964  else
966 
967  rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
968 
969  // Copy the text justification
970  static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
974  };
975 
976  static const EDA_TEXT_VJUSTIFY_T vjustify[] = {
980  };
981 
982  field.SetHorizJustify( hjustify[m_FieldHJustifyCtrl->GetSelection()] );
983  field.SetVertJustify( vjustify[m_FieldVJustifyCtrl->GetSelection()] );
984 
985  field.SetName( fieldNameTextCtrl->GetValue() );
986 
987  /* Void fields texts for REFERENCE and VALUE (value is the name of the
988  * component in lib ! ) are not allowed
989  * change them only for a new non void value
990  * When void, usually netlists are broken
991  */
992  if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
993  field.SetText( fieldValueTextCtrl->GetValue() );
994 
995  setRowItem( fieldNdx, field ); // update fieldListCtrl
996 
998  field.SetTextSize( wxSize( tmp, tmp ) );
999  int style = m_StyleRadioBox->GetSelection();
1000 
1001  field.SetItalic( (style & 1 ) != 0 );
1002  field.SetBold( (style & 2 ) != 0 );
1003 
1004  wxPoint pos;
1005  pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
1006  pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
1007  field.SetTextPos( pos );
1008 
1009  return true;
1010 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:156
#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
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
void SetItalic(bool isItalic)
Definition: eda_text.h:169
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void SetVisible(bool aVisible)
Definition: eda_text.h:175
static int ParseSize(const wxString &sizeText, EDA_UNITS_T user_unit)
Definition: wxwineda.cpp:123
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
#define TEXT_ANGLE_VERT
Definition: common.h:92
double GetTextAngle() const
Definition: eda_text.h:164
void setRowItem(int aFieldNdx, const wxString &aName, const wxString &aValue)
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
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
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
Field Value of part, i.e. "3.3K".
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
void SetName(const wxString &aName)
Definition: sch_field.h:85
void SetBold(bool aBold)
Definition: eda_text.h:172
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel ( )
private

Function copySelectedFieldToPanel sets the values displayed on the panel according to the currently selected field row.

Definition at line 828 of file dialog_edit_component_in_schematic.cpp.

References DATASHEET, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButton, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldNameTextCtrl, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldValueTextCtrl, FOOTPRINT, EDA_GRAPHIC_TEXT_CTRL::FormatSize(), g_UserUnit, EDA_TEXT::GetHorizJustify(), SCH_FIELD::GetId(), SCH_FIELD::GetName(), getSelectedFieldNdx(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetVertJustify(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), LIB_PART::IsPower(), EDA_TEXT::IsVisible(), m_cmp, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_FieldHJustifyCtrl, m_FieldsBuf, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_FieldVJustifyCtrl, m_part, SCH_COMPONENT::m_Pos, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_show_datasheet_button, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_StyleRadioBox, MANDATORY_FIELDS, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButton, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posXTextCtrl, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posYTextCtrl, REFERENCE, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::rotateCheckBox, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::showCheckBox, StringFromValue(), TEXT_ANGLE_VERT, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::textSizeTextCtrl, VALUE, wxPoint::x, and wxPoint::y.

Referenced by InitBuffers(), and OnListItemSelected().

829 {
830  wxCHECK_RET( m_cmp != NULL, wxT( "Component pointer not initialized." ) );
831 
832  unsigned fieldNdx = getSelectedFieldNdx();
833 
834  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
835  return;
836 
837  SCH_FIELD& field = m_FieldsBuf[fieldNdx];
838 
839  showCheckBox->SetValue( field.IsVisible() );
840 
841  rotateCheckBox->SetValue( field.GetTextAngle() == TEXT_ANGLE_VERT );
842 
843  int style = 0;
844 
845  if( field.IsItalic() )
846  style = 1;
847 
848  if( field.IsBold() )
849  style |= 2;
850 
851  m_StyleRadioBox->SetSelection( style );
852 
853  // Select the right text justification
854  if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
855  m_FieldHJustifyCtrl->SetSelection( 0 );
856  else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
857  m_FieldHJustifyCtrl->SetSelection( 2 );
858  else
859  m_FieldHJustifyCtrl->SetSelection( 1 );
860 
861  if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
862  m_FieldVJustifyCtrl->SetSelection( 0 );
863  else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
864  m_FieldVJustifyCtrl->SetSelection( 2 );
865  else
866  m_FieldVJustifyCtrl->SetSelection( 1 );
867 
868 
869  fieldNameTextCtrl->SetValue( field.GetName( false ) );
870 
871  // the names of the fixed fields are not editable, others are.
872  fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS );
873  fieldNameTextCtrl->SetEditable( fieldNdx >= MANDATORY_FIELDS );
874 
875  // only user defined fields may be moved, and not the top most user defined
876  // field since it would be moving up into the fixed fields, > not >=
877  moveUpButton->Enable( fieldNdx > MANDATORY_FIELDS );
878 
879  // may only delete user defined fields
880  deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
881 
882  fieldValueTextCtrl->SetValidator( SCH_FIELD_VALIDATOR( false, field.GetId() ) );
883  fieldValueTextCtrl->SetValue( field.GetText() );
884 
885  m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
886 
887  if( fieldNdx == DATASHEET )
888  {
889  m_show_datasheet_button->SetLabel( _( "Show Datasheet" ) );
890  m_show_datasheet_button->SetToolTip(
891  _("If your datasheet is given as an http:// link,"
892  " then pressing this button should bring it up in your webbrowser.") );
893  }
894  else if( fieldNdx == FOOTPRINT )
895  {
896  m_show_datasheet_button->SetLabel( _( "Browse Footprints" ) );
897  m_show_datasheet_button->SetToolTip(
898  _("Open the footprint browser to choose a footprint and assign it.") );
899  }
900  else
901  {
902  m_show_datasheet_button->SetLabel( wxEmptyString );
903  m_show_datasheet_button->SetToolTip(
904  _("Used only for fields Footprint and Datasheet.") );
905  }
906 
907  // For power symbols, the value is NOR editable, because value and pin
908  // name must be same and can be edited only in library editor
909  if( fieldNdx == VALUE && m_part && m_part->IsPower() )
910  fieldValueTextCtrl->Enable( false );
911  else
912  fieldValueTextCtrl->Enable( true );
913 
915 
916  wxPoint coord = field.GetTextPos();
917  wxPoint zero = -m_cmp->m_Pos; // relative zero
918 
919  // If the field value is empty and the position is at relative zero, we
920  // set the initial position as a small offset from the ref field, and
921  // orient it the same as the ref field. That is likely to put it at least
922  // close to the desired position.
923  if( coord == zero && field.GetText().IsEmpty() )
924  {
925  rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetTextAngle() == TEXT_ANGLE_VERT );
926 
927  coord.x = m_FieldsBuf[REFERENCE].GetTextPos().x
928  + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
929 
930  coord.y = m_FieldsBuf[REFERENCE].GetTextPos().y
931  + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
932 
933  // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
934  // That is ok, we basically don't want all the new empty fields on
935  // top of each other.
936  }
937 
938  wxString coordText = StringFromValue( g_UserUnit, coord.x );
939  posXTextCtrl->SetValue( coordText );
940 
941  coordText = StringFromValue( g_UserUnit, coord.y );
942  posYTextCtrl->SetValue( coordText );
943 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:473
name of datasheet
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
bool IsItalic() const
Definition: eda_text.h:170
bool IsPower() const
int GetId() const
Definition: sch_field.h:87
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
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
int GetTextWidth() const
Definition: eda_text.h:218
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
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
Field Value of part, i.e. "3.3K".
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
bool IsVisible() const
Definition: eda_text.h:176
class SCH_FILED_VALIDATOR
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 DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 531 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldListCtrl, getSelectedFieldNdx(), m_FieldsBuf, m_skipCopyFromPanel, MANDATORY_FIELDS, setSelectedFieldNdx(), and updateDisplay().

532 {
533  unsigned fieldNdx = getSelectedFieldNdx();
534 
535  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
536  return;
537 
538  if( fieldNdx < MANDATORY_FIELDS )
539  {
540  wxBell();
541  return;
542  }
543 
544  m_skipCopyFromPanel = true;
545  m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
546  fieldListCtrl->DeleteItem( fieldNdx );
547 
548  if( fieldNdx >= m_FieldsBuf.size() )
549  --fieldNdx;
550 
551  updateDisplay();
552 
553  setSelectedFieldNdx( fieldNdx );
554  m_skipCopyFromPanel = false;
555 }
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
void updateDisplay()
Function updateDisplay update the listbox showing fields, according to the fields texts must be calle...
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::EditSpiceModel ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 295 of file dialog_edit_component_in_schematic.cpp.

References m_cmp, m_FieldsBuf, setSelectedFieldNdx(), and updateDisplay().

296 {
297 #ifdef KICAD_SPICE
298  setSelectedFieldNdx( 0 );
299  DIALOG_SPICE_MODEL dialog( this, *m_cmp, m_FieldsBuf );
300 
301  if( dialog.ShowModal() == wxID_OK )
302  updateDisplay();
303 #endif /* KICAD_SPICE */
304 }
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
void updateDisplay()
Function updateDisplay update the listbox showing fields, according to the fields texts must be calle...
bool DIALOG_SHIM::Enable ( bool  enable)
overrideinherited

Definition at line 181 of file dialog_shim.cpp.

Referenced by DIALOG_PRINT_USING_PRINTER::InitValues().

182 {
183  // so we can do logging of this state change:
184 
185 #if defined(DEBUG)
186  const char* type_id = typeid( *this ).name();
187  printf( "wxDialog %s: %s\n", type_id, enable ? "enabled" : "disabled" );
188 #endif
189 
190  return wxDialog::Enable( enable );
191 }
void DIALOG_SHIM::EndQuasiModal ( int  retCode)
inherited

Definition at line 539 of file dialog_shim.cpp.

References DIALOG_SHIM::IsQuasiModal(), DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, DIALOG_SHIM::m_qmodal_showing, and DIALOG_SHIM::Show().

Referenced by HK_PROMPT_DIALOG::EndFlexible(), DIALOG_SHIM::OnButton(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCancelButtonClick(), OnCancelButtonClick(), DIALOG_EDIT_ONE_FIELD::OnCancelClick(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCloseDialog(), DIALOG_EDIT_ONE_FIELD::OnCloseDialog(), OnCloseDialog(), DIALOG_CHOOSE_COMPONENT::OnCloseTimer(), DIALOG_SHIM::OnCloseWindow(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick(), OnOKButtonClick(), DIALOG_EDIT_ONE_FIELD::OnOkClick(), DIALOG_EXCHANGE_MODULE::OnQuit(), DIALOG_CHOOSE_COMPONENT::OnSchViewDClick(), SetInitCmp(), and DIALOG_SHIM::~DIALOG_SHIM().

540 {
541  // Hook up validator and transfer data from controls handling so quasi-modal dialogs
542  // handle validation in the same way as other dialogs.
543  if( ( retCode == wxID_OK ) && ( !Validate() || !TransferDataFromWindow() ) )
544  return;
545 
546  SetReturnCode( retCode );
547 
548  if( !IsQuasiModal() )
549  {
550  wxFAIL_MSG( wxT( "either DIALOG_SHIM::EndQuasiModal called twice or ShowQuasiModal wasn't called" ) );
551  return;
552  }
553 
554  m_qmodal_showing = false;
555 
556  if( m_qmodal_loop )
557  {
558  if( m_qmodal_loop->IsRunning() )
559  m_qmodal_loop->Exit( 0 );
560  else
561  m_qmodal_loop->ScheduleExit( 0 );
562 
563  m_qmodal_loop = NULL;
564  }
565 
568 
569  Show( false );
570 }
bool m_qmodal_showing
Definition: dialog_shim.h:132
EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:131
bool IsQuasiModal()
Definition: dialog_shim.h:93
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:133
SCH_FIELD * DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField ( const wxString &  aFieldName)
private

Definition at line 651 of file dialog_edit_component_in_schematic.cpp.

References m_FieldsBuf.

Referenced by InitBuffers().

652 {
653  for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
654  {
655  if( aFieldName == m_FieldsBuf[i].GetName( false ) )
656  return &m_FieldsBuf[i];
657  }
658 
659  return NULL;
660 }
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
void DIALOG_SHIM::FinishDialogSettings ( )
protectedinherited

In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls.

FinishDialogSettings must be called from derived classes, when all widgets are initialized, and therefore their size fixed. If TransferDataToWindow() is used to initialize widgets, at end of TransferDataToWindow, or better at end of a wxInitDialogEvent handler

In any case, the best way is to call it in a wxInitDialogEvent handler after calling TransfertDataToWindow(), which is the default wxInitDialogEvent handler wxDialog

Definition at line 103 of file dialog_shim.cpp.

References PCAD2KICAD::Center.

Referenced by DIALOG_BOM::DIALOG_BOM(), DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE(), DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES(), DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS(), DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS(), DIALOG_ENUM_PADS::DIALOG_ENUM_PADS(), DIALOG_EXPORT_3DFILE::DIALOG_EXPORT_3DFILE(), DIALOG_EXPORT_IDF3::DIALOG_EXPORT_IDF3(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST(), DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES(), DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR(), DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM(), DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT(), DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT(), DIALOG_LIBEDIT_OPTIONS::DIALOG_LIBEDIT_OPTIONS(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN(), DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS(), DIALOG_SELECT_PRETTY_LIB::DIALOG_SELECT_PRETTY_LIB(), DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE(), DIALOG_EDIT_ONE_FIELD::init(), NETLIST_DIALOG::NETLIST_DIALOG(), DIALOG_LIB_EDIT_PIN::OnInitDialog(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog(), DIALOG_TRACK_VIA_PROPERTIES::OnInitDlg(), DIALOG_GRAPHIC_ITEMS_OPTIONS::OnInitDlg(), DialogEditModuleText::OnInitDlg(), DIALOG_SET_GRID::OnInitDlg(), DIALOG_PCB_TEXT_PROPERTIES::OnInitDlg(), DIALOG_PRINT_FOR_MODEDIT::OnInitDlg(), DIALOG_GRAPHIC_ITEM_PROPERTIES::OnInitDlg(), DIALOG_MODULE_MODULE_EDITOR::OnInitDlg(), DIALOG_SIM_SETTINGS::onInitDlg(), DIALOG_SPICE_MODEL::onInitDlg(), DIALOG_MODULE_BOARD_EDITOR::OnInitDlg(), DIALOG_PRINT_USING_PRINTER::OnInitDlg(), OnInitDlg(), TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR(), and DIALOG_SIGNAL_LIST::TransferDataToWindow().

104 {
105  // must be called from the constructor of derived classes,
106  // when all widgets are initialized, and therefore their size fixed
107 
108  // SetSizeHints fixes the minimal size of sizers in the dialog
109  // (SetSizeHints calls Fit(), so no need to call it)
110  GetSizer()->SetSizeHints( this );
111 
112  // the default position, when calling the first time the dlg
113  Center();
114 }
void DIALOG_SHIM::FixOSXCancelButtonIssue ( )
protectedinherited

A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms.

Definition at line 116 of file dialog_shim.cpp.

Referenced by DIALOG_SHIM::Show().

117 {
118 #ifdef __WXMAC__
119  // A ugly hack to fix an issue on OSX: ctrl+c closes the dialog instead of
120  // copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer
121  // created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority
122  // to copy text standard accelerator, and the dlg is closed when trying to copy text
123  wxButton* button = dynamic_cast< wxButton* > ( wxWindow::FindWindowById( wxID_CANCEL, this ) );
124 
125  if( button )
126  button->SetLabel( _( "Cancel" ) );
127 #endif
128 }
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx ( )
private
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers ( SCH_COMPONENT aComponent)

Function InitBuffers sets up to edit the given component.

Parameters
aComponentThe component to edit.

Definition at line 663 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::chipnameTextCtrl, copyOptionsToPanel(), copySelectedFieldToPanel(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldListCtrl, findField(), SCH_COMPONENT::FindField(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_COMPONENT::GetFieldCount(), SCH_COMPONENT::GetLibId(), SCH_FIELD::GetName(), SCH_COMPONENT::GetRef(), SCH_EDIT_FRAME::GetTemplateFieldNames(), EDA_ITEM::IsDragging(), m_cmp, SCH_COMPONENT::m_Fields, m_FieldsBuf, m_parent, m_part, SCH_COMPONENT::m_Pos, MANDATORY_FIELDS, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::mirrorRadioBox, EDA_TEXT::Offset(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::orientationRadioBox, KIWAY_HOLDER::Prj(), REFERENCE, s_SelectedRow, setRowItem(), setSelectedFieldNdx(), EDA_TEXT::SetText(), EDA_TEXT::SetVisible(), and TO_UTF8.

Referenced by SCH_EDIT_FRAME::EditComponent().

664 {
665  m_cmp = aComponent;
666 
667  /* We have 3 component related field lists to be aware of: 1) UI
668  presentation, 2) fields in component ram copy, and 3) fields recorded
669  with component on disk. m_FieldsBuf is the list of UI fields, and this
670  list is not the same as the list which is in the component, which is
671  also not the same as the list on disk. All 3 lists are potentially
672  different. In the UI we choose to preserve the order of the first
673  MANDATORY_FIELDS which are sometimes called fixed fields. Then we append
674  the template fieldnames in the exact same order as the template
675  fieldname editor shows them. Then we append any user defined fieldnames
676  which came from the component.
677  */
678 
679  m_part = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() );
680 
681 #if 0 && defined(DEBUG)
682  for( int i = 0; i<aComponent->GetFieldCount(); ++i )
683  {
684  printf( "Orig[%d] (x=%d, y=%d)\n", i,
685  aComponent->m_Fields[i].GetTextPos().x,
686  aComponent->m_Fields[i].GetTextPos().y );
687  }
688 
689 #endif
690 
691  // When this code was written, all field constructors ensure that the fixed fields
692  // are all present within a component. So we can knowingly copy them over
693  // in the normal order. Copy only the fixed fields at first.
694  // Please do not break the field constructors.
695 
696  m_FieldsBuf.clear();
697 
698  for( int i=0; i<MANDATORY_FIELDS; ++i )
699  {
700  m_FieldsBuf.push_back( aComponent->m_Fields[i] );
701 
702  // make the editable field position relative to the component
703  m_FieldsBuf[i].Offset( -m_cmp->m_Pos );
704  }
705 
706  // Add template fieldnames:
707  // Now copy in the template fields, in the order that they are present in the
708  // template field editor UI.
710 
711  for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
712  {
713  // add a new field unconditionally to the UI only
714  SCH_FIELD fld( wxPoint(0,0), -1 /* id is a relic */, m_cmp, it->m_Name );
715 
716  // See if field by same name already exists in component.
717  SCH_FIELD* schField = aComponent->FindField( it->m_Name );
718 
719  // If the field does not already exist in the component, then we
720  // use defaults from the template fieldname, otherwise the original
721  // values from the component will be set.
722  if( !schField )
723  {
724  if( !it->m_Visible )
725  fld.SetVisible( false );
726  else
727  fld.SetVisible( true );
728 
729  fld.SetText( it->m_Value ); // empty? ok too.
730  }
731  else
732  {
733  fld = *schField;
734 
735  // make the editable field position relative to the component
736  fld.Offset( -m_cmp->m_Pos );
737  }
738 
739  m_FieldsBuf.push_back( fld );
740  }
741 
742  // Lastly, append any original fields from the component which were not added
743  // from the set of fixed fields nor from the set of template fields.
744  for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i )
745  {
746  SCH_FIELD* cmp = &aComponent->m_Fields[i];
747  SCH_FIELD* buf = findField( cmp->GetName( false ) );
748 
749  if( !buf )
750  {
751  int newNdx = m_FieldsBuf.size();
752  m_FieldsBuf.push_back( *cmp );
753 
754  // make the editable field position relative to the component
755  m_FieldsBuf[newNdx].Offset( -m_cmp->m_Pos );
756  }
757  }
758 
759 
760 #if 0 && defined(DEBUG)
761  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
762  {
763  printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
764  m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) );
765  }
766 #endif
767 
769 
770  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
771  {
772  setRowItem( i, m_FieldsBuf[i] );
773  }
774 
775 #if 0 && defined(DEBUG)
776  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
777  {
778  printf( "after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
779  m_FieldsBuf[i].m_Pos.y );
780  }
781 
782 #endif
783 
785 
786  // disable some options inside the edit dialog
787  // which can cause problems while dragging
788  if( m_cmp->IsDragging() )
789  {
790  orientationRadioBox->Disable();
791  mirrorRadioBox->Disable();
792  chipnameTextCtrl->Disable();
793  }
794 
795  // put focus on the list ctrl
796  fieldListCtrl->SetFocus();
797 
798  // resume editing at the last row edited, last time dialog was up.
800 
802 }
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
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:473
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
SCH_FIELD * findField(const wxString &aFieldName)
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
void SetVisible(bool aVisible)
Definition: eda_text.h:175
SCH_FIELD * FindField(const wxString &aFieldName)
Function FindField searches for SCH_FIELD with aFieldName and returns it if found, else NULL.
Field Reference of part, i.e. "IC21".
#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)
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:565
const wxString GetRef(const SCH_SHEET_PATH *sheet)
Function GetRef returns the reference, for the given sheet path.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Function GetTemplateFieldName returns a template field names list for read only access.
Definition: schframe.h:327
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
const LIB_ID & GetLibId() const
void copySelectedFieldToPanel()
Function copySelectedFieldToPanel sets the values displayed on the panel according to the currently s...
bool IsDragging() const
Definition: base_struct.h:219
KIWAY& KIWAY_HOLDER::Kiway ( ) const
inlineinherited

Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in.

A KIWAY_HOLDER is not necessarily a KIWAY_PLAYER.

Definition at line 60 of file kiway_player.h.

References KIWAY_HOLDER::m_kiway.

Referenced by SCH_EDIT_FRAME::AppendOneEEProject(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), CVPCB_MAINFRAME::CreateScreenCmp(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_SHIM::DIALOG_SHIM(), EDIT_TOOL::editFootprintInFpEditor(), SCH_EDIT_FRAME::EditSheet(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_EDIT_FRAME::GetPlotSettings(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers(), LIB_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallModuleOptionsFrame(), KIWAY_PLAYER::language_change(), SCH_SHEET::Load(), CVPCB_MAINFRAME::LoadFootprintFiles(), KIWAY_PLAYER::OnChangeIconsOptions(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnLeftClick(), SCH_BASE_FRAME::OnOpenLibraryViewer(), SCH_EDIT_FRAME::OnSimulate(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard(), SCH_EDIT_FRAME::OpenProjectFiles(), KIWAY_HOLDER::Prj(), PCB_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_EDIT_FRAME::refreshSchematic(), SCH_EDIT_FRAME::SaveEEFile(), CVPCB_MAINFRAME::SaveFootprintAssociation(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_EDIT_FRAME::SetPlotSettings(), DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame(), FOOTPRINT_VIEWER_FRAME::Show3D_Frame(), FOOTPRINT_EDIT_FRAME::Show3D_Frame(), FOOTPRINT_WIZARD_FRAME::Show3D_Frame(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler(), showButtonHandler(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint().

61  {
62  wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
63  return *m_kiway;
64  }
KIWAY * m_kiway
Definition: kiway_player.h:85
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 587 of file dialog_edit_component_in_schematic.cpp.

References copyPanelToSelectedField(), DBG, SCH_FIELD::GetName(), getSelectedFieldNdx(), EDA_TEXT::GetText(), m_FieldsBuf, m_skipCopyFromPanel, MANDATORY_FIELDS, setRowItem(), setSelectedFieldNdx(), TO_UTF8, and updateDisplay().

588 {
589  unsigned fieldNdx = getSelectedFieldNdx();
590 
591  if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
592  return;
593 
594  if( fieldNdx <= MANDATORY_FIELDS )
595  {
596  wxBell();
597  return;
598  }
599 
600  if( !copyPanelToSelectedField() )
601  return;
602 
603  // swap the fieldNdx field with the one before it, in both the vector
604  // and in the fieldListCtrl
605  SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
606 
607  DBG( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
608  TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); )
609 
610  m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
611  setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
612 
613  m_FieldsBuf[fieldNdx] = tmp;
614  setRowItem( fieldNdx, tmp );
615 
616  updateDisplay();
617 
618  m_skipCopyFromPanel = true;
619  setSelectedFieldNdx( fieldNdx - 1 );
620  m_skipCopyFromPanel = false;
621 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
bool copyPanelToSelectedField()
Function copyPanelToSelectedField copies the values displayed on the panel fields to the currently se...
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:473
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
#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)
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
void updateDisplay()
Function updateDisplay update the listbox showing fields, according to the fields texts must be calle...
#define DBG(x)
Definition: fctsys.h:33
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 330 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_SHIM::EndQuasiModal().

331 {
332  EndQuasiModal( wxID_CANCEL );
333 }
void EndQuasiModal(int retCode)
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCloseDialog ( wxCloseEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 318 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_SHIM::EndQuasiModal().

319 {
320  // On wxWidgets 2.8, and on Linux, calling EndQuasiModal here is mandatory
321  // Otherwise, the main event loop is never restored, and Eeschema does not
322  // respond to any event, because the DIALOG_SHIM destructor is never called.
323  // On wxWidgets 3.0, or on Windows, the DIALOG_SHIM destructor is called,
324  // and calls EndQuasiModal.
325  // therefore calling EndQuasiModal here is not always mandatory but it creates no issues
326  EndQuasiModal( wxID_CANCEL );
327 }
void EndQuasiModal(int retCode)
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnInitDlg ( wxInitDialogEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 133 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_SHIM::FinishDialogSettings().

134  {
135  TransferDataToWindow();
136 
137  // Now all widgets have the size fixed, call FinishDialogSettings
139  }
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected ( wxListEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 227 of file dialog_edit_component_in_schematic.cpp.

References copyPanelToSelectedField(), and m_skipCopyFromPanel.

228 {
229  if( !m_skipCopyFromPanel )
230  {
231  if( !copyPanelToSelectedField() )
232  event.Skip(); // do not go to the next row
233  }
234 }
bool copyPanelToSelectedField()
Function copyPanelToSelectedField copies the values displayed on the panel fields to the currently se...
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected ( wxListEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 307 of file dialog_edit_component_in_schematic.cpp.

References copySelectedFieldToPanel(), DBG, and s_SelectedRow.

308 {
309  DBG( printf( "OnListItemSelected()\n" ); )
310 
311  // remember the selected row, statically
312  s_SelectedRow = event.GetIndex();
313 
315 }
void copySelectedFieldToPanel()
Function copySelectedFieldToPanel sets the values displayed on the panel according to the currently s...
#define DBG(x)
Definition: fctsys.h:33
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 424 of file dialog_edit_component_in_schematic.cpp.

References copyPanelToOptions(), copyPanelToSelectedField(), DisplayError(), DIALOG_SHIM::EndQuasiModal(), Format(), GetChars(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibItemName(), SCH_EDIT_FRAME::GetScreen(), BLOCK_SELECTOR::GetState(), SCH_EDIT_FRAME::GetTemplates(), GetText(), TEMPLATES::HasFieldName(), LIB_PART::IsPower(), SCH_COMPONENT::IsReferenceStringValid(), BASE_SCREEN::m_BlockLocate, m_cmp, m_FieldsBuf, m_parent, SCH_COMPONENT::m_Pos, MANDATORY_FIELDS, SCH_EDIT_FRAME::OnModify(), KIWAY_HOLDER::Prj(), REFERENCE, SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_COMPONENT::SetFields(), SCH_COMPONENT::SetRef(), STATE_NO_BLOCK, SCH_SCREEN::TestDanglingEnds(), UR_CHANGED, and VALUE.

425 {
426  bool removeRemainingFields = false;
427 
428  if( !copyPanelToSelectedField() )
429  return;
430 
432  {
433  DisplayError( NULL, _( "Illegal reference. A reference must start with a letter" ) );
434  return;
435  }
436 
437  // save old cmp in undo list if not already in edit, or moving ...
438  // or the component to be edited is part of a block
439  if( m_cmp->GetFlags() == 0
442 
444 
445  // Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
446  for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); )
447  {
448  if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() )
449  {
450  // If a field has no value and is not it the field template list, warn the user
451  // that it will be remove from the component. This gives the user a chance to
452  // correct the problem before removing the undefined fields. It should also
453  // resolve most of the bug reports and questions regarding missing fields.
454  if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty()
455  && !m_parent->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) )
456  && !removeRemainingFields )
457  {
458  wxString msg = wxString::Format(
459  _( "The field name <%s> does not have a value and is not defined in "
460  "the field template list. Empty field values are invalid an will "
461  "be removed from the component. Do you wish to remove this and "
462  "all remaining undefined fields?" ),
463  GetChars( m_FieldsBuf[i].GetName( false ) )
464  );
465 
466  wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT );
467 
468  if( dlg.ShowModal() == wxID_NO )
469  return;
470 
471  removeRemainingFields = true;
472  }
473 
474  m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
475  continue;
476  }
477 
478  ++i;
479  }
480 
481  // change all field positions from relative to absolute
482  for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
483  {
484  m_FieldsBuf[i].Offset( m_cmp->m_Pos );
485  }
486 
487  LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() );
488 
489  if( entry && entry->IsPower() )
490  m_FieldsBuf[VALUE].SetText( m_cmp->GetLibId().GetLibItemName() );
491 
492  // copy all the fields back, and change the length of m_Fields.
494 
495  // Reference has a specific initialization, depending on the current active sheet
496  // because for a given component, in a complex hierarchy, there are more than one
497  // reference.
499 
500  m_parent->OnModify();
502 
503  EndQuasiModal( wxID_OK );
504 }
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:255
bool copyPanelToSelectedField()
Function copyPanelToSelectedField copies the values displayed on the panel fields to the currently se...
const TEMPLATES & GetTemplates()
Function GetTemplates returns the field names template for read only access.
Definition: schframe.h:337
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
bool IsPower() const
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))
Function SaveCopyInUndoList.
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:761
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
void SetRef(const SCH_SHEET_PATH *sheet, const wxString &ref)
Set the reference, for the given sheet path.
Field Reference of part, i.e. "IC21".
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:520
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void SetFields(const SCH_FIELDS &aFields)
const UTF8 & GetLibItemName() const
Function GetLibItemName.
Definition: lib_id.h:129
SCH_SHEET_PATH & GetCurrentSheet()
Definition: schframe.cpp:565
Class LIB_PART defines a library part object.
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
Field Value of part, i.e. "3.3K".
void EndQuasiModal(int retCode)
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
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
BLOCK_STATE_T GetState() const
bool TestDanglingEnds()
Function TestDanglingEnds tests all of the connectible objects in the schematic for unused connection...
Definition: sch_screen.cpp:911
const LIB_ID & GetLibId() const
static bool IsReferenceStringValid(const wxString &aReferenceString)
Function IsReferenceStringValid (static) Tests for an acceptable reference string An acceptable refer...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnSelectChipName ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 282 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::chipnameTextCtrl, dummy(), m_parent, and SCH_BASE_FRAME::SelectComponentFromLibrary().

283 {
285 
286  auto sel = m_parent->SelectComponentFromLibrary( NULL, dummy, true, 0, 0 );
287 
288  if( sel.Name.IsEmpty() )
289  return;
290 
291  chipnameTextCtrl->SetValue( sel.Name );
292 }
std::vector< COMPONENT_SELECTION > HISTORY_LIST
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...
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
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 236 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::chipnameTextCtrl, Format(), GetChars(), LIB_PART::GetLibraryName(), and KIWAY_HOLDER::Prj().

237 {
238  wxString partname = chipnameTextCtrl->GetValue();
239  LIB_PART* entry = Prj().SchLibs()->FindLibPart( partname );
240 
241  wxString msg;
242 
243  if( entry )
244  {
245  msg.Printf( _( "Component '%s' found in library '%s'" ),
246  GetChars( partname ), GetChars( entry->GetLibraryName() ) );
247  wxMessageBox( msg );
248  return;
249  }
250 
251  msg.Printf( _( "Component '%s' not found in any library" ), GetChars( partname ) );
252 
253  // Try to find components which have a name "near" the current chip name,
254  // i.e. the same name when the comparison is case insensitive.
255  // Could be helpful for old designs when lower cases and upper case were
256  // equivalent.
257  std::vector<LIB_ALIAS*> candidates;
258  Prj().SchLibs()->FindLibraryNearEntries( candidates, partname );
259 
260  if( candidates.size() == 0 )
261  {
262  wxMessageBox( msg );
263  return;
264  }
265 
266  // Some candidates are found. Show them:
267  msg << wxT("\n") << _( "However, some candidates are found:" );
268 
269  // add candidate names:
270  for( unsigned ii = 0; ii < candidates.size(); ii++ )
271  {
272  msg << wxT("\n") <<
273  wxString::Format( _( "'%s' found in library '%s'" ),
274  GetChars( candidates[ii]->GetName() ),
275  GetChars( candidates[ii]->GetLibraryName() ) );
276  }
277 
278  wxMessageBox( msg );
279 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
Class LIB_PART defines a library part object.
const wxString GetLibraryName()
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
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
PROJECT & KIWAY_HOLDER::Prj ( ) const
inherited

Function Prj returns a reference to the PROJECT "associated with" this KIWAY.

Definition at line 34 of file kiway_holder.cpp.

References KIWAY_HOLDER::Kiway(), and KIWAY::Prj().

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::AppendOneEEProject(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), LIB_VIEW_FRAME::BestZoom(), DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile(), DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_MODULE_MODULE_EDITOR::Cfg3DPath(), DIALOG_MODULE_BOARD_EDITOR::Cfg3DPath(), SCH_EDIT_FRAME::CheckAnnotate(), SCH_SCREEN::CheckComponentsToPartsLinks(), SCH_EDIT_FRAME::ConvertPart(), copyPanelToOptions(), SCH_EDIT_FRAME::CreateArchiveLibrary(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), LIB_EDIT_FRAME::DeleteOnePart(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG(), DIALOG_FP_LIB_TABLE::DIALOG_FP_LIB_TABLE(), DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR(), DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), LIB_VIEW_FRAME::DisplayLibInfos(), SCH_BASE_FRAME::DisplayListComponentsInLib(), PCB_EDIT_FRAME::doAutoSave(), DIALOG_MODULE_MODULE_EDITOR::Edit3DShapeFileName(), DIALOG_MODULE_BOARD_EDITOR::Edit3DShapeFileName(), SCH_EDIT_FRAME::EditComponentFieldText(), SCH_EDIT_FRAME::EditSheet(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::ExportToGenCAD(), PCB_EDIT_FRAME::ExportVRML_File(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::GenD356File(), DIALOG_GENDRILL::GenDrillAndMapFiles(), NETLIST_DIALOG::GenNetlist(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), LIB_EDIT_FRAME::GetCurPart(), FOOTPRINT_EDIT_FRAME::GetCurrentLib(), FOOTPRINT_EDIT_FRAME::getLibPath(), DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable(), DIALOG_BOM::getPluginFileName(), LIB_VIEW_FRAME::getSelectedAlias(), FP_THREAD_IFACE::GetTable(), InitBuffers(), DIALOG_MODULE_MODULE_EDITOR::initModeditProperties(), DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties(), LIB_EDIT_FRAME::InstallConfigFrame(), SCH_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallNetlistFrame(), SCH_EDIT_FRAME::IsSearchCacheObsolete(), SCH_EDIT_FRAME::Load_Component(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), CVPCB_MAINFRAME::LoadFootprintFiles(), SCH_EDIT_FRAME::LoadOneEEFile(), LIB_EDIT_FRAME::LoadOneLibraryPart(), LIB_EDIT_FRAME::LoadOneSymbol(), CVPCB_MAINFRAME::LoadProjectFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), DIALOG_DRC_CONTROL::makeValidFileNameReport(), FOOTPRINT_VIEWER_FRAME::OnActivate(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath(), DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick(), LIB_EDIT_FRAME::OnCloseWindow(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_GENDRILL::OnGenReportFile(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), PCB_EDIT_FRAME::OnLeftClick(), OnOKButtonClick(), DIALOG_NETLIST::OnOpenNetlistClick(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), SCH_EDIT_FRAME::OnRightClick(), DIALOG_BOM::OnRunPlugin(), DIALOG_NETLIST::OnSaveMessagesToFile(), SCH_EDIT_FRAME::OnSaveProject(), DIALOG_SPICE_MODEL::onSelectIcLib(), LIB_VIEW_FRAME::OnSelectSymbol(), SCH_EDIT_FRAME::OnSelectUnit(), DIALOG_SPICE_MODEL::onSemiSelectLib(), OnTestChipName(), FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib(), LIB_EDIT_FRAME::OnViewEntryDoc(), LIB_VIEW_FRAME::onViewSymbolDocument(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::PasteListOfItems(), PCB_EDITOR_CONTROL::PlaceModule(), SCH_EDIT_FRAME::prepareForNetlist(), SCH_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_VIEW_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListCmp(), LIB_VIEW_FRAME::ReCreateListLib(), LIB_VIEW_FRAME::RedrawActiveWindow(), EDA_3D_VIEWER::ReloadRequest(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), SCH_EDIT_FRAME::RescueProject(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_SCREEN::Save(), LIB_EDIT_FRAME::SaveActiveLibrary(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), CVPCB_MAINFRAME::SaveProjectFile(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), SCH_BASE_FRAME::SelectComponentFromLibrary(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), LIB_EDIT_FRAME::SetCurPart(), SetInitCmp(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), EDA_3D_VIEWER::takeScreenshot(), DIALOG_ERC::TestErc(), DIALOG_SPICE_MODEL::updateFromFile(), SIM_PLOT_FRAME::updateNetlistExporter(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), CVPCB_MAINFRAME::UpdateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR(), and DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR().

35 {
36  return Kiway().Prj();
37 }
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
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:144
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 1094 of file dialog_edit_component_in_schematic.cpp.

References CMP_NORMAL, DATASHEET, SCH_COMPONENT::Draw(), DIALOG_SHIM::EndQuasiModal(), FOOTPRINT, g_XorMode, EDA_DRAW_FRAME::GetCanvas(), SCH_COMPONENT::GetField(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetLibId(), EDA_TEXT::GetTextPos(), GR_DEFAULT_DRAWMODE, SCH_FIELD::ImportValues(), INSTALL_UNBUFFERED_DC, m_cmp, m_parent, SCH_COMPONENT::m_Pos, SCH_EDIT_FRAME::OnModify(), KIWAY_HOLDER::Prj(), REFERENCE, SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_COMPONENT::SetOrientation(), EDA_TEXT::SetTextPos(), UR_CHANGED, and VALUE.

1095 {
1096  if( !m_cmp )
1097  return;
1098 
1099  if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_cmp->GetLibId() ) )
1100  {
1101  // save old cmp in undo list if not already in edit, or moving ...
1102  if( m_cmp->GetFlags() == 0 )
1104 
1106  m_cmp->Draw( m_parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
1107 
1108  // Initialize fixed field values to default values found in library
1109  // Note: the field texts are not modified because they are set in schematic,
1110  // the text from libraries is most of time a dummy text
1111  // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
1112  LIB_FIELD& refField = part->GetReferenceField();
1113 
1114  m_cmp->GetField( REFERENCE )->SetTextPos( refField.GetTextPos() + m_cmp->m_Pos );
1115  m_cmp->GetField( REFERENCE )->ImportValues( refField );
1116 
1117  LIB_FIELD& valField = part->GetValueField();
1118 
1119  m_cmp->GetField( VALUE )->SetTextPos( valField.GetTextPos() + m_cmp->m_Pos );
1120  m_cmp->GetField( VALUE )->ImportValues( valField );
1121 
1122  LIB_FIELD* field = part->GetField(FOOTPRINT);
1123 
1124  if( field && m_cmp->GetField( FOOTPRINT ) )
1125  {
1126  m_cmp->GetField( FOOTPRINT )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
1127  m_cmp->GetField( FOOTPRINT )->ImportValues( *field );
1128  }
1129 
1130  field = part->GetField(DATASHEET);
1131 
1132  if( field && m_cmp->GetField( DATASHEET ) )
1133  {
1134  m_cmp->GetField( DATASHEET )->SetTextPos( field->GetTextPos() + m_cmp->m_Pos );
1135  m_cmp->GetField( DATASHEET )->ImportValues( *field );
1136  }
1137 
1139 
1140  m_parent->OnModify();
1141 
1142  m_cmp->Draw( m_parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
1143 
1144  EndQuasiModal( wxID_OK );
1145  }
1146 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:255
name of datasheet
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))
Function SaveCopyInUndoList.
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:761
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:221
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
Class LIB_FIELD is used in symbol libraries.
Definition: lib_field.h:60
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
Class LIB_PART defines a library part object.
Field Value of part, i.e. "3.3K".
void EndQuasiModal(int retCode)
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
#define INSTALL_UNBUFFERED_DC(name, parent)
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.
const LIB_ID & GetLibId() const
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
void KIWAY_HOLDER::SetKiway ( wxWindow *  aDest,
KIWAY aKiway 
)
inherited

Function SetKiway.

Parameters
aDestis the recipient of aKiway pointer. It is only used for debugging, since "this" is not a wxWindow*. "this" is a KIWAY_HOLDER mix-in.
aKiwayis often from a parent window, or from KIFACE::CreateWindow().

Definition at line 41 of file kiway_holder.cpp.

References KIWAY_HOLDER::m_kiway, and name.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

42 {
43 #if defined(DEBUG)
44  // offer a trap point for debugging most any window
45  wxASSERT( aDest );
46  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
47  {
48  int breakhere=1;
49  (void) breakhere;
50  }
51 #endif
52 
53  (void) aDest;
54 
55  m_kiway = aKiway;
56 }
KIWAY * m_kiway
Definition: kiway_player.h:85
const char * name
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem ( int  aFieldNdx,
const wxString &  aName,
const wxString &  aValue 
)
private

Definition at line 805 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldListCtrl.

Referenced by addFieldButtonHandler(), copyPanelToSelectedField(), InitBuffers(), moveUpButtonHandler(), setRowItem(), showButtonHandler(), and updateDisplay().

806 {
807  wxASSERT( aFieldNdx >= 0 );
808 
809  // insert blanks if aFieldNdx is referencing a "yet to be defined" row
810  while( aFieldNdx >= fieldListCtrl->GetItemCount() )
811  {
812  long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
813 
814  wxASSERT( ndx >= 0 );
815 
816  fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
817  }
818 
819  fieldListCtrl->SetItem( aFieldNdx, 0, aName );
820  fieldListCtrl->SetItem( aFieldNdx, 1, aValue );
821 
822  // recompute the column widths here, after setting texts
823  fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
824  fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
825 }
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem ( int  aFieldNdx,
const SCH_FIELD aField 
)
inlineprivate

Definition at line 115 of file dialog_edit_component_in_schematic.cpp.

References SCH_FIELD::GetName(), EDA_TEXT::GetText(), and setRowItem().

116  {
117  setRowItem( aFieldNdx, aField.GetName( false ), aField.GetText() );
118  }
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:473
void setRowItem(int aFieldNdx, const wxString &aName, const wxString &aValue)
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx ( int  aFieldNdx)
private

Definition at line 624 of file dialog_edit_component_in_schematic.cpp.

References DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldListCtrl, m_FieldsBuf, and s_SelectedRow.

Referenced by addFieldButtonHandler(), deleteFieldButtonHandler(), EditSpiceModel(), InitBuffers(), and moveUpButtonHandler().

625 {
626  /* deselect old selection, but I think this is done by single selection
627  * flag within fieldListCtrl.
628  * fieldListCtrl->SetItemState( s_SelectedRow, 0,
629  * wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
630  */
631 
632  if( aFieldNdx >= (int) m_FieldsBuf.size() )
633  aFieldNdx = m_FieldsBuf.size() - 1;
634 
635  if( aFieldNdx < 0 )
636  aFieldNdx = 0;
637 
638  fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
639  fieldListCtrl->EnsureVisible( aFieldNdx );
640 
641  s_SelectedRow = aFieldNdx;
642 }
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
bool DIALOG_SHIM::Show ( bool  show)
overrideinherited

Definition at line 138 of file dialog_shim.cpp.

References class_map, DIALOG_SHIM::FixOSXCancelButtonIssue(), EDA_RECT::GetPosition(), EDA_RECT::GetSize(), DIALOG_SHIM::m_hash_key, wxPoint::x, and wxPoint::y.

Referenced by DisplayHotkeyList(), DIALOG_SHIM::EndQuasiModal(), InvokeDialogERC(), DIALOG_SCH_FIND::OnCancel(), DIALOG_DRC_CONTROL::OnLeftDClickClearance(), DIALOG_DRC_CONTROL::OnLeftDClickUnconnected(), DIALOG_DRC_CONTROL::OnPopupMenu(), DIALOG_EXCHANGE_MODULE::OnQuit(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), DRC::ShowDRCDialog(), and DIALOG_SHIM::ShowQuasiModal().

139 {
140  bool ret;
141  const char* hash_key;
142 
143  if( m_hash_key.size() )
144  {
145  // a special case like EDA_LIST_DIALOG, which has multiple uses.
146  hash_key = m_hash_key.c_str();
147  }
148  else
149  {
150  hash_key = typeid(*this).name();
151  }
152 
153  // Show or hide the window. If hiding, save current position and size.
154  // If showing, use previous position and size.
155  if( show )
156  {
157  wxDialog::Raise(); // Needed on OS X and some other window managers (i.e. Unity)
158  ret = wxDialog::Show( show );
159 
160  // classname is key, returns a zeroed out default EDA_RECT if none existed before.
161  EDA_RECT r = class_map[ hash_key ];
162 
163  if( r.GetSize().x != 0 && r.GetSize().y != 0 )
164  SetSize( r.GetPosition().x, r.GetPosition().y, r.GetSize().x, r.GetSize().y, 0 );
165  }
166  else
167  {
168  // Save the dialog's position & size before hiding, using classname as key
169  EDA_RECT r( wxDialog::GetPosition(), wxDialog::GetSize() );
170  class_map[ hash_key ] = r;
171 
172  ret = wxDialog::Show( show );
173  }
174 
176 
177  return ret;
178 }
std::string m_hash_key
Definition: dialog_shim.h:128
void FixOSXCancelButtonIssue()
A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms.
static RECT_MAP class_map
const wxPoint & GetPosition() const
Class EDA_RECT handles the component boundary box.
const wxSize & GetSize() const
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP.

Definition at line 558 of file dialog_edit_component_in_schematic.cpp.

References DATASHEET, KIWAY_PLAYER::Destroy(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldValueTextCtrl, FOOTPRINT, FRAME_PCB_MODULE_VIEWER_MODAL, getSelectedFieldNdx(), KIWAY_HOLDER::Kiway(), m_FieldsBuf, m_parent, KIWAY::Player(), setRowItem(), and KIWAY_PLAYER::ShowModal().

559 {
560  unsigned fieldNdx = getSelectedFieldNdx();
561 
562  if( fieldNdx == DATASHEET )
563  {
564  wxString datasheet_uri = fieldValueTextCtrl->GetValue();
565  ::wxLaunchDefaultBrowser( datasheet_uri );
566  }
567  else if( fieldNdx == FOOTPRINT )
568  {
569  // pick a footprint using the footprint picker.
570  wxString fpid;
571 
573 
574  if( frame->ShowModal( &fpid, this ) )
575  {
576  // DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
577  fieldValueTextCtrl->SetValue( fpid );
578 
579  setRowItem( fieldNdx, m_FieldsBuf[fieldNdx].GetName( false ), fpid );
580  }
581 
582  frame->Destroy();
583  }
584 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
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
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
Field Name Module PCB, i.e. "16DIP300".
void setRowItem(int aFieldNdx, const wxString &aName, const wxString &aValue)
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
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
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...
int DIALOG_SHIM::ShowQuasiModal ( )
inherited

Definition at line 494 of file dialog_shim.cpp.

References DBG, DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, DIALOG_SHIM::m_qmodal_showing, and DIALOG_SHIM::Show().

Referenced by LIB_EDIT_FRAME::DeleteOnePart(), SCH_EDIT_FRAME::EditComponent(), SCH_EDIT_FRAME::EditComponentFieldText(), LIB_EDIT_FRAME::EditField(), EDIT_TOOL::ExchangeFootprints(), PCB_EDIT_FRAME::InstallExchangeModuleFrame(), LIB_EDIT_FRAME::InstallFieldsEditorDialog(), LIB_VIEW_FRAME::OnSelectSymbol(), and SCH_BASE_FRAME::SelectComponentFromLibrary().

495 {
496  // This is an exception safe way to zero a pointer before returning.
497  // Yes, even though DismissModal() clears this first normally, this is
498  // here in case there's an exception before the dialog is dismissed.
499  struct NULLER
500  {
501  void*& m_what;
502  NULLER( void*& aPtr ) : m_what( aPtr ) {}
503  ~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
504  } clear_this( (void*&) m_qmodal_loop );
505 
506  // release the mouse if it's currently captured as the window having it
507  // will be disabled when this dialog is shown -- but will still keep the
508  // capture making it impossible to do anything in the modal dialog itself
509  wxWindow* win = wxWindow::GetCapture();
510  if( win )
511  win->ReleaseMouse();
512 
513  // Get the optimal parent
514  wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );
515 
516  // Show the optimal parent
517  DBG( if( parent ) printf( "%s: optimal parent: %s\n", __func__, typeid(*parent).name() );)
518 
519  wxASSERT_MSG( !m_qmodal_parent_disabler,
520  wxT( "Caller using ShowQuasiModal() twice on same window?" ) );
521 
522  // quasi-modal: disable only my "optimal" parent
524 
525  Show( true );
526 
527  m_qmodal_showing = true;
528 
529  EVENT_LOOP event_loop;
530 
531  m_qmodal_loop = &event_loop;
532 
533  event_loop.Run();
534 
535  return GetReturnCode();
536 }
bool m_qmodal_showing
Definition: dialog_shim.h:132
EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:131
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:133
Toggle a window's "enable" status to disabled, then enabled on destruction.
Definition: dialog_shim.cpp:33
#define DBG(x)
Definition: fctsys.h:33
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::updateDisplay ( )
inlineprivate

Function updateDisplay update the listbox showing fields, according to the fields texts must be called after a text change in fields, if this change is not an edition.

Definition at line 150 of file dialog_edit_component_in_schematic.cpp.

References FIELD1, and setRowItem().

Referenced by deleteFieldButtonHandler(), EditSpiceModel(), and moveUpButtonHandler().

151  {
152  for( unsigned ii = FIELD1; ii<m_FieldsBuf.size(); ii++ )
153  setRowItem( ii, m_FieldsBuf[ii] );
154  }
SCH_FIELDS m_FieldsBuf
a copy of the edited component's SCH_FIELDs
void setRowItem(int aFieldNdx, const wxString &aName, const wxString &aValue)

Friends And Related Function Documentation

friend class SCH_EDIT_FRAME
friend

Definition at line 76 of file dialog_edit_component_in_schematic.cpp.

Member Data Documentation

wxButton* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButton
protectedinherited
wxCheckBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::convertCheckBox
protectedinherited
wxButton* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::defaultsButton
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldNameLabel
protectedinherited
wxTextCtrl* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldNameTextCtrl
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldValueLabel
protectedinherited
wxTextCtrl* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::fieldValueTextCtrl
protectedinherited
wxButton* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_buttonSelectChipName
protectedinherited
wxButton* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_buttonTestChipName
protectedinherited
wxRadioBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_FieldHJustifyCtrl
protectedinherited
wxRadioBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_FieldVJustifyCtrl
protectedinherited
std::string DIALOG_SHIM::m_hash_key
protectedinherited
LIB_PART* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::m_part
private
EVENT_LOOP* DIALOG_SHIM::m_qmodal_loop
protectedinherited

Definition at line 131 of file dialog_shim.h.

Referenced by DIALOG_SHIM::EndQuasiModal(), and DIALOG_SHIM::ShowQuasiModal().

WDO_ENABLE_DISABLE* DIALOG_SHIM::m_qmodal_parent_disabler
protectedinherited
bool DIALOG_SHIM::m_qmodal_showing
protectedinherited
bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::m_skipCopyFromPanel
private
wxStaticLine* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticline1
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextTimeStamp
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextUnit
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextUnitPosX
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextUnitPosY
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_staticTextUnitSize
protectedinherited
wxRadioBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_StyleRadioBox
protectedinherited
wxTextCtrl* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::m_textCtrlTimeStamp
protectedinherited
wxRadioBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::mirrorRadioBox
protectedinherited
wxRadioBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::orientationRadioBox
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posXLabel
protectedinherited
wxTextCtrl* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posXTextCtrl
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posYLabel
protectedinherited
wxTextCtrl* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::posYTextCtrl
protectedinherited
wxCheckBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::rotateCheckBox
protectedinherited
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow
staticprivate
wxCheckBox* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::showCheckBox
protectedinherited
wxStdDialogButtonSizer* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::stdDialogButtonSizer
protectedinherited
wxButton* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::stdDialogButtonSizerCancel
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::textSizeLabel
protectedinherited
wxTextCtrl* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::textSizeTextCtrl
protectedinherited
wxChoice* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::unitChoice
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::unitsInterchageableLabel
protectedinherited
wxStaticText* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::unitsInterchageableText
protectedinherited

The documentation for this class was generated from the following file: