diff --git a/eeschema/dialogs/dialog_update_fields.cpp b/eeschema/dialogs/dialog_update_fields.cpp index a2ac55af0b..b7e8c7c943 100644 --- a/eeschema/dialogs/dialog_update_fields.cpp +++ b/eeschema/dialogs/dialog_update_fields.cpp @@ -43,6 +43,7 @@ DIALOG_UPDATE_FIELDS::DIALOG_UPDATE_FIELDS( SCH_EDIT_FRAME* aParent, : DIALOG_UPDATE_FIELDS_BASE( aParent ), m_frame( aParent ), m_components( aComponents ), m_createUndo( aCreateUndoEntry ) { + m_sdbSizerOK->SetDefault(); } @@ -89,10 +90,10 @@ bool DIALOG_UPDATE_FIELDS::TransferDataFromWindow() bool DIALOG_UPDATE_FIELDS::TransferDataToWindow() { - if( !wxDialog::TransferDataToWindow() ) + if( !wxDialog::TransferDataToWindow() || !m_components.size() ) return false; - // Collect all field names from library parts of components that are going to be updated + // Collect all user field names from library parts of components that are going to be updated { for( auto component : m_components ) { @@ -106,7 +107,9 @@ bool DIALOG_UPDATE_FIELDS::TransferDataToWindow() for( auto it = drawItems.begin( LIB_FIELD_T ); it != drawItems.end( LIB_FIELD_T ); ++it ) { const LIB_FIELD* field = static_cast( &( *it ) ); - m_fields.insert( field->GetName( false ) ); + + if( field->GetId() >= MANDATORY_FIELDS ) + m_fields.insert( field->GetName( false ) ); } } } @@ -114,12 +117,18 @@ bool DIALOG_UPDATE_FIELDS::TransferDataToWindow() // Update the listbox widget m_fieldsBox->Clear(); + for( int i = 0; i < MANDATORY_FIELDS; ++i ) + { + m_fieldsBox->Append( m_components.front()->GetField( i )->GetName( false ) ); + + if( i != REFERENCE && i != VALUE ) + m_fieldsBox->Check( i, true ); + } + for( const auto& field : m_fields ) { int idx = m_fieldsBox->Append( field ); - - if( field != "Reference" && field != "Value" ) - m_fieldsBox->Check( idx, true ); + m_fieldsBox->Check( idx, true ); } // Now all widgets have the size fixed, call FinishDialogSettings @@ -174,10 +183,30 @@ void DIALOG_UPDATE_FIELDS::updateFields( SCH_COMPONENT* aComponent ) // If the library field is empty an update would clear an existing entry. // Check if this is the desired behavior. - auto newText = libField->GetText(); - if( !newText.empty() || !m_omitEmpty->IsChecked() ) + if( !libField->GetText().empty() || m_resetEmpty->IsChecked() ) + field->SetText( libField->GetText() ); + + if( m_resetVisibility->IsChecked() ) + field->SetVisible( libField->IsVisible() ); + + if( m_resetPosition->IsChecked() ) { - field->SetText( newText ); + field->SetTextAngle( libField->GetTextAngle() ); + + // Board fields are board-relative; symbol editor fields are component-relative + if( m_createUndo ) + field->SetTextPos( libField->GetTextPos() + aComponent->GetPosition() ); + else + field->SetTextPos( libField->GetTextPos() ); + } + + if( m_resetSizeAndStyle->IsChecked() ) + { + field->SetHorizJustify( libField->GetHorizJustify() ); + field->SetVertJustify( libField->GetVertJustify() ); + field->SetTextSize( libField->GetTextSize() ); + field->SetItalic( libField->IsItalic() ); + field->SetBold( libField->IsBold() ); } } diff --git a/eeschema/dialogs/dialog_update_fields_base.cpp b/eeschema/dialogs/dialog_update_fields_base.cpp index 91fcfe123c..8a2bead9f9 100644 --- a/eeschema/dialogs/dialog_update_fields_base.cpp +++ b/eeschema/dialogs/dialog_update_fields_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 6 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -16,38 +16,63 @@ DIALOG_UPDATE_FIELDS_BASE::DIALOG_UPDATE_FIELDS_BASE( wxWindow* parent, wxWindow wxBoxSizer* m_mainSizer; m_mainSizer = new wxBoxSizer( wxVERTICAL ); - m_infoLabel = new wxStaticText( this, wxID_ANY, _("Select fields to update:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_infoLabel->Wrap( -1 ); - m_mainSizer->Add( m_infoLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + 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( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fieldsBoxChoices, wxLB_NEEDED_SB ); - m_mainSizer->Add( m_fieldsBox, 1, wxALL|wxEXPAND, 5 ); + 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( this, wxID_ANY, _("Select All"), wxDefaultPosition, wxDefaultSize, 0 ); - m_selBtnSizer->Add( m_selAllBtn, 1, wxALL|wxEXPAND, 5 ); + 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( this, wxID_ANY, _("Select None"), wxDefaultPosition, wxDefaultSize, 0 ); - m_selBtnSizer->Add( m_selNoneBtn, 1, wxALL|wxEXPAND, 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 ); - m_mainSizer->Add( m_selBtnSizer, 0, wxEXPAND, 5 ); + sbSizer2->Add( m_selBtnSizer, 0, wxEXPAND, 5 ); - m_removeExtraBox = new wxCheckBox( this, wxID_ANY, _("Remove extra fields"), wxDefaultPosition, wxDefaultSize, 0 ); + + 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 symbols") ); - m_mainSizer->Add( m_removeExtraBox, 0, wxALL, 5 ); + sbSizer1->Add( m_removeExtraBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_omitEmpty = new wxCheckBox( this, wxID_ANY, _("Omit empty fields"), wxDefaultPosition, wxDefaultSize, 0 ); - m_omitEmpty->SetToolTip( _("Do not clear existing entries if library field is empty") ); + m_resetEmpty = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset fields which are empty in library"), wxDefaultPosition, wxDefaultSize, 0 ); + m_resetEmpty->SetToolTip( _("Do not clear existing entries if library field is empty") ); - m_mainSizer->Add( m_omitEmpty, 0, wxALL, 5 ); + sbSizer1->Add( m_resetEmpty, 0, wxALL, 5 ); - m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - m_mainSizer->Add( m_staticline, 0, wxEXPAND | 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 ); diff --git a/eeschema/dialogs/dialog_update_fields_base.fbp b/eeschema/dialogs/dialog_update_fields_base.fbp index 3652e465b1..d72d539009 100644 --- a/eeschema/dialogs/dialog_update_fields_base.fbp +++ b/eeschema/dialogs/dialog_update_fields_base.fbp @@ -14,7 +14,6 @@ dialog_update_fields_base 1000 none - 1 dialog_update_fields_base @@ -94,622 +93,773 @@ m_mainSizer wxVERTICAL none - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Select fields to update: - - 0 - - - 0 - - 1 - m_infoLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_fieldsBox - 1 - - - protected - 1 - - Resizable - 1 - - wxLB_NEEDED_SB - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxEXPAND - 0 + 1 - m_selBtnSizer + bUpperSizer wxHORIZONTAL none - 5 - wxALL|wxEXPAND + 10 + wxEXPAND|wxTOP|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 + Fields to Update - 1 - m_selAllBtn - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onSelectAll - - - - - - - - - - - - - - - - - - - - - - + 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 + + 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 + + 1 + m_selNoneBtn + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onSelectNone + + + + + + + + + + + + + + + + + + + + + + + + + + + - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + wxID_ANY - Select None - - 0 - - - 0 + Options - 1 - m_selNoneBtn - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onSelectNone - - - - - - - - - - - - - - - - - - - - - - + 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 symbols + + 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 + Do not clear existing entries if 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 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Remove extra fields - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Omit empty fields - - 0 - - - 0 - - 1 - m_omitEmpty - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - Do not clear existing entries if library field is empty - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT diff --git a/eeschema/dialogs/dialog_update_fields_base.h b/eeschema/dialogs/dialog_update_fields_base.h index 76b9bd85f9..ef7d43f25d 100644 --- a/eeschema/dialogs/dialog_update_fields_base.h +++ b/eeschema/dialogs/dialog_update_fields_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 6 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -13,16 +13,15 @@ #include #include "dialog_shim.h" #include -#include +#include #include #include #include #include -#include #include #include +#include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -36,13 +35,14 @@ class DIALOG_UPDATE_FIELDS_BASE : public DIALOG_SHIM private: protected: - wxStaticText* m_infoLabel; wxCheckListBox* m_fieldsBox; wxButton* m_selAllBtn; wxButton* m_selNoneBtn; wxCheckBox* m_removeExtraBox; - wxCheckBox* m_omitEmpty; - wxStaticLine* m_staticline; + wxCheckBox* m_resetEmpty; + wxCheckBox* m_resetVisibility; + wxCheckBox* m_resetSizeAndStyle; + wxCheckBox* m_resetPosition; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel;