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:
parent
82dff76530
commit
5a02b91e5f
|
@ -369,7 +369,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
|
||||||
|
|
||||||
if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
|
if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
|
||||||
{
|
{
|
||||||
if( m_gridSelectBox == NULL )
|
if( m_gridSelectBox == NULL ) // Should no happen
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -526,35 +526,44 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
|
||||||
|
|
||||||
void EDA_DRAW_FRAME::SetNextGrid()
|
void EDA_DRAW_FRAME::SetNextGrid()
|
||||||
{
|
{
|
||||||
if( m_gridSelectBox )
|
BASE_SCREEN * screen = GetScreen();
|
||||||
SetPresetGrid( ( m_gridSelectBox->GetSelection() + 1 ) % m_gridSelectBox->GetCount() );
|
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()
|
void EDA_DRAW_FRAME::SetPrevGrid()
|
||||||
{
|
{
|
||||||
if( m_gridSelectBox )
|
BASE_SCREEN * screen = GetScreen();
|
||||||
{
|
int grid_cnt = screen->GetGridCount();
|
||||||
int idx = m_gridSelectBox->GetSelection();
|
|
||||||
|
|
||||||
if( --idx < 0 )
|
int new_grid_idx = screen->GetGridId() - ID_POPUP_GRID_LEVEL_1000 - 1;
|
||||||
idx = m_gridSelectBox->GetCount() - 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 )
|
void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
|
||||||
{
|
{
|
||||||
if( aIndex < 0 || aIndex >= (int) m_gridSelectBox->GetCount() )
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( false, "Invalid grid index" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_gridSelectBox )
|
if( m_gridSelectBox )
|
||||||
|
{
|
||||||
|
if( aIndex < 0 || aIndex >= (int) m_gridSelectBox->GetCount() )
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( false, "Invalid grid index" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_gridSelectBox->SetSelection( aIndex );
|
m_gridSelectBox->SetSelection( aIndex );
|
||||||
|
}
|
||||||
|
|
||||||
// Be sure m_LastGridSizeId is up to date.
|
// Be sure m_LastGridSizeId is up to date.
|
||||||
m_LastGridSizeId = aIndex;
|
m_LastGridSizeId = aIndex;
|
||||||
|
|
|
@ -223,7 +223,8 @@ void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_zoomSelectBox->SetSelection( aIndex );
|
if( m_zoomSelectBox )
|
||||||
|
m_zoomSelectBox->SetSelection( aIndex );
|
||||||
|
|
||||||
if( screen->SetZoom( screen->m_ZoomList[aIndex] ) )
|
if( screen->SetZoom( screen->m_ZoomList[aIndex] ) )
|
||||||
RedrawScreen( GetScrollCenterPosition(), true );
|
RedrawScreen( GetScrollCenterPosition(), true );
|
||||||
|
@ -238,7 +239,7 @@ void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
|
||||||
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
|
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
|
||||||
{
|
{
|
||||||
int maxZoomIds;
|
int maxZoomIds;
|
||||||
int zoom;
|
double zoom;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
BASE_SCREEN* screen = m_canvas->GetScreen();
|
BASE_SCREEN* screen = m_canvas->GetScreen();
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ public:
|
||||||
int m_ScreenNumber;
|
int m_ScreenNumber;
|
||||||
int m_NumberOfScreens;
|
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;
|
bool m_IsPrinting;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -141,7 +141,7 @@ static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Cairo Canvas" ),
|
||||||
static EDA_HOTKEY HkZoneFillOrRefill( _HKI( "Fill or Refill All Zones" ),
|
static EDA_HOTKEY HkZoneFillOrRefill( _HKI( "Fill or Refill All Zones" ),
|
||||||
HK_ZONE_FILL_OR_REFILL, 'B' );
|
HK_ZONE_FILL_OR_REFILL, 'B' );
|
||||||
static EDA_HOTKEY HkZoneRemoveFilled( _HKI( "Remove Filled Areas in All Zones" ),
|
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 */
|
/* Fit on Screen */
|
||||||
#if !defined( __WXMAC__ )
|
#if !defined( __WXMAC__ )
|
||||||
static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
|
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' );
|
HK_SWITCH_GRID_TO_FASTGRID2, GR_KB_ALT + '2' );
|
||||||
|
|
||||||
static EDA_HOTKEY HkSwitchGridToNext( _HKI( "Switch Grid To Next" ),
|
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" ),
|
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 HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' + GR_KB_CTRL );
|
||||||
static EDA_HOTKEY HkTrackDisplayMode( _HKI( "Track Display Mode" ),
|
static EDA_HOTKEY HkTrackDisplayMode( _HKI( "Track Display Mode" ),
|
||||||
|
|
|
@ -312,11 +312,11 @@ TOOL_ACTION COMMON_ACTIONS::gridFast2( "common.Control.gridFast2",
|
||||||
"", "" );
|
"", "" );
|
||||||
|
|
||||||
TOOL_ACTION COMMON_ACTIONS::gridNext( "common.Control.gridNext",
|
TOOL_ACTION COMMON_ACTIONS::gridNext( "common.Control.gridNext",
|
||||||
AS_GLOBAL, '`',
|
AS_GLOBAL, 'N',
|
||||||
"", "" );
|
"", "" );
|
||||||
|
|
||||||
TOOL_ACTION COMMON_ACTIONS::gridPrev( "common.Control.gridPrev",
|
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",
|
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 );
|
_( "Unfill" ), _( "Unfill zone(s)" ), zone_unfill_xpm );
|
||||||
|
|
||||||
TOOL_ACTION COMMON_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll",
|
TOOL_ACTION COMMON_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll",
|
||||||
AS_GLOBAL, int( 'N' ),
|
AS_GLOBAL, MD_CTRL + int( 'B' ),
|
||||||
_( "Unfill all" ), _( "Unfill all zones" ) );
|
_( "Unfill all" ), _( "Unfill all zones" ) );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
||||||
int PCBNEW_CONTROL::ZoomPreset( const TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::ZoomPreset( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
unsigned int idx = aEvent.Parameter<long>();
|
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::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ OPT_TOOL_EVENT ZOOM_MENU::EventHandler( const wxMenuEvent& aEvent )
|
||||||
void ZOOM_MENU::Update()
|
void ZOOM_MENU::Update()
|
||||||
{
|
{
|
||||||
double zoom = m_parent->GetScreen()->GetZoom();
|
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 )
|
for( unsigned int i = 0; i < GetMenuItemCount(); ++i )
|
||||||
Check( ID_POPUP_ZOOM_LEVEL_START + i, zoomList[i] == zoom );
|
Check( ID_POPUP_ZOOM_LEVEL_START + i, zoomList[i] == zoom );
|
||||||
|
|
Loading…
Reference in New Issue