Fix saving undo/redo limits in Eeschema.

This commit is contained in:
Chris Pavlina 2015-08-05 20:10:52 -04:00 committed by Wayne Stambaugh
parent ecb046ad0e
commit fa29c62277
11 changed files with 39 additions and 22 deletions

View File

@ -676,8 +676,8 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
if( m_LastGridSizeId < 0 ) if( m_LastGridSizeId < 0 )
m_LastGridSizeId = 0; m_LastGridSizeId = 0;
GetScreen()->SetMaxUndoItems( aCfg->Read( baseCfgName + MaxUndoItemsEntry, m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
long( DEFAULT_MAX_UNDO_ITEMS ) ) ); long( DEFAULT_MAX_UNDO_ITEMS ) );
} }

View File

@ -430,7 +430,9 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
sheet->SetName( tmp ); sheet->SetName( tmp );
sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ), (long) newtimestamp ) ); sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ), (long) newtimestamp ) );
sheet->SetScreen( new SCH_SCREEN( &Kiway() ) ); SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
screen->SetMaxUndoItems( m_UndoRedoCountMax );
sheet->SetScreen( screen );
sheet->GetScreen()->SetFileName( sheet->GetFileName() ); sheet->GetScreen()->SetFileName( sheet->GetFileName() );
} }
// clear annotation and init new time stamp for the new components // clear annotation and init new time stamp for the new components

View File

@ -208,13 +208,14 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
icon.CopyFromBitmap( KiBitmap( libedit_icon_xpm ) ); icon.CopyFromBitmap( KiBitmap( libedit_icon_xpm ) );
SetIcon( icon ); SetIcon( icon );
LoadSettings( config() );
SetScreen( new SCH_SCREEN( aKiway ) ); SetScreen( new SCH_SCREEN( aKiway ) );
GetScreen()->m_Center = true; GetScreen()->m_Center = true;
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
SetCrossHairPosition( wxPoint( 0, 0 ) ); SetCrossHairPosition( wxPoint( 0, 0 ) );
LoadSettings( config() );
// Ensure m_LastGridSizeId is an offset inside the allowed schematic range // Ensure m_LastGridSizeId is an offset inside the allowed schematic range
if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 ) if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;

View File

@ -66,6 +66,9 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
if( aFullFileName.IsEmpty() ) if( aFullFileName.IsEmpty() )
return false; return false;
// Place the undo limit into the screen
aScreen->SetMaxUndoItems( m_UndoRedoCountMax );
// If path is relative, this expands it from the project directory. // If path is relative, this expands it from the project directory.
wxString fname = Prj().AbsolutePath( aFullFileName ); wxString fname = Prj().AbsolutePath( aFullFileName );

View File

@ -755,9 +755,9 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
{ {
bool success = true; bool success = true;
SCH_SCREEN* screen = NULL;
if( !m_screen ) if( !m_screen )
{ {
SCH_SCREEN* screen = NULL;
g_RootSheet->SearchHierarchy( m_fileName, &screen ); g_RootSheet->SearchHierarchy( m_fileName, &screen );
if( screen ) if( screen )

View File

@ -348,8 +348,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
SetSpiceAddReferencePrefix( false ); SetSpiceAddReferencePrefix( false );
SetSpiceUseNetcodeAsNetname( false ); SetSpiceUseNetcodeAsNetname( false );
CreateScreens();
// Give an icon // Give an icon
wxIcon icon; wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
@ -361,6 +359,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
LoadSettings( config() ); LoadSettings( config() );
CreateScreens();
// Ensure m_LastGridSizeId is an offset inside the allowed schematic grid range // Ensure m_LastGridSizeId is an offset inside the allowed schematic grid range
if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
m_LastGridSizeId = default_grid; m_LastGridSizeId = default_grid;
@ -523,7 +523,9 @@ void SCH_EDIT_FRAME::CreateScreens()
if( g_RootSheet->GetScreen() == NULL ) if( g_RootSheet->GetScreen() == NULL )
{ {
g_RootSheet->SetScreen( new SCH_SCREEN( &Kiway() ) ); SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
screen->SetMaxUndoItems( m_UndoRedoCountMax );
g_RootSheet->SetScreen( screen );
SetScreen( g_RootSheet->GetScreen() ); SetScreen( g_RootSheet->GetScreen() );
} }
@ -533,7 +535,11 @@ void SCH_EDIT_FRAME::CreateScreens()
m_CurrentSheet->Push( g_RootSheet ); m_CurrentSheet->Push( g_RootSheet );
if( GetScreen() == NULL ) if( GetScreen() == NULL )
SetScreen( new SCH_SCREEN( &Kiway() ) ); {
SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
screen->SetMaxUndoItems( m_UndoRedoCountMax );
SetScreen( screen );
}
GetScreen()->SetZoom( 32.0 ); GetScreen()->SetZoom( 32.0 );
} }

View File

@ -141,6 +141,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy )
else // New file. else // New file.
{ {
aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) ); aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
aSheet->GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
aSheet->GetScreen()->SetFileName( newFilename ); aSheet->GetScreen()->SetFileName( newFilename );
} }
} }

View File

@ -31,15 +31,12 @@
#ifndef CLASS_BASE_SCREEN_H_ #ifndef CLASS_BASE_SCREEN_H_
#define CLASS_BASE_SCREEN_H_ #define CLASS_BASE_SCREEN_H_
#include <draw_frame.h>
#include <base_struct.h> #include <base_struct.h>
#include <class_undoredo_container.h> #include <class_undoredo_container.h>
#include <block_commande.h> #include <block_commande.h>
#include <common.h> #include <common.h>
#include <id.h> #include <id.h>
#include <climits>
#define DEFAULT_MAX_UNDO_ITEMS 0
#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
/** /**
* Class GRID_TYPE * Class GRID_TYPE

View File

@ -27,10 +27,14 @@
#include <wxstruct.h> #include <wxstruct.h>
#include <kiway_player.h> #include <kiway_player.h>
#include <climits>
class wxSingleInstanceChecker; class wxSingleInstanceChecker;
class EDA_HOTKEY; class EDA_HOTKEY;
#define DEFAULT_MAX_UNDO_ITEMS 0
#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
/** /**
* Class EDA_DRAW_FRAME * Class EDA_DRAW_FRAME
* is the base class for create windows for drawing purpose. The Eeschema, Pcbnew and * is the base class for create windows for drawing purpose. The Eeschema, Pcbnew and
@ -68,6 +72,8 @@ protected:
double m_zoomLevelCoeff; ///< a suitable value to convert the internal zoom scaling factor double m_zoomLevelCoeff; ///< a suitable value to convert the internal zoom scaling factor
// to a zoom level value which rougly gives 1.0 when the board/schematic // to a zoom level value which rougly gives 1.0 when the board/schematic
// is at scale = 1 // is at scale = 1
int m_UndoRedoCountMax; ///< default Undo/Redo command Max depth, to be handed
// to screens
/// The area to draw on. /// The area to draw on.
EDA_DRAW_PANEL* m_canvas; EDA_DRAW_PANEL* m_canvas;

View File

@ -246,10 +246,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true ); m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
GetScreen()->SetCurItem( NULL );
LoadSettings( config() ); LoadSettings( config() );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
GetScreen()->SetCurItem( NULL );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );

View File

@ -352,15 +352,16 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
SetIcon( icon ); SetIcon( icon );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
// PCB drawings start in the upper left corner.
GetScreen()->m_Center = false;
// LoadSettings() *after* creating m_LayersManager, because LoadSettings() // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
// initialize parameters in m_LayersManager // initialize parameters in m_LayersManager
LoadSettings( config() ); LoadSettings( config() );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
// PCB drawings start in the upper left corner.
GetScreen()->m_Center = false;
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );