Flatten out some more preferences.

This commit is contained in:
Jeff Young 2021-09-07 21:34:10 +01:00
parent 024097dfef
commit 9ee28ea8f5
49 changed files with 330 additions and 615 deletions

View File

@ -100,7 +100,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_currentScreen = nullptr;
m_showBorderAndTitleBlock = false; // true to display reference sheet.
m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
m_showPageLimits = false;
m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
// BLACK for Pcbnew, BLACK or WHITE for Eeschema
m_colorSettings = nullptr;
@ -1061,9 +1060,9 @@ void EDA_DRAW_FRAME::RecreateToolbars()
}
COLOR_SETTINGS* EDA_DRAW_FRAME::GetColorSettings() const
COLOR_SETTINGS* EDA_DRAW_FRAME::GetColorSettings( bool aForceRefresh ) const
{
if( !m_colorSettings )
if( !m_colorSettings || aForceRefresh )
{
COLOR_SETTINGS* colorSettings = Pgm().GetSettingsManager().GetColorSettings();

View File

@ -236,13 +236,14 @@ bool EDA_PATTERN_MATCH_RELATIONAL::SetPattern( const wxString& aPattern )
if( val == "" )
{
// Matching on empty values keeps the match list from going empty when
// the user types the relational operator character, which helps prevent
// confusion.
// Matching on empty values keeps the match list from going empty when the user
// types the relational operator character, which helps prevent confusion.
m_relation = ANY;
}
else if( !val.ToCDouble( &m_value ) )
{
return false;
}
auto unit_it = m_units.find( unit.Lower() );

View File

@ -41,7 +41,6 @@ RENDER_SETTINGS::RENDER_SETTINGS() :
m_drawingSheetLineWidth = 100000;
m_defaultPenWidth = 0;
m_minPenWidth = 0;
m_showPageLimits = false;
m_isPrinting = false;
}

View File

@ -100,7 +100,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
displ_opts.m_DisplayPadNoConnects = false; // Nor do connections
// Track and via clearance has no meaning here.
displ_opts.m_ShowTrackClearanceMode = PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE;
displ_opts.m_ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE;
SetDisplayOptions( displ_opts );
// Create the manager and dispatcher & route draw panel events to the dispatcher
@ -528,7 +528,7 @@ void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel()
}
COLOR_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetColorSettings() const
COLOR_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetColorSettings( bool aForceRefresh ) const
{
auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();

View File

@ -78,7 +78,7 @@ public:
///< @copydoc EDA_DRAW_FRAME::UpdateMsgPanel()
void UpdateMsgPanel() override;
COLOR_SETTINGS* GetColorSettings() const override;
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
/**
* @return the color of the grid.

View File

@ -146,18 +146,6 @@ void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
SCH_BASE_FRAME::LoadSettings( eeconfig() );
GetRenderSettings()->m_ShowPinsElectricalType = false;
GetRenderSettings()->m_ShowHiddenText = false;
GetRenderSettings()->m_ShowHiddenPins = false;
GetRenderSettings()->m_ShowHiddenText = false;
GetRenderSettings()->SetShowPageLimits( true );
GetRenderSettings()->m_ShowUmbilicals = true;
if( eeconfig() )
{
GetRenderSettings()->m_ShowHiddenPins = eeconfig()->m_Appearance.show_hidden_pins;
GetRenderSettings()->m_ShowHiddenText = eeconfig()->m_Appearance.show_hidden_fields;
GetRenderSettings()->SetShowPageLimits( eeconfig()->m_Appearance.show_page_limits );
}
}

View File

@ -418,7 +418,7 @@ void SCH_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
{
EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
COLOR_SETTINGS* colorSettings = GetColorSettings();
COLOR_SETTINGS* colorSettings = GetColorSettings( true );
GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( colorSettings );
GetCanvas()->GetGAL()->SetAxesColor( colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
@ -430,9 +430,9 @@ void SCH_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
}
COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings() const
COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings( bool aForceRefresh ) const
{
if( !m_colorSettings )
if( !m_colorSettings || aForceRefresh )
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();

View File

@ -238,7 +238,7 @@ public:
*/
COLOR4D GetLayerColor( SCH_LAYER_ID aLayer );
COLOR_SETTINGS* GetColorSettings() const override;
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
protected:
/**

View File

@ -1478,10 +1478,6 @@ void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
GetRenderSettings()->m_ShowHiddenPins = cfg->m_Appearance.show_hidden_pins;
GetRenderSettings()->m_ShowHiddenText = cfg->m_Appearance.show_hidden_fields;
GetRenderSettings()->SetShowPageLimits( cfg->m_Appearance.show_page_limits );
GetCanvas()->ForceRefresh();
RecreateToolbars();

View File

@ -66,16 +66,19 @@
namespace KIGFX
{
EESCHEMA_SETTINGS* eeconfig()
{
return dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
}
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_IsSymbolEditor( false ),
m_ShowUnit( 0 ),
m_ShowConvert( 0 ),
m_ShowHiddenText( true ),
m_ShowHiddenPins( true ),
m_ShowPinsElectricalType( true ),
m_ShowDisabled( false ),
m_ShowGraphicsDisabled( false ),
m_ShowUmbilicals( true ),
m_OverrideItemColors( false ),
m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ),
m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ),
@ -112,9 +115,9 @@ COLOR4D SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
}
EESCHEMA_SETTINGS* eeconfig()
bool SCH_RENDER_SETTINGS::GetShowPageLimits() const
{
return dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
return eeconfig()->m_Appearance.show_page_limits;
}
@ -638,7 +641,7 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer )
if( !( aField->IsVisible() || aField->IsForceVisible() ) )
{
if( m_schSettings.m_ShowHiddenText )
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
else
return;
@ -669,8 +672,8 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer )
strokeText( UnescapeString( aField->GetText() ), textpos, aField->GetTextAngleRadians() );
}
// Draw the umbilical line
if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
// Draw the umbilical line when in the schematic editor
if( aField->IsMoving() && m_schematic )
{
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
@ -693,7 +696,7 @@ void SCH_PAINTER::draw( const LIB_TEXT *aText, int aLayer )
if( !aText->IsVisible() )
{
if( m_schSettings.m_ShowHiddenText )
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
else
return;
@ -772,7 +775,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
if( !aPin->IsVisible() )
{
if( m_schSettings.m_ShowHiddenPins )
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_pins )
{
color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
}
@ -1431,7 +1434,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
if( !( aText->IsVisible() || aText->IsForceVisible() ) )
{
if( m_schSettings.m_ShowHiddenText )
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
else
return;
@ -1602,7 +1605,7 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer )
if( !( aField->IsVisible() || aField->IsForceVisible() ) )
{
if( m_schSettings.m_ShowHiddenText )
if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
else
return;

View File

@ -102,17 +102,17 @@ public:
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; }
bool GetShowPageLimits() const override;
public:
bool m_IsSymbolEditor;
int m_ShowUnit; // Show all units if 0
int m_ShowConvert; // Show all conversions if 0
bool m_ShowHiddenText;
bool m_ShowHiddenPins;
bool m_ShowPinsElectricalType;
bool m_ShowDisabled;
bool m_ShowGraphicsDisabled;
bool m_ShowUmbilicals;
bool m_OverrideItemColors;

View File

@ -57,8 +57,6 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo
auto* renderSettings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( m_painter->GetSettings() );
renderSettings->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
renderSettings->m_ShowPinsElectricalType = false;
renderSettings->m_ShowHiddenText = false;
renderSettings->m_ShowHiddenPins = false;
renderSettings->m_TextOffsetRatio = 0.35;
m_view->SetPainter( m_painter.get() );

View File

@ -270,11 +270,6 @@ void SYMBOL_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
SCH_BASE_FRAME::LoadSettings( GetSettings() );
GetRenderSettings()->m_ShowPinsElectricalType = m_settings->m_ShowPinElectricalType;
// Hidden elements must be editable
GetRenderSettings()->m_ShowHiddenText = true;
GetRenderSettings()->m_ShowHiddenPins = true;
GetRenderSettings()->m_ShowUmbilicals = false;
}
@ -297,7 +292,7 @@ APP_SETTINGS_BASE* SYMBOL_EDIT_FRAME::config() const
}
COLOR_SETTINGS* SYMBOL_EDIT_FRAME::GetColorSettings() const
COLOR_SETTINGS* SYMBOL_EDIT_FRAME::GetColorSettings( bool aForceRefresh ) const
{
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();

View File

@ -200,7 +200,7 @@ public:
APP_SETTINGS_BASE* config() const override;
COLOR_SETTINGS* GetColorSettings() const override;
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
/**
* Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:

View File

@ -141,8 +141,6 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAM
GetRenderSettings()->LoadColors( GetColorSettings() );
GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) );
GetRenderSettings()->m_ShowHiddenText = true;
GetRenderSettings()->m_ShowHiddenPins = true;
GetRenderSettings()->SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * IU_PER_MILS );
setupTools();

View File

@ -2130,9 +2130,6 @@ int SCH_EDITOR_CONTROL::ToggleHiddenPins( const TOOL_EVENT& aEvent )
EESCHEMA_SETTINGS* cfg = m_frame->eeconfig();
cfg->m_Appearance.show_hidden_pins = !cfg->m_Appearance.show_hidden_pins;
KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
getView()->UpdateAllItems( KIGFX::REPAINT );
m_frame->GetCanvas()->Refresh();
@ -2145,9 +2142,6 @@ int SCH_EDITOR_CONTROL::ToggleHiddenFields( const TOOL_EVENT& aEvent )
EESCHEMA_SETTINGS* cfg = m_frame->eeconfig();
cfg->m_Appearance.show_hidden_fields = !cfg->m_Appearance.show_hidden_fields;
KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
painter->GetSettings()->m_ShowHiddenText = cfg->m_Appearance.show_hidden_fields;
getView()->UpdateAllItems( KIGFX::REPAINT );
m_frame->GetCanvas()->Refresh();

View File

@ -62,7 +62,7 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow( )
// Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
m_OptDisplayLines->SetValue( !cfg->m_Display.m_DisplayLinesFill );
m_OptDisplayFlashedItems->SetValue( !cfg->m_Display.m_DisplayFlashedItemsFill );
m_OptDisplayDCodes->SetValue( cfg->m_Display.m_DisplayDCodes );
m_OptDisplayDCodes->SetValue( cfg->m_Appearance.show_dcodes );
for( unsigned i = 0; i < arrayDim( gerberPageSizeList ); ++i )
{
@ -88,7 +88,7 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow()
cfg->m_Display.m_DisplayLinesFill = !m_OptDisplayLines->GetValue();
cfg->m_Display.m_DisplayFlashedItemsFill = !m_OptDisplayFlashedItems->GetValue();
cfg->m_Display.m_DisplayPolygonsFill = !m_OptDisplayPolygons->GetValue();
cfg->m_Display.m_DisplayDCodes = m_OptDisplayDCodes->GetValue();
cfg->m_Appearance.show_dcodes = m_OptDisplayDCodes->GetValue();
cfg->m_Appearance.page_type = gerberPageSizeList[ m_PageSize->GetSelection() ];
cfg->m_Display.m_DisplayPageLimits = m_ShowPageLimitsOpt->GetValue();

View File

@ -38,18 +38,14 @@ public:
bool m_DisplayFlashedItemsFill; ///< Option to draw flashed items (filled/sketch)
bool m_DisplayLinesFill; ///< Option to draw line items (filled/sketch)
bool m_DisplayPolygonsFill; ///< Option to draw polygons (filled/sketch)
bool m_DisplayDCodes; ///< Option to show dcode values on items drawn with a dcode tool
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 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
COLOR4D m_BgDrawColor; ///< The background color
public:
GBR_DISPLAY_OPTIONS()
@ -57,13 +53,9 @@ public:
m_DisplayFlashedItemsFill = true;
m_DisplayLinesFill = true;
m_DisplayPolygonsFill = true;
m_DisplayDCodes = false;
m_DisplayPageLimits = false;
m_IsPrinting = false;
m_DisplayNegativeObjects = false;
m_ForceBlackAndWhite = false;
m_NegativeDrawColor = COLOR4D( DARKGRAY );
m_BgDrawColor = COLOR4D::BLACK;
m_DiffMode = false;
m_HighContrastMode = false;
m_FlipGerberView = false;

View File

@ -58,18 +58,8 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
setDefaultLayerDeps();
// Load display options (such as filled/outline display of items).
auto frame = static_cast< GERBVIEW_FRAME* >( GetParentEDAFrame() );
if( frame )
{
auto& displ_opts = frame->GetDisplayOptions();
auto rs = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>(
m_view->GetPainter()->GetSettings() );
rs->LoadDisplayOptions( displ_opts );
rs->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
}
auto renderSettings = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( m_painter->GetSettings() );
renderSettings->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
}
@ -96,7 +86,6 @@ void GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer( int aLayer )
void GERBVIEW_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
std::vector<MSG_PANEL_ITEM>& aList )
{
}
@ -105,12 +94,7 @@ void GERBVIEW_DRAW_PANEL_GAL::OnShow()
GERBVIEW_FRAME* frame = dynamic_cast<GERBVIEW_FRAME*>( GetParentEDAFrame() );
if( frame )
{
SetTopLayer( frame->GetActiveLayer() );
auto& displ_opts = frame->GetDisplayOptions();
static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>(
m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts );
}
m_view->RecacheAllItems();
}

View File

@ -285,6 +285,12 @@ bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
GERBVIEW_SETTINGS* GERBVIEW_FRAME::gvconfig() const
{
return dynamic_cast<GERBVIEW_SETTINGS*>( config() );
}
void GERBVIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
@ -347,9 +353,6 @@ void GERBVIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
wxCHECK( cfg, /*void*/ );
cfg->m_Appearance.page_type = GetPageSettings().GetType();
cfg->m_Appearance.show_border_and_titleblock = m_showBorderAndTitleBlock;
cfg->m_Appearance.show_dcodes = IsElementVisible( LAYER_DCODES );
cfg->m_Appearance.show_negative_objects = IsElementVisible( LAYER_NEGATIVE_OBJECTS );
m_drillFileHistory.Save( &cfg->m_DrillFileHistory );
m_zipFileHistory.Save( &cfg->m_ZipFileHistory );
@ -387,20 +390,25 @@ void GERBVIEW_FRAME::ReFillLayerWidget()
void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
{
bool dcodes_changed = false;
KIGFX::VIEW* view = GetCanvas()->GetView();
switch( aLayerID )
{
case LAYER_DCODES:
dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
m_DisplayOptions.m_DisplayDCodes = aNewState;
gvconfig()->m_Appearance.show_dcodes = aNewState;
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
{
int layer = GERBER_DRAW_LAYER( i );
int dcode_layer = GERBER_DCODE_LAYER( layer );
view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
}
break;
case LAYER_NEGATIVE_OBJECTS:
{
m_DisplayOptions.m_DisplayNegativeObjects = aNewState;
auto view = GetCanvas()->GetView();
gvconfig()->m_Appearance.show_negative_objects = aNewState;
view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
{
@ -414,7 +422,9 @@ void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
}
case LAYER_GERBVIEW_DRAWINGSHEET:
m_showBorderAndTitleBlock = aNewState;
gvconfig()->m_Appearance.show_border_and_titleblock = aNewState;
m_showBorderAndTitleBlock = gvconfig()->m_Appearance.show_border_and_titleblock;
// NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
// LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
@ -430,28 +440,15 @@ void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
aLayerID ) );
}
if( dcodes_changed )
{
auto view = GetCanvas()->GetView();
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
{
int layer = GERBER_DRAW_LAYER( i );
int dcode_layer = GERBER_DCODE_LAYER( layer );
view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
}
}
applyDisplaySettingsToGAL();
ApplyDisplaySettingsToGAL();
m_LayersManager->SetRenderState( aLayerID, aNewState );
}
void GERBVIEW_FRAME::applyDisplaySettingsToGAL()
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->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
@ -527,24 +524,33 @@ void GERBVIEW_FRAME::SortLayersByX2Attributes()
GetCanvas()->Refresh();
}
void GERBVIEW_FRAME::UpdateDiffLayers()
{
auto target = GetCanvas()->GetBackend() == GERBVIEW_DRAW_PANEL_GAL::GAL_TYPE::GAL_TYPE_OPENGL
auto target = GetCanvas()->GetBackend() == GERBVIEW_DRAW_PANEL_GAL::GAL_TYPE_OPENGL
? KIGFX::TARGET_CACHED
: KIGFX::TARGET_NONCACHED;
auto view = GetCanvas()->GetView();
int lastVisibleLayer = -1;
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
{
view->SetLayerDiff( GERBER_DRAW_LAYER( i ), m_DisplayOptions.m_DiffMode );
view->SetLayerDiff( GERBER_DRAW_LAYER( i ), gvconfig()->m_Display.m_DiffMode );
// Caching doesn't work with layered rendering of diff'd layers
view->SetLayerTarget( GERBER_DRAW_LAYER( i ),
m_DisplayOptions.m_DiffMode ? KIGFX::TARGET_NONCACHED : target );
//We want the last visible layer, but deprioritize the active layer unless it's the only layer
if( gvconfig()->m_Display.m_DiffMode )
view->SetLayerTarget( GERBER_DRAW_LAYER( i ), KIGFX::TARGET_NONCACHED );
else
view->SetLayerTarget( GERBER_DRAW_LAYER( i ), target );
// We want the last visible layer, but deprioritize the active layer unless it's the
// only layer
if( ( lastVisibleLayer == -1 )
|| ( view->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) && i != GetActiveLayer() ) )
{
lastVisibleLayer = i;
}
}
//We don't want to diff the last visible layer onto the background, etc.
@ -560,78 +566,6 @@ void GERBVIEW_FRAME::UpdateDiffLayers()
}
void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
{
bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
aOptions.m_DisplayFlashedItemsFill );
bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
aOptions.m_DisplayLinesFill );
bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
aOptions.m_DisplayPolygonsFill );
bool update_diff_mode = ( m_DisplayOptions.m_DiffMode != aOptions.m_DiffMode );
auto view = GetCanvas()->GetView();
m_DisplayOptions = aOptions;
applyDisplaySettingsToGAL();
if( update_diff_mode )
UpdateDiffLayers();
if( update_flashed )
{
view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
{
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape )
{
case GBR_SPOT_CIRCLE:
case GBR_SPOT_RECT:
case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
return true;
default:
return false;
}
} );
}
else if( update_lines )
{
view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
{
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape )
{
case GBR_CIRCLE:
case GBR_ARC:
case GBR_SEGMENT:
return true;
default:
return false;
}
} );
}
else if( update_polygons )
{
view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
{
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
return ( item->m_Shape == GBR_POLYGON );
} );
}
view->UpdateAllItems( KIGFX::COLOR );
GetCanvas()->Refresh();
}
void GERBVIEW_FRAME::UpdateTitleAndInfo()
{
GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() );
@ -700,15 +634,14 @@ bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
{
switch( aLayerID )
{
case LAYER_DCODES: return m_DisplayOptions.m_DisplayDCodes;
case LAYER_NEGATIVE_OBJECTS: return m_DisplayOptions.m_DisplayNegativeObjects;
case LAYER_DCODES: return gvconfig()->m_Appearance.show_dcodes;
case LAYER_NEGATIVE_OBJECTS: return gvconfig()->m_Appearance.show_negative_objects;
case LAYER_GERBVIEW_GRID: return IsGridVisible();
case LAYER_GERBVIEW_DRAWINGSHEET: return m_showBorderAndTitleBlock;
case LAYER_GERBVIEW_DRAWINGSHEET: return gvconfig()->m_Appearance.show_border_and_titleblock;
case LAYER_GERBVIEW_BACKGROUND: return true;
default:
wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d",
aLayerID ) );
wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible bad arg %d", aLayerID ) );
}
return true;
@ -739,7 +672,7 @@ void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask )
int layer = GERBER_DRAW_LAYER( i );
GetCanvas()->GetView()->SetLayerVisible( layer, v );
GetCanvas()->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
m_DisplayOptions.m_DisplayDCodes && v );
gvconfig()->m_Appearance.show_dcodes && v );
}
}
}
@ -824,7 +757,7 @@ void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, const COLOR4D& aColor
COLOR4D GERBVIEW_FRAME::GetNegativeItemsColor()
{
if( IsElementVisible( LAYER_NEGATIVE_OBJECTS ) )
if( gvconfig()->m_Appearance.show_negative_objects )
return GetVisibleElementColor( LAYER_NEGATIVE_OBJECTS );
else
return GetDrawBgColor();
@ -840,7 +773,7 @@ COLOR4D GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
void GERBVIEW_FRAME::SetLayerColor( int aLayer, const COLOR4D& aColor )
{
Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
applyDisplaySettingsToGAL();
ApplyDisplaySettingsToGAL();
}
@ -848,7 +781,7 @@ void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
{
m_activeLayer = aLayer;
if( m_DisplayOptions.m_DiffMode )
if( gvconfig()->m_Display.m_DiffMode )
UpdateDiffLayers();
if( doLayerWidgetUpdate )
@ -1100,49 +1033,49 @@ void GERBVIEW_FRAME::setupUIConditions()
auto flashedDisplayOutlinesCond =
[this] ( const SELECTION& )
{
return !m_DisplayOptions.m_DisplayFlashedItemsFill;
return !gvconfig()->m_Display.m_DisplayFlashedItemsFill;
};
auto linesFillCond =
[this] ( const SELECTION& )
{
return !m_DisplayOptions.m_DisplayLinesFill;
return !gvconfig()->m_Display.m_DisplayLinesFill;
};
auto polygonsFilledCond =
[this] ( const SELECTION& )
{
return !m_DisplayOptions.m_DisplayPolygonsFill;
return !gvconfig()->m_Display.m_DisplayPolygonsFill;
};
auto negativeObjectsCond =
[this] ( const SELECTION& )
{
return IsElementVisible( LAYER_NEGATIVE_OBJECTS );
return gvconfig()->m_Appearance.show_negative_objects;
};
auto dcodeCond =
[this] ( const SELECTION& )
{
return IsElementVisible( LAYER_DCODES );
return gvconfig()->m_Appearance.show_dcodes;
};
auto diffModeCond =
[this] ( const SELECTION& )
{
return m_DisplayOptions.m_DiffMode;
return gvconfig()->m_Display.m_DiffMode;
};
auto highContrastModeCond =
[this] ( const SELECTION& )
{
return m_DisplayOptions.m_HighContrastMode;
return gvconfig()->m_Display.m_HighContrastMode;
};
auto flipGerberCond =
[this] ( const SELECTION& )
{
return m_DisplayOptions.m_FlipGerberView;
return gvconfig()->m_Display.m_FlipGerberView;
};
auto layersManagerShownCondition =
@ -1172,18 +1105,12 @@ void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
{
EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
GERBVIEW_SETTINGS* cfg = static_cast<GERBVIEW_SETTINGS*>( config() );
SetPageSettings( PAGE_INFO( cfg->m_Appearance.page_type ) );
SetPageSettings( PAGE_INFO( gvconfig()->m_Appearance.page_type ) );
if( cfg->m_Display.m_DiffMode )
if( gvconfig()->m_Display.m_DiffMode )
UpdateDiffLayers();
// Apply changes to the GAL
auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
auto settings = painter->GetSettings();
settings->LoadDisplayOptions( GetDisplayOptions() );
SetElementVisibility( LAYER_DCODES, GetDisplayOptions().m_DisplayDCodes );
SetElementVisibility( LAYER_DCODES, gvconfig()->m_Appearance.show_dcodes );
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );

View File

@ -40,6 +40,7 @@ class GBR_LAYER_BOX_SELECTOR;
class GERBER_DRAW_ITEM;
class GERBER_FILE_IMAGE;
class GERBER_FILE_IMAGE_LIST;
class GERBVIEW_SETTINGS;
class REPORTER;
class SELECTION;
class wxStaticText;
@ -92,6 +93,11 @@ public:
void UpdateStatusBar() override;
void UpdateToolbarControlSizes() override;
GERBVIEW_SETTINGS* gvconfig() const;
/// Updates the GAL with display settings changes
void ApplyDisplaySettingsToGAL();
/**
* @return 0 for fast mode (not fully compatible with negative objects)
* 1 for exact mode, write mode
@ -351,13 +357,6 @@ public:
*/
void UpdateDiffLayers();
/**
* Update the display options and refreshes the view as needed.
*
* @param aOptions is the new options to apply
*/
void UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions );
/*
* Do nothing in GerbView.
*/
@ -389,9 +388,6 @@ public:
SELECTION& GetCurrentSelection() override;
const GBR_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_DisplayOptions; }
void SetDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions ) { m_DisplayOptions = aOptions; }
/**
* Set the m_gerberLayout member in such as way as to ensure deleting any previous
* GBR_LAYOUT.
@ -471,11 +467,11 @@ protected:
void setupUIConditions() override;
private:
void updateComponentListSelectBox();
void updateNetnameListSelectBox();
void updateAperAttributesSelectBox();
void updateDCodeSelectBox();
void unitsChangeRefresh() override; // See class EDA_DRAW_FRAME
void updateComponentListSelectBox();
void updateNetnameListSelectBox();
void updateAperAttributesSelectBox();
void updateDCodeSelectBox();
void unitsChangeRefresh() override; // See class EDA_DRAW_FRAME
void OnClearJobFileHistory( wxCommandEvent& aEvent );
void OnClearZipFileHistory( wxCommandEvent& aEvent );
@ -485,9 +481,6 @@ private:
// The Tool Framework initialization
void setupTools();
/// Updates the GAL with display settings changes
void applyDisplaySettingsToGAL();
public:
wxChoice* m_SelComponentBox; // a choice box to display and highlight component
// graphic items
@ -529,7 +522,6 @@ private:
int m_activeLayer;
wxPoint m_grid_origin;
PAGE_INFO m_paper; // used only to show paper limits to screen
GBR_DISPLAY_OPTIONS m_DisplayOptions;
wxStaticText* m_cmpText; // a message on the auxiliary toolbar,
// relative to the m_SelComponentBox
wxStaticText* m_netText; // a message on the auxiliary toolbar,

View File

@ -20,7 +20,10 @@
#include <gerbview_painter.h>
#include <gal/graphics_abstraction_layer.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <settings/color_settings.h>
#include <gerbview_settings.h>
#include <convert_basic_shapes_to_polygon.h>
#include <convert_to_biu.h>
#include <gerbview.h>
@ -32,17 +35,17 @@
using namespace KIGFX;
GERBVIEW_SETTINGS* gvconfig()
{
return Pgm().GetSettingsManager().GetAppSettings<GERBVIEW_SETTINGS>();
}
GERBVIEW_RENDER_SETTINGS::GERBVIEW_RENDER_SETTINGS()
{
m_backgroundColor = COLOR4D::BLACK;
m_spotFill = true;
m_lineFill = true;
m_polygonFill = true;
m_showNegativeItems = false;
m_showCodes = false;
m_diffMode = true;
m_componentHighlightString = "";
m_netHighlightString = "";
m_attributeHighlightString = "";
@ -85,22 +88,6 @@ void GERBVIEW_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
}
void GERBVIEW_RENDER_SETTINGS::LoadDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
{
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();
}
void GERBVIEW_RENDER_SETTINGS::ClearHighlightSelections()
{
// Clear all highlight selections (dcode, net, component, attribute selection)
@ -128,7 +115,7 @@ COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer )
if( gbrItem && gbrItem->GetLayerPolarity() )
{
if( m_showNegativeItems )
if( gvconfig()->m_Appearance.show_negative_objects )
return m_layerColors[LAYER_NEGATIVE_OBJECTS];
else
return transparent;
@ -164,6 +151,12 @@ COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer )
}
bool GERBVIEW_RENDER_SETTINGS::GetShowPageLimits() const
{
return gvconfig()->m_Display.m_DisplayPageLimits;
}
GERBVIEW_PAINTER::GERBVIEW_PAINTER( GAL* aGal ) :
PAINTER( aGal )
{
@ -173,9 +166,8 @@ GERBVIEW_PAINTER::GERBVIEW_PAINTER( GAL* aGal ) :
// TODO(JE): Pull up to PAINTER?
int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
{
// if items have 0 thickness, draw them with the outline
// width, otherwise respect the set value (which, no matter
// how small will produce something)
// if items have 0 thickness, draw them with the outline width, otherwise respect the set
// value (which, no matter how small will produce something)
if( aActualThickness == 0 )
return m_gerbviewSettings.m_outlineWidth;
@ -185,24 +177,15 @@ int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
{
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
GERBER_DRAW_ITEM* gbrItem = dynamic_cast<GERBER_DRAW_ITEM*>( const_cast<VIEW_ITEM*>( aItem ) );
if( !item )
return false;
// the "cast" applied in here clarifies which overloaded draw() is called
switch( item->Type() )
if( gbrItem )
{
case GERBER_DRAW_ITEM_T:
draw( static_cast<GERBER_DRAW_ITEM*>( const_cast<EDA_ITEM*>( item ) ), aLayer );
break;
default:
// Painter does not know how to draw the object
return false;
draw( gbrItem, aLayer );
return true;
}
return true;
return false;
}
@ -255,7 +238,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
if( aItem->IsBrightened() )
color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
m_gal->SetNegativeDrawMode( isNegative && ! m_gerbviewSettings.IsShowNegativeItems() );
m_gal->SetNegativeDrawMode( isNegative && !gvconfig()->m_Appearance.show_negative_objects );
m_gal->SetStrokeColor( color );
m_gal->SetFillColor( color );
m_gal->SetIsFill( isFilled );
@ -265,7 +248,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
{
case GBR_POLYGON:
{
isFilled = m_gerbviewSettings.m_polygonFill;
isFilled = gvconfig()->m_Display.m_DisplayPolygonsFill;
m_gal->SetIsFill( isFilled );
m_gal->SetIsStroke( !isFilled );
@ -296,9 +279,9 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
m_gal->DrawPolyline( aItem->m_AbsolutePolygon.COutline( 0 ) );
else
{
// On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
// CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
// on Opengl
// On Opengl, a not convex filled polygon is usually drawn by using triangles as
// primitives. CacheTriangulation() can create basic triangle primitives to draw the
// polygon solid shape on Opengl
if( m_gal->IsOpenGlEngine() && !aItem->m_AbsolutePolygon.IsTriangulationUpToDate() )
aItem->m_AbsolutePolygon.CacheTriangulation();
@ -310,7 +293,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
case GBR_CIRCLE:
{
isFilled = m_gerbviewSettings.m_lineFill;
isFilled = gvconfig()->m_Display.m_DisplayLinesFill;
double radius = GetLineLength( aItem->m_Start, aItem->m_End );
m_gal->DrawCircle( start, radius );
break;
@ -318,7 +301,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
case GBR_ARC:
{
isFilled = m_gerbviewSettings.m_lineFill;
isFilled = gvconfig()->m_Display.m_DisplayLinesFill;
// These are swapped because wxDC fills arcs counterclockwise and GAL
// fills them clockwise.
@ -347,9 +330,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
// In Gerber, 360-degree arcs are stored in the file with start equal to end
if( arcStart == arcEnd )
{
endAngle = startAngle + 2*M_PI;
}
m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width, ARC_HIGH_DEF );
@ -380,11 +361,9 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
{
isFilled = m_gerbviewSettings.m_spotFill;
isFilled = gvconfig()->m_Display.m_DisplayFlashedItemsFill;
drawFlashedShape( aItem, isFilled );
break;
}
case GBR_SEGMENT:
{
@ -393,7 +372,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
* In fact, any aperture can be used to plot a line.
* currently: only a square pen is handled (I believe using a polygon gives a strange plot).
*/
isFilled = m_gerbviewSettings.m_lineFill;
isFilled = gvconfig()->m_Display.m_DisplayLinesFill;
m_gal->SetIsFill( isFilled );
m_gal->SetIsStroke( !isFilled );
@ -438,8 +417,8 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
}
void GERBVIEW_PAINTER::drawPolygon(
GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon, bool aFilled, bool aShift )
void GERBVIEW_PAINTER::drawPolygon( GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon,
bool aFilled, bool aShift )
{
wxASSERT( aPolygon.OutlineCount() == 1 );
@ -449,18 +428,16 @@ void GERBVIEW_PAINTER::drawPolygon(
SHAPE_POLY_SET poly;
poly.NewOutline();
const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
for( auto& pt : pts )
for( const VECTOR2I& pt : pts )
poly.Append( aParent->GetABPosition( pt + offset ) );
if( !m_gerbviewSettings.m_polygonFill )
if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
if( !aFilled )
{
m_gal->DrawPolyline( poly.COutline( 0 ) );
}
else
m_gal->DrawPolygon( poly );
}
@ -565,13 +542,11 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
}
case GBR_SPOT_POLY:
{
if( code->m_Polygon.OutlineCount() == 0 )
code->ConvertShapeToPolygon();
drawPolygon( aItem, code->m_Polygon, aFilled, true );
break;
}
case GBR_SPOT_MACRO:
drawApertureMacro( aItem, aFilled );
@ -586,12 +561,11 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
void GERBVIEW_PAINTER::drawApertureMacro( GERBER_DRAW_ITEM* aParent, bool aFilled )
{
D_CODE* code = aParent->GetDcodeDescr();
D_CODE* code = aParent->GetDcodeDescr();
APERTURE_MACRO* macro = code->GetMacro();
SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aParent, aParent->m_Start );
if( !m_gerbviewSettings.m_polygonFill )
if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
if( !aFilled )
@ -600,7 +574,9 @@ void GERBVIEW_PAINTER::drawApertureMacro( GERBER_DRAW_ITEM* aParent, bool aFille
m_gal->DrawPolyline( macroShape->COutline( i ) );
}
else
{
m_gal->DrawPolygon( *macroShape );
}
}

View File

@ -52,13 +52,6 @@ public:
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
/**
* Load settings related to display options.
*
* @param aOptions are settings that you want to use for displaying items.
*/
void LoadDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions );
/// @copydoc RENDER_SETTINGS::GetColor()
virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
@ -99,35 +92,7 @@ public:
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; }
inline bool IsSpotFill() const
{
return m_spotFill;
}
inline bool IsLineFill() const
{
return m_lineFill;
}
inline bool IsPolygonFill() const
{
return m_polygonFill;
}
inline bool IsShowNegativeItems() const
{
return m_showNegativeItems;
}
inline bool IsShowCodes() const
{
return m_showCodes;
}
inline bool IsDiffMode() const
{
return m_diffMode;
}
bool GetShowPageLimits() const override;
/// Clear all highlight selections (dcode, net, component, attribute selection)
void ClearHighlightSelections();
@ -146,24 +111,6 @@ public:
int m_dcodeHighlightValue;
protected:
/// Flag determining if spots should be drawn with fill
bool m_spotFill;
/// Flag determining if lines should be drawn with fill
bool m_lineFill;
/// Flag determining if polygons should be drawn with fill
bool m_polygonFill;
/// Flag determining if negative items should be drawn with a "ghost" color
bool m_showNegativeItems;
/// Flag determining if D-Codes should be drawn
bool m_showCodes;
/// Flag determining if layers should be rendered in "diff" mode
bool m_diffMode;
/// Maximum font size for D-Codes and other strings
static const double MAX_FONT_SIZE;
};

View File

@ -25,6 +25,7 @@
#include <gerber_file_image_list.h>
#include <gerbview_painter.h>
#include <gerbview_frame.h>
#include <gerbview_settings.h>
#include <string_utils.h>
#include <excellon_image.h>
#include <menus_helpers.h>
@ -225,56 +226,92 @@ int GERBVIEW_CONTROL::HighlightControl( const TOOL_EVENT& aEvent )
int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
{
bool state;
bool needs_refresh = false;
auto options = m_frame->GetDisplayOptions();
GERBVIEW_SETTINGS* cfg = m_frame->gvconfig();
KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
if( aEvent.IsAction( &GERBVIEW_ACTIONS::linesDisplayOutlines ) )
{
options.m_DisplayLinesFill = !options.m_DisplayLinesFill;
needs_refresh = true;
cfg->m_Display.m_DisplayLinesFill = !cfg->m_Display.m_DisplayLinesFill;
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
[]( KIGFX::VIEW_ITEM* aItem )
{
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape )
{
case GBR_CIRCLE:
case GBR_ARC:
case GBR_SEGMENT:
return true;
default:
return false;
}
} );
}
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::flashedDisplayOutlines ) )
{
options.m_DisplayFlashedItemsFill = !options.m_DisplayFlashedItemsFill;
needs_refresh = true;
cfg->m_Display.m_DisplayFlashedItemsFill = !cfg->m_Display.m_DisplayFlashedItemsFill;
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
[]( KIGFX::VIEW_ITEM* aItem )
{
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape )
{
case GBR_SPOT_CIRCLE:
case GBR_SPOT_RECT:
case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
return true;
default:
return false;
}
} );
}
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::polygonsDisplayOutlines ) )
{
options.m_DisplayPolygonsFill = !options.m_DisplayPolygonsFill;
needs_refresh = true;
cfg->m_Display.m_DisplayPolygonsFill = !cfg->m_Display.m_DisplayPolygonsFill;
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
[]( KIGFX::VIEW_ITEM* aItem )
{
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
return ( item->m_Shape == GBR_POLYGON );
} );
}
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::negativeObjectDisplay ) )
{
state = !m_frame->IsElementVisible( LAYER_NEGATIVE_OBJECTS );
m_frame->SetElementVisibility( LAYER_NEGATIVE_OBJECTS, state );
m_frame->SetElementVisibility( LAYER_NEGATIVE_OBJECTS, !cfg->m_Appearance.show_negative_objects );
}
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::dcodeDisplay ) )
{
state = !m_frame->IsElementVisible( LAYER_DCODES );
m_frame->SetElementVisibility( LAYER_DCODES, state );
m_frame->SetElementVisibility( LAYER_DCODES, !cfg->m_Appearance.show_dcodes );
}
else if( aEvent.IsAction( &ACTIONS::highContrastMode ) )
{
options.m_HighContrastMode = !options.m_HighContrastMode;
needs_refresh = true;
cfg->m_Display.m_HighContrastMode = !cfg->m_Display.m_HighContrastMode;
}
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::toggleDiffMode ) )
{
options.m_DiffMode = !options.m_DiffMode;
needs_refresh = true;
cfg->m_Display.m_DiffMode = !cfg->m_Display.m_DiffMode;
m_frame->UpdateDiffLayers();
}
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::flipGerberView ) )
{
options.m_FlipGerberView = !options.m_FlipGerberView;
KIGFX::VIEW* view = canvas()->GetView();
view->SetMirror( options.m_FlipGerberView, false );
needs_refresh = true;
cfg->m_Display.m_FlipGerberView = !cfg->m_Display.m_FlipGerberView;
view->SetMirror( cfg->m_Display.m_FlipGerberView, false );
}
if( needs_refresh )
m_frame->UpdateDisplayOptions( options );
m_frame->ApplyDisplaySettingsToGAL();
view->UpdateAllItems( KIGFX::COLOR );
m_frame->GetCanvas()->Refresh();
return 0;
}

View File

@ -25,6 +25,7 @@ using namespace std::placeholders;
#include <bitmaps.h>
#include <eda_item.h>
#include <gerber_collectors.h>
#include <gerbview_settings.h>
#include <class_draw_panel_gal.h>
#include <string_utils.h>
#include <view/view.h>
@ -32,8 +33,6 @@ using namespace std::placeholders;
#include <painter.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <gerbview_id.h>
#include <gerbview_painter.h>
#include "gerbview_selection_tool.h"
#include "gerbview_actions.h"
@ -496,18 +495,11 @@ bool GERBVIEW_SELECTION_TOOL::selectable( const EDA_ITEM* aItem ) const
const GERBER_DRAW_ITEM* item = static_cast<const GERBER_DRAW_ITEM*>( aItem );
int layer = item->GetLayer();
if( item->GetLayerPolarity() )
{
// Don't allow selection of invisible negative items
auto rs = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( getView()->GetPainter()->GetSettings() );
if( !rs->IsShowNegativeItems() )
return false;
}
if( !frame->gvconfig()->m_Appearance.show_negative_objects && item->GetLayerPolarity() )
return false;
// We do not want to select items that are in the background
if( frame->GetDisplayOptions().m_HighContrastMode && layer != frame->GetActiveLayer() )
if( frame->gvconfig()->m_Display.m_HighContrastMode && layer != frame->GetActiveLayer() )
return false;
return frame->IsLayerVisible( layer );

View File

@ -166,10 +166,7 @@ public:
virtual void SetDrawBgColor( const COLOR4D& aColor) { m_drawBgColor= aColor ; }
/// Returns a pointer to the active color theme settings
virtual COLOR_SETTINGS* GetColorSettings() const;
bool ShowPageLimits() const { return m_showPageLimits; }
void SetShowPageLimits( bool aShow ) { m_showPageLimits = aShow; }
virtual COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const;
/**
* @param doOpen if true runs an Open Library browser, otherwise New Library
@ -486,7 +483,6 @@ protected:
///< Prevents opening same file multiple times.
std::unique_ptr<wxSingleInstanceChecker> m_file_checker;
bool m_showPageLimits; // True to display the page limits
COLOR4D m_gridColor; // Grid color
COLOR4D m_drawBgColor; // The background color of the draw canvas; BLACK for
// Pcbnew, BLACK or WHITE for Eeschema

View File

@ -163,7 +163,7 @@ public:
*
* @return a pointer to the active COLOR_SETTINGS.
*/
virtual COLOR_SETTINGS* GetColorSettings() const override
virtual COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override
{
wxFAIL_MSG( "Color settings requested for a PCB_BASE_FRAME that does not override!" );
return nullptr;

View File

@ -32,6 +32,16 @@
#include <project/board_project_settings.h>
enum TRACE_CLEARANCE_DISPLAY_MODE_T
{
DO_NOT_SHOW_CLEARANCE = 0,
SHOW_TRACK_CLEARANCE_WHILE_ROUTING,
SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING,
SHOW_WHILE_ROUTING_OR_DRAGGING,
SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS
};
/**
* Container for display options like enable/disable some optional drawings.
*/
@ -45,14 +55,6 @@ public:
*
* This parameter controls how to show tracks and vias clearance area.
*/
enum TRACE_CLEARANCE_DISPLAY_MODE_T {
DO_NOT_SHOW_CLEARANCE = 0,
SHOW_TRACK_CLEARANCE_WHILE_ROUTING,
SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING,
SHOW_WHILE_ROUTING_OR_DRAGGING,
SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS
};
bool m_DisplayPadFill;
bool m_DisplayViaFill;
bool m_DisplayPadNum; // show pads numbers

View File

@ -212,8 +212,7 @@ public:
void SetGapLengthRatio( double aRatio ) { m_gapLengthRatio = aRatio; }
double GetGapLength( int aLineWidth ) const;
bool GetShowPageLimits() const { return m_showPageLimits; }
void SetShowPageLimits( bool aDraw ) { m_showPageLimits = aDraw; }
virtual bool GetShowPageLimits() const { return true; }
bool IsPrinting() const { return m_isPrinting; }
void SetIsPrinting( bool isPrinting ) { m_isPrinting = isPrinting; }
@ -321,7 +320,6 @@ protected:
double m_dashLengthRatio;
double m_gapLengthRatio;
bool m_showPageLimits;
bool m_isPrinting;
wxDC* m_printDC; // This can go away once the drawing sheet is moved to

View File

@ -93,12 +93,6 @@ void PL_DRAW_PANEL_GAL::DisplayDrawingSheet()
m_pageDrawItem.reset();
// Obviously, always show the page limit:
m_edaFrame->SetShowPageLimits( true );
auto painter = m_view->GetPainter();
auto settings = painter->GetSettings();
settings->SetShowPageLimits( true );
model.SetupDrawEnvironment( m_edaFrame->GetPageSettings(), IU_PER_MILS );
// To show the formatted texts instead of raw texts in drawing sheet editor, we need

View File

@ -90,7 +90,6 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_showBorderAndTitleBlock = true; // true for reference drawings.
DS_DATA_MODEL::GetTheInstance().m_EditMode = true;
SetShowPageLimits( true );
m_aboutTitle = _( "KiCad Drawing Sheet Editor" );
// Give an icon

View File

@ -26,13 +26,13 @@
#include <widgets/gal_options_panel.h>
static const UTIL::CFG_MAP<PCB_DISPLAY_OPTIONS::TRACE_CLEARANCE_DISPLAY_MODE_T> traceClearanceSelectMap =
static const UTIL::CFG_MAP<TRACE_CLEARANCE_DISPLAY_MODE_T> clearanceModeMap =
{
{ PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING, 2 }, // Default
{ PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE, 0 },
{ PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WHILE_ROUTING, 1 },
{ PCB_DISPLAY_OPTIONS::SHOW_WHILE_ROUTING_OR_DRAGGING, 3 },
{ PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS, 4 },
{ SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING, 2 }, // Default
{ DO_NOT_SHOW_CLEARANCE, 0 },
{ SHOW_TRACK_CLEARANCE_WHILE_ROUTING, 1 },
{ SHOW_WHILE_ROUTING_OR_DRAGGING, 3 },
{ SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS, 4 },
};
@ -54,9 +54,8 @@ bool PANEL_DISPLAY_OPTIONS::TransferDataToWindow()
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>();
m_OptDisplayTracksClearance->SetSelection( UTIL::GetConfigForVal(
traceClearanceSelectMap,
cfg->m_Display.m_ShowTrackClearanceMode ) );
int i = UTIL::GetConfigForVal( clearanceModeMap, cfg->m_Display.m_ShowTrackClearanceMode );
m_OptDisplayTracksClearance->SetSelection( i );
m_OptDisplayPadClearence->SetValue( cfg->m_Display.m_DisplayPadClearance );
m_OptDisplayPadNumber->SetValue( cfg->m_Display.m_DisplayPadNum );
@ -86,9 +85,8 @@ bool PANEL_DISPLAY_OPTIONS::TransferDataFromWindow()
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>();
cfg->m_Display.m_ShowTrackClearanceMode = UTIL::GetValFromConfig(
traceClearanceSelectMap,
m_OptDisplayTracksClearance->GetSelection() );
int i = m_OptDisplayTracksClearance->GetSelection();
cfg->m_Display.m_ShowTrackClearanceMode = UTIL::GetValFromConfig( clearanceModeMap, i );
cfg->m_Display.m_DisplayPadClearance = m_OptDisplayPadClearence->GetValue();
cfg->m_Display.m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();

View File

@ -584,12 +584,10 @@ void FOOTPRINT_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
GetSettingsManager()->SaveColorSettings( GetColorSettings(), "board" );
}
COLOR_SETTINGS* FOOTPRINT_EDIT_FRAME::GetColorSettings() const
COLOR_SETTINGS* FOOTPRINT_EDIT_FRAME::GetColorSettings( bool aForceRefresh ) const
{
wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
return Pgm().GetSettingsManager().GetColorSettings( currentTheme );

View File

@ -75,7 +75,7 @@ public:
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
COLOR_SETTINGS* GetColorSettings() const override;
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;

View File

@ -809,7 +809,7 @@ WINDOW_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetWindowSettings( APP_SETTINGS_BASE* a
}
COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetColorSettings() const
COLOR_SETTINGS* FOOTPRINT_VIEWER_FRAME::GetColorSettings( bool aForceRefresh ) const
{
auto* settings = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();

View File

@ -79,7 +79,7 @@ public:
*/
bool ShowModal( wxString* aFootprint, wxWindow* aParent ) override;
COLOR_SETTINGS* GetColorSettings() const override;
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
protected:
FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType );

View File

@ -283,7 +283,7 @@ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
}
COLOR_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetColorSettings() const
COLOR_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetColorSettings( bool aForceRefresh ) const
{
wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;

View File

@ -67,7 +67,7 @@ public:
*/
void PythonPluginsReload();
COLOR_SETTINGS* GetColorSettings() const override;
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
private:

View File

@ -223,7 +223,7 @@ void PCB_BASE_EDIT_FRAME::SetObjectVisible( GAL_LAYER_ID aLayer, bool aVisible )
}
COLOR_SETTINGS* PCB_BASE_EDIT_FRAME::GetColorSettings() const
COLOR_SETTINGS* PCB_BASE_EDIT_FRAME::GetColorSettings( bool aForceRefresh ) const
{
return Pgm().GetSettingsManager().GetColorSettings( GetPcbNewSettings()->m_ColorTheme );
}

View File

@ -175,7 +175,7 @@ public:
///< @copydoc PCB_BASE_FRAME::SetBoard()
virtual void SetBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter = nullptr ) override;
COLOR_SETTINGS* GetColorSettings() const override;
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
/* full undo redo management : */

View File

@ -847,8 +847,8 @@ void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
RENDER_SETTINGS* settings = GetCanvas()->GetView()->GetPainter()->GetSettings();
PCB_RENDER_SETTINGS* renderSettings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( settings );
renderSettings->LoadColors( GetColorSettings() );
renderSettings->LoadDisplayOptions( GetDisplayOptions(), ShowPageLimits() );
renderSettings->LoadColors( GetColorSettings( true ) );
renderSettings->LoadDisplayOptions( GetDisplayOptions() );
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
RecreateToolbars();
@ -896,7 +896,7 @@ void PCB_BASE_FRAME::ActivateGalCanvas()
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
settings->LoadDisplayOptions( displ_opts );
settings->LoadColors( GetColorSettings() );
view->RecacheAllItems();

View File

@ -513,7 +513,7 @@ void PCB_DRAW_PANEL_GAL::OnShow()
SetTopLayer( frame->GetActiveLayer() );
KIGFX::PAINTER* painter = m_view->GetPainter();
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
settings->LoadDisplayOptions( frame->GetDisplayOptions(), frame->ShowPageLimits() );
settings->LoadDisplayOptions( frame->GetDisplayOptions() );
}
}

View File

@ -1028,7 +1028,6 @@ void PCB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
m_rotationAngle = cfg->m_RotationAngle;
m_show_layer_manager_tools = cfg->m_AuiPanels.show_layer_manager;
m_showPageLimits = cfg->m_ShowPageLimits;
}
}
@ -1046,11 +1045,7 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
cfg->m_ShowPageLimits = m_showPageLimits;
}
if( GetSettingsManager() )
GetSettingsManager()->SaveColorSettings( GetColorSettings(), "board" );
}
@ -1727,7 +1722,7 @@ void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
auto* painter = static_cast<KIGFX::PCB_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
auto* renderSettings = painter->GetSettings();
renderSettings->LoadDisplayOptions( GetDisplayOptions(), ShowPageLimits() );
renderSettings->LoadDisplayOptions( GetDisplayOptions() );
SetElementVisibility( LAYER_NO_CONNECTS, GetDisplayOptions().m_DisplayPadNoConnects );
SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest );

View File

@ -56,24 +56,20 @@
#include <geometry/shape_simple.h>
#include <geometry/shape_circle.h>
#include <bezier_curves.h>
#include <kiface_base.h>
#include "pcbnew_settings.h"
using namespace KIGFX;
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
{
m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
m_padNumbers = true;
m_netNamesOnPads = true;
m_netNamesOnTracks = true;
m_netNamesOnVias = true;
m_zoneOutlines = true;
m_zoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
m_clearanceDisplayFlags = CL_NONE;
m_sketchGraphics = false;
m_sketchText = false;
m_netColorMode = NET_COLOR_MODE::RATSNEST;
m_contrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
m_ratsnestDisplayMode = RATSNEST_MODE::ALL;
m_trackOpacity = 1.0;
m_viaOpacity = 1.0;
@ -135,16 +131,11 @@ void PCB_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
}
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions,
bool aShowPageLimits )
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
{
m_hiContrastEnabled = ( aOptions.m_ContrastModeDisplay !=
HIGH_CONTRAST_MODE::NORMAL );
m_padNumbers = aOptions.m_DisplayPadNum;
m_sketchGraphics = !aOptions.m_DisplayGraphicsFill;
m_sketchText = !aOptions.m_DisplayTextFill;
m_curvedRatsnestlines = aOptions.m_DisplayRatsnestLinesCurved;
m_globalRatsnestlines = aOptions.m_ShowGlobalRatsnest;
m_hiContrastEnabled = aOptions.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
m_sketchGraphics = !aOptions.m_DisplayGraphicsFill;
m_sketchText = !aOptions.m_DisplayTextFill;
// Whether to draw tracks, vias & pads filled or as outlines
m_sketchMode[LAYER_PADS_TH] = !aOptions.m_DisplayPadFill;
@ -153,76 +144,17 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOption
m_sketchMode[LAYER_VIA_MICROVIA] = !aOptions.m_DisplayViaFill;
m_sketchMode[LAYER_TRACKS] = !aOptions.m_DisplayPcbTrackFill;
// Net names display settings
switch( aOptions.m_DisplayNetNamesMode )
{
case 0:
m_netNamesOnPads = false;
m_netNamesOnTracks = false;
m_netNamesOnVias = false;
break;
case 1:
m_netNamesOnPads = true;
m_netNamesOnTracks = false;
m_netNamesOnVias = true; // Follow pads or tracks? For now we chose pads....
break;
case 2:
m_netNamesOnPads = false;
m_netNamesOnTracks = true;
m_netNamesOnVias = false; // Follow pads or tracks? For now we chose pads....
break;
case 3:
m_netNamesOnPads = true;
m_netNamesOnTracks = true;
m_netNamesOnVias = true;
break;
}
// Zone display settings
m_zoneDisplayMode = aOptions.m_ZoneDisplayMode;
// Clearance settings
switch( aOptions.m_ShowTrackClearanceMode )
{
case PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE:
m_clearanceDisplayFlags = CL_NONE;
break;
case PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WHILE_ROUTING:
m_clearanceDisplayFlags = CL_NEW | CL_TRACKS;
break;
case PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING:
m_clearanceDisplayFlags = CL_NEW | CL_TRACKS | CL_VIAS;
break;
case PCB_DISPLAY_OPTIONS::SHOW_WHILE_ROUTING_OR_DRAGGING:
m_clearanceDisplayFlags = CL_NEW | CL_EDITED | CL_TRACKS | CL_VIAS;
break;
case PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS:
m_clearanceDisplayFlags = CL_NEW | CL_EDITED | CL_EXISTING | CL_TRACKS | CL_VIAS;
break;
}
if( aOptions.m_DisplayPadClearance )
m_clearanceDisplayFlags |= CL_PADS;
m_contrastModeDisplay = aOptions.m_ContrastModeDisplay;
m_netColorMode = aOptions.m_NetColorMode;
m_ratsnestDisplayMode = aOptions.m_RatsnestMode;
m_trackOpacity = aOptions.m_TrackOpacity;
m_viaOpacity = aOptions.m_ViaOpacity;
m_padOpacity = aOptions.m_PadOpacity;
m_zoneOpacity = aOptions.m_ZoneOpacity;
m_showPageLimits = aShowPageLimits;
}
@ -424,6 +356,18 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
}
PCBNEW_SETTINGS* pcbconfig()
{
return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
}
bool PCB_RENDER_SETTINGS::GetShowPageLimits() const
{
return pcbconfig()->m_ShowPageLimits;
}
PCB_PAINTER::PCB_PAINTER( GAL* aGal ) :
PAINTER( aGal ),
m_maxError( ARC_HIGH_DEF ),
@ -601,7 +545,7 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
if( IsNetnameLayer( aLayer ) )
{
if( !m_pcbSettings.m_netNamesOnTracks )
if( pcbconfig()->m_Display.m_DisplayNetNamesMode < 2 )
return;
if( aTrack->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
@ -667,10 +611,7 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
}
// Clearance lines
constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING
| PCB_RENDER_SETTINGS::CL_TRACKS;
if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags )
if( pcbconfig()->m_Display.m_ShowTrackClearanceMode == SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS )
{
int clearance = aTrack->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
@ -711,10 +652,7 @@ void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
}
// Clearance lines
constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING
| PCB_RENDER_SETTINGS::CL_TRACKS;
if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags )
if( pcbconfig()->m_Display.m_ShowTrackClearanceMode >= SHOW_TRACK_CLEARANCE_WHILE_ROUTING )
{
int clearance = aArc->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
@ -772,8 +710,12 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
VECTOR2D position( center );
// Is anything that we can display enabled?
if( !m_pcbSettings.m_netNamesOnVias || aVia->GetNetname().empty() )
if( pcbconfig()->m_Display.m_DisplayNetNamesMode == 0
|| pcbconfig()->m_Display.m_DisplayNetNamesMode == 2
|| aVia->GetNetname().empty() )
{
return;
}
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
double size = aVia->GetWidth();
@ -887,9 +829,7 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
}
// Clearance lines
constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags
if( pcbconfig()->m_Display.m_ShowTrackClearanceMode >= SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING
&& aLayer != LAYER_VIA_HOLES )
{
PCB_LAYER_ID activeLayer = m_pcbSettings.GetActiveLayer();
@ -911,14 +851,19 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
{
COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
if( IsNetnameLayer( aLayer ) )
{
// Is anything that we can display enabled?
if( m_pcbSettings.m_netNamesOnPads || m_pcbSettings.m_padNumbers )
bool displayNetname = ( pcbconfig()->m_Display.m_DisplayNetNamesMode == 1
|| pcbconfig()->m_Display.m_DisplayNetNamesMode == 3 )
&& !aPad->GetNetname().empty();
bool displayPadNumber = pcbconfig()->m_Display.m_DisplayPadNum;
if( displayNetname || displayPadNumber )
{
bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
EDA_RECT padBBox = aPad->GetBoundingBox();
VECTOR2D position = padBBox.Centre();
VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
@ -970,7 +915,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
// Divide the space, to display both pad numbers and netnames and set the Y text
// position to display 2 lines
if( displayNetname && m_pcbSettings.m_padNumbers )
if( displayNetname && displayPadNumber )
{
size = size / 2.5;
textpos.y = size / 1.7;
@ -1006,7 +951,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->BitmapText( netname, textpos, 0.0 );
}
if( m_pcbSettings.m_padNumbers )
if( displayPadNumber )
{
const wxString& padNumber = aPad->GetNumber();
textpos.y = -textpos.y;
@ -1285,9 +1230,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
}
}
constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags
if( pcbconfig()->m_Display.m_DisplayPadClearance
&& ( aLayer == LAYER_PAD_FR || aLayer == LAYER_PAD_BK || aLayer == LAYER_PADS_TH ) )
{
/* Showing the clearance area is not obvious.

View File

@ -66,22 +66,6 @@ class PCB_RENDER_SETTINGS : public RENDER_SETTINGS
public:
friend class PCB_PAINTER;
///< Flags to control clearance lines visibility
enum CLEARANCE_MODE
{
CL_NONE = 0x00,
// Object type
CL_PADS = 0x01,
CL_VIAS = 0x02,
CL_TRACKS = 0x04,
// Existence
CL_NEW = 0x08,
CL_EDITED = 0x10,
CL_EXISTING = 0x20
};
PCB_RENDER_SETTINGS();
/**
@ -90,12 +74,14 @@ public:
*
* @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 );
virtual void LoadColors( const COLOR_SETTINGS* aSettings ) override;
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
/// @copydoc RENDER_SETTINGS::GetColor()
virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
bool GetShowPageLimits() const override;
/**
* Turn on/off sketch mode for given item layer.
@ -167,19 +153,12 @@ public:
*/
HIGH_CONTRAST_MODE GetContrastModeDisplay() { return m_contrastModeDisplay; }
inline bool GetCurvedRatsnestLinesEnabled() const { return m_curvedRatsnestlines; }
inline bool GetGlobalRatsnestLinesEnabled() const { return m_globalRatsnestlines; }
bool GetDrawIndividualViaLayers() const { return m_drawIndividualViaLayers; }
void SetDrawIndividualViaLayers( bool aFlag ) { m_drawIndividualViaLayers = aFlag; }
NET_COLOR_MODE GetNetColorMode() const { return m_netColorMode; }
void SetNetColorMode( NET_COLOR_MODE aMode ) { m_netColorMode = aMode; }
RATSNEST_MODE GetRatsnestDisplayMode() const { return m_ratsnestDisplayMode; }
void SetRatsnestDisplayMode( RATSNEST_MODE aMode ) { m_ratsnestDisplayMode = aMode; }
std::map<wxString, KIGFX::COLOR4D>& GetNetclassColorMap() { return m_netclassColors; }
std::map<int, KIGFX::COLOR4D>& GetNetColorMap() { return m_netColors; }
@ -197,23 +176,12 @@ protected:
bool m_sketchGraphics;
bool m_sketchText;
bool m_padNumbers;
bool m_netNamesOnPads;
bool m_netNamesOnTracks;
bool m_netNamesOnVias;
bool m_zoneOutlines;
bool m_curvedRatsnestlines = true;
bool m_globalRatsnestlines = true;
bool m_drawIndividualViaLayers = false;
ZONE_DISPLAY_MODE m_zoneDisplayMode;
HIGH_CONTRAST_MODE m_contrastModeDisplay;
RATSNEST_MODE m_ratsnestDisplayMode;
int m_clearanceDisplayFlags;
///< How to display nets and netclasses with color overrides
NET_COLOR_MODE m_netColorMode;

View File

@ -127,6 +127,6 @@ 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() );
settings->LoadDisplayOptions( aOptions, settings->GetShowPageLimits() );
settings->LoadDisplayOptions( aOptions );
}
}

View File

@ -173,7 +173,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<int>( "pcb_display.track_clearance_mode",
reinterpret_cast<int*>( &m_Display.m_ShowTrackClearanceMode ),
PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING ) );
SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.track_fill",
&m_Display.m_DisplayPcbTrackFill, true ) );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -30,17 +30,17 @@
#include <ratsnest/ratsnest_view_item.h>
#include <gal/graphics_abstraction_layer.h>
#include <kiface_base.h>
#include <pcbnew_settings.h>
#include <pcb_painter.h>
#include <ratsnest/ratsnest_data.h>
#include <layer_ids.h>
#include <pcb_base_frame.h>
#include <view/view.h>
#include <memory>
#include <utility>
#include <view/view.h>
RATSNEST_VIEW_ITEM::RATSNEST_VIEW_ITEM( std::shared_ptr<CONNECTIVITY_DATA> aData ) :
EDA_ITEM( NOT_USED ), m_data( std::move(aData) )
@ -71,6 +71,7 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
gal->SetIsStroke( true );
gal->SetIsFill( false );
gal->SetLineWidth( 1.0 );
auto cfg = static_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
COLOR4D defaultColor = rs->GetColor( nullptr, LAYER_RATSNEST );
@ -80,13 +81,12 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
std::set<int> highlightedNets = rs->GetHighlightNetCodes();
const std::set<int>& hiddenNets = rs->GetHiddenNets();
std::map<int, KIGFX::COLOR4D>& netColors = rs->GetNetColorMap();
std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
const std::map<int, wxString>& netclassMap = m_data->GetNetclassMap();
std::map<int, KIGFX::COLOR4D>& netColors = rs->GetNetColorMap();
std::map<wxString, KIGFX::COLOR4D>& ncColors = rs->GetNetclassColorMap();
const std::map<int, wxString>& ncMap = m_data->GetNetclassMap();
const bool onlyVisibleLayers = rs->GetRatsnestDisplayMode() == RATSNEST_MODE::VISIBLE;
LSET visibleLayers;
const bool onlyVisibleLayers = cfg->m_Display.m_RatsnestMode == RATSNEST_MODE::VISIBLE;
LSET visibleLayers;
// If we are in "other layers off" mode, the active layer is the only visible layer
if( rs->GetContrastModeDisplay() == HIGH_CONTRAST_MODE::HIDDEN )
@ -96,11 +96,13 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
else
{
for( PCB_LAYER_ID layer : LSET::AllCuMask().Seq() )
{
if( aView->IsLayerVisible( layer ) )
visibleLayers.set( layer );
}
}
const bool curved_ratsnest = rs->GetCurvedRatsnestLinesEnabled();
const bool curved_ratsnest = cfg->m_Display.m_DisplayRatsnestLinesCurved;
// Draw the "dynamic" ratsnest (i.e. for objects that may be currently being moved)
for( const RN_DYNAMIC_LINE& l : m_data->GetDynamicRatsnest() )
@ -110,9 +112,8 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
if( colorByNet && netColors.count( l.netCode ) )
color = netColors.at( l.netCode );
else if( colorByNet && netclassMap.count( l.netCode )
&& netclassColors.count( netclassMap.at( l.netCode ) ) )
color = netclassColors.at( netclassMap.at( l.netCode ) );
else if( colorByNet && ncMap.count( l.netCode ) && ncColors.count( ncMap.at( l.netCode ) ) )
color = ncColors.at( ncMap.at( l.netCode ) );
else
color = defaultColor;
@ -132,10 +133,10 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{
if( curved_ratsnest )
{
auto dx = l.b.x - l.a.x;
auto dy = l.b.y - l.a.y;
const auto center = VECTOR2I( l.a.x + 0.5 * dx - 0.1 * dy,
l.a.y + 0.5 * dy + 0.1 * dx );
int dx = l.b.x - l.a.x;
int dy = l.b.y - l.a.y;
const VECTOR2I center = VECTOR2I( l.a.x + 0.5 * dx - 0.1 * dy,
l.a.y + 0.5 * dy + 0.1 * dx );
gal->DrawCurve( l.a, center, center, l.b );
}
else
@ -157,9 +158,8 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
if( colorByNet && netColors.count( i ) )
color = netColors.at( i );
else if( colorByNet && netclassMap.count( i )
&& netclassColors.count( netclassMap.at( i ) ) )
color = netclassColors.at( netclassMap.at( i ) );
else if( colorByNet && ncMap.count( i ) && ncColors.count( ncMap.at( i ) ) )
color = ncColors.at( ncMap.at( i ) );
else
color = defaultColor;
@ -188,16 +188,20 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
bool enable = !sourceNode->GetNoLine() && !targetNode->GetNoLine();
bool show;
// If the global ratsnest is currently enabled, the local ratsnest
// should be easy to turn off, so either element can disable it
// If the global ratsnest is currently enabled, the local ratsnest should be easy to
// turn off, so either element can disable it.
// If the global ratsnest is disabled, the local ratsnest should be easy to turn on
// so either element can enable it.
if( rs->GetGlobalRatsnestLinesEnabled() )
if( cfg->m_Display.m_ShowGlobalRatsnest )
{
show = sourceNode->Parent()->GetLocalRatsnestVisible() &&
targetNode->Parent()->GetLocalRatsnestVisible();
}
else
{
show = sourceNode->Parent()->GetLocalRatsnestVisible() ||
targetNode->Parent()->GetLocalRatsnestVisible();
}
if( onlyVisibleLayers && show )
{
@ -206,7 +210,9 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
if( !( sourceLayers & visibleLayers ).any() ||
!( targetLayers & visibleLayers ).any() )
{
show = false;
}
}
if ( enable && show )
@ -222,10 +228,10 @@ void RATSNEST_VIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{
if( curved_ratsnest )
{
auto dx = target.x - source.x;
auto dy = target.y - source.y;
const auto center = VECTOR2I( source.x + 0.5 * dx - 0.1 * dy,
source.y + 0.5 * dy + 0.1 * dx );
int dx = target.x - source.x;
int dy = target.y - source.y;
const VECTOR2I center = VECTOR2I( source.x + 0.5 * dx - 0.1 * dy,
source.y + 0.5 * dy + 0.1 * dx );
gal->DrawCurve( source, center, center, target );
}
else

View File

@ -1426,16 +1426,16 @@ void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aClearance, bool
switch( m_dispOptions->m_ShowTrackClearanceMode )
{
case PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS:
case PCB_DISPLAY_OPTIONS::SHOW_WHILE_ROUTING_OR_DRAGGING:
case SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS:
case SHOW_WHILE_ROUTING_OR_DRAGGING:
pitem->ShowClearance( aItem->OfKind( tracksOrVias ) );
break;
case PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING:
case SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING:
pitem->ShowClearance( aItem->OfKind( tracksOrVias ) && !aEdit );
break;
case PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WHILE_ROUTING:
case SHOW_TRACK_CLEARANCE_WHILE_ROUTING:
pitem->ShowClearance( aItem->OfKind( tracks ) && !aEdit );
break;