Fix regression in GerbView display settings; some optimization too

This commit is contained in:
Jon Evans 2018-02-25 12:38:35 -05:00 committed by Wayne Stambaugh
parent 2b52415cae
commit b90528a7ae
4 changed files with 44 additions and 15 deletions

View File

@ -1288,6 +1288,20 @@ void VIEW::UpdateItems()
}
void VIEW::UpdateAllItems( int aUpdateFlags )
{
for( VIEW_ITEM* item : m_allItems )
{
auto viewData = item->viewPrivData();
if( !viewData )
continue;
viewData->m_requiredUpdate |= aUpdateFlags;
}
}
struct VIEW::extentsVisitor
{
BOX2I extents;

View File

@ -450,6 +450,8 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
bool state;
bool needs_refresh = false;
bool needs_repaint = false;
switch( id )
{
@ -471,20 +473,17 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
m_DisplayOptions.m_DisplayFlashedItemsFill = not state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
needs_refresh = needs_repaint = true;
break;
case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
m_DisplayOptions.m_DisplayLinesFill = not state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
needs_refresh = needs_repaint = true;
break;
case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH:
m_DisplayOptions.m_DisplayPolygonsFill = not state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
needs_refresh = needs_repaint = true;
break;
case ID_TB_OPTIONS_SHOW_DCODES:
@ -499,14 +498,12 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_DIFF_MODE:
m_DisplayOptions.m_DiffMode = state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
needs_refresh = true;
break;
case ID_TB_OPTIONS_HIGH_CONTRAST_MODE:
m_DisplayOptions.m_HighContrastMode = state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
needs_refresh = true;
break;
case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR:
@ -529,6 +526,19 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
wxMessageBox( wxT( "GERBVIEW_FRAME::OnSelectOptionToolbar error" ) );
break;
}
if( needs_refresh )
{
applyDisplaySettingsToGAL();
auto view = GetGalCanvas()->GetView();
if( needs_repaint )
view->UpdateAllItems( KIGFX::GEOMETRY );
else
view->UpdateAllItems( KIGFX::COLOR );
m_canvas->Refresh( true );
}
}

View File

@ -56,6 +56,10 @@ void GERBVIEW_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS*
i < GERBVIEW_LAYER_ID_START + GERBER_DRAWLAYERS_COUNT; i++ )
{
COLOR4D baseColor = aSettings->GetLayerColor( i );
if( m_diffMode )
baseColor.a = 0.75;
m_layerColors[i] = baseColor;
m_layerColorsHi[i] = baseColor.Brightened( 0.5 );
m_layerColorsSel[i] = baseColor.Brightened( 0.8 );
@ -225,11 +229,6 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
if( aItem->IsBrightened() )
color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
if( m_gerbviewSettings.m_diffMode )
{
color.a = 0.75;
}
m_gal->SetNegativeDrawMode( isNegative );
m_gal->SetStrokeColor( color );
m_gal->SetFillColor( color );

View File

@ -610,6 +610,12 @@ public:
*/
void UpdateItems();
/**
* Updates all items in the view according to the given flags
* @param aUpdateFlags is is according to KIGFX::VIEW_UPDATE_FLAGS
*/
void UpdateAllItems( int aUpdateFlags );
const BOX2I CalculateExtents() ;
/**