diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index b06fc7f31b..f3262782f2 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -101,8 +101,6 @@ set( EESCHEMA_DLGS dialogs/dialog_schematic_setup.cpp dialogs/dialog_symbol_remap.cpp dialogs/dialog_symbol_remap_base.cpp - dialogs/dialog_update_fields.cpp - dialogs/dialog_update_fields_base.cpp dialogs/dialog_update_from_pcb.cpp dialogs/dialog_update_from_pcb_base.cpp dialogs/panel_eeschema_color_settings.cpp diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 281ca670ee..027dce6bc9 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -45,7 +45,7 @@ bool g_resetFieldPositions = false; DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aSymbol, - MODE aMode ) : + MODE aMode ) : DIALOG_CHANGE_SYMBOLS_BASE( aParent ), m_symbol( aSymbol), m_mode( aMode ) @@ -99,6 +99,16 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPO m_matchSizer->SetEmptyCellSize( wxSize( 0, 0 ) ); m_matchSizer->Layout(); + for( int i = 0; i < MANDATORY_FIELDS; ++i ) + { + m_fieldsBox->Append( TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) ); + + if( i != REFERENCE && i != VALUE ) + m_fieldsBox->Check( i, true ); + } + + updateFieldsList(); + m_messagePanel->SetLazyUpdate( true ); if( aSymbol && aSymbol->IsSelected() ) @@ -113,6 +123,9 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPO m_matchByReference->SetValue( true ); } + label.Printf( m_updateFieldsSizer->GetStaticBox()->GetLabel(), reset ); + m_updateFieldsSizer->GetStaticBox()->SetLabel( label ); + label.Printf( m_removeExtraBox->GetLabel(), library ); m_removeExtraBox->SetLabel( label ); @@ -149,24 +162,45 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPO } +void DIALOG_CHANGE_SYMBOLS::onMatchByAll( wxCommandEvent& aEvent ) +{ + updateFieldsList(); +} + + +void DIALOG_CHANGE_SYMBOLS::onMatchBySelected( wxCommandEvent& aEvent ) +{ + updateFieldsList(); +} + + void DIALOG_CHANGE_SYMBOLS::onMatchByReference( wxCommandEvent& aEvent ) { + updateFieldsList(); m_specifiedReference->SetFocus(); } void DIALOG_CHANGE_SYMBOLS::onMatchByValue( wxCommandEvent& aEvent ) { + updateFieldsList(); m_specifiedValue->SetFocus(); } void DIALOG_CHANGE_SYMBOLS::onMatchById( wxCommandEvent& aEvent ) { + updateFieldsList(); m_specifiedId->SetFocus(); } +void DIALOG_CHANGE_SYMBOLS::onMatchTextKillFocus( wxFocusEvent& event ) +{ + updateFieldsList(); +} + + DIALOG_CHANGE_SYMBOLS::~DIALOG_CHANGE_SYMBOLS() { g_removeExtraFields = m_removeExtraBox->GetValue(); @@ -184,7 +218,10 @@ void DIALOG_CHANGE_SYMBOLS::launchMatchIdSymbolBrowser( wxCommandEvent& aEvent ) KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH_VIEWER_MODAL, true ); if( frame->ShowModal( &newName, this ) ) + { m_specifiedId->SetValue( newName ); + updateFieldsList(); + } frame->Destroy(); } @@ -197,12 +234,81 @@ void DIALOG_CHANGE_SYMBOLS::launchNewIdSymbolBrowser( wxCommandEvent& aEvent ) KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH_VIEWER_MODAL, true ); if( frame->ShowModal( &newName, this ) ) + { m_newId->SetValue( newName ); + updateFieldsList(); + } frame->Destroy(); } +void DIALOG_CHANGE_SYMBOLS::updateFieldsList() +{ + SCH_EDIT_FRAME* frame = dynamic_cast( GetParent() ); + LIB_ID newId; + SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets(); + + if( m_mode == MODE::CHANGE ) + { + newId.Parse( m_newId->GetValue(), LIB_ID::ID_SCH ); + + if( !newId.IsValid() ) + return; + } + + // Load new non-mandatory fields from the library parts of all matching symbols + std::set fieldNames; + + for( SCH_SHEET_PATH& instance : hierarchy ) + { + SCH_SCREEN* screen = instance.LastScreen(); + + wxCHECK2( screen, continue ); + + for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) ) + { + SCH_COMPONENT* symbol = dynamic_cast( item ); + + wxCHECK2( symbol, continue ); + + if( !isMatch( symbol, &instance ) ) + continue; + + LIB_PART* libSymbol = frame->GetLibPart( symbol->GetLibId() ); + + if( !libSymbol ) + continue; + + std::unique_ptr flattenedSymbol = libSymbol->Flatten(); + + LIB_FIELDS libFields; + flattenedSymbol->GetFields( libFields ); + + for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i ) + fieldNames.insert( libFields[i].GetName() ); + } + } + + // Update the listbox widget + for( unsigned i = m_fieldsBox->GetCount() - 1; i >= MANDATORY_FIELDS; --i ) + m_fieldsBox->Delete( i ); + + for( const wxString& fieldName : fieldNames ) + m_fieldsBox->Append( fieldName ); + + for( unsigned i = MANDATORY_FIELDS; i < m_fieldsBox->GetCount(); ++i ) + m_fieldsBox->Check( i, true ); +} + + +void DIALOG_CHANGE_SYMBOLS::checkAll( bool aCheck ) +{ + for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i ) + m_fieldsBox->Check( i, aCheck ); +} + + void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent ) { wxBusyCursor dummy; @@ -213,6 +319,15 @@ void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent ) m_messagePanel->Clear(); m_messagePanel->Flush( false ); + // Create the set of fields to be updated + m_updateFields.clear(); + + for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i ) + { + if( m_fieldsBox->IsChecked( i ) ) + m_updateFields.insert( m_fieldsBox->GetString( i ) ); + } + if( processMatchingSymbols() ) { parent->TestDanglingEnds(); // This will also redraw the changed symbols. @@ -396,6 +511,9 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_COMPONENT* aSymbol, SCH_SCREEN* a SCH_FIELD* field = aSymbol->GetField( (int) i ) ; LIB_FIELD* libField = nullptr; + if( alg::contains( m_updateFields, field->GetName() ) ) + continue; + if( i < MANDATORY_FIELDS ) libField = libSymbol->GetField( (int) i ); else @@ -436,6 +554,9 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_COMPONENT* aSymbol, SCH_SCREEN* a { LIB_FIELD& libField = libFields[i]; + if( !alg::contains( m_updateFields, libField.GetName() ) ) + continue; + if( !aSymbol->FindField( libField.GetName(), false ) ) { wxString fieldName = libField.GetCanonicalName(); diff --git a/eeschema/dialogs/dialog_change_symbols.h b/eeschema/dialogs/dialog_change_symbols.h index 84608f96c0..35245408cf 100644 --- a/eeschema/dialogs/dialog_change_symbols.h +++ b/eeschema/dialogs/dialog_change_symbols.h @@ -39,25 +39,46 @@ public: enum class MODE { CHANGE, UPDATE }; DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aSymbol, - MODE aMode = MODE::UPDATE ); + MODE aMode = MODE::UPDATE ); ~DIALOG_CHANGE_SYMBOLS() override; protected: void launchMatchIdSymbolBrowser( wxCommandEvent& aEvent ) override; void launchNewIdSymbolBrowser( wxCommandEvent& aEvent ) override; + void onMatchTextKillFocus( wxFocusEvent& event ) override; void onOkButtonClicked( wxCommandEvent& aEvent ) override; + void onMatchByAll( wxCommandEvent& aEvent ) override; + void onMatchBySelected( wxCommandEvent& aEvent ) override; void onMatchByReference( wxCommandEvent& aEvent ) override; void onMatchByValue( wxCommandEvent& aEvent ) override; void onMatchById( wxCommandEvent& aEvent ) override; + void onSelectAll( wxCommandEvent& event ) override + { + checkAll( true ); + } + + void onSelectNone( wxCommandEvent& event ) override + { + checkAll( false ); + } + + ///> Selects or deselects all fields in the listbox widget + void checkAll( bool aCheck ); + private: + void updateFieldsList(); + bool isMatch( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aInstance ); bool processMatchingSymbols(); bool processSymbol( SCH_COMPONENT* aSymbol, SCH_SCREEN* aScreen, const LIB_ID& aNewId, - bool aAppendToUndo ); + bool aAppendToUndo ); SCH_COMPONENT* m_symbol; MODE m_mode; + + ///> Set of field names that should have values updated + std::set m_updateFields; }; #endif // _DIALOG_CHANGE_SYMBOLS_H_ diff --git a/eeschema/dialogs/dialog_change_symbols_base.cpp b/eeschema/dialogs/dialog_change_symbols_base.cpp index 359efe4963..cb8a990039 100644 --- a/eeschema/dialogs/dialog_change_symbols_base.cpp +++ b/eeschema/dialogs/dialog_change_symbols_base.cpp @@ -30,19 +30,19 @@ DIALOG_CHANGE_SYMBOLS_BASE::DIALOG_CHANGE_SYMBOLS_BASE( wxWindow* parent, wxWind m_matchBySelection = new wxRadioButton( this, wxID_ANY, _("%s selected symbol"), wxDefaultPosition, wxDefaultSize, 0 ); m_matchSizer->Add( m_matchBySelection, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); - m_matchByReference = new wxRadioButton( this, wxID_ANY, _("%s by reference:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchByReference = new wxRadioButton( this, wxID_ANY, _("%s symbols matching reference designator:"), wxDefaultPosition, wxDefaultSize, 0 ); m_matchSizer->Add( m_matchByReference, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM, 2 ); m_specifiedReference = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), wxTE_PROCESS_ENTER ); m_matchSizer->Add( m_specifiedReference, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM, 2 ); - m_matchByValue = new wxRadioButton( this, wxID_ANY, _("%s by value:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchByValue = new wxRadioButton( this, wxID_ANY, _("%s symbols matching value:"), wxDefaultPosition, wxDefaultSize, 0 ); m_matchSizer->Add( m_matchByValue, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_specifiedValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); m_matchSizer->Add( m_specifiedValue, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_matchById = new wxRadioButton( this, wxID_ANY, _("%s by library indentifier:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_matchById = new wxRadioButton( this, wxID_ANY, _("%s symbols matching library indentifier:"), wxDefaultPosition, wxDefaultSize, 0 ); m_matchSizer->Add( m_matchById, wxGBPosition( 4, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxTOP, 6 ); m_specifiedId = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); @@ -88,18 +88,44 @@ DIALOG_CHANGE_SYMBOLS_BASE::DIALOG_CHANGE_SYMBOLS_BASE( wxWindow* parent, wxWind m_mainSizer->Add( m_newIdSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_updateOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Update Options") ), wxVERTICAL ); + wxBoxSizer* bSizerUpdate; + bSizerUpdate = new wxBoxSizer( wxHORIZONTAL ); - m_removeExtraBox = new wxCheckBox( m_updateOptionsSizer->GetStaticBox(), wxID_ANY, _("Remove fields which are not in %s symbol"), wxDefaultPosition, wxDefaultSize, 0 ); + m_updateFieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("%s Fields") ), wxVERTICAL ); + + wxArrayString m_fieldsBoxChoices; + m_fieldsBox = new wxCheckListBox( m_updateFieldsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fieldsBoxChoices, wxLB_NEEDED_SB ); + m_fieldsBox->SetMinSize( wxSize( -1,120 ) ); + + m_updateFieldsSizer->Add( m_fieldsBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* m_selBtnSizer; + m_selBtnSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_selAllBtn = new wxButton( m_updateFieldsSizer->GetStaticBox(), wxID_ANY, _("Select All"), wxDefaultPosition, wxDefaultSize, 0 ); + m_selBtnSizer->Add( m_selAllBtn, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_selNoneBtn = new wxButton( m_updateFieldsSizer->GetStaticBox(), wxID_ANY, _("Select None"), wxDefaultPosition, wxDefaultSize, 0 ); + m_selBtnSizer->Add( m_selNoneBtn, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + m_updateFieldsSizer->Add( m_selBtnSizer, 0, wxEXPAND, 5 ); + + + bSizerUpdate->Add( m_updateFieldsSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 ); + + m_updateOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); + + m_removeExtraBox = new wxCheckBox( m_updateOptionsSizer->GetStaticBox(), wxID_ANY, _("Remove fields if not in %s symbol"), wxDefaultPosition, wxDefaultSize, 0 ); m_removeExtraBox->SetToolTip( _("Removes fields that do not occur in the original library symbols") ); m_updateOptionsSizer->Add( m_removeExtraBox, 0, wxBOTTOM|wxRIGHT, 4 ); - m_resetEmptyFields = new wxCheckBox( m_updateOptionsSizer->GetStaticBox(), wxID_ANY, _("Reset fields which are empty in %s symbol"), wxDefaultPosition, wxDefaultSize, 0 ); + m_resetEmptyFields = new wxCheckBox( m_updateOptionsSizer->GetStaticBox(), wxID_ANY, _("Reset fields if empty in %s symbol"), wxDefaultPosition, wxDefaultSize, 0 ); m_updateOptionsSizer->Add( m_resetEmptyFields, 0, wxBOTTOM|wxRIGHT, 4 ); - m_updateOptionsSizer->Add( 0, 10, 0, wxEXPAND, 5 ); + m_updateOptionsSizer->Add( 0, 15, 0, wxEXPAND, 5 ); m_resetFieldVisibilities = new wxCheckBox( m_updateOptionsSizer->GetStaticBox(), wxID_ANY, _("%s field visibilities"), wxDefaultPosition, wxDefaultSize, 0 ); m_updateOptionsSizer->Add( m_resetFieldVisibilities, 0, wxBOTTOM|wxRIGHT, 4 ); @@ -111,13 +137,16 @@ DIALOG_CHANGE_SYMBOLS_BASE::DIALOG_CHANGE_SYMBOLS_BASE( wxWindow* parent, wxWind m_updateOptionsSizer->Add( m_resetFieldPositions, 0, wxBOTTOM|wxRIGHT, 4 ); - m_mainSizer->Add( m_updateOptionsSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 ); + bSizerUpdate->Add( m_updateOptionsSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 ); + + + m_mainSizer->Add( bSizerUpdate, 0, wxEXPAND, 5 ); wxBoxSizer* bSizer2; bSizer2 = new wxBoxSizer( wxVERTICAL ); m_messagePanel = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_messagePanel->SetMinSize( wxSize( -1,240 ) ); + m_messagePanel->SetMinSize( wxSize( -1,200 ) ); bSizer2->Add( m_messagePanel, 1, wxEXPAND | wxALL, 5 ); @@ -141,22 +170,36 @@ DIALOG_CHANGE_SYMBOLS_BASE::DIALOG_CHANGE_SYMBOLS_BASE( wxWindow* parent, wxWind this->Centre( wxBOTH ); // Connect Events + m_matchAll->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchByAll ), NULL, this ); + m_matchBySelection->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchBySelected ), NULL, this ); m_matchByReference->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchByReference ), NULL, this ); + m_specifiedReference->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchTextKillFocus ), NULL, this ); m_matchByValue->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchByValue ), NULL, this ); + m_specifiedValue->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchTextKillFocus ), NULL, this ); + m_specifiedValue->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::OnMatchText ), NULL, this ); m_matchById->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchById ), NULL, this ); m_matchIdBrowserButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::launchMatchIdSymbolBrowser ), NULL, this ); m_newIdBrowserButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::launchNewIdSymbolBrowser ), NULL, this ); + m_selAllBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onSelectAll ), NULL, this ); + m_selNoneBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onSelectNone ), NULL, this ); m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onOkButtonClicked ), NULL, this ); } DIALOG_CHANGE_SYMBOLS_BASE::~DIALOG_CHANGE_SYMBOLS_BASE() { // Disconnect Events + m_matchAll->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchByAll ), NULL, this ); + m_matchBySelection->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchBySelected ), NULL, this ); m_matchByReference->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchByReference ), NULL, this ); + m_specifiedReference->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchTextKillFocus ), NULL, this ); m_matchByValue->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchByValue ), NULL, this ); + m_specifiedValue->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchTextKillFocus ), NULL, this ); + m_specifiedValue->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::OnMatchText ), NULL, this ); m_matchById->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onMatchById ), NULL, this ); m_matchIdBrowserButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::launchMatchIdSymbolBrowser ), NULL, this ); m_newIdBrowserButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::launchNewIdSymbolBrowser ), NULL, this ); + m_selAllBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onSelectAll ), NULL, this ); + m_selNoneBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onSelectNone ), NULL, this ); m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CHANGE_SYMBOLS_BASE::onOkButtonClicked ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_change_symbols_base.fbp b/eeschema/dialogs/dialog_change_symbols_base.fbp index 847c462af4..1c09048aaa 100644 --- a/eeschema/dialogs/dialog_change_symbols_base.fbp +++ b/eeschema/dialogs/dialog_change_symbols_base.fbp @@ -147,6 +147,7 @@ + onMatchByAll @@ -214,6 +215,7 @@ + onMatchBySelected @@ -251,7 +253,7 @@ 0 0 wxID_ANY - %s by reference: + %s symbols matching reference designator: 0 @@ -349,6 +351,7 @@ + onMatchTextKillFocus @@ -386,7 +389,7 @@ 0 0 wxID_ANY - %s by value: + %s symbols matching value: 0 @@ -484,6 +487,8 @@ + onMatchTextKillFocus + OnMatchText @@ -521,7 +526,7 @@ 0 0 wxID_ANY - %s by library indentifier: + %s symbols matching library indentifier: 0 @@ -990,345 +995,590 @@ - 8 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 5 + wxEXPAND 0 - - wxID_ANY - Update Options + - m_updateOptionsSizer - wxVERTICAL - 1 - protected + bSizerUpdate + wxHORIZONTAL + none - 4 - wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + 8 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + wxID_ANY - Remove fields which are not in %s symbol - - 0 - - - 0 + %s Fields - 1 - m_removeExtraBox - 1 - - + m_updateFieldsSizer + wxVERTICAL + 1 protected - 1 - - Resizable - 1 - - - - 0 - Removes fields that do not occur in the original library symbols - - wxFILTER_NONE - wxDefaultValidator - - - - + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,120 + 1 + m_fieldsBox + 1 + + + protected + 1 + + Resizable + 1 + + wxLB_NEEDED_SB + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 0 + + + m_selBtnSizer + wxHORIZONTAL + none + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Select All + + 0 + + 0 + + + 0 + + 1 + m_selAllBtn + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onSelectAll + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Select None + + 0 + + 0 + + + 0 + + 1 + m_selNoneBtn + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onSelectNone + + + + - 4 - wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + 8 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + wxID_ANY - Reset fields which are empty in %s symbol - - 0 - - - 0 + Options - 1 - m_resetEmptyFields - 1 - - + m_updateOptionsSizer + wxVERTICAL + 1 protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND - 0 - - 10 - protected - 0 - - - - 4 - wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - %s field visibilities - - 0 - - - 0 - - 1 - m_resetFieldVisibilities - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 4 - wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - %s field sizes and styles - - 0 - - - 0 - - 1 - m_resetFieldEffects - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 4 - wxBOTTOM|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - %s field positions - - 0 - - - 0 - - 1 - m_resetFieldPositions - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - + + 4 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Remove fields if not in %s symbol + + 0 + + + 0 + + 1 + m_removeExtraBox + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Removes fields that do not occur in the original library symbols + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 4 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Reset fields if empty in %s symbol + + 0 + + + 0 + + 1 + m_resetEmptyFields + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 0 + + 15 + protected + 0 + + + + 4 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + %s field visibilities + + 0 + + + 0 + + 1 + m_resetFieldVisibilities + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 4 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + %s field sizes and styles + + 0 + + + 0 + + 1 + m_resetFieldEffects + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 4 + wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + %s field positions + + 0 + + + 0 + + 1 + m_resetFieldPositions + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + @@ -1379,7 +1629,7 @@ 0 - -1,240 + -1,200 1 m_messagePanel 1 diff --git a/eeschema/dialogs/dialog_change_symbols_base.h b/eeschema/dialogs/dialog_change_symbols_base.h index deda123af5..9dd9d852e1 100644 --- a/eeschema/dialogs/dialog_change_symbols_base.h +++ b/eeschema/dialogs/dialog_change_symbols_base.h @@ -29,8 +29,9 @@ class WX_HTML_REPORT_PANEL; #include #include #include -#include +#include #include +#include #include #include @@ -60,6 +61,10 @@ class DIALOG_CHANGE_SYMBOLS_BASE : public DIALOG_SHIM wxBoxSizer* m_newIdSizer; wxTextCtrl* m_newId; wxBitmapButton* m_newIdBrowserButton; + wxStaticBoxSizer* m_updateFieldsSizer; + wxCheckListBox* m_fieldsBox; + wxButton* m_selAllBtn; + wxButton* m_selNoneBtn; wxStaticBoxSizer* m_updateOptionsSizer; wxCheckBox* m_removeExtraBox; wxCheckBox* m_resetEmptyFields; @@ -72,11 +77,17 @@ class DIALOG_CHANGE_SYMBOLS_BASE : public DIALOG_SHIM wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class + virtual void onMatchByAll( wxCommandEvent& event ) { event.Skip(); } + virtual void onMatchBySelected( wxCommandEvent& event ) { event.Skip(); } virtual void onMatchByReference( wxCommandEvent& event ) { event.Skip(); } + virtual void onMatchTextKillFocus( wxFocusEvent& event ) { event.Skip(); } virtual void onMatchByValue( wxCommandEvent& event ) { event.Skip(); } + virtual void OnMatchText( wxCommandEvent& event ) { event.Skip(); } virtual void onMatchById( wxCommandEvent& event ) { event.Skip(); } virtual void launchMatchIdSymbolBrowser( wxCommandEvent& event ) { event.Skip(); } virtual void launchNewIdSymbolBrowser( wxCommandEvent& event ) { event.Skip(); } + virtual void onSelectAll( wxCommandEvent& event ) { event.Skip(); } + virtual void onSelectNone( wxCommandEvent& event ) { event.Skip(); } virtual void onOkButtonClicked( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/dialogs/dialog_update_fields.cpp b/eeschema/dialogs/dialog_update_fields.cpp deleted file mode 100644 index 161daa0782..0000000000 --- a/eeschema/dialogs/dialog_update_fields.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2017 CERN - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. - * - * @author Maciej Suminski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * https://www.gnu.org/licenses/gpl-3.0.html - * or you may search the http://www.gnu.org website for the version 3 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "dialog_update_fields.h" - -#include -#include -#include -#include -#include - - -int InvokeDialogUpdateFields( SCH_EDIT_FRAME* aCaller, SCH_COMPONENT* aSpecificComponent, - bool aCreateUndoEntry ) -{ - DIALOG_UPDATE_FIELDS dlg( aCaller, aSpecificComponent, aCreateUndoEntry ); - return dlg.ShowQuasiModal(); -} - - -DIALOG_UPDATE_FIELDS::DIALOG_UPDATE_FIELDS( SCH_EDIT_FRAME* aParent, - SCH_COMPONENT* aSpecificComponent, - bool aCreateUndoEntry ) : - DIALOG_UPDATE_FIELDS_BASE( aParent ), - m_frame( aParent ), - m_createUndo( aCreateUndoEntry ) -{ - if( aSpecificComponent ) - { - m_components.emplace_back( aParent->GetScreen(), aSpecificComponent ); - } - else - { - for( SCH_SHEET_PATH& path : aParent->Schematic().GetSheets() ) - { - SCH_SCREEN* screen = path.LastScreen(); - - for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) ) - m_components.emplace_back( screen, static_cast( item ) ); - } - } - - m_sdbSizerOK->SetDefault(); -} - - -bool DIALOG_UPDATE_FIELDS::TransferDataFromWindow() -{ - if( !wxDialog::TransferDataFromWindow() ) - return false; - - if( m_components.empty() ) - return true; // nothing to process - - // Create the set of fields to be updated - m_updateFields.clear(); - - for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i ) - { - if( m_fieldsBox->IsChecked( i ) ) - m_updateFields.insert( m_fieldsBox->GetString( i ) ); - } - - - // Undo buffer entry - if( m_createUndo ) - { - PICKED_ITEMS_LIST itemsList; - - for( std::pair& component : m_components ) - itemsList.PushItem( ITEM_PICKER( component.first, component.second, UNDO_REDO::CHANGED ) ); - - m_frame->SaveCopyInUndoList( itemsList, UNDO_REDO::CHANGED, true ); - } - - - // Do it! - for( std::pair& component : m_components ) - updateFields( component.second ); - - m_frame->SyncView(); - m_frame->GetCanvas()->Refresh(); - m_frame->OnModify(); - - return true; -} - - -bool DIALOG_UPDATE_FIELDS::TransferDataToWindow() -{ - if( !wxDialog::TransferDataToWindow() || !m_components.size() ) - return false; - - // Collect all user field names from library parts of components that are going to be updated - { - for( std::pair& component : m_components ) - { - const std::unique_ptr< LIB_PART >& part = component.second->GetPartRef(); - - if( !part ) - continue; - - const auto& drawItems = part->GetDrawItems(); - - for( auto it = drawItems.begin( LIB_FIELD_T ); it != drawItems.end( LIB_FIELD_T ); ++it ) - { - const LIB_FIELD* field = static_cast( &( *it ) ); - - if( field->GetId() >= MANDATORY_FIELDS ) - m_updateFields.insert( field->GetName() ); - } - } - } - - // Update the listbox widget - m_fieldsBox->Clear(); - - for( int i = 0; i < MANDATORY_FIELDS; ++i ) - { - m_fieldsBox->Append( m_components.front().second->GetField( i )->GetName() ); - - if( i != REFERENCE && i != VALUE ) - m_fieldsBox->Check( i, true ); - } - - for( const wxString& fieldName : m_updateFields ) - { - int idx = m_fieldsBox->Append( fieldName ); - m_fieldsBox->Check( idx, true ); - } - - // Now all widgets have the size fixed, call FinishDialogSettings - FinishDialogSettings(); - - return true; -} - - -void DIALOG_UPDATE_FIELDS::updateFields( SCH_COMPONENT* aComponent ) -{ - SCH_FIELDS newFields; - - std::unique_ptr< LIB_PART >& libPart = aComponent->GetPartRef(); - - if( !libPart ) // the symbol is not found in lib: cannot update fields - return; - - LIB_PART* alias = m_frame->GetLibPart( aComponent->GetLibId() ); - - for( const SCH_FIELD& existingField : aComponent->GetFields() ) - { - if( existingField.GetId() >= 0 && existingField.GetId() < MANDATORY_FIELDS ) - { - newFields.push_back( existingField ); - continue; - } - - // If requested, transfer only fields that occur also in the original library part - if( m_removeExtraBox->IsChecked() && !libPart->FindField( existingField.GetName() ) ) - continue; - - newFields.push_back( existingField ); - } - - // Update the requested fields - for( const wxString& fieldName : m_updateFields ) - { - LIB_FIELD* libField = libPart->FindField( fieldName ); - - if( !libField ) - continue; - - auto it = std::find_if( newFields.begin(), newFields.end(), - [&] ( const SCH_FIELD& f ) - { - return f.GetName() == fieldName; - } ); - - if( it != newFields.end() ) - { - SCH_FIELD* newField = &*it; - wxString fieldValue = libField->GetText(); - - if( alias ) - { - if( fieldName == TEMPLATE_FIELDNAME::GetDefaultFieldName( VALUE ) ) - fieldValue = alias->GetName(); - else if( fieldName == TEMPLATE_FIELDNAME::GetDefaultFieldName( DATASHEET ) ) - fieldValue = alias->GetDatasheetField().GetText(); - } - - if( fieldValue.IsEmpty() ) - { - // If the library field is empty an update would clear an existing entry. - // Check if this is the desired behavior. - if( m_resetEmpty->IsChecked() ) - newField->SetText( wxEmptyString ); - } - else - { - newField->SetText( fieldValue ); - } - - if( m_resetVisibility->IsChecked() ) - { - newField->SetVisible( libField->IsVisible() ); - } - - if( m_resetPosition->IsChecked() ) - { - newField->SetTextAngle( libField->GetTextAngle() ); - - // Schematic fields are schematic-relative; symbol editor fields are component-relative - if( m_createUndo ) - newField->SetTextPos( libField->GetTextPos() + aComponent->GetPosition() ); - else - newField->SetTextPos( libField->GetTextPos() ); - } - - if( m_resetSizeAndStyle->IsChecked() ) - { - newField->SetHorizJustify( libField->GetHorizJustify() ); - newField->SetVertJustify( libField->GetVertJustify() ); - newField->SetTextSize( libField->GetTextSize() ); - newField->SetItalic( libField->IsItalic() ); - newField->SetBold( libField->IsBold() ); - } - } - else - { - // Missing field, it has to be added to the component - SCH_FIELD newField( wxPoint( 0, 0 ), newFields.size(), aComponent, fieldName ); - - newField.ImportValues( *libField ); - newField.SetText( libField->GetText() ); - - // Schematic fields are schematic-relative; symbol editor fields are component-relative - if( m_createUndo ) - newField.SetTextPos( libField->GetTextPos() + aComponent->GetPosition() ); - else - newField.SetTextPos( libField->GetTextPos() ); - - newFields.push_back( newField ); - } - } - - // Apply changes & clean-up - aComponent->SetFields( newFields ); -} - - -void DIALOG_UPDATE_FIELDS::checkAll( bool aCheck ) -{ - for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i ) - m_fieldsBox->Check( i, aCheck ); -} diff --git a/eeschema/dialogs/dialog_update_fields.h b/eeschema/dialogs/dialog_update_fields.h deleted file mode 100644 index bad6eb1940..0000000000 --- a/eeschema/dialogs/dialog_update_fields.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2017 CERN - * @author Maciej Suminski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * https://www.gnu.org/licenses/gpl-3.0.html - * or you may search the http://www.gnu.org website for the version 3 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef DIALOG_UPDATE_FIELDS_H -#define DIALOG_UPDATE_FIELDS_H - -#include "dialog_update_fields_base.h" - -#include -#include - -class SCH_COMPONENT; -class SCH_SCREEN; -class SCH_EDIT_FRAME; - -/** - * Dialog to update component fields (i.e. restore them from the original library symbols). - */ -class DIALOG_UPDATE_FIELDS : public DIALOG_UPDATE_FIELDS_BASE -{ -public: - DIALOG_UPDATE_FIELDS( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aComponent, - bool aCreateUndoEntry ); - -private: - bool TransferDataFromWindow() override; - bool TransferDataToWindow() override; - - ///> Update fields for a single component - void updateFields( SCH_COMPONENT* aComponent ); - - ///> Selects or deselects all fields in the listbox widget - void checkAll( bool aCheck ); - - void onSelectAll( wxCommandEvent& event ) override - { - checkAll( true ); - } - - void onSelectNone( wxCommandEvent& event ) override - { - checkAll( false ); - } - - SCH_EDIT_FRAME* m_frame; - - ///> Set of field names that should have values updated - std::set m_updateFields; - - ///> Components to update - std::vector< std::pair> m_components; - - bool m_createUndo; -}; - -#endif /* DIALOG_UPDATE_FIELDS_H */ diff --git a/eeschema/dialogs/dialog_update_fields_base.cpp b/eeschema/dialogs/dialog_update_fields_base.cpp deleted file mode 100644 index a1501a7d64..0000000000 --- a/eeschema/dialogs/dialog_update_fields_base.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 6 2019) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_update_fields_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_UPDATE_FIELDS_BASE::DIALOG_UPDATE_FIELDS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* m_mainSizer; - m_mainSizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bUpperSizer; - bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxStaticBoxSizer* sbSizer2; - sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields to Update") ), wxVERTICAL ); - - wxArrayString m_fieldsBoxChoices; - m_fieldsBox = new wxCheckListBox( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fieldsBoxChoices, wxLB_NEEDED_SB ); - m_fieldsBox->SetMinSize( wxSize( -1,150 ) ); - - sbSizer2->Add( m_fieldsBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - wxBoxSizer* m_selBtnSizer; - m_selBtnSizer = new wxBoxSizer( wxHORIZONTAL ); - - m_selAllBtn = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _("Select All"), wxDefaultPosition, wxDefaultSize, 0 ); - m_selBtnSizer->Add( m_selAllBtn, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_selNoneBtn = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _("Select None"), wxDefaultPosition, wxDefaultSize, 0 ); - m_selBtnSizer->Add( m_selNoneBtn, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - - sbSizer2->Add( m_selBtnSizer, 0, wxEXPAND, 5 ); - - - bUpperSizer->Add( sbSizer2, 1, wxEXPAND|wxTOP|wxLEFT, 10 ); - - wxStaticBoxSizer* sbSizer1; - sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); - - m_removeExtraBox = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Remove fields not in library"), wxDefaultPosition, wxDefaultSize, 0 ); - m_removeExtraBox->SetToolTip( _("Removes fields that do not occur in the original library symbol") ); - - sbSizer1->Add( m_removeExtraBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_resetEmpty = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset fields which are empty in library"), wxDefaultPosition, wxDefaultSize, 0 ); - m_resetEmpty->SetToolTip( _("Clear existing entries if the correspondig library field is empty") ); - - sbSizer1->Add( m_resetEmpty, 0, wxALL, 5 ); - - - sbSizer1->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - m_resetVisibility = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset field visibilities"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer1->Add( m_resetVisibility, 0, wxALL, 5 ); - - m_resetSizeAndStyle = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset field text sizes and styles"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer1->Add( m_resetSizeAndStyle, 0, wxALL, 5 ); - - m_resetPosition = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset field positions"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer1->Add( m_resetPosition, 0, wxALL, 5 ); - - - bUpperSizer->Add( sbSizer1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); - - - m_mainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); - - m_sdbSizer = new wxStdDialogButtonSizer(); - m_sdbSizerOK = new wxButton( this, wxID_OK ); - m_sdbSizer->AddButton( m_sdbSizerOK ); - m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer->AddButton( m_sdbSizerCancel ); - m_sdbSizer->Realize(); - - m_mainSizer->Add( m_sdbSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); - - - this->SetSizer( m_mainSizer ); - this->Layout(); - m_mainSizer->Fit( this ); - - this->Centre( wxBOTH ); - - // Connect Events - m_selAllBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FIELDS_BASE::onSelectAll ), NULL, this ); - m_selNoneBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FIELDS_BASE::onSelectNone ), NULL, this ); -} - -DIALOG_UPDATE_FIELDS_BASE::~DIALOG_UPDATE_FIELDS_BASE() -{ - // Disconnect Events - m_selAllBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FIELDS_BASE::onSelectAll ), NULL, this ); - m_selNoneBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FIELDS_BASE::onSelectNone ), NULL, this ); - -} diff --git a/eeschema/dialogs/dialog_update_fields_base.fbp b/eeschema/dialogs/dialog_update_fields_base.fbp deleted file mode 100644 index f5398c4751..0000000000 --- a/eeschema/dialogs/dialog_update_fields_base.fbp +++ /dev/null @@ -1,671 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_update_fields_base - 1000 - none - - 1 - dialog_update_fields_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_UPDATE_FIELDS_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Update Symbol Fields - - - - - - - m_mainSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - bUpperSizer - wxHORIZONTAL - none - - 10 - wxEXPAND|wxTOP|wxLEFT - 1 - - wxID_ANY - Fields to Update - - sbSizer2 - wxVERTICAL - 1 - none - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - -1,150 - 1 - m_fieldsBox - 1 - - - protected - 1 - - Resizable - 1 - - wxLB_NEEDED_SB - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND - 0 - - - m_selBtnSizer - wxHORIZONTAL - none - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Select All - - 0 - - 0 - - - 0 - - 1 - m_selAllBtn - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onSelectAll - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Select None - - 0 - - 0 - - - 0 - - 1 - m_selNoneBtn - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onSelectNone - - - - - - - - 10 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - wxID_ANY - Options - - sbSizer1 - wxVERTICAL - 1 - none - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Remove fields not in library - - 0 - - - 0 - - 1 - m_removeExtraBox - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Removes fields that do not occur in the original library symbol - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset fields which are empty in library - - 0 - - - 0 - - 1 - m_resetEmpty - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - Clear existing entries if the correspondig library field is empty - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 0 - protected - 0 - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset field visibilities - - 0 - - - 0 - - 1 - m_resetVisibility - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset field text sizes and styles - - 0 - - - 0 - - 1 - m_resetSizeAndStyle - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Reset field positions - - 0 - - - 0 - - 1 - m_resetPosition - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - diff --git a/eeschema/dialogs/dialog_update_fields_base.h b/eeschema/dialogs/dialog_update_fields_base.h deleted file mode 100644 index 2c09f6b980..0000000000 --- a/eeschema/dialogs/dialog_update_fields_base.h +++ /dev/null @@ -1,63 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 6 2019) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -#include "dialog_shim.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_UPDATE_FIELDS_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_UPDATE_FIELDS_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxCheckListBox* m_fieldsBox; - wxButton* m_selAllBtn; - wxButton* m_selNoneBtn; - wxCheckBox* m_removeExtraBox; - wxCheckBox* m_resetEmpty; - wxCheckBox* m_resetVisibility; - wxCheckBox* m_resetSizeAndStyle; - wxCheckBox* m_resetPosition; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - // Virtual event handlers, overide them in your derived class - virtual void onSelectAll( wxCommandEvent& event ) { event.Skip(); } - virtual void onSelectNone( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_UPDATE_FIELDS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Update Symbol Fields"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_UPDATE_FIELDS_BASE(); - -}; - diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h index 7c50877115..40aec1acbc 100644 --- a/eeschema/invoke_sch_dialog.h +++ b/eeschema/invoke_sch_dialog.h @@ -85,10 +85,6 @@ int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller ); /// Create and show DIALOG_BUS_MANAGER void InvokeDialogBusManager( SCH_EDIT_FRAME* aCaller ); -/// Update symbol fields -int InvokeDialogUpdateFields( SCH_EDIT_FRAME* aCaller, SCH_COMPONENT* aSpecificComponent = nullptr, - bool aCreateUndoEntry = true ); - /** * Create and shows NETLIST_DIALOG and returns whatever * NETLIST_DIALOG::ShowModal() returns. diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 7fcc150178..9f0ec2a5d6 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -395,11 +395,6 @@ TOOL_ACTION EE_ACTIONS::autoplaceFields( "eeschema.InteractiveEdit.autoplaceFiel _( "Autoplace Fields" ), _( "Runs the automatic placement algorithm on the symbol's fields" ), autoplace_fields_xpm ); -TOOL_ACTION EE_ACTIONS::updateFieldsFromLibrary( "eeschema.InteractiveEdit.updateFieldsFromLibrary", - AS_GLOBAL, 0, "", - _( "Update Fields from Library..." ), _( "Sets symbol fields to original library values" ), - update_fields_xpm ); - TOOL_ACTION EE_ACTIONS::changeSymbols( "eeschema.InteractiveEdit.changeSymbols", AS_GLOBAL, 0, "", _( "Change Symbols..." ), diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 777e2ed562..94d94e9463 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -144,7 +144,6 @@ public: static TOOL_ACTION editSymbolLibraryLinks; static TOOL_ACTION symbolProperties; static TOOL_ACTION pinTable; - static TOOL_ACTION updateFieldsFromLibrary; static TOOL_ACTION changeSymbols; static TOOL_ACTION updateSymbols; static TOOL_ACTION changeSymbol; diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index e46fa586e6..327348bb64 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -1235,15 +1235,6 @@ int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent ) } -int SCH_EDIT_TOOL::UpdateFields( const TOOL_EVENT& aEvent ) -{ - if( InvokeDialogUpdateFields( m_frame ) == wxID_OK ) - m_frame->GetCanvas()->Refresh(); - - return 0; -} - - int SCH_EDIT_TOOL::ChangeSymbols( const TOOL_EVENT& aEvent ) { SCH_COMPONENT* selectedSymbol = nullptr; @@ -1788,7 +1779,6 @@ void SCH_EDIT_TOOL::setTransitions() Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editValue.MakeEvent() ); Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editFootprint.MakeEvent() ); Go( &SCH_EDIT_TOOL::AutoplaceFields, EE_ACTIONS::autoplaceFields.MakeEvent() ); - Go( &SCH_EDIT_TOOL::UpdateFields, EE_ACTIONS::updateFieldsFromLibrary.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeSymbols, EE_ACTIONS::changeSymbols.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeSymbols, EE_ACTIONS::updateSymbols.MakeEvent() ); Go( &SCH_EDIT_TOOL::ChangeSymbols, EE_ACTIONS::changeSymbol.MakeEvent() );