Gerbview: fix issues when setting the grid color and the worksheet color.
The issue for the grid color was due to the fact there are 2 places to store the color: the color settings and the m_gridColor GERBVIEW_FRAME member. The worksheet color (color set to RED after a color change in layer render) is a bit strange: looks like LAYER_GERBVIEW_WORKSHEET and LAYER_WORKSHEET are both used to draw the worksheet.
This commit is contained in:
parent
3dd2dc89ad
commit
8c15ecf8e4
|
@ -110,7 +110,7 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
|
|||
CLR( "gerbview.dcodes", LAYER_DCODES, COLOR4D( WHITE ) );
|
||||
CLR( "gerbview.grid", LAYER_GERBVIEW_GRID, COLOR4D( MAGENTA ) );
|
||||
CLR( "gerbview.negative_objects", LAYER_NEGATIVE_OBJECTS, COLOR4D( DARKGRAY ) );
|
||||
CLR( "gerbview.worksheet", LAYER_GERBVIEW_WORKSHEET, COLOR4D( BLUE ) );
|
||||
CLR( "gerbview.worksheet", LAYER_GERBVIEW_WORKSHEET, COLOR4D( RED ) );
|
||||
|
||||
// TODO(JE) New default scheme for GerbView
|
||||
for( int i = 0, id = GERBVIEW_LAYER_ID_START;
|
||||
|
|
|
@ -205,6 +205,8 @@ void GERBVIEW_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
|
|||
|
||||
BOX2I GERBVIEW_DRAW_PANEL_GAL::GetDefaultViewBBox() const
|
||||
{
|
||||
// Even in Gervbview, this is the LAYER_WORKSHEET that controls the visibility
|
||||
// of the worksheet
|
||||
if( m_worksheet && m_view->IsLayerVisible( LAYER_WORKSHEET ) )
|
||||
return m_worksheet->ViewBBox();
|
||||
|
||||
|
|
|
@ -62,6 +62,11 @@ public:
|
|||
*/
|
||||
void SetWorksheet( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet );
|
||||
|
||||
/**
|
||||
* @return the current worksheet
|
||||
*/
|
||||
KIGFX::WS_PROXY_VIEW_ITEM* GetWorksheet() const { return m_worksheet.get(); }
|
||||
|
||||
protected:
|
||||
///> Sets rendering targets & dependencies for layers.
|
||||
void setDefaultLayerDeps();
|
||||
|
|
|
@ -807,6 +807,7 @@ bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
|
|||
COLOR4D GERBVIEW_FRAME::GetVisibleElementColor( int aLayerID )
|
||||
{
|
||||
COLOR4D color = COLOR4D::UNSPECIFIED;
|
||||
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
switch( aLayerID )
|
||||
{
|
||||
|
@ -814,7 +815,7 @@ COLOR4D GERBVIEW_FRAME::GetVisibleElementColor( int aLayerID )
|
|||
case LAYER_DCODES:
|
||||
case LAYER_GERBVIEW_WORKSHEET:
|
||||
case LAYER_GERBVIEW_BACKGROUND:
|
||||
color = Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayerID );
|
||||
color = settings->GetColor( aLayerID );
|
||||
break;
|
||||
|
||||
case LAYER_GERBVIEW_GRID:
|
||||
|
@ -844,10 +845,17 @@ void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, COLOR4D aColor )
|
|||
{
|
||||
case LAYER_NEGATIVE_OBJECTS:
|
||||
case LAYER_DCODES:
|
||||
case LAYER_GERBVIEW_WORKSHEET:
|
||||
settings->SetColor( aLayerID, aColor );
|
||||
break;
|
||||
|
||||
case LAYER_GERBVIEW_WORKSHEET:
|
||||
settings->SetColor( LAYER_GERBVIEW_WORKSHEET, aColor );
|
||||
// LAYER_WORKSHEET color is alsu used to draw the worksheet
|
||||
// FIX ME: why LAYER_WORKSHEET must be set, although LAYER_GERBVIEW_WORKSHEET
|
||||
// is used to initialize the worksheet color layer.
|
||||
settings->SetColor( LAYER_WORKSHEET, aColor );
|
||||
break;
|
||||
|
||||
case LAYER_GERBVIEW_GRID:
|
||||
SetGridColor( aColor );
|
||||
settings->SetColor( aLayerID, aColor );
|
||||
|
@ -958,8 +966,15 @@ void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
|
|||
}
|
||||
|
||||
|
||||
COLOR4D GERBVIEW_FRAME::GetGridColor()
|
||||
{
|
||||
return Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_GRID );
|
||||
}
|
||||
|
||||
|
||||
void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor )
|
||||
{
|
||||
Pgm().GetSettingsManager().GetColorSettings()->SetColor( LAYER_GRID, aColor );
|
||||
GetCanvas()->GetGAL()->SetGridColor( aColor );
|
||||
m_gridColor = aColor;
|
||||
}
|
||||
|
|
|
@ -129,6 +129,11 @@ public:
|
|||
*/
|
||||
int SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount );
|
||||
|
||||
/**
|
||||
* @return the color of the grid
|
||||
*/
|
||||
COLOR4D GetGridColor() override;
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::SetGridColor()
|
||||
virtual void SetGridColor( COLOR4D aColor ) override;
|
||||
|
||||
|
|
|
@ -250,7 +250,6 @@ void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
|
|||
{
|
||||
// NOTE: Active layer in GerbView is stored as 0-indexed, but layer color is
|
||||
// stored according to the GERBER_DRAW_LAYER() offset.
|
||||
|
||||
myframe->SetLayerColor( GERBER_DRAW_LAYER( aLayer ), aColor );
|
||||
myframe->m_SelLayerBox->ResyncBitmapOnly();
|
||||
|
||||
|
@ -294,17 +293,16 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin
|
|||
myframe->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
#include "gerbview_draw_panel_gal.h"
|
||||
void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
|
||||
{
|
||||
myframe->SetVisibleElementColor( aId, aColor );
|
||||
|
||||
auto view = myframe->GetCanvas()->GetView();
|
||||
auto settings = Pgm().GetSettingsManager().GetColorSettings();
|
||||
COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
view->GetPainter()->GetSettings()->LoadColors( settings );
|
||||
view->UpdateLayerColor( aId );
|
||||
|
||||
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
view->UpdateAllItems( KIGFX::COLOR );
|
||||
myframe->GetCanvas()->Refresh();
|
||||
|
|
|
@ -55,6 +55,7 @@ void GERBVIEW_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
|||
size_t palette_size = aSettings->m_Palette.size();
|
||||
size_t palette_idx = 0;
|
||||
|
||||
// Layers to draw gerber data read from gerber files:
|
||||
for( int i = GERBVIEW_LAYER_ID_START;
|
||||
i < GERBVIEW_LAYER_ID_START + GERBER_DRAWLAYERS_COUNT; i++ )
|
||||
{
|
||||
|
@ -72,6 +73,9 @@ void GERBVIEW_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
|||
m_layerColorsDark[i] = baseColor.Darkened( 0.25 );
|
||||
}
|
||||
|
||||
// Draw layers specific to Gerbview:
|
||||
// LAYER_DCODES, LAYER_NEGATIVE_OBJECTS, LAYER_GERBVIEW_GRID,
|
||||
// LAYER_GERBVIEW_AXES, LAYER_GERBVIEW_BACKGROUND, LAYER_GERBVIEW_WORKSHEET,
|
||||
for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ )
|
||||
m_layerColors[i] = aSettings->GetColor( i );
|
||||
|
||||
|
|
Loading…
Reference in New Issue