From 6dd4e01f16eef127421855d97a9f823054602997 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 27 Aug 2025 17:24:41 +0100 Subject: [PATCH] ADDED: custom body styles. (Also moves editing of unit display names to the Symbol Properties dialog and retires the Set Unit Display Name dialog.) Fixes https://gitlab.com/kicad/code/kicad/-/issues/16069 Fixes https://gitlab.com/kicad/code/kicad/-/issues/14843 --- common/tool/action_toolbar.cpp | 4 + eeschema/dialogs/dialog_field_properties.cpp | 2 +- .../dialogs/dialog_lib_edit_pin_table.cpp | 212 +-- eeschema/dialogs/dialog_lib_edit_pin_table.h | 2 +- .../dialog_lib_edit_pin_table_base.cpp | 5 +- .../dialog_lib_edit_pin_table_base.fbp | 4 +- .../dialogs/dialog_lib_symbol_properties.cpp | 266 ++- .../dialogs/dialog_lib_symbol_properties.h | 12 +- .../dialog_lib_symbol_properties_base.cpp | 311 +++- .../dialog_lib_symbol_properties_base.fbp | 1434 +++++++++++++---- .../dialog_lib_symbol_properties_base.h | 37 +- eeschema/dialogs/dialog_pin_properties.cpp | 17 +- .../dialogs/dialog_pin_properties_base.cpp | 2 +- .../dialogs/dialog_pin_properties_base.fbp | 2 +- eeschema/dialogs/dialog_rescue_each.cpp | 8 +- eeschema/dialogs/dialog_shape_properties.cpp | 18 +- .../dialogs/dialog_shape_properties_base.cpp | 2 +- .../dialogs/dialog_shape_properties_base.fbp | 2 +- eeschema/dialogs/dialog_sim_model.cpp | 4 +- eeschema/dialogs/dialog_symbol_properties.cpp | 36 +- .../dialogs/dialog_symbol_properties_base.cpp | 18 +- .../dialogs/dialog_symbol_properties_base.fbp | 92 +- .../dialogs/dialog_symbol_properties_base.h | 7 +- eeschema/dialogs/dialog_text_properties.cpp | 9 +- eeschema/eeschema_id.h | 12 +- eeschema/eeschema_jobs_handler.cpp | 19 +- eeschema/erc/erc.cpp | 2 +- eeschema/lib_symbol.cpp | 93 +- eeschema/lib_symbol.h | 80 +- eeschema/picksymbol.cpp | 31 +- eeschema/project_rescue.cpp | 101 +- eeschema/project_rescue.h | 65 +- eeschema/sch_collectors.cpp | 8 +- eeschema/sch_collectors.h | 10 +- eeschema/sch_edit_frame.h | 12 +- eeschema/sch_field.cpp | 2 +- eeschema/sch_file_versions.h | 3 +- eeschema/sch_io/altium/sch_io_altium.cpp | 4 +- .../cadstar/cadstar_sch_archive_loader.cpp | 6 +- eeschema/sch_io/eagle/sch_io_eagle.cpp | 4 +- .../sch_io_kicad_legacy_lib_cache.cpp | 33 +- .../sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp | 4 +- .../sch_io_kicad_sexpr_lib_cache.cpp | 21 +- .../kicad_sexpr/sch_io_kicad_sexpr_parser.cpp | 64 +- .../kicad_sexpr/sch_io_kicad_sexpr_parser.h | 4 +- eeschema/sch_item.cpp | 8 +- eeschema/sch_symbol.cpp | 55 +- eeschema/sch_symbol.h | 24 +- eeschema/schematic.keywords | 3 + eeschema/symbol.h | 21 +- eeschema/symbol_checker.cpp | 12 +- .../lib_symbol_library_manager.cpp | 5 +- .../symbol_editor/menubar_symbol_editor.cpp | 1 - eeschema/symbol_editor/symbol_edit_frame.cpp | 152 +- eeschema/symbol_editor/symbol_edit_frame.h | 32 +- eeschema/symbol_editor/symbol_editor.cpp | 21 +- .../symbol_editor/symbol_editor_undo_redo.cpp | 6 +- .../symbol_editor/toolbars_symbol_editor.cpp | 18 +- eeschema/symbol_viewer_frame.cpp | 80 +- eeschema/symbol_viewer_frame.h | 3 + eeschema/toolbars_symbol_viewer.cpp | 18 +- eeschema/tools/sch_actions.cpp | 28 +- eeschema/tools/sch_actions.h | 5 +- eeschema/tools/sch_drawing_tools.cpp | 10 +- eeschema/tools/sch_edit_tool.cpp | 59 +- eeschema/tools/sch_edit_tool.h | 2 +- eeschema/tools/sch_move_tool.cpp | 8 +- eeschema/tools/sch_selection_tool.cpp | 28 +- eeschema/tools/sch_selection_tool.h | 2 +- eeschema/tools/symbol_editor_control.cpp | 29 - eeschema/tools/symbol_editor_control.h | 2 - eeschema/tools/symbol_editor_edit_tool.cpp | 52 +- eeschema/tools/symbol_editor_edit_tool.h | 2 - eeschema/widgets/panel_symbol_chooser.cpp | 26 +- eeschema/widgets/symbol_diff_widget.cpp | 9 +- eeschema/widgets/symbol_diff_widget.h | 2 +- eeschema/widgets/symbol_preview_widget.cpp | 22 +- include/tool/action_toolbar.h | 1 + qa/tests/eeschema/test_lib_part.cpp | 23 +- 79 files changed, 2543 insertions(+), 1310 deletions(-) diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index 68198c6edb..4e5f8aff1d 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -1039,5 +1039,9 @@ ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::layerSelector( "control.LayerSel ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::unitSelector( "control.UnitSelector", _( "Symbol unit selector" ), _( "Displays the current unit" ) ); +ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::bodyStyleSelector( "control.BodyStyleSelector", + _( "Symbol body style selector" ), + _( "Displays the current body style" ) ); + ACTION_TOOLBAR_CONTROL ACTION_TOOLBAR_CONTROLS::overrideLocks( "control.OverrideLocks", _( "Override locks" ), _( "Allow moving of locked items with the mouse" ) ); \ No newline at end of file diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index d5ceb6d569..c73d2db857 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -306,7 +306,7 @@ void DIALOG_FIELD_PROPERTIES::init() bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE && m_field->GetParentSymbol() && m_field->GetParentSymbol()->Type() == SCH_SYMBOL_T - && m_field->GetParentSymbol()->IsMulti(); + && m_field->GetParentSymbol()->IsMultiUnit(); m_unitLabel->Show( showUnitSelector ); m_unitChoice->Show( showUnitSelector ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index caa578e218..46697b229d 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -56,11 +56,6 @@ #define BOOL_TRUE _HKI( "True" ) #define BOOL_FALSE _HKI( "False" ) -#define UNITS_ALL _HKI( "ALL" ) -#define DEMORGAN_ALL _HKI( "ALL" ) -#define DEMORGAN_STD _HKI( "Standard" ) -#define DEMORGAN_ALT _HKI( "Alternate" ) - /** * Get the label for a given column in the pin table. @@ -84,7 +79,7 @@ static wxString GetPinTableColLabel( int aCol ) case COL_POSY: return _HKI( "Y Position" ); case COL_VISIBLE: return _HKI( "Visible" ); case COL_UNIT: return _HKI( "Unit" ); - case COL_DEMORGAN: return _HKI( "De Morgan" ); + case COL_BODY_STYLE: return _HKI( "Body Style" ); default: wxFAIL; return wxEmptyString; } } @@ -131,71 +126,64 @@ public: wxString Format( const SCH_PIN& aPin, int aFieldId ) const { - wxString val; switch( aFieldId ) { case COL_NAME: - val << aPin.GetName(); - break; + return aPin.GetName(); + case COL_NUMBER: - val << aPin.GetNumber(); - break; + return aPin.GetNumber(); + case COL_TYPE: - val << PinTypeNames()[static_cast( aPin.GetType() )]; - break; + return PinTypeNames()[static_cast( aPin.GetType() )]; + case COL_SHAPE: - val << PinShapeNames()[static_cast( aPin.GetShape() )]; - break; + return PinShapeNames()[static_cast( aPin.GetShape() )]; + case COL_ORIENTATION: { const int index = PinOrientationIndex( aPin.GetOrientation() ); + if( index >= 0) - val << PinOrientationNames()[ index ]; - break; + return PinOrientationNames()[ index ]; + + return wxEmptyString; } + case COL_NUMBER_SIZE: - val << m_unitsProvider.StringFromValue( aPin.GetNumberTextSize(), m_includeUnits ); - break; + return m_unitsProvider.StringFromValue( aPin.GetNumberTextSize(), m_includeUnits ); + case COL_NAME_SIZE: - val << m_unitsProvider.StringFromValue( aPin.GetNameTextSize(), m_includeUnits ); - break; + return m_unitsProvider.StringFromValue( aPin.GetNameTextSize(), m_includeUnits ); + case COL_LENGTH: - val << m_unitsProvider.StringFromValue( aPin.GetLength(), m_includeUnits ); - break; + return m_unitsProvider.StringFromValue( aPin.GetLength(), m_includeUnits ); + case COL_POSX: - val << m_unitsProvider.StringFromValue( aPin.GetPosition().x, m_includeUnits ); - break; + return m_unitsProvider.StringFromValue( aPin.GetPosition().x, m_includeUnits ); + case COL_POSY: - val << m_unitsProvider.StringFromValue( aPin.GetPosition().y, m_includeUnits ); - break; + return m_unitsProvider.StringFromValue( aPin.GetPosition().y, m_includeUnits ); + case COL_VISIBLE: - val << stringFromBool( aPin.IsVisible() ); - break; + return stringFromBool( aPin.IsVisible() ); + case COL_UNIT: - if( aPin.GetUnit() ) - val << LIB_SYMBOL::LetterSubReference( aPin.GetUnit(), 'A' ); - else - val << wxGetTranslation( UNITS_ALL ); - break; - case COL_DEMORGAN: - switch( aPin.GetBodyStyle() ) - { - case BODY_STYLE::BASE: - val << wxGetTranslation( DEMORGAN_STD ); - break; - case BODY_STYLE::DEMORGAN: - val << wxGetTranslation( DEMORGAN_ALT ); - break; - default: - val << wxGetTranslation( DEMORGAN_ALL ); - break; - } - break; + if( aPin.GetUnit() == 0 ) + return wxGetTranslation( UNITS_ALL ); + + return aPin.GetUnitDisplayName( aPin.GetUnit(), true ); + + case COL_BODY_STYLE: + if( aPin.GetBodyStyle() == 0 ) + return wxGetTranslation( DEMORGAN_ALL ); + + return aPin.GetBodyStyleDescription( aPin.GetBodyStyle(), true ); + default: wxFAIL_MSG( wxString::Format( "Invalid field id %d", aFieldId ) ); - break; + return wxEmptyString; } - return val; } /** @@ -219,16 +207,19 @@ public: case COL_TYPE: if( PinTypeNames().Index( aValue, false ) != wxNOT_FOUND ) aPin.SetType( (ELECTRICAL_PINTYPE) PinTypeNames().Index( aValue ) ); + break; case COL_SHAPE: if( PinShapeNames().Index( aValue, false ) != wxNOT_FOUND ) aPin.SetShape( (GRAPHIC_PINSHAPE) PinShapeNames().Index( aValue ) ); + break; case COL_ORIENTATION: if( PinOrientationNames().Index( aValue, false ) != wxNOT_FOUND ) aPin.SetOrientation( (PIN_ORIENTATION) PinOrientationNames().Index( aValue ) ); + break; case COL_NUMBER_SIZE: @@ -244,8 +235,7 @@ public: break; case COL_POSX: - aPin.SetPosition( VECTOR2I( m_unitsProvider.ValueFromString( aValue ), - aPin.GetPosition().y ) ); + aPin.SetPosition( VECTOR2I( m_unitsProvider.ValueFromString( aValue ), aPin.GetPosition().y ) ); break; case COL_POSY: @@ -253,35 +243,45 @@ public: break; case COL_VISIBLE: - aPin.SetVisible(boolFromString( aValue, m_reporter )); + aPin.SetVisible(boolFromString( aValue, m_reporter ) ); break; case COL_UNIT: if( MatchTranslationOrNative( aValue, UNITS_ALL, false ) ) { aPin.SetUnit( 0 ); + break; } - else + + for( int i = 1; i <= aSymbol.GetUnitCount(); i++ ) { - for( int i = 1; i <= aSymbol.GetUnitCount(); i++ ) + if( aValue == aPin.GetBodyStyleDescription( i, true ) + || aValue == aPin.GetBodyStyleDescription( i, false ) ) { - if( aValue == LIB_SYMBOL::LetterSubReference( i, 'A' ) ) - { - aPin.SetUnit( i ); - break; - } + aPin.SetUnit( i ); + break; } } break; - case COL_DEMORGAN: - if( MatchTranslationOrNative( aValue, DEMORGAN_STD, false ) ) - aPin.SetBodyStyle( 1 ); - else if( MatchTranslationOrNative( aValue, DEMORGAN_ALT, false ) ) - aPin.SetBodyStyle( 2 ); - else + case COL_BODY_STYLE: + if( MatchTranslationOrNative( aValue, DEMORGAN_ALL, false ) ) + { aPin.SetBodyStyle( 0 ); + break; + } + + for( int i = 1; i <= aSymbol.GetBodyStyleCount(); i++ ) + { + if( aValue == aPin.GetBodyStyleDescription( i, true ) + || aValue == aPin.GetBodyStyleDescription( i, false ) ) + { + aPin.SetBodyStyle( i ); + break; + } + } + break; default: @@ -434,8 +434,7 @@ public: return GetValue( m_rows[ aRow ], aCol, m_frame ); } - static wxString GetValue( const std::vector& pins, int aCol, - EDA_DRAW_FRAME* aParentFrame ) + static wxString GetValue( const std::vector& pins, int aCol, EDA_DRAW_FRAME* aParentFrame ) { wxString fieldValue; @@ -615,13 +614,14 @@ public: // 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; - }; + auto cmp = + [ ascending ]( const auto a, const auto b ) + { + if( ascending ) + return a < b; + else + return b < a; + }; switch( sortCol ) { @@ -629,19 +629,21 @@ public: case COL_NAME: res = cmp( PIN_NUMBERS::Compare( lhStr, rhStr ), 0 ); break; + case COL_NUMBER_SIZE: case COL_NAME_SIZE: - res = cmp( parentFrame->ValueFromString( lhStr ), - parentFrame->ValueFromString( rhStr ) ); + res = cmp( parentFrame->ValueFromString( lhStr ), parentFrame->ValueFromString( rhStr ) ); break; + case COL_LENGTH: case COL_POSX: case COL_POSY: - res = cmp( parentFrame->ValueFromString( lhStr ), - parentFrame->ValueFromString( rhStr ) ); + res = cmp( parentFrame->ValueFromString( lhStr ), parentFrame->ValueFromString( rhStr ) ); break; + case COL_VISIBLE: - case COL_DEMORGAN: + case COL_UNIT: + case COL_BODY_STYLE: default: res = cmp( StrNumCmp( lhStr, rhStr ), 0 ); break; @@ -728,10 +730,8 @@ public: for( SCH_PIN* pin : aPins ) { - const bool includedByUnit = - ( m_unitFilter == -1 ) || ( pin->GetUnit() == 0 ) || ( pin->GetUnit() == m_unitFilter ); - const bool includedByBodyStyle = - ( m_bodyStyleFilter == -1 ) || ( pin->GetBodyStyle() == m_bodyStyleFilter ); + const bool includedByUnit = m_unitFilter == -1 || pin->GetUnit() == 0 || pin->GetUnit() == m_unitFilter; + const bool includedByBodyStyle = m_bodyStyleFilter == -1 || pin->GetBodyStyle() == m_bodyStyleFilter; const bool includedBySelection = !m_filterBySelection || pinIsInEditorSelection( pin ); if( includedByUnit && includedByBodyStyle && includedBySelection ) @@ -885,7 +885,7 @@ public: COL_POSY, COL_VISIBLE, COL_UNIT, - COL_DEMORGAN, + COL_BODY_STYLE, }; std::vector> exportTable; @@ -1038,8 +1038,7 @@ private: }; -DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, - LIB_SYMBOL* aSymbol, +DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, LIB_SYMBOL* aSymbol, const std::vector& aSelectedPins ) : DIALOG_LIB_EDIT_PIN_TABLE_BASE( parent ), m_editFrame( parent ), @@ -1089,8 +1088,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, attr = new wxGridCellAttr; wxArrayString orientationNames = PinOrientationNames(); orientationNames.push_back( INDETERMINATE_STATE ); - attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinOrientationIcons(), - orientationNames ) ); + attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinOrientationIcons(), orientationNames ) ); attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) ); m_grid->SetColAttr( COL_ORIENTATION, attr ); @@ -1105,12 +1103,15 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, m_grid->SetColAttr( COL_UNIT, attr ); attr = new wxGridCellAttr; - wxArrayString demorganNames; - demorganNames.push_back( wxGetTranslation( DEMORGAN_ALL ) ); - demorganNames.push_back( wxGetTranslation( DEMORGAN_STD ) ); - demorganNames.push_back( wxGetTranslation( DEMORGAN_ALT ) ); - attr->SetEditor( new GRID_CELL_COMBOBOX( demorganNames ) ); - m_grid->SetColAttr( COL_DEMORGAN, attr ); + wxArrayString bodyStyleNames; + + bodyStyleNames.push_back( wxGetTranslation( DEMORGAN_ALL ) ); + + for( int i = 0; i < aSymbol->GetBodyStyleCount(); i++ ) + bodyStyleNames.push_back( aSymbol->GetBodyStyleNames()[i] ); + + attr->SetEditor( new GRID_CELL_COMBOBOX( bodyStyleNames ) ); + m_grid->SetColAttr( COL_BODY_STYLE, attr ); attr = new wxGridCellAttr; attr->SetRenderer( new wxGridCellBoolRenderer() ); @@ -1139,7 +1140,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, GetSizer()->SetSizeHints(this); Centre(); - if( aSymbol->IsMulti() ) + if( aSymbol->IsMultiUnit() ) { m_unitFilter->Append( wxGetTranslation( UNITS_ALL ) ); @@ -1154,7 +1155,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, m_unitFilter->Enable( false ); } - if( aSymbol->HasAlternateBodyStyle() ) + if( aSymbol->HasDeMorganBodyStyles() ) { m_bodyStyleFilter->Append( wxGetTranslation( DEMORGAN_ALL ) ); m_bodyStyleFilter->Append( wxGetTranslation( DEMORGAN_STD ) ); @@ -1162,6 +1163,15 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, m_bodyStyleFilter->SetSelection( -1 ); } + else if( aSymbol->IsMultiBodyStyle() ) + { + m_bodyStyleFilter->Append( wxGetTranslation( DEMORGAN_ALL ) ); + + for( const wxString& bodyStyle : aSymbol->GetBodyStyleNames() ) + m_bodyStyleFilter->Append( bodyStyle ); + + m_bodyStyleFilter->SetSelection( -1 ); + } else { m_cbFilterByBodyStyle->Enable( false ); @@ -1223,15 +1233,15 @@ bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataToWindow() m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue(), false ); - if( m_symbol->IsMulti() ) + if( m_symbol->IsMultiUnit() ) m_grid->ShowCol( COL_UNIT ); else m_grid->HideCol( COL_UNIT ); - if( m_editFrame->GetShowDeMorgan() ) - m_grid->ShowCol( COL_DEMORGAN ); + if( m_symbol->IsMultiBodyStyle() ) + m_grid->ShowCol( COL_BODY_STYLE ); else - m_grid->HideCol( COL_DEMORGAN ); + m_grid->HideCol( COL_BODY_STYLE ); updateSummary(); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h index 3acbe34ca2..953898a082 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h @@ -40,7 +40,7 @@ enum COL_ORDER COL_POSY, COL_VISIBLE, COL_UNIT, - COL_DEMORGAN, + COL_BODY_STYLE, COL_COUNT // keep as last }; diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp index 68527c3a4a..4f755faa07 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp @@ -87,7 +87,8 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent m_grid->SetColSize( 9, 84 ); m_grid->SetColSize( 10, 84 ); m_grid->SetColSize( 11, 84 ); - m_grid->SetColSize( 12, 66 ); + m_grid->SetColSize( 12, 100 ); + m_grid->SetColSize( 13, 100 ); m_grid->EnableDragColMove( false ); m_grid->EnableDragColSize( true ); m_grid->SetColLabelValue( 0, _("Count") ); @@ -103,7 +104,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent m_grid->SetColLabelValue( 10, _("Y Position") ); m_grid->SetColLabelValue( 11, _("Visible") ); m_grid->SetColLabelValue( 12, _("Unit") ); - m_grid->SetColLabelValue( 13, _("De Morgan") ); + m_grid->SetColLabelValue( 13, _("Body Style") ); m_grid->SetColLabelSize( 24 ); m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp index 2ba44c8a29..77d6b029f2 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp @@ -524,10 +524,10 @@ 1 wxALIGN_CENTER 24 - "Count" "Number" "Name" "Electrical Type" "Graphic Style" "Orientation" "Number Text Size" "Name Text Size" "Length" "X Position" "Y Position" "Visible" "Unit" "De Morgan" + "Count" "Number" "Name" "Electrical Type" "Graphic Style" "Orientation" "Number Text Size" "Name Text Size" "Length" "X Position" "Y Position" "Visible" "Unit" "Body Style" wxALIGN_CENTER 14 - 60,66,84,140,140,100,110,110,84,84,84,84,66 + 60,66,84,140,140,100,110,110,84,84,84,84,100,100 1 0 diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 89e9e362d5..591647bb43 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -131,14 +131,30 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a m_SymbolNameCtrl->SetValidator( FIELD_VALIDATOR( FIELD_T::VALUE ) ); + m_unitNamesGrid->PushEventHandler( new GRID_TRICKS( m_unitNamesGrid ) ); + m_unitNamesGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); + + m_bodyStyleNamesGrid->PushEventHandler( new GRID_TRICKS( m_bodyStyleNamesGrid, + [this]( wxCommandEvent& aEvent ) + { + OnAddBodyStyle( aEvent ); + } ) ); + m_bodyStyleNamesGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); + // Configure button logos m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) ); - m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) ); m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) ); + m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); + + m_bpAddBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) ); + m_bpMoveUpBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) ); + m_bpMoveDownBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) ); + m_bpDeleteBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); + m_addFilterButton->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) ); - m_deleteFilterButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); m_editFilterButton->SetBitmap( KiBitmapBundle( BITMAPS::small_edit ) ); + m_deleteFilterButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) ); m_btnCreateJumperPinGroup->SetBitmap( KiBitmapBundle( BITMAPS::right ) ); m_btnRemoveJumperPinGroup->SetBitmap( KiBitmapBundle( BITMAPS::left ) ); @@ -153,10 +169,8 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a } // wxFormBuilder doesn't include this event... - m_grid->Connect( wxEVT_GRID_CELL_CHANGING, - wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging ), nullptr, this ); - m_grid->Connect( wxEVT_GRID_CELL_CHANGED, - wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanged ), nullptr, this ); + m_grid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging, this ); + m_grid->Bind( wxEVT_GRID_CELL_CHANGED, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanged, this ); m_grid->GetGridWindow()->Bind( wxEVT_MOTION, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridMotion, this ); @@ -205,14 +219,14 @@ DIALOG_LIB_SYMBOL_PROPERTIES::~DIALOG_LIB_SYMBOL_PROPERTIES() // Prevents crash bug in wxGrid's d'tor m_grid->DestroyTable( m_fields ); - m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING, - wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging ), nullptr, this ); - m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, - wxGridEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanged ), nullptr, this ); + m_grid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging, this ); + m_grid->Unbind( wxEVT_GRID_CELL_CHANGED, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanged, this ); m_grid->GetGridWindow()->Unbind( wxEVT_MOTION, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridMotion, this ); // Delete the GRID_TRICKS. m_grid->PopEventHandler( true ); + m_unitNamesGrid->PopEventHandler( true ); + m_bodyStyleNamesGrid->PopEventHandler( true ); } @@ -264,15 +278,36 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() m_SymbolNameCtrl->ChangeValue( UnescapeString( m_libEntry->GetName() ) ); m_KeywordCtrl->ChangeValue( m_libEntry->GetKeyWords() ); - m_SelNumberOfUnits->SetValue( m_libEntry->GetUnitCount() ); + m_unitSpinCtrl->SetValue( m_libEntry->GetUnitCount() ); m_OptionPartsInterchangeable->SetValue( !m_libEntry->UnitsLocked() || m_libEntry->GetUnitCount() == 1 ); - // If a symbol contains no body-style-specific pins or graphic items, - // symbol->HasAlternateBodyStyle() will return false. - // But when editing a symbol with DeMorgan option set, we don't want to keep turning it off - // just because there aren't any body-style-specific items yet, so we force it to on if the - // parent frame has it enabled. - m_hasAlternateBodyStyles->SetValue( m_Parent->GetShowDeMorgan() ); + updateUnitCount(); + + for( int unit = 0; unit < m_libEntry->GetUnitCount(); unit++ ) + { + if( m_libEntry->GetUnitDisplayNames().contains( unit + 1 ) ) + m_unitNamesGrid->SetCellValue( unit, 1, m_libEntry->GetUnitDisplayNames().at( unit + 1 ) ); + } + + if( m_libEntry->HasDeMorganBodyStyles() ) + { + m_radioDeMorgan->SetValue( true ); + } + else if( m_libEntry->IsMultiBodyStyle() ) + { + m_radioCustom->SetValue( true ); + + for( const wxString& name : m_libEntry->GetBodyStyleNames() ) + { + int row = m_bodyStyleNamesGrid->GetNumberRows(); + m_bodyStyleNamesGrid->AppendRows( 1 ); + m_bodyStyleNamesGrid->SetCellValue( row, 0, name ); + } + } + else + { + m_radioSingle->SetValue( true ); + } m_OptionPower->SetValue( m_libEntry->IsPower() ); m_OptionLocalPower->SetValue( m_libEntry->IsLocalPower() ); @@ -440,15 +475,40 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::Validate() * Confirm destructive actions. */ - if( m_SelNumberOfUnits->GetValue() < m_libEntry->GetUnitCount() ) + if( m_unitSpinCtrl->GetValue() < m_libEntry->GetUnitCount() ) { if( !IsOK( this, _( "Delete extra units from symbol?" ) ) ) return false; } - if( !m_hasAlternateBodyStyles->GetValue() && m_libEntry->HasAlternateBodyStyle() ) + int bodyStyleCount = 0; + + if( m_radioSingle->GetValue() ) { - if( !IsOK( this, _( "Delete alternate body style (De Morgan) from symbol?" ) ) ) + bodyStyleCount = 1; + } + if( m_radioDeMorgan->GetValue() ) + { + bodyStyleCount = 2; + } + else if( m_radioCustom->GetValue() ) + { + for( int ii = 0; ii < m_bodyStyleNamesGrid->GetNumberRows(); ++ii ) + { + if( !m_bodyStyleNamesGrid->GetCellValue( ii, 0 ).IsEmpty() ) + bodyStyleCount++; + } + } + + if( bodyStyleCount == 0 ) + { + m_delayedErrorMessage = _( "Symbol must have at least 1 body style" ); + return false; + } + + if( bodyStyleCount < m_libEntry->GetBodyStyleCount() ) + { + if( !IsOK( this, _( "Delete extra body styles from symbol?" ) ) ) return false; } @@ -464,6 +524,12 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() if( !m_grid->CommitPendingChanges() ) return false; + if( !m_unitNamesGrid->CommitPendingChanges() ) + return false; + + if( !m_bodyStyleNamesGrid->CommitPendingChanges() ) + return false; + wxString newName = EscapeString( m_SymbolNameCtrl->GetValue(), CTX_LIBID ); wxString oldName = m_libEntry->GetName(); @@ -550,10 +616,43 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() m_libEntry->SetName( newName ); m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() ); - m_libEntry->SetUnitCount( m_SelNumberOfUnits->GetValue() ); + m_libEntry->SetUnitCount( m_unitSpinCtrl->GetValue(), true ); m_libEntry->LockUnits( m_libEntry->GetUnitCount() > 1 && !m_OptionPartsInterchangeable->GetValue() ); - m_libEntry->SetHasAlternateBodyStyle( m_hasAlternateBodyStyles->GetValue() ); - m_Parent->SetShowDeMorgan( m_hasAlternateBodyStyles->GetValue() ); + + m_libEntry->GetUnitDisplayNames().clear(); + + for( int row = 0; row < m_unitNamesGrid->GetNumberRows(); row++ ) + { + if( !m_unitNamesGrid->GetCellValue( row, 1 ).IsEmpty() ) + m_libEntry->GetUnitDisplayNames()[row+1] = m_unitNamesGrid->GetCellValue( row, 1 ); + } + + if( m_radioSingle->GetValue() ) + { + m_libEntry->SetHasDeMorganBodyStyles( false ); + m_libEntry->SetBodyStyleCount( 1, false, false ); + m_libEntry->SetBodyStyleNames( {} ); + } + else if( m_radioDeMorgan->GetValue() ) + { + m_libEntry->SetHasDeMorganBodyStyles( true ); + m_libEntry->SetBodyStyleCount( 2, false, true ); + m_libEntry->SetBodyStyleNames( {} ); + } + else + { + std::vector bodyStyleNames; + + for( int row = 0; row < m_bodyStyleNamesGrid->GetNumberRows(); ++row ) + { + if( !m_bodyStyleNamesGrid->GetCellValue( row, 0 ).IsEmpty() ) + bodyStyleNames.push_back( m_bodyStyleNamesGrid->GetCellValue( row, 0 ) ); + } + + m_libEntry->SetHasDeMorganBodyStyles( false ); + m_libEntry->SetBodyStyleCount( bodyStyleNames.size(), true, true ); + m_libEntry->SetBodyStyleNames( bodyStyleNames ); + } if( m_OptionPower->GetValue() ) { @@ -610,16 +709,21 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() m_Parent->UpdateAfterSymbolProperties( &oldName ); - // It's possible that the symbol being edited has no pins, in which case there may be no - // alternate body style objects causing #LIB_SYMBOL::HasAlternateBodyStyle() to always return - // false. This allows the user to edit the alternate body style just in case this condition - // occurs. - m_Parent->SetShowDeMorgan( m_hasAlternateBodyStyles->GetValue() ); - return true; } +void DIALOG_LIB_SYMBOL_PROPERTIES::OnBodyStyle( wxCommandEvent& event ) +{ + m_bodyStyleNamesGrid->Enable( m_radioCustom->GetValue() ); + + m_bpAddBodyStyle->Enable( m_radioCustom->GetValue() ); + m_bpMoveUpBodyStyle->Enable( m_radioCustom->GetValue() ); + m_bpMoveDownBodyStyle->Enable( m_radioCustom->GetValue() ); + m_bpDeleteBodyStyle->Enable( m_radioCustom->GetValue() ); +} + + void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridMotion( wxMouseEvent& aEvent ) { aEvent.Skip(); @@ -635,9 +739,8 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridMotion( wxMouseEvent& aEvent ) return; } - m_grid->SetToolTip( - wxString::Format( _( "This field is inherited from '%s'." ), - m_fields->ParentField( row ).GetName() ) ); + m_grid->SetToolTip( wxString::Format( _( "This field is inherited from '%s'." ), + m_fields->ParentField( row ).GetName() ) ); } @@ -799,6 +902,53 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event ) } +void DIALOG_LIB_SYMBOL_PROPERTIES::OnAddBodyStyle( wxCommandEvent& event ) +{ + m_bodyStyleNamesGrid->OnAddRow( + [&]() -> std::pair + { + m_bodyStyleNamesGrid->AppendRows( 1 ); + OnModify(); + + return { m_bodyStyleNamesGrid->GetNumberRows() - 1, 0 }; + } ); +} + + +void DIALOG_LIB_SYMBOL_PROPERTIES::OnDeleteBodyStyle( wxCommandEvent& event ) +{ + m_bodyStyleNamesGrid->OnDeleteRows( + [&]( int row ) + { + m_bodyStyleNamesGrid->DeleteRows( row ); + } ); + + OnModify(); +} + + +void DIALOG_LIB_SYMBOL_PROPERTIES::OnBodyStyleMoveUp( wxCommandEvent& event ) +{ + m_bodyStyleNamesGrid->OnMoveRowUp( + [&]( int row ) + { + m_bodyStyleNamesGrid->SwapRows( row, row - 1 ); + OnModify(); + } ); +} + + +void DIALOG_LIB_SYMBOL_PROPERTIES::OnBodyStyleMoveDown( wxCommandEvent& event ) +{ + m_bodyStyleNamesGrid->OnMoveRowDown( + [&]( int row ) + { + m_bodyStyleNamesGrid->SwapRows( row, row + 1 ); + OnModify(); + } ); +} + + void DIALOG_LIB_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event ) { if( !m_grid->CommitPendingChanges() ) @@ -949,7 +1099,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::adjustGridColumns() void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) { - m_OptionPartsInterchangeable->Enable( m_SelNumberOfUnits->GetValue() > 1 ); + m_OptionPartsInterchangeable->Enable( m_unitSpinCtrl->GetValue() > 1 ); m_pinNameOffset.Enable( m_PinsNameInsideButt->GetValue() ); if( m_grid->IsCellEditControlShown() ) @@ -1092,15 +1242,57 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event ) } -void DIALOG_LIB_SYMBOL_PROPERTIES::OnSpinCtrl( wxSpinEvent& event ) +bool DIALOG_LIB_SYMBOL_PROPERTIES::updateUnitCount() { - OnModify(); + m_unitNamesGrid->CommitPendingChanges( true /* aQuietMode */ ); + + int extra = m_unitNamesGrid->GetNumberRows() - m_unitSpinCtrl->GetValue(); + int needed = m_unitSpinCtrl->GetValue() - m_unitNamesGrid->GetNumberRows(); + + if( extra > 0 ) + { + m_unitNamesGrid->DeleteRows( m_unitNamesGrid->GetNumberRows() - extra, extra ); + return true; + } + + if( needed > 0 ) + { + m_unitNamesGrid->AppendRows( needed ); + + for( int row = m_unitNamesGrid->GetNumberRows() - needed; row < m_unitNamesGrid->GetNumberRows(); ++row ) + m_unitNamesGrid->SetCellValue( row, 0, LIB_SYMBOL::LetterSubReference( row + 1, 'A' ) ); + + return true; + } + + return false; } -void DIALOG_LIB_SYMBOL_PROPERTIES::OnSpinCtrlText( wxCommandEvent& event ) +void DIALOG_LIB_SYMBOL_PROPERTIES::OnUnitSpinCtrl( wxSpinEvent& event ) { - OnModify(); + if( updateUnitCount() ) + OnModify(); +} + + +void DIALOG_LIB_SYMBOL_PROPERTIES::OnUnitSpinCtrlText( wxCommandEvent& event ) +{ + // wait for kill focus to update unit count +} + + +void DIALOG_LIB_SYMBOL_PROPERTIES::OnUnitSpinCtrlEnter( wxCommandEvent& event ) +{ + if( updateUnitCount() ) + OnModify(); +} + + +void DIALOG_LIB_SYMBOL_PROPERTIES::OnUnitSpinCtrlKillFocus( wxFocusEvent& event ) +{ + if( updateUnitCount() ) + OnModify(); } diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.h b/eeschema/dialogs/dialog_lib_symbol_properties.h index cea5a090d0..18f7492880 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.h +++ b/eeschema/dialogs/dialog_lib_symbol_properties.h @@ -54,14 +54,21 @@ protected: void OnText( wxCommandEvent& event ) override; void OnCombobox( wxCommandEvent& event ) override; void OnCheckBox( wxCommandEvent& event ) override; - void OnSpinCtrl( wxSpinEvent& event ) override; - void OnSpinCtrlText( wxCommandEvent& event ) override; + void OnUnitSpinCtrl( wxSpinEvent& event ) override; + void OnUnitSpinCtrlText( wxCommandEvent& event ) override; + void OnUnitSpinCtrlKillFocus( wxFocusEvent& event ) override; + void OnUnitSpinCtrlEnter( wxCommandEvent& event ) override; + void OnBodyStyle( wxCommandEvent& event ) override; private: void OnAddField( wxCommandEvent& event ) override; void OnDeleteField( wxCommandEvent& event ) override; void OnMoveUp( wxCommandEvent& event ) override; void OnMoveDown( wxCommandEvent& event ) override; + void OnAddBodyStyle( wxCommandEvent& event ) override; + void OnBodyStyleMoveUp( wxCommandEvent& event ) override; + void OnBodyStyleMoveDown( wxCommandEvent& event ) override; + void OnDeleteBodyStyle( wxCommandEvent& event ) override; void OnSymbolNameKillFocus( wxFocusEvent& event ) override; void OnSymbolNameText( wxCommandEvent& event ) override; void OnAddFootprintFilter( wxCommandEvent& event ) override; @@ -80,6 +87,7 @@ private: void OnGroupedPinListClick( wxCommandEvent& event ) override; void OnAvailablePinsClick( wxCommandEvent& event ) override; + bool updateUnitCount(); void adjustGridColumns(); void syncControlStates( bool aIsAlias ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp index 9f9dce4229..48d0bb1d4f 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp @@ -164,31 +164,6 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* wxStaticBoxSizer* sbSizerSymbol; sbSizerSymbol = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("General") ), wxVERTICAL ); - wxBoxSizer* bSizerUnitCount; - bSizerUnitCount = new wxBoxSizer( wxHORIZONTAL ); - - m_staticTextNbUnits = new wxStaticText( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Number of units:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextNbUnits->Wrap( -1 ); - m_staticTextNbUnits->SetToolTip( _("Enter the number of units for a symbol that contains more than one unit") ); - - bSizerUnitCount->Add( m_staticTextNbUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_SelNumberOfUnits = new wxSpinCtrl( sbSizerSymbol->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 64, 1 ); - bSizerUnitCount->Add( m_SelNumberOfUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - - sbSizerSymbol->Add( bSizerUnitCount, 1, wxEXPAND|wxLEFT, 4 ); - - m_OptionPartsInterchangeable = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("All units are interchangeable"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptionPartsInterchangeable->SetToolTip( _("Check this option when all symbol units have the same function.\nFor instance, this should be checked for a quad NAND gate, while it should not be checked for a dual triode (where unit C is the filament).") ); - - sbSizerSymbol->Add( m_OptionPartsInterchangeable, 0, wxALL, 4 ); - - m_hasAlternateBodyStyles = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Has alternate body style (De Morgan)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_hasAlternateBodyStyles->SetToolTip( _("Check this option if the symbol has an alternate body style for a De Morgan logic equivalence.\nFor instance, this should be checked for a NAND gate to provide an alternate representation as an OR gate with inverted inputs.") ); - - sbSizerSymbol->Add( m_hasAlternateBodyStyles, 0, wxBOTTOM|wxRIGHT|wxLEFT, 4 ); - m_OptionPower = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Define as power symbol"), wxDefaultPosition, wxDefaultSize, 0 ); m_OptionPower->SetToolTip( _("Power symbols define a global net with the value as a netname.\nThey will not be included in the BOM and cannot be assigned a footprint.") ); @@ -209,7 +184,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* sbSizerSymbol->Add( bSizer16, 1, wxEXPAND, 5 ); - bSizerLeftCol->Add( sbSizerSymbol, 0, wxEXPAND|wxALL, 5 ); + bSizerLeftCol->Add( sbSizerSymbol, 1, wxEXPAND|wxALL, 5 ); bSizerLowerBasicPanel->Add( bSizerLeftCol, 1, wxEXPAND, 5 ); @@ -258,7 +233,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* bSizerNameOffset->Add( m_nameOffsetUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - sbSizerPinTextOpts->Add( bSizerNameOffset, 0, wxBOTTOM|wxEXPAND|wxTOP, 4 ); + sbSizerPinTextOpts->Add( bSizerNameOffset, 0, wxEXPAND|wxTOP, 2 ); sbSizerPinTextOpts->Add( 0, 0, 0, wxEXPAND, 5 ); @@ -300,32 +275,187 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* m_PanelBasic->SetSizer( bSizerBasicPanel ); m_PanelBasic->Layout(); bSizerBasicPanel->Fit( m_PanelBasic ); - m_NoteBook->AddPage( m_PanelBasic, _("General"), false ); - m_PanelFootprintFilter = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bPanelFpFilterBoxSizer; - bPanelFpFilterBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + m_NoteBook->AddPage( m_PanelBasic, _("General"), true ); + m_PanelUnitsAndBodyStyles = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerUnitsAndBodyStyles; + bSizerUnitsAndBodyStyles = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bFpFilterLeftBoxSizer; - bFpFilterLeftBoxSizer = new wxBoxSizer( wxVERTICAL ); + wxStaticBoxSizer* sbSizerUnits; + sbSizerUnits = new wxStaticBoxSizer( new wxStaticBox( m_PanelUnitsAndBodyStyles, wxID_ANY, _("Symbol Units") ), wxVERTICAL ); - m_staticTextFootprints = new wxStaticText( m_PanelFootprintFilter, wxID_ANY, _("Footprint filters:"), wxDefaultPosition, wxDefaultSize, 0 ); + wxBoxSizer* bSizerUnitCount; + bSizerUnitCount = new wxBoxSizer( wxHORIZONTAL ); + + m_staticTextNbUnits = new wxStaticText( sbSizerUnits->GetStaticBox(), wxID_ANY, _("Number of units:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextNbUnits->Wrap( -1 ); + m_staticTextNbUnits->SetToolTip( _("Enter the number of units for a symbol that contains more than one unit") ); + + bSizerUnitCount->Add( m_staticTextNbUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_unitSpinCtrl = new wxSpinCtrl( sbSizerUnits->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 64, 1 ); + bSizerUnitCount->Add( m_unitSpinCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + sbSizerUnits->Add( bSizerUnitCount, 0, wxEXPAND|wxBOTTOM|wxLEFT, 4 ); + + + sbSizerUnits->Add( 0, 2, 0, wxEXPAND, 5 ); + + m_OptionPartsInterchangeable = new wxCheckBox( sbSizerUnits->GetStaticBox(), wxID_ANY, _("All units are interchangeable"), wxDefaultPosition, wxDefaultSize, 0 ); + m_OptionPartsInterchangeable->SetToolTip( _("Check this option when all symbol units have the same function.\nFor instance, this should be checked for a quad NAND gate, while it should not be checked for a dual triode (where unit C is the filament).") ); + + sbSizerUnits->Add( m_OptionPartsInterchangeable, 0, wxBOTTOM|wxRIGHT|wxLEFT, 4 ); + + + sbSizerUnits->Add( 0, 15, 0, wxEXPAND, 5 ); + + m_unitNamesLabel = new wxStaticText( sbSizerUnits->GetStaticBox(), wxID_ANY, _("Unit display names (optional):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_unitNamesLabel->Wrap( -1 ); + sbSizerUnits->Add( m_unitNamesLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_unitNamesGrid = new WX_GRID( sbSizerUnits->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_unitNamesGrid->CreateGrid( 0, 2 ); + m_unitNamesGrid->EnableEditing( true ); + m_unitNamesGrid->EnableGridLines( true ); + m_unitNamesGrid->EnableDragGridSize( false ); + m_unitNamesGrid->SetMargins( 0, 0 ); + + // Columns + m_unitNamesGrid->SetColSize( 0, 36 ); + m_unitNamesGrid->SetColSize( 1, 400 ); + m_unitNamesGrid->EnableDragColMove( false ); + m_unitNamesGrid->EnableDragColSize( false ); + m_unitNamesGrid->SetColLabelSize( 0 ); + m_unitNamesGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + m_unitNamesGrid->EnableDragRowSize( false ); + m_unitNamesGrid->SetRowLabelSize( 0 ); + m_unitNamesGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + m_unitNamesGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + sbSizerUnits->Add( m_unitNamesGrid, 1, wxALL|wxEXPAND, 5 ); + + + bSizerUnitsAndBodyStyles->Add( sbSizerUnits, 1, wxEXPAND|wxALL, 10 ); + + wxStaticBoxSizer* sbSizerBodyStyles; + sbSizerBodyStyles = new wxStaticBoxSizer( new wxStaticBox( m_PanelUnitsAndBodyStyles, wxID_ANY, _("Body Styles") ), wxVERTICAL ); + + m_radioSingle = new wxRadioButton( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, _("Single body style"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); + sbSizerBodyStyles->Add( m_radioSingle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + + sbSizerBodyStyles->Add( 0, 3, 0, wxEXPAND, 5 ); + + m_radioDeMorgan = new wxRadioButton( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, _("‘Standard’ and ‘Alternate’ De Morgan body styles"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerBodyStyles->Add( m_radioDeMorgan, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + + sbSizerBodyStyles->Add( 0, 3, 0, wxEXPAND, 5 ); + + m_radioCustom = new wxRadioButton( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, _("Custom body styles:"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerBodyStyles->Add( m_radioCustom, 0, wxALL, 5 ); + + wxBoxSizer* bSizerIndent; + bSizerIndent = new wxBoxSizer( wxVERTICAL ); + + m_bodyStyleNamesGrid = new WX_GRID( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_bodyStyleNamesGrid->CreateGrid( 0, 1 ); + m_bodyStyleNamesGrid->EnableEditing( true ); + m_bodyStyleNamesGrid->EnableGridLines( true ); + m_bodyStyleNamesGrid->EnableDragGridSize( false ); + m_bodyStyleNamesGrid->SetMargins( 0, 0 ); + + // Columns + m_bodyStyleNamesGrid->SetColSize( 0, 400 ); + m_bodyStyleNamesGrid->EnableDragColMove( false ); + m_bodyStyleNamesGrid->EnableDragColSize( false ); + m_bodyStyleNamesGrid->SetColLabelSize( 0 ); + m_bodyStyleNamesGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + m_bodyStyleNamesGrid->EnableDragRowSize( false ); + m_bodyStyleNamesGrid->SetRowLabelSize( 0 ); + m_bodyStyleNamesGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + m_bodyStyleNamesGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + bSizerIndent->Add( m_bodyStyleNamesGrid, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + bButtonSize1 = new wxBoxSizer( wxHORIZONTAL ); + + m_bpAddBodyStyle = new STD_BITMAP_BUTTON( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpAddBodyStyle->SetToolTip( _("Add field") ); + + bButtonSize1->Add( m_bpAddBodyStyle, 0, wxRIGHT|wxLEFT, 5 ); + + m_bpMoveUpBodyStyle = new STD_BITMAP_BUTTON( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpMoveUpBodyStyle->SetToolTip( _("Move up") ); + + bButtonSize1->Add( m_bpMoveUpBodyStyle, 0, wxRIGHT, 5 ); + + m_bpMoveDownBodyStyle = new STD_BITMAP_BUTTON( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpMoveDownBodyStyle->SetToolTip( _("Move down") ); + + bButtonSize1->Add( m_bpMoveDownBodyStyle, 0, wxRIGHT, 5 ); + + + bButtonSize1->Add( 20, 0, 0, wxEXPAND, 5 ); + + m_bpDeleteBodyStyle = new STD_BITMAP_BUTTON( sbSizerBodyStyles->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpDeleteBodyStyle->SetToolTip( _("Delete field") ); + + bButtonSize1->Add( m_bpDeleteBodyStyle, 0, wxRIGHT|wxLEFT, 10 ); + + + bSizerIndent->Add( bButtonSize1, 0, wxEXPAND, 5 ); + + + sbSizerBodyStyles->Add( bSizerIndent, 1, wxEXPAND|wxLEFT, 24 ); + + + bSizerUnitsAndBodyStyles->Add( sbSizerBodyStyles, 1, wxEXPAND|wxALL, 10 ); + + + m_PanelUnitsAndBodyStyles->SetSizer( bSizerUnitsAndBodyStyles ); + m_PanelUnitsAndBodyStyles->Layout(); + bSizerUnitsAndBodyStyles->Fit( m_PanelUnitsAndBodyStyles ); + m_NoteBook->AddPage( m_PanelUnitsAndBodyStyles, _("Units && Body Styles"), false ); + m_PanelFootprintFilters = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerFPFilters; + bSizerFPFilters = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bFPFiltersMargins; + bFPFiltersMargins = new wxBoxSizer( wxVERTICAL ); + + m_staticTextFootprints = new wxStaticText( m_PanelFootprintFilters, wxID_ANY, _("Footprint filters:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextFootprints->Wrap( -1 ); m_staticTextFootprints->SetToolTip( _("A list of footprints names that can be used for this symbol.\nFootprints names can used wildcards like sm* to allow all footprints names starting by sm.") ); - bFpFilterLeftBoxSizer->Add( m_staticTextFootprints, 0, wxRIGHT|wxLEFT, 5 ); + bFPFiltersMargins->Add( m_staticTextFootprints, 0, wxRIGHT|wxLEFT, 5 ); - m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_MULTIPLE ); - bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilters, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_MULTIPLE ); + bFPFiltersMargins->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bFpFilterRightBoxSizer; bFpFilterRightBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - m_addFilterButton = new STD_BITMAP_BUTTON( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); + m_addFilterButton = new STD_BITMAP_BUTTON( m_PanelFootprintFilters, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); m_addFilterButton->SetToolTip( _("Add footprint filter") ); bFpFilterRightBoxSizer->Add( m_addFilterButton, 0, wxTOP|wxBOTTOM|wxLEFT, 5 ); - m_editFilterButton = new STD_BITMAP_BUTTON( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); + m_editFilterButton = new STD_BITMAP_BUTTON( m_PanelFootprintFilters, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); m_editFilterButton->SetToolTip( _("Edit footprint filter") ); bFpFilterRightBoxSizer->Add( m_editFilterButton, 0, wxALL, 5 ); @@ -333,94 +463,97 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* bFpFilterRightBoxSizer->Add( 20, 0, 0, wxEXPAND, 5 ); - m_deleteFilterButton = new STD_BITMAP_BUTTON( m_PanelFootprintFilter, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); + m_deleteFilterButton = new STD_BITMAP_BUTTON( m_PanelFootprintFilters, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), wxBU_AUTODRAW|0 ); m_deleteFilterButton->SetToolTip( _("Delete footprint filter") ); bFpFilterRightBoxSizer->Add( m_deleteFilterButton, 0, wxALL, 5 ); - bFpFilterLeftBoxSizer->Add( bFpFilterRightBoxSizer, 0, 0, 5 ); + bFPFiltersMargins->Add( bFpFilterRightBoxSizer, 0, 0, 5 ); - bPanelFpFilterBoxSizer->Add( bFpFilterLeftBoxSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bSizerFPFilters->Add( bFPFiltersMargins, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer ); - m_PanelFootprintFilter->Layout(); - bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter ); - m_NoteBook->AddPage( m_PanelFootprintFilter, _("Footprint Filters"), false ); + m_PanelFootprintFilters->SetSizer( bSizerFPFilters ); + m_PanelFootprintFilters->Layout(); + bSizerFPFilters->Fit( m_PanelFootprintFilters ); + m_NoteBook->AddPage( m_PanelFootprintFilters, _("Footprint Filters"), false ); m_PanelPinConnections = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer19; - bSizer19 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerPinConnections; + bSizerPinConnections = new wxBoxSizer( wxVERTICAL ); m_cbDuplicatePinsAreJumpers = new wxCheckBox( m_PanelPinConnections, wxID_ANY, _("Pins with duplicate numbers are jumpers"), wxDefaultPosition, wxDefaultSize, 0 ); m_cbDuplicatePinsAreJumpers->SetToolTip( _("When enabled, this symbol can have more than one pin with the same number, and pins with the same number will be considered to be jumpered together internally.") ); - bSizer19->Add( m_cbDuplicatePinsAreJumpers, 0, wxALL, 5 ); + bSizerPinConnections->Add( m_cbDuplicatePinsAreJumpers, 0, wxALL, 5 ); + + + bSizerPinConnections->Add( 0, 3, 0, wxEXPAND, 5 ); wxStaticBoxSizer* sbJumperPinGroups; sbJumperPinGroups = new wxStaticBoxSizer( new wxStaticBox( m_PanelPinConnections, wxID_ANY, _("Jumper Pin Groups") ), wxVERTICAL ); - wxBoxSizer* bSizer20; - bSizer20 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerMargins; + bSizerMargins = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bSizer22; - bSizer22 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerLeft; + bSizerLeft = new wxBoxSizer( wxVERTICAL ); - stLabelAvailablePins = new wxStaticText( sbJumperPinGroups->GetStaticBox(), wxID_ANY, _("Available pins"), wxDefaultPosition, wxDefaultSize, 0 ); + stLabelAvailablePins = new wxStaticText( sbJumperPinGroups->GetStaticBox(), wxID_ANY, _("Available pins:"), wxDefaultPosition, wxDefaultSize, 0 ); stLabelAvailablePins->Wrap( -1 ); - bSizer22->Add( stLabelAvailablePins, 0, wxALL, 5 ); + bSizerLeft->Add( stLabelAvailablePins, 0, wxRIGHT|wxLEFT, 4 ); m_listAvailablePins = new wxListBox( sbJumperPinGroups->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_SORT ); m_listAvailablePins->SetMinSize( wxSize( 200,-1 ) ); - bSizer22->Add( m_listAvailablePins, 1, wxALL|wxEXPAND, 5 ); + bSizerLeft->Add( m_listAvailablePins, 1, wxALL|wxEXPAND, 2 ); - bSizer20->Add( bSizer22, 1, wxEXPAND, 5 ); + bSizerMargins->Add( bSizerLeft, 1, wxEXPAND, 5 ); - wxBoxSizer* bSizer21; - bSizer21 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerCenter; + bSizerCenter = new wxBoxSizer( wxVERTICAL ); m_btnCreateJumperPinGroup = new wxBitmapButton( sbJumperPinGroups->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_btnCreateJumperPinGroup->SetToolTip( _("Create jumper group from the selected pins") ); - bSizer21->Add( m_btnCreateJumperPinGroup, 0, wxALL, 5 ); + bSizerCenter->Add( m_btnCreateJumperPinGroup, 0, wxALL, 5 ); m_btnRemoveJumperPinGroup = new wxBitmapButton( sbJumperPinGroups->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_btnRemoveJumperPinGroup->SetToolTip( _("Remove the selected jumper pin group") ); - bSizer21->Add( m_btnRemoveJumperPinGroup, 0, wxALL, 5 ); + bSizerCenter->Add( m_btnRemoveJumperPinGroup, 0, wxALL, 5 ); - bSizer20->Add( bSizer21, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bSizerMargins->Add( bSizerCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); - wxBoxSizer* bSizer23; - bSizer23 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerRight; + bSizerRight = new wxBoxSizer( wxVERTICAL ); - stLabelGroups = new wxStaticText( sbJumperPinGroups->GetStaticBox(), wxID_ANY, _("Grouped pins"), wxDefaultPosition, wxDefaultSize, 0 ); + stLabelGroups = new wxStaticText( sbJumperPinGroups->GetStaticBox(), wxID_ANY, _("Grouped pins:"), wxDefaultPosition, wxDefaultSize, 0 ); stLabelGroups->Wrap( -1 ); - bSizer23->Add( stLabelGroups, 0, wxALL, 5 ); + bSizerRight->Add( stLabelGroups, 0, wxRIGHT|wxLEFT, 4 ); m_listJumperPinGroups = new wxListBox( sbJumperPinGroups->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_SORT ); m_listJumperPinGroups->SetMinSize( wxSize( 200,-1 ) ); - bSizer23->Add( m_listJumperPinGroups, 1, wxALL|wxEXPAND, 5 ); + bSizerRight->Add( m_listJumperPinGroups, 1, wxALL|wxEXPAND, 2 ); - bSizer20->Add( bSizer23, 1, wxEXPAND, 5 ); + bSizerMargins->Add( bSizerRight, 1, wxEXPAND, 5 ); - sbJumperPinGroups->Add( bSizer20, 1, wxEXPAND, 5 ); + sbJumperPinGroups->Add( bSizerMargins, 1, wxEXPAND|wxTOP, 2 ); - bSizer19->Add( sbJumperPinGroups, 1, wxALL|wxTOP, 5 ); + bSizerPinConnections->Add( sbJumperPinGroups, 1, wxALL|wxTOP, 5 ); - m_PanelPinConnections->SetSizer( bSizer19 ); + m_PanelPinConnections->SetSizer( bSizerPinConnections ); m_PanelPinConnections->Layout(); - bSizer19->Fit( m_PanelPinConnections ); - m_NoteBook->AddPage( m_PanelPinConnections, _("Pin Connections"), true ); + bSizerPinConnections->Fit( m_PanelPinConnections ); + m_NoteBook->AddPage( m_PanelPinConnections, _("Pin Connections"), false ); bUpperSizer->Add( m_NoteBook, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); @@ -469,10 +602,6 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* m_KeywordCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnText ), NULL, this ); m_inheritanceSelectCombo->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCombobox ), NULL, this ); m_inheritanceSelectCombo->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnText ), NULL, this ); - m_SelNumberOfUnits->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnSpinCtrl ), NULL, this ); - m_SelNumberOfUnits->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnSpinCtrlText ), NULL, this ); - m_OptionPartsInterchangeable->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); - m_hasAlternateBodyStyles->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_OptionPower->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); m_OptionLocalPower->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); m_ShowPinNumButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); @@ -482,6 +611,18 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* m_excludeFromSimCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBomCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBoardCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); + m_unitSpinCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrlKillFocus ), NULL, this ); + m_unitSpinCtrl->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrl ), NULL, this ); + m_unitSpinCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrlText ), NULL, this ); + m_unitSpinCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrlEnter ), NULL, this ); + m_OptionPartsInterchangeable->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); + m_radioSingle->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyle ), NULL, this ); + m_radioDeMorgan->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyle ), NULL, this ); + m_radioCustom->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyle ), NULL, this ); + m_bpAddBodyStyle->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnAddBodyStyle ), NULL, this ); + m_bpMoveUpBodyStyle->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyleMoveUp ), NULL, this ); + m_bpMoveDownBodyStyle->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyleMoveDown ), NULL, this ); + m_bpDeleteBodyStyle->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnDeleteBodyStyle ), NULL, this ); m_FootprintFilterListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnFpFilterDClick ), NULL, this ); m_FootprintFilterListBox->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnEditFootprintFilter ), NULL, this ); m_addFilterButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnAddFootprintFilter ), NULL, this ); @@ -509,10 +650,6 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::~DIALOG_LIB_SYMBOL_PROPERTIES_BASE() m_KeywordCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnText ), NULL, this ); m_inheritanceSelectCombo->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCombobox ), NULL, this ); m_inheritanceSelectCombo->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnText ), NULL, this ); - m_SelNumberOfUnits->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnSpinCtrl ), NULL, this ); - m_SelNumberOfUnits->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnSpinCtrlText ), NULL, this ); - m_OptionPartsInterchangeable->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); - m_hasAlternateBodyStyles->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_OptionPower->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); m_OptionLocalPower->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); m_ShowPinNumButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); @@ -522,6 +659,18 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::~DIALOG_LIB_SYMBOL_PROPERTIES_BASE() m_excludeFromSimCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBomCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_excludeFromBoardCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); + m_unitSpinCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrlKillFocus ), NULL, this ); + m_unitSpinCtrl->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrl ), NULL, this ); + m_unitSpinCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrlText ), NULL, this ); + m_unitSpinCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnUnitSpinCtrlEnter ), NULL, this ); + m_OptionPartsInterchangeable->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); + m_radioSingle->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyle ), NULL, this ); + m_radioDeMorgan->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyle ), NULL, this ); + m_radioCustom->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyle ), NULL, this ); + m_bpAddBodyStyle->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnAddBodyStyle ), NULL, this ); + m_bpMoveUpBodyStyle->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyleMoveUp ), NULL, this ); + m_bpMoveDownBodyStyle->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnBodyStyleMoveDown ), NULL, this ); + m_bpDeleteBodyStyle->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnDeleteBodyStyle ), NULL, this ); m_FootprintFilterListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnFpFilterDClick ), NULL, this ); m_FootprintFilterListBox->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnEditFootprintFilter ), NULL, this ); m_addFilterButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnAddFootprintFilter ), NULL, this ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp index 41b8d134c8..5de405c2be 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp @@ -136,7 +136,7 @@ General - 0 + 1 1 1 @@ -1056,7 +1056,7 @@ 5 wxEXPAND|wxALL - 0 + 1 wxID_ANY General @@ -1065,276 +1065,6 @@ wxVERTICAL 1 none - - 4 - wxEXPAND|wxLEFT - 1 - - - bSizerUnitCount - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Number of units: - 0 - - 0 - - - 0 - - 1 - m_staticTextNbUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Enter the number of units for a symbol that contains more than one unit - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - 1 - 64 - - 0 - - 1 - - 0 - - 1 - m_SelNumberOfUnits - 1 - - - protected - 1 - - Resizable - 1 - - wxSP_ARROW_KEYS - - 0 - - - - - - OnSpinCtrl - OnSpinCtrlText - - - - - - 4 - wxALL - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - All units are interchangeable - - 0 - - - 0 - - 1 - m_OptionPartsInterchangeable - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Check this option when all symbol units have the same function. For instance, this should be checked for a quad NAND gate, while it should not be checked for a dual triode (where unit C is the filament). - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCheckBox - - - - 4 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - 0 - - 0 - 0 - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Has alternate body style (De Morgan) - - 0 - - - 0 - - 1 - m_hasAlternateBodyStyles - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Check this option if the symbol has an alternate body style for a De Morgan logic equivalence. For instance, this should be checked for a NAND gate to provide an alternate representation as an OR gate with inverted inputs. - - wxFILTER_NONE - wxDefaultValidator - - - - - OnCheckBox - - 4 wxBOTTOM|wxRIGHT|wxLEFT @@ -1722,8 +1452,8 @@ - 4 - wxBOTTOM|wxEXPAND|wxTOP + 2 + wxEXPAND|wxTOP 0 @@ -2174,6 +1904,1114 @@ + + + Units && Body Styles + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_PanelUnitsAndBodyStyles + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + bSizerUnitsAndBodyStyles + wxHORIZONTAL + none + + 10 + wxEXPAND|wxALL + 1 + + wxID_ANY + Symbol Units + + sbSizerUnits + wxVERTICAL + 1 + none + + 4 + wxEXPAND|wxBOTTOM|wxLEFT + 0 + + + bSizerUnitCount + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Number of units: + 0 + + 0 + + + 0 + + 1 + m_staticTextNbUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter the number of units for a symbol that contains more than one unit + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + 1 + 64 + + 0 + + 1 + + 0 + + 1 + m_unitSpinCtrl + 1 + + + protected + 1 + + Resizable + 1 + + wxSP_ARROW_KEYS + + 0 + + + + + + OnUnitSpinCtrlKillFocus + OnUnitSpinCtrl + OnUnitSpinCtrlText + OnUnitSpinCtrlEnter + + + + + + 5 + wxEXPAND + 0 + + 2 + protected + 0 + + + + 4 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + All units are interchangeable + + 0 + + + 0 + + 1 + m_OptionPartsInterchangeable + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Check this option when all symbol units have the same function. For instance, this should be checked for a quad NAND gate, while it should not be checked for a dual triode (where unit C is the filament). + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCheckBox + + + + 5 + wxEXPAND + 0 + + 15 + protected + 0 + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Unit display names (optional): + 0 + + 0 + + + 0 + + 1 + m_unitNamesLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + 2 + 36,400 + + 1 + 0 + Dock + 0 + Left + 0 + 0 + 0 + 0 + 0 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + m_unitNamesGrid + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + + 0 + 1 + + WX_GRID; widgets/wx_grid.h; forward_declare + 0 + + + + + + + + + + 10 + wxEXPAND|wxALL + 1 + + wxID_ANY + Body Styles + + sbSizerBodyStyles + wxVERTICAL + 1 + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Single body style + + 0 + + + 0 + + 1 + m_radioSingle + 1 + + + protected + 1 + + Resizable + 1 + + wxRB_GROUP + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnBodyStyle + + + + 5 + wxEXPAND + 0 + + 3 + protected + 0 + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + ‘Standard’ and ‘Alternate’ De Morgan body styles + + 0 + + + 0 + + 1 + m_radioDeMorgan + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnBodyStyle + + + + 5 + wxEXPAND + 0 + + 3 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Custom body styles: + + 0 + + + 0 + + 1 + m_radioCustom + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + OnBodyStyle + + + + 24 + wxEXPAND|wxLEFT + 1 + + + bSizerIndent + wxVERTICAL + none + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + 1 + 400 + + 1 + 0 + Dock + 0 + Left + 0 + 0 + 0 + 0 + 0 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + m_bodyStyleNamesGrid + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTER + 0 + + wxALIGN_CENTER + + 0 + 1 + + WX_GRID; widgets/wx_grid.h; forward_declare + 0 + + + + + + + + 5 + wxEXPAND + 0 + + + bButtonSize1 + wxHORIZONTAL + protected + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Add Field + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpAddBodyStyle + 1 + + + protected + 1 + + + + Resizable + 1 + + + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare + 0 + Add field + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddBodyStyle + + + + 5 + wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Move Up + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpMoveUpBodyStyle + 1 + + + protected + 1 + + + + Resizable + 1 + + + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare + 0 + Move up + + wxFILTER_NONE + wxDefaultValidator + + + + + OnBodyStyleMoveUp + + + + 5 + wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Move Down + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpMoveDownBodyStyle + 1 + + + protected + 1 + + + + Resizable + 1 + + + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare + 0 + Move down + + wxFILTER_NONE + wxDefaultValidator + + + + + OnBodyStyleMoveDown + + + + 5 + wxEXPAND + 0 + + 0 + protected + 20 + + + + 10 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + 1 + + 1 + + + 0 + 0 + wxID_ANY + Delete Field + + 0 + + 0 + + + 0 + -1,-1 + 1 + m_bpDeleteBodyStyle + 1 + + + protected + 1 + + + + Resizable + 1 + + + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare + 0 + Delete field + + wxFILTER_NONE + wxDefaultValidator + + + + + OnDeleteBodyStyle + + + + + + + + + + + Footprint Filters @@ -2214,7 +3052,7 @@ 0 1 - m_PanelFootprintFilter + m_PanelFootprintFilters 1 @@ -2232,7 +3070,7 @@ wxTAB_TRAVERSAL - bPanelFpFilterBoxSizer + bSizerFPFilters wxHORIZONTAL none @@ -2241,7 +3079,7 @@ 1 - bFpFilterLeftBoxSizer + bFPFiltersMargins wxVERTICAL none @@ -2625,7 +3463,7 @@ Pin Connections - 1 + 0 1 1 @@ -2680,7 +3518,7 @@ wxTAB_TRAVERSAL - bSizer19 + bSizerPinConnections wxVERTICAL none @@ -2748,6 +3586,16 @@ + + 5 + wxEXPAND + 0 + + 3 + protected + 0 + + 5 wxALL|wxTOP @@ -2761,12 +3609,12 @@ 1 none - 5 - wxEXPAND + 2 + wxEXPAND|wxTOP 1 - bSizer20 + bSizerMargins wxHORIZONTAL none @@ -2775,12 +3623,12 @@ 1 - bSizer22 + bSizerLeft wxVERTICAL none - 5 - wxALL + 4 + wxRIGHT|wxLEFT 0 1 @@ -2811,7 +3659,7 @@ 0 0 wxID_ANY - Available pins + Available pins: 0 0 @@ -2841,7 +3689,7 @@ - 5 + 2 wxALL|wxEXPAND 1 @@ -2913,7 +3761,7 @@ 0 - bSizer21 + bSizerCenter wxVERTICAL none @@ -3074,12 +3922,12 @@ 1 - bSizer23 + bSizerRight wxVERTICAL none - 5 - wxALL + 4 + wxRIGHT|wxLEFT 0 1 @@ -3110,7 +3958,7 @@ 0 0 wxID_ANY - Grouped pins + Grouped pins: 0 0 @@ -3140,7 +3988,7 @@ - 5 + 2 wxALL|wxEXPAND 1 diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.h b/eeschema/dialogs/dialog_lib_symbol_properties_base.h index 70db8b5cda..4d46977a42 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.h +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.h @@ -30,9 +30,10 @@ class WX_GRID; #include #include #include -#include #include #include +#include +#include #include #include #include @@ -63,10 +64,6 @@ class DIALOG_LIB_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_inheritsStaticText; wxComboBox* m_inheritanceSelectCombo; wxBoxSizer* bSizerLowerBasicPanel; - wxStaticText* m_staticTextNbUnits; - wxSpinCtrl* m_SelNumberOfUnits; - wxCheckBox* m_OptionPartsInterchangeable; - wxCheckBox* m_hasAlternateBodyStyles; wxCheckBox* m_OptionPower; wxCheckBox* m_OptionLocalPower; wxCheckBox* m_ShowPinNumButt; @@ -78,7 +75,22 @@ class DIALOG_LIB_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM wxCheckBox* m_excludeFromSimCheckBox; wxCheckBox* m_excludeFromBomCheckBox; wxCheckBox* m_excludeFromBoardCheckBox; - wxPanel* m_PanelFootprintFilter; + wxPanel* m_PanelUnitsAndBodyStyles; + wxStaticText* m_staticTextNbUnits; + wxSpinCtrl* m_unitSpinCtrl; + wxCheckBox* m_OptionPartsInterchangeable; + wxStaticText* m_unitNamesLabel; + WX_GRID* m_unitNamesGrid; + wxRadioButton* m_radioSingle; + wxRadioButton* m_radioDeMorgan; + wxRadioButton* m_radioCustom; + WX_GRID* m_bodyStyleNamesGrid; + wxBoxSizer* bButtonSize1; + STD_BITMAP_BUTTON* m_bpAddBodyStyle; + STD_BITMAP_BUTTON* m_bpMoveUpBodyStyle; + STD_BITMAP_BUTTON* m_bpMoveDownBodyStyle; + STD_BITMAP_BUTTON* m_bpDeleteBodyStyle; + wxPanel* m_PanelFootprintFilters; wxStaticText* m_staticTextFootprints; wxListBox* m_FootprintFilterListBox; STD_BITMAP_BUTTON* m_addFilterButton; @@ -109,10 +121,17 @@ class DIALOG_LIB_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM virtual void OnSymbolNameText( wxCommandEvent& event ) { event.Skip(); } virtual void OnText( wxCommandEvent& event ) { event.Skip(); } virtual void OnCombobox( wxCommandEvent& event ) { event.Skip(); } - virtual void OnSpinCtrl( wxSpinEvent& event ) { event.Skip(); } - virtual void OnSpinCtrlText( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void onPowerCheckBox( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } + virtual void OnUnitSpinCtrlKillFocus( wxFocusEvent& event ) { event.Skip(); } + virtual void OnUnitSpinCtrl( wxSpinEvent& event ) { event.Skip(); } + virtual void OnUnitSpinCtrlText( wxCommandEvent& event ) { event.Skip(); } + virtual void OnUnitSpinCtrlEnter( wxCommandEvent& event ) { event.Skip(); } + virtual void OnBodyStyle( wxCommandEvent& event ) { event.Skip(); } + virtual void OnAddBodyStyle( wxCommandEvent& event ) { event.Skip(); } + virtual void OnBodyStyleMoveUp( wxCommandEvent& event ) { event.Skip(); } + virtual void OnBodyStyleMoveDown( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDeleteBodyStyle( wxCommandEvent& event ) { event.Skip(); } virtual void OnFpFilterDClick( wxMouseEvent& event ) { event.Skip(); } virtual void OnEditFootprintFilter( wxCommandEvent& event ) { event.Skip(); } virtual void OnAddFootprintFilter( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_pin_properties.cpp b/eeschema/dialogs/dialog_pin_properties.cpp index 84355c2eda..77c5b60bb6 100644 --- a/eeschema/dialogs/dialog_pin_properties.cpp +++ b/eeschema/dialogs/dialog_pin_properties.cpp @@ -160,7 +160,7 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN m_frame->GetCanvas()->GetBackend() ); m_previewWidget->SetLayoutDirection( wxLayout_LeftToRight ); - m_previewWidget->DisplayPart( m_dummyParent, m_dummyPin->GetUnit(), 0 ); + m_previewWidget->DisplayPart( m_dummyParent, m_dummyPin->GetUnit(), m_dummyPin->GetBodyStyle() ); wxBoxSizer* previewSizer = new wxBoxSizer( wxHORIZONTAL ); previewSizer->Add( m_previewWidget, 1, wxEXPAND, 5 ); @@ -217,12 +217,12 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, SCH_PIN } ) ); m_alternatesGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); - if( aPin->GetParentSymbol()->HasAlternateBodyStyle() ) + if( aPin->GetParentSymbol()->IsMultiBodyStyle() ) { m_alternatesTurndown->Collapse(); m_alternatesTurndown->Disable(); - m_alternatesTurndown->SetToolTip( _( "Alternate pin assignments are not available for " - "De Morgan symbols." ) ); + m_alternatesTurndown->SetToolTip( _( "Alternate pin assignments are not available for symbols with " + "multiple body styles." ) ); } // Set special attributes @@ -287,8 +287,9 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow() m_textPinNumber->SetValue( m_pin->GetNumber() ); m_numberSize.SetValue( m_pin->GetNumberTextSize() ); m_pinLength.SetValue( m_pin->GetLength() ); - m_checkApplyToAllParts->Enable( m_pin->GetParentSymbol()->IsMulti() ); - m_checkApplyToAllParts->SetValue( m_pin->GetParentSymbol()->IsMulti() && m_pin->GetUnit() == 0 ); + m_checkApplyToAllParts->Enable( m_pin->GetParentSymbol()->IsMultiUnit() ); + m_checkApplyToAllParts->SetValue( m_pin->GetParentSymbol()->IsMultiUnit() && m_pin->GetUnit() == 0 ); + m_checkApplyToAllBodyStyles->Enable( m_pin->GetParentSymbol()->IsMultiBodyStyle() ); m_checkApplyToAllBodyStyles->SetValue( m_pin->GetBodyStyle() == 0 ); m_checkShow->SetValue( m_pin->IsVisible() ); @@ -321,7 +322,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow() commonUnitsToolTip = _( "If checked, this pin will exist in all units." ); } - if( !m_pin->GetParentSymbol()->IsMulti() ) + if( !m_pin->GetParentSymbol()->IsMultiUnit() ) commonUnitsToolTip = _( "This symbol only has one unit. This control has no effect." ); m_checkApplyToAllParts->SetToolTip( commonUnitsToolTip ); @@ -418,7 +419,7 @@ void DIALOG_PIN_PROPERTIES::OnPropertiesChange( wxCommandEvent& event ) m_infoBar->GetSizer()->Layout(); } - m_previewWidget->DisplayPart( m_dummyParent, m_dummyPin->GetUnit(), 0 ); + m_previewWidget->DisplayPart( m_dummyParent, m_dummyPin->GetUnit(), m_dummyPin->GetBodyStyle() ); } diff --git a/eeschema/dialogs/dialog_pin_properties_base.cpp b/eeschema/dialogs/dialog_pin_properties_base.cpp index bdf0e64ae6..bb318dd47a 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.cpp +++ b/eeschema/dialogs/dialog_pin_properties_base.cpp @@ -154,7 +154,7 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind m_checkApplyToAllParts = new wxCheckBox( this, wxID_ANY, _("Common to all &units in symbol"), wxDefaultPosition, wxDefaultSize, 0 ); checkboxesSizer->Add( m_checkApplyToAllParts, 0, wxBOTTOM, 3 ); - m_checkApplyToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles (De Morgan)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkApplyToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles"), wxDefaultPosition, wxDefaultSize, 0 ); checkboxesSizer->Add( m_checkApplyToAllBodyStyles, 0, wxBOTTOM, 3 ); diff --git a/eeschema/dialogs/dialog_pin_properties_base.fbp b/eeschema/dialogs/dialog_pin_properties_base.fbp index b477ca7931..629cf596d5 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.fbp +++ b/eeschema/dialogs/dialog_pin_properties_base.fbp @@ -1948,7 +1948,7 @@ 0 0 wxID_ANY - Common to all body &styles (De Morgan) + Common to all body &styles 0 diff --git a/eeschema/dialogs/dialog_rescue_each.cpp b/eeschema/dialogs/dialog_rescue_each.cpp index 581e5ed9cb..812d6c8592 100644 --- a/eeschema/dialogs/dialog_rescue_each.cpp +++ b/eeschema/dialogs/dialog_rescue_each.cpp @@ -230,17 +230,17 @@ void DIALOG_RESCUE_EACH::displayItemsInConflict() if( row < 0 ) { - m_previewOldWidget->DisplayPart( nullptr, 0 ); - m_previewNewWidget->DisplayPart( nullptr, 0 ); + m_previewOldWidget->DisplayPart( nullptr, 0, 0 ); + m_previewNewWidget->DisplayPart( nullptr, 0, 0 ); } else { RESCUE_CANDIDATE& selected_part = m_rescuer->m_all_candidates[row]; m_previewOldWidget->DisplayPart( selected_part.GetCacheCandidate(), selected_part.GetUnit(), - selected_part.GetConvert() ); + selected_part.GetBodyStyle() ); m_previewNewWidget->DisplayPart( selected_part.GetLibCandidate(), selected_part.GetUnit(), - selected_part.GetConvert() ); + selected_part.GetBodyStyle() ); } } diff --git a/eeschema/dialogs/dialog_shape_properties.cpp b/eeschema/dialogs/dialog_shape_properties.cpp index dad82187e3..112a86602d 100644 --- a/eeschema/dialogs/dialog_shape_properties.cpp +++ b/eeschema/dialogs/dialog_shape_properties.cpp @@ -190,20 +190,10 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow() const SYMBOL* symbol = m_shape->GetParentSymbol(); m_privateCheckbox->SetValue( m_shape->IsPrivate() ); - m_checkApplyToAllUnits->SetValue( symbol->GetUnitCount() > 1 && m_shape->GetUnit() == 0 ); - m_checkApplyToAllUnits->Enable( symbol->GetUnitCount() > 1 ); - m_checkApplyToAllBodyStyles->SetValue( m_shape->GetBodyStyle() == 0 ); - - bool enableAlternateBodyStyle = symbol->HasAlternateBodyStyle(); - - // If a symbol contains no body-style-specific pins or graphic items, - // symbol->HasAlternateBodyStyle() will return false. - // But when creating a new symbol, with DeMorgan option set, the m_checkApplyToAllBodyStyles - // must be enabled in order to be able to create graphic items shared by all body styles. - if( symbolEditor->GetShowDeMorgan() ) - enableAlternateBodyStyle = true; - - m_checkApplyToAllBodyStyles->Enable( enableAlternateBodyStyle ); + m_checkApplyToAllUnits->SetValue( symbol->IsMultiUnit() && m_shape->GetUnit() == 0 ); + m_checkApplyToAllUnits->Enable( symbol->IsMultiUnit() ); + m_checkApplyToAllBodyStyles->SetValue( symbol->IsMultiBodyStyle() && m_shape->GetBodyStyle() == 0 ); + m_checkApplyToAllBodyStyles->Enable( symbol->IsMultiBodyStyle() ); } else { diff --git a/eeschema/dialogs/dialog_shape_properties_base.cpp b/eeschema/dialogs/dialog_shape_properties_base.cpp index 4b35e43d84..7988a32298 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.cpp +++ b/eeschema/dialogs/dialog_shape_properties_base.cpp @@ -251,7 +251,7 @@ DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wx m_checkApplyToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all &units in symbol"), wxDefaultPosition, wxDefaultSize, 0 ); bRight2->Add( m_checkApplyToAllUnits, 0, wxTOP|wxRIGHT, 5 ); - m_checkApplyToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles (De Morgan)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkApplyToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body &styles"), wxDefaultPosition, wxDefaultSize, 0 ); bRight2->Add( m_checkApplyToAllBodyStyles, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); diff --git a/eeschema/dialogs/dialog_shape_properties_base.fbp b/eeschema/dialogs/dialog_shape_properties_base.fbp index 19c57bddf3..a705b8dd50 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.fbp +++ b/eeschema/dialogs/dialog_shape_properties_base.fbp @@ -2320,7 +2320,7 @@ 0 0 wxID_ANY - Common to all body &styles (De Morgan) + Common to all body &styles 0 diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index e4be8022ad..406acb3951 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -96,8 +96,8 @@ DIALOG_SIM_MODEL::DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame for( SCH_PIN* pin : aSymbol.GetPins() ) { - // De Morgan conversions are equivalences, not additional items to simulate - if( !pin->GetParentSymbol()->HasAlternateBodyStyle() || pin->GetBodyStyle() < 2 ) + // Body styles (including De Morgan variants) are equivalences, not additional items to simulate + if( !pin->GetParentSymbol()->IsMultiBodyStyle() || pin->GetBodyStyle() < 2 ) m_sortedPartPins.push_back( pin ); } diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 0837daaf34..d7c47560bf 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -342,13 +342,14 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH m_shownColumns = m_fieldsGrid->GetShownColumns(); } - if( m_part && m_part->HasAlternateBodyStyle() ) + if( m_part && m_part->IsMultiBodyStyle() ) { - // DeMorgan conversions are a subclass of alternate pin assignments, so don't allow + // Multiple body styles are a superclass of alternate pin assignments, so don't allow // free-form alternate assignments as well. (We won't know how to map the alternates - // back and forth when the conversion is changed.) + // back and forth when the body style is changed.) m_pinTablePage->Disable(); - m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for De Morgan symbols." ) ); + m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for symbols with multiple " + "body styles." ) ); } else { @@ -472,7 +473,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() AdjustFieldsGridColumns(); // If a multi-unit symbol, set up the unit selector and interchangeable checkbox. - if( m_symbol->GetUnitCount() > 1 ) + if( m_symbol->IsMultiUnit() ) { // Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies) // from the current sheet path, because it can be modified by previous calculations @@ -490,14 +491,18 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() m_unitChoice->Enable( false ); } - if( m_part && m_part->HasAlternateBodyStyle() ) + if( m_part && m_part->IsMultiBodyStyle() ) { - if( m_symbol->GetBodyStyle() > BODY_STYLE::BASE ) - m_cbAlternateSymbol->SetValue( true ); + for( int ii = 0; ii < m_part->GetBodyStyleCount(); ii++ ) + m_bodyStyleChoice->Append( m_part->GetBodyStyleNames()[ii] ); + + if( m_symbol->GetBodyStyle() <= (int) m_bodyStyleChoice->GetCount() ) + m_bodyStyleChoice->SetSelection( m_symbol->GetBodyStyle() - 1 ); } else { - m_cbAlternateSymbol->Enable( false ); + m_bodyStyle->Enable( false ); + m_bodyStyleChoice->Enable( false ); } // Set the symbol orientation and mirroring. @@ -517,8 +522,8 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() switch( mirror ) { default: m_mirrorCtrl->SetSelection( 0 ) ; break; - case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break; - case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break; + case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break; + case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break; } m_cbExcludeFromSim->SetValue( m_symbol->GetExcludedFromSim() ); @@ -681,17 +686,14 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() // Save current flags which could be modified by next change settings EDA_ITEM_FLAGS flags = m_symbol->GetFlags(); - // For symbols with multiple shapes (De Morgan representation) Set the selected shape: - if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() ) - m_symbol->SetBodyStyle( BODY_STYLE::DEMORGAN ); - else - m_symbol->SetBodyStyle( BODY_STYLE::BASE ); - //Set the part selection in multiple part per package int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1; m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection ); m_symbol->SetUnit( unit_selection ); + int bodyStyle_selection = m_bodyStyleChoice->IsEnabled() ? m_bodyStyleChoice->GetSelection() + 1 : 1; + m_symbol->SetBodyStyle( bodyStyle_selection ); + switch( m_orientationCtrl->GetSelection() ) { case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break; diff --git a/eeschema/dialogs/dialog_symbol_properties_base.cpp b/eeschema/dialogs/dialog_symbol_properties_base.cpp index 9dd00720f1..71e42cd19a 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.cpp +++ b/eeschema/dialogs/dialog_symbol_properties_base.cpp @@ -139,12 +139,16 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, m_unitChoice->SetSelection( 0 ); m_unitChoice->SetMinSize( wxSize( 100,-1 ) ); - gbSizer1->Add( m_unitChoice, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT|wxRIGHT, 5 ); + gbSizer1->Add( m_unitChoice, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT, 5 ); - m_cbAlternateSymbol = new wxCheckBox( sbGeneralProps->GetStaticBox(), wxID_ANY, _("Alternate symbol (De Morgan)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_cbAlternateSymbol->SetToolTip( _("Use the alternate shape of this symbol.\nFor gates, this is the \"De Morgan\" conversion") ); + m_bodyStyle = new wxStaticText( sbGeneralProps->GetStaticBox(), wxID_ANY, _("Body style:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_bodyStyle->Wrap( -1 ); + gbSizer1->Add( m_bodyStyle, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - gbSizer1->Add( m_cbAlternateSymbol, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 4 ); + wxArrayString m_bodyStyleChoiceChoices; + m_bodyStyleChoice = new wxChoice( sbGeneralProps->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_bodyStyleChoiceChoices, 0 ); + m_bodyStyleChoice->SetSelection( 0 ); + gbSizer1->Add( m_bodyStyleChoice, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_orientationLabel = new wxStaticText( sbGeneralProps->GetStaticBox(), wxID_ANY, _("Angle:"), wxDefaultPosition, wxDefaultSize, 0 ); m_orientationLabel->Wrap( -1 ); @@ -154,7 +158,7 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, int m_orientationCtrlNChoices = sizeof( m_orientationCtrlChoices ) / sizeof( wxString ); m_orientationCtrl = new wxChoice( sbGeneralProps->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_orientationCtrlNChoices, m_orientationCtrlChoices, 0 ); m_orientationCtrl->SetSelection( 0 ); - gbSizer1->Add( m_orientationCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxEXPAND, 5 ); + gbSizer1->Add( m_orientationCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 5 ); m_mirrorLabel = new wxStaticText( sbGeneralProps->GetStaticBox(), wxID_ANY, _("Mirror:"), wxDefaultPosition, wxDefaultSize, 0 ); m_mirrorLabel->Wrap( -1 ); @@ -164,7 +168,7 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, int m_mirrorCtrlNChoices = sizeof( m_mirrorCtrlChoices ) / sizeof( wxString ); m_mirrorCtrl = new wxChoice( sbGeneralProps->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_mirrorCtrlNChoices, m_mirrorCtrlChoices, 0 ); m_mirrorCtrl->SetSelection( 0 ); - gbSizer1->Add( m_mirrorCtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT|wxRIGHT, 5 ); + gbSizer1->Add( m_mirrorCtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxRIGHT, 5 ); gbSizer1->AddGrowableCol( 1 ); @@ -351,7 +355,6 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent, m_bpMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnMoveDown ), NULL, this ); m_bpDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnDeleteField ), NULL, this ); m_unitChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnUnitChoice ), NULL, this ); - m_cbAlternateSymbol->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_orientationCtrl->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnChoice ), NULL, this ); m_mirrorCtrl->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnChoice ), NULL, this ); m_ShowPinNumButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); @@ -385,7 +388,6 @@ DIALOG_SYMBOL_PROPERTIES_BASE::~DIALOG_SYMBOL_PROPERTIES_BASE() m_bpMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnMoveDown ), NULL, this ); m_bpDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnDeleteField ), NULL, this ); m_unitChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnUnitChoice ), NULL, this ); - m_cbAlternateSymbol->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_orientationCtrl->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnChoice ), NULL, this ); m_mirrorCtrl->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnChoice ), NULL, this ); m_ShowPinNumButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); diff --git a/eeschema/dialogs/dialog_symbol_properties_base.fbp b/eeschema/dialogs/dialog_symbol_properties_base.fbp index 9bdfac3e4f..6e63b6819a 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.fbp +++ b/eeschema/dialogs/dialog_symbol_properties_base.fbp @@ -728,7 +728,7 @@ 5 1 1 - wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND|wxRIGHT 0 1 @@ -793,14 +793,14 @@ OnUnitChoice - - 4 - 2 + + 5 + 1 0 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxALIGN_CENTER_VERTICAL|wxLEFT 1 1 - + 1 1 1 @@ -814,7 +814,6 @@ 1 0 - 0 1 1 @@ -830,7 +829,8 @@ 0 0 wxID_ANY - Alternate symbol (De Morgan) + Body style: + 0 0 @@ -838,7 +838,7 @@ 0 1 - m_cbAlternateSymbol + m_bodyStyle 1 @@ -849,9 +849,74 @@ 1 - + ; ; forward_declare 0 - Use the alternate shape of this symbol. For gates, this is the "De Morgan" conversion + + + + + -1 + + + + 5 + 1 + 1 + wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT + 1 + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_bodyStyleChoice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + wxFILTER_NONE wxDefaultValidator @@ -859,7 +924,6 @@ - OnCheckBox @@ -931,7 +995,7 @@ 5 1 1 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT 3 1 @@ -1065,7 +1129,7 @@ 5 1 1 - wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND|wxRIGHT 4 1 diff --git a/eeschema/dialogs/dialog_symbol_properties_base.h b/eeschema/dialogs/dialog_symbol_properties_base.h index 929d4aa85f..24bd89a6c1 100644 --- a/eeschema/dialogs/dialog_symbol_properties_base.h +++ b/eeschema/dialogs/dialog_symbol_properties_base.h @@ -29,8 +29,8 @@ class WX_GRID; #include #include #include -#include #include +#include #include #include #include @@ -55,7 +55,8 @@ class DIALOG_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM STD_BITMAP_BUTTON* m_bpDelete; wxStaticText* m_unitLabel; wxChoice* m_unitChoice; - wxCheckBox* m_cbAlternateSymbol; + wxStaticText* m_bodyStyle; + wxChoice* m_bodyStyleChoice; wxStaticText* m_orientationLabel; wxChoice* m_orientationCtrl; wxStaticText* m_mirrorLabel; @@ -91,8 +92,8 @@ class DIALOG_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM virtual void OnMoveDown( wxCommandEvent& event ) { event.Skip(); } virtual void OnDeleteField( wxCommandEvent& event ) { event.Skip(); } virtual void OnUnitChoice( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void OnChoice( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void OnUpdateSymbol( wxCommandEvent& event ) { event.Skip(); } virtual void OnExchangeSymbol( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditSymbol( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 13af4035d5..005c4bb1e4 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -349,11 +349,10 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() SYMBOL* symbol = m_currentItem->GetParentSymbol(); m_privateCheckbox->SetValue( m_currentItem->IsPrivate() ); - m_commonToAllUnits->SetValue( symbol->IsMulti() && m_currentItem->GetUnit() == 0 ); - m_commonToAllUnits->Enable( symbol->IsMulti() ); - m_commonToAllBodyStyles->SetValue( symbol->HasAlternateBodyStyle() - && m_currentItem->GetBodyStyle() == 0 ); - m_commonToAllBodyStyles->Enable( symbol->HasAlternateBodyStyle() ); + m_commonToAllUnits->SetValue( symbol->IsMultiUnit() && m_currentItem->GetUnit() == 0 ); + m_commonToAllUnits->Enable( symbol->IsMultiUnit() ); + m_commonToAllBodyStyles->SetValue( symbol->IsMultiBodyStyle() && m_currentItem->GetBodyStyle() == 0 ); + m_commonToAllBodyStyles->Enable( symbol->IsMultiBodyStyle() ); } return true; diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 3a61bffa5d..08f445469c 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -35,6 +35,11 @@ */ #define MAX_UNIT_COUNT_PER_PACKAGE 676 +/** + * Purely arbitrary limit. + */ +#define MAX_BODY_STYLE_PER_PACKAGE 100 + #define MAX_ALT_PIN_FUNCTION_ITEMS 1024 /** @@ -58,11 +63,13 @@ enum id_eeschema_frm /* Library editor horizontal toolbar IDs. */ ID_LIBEDIT_SELECT_UNIT_NUMBER, + ID_LIBEDIT_SELECT_BODY_STYLE, /* Library viewer horizontal toolbar IDs */ ID_LIBVIEW_NEXT, ID_LIBVIEW_PREVIOUS, ID_LIBVIEW_SELECT_UNIT_NUMBER, + ID_LIBVIEW_SELECT_BODY_STYLE, ID_LIBVIEW_LIB_FILTER, ID_LIBVIEW_LIB_LIST, ID_LIBVIEW_SYM_FILTER, @@ -85,8 +92,9 @@ enum id_eeschema_frm // to select one unit among MAX_UNIT_COUNT_PER_PACKAGE in popup menu ID_POPUP_SCH_SELECT_UNIT_END = ID_POPUP_SCH_SELECT_UNIT1 + MAX_UNIT_COUNT_PER_PACKAGE, - ID_POPUP_SCH_SELECT_BASE, - ID_POPUP_SCH_SELECT_ALT, + ID_POPUP_SCH_SELECT_BODY_STYLE, + ID_POPUP_SCH_SELECT_BODY_STYLE1, + ID_POPUP_SCH_SELECT_BODY_STYLE_END = ID_POPUP_SCH_SELECT_BODY_STYLE1 + MAX_BODY_STYLE_PER_PACKAGE, ID_POPUP_SCH_PIN_TRICKS_START, ID_POPUP_SCH_PIN_TRICKS_NO_CONNECT = ID_POPUP_SCH_PIN_TRICKS_START, diff --git a/eeschema/eeschema_jobs_handler.cpp b/eeschema/eeschema_jobs_handler.cpp index d6aff3fd9d..252dd79a0b 100644 --- a/eeschema/eeschema_jobs_handler.cpp +++ b/eeschema/eeschema_jobs_handler.cpp @@ -823,9 +823,8 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob ) } -int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, - SCH_RENDER_SETTINGS* aRenderSettings, - LIB_SYMBOL* symbol ) +int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, SCH_RENDER_SETTINGS* aRenderSettings, + LIB_SYMBOL* symbol ) { wxCHECK( symbol, CLI::EXIT_CODES::ERR_UNKNOWN ); @@ -845,8 +844,7 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, // iterate from unit 1, unit 0 would be "all units" which we don't want for( int unit = 1; unit < symbol->GetUnitCount() + 1; unit++ ) { - for( int bodyStyle = 1; bodyStyle < ( symbol->HasAlternateBodyStyle() ? 2 : 1 ) + 1; - ++bodyStyle ) + for( int bodyStyle = 1; bodyStyle <= symbol->GetBodyStyleCount(); ++bodyStyle ) { wxString filename; wxFileName fn; @@ -864,8 +862,15 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, // Also avoids aliasing 'sym', unit 2 and 'sym_unit2', unit 1 to the same file. filename += wxString::Format( "_unit%d", unit ); - if( bodyStyle == 2 ) - filename += wxS( "_demorgan" ); + if( symbol->HasDeMorganBodyStyles() ) + { + if( bodyStyle == 2 ) + filename += wxS( "_demorgan" ); + } + else if( bodyStyle <= (int) symbol->GetBodyStyleNames().size() ) + { + filename += wxS( "_" ) + symbol->GetBodyStyleNames()[bodyStyle-1].Lower(); + } fn.SetName( filename ); m_reporter->Report( wxString::Format( _( "Plotting symbol '%s' unit %d to '%s'\n" ), diff --git a/eeschema/erc/erc.cpp b/eeschema/erc/erc.cpp index 844ed0ecc3..b4ff0c1d36 100644 --- a/eeschema/erc/erc.cpp +++ b/eeschema/erc/erc.cpp @@ -1195,7 +1195,7 @@ int ERC_TESTER::TestMultUnitPinConflicts() SCH_PIN* pin = static_cast( item ); const SCH_SHEET_PATH& sheet = subgraph->GetSheet(); - if( !pin->GetLibPin()->GetParentSymbol()->IsMulti() ) + if( !pin->GetLibPin()->GetParentSymbol()->IsMultiUnit() ) continue; wxString name = pin->GetParentSymbol()->GetRef( &sheet ) + diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index ea05843d59..cf65eed24a 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -91,11 +91,12 @@ struct null_deleter LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB* aLibrary ) : - SYMBOL( LIB_SYMBOL_T ), - m_me( this, null_deleter() ) + SYMBOL( LIB_SYMBOL_T ), + m_me( this, null_deleter() ) { m_lastModDate = 0; m_unitCount = 1; + m_demorgan = false; m_pinNameOffset = schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET ); m_options = ENTRY_NORMAL; m_unitsLocked = false; @@ -126,14 +127,15 @@ LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB* LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) : - SYMBOL( aSymbol ), - EMBEDDED_FILES( aSymbol ), - m_me( this, null_deleter() ) + SYMBOL( aSymbol ), + EMBEDDED_FILES( aSymbol ), + m_me( this, null_deleter() ) { m_library = aLibrary; m_name = aSymbol.m_name; m_fpFilters = wxArrayString( aSymbol.m_fpFilters ); m_unitCount = aSymbol.m_unitCount; + m_demorgan = aSymbol.m_demorgan; m_unitsLocked = aSymbol.m_unitsLocked; m_lastModDate = aSymbol.m_lastModDate; m_options = aSymbol.m_options; @@ -143,7 +145,8 @@ LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) : std::ranges::copy( aSymbol.m_jumperPinGroups, std::back_inserter( m_jumperPinGroups ) ); m_duplicatePinNumbersAreJumpers = aSymbol.m_duplicatePinNumbersAreJumpers; - aSymbol.CopyUnitDisplayNames( m_unitDisplayNames ); + m_unitDisplayNames = aSymbol.GetUnitDisplayNames(); + m_bodyStyleNames = aSymbol.GetBodyStyleNames(); ClearSelected(); @@ -184,6 +187,7 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol ) m_name = aSymbol.m_name; m_fpFilters = wxArrayString( aSymbol.m_fpFilters ); m_unitCount = aSymbol.m_unitCount; + m_demorgan = aSymbol.m_demorgan; m_unitsLocked = aSymbol.m_unitsLocked; m_lastModDate = aSymbol.m_lastModDate; m_options = aSymbol.m_options; @@ -193,8 +197,8 @@ const LIB_SYMBOL& LIB_SYMBOL::operator=( const LIB_SYMBOL& aSymbol ) std::ranges::copy( aSymbol.m_jumperPinGroups, std::back_inserter( m_jumperPinGroups ) ); m_duplicatePinNumbersAreJumpers = aSymbol.m_duplicatePinNumbersAreJumpers; - m_unitDisplayNames.clear(); - aSymbol.CopyUnitDisplayNames( m_unitDisplayNames ); + m_unitDisplayNames = aSymbol.GetUnitDisplayNames(); + m_bodyStyleNames = aSymbol.GetBodyStyleNames(); m_drawings.clear(); @@ -278,12 +282,6 @@ LIB_SYMBOL_SPTR LIB_SYMBOL::GetRootSymbol() const } -bool LIB_SYMBOL::HasUnitDisplayName( int aUnit ) const -{ - return ( m_unitDisplayNames.count( aUnit ) == 1 ); -} - - wxString LIB_SYMBOL::GetUnitDisplayName( int aUnit, bool aLabel ) const { if( m_unitDisplayNames.contains( aUnit ) ) @@ -297,31 +295,20 @@ wxString LIB_SYMBOL::GetUnitDisplayName( int aUnit, bool aLabel ) const wxString LIB_SYMBOL::GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const { - if( aBodyStyle == BODY_STYLE::DEMORGAN ) - return aLabel ? _( "Alternate" ) : wxString( _HKI( "Alternate" ) ); - else if( aBodyStyle == BODY_STYLE::BASE ) - return aLabel ? _( "Standard" ) : wxString( _HKI( "Standard" ) ); - else - return wxT( "?" ); -} - - -void LIB_SYMBOL::CopyUnitDisplayNames( std::map& aTarget ) const -{ - for( const auto& it : m_unitDisplayNames ) - aTarget[it.first] = it.second; -} - - -void LIB_SYMBOL::SetUnitDisplayName( int aUnit, const wxString& aName ) -{ - if( aUnit <= GetUnitCount() ) + if( HasDeMorganBodyStyles() ) { - if( aName.Length() > 0 ) - m_unitDisplayNames[aUnit] = aName; - else - m_unitDisplayNames.erase( aUnit ); + if( aBodyStyle == BODY_STYLE::DEMORGAN ) + return aLabel ? _( "Alternate" ) : wxString( _HKI( "Alternate" ) ); + else if( aBodyStyle == BODY_STYLE::BASE ) + return aLabel ? _( "Standard" ) : wxString( _HKI( "Standard" ) ); } + else if( IsMultiBodyStyle() ) + { + if( aBodyStyle <= (int) m_bodyStyleNames.size() ) + return m_bodyStyleNames[aBodyStyle-1]; + } + + return wxT( "?" ); } @@ -1215,7 +1202,11 @@ void LIB_SYMBOL::Move( const VECTOR2I& aOffset ) } -bool LIB_SYMBOL::HasAlternateBodyStyle() const +// Before V10 we didn't store the number of body styles in a symbol -- we just looked through all +// its drawings each time we wanted to know. This is now only used to set the count when a legacy +// symbol is first read. (Legacy symbols also didn't support arbitrary body styles, so the count +// is always 1 or 2, and when 2 it is always a De Morgan pair.) +bool LIB_SYMBOL::HasLegacyAlternateBodyStyle() const { for( const SCH_ITEM& item : m_drawings ) { @@ -1387,20 +1378,23 @@ int LIB_SYMBOL::GetUnitCount() const } -void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePins ) +void LIB_SYMBOL::SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins ) { - if( aHasAlternate == HasAlternateBodyStyle() ) + if( GetBodyStyleCount() == aCount ) return; // Duplicate items to create the converted shape - if( aHasAlternate ) + if( GetBodyStyleCount() < aCount ) { - if( aDuplicatePins ) + if( aDuplicateDrawItems || aDuplicatePins ) { std::vector tmp; // Temporarily store the duplicated pins here. - for( SCH_ITEM& item : m_drawings[ SCH_PIN_T ] ) + for( SCH_ITEM& item : m_drawings ) { + if( item.Type() != SCH_PIN_T && !aDuplicateDrawItems ) + continue; + if( item.m_bodyStyle == 1 ) { SCH_ITEM* newItem = item.Duplicate( IGNORE_PARENT_GROUP ); @@ -1754,11 +1748,17 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR if( m_unitsLocked != aRhs.m_unitsLocked ) return ( m_unitsLocked ) ? 1 : -1; - // Compare unit display names + // Compare unit display names... if( m_unitDisplayNames < aRhs.m_unitDisplayNames ) return -1; else if( m_unitDisplayNames > aRhs.m_unitDisplayNames ) return 1; + + // ... and body style names. + if( m_bodyStyleNames < aRhs.m_bodyStyleNames ) + return -1; + else if( m_bodyStyleNames > aRhs.m_bodyStyleNames ) + return 1; } return retv; @@ -1841,6 +1841,11 @@ double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const if( m_unitCount != other.m_unitCount ) similarity *= 0.5; + if( GetBodyStyleCount() != other.GetBodyStyleCount() ) + similarity *= 0.5; + else if( m_bodyStyleNames != other.m_bodyStyleNames ) + similarity *= 0.9; + if( m_pinNameOffset != other.m_pinNameOffset ) similarity *= 0.9; diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 4cee72ca05..dae2c565a4 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -89,8 +89,7 @@ public: LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary = nullptr ); - virtual ~LIB_SYMBOL() - {} + virtual ~LIB_SYMBOL() = default; /// http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared. LIB_SYMBOL_SPTR SharedPtr() const { return m_me; } @@ -231,9 +230,9 @@ public: * * @return the symbol bounding box ( in user coordinates ) * @param aUnit = unit selection = 0, or 1..n - * @param aBodyStyle = 0, 1 or 2 + * @param aBodyStyle = body style selection = 0, or 1..n * If aUnit == 0, unit is not used - * if aBodyStyle == 0 Convert is non used + * if aBodyStyle == 0, body style is not used * @param aIgnoreHiddenFields default true, ignores any hidden fields * @param aIgnoreLabelsOnInvisiblePins default true, ignores pin number and pin name * of invisible pins @@ -252,9 +251,9 @@ public: * * @return the symbol bounding box ( in user coordinates ) without fields * @param aUnit = unit selection = 0, or 1..n - * @param aBodyStyle = 0, 1 or 2 + * @param aBodyStyle = body style selection = 0, or 1..n * If aUnit == 0, unit is not used - * if aBodyStyle == 0 Convert is non used + * if aBodyStyle == 0, body style is not used * Fields are not taken in account */ const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins, @@ -422,9 +421,9 @@ public: * Note pin objects are owned by the draw list of the symbol. Deleting any of the objects * will leave list in a unstable state and will likely segfault when the list is destroyed. * - * @param aUnit - Unit number of pins to collect. Set to 0 to get pins from any symbol unit. + * @param aUnit - Unit number of pins to collect. Set to 0 to get pins from all symbol units. * @param aBodyStyle - Symbol alternate body style of pins to collect. Set to 0 to get pins - * from any DeMorgan variant of symbol. + * from all body styles. */ std::vector GetPins( int aUnit, int aBodyStyle ) const; @@ -444,8 +443,7 @@ public: * * @param aNumber - Number of the pin to find. * @param aUnit - Unit filter. Set to 0 if a specific unit number is not required. - * @param aBodyStyle - DeMorgan variant filter. Set to 0 if no specific DeMorgan variant is - * required. + * @param aBodyStyle - Body style filter. Set to 0 if no specific body style is not required. * @return The pin object if found. Otherwise NULL. */ SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const; @@ -472,11 +470,12 @@ public: void Move( const VECTOR2I& aOffset ) override; /** - * Test if symbol has more than one body conversion type (DeMorgan). - * - * @return True if symbol has more than one conversion. + * Before V10 we didn't store the number of body styles in a symbol -- we just looked through all + * its drawings each time we wanted to know. This is now only used to set the count when a legacy + * symbol is first read. (Legacy symbols also didn't support arbitrary body styles, so the count + * is always 1 or 2, and when 2 it is always a De Morgan pair.) */ - bool HasAlternateBodyStyle() const override; + bool HasLegacyAlternateBodyStyle() const; /** * @return the highest pin number of the symbol's pins. @@ -542,14 +541,9 @@ public: * @param aCount - Number of units per package. * @param aDuplicateDrawItems Create duplicate draw items of unit 1 for each additional unit. */ - void SetUnitCount( int aCount, bool aDuplicateDrawItems = true ); + void SetUnitCount( int aCount, bool aDuplicateDrawItems ); int GetUnitCount() const override; - /** - * Return true if the given unit \a aUnit has a display name defined - */ - bool HasUnitDisplayName( int aUnit ) const; - wxString GetUnitName( int aUnit ) const override { return GetUnitDisplayName( aUnit, true ); @@ -562,15 +556,8 @@ public: wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override; - /** - * Copy all unit display names into the given map \a aTarget - */ - void CopyUnitDisplayNames( std::map& aTarget ) const; - - /** - * Set the user-defined display name for \a aUnit to \a aName for symbols with units. - */ - void SetUnitDisplayName( int aUnit, const wxString& aName ); + std::map& GetUnitDisplayNames() { return m_unitDisplayNames; } + const std::map& GetUnitDisplayNames() const { return m_unitDisplayNames; } bool GetDuplicatePinNumbersAreJumpers() const { return m_duplicatePinNumbersAreJumpers; } void SetDuplicatePinNumbersAreJumpers( bool aEnabled ) { m_duplicatePinNumbersAreJumpers = aEnabled; } @@ -589,10 +576,26 @@ public: * @return true if the symbol has multiple units per symbol. * When true, the reference has a sub reference to identify symbol. */ - bool IsMulti() const override { return m_unitCount > 1; } + bool IsMultiUnit() const override { return m_unitCount > 1; } static wxString LetterSubReference( int aUnit, wxChar aInitialLetter ); + bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; } + + int GetBodyStyleCount() const override + { + if( m_demorgan ) + return 2; + else + return std::max( 1, (int) m_bodyStyleNames.size() ); + } + + bool HasDeMorganBodyStyles() const override { return m_demorgan; } + void SetHasDeMorganBodyStyles( bool aFlag ) { m_demorgan = aFlag; } + + const std::vector& GetBodyStyleNames() const { return m_bodyStyleNames; } + void SetBodyStyleNames( const std::vector& aBodyStyleNames ) { m_bodyStyleNames = aBodyStyleNames; } + /** * Set or clear the alternate body style (DeMorgan) for the symbol. * @@ -604,7 +607,7 @@ public: * @param aHasAlternate - Set or clear the symbol alternate body style. * @param aDuplicatePins - Duplicate all pins from original body style if true. */ - void SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePins = true ); + void SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins ); /** * Comparison test that can be used for operators. @@ -682,18 +685,22 @@ private: timestamp_t m_lastModDate; int m_unitCount; ///< Number of units (parts) per package. - bool m_unitsLocked; ///< True if symbol has multiple units and changing one - ///< unit does not automatically change another unit. + bool m_unitsLocked; ///< True if symbol has multiple units and changing one unit + ///< does not automatically change another unit. - LIBRENTRYOPTIONS m_options; ///< Special symbol features such as POWER or NORMAL.) + bool m_demorgan; ///< True if there are two body styles: normal and De Morgan + ///< If false, the body style count is taken from m_bodyStyleNames + ///< size + + LIBRENTRYOPTIONS m_options; ///< Special symbol features such as POWER or NORMAL. LIB_ITEMS_CONTAINER m_drawings; SYMBOL_LIB* m_library; wxString m_name; wxString m_keyWords; ///< Search keywords - wxArrayString m_fpFilters; ///< List of suitable footprint names for the - ///< symbol (wild card names accepted). + wxArrayString m_fpFilters; ///< List of suitable footprint names for the symbol (wild card + ///< names accepted). /// A list of jumper pin groups, each of which is a set of pin numbers that should be jumpered /// together (treated as internally connected for the purposes of connectivity) @@ -704,6 +711,7 @@ private: bool m_duplicatePinNumbersAreJumpers; std::map m_unitDisplayNames; + std::vector m_bodyStyleNames; }; #endif // CLASS_LIBENTRY_H diff --git a/eeschema/picksymbol.cpp b/eeschema/picksymbol.cpp index ac99570b57..dd751aa23d 100644 --- a/eeschema/picksymbol.cpp +++ b/eeschema/picksymbol.cpp @@ -185,36 +185,25 @@ void SCH_EDIT_FRAME::SelectUnit( SCH_SYMBOL* aSymbol, int aUnit ) } -void SCH_EDIT_FRAME::FlipBodyStyle( SCH_SYMBOL* aSymbol ) +void SCH_EDIT_FRAME::SelectBodyStyle( SCH_SYMBOL* aSymbol, int aBodyStyle ) { if( !aSymbol || !aSymbol->GetLibSymbolRef() ) return; - SCH_COMMIT commit( m_toolManager ); - wxString msg; + const int bodyStyleCount = aSymbol->GetLibSymbolRef()->GetBodyStyleCount(); + const int currentBodyStyle = aSymbol->GetBodyStyle(); - if( !aSymbol->GetLibSymbolRef()->HasAlternateBodyStyle() ) - { - LIB_ID id = aSymbol->GetLibSymbolRef()->GetLibId(); - - msg.Printf( _( "No alternate body style found for symbol '%s' in library '%s'." ), - id.GetLibItemName().wx_str(), - id.GetLibNickname().wx_str() ); - DisplayError( this, msg ); + if( bodyStyleCount <= 1 || currentBodyStyle == aBodyStyle ) return; - } + + if( aBodyStyle > bodyStyleCount ) + aBodyStyle = bodyStyleCount; + + SCH_COMMIT commit( m_toolManager ); commit.Modify( aSymbol, GetScreen() ); - aSymbol->SetBodyStyle( aSymbol->GetBodyStyle() + 1 ); - - // ensure m_bodyStyle = 1 or 2 - // 1 = shape 1 = first (base DeMorgan) alternate body style - // 2 = shape 2 = second (DeMorgan conversion) alternate body style - // > 2 is not currently supported - // When m_bodyStyle = val max, return to the first shape - if( aSymbol->GetBodyStyle() > BODY_STYLE::DEMORGAN ) - aSymbol->SetBodyStyle( BODY_STYLE::BASE ); + aSymbol->SetBodyStyle( aBodyStyle ); // If selected make sure all the now-included pins are selected if( aSymbol->IsSelected() ) diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index e1c4534fb4..3cabe37483 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -114,22 +114,13 @@ static wxFileName GetRescueLibraryFileName( SCHEMATIC* aSchematic ) } -RESCUE_CASE_CANDIDATE::RESCUE_CASE_CANDIDATE( const wxString& aRequestedName, - const wxString& aNewName, - LIB_SYMBOL* aLibCandidate, - int aUnit, - int aConvert ) -{ - m_requested_name = aRequestedName; - m_new_name = aNewName; - m_lib_candidate = aLibCandidate; - m_unit = aUnit; - m_convert = aConvert; -} +RESCUE_CASE_CANDIDATE::RESCUE_CASE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, + LIB_SYMBOL* aLibCandidate, int aUnit, int aBodyStyle ) : + RESCUE_CANDIDATE( aRequestedName, aNewName, aLibCandidate, aUnit, aBodyStyle ) +{} -void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer, - boost::ptr_vector& aCandidates ) +void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer, boost::ptr_vector& aCandidates ) { std::map candidate_map; @@ -214,31 +205,7 @@ bool RESCUE_CASE_CANDIDATE::PerformAction( RESCUER* aRescuer ) } -RESCUE_CACHE_CANDIDATE::RESCUE_CACHE_CANDIDATE( const wxString& aRequestedName, - const wxString& aNewName, - LIB_SYMBOL* aCacheCandidate, - LIB_SYMBOL* aLibCandidate, - int aUnit, - int aConvert ) -{ - m_requested_name = aRequestedName; - m_new_name = aNewName; - m_cache_candidate = aCacheCandidate; - m_lib_candidate = aLibCandidate; - m_unit = aUnit; - m_convert = aConvert; -} - - -RESCUE_CACHE_CANDIDATE::RESCUE_CACHE_CANDIDATE() -{ - m_cache_candidate = nullptr; - m_lib_candidate = nullptr; -} - - -void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer, - boost::ptr_vector& aCandidates ) +void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer, boost::ptr_vector& aCandidates ) { std::map candidate_map; @@ -258,8 +225,7 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer, // A new symbol name is found (a new group starts here). // Search the symbol names candidates only once for this group: old_symbol_name = symbol_name; - cache_match = findSymbol( symbol_name, PROJECT_SCH::SchLibs( aRescuer.GetPrj() ), - true ); + cache_match = findSymbol( symbol_name, PROJECT_SCH::SchLibs( aRescuer.GetPrj() ), true ); lib_match = findSymbol( symbol_name, PROJECT_SCH::SchLibs( aRescuer.GetPrj() ), false ); // At some point during V5 development, the LIB_ID delimiter character ':' was @@ -304,8 +270,7 @@ wxString RESCUE_CACHE_CANDIDATE::GetActionDescription() const if( !m_cache_candidate && !m_lib_candidate ) { - action.Printf( _( "Cannot rescue symbol %s which is not available in any library or " - "the cache." ), + action.Printf( _( "Cannot rescue symbol %s which is not available in any library or the cache." ), m_requested_name ); } else if( m_cache_candidate && !m_lib_candidate ) @@ -358,24 +323,20 @@ RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( const LIB_ const LIB_ID& aNewId, LIB_SYMBOL* aCacheCandidate, LIB_SYMBOL* aLibCandidate, - int aUnit, int aConvert ) : - RESCUE_CANDIDATE() -{ - m_requested_id = aRequestedId; - m_requested_name = aRequestedId.Format().wx_str(); - m_new_id = aNewId; - m_lib_candidate = aLibCandidate; - m_cache_candidate = aCacheCandidate; - m_unit = aUnit; - m_convert = aConvert; -} + int aUnit, int aBodyStyle ) : + RESCUE_CANDIDATE( aRequestedId.Format().wx_str(), wxEmptyString, aLibCandidate, aUnit, aBodyStyle ), + m_requested_id( aRequestedId ), + m_new_id( aNewId ), + m_cache_candidate( aCacheCandidate ) +{} -RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE() -{ - m_cache_candidate = nullptr; - m_lib_candidate = nullptr; -} +RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE() : + RESCUE_CANDIDATE( wxEmptyString, wxEmptyString, nullptr, 0, 0 ), + m_requested_id(), + m_new_id(), + m_cache_candidate( nullptr ) +{} void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( RESCUER& aRescuer, @@ -415,13 +376,11 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( RESCUER& aRescuer, symbolName.Printf( wxT( "%s-%s" ), symbol_id.GetLibNickname().wx_str(), symbol_id.GetLibItemName().wx_str() ); - cache_match = findSymbol( symbolName, PROJECT_SCH::SchLibs( aRescuer.GetPrj() ), - true ); + cache_match = findSymbol( symbolName, PROJECT_SCH::SchLibs( aRescuer.GetPrj() ), true ); } // Get the library symbol from the symbol library table. - lib_match = SchGetLibSymbol( symbol_id, - PROJECT_SCH::SchSymbolLibTable( aRescuer.GetPrj() ) ); + lib_match = SchGetLibSymbol( symbol_id, PROJECT_SCH::SchSymbolLibTable( aRescuer.GetPrj() ) ); if( !cache_match && !lib_match ) continue; @@ -484,8 +443,7 @@ wxString RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::GetActionDescription() const if( !m_cache_candidate && !m_lib_candidate ) { - action.Printf( _( "Cannot rescue symbol %s which is not available in any library or " - "the cache." ), + action.Printf( _( "Cannot rescue symbol %s which is not available in any library or the cache." ), UnescapeString( m_requested_id.GetLibItemName().wx_str() ) ); } else if( m_cache_candidate && !m_lib_candidate ) @@ -546,8 +504,7 @@ RESCUER::RESCUER( PROJECT& aProject, SCHEMATIC* aSchematic, SCH_SHEET_PATH* aCur } -void RESCUER::LogRescue( SCH_SYMBOL* aSymbol, const wxString &aOldName, - const wxString &aNewName ) +void RESCUER::LogRescue( SCH_SYMBOL* aSymbol, const wxString &aOldName, const wxString &aNewName ) { RESCUE_LOG logitem; logitem.symbol = aSymbol; @@ -711,11 +668,8 @@ bool LEGACY_RESCUER::WriteRescueLibrary( wxWindow *aParent ) } catch( ... /* IO_ERROR ioe */ ) { - wxString msg; - - msg.Printf( _( "Failed to create symbol library file '%s'." ), - m_rescue_lib->GetFullFileName() ); - DisplayError( aParent, msg ); + DisplayError( aParent, wxString::Format( _( "Failed to create symbol library file '%s'." ), + m_rescue_lib->GetFullFileName() ) ); return false; } @@ -723,8 +677,7 @@ bool LEGACY_RESCUER::WriteRescueLibrary( wxWindow *aParent ) wxString libPaths; wxString libName = m_rescue_lib->GetName(); - SYMBOL_LIBS* libs = - dynamic_cast( m_prj->GetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS ) ); + SYMBOL_LIBS* libs = dynamic_cast( m_prj->GetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS ) ); if( !libs ) { diff --git a/eeschema/project_rescue.h b/eeschema/project_rescue.h index e0b72a9be8..5cc5935a36 100644 --- a/eeschema/project_rescue.h +++ b/eeschema/project_rescue.h @@ -63,6 +63,15 @@ enum RESCUE_TYPE class RESCUE_CANDIDATE { public: + RESCUE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, + LIB_SYMBOL* aLibCandidate, int aUnit, int aBodyStyle ) : + m_requested_name( aRequestedName ), + m_new_name( aNewName ), + m_lib_candidate( aLibCandidate ), + m_unit( aUnit ), + m_bodyStyle( aBodyStyle ) + {} + virtual ~RESCUE_CANDIDATE() {} /** @@ -88,8 +97,7 @@ public: virtual LIB_SYMBOL* GetLibCandidate() const { return m_lib_candidate; } int GetUnit() const { return m_unit; } - - int GetConvert() const { return m_convert; } + int GetBodyStyle() const { return m_bodyStyle; } /** * Get a description of the action proposed, for displaying in the UI. @@ -108,7 +116,7 @@ protected: wxString m_new_name; LIB_SYMBOL* m_lib_candidate; int m_unit; - int m_convert; + int m_bodyStyle; }; @@ -130,12 +138,14 @@ public: * @param aNewName is the name we want to change it to. * @param aLibCandidate is the part that will give us. * @param aUnit is the unit of the rescued symbol. - * @param aConvert is the body style of the rescued symbol. + * @param aBodyStyle is the body style of the rescued symbol. */ RESCUE_CASE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, - LIB_SYMBOL* aLibCandidate, int aUnit = 0, int aConvert = 0 ); + LIB_SYMBOL* aLibCandidate, int aUnit = 0, int aBodyStyle = 0 ); - RESCUE_CASE_CANDIDATE() { m_lib_candidate = nullptr; } + RESCUE_CASE_CANDIDATE() : + RESCUE_CANDIDATE( wxEmptyString, wxEmptyString, nullptr, 0, 0 ) + {} virtual wxString GetActionDescription() const override; @@ -164,13 +174,19 @@ public: * @param aCacheCandidate is the part from the cache. * @param aLibCandidate is the part that would be loaded from the library. * @param aUnit is the unit of the rescued symbol. - * @param aConvert is the body style of the rescued symbol. + * @param aBodyStyle is the body style of the rescued symbol. */ RESCUE_CACHE_CANDIDATE( const wxString& aRequestedName, const wxString& aNewName, LIB_SYMBOL* aCacheCandidate, LIB_SYMBOL* aLibCandidate, - int aUnit = 0, int aConvert = 0 ); + int aUnit = 0, int aBodyStyle = 0 ) : + RESCUE_CANDIDATE( aRequestedName, aNewName, aLibCandidate, aUnit, aBodyStyle ), + m_cache_candidate( aCacheCandidate ) + {} - RESCUE_CACHE_CANDIDATE(); + RESCUE_CACHE_CANDIDATE() : + RESCUE_CANDIDATE( wxEmptyString, wxEmptyString, nullptr, 0, 0 ), + m_cache_candidate( nullptr ) + {} virtual LIB_SYMBOL* GetCacheCandidate() const override { return m_cache_candidate; } @@ -199,11 +215,11 @@ public: * @param aCacheCandidate is the part from the cache. * @param aLibCandidate is the part that would be loaded from the library. * @param aUnit is the unit of the rescued symbol. - * @param aConvert is the body style of the rescued symbol. + * @param aBodyStyle is the body style of the rescued symbol. */ RESCUE_SYMBOL_LIB_TABLE_CANDIDATE( const LIB_ID& aRequestedId, const LIB_ID& aNewId, LIB_SYMBOL* aCacheCandidate, LIB_SYMBOL* aLibCandidate, - int aUnit = 0, int aConvert = 0 ); + int aUnit = 0, int aBodyStyle = 0 ); RESCUE_SYMBOL_LIB_TABLE_CANDIDATE(); @@ -235,9 +251,7 @@ public: RESCUER( PROJECT& aProject, SCHEMATIC* aSchematic, SCH_SHEET_PATH* aCurrentSheet, EDA_DRAW_PANEL_GAL::GAL_TYPE aGalBackeEndType ); - virtual ~RESCUER() - { - } + virtual ~RESCUER() = default; /** * Write the rescue library. @@ -313,16 +327,16 @@ public: protected: friend class DIALOG_RESCUE_EACH; - std::vector m_symbols; - PROJECT* m_prj; - SCHEMATIC* m_schematic; + std::vector m_symbols; + PROJECT* m_prj; + SCHEMATIC* m_schematic; EDA_DRAW_PANEL_GAL::GAL_TYPE m_galBackEndType; - SCH_SHEET_PATH* m_currentSheet; + SCH_SHEET_PATH* m_currentSheet; boost::ptr_vector m_all_candidates; - std::vector m_chosen_candidates; + std::vector m_chosen_candidates; - std::vector m_rescue_log; + std::vector m_rescue_log; }; @@ -335,9 +349,7 @@ public: { } - virtual ~LEGACY_RESCUER() - { - } + virtual ~LEGACY_RESCUER() = default; virtual void FindCandidates() override; @@ -361,9 +373,7 @@ public: SCH_SHEET_PATH* aCurrentSheet, EDA_DRAW_PANEL_GAL::GAL_TYPE aGalBackeEndType ); - virtual ~SYMBOL_LIB_TABLE_RESCUER() - { - } + virtual ~SYMBOL_LIB_TABLE_RESCUER() = default; virtual void FindCandidates() override; @@ -376,8 +386,7 @@ public: virtual void AddSymbol( LIB_SYMBOL* aNewSymbol ) override; private: - std::vector> m_rescueLibSymbols; - + std::vector> m_rescueLibSymbols; std::unique_ptr> m_properties; ///< Library plugin properties. }; diff --git a/eeschema/sch_collectors.cpp b/eeschema/sch_collectors.cpp index 2e18490a9f..73bdf518c2 100644 --- a/eeschema/sch_collectors.cpp +++ b/eeschema/sch_collectors.cpp @@ -123,13 +123,13 @@ INSPECT_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData ) void SCH_COLLECTOR::Collect( SCH_SCREEN* aScreen, const std::vector& aFilterList, - const VECTOR2I& aPos, int aUnit, int aConvert ) + const VECTOR2I& aPos, int aUnit, int aBodyStyle ) { Empty(); // empty the collection just in case SetScanTypes( aFilterList ); m_Unit = aUnit; - m_BodyStyle = aConvert; + m_BodyStyle = aBodyStyle; // remember where the snapshot was taken from and pass refPos to the Inspect() function. SetRefPos( aPos ); @@ -143,13 +143,13 @@ void SCH_COLLECTOR::Collect( SCH_SCREEN* aScreen, const std::vector& aF void SCH_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector& aFilterList, - const VECTOR2I& aPos, int aUnit, int aConvert ) + const VECTOR2I& aPos, int aUnit, int aBodyStyle ) { Empty(); // empty the collection just in case SetScanTypes( aFilterList ); m_Unit = aUnit; - m_BodyStyle = aConvert; + m_BodyStyle = aBodyStyle; // remember where the snapshot was taken from and pass refPos to the Inspect() function. SetRefPos( aPos ); diff --git a/eeschema/sch_collectors.h b/eeschema/sch_collectors.h index 9025b3f99e..fdb9b31bda 100644 --- a/eeschema/sch_collectors.h +++ b/eeschema/sch_collectors.h @@ -74,10 +74,10 @@ public: * the priority order of the resulting collection. * @param aPos are the coordinates to use in hit testing. * @param aUnit is the symbol unit filter (for symbol editor). - * @param aConvert is the DeMorgan filter (for symbol editor) + * @param aBodyStyle is the body style filter (for symbol editor) */ void Collect( SCH_SCREEN* aScreen, const std::vector& aScanTypes, - const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 ); + const VECTOR2I& aPos, int aUnit = 0, int aBodyStyle = 0 ); /** * Scan an #EDA_ITEM using this class's Inspector method which does the collection. @@ -87,10 +87,10 @@ public: * and the priority order of the resulting collection. * @param aPos are the coordinates to use in hit testing. * @param aUnit is the symbol unit filter (for symbol editor). - * @param aConvert is the DeMorgan filter (for symbol editor). + * @param aBodyStyle is the body style filter (for symbol editor). */ void Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector& aScanTypes, - const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 ); + const VECTOR2I& aPos, int aUnit = 0, int aBodyStyle = 0 ); /** * Test if the collected items form a corner of two line segments. @@ -101,7 +101,7 @@ public: public: int m_Unit; // Fixed symbol unit filter (for symbol editor) - int m_BodyStyle; // Fixed DeMorgan filter (for symbol editor) + int m_BodyStyle; // Fixed body style filter (for symbol editor) bool m_ShowPinElectricalTypes; }; diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 1bececc1c2..f99e0ffca0 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -394,8 +394,7 @@ public: void SetCurrentSheet( const SCH_SHEET_PATH& aSheet ); - void UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete = false, - bool aUpdateRtree = false ) override; + void UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete = false, bool aUpdateRtree = false ) override; /** * Rebuild the GAL and redraw the screen. @@ -589,9 +588,8 @@ public: * new/duplicate libs. * @return True if the schematic was imported properly. */ - bool LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurrentSheet, - const wxString& aFileName, bool aSkipRecursionCheck = false, - bool aSkipLibCheck = false ); + bool LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurrentSheet, const wxString& aFileName, + bool aSkipRecursionCheck = false, bool aSkipLibCheck = false ); /** * Remove a given junction and heals any wire segments under the junction. @@ -602,10 +600,10 @@ public: void UpdateHopOveredWires( SCH_ITEM* aItem ); - void FlipBodyStyle( SCH_SYMBOL* aSymbol ); - void SelectUnit( SCH_SYMBOL* aSymbol, int aUnit ); + void SelectBodyStyle( SCH_SYMBOL* aSymbol, int aBodyStyle ); + void SetAltPinFunction( SCH_PIN* aPin, const wxString& aFunction ); /* Undo - redo */ diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 6f9fed6f0b..c6e39ddb58 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -306,7 +306,7 @@ wxString SCH_FIELD::GetFullText( int unit ) const wxString text = GetText(); text << wxT( "?" ); - if( GetParentSymbol() && GetParentSymbol()->IsMulti() ) + if( GetParentSymbol() && GetParentSymbol()->IsMultiUnit() ) text << LIB_SYMBOL::LetterSubReference( unit, 'A' ); return text; diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index 96a0fd8ffa..c36fc610f9 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -123,4 +123,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20250318 // ~ no longer means empty text //#define SEXPR_SCHEMATIC_FILE_VERSION 20250425 // uuids for tables //#define SEXPR_SCHEMATIC_FILE_VERSION 20250513 // Groups can have design block lib_id -#define SEXPR_SCHEMATIC_FILE_VERSION 20250610 // DNP, etc. flags for rule areas +//#define SEXPR_SCHEMATIC_FILE_VERSION 20250610 // DNP, etc. flags for rule areas +#define SEXPR_SCHEMATIC_FILE_VERSION 20250827 // Custom body styles diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 85e7fee11f..4e0c1da5b5 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -1485,7 +1485,7 @@ void SCH_IO_ALTIUM::ParseComponent( int aIndex, const std::mapSetName( name ); ksymbol->SetDescription( elem.componentdescription ); ksymbol->SetLibId( libId ); - ksymbol->SetUnitCount( elem.partcount - 1 ); + ksymbol->SetUnitCount( elem.partcount - 1, true ); m_libSymbols.insert( { aIndex, ksymbol } ); // each component has its own symbol for now @@ -4499,7 +4499,7 @@ std::vector SCH_IO_ALTIUM::ParseLibComponent( const std::mapGetName() ); symbol->SetDescription( elem.componentdescription ); symbol->SetLibId( libId ); - symbol->SetUnitCount( elem.partcount - 1 ); + symbol->SetUnitCount( elem.partcount - 1, true ); symbols.push_back( symbol ); } diff --git a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp index 3337847e7a..340f71a374 100644 --- a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp @@ -302,11 +302,11 @@ void CADSTAR_SCH_ARCHIVE_LOADER::copySymbolItems( std::unique_ptr& a int aDestUnit, bool aOverrideFields ) { // Ensure there are no items on the unit we want to load onto - for( SCH_ITEM* item : aDestSym->GetUnitDrawItems( aDestUnit, 0 /*aConvert*/ ) ) + for( SCH_ITEM* item : aDestSym->GetUnitDrawItems( aDestUnit, 0 /* aBodyStyle */ ) ) aDestSym->RemoveDrawItem( item ); // Copy all draw items - for( SCH_ITEM* newItem : aSourceSym->GetUnitDrawItems( 1, 0 /*aConvert*/ ) ) + for( SCH_ITEM* newItem : aSourceSym->GetUnitDrawItems( 1, 0 /* aBodyStyle */ ) ) { SCH_ITEM* itemCopy = static_cast( newItem->Clone() ); itemCopy->SetParent( aDestSym.get() ); @@ -664,7 +664,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary() wxString escapedPartName = EscapeString( part.Name, CTX_LIBID ); LIB_SYMBOL* kiSym = new LIB_SYMBOL( escapedPartName ); - kiSym->SetUnitCount( part.Definition.GateSymbols.size() ); + kiSym->SetUnitCount( part.Definition.GateSymbols.size(), true ); bool ok = true; for( std::pair gatePair : part.Definition.GateSymbols ) diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index 3cdbfe81f6..1cff1adbce 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -2038,7 +2038,7 @@ EAGLE_LIBRARY* SCH_IO_EAGLE::loadLibrary( const ELIBRARY* aLibrary, EAGLE_LIBRAR // Process each gate in the deviceset for this device. int gate_count = static_cast( edeviceset->gates.size() ); - libSymbol->SetUnitCount( gate_count ); + libSymbol->SetUnitCount( gate_count, true ); libSymbol->LockUnits( true ); SCH_FIELD* reference = libSymbol->GetField( FIELD_T::REFERENCE ); @@ -2078,7 +2078,7 @@ EAGLE_LIBRARY* SCH_IO_EAGLE::loadLibrary( const ELIBRARY* aLibrary, EAGLE_LIBRAR gateindex++; } - libSymbol->SetUnitCount( gate_count ); + libSymbol->SetUnitCount( gate_count, true ); if( gate_count == 1 && ispower ) libSymbol->SetGlobalPower(); diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp index 776810c404..cb9254c706 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp @@ -194,10 +194,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDocs() THROW_IO_ERROR( _( "symbol document library file is empty" ) ); if( !strCompare( DOCFILE_IDENT, line, &line ) ) - { - SCH_PARSE_ERROR( "invalid document library file version formatting in header", - reader, line ); - } + SCH_PARSE_ERROR( "invalid document library file version formatting in header", reader, line ); while( reader.ReadLine() ) { @@ -352,8 +349,10 @@ LIB_SYMBOL* SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart( LINE_READER& aReader, int a tmp = tokens.GetNextToken(); // Show pin numbers. if( !( tmp == "Y" || tmp == "N") ) + { THROW_PARSE_ERROR( "expected Y or N", aReader.GetSource(), aReader.Line(), aReader.LineNumber(), pos ); + } pos += tmp.size() + 1; symbol->SetShowPinNumbers( ( tmp == "N" ) ? false : true ); @@ -372,17 +371,14 @@ LIB_SYMBOL* SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart( LINE_READER& aReader, int a tmp = tokens.GetNextToken(); // Number of units. if( !tmp.ToLong( &num ) ) - { - THROW_PARSE_ERROR( "invalid unit count", aReader.GetSource(), aReader.Line(), - aReader.LineNumber(), pos ); - } + THROW_PARSE_ERROR( "invalid unit count", aReader.GetSource(), aReader.Line(), aReader.LineNumber(), pos ); pos += tmp.size() + 1; - symbol->SetUnitCount( (int)num ); + symbol->SetUnitCount( (int)num, true ); // Ensure m_unitCount is >= 1. Could be read as 0 in old libraries. if( symbol->GetUnitCount() < 1 ) - symbol->SetUnitCount( 1 ); + symbol->SetUnitCount( 1, true ); // Copy symbol name and prefix. @@ -474,6 +470,7 @@ LIB_SYMBOL* SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart( LINE_READER& aReader, int a loadFootprintFilters( symbol, aReader ); else if( strCompare( "ENDDEF", line, &line ) ) // End of symbol description { + symbol->SetHasDeMorganBodyStyles( symbol->HasLegacyAlternateBodyStyle() ); return symbol.release(); } @@ -520,6 +517,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadAliases( std::unique_ptr& aS } newSymbol->SetParent( aSymbol.get() ); + newSymbol->SetHasDeMorganBodyStyles( newSymbol->HasLegacyAlternateBodyStyle() ); // This will prevent duplicate aliases. (*aMap)[ newSymbol->GetName() ] = newSymbol; @@ -1224,12 +1222,12 @@ SCH_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr& aS if( !tmp.ToLong( &num ) ) { - THROW_PARSE_ERROR( "invalid pin alternate body type", aReader.GetSource(), aReader.Line(), + THROW_PARSE_ERROR( "invalid pin body style", aReader.GetSource(), aReader.Line(), aReader.LineNumber(), pos ); } pos += tmp.size() + 1; - int convert = (int) num; + int bodyStyle = (int) num; tmp = tokens.GetNextToken(); @@ -1269,7 +1267,7 @@ SCH_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr& aS length, nameTextSize, numberTextSize, - convert, + bodyStyle, position, unit ); @@ -1320,8 +1318,7 @@ SCH_PIN* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPin( std::unique_ptr& aS case LOWLEVEL_OUT: pin->SetShape( GRAPHIC_PINSHAPE::OUTPUT_LOW ); break; case FALLING_EDGE: pin->SetShape( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK ); break; case NONLOGIC: pin->SetShape( GRAPHIC_PINSHAPE::NONLOGIC ); break; - default: - SCH_PARSE_ERROR( "pin attributes do not define a valid pin shape", aReader, line ); + default: SCH_PARSE_ERROR( "pin attributes do not define a valid pin shape", aReader, line ); } } @@ -1341,8 +1338,7 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadPolyLine( LINE_READER& aReader ) polyLine->SetUnit( parseInt( aReader, line, &line ) ); polyLine->SetBodyStyle( parseInt( aReader, line, &line ) ); - STROKE_PARAMS stroke( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), - LINE_STYLE::SOLID ); + STROKE_PARAMS stroke( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), LINE_STYLE::SOLID ); polyLine->SetStroke( stroke ); @@ -1377,8 +1373,7 @@ SCH_SHAPE* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadBezier( LINE_READER& aReader ) bezier->SetUnit( parseInt( aReader, line, &line ) ); bezier->SetBodyStyle( parseInt( aReader, line, &line ) ); - STROKE_PARAMS stroke ( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), - LINE_STYLE::SOLID ); + STROKE_PARAMS stroke ( schIUScale.MilsToIU( parseInt( aReader, line, &line ) ), LINE_STYLE::SOLID ); bezier->SetStroke( stroke ); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp index da882e667a..34293f3c1b 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp @@ -733,9 +733,7 @@ void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSche } m_out->Print( "(unit %d)", unit ); - - if( aSymbol->GetBodyStyle() == BODY_STYLE::DEMORGAN ) - m_out->Print( "(convert %d)", aSymbol->GetBodyStyle() ); + m_out->Print( "(body_style %d)", aSymbol->GetBodyStyle() ); KICAD_FORMAT::FormatBool( m_out, "exclude_from_sim", aSymbol->GetExcludedFromSim() ); KICAD_FORMAT::FormatBool( m_out, "in_bom", !aSymbol->GetExcludedFromBOM() ); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp index 406796f9c1..000f6f5aa9 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp @@ -168,6 +168,23 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT // TODO: add anchor position token here. + if( aSymbol->IsMultiBodyStyle() ) + { + aFormatter.Print( "(body_styles " ); + + if( aSymbol->HasDeMorganBodyStyles() ) + { + aFormatter.Print( "demorgan" ); + } + else + { + for( const wxString& bodyStyle : aSymbol->GetBodyStyleNames() ) + aFormatter.Print( "%s ", aFormatter.Quotew( bodyStyle ).c_str() ); + } + + aFormatter.Print( ")" ); + } + if( !aSymbol->GetShowPinNumbers() ) aFormatter.Print( "(pin_numbers (hide yes))" ); @@ -258,9 +275,9 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT unit.m_bodyStyle ); // if the unit has a display name, write that - if( aSymbol->HasUnitDisplayName( unit.m_unit ) ) + if( aSymbol->GetUnitDisplayNames().contains( unit.m_unit ) ) { - name = aSymbol->GetUnitDisplayName( unit.m_unit, false ); + name = aSymbol->GetUnitDisplayNames().at( unit.m_unit ); aFormatter.Print( "(unit_name %s)", aFormatter.Quotes( name ).c_str() ); } diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index fc4c027eee..782b276e55 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -309,19 +309,15 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi long tmp; wxString name; wxString error; - wxString unitDisplayName; SCH_ITEM* item; std::unique_ptr symbol = std::make_unique( wxEmptyString ); - symbol->SetUnitCount( 1 ); + symbol->SetUnitCount( 1, true ); token = NextTok(); if( !IsSymbol( token ) ) - { - THROW_PARSE_ERROR( _( "Invalid symbol name" ), CurSource(), CurLine(), CurLineNumber(), - CurOffset() ); - } + THROW_PARSE_ERROR( _( "Invalid symbol name" ), CurSource(), CurLine(), CurLineNumber(), CurOffset() ); name = FromUTF8(); @@ -377,6 +373,10 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi NeedRIGHT(); break; + case T_body_styles: + parseBodyStyles( symbol ); + break; + case T_pin_names: parsePinNames( symbol ); break; @@ -512,14 +512,14 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi if( !tokenizer.GetNextToken().ToLong( &tmp ) ) { - error.Printf( _( "Invalid symbol convert number %s" ), name.c_str() ); + error.Printf( _( "Invalid symbol body style number %s" ), name.c_str() ); THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } m_bodyStyle = static_cast( tmp ); if( m_bodyStyle > 1 ) - symbol->SetHasAlternateBodyStyle( true, false ); + symbol->SetBodyStyleCount( m_bodyStyle, false, false ); if( m_unit > symbol->GetUnitCount() ) symbol->SetUnitCount( m_unit, false ); @@ -537,10 +537,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi token = NextTok(); if( IsSymbol( token ) ) - { - unitDisplayName = FromUTF8(); - symbol->SetUnitDisplayName( m_unit, unitDisplayName ); - } + symbol->GetUnitDisplayNames()[m_unit] = FromUTF8(); NeedRIGHT(); break; @@ -621,8 +618,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi symbol->GetDrawItems().sort(); m_symbolName.clear(); - const std::vector* embeddedFonts = - symbol->GetEmbeddedFiles()->UpdateFontFiles(); + const std::vector* embeddedFonts = symbol->GetEmbeddedFiles()->UpdateFontFiles(); symbol->RunOnChildren( [&]( SCH_ITEM* aChild ) @@ -632,6 +628,11 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi }, RECURSE_MODE::NO_RECURSE ); + // Before V10 we didn't store the number of body styles in a symbol, we just looked at all its + // drawings each time we wanted to know. + if( m_requiredVersion < 20250827 ) + symbol->SetHasDeMorganBodyStyles( symbol->HasLegacyAlternateBodyStyle() ); + return symbol.release(); } @@ -906,6 +907,34 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseHeader( TSCHEMATIC_T::T aHeaderType, int aF } +void SCH_IO_KICAD_SEXPR_PARSER::parseBodyStyles( std::unique_ptr& aSymbol ) +{ + wxCHECK_RET( CurTok() == T_body_styles, + "Cannot parse " + GetTokenString( CurTok() ) + " as a body_styles token." ); + + std::vector names; + + for( T token = NextTok(); token != T_RIGHT; token = NextTok() ) + { + if( token == T_demorgan ) + { + aSymbol->SetHasDeMorganBodyStyles( true ); + continue; + } + else if( !IsSymbol( token ) ) + { + THROW_PARSE_ERROR( _( "Invalid property value" ), CurSource(), CurLine(), CurLineNumber(), + CurOffset() ); + } + + names.push_back( FromUTF8() ); + } + + if( !names.empty() ) + aSymbol->SetBodyStyleNames( names ); +} + + void SCH_IO_KICAD_SEXPR_PARSER::parsePinNames( std::unique_ptr& aSymbol ) { wxCHECK_RET( CurTok() == T_pin_names, @@ -3146,10 +3175,9 @@ SCH_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseSchematicSymbol() NeedRIGHT(); break; - case T_convert: - // Use SetBodyStyleUnconditional() because the full symbol properties - // (including the corresponding LIB_SYMBOL) are not known - symbol->SetBodyStyleUnconditional( parseInt( "symbol body style" ) ); + case T_convert: // Legacy token + case T_body_style: + symbol->SetBodyStyle( parseInt( "symbol body style" ) ); NeedRIGHT(); break; diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h index 8180ed613a..67fabe9603 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.h @@ -203,8 +203,8 @@ private: aBottom = parseInternalUnits( "bottom margin" ); } - void parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSyntax, - bool aEnforceMinTextSize = true ); + void parseEDA_TEXT( EDA_TEXT* aText, bool aConvertOverbarSyntax, bool aEnforceMinTextSize = true ); + void parseBodyStyles( std::unique_ptr& aSymbol ); void parsePinNames( std::unique_ptr& aSymbol ); void parsePinNumbers( std::unique_ptr& aSymbol ); diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index aaf78f9b24..efe1f65516 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -669,10 +669,10 @@ void SCH_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUnitCount() ) + if( symbol->IsMultiUnit() ) aList.emplace_back( _( "Unit" ), GetUnitDisplayName( GetUnit(), false ) ); - if( symbol->HasAlternateBodyStyle() ) + if( symbol->IsMultiBodyStyle() ) aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( GetBodyStyle(), true ) ); if( dynamic_cast( symbol ) && IsPrivate() ) @@ -716,7 +716,7 @@ static struct SCH_ITEM_DESC if( SCH_ITEM* schItem = dynamic_cast( aItem ) ) { if( const SYMBOL* symbol = schItem->GetParentSymbol() ) - return symbol->IsMulti(); + return symbol->IsMultiUnit(); } return false; @@ -728,7 +728,7 @@ static struct SCH_ITEM_DESC if( SCH_ITEM* schItem = dynamic_cast( aItem ) ) { if( const SYMBOL* symbol = schItem->GetParentSymbol() ) - return symbol->HasAlternateBodyStyle(); + return symbol->IsMultiBodyStyle(); } return false; diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index a4644449b5..8707560852 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -454,25 +454,11 @@ void SCH_SYMBOL::UpdatePins() } -void SCH_SYMBOL::SetBodyStyleUnconditional( int aBodyStyle ) -{ - if( m_bodyStyle != aBodyStyle ) - { - m_bodyStyle = ( m_bodyStyle == BODY_STYLE::BASE ) ? BODY_STYLE::DEMORGAN - : BODY_STYLE::BASE; - - // The body style may have a different pin layout so the update the pin map. - UpdatePins(); - } -} - - void SCH_SYMBOL::SetBodyStyle( int aBodyStyle ) { - if( HasAlternateBodyStyle() && m_bodyStyle != aBodyStyle ) + if( aBodyStyle != m_bodyStyle ) { - m_bodyStyle = ( m_bodyStyle == BODY_STYLE::BASE ) ? BODY_STYLE::DEMORGAN - : BODY_STYLE::BASE; + m_bodyStyle = aBodyStyle; // The body style may have a different pin layout so the update the pin map. UpdatePins(); @@ -480,15 +466,6 @@ void SCH_SYMBOL::SetBodyStyle( int aBodyStyle ) } -bool SCH_SYMBOL::HasAlternateBodyStyle() const -{ - if( m_part ) - return m_part->HasAlternateBodyStyle(); - - return false; -} - - int SCH_SYMBOL::GetUnitCount() const { if( m_part ) @@ -498,6 +475,24 @@ int SCH_SYMBOL::GetUnitCount() const } +int SCH_SYMBOL::GetBodyStyleCount() const +{ + if( m_part ) + return m_part->GetBodyStyleCount(); + + return 0; +} + + +bool SCH_SYMBOL::HasDeMorganBodyStyles() const +{ + if( m_part ) + return m_part->HasDeMorganBodyStyles(); + + return false; +} + + wxString SCH_SYMBOL::GetUnitDisplayName( int aUnit, bool aLabel ) const { if( m_part ) @@ -513,10 +508,6 @@ wxString SCH_SYMBOL::GetBodyStyleDescription( int aBodyStyle, bool aLabel ) cons { if( m_part ) return m_part->GetBodyStyleDescription( aBodyStyle, aLabel ); - else if( aBodyStyle == BODY_STYLE::DEMORGAN ) - return aLabel ? _( "Alternate" ) : wxString( _HKI( "Alternate" ) ); - else if( aBodyStyle == BODY_STYLE::BASE ) - return aLabel ? _( "Standard" ) : wxString( _HKI( "Standard" ) ); else return wxT( "?" ); } @@ -2972,7 +2963,7 @@ static struct SCH_SYMBOL_DESC [=]( INSPECTABLE* aItem ) -> bool { if( SCH_SYMBOL* symbol = dynamic_cast( aItem ) ) - return symbol->IsMulti(); + return symbol->IsMultiUnit(); return false; }; @@ -2981,7 +2972,7 @@ static struct SCH_SYMBOL_DESC [=]( INSPECTABLE* aItem ) -> bool { if( SCH_SYMBOL* symbol = dynamic_cast( aItem ) ) - return symbol->HasAlternateBodyStyle(); + return symbol->IsMultiBodyStyle(); return false; }; @@ -3011,7 +3002,7 @@ static struct SCH_SYMBOL_DESC if( SCH_SYMBOL* symbol = dynamic_cast( aItem ) ) { - for( int ii : { BODY_STYLE::BASE, BODY_STYLE::DEMORGAN } ) + for( int ii = 1; ii <= symbol->GetBodyStyleCount(); ii++ ) choices.Add( symbol->GetBodyStyleDescription( ii, false ) ); } diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 356866ecca..58b10267fb 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -232,15 +232,6 @@ public: void SetBodyStyle( int aBodyStyle ) override; - /** - * Similar to SetBodyStyle(), but always set the body style, regardless - * the lib symbol properties (the LIB_SYMBOL m_part can be not set during - * schematic files loading) - */ - void SetBodyStyleUnconditional( int aBodyStyle ); - - bool HasAlternateBodyStyle() const override; - wxString GetPrefix() const { return m_prefix; } void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; } @@ -258,7 +249,18 @@ public: */ int GetUnitCount() const override; - bool IsMulti() const override { return GetUnitCount() > 1; } + bool IsMultiUnit() const override { return GetUnitCount() > 1; } + + /** + * Return the number of body styles of the symbol. + * + * @return the number of body styles or zero if the library entry cannot be found. + */ + int GetBodyStyleCount() const override; + + bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; } + + bool HasDeMorganBodyStyles() const override; /** * Compute the new transform matrix based on \a aOrientation for the symbol which is @@ -522,7 +524,7 @@ public: void SetBodyStyleProp( const wxString& aBodyStyle ) override { - for( int bodyStyle : { BODY_STYLE::BASE, BODY_STYLE::DEMORGAN } ) + for( int bodyStyle = 1; bodyStyle <= GetBodyStyleCount(); bodyStyle++ ) { if( GetBodyStyleDescription( bodyStyle, false ) == aBodyStyle ) { diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index 1744b4c2d4..ae02ba927b 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -8,6 +8,8 @@ background bezier bidirectional bitmap +body_style +body_styles bold border bottom @@ -32,6 +34,7 @@ data date default default_instance +demorgan diameter diamond directive_label diff --git a/eeschema/symbol.h b/eeschema/symbol.h index 2f6de0988f..59cf8bb8cf 100644 --- a/eeschema/symbol.h +++ b/eeschema/symbol.h @@ -115,23 +115,28 @@ public: virtual bool IsPower() const = 0; virtual bool IsNormal() const = 0; - /** - * Test if symbol has more than one body conversion type (DeMorgan). - * - * @return True if symbol has more than one conversion. - */ - virtual bool HasAlternateBodyStyle() const = 0; - /** * @return true if the symbol has multiple units per symbol. */ - virtual bool IsMulti() const = 0; + virtual bool IsMultiUnit() const = 0; /** * @return the number of units defined for the symbol. */ virtual int GetUnitCount() const = 0; + /** + * @return true if the symbol has multiple body styles available. + */ + virtual bool IsMultiBodyStyle() const = 0; + + /** + * @return the number of body styles defined for the symbol. + */ + virtual int GetBodyStyleCount() const = 0; + + virtual bool HasDeMorganBodyStyles() const = 0; + virtual const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const = 0; diff --git a/eeschema/symbol_checker.cpp b/eeschema/symbol_checker.cpp index 5eeba9f156..eee770bf90 100644 --- a/eeschema/symbol_checker.cpp +++ b/eeschema/symbol_checker.cpp @@ -71,7 +71,7 @@ void CheckDuplicatePins( LIB_SYMBOL* aSymbol, std::vector& aMessages, if( !next->GetName().IsEmpty() ) nextName = " '" + next->GetName() + "'"; - if( aSymbol->HasAlternateBodyStyle() && next->GetBodyStyle() ) + if( aSymbol->IsMultiBodyStyle() && next->GetBodyStyle() ) { if( pin->GetUnit() == 0 || next->GetUnit() == 0 ) { @@ -217,12 +217,6 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, aMessages.push_back( msg ); } - if( aSymbol->HasAlternateBodyStyle() ) - { - msg.Printf( _( "A Power Symbol should not have DeMorgan variants

" ) ); - aMessages.push_back( msg ); - } - if( pinList.size() != 1 ) { msg.Printf( _( "A Power Symbol should have only one pin

" ) ); @@ -262,7 +256,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, && !pin->IsVisible() ) { // hidden power pin - if( aSymbol->HasAlternateBodyStyle() && pin->GetBodyStyle() ) + if( aSymbol->IsMultiBodyStyle() && pin->GetBodyStyle() ) { if( aSymbol->GetUnitCount() <= 1 ) { @@ -321,7 +315,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, // pin is off grid msg.Empty(); - if( aSymbol->HasAlternateBodyStyle() && pin->GetBodyStyle() ) + if( aSymbol->IsMultiBodyStyle() && pin->GetBodyStyle() ) { if( aSymbol->GetUnitCount() <= 1 ) { diff --git a/eeschema/symbol_editor/lib_symbol_library_manager.cpp b/eeschema/symbol_editor/lib_symbol_library_manager.cpp index 03c25427e3..515a9d6010 100644 --- a/eeschema/symbol_editor/lib_symbol_library_manager.cpp +++ b/eeschema/symbol_editor/lib_symbol_library_manager.cpp @@ -56,7 +56,7 @@ std::unique_ptr LIB_SYMBOL_LIBRARY_MANAGER::CreateSymbol( const NEW_ if( !aParent ) { new_symbol->GetReferenceField().SetText( aProps.reference ); - new_symbol->SetUnitCount( aProps.unitCount ); + new_symbol->SetUnitCount( aProps.unitCount, true ); if( aProps.pinNameInside ) { @@ -80,7 +80,8 @@ std::unique_ptr LIB_SYMBOL_LIBRARY_MANAGER::CreateSymbol( const NEW_ if( aProps.unitCount < 2 ) new_symbol->LockUnits( false ); - new_symbol->SetHasAlternateBodyStyle( aProps.alternateBodyStyle ); + if( aProps.alternateBodyStyle ) + new_symbol->SetBodyStyleCount( 2, false, true ); } else { diff --git a/eeschema/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index e7e46d67a9..c473398dc0 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -113,7 +113,6 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar() editMenu->AppendSeparator(); editMenu->Add( SCH_ACTIONS::pinTable ); - editMenu->Add( SCH_ACTIONS::setUnitDisplayName ); editMenu->Add( SCH_ACTIONS::updateSymbolFields ); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 5d988cb685..7e79f7530b 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -94,6 +94,7 @@ bool SYMBOL_EDIT_FRAME::m_showDeMorgan = false; BEGIN_EVENT_TABLE( SYMBOL_EDIT_FRAME, SCH_BASE_FRAME ) EVT_COMBOBOX( ID_LIBEDIT_SELECT_UNIT_NUMBER, SYMBOL_EDIT_FRAME::OnSelectUnit ) + EVT_COMBOBOX( ID_LIBEDIT_SELECT_BODY_STYLE, SYMBOL_EDIT_FRAME::OnSelectBodyStyle ) // menubar commands EVT_MENU( wxID_EXIT, SYMBOL_EDIT_FRAME::OnExitKiCad ) @@ -101,6 +102,7 @@ BEGIN_EVENT_TABLE( SYMBOL_EDIT_FRAME, SCH_BASE_FRAME ) // Update user interface elements. EVT_UPDATE_UI( ID_LIBEDIT_SELECT_UNIT_NUMBER, SYMBOL_EDIT_FRAME::OnUpdateUnitNumber ) + EVT_UPDATE_UI( ID_LIBEDIT_SELECT_BODY_STYLE, SYMBOL_EDIT_FRAME::OnUpdateBodyStyle ) // Drop files event EVT_DROP_FILES( SYMBOL_EDIT_FRAME::OnDropFiles ) @@ -113,9 +115,9 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME ), m_unitSelectBox( nullptr ), + m_bodyStyleSelectBox( nullptr ), m_isSymbolFromSchematic( false ) { - SetShowDeMorgan( false ); m_SyncPinEdit = false; m_symbol = nullptr; @@ -190,7 +192,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : UpdateTitle(); UpdateSymbolMsgPanelInfo(); - RebuildSymbolUnitsList(); + RebuildSymbolUnitAndBodyStyleLists(); m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this ); m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter ); @@ -560,34 +562,16 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() mgr->SetConditions( SCH_ACTIONS::showHiddenFields, CHECK( hiddenFieldCond ) ); mgr->SetConditions( SCH_ACTIONS::togglePinAltIcons, CHECK( showPinAltIconsCond ) ); - auto demorganCond = - [this]( const SELECTION& ) - { - return GetShowDeMorgan(); - }; - - auto demorganStandardCond = - [this]( const SELECTION& ) - { - return m_bodyStyle == BODY_STYLE::BASE; - }; - - auto demorganAlternateCond = - [this]( const SELECTION& ) - { - return m_bodyStyle == BODY_STYLE::DEMORGAN; - }; - auto multiUnitModeCond = [this]( const SELECTION& ) { - return m_symbol && m_symbol->IsMulti() && !m_symbol->UnitsLocked(); + return m_symbol && m_symbol->IsMultiUnit() && !m_symbol->UnitsLocked(); }; - auto hasMultipleUnitsCond = + auto multiBodyStyleModeCond = [this]( const SELECTION& ) { - return m_symbol && m_symbol->IsMulti(); + return m_symbol && m_symbol->IsMultiBodyStyle(); }; auto syncedPinsModeCond = @@ -606,11 +590,9 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() mgr->SetConditions( SCH_ACTIONS::symbolProperties, ENABLE( canEditProperties && haveSymbolCond ) ); mgr->SetConditions( SCH_ACTIONS::runERC, ENABLE( haveSymbolCond ) ); mgr->SetConditions( SCH_ACTIONS::pinTable, ENABLE( isEditableCond && haveSymbolCond ) ); + mgr->SetConditions( SCH_ACTIONS::cycleBodyStyle, ENABLE( multiBodyStyleModeCond ) ); - mgr->SetConditions( SCH_ACTIONS::showDeMorganStandard, ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) ); - mgr->SetConditions( SCH_ACTIONS::showDeMorganAlternate, ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) ); mgr->SetConditions( SCH_ACTIONS::toggleSyncedPinsMode, ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) ); - mgr->SetConditions( SCH_ACTIONS::setUnitDisplayName, ACTION_CONDITIONS().Enable( isEditableCond && hasMultipleUnitsCond ) ); // Only enable a tool if the symbol is edtable #define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) ) @@ -705,33 +687,58 @@ void SYMBOL_EDIT_FRAME::doCloseWindow() } -void SYMBOL_EDIT_FRAME::RebuildSymbolUnitsList() +void SYMBOL_EDIT_FRAME::RebuildSymbolUnitAndBodyStyleLists() { - if( !m_unitSelectBox ) - return; - - if( m_unitSelectBox->GetCount() != 0 ) - m_unitSelectBox->Clear(); - - if( !m_symbol || m_symbol->GetUnitCount() <= 1 ) + if( m_unitSelectBox ) { - m_unit = 1; - m_unitSelectBox->Append( wxEmptyString ); - } - else - { - for( int i = 0; i < m_symbol->GetUnitCount(); i++ ) + if( m_unitSelectBox->GetCount() != 0 ) + m_unitSelectBox->Clear(); + + if( !m_symbol || m_symbol->GetUnitCount() <= 1 ) { - wxString unitDisplayName = m_symbol->GetUnitDisplayName( i + 1, true ); - m_unitSelectBox->Append( unitDisplayName ); + m_unit = 1; + m_unitSelectBox->Append( wxEmptyString ); } + else + { + for( int i = 0; i < m_symbol->GetUnitCount(); i++ ) + m_unitSelectBox->Append( m_symbol->GetUnitDisplayName( i + 1, true ) ); + } + + // Ensure the selected unit is compatible with the number of units of the current symbol: + if( m_symbol && m_symbol->GetUnitCount() < m_unit ) + m_unit = 1; + + m_unitSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 ); } - // Ensure the selected unit is compatible with the number of units of the current symbol: - if( m_symbol && m_symbol->GetUnitCount() < m_unit ) - m_unit = 1; + if( m_bodyStyleSelectBox ) + { + if( m_bodyStyleSelectBox->GetCount() != 0 ) + m_bodyStyleSelectBox->Clear(); - m_unitSelectBox->SetSelection(( m_unit > 0 ) ? m_unit - 1 : 0 ); + if( !m_symbol || !m_symbol->IsMultiBodyStyle() ) + { + m_bodyStyle = 1; + m_bodyStyleSelectBox->Append( wxEmptyString ); + } + else if( m_symbol && m_symbol->HasDeMorganBodyStyles() ) + { + m_bodyStyleSelectBox->Append( wxGetTranslation( DEMORGAN_STD ) ); + m_bodyStyleSelectBox->Append( wxGetTranslation( DEMORGAN_ALT ) ); + } + else + { + for( int i = 0; i < m_symbol->GetBodyStyleCount(); i++ ) + m_bodyStyleSelectBox->Append( m_symbol->GetBodyStyleNames()[i] ); + } + + // Ensure the selected body style is compatible with the number of body styles of the current symbol: + if( m_symbol && m_symbol->GetBodyStyleCount() < m_bodyStyle ) + m_bodyStyle = 1; + + m_bodyStyleSelectBox->SetSelection( ( m_bodyStyle > 0 ) ? m_bodyStyle - 1 : 0 ); + } } @@ -811,12 +818,25 @@ void SYMBOL_EDIT_FRAME::OnUpdateUnitNumber( wxUpdateUIEvent& event ) void SYMBOL_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event ) { - int i = event.GetSelection(); - - if( i == wxNOT_FOUND ) + if( event.GetSelection() == wxNOT_FOUND ) return; - SetUnit( i + 1 ); + SetUnit( event.GetSelection() + 1 ); +} + + +void SYMBOL_EDIT_FRAME::OnUpdateBodyStyle( wxUpdateUIEvent& event ) +{ + event.Enable( m_symbol && m_symbol->GetBodyStyleCount() > 1 ); +} + + +void SYMBOL_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event ) +{ + if( event.GetSelection() == wxNOT_FOUND ) + return; + + SetBodyStyle( event.GetSelection() + 1 ); } @@ -893,7 +913,7 @@ void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom ) Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_SYMBOL, symbolName ); // Ensure synchronized pin edit can be enabled only symbols with interchangeable units - m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMulti() && !aSymbol->UnitsLocked(); + m_SyncPinEdit = aSymbol && aSymbol->IsRoot() && aSymbol->IsMultiUnit() && !aSymbol->UnitsLocked(); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); @@ -1076,9 +1096,31 @@ void SYMBOL_EDIT_FRAME::SetUnit( int aUnit ) } +void SYMBOL_EDIT_FRAME::SetBodyStyle( int aBodyStyle ) +{ + wxCHECK( aBodyStyle > 0 && aBodyStyle <= GetCurSymbol()->GetBodyStyleCount(), /* void */ ); + + if( m_bodyStyle == aBodyStyle ) + return; + + m_toolManager->RunAction( ACTIONS::cancelInteractive ); + m_toolManager->RunAction( ACTIONS::selectionClear ); + + m_bodyStyle = aBodyStyle; + + if( m_bodyStyleSelectBox->GetSelection() != ( m_bodyStyle - 1 ) ) + m_bodyStyleSelectBox->SetSelection( m_bodyStyle - 1 ); + + + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); + RebuildView(); + UpdateSymbolMsgPanelInfo(); +} + + bool SYMBOL_EDIT_FRAME::SynchronizePins() { - return m_SyncPinEdit && m_symbol && m_symbol->IsMulti() && !m_symbol->UnitsLocked(); + return m_SyncPinEdit && m_symbol && m_symbol->IsMultiUnit() && !m_symbol->UnitsLocked(); } @@ -1656,8 +1698,7 @@ void SYMBOL_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) SetScreen( symbol_screen ); SetCurSymbol( new LIB_SYMBOL( *lib_symbol ), false ); - RebuildSymbolUnitsList(); - SetShowDeMorgan( GetCurSymbol()->HasAlternateBodyStyle() ); + RebuildSymbolUnitAndBodyStyleLists(); if( m_toolManager ) m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); @@ -1837,8 +1878,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol ) ToggleLibraryTree(); UpdateTitle(); - RebuildSymbolUnitsList(); - SetShowDeMorgan( GetCurSymbol()->HasAlternateBodyStyle() ); + RebuildSymbolUnitAndBodyStyleLists(); UpdateSymbolMsgPanelInfo(); // Let tools add things to the view if necessary diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 1396d5b027..613acf6963 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -43,6 +43,12 @@ class SYMBOL_EDITOR_SETTINGS; class EDA_LIST_DIALOG; +#define UNITS_ALL _HKI( "ALL" ) +#define DEMORGAN_ALL _HKI( "ALL" ) +#define DEMORGAN_STD _HKI( "Standard" ) +#define DEMORGAN_ALT _HKI( "Alternate" ) + + /** * The symbol library editor main window. */ @@ -180,6 +186,7 @@ public: void DuplicateSymbol( bool aFromClipboard ); void OnSelectUnit( wxCommandEvent& event ); + void OnSelectBodyStyle( wxCommandEvent& event ); void ToggleProperties() override; @@ -190,9 +197,10 @@ public: void ThawLibraryTree(); void OnUpdateUnitNumber( wxUpdateUIEvent& event ); + void OnUpdateBodyStyle( wxUpdateUIEvent& event ); void UpdateAfterSymbolProperties( wxString* aOldName = nullptr ); - void RebuildSymbolUnitsList(); + void RebuildSymbolUnitAndBodyStyleLists(); bool canCloseWindow( wxCloseEvent& aCloseEvent ) override; void doCloseWindow() override; @@ -232,10 +240,7 @@ public: void SetUnit( int aUnit ); int GetBodyStyle() const { return m_bodyStyle; } - void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; } - - bool GetShowDeMorgan() const { return m_showDeMorgan; } - void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; } + void SetBodyStyle( int aBodyStyle ); bool GetShowInvisibleFields(); bool GetShowInvisiblePins(); @@ -545,17 +550,18 @@ public: private: ///< Helper screen used when no symbol is loaded - SCH_SCREEN* m_dummyScreen; + SCH_SCREEN* m_dummyScreen; - LIB_SYMBOL* m_symbol; // a symbol I own, it is not in any library, but a - // copy could be. - wxComboBox* m_unitSelectBox; // a ComboBox to select a unit to edit (if the - // symbol has multiple units) - SYMBOL_TREE_PANE* m_treePane; // symbol search tree widget + LIB_SYMBOL* m_symbol; // a symbol I own, it is not in any library, but a copy could be. + wxComboBox* m_unitSelectBox; // a ComboBox to select a unit to edit (if the + // symbol has multiple units) + wxComboBox* m_bodyStyleSelectBox; // a ComboBox to select a body style to edit (if the symbol has + // multiple body styles) + SYMBOL_TREE_PANE* m_treePane; // symbol search tree widget LIB_SYMBOL_LIBRARY_MANAGER* m_libMgr; // manager taking care of temporary modifications - SYMBOL_EDITOR_SETTINGS* m_settings; // Handle to the settings + SYMBOL_EDITOR_SETTINGS* m_settings; // Handle to the settings - LIB_ID m_centerItemOnIdle; + LIB_ID m_centerItemOnIdle; // The unit number to edit and show int m_unit; diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index d9306861f0..5a755b1104 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -243,14 +243,12 @@ bool SYMBOL_EDIT_FRAME::LoadSymbolFromCurrentLib( const wxString& aSymbolName, i return false; // Enable synchronized pin edit mode for symbols with interchangeable units - m_SyncPinEdit = GetCurSymbol()->IsMulti() && !GetCurSymbol()->UnitsLocked(); + m_SyncPinEdit = GetCurSymbol()->IsMultiUnit() && !GetCurSymbol()->UnitsLocked(); ClearUndoRedoList(); m_toolManager->RunAction( ACTIONS::zoomFitScreen ); - SetShowDeMorgan( GetCurSymbol()->Flatten()->HasAlternateBodyStyle() ); - if( aUnit > 0 ) - RebuildSymbolUnitsList(); + RebuildSymbolUnitAndBodyStyleLists(); return true; } @@ -306,8 +304,7 @@ bool SYMBOL_EDIT_FRAME::LoadOneLibrarySymbolAux( LIB_SYMBOL* aEntry, const wxStr } UpdateTitle(); - RebuildSymbolUnitsList(); - SetShowDeMorgan( GetCurSymbol()->HasAlternateBodyStyle() ); + RebuildSymbolUnitAndBodyStyleLists(); ClearUndoRedoList(); @@ -414,13 +411,6 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol( const wxString& aInheritFrom ) m_libMgr->CreateNewSymbol( lib, props ); SyncLibraries( false ); LoadSymbol( props.name, lib, 1 ); - - LIB_SYMBOL* createdSymbol = m_libMgr->GetSymbol( props.name, lib ); - - if( props.parentSymbolName.IsEmpty() ) - SetShowDeMorgan( props.alternateBodyStyle ); - else if( createdSymbol ) - SetShowDeMorgan( createdSymbol->HasAlternateBodyStyle() ); } @@ -1231,8 +1221,7 @@ void SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties( wxString* aOldName ) m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, m_symbol->GetName() ) ); } - RebuildSymbolUnitsList(); - SetShowDeMorgan( GetCurSymbol()->Flatten()->HasAlternateBodyStyle() ); + RebuildSymbolUnitAndBodyStyleLists(); UpdateTitle(); // N.B. The view needs to be rebuilt first as the Symbol Properties change may invalidate @@ -1623,7 +1612,7 @@ bool SYMBOL_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile ) ClearMsgPanel(); msg.Printf( _( "Symbol library file '%s' saved." ), fn.GetFullPath() ); - RebuildSymbolUnitsList(); + RebuildSymbolUnitAndBodyStyleLists(); return true; } diff --git a/eeschema/symbol_editor/symbol_editor_undo_redo.cpp b/eeschema/symbol_editor/symbol_editor_undo_redo.cpp index 36e0e5eed8..e1a7d6720e 100644 --- a/eeschema/symbol_editor/symbol_editor_undo_redo.cpp +++ b/eeschema/symbol_editor/symbol_editor_undo_redo.cpp @@ -103,8 +103,7 @@ void SYMBOL_EDIT_FRAME::GetSymbolFromRedoList() m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, symbol->GetName() ) ); } - RebuildSymbolUnitsList(); - SetShowDeMorgan( symbol->HasAlternateBodyStyle() ); + RebuildSymbolUnitAndBodyStyleLists(); UpdateTitle(); RebuildView(); @@ -154,8 +153,7 @@ void SYMBOL_EDIT_FRAME::GetSymbolFromUndoList() m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, symbol->GetName() ) ); } - RebuildSymbolUnitsList(); - SetShowDeMorgan( symbol->HasAlternateBodyStyle() ); + RebuildSymbolUnitAndBodyStyleLists(); UpdateTitle(); RebuildView(); diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.cpp b/eeschema/symbol_editor/toolbars_symbol_editor.cpp index e4e4cc07ad..81bcf693ad 100644 --- a/eeschema/symbol_editor/toolbars_symbol_editor.cpp +++ b/eeschema/symbol_editor/toolbars_symbol_editor.cpp @@ -145,8 +145,7 @@ std::optional SYMBOL_EDIT_TOOLBAR_SETTINGS::DefaultToolba .AppendAction( SCH_ACTIONS::checkSymbol ); config.AppendSeparator() - .AppendAction( SCH_ACTIONS::showDeMorganStandard ) - .AppendAction( SCH_ACTIONS::showDeMorganAlternate ); + .AppendControl( ACTION_TOOLBAR_CONTROLS::bodyStyleSelector ); config.AppendSeparator() .AppendControl( ACTION_TOOLBAR_CONTROLS::unitSelector ); @@ -182,6 +181,21 @@ void SYMBOL_EDIT_FRAME::configureToolbars() aToolbar->Add( m_unitSelectBox ); }; + auto bodyDisplayFactory = + [this]( ACTION_TOOLBAR* aToolbar ) + { + if( !m_bodyStyleSelectBox ) + { + m_bodyStyleSelectBox = new wxComboBox( aToolbar, ID_LIBEDIT_SELECT_BODY_STYLE, + wxEmptyString, wxDefaultPosition, + wxSize( LISTBOX_WIDTH, -1 ), 0, + nullptr, wxCB_READONLY ); + } + + aToolbar->Add( m_bodyStyleSelectBox ); + }; + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::unitSelector, unitDisplayFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::bodyStyleSelector, bodyDisplayFactory ); } diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 649039d05a..49a4b1992c 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -86,6 +86,7 @@ BEGIN_EVENT_TABLE( SYMBOL_VIEWER_FRAME, SCH_BASE_FRAME ) EVT_TOOL( ID_LIBVIEW_NEXT, SYMBOL_VIEWER_FRAME::onSelectNextSymbol ) EVT_TOOL( ID_LIBVIEW_PREVIOUS, SYMBOL_VIEWER_FRAME::onSelectPreviousSymbol ) EVT_CHOICE( ID_LIBVIEW_SELECT_UNIT_NUMBER, SYMBOL_VIEWER_FRAME::onSelectSymbolUnit ) + EVT_CHOICE( ID_LIBVIEW_SELECT_BODY_STYLE, SYMBOL_VIEWER_FRAME::onSelectSymbolBodyStyle ) // listbox events EVT_TEXT( ID_LIBVIEW_LIB_FILTER, SYMBOL_VIEWER_FRAME::OnLibFilter ) @@ -98,6 +99,7 @@ BEGIN_EVENT_TABLE( SYMBOL_VIEWER_FRAME, SCH_BASE_FRAME ) EVT_MENU( wxID_CLOSE, SYMBOL_VIEWER_FRAME::CloseLibraryViewer ) EVT_UPDATE_UI( ID_LIBVIEW_SELECT_UNIT_NUMBER, SYMBOL_VIEWER_FRAME::onUpdateUnitChoice ) + EVT_UPDATE_UI( ID_LIBVIEW_SELECT_BODY_STYLE, SYMBOL_VIEWER_FRAME::onUpdateBodyStyleChoice ) END_EVENT_TABLE() @@ -107,6 +109,7 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_VIEW_FRAME_NAME ), m_unitChoice( nullptr ), + m_bodyStyleChoice( nullptr ), m_libList( nullptr ), m_symbolList( nullptr ) { @@ -371,25 +374,6 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions() return GetRenderSettings() && GetRenderSettings()->m_ShowPinNumbers; }; - auto demorganCond = - [this]( const SELECTION& ) - { - LIB_SYMBOL* symbol = GetSelectedSymbol(); - return symbol && symbol->HasAlternateBodyStyle(); - }; - - auto demorganStandardCond = - []( const SELECTION& ) - { - return m_bodyStyle == BODY_STYLE::BASE; - }; - - auto demorganAlternateCond = - []( const SELECTION& ) - { - return m_bodyStyle == BODY_STYLE::DEMORGAN; - }; - auto haveDatasheetCond = [this]( const SELECTION& ) { @@ -401,9 +385,6 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions() mgr->SetConditions( SCH_ACTIONS::showElectricalTypes, CHECK( electricalTypesShownCondition ) ); mgr->SetConditions( SCH_ACTIONS::showPinNumbers, CHECK( pinNumbersShownCondition ) ); - mgr->SetConditions( SCH_ACTIONS::showDeMorganStandard, ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) ); - mgr->SetConditions( SCH_ACTIONS::showDeMorganAlternate, ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) ); - #undef CHECK #undef ENABLE } @@ -498,28 +479,50 @@ void SYMBOL_VIEWER_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent ) unit_count = std::max( symbol->GetUnitCount(), 1 ); m_unitChoice->Enable( unit_count > 1 ); + m_unitChoice->Clear(); if( unit_count > 1 ) { // rebuild the unit list if it is not suitable (after a new selection for instance) - if( unit_count != (int)m_unitChoice->GetCount() ) + if( unit_count != (int) m_unitChoice->GetCount() ) { - m_unitChoice->Clear(); - for( int ii = 0; ii < unit_count; ii++ ) - { - wxString unit = symbol->GetUnitDisplayName( ii + 1, true ); - m_unitChoice->Append( unit ); - } - + m_unitChoice->Append( symbol->GetUnitDisplayName( ii + 1, true ) ); } if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) ) m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) ); } - else if( m_unitChoice->GetCount() ) +} + + +void SYMBOL_VIEWER_FRAME::onUpdateBodyStyleChoice( wxUpdateUIEvent& aEvent ) +{ + LIB_SYMBOL* symbol = GetSelectedSymbol(); + + int bodyStyle_count = 1; + + if( symbol ) + bodyStyle_count = std::max( symbol->GetBodyStyleCount(), 1 ); + + m_bodyStyleChoice->Enable( bodyStyle_count > 1 ); + m_bodyStyleChoice->Clear(); + + if( bodyStyle_count > 1 ) { - m_unitChoice->Clear(); + if( symbol && symbol->HasDeMorganBodyStyles() ) + { + m_bodyStyleChoice->Append( wxGetTranslation( DEMORGAN_STD ) ); + m_bodyStyleChoice->Append( wxGetTranslation( DEMORGAN_ALT ) ); + } + else if( symbol ) + { + for( int i = 0; i < symbol->GetBodyStyleCount(); i++ ) + m_bodyStyleChoice->Append( symbol->GetBodyStyleNames()[i] ); + } + + if( m_bodyStyleChoice->GetSelection() != std::max( 0, m_bodyStyle - 1 ) ) + m_bodyStyleChoice->SetSelection( std::max( 0, m_bodyStyle - 1 ) ); } } @@ -1105,6 +1108,19 @@ void SYMBOL_VIEWER_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent ) } +void SYMBOL_VIEWER_FRAME::onSelectSymbolBodyStyle( wxCommandEvent& aEvent ) +{ + int ii = m_bodyStyleChoice->GetSelection(); + + if( ii < 0 ) + return; + + m_bodyStyle = ii + 1; + + updatePreviewSymbol(); +} + + void SYMBOL_VIEWER_FRAME::DisplayLibInfos() { wxString libName = m_currentSymbol.GetUniStringLibNickname(); diff --git a/eeschema/symbol_viewer_frame.h b/eeschema/symbol_viewer_frame.h index 8a64d72fbd..ee575784e3 100644 --- a/eeschema/symbol_viewer_frame.h +++ b/eeschema/symbol_viewer_frame.h @@ -137,6 +137,7 @@ private: void DClickOnSymbolList( wxCommandEvent& event ); void onUpdateUnitChoice( wxUpdateUIEvent& aEvent ); + void onUpdateBodyStyleChoice( wxUpdateUIEvent& aEvent ); void OnLibFilter( wxCommandEvent& aEvent ); void OnSymFilter( wxCommandEvent& aEvent ); @@ -145,6 +146,7 @@ private: void onSelectNextSymbol( wxCommandEvent& aEvent ); void onSelectPreviousSymbol( wxCommandEvent& aEvent ); void onSelectSymbolUnit( wxCommandEvent& aEvent ); + void onSelectSymbolBodyStyle( wxCommandEvent& aEvent ); void updatePreviewSymbol(); @@ -152,6 +154,7 @@ private: private: wxChoice* m_unitChoice; + wxChoice* m_bodyStyleChoice; wxSearchCtrl* m_libFilter; WX_LISTBOX* m_libList; // The list of libraries. diff --git a/eeschema/toolbars_symbol_viewer.cpp b/eeschema/toolbars_symbol_viewer.cpp index 45779f3a9e..357d0e5d44 100644 --- a/eeschema/toolbars_symbol_viewer.cpp +++ b/eeschema/toolbars_symbol_viewer.cpp @@ -68,8 +68,7 @@ std::optional SYMBOL_VIEWER_TOOLBAR_SETTINGS::DefaultTool .AppendAction( SCH_ACTIONS::showPinNumbers ); config.AppendSeparator() - .AppendAction( SCH_ACTIONS::showDeMorganStandard ) - .AppendAction( SCH_ACTIONS::showDeMorganAlternate ); + .AppendControl( ACTION_TOOLBAR_CONTROLS::bodyStyleSelector ); config.AppendSeparator() .AppendControl( ACTION_TOOLBAR_CONTROLS::unitSelector ); @@ -98,13 +97,26 @@ void SYMBOL_VIEWER_FRAME::configureToolbars() if( !m_unitChoice ) { m_unitChoice = new wxChoice( m_tbTopMain, ID_LIBVIEW_SELECT_UNIT_NUMBER, - wxDefaultPosition, wxSize( 150, -1 ) ); + wxDefaultPosition, wxSize( 150, -1 ) ); } aToolbar->Add( m_unitChoice ); }; + auto bodyChoiceFactory = + [this]( ACTION_TOOLBAR* aToolbar ) + { + if( !m_bodyStyleChoice ) + { + m_bodyStyleChoice = new wxChoice( m_tbTopMain, ID_LIBVIEW_SELECT_BODY_STYLE, + wxDefaultPosition, wxSize( 150, -1 ) ); + } + + aToolbar->Add( m_bodyStyleChoice ); + }; + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::unitSelector, unitChoiceFactory ); + RegisterCustomToolbarControlFactory( ACTION_TOOLBAR_CONTROLS::bodyStyleSelector, bodyChoiceFactory ); } diff --git a/eeschema/tools/sch_actions.cpp b/eeschema/tools/sch_actions.cpp index 8d7cd74019..2031b3ded4 100644 --- a/eeschema/tools/sch_actions.cpp +++ b/eeschema/tools/sch_actions.cpp @@ -270,12 +270,6 @@ TOOL_ACTION SCH_ACTIONS::updateSymbolFields( TOOL_ACTION_ARGS() .Tooltip( _( "Update symbol to match changes made in parent symbol" ) ) .Icon( BITMAPS::refresh ) ); -TOOL_ACTION SCH_ACTIONS::setUnitDisplayName( TOOL_ACTION_ARGS() - .Name( "eeschema.SymbolLibraryControl.setUnitDisplayName" ) - .Scope( AS_GLOBAL ) - .FriendlyName( _( "Set Unit Display Name..." ) ) - .Tooltip( _( "Set the display name for a particular unit in a multi-unit symbol" ) ) ); - TOOL_ACTION SCH_ACTIONS::addSymbolToSchematic( TOOL_ACTION_ARGS() .Name( "eeschema.SymbolLibraryControl.addSymbolToSchematic" ) .Scope( AS_GLOBAL ) @@ -846,27 +840,11 @@ TOOL_ACTION SCH_ACTIONS::assignNetclass( TOOL_ACTION_ARGS() .Tooltip( _( "Assign a netclass to nets matching a pattern" ) ) .Icon( BITMAPS::netlist ) ); -TOOL_ACTION SCH_ACTIONS::toggleDeMorgan( TOOL_ACTION_ARGS() +TOOL_ACTION SCH_ACTIONS::cycleBodyStyle( TOOL_ACTION_ARGS() .Name( "eeschema.InteractiveEdit.toggleDeMorgan" ) .Scope( AS_GLOBAL ) - .FriendlyName( _( "De Morgan Conversion" ) ) - .Tooltip( _( "Switch between De Morgan representations" ) ) - .Icon( BITMAPS::morgan2 ) ); - -TOOL_ACTION SCH_ACTIONS::showDeMorganStandard( TOOL_ACTION_ARGS() - .Name( "eeschema.InteractiveEdit.showDeMorganStandard" ) - .Scope( AS_GLOBAL ) - .FriendlyName( _( "De Morgan Standard" ) ) - .Tooltip( _( "Switch to standard De Morgan representation" ) ) - .ToolbarState( TOOLBAR_STATE::TOGGLE ) - .Icon( BITMAPS::morgan1 ) ); - -TOOL_ACTION SCH_ACTIONS::showDeMorganAlternate( TOOL_ACTION_ARGS() - .Name( "eeschema.InteractiveEdit.showDeMorganAlternate" ) - .Scope( AS_GLOBAL ) - .FriendlyName( _( "De Morgan Alternate" ) ) - .Tooltip( _( "Switch to alternate De Morgan representation" ) ) - .ToolbarState( TOOLBAR_STATE::TOGGLE ) + .FriendlyName( _( "Cycle Body Style" ) ) + .Tooltip( _( "Switch between De Morgan (or other) representations" ) ) .Icon( BITMAPS::morgan2 ) ); TOOL_ACTION SCH_ACTIONS::toLabel( TOOL_ACTION_ARGS() diff --git a/eeschema/tools/sch_actions.h b/eeschema/tools/sch_actions.h index 6874bac871..b016931c37 100644 --- a/eeschema/tools/sch_actions.h +++ b/eeschema/tools/sch_actions.h @@ -127,9 +127,7 @@ public: static TOOL_ACTION editValue; static TOOL_ACTION editFootprint; static TOOL_ACTION autoplaceFields; - static TOOL_ACTION toggleDeMorgan; - static TOOL_ACTION showDeMorganStandard; - static TOOL_ACTION showDeMorganAlternate; + static TOOL_ACTION cycleBodyStyle; static TOOL_ACTION editSymbolUnit; static TOOL_ACTION toLabel; static TOOL_ACTION toCLabel; @@ -211,7 +209,6 @@ public: static TOOL_ACTION importSymbol; static TOOL_ACTION exportSymbol; static TOOL_ACTION updateSymbolFields; - static TOOL_ACTION setUnitDisplayName; // Hierarchy navigation static TOOL_ACTION changeSheet; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 0ad1f5190d..4cd0378779 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -528,14 +528,14 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent ) m_toolMgr->PostAction( ACTIONS::refreshPreview ); } } - else if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_BASE - && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_ALT ) + else if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_BODY_STYLE + && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_BODY_STYLE_END ) { - int bodyStyle = ( *evt->GetCommandId() - ID_POPUP_SCH_SELECT_BASE ) + 1; + int bodyStyle = ( *evt->GetCommandId() - ID_POPUP_SCH_SELECT_BODY_STYLE ) + 1; if( symbol && symbol->GetBodyStyle() != bodyStyle ) { - m_frame->FlipBodyStyle( symbol ); + m_frame->SelectBodyStyle( symbol, bodyStyle ); m_toolMgr->PostAction( ACTIONS::refreshPreview ); } } @@ -612,7 +612,7 @@ int SCH_DRAWING_TOOLS::PlaceNextSymbolUnit( const TOOL_EVENT& aEvent ) if( !symbol ) return 0; - if( !symbol->IsMulti() ) + if( !symbol->IsMultiUnit() ) { m_frame->ShowInfoBarMsg( _( "This symbol has only one unit." ) ); return 0; diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 50de8ba8ef..d1ca3c6cee 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -159,11 +159,23 @@ private: wxCHECK( symbol, /* void */ ); - item = Append( ID_POPUP_SCH_SELECT_BASE, _( "Standard" ), wxEmptyString, wxITEM_CHECK ); - item->Check( symbol->GetBodyStyle() == BODY_STYLE::BASE ); + if( symbol->HasDeMorganBodyStyles() ) + { + item = Append( ID_POPUP_SCH_SELECT_BODY_STYLE, _( "Standard" ), wxEmptyString, wxITEM_CHECK ); + item->Check( symbol->GetBodyStyle() == BODY_STYLE::BASE ); - item = Append( ID_POPUP_SCH_SELECT_ALT, _( "Alternate" ), wxEmptyString, wxITEM_CHECK ); - item->Check( symbol->GetBodyStyle() != BODY_STYLE::BASE ); + item = Append( ID_POPUP_SCH_SELECT_BODY_STYLE1, _( "Alternate" ), wxEmptyString, wxITEM_CHECK ); + item->Check( symbol->GetBodyStyle() != BODY_STYLE::BASE ); + } + else if( symbol->IsMultiBodyStyle() ) + { + for( int i = 0; i < symbol->GetBodyStyleCount(); i++ ) + { + item = Append( ID_POPUP_SCH_SELECT_BODY_STYLE + i, symbol->GetBodyStyleDescription( i + 1, true ), + wxEmptyString, wxITEM_CHECK ); + item->Check( symbol->GetBodyStyle() == i + 1 ); + } + } } }; @@ -658,7 +670,7 @@ bool SCH_EDIT_TOOL::Init() moveMenu.AddSeparator(); moveMenu.AddMenu( makeSymbolUnitMenu( moveTool ), S_C::SingleMultiUnitSymbol, 1 ); - moveMenu.AddMenu( makeBodyStyleMenu( moveTool ), S_C::SingleDeMorganSymbol, 1 ); + moveMenu.AddMenu( makeBodyStyleMenu( moveTool ), S_C::SingleMultiBodyStyleSymbol, 1 ); moveMenu.AddMenu( makeTransformMenu(), orientCondition, 200 ); moveMenu.AddMenu( makeAttributesMenu(), S_C::HasType( SCH_SYMBOL_T ), 200 ); @@ -685,7 +697,7 @@ bool SCH_EDIT_TOOL::Init() drawMenu.AddSeparator( sheetSelection && SCH_CONDITIONS::Idle, 1 ); drawMenu.AddMenu( makeSymbolUnitMenu( drawingTools ), S_C::SingleMultiUnitSymbol, 1 ); - drawMenu.AddMenu( makeBodyStyleMenu( drawingTools ), S_C::SingleDeMorganSymbol, 1 ); + drawMenu.AddMenu( makeBodyStyleMenu( drawingTools ), S_C::SingleMultiBodyStyleSymbol, 1 ); drawMenu.AddMenu( makeTransformMenu(), orientCondition, 200 ); drawMenu.AddMenu( makeAttributesMenu(), S_C::HasType( SCH_SYMBOL_T ), 200 ); @@ -707,7 +719,7 @@ bool SCH_EDIT_TOOL::Init() CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu(); selToolMenu.AddMenu( makeSymbolUnitMenu( m_selectionTool ), S_C::SingleMultiUnitSymbol, 1 ); - selToolMenu.AddMenu( makeBodyStyleMenu( m_selectionTool ), S_C::SingleDeMorganSymbol, 1 ); + selToolMenu.AddMenu( makeBodyStyleMenu( m_selectionTool ), S_C::SingleMultiBodyStyleSymbol, 1 ); selToolMenu.AddMenu( makePinFunctionMenu( m_selectionTool ), S_C::SingleMultiFunctionPin, 1 ); selToolMenu.AddMenu( makePinTricksMenu( m_selectionTool ), S_C::AllPinsOrSheetPins, 1 ); @@ -1958,11 +1970,8 @@ int SCH_EDIT_TOOL::ChangeSymbols( const TOOL_EVENT& aEvent ) DIALOG_CHANGE_SYMBOLS::MODE mode = DIALOG_CHANGE_SYMBOLS::MODE::UPDATE; - if( aEvent.IsAction( &SCH_ACTIONS::changeSymbol ) - || aEvent.IsAction( &SCH_ACTIONS::changeSymbols ) ) - { + if( aEvent.IsAction( &SCH_ACTIONS::changeSymbol ) || aEvent.IsAction( &SCH_ACTIONS::changeSymbols ) ) mode = DIALOG_CHANGE_SYMBOLS::MODE::CHANGE; - } DIALOG_CHANGE_SYMBOLS dlg( m_frame, selectedSymbol, mode ); @@ -1976,7 +1985,7 @@ int SCH_EDIT_TOOL::ChangeSymbols( const TOOL_EVENT& aEvent ) } -int SCH_EDIT_TOOL::ChangeBodyStyle( const TOOL_EVENT& aEvent ) +int SCH_EDIT_TOOL::CycleBodyStyle( const TOOL_EVENT& aEvent ) { SCH_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } ); @@ -1984,25 +1993,17 @@ int SCH_EDIT_TOOL::ChangeBodyStyle( const TOOL_EVENT& aEvent ) return 0; SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front(); - - if( aEvent.IsAction( &SCH_ACTIONS::showDeMorganStandard ) - && symbol->GetBodyStyle() == BODY_STYLE::BASE ) - { - return 0; - } - - if( aEvent.IsAction( &SCH_ACTIONS::showDeMorganAlternate ) - && symbol->GetBodyStyle() == BODY_STYLE::DEMORGAN ) - { - return 0; - } - - SCH_COMMIT commit( m_toolMgr ); + SCH_COMMIT commit( m_toolMgr ); if( !symbol->IsNew() ) commit.Modify( symbol, m_frame->GetScreen() ); - m_frame->FlipBodyStyle( symbol ); + int nextBodyStyle = symbol->GetBodyStyle() + 1; + + if( nextBodyStyle > symbol->GetBodyStyleCount() ) + nextBodyStyle = 1; + + m_frame->SelectBodyStyle( symbol, nextBodyStyle ); if( symbol->IsNew() ) m_toolMgr->PostAction( ACTIONS::refreshPreview ); @@ -3207,9 +3208,7 @@ void SCH_EDIT_TOOL::setTransitions() Go( &SCH_EDIT_TOOL::ChangeSymbols, SCH_ACTIONS::updateSymbols.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeSymbols, SCH_ACTIONS::changeSymbol.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeSymbols, SCH_ACTIONS::updateSymbol.MakeEvent() ); - Go( &SCH_EDIT_TOOL::ChangeBodyStyle, SCH_ACTIONS::toggleDeMorgan.MakeEvent() ); - Go( &SCH_EDIT_TOOL::ChangeBodyStyle, SCH_ACTIONS::showDeMorganStandard.MakeEvent() ); - Go( &SCH_EDIT_TOOL::ChangeBodyStyle, SCH_ACTIONS::showDeMorganAlternate.MakeEvent() ); + Go( &SCH_EDIT_TOOL::CycleBodyStyle, SCH_ACTIONS::cycleBodyStyle.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeTextType, SCH_ACTIONS::toLabel.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeTextType, SCH_ACTIONS::toHLabel.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeTextType, SCH_ACTIONS::toGLabel.MakeEvent() ); diff --git a/eeschema/tools/sch_edit_tool.h b/eeschema/tools/sch_edit_tool.h index 86668a8050..3de495415a 100644 --- a/eeschema/tools/sch_edit_tool.h +++ b/eeschema/tools/sch_edit_tool.h @@ -49,7 +49,7 @@ public: int EditField( const TOOL_EVENT& aEvent ); int AutoplaceFields( const TOOL_EVENT& aEvent ); int ChangeSymbols( const TOOL_EVENT& aEvent ); - int ChangeBodyStyle( const TOOL_EVENT& aEvent ); + int CycleBodyStyle( const TOOL_EVENT& aEvent ); int EditPageNumber( const TOOL_EVENT& aEvent ); /** diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 03499017d0..d414ba154d 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -979,15 +979,15 @@ bool SCH_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COMMIT* aComm m_toolMgr->PostAction( ACTIONS::refreshPreview ); } } - else if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_BASE - && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_ALT ) + else if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_BODY_STYLE + && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_BODY_STYLE_END ) { SCH_SYMBOL* symbol = dynamic_cast( selection.Front() ); - int bodyStyle = ( *evt->GetCommandId() - ID_POPUP_SCH_SELECT_BASE ) + 1; + int bodyStyle = ( *evt->GetCommandId() - ID_POPUP_SCH_SELECT_BODY_STYLE ) + 1; if( symbol && symbol->GetBodyStyle() != bodyStyle ) { - m_frame->FlipBodyStyle( symbol ); + m_frame->SelectBodyStyle( symbol, bodyStyle ); m_toolMgr->PostAction( ACTIONS::refreshPreview ); } } diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index 9838e6f4e5..0126557a4d 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -80,14 +80,14 @@ SELECTION_CONDITION SCH_CONDITIONS::SingleSymbolOrPower = []( const SELECTION& a }; -SELECTION_CONDITION SCH_CONDITIONS::SingleDeMorganSymbol = []( const SELECTION& aSel ) +SELECTION_CONDITION SCH_CONDITIONS::SingleMultiBodyStyleSymbol = []( const SELECTION& aSel ) { if( aSel.GetSize() == 1 ) { SCH_SYMBOL* symbol = dynamic_cast( aSel.Front() ); if( symbol ) - return symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->HasAlternateBodyStyle(); + return symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsMultiBodyStyle(); } return false; @@ -284,21 +284,6 @@ bool SCH_SELECTION_TOOL::Init() return m_enteredGroup != nullptr; }; - auto symbolDisplayNameIsEditable = - [&]( const SELECTION& sel ) - { - if ( !m_isSymbolEditor ) - return false; - - SYMBOL_EDIT_FRAME* symbEditorFrame = dynamic_cast( m_frame ); - - return symbEditorFrame - && symbEditorFrame->GetCurSymbol() - && symbEditorFrame->GetCurSymbol()->IsMulti() - && symbEditorFrame->IsSymbolEditable() - && !symbEditorFrame->IsSymbolAlias(); - }; - auto& menu = m_menu->GetMenu(); // clang-format off @@ -341,7 +326,6 @@ bool SCH_SELECTION_TOOL::Init() menu.AddSeparator( 400 ); menu.AddItem( SCH_ACTIONS::symbolProperties, haveSymbol && SCH_CONDITIONS::Empty, 400 ); menu.AddItem( SCH_ACTIONS::pinTable, haveSymbol && SCH_CONDITIONS::Empty, 400 ); - menu.AddItem( SCH_ACTIONS::setUnitDisplayName, haveSymbol && symbolDisplayNameIsEditable && SCH_CONDITIONS::Empty, 400 ); menu.AddSeparator( 1000 ); m_frame->AddStandardSubMenus( *m_menu.get() ); @@ -764,14 +748,14 @@ int SCH_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( symbol ) static_cast( m_frame )->SelectUnit( symbol, unit ); } - else if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_BASE - && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_ALT ) + else if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_BODY_STYLE + && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_BODY_STYLE_END ) { SCH_SYMBOL* symbol = dynamic_cast( m_selection.Front() ); - int bodyStyle = ( *evt->GetCommandId() - ID_POPUP_SCH_SELECT_BASE ) + 1; + int bodyStyle = ( *evt->GetCommandId() - ID_POPUP_SCH_SELECT_BODY_STYLE ) + 1; if( symbol && symbol->GetBodyStyle() != bodyStyle ) - static_cast( m_frame )->FlipBodyStyle( symbol ); + static_cast( m_frame )->SelectBodyStyle( symbol, bodyStyle ); } else if( *evt->GetCommandId() >= ID_POPUP_SCH_ALT_PIN_FUNCTION && *evt->GetCommandId() <= ID_POPUP_SCH_ALT_PIN_FUNCTION_END ) diff --git a/eeschema/tools/sch_selection_tool.h b/eeschema/tools/sch_selection_tool.h index 66f17c2417..9e4ceb86a7 100644 --- a/eeschema/tools/sch_selection_tool.h +++ b/eeschema/tools/sch_selection_tool.h @@ -52,7 +52,7 @@ class SCH_CONDITIONS : public SELECTION_CONDITIONS public: static SELECTION_CONDITION SingleSymbol; static SELECTION_CONDITION SingleSymbolOrPower; - static SELECTION_CONDITION SingleDeMorganSymbol; + static SELECTION_CONDITION SingleMultiBodyStyleSymbol; static SELECTION_CONDITION SingleMultiUnitSymbol; static SELECTION_CONDITION SingleMultiFunctionPin; static SELECTION_CONDITION SingleNonExcludedMarker; diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index ea60c4f696..3c78318989 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -582,32 +582,6 @@ int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent ) } -int SYMBOL_EDITOR_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent ) -{ - int bodyStyle = aEvent.IsAction( &SCH_ACTIONS::showDeMorganStandard ) ? BODY_STYLE::BASE - : BODY_STYLE::DEMORGAN; - - if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) - { - m_toolMgr->RunAction( ACTIONS::cancelInteractive ); - m_toolMgr->RunAction( ACTIONS::selectionClear ); - - SYMBOL_EDIT_FRAME* symbolEditor = static_cast( m_frame ); - symbolEditor->SetBodyStyle( bodyStyle ); - - m_toolMgr->ResetTools( TOOL_BASE::MODEL_RELOAD ); - symbolEditor->RebuildView(); - } - else if( m_frame->IsType( FRAME_SCH_VIEWER ) ) - { - SYMBOL_VIEWER_FRAME* symbolViewer = static_cast( m_frame ); - symbolViewer->SetUnitAndBodyStyle( symbolViewer->GetUnit(), bodyStyle ); - } - - return 0; -} - - int SYMBOL_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent ) { if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) ) @@ -923,9 +897,6 @@ void SYMBOL_EDITOR_CONTROL::setTransitions() Go( &SYMBOL_EDITOR_CONTROL::ExportSymbolAsSVG, SCH_ACTIONS::exportSymbolAsSVG.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic, SCH_ACTIONS::addSymbolToSchematic.MakeEvent() ); - Go( &SYMBOL_EDITOR_CONTROL::OnDeMorgan, SCH_ACTIONS::showDeMorganStandard.MakeEvent() ); - Go( &SYMBOL_EDITOR_CONTROL::OnDeMorgan, SCH_ACTIONS::showDeMorganAlternate.MakeEvent() ); - Go( &SYMBOL_EDITOR_CONTROL::ShowElectricalTypes, SCH_ACTIONS::showElectricalTypes.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ShowPinNumbers, SCH_ACTIONS::showPinNumbers.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, SCH_ACTIONS::toggleSyncedPinsMode.MakeEvent() ); diff --git a/eeschema/tools/symbol_editor_control.h b/eeschema/tools/symbol_editor_control.h index 29ca6788ef..2e5079c3f3 100644 --- a/eeschema/tools/symbol_editor_control.h +++ b/eeschema/tools/symbol_editor_control.h @@ -62,8 +62,6 @@ public: int ExportSymbolAsSVG( const TOOL_EVENT& aEvent ); int AddSymbolToSchematic( const TOOL_EVENT& aEvent ); - int OnDeMorgan( const TOOL_EVENT& aEvent ); - int ShowElectricalTypes( const TOOL_EVENT& aEvent ); int ShowPinNumbers( const TOOL_EVENT& aEvent ); int ToggleProperties( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 5945958673..b3590e8bc1 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -650,6 +650,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties() if( dlg.ShowQuasiModal() != wxID_OK ) return; + m_frame->RebuildSymbolUnitAndBodyStyleLists(); m_frame->OnModify(); // if m_UnitSelectionLocked has changed, set some edit options or defaults @@ -668,17 +669,6 @@ void SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties() } } -void SYMBOL_EDITOR_EDIT_TOOL::handlePinDuplication( SCH_PIN* aOldPin, SCH_PIN* aNewPin, - int& aSymbolLastPinNumber ) -{ - if( !aNewPin->GetNumber().IsEmpty() ) - { - // when duplicating a pin in symbol editor, assigning identical pin number - // to the old one does not makes any sense, so assign the next unassigned number to it - aSymbolLastPinNumber++; - aNewPin->SetNumber( wxString::Format( wxT( "%i" ), aSymbolLastPinNumber ) ); - } -} int SYMBOL_EDITOR_EDIT_TOOL::PinTable( const TOOL_EVENT& aEvent ) { @@ -745,45 +735,6 @@ int SYMBOL_EDITOR_EDIT_TOOL::UpdateSymbolFields( const TOOL_EVENT& aEvent ) } -int SYMBOL_EDITOR_EDIT_TOOL::SetUnitDisplayName( const TOOL_EVENT& aEvent ) -{ - LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); - - if( !symbol ) - return 0; - - int unitid = m_frame->GetUnit(); - - if( unitid == 0 ) - { - return -1; - } - - wxString promptText = wxString::Format( _( "Enter display name for unit %s" ), - LIB_SYMBOL::LetterSubReference( unitid, 'A' ) ); - wxString currentvalue; - - if( symbol->HasUnitDisplayName( unitid ) ) - currentvalue = symbol->GetUnitDisplayName( unitid, false ); - - wxTextEntryDialog dlg( m_frame, promptText, _( "Set Unit Display Name" ), currentvalue ); - - if( dlg.ShowModal() == wxID_OK ) - { - saveCopyInUndoList( symbol, UNDO_REDO::LIBEDIT ); - symbol->SetUnitDisplayName( unitid, dlg.GetValue() ); - m_frame->RebuildSymbolUnitsList(); - m_frame->OnModify(); - } - else - { - return -1; - } - - return 0; -} - - int SYMBOL_EDITOR_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent ) { SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); @@ -1071,6 +1022,5 @@ void SYMBOL_EDITOR_EDIT_TOOL::setTransitions() Go( &SYMBOL_EDITOR_EDIT_TOOL::Properties, SCH_ACTIONS::symbolProperties.MakeEvent() ); Go( &SYMBOL_EDITOR_EDIT_TOOL::PinTable, SCH_ACTIONS::pinTable.MakeEvent() ); Go( &SYMBOL_EDITOR_EDIT_TOOL::UpdateSymbolFields, SCH_ACTIONS::updateSymbolFields.MakeEvent() ); - Go( &SYMBOL_EDITOR_EDIT_TOOL::SetUnitDisplayName, SCH_ACTIONS::setUnitDisplayName.MakeEvent() ); // clang-format on } diff --git a/eeschema/tools/symbol_editor_edit_tool.h b/eeschema/tools/symbol_editor_edit_tool.h index 1369902ab6..7e17838cbd 100644 --- a/eeschema/tools/symbol_editor_edit_tool.h +++ b/eeschema/tools/symbol_editor_edit_tool.h @@ -49,7 +49,6 @@ public: int Properties( const TOOL_EVENT& aEvent ); int PinTable( const TOOL_EVENT& aEvent ); - int SetUnitDisplayName( const TOOL_EVENT& aEvent ); int UpdateSymbolFields( const TOOL_EVENT& aEvent ); int Undo( const TOOL_EVENT& aEvent ); @@ -70,7 +69,6 @@ private: void editTextBoxProperties( SCH_ITEM* aItem ); void editFieldProperties( SCH_FIELD* aField ); void editSymbolProperties(); - void handlePinDuplication(SCH_PIN* aOldPin, SCH_PIN* aNewPin, int &aSymbolLastPinNumber ); ///< Set up handlers for various events. void setTransitions() override; diff --git a/eeschema/widgets/panel_symbol_chooser.cpp b/eeschema/widgets/panel_symbol_chooser.cpp index 1bd662cd9b..86fff5c201 100644 --- a/eeschema/widgets/panel_symbol_chooser.cpp +++ b/eeschema/widgets/panel_symbol_chooser.cpp @@ -251,8 +251,8 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP wxBoxSizer* treeSizer = new wxBoxSizer( wxVERTICAL ); treePanel->SetSizer( treeSizer ); - m_tree = new LIB_TREE( treePanel, m_showPower ? wxT( "power" ) : wxT( "symbols" ), - libs, m_adapter, LIB_TREE::FLAGS::ALL_WIDGETS, m_details ); + m_tree = new LIB_TREE( treePanel, m_showPower ? wxT( "power" ) : wxT( "symbols" ), libs, m_adapter, + LIB_TREE::FLAGS::ALL_WIDGETS, m_details ); treeSizer->Add( m_tree, 1, wxALL | wxEXPAND, 5 ); treePanel->Layout(); @@ -284,17 +284,10 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP aFrame->Bind( wxEVT_MENU_CLOSE, &PANEL_SYMBOL_CHOOSER::onMenuClose, this ); if( m_fp_sel_ctrl ) - { - m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected, - this ); - } + m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected, this ); if( m_details ) - { - m_details->Connect( wxEVT_CHAR_HOOK, - wxKeyEventHandler( PANEL_SYMBOL_CHOOSER::OnDetailsCharHook ), - nullptr, this ); - } + m_details->Bind( wxEVT_CHAR_HOOK, &PANEL_SYMBOL_CHOOSER::OnDetailsCharHook, this ); // Open the user's previously opened libraries on timer expiration. // This is done on a timer because we need a gross hack to keep GTK from garbling the @@ -323,17 +316,10 @@ PANEL_SYMBOL_CHOOSER::~PANEL_SYMBOL_CHOOSER() g_symbolSearchString = m_tree->GetSearchString(); if( m_fp_sel_ctrl ) - { - m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected, - this ); - } + m_fp_sel_ctrl->Unbind( EVT_FOOTPRINT_SELECTED, &PANEL_SYMBOL_CHOOSER::onFootprintSelected, this ); if( m_details ) - { - m_details->Disconnect( wxEVT_CHAR_HOOK, - wxKeyEventHandler( PANEL_SYMBOL_CHOOSER::OnDetailsCharHook ), - nullptr, this ); - } + m_details->Unbind( wxEVT_CHAR_HOOK, &PANEL_SYMBOL_CHOOSER::OnDetailsCharHook, this ); if( EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ) ) { diff --git a/eeschema/widgets/symbol_diff_widget.cpp b/eeschema/widgets/symbol_diff_widget.cpp index 104a2ade6c..a1797f8d31 100644 --- a/eeschema/widgets/symbol_diff_widget.cpp +++ b/eeschema/widgets/symbol_diff_widget.cpp @@ -87,7 +87,7 @@ SYMBOL_DIFF_WIDGET::~SYMBOL_DIFF_WIDGET() void SYMBOL_DIFF_WIDGET::DisplayDiff( LIB_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSymbol, int aUnit, - int aConvert ) + int aBodyStyle ) { KIGFX::VIEW* view = m_preview->GetView(); @@ -111,14 +111,13 @@ void SYMBOL_DIFF_WIDGET::DisplayDiff( LIB_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSy // For symbols having a De Morgan body style, use the first style auto settings = static_cast( view->GetPainter()->GetSettings() ); - settings->m_ShowUnit = ( m_previewItem->IsMulti() && !aUnit ) ? 1 : aUnit; - settings->m_ShowBodyStyle = ( m_previewItem->HasAlternateBodyStyle() && !aConvert ) ? 1 : aConvert; + settings->m_ShowUnit = ( m_previewItem->IsMultiUnit() && !aUnit ) ? 1 : aUnit; + settings->m_ShowBodyStyle = ( m_previewItem->IsMultiBodyStyle() && !aBodyStyle ) ? 1 : aBodyStyle; view->Add( m_previewItem ); // Get the symbol size, in internal units - m_itemBBox = m_previewItem->GetUnitBoundingBox( settings->m_ShowUnit, - settings->m_ShowBodyStyle ); + m_itemBBox = m_previewItem->GetUnitBoundingBox( settings->m_ShowUnit, settings->m_ShowBodyStyle ); // Calculate the draw scale to fit the drawing area fitOnDrawArea(); diff --git a/eeschema/widgets/symbol_diff_widget.h b/eeschema/widgets/symbol_diff_widget.h index d73be411ab..f6468f52b7 100644 --- a/eeschema/widgets/symbol_diff_widget.h +++ b/eeschema/widgets/symbol_diff_widget.h @@ -45,7 +45,7 @@ public: /** * Set the currently displayed symbol. */ - void DisplayDiff( LIB_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSymbol, int aUnit, int aConvert ); + void DisplayDiff( LIB_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSymbol, int aUnit, int aBodyStyle ); /** * Toggle between full-A and full-B display. diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index 47e702e2f3..ddae327842 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -173,8 +173,8 @@ void SYMBOL_PREVIEW_WIDGET::fitOnDrawArea() view->SetScale( 1.0 ); VECTOR2D clientSize = view->ToWorld( ToVECTOR2D( m_preview->GetClientSize() ), false ); // Calculate the draw scale to fit the drawing area - double scale = std::min( fabs( clientSize.x / m_itemBBox.GetWidth() ), - fabs( clientSize.y / m_itemBBox.GetHeight() ) ); + double scale = std::min( fabs( clientSize.x / (double) m_itemBBox.GetWidth() ), + fabs( clientSize.y / (double) m_itemBBox.GetHeight() ) ); // Above calculation will yield an exact fit; add a bit of whitespace around symbol scale /= 1.2; @@ -217,13 +217,11 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, i // This will flatten derived parts so that the correct final symbol can be shown. m_previewItem = symbol.release(); - // If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll - // draw all of them.) - m_renderSettings->m_ShowUnit = ( m_previewItem->IsMulti() && aUnit == 0 ) ? 1 : aUnit; + // If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll draw all of them.) + m_renderSettings->m_ShowUnit = ( m_previewItem->IsMultiUnit() && aUnit == 0 ) ? 1 : aUnit; - // For symbols having a De Morgan body style, use the first style - m_renderSettings->m_ShowBodyStyle = - ( m_previewItem->HasAlternateBodyStyle() && aBodyStyle == 0 ) ? 1 : aBodyStyle; + // For symbols having multiple body styles, use the first style. + m_renderSettings->m_ShowBodyStyle = ( m_previewItem->IsMultiBodyStyle() && aBodyStyle == 0 ) ? 1 : aBodyStyle; m_previewItem->SetPreviewUnit( m_renderSettings->m_ShowUnit ); m_previewItem->SetPreviewBodyStyle( m_renderSettings->m_ShowBodyStyle ); @@ -275,12 +273,10 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_SYMBOL* aSymbol, int aUnit, int aBo // For symbols having a De Morgan body style, use the first style - // If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll - // draw all of them.) - m_renderSettings->m_ShowUnit = ( m_previewItem->IsMulti() && aUnit == 0 ) ? 1 : aUnit; + // If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll draw all of them.) + m_renderSettings->m_ShowUnit = ( m_previewItem->IsMultiUnit() && aUnit == 0 ) ? 1 : aUnit; - m_renderSettings->m_ShowBodyStyle = - ( m_previewItem->HasAlternateBodyStyle() && aBodyStyle == 0 ) ? 1 : aBodyStyle; + m_renderSettings->m_ShowBodyStyle = ( m_previewItem->IsMultiBodyStyle() && aBodyStyle == 0 ) ? 1 : aBodyStyle; m_previewItem->SetPreviewUnit( m_renderSettings->m_ShowUnit ); m_previewItem->SetPreviewBodyStyle( m_renderSettings->m_ShowBodyStyle ); diff --git a/include/tool/action_toolbar.h b/include/tool/action_toolbar.h index fb12cf32e2..f63e336ed8 100644 --- a/include/tool/action_toolbar.h +++ b/include/tool/action_toolbar.h @@ -467,6 +467,7 @@ public: static ACTION_TOOLBAR_CONTROL zoomSelect; static ACTION_TOOLBAR_CONTROL ipcScripting; static ACTION_TOOLBAR_CONTROL unitSelector; + static ACTION_TOOLBAR_CONTROL bodyStyleSelector; static ACTION_TOOLBAR_CONTROL layerSelector; static ACTION_TOOLBAR_CONTROL overrideLocks; }; diff --git a/qa/tests/eeschema/test_lib_part.cpp b/qa/tests/eeschema/test_lib_part.cpp index ee7b173aa4..49103ff646 100644 --- a/qa/tests/eeschema/test_lib_part.cpp +++ b/qa/tests/eeschema/test_lib_part.cpp @@ -72,10 +72,10 @@ BOOST_AUTO_TEST_CASE( DefaultProperties ) // no sub units BOOST_CHECK_EQUAL( m_part_no_data.GetUnitCount(), 1 ); - BOOST_CHECK_EQUAL( m_part_no_data.IsMulti(), false ); + BOOST_CHECK_EQUAL( m_part_no_data.IsMultiUnit(), false ); - // no conversion - BOOST_CHECK_EQUAL( m_part_no_data.HasAlternateBodyStyle(), false ); + // single body style + BOOST_CHECK_EQUAL( m_part_no_data.HasDeMorganBodyStyles(), false ); } @@ -383,12 +383,12 @@ BOOST_AUTO_TEST_CASE( Compare ) testPart.SetLibId( id ); // Unit count comparison tests. - testPart.SetUnitCount( 2 ); + testPart.SetUnitCount( 2, true ); BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); - testPart.SetUnitCount( 1 ); - m_part_no_data.SetUnitCount( 2 ); + testPart.SetUnitCount( 1, true ); + m_part_no_data.SetUnitCount( 2, true ); BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); - m_part_no_data.SetUnitCount( 1 ); + m_part_no_data.SetUnitCount( 1, true ); // Options flag comparison tests. testPart.SetGlobalPower(); @@ -534,7 +534,7 @@ BOOST_AUTO_TEST_CASE( GetUnitItems ) // Two unique units with pin 1 assigned to unit 1 and body style 1 and pin 2 assigned to // unit 2 and body style 1. SCH_PIN* pin2 = new SCH_PIN( &m_part_no_data ); - m_part_no_data.SetUnitCount( 2 ); + m_part_no_data.SetUnitCount( 2, true ); pin2->SetUnit( 2 ); pin2->SetBodyStyle( 2 ); pin2->SetNumber( "4" ); @@ -587,8 +587,7 @@ BOOST_AUTO_TEST_CASE( Inheritance ) BOOST_CHECK( child->IsDerived() ); BOOST_CHECK_EQUAL( child->GetInheritanceDepth(), 1 ); - std::unique_ptr grandChild = std::make_unique( "grandchild", - child.get() ); + std::unique_ptr grandChild = std::make_unique( "grandchild", child.get() ); BOOST_CHECK( grandChild->IsDerived() ); BOOST_CHECK_EQUAL( grandChild->GetInheritanceDepth(), 2 ); @@ -607,9 +606,9 @@ BOOST_AUTO_TEST_CASE( Inheritance ) BOOST_CHECK_EQUAL( child->SharedPtr().use_count(), 3 ); BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 ); - parent->SetUnitCount( 4 ); + parent->SetUnitCount( 4, true ); BOOST_CHECK_EQUAL( child->GetUnitCount(), 4 ); - parent->SetUnitCount( 1 ); + parent->SetUnitCount( 1, true ); parent->GetField( FIELD_T::DATASHEET )->SetText( "https://kicad/resistors.pdf" ); ref->GetField( FIELD_T::DATASHEET )->SetText( "https://kicad/resistors.pdf" );