29#include <wx/tooltip.h>
113 wxGridCellAttr* attr =
nullptr;
117 attr =
new wxGridCellAttr;
118 attr->SetReadOnly(
true );
122 wxArrayString choices;
123 choices.push_back( lib_pin->
GetName() );
125 for(
const std::pair<const wxString, LIB_PIN::ALT>& alt : lib_pin->
GetAlternates() )
126 choices.push_back( alt.first );
128 attr =
new wxGridCellAttr();
162 case COL_TYPE:
return _(
"Electrical Type" );
164 default: wxFAIL;
return wxEmptyString;
175 return GetValue( at( aRow ), aCol );
187 default: wxFAIL;
return wxEmptyString;
191 wxGridCellAttr*
GetAttr(
int aRow,
int aCol, wxGridCellAttr::wxAttrKind )
override
218 void SetValue(
int aRow,
int aCol,
const wxString &aValue )
override
223 if( aValue == at( aRow ).GetLibPin()->GetName() )
224 at( aRow ).SetAlt( wxEmptyString );
226 at( aRow ).SetAlt( aValue );
244 wxString lhStr =
GetValue( lhs, sortCol );
245 wxString rhStr =
GetValue( rhs, sortCol );
259 auto cmp = [ ascending ](
const auto a,
const auto b )
276 res = cmp( lhStr.CmpNoCase( rhStr ), 0 );
288 std::sort( begin(), end(),
289 [ aSortCol, ascending ](
const SCH_PIN& lhs,
const SCH_PIN& rhs ) ->
bool
291 return compare( lhs, rhs, aSortCol, ascending );
302 m_fieldsSize( 0, 0 ),
303 m_lastRequestedSize( 0, 0 ),
304 m_editorShown( false ),
306 m_dataModel( nullptr )
329 [&]( wxCommandEvent& aEvent )
333 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
350 m_pinTablePage->SetToolTip(
_(
"Alternate pin assignments are not available for De Morgan "
368 m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
370 wxToolTip::Enable(
true );
386 QueueEvent(
new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
387 wxCommandEvent *evt =
new wxCommandEvent( SYMBOL_DELAY_FOCUS );
432 if( !wxDialog::TransferDataToWindow() )
435 std::set<wxString> defined;
445 defined.insert( field.
GetName() );
451 GetParent()->Schematic().Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
453 if( defined.count( templateFieldname.m_Name ) <= 0 )
456 field.
SetVisible( templateFieldname.m_Visible );
462 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_fields->size() );
503 switch( orientation )
548 int simEnableFieldRow = -1;
553 simEnableFieldRow = ii;
556 if( event.IsChecked() )
558 if( simEnableFieldRow == -1 )
560 simEnableFieldRow = (int)
m_fields->size();
564 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
572 else if( simEnableFieldRow >= 0 )
577 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, simEnableFieldRow, 1 );
592 std::vector<SCH_FIELD> fields;
595 fields.emplace_back( field );
599 if( dialog.ShowModal() != wxID_OK )
603 for(
const SCH_FIELD& editedField : fields )
609 if( existingField.GetName() == editedField.GetName() )
612 existingField.SetText( editedField.GetText() );
619 m_fields->emplace_back( editedField );
620 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
626 for(
int ii = (
int)
m_fields->size() - 1; ii >= 0; --ii )
633 if( editedField.GetName() == existingField.
GetName() )
643 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
674 wxCommandEvent *evt =
new wxCommandEvent( SYMBOL_DELAY_FOCUS );
685 wxString fieldName = field.
GetName(
false );
687 if( fieldName.IsEmpty() )
691 wxCommandEvent *evt =
new wxCommandEvent( SYMBOL_DELAY_FOCUS );
705 if( !wxDialog::TransferDataFromWindow() )
715 wxCHECK( currentScreen,
false );
765 for(
unsigned i = 0; i <
m_fields->size(); ++i )
772 for(
size_t i = 0; i <
m_fields->size(); ++i )
773 fields.push_back(
m_fields->at( i ) );
798 src_pin->
SetAlt( model_pin.GetAlt() );
813 std::vector<SCH_SYMBOL*> otherUnits;
814 constexpr bool appendUndo =
true;
839 newField.
Offset( otherUnit->GetPosition() );
842 otherUnit->AddField( newField );
846 for(
size_t ii = otherUnit->GetFields().size() - 1; ii >
DATASHEET_FIELD; ii-- )
848 SCH_FIELD& otherField = otherUnit->GetFields().at( ii );
851 otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
856 otherUnit->SetDNP(
m_cbDNP->IsChecked() );
862 SCH_PIN* src_pin = otherUnit->GetPin( model_pin.GetNumber() );
865 src_pin->
SetAlt( model_pin.GetAlt() );
888 wxGridCellEditor*
editor =
m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
894 wxCommandEvent *evt =
new wxCommandEvent( SYMBOL_DELAY_FOCUS );
895 evt->SetClientData(
new VECTOR2I( event.GetRow(), event.GetCol() ) );
898 else if( event.GetCol() ==
FDC_NAME )
900 wxString newName =
event.GetString();
902 for(
int i = 0; i <
m_fieldsGrid->GetNumberRows(); ++i )
904 if( i == event.GetRow() )
912 wxCommandEvent *evt =
new wxCommandEvent( SYMBOL_DELAY_FOCUS );
913 evt->SetClientData(
new VECTOR2I( event.GetRow(), event.GetCol() ) );
926 QueueEvent(
new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
944 int fieldID = (int)
m_fields->size();
954 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
969 wxArrayInt selectedRows =
m_fieldsGrid->GetSelectedRows();
971 if( selectedRows.empty() &&
m_fieldsGrid->GetGridCursorRow() >= 0 )
972 selectedRows.push_back(
m_fieldsGrid->GetGridCursorRow() );
974 if( selectedRows.empty() )
977 for(
int row : selectedRows )
991 selectedRows.Sort( [](
int* first,
int* second ) {
return *second - *first; } );
993 for(
int row : selectedRows )
998 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
1096 int row = aEvent.GetRow();
1114 int sortCol = aEvent.GetCol();
1121 ascending = !
m_pinGrid->IsSortOrderAscending();
1133 wxGridUpdateLocker deferRepaintsTillLeavingScope(
m_fieldsGrid );
1143 for(
int i = 2; i <
m_fieldsGrid->GetNumberCols(); i++ )
1146 m_fieldsGrid->SetColSize( 1, std::max( 120, fieldsWidth - fixedColsWidth ) );
1152 wxGridUpdateLocker deferRepaintsTillLeavingScope(
m_pinGrid );
1161 pinTblWidth -=
m_pinGrid->GetColSize( i );
1202 wxCHECK_RET( loc, wxT(
"Missing focus cell location" ) );
1222 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
1225 cellEditor->DecRef();
1230 wxSize new_size =
event.GetSize();
1251 wxSize new_size =
event.GetSize();
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void EndQuasiModal(int retCode)
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SYMBOL_PROPERTIES_BASE.
wxCheckBox * m_cbExcludeFromBom
wxChoice * m_orientationCtrl
STD_BITMAP_BUTTON * m_bpMoveDown
wxStaticText * m_unitLabel
wxCheckBox * m_cbExcludeFromSim
STD_BITMAP_BUTTON * m_bpAdd
STD_BITMAP_BUTTON * m_bpDelete
wxTextCtrl * m_tcLibraryID
wxCheckBox * m_cbAlternateSymbol
wxButton * m_spiceFieldsButton
wxCheckBox * m_cbExcludeFromBoard
wxCheckBox * m_ShowPinNameButt
wxCheckBox * m_ShowPinNumButt
STD_BITMAP_BUTTON * m_bpMoveUp
void OnSizePinsGrid(wxSizeEvent &event) override
wxSize m_lastRequestedSize
void OnPinTableCellEdited(wxGridEvent &event) override
void OnGridEditorShown(wxGridEvent &event) override
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnEditSymbol(wxCommandEvent &) override
void OnCancelButtonClick(wxCommandEvent &event) override
bool TransferDataFromWindow() override
virtual void onUpdateEditLibrarySymbol(wxUpdateUIEvent &event) override
SCH_PIN_TABLE_DATA_MODEL * m_dataModel
void OnExcludeFromSimulation(wxCommandEvent &event) override
void OnMoveDown(wxCommandEvent &event) override
void OnSizeFieldsGrid(wxSizeEvent &event) override
SCH_EDIT_FRAME * GetParent()
void OnPinTableColSort(wxGridEvent &aEvent)
void OnMoveUp(wxCommandEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
void OnInitDlg(wxInitDialogEvent &event) override
void OnAddField(wxCommandEvent &event) override
void OnGridEditorHidden(wxGridEvent &event) override
bool TransferDataToWindow() override
void AdjustPinsGridColumns()
~DIALOG_SYMBOL_PROPERTIES() override
void OnUnitChoice(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &event) override
DIALOG_SYMBOL_PROPERTIES(SCH_EDIT_FRAME *aParent, SCH_SYMBOL *aSymbol)
void HandleDelayedFocus(wxCommandEvent &event)
void HandleDelayedSelection(wxCommandEvent &event)
void OnCheckBox(wxCommandEvent &event) override
void OnGridCellChanging(wxGridEvent &event)
void OnEditLibrarySymbol(wxCommandEvent &) override
void OnUpdateSymbol(wxCommandEvent &) override
void AdjustFieldsGridColumns()
FIELDS_GRID_TABLE< SCH_FIELD > * m_fields
void OnExchangeSymbol(wxCommandEvent &) override
virtual void onUpdateEditSymbol(wxUpdateUIEvent &event) override
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM_FLAGS GetFlags() const
void Offset(const VECTOR2I &aOffset)
virtual void SetVisible(bool aVisible)
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
APP_SETTINGS_BASE * KifaceSettings() const
A logical library item identifier and consists of various portions much like a URI.
std::map< wxString, ALT > & GetAlternates()
const wxString & GetName() const
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
bool ShowPinNames() const
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
bool ShowPinNumbers() const
static int Compare(const wxString &lhs, const wxString &rhs)
These settings were stored in SCH_BASE_FRAME previously.
SCHEMATIC_SETTINGS & Settings() const
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
bool IsEmptyCell(int row, int col) override
wxGridCellAttr * m_typeAttr
wxString GetValue(int aRow, int aCol) override
std::vector< wxGridCellAttr * > m_nameAttrs
int GetNumberCols() override
static bool compare(const SCH_PIN &lhs, const SCH_PIN &rhs, int sortCol, bool ascending)
void SortRows(int aSortCol, bool ascending)
~SCH_PIN_TABLE_DATA_MODEL()
wxGridCellAttr * m_shapeAttr
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind) override
SCH_PIN_TABLE_DATA_MODEL()
int GetNumberRows() override
static wxString GetValue(const SCH_PIN &aPin, int aCol)
wxGridCellAttr * m_readOnlyAttr
wxString GetColLabelValue(int aCol) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
void SetAlt(const wxString &aAlt)
LIB_PIN * GetLibPin() const
wxString GetNumber() const
GRAPHIC_PINSHAPE GetShape() const
ELECTRICAL_PINTYPE GetType() const
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
int GetUnitCount() const
Return the number of units per package of the symbol.
void SetConvert(int aConvert)
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
int GetFieldCount() const
Return the number of fields in this symbol.
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
void SetIncludeOnBoard(bool aIncludeOnBoard)
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
void SetValueFieldText(const wxString &aValue)
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
bool GetIncludeOnBoard() const
bool GetIncludeInBom() const
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void SetFootprintFieldText(const wxString &aFootprint)
VECTOR2I GetPosition() const override
bool HasUnitDisplayName(int aUnit)
Return true if the given unit aUnit has a display name set.
int GetOrientation() const
Get the display symbol orientation.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
void SetUnit(int aUnit)
Change the unit number to aUnit.
const LIB_ID & GetLibId() const
wxString GetUnitDisplayName(int aUnit)
Return the display name for a given unit aUnit.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
wxString GetFieldText(const wxString &aFieldName) const
Search for a field named aFieldName and returns text associated with this field.
void SetIncludeInBom(bool aIncludeInBom)
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
wxDEFINE_EVENT(SYMBOL_DELAY_FOCUS, wxCommandEvent)
@ SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL
@ SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL
@ SYMBOL_PROPS_WANT_UPDATE_SYMBOL
@ SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL
std::uint32_t EDA_ITEM_FLAGS
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
must_if< error >::control< Rule > control
const std::vector< BITMAPS > & PinTypeIcons()
const wxArrayString & PinTypeNames()
const wxArrayString & PinShapeNames()
const std::vector< BITMAPS > & PinShapeIcons()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString UnescapeString(const wxString &aSource)
wxString edit_symbol_visible_columns
Hold a name of a symbol's field, field value, and default visibility.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
Definition for symbol library class.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".