diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index fcffdc9db0..1b5d3ad08e 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -676,8 +676,8 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg ) if( m_LastGridSizeId < 0 ) m_LastGridSizeId = 0; - GetScreen()->SetMaxUndoItems( aCfg->Read( baseCfgName + MaxUndoItemsEntry, - long( DEFAULT_MAX_UNDO_ITEMS ) ) ); + m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry, + long( DEFAULT_MAX_UNDO_ITEMS ) ); } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index b4135fd66e..c898c386bb 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -430,7 +430,9 @@ bool SCH_EDIT_FRAME::AppendOneEEProject() sheet->SetName( tmp ); 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() ); } // clear annotation and init new time stamp for the new components diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index d368dbc02b..e846734714 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -208,13 +208,14 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : icon.CopyFromBitmap( KiBitmap( libedit_icon_xpm ) ); SetIcon( icon ); + LoadSettings( config() ); + SetScreen( new SCH_SCREEN( aKiway ) ); GetScreen()->m_Center = true; + GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax ); SetCrossHairPosition( wxPoint( 0, 0 ) ); - LoadSettings( config() ); - // Ensure m_LastGridSizeId is an offset inside the allowed schematic range 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; diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 4afc8fd9c4..5d4e3458a9 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -66,6 +66,9 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi if( aFullFileName.IsEmpty() ) return false; + // Place the undo limit into the screen + aScreen->SetMaxUndoItems( m_UndoRedoCountMax ); + // If path is relative, this expands it from the project directory. wxString fname = Prj().AbsolutePath( aFullFileName ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index c9afde736d..ddce303fa4 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -755,9 +755,9 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame ) { bool success = true; + SCH_SCREEN* screen = NULL; if( !m_screen ) { - SCH_SCREEN* screen = NULL; g_RootSheet->SearchHierarchy( m_fileName, &screen ); if( screen ) diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 15ee725e75..d0aa2f40d4 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -348,8 +348,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): SetSpiceAddReferencePrefix( false ); SetSpiceUseNetcodeAsNetname( false ); - CreateScreens(); - // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) ); @@ -361,6 +359,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): LoadSettings( config() ); + CreateScreens(); + // Ensure m_LastGridSizeId is an offset inside the allowed schematic grid range if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) m_LastGridSizeId = default_grid; @@ -523,7 +523,9 @@ void SCH_EDIT_FRAME::CreateScreens() 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() ); } @@ -533,7 +535,11 @@ void SCH_EDIT_FRAME::CreateScreens() m_CurrentSheet->Push( g_RootSheet ); 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 ); } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index e532ec4df6..d4fb0f2b20 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -141,6 +141,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy ) else // New file. { aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) ); + aSheet->GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax ); aSheet->GetScreen()->SetFileName( newFilename ); } } diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 82da9ff86a..fe77668c67 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -31,15 +31,12 @@ #ifndef CLASS_BASE_SCREEN_H_ #define CLASS_BASE_SCREEN_H_ +#include #include #include #include #include #include -#include - -#define DEFAULT_MAX_UNDO_ITEMS 0 -#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2) /** * Class GRID_TYPE diff --git a/include/draw_frame.h b/include/draw_frame.h index d787a4f52e..d88ca5cdf1 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -27,10 +27,14 @@ #include #include +#include class wxSingleInstanceChecker; class EDA_HOTKEY; +#define DEFAULT_MAX_UNDO_ITEMS 0 +#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2) + /** * Class EDA_DRAW_FRAME * 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 // to a zoom level value which rougly gives 1.0 when the board/schematic // is at scale = 1 + int m_UndoRedoCountMax; ///< default Undo/Redo command Max depth, to be handed + // to screens /// The area to draw on. EDA_DRAW_PANEL* m_canvas; diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 4337a8d686..79d68f945e 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -246,10 +246,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true ); - SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) ); - - GetScreen()->SetCurItem( NULL ); 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()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 33faef8e6c..9f84003f89 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -352,15 +352,16 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) ); 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() // initialize parameters in m_LayersManager 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 ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );