Implement Get/Set display options

The pointer passing for display options is deprecated.  This removes the
excess casting as the EDA_FRAME didn't need the base call with no value.
All requests for display options are now returned const and are updated
with a Set() routine after modification.

In Gerbview, this resolves an issue where the display options were not
stored because it was receiving the NULL from EDA_FRAME.
This commit is contained in:
Seth Hillbrand 2019-11-07 06:23:09 -08:00
parent 29ce76b4e4
commit 6625d0721e
54 changed files with 314 additions and 292 deletions

View File

@ -55,12 +55,12 @@ void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::initDialog()
/* mandatory to use escape key as cancel under wxGTK. */
SetFocus();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions();
auto& displ_opts = m_Parent->GetDisplayOptions();
m_EdgesDisplayOption->SetValue( not displ_opts->m_DisplayModEdgeFill );
m_TextDisplayOption->SetValue( not displ_opts->m_DisplayModTextFill );
m_ShowPadSketch->SetValue( not displ_opts->m_DisplayPadFill );
m_ShowPadNum->SetValue( displ_opts->m_DisplayPadNum );
m_EdgesDisplayOption->SetValue( not displ_opts.m_DisplayModEdgeFill );
m_TextDisplayOption->SetValue( not displ_opts.m_DisplayModTextFill );
m_ShowPadSketch->SetValue( not displ_opts.m_DisplayPadFill );
m_ShowPadNum->SetValue( displ_opts.m_DisplayPadNum );
m_autoZoomOption->SetValue( m_Parent->GetAutoZoom() );
}
@ -68,13 +68,14 @@ void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::initDialog()
void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings( void )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_Parent->GetDisplayOptions();
PCB_DISPLAY_OPTIONS displ_opts = m_Parent->GetDisplayOptions();
displ_opts->m_DisplayModEdgeFill = not m_EdgesDisplayOption->GetValue();
displ_opts->m_DisplayModTextFill = not m_TextDisplayOption->GetValue();
displ_opts->m_DisplayPadNum = m_ShowPadNum->GetValue();
displ_opts->m_DisplayPadFill = not m_ShowPadSketch->GetValue();
displ_opts.m_DisplayModEdgeFill = not m_EdgesDisplayOption->GetValue();
displ_opts.m_DisplayModTextFill = not m_TextDisplayOption->GetValue();
displ_opts.m_DisplayPadNum = m_ShowPadNum->GetValue();
displ_opts.m_DisplayPadFill = not m_ShowPadSketch->GetValue();
m_Parent->ApplyDisplaySettingsToGAL();
m_Parent->SetDisplayOptions( displ_opts );
m_Parent->SetAutoZoom( m_autoZoomOption->GetValue() );
}

View File

@ -84,11 +84,12 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
// Initialize some display options
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
displ_opts->m_DisplayPadIsol = false; // Pad clearance has no meaning here
auto displ_opts = GetDisplayOptions();
displ_opts.m_DisplayPadIsol = false; // Pad clearance has no meaning here
// Track and via clearance has no meaning here.
displ_opts->m_ShowTrackClearanceMode = PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE;
displ_opts.m_ShowTrackClearanceMode = PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE;
SetDisplayOptions( displ_opts );
// Create GAL canvas
#ifdef __WXMAC__
@ -285,7 +286,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ApplyDisplaySettingsToGAL()
{
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
painter->GetSettings()->LoadDisplayOptions( &m_DisplayOptions, false );
painter->GetSettings()->LoadDisplayOptions( GetDisplayOptions(), false );
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
GetCanvas()->Refresh();

View File

@ -46,11 +46,11 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow( )
m_galOptsPanel->TransferDataToWindow();
// Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
m_OptDisplayLines->SetValue( !m_Parent->m_DisplayOptions.m_DisplayLinesFill );
m_OptDisplayFlashedItems->SetValue( !m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill );
m_OptDisplayLines->SetValue( !m_Parent->GetDisplayOptions().m_DisplayLinesFill );
m_OptDisplayFlashedItems->SetValue( !m_Parent->GetDisplayOptions().m_DisplayFlashedItemsFill );
// Show Option Draw polygons
m_OptDisplayPolygons->SetValue( !m_Parent->m_DisplayOptions.m_DisplayPolygonsFill );
m_OptDisplayPolygons->SetValue( !m_Parent->GetDisplayOptions().m_DisplayPolygonsFill );
m_OptDisplayDCodes->SetValue( m_Parent->IsElementVisible( LAYER_DCODES ) );
@ -60,30 +60,30 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow( )
bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow()
{
auto displayOptions = (GBR_DISPLAY_OPTIONS*) m_Parent->GetDisplayOptions();
GBR_DISPLAY_OPTIONS displayOptions = m_Parent->GetDisplayOptions();
bool needs_repaint = false, option;
option = !m_OptDisplayLines->GetValue();
if( option != m_Parent->m_DisplayOptions.m_DisplayLinesFill )
if( option != displayOptions.m_DisplayLinesFill )
needs_repaint = true;
m_Parent->m_DisplayOptions.m_DisplayLinesFill = option;
displayOptions.m_DisplayLinesFill = option;
option = !m_OptDisplayFlashedItems->GetValue();
if( option != m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill )
if( option != m_Parent->GetDisplayOptions().m_DisplayFlashedItemsFill )
needs_repaint = true;
m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = option;
displayOptions.m_DisplayFlashedItemsFill = option;
option = !m_OptDisplayPolygons->GetValue();
if( option != m_Parent->m_DisplayOptions.m_DisplayPolygonsFill )
if( option != displayOptions.m_DisplayPolygonsFill )
needs_repaint = true;
m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = option;
displayOptions.m_DisplayPolygonsFill = option;
m_Parent->SetElementVisibility( LAYER_DCODES, m_OptDisplayDCodes->GetValue() );

View File

@ -38,7 +38,7 @@ bool PANEL_GERBVIEW_SETTINGS::TransferDataToWindow( )
{
m_PolarDisplay->SetSelection( m_Parent->GetShowPolarCoords() ? 1 : 0 );
m_BoxUnits->SetSelection( m_Parent->GetUserUnits() ? 1 : 0 );
m_ShowPageLimitsOpt->SetValue( m_Parent->m_DisplayOptions.m_DisplayPageLimits );
m_ShowPageLimitsOpt->SetValue( m_Parent->GetDisplayOptions().m_DisplayPageLimits );
for( unsigned i = 0; i < arrayDim( g_GerberPageSizeList ); ++i )
{
@ -57,11 +57,15 @@ bool PANEL_GERBVIEW_SETTINGS::TransferDataFromWindow()
{
m_Parent->SetShowPolarCoords( m_PolarDisplay->GetSelection() != 0 );
m_Parent->SetUserUnits( m_BoxUnits->GetSelection() == 0 ? INCHES : MILLIMETRES );
m_Parent->m_DisplayOptions.m_DisplayPageLimits = m_ShowPageLimitsOpt->GetValue();
auto opts = m_Parent->GetDisplayOptions();
opts.m_DisplayPageLimits = m_ShowPageLimitsOpt->GetValue();
PAGE_INFO pageInfo( g_GerberPageSizeList[ m_PageSize->GetSelection() ] );
m_Parent->SetPageSettings( pageInfo );
m_Parent->UpdateDisplayOptions( opts );
return true;
}

View File

@ -57,7 +57,7 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
if( frame )
{
auto displ_opts = (GBR_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
auto& displ_opts = frame->GetDisplayOptions();
static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() )
->LoadDisplayOptions( displ_opts );
UseColorScheme( frame->m_colorsSettings );
@ -107,7 +107,7 @@ void GERBVIEW_DRAW_PANEL_GAL::OnShow()
if( frame )
{
SetTopLayer( frame->GetActiveLayer() );
GBR_DISPLAY_OPTIONS* displ_opts = (GBR_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
auto& displ_opts = frame->GetDisplayOptions();
static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>(
m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts );
}

View File

@ -462,7 +462,7 @@ void GERBVIEW_FRAME::applyDisplaySettingsToGAL()
{
auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
settings->LoadDisplayOptions( &m_DisplayOptions );
settings->LoadDisplayOptions( m_DisplayOptions );
settings->ImportLegacyColors( m_colorsSettings );

View File

@ -57,12 +57,26 @@ class REPORTER;
class GERBVIEW_FRAME : public EDA_DRAW_FRAME // PCB_BASE_FRAME
{
GBR_LAYOUT* m_gerberLayout;
wxPoint m_grid_origin;
PAGE_INFO m_paper; // used only to show paper limits to screen
GBR_LAYOUT* m_gerberLayout;
wxPoint m_grid_origin;
PAGE_INFO m_paper; // used only to show paper limits to screen
GBR_DISPLAY_OPTIONS m_DisplayOptions;
public:
GBR_DISPLAY_OPTIONS m_DisplayOptions;
/**
* Function GetDisplayOptions
* returns the display options current in use
*/
const GBR_DISPLAY_OPTIONS& GetDisplayOptions() const
{
return m_DisplayOptions;
}
void SetDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
{
m_DisplayOptions = aOptions;
}
/**
* Function SetLayout

View File

@ -76,20 +76,18 @@ void GERBVIEW_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS*
}
void GERBVIEW_RENDER_SETTINGS::LoadDisplayOptions( const GBR_DISPLAY_OPTIONS* aOptions )
void GERBVIEW_RENDER_SETTINGS::LoadDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
{
if( aOptions == NULL )
return;
m_spotFill = aOptions->m_DisplayFlashedItemsFill;
m_lineFill = aOptions->m_DisplayLinesFill;
m_polygonFill = aOptions->m_DisplayPolygonsFill;
m_showNegativeItems = aOptions->m_DisplayNegativeObjects;
m_showCodes = aOptions->m_DisplayDCodes;
m_diffMode = aOptions->m_DiffMode;
m_hiContrastEnabled = aOptions->m_HighContrastMode;
m_showPageLimits = aOptions->m_DisplayPageLimits;
m_backgroundColor = aOptions->m_BgDrawColor;
m_spotFill = aOptions.m_DisplayFlashedItemsFill;
m_lineFill = aOptions.m_DisplayLinesFill;
m_polygonFill = aOptions.m_DisplayPolygonsFill;
m_showNegativeItems = aOptions.m_DisplayNegativeObjects;
m_showCodes = aOptions.m_DisplayDCodes;
m_diffMode = aOptions.m_DiffMode;
m_hiContrastEnabled = aOptions.m_HighContrastMode;
m_showPageLimits = aOptions.m_DisplayPageLimits;
m_backgroundColor = aOptions.m_BgDrawColor;
update();
}

View File

@ -59,7 +59,7 @@ public:
* Loads settings related to display options
* @param aOptions are settings that you want to use for displaying items.
*/
void LoadDisplayOptions( const GBR_DISPLAY_OPTIONS* aOptions );
void LoadDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions );
/// @copydoc RENDER_SETTINGS::GetColor()
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;

View File

@ -96,7 +96,7 @@ int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
{
bool state;
bool needs_refresh = false;
GBR_DISPLAY_OPTIONS options = m_frame->m_DisplayOptions;
auto options = m_frame->GetDisplayOptions();
if( aEvent.IsAction( &GERBVIEW_ACTIONS::linesDisplayOutlines ) )
{

View File

@ -512,7 +512,7 @@ bool GERBVIEW_SELECTION_TOOL::selectable( const EDA_ITEM* aItem ) const
}
// We do not want to select items that are in the background
if( frame->m_DisplayOptions.m_HighContrastMode && layer != frame->GetActiveLayer() )
if( frame->GetDisplayOptions().m_HighContrastMode && layer != frame->GetActiveLayer() )
return false;
return frame->IsLayerVisible( layer );

View File

@ -486,13 +486,6 @@ public:
virtual EDA_DRAW_PANEL_GAL* GetCanvas() const { return m_canvas; }
void SetCanvas( EDA_DRAW_PANEL_GAL* aPanel ) { m_canvas = aPanel; }
/**
* A way to pass info to draw functions. the base class has no knowledge about
* these options. It is virtual because this function must be overloaded to
* pass usefull info.
*/
virtual void* GetDisplayOptions() { return NULL; }
/**
* Return a reference to the gal rendering options used by GAL for rendering.
*/

View File

@ -67,16 +67,17 @@ class FP_LIB_TABLE;
class PCB_BASE_FRAME : public EDA_DRAW_FRAME
{
public:
PCB_DISPLAY_OPTIONS m_DisplayOptions;
wxPoint m_UserGridSize;
int m_FastGrid1; // 1st fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox)
int m_FastGrid2; // 2nd fast grid setting (index in EDA_DRAW_FRAME::m_gridSelectBox)
protected:
BOARD* m_Pcb;
BOARD* m_Pcb;
PCB_GENERAL_SETTINGS m_configSettings;
PCB_DISPLAY_OPTIONS m_DisplayOptions;
PCB_GENERAL_SETTINGS m_configSettings;
void updateZoomSelectBox();
virtual void unitsChangeRefresh() override;
@ -165,10 +166,16 @@ public:
* returns the display options current in use
* Display options are relative to the way tracks, vias, outlines
* and other things are shown (for instance solid or sketch mode)
* Must be overloaded in frames which have display options
* (board editor and footprint editor)
*/
void* GetDisplayOptions() override { return &m_DisplayOptions; }
const PCB_DISPLAY_OPTIONS& GetDisplayOptions() const
{
return m_DisplayOptions;
}
void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
{
m_DisplayOptions = aOptions;
}
const ZONE_SETTINGS& GetZoneSettings() const;
void SetZoneSettings( const ZONE_SETTINGS& aSettings );

View File

@ -150,7 +150,7 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
m_reporter->Report( msg, REPORTER::RPT_ACTION );
// Set the pads ratsnest settings to the global settings
bool set_ratsnest = ((PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions())->m_ShowGlobalRatsnest;
bool set_ratsnest = m_frame->GetDisplayOptions().m_ShowGlobalRatsnest;
for ( auto pad : footprint->Pads() )
pad->SetLocalRatsnestVisible( set_ratsnest );

View File

@ -362,8 +362,8 @@ void DIMENSION::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset )
m_Text.Print( aFrame, DC, offset );
auto gcolor = aFrame->Settings().Colors().GetLayerColor( m_Layer );
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED;
auto displ_opts = aFrame->GetDisplayOptions();
bool filled = displ_opts.m_DisplayDrawItemsFill;
int width = m_Width;
if( filled )

View File

@ -357,7 +357,7 @@ void DRAWSEGMENT::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffse
return;
auto color = aFrame->Settings().Colors().GetLayerColor( GetLayer() );
auto displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions();
auto displ_opts = aFrame->GetDisplayOptions();
l_trace = m_Width >> 1; // half trace width
@ -369,7 +369,7 @@ void DRAWSEGMENT::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffse
dx = m_End.x + aOffset.x;
dy = m_End.y + aOffset.y;
bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED;
bool filled = displ_opts.m_DisplayDrawItemsFill;
if( m_Flags & FORCE_SKETCH )
filled = SKETCH;

View File

@ -127,7 +127,7 @@ void EDGE_MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset
return;
auto color = aFrame->Settings().Colors().GetLayerColor( m_Layer );
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
auto displ_opts = aFrame->GetDisplayOptions();
ux0 = m_Start.x - offset.x;
uy0 = m_Start.y - offset.y;
@ -135,10 +135,10 @@ void EDGE_MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset
dx = m_End.x - offset.x;
dy = m_End.y - offset.y;
bool filled = displ_opts ? displ_opts->m_DisplayModEdgeFill : FILLED;
bool filled = displ_opts.m_DisplayModEdgeFill;
if( IsCopperLayer( m_Layer ) )
filled = displ_opts ? displ_opts->m_DisplayPcbTrackFill : FILLED;
filled = displ_opts.m_DisplayPcbTrackFill;
switch( m_Shape )
{

View File

@ -87,8 +87,8 @@ void PCB_TARGET::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset
return;
auto gcolor = aFrame->Settings().Colors().GetLayerColor( m_Layer );
auto displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions();
bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED;
auto displ_opts = aFrame->GetDisplayOptions();
bool filled = displ_opts.m_DisplayDrawItemsFill;
width = m_Width;
radius = m_Size / 3;

View File

@ -73,9 +73,9 @@ void TEXTE_PCB::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset )
auto color = aFrame->Settings().Colors().GetLayerColor( m_Layer );
EDA_DRAW_MODE_T fillmode = FILLED;
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
auto& displ_opts = aFrame->GetDisplayOptions();
if( displ_opts && displ_opts->m_DisplayDrawItemsFill == SKETCH )
if( displ_opts.m_DisplayDrawItemsFill == SKETCH )
fillmode = SKETCH;
EDA_TEXT::Print( DC, offset, color, fillmode );

View File

@ -287,12 +287,10 @@ void TEXTE_MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOff
color = aFrame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE );
}
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
// Draw mode compensation for the width
int width = GetThickness();
if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH )
if( aFrame->GetDisplayOptions().m_DisplayModTextFill == SKETCH )
width = -width;
wxPoint pos = GetTextPos() - aOffset;

View File

@ -45,14 +45,14 @@
* tests to see if the clearance border is drawn on the given track.
* @return bool - true if should draw clearance, else false.
*/
static bool ShowClearance( PCB_DISPLAY_OPTIONS* aDisplOpts, const TRACK* aTrack )
static bool ShowClearance( const PCB_DISPLAY_OPTIONS& aDisplOpts, const TRACK* aTrack )
{
// maybe return true for tracks and vias, not for zone segments
return IsCopperLayer( aTrack->GetLayer() )
&& ( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_VIA_T )
&& ( ( aDisplOpts->m_ShowTrackClearanceMode == PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS
&& ( ( aDisplOpts.m_ShowTrackClearanceMode == PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS
&& ( aTrack->IsDragging() || aTrack->IsMoving() || aTrack->IsNew() ) )
|| ( aDisplOpts->m_ShowTrackClearanceMode == PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS )
|| ( aDisplOpts.m_ShowTrackClearanceMode == PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS )
);
}
@ -467,7 +467,7 @@ void TRACK::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
if( !brd->IsLayerVisible( m_Layer ) || !brd->IsElementVisible( LAYER_TRACKS ) )
return;
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
auto displ_opts = aFrame->GetDisplayOptions();
color.a = 0.588;
@ -478,7 +478,7 @@ void TRACK::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
return;
}
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
if( !displ_opts.m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
{
GRCSegm( nullptr, aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
}
@ -530,11 +530,11 @@ void VIA::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
int radius;
int fillvia = 0;
PCB_SCREEN* screen = aFrame->GetScreen();
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions();
auto& displ_opts = aFrame->GetDisplayOptions();
BOARD* brd = GetBoard();
COLOR4D color = aFrame->Settings().Colors().GetItemColor( LAYER_VIAS + GetViaType() );
if( displ_opts->m_DisplayViaFill == FILLED )
if( displ_opts.m_DisplayViaFill == FILLED )
fillvia = 1;
if( !brd->IsElementVisible( LAYER_VIAS + GetViaType() ) )
@ -667,7 +667,7 @@ void VIA::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
if( GetNetCode() == NETINFO_LIST::UNCONNECTED )
return;
if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 )
if( displ_opts.m_DisplayNetNamesMode == 0 || displ_opts.m_DisplayNetNamesMode == 1 )
return;
NETINFO_ITEM* net = GetNet();

View File

@ -376,9 +376,9 @@ void ZONE_CONTAINER::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& off
auto color = aFrame->Settings().Colors().GetLayerColor( draw_layer );
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
auto displ_opts = aFrame->GetDisplayOptions();
if( displ_opts->m_ContrastModeDisplay )
if( displ_opts.m_ContrastModeDisplay )
{
if( !IsOnLayer( curr_layer ) )
color = COLOR4D( DARKDARKGRAY );
@ -424,13 +424,13 @@ void ZONE_CONTAINER::PrintFilledArea( PCB_BASE_FRAME* aFrame, wxDC* DC, const wx
BOARD* brd = GetBoard();
KIGFX::COLOR4D color = aFrame->Settings().Colors().GetLayerColor( GetLayer() );
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions();
bool outline_mode = displ_opts->m_DisplayZonesMode == 2;
auto& displ_opts = aFrame->GetDisplayOptions();
bool outline_mode = displ_opts.m_DisplayZonesMode == 2;
if( DC == NULL )
return;
if( displ_opts->m_DisplayZonesMode == 1 ) // Do not show filled areas
if( displ_opts.m_DisplayZonesMode == 1 ) // Do not show filled areas
return;
if( m_FilledPolysList.IsEmpty() ) // Nothing to draw
@ -473,7 +473,7 @@ void ZONE_CONTAINER::PrintFilledArea( PCB_BASE_FRAME* aFrame, wxDC* DC, const wx
for( int is = 0, ie = ilim; is <= ilim; ie = is, is++ )
{
// Draw only basic outlines, not extra segments.
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
if( !displ_opts.m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
{
GRCSegm( nullptr, DC, CornersBuffer[is], CornersBuffer[ie],
outline_thickness, color );

View File

@ -56,12 +56,12 @@ void DIALOG_FP_BROWSER_DISPLAY_OPTIONS::initDialog()
/* mandatory to use escape key as cancel under wxGTK. */
SetFocus();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
auto displ_opts = m_frame->GetDisplayOptions();
m_EdgesDisplayOption->SetValue( not displ_opts->m_DisplayModEdgeFill );
m_TextDisplayOption->SetValue( not displ_opts->m_DisplayModTextFill );
m_ShowPadSketch->SetValue( not displ_opts->m_DisplayPadFill );
m_ShowPadNum->SetValue( displ_opts->m_DisplayPadNum );
m_EdgesDisplayOption->SetValue( not displ_opts.m_DisplayModEdgeFill );
m_TextDisplayOption->SetValue( not displ_opts.m_DisplayModTextFill );
m_ShowPadSketch->SetValue( not displ_opts.m_DisplayPadFill );
m_ShowPadNum->SetValue( displ_opts.m_DisplayPadNum );
m_autoZoomOption->SetValue( m_frame->GetAutoZoom() );
}
@ -69,12 +69,12 @@ void DIALOG_FP_BROWSER_DISPLAY_OPTIONS::initDialog()
void DIALOG_FP_BROWSER_DISPLAY_OPTIONS::UpdateObjectSettings()
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)m_frame->GetDisplayOptions();
auto displ_opts = m_frame->GetDisplayOptions();
displ_opts->m_DisplayModEdgeFill = not m_EdgesDisplayOption->GetValue();
displ_opts->m_DisplayModTextFill = not m_TextDisplayOption->GetValue();
displ_opts->m_DisplayPadNum = m_ShowPadNum->GetValue();
displ_opts->m_DisplayPadFill = not m_ShowPadSketch->GetValue();
displ_opts.m_DisplayModEdgeFill = not m_EdgesDisplayOption->GetValue();
displ_opts.m_DisplayModTextFill = not m_TextDisplayOption->GetValue();
displ_opts.m_DisplayPadNum = m_ShowPadNum->GetValue();
displ_opts.m_DisplayPadFill = not m_ShowPadSketch->GetValue();
m_frame->ApplyDisplaySettingsToGAL();
m_frame->SetAutoZoom( m_autoZoomOption->GetValue() );

View File

@ -56,15 +56,15 @@ PANEL_PCBNEW_DISPLAY_OPTIONS::PANEL_PCBNEW_DISPLAY_OPTIONS( PCB_EDIT_FRAME* aFra
bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataToWindow()
{
const PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_frame->GetDisplayOptions();
auto& displ_opts = m_frame->GetDisplayOptions();
m_OptDisplayTracksClearance->SetSelection( UTIL::GetConfigForVal(
traceClearanceSelectMap, displ_opts->m_ShowTrackClearanceMode ) );
traceClearanceSelectMap, displ_opts.m_ShowTrackClearanceMode ) );
m_OptDisplayPadClearence->SetValue( displ_opts->m_DisplayPadIsol );
m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum );
m_OptDisplayPadClearence->SetValue( displ_opts.m_DisplayPadIsol );
m_OptDisplayPadNumber->SetValue( displ_opts.m_DisplayPadNum );
m_OptDisplayPadNoConn->SetValue( m_frame->IsElementVisible( LAYER_NO_CONNECTS ) );
m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode );
m_ShowNetNamesOption->SetSelection( displ_opts.m_DisplayNetNamesMode );
m_galOptsPanel->TransferDataToWindow();
@ -77,17 +77,17 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataToWindow()
*/
bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow()
{
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_frame->GetDisplayOptions();
PCB_DISPLAY_OPTIONS displ_opts = m_frame->GetDisplayOptions();
displ_opts->m_ShowTrackClearanceMode = UTIL::GetValFromConfig(
displ_opts.m_ShowTrackClearanceMode = UTIL::GetValFromConfig(
traceClearanceSelectMap, m_OptDisplayTracksClearance->GetSelection() );
displ_opts->m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
displ_opts->m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
displ_opts.m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
displ_opts.m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
m_frame->SetElementVisibility( LAYER_NO_CONNECTS, m_OptDisplayPadNoConn->GetValue() );
displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
displ_opts.m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
m_galOptsPanel->TransferDataFromWindow();
@ -96,8 +96,9 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow()
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
m_frame->SetDisplayOptions( displ_opts );
settings->LoadDisplayOptions( displ_opts, m_frame->ShowPageLimits() );
m_frame->SetElementVisibility( LAYER_RATSNEST, displ_opts->m_ShowGlobalRatsnest );
m_frame->SetElementVisibility( LAYER_RATSNEST, displ_opts.m_ShowGlobalRatsnest );
view->RecacheAllItems();
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );

View File

@ -41,16 +41,16 @@ PANEL_PCBNEW_SETTINGS::PANEL_PCBNEW_SETTINGS( PCB_EDIT_FRAME* aFrame, PAGED_DIAL
bool PANEL_PCBNEW_SETTINGS::TransferDataToWindow()
{
const PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_Frame->GetDisplayOptions();
const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions();
const PCB_GENERAL_SETTINGS& general_opts = m_Frame->Settings();
/* Set display options */
m_PolarDisplay->SetSelection( m_Frame->GetShowPolarCoords() ? 1 : 0 );
m_UnitsSelection->SetSelection( m_Frame->GetUserUnits() == INCHES ? 0 : 1 );
m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts->m_DisplayRatsnestLinesCurved );
m_showGlobalRatsnest->SetValue( displ_opts->m_ShowGlobalRatsnest );
m_showSelectedRatsnest->SetValue( displ_opts->m_ShowModuleRatsnest );
m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts->m_DisplayRatsnestLinesCurved );
m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts.m_DisplayRatsnestLinesCurved );
m_showGlobalRatsnest->SetValue( displ_opts.m_ShowGlobalRatsnest );
m_showSelectedRatsnest->SetValue( displ_opts.m_ShowModuleRatsnest );
m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts.m_DisplayRatsnestLinesCurved );
wxString rotationAngle;
rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() );
@ -86,15 +86,16 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow()
m_Frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
// Apply changes to the GAL
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_Frame->GetDisplayOptions();
PCB_DISPLAY_OPTIONS displ_opts = m_Frame->GetDisplayOptions();
KIGFX::VIEW* view = m_Frame->GetCanvas()->GetView();
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
displ_opts->m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
displ_opts->m_ShowGlobalRatsnest = m_showGlobalRatsnest->GetValue();
displ_opts->m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
displ_opts.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
displ_opts.m_ShowGlobalRatsnest = m_showGlobalRatsnest->GetValue();
displ_opts.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
m_Frame->SetDisplayOptions( displ_opts );
settings->LoadDisplayOptions( displ_opts, m_Frame->ShowPageLimits() );
view->RecacheAllItems();
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );

View File

@ -50,7 +50,7 @@
void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto displ_opts = GetDisplayOptions();
switch( id ) // Execute command
{
@ -60,7 +60,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_TOOLBARH_PCB_SELECT_LAYER:
SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) );
if( displ_opts->m_ContrastModeDisplay )
if( displ_opts.m_ContrastModeDisplay )
GetCanvas()->Refresh();
break;
@ -82,7 +82,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer )
{
PCB_LAYER_ID curLayer = GetActiveLayer();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto displ_opts = GetDisplayOptions();
// Check if the specified layer matches the present layer
if( layer == curLayer )
@ -118,7 +118,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer )
SetActiveLayer( layer );
if( displ_opts->m_ContrastModeDisplay )
if( displ_opts.m_ContrastModeDisplay )
GetCanvas()->Refresh();
}

View File

@ -34,7 +34,7 @@
PARAM_CFG_ARRAY& FOOTPRINT_EDIT_FRAME::GetConfigurationSettings()
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto& displ_opts = m_DisplayOptions;
BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();
// Update everything
@ -44,13 +44,13 @@ PARAM_CFG_ARRAY& FOOTPRINT_EDIT_FRAME::GetConfigurationSettings()
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorDisplayPolarCoords" ),
&m_PolarCoords, false ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorPadDisplayMode" ),
&displ_opts->m_DisplayPadFill, true ) );
&displ_opts.m_DisplayPadFill, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorGraphicLinesDisplayMode" ),
&displ_opts->m_DisplayModEdgeFill, FILLED ) );
&displ_opts.m_DisplayModEdgeFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ),
&displ_opts->m_DisplayModTextFill, FILLED ) );
&displ_opts.m_DisplayModTextFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ),
&displ_opts->m_DisplayModTextFill, FILLED ) );
&displ_opts.m_DisplayModTextFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_WXSTRING( true, wxT( "FpEditorTextsRefDefaultText" ),
&settings.m_RefDefaultText, wxT( "REF**" ) ) );

View File

@ -311,7 +311,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_TOOLBARH_PCB_SELECT_LAYER:
SetActiveLayer( ToLAYER_ID( m_selLayerBox->GetLayerSelection() ) );
if( static_cast<PCB_DISPLAY_OPTIONS*>( GetDisplayOptions() )->m_ContrastModeDisplay )
if( GetDisplayOptions().m_ContrastModeDisplay )
GetCanvas()->Refresh();
break;

View File

@ -945,7 +945,7 @@ void FOOTPRINT_VIEWER_FRAME::ApplyDisplaySettingsToGAL()
{
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
settings->LoadDisplayOptions( &m_DisplayOptions, false );
settings->LoadDisplayOptions( m_DisplayOptions, false );
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
GetCanvas()->Refresh();

View File

@ -115,14 +115,16 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
if( caller )
SetUserUnits( caller->GetUserUnits() );
auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions();
// In viewer, the default net clearance is not known (it depends on the actual board).
// So we do not show the default clearance, by setting it to 0
// The footprint or pad specific clearance will be shown
GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
disp_opts->m_DisplayPadIsol = true;
disp_opts->m_DisplayPadNum = true;
disp_opts.m_DisplayPadIsol = true;
disp_opts.m_DisplayPadNum = true;
SetDisplayOptions( disp_opts );
GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );

View File

@ -58,7 +58,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal )
// Items visibility flags will be set because a new board will be created.
// Grid and ratsnest can be left to their previous state
bool showGrid = IsElementVisible( LAYER_GRID );
bool showRats = m_DisplayOptions.m_ShowGlobalRatsnest;
bool showRats = GetDisplayOptions().m_ShowGlobalRatsnest;
if( !aFinal )
{

View File

@ -159,13 +159,13 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
return GetGalDisplayOptions().m_fullscreenCursor;
};
auto sketchPadsCondition = [ this ] ( const SELECTION& aSel ) {
return !( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayPadFill;
return !GetDisplayOptions().m_DisplayPadFill;
};
auto sketchEdgesCondition = [ this ] ( const SELECTION& aSel ) {
return !( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayModEdgeFill;
return !GetDisplayOptions().m_DisplayModEdgeFill;
};
auto contrastModeCondition = [ this ] ( const SELECTION& aSel ) {
return !( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_ContrastModeDisplay;
return !GetDisplayOptions().m_ContrastModeDisplay;
};
auto searchTreeShownCondition = [ this ] ( const SELECTION& aSel ) {
return IsSearchTreeShown();

View File

@ -59,7 +59,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
//
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
static ACTION_MENU* openRecentMenu;
auto disp_opt = static_cast<PCB_DISPLAY_OPTIONS*>( GetDisplayOptions() );
auto& disp_opt = GetDisplayOptions();
if( Kiface().IsSingle() ) // not when under a project mgr
{
@ -266,35 +266,35 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalDisplayOptions().m_fullscreenCursor;
};
auto ratsnestShownCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return disp_opt->m_ShowGlobalRatsnest;
auto ratsnestShownCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return disp_opt.m_ShowGlobalRatsnest;
};
auto curvedRatsnestCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return disp_opt->m_DisplayRatsnestLinesCurved;
auto curvedRatsnestCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return disp_opt.m_DisplayRatsnestLinesCurved;
};
auto boardFlippedCondition = [ this ] ( const SELECTION& aSel ) {
return GetCanvas()->GetView()->IsMirroredX();
};
auto zonesFilledCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return disp_opt->m_DisplayZonesMode == 0;
auto zonesFilledCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return disp_opt.m_DisplayZonesMode == 0;
};
auto zonesWireframedCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return disp_opt->m_DisplayZonesMode == 1;
auto zonesWireframedCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return disp_opt.m_DisplayZonesMode == 1;
};
auto zonesOutlinedCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return disp_opt->m_DisplayZonesMode == 2;
auto zonesOutlinedCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return disp_opt.m_DisplayZonesMode == 2;
};
auto sketchTracksCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return !disp_opt->m_DisplayPcbTrackFill;
auto sketchTracksCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return !disp_opt.m_DisplayPcbTrackFill;
};
auto sketchViasCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return !disp_opt->m_DisplayViaFill;
auto sketchViasCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return !disp_opt.m_DisplayViaFill;
};
auto sketchPadsCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return !disp_opt->m_DisplayPadFill;
return !disp_opt.m_DisplayPadFill;
};
auto contrastModeCondition = [ this, disp_opt ] ( const SELECTION& aSel ) {
return !disp_opt->m_ContrastModeDisplay;
auto contrastModeCondition = [ this, &disp_opt ] ( const SELECTION& aSel ) {
return !disp_opt.m_ContrastModeDisplay;
};
viewMenu->AddCheckItem( PCB_ACTIONS::showLayersManager, layersPaletteShownCondition );

View File

@ -98,10 +98,10 @@ void D_PAD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
return;
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
auto& displ_opts = aFrame->GetDisplayOptions();
PCB_SCREEN* screen = aFrame->GetScreen();
if( displ_opts && displ_opts->m_DisplayPadFill == SKETCH )
if( displ_opts.m_DisplayPadFill == SKETCH )
drawInfo.m_ShowPadFilled = false;
else
drawInfo.m_ShowPadFilled = true;
@ -152,7 +152,7 @@ void D_PAD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
mask_margin.y = std::max( mask_margin.y, GetSolderMaskMargin() );
}
bool DisplayIsol = displ_opts && displ_opts->m_DisplayPadIsol;
bool DisplayIsol = displ_opts.m_DisplayPadIsol;
if( !( m_layerMask & LSET::AllCuMask() ).any() )
DisplayIsol = false;
@ -185,11 +185,10 @@ void D_PAD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
drawInfo.m_PadClearance = DisplayIsol ? GetClearance() : 0;
// Draw the pad number
if( displ_opts && !displ_opts->m_DisplayPadNum )
if( !displ_opts.m_DisplayPadNum )
drawInfo.m_Display_padnum = false;
if( displ_opts &&
(( displ_opts ->m_DisplayNetNamesMode == 0 ) || ( displ_opts->m_DisplayNetNamesMode == 2 )) )
if( ( displ_opts.m_DisplayNetNamesMode == 0 ) || ( displ_opts.m_DisplayNetNamesMode == 2 ) )
drawInfo.m_Display_netname = false;
PrintShape( aDC, drawInfo );

View File

@ -391,7 +391,7 @@ EDA_3D_VIEWER* PCB_BASE_FRAME::CreateAndShow3D_Frame()
void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer )
{
PCB_LAYER_ID preslayer = GetActiveLayer();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto& displ_opts = GetDisplayOptions();
// Check if the specified layer matches the present layer
if( layer == preslayer )
@ -425,16 +425,16 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer )
SetActiveLayer( layer );
if( displ_opts->m_ContrastModeDisplay )
if( displ_opts.m_ContrastModeDisplay )
GetCanvas()->Refresh();
}
void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto displ_opts = GetDisplayOptions();
displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill;
displ_opts.m_DisplayPadFill = !displ_opts.m_DisplayPadFill;
if( GetCanvas() )
{
@ -451,22 +451,24 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
}
}
SetDisplayOptions( displ_opts );
GetCanvas()->Refresh();
}
void PCB_BASE_FRAME::OnToggleGraphicDrawMode( wxCommandEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
displ_opts->m_DisplayDrawItemsFill = !displ_opts->m_DisplayDrawItemsFill;
auto displ_opts = GetDisplayOptions();
displ_opts.m_DisplayDrawItemsFill = !displ_opts.m_DisplayDrawItemsFill;
SetDisplayOptions( displ_opts );
GetCanvas()->Refresh();
}
void PCB_BASE_FRAME::OnToggleEdgeDrawMode( wxCommandEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
displ_opts->m_DisplayModEdgeFill = !displ_opts->m_DisplayModEdgeFill;
auto displ_opts = GetDisplayOptions();
displ_opts.m_DisplayModEdgeFill = !displ_opts.m_DisplayModEdgeFill;
if( GetCanvas() )
{
@ -476,14 +478,15 @@ void PCB_BASE_FRAME::OnToggleEdgeDrawMode( wxCommandEvent& aEvent )
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
SetDisplayOptions( displ_opts );
GetCanvas()->Refresh();
}
void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
displ_opts->m_DisplayModTextFill = !displ_opts->m_DisplayModTextFill;
auto displ_opts = GetDisplayOptions();
displ_opts.m_DisplayModTextFill = !displ_opts.m_DisplayModTextFill;
if( GetCanvas() )
{
@ -493,6 +496,7 @@ void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent )
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
SetDisplayOptions( displ_opts );
GetCanvas()->Refresh();
}
@ -858,7 +862,7 @@ void PCB_BASE_FRAME::ActivateGalCanvas()
// Transfer latest current display options from legacy to GAL canvas:
auto painter = static_cast<KIGFX::PCB_PAINTER*>( canvas->GetView()->GetPainter() );
auto settings = painter->GetSettings();
auto displ_opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
auto displ_opts = GetDisplayOptions();
settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
canvas->GetView()->RecacheAllItems();

View File

@ -124,13 +124,11 @@ PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
// 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)
// which is not always the case (namely when it is used from a wxDialog like the pad editor)
EDA_DRAW_FRAME* frame = GetParentEDAFrame();
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
if( frame )
{
auto opts = (PCB_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
static_cast<KIGFX::PCB_VIEW*>( m_view )->UpdateDisplayOptions( opts );
}
static_cast<KIGFX::PCB_VIEW*>( m_view )->UpdateDisplayOptions(
frame->GetDisplayOptions() );
}
@ -394,10 +392,9 @@ void PCB_DRAW_PANEL_GAL::OnShow()
if( frame )
{
SetTopLayer( frame->GetActiveLayer() );
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
KIGFX::PAINTER* painter = m_view->GetPainter();
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
settings->LoadDisplayOptions( displ_opts, frame->ShowPageLimits() );
settings->LoadDisplayOptions( frame->GetDisplayOptions(), frame->ShowPageLimits() );
}
}

View File

@ -665,8 +665,7 @@ void PCB_EDIT_FRAME::onBoardLoaded()
syncLayerWidgetLayer();
syncRenderStates();
SetElementVisibility( LAYER_RATSNEST,
static_cast<PCB_DISPLAY_OPTIONS*>( GetDisplayOptions() )->m_ShowGlobalRatsnest );
SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest );
// Update the tracks / vias available sizes list:
ReCreateAuxiliaryToolbar();

View File

@ -409,8 +409,7 @@ void PCB_LAYER_WIDGET::ReFillRender()
}
if( renderRow.id == LAYER_RATSNEST )
renderRow.state =
static_cast<PCB_DISPLAY_OPTIONS*>( myframe->GetDisplayOptions() )->m_ShowGlobalRatsnest;
renderRow.state = myframe->GetDisplayOptions().m_ShowGlobalRatsnest;
else
renderRow.state = board->IsElementVisible(
static_cast<GAL_LAYER_ID>( renderRow.id ) );
@ -600,11 +599,10 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
return false;
myframe->SetActiveLayer( layer );
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*)myframe->GetDisplayOptions();
if( m_alwaysShowActiveCopperLayer )
OnLayerSelected();
else if( displ_opts->m_ContrastModeDisplay )
else if( myframe->GetDisplayOptions().m_ContrastModeDisplay )
myframe->GetCanvas()->Refresh();
return true;
@ -709,8 +707,8 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
if( myframe->IsType( FRAME_PCB_EDITOR ) )
{
auto opt = static_cast<PCB_DISPLAY_OPTIONS*>( myframe->GetDisplayOptions() );
opt->m_ShowGlobalRatsnest = isEnabled;
PCB_DISPLAY_OPTIONS opt = myframe->GetDisplayOptions();
opt.m_ShowGlobalRatsnest = isEnabled;
myframe->GetCanvas()->GetView()->UpdateDisplayOptions( opt );
}
}

View File

@ -156,10 +156,11 @@ void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset )
static void Trace_Pads_Only( PCB_BASE_FRAME* aFrame, wxDC* DC, MODULE* aModule,
int ox, int oy, LSET aLayerMask )
{
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions();
int tmp = displ_opts->m_DisplayPadFill;
PCB_DISPLAY_OPTIONS displ_opts = aFrame->GetDisplayOptions();
int tmp = displ_opts.m_DisplayPadFill;
displ_opts->m_DisplayPadFill = false;
displ_opts.m_DisplayPadFill = false;
aFrame->SetDisplayOptions( displ_opts );
// Draw pads.
for( auto pad : aModule->Pads() )
@ -170,5 +171,6 @@ static void Trace_Pads_Only( PCB_BASE_FRAME* aFrame, wxDC* DC, MODULE* aModule,
pad->Print( aFrame, DC, wxPoint( ox, oy ) );
}
displ_opts->m_DisplayPadFill = tmp;
displ_opts.m_DisplayPadFill = tmp;
aFrame->SetDisplayOptions( displ_opts );
}

View File

@ -127,29 +127,26 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSet
}
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOptions,
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions,
bool aShowPageLimits )
{
if( aOptions == NULL )
return;
m_hiContrastEnabled = aOptions->m_ContrastModeDisplay;
m_padNumbers = aOptions->m_DisplayPadNum;
m_sketchBoardGfx = !aOptions->m_DisplayDrawItemsFill;
m_sketchFpGfx = !aOptions->m_DisplayModEdgeFill;
m_sketchFpTxtfx = !aOptions->m_DisplayModTextFill;
m_curvedRatsnestlines = aOptions->m_DisplayRatsnestLinesCurved;
m_globalRatsnestlines = aOptions->m_ShowGlobalRatsnest;
m_hiContrastEnabled = aOptions.m_ContrastModeDisplay;
m_padNumbers = aOptions.m_DisplayPadNum;
m_sketchBoardGfx = !aOptions.m_DisplayDrawItemsFill;
m_sketchFpGfx = !aOptions.m_DisplayModEdgeFill;
m_sketchFpTxtfx = !aOptions.m_DisplayModTextFill;
m_curvedRatsnestlines = aOptions.m_DisplayRatsnestLinesCurved;
m_globalRatsnestlines = aOptions.m_ShowGlobalRatsnest;
// Whether to draw tracks, vias & pads filled or as outlines
m_sketchMode[LAYER_PADS_TH] = !aOptions->m_DisplayPadFill;
m_sketchMode[LAYER_VIA_THROUGH] = !aOptions->m_DisplayViaFill;
m_sketchMode[LAYER_VIA_BBLIND] = !aOptions->m_DisplayViaFill;
m_sketchMode[LAYER_VIA_MICROVIA] = !aOptions->m_DisplayViaFill;
m_sketchMode[LAYER_TRACKS] = !aOptions->m_DisplayPcbTrackFill;
m_sketchMode[LAYER_PADS_TH] = !aOptions.m_DisplayPadFill;
m_sketchMode[LAYER_VIA_THROUGH] = !aOptions.m_DisplayViaFill;
m_sketchMode[LAYER_VIA_BBLIND] = !aOptions.m_DisplayViaFill;
m_sketchMode[LAYER_VIA_MICROVIA] = !aOptions.m_DisplayViaFill;
m_sketchMode[LAYER_TRACKS] = !aOptions.m_DisplayPcbTrackFill;
// Net names display settings
switch( aOptions->m_DisplayNetNamesMode )
switch( aOptions.m_DisplayNetNamesMode )
{
case 0:
m_netNamesOnPads = false;
@ -173,7 +170,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption
}
// Zone display settings
switch( aOptions->m_DisplayZonesMode )
switch( aOptions.m_DisplayZonesMode )
{
case 0:
m_displayZone = DZ_SHOW_FILLED;
@ -189,7 +186,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption
}
// Clearance settings
switch( aOptions->m_ShowTrackClearanceMode )
switch( aOptions.m_ShowTrackClearanceMode )
{
case PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE:
m_clearance = CL_NONE;
@ -212,7 +209,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption
break;
}
if( aOptions->m_DisplayPadIsol )
if( aOptions.m_DisplayPadIsol )
m_clearance |= CL_PADS;
m_showPageLimits = aShowPageLimits;

View File

@ -98,7 +98,7 @@ public:
* for vias/pads/tracks and so on).
* @param aOptions are settings that you want to use for displaying items.
*/
void LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOptions, bool aShowPageLimits );
void LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aShowPageLimits );
/// @copydoc RENDER_SETTINGS::GetColor()
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;

View File

@ -110,7 +110,7 @@ void PCB_VIEW::Update( KIGFX::VIEW_ITEM* aItem )
}
void PCB_VIEW::UpdateDisplayOptions( PCB_DISPLAY_OPTIONS* aOptions )
void PCB_VIEW::UpdateDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
{
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetPainter() );
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );

View File

@ -51,7 +51,7 @@ public:
/// @copydoc VIEW::Update()
virtual void Update( VIEW_ITEM* aItem ) override;
void UpdateDisplayOptions( PCB_DISPLAY_OPTIONS* aOptions );
void UpdateDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions );
};
}

View File

@ -150,7 +150,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters()
PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto displ_opts = m_DisplayOptions;
if( m_configParams.empty() )
{
@ -158,40 +158,40 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
&m_PolarCoords, false ) );
// Display options and modes:
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "ShowNetNamesMode" ),
&displ_opts->m_DisplayNetNamesMode, 3, 0, 3 ) );
&displ_opts.m_DisplayNetNamesMode, 3, 0, 3 ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayTrackFilled" ),
&displ_opts->m_DisplayPcbTrackFill, true ) );
&displ_opts.m_DisplayPcbTrackFill, true ) );
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "TrackDisplayClearance" ),
(int*) &displ_opts->m_ShowTrackClearanceMode,
(int*) &displ_opts.m_ShowTrackClearanceMode,
PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadFill" ),
&displ_opts->m_DisplayPadFill, true ) );
&displ_opts.m_DisplayPadFill, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ViaFill" ),
&displ_opts->m_DisplayViaFill, true ) );
&displ_opts.m_DisplayViaFill, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadAffG" ),
&displ_opts->m_DisplayPadIsol, true ) );
&displ_opts.m_DisplayPadIsol, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadSNum" ),
&displ_opts->m_DisplayPadNum, true ) );
&displ_opts.m_DisplayPadNum, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffC" ),
&displ_opts->m_DisplayModEdgeFill, FILLED ) );
&displ_opts.m_DisplayModEdgeFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffT" ),
&displ_opts->m_DisplayModTextFill, FILLED ) );
&displ_opts.m_DisplayModTextFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PcbAffT" ),
&displ_opts->m_DisplayDrawItemsFill, FILLED ) );
&displ_opts.m_DisplayDrawItemsFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ),
&displ_opts->m_DisplayZonesMode, 0, 0, 2 ) );
&displ_opts.m_DisplayZonesMode, 0, 0, 2 ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "CurvedRatsnestLines" ),
&displ_opts->m_DisplayRatsnestLinesCurved, false ) );
&displ_opts.m_DisplayRatsnestLinesCurved, false ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestLines" ),
&displ_opts->m_ShowGlobalRatsnest, true) );
&displ_opts.m_ShowGlobalRatsnest, true) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestModuleLines" ),
&displ_opts->m_ShowModuleRatsnest, true) );
&displ_opts.m_ShowModuleRatsnest, true) );
// Miscellaneous:
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ),
&m_rotationAngle, 900, 1, 900 ) );
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ),
&displ_opts->m_MaxLinksShowed, 3, 0, 15 ) );
&displ_opts.m_MaxLinksShowed, 3, 0, 15 ) );
}
return m_configParams;

View File

@ -1222,30 +1222,27 @@ void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClea
{
pitem->SetClearance( aClearance );
if( m_dispOptions )
switch( m_dispOptions->m_ShowTrackClearanceMode )
{
switch( m_dispOptions->m_ShowTrackClearanceMode )
{
case PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE:
pitem->ShowTrackClearance( false );
pitem->ShowViaClearance( false );
break;
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS:
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS:
pitem->ShowTrackClearance( true );
pitem->ShowViaClearance( true );
break;
case PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE:
pitem->ShowTrackClearance( false );
pitem->ShowViaClearance( false );
break;
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS:
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS:
pitem->ShowTrackClearance( true );
pitem->ShowViaClearance( true );
break;
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS:
pitem->ShowTrackClearance( !aEdit );
pitem->ShowViaClearance( !aEdit );
break;
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS:
pitem->ShowTrackClearance( !aEdit );
pitem->ShowViaClearance( !aEdit );
break;
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS:
pitem->ShowTrackClearance( !aEdit );
pitem->ShowViaClearance( false );
break;
}
case PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS:
pitem->ShowTrackClearance( !aEdit );
pitem->ShowViaClearance( false );
break;
}
}
@ -1383,7 +1380,7 @@ void PNS_KICAD_IFACE::SetHostTool( PCB_TOOL_BASE* aTool )
m_commit.reset( new BOARD_COMMIT( m_tool ) );
}
void PNS_KICAD_IFACE::SetDisplayOptions( PCB_DISPLAY_OPTIONS *aDispOptions )
void PNS_KICAD_IFACE::SetDisplayOptions( const PCB_DISPLAY_OPTIONS* aDispOptions )
{
m_dispOptions = aDispOptions;
}

View File

@ -46,7 +46,7 @@ public:
void SetRouter( PNS::ROUTER* aRouter ) override;
void SetHostTool( PCB_TOOL_BASE* aTool );
void SetDisplayOptions( PCB_DISPLAY_OPTIONS* aDispOptions );
void SetDisplayOptions( const PCB_DISPLAY_OPTIONS* aDispOptions );
void SetBoard( BOARD* aBoard );
void SetView( KIGFX::VIEW* aView );
@ -84,7 +84,7 @@ private:
BOARD* m_board;
PCB_TOOL_BASE* m_tool;
std::unique_ptr<BOARD_COMMIT> m_commit;
PCB_DISPLAY_OPTIONS* m_dispOptions;
const PCB_DISPLAY_OPTIONS* m_dispOptions;
};
#endif

View File

@ -96,7 +96,7 @@ void TOOL_BASE::Reset( RESET_REASON aReason )
m_iface->SetBoard( board() );
m_iface->SetView( getView() );
m_iface->SetHostTool( this );
m_iface->SetDisplayOptions( (PCB_DISPLAY_OPTIONS*) frame()->GetDisplayOptions() );
m_iface->SetDisplayOptions( &( frame()->GetDisplayOptions() ) );
m_router = new ROUTER;
m_router->SetInterface( m_iface );
@ -192,7 +192,7 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
{
ITEM* item = prioritized[i];
if( displayOptions()->m_ContrastModeDisplay )
if( displayOptions().m_ContrastModeDisplay )
if( item && !item->Layers().Overlaps( tl ) )
item = NULL;

View File

@ -219,7 +219,7 @@ void FOOTPRINT_EDIT_FRAME::SyncToolbars()
{
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
auto& opts = GetDisplayOptions();
if( IsCurrentFPFromBoard() )
m_mainToolBar->Toggle( PCB_ACTIONS::saveToBoard, GetScreen() && GetScreen()->IsModify() );
@ -236,9 +236,9 @@ void FOOTPRINT_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );
m_optionsToolBar->Toggle( ACTIONS::togglePolarCoords, GetShowPolarCoords() );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts->m_DisplayPadFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::moduleEdgeOutlines, !opts->m_DisplayModEdgeFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts->m_ContrastModeDisplay );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts.m_DisplayPadFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::moduleEdgeOutlines, !opts.m_DisplayModEdgeFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts.m_ContrastModeDisplay );
m_optionsToolBar->Toggle( PCB_ACTIONS::toggleFootprintTree, IsSearchTreeShown() );
m_optionsToolBar->Refresh();

View File

@ -663,9 +663,9 @@ void PCB_EDIT_FRAME::SyncToolbars()
{
#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) )
PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
auto& opts = GetDisplayOptions();
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
int zoneMode = opts->m_DisplayZonesMode;
int zoneMode = opts.m_DisplayZonesMode;
m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
@ -687,18 +687,18 @@ void PCB_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );
m_optionsToolBar->Toggle( ACTIONS::togglePolarCoords, GetShowPolarCoords() );
m_optionsToolBar->Toggle( ACTIONS::toggleCursorStyle, !galOpts.m_fullscreenCursor );
m_optionsToolBar->Toggle( PCB_ACTIONS::showRatsnest, opts->m_ShowGlobalRatsnest );
m_optionsToolBar->Toggle( PCB_ACTIONS::ratsnestLineMode, opts->m_DisplayRatsnestLinesCurved );
m_optionsToolBar->Toggle( PCB_ACTIONS::showRatsnest, opts.m_ShowGlobalRatsnest );
m_optionsToolBar->Toggle( PCB_ACTIONS::ratsnestLineMode, opts.m_DisplayRatsnestLinesCurved );
m_optionsToolBar->Toggle( PCB_ACTIONS::showLayersManager, LayerManagerShown() );
m_optionsToolBar->Toggle( PCB_ACTIONS::showMicrowaveToolbar, MicrowaveToolbarShown() );
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayEnable, zoneMode == 0 );
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayDisable, zoneMode == 1 );
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayOutlines, zoneMode == 2 );
m_optionsToolBar->Toggle( PCB_ACTIONS::trackDisplayMode, !opts->m_DisplayPcbTrackFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::viaDisplayMode, !opts->m_DisplayViaFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts->m_DisplayPadFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts->m_ContrastModeDisplay );
m_optionsToolBar->Toggle( PCB_ACTIONS::trackDisplayMode, !opts.m_DisplayPcbTrackFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::viaDisplayMode, !opts.m_DisplayViaFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts.m_DisplayPadFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts.m_ContrastModeDisplay );
m_optionsToolBar->Refresh();
TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );

View File

@ -290,7 +290,7 @@ int PCB_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
std::string tool = aEvent.GetCommandStr().get();
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
BOARD* board = getModel<BOARD>();
PCB_DISPLAY_OPTIONS* opt = displayOptions();
auto& opt = displayOptions();
// Deactivate other tools; particularly important if another PICKER is currently running
Activate();
@ -317,7 +317,7 @@ int PCB_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
for( auto mod : board->Modules() )
{
for( auto pad : mod->Pads() )
pad->SetLocalRatsnestVisible( opt->m_ShowGlobalRatsnest );
pad->SetLocalRatsnestVisible( opt.m_ShowGlobalRatsnest );
}
}
else
@ -351,7 +351,7 @@ int PCB_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
for( auto mod : board->Modules() )
{
for( auto pad : mod->Pads() )
pad->SetLocalRatsnestVisible( opt->m_ShowGlobalRatsnest );
pad->SetLocalRatsnestVisible( opt.m_ShowGlobalRatsnest );
}
}
} );
@ -430,11 +430,11 @@ void PCB_INSPECTION_TOOL::calculateSelectionRatsnest()
{
for( auto pad : static_cast<MODULE*>( item )->Pads() )
{
if( pad->GetLocalRatsnestVisible() || displayOptions()->m_ShowModuleRatsnest )
if( pad->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
items.push_back( pad );
}
}
else if( boardItem->GetLocalRatsnestVisible() || displayOptions()->m_ShowModuleRatsnest )
else if( boardItem->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
{
items.push_back( boardItem );
}

View File

@ -255,9 +255,9 @@ void PCB_TOOL_BASE::setTransitions()
}
PCB_DISPLAY_OPTIONS* PCB_TOOL_BASE::displayOptions() const
const PCB_DISPLAY_OPTIONS& PCB_TOOL_BASE::displayOptions() const
{
return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
return frame()->GetDisplayOptions();
}
PCB_DRAW_PANEL_GAL* PCB_TOOL_BASE::canvas() const

View File

@ -155,7 +155,7 @@ protected:
return board()->GetFirstModule();
}
PCB_DISPLAY_OPTIONS* displayOptions() const;
const PCB_DISPLAY_OPTIONS& displayOptions() const;
PCB_DRAW_PANEL_GAL* canvas() const;
const PCBNEW_SELECTION& selection() const;
PCBNEW_SELECTION& selection();

View File

@ -122,7 +122,8 @@ int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
{
auto opts = displayOptions();
Flip( opts->m_DisplayPcbTrackFill );
Flip( opts.m_DisplayPcbTrackFill );
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
for( auto track : board()->Tracks() )
@ -144,15 +145,17 @@ int PCBNEW_CONTROL::ToggleRatsnest( const TOOL_EVENT& aEvent )
if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
{
// N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
Flip( opts->m_ShowGlobalRatsnest );
Flip( opts.m_ShowGlobalRatsnest );
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
opts->m_ShowGlobalRatsnest );
opts.m_ShowGlobalRatsnest );
}
else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
{
Flip( opts->m_DisplayRatsnestLinesCurved );
Flip( opts.m_DisplayRatsnestLinesCurved );
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
}
@ -167,7 +170,8 @@ int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent )
{
auto opts = displayOptions();
Flip( opts->m_DisplayPadFill );
Flip( opts.m_DisplayPadFill );
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
@ -186,8 +190,9 @@ int PCBNEW_CONTROL::ViaDisplayMode( const TOOL_EVENT& aEvent )
{
auto opts = displayOptions();
Flip( opts->m_DisplayViaFill );
Flip( opts.m_DisplayViaFill );
view()->UpdateDisplayOptions( opts );
m_frame->SetDisplayOptions( opts );
for( auto track : board()->Tracks() )
{
@ -205,7 +210,8 @@ int PCBNEW_CONTROL::GraphicDisplayMode( const TOOL_EVENT& aEvent )
{
auto opts = displayOptions();
Flip( opts->m_DisplayDrawItemsFill );
Flip( opts.m_DisplayDrawItemsFill );
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
for( auto item : board()->Drawings() )
@ -223,7 +229,8 @@ int PCBNEW_CONTROL::ModuleEdgeOutlines( const TOOL_EVENT& aEvent )
{
auto opts = displayOptions();
Flip( opts->m_DisplayModEdgeFill );
Flip( opts.m_DisplayModEdgeFill );
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
for( auto module : board()->Modules() )
@ -247,16 +254,17 @@ int PCBNEW_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent )
// Apply new display options to the GAL canvas
if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayEnable ) )
opts->m_DisplayZonesMode = 0;
opts.m_DisplayZonesMode = 0;
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
opts->m_DisplayZonesMode = 1;
opts.m_DisplayZonesMode = 1;
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
opts->m_DisplayZonesMode = 2;
opts.m_DisplayZonesMode = 2;
else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
opts->m_DisplayZonesMode = ( opts->m_DisplayZonesMode + 1 ) % 3;
opts.m_DisplayZonesMode = ( opts.m_DisplayZonesMode + 1 ) % 3;
else
wxFAIL;
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
for( int i = 0; i < board()->GetAreaCount(); ++i )
@ -272,7 +280,8 @@ int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
{
auto opts = displayOptions();
Flip( opts->m_ContrastModeDisplay );
Flip( opts.m_ContrastModeDisplay );
m_frame->SetDisplayOptions( opts );
view()->UpdateDisplayOptions( opts );
canvas()->SetHighContrastLayer( m_frame->GetActiveLayer() );

View File

@ -392,10 +392,10 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
{
GENERAL_COLLECTORS_GUIDE guide = getCollectorsGuide();
GENERAL_COLLECTOR collector;
PCB_DISPLAY_OPTIONS* displayOpts = (PCB_DISPLAY_OPTIONS*) m_frame->GetDisplayOptions();
auto& displayOpts = m_frame->GetDisplayOptions();
bool cleared = false;
guide.SetIgnoreZoneFills( displayOpts->m_DisplayZonesMode != 0 );
guide.SetIgnoreZoneFills( displayOpts.m_DisplayZonesMode != 0 );
collector.Collect( board(),
m_editModules ? GENERAL_COLLECTOR::ModuleItems : GENERAL_COLLECTOR::AllBoardItems,