Gerbview: fix not working menu item "Zoom to Selection" in main menu. This also fixes a wxASSERT for this menu item

This commit is contained in:
jean-pierre charras 2018-04-03 13:54:10 +02:00
parent 71bf488507
commit a2f118d2fa
7 changed files with 36 additions and 2 deletions

View File

@ -116,6 +116,8 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode ) EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode )
EVT_MENU( ID_MENU_ZOOM_SELECTION, GERBVIEW_FRAME::Process_Special_Functions )
// Vertical toolbar: // Vertical toolbar:
EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions ) EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions )
@ -231,6 +233,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetNoToolSelected(); SetNoToolSelected();
break; break;
case ID_MENU_ZOOM_SELECTION:
case ID_ZOOM_SELECTION: case ID_ZOOM_SELECTION:
// This tool is located on the main toolbar: switch it on or off on click // This tool is located on the main toolbar: switch it on or off on click
if( GetToolId() != ID_ZOOM_SELECTION ) if( GetToolId() != ID_ZOOM_SELECTION )

View File

@ -64,7 +64,7 @@ static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3
static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ),
HK_ZOOM_SELECTION, '@' ); HK_ZOOM_SELECTION, GR_KB_CTRL + WXK_F5 );
static EDA_HOTKEY HkHelp( _HKI( "Help (this window)" ), HK_HELP, '?' ); static EDA_HOTKEY HkHelp( _HKI( "Help (this window)" ), HK_HELP, '?' );
static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' ); static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ),
@ -192,6 +192,11 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
break; break;
case HK_ZOOM_SELECTION:
//cmd.SetId( ID_ZOOM_SELECTION );
//GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_AUTO: case HK_ZOOM_AUTO:
cmd.SetId( ID_ZOOM_PAGE ); cmd.SetId( ID_ZOOM_PAGE );
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );

View File

@ -212,7 +212,8 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit" ), AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit" ),
KiBitmap( zoom_fit_in_page_xpm ) ); KiBitmap( zoom_fit_in_page_xpm ) );
AddMenuItem( viewMenu, ID_ZOOM_SELECTION, _( "Zoom to Selection" ), text = AddHotkeyName( _( "Zoom to Selection" ), GerbviewHokeysDescr, HK_ZOOM_SELECTION );
AddMenuItem( viewMenu, ID_MENU_ZOOM_SELECTION, text,
KiBitmap( zoom_area_xpm ) ); KiBitmap( zoom_area_xpm ) );
text = AddHotkeyName( _( "&Redraw" ), GerbviewHokeysDescr, HK_ZOOM_REDRAW ); text = AddHotkeyName( _( "&Redraw" ), GerbviewHokeysDescr, HK_ZOOM_REDRAW );

View File

@ -49,6 +49,9 @@ OPT<TOOL_EVENT> GERBVIEW_ACTIONS::TranslateLegacyId( int aId )
case ID_ZOOM_PAGE: // toolbar button "Fit on Screen" case ID_ZOOM_PAGE: // toolbar button "Fit on Screen"
return ACTIONS::zoomFitScreen.MakeEvent(); return ACTIONS::zoomFitScreen.MakeEvent();
case ID_MENU_ZOOM_SELECTION:
return GERBVIEW_ACTIONS::switchZoomToSelectionTool.MakeEvent();
case ID_ZOOM_SELECTION: case ID_ZOOM_SELECTION:
return ACTIONS::zoomTool.MakeEvent(); return ACTIONS::zoomTool.MakeEvent();

View File

@ -124,6 +124,7 @@ public:
static TOOL_ACTION switchCursor; static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits; static TOOL_ACTION switchUnits;
static TOOL_ACTION showHelp; static TOOL_ACTION showHelp;
static TOOL_ACTION switchZoomToSelectionTool;
static TOOL_ACTION toBeDone; static TOOL_ACTION toBeDone;
// Highlighting // Highlighting

View File

@ -33,6 +33,9 @@ TOOL_ACTION GERBVIEW_ACTIONS::selectionTool( "gerbview.Control.selectionTool",
AS_GLOBAL, 0, AS_GLOBAL, 0,
"", "", NULL, AF_ACTIVATE ); "", "", NULL, AF_ACTIVATE );
TOOL_ACTION GERBVIEW_ACTIONS::switchZoomToSelectionTool( "gerbview.Control.switchZoomToSelectionTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_SELECTION ), "", "" );
TOOL_ACTION GERBVIEW_ACTIONS::layerChanged( "gerbview.Control.layerChanged", TOOL_ACTION GERBVIEW_ACTIONS::layerChanged( "gerbview.Control.layerChanged",
AS_GLOBAL, 0, AS_GLOBAL, 0,
"", "", NULL, AF_NOTIFY ); "", "", NULL, AF_NOTIFY );
@ -257,6 +260,21 @@ int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
} }
int GERBVIEW_CONTROL::SwitchZoomToSelectionTool( const TOOL_EVENT& aEvent )
{
// Update the Zoom to Selection Tool state changed from the zoom menuitem
bool state = m_frame->GetToolToggled( ID_ZOOM_SELECTION );
m_frame->GetMainToolBar()->ToggleTool( ID_ZOOM_SELECTION, !state );
m_frame->GetMainToolBar()->Refresh();
// Send the Zoom to Selection Tool event similar to a tool click:
wxCommandEvent evt( wxEVT_TOOL );
evt.SetId( ID_ZOOM_SELECTION );
m_frame->ProcessEvent( evt );
return 0;
}
void GERBVIEW_CONTROL::setTransitions() void GERBVIEW_CONTROL::setTransitions()
{ {
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightClear.MakeEvent() ); Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightClear.MakeEvent() );
@ -276,4 +294,6 @@ void GERBVIEW_CONTROL::setTransitions()
Go( &GERBVIEW_CONTROL::ResetCoords, GERBVIEW_ACTIONS::resetCoords.MakeEvent() ); Go( &GERBVIEW_CONTROL::ResetCoords, GERBVIEW_ACTIONS::resetCoords.MakeEvent() );
Go( &GERBVIEW_CONTROL::SwitchUnits, GERBVIEW_ACTIONS::switchUnits.MakeEvent() ); Go( &GERBVIEW_CONTROL::SwitchUnits, GERBVIEW_ACTIONS::switchUnits.MakeEvent() );
Go( &GERBVIEW_CONTROL::ShowHelp, GERBVIEW_ACTIONS::showHelp.MakeEvent() ); Go( &GERBVIEW_CONTROL::ShowHelp, GERBVIEW_ACTIONS::showHelp.MakeEvent() );
Go( &GERBVIEW_CONTROL::SwitchZoomToSelectionTool,
GERBVIEW_ACTIONS::switchZoomToSelectionTool.MakeEvent() );
} }

View File

@ -60,6 +60,7 @@ public:
int ResetCoords( const TOOL_EVENT& aEvent ); int ResetCoords( const TOOL_EVENT& aEvent );
int SwitchUnits( const TOOL_EVENT& aEvent ); int SwitchUnits( const TOOL_EVENT& aEvent );
int ShowHelp( const TOOL_EVENT& aEvent ); int ShowHelp( const TOOL_EVENT& aEvent );
int SwitchZoomToSelectionTool( const TOOL_EVENT& aEvent ); // On/off main toolbar Zoom to selection tool
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions() override; void setTransitions() override;