GerbView #2501 - Add mirror display function to GerbView

Adds the ability to flip (mirror) the display, just like "Flip
Board View" does in Pcbnew.

Also added this to vertical toolbar since it's handy to not
have to go into the menu system to flip the display back and
forth.

Fixes issue https://gitlab.com/kicad/code/kicad/-/issues/2501
This commit is contained in:
PJM 2020-07-25 21:20:07 -07:00
parent 95c2b261e8
commit 4d2bc1fa54
6 changed files with 25 additions and 4 deletions

View File

@ -46,9 +46,10 @@ public:
bool m_DisplayPageLimits; bool m_DisplayPageLimits;
bool m_DisplayNegativeObjects; ///< Option to draw negative objects in a specific color bool m_DisplayNegativeObjects; ///< Option to draw negative objects in a specific color
bool m_IsPrinting; ///< true when printing a page, false when drawing on screen bool m_IsPrinting; ///< true when printing a page, false when drawing on screen
bool m_ForceBlackAndWhite; ///< Option print in blackand white (ont used id draw mode bool m_ForceBlackAndWhite; ///< Option print in black and white (not used in draw mode
bool m_DiffMode; ///< Display layers in diff mode bool m_DiffMode; ///< Display layers in diff mode
bool m_HighContrastMode; ///< High contrast mode (dim un-highlighted objects) bool m_HighContrastMode; ///< High contrast mode (dim un-highlighted objects)
bool m_FlipGerberView; ///< Display as a mirror image
COLOR4D m_NegativeDrawColor; ///< The color used to draw negative objects, usually the COLOR4D m_NegativeDrawColor; ///< The color used to draw negative objects, usually the
///< background color, but not always, when negative objects ///< background color, but not always, when negative objects
///< must be visible ///< must be visible
@ -69,6 +70,7 @@ public:
m_BgDrawColor = COLOR4D::BLACK; m_BgDrawColor = COLOR4D::BLACK;
m_DiffMode = false; m_DiffMode = false;
m_HighContrastMode = false; m_HighContrastMode = false;
m_FlipGerberView = false;
} }
}; };

View File

@ -182,6 +182,9 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
auto contrastModeCondition = [ this ] ( const SELECTION& aSel ) { auto contrastModeCondition = [ this ] ( const SELECTION& aSel ) {
return m_DisplayOptions.m_HighContrastMode; return m_DisplayOptions.m_HighContrastMode;
}; };
auto flipViewCondition = [this]( const SELECTION& aSel ) {
return m_DisplayOptions.m_FlipGerberView;
};
// Hide layer manager // Hide layer manager
viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
@ -215,6 +218,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
viewMenu->AddCheckItem( GERBVIEW_ACTIONS::negativeObjectDisplay, showNegativeObjects ); viewMenu->AddCheckItem( GERBVIEW_ACTIONS::negativeObjectDisplay, showNegativeObjects );
viewMenu->AddCheckItem( GERBVIEW_ACTIONS::toggleDiffMode, diffModeCondition ); viewMenu->AddCheckItem( GERBVIEW_ACTIONS::toggleDiffMode, diffModeCondition );
viewMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition ); viewMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition );
viewMenu->AddCheckItem( GERBVIEW_ACTIONS::flipGerberView, flipViewCondition );
viewMenu->Resolve(); viewMenu->Resolve();

View File

@ -249,6 +249,7 @@ void GERBVIEW_FRAME::ReCreateOptToolbar()
m_optionsToolBar->Add( GERBVIEW_ACTIONS::dcodeDisplay, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( GERBVIEW_ACTIONS::dcodeDisplay, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( GERBVIEW_ACTIONS::toggleDiffMode, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( GERBVIEW_ACTIONS::toggleDiffMode, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( GERBVIEW_ACTIONS::flipGerberView, ACTION_TOOLBAR::TOGGLE );
// Tools to show/hide toolbars: // Tools to show/hide toolbars:
m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->AddScaledSeparator( this );
@ -500,5 +501,6 @@ void GERBVIEW_FRAME::SyncToolbars()
IsElementVisible( LAYER_DCODES ) ); IsElementVisible( LAYER_DCODES ) );
m_optionsToolBar->Toggle( GERBVIEW_ACTIONS::toggleDiffMode,m_DisplayOptions.m_DiffMode ); m_optionsToolBar->Toggle( GERBVIEW_ACTIONS::toggleDiffMode,m_DisplayOptions.m_DiffMode );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, m_DisplayOptions.m_HighContrastMode ); m_optionsToolBar->Toggle( ACTIONS::highContrastMode, m_DisplayOptions.m_HighContrastMode );
m_optionsToolBar->Toggle( GERBVIEW_ACTIONS::flipGerberView, m_DisplayOptions.m_FlipGerberView );
m_optionsToolBar->Refresh(); m_optionsToolBar->Refresh();
} }

View File

@ -148,6 +148,11 @@ TOOL_ACTION GERBVIEW_ACTIONS::toggleDiffMode( "gerbview.Control.toggleDiffMode",
_( "Show in Differential Mode" ), _( "Show layers in diff (compare) mode" ), _( "Show in Differential Mode" ), _( "Show layers in diff (compare) mode" ),
gbr_select_mode2_xpm ); gbr_select_mode2_xpm );
TOOL_ACTION GERBVIEW_ACTIONS::flipGerberView( "gerbview.Control.flipGerberView",
AS_GLOBAL, 0, "",
_( "Flip Gerber View" ), _( "Show as mirror image" ),
swap_layer_xpm );
// GERBVIEW_SELECTION_TOOL // GERBVIEW_SELECTION_TOOL
// //

View File

@ -63,6 +63,7 @@ public:
static TOOL_ACTION negativeObjectDisplay; static TOOL_ACTION negativeObjectDisplay;
static TOOL_ACTION dcodeDisplay; static TOOL_ACTION dcodeDisplay;
static TOOL_ACTION toggleDiffMode; static TOOL_ACTION toggleDiffMode;
static TOOL_ACTION flipGerberView;
// Layer control // Layer control
static TOOL_ACTION layerPrev; static TOOL_ACTION layerPrev;

View File

@ -28,9 +28,7 @@
#include "gerbview_selection_tool.h" #include "gerbview_selection_tool.h"
GERBVIEW_CONTROL::GERBVIEW_CONTROL() : GERBVIEW_CONTROL::GERBVIEW_CONTROL() : TOOL_INTERACTIVE( "gerbview.Control" ), m_frame( nullptr )
TOOL_INTERACTIVE( "gerbview.Control" ),
m_frame( nullptr )
{ {
} }
@ -169,6 +167,14 @@ int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
options.m_DiffMode = !options.m_DiffMode; options.m_DiffMode = !options.m_DiffMode;
needs_refresh = true; needs_refresh = true;
} }
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::flipGerberView ) )
{
options.m_FlipGerberView = !options.m_FlipGerberView;
KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
view->SetMirror( options.m_FlipGerberView, false );
needs_refresh = true;
}
if( needs_refresh ) if( needs_refresh )
m_frame->UpdateDisplayOptions( options ); m_frame->UpdateDisplayOptions( options );
@ -244,6 +250,7 @@ void GERBVIEW_CONTROL::setTransitions()
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::dcodeDisplay.MakeEvent() ); Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::dcodeDisplay.MakeEvent() );
Go( &GERBVIEW_CONTROL::DisplayControl, ACTIONS::highContrastMode.MakeEvent() ); Go( &GERBVIEW_CONTROL::DisplayControl, ACTIONS::highContrastMode.MakeEvent() );
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::toggleDiffMode.MakeEvent() ); Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::toggleDiffMode.MakeEvent() );
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::flipGerberView.MakeEvent() );
Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent ); Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent );
Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent ); Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent );