Fix some issues created by rev 5632:

*  Use only double to store zoom levels in class BASE_SCREEN (int type is not working for eeschema or page layout editor) (this fix Bug #1450551, Assertion failed on wxRound() when zooming)
*  Fix crash in all apps but Pcbnew when a grid or a zoom was selected from the popup menu.
*  Modify default hotkeys for Next Grid and Previous Grid: the initial key was a dead key, not suitable as hotkey. the 'N' and Shift N keys are used instead (with a change for unfill zone hotkey)
*  Modify code in EDA_DRAW_FRAME::SetNextGrid() and EDA_DRAW_FRAME::SetPreviousGrid() to make them compatible with other editors than the board editor.
This commit is contained in:
jean-pierre charras 2015-05-01 11:31:23 +02:00
parent 82dff76530
commit 5a02b91e5f
7 changed files with 37 additions and 27 deletions

View File

@ -369,7 +369,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
{
if( m_gridSelectBox == NULL )
if( m_gridSelectBox == NULL ) // Should no happen
return;
/*
@ -526,35 +526,44 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
void EDA_DRAW_FRAME::SetNextGrid()
{
if( m_gridSelectBox )
SetPresetGrid( ( m_gridSelectBox->GetSelection() + 1 ) % m_gridSelectBox->GetCount() );
BASE_SCREEN * screen = GetScreen();
int grid_cnt = screen->GetGridCount();
int new_grid_idx = screen->GetGridId() - ID_POPUP_GRID_LEVEL_1000 + 1;
if( new_grid_idx >= grid_cnt )
new_grid_idx = 0;
SetPresetGrid( new_grid_idx );
}
void EDA_DRAW_FRAME::SetPrevGrid()
{
if( m_gridSelectBox )
{
int idx = m_gridSelectBox->GetSelection();
BASE_SCREEN * screen = GetScreen();
int grid_cnt = screen->GetGridCount();
if( --idx < 0 )
idx = m_gridSelectBox->GetCount() - 1;
int new_grid_idx = screen->GetGridId() - ID_POPUP_GRID_LEVEL_1000 - 1;
SetPresetGrid( idx );
}
if( new_grid_idx < 0 )
new_grid_idx = grid_cnt - 1;
SetPresetGrid( new_grid_idx );
}
void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
{
if( m_gridSelectBox )
{
if( aIndex < 0 || aIndex >= (int) m_gridSelectBox->GetCount() )
{
wxASSERT_MSG( false, "Invalid grid index" );
return;
}
if( m_gridSelectBox )
m_gridSelectBox->SetSelection( aIndex );
}
// Be sure m_LastGridSizeId is up to date.
m_LastGridSizeId = aIndex;

View File

@ -223,6 +223,7 @@ void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
return;
}
if( m_zoomSelectBox )
m_zoomSelectBox->SetSelection( aIndex );
if( screen->SetZoom( screen->m_ZoomList[aIndex] ) )
@ -238,7 +239,7 @@ void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
{
int maxZoomIds;
int zoom;
double zoom;
wxString msg;
BASE_SCREEN* screen = m_canvas->GetScreen();

View File

@ -215,7 +215,7 @@ public:
int m_ScreenNumber;
int m_NumberOfScreens;
std::vector<int> m_ZoomList; ///< standard zoom (i.e. scale) coefficients.
std::vector<double> m_ZoomList; ///< standard zoom (i.e. scale) coefficients.
bool m_IsPrinting;
public:

View File

@ -141,7 +141,7 @@ static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Cairo Canvas" ),
static EDA_HOTKEY HkZoneFillOrRefill( _HKI( "Fill or Refill All Zones" ),
HK_ZONE_FILL_OR_REFILL, 'B' );
static EDA_HOTKEY HkZoneRemoveFilled( _HKI( "Remove Filled Areas in All Zones" ),
HK_ZONE_REMOVE_FILLED, 'N' );
HK_ZONE_REMOVE_FILLED, 'B' + GR_KB_CTRL );
/* Fit on Screen */
#if !defined( __WXMAC__ )
static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
@ -203,10 +203,10 @@ static EDA_HOTKEY HkSwitchGridToFastGrid2( _HKI( "Switch Grid To Fast Grid2" ),
HK_SWITCH_GRID_TO_FASTGRID2, GR_KB_ALT + '2' );
static EDA_HOTKEY HkSwitchGridToNext( _HKI( "Switch Grid To Next" ),
HK_SWITCH_GRID_TO_NEXT, '`' );
HK_SWITCH_GRID_TO_NEXT, 'N' );
static EDA_HOTKEY HkSwitchGridToPrevious( _HKI( "Switch Grid To Previous" ),
HK_SWITCH_GRID_TO_PREVIOUS, '`' + GR_KB_CTRL );
HK_SWITCH_GRID_TO_PREVIOUS, 'N' + GR_KB_SHIFT );
static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' + GR_KB_CTRL );
static EDA_HOTKEY HkTrackDisplayMode( _HKI( "Track Display Mode" ),

View File

@ -312,11 +312,11 @@ TOOL_ACTION COMMON_ACTIONS::gridFast2( "common.Control.gridFast2",
"", "" );
TOOL_ACTION COMMON_ACTIONS::gridNext( "common.Control.gridNext",
AS_GLOBAL, '`',
AS_GLOBAL, 'N',
"", "" );
TOOL_ACTION COMMON_ACTIONS::gridPrev( "common.Control.gridPrev",
AS_GLOBAL, MD_CTRL + int( '`' ),
AS_GLOBAL, MD_SHIFT + int( 'N' ),
"", "" );
TOOL_ACTION COMMON_ACTIONS::gridSetOrigin( "common.Control.gridSetOrigin",
@ -363,7 +363,7 @@ TOOL_ACTION COMMON_ACTIONS::zoneUnfill( "pcbnew.EditorControl.zoneUnfill",
_( "Unfill" ), _( "Unfill zone(s)" ), zone_unfill_xpm );
TOOL_ACTION COMMON_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll",
AS_GLOBAL, int( 'N' ),
AS_GLOBAL, MD_CTRL + int( 'B' ),
_( "Unfill all" ), _( "Unfill all zones" ) );

View File

@ -129,7 +129,7 @@ int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoomPreset( const TOOL_EVENT& aEvent )
{
unsigned int idx = aEvent.Parameter<long>();
std::vector<int>& zoomList = m_frame->GetScreen()->m_ZoomList;
std::vector<double>& zoomList = m_frame->GetScreen()->m_ZoomList;
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();

View File

@ -64,7 +64,7 @@ OPT_TOOL_EVENT ZOOM_MENU::EventHandler( const wxMenuEvent& aEvent )
void ZOOM_MENU::Update()
{
double zoom = m_parent->GetScreen()->GetZoom();
const std::vector<int>& zoomList = m_parent->GetScreen()->m_ZoomList;
const std::vector<double>& zoomList = m_parent->GetScreen()->m_ZoomList;
for( unsigned int i = 0; i < GetMenuItemCount(); ++i )
Check( ID_POPUP_ZOOM_LEVEL_START + i, zoomList[i] == zoom );