diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 4ad7a91be5..1e617b2125 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -94,8 +94,6 @@ set( EESCHEMA_DLGS dialogs/dialog_edit_sheet_pin.cpp dialogs/dialog_sch_import_settings.cpp dialogs/dialog_sch_import_settings_base.cpp - dialogs/dialog_sch_pin_table.cpp - dialogs/dialog_sch_pin_table_base.cpp dialogs/dialog_sch_sheet_props.cpp dialogs/dialog_sch_sheet_props_base.cpp dialogs/dialog_schematic_find.cpp diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index e23c6e02fe..757d037d0c 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -24,10 +24,12 @@ #include "dialog_edit_component_in_schematic.h" #include - +#include #include #include +#include #include +#include #include #include #include @@ -38,19 +40,240 @@ #include #include #include -#include #ifdef KICAD_SPICE #include #endif /* KICAD_SPICE */ +enum PIN_TABLE_COL_ORDER +{ + COL_NUMBER, + COL_BASE_NAME, + COL_ALT_NAME, + COL_TYPE, + COL_SHAPE, + + COL_COUNT // keep as last +}; + + +class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector +{ +protected: + std::vector m_nameAttrs; + wxGridCellAttr* m_readOnlyAttr; + wxGridCellAttr* m_typeAttr; + wxGridCellAttr* m_shapeAttr; + +public: + SCH_PIN_TABLE_DATA_MODEL() : + m_readOnlyAttr( nullptr ), + m_typeAttr( nullptr ), + m_shapeAttr( nullptr ) + { + } + + ~SCH_PIN_TABLE_DATA_MODEL() + { + for( wxGridCellAttr* attr : m_nameAttrs ) + attr->DecRef(); + + m_readOnlyAttr->DecRef(); + m_typeAttr->DecRef(); + m_shapeAttr->DecRef(); + } + + void BuildAttrs() + { + m_readOnlyAttr = new wxGridCellAttr; + m_readOnlyAttr->SetReadOnly( true ); + + for( const SCH_PIN& pin : *this ) + { + LIB_PIN* lib_pin = pin.GetLibPin(); + wxGridCellAttr* attr = nullptr; + + if( lib_pin->GetAlternates().empty() ) + { + attr = new wxGridCellAttr; + attr->SetReadOnly( true ); + } + else + { + wxArrayString choices; + choices.push_back( lib_pin->GetName() ); + + for( const std::pair& alt : lib_pin->GetAlternates() ) + choices.push_back( alt.first ); + + attr = new wxGridCellAttr(); + attr->SetEditor( new wxGridCellChoiceEditor( choices ) ); + } + + m_nameAttrs.push_back( attr ); + } + + m_typeAttr = new wxGridCellAttr; + m_typeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(), PinTypeNames() ) ); + m_typeAttr->SetReadOnly( true ); + + m_shapeAttr = new wxGridCellAttr; + m_shapeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(), PinShapeNames() ) ); + m_shapeAttr->SetReadOnly( true ); + } + + int GetNumberRows() override { return (int) size(); } + int GetNumberCols() override { return COL_COUNT; } + + wxString GetColLabelValue( int aCol ) override + { + switch( aCol ) + { + case COL_NUMBER: return _( "Number" ); + case COL_BASE_NAME: return _( "Base Name" ); + case COL_ALT_NAME: return _( "Alternate Assignment" ); + case COL_TYPE: return _( "Electrical Type" ); + case COL_SHAPE: return _( "Graphic Style" ); + default: wxFAIL; return wxEmptyString; + } + } + + bool IsEmptyCell( int row, int col ) override + { + return false; // don't allow adjacent cell overflow, even if we are actually empty + } + + wxString GetValue( int aRow, int aCol ) override + { + return GetValue( at( aRow ), aCol ); + } + + static wxString GetValue( const SCH_PIN& aPin, int aCol ) + { + switch( aCol ) + { + case COL_NUMBER: return aPin.GetNumber(); + case COL_BASE_NAME: return aPin.GetLibPin()->GetName(); + case COL_ALT_NAME: return aPin.GetAlt(); + case COL_TYPE: return PinTypeNames()[static_cast( aPin.GetType() )]; + case COL_SHAPE: return PinShapeNames()[static_cast( aPin.GetShape() )]; + default: wxFAIL; return wxEmptyString; + } + } + + wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) override + { + switch( aCol ) + { + case COL_NUMBER: + case COL_BASE_NAME: + m_readOnlyAttr->IncRef(); + return m_readOnlyAttr; + + case COL_ALT_NAME: + m_nameAttrs[ aRow ]->IncRef(); + return m_nameAttrs[ aRow ]; + + case COL_TYPE: + m_typeAttr->IncRef(); + return m_typeAttr; + + case COL_SHAPE: + m_shapeAttr->IncRef(); + return m_shapeAttr; + + default: + wxFAIL; + return nullptr; + } + } + + void SetValue( int aRow, int aCol, const wxString &aValue ) override + { + switch( aCol ) + { + case COL_ALT_NAME: + if( aValue == at( aRow ).GetName() ) + at( aRow ).SetAlt( wxEmptyString ); + else + at( aRow ).SetAlt( aValue ); + break; + + case COL_NUMBER: + case COL_BASE_NAME: + case COL_TYPE: + case COL_SHAPE: + // Read-only. + break; + + default: + wxFAIL; + break; + } + } + + static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending ) + { + wxString lhStr = GetValue( lhs, sortCol ); + wxString rhStr = GetValue( rhs, sortCol ); + + if( lhStr == rhStr ) + { + // Secondary sort key is always COL_NUMBER + sortCol = COL_NUMBER; + lhStr = GetValue( lhs, sortCol ); + rhStr = GetValue( rhs, sortCol ); + } + + bool res; + + // N.B. To meet the iterator sort conditions, we cannot simply invert the truth + // to get the opposite sort. i.e. ~(ab) + auto cmp = [ ascending ]( const auto a, const auto b ) + { + if( ascending ) + return a < b; + else + return b < a; + }; + + switch( sortCol ) + { + case COL_NUMBER: + case COL_BASE_NAME: + case COL_ALT_NAME: + res = cmp( PinNumbers::Compare( lhStr, rhStr ), 0 ); + break; + case COL_TYPE: + case COL_SHAPE: + res = cmp( lhStr.CmpNoCase( rhStr ), 0 ); + break; + default: + res = cmp( StrNumCmp( lhStr, rhStr ), 0 ); + break; + } + + return res; + } + + void SortRows( int aSortCol, bool ascending ) + { + std::sort( begin(), end(), + [ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool + { + return compare( lhs, rhs, aSortCol, ascending ); + } ); + } +}; + + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aComponent ) : DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( aParent ) { - m_cmp = aComponent; - m_part = m_cmp->GetPartRef().get(); + m_comp = aComponent; + m_part = m_comp->GetPartRef().get(); m_fields = new FIELDS_GRID_TABLE( this, aParent, m_part ); m_width = 0; @@ -62,7 +285,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT #endif /* not KICAD_SPICE */ // disable some options inside the edit dialog which can cause problems while dragging - if( m_cmp->IsDragging() ) + if( m_comp->IsDragging() ) { m_orientationLabel->Disable(); m_orientationCtrl->Disable(); @@ -71,10 +294,11 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT } // Give a bit more room for combobox editors - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); + m_fieldsGrid->SetDefaultRowSize( m_fieldsGrid->GetDefaultRowSize() + 4 ); + m_pinGrid->SetDefaultRowSize( m_pinGrid->GetDefaultRowSize() + 4 ); - m_grid->SetTable( m_fields ); - m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); + m_fieldsGrid->SetTable( m_fields ); + m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this ) ); // Show/hide columns according to user's preference auto cfg = dynamic_cast( Kiface().KifaceSettings() ); @@ -82,9 +306,21 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT if( cfg ) { m_shownColumns = cfg->m_Appearance.edit_component_visible_columns; - m_grid->ShowHideColumns( m_shownColumns ); + m_fieldsGrid->ShowHideColumns( m_shownColumns ); } + m_dataModel = new SCH_PIN_TABLE_DATA_MODEL(); + + // Make a copy of the pins for editing + for( const std::unique_ptr& pin : m_comp->GetRawPins() ) + m_dataModel->push_back( *pin ); + + m_dataModel->SortRows( COL_NUMBER, true ); + m_dataModel->BuildAttrs(); + + m_pinGrid->SetTable( m_dataModel ); + m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) ); + // Set font size for items showing long strings: wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); infoFont.SetSymbolicSize( wxFONTSIZE_SMALL ); @@ -102,9 +338,13 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT m_bpMoveDown->SetBitmap( KiBitmap( small_down_xpm ) ); // wxFormBuilder doesn't include this event... - m_grid->Connect( wxEVT_GRID_CELL_CHANGING, - wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ), - NULL, this ); + m_fieldsGrid->Connect( wxEVT_GRID_CELL_CHANGING, + wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ), + nullptr, this ); + + m_pinGrid->Connect( wxEVT_GRID_COL_SORT, + wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnPinTableColSort ), + nullptr, this ); FinishDialogSettings(); } @@ -115,17 +355,22 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC() auto cfg = dynamic_cast( Kiface().KifaceSettings() ); if( cfg ) - cfg->m_Appearance.edit_component_visible_columns = m_grid->GetShownColumns(); + cfg->m_Appearance.edit_component_visible_columns = m_fieldsGrid->GetShownColumns(); // Prevents crash bug in wxGrid's d'tor - m_grid->DestroyTable( m_fields ); + m_fieldsGrid->DestroyTable( m_fields ); + m_pinGrid->DestroyTable( m_dataModel ); - m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING, - wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ), - NULL, this ); + m_fieldsGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, + wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ), + nullptr, this ); + m_pinGrid->Disconnect( wxEVT_GRID_COL_SORT, + wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnPinTableColSort ), + nullptr, this ); // Delete the GRID_TRICKS. - m_grid->PopEventHandler( true ); + m_fieldsGrid->PopEventHandler( true ); + m_pinGrid->PopEventHandler( true ); } @@ -143,12 +388,12 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() std::set defined; // Push a copy of each field into m_updateFields - for( int i = 0; i < m_cmp->GetFieldCount(); ++i ) + for( int i = 0; i < m_comp->GetFieldCount(); ++i ) { - SCH_FIELD field( *m_cmp->GetField( i ) ); + SCH_FIELD field( *m_comp->GetField( i ) ); // change offset to be symbol-relative - field.Offset( -m_cmp->GetPosition() ); + field.Offset( -m_comp->GetPosition() ); defined.insert( field.GetName() ); m_fields->push_back( field ); @@ -160,7 +405,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() { if( defined.count( templateFieldname.m_Name ) <= 0 ) { - SCH_FIELD field( wxPoint( 0, 0 ), -1, m_cmp, templateFieldname.m_Name ); + SCH_FIELD field( wxPoint( 0, 0 ), -1, m_comp, templateFieldname.m_Name ); field.SetVisible( templateFieldname.m_Visible ); m_fields->push_back( field ); } @@ -168,17 +413,17 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() // notify the grid wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() ); - m_grid->ProcessTableMessage( msg ); - AdjustGridColumns( m_grid->GetRect().GetWidth() ); + m_fieldsGrid->ProcessTableMessage( msg ); + AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() ); // If a multi-unit component, set up the unit selector and interchangeable checkbox. - if( m_cmp->GetUnitCount() > 1 ) + if( m_comp->GetUnitCount() > 1 ) { - for( int ii = 1; ii <= m_cmp->GetUnitCount(); ii++ ) + for( int ii = 1; ii <= m_comp->GetUnitCount(); ii++ ) m_unitChoice->Append( LIB_PART::SubReference( ii, false ) ); - if( m_cmp->GetUnit() <= ( int )m_unitChoice->GetCount() ) - m_unitChoice->SetSelection( m_cmp->GetUnit() - 1 ); + if( m_comp->GetUnit() <= ( int )m_unitChoice->GetCount() ) + m_unitChoice->SetSelection( m_comp->GetUnit() - 1 ); } else { @@ -188,14 +433,14 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() if( m_part != nullptr && m_part->HasConversion() ) { - if( m_cmp->GetConvert() > LIB_ITEM::LIB_CONVERT::BASE ) + if( m_comp->GetConvert() > LIB_ITEM::LIB_CONVERT::BASE ) m_cbAlternateSymbol->SetValue( true ); } else m_cbAlternateSymbol->Enable( false ); // Set the symbol orientation and mirroring. - int orientation = m_cmp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y ); + int orientation = m_comp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y ); switch( orientation ) { @@ -206,7 +451,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() case CMP_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break; } - int mirror = m_cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y ); + int mirror = m_comp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y ); switch( mirror ) { @@ -215,14 +460,14 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() case CMP_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break; } - m_cbExcludeFromBom->SetValue( !m_cmp->GetIncludeInBom() ); - m_cbExcludeFromBoard->SetValue( !m_cmp->GetIncludeOnBoard() ); + m_cbExcludeFromBom->SetValue( !m_comp->GetIncludeInBom() ); + m_cbExcludeFromBoard->SetValue( !m_comp->GetIncludeOnBoard() ); m_ShowPinNumButt->SetValue( m_part->ShowPinNumbers() ); m_ShowPinNameButt->SetValue( m_part->ShowPinNames() ); // Set the component's library name. - m_tcLibraryID->SetValue( m_cmp->GetLibId().Format() ); + m_tcLibraryID->SetValue( m_comp->GetLibId().Format() ); Layout(); @@ -235,7 +480,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditSpiceModel( wxCommandEvent& event #ifdef KICAD_SPICE int diff = m_fields->size(); - DIALOG_SPICE_MODEL dialog( this, *m_cmp, m_fields ); + DIALOG_SPICE_MODEL dialog( this, *m_comp, m_fields ); if( dialog.ShowModal() != wxID_OK ) return; @@ -245,27 +490,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditSpiceModel( wxCommandEvent& event if( diff > 0 ) { wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff ); - m_grid->ProcessTableMessage( msg ); + m_fieldsGrid->ProcessTableMessage( msg ); } else if( diff < 0 ) { wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, -diff ); - m_grid->ProcessTableMessage( msg ); + m_fieldsGrid->ProcessTableMessage( msg ); } - m_grid->ForceRefresh(); + m_fieldsGrid->ForceRefresh(); #endif /* KICAD_SPICE */ } -void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditPinTable( wxCommandEvent& event ) -{ - DIALOG_SCH_PIN_TABLE dialog( GetParent(), m_cmp ); - - dialog.ShowModal(); -} - - void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event ) { // Running the Footprint Browser gums up the works and causes the automatic cancel @@ -279,7 +516,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::Validate() wxString msg; LIB_ID id; - if( !m_grid->CommitPendingChanges() || !m_grid->Validate() ) + if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() ) return false; if( !SCH_COMPONENT::IsReferenceStringValid( m_fields->at( REFERENCE ).GetText() ) ) @@ -318,6 +555,12 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method. return false; + if( !m_fieldsGrid->CommitPendingChanges() ) + return false; + + if( !m_pinGrid->CommitPendingChanges() ) + return false; + SCH_SCREEN* currentScreen = GetParent()->GetScreen(); SCHEMATIC& schematic = GetParent()->Schematic(); @@ -325,62 +568,62 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() // This needs to be done before the LIB_ID is changed to prevent stale library symbols in // the schematic file. - currentScreen->Remove( m_cmp ); + currentScreen->Remove( m_comp ); wxString msg; // save old cmp in undo list if not already in edit, or moving ... - if( m_cmp->GetEditFlags() == 0 ) - GetParent()->SaveCopyInUndoList( currentScreen, m_cmp, UNDO_REDO::CHANGED, false ); + if( m_comp->GetEditFlags() == 0 ) + GetParent()->SaveCopyInUndoList( currentScreen, m_comp, UNDO_REDO::CHANGED, false ); // Save current flags which could be modified by next change settings - STATUS_FLAGS flags = m_cmp->GetFlags(); + STATUS_FLAGS flags = m_comp->GetFlags(); // For symbols with multiple shapes (De Morgan representation) Set the selected shape: if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() ) - m_cmp->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN ); + m_comp->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN ); else - m_cmp->SetConvert( LIB_ITEM::LIB_CONVERT::BASE ); + m_comp->SetConvert( LIB_ITEM::LIB_CONVERT::BASE ); //Set the part selection in multiple part per package int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1; - m_cmp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection ); - m_cmp->SetUnit( unit_selection ); + m_comp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection ); + m_comp->SetUnit( unit_selection ); switch( m_orientationCtrl->GetSelection() ) { - case 0: m_cmp->SetOrientation( CMP_ORIENT_0 ); break; - case 1: m_cmp->SetOrientation( CMP_ORIENT_90 ); break; - case 2: m_cmp->SetOrientation( CMP_ORIENT_270 ); break; - case 3: m_cmp->SetOrientation( CMP_ORIENT_180 ); break; + case 0: m_comp->SetOrientation( CMP_ORIENT_0 ); break; + case 1: m_comp->SetOrientation( CMP_ORIENT_90 ); break; + case 2: m_comp->SetOrientation( CMP_ORIENT_270 ); break; + case 3: m_comp->SetOrientation( CMP_ORIENT_180 ); break; } switch( m_mirrorCtrl->GetSelection() ) { case 0: break; - case 1: m_cmp->SetOrientation( CMP_MIRROR_X ); break; - case 2: m_cmp->SetOrientation( CMP_MIRROR_Y ); break; + case 1: m_comp->SetOrientation( CMP_MIRROR_X ); break; + case 2: m_comp->SetOrientation( CMP_MIRROR_Y ); break; } m_part->SetShowPinNames( m_ShowPinNameButt->GetValue() ); m_part->SetShowPinNumbers( m_ShowPinNumButt->GetValue() ); // Restore m_Flag modified by SetUnit() and other change settings - m_cmp->ClearFlags(); - m_cmp->SetFlags( flags ); + m_comp->ClearFlags(); + m_comp->SetFlags( flags ); // change all field positions from relative to absolute for( unsigned i = 0; i < m_fields->size(); ++i ) - m_fields->at( i ).Offset( m_cmp->GetPosition() ); + m_fields->at( i ).Offset( m_comp->GetPosition() ); - LIB_PART* entry = GetParent()->GetLibPart( m_cmp->GetLibId() ); + LIB_PART* entry = GetParent()->GetLibPart( m_comp->GetLibId() ); if( entry && entry->IsPower() ) - m_fields->at( VALUE ).SetText( m_cmp->GetLibId().GetLibItemName() ); + m_fields->at( VALUE ).SetText( m_comp->GetLibId().GetLibItemName() ); // Push all fields to the component -except- for those which are TEMPLATE_FIELDNAMES // with empty values. - SCH_FIELDS& fields = m_cmp->GetFields(); + SCH_FIELDS& fields = m_comp->GetFields(); fields.clear(); @@ -409,21 +652,21 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() // Reference has a specific initialization, depending on the current active sheet // because for a given component, in a complex hierarchy, there are more than one // reference. - m_cmp->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE ).GetText() ); + m_comp->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE ).GetText() ); - m_cmp->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() ); - m_cmp->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() ); + m_comp->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() ); + m_comp->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() ); // The value, footprint and datasheet fields and exclude from bill of materials setting // should be kept in sync in multi-unit parts. - if( m_cmp->GetUnitCount() > 1 ) + if( m_comp->GetUnitCount() > 1 ) { for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() ) { SCH_SCREEN* screen = sheet.LastScreen(); std::vector otherUnits; - CollectOtherUnits( sheet, m_cmp, &otherUnits ); + CollectOtherUnits( sheet, m_comp, &otherUnits ); for( SCH_COMPONENT* otherUnit : otherUnits ) { @@ -438,9 +681,17 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() } } - currentScreen->Append( m_cmp ); + // Update any assignments + for( const SCH_PIN& model_pin : *m_dataModel ) + { + // map from the edited copy back to the "real" pin in the component + SCH_PIN* src_pin = m_comp->GetPin( model_pin.GetLibPin() ); + src_pin->SetAlt( model_pin.GetAlt() ); + } + + currentScreen->Append( m_comp ); GetParent()->TestDanglingEnds(); - GetParent()->UpdateItem( m_cmp ); + GetParent()->UpdateItem( m_comp ); GetParent()->OnModify(); // This must go after OnModify() so that the connectivity graph will have been updated. @@ -452,7 +703,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging( wxGridEvent& event ) { - wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() ); + wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() ); wxControl* control = editor->GetControl(); if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) ) @@ -465,12 +716,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging( wxGridEvent& event { wxString newName = event.GetString(); - for( int i = 0; i < m_grid->GetNumberRows(); ++i ) + for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i ) { if( i == event.GetRow() ) continue; - if( newName.CmpNoCase( m_grid->GetCellValue( i, FDC_NAME ) ) == 0 ) + if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 ) { DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ), newName ) ); @@ -487,12 +738,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging( wxGridEvent& event void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField( wxCommandEvent& event ) { - if( !m_grid->CommitPendingChanges() ) + if( !m_fieldsGrid->CommitPendingChanges() ) return; - SCHEMATIC_SETTINGS& settings = m_cmp->Schematic()->Settings(); + SCHEMATIC_SETTINGS& settings = m_comp->Schematic()->Settings(); int fieldID = m_fields->size(); - SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_cmp, + SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_comp, TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID ) ); newField.SetTextAngle( m_fields->at( REFERENCE ).GetTextAngle() ); @@ -502,19 +753,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField( wxCommandEvent& event ) // notify the grid wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 ); - m_grid->ProcessTableMessage( msg ); + m_fieldsGrid->ProcessTableMessage( msg ); - m_grid->MakeCellVisible( (int) m_fields->size() - 1, 0 ); - m_grid->SetGridCursor( (int) m_fields->size() - 1, 0 ); + m_fieldsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 ); + m_fieldsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 ); - m_grid->EnableCellEditControl(); - m_grid->ShowCellEditControl(); + m_fieldsGrid->EnableCellEditControl(); + m_fieldsGrid->ShowCellEditControl(); } void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnDeleteField( wxCommandEvent& event ) { - int curRow = m_grid->GetGridCursorRow(); + int curRow = m_fieldsGrid->GetGridCursorRow(); if( curRow < 0 ) { @@ -527,38 +778,38 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnDeleteField( wxCommandEvent& event ) return; } - m_grid->CommitPendingChanges( true /* quiet mode */ ); + m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ ); m_fields->erase( m_fields->begin() + curRow ); // notify the grid wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 ); - m_grid->ProcessTableMessage( msg ); + m_fieldsGrid->ProcessTableMessage( msg ); - if( m_grid->GetNumberRows() > 0 ) + if( m_fieldsGrid->GetNumberRows() > 0 ) { - m_grid->MakeCellVisible( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() ); - m_grid->SetGridCursor( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() ); + m_fieldsGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_fieldsGrid->GetGridCursorCol() ); + m_fieldsGrid->SetGridCursor( std::max( 0, curRow-1 ), m_fieldsGrid->GetGridCursorCol() ); } } void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveUp( wxCommandEvent& event ) { - if( !m_grid->CommitPendingChanges() ) + if( !m_fieldsGrid->CommitPendingChanges() ) return; - int i = m_grid->GetGridCursorRow(); + int i = m_fieldsGrid->GetGridCursorRow(); if( i > MANDATORY_FIELDS ) { SCH_FIELD tmp = m_fields->at( (unsigned) i ); m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 ); m_fields->insert( m_fields->begin() + i - 1, tmp ); - m_grid->ForceRefresh(); + m_fieldsGrid->ForceRefresh(); - m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() ); - m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); + m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() ); + m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(), m_fieldsGrid->GetGridCursorCol() ); } else { @@ -569,20 +820,20 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveUp( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveDown( wxCommandEvent& event ) { - if( !m_grid->CommitPendingChanges() ) + if( !m_fieldsGrid->CommitPendingChanges() ) return; - int i = m_grid->GetGridCursorRow(); + int i = m_fieldsGrid->GetGridCursorRow(); - if( i >= MANDATORY_FIELDS && i < m_grid->GetNumberRows() - 1 ) + if( i >= MANDATORY_FIELDS && i < m_fieldsGrid->GetNumberRows() - 1 ) { SCH_FIELD tmp = m_fields->at( (unsigned) i ); m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 ); m_fields->insert( m_fields->begin() + i + 1, tmp ); - m_grid->ForceRefresh(); + m_fieldsGrid->ForceRefresh(); - m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() ); - m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); + m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() ); + m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(), m_fieldsGrid->GetGridCursorCol() ); } else { @@ -615,45 +866,95 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnExchangeSymbol( wxCommandEvent& ) } +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnPinTableCellEdited( wxGridEvent& aEvent ) +{ + int row = aEvent.GetRow(); + + if( m_pinGrid->GetCellValue( row, COL_ALT_NAME ) == m_dataModel->GetValue( row, COL_BASE_NAME ) ) + m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString ); + + // These are just to get the cells refreshed + m_dataModel->SetValue( row, COL_TYPE, m_dataModel->GetValue( row, COL_TYPE ) ); + m_dataModel->SetValue( row, COL_SHAPE, m_dataModel->GetValue( row, COL_SHAPE ) ); + + m_modified = true; +} + + +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnPinTableColSort( wxGridEvent& aEvent ) +{ + int sortCol = aEvent.GetCol(); + bool ascending; + + // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the + // event, and if we ask it will give us pre-event info. + if( m_pinGrid->IsSortingBy( sortCol ) ) + // same column; invert ascending + ascending = !m_pinGrid->IsSortOrderAscending(); + else + // different column; start with ascending + ascending = true; + + m_dataModel->SortRows( sortCol, ascending ); +} + + void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::AdjustGridColumns( int aWidth ) { + wxGridUpdateLocker deferRepaintsTillLeavingScope; + m_width = aWidth; + // Account for scroll bars - aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x ); + int fieldsWidth = aWidth - ( m_fieldsGrid->GetSize().x - m_fieldsGrid->GetClientSize().x ); + int pinTblWidth = aWidth - ( m_pinGrid->GetSize().x - m_pinGrid->GetClientSize().x ); - m_grid->AutoSizeColumn( 0 ); + m_fieldsGrid->AutoSizeColumn( 0 ); - int fixedColsWidth = m_grid->GetColSize( 0 ); + int fixedColsWidth = m_fieldsGrid->GetColSize( 0 ); - for( int i = 2; i < m_grid->GetNumberCols(); i++ ) - fixedColsWidth += m_grid->GetColSize( i ); + for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ ) + fixedColsWidth += m_fieldsGrid->GetColSize( i ); - m_grid->SetColSize( 1, aWidth - fixedColsWidth ); + m_fieldsGrid->SetColSize( 1, fieldsWidth - fixedColsWidth ); + + // Stretch the Base Name and Alternate Assignment columns to fit. + for( int i = 0; i < COL_COUNT; ++i ) + { + if( i != COL_BASE_NAME && i != COL_ALT_NAME ) + pinTblWidth -= m_pinGrid->GetColSize( i ); + } + + // Why? I haven't a clue.... + pinTblWidth += 22; + + m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 ); + m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 ); } void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event ) { - wxString shownColumns = m_grid->GetShownColumns(); + wxString shownColumns = m_fieldsGrid->GetShownColumns(); if( shownColumns != m_shownColumns ) { m_shownColumns = shownColumns; - if( !m_grid->IsCellEditControlShown() ) - AdjustGridColumns( m_grid->GetRect().GetWidth() ); + if( !m_fieldsGrid->IsCellEditControlShown() ) + AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() ); } // Handle a delayed focus if( m_delayedFocusRow >= 0 ) { - m_grid->SetFocus(); - m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn ); - m_grid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn ); + m_fieldsGrid->SetFocus(); + m_fieldsGrid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn ); + m_fieldsGrid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn ); - m_grid->EnableCellEditControl( true ); - m_grid->ShowCellEditControl(); + m_fieldsGrid->EnableCellEditControl( true ); + m_fieldsGrid->ShowCellEditControl(); m_delayedFocusRow = -1; m_delayedFocusColumn = -1; diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.h b/eeschema/dialogs/dialog_edit_component_in_schematic.h index e0f040e6be..d96cc623dc 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.h @@ -26,12 +26,13 @@ #define _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ #include - #include +#include -class SCH_EDIT_FRAME; class LIB_PART; +class SCH_PIN_TABLE_DATA_MODEL; +class SCH_EDIT_FRAME; // The dialog can be closed for several reasons. @@ -71,7 +72,8 @@ private: void OnMoveUp( wxCommandEvent& event ) override; void OnMoveDown( wxCommandEvent& event ) override; void OnEditSpiceModel( wxCommandEvent& event ) override; - void OnEditPinTable( wxCommandEvent& event ) override; + void OnPinTableColSort( wxGridEvent& aEvent ); + void OnPinTableCellEdited( wxGridEvent& event ) override; void OnSizeGrid( wxSizeEvent& event ) override; void OnGridCellChanging( wxGridEvent& event ); void OnUpdateUI( wxUpdateUIEvent& event ) override; @@ -86,7 +88,7 @@ private: void AdjustGridColumns( int aWidth ); private: - SCH_COMPONENT* m_cmp; + SCH_COMPONENT* m_comp; LIB_PART* m_part; int m_width; @@ -95,6 +97,7 @@ private: wxString m_shownColumns; FIELDS_GRID_TABLE* m_fields; + SCH_PIN_TABLE_DATA_MODEL* m_dataModel; }; #endif // _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp index 653ea03e8e..09363a82b4 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp @@ -18,58 +18,63 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE wxBoxSizer* mainSizer; mainSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* sbFields; - sbFields = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxVERTICAL ); + m_notebook1 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + generalPage = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* generalPageSizer; + generalPageSizer = new wxBoxSizer( wxVERTICAL ); - m_grid = new WX_GRID( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticBoxSizer* sbFields; + sbFields = new wxStaticBoxSizer( new wxStaticBox( generalPage, wxID_ANY, _("Fields") ), wxVERTICAL ); + + m_fieldsGrid = new WX_GRID( sbFields->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_grid->CreateGrid( 4, 11 ); - m_grid->EnableEditing( true ); - m_grid->EnableGridLines( true ); - m_grid->EnableDragGridSize( false ); - m_grid->SetMargins( 0, 0 ); + m_fieldsGrid->CreateGrid( 4, 11 ); + m_fieldsGrid->EnableEditing( true ); + m_fieldsGrid->EnableGridLines( true ); + m_fieldsGrid->EnableDragGridSize( false ); + m_fieldsGrid->SetMargins( 0, 0 ); // Columns - m_grid->SetColSize( 0, 72 ); - m_grid->SetColSize( 1, 120 ); - m_grid->SetColSize( 2, 48 ); - m_grid->SetColSize( 3, 72 ); - m_grid->SetColSize( 4, 72 ); - m_grid->SetColSize( 5, 48 ); - m_grid->SetColSize( 6, 48 ); - m_grid->SetColSize( 7, 84 ); - m_grid->SetColSize( 8, 84 ); - m_grid->SetColSize( 9, 84 ); - m_grid->SetColSize( 10, 84 ); - m_grid->EnableDragColMove( false ); - m_grid->EnableDragColSize( true ); - m_grid->SetColLabelSize( 22 ); - m_grid->SetColLabelValue( 0, _("Name") ); - m_grid->SetColLabelValue( 1, _("Value") ); - m_grid->SetColLabelValue( 2, _("Show") ); - m_grid->SetColLabelValue( 3, _("H Align") ); - m_grid->SetColLabelValue( 4, _("V Align") ); - m_grid->SetColLabelValue( 5, _("Italic") ); - m_grid->SetColLabelValue( 6, _("Bold") ); - m_grid->SetColLabelValue( 7, _("Text Size") ); - m_grid->SetColLabelValue( 8, _("Orientation") ); - m_grid->SetColLabelValue( 9, _("X Position") ); - m_grid->SetColLabelValue( 10, _("Y Position") ); - m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + m_fieldsGrid->SetColSize( 0, 72 ); + m_fieldsGrid->SetColSize( 1, 120 ); + m_fieldsGrid->SetColSize( 2, 48 ); + m_fieldsGrid->SetColSize( 3, 72 ); + m_fieldsGrid->SetColSize( 4, 72 ); + m_fieldsGrid->SetColSize( 5, 48 ); + m_fieldsGrid->SetColSize( 6, 48 ); + m_fieldsGrid->SetColSize( 7, 84 ); + m_fieldsGrid->SetColSize( 8, 84 ); + m_fieldsGrid->SetColSize( 9, 84 ); + m_fieldsGrid->SetColSize( 10, 84 ); + m_fieldsGrid->EnableDragColMove( false ); + m_fieldsGrid->EnableDragColSize( true ); + m_fieldsGrid->SetColLabelSize( 22 ); + m_fieldsGrid->SetColLabelValue( 0, _("Name") ); + m_fieldsGrid->SetColLabelValue( 1, _("Value") ); + m_fieldsGrid->SetColLabelValue( 2, _("Show") ); + m_fieldsGrid->SetColLabelValue( 3, _("H Align") ); + m_fieldsGrid->SetColLabelValue( 4, _("V Align") ); + m_fieldsGrid->SetColLabelValue( 5, _("Italic") ); + m_fieldsGrid->SetColLabelValue( 6, _("Bold") ); + m_fieldsGrid->SetColLabelValue( 7, _("Text Size") ); + m_fieldsGrid->SetColLabelValue( 8, _("Orientation") ); + m_fieldsGrid->SetColLabelValue( 9, _("X Position") ); + m_fieldsGrid->SetColLabelValue( 10, _("Y Position") ); + m_fieldsGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); // Rows - m_grid->EnableDragRowSize( true ); - m_grid->SetRowLabelSize( 0 ); - m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + m_fieldsGrid->EnableDragRowSize( true ); + m_fieldsGrid->SetRowLabelSize( 0 ); + m_fieldsGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); // Label Appearance // Cell Defaults - m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_grid->SetMinSize( wxSize( -1,180 ) ); + m_fieldsGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_fieldsGrid->SetMinSize( wxSize( -1,180 ) ); - sbFields->Add( m_grid, 1, wxALL|wxEXPAND, 5 ); + sbFields->Add( m_fieldsGrid, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bButtonSize; bButtonSize = new wxBoxSizer( wxHORIZONTAL ); @@ -104,13 +109,13 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE sbFields->Add( bButtonSize, 0, wxALL|wxEXPAND, 5 ); - mainSizer->Add( sbFields, 1, wxALL|wxEXPAND, 10 ); + generalPageSizer->Add( sbFields, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bLowerSizer; bLowerSizer = new wxBoxSizer( wxHORIZONTAL ); wxStaticBoxSizer* sbGeneralProps; - sbGeneralProps = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General") ), wxHORIZONTAL ); + sbGeneralProps = new wxStaticBoxSizer( new wxStaticBox( generalPage, wxID_ANY, _("General") ), wxHORIZONTAL ); wxGridBagSizer* gbSizer1; gbSizer1 = new wxGridBagSizer( 3, 3 ); @@ -166,7 +171,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE bMiddleCol = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* sbSizerPinTextOpts; - sbSizerPinTextOpts = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pin Text") ), wxVERTICAL ); + sbSizerPinTextOpts = new wxStaticBoxSizer( new wxStaticBox( generalPage, wxID_ANY, _("Pin Text") ), wxVERTICAL ); m_ShowPinNumButt = new wxCheckBox( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, _("Show pin numbers"), wxDefaultPosition, wxDefaultSize, 0 ); m_ShowPinNumButt->SetValue(true); @@ -184,7 +189,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE bMiddleCol->Add( sbSizerPinTextOpts, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxStaticBoxSizer* sbAttributes; - sbAttributes = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Attributes") ), wxVERTICAL ); + sbAttributes = new wxStaticBoxSizer( new wxStaticBox( generalPage, wxID_ANY, _("Attributes") ), wxVERTICAL ); m_cbExcludeFromBom = new wxCheckBox( sbAttributes->GetStaticBox(), wxID_ANY, _("Exclude from bill of materials"), wxDefaultPosition, wxDefaultSize, 0 ); m_cbExcludeFromBom->SetToolTip( _("This is useful for adding symbols for board footprints such as fiducials\nand logos that you do not want to appear in the bill of materials export") ); @@ -205,34 +210,87 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE wxBoxSizer* buttonsSizer; buttonsSizer = new wxBoxSizer( wxVERTICAL ); - m_updateSymbolBtn = new wxButton( this, wxID_ANY, _("Update Symbol from Library..."), wxDefaultPosition, wxDefaultSize, 0 ); + m_updateSymbolBtn = new wxButton( generalPage, wxID_ANY, _("Update Symbol from Library..."), wxDefaultPosition, wxDefaultSize, 0 ); buttonsSizer->Add( m_updateSymbolBtn, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_changeSymbolBtn = new wxButton( this, wxID_ANY, _("Change Symbol..."), wxDefaultPosition, wxDefaultSize, 0 ); + m_changeSymbolBtn = new wxButton( generalPage, wxID_ANY, _("Change Symbol..."), wxDefaultPosition, wxDefaultSize, 0 ); buttonsSizer->Add( m_changeSymbolBtn, 0, wxEXPAND|wxALL, 5 ); - m_editSchematicSymbolBtn = new wxButton( this, wxID_ANY, _("Edit Symbol..."), wxDefaultPosition, wxDefaultSize, 0 ); + m_editSchematicSymbolBtn = new wxButton( generalPage, wxID_ANY, _("Edit Symbol..."), wxDefaultPosition, wxDefaultSize, 0 ); buttonsSizer->Add( m_editSchematicSymbolBtn, 0, wxEXPAND|wxALL, 5 ); - m_pinTableButton = new wxButton( this, wxID_ANY, _("Alternate Pin Assignments..."), wxDefaultPosition, wxDefaultSize, 0 ); - m_pinTableButton->SetMinSize( wxSize( 112,-1 ) ); - buttonsSizer->Add( m_pinTableButton, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxALL, 5 ); + buttonsSizer->Add( 0, 20, 0, wxEXPAND, 5 ); - - buttonsSizer->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - m_editLibrarySymbolBtn = new wxButton( this, wxID_ANY, _("Edit Library Symbol..."), wxDefaultPosition, wxDefaultSize, 0 ); + m_editLibrarySymbolBtn = new wxButton( generalPage, wxID_ANY, _("Edit Library Symbol..."), wxDefaultPosition, wxDefaultSize, 0 ); buttonsSizer->Add( m_editLibrarySymbolBtn, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - bLowerSizer->Add( buttonsSizer, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bLowerSizer->Add( buttonsSizer, 1, wxEXPAND|wxALL, 5 ); - mainSizer->Add( bLowerSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + generalPageSizer->Add( bLowerSizer, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + generalPage->SetSizer( generalPageSizer ); + generalPage->Layout(); + generalPageSizer->Fit( generalPage ); + m_notebook1->AddPage( generalPage, _("General"), false ); + m_pinTablePage = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* pinTableSizer; + pinTableSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bMargins; + bMargins = new wxBoxSizer( wxVERTICAL ); + + m_pinGrid = new WX_GRID( m_pinTablePage, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + + // Grid + m_pinGrid->CreateGrid( 5, 5 ); + m_pinGrid->EnableEditing( true ); + m_pinGrid->EnableGridLines( true ); + m_pinGrid->EnableDragGridSize( false ); + m_pinGrid->SetMargins( 0, 0 ); + + // Columns + m_pinGrid->SetColSize( 0, 160 ); + m_pinGrid->SetColSize( 1, 160 ); + m_pinGrid->SetColSize( 2, 160 ); + m_pinGrid->SetColSize( 3, 140 ); + m_pinGrid->SetColSize( 4, 140 ); + m_pinGrid->EnableDragColMove( false ); + m_pinGrid->EnableDragColSize( true ); + m_pinGrid->SetColLabelSize( 24 ); + m_pinGrid->SetColLabelValue( 0, _("Pin Number") ); + m_pinGrid->SetColLabelValue( 1, _("Base Pin Name") ); + m_pinGrid->SetColLabelValue( 2, _("Alternate Assignment") ); + m_pinGrid->SetColLabelValue( 3, _("Electrical Type") ); + m_pinGrid->SetColLabelValue( 4, _("Graphic Style") ); + m_pinGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + m_pinGrid->EnableDragRowSize( false ); + m_pinGrid->SetRowLabelSize( 0 ); + m_pinGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + m_pinGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_pinGrid->SetMinSize( wxSize( 512,320 ) ); + + bMargins->Add( m_pinGrid, 1, wxEXPAND|wxALL, 5 ); + + + pinTableSizer->Add( bMargins, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + + m_pinTablePage->SetSizer( pinTableSizer ); + m_pinTablePage->Layout(); + pinTableSizer->Fit( m_pinTablePage ); + m_notebook1->AddPage( m_pinTablePage, _("Alternate Pin Assignments"), false ); + + mainSizer->Add( m_notebook1, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bSizerBottom; bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); @@ -281,7 +339,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE // Connect Events this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnInitDlg ) ); this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnUpdateUI ) ); - m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnSizeGrid ), NULL, this ); + m_fieldsGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnSizeGrid ), NULL, this ); m_bpAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnAddField ), NULL, this ); m_bpMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnMoveUp ), NULL, this ); m_bpMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnMoveDown ), NULL, this ); @@ -289,8 +347,8 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE m_updateSymbolBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnUpdateSymbol ), NULL, this ); m_changeSymbolBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnExchangeSymbol ), NULL, this ); m_editSchematicSymbolBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSymbol ), NULL, this ); - m_pinTableButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditPinTable ), NULL, this ); m_editLibrarySymbolBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditLibrarySymbol ), NULL, this ); + m_pinGrid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnPinTableCellEdited ), NULL, this ); m_spiceFieldsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSpiceModel ), NULL, this ); m_stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnCancelButtonClick ), NULL, this ); } @@ -300,7 +358,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BAS // Disconnect Events this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnInitDlg ) ); this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnUpdateUI ) ); - m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnSizeGrid ), NULL, this ); + m_fieldsGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnSizeGrid ), NULL, this ); m_bpAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnAddField ), NULL, this ); m_bpMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnMoveUp ), NULL, this ); m_bpMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnMoveDown ), NULL, this ); @@ -308,8 +366,8 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BAS m_updateSymbolBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnUpdateSymbol ), NULL, this ); m_changeSymbolBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnExchangeSymbol ), NULL, this ); m_editSchematicSymbolBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSymbol ), NULL, this ); - m_pinTableButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditPinTable ), NULL, this ); m_editLibrarySymbolBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditLibrarySymbol ), NULL, this ); + m_pinGrid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnPinTableCellEdited ), NULL, this ); m_spiceFieldsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSpiceModel ), NULL, this ); m_stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnCancelButtonClick ), NULL, this ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp index fb6772adde..694dd65090 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp @@ -60,1620 +60,11 @@ mainSizer wxVERTICAL none - - 10 - wxALL|wxEXPAND - 1 - - wxID_ANY - Fields - - sbFields - wxVERTICAL - 1 - none - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - 0 - - - - 1 - - - wxALIGN_LEFT - - wxALIGN_TOP - 0 - 1 - wxALIGN_CENTER - 22 - "Name" "Value" "Show" "H Align" "V Align" "Italic" "Bold" "Text Size" "Orientation" "X Position" "Y Position" - wxALIGN_CENTER - 11 - 72,120,48,72,72,48,48,84,84,84,84 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - 0 - 1 - 1 - 1 - - 1 - - - 1 - 0 - 0 - wxID_ANY - - - - 0 - 0 - - 0 - - - 0 - -1,180 - 1 - m_grid - 1 - - - protected - 1 - - Resizable - wxALIGN_CENTER - 0 - - wxALIGN_CENTER - - 4 - 1 - - WX_GRID; widgets/wx_grid.h; forward_declare - 0 - - - - - OnSizeGrid - - - - 5 - wxALL|wxEXPAND - 0 - - - bButtonSize - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Add Field - - 0 - - 0 - - - 0 - -1,-1 - 1 - m_bpAdd - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; forward_declare - 0 - Add field - - wxFILTER_NONE - wxDefaultValidator - - - - - OnAddField - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Move Up - - 0 - - 0 - - - 0 - -1,-1 - 1 - m_bpMoveUp - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; forward_declare - 0 - Move up - - wxFILTER_NONE - wxDefaultValidator - - - - - OnMoveUp - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Move Down - - 0 - - 0 - - - 0 - -1,-1 - 1 - m_bpMoveDown - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; forward_declare - 0 - Move down - - wxFILTER_NONE - wxDefaultValidator - - - - - OnMoveDown - - - - 10 - wxEXPAND - 0 - - 0 - protected - 20 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Delete Field - - 0 - - 0 - - - 0 - -1,-1 - 1 - m_bpDelete - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; forward_declare - 0 - Delete field - - wxFILTER_NONE - wxDefaultValidator - - - - - OnDeleteField - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - bLowerSizer - wxHORIZONTAL - none - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 1 - - wxID_ANY - General - - sbGeneralProps - wxHORIZONTAL - 1 - none - - 5 - wxEXPAND - 1 - - -1,10 - wxBOTH - 1 - - 3 - - gbSizer1 - wxFLEX_GROWMODE_SPECIFIED - none - 3 - - 5 - 1 - 0 - wxBOTTOM|wxRIGHT - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Unit: - 0 - - 0 - - - 0 - - 1 - m_unitLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - 100,-1 - 1 - m_unitChoice - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - 2 - 0 - wxEXPAND|wxBOTTOM|wxRIGHT - 1 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Alternate symbol (DeMorgan) - - 0 - - - 0 - - 1 - m_cbAlternateSymbol - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Use the alternate shape of this symbol. For gates, this is the "De Morgan" conversion - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - 1 - 0 - wxTOP|wxBOTTOM|wxRIGHT - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Angle: - 0 - - 0 - - - 0 - - 1 - m_orientationLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxALL|wxEXPAND - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "0" "+90" "-90" "180" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_orientationCtrl - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - 1 - 0 - wxBOTTOM|wxRIGHT - 4 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Mirror: - 0 - - 0 - - - 0 - - 1 - m_mirrorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 4 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Not mirrored" "Around X axis" "Around Y axis" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_mirrorCtrl - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 1 - - - bMiddleCol - wxVERTICAL - none - - 5 - wxEXPAND|wxRIGHT|wxLEFT - 1 - - wxID_ANY - Pin Text - - sbSizerPinTextOpts - wxVERTICAL - 1 - none - - 4 - wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show pin numbers - - 0 - - - 0 - - 1 - m_ShowPinNumButt - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Show or hide pin numbers - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 4 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show pin names - - 0 - - - 0 - - 1 - m_ShowPinNameButt - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Show or hide pin names - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - wxID_ANY - Attributes - - sbAttributes - wxVERTICAL - 1 - none - - 4 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Exclude from bill of materials - - 0 - - - 0 - - 1 - m_cbExcludeFromBom - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - This is useful for adding symbols for board footprints such as fiducials and logos that you do not want to appear in the bill of materials export - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 4 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Exclude from board - - 0 - - - 0 - - 1 - m_cbExcludeFromBoard - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - This is useful for adding symbols that only get exported to the bill of materials but not required to layout the board such as mechanical fasteners and enclosures - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - - buttonsSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Update Symbol from Library... - - 0 - - 0 - - - 0 - - 1 - m_updateSymbolBtn - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnUpdateSymbol - - - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Change Symbol... - - 0 - - 0 - - - 0 - - 1 - m_changeSymbolBtn - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnExchangeSymbol - - - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Edit Symbol... - - 0 - - 0 - - - 0 - - 1 - m_editSchematicSymbolBtn - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnEditSymbol - - - - 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Alternate Pin Assignments... - - 0 - - 0 - - - 0 - 112,-1 - 1 - m_pinTableButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnEditPinTable - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 0 - protected - 0 - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Edit Library Symbol... - - 0 - - 0 - - - 0 - - 1 - m_editLibrarySymbolBtn - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnEditLibrarySymbol - - - - - - 5 wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - + 1 + 1 1 1 @@ -1684,6 +75,7 @@ + 1 0 @@ -1708,7 +100,7 @@ 0 1 - m_staticline1 + m_notebook1 1 @@ -1718,13 +110,1775 @@ Resizable 1 - wxLI_HORIZONTAL - ; forward_declare + + ; ; forward_declare 0 + + + General + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + generalPage + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + generalPageSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + wxID_ANY + Fields + + sbFields + wxVERTICAL + 1 + none + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 22 + "Name" "Value" "Show" "H Align" "V Align" "Italic" "Bold" "Text Size" "Orientation" "X Position" "Y Position" + wxALIGN_CENTER + 11 + 72,120,48,72,72,48,48,84,84,84,84 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 1 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + -1,180 + 1 + m_fieldsGrid + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + + 4 + 1 + + WX_GRID; widgets/wx_grid.h; forward_declare + 0 + + + + + OnSizeGrid + + + + 5 + wxALL|wxEXPAND + 0 + + + bButtonSize + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Add Field + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpAdd + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Add field + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddField + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Move Up + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpMoveUp + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Move up + + wxFILTER_NONE + wxDefaultValidator + + + + + OnMoveUp + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Move Down + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpMoveDown + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Move down + + wxFILTER_NONE + wxDefaultValidator + + + + + OnMoveDown + + + + 10 + wxEXPAND + 0 + + 0 + protected + 20 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Delete Field + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpDelete + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + Delete field + + wxFILTER_NONE + wxDefaultValidator + + + + + OnDeleteField + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + + bLowerSizer + wxHORIZONTAL + none + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 1 + + wxID_ANY + General + + sbGeneralProps + wxHORIZONTAL + 1 + none + + 5 + wxEXPAND + 1 + + -1,10 + wxBOTH + 1 + + 3 + + gbSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 3 + + 5 + 1 + 0 + wxBOTTOM|wxRIGHT + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Unit: + 0 + + 0 + + + 0 + + 1 + m_unitLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 100,-1 + 1 + m_unitChoice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 2 + 0 + wxEXPAND|wxBOTTOM|wxRIGHT + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Alternate symbol (DeMorgan) + + 0 + + + 0 + + 1 + m_cbAlternateSymbol + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Use the alternate shape of this symbol. For gates, this is the "De Morgan" conversion + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 0 + wxTOP|wxBOTTOM|wxRIGHT + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Angle: + 0 + + 0 + + + 0 + + 1 + m_orientationLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALL|wxEXPAND + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "0" "+90" "-90" "180" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_orientationCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 0 + wxBOTTOM|wxRIGHT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Mirror: + 0 + + 0 + + + 0 + + 1 + m_mirrorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Not mirrored" "Around X axis" "Around Y axis" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_mirrorCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 1 + + + bMiddleCol + wxVERTICAL + none + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 1 + + wxID_ANY + Pin Text + + sbSizerPinTextOpts + wxVERTICAL + 1 + none + + 4 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show pin numbers + + 0 + + + 0 + + 1 + m_ShowPinNumButt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Show or hide pin numbers + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 4 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show pin names + + 0 + + + 0 + + 1 + m_ShowPinNameButt + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Show or hide pin names + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + wxID_ANY + Attributes + + sbAttributes + wxVERTICAL + 1 + none + + 4 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Exclude from bill of materials + + 0 + + + 0 + + 1 + m_cbExcludeFromBom + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + This is useful for adding symbols for board footprints such as fiducials and logos that you do not want to appear in the bill of materials export + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 4 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Exclude from board + + 0 + + + 0 + + 1 + m_cbExcludeFromBoard + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + This is useful for adding symbols that only get exported to the bill of materials but not required to layout the board such as mechanical fasteners and enclosures + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 1 + + + buttonsSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Update Symbol from Library... + + 0 + + 0 + + + 0 + + 1 + m_updateSymbolBtn + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnUpdateSymbol + + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Change Symbol... + + 0 + + 0 + + + 0 + + 1 + m_changeSymbolBtn + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnExchangeSymbol + + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Edit Symbol... + + 0 + + 0 + + + 0 + + 1 + m_editSchematicSymbolBtn + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnEditSymbol + + + + 5 + wxEXPAND + 0 + + 20 + protected + 0 + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Edit Library Symbol... + + 0 + + 0 + + + 0 + + 1 + m_editLibrarySymbolBtn + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnEditLibrarySymbol + + + + + + + + + + + + Alternate Pin Assignments + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_pinTablePage + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + pinTableSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 1 + + + bMargins + wxVERTICAL + none + + 5 + wxEXPAND|wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 24 + "Pin Number" "Base Pin Name" "Alternate Assignment" "Electrical Type" "Graphic Style" + wxALIGN_CENTER + 5 + 160,160,160,140,140 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 0 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + 512,320 + 1 + m_pinGrid + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + + 5 + 1 + -1,-1 + WX_GRID; widgets/wx_grid.h; forward_declare + 0 + + + + + OnPinTableCellEdited + + + + + + + diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h index 3136ac731f..aae73ce1d8 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h @@ -30,7 +30,8 @@ class WX_GRID; #include #include #include -#include +#include +#include #include #include @@ -45,7 +46,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM private: protected: - WX_GRID* m_grid; + wxNotebook* m_notebook1; + wxPanel* generalPage; + WX_GRID* m_fieldsGrid; wxBitmapButton* m_bpAdd; wxBitmapButton* m_bpMoveUp; wxBitmapButton* m_bpMoveDown; @@ -64,9 +67,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM wxButton* m_updateSymbolBtn; wxButton* m_changeSymbolBtn; wxButton* m_editSchematicSymbolBtn; - wxButton* m_pinTableButton; wxButton* m_editLibrarySymbolBtn; - wxStaticLine* m_staticline1; + wxPanel* m_pinTablePage; + WX_GRID* m_pinGrid; wxStaticText* m_libraryIDLabel; wxTextCtrl* m_tcLibraryID; wxButton* m_spiceFieldsButton; @@ -85,8 +88,8 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM virtual void OnUpdateSymbol( wxCommandEvent& event ) { event.Skip(); } virtual void OnExchangeSymbol( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditSymbol( wxCommandEvent& event ) { event.Skip(); } - virtual void OnEditPinTable( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditLibrarySymbol( wxCommandEvent& event ) { event.Skip(); } + virtual void OnPinTableCellEdited( wxGridEvent& event ) { event.Skip(); } virtual void OnEditSpiceModel( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_sch_pin_table.cpp b/eeschema/dialogs/dialog_sch_pin_table.cpp deleted file mode 100644 index 40531b4c88..0000000000 --- a/eeschema/dialogs/dialog_sch_pin_table.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "dialog_sch_pin_table.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector -{ -protected: - std::vector m_nameAttrs; - wxGridCellAttr* m_numberAttr; - wxGridCellAttr* m_typeAttr; - wxGridCellAttr* m_shapeAttr; - -public: - SCH_PIN_TABLE_DATA_MODEL() : - m_numberAttr( nullptr ), - m_typeAttr( nullptr ), - m_shapeAttr( nullptr ) - { - } - - ~SCH_PIN_TABLE_DATA_MODEL() - { - for( wxGridCellAttr* attr : m_nameAttrs ) - attr->DecRef(); - - m_numberAttr->DecRef(); - m_typeAttr->DecRef(); - m_shapeAttr->DecRef(); - } - - void BuildAttrs() - { - m_numberAttr = new wxGridCellAttr; - m_numberAttr->SetReadOnly( true ); - - for( const SCH_PIN& pin : *this ) - { - wxArrayString choices; - LIB_PIN* lib_pin = pin.GetLibPin(); - - choices.push_back( lib_pin->GetName() ); - - for( const std::pair& alt : lib_pin->GetAlternates() ) - choices.push_back( alt.first ); - - wxGridCellAttr* attr = new wxGridCellAttr(); - attr->SetEditor( new wxGridCellChoiceEditor( choices ) ); - - m_nameAttrs.push_back( attr ); - } - - m_typeAttr = new wxGridCellAttr; - m_typeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(), PinTypeNames() ) ); - m_typeAttr->SetReadOnly( true ); - - m_shapeAttr = new wxGridCellAttr; - m_shapeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(), PinShapeNames() ) ); - m_shapeAttr->SetReadOnly( true ); - } - - int GetNumberRows() override { return (int) size(); } - int GetNumberCols() override { return COL_COUNT; } - - wxString GetColLabelValue( int aCol ) override - { - switch( aCol ) - { - case COL_NUMBER: return _( "Number" ); - case COL_NAME: return _( "Name" ); - case COL_TYPE: return _( "Electrical Type" ); - case COL_SHAPE: return _( "Graphic Style" ); - default: wxFAIL; return wxEmptyString; - } - } - - bool IsEmptyCell( int row, int col ) override - { - return false; // don't allow adjacent cell overflow, even if we are actually empty - } - - wxString GetValue( int aRow, int aCol ) override - { - return GetValue( at( aRow ), aCol ); - } - - static wxString GetValue( const SCH_PIN& aPin, int aCol ) - { - switch( aCol ) - { - case COL_NUMBER: return aPin.GetNumber(); - case COL_NAME: return aPin.GetName(); - case COL_TYPE: return PinTypeNames()[static_cast( aPin.GetType() )]; - case COL_SHAPE: return PinShapeNames()[static_cast( aPin.GetShape() )]; - default: wxFAIL; return wxEmptyString; - } - } - - wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) override - { - switch( aCol ) - { - case COL_NAME: - m_nameAttrs[ aRow ]->IncRef(); - return m_nameAttrs[ aRow ]; - - case COL_NUMBER: - m_numberAttr->IncRef(); - return m_numberAttr; - - case COL_TYPE: - m_typeAttr->IncRef(); - return m_typeAttr; - - case COL_SHAPE: - m_shapeAttr->IncRef(); - return m_shapeAttr; - - default: - wxFAIL; - return nullptr; - } - } - - void SetValue( int aRow, int aCol, const wxString &aValue ) override - { - switch( aCol ) - { - case COL_NAME: - if( aValue == at( aRow ).GetName() ) - at( aRow ).SetAlt( wxEmptyString ); - else - at( aRow ).SetAlt( aValue ); - break; - - case COL_NUMBER: - case COL_TYPE: - case COL_SHAPE: - // Read-only. - break; - - default: - wxFAIL; - break; - } - } - - static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending ) - { - wxString lhStr = GetValue( lhs, sortCol ); - wxString rhStr = GetValue( rhs, sortCol ); - - if( lhStr == rhStr ) - { - // Secondary sort key is always COL_NUMBER - sortCol = COL_NUMBER; - lhStr = GetValue( lhs, sortCol ); - rhStr = GetValue( rhs, sortCol ); - } - - bool res; - - // N.B. To meet the iterator sort conditions, we cannot simply invert the truth - // to get the opposite sort. i.e. ~(ab) - auto cmp = [ ascending ]( const auto a, const auto b ) - { - if( ascending ) - return a < b; - else - return b < a; - }; - - switch( sortCol ) - { - case COL_NUMBER: - case COL_NAME: - res = cmp( PinNumbers::Compare( lhStr, rhStr ), 0 ); - break; - case COL_TYPE: - case COL_SHAPE: - res = cmp( lhStr.CmpNoCase( rhStr ), 0 ); - break; - default: - res = cmp( StrNumCmp( lhStr, rhStr ), 0 ); - break; - } - - return res; - } - - void SortRows( int aSortCol, bool ascending ) - { - std::sort( begin(), end(), - [ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool - { - return compare( lhs, rhs, aSortCol, ascending ); - } ); - } -}; - - -DIALOG_SCH_PIN_TABLE::DIALOG_SCH_PIN_TABLE( SCH_EDIT_FRAME* parent, SCH_COMPONENT* aComp ) : - DIALOG_SCH_PIN_TABLE_BASE( parent ), - m_editFrame( parent ), - m_comp( aComp ) -{ - m_dataModel = new SCH_PIN_TABLE_DATA_MODEL(); - - // Make a copy of the pins for editing - for( const std::unique_ptr& pin : m_comp->GetRawPins() ) - m_dataModel->push_back( *pin ); - - m_dataModel->SortRows( COL_NUMBER, true ); - m_dataModel->BuildAttrs(); - - // Save original columns widths so we can do proportional sizing. - for( int i = 0; i < COL_COUNT; ++i ) - m_originalColWidths[ i ] = m_grid->GetColSize( i ); - - // Give a bit more room for combobox editors - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); - - m_grid->SetTable( m_dataModel ); - m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); - - GetSizer()->SetSizeHints(this); - Centre(); - - m_ButtonsOK->SetDefault(); - m_initialized = true; - m_modified = false; - m_width = 0; - - // Connect Events - m_grid->Connect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_SCH_PIN_TABLE::OnColSort ), nullptr, this ); -} - - -DIALOG_SCH_PIN_TABLE::~DIALOG_SCH_PIN_TABLE() -{ - // Disconnect Events - m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_SCH_PIN_TABLE::OnColSort ), nullptr, this ); - - // Prevents crash bug in wxGrid's d'tor - m_grid->DestroyTable( m_dataModel ); - - // Delete the GRID_TRICKS. - m_grid->PopEventHandler( true ); -} - - -bool DIALOG_SCH_PIN_TABLE::TransferDataToWindow() -{ - return true; -} - - -bool DIALOG_SCH_PIN_TABLE::TransferDataFromWindow() -{ - if( !m_grid->CommitPendingChanges() ) - return false; - - // Update any assignments - for( const SCH_PIN& model_pin : *m_dataModel ) - { - // map from the edited copy back to the "real" pin in the component - SCH_PIN* src_pin = m_comp->GetPin( model_pin.GetLibPin() ); - src_pin->SetAlt( model_pin.GetAlt() ); - } - - return true; -} - - -void DIALOG_SCH_PIN_TABLE::OnCellEdited( wxGridEvent& aEvent ) -{ - int row = aEvent.GetRow(); - - // These are just to get the cells refreshed - m_dataModel->SetValue( row, COL_TYPE, m_dataModel->GetValue( row, COL_TYPE ) ); - m_dataModel->SetValue( row, COL_SHAPE, m_dataModel->GetValue( row, COL_SHAPE ) ); - - m_modified = true; -} - - -void DIALOG_SCH_PIN_TABLE::OnColSort( wxGridEvent& aEvent ) -{ - int sortCol = aEvent.GetCol(); - bool ascending; - - // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the - // event, and if we ask it will give us pre-event info. - if( m_grid->IsSortingBy( sortCol ) ) - // same column; invert ascending - ascending = !m_grid->IsSortOrderAscending(); - else - // different column; start with ascending - ascending = true; - - m_dataModel->SortRows( sortCol, ascending ); -} - - -void DIALOG_SCH_PIN_TABLE::adjustGridColumns( int aWidth ) -{ - m_width = aWidth; - - // Account for scroll bars - aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x ); - - wxGridUpdateLocker deferRepaintsTillLeavingScope; - - // The Number and Name columns must be at least wide enough to hold their contents, but - // no less wide than their original widths. - - m_grid->AutoSizeColumn( COL_NUMBER ); - - if( m_grid->GetColSize( COL_NUMBER ) < m_originalColWidths[ COL_NUMBER ] ) - m_grid->SetColSize( COL_NUMBER, m_originalColWidths[ COL_NUMBER ] ); - - m_grid->AutoSizeColumn( COL_NAME ); - - if( m_grid->GetColSize( COL_NAME ) < m_originalColWidths[ COL_NAME ] ) - m_grid->SetColSize( COL_NAME, m_originalColWidths[ COL_NAME ] ); - - // If the grid is still wider than the columns, then stretch the Number and Name columns - // to fit. - - for( int i = 0; i < COL_COUNT; ++i ) - aWidth -= m_grid->GetColSize( i ); - - if( aWidth > 0 ) - { - m_grid->SetColSize( COL_NUMBER, m_grid->GetColSize( COL_NUMBER ) + aWidth / 2 ); - m_grid->SetColSize( COL_NAME, m_grid->GetColSize( COL_NAME ) + aWidth / 2 ); - } -} - - -void DIALOG_SCH_PIN_TABLE::OnSize( wxSizeEvent& event ) -{ - auto new_size = event.GetSize().GetX(); - - if( m_initialized && m_width != new_size ) - { - adjustGridColumns( new_size ); - } - - // Always propagate for a grid repaint (needed if the height changes, as well as width) - event.Skip(); -} - - -void DIALOG_SCH_PIN_TABLE::OnCancel( wxCommandEvent& event ) -{ - Close(); -} - - -void DIALOG_SCH_PIN_TABLE::OnClose( wxCloseEvent& event ) -{ - // This is a cancel, so commit quietly as we're going to throw the results away anyway. - m_grid->CommitPendingChanges( true ); - - int retval = wxCANCEL; - - if( m_modified && !HandleUnsavedChanges( this, _( "Save changes?" ), - [&]()->bool - { - if( TransferDataFromWindow() ) - { - retval = wxOK; - return true; - } - - return false; - } ) ) - { - event.Veto(); - return; - } - - if( IsQuasiModal() ) - EndQuasiModal( retval ); - else - EndModal( retval ); -} diff --git a/eeschema/dialogs/dialog_sch_pin_table.h b/eeschema/dialogs/dialog_sch_pin_table.h deleted file mode 100644 index b9f4b7c4a4..0000000000 --- a/eeschema/dialogs/dialog_sch_pin_table.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "dialog_sch_pin_table_base.h" -#include - -enum COL_ORDER -{ - COL_NUMBER, - COL_NAME, - COL_TYPE, - COL_SHAPE, - - COL_COUNT // keep as last -}; - - -class SCH_PIN_TABLE_DATA_MODEL; -class SCH_EDIT_FRAME; - - -class DIALOG_SCH_PIN_TABLE : public DIALOG_SCH_PIN_TABLE_BASE -{ -public: - DIALOG_SCH_PIN_TABLE( SCH_EDIT_FRAME* parent, SCH_COMPONENT* aPart ); - ~DIALOG_SCH_PIN_TABLE() override; - - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - void OnColSort( wxGridEvent& aEvent ); - void OnCellEdited( wxGridEvent& event ) override; - void OnSize( wxSizeEvent& event ) override; - void OnCancel( wxCommandEvent& event ) override; - void OnClose( wxCloseEvent& event ) override; - -protected: - void adjustGridColumns( int aWidth ); - - SCH_EDIT_FRAME* m_editFrame; - bool m_initialized = false; - int m_originalColWidths[ COL_COUNT ]; - SCH_COMPONENT* m_comp; - - int m_width; - - SCH_PIN_TABLE_DATA_MODEL* m_dataModel; - bool m_modified; ///< true when there are unsaved changes -}; diff --git a/eeschema/dialogs/dialog_sch_pin_table_base.cpp b/eeschema/dialogs/dialog_sch_pin_table_base.cpp deleted file mode 100644 index 3e363a1455..0000000000 --- a/eeschema/dialogs/dialog_sch_pin_table_base.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "widgets/wx_grid.h" - -#include "dialog_sch_pin_table_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_SCH_PIN_TABLE_BASE::DIALOG_SCH_PIN_TABLE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* top_sizer; - top_sizer = new wxBoxSizer( wxVERTICAL ); - - m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - - // Grid - m_grid->CreateGrid( 5, 4 ); - m_grid->EnableEditing( true ); - m_grid->EnableGridLines( true ); - m_grid->EnableDragGridSize( false ); - m_grid->SetMargins( 0, 0 ); - - // Columns - m_grid->SetColSize( 0, 84 ); - m_grid->SetColSize( 1, 140 ); - m_grid->SetColSize( 2, 140 ); - m_grid->SetColSize( 3, 140 ); - m_grid->EnableDragColMove( false ); - m_grid->EnableDragColSize( true ); - m_grid->SetColLabelSize( 24 ); - m_grid->SetColLabelValue( 0, _("Number") ); - m_grid->SetColLabelValue( 1, _("Name") ); - m_grid->SetColLabelValue( 2, _("Electrical Type") ); - m_grid->SetColLabelValue( 3, _("Graphic Style") ); - m_grid->SetColLabelValue( 4, _("Orientation") ); - m_grid->SetColLabelValue( 5, _("Number Text Size") ); - m_grid->SetColLabelValue( 6, _("Name Text Size") ); - m_grid->SetColLabelValue( 7, _("Length") ); - m_grid->SetColLabelValue( 8, _("X Position") ); - m_grid->SetColLabelValue( 9, _("Y Position") ); - m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); - - // Rows - m_grid->EnableDragRowSize( false ); - m_grid->SetRowLabelSize( 0 ); - m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); - - // Label Appearance - - // Cell Defaults - m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_grid->SetMinSize( wxSize( 512,320 ) ); - - top_sizer->Add( m_grid, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 15 ); - - m_Buttons = new wxStdDialogButtonSizer(); - m_ButtonsOK = new wxButton( this, wxID_OK ); - m_Buttons->AddButton( m_ButtonsOK ); - m_ButtonsCancel = new wxButton( this, wxID_CANCEL ); - m_Buttons->AddButton( m_ButtonsCancel ); - m_Buttons->Realize(); - - top_sizer->Add( m_Buttons, 0, wxEXPAND|wxALL, 5 ); - - - this->SetSizer( top_sizer ); - this->Layout(); - top_sizer->Fit( this ); - - this->Centre( wxBOTH ); - - // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnClose ) ); - m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCellEdited ), NULL, this ); - m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnSize ), NULL, this ); - m_ButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCancel ), NULL, this ); -} - -DIALOG_SCH_PIN_TABLE_BASE::~DIALOG_SCH_PIN_TABLE_BASE() -{ - // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnClose ) ); - m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCellEdited ), NULL, this ); - m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnSize ), NULL, this ); - m_ButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCancel ), NULL, this ); - -} diff --git a/eeschema/dialogs/dialog_sch_pin_table_base.fbp b/eeschema/dialogs/dialog_sch_pin_table_base.fbp deleted file mode 100644 index 9093116986..0000000000 --- a/eeschema/dialogs/dialog_sch_pin_table_base.fbp +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_sch_pin_table_base - 1000 - none - - 1 - dialog_sch_pin_table - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - decl_pure_virtual - - - - 0 - wxID_ANY - - - DIALOG_SCH_PIN_TABLE_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Pin Table - - - - - OnClose - - - top_sizer - wxVERTICAL - none - - 15 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - 0 - - - - 1 - - - wxALIGN_LEFT - - wxALIGN_TOP - 0 - 1 - wxALIGN_CENTER - 24 - "Number" "Name" "Electrical Type" "Graphic Style" "Orientation" "Number Text Size" "Name Text Size" "Length" "X Position" "Y Position" - wxALIGN_CENTER - 4 - 84,140,140,140 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - 0 - 0 - 1 - 1 - - 1 - - - 1 - 0 - 0 - wxID_ANY - - - - 0 - 0 - - 0 - - - 0 - 512,320 - 1 - m_grid - 1 - - - protected - 1 - - Resizable - wxALIGN_CENTER - 0 - - wxALIGN_CENTER - - 5 - 1 - -1,-1 - WX_GRID; widgets/wx_grid.h; forward_declare - 0 - - - - - OnCellEdited - OnSize - - - - 5 - wxEXPAND|wxALL - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_Buttons - protected - OnCancel - - - - - - diff --git a/eeschema/dialogs/dialog_sch_pin_table_base.h b/eeschema/dialogs/dialog_sch_pin_table_base.h deleted file mode 100644 index 0b54f0f39c..0000000000 --- a/eeschema/dialogs/dialog_sch_pin_table_base.h +++ /dev/null @@ -1,55 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -class WX_GRID; - -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_SCH_PIN_TABLE_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_SCH_PIN_TABLE_BASE : public DIALOG_SHIM -{ - private: - - protected: - WX_GRID* m_grid; - wxStdDialogButtonSizer* m_Buttons; - wxButton* m_ButtonsOK; - wxButton* m_ButtonsCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnClose( wxCloseEvent& event ) = 0; - virtual void OnCellEdited( wxGridEvent& event ) = 0; - virtual void OnSize( wxSizeEvent& event ) = 0; - virtual void OnCancel( wxCommandEvent& event ) = 0; - - - public: - - DIALOG_SCH_PIN_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pin Table"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_SCH_PIN_TABLE_BASE(); - -}; -