refactoring: derive PCB-specific PCB_VIEW from VIEW with the intention of moving PCB_EDIT_FRAME entries used by the tools (e.g. GetActiveLayer) there

This commit is contained in:
Tomasz Włostowski 2017-10-30 20:17:23 +01:00
parent 81d1e17f02
commit 8a09a1d329
14 changed files with 197 additions and 70 deletions

View File

@ -74,9 +74,6 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS ); ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
m_view = new KIGFX::VIEW( true );
m_view->SetGAL( m_gal );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this ); Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this ); Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this ); Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), NULL, this );
@ -103,10 +100,6 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
NULL, m_eventDispatcher ); NULL, m_eventDispatcher );
} }
// View controls is the first in the event handler chain, so the Tool Framework operates
// on updated viewport data.
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
m_pendingRefresh = false; m_pendingRefresh = false;
m_drawing = false; m_drawing = false;
m_drawingEnabled = false; m_drawingEnabled = false;

View File

@ -68,7 +68,7 @@ public:
*/ */
VIEW( bool aIsDynamic = true ); VIEW( bool aIsDynamic = true );
~VIEW(); virtual ~VIEW();
// nasty hack, invoked by the destructor of VIEW_ITEM to auto-remove the item // nasty hack, invoked by the destructor of VIEW_ITEM to auto-remove the item
// from the owning VIEW if there is any. Kicad relies too much on this mechanism. // from the owning VIEW if there is any. Kicad relies too much on this mechanism.
@ -83,14 +83,14 @@ public:
* @param aItem: item to be added. No ownership is given * @param aItem: item to be added. No ownership is given
* @param aDrawPriority: priority to draw this item on its layer, lowest first. * @param aDrawPriority: priority to draw this item on its layer, lowest first.
*/ */
void Add( VIEW_ITEM* aItem, int aDrawPriority = -1 ); virtual void Add( VIEW_ITEM* aItem, int aDrawPriority = -1 );
/** /**
* Function Remove() * Function Remove()
* Removes a VIEW_ITEM from the view. * Removes a VIEW_ITEM from the view.
* @param aItem: item to be removed. Caller must dispose the removed item if necessary * @param aItem: item to be removed. Caller must dispose the removed item if necessary
*/ */
void Remove( VIEW_ITEM* aItem ); virtual void Remove( VIEW_ITEM* aItem );
/** /**
@ -102,7 +102,7 @@ public:
* first). * first).
* @return Number of found items. * @return Number of found items.
*/ */
int Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult ) const; virtual int Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult ) const;
/** /**
* Sets the item visibility. * Sets the item visibility.
@ -136,8 +136,8 @@ public:
* @param aItem: the item to update. * @param aItem: the item to update.
* @param aUpdateFlags: how much the object has changed. * @param aUpdateFlags: how much the object has changed.
*/ */
void Update( VIEW_ITEM* aItem, int aUpdateFlags ); virtual void Update( VIEW_ITEM* aItem, int aUpdateFlags );
void Update( VIEW_ITEM* aItem ); virtual void Update( VIEW_ITEM* aItem );
/** /**
* Function SetRequired() * Function SetRequired()
@ -476,7 +476,7 @@ public:
* @param aLayer: the layer or -1 in case when no particular layer should * @param aLayer: the layer or -1 in case when no particular layer should
* be displayed on the top. * be displayed on the top.
*/ */
void SetTopLayer( int aLayer, bool aEnabled = true ); virtual void SetTopLayer( int aLayer, bool aEnabled = true );
/** /**
* Function EnableTopLayer() * Function EnableTopLayer()
@ -485,9 +485,9 @@ public:
* layer set previously with SetTopLayer function. * layer set previously with SetTopLayer function.
* @param aEnable whether to enable or disable display of the top layer. * @param aEnable whether to enable or disable display of the top layer.
*/ */
void EnableTopLayer( bool aEnable ); virtual void EnableTopLayer( bool aEnable );
int GetTopLayer() const; virtual int GetTopLayer() const;
/** /**
* Function ClearTopLayers() * Function ClearTopLayers()
@ -513,7 +513,7 @@ public:
* Function Redraw() * Function Redraw()
* Immediately redraws the whole view. * Immediately redraws the whole view.
*/ */
void Redraw(); virtual void Redraw();
/** /**
* Function RecacheAllItems() * Function RecacheAllItems()

View File

@ -47,7 +47,7 @@ class WX_VIEW_CONTROLS : public VIEW_CONTROLS, public wxEvtHandler
{ {
public: public:
WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel ); WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel );
~WX_VIEW_CONTROLS() virtual ~WX_VIEW_CONTROLS()
{} {}
/// Handler functions /// Handler functions

View File

@ -264,6 +264,7 @@ set( PCBNEW_CLASS_SRCS
pcbplot.cpp pcbplot.cpp
pcb_draw_panel_gal.cpp pcb_draw_panel_gal.cpp
pcb_general_settings.cpp pcb_general_settings.cpp
pcb_view.cpp
plot_board_layers.cpp plot_board_layers.cpp
plot_brditems_plotter.cpp plot_brditems_plotter.cpp
print_board_functions.cpp print_board_functions.cpp

View File

@ -52,7 +52,7 @@
#include <collectors.h> #include <collectors.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <pcb_draw_panel_gal.h> #include <pcb_draw_panel_gal.h>
#include <view/view.h> #include <pcb_view.h>
#include <math/vector2d.h> #include <math/vector2d.h>
#include <trigo.h> #include <trigo.h>
#include <pcb_painter.h> #include <pcb_painter.h>
@ -450,10 +450,8 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
if( gal ) if( gal )
{ {
// Apply new display options to the GAL canvas // Apply new display options to the GAL canvas
auto view = gal->GetView(); auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
auto painter = static_cast<KIGFX::PCB_PAINTER*> ( view->GetPainter() ); view->UpdateDisplayOptions( displ_opts );
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
settings->LoadDisplayOptions( displ_opts );
// Update pads // Update pads
BOARD* board = GetBoard(); BOARD* board = GetBoard();

View File

@ -40,7 +40,7 @@
#include <dialog_display_options_base.h> #include <dialog_display_options_base.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <view/view.h> #include <pcb_view.h>
#include <pcb_painter.h> #include <pcb_painter.h>
#include <widgets/gal_options_panel.h> #include <widgets/gal_options_panel.h>

View File

@ -23,7 +23,7 @@
*/ */
#include "pcb_draw_panel_gal.h" #include "pcb_draw_panel_gal.h"
#include <view/view.h> #include <pcb_view.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <pcb_painter.h> #include <pcb_painter.h>
#include <worksheet_viewitem.h> #include <worksheet_viewitem.h>
@ -104,12 +104,19 @@ PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) : KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType ) EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType )
{ {
setDefaultLayerOrder(); m_view = new KIGFX::PCB_VIEW( true );
setDefaultLayerDeps(); m_view->SetGAL( m_gal );
m_painter.reset( new KIGFX::PCB_PAINTER( m_gal ) ); m_painter.reset( new KIGFX::PCB_PAINTER( m_gal ) );
m_view->SetPainter( m_painter.get() ); m_view->SetPainter( m_painter.get() );
setDefaultLayerOrder();
setDefaultLayerDeps();
// View controls is the first in the event handler chain, so the Tool Framework operates
// on updated viewport data.
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
// Load display options (such as filled/outline display of items). // Load display options (such as filled/outline display of items).
// Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class) // Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
// which is not always the case (namely when it is used from a wxDialog like the pad editor) // which is not always the case (namely when it is used from a wxDialog like the pad editor)
@ -117,8 +124,8 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
if( frame ) if( frame )
{ {
auto displ_opts = (PCB_DISPLAY_OPTIONS*) frame->GetDisplayOptions(); auto opts = (PCB_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts ); static_cast<KIGFX::PCB_VIEW*>( m_view )->UpdateDisplayOptions( opts );
} }
} }
@ -442,3 +449,9 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
m_view->SetLayerDisplayOnly( LAYER_GRID ); m_view->SetLayerDisplayOnly( LAYER_GRID );
m_view->SetLayerDisplayOnly( LAYER_DRC ); m_view->SetLayerDisplayOnly( LAYER_DRC );
} }
KIGFX::PCB_VIEW* PCB_DRAW_PANEL_GAL::view() const
{
return static_cast<KIGFX::PCB_VIEW*>( m_view );
}

View File

@ -32,6 +32,7 @@ namespace KIGFX
{ {
class WORKSHEET_VIEWITEM; class WORKSHEET_VIEWITEM;
class RATSNEST_VIEWITEM; class RATSNEST_VIEWITEM;
class PCB_VIEW;
} }
class COLORS_DESIGN_SETTINGS; class COLORS_DESIGN_SETTINGS;
@ -103,6 +104,9 @@ public:
void RedrawRatsnest(); void RedrawRatsnest();
protected: protected:
KIGFX::PCB_VIEW* view() const;
///> Reassigns layer order to the initial settings. ///> Reassigns layer order to the initial settings.
void setDefaultLayerOrder(); void setDefaultLayerOrder();

View File

@ -63,6 +63,9 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
m_sketchMode[i] = false; m_sketchMode[i] = false;
} }
COLORS_DESIGN_SETTINGS dummyCds( FRAME_PCB );
ImportLegacyColors( &dummyCds );
update(); update();
} }

47
pcbnew/pcb_view.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <pcb_view.h>
#include <pcb_display_options.h>
#include <pcb_painter.h>
namespace KIGFX
{
PCB_VIEW::PCB_VIEW( bool aIsDynamic ) :
VIEW ( aIsDynamic )
{
}
PCB_VIEW::~PCB_VIEW()
{
}
void PCB_VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
{
VIEW::Add( aItem, aDrawPriority );
}
void PCB_VIEW::Remove( VIEW_ITEM* aItem )
{
VIEW::Remove( aItem );
}
void PCB_VIEW::Update( VIEW_ITEM* aItem, int aUpdateFlags )
{
VIEW::Update( aItem, aUpdateFlags );
}
/// @copydoc VIEW::Update()
void PCB_VIEW::Update( VIEW_ITEM* aItem )
{
VIEW::Update( aItem );
}
void PCB_VIEW::UpdateDisplayOptions( PCB_DISPLAY_OPTIONS* aOptions )
{
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetPainter() );
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
settings->LoadDisplayOptions( aOptions );
}
};

63
pcbnew/pcb_view.h Normal file
View File

@ -0,0 +1,63 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2016 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __PCB_VIEW_H
#define __PCB_VIEW_H
#include <layers_id_colors_and_visibility.h>
#include <view/view.h>
class PCB_DISPLAY_OPTIONS;
namespace KIGFX {
class PCB_VIEW : public VIEW
{
public:
PCB_VIEW( bool aIsDynamic = true );
virtual ~PCB_VIEW();
/// @copydoc VIEW::Add()
virtual void Add( VIEW_ITEM* aItem, int aDrawPriority = -1 ) override;
/// @copydoc VIEW::Remove()
virtual void Remove( VIEW_ITEM* aItem ) override;
/// @copydoc VIEW::Update()
virtual void Update( VIEW_ITEM* aItem, int aUpdateFlags ) override;
/// @copydoc VIEW::Update()
virtual void Update( VIEW_ITEM* aItem ) override;
void UpdateDisplayOptions( PCB_DISPLAY_OPTIONS* aOptions );
private:
PCB_LAYER_ID m_activeLayer;
PCB_LAYER_ID m_routeLayerTop;
PCB_LAYER_ID m_routeLayerBottom;
};
};
#endif

View File

@ -30,6 +30,7 @@
#include <board_commit.h> #include <board_commit.h>
#include <class_module.h> #include <class_module.h>
#include <pcb_draw_panel_gal.h>
#include "selection_tool.h" #include "selection_tool.h"
#include "pcb_actions.h" #include "pcb_actions.h"
@ -193,3 +194,13 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
view()->Remove( &preview ); view()->Remove( &preview );
} }
PCB_DISPLAY_OPTIONS* PCB_TOOL::displayOptions() const
{
return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
}
PCB_DRAW_PANEL_GAL* PCB_TOOL::canvas() const
{
return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetGalCanvas() );
}

View File

@ -32,6 +32,7 @@
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
#include <class_board.h> #include <class_board.h>
#include <view/view_group.h> #include <view/view_group.h>
#include <pcb_view.h>
#include <functional> #include <functional>
@ -44,6 +45,8 @@
class PCB_TOOL; class PCB_TOOL;
class PCB_EDIT_FRAME; class PCB_EDIT_FRAME;
class PCB_DISPLAY_OPTIONS;
class PCB_DRAW_PANEL_GAL;
struct INTERACTIVE_PLACER_BASE struct INTERACTIVE_PLACER_BASE
{ {
@ -120,11 +123,13 @@ protected:
const wxString& aCommitMessage, const wxString& aCommitMessage,
int aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT ); int aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT );
KIGFX::VIEW* view() const { return getView(); } KIGFX::PCB_VIEW* view() const { return static_cast<KIGFX::PCB_VIEW*>( getView() ); }
KIGFX::VIEW_CONTROLS* controls() const { return getViewControls(); } KIGFX::VIEW_CONTROLS* controls() const { return getViewControls(); }
PCB_EDIT_FRAME* frame() const { return getEditFrame<PCB_EDIT_FRAME>(); } PCB_EDIT_FRAME* frame() const { return getEditFrame<PCB_EDIT_FRAME>(); }
BOARD* board() const { return getModel<BOARD>(); } BOARD* board() const { return getModel<BOARD>(); }
MODULE* module() const { return board()->m_Modules; } MODULE* module() const { return board()->m_Modules; }
PCB_DISPLAY_OPTIONS* displayOptions() const;
PCB_DRAW_PANEL_GAL* canvas() const;
bool m_editModules; bool m_editModules;
}; };

View File

@ -256,16 +256,17 @@ void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
} }
} }
template<class T> void Flip( T& aValue )
{
aValue = !aValue;
}
int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
{ {
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() ); auto opts = displayOptions();
auto settings = painter->GetSettings();
// Apply new display options to the GAL canvas Flip( opts->m_DisplayPcbTrackFill );
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions(); view()->UpdateDisplayOptions( opts );
displ_opts->m_DisplayPcbTrackFill = !displ_opts->m_DisplayPcbTrackFill;
settings->LoadDisplayOptions( displ_opts );
for( auto track : board()->Tracks() ) for( auto track : board()->Tracks() )
{ {
@ -273,30 +274,25 @@ int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
view()->Update( track, KIGFX::GEOMETRY ); view()->Update( track, KIGFX::GEOMETRY );
} }
m_frame->GetGalCanvas()->Refresh(); canvas()->Refresh();
return 0; return 0;
} }
int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
{ {
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() ); auto opts = displayOptions();
auto settings = painter->GetSettings();
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions(); Flip( opts->m_DisplayPadFill );
view()->UpdateDisplayOptions( opts );
// Apply new display options to the GAL canvas for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill;
settings->LoadDisplayOptions( displ_opts );
for( auto module : board()->Modules() )
{ {
for( auto pad : module->Pads() ) for( auto pad : module->Pads() )
getView()->Update( pad, KIGFX::GEOMETRY ); view()->Update( pad, KIGFX::GEOMETRY );
} }
m_frame->GetGalCanvas()->Refresh(); canvas()->Refresh();
return 0; return 0;
} }
@ -304,21 +300,18 @@ int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
{ {
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() ); auto opts = displayOptions();
auto settings = painter->GetSettings();
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
// Apply new display options to the GAL canvas Flip( opts->m_DisplayViaFill );
displ_opts->m_DisplayViaFill = !displ_opts->m_DisplayViaFill; view()->UpdateDisplayOptions( opts );
settings->LoadDisplayOptions( displ_opts );
for( auto track : board()->Tracks() ) for( auto track : board()->Tracks() )
{ {
if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T ) if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
getView()->Update( track, KIGFX::GEOMETRY ); view()->Update( track, KIGFX::GEOMETRY );
} }
m_frame->GetGalCanvas()->Refresh(); canvas()->Refresh();
return 0; return 0;
} }
@ -326,26 +319,24 @@ int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
{ {
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() ); auto opts = displayOptions();
auto settings = painter->GetSettings();
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
// Apply new display options to the GAL canvas // Apply new display options to the GAL canvas
if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayEnable ) ) if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayEnable ) )
displ_opts->m_DisplayZonesMode = 0; opts->m_DisplayZonesMode = 0;
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) ) else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
displ_opts->m_DisplayZonesMode = 1; opts->m_DisplayZonesMode = 1;
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) ) else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
displ_opts->m_DisplayZonesMode = 2; opts->m_DisplayZonesMode = 2;
else else
assert( false ); assert( false );
settings->LoadDisplayOptions( displ_opts ); view()->UpdateDisplayOptions( opts );
for( int i = 0; i < board()->GetAreaCount(); ++i ) for( int i = 0; i < board()->GetAreaCount(); ++i )
view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY ); view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
m_frame->GetGalCanvas()->Refresh(); canvas()->Refresh();
return 0; return 0;
} }
@ -353,13 +344,11 @@ int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
{ {
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() ); auto opts = displayOptions();
auto settings = painter->GetSettings();
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
displ_opts->m_ContrastModeDisplay = !displ_opts->m_ContrastModeDisplay; Flip( opts->m_ContrastModeDisplay );
settings->LoadDisplayOptions( displ_opts ); view()->UpdateDisplayOptions( opts );
m_frame->GetGalCanvas()->SetHighContrastLayer( m_frame->GetActiveLayer() ); canvas()->SetHighContrastLayer( m_frame->GetActiveLayer() );
return 0; return 0;
} }