From dcfd4263337bd3dea6294e2ebe2e5433234aceb3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 7 Jun 2023 23:45:06 +0100 Subject: [PATCH] Upgrade some dialogs to SCHEMATIC_COMMIT. --- eeschema/bus-wire-junction.cpp | 4 -- eeschema/dialogs/dialog_change_symbols.cpp | 25 ++++---- eeschema/dialogs/dialog_change_symbols.h | 6 +- eeschema/dialogs/dialog_field_properties.cpp | 9 ++- eeschema/dialogs/dialog_field_properties.h | 3 +- .../dialog_global_edit_text_and_graphics.cpp | 55 ++++++++--------- eeschema/dialogs/dialog_image_properties.cpp | 11 ++-- eeschema/dialogs/dialog_junction_props.cpp | 15 +++-- eeschema/dialogs/dialog_label_properties.cpp | 59 ++++++++----------- eeschema/dialogs/dialog_line_properties.cpp | 14 ++--- eeschema/dialogs/dialog_shape_properties.cpp | 16 +++-- .../dialogs/dialog_sheet_pin_properties.cpp | 31 +++++----- eeschema/dialogs/dialog_text_properties.cpp | 21 +++---- .../dialogs/dialog_wire_bus_properties.cpp | 13 ++-- eeschema/schematic_commit.cpp | 5 +- eeschema/tools/sch_edit_tool.cpp | 9 +-- 16 files changed, 140 insertions(+), 156 deletions(-) diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 42e6cac181..162dddb5f8 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -23,17 +23,13 @@ */ #include -#include #include -#include #include -#include #include #include #include #include #include -#include #include #include #include diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 43eadd6eff..39a4348f48 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -34,6 +34,7 @@ #include #include #include +#include bool g_selectRefDes = false; bool g_selectValue = false; @@ -369,8 +370,9 @@ void DIALOG_CHANGE_SYMBOLS::checkAll( bool aCheck ) void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent ) { - wxBusyCursor dummy; - SCH_EDIT_FRAME* parent = dynamic_cast( GetParent() ); + wxBusyCursor dummy; + SCH_EDIT_FRAME* parent = dynamic_cast( GetParent() ); + SCHEMATIC_COMMIT commit( parent ); wxCHECK( parent, /* void */ ); @@ -391,14 +393,16 @@ void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent ) m_updateFields.insert( dummy_field.GetCanonicalName() ); } else + { m_updateFields.insert( m_fieldsBox->GetString( i ) ); + } } } - if( processMatchingSymbols() ) + if( processMatchingSymbols( &commit) ) { parent->TestDanglingEnds(); // This will also redraw the changed symbols. - parent->OnModify(); + commit.Push( m_mode == MODE::CHANGE ? _( "Change Symbols" ) : _( "Update Symbols" ) ); } m_messagePanel->Flush( false ); @@ -447,7 +451,7 @@ bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInsta -int DIALOG_CHANGE_SYMBOLS::processMatchingSymbols() +int DIALOG_CHANGE_SYMBOLS::processMatchingSymbols( SCHEMATIC_COMMIT* aCommit ) { SCH_EDIT_FRAME* frame = dynamic_cast( GetParent() ); @@ -505,7 +509,7 @@ int DIALOG_CHANGE_SYMBOLS::processMatchingSymbols() } } - matchesProcessed += processSymbols( symbols ); + matchesProcessed += processSymbols( aCommit, symbols ); frame->GetCurrentSheet().UpdateAllScreenReferences(); @@ -513,8 +517,8 @@ int DIALOG_CHANGE_SYMBOLS::processMatchingSymbols() } -int DIALOG_CHANGE_SYMBOLS::processSymbols( const std::map& aSymbols ) +int DIALOG_CHANGE_SYMBOLS::processSymbols( SCHEMATIC_COMMIT* aCommit, + const std::map& aSymbols ) { wxCHECK( !aSymbols.empty(), 0 ); @@ -561,8 +565,6 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( const std::mapRemove( symbol ); - frame->SaveCopyInUndoList( screen, symbol, UNDO_REDO::CHANGED, appendUndo ); - appendUndo = true; + aCommit->Modify( symbol, screen ); } for( const auto& [ symbol, symbol_change_info ] : symbols ) diff --git a/eeschema/dialogs/dialog_change_symbols.h b/eeschema/dialogs/dialog_change_symbols.h index acf2ebb95e..ff911ef635 100644 --- a/eeschema/dialogs/dialog_change_symbols.h +++ b/eeschema/dialogs/dialog_change_symbols.h @@ -32,6 +32,7 @@ class SCH_SYMBOL; class SCH_EDIT_FRAME; class SCH_SCREEN; +class SCHEMATIC_COMMIT; struct SYMBOL_CHANGE_INFO @@ -83,8 +84,9 @@ private: void updateFieldsList(); bool isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInstance ); - int processMatchingSymbols(); - int processSymbols( const std::map& aSymbols ); + int processMatchingSymbols( SCHEMATIC_COMMIT* aCommit ); + int processSymbols( SCHEMATIC_COMMIT* aCommit, + const std::map& aSymbols ); wxString getSymbolReferences( SCH_SYMBOL& aSymbol, const LIB_ID& aNewId ); SCH_SYMBOL* m_symbol; diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index ba85836b64..ba8026fbe7 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -629,7 +629,8 @@ void DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEven } -void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH* aSheetPath ) +void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCHEMATIC_COMMIT* aCommit, SCH_FIELD* aField, + SCH_SHEET_PATH* aSheetPath ) { SCH_EDIT_FRAME* editFrame = dynamic_cast( GetParent() ); SCH_ITEM* parent = dynamic_cast( aField->GetParent() ); @@ -715,14 +716,12 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH { SCH_SCREEN* screen = sheet.LastScreen(); std::vector otherUnits; - constexpr bool appendUndo = true; CollectOtherUnits( ref, unit, libId, sheet, &otherUnits ); for( SCH_SYMBOL* otherUnit : otherUnits ) { - editFrame->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED, - appendUndo ); + aCommit->Modify( otherUnit, screen ); if( fieldType == VALUE_FIELD ) otherUnit->SetValueFieldText( m_text ); diff --git a/eeschema/dialogs/dialog_field_properties.h b/eeschema/dialogs/dialog_field_properties.h index 52fc725fc0..bdbde40050 100644 --- a/eeschema/dialogs/dialog_field_properties.h +++ b/eeschema/dialogs/dialog_field_properties.h @@ -35,6 +35,7 @@ class SCH_BASE_FRAME; class SCH_FIELD; class EDA_TEXT; class SCINTILLA_TRICKS; +class SCHEMATIC_COMMIT; /** @@ -141,7 +142,7 @@ public: void onScintillaCharAdded( wxStyledTextEvent &aEvent ); - void UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH* aSheetPath ); + void UpdateField( SCHEMATIC_COMMIT* aCommit, SCH_FIELD* aField, SCH_SHEET_PATH* aSheetPath ); private: const SCH_FIELD* m_field; diff --git a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp index 8bf3eaaa55..a8b15c9b73 100644 --- a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -78,8 +78,6 @@ class DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS : public DIALOG_GLOBAL_EDIT_TEXT_AND_ UNIT_BINDER m_lineWidth; UNIT_BINDER m_junctionSize; - bool m_appendUndo; - public: DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( SCH_EDIT_FRAME* parent ); ~DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS() override; @@ -105,8 +103,8 @@ protected: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - void visitItem( const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem ); - void processItem( const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem ); + void visitItem( SCHEMATIC_COMMIT* aCommit, const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem ); + void processItem( SCHEMATIC_COMMIT* aCommit, const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem ); }; @@ -117,7 +115,6 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( SCH_ m_junctionSize( parent, m_dotSizeLabel, m_dotSizeCtrl, m_dotSizeUnits, true ) { m_parent = parent; - m_appendUndo = false; m_lineStyle->Append( DEFAULT_STYLE ); m_lineStyle->Append( INDETERMINATE_ACTION ); @@ -239,7 +236,8 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow() } -void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aSheetPath, +void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( SCHEMATIC_COMMIT* aCommit, + const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem ) { if( m_selectedFilterOpt->GetValue() ) @@ -248,9 +246,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aS return; } - m_parent->SaveCopyInUndoList( aSheetPath.LastScreen(), aItem, UNDO_REDO::CHANGED, m_appendUndo, - false ); - m_appendUndo = true; + aCommit->Modify( aItem, aSheetPath.LastScreen() ); if( EDA_TEXT* eda_text = dynamic_cast( aItem ) ) { @@ -375,7 +371,8 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( const SCH_SHEET_PATH& aS } } -void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aSheetPath, +void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( SCHEMATIC_COMMIT* aCommit, + const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem ) { if( m_netFilterOpt->GetValue() && !m_netFilter->GetValue().IsEmpty() ) @@ -427,10 +424,10 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem; if( m_references->GetValue() ) - processItem( aSheetPath, symbol->GetField( REFERENCE_FIELD ) ); + processItem( aCommit, aSheetPath, symbol->GetField( REFERENCE_FIELD ) ); if( m_values->GetValue() ) - processItem( aSheetPath, symbol->GetField( VALUE_FIELD ) ); + processItem( aCommit, aSheetPath, symbol->GetField( VALUE_FIELD ) ); if( m_otherFields->GetValue() ) { @@ -442,7 +439,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty() || WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) ) { - processItem( aSheetPath, &field ); + processItem( aCommit, aSheetPath, &field ); } } } @@ -452,7 +449,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe SCH_SHEET* sheet = static_cast( aItem ); if( m_sheetTitles->GetValue() ) - processItem( aSheetPath, &sheet->GetFields()[SHEETNAME] ); + processItem( aCommit, aSheetPath, &sheet->GetFields()[SHEETNAME] ); if( m_sheetFields->GetValue() ) { @@ -466,7 +463,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty() || WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) ) { - processItem( aSheetPath, &field ); + processItem( aCommit, aSheetPath, &field ); } } } @@ -486,26 +483,26 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe if( m_sheetPins->GetValue() ) { for( SCH_SHEET_PIN* pin : sheet->GetPins() ) - processItem( aSheetPath, pin ); + processItem( aCommit, aSheetPath, pin ); } } else if( m_wires->GetValue() && aItem->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_LABEL_LOCATE_WIRE_T } ) ) { - processItem( aSheetPath, aItem ); + processItem( aCommit, aSheetPath, aItem ); } else if( m_buses->GetValue() && aItem->IsType( { SCH_ITEM_LOCATE_BUS_T, SCH_LABEL_LOCATE_BUS_T } ) ) { - processItem( aSheetPath, aItem ); + processItem( aCommit, aSheetPath, aItem ); } else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) ) { if( m_globalLabels->GetValue() && aItem->Type() == SCH_GLOBAL_LABEL_T ) - processItem( aSheetPath, aItem ); + processItem( aCommit, aSheetPath, aItem ); if( m_hierLabels->GetValue() && aItem->Type() == SCH_HIER_LABEL_T ) - processItem( aSheetPath, aItem ); + processItem( aCommit, aSheetPath, aItem ); if( m_labelFields->GetValue() ) { @@ -516,7 +513,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty() || WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) ) { - processItem( aSheetPath, &field ); + processItem( aCommit, aSheetPath, &field ); } } } @@ -529,12 +526,12 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe { if( item->GetLayer() == LAYER_BUS && m_buses->GetValue() ) { - processItem( aSheetPath, aItem ); + processItem( aCommit, aSheetPath, aItem ); break; } else if( item->GetLayer() == LAYER_WIRE && m_wires->GetValue() ) { - processItem( aSheetPath, aItem ); + processItem( aCommit, aSheetPath, aItem ); break; } } @@ -543,7 +540,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe SCH_ITEM_LOCATE_GRAPHIC_LINE_T, SCH_SHAPE_T } ) ) { - processItem( aSheetPath, aItem ); + processItem( aCommit, aSheetPath, aItem ); } } @@ -553,8 +550,8 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() if( !m_textSize.Validate( 1.0, 10000.0, EDA_UNITS::MILS ) ) // 1 mil .. 10 inches return false; - SCH_SHEET_PATH currentSheet = m_parent->GetCurrentSheet(); - m_appendUndo = false; + SCH_SHEET_PATH currentSheet = m_parent->GetCurrentSheet(); + SCHEMATIC_COMMIT commit( m_parent ); // Go through sheets for( const SCH_SHEET_PATH& sheetPath : m_parent->Schematic().GetSheets() ) @@ -566,13 +563,13 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() m_parent->SetCurrentSheet( sheetPath ); for( SCH_ITEM* item : screen->Items() ) - visitItem( sheetPath, item ); + visitItem( &commit, sheetPath, item ); } } - if( m_appendUndo ) + if( !commit.Empty() ) { - m_parent->OnModify(); + commit.Push( _( "Edit Text and Graphics" ), SKIP_CONNECTIVITY ); m_parent->HardRedraw(); } diff --git a/eeschema/dialogs/dialog_image_properties.cpp b/eeschema/dialogs/dialog_image_properties.cpp index ed5a9e89ad..8496f3038b 100644 --- a/eeschema/dialogs/dialog_image_properties.cpp +++ b/eeschema/dialogs/dialog_image_properties.cpp @@ -26,8 +26,7 @@ #include #include -#include -#include +#include DIALOG_IMAGE_PROPERTIES::DIALOG_IMAGE_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_BITMAP* aBitmap ) : @@ -61,16 +60,20 @@ bool DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow() { if( m_imageEditor->TransferDataFromWindow() ) { + SCHEMATIC_COMMIT commit( m_frame ); + // Save old image in undo list if not already in edit if( m_bitmap->GetEditFlags() == 0 ) - m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_bitmap, UNDO_REDO::CHANGED, false, - false ); + commit.Modify( m_bitmap, m_frame->GetScreen() ); // Update our bitmap from the editor m_imageEditor->TransferToImage( m_bitmap->GetImage() ); m_bitmap->SetPosition( VECTOR2I( m_posX.GetValue(), m_posY.GetValue() ) ); + if( !commit.Empty() ) + commit.Push( _( "Image Properties" ), SKIP_CONNECTIVITY ); + return true; } diff --git a/eeschema/dialogs/dialog_junction_props.cpp b/eeschema/dialogs/dialog_junction_props.cpp index ac87a5c368..e98d5c0c45 100644 --- a/eeschema/dialogs/dialog_junction_props.cpp +++ b/eeschema/dialogs/dialog_junction_props.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Wayne Stambaugh - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -23,6 +23,7 @@ #include #include #include +#include DIALOG_JUNCTION_PROPS::DIALOG_JUNCTION_PROPS( SCH_EDIT_FRAME* aParent, @@ -95,15 +96,12 @@ void DIALOG_JUNCTION_PROPS::resetDefaults( wxCommandEvent& event ) bool DIALOG_JUNCTION_PROPS::TransferDataFromWindow() { - PICKED_ITEMS_LIST pickedItems; - - for( SCH_JUNCTION* junction : m_junctions ) - pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), junction, UNDO_REDO::CHANGED ) ); - - m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false, false ); + SCHEMATIC_COMMIT commit( m_frame ); for( SCH_JUNCTION* junction : m_junctions ) { + commit.Modify( junction, m_frame->GetScreen() ); + if( !m_diameter.IsIndeterminate() ) junction->SetDiameter( m_diameter.GetValue() ); @@ -112,8 +110,9 @@ bool DIALOG_JUNCTION_PROPS::TransferDataFromWindow() m_frame->GetCanvas()->GetView()->Update( junction ); } + commit.Push( m_junctions.size() == 1 ? _( "Edit Junction" ) : _( "Edit Junctions" ), + SKIP_CONNECTIVITY ); m_frame->GetCanvas()->Refresh(); - m_frame->OnModify(); return true; } diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index ad9243e761..a74b8860fb 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -37,10 +36,9 @@ #include #include #include -#include -#include #include #include +#include DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_LABEL_BASE* aLabel ) : @@ -433,14 +431,12 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow() if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) ) return false; - wxString text; + SCHEMATIC_COMMIT commit( m_Parent ); + wxString text; /* save old text in undo list if not already in edit */ if( m_currentLabel->GetEditFlags() == 0 ) - { - m_Parent->SaveCopyInUndoList( m_Parent->GetScreen(), m_currentLabel, UNDO_REDO::CHANGED, - false ); - } + commit.Modify( m_currentLabel, m_Parent->GetScreen() ); m_Parent->GetCanvas()->Refresh(); @@ -517,24 +513,15 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow() if( m_shapeSizer->AreAnyItemsShown() ) { - if( m_input->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); - else if( m_output->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); - else if( m_bidirectional->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); - else if( m_triState->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); - else if( m_passive->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); - else if( m_dot->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_DOT ); - else if( m_circle->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_ROUND ); - else if( m_diamond->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_DIAMOND ); - else if( m_rectangle->GetValue() ) - m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_RECTANGLE ); + if( m_bidirectional->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); + else if( m_input->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); + else if( m_output->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); + else if( m_triState->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); + else if( m_passive->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); + else if( m_dot->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_DOT ); + else if( m_circle->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_ROUND ); + else if( m_diamond->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_DIAMOND ); + else if( m_rectangle->GetValue() ) m_currentLabel->SetShape( LABEL_FLAG_SHAPE::F_RECTANGLE ); } if( m_fontCtrl->HaveFontSelection() ) @@ -568,14 +555,10 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow() TEXT_SPIN_STYLE selectedSpinStyle= TEXT_SPIN_STYLE::LEFT; - if( m_spin0->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::RIGHT; - else if( m_spin1->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::LEFT; - else if( m_spin2->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::UP; - else if( m_spin3->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::BOTTOM; + if( m_spin0->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::RIGHT; + else if( m_spin1->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::LEFT; + else if( m_spin2->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::UP; + else if( m_spin3->IsChecked() ) selectedSpinStyle = TEXT_SPIN_STYLE::BOTTOM; if( m_currentLabel->AutoRotateOnPlacementSupported() ) { @@ -584,16 +567,24 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow() frame->AutoRotateItem( frame->GetScreen(), m_currentLabel ); } else + { m_currentLabel->SetAutoRotateOnPlacement( false ); + } if( !m_currentLabel->AutoRotateOnPlacement() && m_currentLabel->GetTextSpinStyle() != selectedSpinStyle ) + { m_currentLabel->SetTextSpinStyle( selectedSpinStyle ); + } if( doAutoplace ) m_currentLabel->AutoAutoplaceFields( m_Parent->GetScreen() ); m_Parent->UpdateItem( m_currentLabel ); + + if( !commit.Empty() ) + commit.Push( _( "Edit Label" ), SKIP_CONNECTIVITY ); + m_Parent->GetCanvas()->Refresh(); return true; diff --git a/eeschema/dialogs/dialog_line_properties.cpp b/eeschema/dialogs/dialog_line_properties.cpp index d9632313f9..d89a9fae5c 100644 --- a/eeschema/dialogs/dialog_line_properties.cpp +++ b/eeschema/dialogs/dialog_line_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Seth Hillbrand - * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -29,6 +29,7 @@ #include #include #include +#include DIALOG_LINE_PROPERTIES::DIALOG_LINE_PROPERTIES( SCH_EDIT_FRAME* aParent, @@ -128,15 +129,12 @@ void DIALOG_LINE_PROPERTIES::resetDefaults( wxCommandEvent& event ) bool DIALOG_LINE_PROPERTIES::TransferDataFromWindow() { - PICKED_ITEMS_LIST pickedItems; - - for( SCH_LINE* line : m_lines ) - pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), line, UNDO_REDO::CHANGED ) ); - - m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false, false ); + SCHEMATIC_COMMIT commit( m_frame ); for( SCH_LINE* line : m_lines ) { + commit.Modify( line, m_frame->GetScreen() ); + if( !m_width.IsIndeterminate() ) line->SetLineWidth( std::max( (long long int) 0, m_width.GetValue() ) ); @@ -153,8 +151,8 @@ bool DIALOG_LINE_PROPERTIES::TransferDataFromWindow() m_frame->UpdateItem( line, false, true ); } + commit.Push( m_lines.size() == 1 ? _( "Edit Line" ) : _( "Edit Lines" ), SKIP_CONNECTIVITY ); m_frame->GetCanvas()->Refresh(); - m_frame->OnModify(); return true; } diff --git a/eeschema/dialogs/dialog_shape_properties.cpp b/eeschema/dialogs/dialog_shape_properties.cpp index cfeecaa921..81ff25a864 100644 --- a/eeschema/dialogs/dialog_shape_properties.cpp +++ b/eeschema/dialogs/dialog_shape_properties.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,6 +27,8 @@ #include #include #include +#include + DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SHAPE* aShape ) : DIALOG_SHAPE_PROPERTIES_BASE( aParent ), @@ -135,16 +137,15 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; + SCHEMATIC_COMMIT commit( m_frame ); + if( !m_shape->IsNew() ) - { - m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_shape, UNDO_REDO::CHANGED, false, - false ); - } + commit.Modify( m_shape, m_frame->GetScreen() ); STROKE_PARAMS stroke = m_shape->GetStroke(); if( m_borderCheckbox->GetValue() ) - stroke.SetWidth( std::max( (long long int) 0, m_borderWidth.GetValue() ) ); + stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) ); else stroke.SetWidth( -1 ); @@ -163,6 +164,9 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow() m_shape->SetFillMode( m_filledCtrl->GetValue() ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL ); m_shape->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); + if( !commit.Empty() ) + commit.Push( wxString::Format( _( "Edit %s" ), m_shape->ShowShape() ), SKIP_CONNECTIVITY ); + return true; } diff --git a/eeschema/dialogs/dialog_sheet_pin_properties.cpp b/eeschema/dialogs/dialog_sheet_pin_properties.cpp index bdd596c5bc..f7e7d8337f 100644 --- a/eeschema/dialogs/dialog_sheet_pin_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_pin_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010 Wayne Stambaugh - * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -133,11 +134,10 @@ bool DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow() bool DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow() { + SCHEMATIC_COMMIT commit( m_frame ); + if( !m_sheetPin->IsNew() ) - { - SCH_SHEET* parentSheet = m_sheetPin->GetParent(); - m_frame->SaveCopyInUndoList( m_frame->GetScreen(), parentSheet, UNDO_REDO::CHANGED, false ); - } + commit.Modify( m_sheetPin->GetParent(), m_frame->GetScreen() ); m_sheetPin->SetText( EscapeString( m_comboName->GetValue(), CTX_NETNAME ) ); @@ -165,24 +165,21 @@ bool DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow() // Currently, eeschema uses only the text width as text size, // and expects text width = text height - m_sheetPin->SetTextSize( VECTOR2I( m_textSize.GetValue(), m_textSize.GetValue() ) ); + m_sheetPin->SetTextSize( VECTOR2I( m_textSize.GetIntValue(), m_textSize.GetIntValue() ) ); m_sheetPin->SetTextColor( m_textColorSwatch->GetSwatchColor() ); - if( m_input->GetValue() ) - m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); - else if( m_output->GetValue() ) - m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); - else if( m_bidirectional->GetValue() ) - m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); - else if( m_triState->GetValue() ) - m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); - else if( m_passive->GetValue() ) - m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); + if( m_input->GetValue() ) m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_INPUT ); + else if( m_output->GetValue() ) m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_OUTPUT ); + else if( m_bidirectional->GetValue() ) m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_BIDI ); + else if( m_triState->GetValue() ) m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_TRISTATE ); + else if( m_passive->GetValue() ) m_sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED ); + + if( !commit.Empty() ) + commit.Push( _( "Edit Sheet Pin" ) ); m_frame->UpdateItem( m_sheetPin, false, true ); m_frame->GetCanvas()->Refresh(); - m_frame->OnModify(); return true; } diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index e40cf86a1e..34be04b0ea 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,15 +28,12 @@ #include #include #include -#include #include -#include -#include #include #include #include +#include #include -#include #include #include #include @@ -437,14 +434,12 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) ) return false; - wxString text; + SCHEMATIC_COMMIT commit( m_frame ); + wxString text; /* save old text in undo list if not already in edit */ if( m_currentItem->GetEditFlags() == 0 ) - { - m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_currentItem, UNDO_REDO::CHANGED, - false, false ); - } + commit.Modify( m_currentItem, m_frame->GetScreen() ); m_frame->GetCanvas()->Refresh(); @@ -561,7 +556,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() STROKE_PARAMS stroke = textBox->GetStroke(); if( m_borderCheckbox->GetValue() ) - stroke.SetWidth( std::max( (long long int) 0, m_borderWidth.GetValue() ) ); + stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) ); else stroke.SetWidth( -1 ); @@ -582,9 +577,11 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() textBox->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); } + if( !commit.Empty() ) + commit.Push( _( "Edit Text" ), SKIP_CONNECTIVITY ); + m_frame->UpdateItem( m_currentItem, false, true ); m_frame->GetCanvas()->Refresh(); - m_frame->OnModify(); return true; } diff --git a/eeschema/dialogs/dialog_wire_bus_properties.cpp b/eeschema/dialogs/dialog_wire_bus_properties.cpp index b80ed8caa6..ae0d68dbfc 100644 --- a/eeschema/dialogs/dialog_wire_bus_properties.cpp +++ b/eeschema/dialogs/dialog_wire_bus_properties.cpp @@ -31,6 +31,7 @@ #include #include #include +#include DIALOG_WIRE_BUS_PROPERTIES::DIALOG_WIRE_BUS_PROPERTIES( SCH_EDIT_FRAME* aParent, @@ -174,15 +175,12 @@ void DIALOG_WIRE_BUS_PROPERTIES::resetDefaults( wxCommandEvent& event ) bool DIALOG_WIRE_BUS_PROPERTIES::TransferDataFromWindow() { - PICKED_ITEMS_LIST pickedItems; - - for( SCH_ITEM* strokeItem : m_items ) - pickedItems.PushItem( ITEM_PICKER( m_frame->GetScreen(), strokeItem, UNDO_REDO::CHANGED ) ); - - m_frame->SaveCopyInUndoList( pickedItems, UNDO_REDO::CHANGED, false, false ); + SCHEMATIC_COMMIT commit( m_frame ); for( SCH_ITEM* item : m_items ) { + commit.Modify( item, m_frame->GetScreen() ); + if( item->HasLineStroke() ) { if( !m_wireWidth.IsIndeterminate() ) @@ -228,8 +226,9 @@ bool DIALOG_WIRE_BUS_PROPERTIES::TransferDataFromWindow() m_frame->UpdateItem( item, false, true ); } + commit.Push( wxString::Format( _( "Edit %s" ), m_items.size() == 1 ? _( "Wire/Bus" ) + : _( "Wires/Buses" ) ) ); m_frame->GetCanvas()->Refresh(); - m_frame->OnModify(); return true; } diff --git a/eeschema/schematic_commit.cpp b/eeschema/schematic_commit.cpp index c5e8d05528..7e201bfc5b 100644 --- a/eeschema/schematic_commit.cpp +++ b/eeschema/schematic_commit.cpp @@ -359,7 +359,10 @@ void SCHEMATIC_COMMIT::pushSchEdit( const wxString& aMessage, int aCommitFlags ) schematic.OnItemsChanged( itemsChanged ); if( !( aCommitFlags & SKIP_UNDO ) && frame ) - frame->SaveCopyInUndoList(undoList, UNDO_REDO::UNSPECIFIED, aCommitFlags & APPEND_UNDO ); + { + frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED, aCommitFlags & APPEND_UNDO, + ( aCommitFlags & SKIP_CONNECTIVITY ) == 0 ); + } m_toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 72c29eabc8..f2389dec1b 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -30,9 +30,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -67,7 +65,7 @@ #include #include #include -#include "project/net_settings.h" +#include class SYMBOL_UNIT_MENU : public ACTION_MENU { @@ -1538,16 +1536,15 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField ) if( dlg.ShowQuasiModal() != wxID_OK ) return; - dlg.UpdateField( aField, &m_frame->GetCurrentSheet() ); + dlg.UpdateField( &commit, aField, &m_frame->GetCurrentSheet() ); if( m_frame->eeconfig()->m_AutoplaceFields.enable || parentType == SCH_SHEET_T ) static_cast( aField->GetParent() )->AutoAutoplaceFields( m_frame->GetScreen() ); if( !commit.Empty() ) - commit.Push( caption ); + commit.Push( caption, SKIP_CONNECTIVITY ); m_frame->UpdateItem( aField, false, true ); - m_frame->OnModify(); // This must go after OnModify() so that the connectivity graph will have been updated. m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );