diff --git a/gerbview/gbr_display_options.h b/gerbview/gbr_display_options.h index bcb38f7bff..ec8f77cadb 100644 --- a/gerbview/gbr_display_options.h +++ b/gerbview/gbr_display_options.h @@ -46,9 +46,10 @@ public: bool m_DisplayPageLimits; 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_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_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 ///< background color, but not always, when negative objects ///< must be visible @@ -69,6 +70,7 @@ public: m_BgDrawColor = COLOR4D::BLACK; m_DiffMode = false; m_HighContrastMode = false; + m_FlipGerberView = false; } }; diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 593fead151..75becba36e 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -182,6 +182,9 @@ void GERBVIEW_FRAME::ReCreateMenuBar() auto contrastModeCondition = [ this ] ( const SELECTION& aSel ) { return m_DisplayOptions.m_HighContrastMode; }; + auto flipViewCondition = [this]( const SELECTION& aSel ) { + return m_DisplayOptions.m_FlipGerberView; + }; // Hide layer manager 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::toggleDiffMode, diffModeCondition ); viewMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition ); + viewMenu->AddCheckItem( GERBVIEW_ACTIONS::flipGerberView, flipViewCondition ); viewMenu->Resolve(); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index c6499d6ad6..8a7ecb8560 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -249,6 +249,7 @@ void GERBVIEW_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( GERBVIEW_ACTIONS::dcodeDisplay, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( GERBVIEW_ACTIONS::toggleDiffMode, 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: m_optionsToolBar->AddScaledSeparator( this ); @@ -500,5 +501,6 @@ void GERBVIEW_FRAME::SyncToolbars() IsElementVisible( LAYER_DCODES ) ); m_optionsToolBar->Toggle( GERBVIEW_ACTIONS::toggleDiffMode,m_DisplayOptions.m_DiffMode ); m_optionsToolBar->Toggle( ACTIONS::highContrastMode, m_DisplayOptions.m_HighContrastMode ); + m_optionsToolBar->Toggle( GERBVIEW_ACTIONS::flipGerberView, m_DisplayOptions.m_FlipGerberView ); m_optionsToolBar->Refresh(); } diff --git a/gerbview/tools/gerbview_actions.cpp b/gerbview/tools/gerbview_actions.cpp index 2852322b3d..5185c5ad3e 100644 --- a/gerbview/tools/gerbview_actions.cpp +++ b/gerbview/tools/gerbview_actions.cpp @@ -148,6 +148,11 @@ TOOL_ACTION GERBVIEW_ACTIONS::toggleDiffMode( "gerbview.Control.toggleDiffMode", _( "Show in Differential Mode" ), _( "Show layers in diff (compare) mode" ), 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 // diff --git a/gerbview/tools/gerbview_actions.h b/gerbview/tools/gerbview_actions.h index c2c7e76e98..ac72ba0dac 100644 --- a/gerbview/tools/gerbview_actions.h +++ b/gerbview/tools/gerbview_actions.h @@ -63,6 +63,7 @@ public: static TOOL_ACTION negativeObjectDisplay; static TOOL_ACTION dcodeDisplay; static TOOL_ACTION toggleDiffMode; + static TOOL_ACTION flipGerberView; // Layer control static TOOL_ACTION layerPrev; diff --git a/gerbview/tools/gerbview_control.cpp b/gerbview/tools/gerbview_control.cpp index 55dfce4961..e3fe5e7593 100644 --- a/gerbview/tools/gerbview_control.cpp +++ b/gerbview/tools/gerbview_control.cpp @@ -28,9 +28,7 @@ #include "gerbview_selection_tool.h" -GERBVIEW_CONTROL::GERBVIEW_CONTROL() : - TOOL_INTERACTIVE( "gerbview.Control" ), - m_frame( nullptr ) +GERBVIEW_CONTROL::GERBVIEW_CONTROL() : 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; 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 ) m_frame->UpdateDisplayOptions( options ); @@ -244,6 +250,7 @@ void GERBVIEW_CONTROL::setTransitions() Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::dcodeDisplay.MakeEvent() ); Go( &GERBVIEW_CONTROL::DisplayControl, ACTIONS::highContrastMode.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::UnselectedEvent );