Fold pin table in to Symbol Properties.

This commit is contained in:
Jeff Young 2020-09-02 12:50:07 +01:00
parent fa8138ee5a
commit c0bc47810a
11 changed files with 2320 additions and 2612 deletions

View File

@ -94,8 +94,6 @@ set( EESCHEMA_DLGS
dialogs/dialog_edit_sheet_pin.cpp dialogs/dialog_edit_sheet_pin.cpp
dialogs/dialog_sch_import_settings.cpp dialogs/dialog_sch_import_settings.cpp
dialogs/dialog_sch_import_settings_base.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.cpp
dialogs/dialog_sch_sheet_props_base.cpp dialogs/dialog_sch_sheet_props_base.cpp
dialogs/dialog_schematic_find.cpp dialogs/dialog_schematic_find.cpp

View File

@ -24,10 +24,12 @@
#include "dialog_edit_component_in_schematic.h" #include "dialog_edit_component_in_schematic.h"
#include <wx/tooltip.h> #include <wx/tooltip.h>
#include <grid_tricks.h>
#include <confirm.h> #include <confirm.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <pin_number.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_grid.h> #include <widgets/wx_grid.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <ee_collectors.h> #include <ee_collectors.h>
@ -38,19 +40,240 @@
#include <schematic.h> #include <schematic.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/actions.h> #include <tool/actions.h>
#include <dialog_sch_pin_table.h>
#ifdef KICAD_SPICE #ifdef KICAD_SPICE
#include <dialog_spice_model.h> #include <dialog_spice_model.h>
#endif /* KICAD_SPICE */ #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<SCH_PIN>
{
protected:
std::vector<wxGridCellAttr*> 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<const wxString, LIB_PIN::ALT>& 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<int>( aPin.GetType() )];
case COL_SHAPE: return PinShapeNames()[static_cast<int>( 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. ~(a<b) != (a>b)
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, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT_FRAME* aParent,
SCH_COMPONENT* aComponent ) : SCH_COMPONENT* aComponent ) :
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( aParent ) DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( aParent )
{ {
m_cmp = aComponent; m_comp = aComponent;
m_part = m_cmp->GetPartRef().get(); m_part = m_comp->GetPartRef().get();
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_part ); m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_part );
m_width = 0; m_width = 0;
@ -62,7 +285,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
#endif /* not KICAD_SPICE */ #endif /* not KICAD_SPICE */
// disable some options inside the edit dialog which can cause problems while dragging // 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_orientationLabel->Disable();
m_orientationCtrl->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 // 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_fieldsGrid->SetTable( m_fields );
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this ) );
// Show/hide columns according to user's preference // Show/hide columns according to user's preference
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
@ -82,9 +306,21 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
if( cfg ) if( cfg )
{ {
m_shownColumns = cfg->m_Appearance.edit_component_visible_columns; 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<SCH_PIN>& 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: // Set font size for items showing long strings:
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL ); 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 ) ); m_bpMoveDown->SetBitmap( KiBitmap( small_down_xpm ) );
// wxFormBuilder doesn't include this event... // wxFormBuilder doesn't include this event...
m_grid->Connect( wxEVT_GRID_CELL_CHANGING, m_fieldsGrid->Connect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ), wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ),
NULL, this ); nullptr, this );
m_pinGrid->Connect( wxEVT_GRID_COL_SORT,
wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnPinTableColSort ),
nullptr, this );
FinishDialogSettings(); FinishDialogSettings();
} }
@ -115,17 +355,22 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC()
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
if( cfg ) 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 // 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, m_fieldsGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ), wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging ),
NULL, this ); nullptr, this );
m_pinGrid->Disconnect( wxEVT_GRID_COL_SORT,
wxGridEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnPinTableColSort ),
nullptr, this );
// Delete the GRID_TRICKS. // 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<wxString> defined; std::set<wxString> defined;
// Push a copy of each field into m_updateFields // 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 // change offset to be symbol-relative
field.Offset( -m_cmp->GetPosition() ); field.Offset( -m_comp->GetPosition() );
defined.insert( field.GetName() ); defined.insert( field.GetName() );
m_fields->push_back( field ); m_fields->push_back( field );
@ -160,7 +405,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
{ {
if( defined.count( templateFieldname.m_Name ) <= 0 ) 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 ); field.SetVisible( templateFieldname.m_Visible );
m_fields->push_back( field ); m_fields->push_back( field );
} }
@ -168,17 +413,17 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
// notify the grid // notify the grid
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() ); wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
m_grid->ProcessTableMessage( msg ); m_fieldsGrid->ProcessTableMessage( msg );
AdjustGridColumns( m_grid->GetRect().GetWidth() ); AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() );
// If a multi-unit component, set up the unit selector and interchangeable checkbox. // 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 ) ); m_unitChoice->Append( LIB_PART::SubReference( ii, false ) );
if( m_cmp->GetUnit() <= ( int )m_unitChoice->GetCount() ) if( m_comp->GetUnit() <= ( int )m_unitChoice->GetCount() )
m_unitChoice->SetSelection( m_cmp->GetUnit() - 1 ); m_unitChoice->SetSelection( m_comp->GetUnit() - 1 );
} }
else else
{ {
@ -188,14 +433,14 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
if( m_part != nullptr && m_part->HasConversion() ) 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 ); m_cbAlternateSymbol->SetValue( true );
} }
else else
m_cbAlternateSymbol->Enable( false ); m_cbAlternateSymbol->Enable( false );
// Set the symbol orientation and mirroring. // 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 ) switch( orientation )
{ {
@ -206,7 +451,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
case CMP_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break; 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 ) switch( mirror )
{ {
@ -215,14 +460,14 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
case CMP_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break; case CMP_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
} }
m_cbExcludeFromBom->SetValue( !m_cmp->GetIncludeInBom() ); m_cbExcludeFromBom->SetValue( !m_comp->GetIncludeInBom() );
m_cbExcludeFromBoard->SetValue( !m_cmp->GetIncludeOnBoard() ); m_cbExcludeFromBoard->SetValue( !m_comp->GetIncludeOnBoard() );
m_ShowPinNumButt->SetValue( m_part->ShowPinNumbers() ); m_ShowPinNumButt->SetValue( m_part->ShowPinNumbers() );
m_ShowPinNameButt->SetValue( m_part->ShowPinNames() ); m_ShowPinNameButt->SetValue( m_part->ShowPinNames() );
// Set the component's library name. // Set the component's library name.
m_tcLibraryID->SetValue( m_cmp->GetLibId().Format() ); m_tcLibraryID->SetValue( m_comp->GetLibId().Format() );
Layout(); Layout();
@ -235,7 +480,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditSpiceModel( wxCommandEvent& event
#ifdef KICAD_SPICE #ifdef KICAD_SPICE
int diff = m_fields->size(); 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 ) if( dialog.ShowModal() != wxID_OK )
return; return;
@ -245,27 +490,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditSpiceModel( wxCommandEvent& event
if( diff > 0 ) if( diff > 0 )
{ {
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff ); wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff );
m_grid->ProcessTableMessage( msg ); m_fieldsGrid->ProcessTableMessage( msg );
} }
else if( diff < 0 ) else if( diff < 0 )
{ {
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, -diff ); 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 */ #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 ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
{ {
// Running the Footprint Browser gums up the works and causes the automatic cancel // 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; wxString msg;
LIB_ID id; LIB_ID id;
if( !m_grid->CommitPendingChanges() || !m_grid->Validate() ) if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
return false; return false;
if( !SCH_COMPONENT::IsReferenceStringValid( m_fields->at( REFERENCE ).GetText() ) ) 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. if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
return false; return false;
if( !m_fieldsGrid->CommitPendingChanges() )
return false;
if( !m_pinGrid->CommitPendingChanges() )
return false;
SCH_SCREEN* currentScreen = GetParent()->GetScreen(); SCH_SCREEN* currentScreen = GetParent()->GetScreen();
SCHEMATIC& schematic = GetParent()->Schematic(); 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 // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
// the schematic file. // the schematic file.
currentScreen->Remove( m_cmp ); currentScreen->Remove( m_comp );
wxString msg; wxString msg;
// save old cmp in undo list if not already in edit, or moving ... // save old cmp in undo list if not already in edit, or moving ...
if( m_cmp->GetEditFlags() == 0 ) if( m_comp->GetEditFlags() == 0 )
GetParent()->SaveCopyInUndoList( currentScreen, m_cmp, UNDO_REDO::CHANGED, false ); GetParent()->SaveCopyInUndoList( currentScreen, m_comp, UNDO_REDO::CHANGED, false );
// Save current flags which could be modified by next change settings // 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: // For symbols with multiple shapes (De Morgan representation) Set the selected shape:
if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() ) if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
m_cmp->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN ); m_comp->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN );
else 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 //Set the part selection in multiple part per package
int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1; int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
m_cmp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection ); m_comp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
m_cmp->SetUnit( unit_selection ); m_comp->SetUnit( unit_selection );
switch( m_orientationCtrl->GetSelection() ) switch( m_orientationCtrl->GetSelection() )
{ {
case 0: m_cmp->SetOrientation( CMP_ORIENT_0 ); break; case 0: m_comp->SetOrientation( CMP_ORIENT_0 ); break;
case 1: m_cmp->SetOrientation( CMP_ORIENT_90 ); break; case 1: m_comp->SetOrientation( CMP_ORIENT_90 ); break;
case 2: m_cmp->SetOrientation( CMP_ORIENT_270 ); break; case 2: m_comp->SetOrientation( CMP_ORIENT_270 ); break;
case 3: m_cmp->SetOrientation( CMP_ORIENT_180 ); break; case 3: m_comp->SetOrientation( CMP_ORIENT_180 ); break;
} }
switch( m_mirrorCtrl->GetSelection() ) switch( m_mirrorCtrl->GetSelection() )
{ {
case 0: break; case 0: break;
case 1: m_cmp->SetOrientation( CMP_MIRROR_X ); break; case 1: m_comp->SetOrientation( CMP_MIRROR_X ); break;
case 2: m_cmp->SetOrientation( CMP_MIRROR_Y ); break; case 2: m_comp->SetOrientation( CMP_MIRROR_Y ); break;
} }
m_part->SetShowPinNames( m_ShowPinNameButt->GetValue() ); m_part->SetShowPinNames( m_ShowPinNameButt->GetValue() );
m_part->SetShowPinNumbers( m_ShowPinNumButt->GetValue() ); m_part->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
// Restore m_Flag modified by SetUnit() and other change settings // Restore m_Flag modified by SetUnit() and other change settings
m_cmp->ClearFlags(); m_comp->ClearFlags();
m_cmp->SetFlags( flags ); m_comp->SetFlags( flags );
// change all field positions from relative to absolute // change all field positions from relative to absolute
for( unsigned i = 0; i < m_fields->size(); ++i ) 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() ) 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 // Push all fields to the component -except- for those which are TEMPLATE_FIELDNAMES
// with empty values. // with empty values.
SCH_FIELDS& fields = m_cmp->GetFields(); SCH_FIELDS& fields = m_comp->GetFields();
fields.clear(); fields.clear();
@ -409,21 +652,21 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow()
// Reference has a specific initialization, depending on the current active sheet // 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 // because for a given component, in a complex hierarchy, there are more than one
// reference. // 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_comp->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() );
m_cmp->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() ); m_comp->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() );
// The value, footprint and datasheet fields and exclude from bill of materials setting // The value, footprint and datasheet fields and exclude from bill of materials setting
// should be kept in sync in multi-unit parts. // 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() ) for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() )
{ {
SCH_SCREEN* screen = sheet.LastScreen(); SCH_SCREEN* screen = sheet.LastScreen();
std::vector<SCH_COMPONENT*> otherUnits; std::vector<SCH_COMPONENT*> otherUnits;
CollectOtherUnits( sheet, m_cmp, &otherUnits ); CollectOtherUnits( sheet, m_comp, &otherUnits );
for( SCH_COMPONENT* otherUnit : 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()->TestDanglingEnds();
GetParent()->UpdateItem( m_cmp ); GetParent()->UpdateItem( m_comp );
GetParent()->OnModify(); GetParent()->OnModify();
// This must go after OnModify() so that the connectivity graph will have been updated. // 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 ) 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(); wxControl* control = editor->GetControl();
if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) ) 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(); 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() ) if( i == event.GetRow() )
continue; 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." ), DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ),
newName ) ); newName ) );
@ -487,12 +738,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellChanging( wxGridEvent& event
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField( wxCommandEvent& event )
{ {
if( !m_grid->CommitPendingChanges() ) if( !m_fieldsGrid->CommitPendingChanges() )
return; return;
SCHEMATIC_SETTINGS& settings = m_cmp->Schematic()->Settings(); SCHEMATIC_SETTINGS& settings = m_comp->Schematic()->Settings();
int fieldID = m_fields->size(); 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 ) ); TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID ) );
newField.SetTextAngle( m_fields->at( REFERENCE ).GetTextAngle() ); newField.SetTextAngle( m_fields->at( REFERENCE ).GetTextAngle() );
@ -502,19 +753,19 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField( wxCommandEvent& event )
// notify the grid // notify the grid
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 ); 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_fieldsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
m_grid->SetGridCursor( (int) m_fields->size() - 1, 0 ); m_fieldsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 );
m_grid->EnableCellEditControl(); m_fieldsGrid->EnableCellEditControl();
m_grid->ShowCellEditControl(); m_fieldsGrid->ShowCellEditControl();
} }
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnDeleteField( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnDeleteField( wxCommandEvent& event )
{ {
int curRow = m_grid->GetGridCursorRow(); int curRow = m_fieldsGrid->GetGridCursorRow();
if( curRow < 0 ) if( curRow < 0 )
{ {
@ -527,38 +778,38 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnDeleteField( wxCommandEvent& event )
return; return;
} }
m_grid->CommitPendingChanges( true /* quiet mode */ ); m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ );
m_fields->erase( m_fields->begin() + curRow ); m_fields->erase( m_fields->begin() + curRow );
// notify the grid // notify the grid
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 ); 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_fieldsGrid->MakeCellVisible( std::max( 0, curRow-1 ), m_fieldsGrid->GetGridCursorCol() );
m_grid->SetGridCursor( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() ); m_fieldsGrid->SetGridCursor( std::max( 0, curRow-1 ), m_fieldsGrid->GetGridCursorCol() );
} }
} }
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveUp( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveUp( wxCommandEvent& event )
{ {
if( !m_grid->CommitPendingChanges() ) if( !m_fieldsGrid->CommitPendingChanges() )
return; return;
int i = m_grid->GetGridCursorRow(); int i = m_fieldsGrid->GetGridCursorRow();
if( i > MANDATORY_FIELDS ) if( i > MANDATORY_FIELDS )
{ {
SCH_FIELD tmp = m_fields->at( (unsigned) i ); SCH_FIELD tmp = m_fields->at( (unsigned) i );
m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 ); m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
m_fields->insert( m_fields->begin() + i - 1, tmp ); m_fields->insert( m_fields->begin() + i - 1, tmp );
m_grid->ForceRefresh(); m_fieldsGrid->ForceRefresh();
m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() ); m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() );
m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(), m_fieldsGrid->GetGridCursorCol() );
} }
else else
{ {
@ -569,20 +820,20 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveUp( wxCommandEvent& event )
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveDown( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnMoveDown( wxCommandEvent& event )
{ {
if( !m_grid->CommitPendingChanges() ) if( !m_fieldsGrid->CommitPendingChanges() )
return; 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 ); SCH_FIELD tmp = m_fields->at( (unsigned) i );
m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 ); m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
m_fields->insert( m_fields->begin() + i + 1, tmp ); m_fields->insert( m_fields->begin() + i + 1, tmp );
m_grid->ForceRefresh(); m_fieldsGrid->ForceRefresh();
m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() ); m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() );
m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() ); m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(), m_fieldsGrid->GetGridCursorCol() );
} }
else 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 ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::AdjustGridColumns( int aWidth )
{ {
wxGridUpdateLocker deferRepaintsTillLeavingScope;
m_width = aWidth; m_width = aWidth;
// Account for scroll bars // 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++ ) for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
fixedColsWidth += m_grid->GetColSize( 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 ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event )
{ {
wxString shownColumns = m_grid->GetShownColumns(); wxString shownColumns = m_fieldsGrid->GetShownColumns();
if( shownColumns != m_shownColumns ) if( shownColumns != m_shownColumns )
{ {
m_shownColumns = shownColumns; m_shownColumns = shownColumns;
if( !m_grid->IsCellEditControlShown() ) if( !m_fieldsGrid->IsCellEditControlShown() )
AdjustGridColumns( m_grid->GetRect().GetWidth() ); AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() );
} }
// Handle a delayed focus // Handle a delayed focus
if( m_delayedFocusRow >= 0 ) if( m_delayedFocusRow >= 0 )
{ {
m_grid->SetFocus(); m_fieldsGrid->SetFocus();
m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn ); m_fieldsGrid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
m_grid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn ); m_fieldsGrid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn );
m_grid->EnableCellEditControl( true ); m_fieldsGrid->EnableCellEditControl( true );
m_grid->ShowCellEditControl(); m_fieldsGrid->ShowCellEditControl();
m_delayedFocusRow = -1; m_delayedFocusRow = -1;
m_delayedFocusColumn = -1; m_delayedFocusColumn = -1;

View File

@ -26,12 +26,13 @@
#define _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ #define _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_
#include <dialog_edit_component_in_schematic_base.h> #include <dialog_edit_component_in_schematic_base.h>
#include <fields_grid_table.h> #include <fields_grid_table.h>
#include <sch_pin.h>
class SCH_EDIT_FRAME;
class LIB_PART; class LIB_PART;
class SCH_PIN_TABLE_DATA_MODEL;
class SCH_EDIT_FRAME;
// The dialog can be closed for several reasons. // The dialog can be closed for several reasons.
@ -71,7 +72,8 @@ private:
void OnMoveUp( wxCommandEvent& event ) override; void OnMoveUp( wxCommandEvent& event ) override;
void OnMoveDown( wxCommandEvent& event ) override; void OnMoveDown( wxCommandEvent& event ) override;
void OnEditSpiceModel( 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 OnSizeGrid( wxSizeEvent& event ) override;
void OnGridCellChanging( wxGridEvent& event ); void OnGridCellChanging( wxGridEvent& event );
void OnUpdateUI( wxUpdateUIEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override;
@ -86,7 +88,7 @@ private:
void AdjustGridColumns( int aWidth ); void AdjustGridColumns( int aWidth );
private: private:
SCH_COMPONENT* m_cmp; SCH_COMPONENT* m_comp;
LIB_PART* m_part; LIB_PART* m_part;
int m_width; int m_width;
@ -95,6 +97,7 @@ private:
wxString m_shownColumns; wxString m_shownColumns;
FIELDS_GRID_TABLE<SCH_FIELD>* m_fields; FIELDS_GRID_TABLE<SCH_FIELD>* m_fields;
SCH_PIN_TABLE_DATA_MODEL* m_dataModel;
}; };
#endif // _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_ #endif // _DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_H_

View File

@ -18,58 +18,63 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE
wxBoxSizer* mainSizer; wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxVERTICAL ); mainSizer = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbFields; m_notebook1 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
sbFields = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxVERTICAL ); 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 // Grid
m_grid->CreateGrid( 4, 11 ); m_fieldsGrid->CreateGrid( 4, 11 );
m_grid->EnableEditing( true ); m_fieldsGrid->EnableEditing( true );
m_grid->EnableGridLines( true ); m_fieldsGrid->EnableGridLines( true );
m_grid->EnableDragGridSize( false ); m_fieldsGrid->EnableDragGridSize( false );
m_grid->SetMargins( 0, 0 ); m_fieldsGrid->SetMargins( 0, 0 );
// Columns // Columns
m_grid->SetColSize( 0, 72 ); m_fieldsGrid->SetColSize( 0, 72 );
m_grid->SetColSize( 1, 120 ); m_fieldsGrid->SetColSize( 1, 120 );
m_grid->SetColSize( 2, 48 ); m_fieldsGrid->SetColSize( 2, 48 );
m_grid->SetColSize( 3, 72 ); m_fieldsGrid->SetColSize( 3, 72 );
m_grid->SetColSize( 4, 72 ); m_fieldsGrid->SetColSize( 4, 72 );
m_grid->SetColSize( 5, 48 ); m_fieldsGrid->SetColSize( 5, 48 );
m_grid->SetColSize( 6, 48 ); m_fieldsGrid->SetColSize( 6, 48 );
m_grid->SetColSize( 7, 84 ); m_fieldsGrid->SetColSize( 7, 84 );
m_grid->SetColSize( 8, 84 ); m_fieldsGrid->SetColSize( 8, 84 );
m_grid->SetColSize( 9, 84 ); m_fieldsGrid->SetColSize( 9, 84 );
m_grid->SetColSize( 10, 84 ); m_fieldsGrid->SetColSize( 10, 84 );
m_grid->EnableDragColMove( false ); m_fieldsGrid->EnableDragColMove( false );
m_grid->EnableDragColSize( true ); m_fieldsGrid->EnableDragColSize( true );
m_grid->SetColLabelSize( 22 ); m_fieldsGrid->SetColLabelSize( 22 );
m_grid->SetColLabelValue( 0, _("Name") ); m_fieldsGrid->SetColLabelValue( 0, _("Name") );
m_grid->SetColLabelValue( 1, _("Value") ); m_fieldsGrid->SetColLabelValue( 1, _("Value") );
m_grid->SetColLabelValue( 2, _("Show") ); m_fieldsGrid->SetColLabelValue( 2, _("Show") );
m_grid->SetColLabelValue( 3, _("H Align") ); m_fieldsGrid->SetColLabelValue( 3, _("H Align") );
m_grid->SetColLabelValue( 4, _("V Align") ); m_fieldsGrid->SetColLabelValue( 4, _("V Align") );
m_grid->SetColLabelValue( 5, _("Italic") ); m_fieldsGrid->SetColLabelValue( 5, _("Italic") );
m_grid->SetColLabelValue( 6, _("Bold") ); m_fieldsGrid->SetColLabelValue( 6, _("Bold") );
m_grid->SetColLabelValue( 7, _("Text Size") ); m_fieldsGrid->SetColLabelValue( 7, _("Text Size") );
m_grid->SetColLabelValue( 8, _("Orientation") ); m_fieldsGrid->SetColLabelValue( 8, _("Orientation") );
m_grid->SetColLabelValue( 9, _("X Position") ); m_fieldsGrid->SetColLabelValue( 9, _("X Position") );
m_grid->SetColLabelValue( 10, _("Y Position") ); m_fieldsGrid->SetColLabelValue( 10, _("Y Position") );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); m_fieldsGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows // Rows
m_grid->EnableDragRowSize( true ); m_fieldsGrid->EnableDragRowSize( true );
m_grid->SetRowLabelSize( 0 ); m_fieldsGrid->SetRowLabelSize( 0 );
m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); m_fieldsGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Label Appearance // Label Appearance
// Cell Defaults // Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_fieldsGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_grid->SetMinSize( wxSize( -1,180 ) ); 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; wxBoxSizer* bButtonSize;
bButtonSize = new wxBoxSizer( wxHORIZONTAL ); 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 ); 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; wxBoxSizer* bLowerSizer;
bLowerSizer = new wxBoxSizer( wxHORIZONTAL ); bLowerSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbGeneralProps; wxStaticBoxSizer* sbGeneralProps;
sbGeneralProps = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General") ), wxHORIZONTAL ); sbGeneralProps = new wxStaticBoxSizer( new wxStaticBox( generalPage, wxID_ANY, _("General") ), wxHORIZONTAL );
wxGridBagSizer* gbSizer1; wxGridBagSizer* gbSizer1;
gbSizer1 = new wxGridBagSizer( 3, 3 ); 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 ); bMiddleCol = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizerPinTextOpts; 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 = new wxCheckBox( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, _("Show pin numbers"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowPinNumButt->SetValue(true); 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 ); bMiddleCol->Add( sbSizerPinTextOpts, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbAttributes; 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 = 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") ); 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; wxBoxSizer* buttonsSizer;
buttonsSizer = new wxBoxSizer( wxVERTICAL ); 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 ); 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 ); 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 ); 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 );
m_editLibrarySymbolBtn = new wxButton( generalPage, wxID_ANY, _("Edit Library Symbol..."), wxDefaultPosition, wxDefaultSize, 0 );
buttonsSizer->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
m_editLibrarySymbolBtn = new wxButton( this, wxID_ANY, _("Edit Library Symbol..."), wxDefaultPosition, wxDefaultSize, 0 );
buttonsSizer->Add( m_editLibrarySymbolBtn, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); 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; wxBoxSizer* bSizerBottom;
bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); bSizerBottom = new wxBoxSizer( wxHORIZONTAL );
@ -281,7 +339,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE
// Connect Events // Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnInitDlg ) ); 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 ) ); 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_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_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 ); 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_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_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_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_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_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 ); 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 // Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnInitDlg ) ); 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 ) ); 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_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_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 ); 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_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_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_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_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_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 ); m_stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnCancelButtonClick ), NULL, this );

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,8 @@ class WX_GRID;
#include <wx/choice.h> #include <wx/choice.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/gbsizer.h> #include <wx/gbsizer.h>
#include <wx/statline.h> #include <wx/panel.h>
#include <wx/notebook.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -45,7 +46,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM
private: private:
protected: protected:
WX_GRID* m_grid; wxNotebook* m_notebook1;
wxPanel* generalPage;
WX_GRID* m_fieldsGrid;
wxBitmapButton* m_bpAdd; wxBitmapButton* m_bpAdd;
wxBitmapButton* m_bpMoveUp; wxBitmapButton* m_bpMoveUp;
wxBitmapButton* m_bpMoveDown; wxBitmapButton* m_bpMoveDown;
@ -64,9 +67,9 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM
wxButton* m_updateSymbolBtn; wxButton* m_updateSymbolBtn;
wxButton* m_changeSymbolBtn; wxButton* m_changeSymbolBtn;
wxButton* m_editSchematicSymbolBtn; wxButton* m_editSchematicSymbolBtn;
wxButton* m_pinTableButton;
wxButton* m_editLibrarySymbolBtn; wxButton* m_editLibrarySymbolBtn;
wxStaticLine* m_staticline1; wxPanel* m_pinTablePage;
WX_GRID* m_pinGrid;
wxStaticText* m_libraryIDLabel; wxStaticText* m_libraryIDLabel;
wxTextCtrl* m_tcLibraryID; wxTextCtrl* m_tcLibraryID;
wxButton* m_spiceFieldsButton; 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 OnUpdateSymbol( wxCommandEvent& event ) { event.Skip(); }
virtual void OnExchangeSymbol( wxCommandEvent& event ) { event.Skip(); } virtual void OnExchangeSymbol( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEditSymbol( 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 OnEditLibrarySymbol( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPinTableCellEdited( wxGridEvent& event ) { event.Skip(); }
virtual void OnEditSpiceModel( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditSpiceModel( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); }

View File

@ -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 <grid_tricks.h>
#include <pin_number.h>
#include <sch_edit_frame.h>
#include <confirm.h>
#include <lib_edit_frame.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_grid.h>
#include <settings/settings_manager.h>
#include <widgets/grid_combobox.h>
class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector<SCH_PIN>
{
protected:
std::vector<wxGridCellAttr*> 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<const wxString, LIB_PIN::ALT>& 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<int>( aPin.GetType() )];
case COL_SHAPE: return PinShapeNames()[static_cast<int>( 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. ~(a<b) != (a>b)
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<SCH_PIN>& 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 );
}

View File

@ -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 <sch_pin.h>
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
};

View File

@ -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 );
}

View File

@ -1,174 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_sch_pin_table_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_sch_pin_table</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">decl_pure_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_SCH_PIN_TABLE_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Pin Table</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnClose">OnClose</event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">top_sizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">15</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property>
<property name="proportion">1</property>
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="autosize_cols">0</property>
<property name="autosize_rows">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="cell_bg"></property>
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">24</property>
<property name="col_label_values">&quot;Number&quot; &quot;Name&quot; &quot;Electrical Type&quot; &quot;Graphic Style&quot; &quot;Orientation&quot; &quot;Number Text Size&quot; &quot;Name Text Size&quot; &quot;Length&quot; &quot;X Position&quot; &quot;Y Position&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">4</property>
<property name="column_sizes">84,140,140,140</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_col_move">0</property>
<property name="drag_col_size">1</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">0</property>
<property name="editing">1</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label_bg"></property>
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">0</property>
<property name="margin_width">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">512,320</property>
<property name="moveable">1</property>
<property name="name">m_grid</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="row_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="row_label_size">0</property>
<property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTER</property>
<property name="row_sizes"></property>
<property name="rows">5</property>
<property name="show">1</property>
<property name="size">-1,-1</property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnGridCellChange">OnCellEdited</event>
<event name="OnSize">OnSize</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_Buttons</property>
<property name="permission">protected</property>
<event name="OnCancelButtonClick">OnCancel</event>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -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 <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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();
};