From a3f83d771f7f3d304fa03049561cb644a1d6ac09 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 6 May 2012 18:55:51 +0200 Subject: [PATCH] Fix grid selection issue when starting Eeschema or Gerbview: Eeschema (also Libedit and Libview) starts always to the default grid (50 mils) Gerbview starts with the last selected grid, but the validity is tested. In Pcbnew the grid value is always displayed, so it should always be good. --- eeschema/libeditframe.cpp | 9 ++++----- eeschema/schframe.cpp | 7 ++----- eeschema/viewlib_frame.cpp | 3 +++ gerbview/gerbview_frame.cpp | 5 +++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index b130655020..fc403a8fdf 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -204,6 +204,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, m_tempCopyComponent = NULL; m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr; m_editPinsPerPartOrConvert = false; + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; wxIcon icon; @@ -219,12 +220,10 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, LoadSettings(); - // Initialize grid id to a default value if not found in config or bad: - if( (m_LastGridSizeId <= 0) - || ( m_LastGridSizeId < (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000) ) ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; - SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); + + // Initialize grid id to the default value 50 mils: + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); if( m_canvas ) diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 1a146a72da..ec6207c5ee 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -216,11 +216,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father, /* Get config */ LoadSettings(); - // Initialize grid id to a default value if not found in config or bad: - if( (m_LastGridSizeId <= 0) - || ( m_LastGridSizeId < (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000) ) ) - m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; - + // Initialize grid id to the default value (50 mils): + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( m_canvas ) diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 80fae3b41e..984cb11737 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -130,6 +130,9 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); + + // Initialize grid id to the default value (50 mils): + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateHToolbar(); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 669932a48e..86de733f2e 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -107,6 +107,11 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, // initialize parameters in m_LayersManager LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); + + if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_1000 ) + m_LastGridSizeId = m_LastGridSizeId; + if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM ) + m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateMenuBar();