Upgrade some dialogs to SCHEMATIC_COMMIT.

This commit is contained in:
Jeff Young 2023-06-07 23:45:06 +01:00
parent e9dc00cda3
commit dcfd426333
16 changed files with 140 additions and 156 deletions

View File

@ -23,17 +23,13 @@
*/
#include <core/kicad_algo.h>
#include <eeschema_id.h>
#include <general.h>
#include <lib_item.h>
#include <sch_bus_entry.h>
#include <sch_symbol.h>
#include <sch_edit_frame.h>
#include <sch_junction.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_screen.h>
#include <sch_sheet.h>
#include <sch_view.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>

View File

@ -34,6 +34,7 @@
#include <schematic.h>
#include <template_fieldnames.h>
#include <widgets/wx_html_report_panel.h>
#include <schematic_commit.h>
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<SCH_EDIT_FRAME*>( GetParent() );
wxBusyCursor dummy;
SCH_EDIT_FRAME* parent = dynamic_cast<SCH_EDIT_FRAME*>( 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<SCH_EDIT_FRAME*>( 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<SCH_SYMBOL*,
SYMBOL_CHANGE_INFO>& aSymbols )
int DIALOG_CHANGE_SYMBOLS::processSymbols( SCHEMATIC_COMMIT* aCommit,
const std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO>& aSymbols )
{
wxCHECK( !aSymbols.empty(), 0 );
@ -561,8 +565,6 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( const std::map<SCH_SYMBOL*,
}
}
bool appendUndo = false;
// Removing the symbol needs to be done before the LIB_SYMBOL is changed to prevent stale
// library symbols in the schematic file.
for( const auto& [ symbol, symbol_change_info ] : symbols )
@ -574,8 +576,7 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( const std::map<SCH_SYMBOL*,
wxCHECK( screen, 0 );
screen->Remove( symbol );
frame->SaveCopyInUndoList( screen, symbol, UNDO_REDO::CHANGED, appendUndo );
appendUndo = true;
aCommit->Modify( symbol, screen );
}
for( const auto& [ symbol, symbol_change_info ] : symbols )

View File

@ -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<SCH_SYMBOL*, SYMBOL_CHANGE_INFO>& aSymbols );
int processMatchingSymbols( SCHEMATIC_COMMIT* aCommit );
int processSymbols( SCHEMATIC_COMMIT* aCommit,
const std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO>& aSymbols );
wxString getSymbolReferences( SCH_SYMBOL& aSymbol, const LIB_ID& aNewId );
SCH_SYMBOL* m_symbol;

View File

@ -32,7 +32,6 @@
#include <confirm.h>
#include <common.h>
#include <string_utils.h>
#include <sch_base_frame.h>
#include <sch_edit_frame.h>
#include <ee_collectors.h>
#include <sch_symbol.h>
@ -42,6 +41,7 @@
#include <symbol_library.h>
#include <sch_validators.h>
#include <schematic.h>
#include <schematic_commit.h>
#include <dialog_field_properties.h>
#include <sch_text.h>
#include <scintilla_tricks.h>
@ -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<SCH_EDIT_FRAME*>( GetParent() );
SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( 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<SCH_SYMBOL*> 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 );

View File

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

View File

@ -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<EDA_TEXT*>( 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<SCH_SHEET*>( 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();
}

View File

@ -26,8 +26,7 @@
#include <sch_edit_frame.h>
#include <sch_bitmap.h>
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <schematic_commit.h>
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;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <settings/settings_manager.h>
#include <sch_edit_frame.h>
#include <widgets/color_swatch.h>
#include <schematic_commit.h>
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;
}

View File

@ -29,7 +29,6 @@
#include <widgets/color_swatch.h>
#include <settings/color_settings.h>
#include <sch_edit_frame.h>
#include <sch_validators.h>
#include <tool/tool_manager.h>
#include <gr_text.h>
#include <confirm.h>
@ -37,10 +36,9 @@
#include <dialogs/html_message_box.h>
#include <dialog_label_properties.h>
#include <string_utils.h>
#include <project/net_settings.h>
#include <project/project_file.h>
#include <kiface_base.h>
#include <sch_label.h>
#include <schematic_commit.h>
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;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Seth Hillbrand <hillbrand@ucdavis.edu>
* 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 <sch_edit_frame.h>
#include <stroke_params.h>
#include <widgets/color_swatch.h>
#include <schematic_commit.h>
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;
}

View File

@ -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 <sch_shape.h>
#include <dialog_shape_properties.h>
#include <settings/color_settings.h>
#include <schematic_commit.h>
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;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <sch_validators.h>
#include <schematic_commit.h>
#include <dialog_sheet_pin_properties.h>
#include <dialogs/html_message_box.h>
#include <string_utils.h>
@ -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;
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* 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 <widgets/font_choice.h>
#include <widgets/color_swatch.h>
#include <widgets/wx_combobox.h>
#include <base_units.h>
#include <settings/color_settings.h>
#include <tool/tool_manager.h>
#include <general.h>
#include <sch_textbox.h>
#include <confirm.h>
#include <schematic.h>
#include <schematic_commit.h>
#include <dialogs/html_message_box.h>
#include <string_utils.h>
#include <scintilla_tricks.h>
#include <dialog_text_properties.h>
#include <gr_text.h>
@ -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;
}

View File

@ -31,6 +31,7 @@
#include <sch_edit_frame.h>
#include <stroke_params.h>
#include <widgets/color_swatch.h>
#include <schematic_commit.h>
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;
}

View File

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

View File

@ -30,9 +30,7 @@
#include <tools/sch_move_tool.h>
#include <tools/sch_drawing_tools.h>
#include <ee_actions.h>
#include <bitmaps.h>
#include <confirm.h>
#include <eda_item.h>
#include <string_utils.h>
#include <sch_item.h>
#include <sch_symbol.h>
@ -67,7 +65,7 @@
#include <symbol_editor_settings.h>
#include <core/kicad_algo.h>
#include <wx/textdlg.h>
#include "project/net_settings.h"
#include <project/net_settings.h>
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<SCH_ITEM*>( 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 );