Add missing hotkey support to GerbView
Fixes: lp:1752982 * https://bugs.launchpad.net/kicad/+bug/1752982
This commit is contained in:
parent
d2c86f8594
commit
cd2224b94d
|
@ -457,6 +457,8 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
bool state;
|
||||
bool needs_refresh = false;
|
||||
|
||||
GBR_DISPLAY_OPTIONS options = m_DisplayOptions;
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG:
|
||||
|
@ -472,21 +474,21 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
switch( id )
|
||||
{
|
||||
case ID_TB_OPTIONS_SHOW_POLAR_COORD:
|
||||
m_DisplayOptions.m_DisplayPolarCood = state;
|
||||
options.m_DisplayPolarCood = state;
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
|
||||
m_DisplayOptions.m_DisplayFlashedItemsFill = not state;
|
||||
options.m_DisplayFlashedItemsFill = not state;
|
||||
needs_refresh = true;
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
|
||||
m_DisplayOptions.m_DisplayLinesFill = not state;
|
||||
options.m_DisplayLinesFill = not state;
|
||||
needs_refresh = true;
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH:
|
||||
m_DisplayOptions.m_DisplayPolygonsFill = not state;
|
||||
options.m_DisplayPolygonsFill = not state;
|
||||
needs_refresh = true;
|
||||
break;
|
||||
|
||||
|
@ -501,12 +503,12 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_TB_OPTIONS_DIFF_MODE:
|
||||
m_DisplayOptions.m_DiffMode = state;
|
||||
options.m_DiffMode = state;
|
||||
needs_refresh = true;
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_HIGH_CONTRAST_MODE:
|
||||
m_DisplayOptions.m_HighContrastMode = state;
|
||||
options.m_HighContrastMode = state;
|
||||
needs_refresh = true;
|
||||
break;
|
||||
|
||||
|
@ -532,66 +534,7 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
if( needs_refresh )
|
||||
{
|
||||
applyDisplaySettingsToGAL();
|
||||
auto view = GetGalCanvas()->GetView();
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
|
||||
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[]( KIGFX::VIEW_ITEM* aItem ) {
|
||||
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
||||
|
||||
switch( item->m_Shape )
|
||||
{
|
||||
case GBR_SPOT_CIRCLE:
|
||||
case GBR_SPOT_RECT:
|
||||
case GBR_SPOT_OVAL:
|
||||
case GBR_SPOT_POLY:
|
||||
case GBR_SPOT_MACRO:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
|
||||
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[]( KIGFX::VIEW_ITEM* aItem ) {
|
||||
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
||||
|
||||
switch( item->m_Shape )
|
||||
{
|
||||
case GBR_CIRCLE:
|
||||
case GBR_ARC:
|
||||
case GBR_SEGMENT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH:
|
||||
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[]( KIGFX::VIEW_ITEM* aItem ) {
|
||||
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
||||
|
||||
return ( item->m_Shape == GBR_POLYGON );
|
||||
} );
|
||||
break;
|
||||
|
||||
default:
|
||||
view->UpdateAllItems( KIGFX::COLOR );
|
||||
break;
|
||||
}
|
||||
|
||||
m_canvas->Refresh( true );
|
||||
}
|
||||
UpdateDisplayOptions( options );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -689,6 +689,75 @@ void GERBVIEW_FRAME::SortLayersByX2Attributes()
|
|||
}
|
||||
|
||||
|
||||
void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
|
||||
{
|
||||
bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
|
||||
aOptions.m_DisplayFlashedItemsFill );
|
||||
bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
|
||||
aOptions.m_DisplayLinesFill );
|
||||
bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
|
||||
aOptions.m_DisplayPolygonsFill );
|
||||
|
||||
m_DisplayOptions = aOptions;
|
||||
|
||||
applyDisplaySettingsToGAL();
|
||||
|
||||
auto view = GetGalCanvas()->GetView();
|
||||
|
||||
if( update_flashed )
|
||||
{
|
||||
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[]( KIGFX::VIEW_ITEM* aItem ) {
|
||||
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
||||
|
||||
switch( item->m_Shape )
|
||||
{
|
||||
case GBR_SPOT_CIRCLE:
|
||||
case GBR_SPOT_RECT:
|
||||
case GBR_SPOT_OVAL:
|
||||
case GBR_SPOT_POLY:
|
||||
case GBR_SPOT_MACRO:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
}
|
||||
else if( update_lines )
|
||||
{
|
||||
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[]( KIGFX::VIEW_ITEM* aItem ) {
|
||||
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
||||
|
||||
switch( item->m_Shape )
|
||||
{
|
||||
case GBR_CIRCLE:
|
||||
case GBR_ARC:
|
||||
case GBR_SEGMENT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
}
|
||||
else if( update_polygons )
|
||||
{
|
||||
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
||||
[]( KIGFX::VIEW_ITEM* aItem ) {
|
||||
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
||||
|
||||
return ( item->m_Shape == GBR_POLYGON );
|
||||
} );
|
||||
}
|
||||
|
||||
view->UpdateAllItems( KIGFX::COLOR );
|
||||
|
||||
GetGalCanvas()->Refresh( true );
|
||||
}
|
||||
|
||||
|
||||
void GERBVIEW_FRAME::UpdateTitleAndInfo()
|
||||
{
|
||||
GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() );
|
||||
|
|
|
@ -703,6 +703,12 @@ public:
|
|||
|
||||
void SortLayersByX2Attributes();
|
||||
|
||||
/**
|
||||
* Updates the display options and refreshes the view as needed
|
||||
* @param aOptions is the new options to apply
|
||||
*/
|
||||
void UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions );
|
||||
|
||||
// Conversion function
|
||||
void ExportDataInPcbnewFormat( wxCommandEvent& event );
|
||||
|
||||
|
|
|
@ -68,15 +68,18 @@ public:
|
|||
static TOOL_ACTION zoomPreset;
|
||||
|
||||
// Display modes
|
||||
static TOOL_ACTION zoneDisplayEnable;
|
||||
static TOOL_ACTION zoneDisplayDisable;
|
||||
static TOOL_ACTION zoneDisplayOutlines;
|
||||
static TOOL_ACTION linesDisplayOutlines;
|
||||
static TOOL_ACTION flashedDisplayOutlines;
|
||||
static TOOL_ACTION polygonsDisplayOutlines;
|
||||
static TOOL_ACTION negativeObjectDisplay;
|
||||
static TOOL_ACTION dcodeDisplay;
|
||||
static TOOL_ACTION highContrastMode;
|
||||
static TOOL_ACTION highContrastInc;
|
||||
static TOOL_ACTION highContrastDec;
|
||||
|
||||
// Layer control
|
||||
static TOOL_ACTION layerPrev;
|
||||
static TOOL_ACTION layerNext;
|
||||
static TOOL_ACTION layerAlphaInc;
|
||||
static TOOL_ACTION layerAlphaDec;
|
||||
static TOOL_ACTION layerToggle;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <gerbview_frame.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <hotkeys.h>
|
||||
|
||||
#include "gerbview_actions.h"
|
||||
#include "gerbview_control.h"
|
||||
|
@ -52,6 +53,46 @@ TOOL_ACTION GERBVIEW_ACTIONS::highlightAttribute( "gerbview.Control.highlightAtt
|
|||
AS_GLOBAL, 0,
|
||||
_( "Highlight Attribute" ), "", flag_xpm );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::layerNext( "gerbview.Control.layerNext",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_NEXT ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::layerPrev( "gerbview.Control.layerPrev",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_PREVIOUS ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::linesDisplayOutlines( "gerbview.Control.linesDisplayOutlines",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_LINES_DISPLAY_MODE ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::flashedDisplayOutlines( "gerbview.Control.flashedDisplayOutlines",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_FLASHED_DISPLAY_MODE ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::polygonsDisplayOutlines( "gerbview.Control.polygonsDisplayOutlines",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_POLYGON_DISPLAY_MODE ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::negativeObjectDisplay( "gerbview.Control.negativeObjectDisplay",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_NEGATIVE_DISPLAY_ONOFF ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::dcodeDisplay( "gerbview.Control.dcodeDisplay",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GBR_DCODE_DISPLAY_ONOFF ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::switchUnits( "gerbview.Control.switchUnits",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_UNITS ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::resetCoords( "gerbview.Control.resetCoords",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ),
|
||||
"", "" );
|
||||
|
||||
TOOL_ACTION GERBVIEW_ACTIONS::showHelp( "gerbview.Control.showHelp",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HELP ),
|
||||
"", "" );
|
||||
|
||||
GERBVIEW_CONTROL::GERBVIEW_CONTROL() :
|
||||
TOOL_INTERACTIVE( "gerbview.Control" ), m_frame( NULL )
|
||||
{
|
||||
|
@ -120,10 +161,119 @@ int GERBVIEW_CONTROL::HighlightControl( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
bool state;
|
||||
bool needs_refresh = false;
|
||||
GBR_DISPLAY_OPTIONS options = m_frame->m_DisplayOptions;
|
||||
|
||||
if( aEvent.IsAction( &GERBVIEW_ACTIONS::linesDisplayOutlines ) )
|
||||
{
|
||||
options.m_DisplayLinesFill = !options.m_DisplayLinesFill;
|
||||
needs_refresh = true;
|
||||
}
|
||||
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::flashedDisplayOutlines ) )
|
||||
{
|
||||
options.m_DisplayFlashedItemsFill = !options.m_DisplayFlashedItemsFill;
|
||||
needs_refresh = true;
|
||||
}
|
||||
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::polygonsDisplayOutlines ) )
|
||||
{
|
||||
options.m_DisplayPolygonsFill = !options.m_DisplayPolygonsFill;
|
||||
needs_refresh = true;
|
||||
}
|
||||
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::negativeObjectDisplay ) )
|
||||
{
|
||||
state = !m_frame->IsElementVisible( LAYER_NEGATIVE_OBJECTS );
|
||||
m_frame->SetElementVisibility( LAYER_NEGATIVE_OBJECTS, state );
|
||||
}
|
||||
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::dcodeDisplay ) )
|
||||
{
|
||||
state = !m_frame->IsElementVisible( LAYER_DCODES );
|
||||
m_frame->SetElementVisibility( LAYER_DCODES, state );
|
||||
}
|
||||
|
||||
if( needs_refresh )
|
||||
m_frame->UpdateDisplayOptions( options );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GERBVIEW_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
int layer = m_frame->GetActiveLayer();
|
||||
|
||||
if( layer < GERBER_DRAWLAYERS_COUNT - 1 )
|
||||
m_frame->SetActiveLayer( layer + 1, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GERBVIEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
int layer = m_frame->GetActiveLayer();
|
||||
|
||||
if( layer > 0 )
|
||||
m_frame->SetActiveLayer( layer - 1, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GERBVIEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
|
||||
|
||||
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
|
||||
m_frame->UpdateStatusBar();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GERBVIEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
// TODO: Refactor to share with pcbnew
|
||||
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
|
||||
|
||||
if( g_UserUnit == INCHES )
|
||||
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
|
||||
else
|
||||
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
|
||||
|
||||
m_frame->ProcessEvent( evt );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
DisplayHotkeyList( m_frame, m_frame->GetHotkeyConfig() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GERBVIEW_CONTROL::setTransitions()
|
||||
{
|
||||
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightClear.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightNet.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightComponent.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightAttribute.MakeEvent() );
|
||||
|
||||
Go( &GERBVIEW_CONTROL::LayerNext, GERBVIEW_ACTIONS::layerNext.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::LayerPrev, GERBVIEW_ACTIONS::layerPrev.MakeEvent() );
|
||||
|
||||
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::linesDisplayOutlines.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::flashedDisplayOutlines.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::polygonsDisplayOutlines.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::negativeObjectDisplay.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::dcodeDisplay.MakeEvent() );
|
||||
|
||||
Go( &GERBVIEW_CONTROL::ResetCoords, GERBVIEW_ACTIONS::resetCoords.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::SwitchUnits, GERBVIEW_ACTIONS::switchUnits.MakeEvent() );
|
||||
Go( &GERBVIEW_CONTROL::ShowHelp, GERBVIEW_ACTIONS::showHelp.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
int HighContrastMode( const TOOL_EVENT& aEvent );
|
||||
int HighContrastInc( const TOOL_EVENT& aEvent );
|
||||
int HighContrastDec( const TOOL_EVENT& aEvent );
|
||||
int DisplayControl( const TOOL_EVENT& aEvent );
|
||||
|
||||
// Layer control
|
||||
int LayerSwitch( const TOOL_EVENT& aEvent );
|
||||
|
@ -55,6 +56,11 @@ public:
|
|||
// Highlight control
|
||||
int HighlightControl( const TOOL_EVENT& aEvent );
|
||||
|
||||
// Miscellaneous
|
||||
int ResetCoords( const TOOL_EVENT& aEvent );
|
||||
int SwitchUnits( const TOOL_EVENT& aEvent );
|
||||
int ShowHelp( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Sets up handlers for various events.
|
||||
void setTransitions() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue