diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index cf091b05a9..b17e97974b 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -68,7 +68,7 @@ class PCB_BASE_FRAME : public EDA_DRAW_FRAME { public: PCB_DISPLAY_OPTIONS m_DisplayOptions; - wxRealPoint m_UserGridSize; + wxPoint m_UserGridSize; int m_FastGrid1; // 1st fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox) int m_FastGrid2; // 2nd fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox) diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index 72af82937e..ffc0f6f4b5 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -72,8 +72,8 @@ private: FinishDialogSettings(); } - void setGridSize( const wxRealPoint& grid ); - bool getGridSize( wxRealPoint& aGrisSize ); + void setGridSize( const wxPoint& grid ); + bool getGridSize( wxPoint& aGrisSize ); void setGridOrigin( const wxPoint& grid ); bool getGridOrigin( wxPoint& aGridOrigin ); @@ -112,7 +112,7 @@ bool DIALOG_SET_GRID::TransferDataFromWindow() return false; } - wxRealPoint gridSize; + wxPoint gridSize; if( !getGridSize( gridSize ) ) { @@ -137,7 +137,7 @@ bool DIALOG_SET_GRID::TransferDataFromWindow() // User grid BASE_SCREEN* screen = m_parent->GetScreen(); - screen->AddGrid( gridSize, g_UserUnit, ID_POPUP_GRID_USER ); + screen->AddGrid( gridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER ); // If the user grid is the current option, recall SetGrid() // to force new values put in list as current grid value @@ -171,7 +171,7 @@ bool DIALOG_SET_GRID::TransferDataToWindow() } -void DIALOG_SET_GRID::setGridSize( const wxRealPoint& grid ) +void DIALOG_SET_GRID::setGridSize( const wxPoint& grid ) { wxString msg; @@ -183,7 +183,7 @@ void DIALOG_SET_GRID::setGridSize( const wxRealPoint& grid ) } -bool DIALOG_SET_GRID::getGridSize( wxRealPoint& aGridSize ) +bool DIALOG_SET_GRID::getGridSize( wxPoint& aGridSize ) { double x, y; @@ -198,8 +198,6 @@ bool DIALOG_SET_GRID::getGridSize( wxRealPoint& aGridSize ) if( x < MIN_GRID_SIZE || x > MAX_GRID_SIZE ) return false; - aGridSize.x = x; - const wxString& y_str = m_OptGridSizeY->GetValue(); if( !y_str.ToDouble( &y ) ) @@ -211,7 +209,8 @@ bool DIALOG_SET_GRID::getGridSize( wxRealPoint& aGridSize ) if( y < MIN_GRID_SIZE || y > MAX_GRID_SIZE ) return false; - aGridSize.y = y; + aGridSize.x = KiROUND( x ); + aGridSize.y = KiROUND( y ); return true; } diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 3313076f57..326b8ebabf 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -278,7 +278,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax ); GetScreen()->SetCurItem( NULL ); - GetScreen()->AddGrid( m_UserGridSize, g_UserUnit, ID_POPUP_GRID_USER ); + GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); // In modedit, set the default paper size to A4: diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index e3b0ff491d..7db183b600 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -109,7 +109,7 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame { m_Pcb = NULL; - m_UserGridSize = wxRealPoint( 100.0, 100.0 ); + m_UserGridSize = wxPoint( 10 * IU_PER_MILS, 10 * IU_PER_MILS ); m_Collector = new GENERAL_COLLECTOR(); m_FastGrid1 = 0; @@ -840,8 +840,15 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) wxString baseCfgName = GetName(); - aCfg->Read( baseCfgName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 ); - aCfg->Read( baseCfgName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 ); + EDA_UNITS_T userGridUnits; + aCfg->Read( baseCfgName + UserGridUnitsEntry, ( int* )&userGridUnits, ( int )INCHES ); + + double tmp; + aCfg->Read( baseCfgName + UserGridSizeXEntry, &tmp, 0.01 ); + m_UserGridSize.x = From_User_Unit( userGridUnits, tmp ); + + aCfg->Read( baseCfgName + UserGridSizeYEntry, &tmp, 0.01 ); + m_UserGridSize.y = From_User_Unit( userGridUnits, tmp ); aCfg->Read( baseCfgName + DisplayPadFillEntry, &m_DisplayOptions.m_DisplayPadFill, true ); aCfg->Read( baseCfgName + DisplayViaFillEntry, &m_DisplayOptions.m_DisplayViaFill, true ); @@ -864,8 +871,9 @@ void PCB_BASE_FRAME::SaveSettings( wxConfigBase* aCfg ) wxString baseCfgName = GetName(); - aCfg->Write( baseCfgName + UserGridSizeXEntry, m_UserGridSize.x ); - aCfg->Write( baseCfgName + UserGridSizeYEntry, m_UserGridSize.y ); + aCfg->Write( baseCfgName + UserGridSizeXEntry, To_User_Unit( g_UserUnit, m_UserGridSize.x ) ); + aCfg->Write( baseCfgName + UserGridSizeYEntry, To_User_Unit( g_UserUnit, m_UserGridSize.y ) ); + aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )g_UserUnit ); aCfg->Write( baseCfgName + DisplayPadFillEntry, m_DisplayOptions.m_DisplayPadFill ); aCfg->Write( baseCfgName + DisplayViaFillEntry, m_DisplayOptions.m_DisplayViaFill ); aCfg->Write( baseCfgName + DisplayPadNumberEntry, m_DisplayOptions.m_DisplayPadNum ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 2498e6482f..f550c9c9cf 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -378,7 +378,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - GetScreen()->AddGrid( m_UserGridSize, g_UserUnit, ID_POPUP_GRID_USER ); + GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); if( m_canvas )