Commit 5a02b91e authored by jean-pierre charras's avatar jean-pierre charras
Browse files

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.
parent 82dff765
Loading
Loading
Loading
Loading
+24 −15
Original line number Original line Diff line number Diff line
@@ -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,26 +526,35 @@ 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( m_gridSelectBox )
    {
    {
        if( aIndex < 0 || aIndex >= (int) m_gridSelectBox->GetCount() )
        if( aIndex < 0 || aIndex >= (int) m_gridSelectBox->GetCount() )
        {
        {
@@ -553,8 +562,8 @@ void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
            return;
            return;
        }
        }


    if( m_gridSelectBox )
        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;
+3 −2
Original line number Original line Diff line number Diff line
@@ -223,6 +223,7 @@ void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
        return;
        return;
    }
    }


    if( m_zoomSelectBox )
        m_zoomSelectBox->SetSelection( aIndex );
        m_zoomSelectBox->SetSelection( aIndex );


    if( screen->SetZoom( screen->m_ZoomList[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 )
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();


+1 −1
Original line number Original line Diff line number Diff line
@@ -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:
+3 −3
Original line number Original line Diff line number Diff line
@@ -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" ),
+3 −3
Original line number Original line Diff line number Diff line
@@ -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" ) );




Loading