Modified properties dialog to take advantage of BOARD_COMMIT class.

This commit is contained in:
Maciej Suminski 2016-06-20 15:46:58 +02:00
parent 38177b70b9
commit c4be379b31
11 changed files with 167 additions and 134 deletions

View File

@ -41,6 +41,7 @@
#include <wxPcbStruct.h>
#include <base_units.h>
#include <project.h>
#include <board_commit.h>
#include <class_module.h>
#include <class_text_mod.h>
@ -610,6 +611,9 @@ bool DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow()
wxPoint modpos;
wxString msg;
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_CurrentModule );
if( !Validate() || !DIALOG_MODULE_BOARD_EDITOR_BASE::TransferDataFromWindow() ||
!m_PanelProperties->TransferDataFromWindow() )
{
@ -623,10 +627,6 @@ bool DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow()
return false;
}
if( m_CurrentModule->GetFlags() == 0 ) // this is a simple edition, we
// must create an undo entry
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_CHANGED );
if( m_DC )
{
m_Parent->GetCanvas()->CrossHairOff( m_DC );
@ -741,7 +741,9 @@ bool DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow()
m_CurrentModule->CalculateBoundingBox();
m_Parent->OnModify();
// This is a simple edition, we must create an undo entry
if( m_CurrentModule->GetFlags() == 0 )
commit.Push( _( "Modify module properties" ) );
SetReturnCode( PRM_EDITOR_EDIT_OK );

View File

@ -43,6 +43,7 @@
#include <macros.h>
#include <validators.h>
#include <kicad_string.h>
#include <board_commit.h>
#include <class_module.h>
#include <class_text_mod.h>
@ -440,6 +441,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& event )
void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
{
BOARD_COMMIT commit( m_parent );
wxString msg;
// First, test for invalid chars in module name
@ -465,7 +467,8 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
return;
}
m_parent->SaveCopyInUndoList( m_currentModule, UR_CHANGED );
commit.Modify( m_currentModule );
m_currentModule->SetLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
switch( m_AttributsCtrl->GetSelection() )
@ -522,7 +525,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
m_currentModule->CalculateBoundingBox();
m_parent->OnModify();
commit.Push( _( "Modify module properties" ) );
EndModal( 1 );
}

View File

@ -41,6 +41,7 @@
#include <wxBasePcbFrame.h>
#include <base_units.h>
#include <wx/numformatter.h>
#include <board_commit.h>
#include <class_module.h>
#include <class_text_mod.h>
@ -207,11 +208,13 @@ bool DialogEditModuleText::TransferDataToWindow()
bool DialogEditModuleText::TransferDataFromWindow()
{
BOARD_COMMIT commit( m_parent );
if( !Validate() || !DialogEditModuleText_base::TransferDataFromWindow() )
return false;
if( m_module )
m_parent->SaveCopyInUndoList( m_module, UR_CHANGED );
commit.Modify( m_currentText );
#ifndef USE_WX_OVERLAY
if( m_dc ) //Erase old text on screen
@ -325,7 +328,7 @@ bool DialogEditModuleText::TransferDataFromWindow()
m_parent->Refresh();
#endif
m_parent->OnModify();
commit.Push( _( "Modify module text" ) );
if( m_module )
m_module->SetLastEditTime();

View File

@ -44,6 +44,7 @@
#include <class_board_design_settings.h>
#include <base_units.h>
#include <wx/valnum.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_drawsegment.h>
@ -227,7 +228,8 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
m_parent->SaveCopyInUndoList( m_item, UR_CHANGED );
BOARD_COMMIT commit( m_parent );
commit.Modify( m_item );
wxString msg;
@ -264,7 +266,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow()
m_item->SetAngle( m_AngleValue * 10.0 );
}
m_parent->OnModify();
commit.Push( _( "Modify drawing properties" ) );
if( m_DC )
m_item->Draw( m_parent->GetCanvas(), m_DC, GR_OR );

View File

@ -43,6 +43,7 @@
#include <module_editor_frame.h>
#include <base_units.h>
#include <wx/valnum.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_module.h>
@ -212,6 +213,9 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnLayerChoice( wxCommandEvent& even
bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataFromWindow()
{
BOARD_COMMIT commit( m_parent );
commit.Modify( m_module );
if( !DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
@ -223,14 +227,10 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataFromWindow()
* confirmation is requested */
if( !IsOK( NULL,
_( "The graphic item will be on a copper layer. This is very dangerous. Are you sure?" ) ) )
return false;;
return false;
}
m_parent->SaveCopyInUndoList( m_module, UR_CHANGED );
m_module->SetLastEditTime();
wxString msg;
wxPoint coord;
msg = m_Center_StartXCtrl->GetValue();
@ -262,7 +262,8 @@ bool DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataFromWindow()
m_item->SetAngle( m_AngleValue * 10.0 );
}
m_parent->OnModify();
commit.Push( _( "Modify module graphic item" ) );
m_parent->SetMsgPanel( m_item );
return true;

View File

@ -38,6 +38,7 @@
#include <wxBasePcbFrame.h>
#include <pcbcommon.h>
#include <base_units.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_module.h>
@ -921,6 +922,8 @@ bool DIALOG_PAD_PROPERTIES::TransferDataToWindow()
bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
{
BOARD_COMMIT commit( m_parent );
if( !wxDialog::TransferDataFromWindow() )
return false;
@ -940,12 +943,14 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
// m_padMaster is a pattern: ensure there is no net for this pad:
m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
if( m_currentPad ) // Set current Pad parameters
{
if( !m_currentPad ) // Set current Pad parameters
return false;
commit.Modify( m_currentPad );
wxSize size;
MODULE* footprint = m_currentPad->GetParent();
m_parent->SaveCopyInUndoList( footprint, UR_CHANGED );
footprint->SetLastEditTime();
// redraw the area where the pad was, without pad (delete pad on screen)
@ -1045,8 +1050,8 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
// redraw the area where the pad was
m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
m_parent->OnModify();
}
commit.Push( _( "Modify pad" ) );
if( rastnestIsChanged ) // The net ratsnest must be recalculated
m_board->m_Status_Pcb = 0;

View File

@ -43,6 +43,7 @@
#include <wx/wx.h>
#include <dialog_pcb_text_properties_base.h>
#include <class_pcb_layer_box_selector.h>
#include <board_commit.h>
class PCB_EDIT_FRAME;
@ -188,10 +189,12 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow()
bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
{
if( !DIALOG_PCB_TEXT_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_SelectedPCBText );
// Test for acceptable layer.
// Incorrect layer can happen for old boards,
// having texts on edge cut layer for instance
@ -206,8 +209,7 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
// If no other command in progress, prepare undo command
// (for a command in progress, will be made later, at the completion of command)
if( m_SelectedPCBText->GetFlags() == 0 )
m_Parent->SaveCopyInUndoList( m_SelectedPCBText, UR_CHANGED );
bool pushCommit = ( m_SelectedPCBText->GetFlags() == 0 );
/* set flag in edit to force undo/redo/abort proper operation,
* and avoid new calls to SaveCopyInUndoList for the same text
@ -303,9 +305,11 @@ bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow()
m_SelectedPCBText->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
}
#else
m_parent->Refresh();
m_Parent->Refresh();
#endif
m_Parent->OnModify();
if( pushCommit )
commit.Push( _( "Change text properties" ) );
return true;
}

View File

@ -29,6 +29,8 @@
#include <wxPcbStruct.h>
#include <confirm.h>
#include <board_commit.h>
DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems ) :
DIALOG_TRACK_VIA_PROPERTIES_BASE( aParent ), m_items( aItems ),
m_trackStartX( aParent, m_TrackStartXCtrl, m_TrackStartXUnit ),
@ -202,7 +204,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
}
bool DIALOG_TRACK_VIA_PROPERTIES::Apply()
bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit )
{
if( !check() )
return false;
@ -214,6 +216,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::Apply()
for( int i = 0; i < m_items.Size(); ++i )
{
BOARD_ITEM* item = m_items.Item<BOARD_ITEM>( i );
aCommit.Modify( item );
switch( item->Type() )
{

View File

@ -28,6 +28,8 @@
#include <layers_id_colors_and_visibility.h>
struct SELECTION;
class COMMIT;
class PCB_BASE_FRAME;
class DIALOG_TRACK_VIA_PROPERTIES : public DIALOG_TRACK_VIA_PROPERTIES_BASE
@ -36,7 +38,7 @@ public:
DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems );
///> Applies values from the dialog to the selected items.
bool Apply();
bool Apply( COMMIT& aCommit );
private:
void onClose( wxCloseEvent& aEvent );

View File

@ -37,6 +37,7 @@
#include <dialog_helpers.h>
#include <macros.h>
#include <base_units.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_pcb_text.h>
@ -161,6 +162,8 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
{
BOARD_COMMIT commit( m_parent );
LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() );
if( !m_parent->GetBoard()->IsLayerEnabled( newlayer ) )
@ -177,7 +180,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
}
#endif
m_parent->SaveCopyInUndoList(m_currentDimension, UR_CHANGED);
commit.Modify( m_currentDimension );
if( m_Name->GetValue() != wxEmptyString )
{
@ -228,7 +231,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
m_parent->Refresh();
#endif
m_parent->OnModify();
commit.Push( _( "Modifed dimensions properties" ) );
event.Skip(); // ends returning wxID_OK (default behavior)
}

View File

@ -34,6 +34,7 @@
#include <dialog_helpers.h>
#include <base_units.h>
#include <gr_basic.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_mire.h>
@ -128,12 +129,14 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event )
*/
void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
{
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_Target );
if( m_DC )
m_Target->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR );
// Save old item in undo list, if is is not currently edited (will be later if so)
if( m_Target->GetFlags() == 0 )
m_Parent->SaveCopyInUndoList( m_Target, UR_CHANGED );
bool pushCommit = ( m_Target->GetFlags() == 0 );
if( m_Target->GetFlags() != 0 ) // other edition in progress (MOVE, NEW ..)
m_Target->SetFlags( IN_EDIT ); // set flag in edit to force
@ -150,7 +153,9 @@ void TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick( wxCommandEvent& event )
if( m_DC )
m_Target->Draw( m_Parent->GetCanvas(), m_DC, ( m_Target->IsMoving() ) ? GR_XOR : GR_OR );
m_Parent->OnModify();
if( pushCommit )
commit.Push( _( "Modified alignment target" ) );
EndModal( 1 );
}