Moved background color settings from GAL to RENDER_SETTINGS. Added RENDER_SETTINGS::TranslateColor() to convert between EDA_COLOR_T and COLOR4D.
This commit is contained in:
parent
2cba91f974
commit
d27ea7895d
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 CERN
|
* Copyright (C) 2013-2014 CERN
|
||||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -124,7 +124,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||||
|
|
||||||
m_view->UpdateItems();
|
m_view->UpdateItems();
|
||||||
m_gal->BeginDrawing();
|
m_gal->BeginDrawing();
|
||||||
m_gal->ClearScreen();
|
m_gal->ClearScreen( m_painter->GetSettings()->GetBackgroundColor() );
|
||||||
|
|
||||||
if( m_view->IsDirty() )
|
if( m_view->IsDirty() )
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,6 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
|
||||||
|
|
||||||
wxSize size = GetClientSize();
|
wxSize size = GetClientSize();
|
||||||
m_gal->ResizeScreen( size.GetX(), size.GetY() );
|
m_gal->ResizeScreen( size.GetX(), size.GetY() );
|
||||||
m_gal->SetBackgroundColor( KIGFX::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
|
|
||||||
|
|
||||||
if( m_painter )
|
if( m_painter )
|
||||||
m_painter->SetGAL( m_gal );
|
m_painter->SetGAL( m_gal );
|
||||||
|
|
|
@ -315,10 +315,10 @@ void CAIRO_GAL::Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL::ClearScreen()
|
void CAIRO_GAL::ClearScreen( const COLOR4D& aColor )
|
||||||
{
|
{
|
||||||
cairo_set_source_rgb( currentContext,
|
backgroundColor = aColor;
|
||||||
backgroundColor.r, backgroundColor.g, backgroundColor.b );
|
cairo_set_source_rgb( currentContext, aColor.r, aColor.g, aColor.b );
|
||||||
cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
|
cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
|
||||||
cairo_fill( currentContext );
|
cairo_fill( currentContext );
|
||||||
}
|
}
|
||||||
|
@ -973,7 +973,7 @@ void CAIRO_GAL::initSurface()
|
||||||
cairo_set_antialias( context, CAIRO_ANTIALIAS_SUBPIXEL );
|
cairo_set_antialias( context, CAIRO_ANTIALIAS_SUBPIXEL );
|
||||||
|
|
||||||
// Clear the screen
|
// Clear the screen
|
||||||
ClearScreen();
|
ClearScreen( backgroundColor );
|
||||||
|
|
||||||
// Compute the world <-> screen transformations
|
// Compute the world <-> screen transformations
|
||||||
ComputeWorldScreenMatrix();
|
ComputeWorldScreenMatrix();
|
||||||
|
|
|
@ -589,10 +589,10 @@ void OPENGL_GAL::Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OPENGL_GAL::ClearScreen()
|
void OPENGL_GAL::ClearScreen( const COLOR4D& aColor )
|
||||||
{
|
{
|
||||||
// Clear screen
|
// Clear screen
|
||||||
glClearColor( backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a );
|
glClearColor( aColor.r, aColor.g, aColor.b, aColor.a );
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 CERN
|
* Copyright (C) 2013-2014 CERN
|
||||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
virtual void Flush();
|
virtual void Flush();
|
||||||
|
|
||||||
/// @copydoc GAL::ClearScreen()
|
/// @copydoc GAL::ClearScreen()
|
||||||
virtual void ClearScreen();
|
virtual void ClearScreen( const COLOR4D& aColor );
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
// Attribute setting
|
// Attribute setting
|
||||||
|
@ -309,7 +309,7 @@ private:
|
||||||
/// Type definition for an graphics group element
|
/// Type definition for an graphics group element
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GRAPHICS_COMMAND command; ///< Command to execute
|
GRAPHICS_COMMAND command; ///< Command to execute
|
||||||
double arguments[MAX_CAIRO_ARGUMENTS]; ///< Arguments for Cairo commands
|
double arguments[MAX_CAIRO_ARGUMENTS]; ///< Arguments for Cairo commands
|
||||||
bool boolArgument; ///< A bool argument
|
bool boolArgument; ///< A bool argument
|
||||||
int intArgument; ///< An int argument
|
int intArgument; ///< An int argument
|
||||||
|
@ -333,6 +333,7 @@ private:
|
||||||
unsigned int* bitmapBufferBackup; ///< Backup storage of the cairo image
|
unsigned int* bitmapBufferBackup; ///< Backup storage of the cairo image
|
||||||
int stride; ///< Stride value for Cairo
|
int stride; ///< Stride value for Cairo
|
||||||
bool isInitialized; ///< Are Cairo image & surface ready to use
|
bool isInitialized; ///< Are Cairo image & surface ready to use
|
||||||
|
COLOR4D backgroundColor; ///< Background color
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void storePath(); ///< Store the actual path
|
void storePath(); ///< Store the actual path
|
||||||
|
|
|
@ -168,8 +168,11 @@ public:
|
||||||
/// @brief Force all remaining objects to be drawn.
|
/// @brief Force all remaining objects to be drawn.
|
||||||
virtual void Flush() = 0;
|
virtual void Flush() = 0;
|
||||||
|
|
||||||
/// @brief Clear the screen.
|
/**
|
||||||
virtual void ClearScreen() = 0;
|
* @brief Clear the screen.
|
||||||
|
* @param aColor is the color used for clearing.
|
||||||
|
*/
|
||||||
|
virtual void ClearScreen( const COLOR4D& aColor ) = 0;
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
// Attribute setting
|
// Attribute setting
|
||||||
|
@ -225,16 +228,6 @@ public:
|
||||||
return strokeColor;
|
return strokeColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the background color.
|
|
||||||
*
|
|
||||||
* @param aColor is the color for background filling.
|
|
||||||
*/
|
|
||||||
inline virtual void SetBackgroundColor( const COLOR4D& aColor )
|
|
||||||
{
|
|
||||||
backgroundColor = aColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the line width.
|
* @brief Set the line width.
|
||||||
*
|
*
|
||||||
|
@ -849,7 +842,6 @@ protected:
|
||||||
bool isFillEnabled; ///< Is filling of graphic objects enabled ?
|
bool isFillEnabled; ///< Is filling of graphic objects enabled ?
|
||||||
bool isStrokeEnabled; ///< Are the outlines stroked ?
|
bool isStrokeEnabled; ///< Are the outlines stroked ?
|
||||||
|
|
||||||
COLOR4D backgroundColor; ///< The background color
|
|
||||||
COLOR4D fillColor; ///< The fill color
|
COLOR4D fillColor; ///< The fill color
|
||||||
COLOR4D strokeColor; ///< The color of the outlines
|
COLOR4D strokeColor; ///< The color of the outlines
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ public:
|
||||||
virtual void Flush();
|
virtual void Flush();
|
||||||
|
|
||||||
/// @copydoc GAL::ClearScreen()
|
/// @copydoc GAL::ClearScreen()
|
||||||
virtual void ClearScreen();
|
virtual void ClearScreen( const COLOR4D& aColor );
|
||||||
|
|
||||||
// --------------
|
// --------------
|
||||||
// Transformation
|
// Transformation
|
||||||
|
|
|
@ -177,6 +177,36 @@ public:
|
||||||
return m_worksheetLineWidth;
|
return m_worksheetLineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function TranslateColor
|
||||||
|
* Returns the color responding to the one of EDA_COLOR_T enum values.
|
||||||
|
* @param EDA_COLOR_T color equivalent.
|
||||||
|
*/
|
||||||
|
const COLOR4D& TranslateColor( EDA_COLOR_T aColor )
|
||||||
|
{
|
||||||
|
return m_legacyColorMap[aColor];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetBackgroundColor
|
||||||
|
* Returns current background color settings.
|
||||||
|
* @return Background color.
|
||||||
|
*/
|
||||||
|
const COLOR4D& GetBackgroundColor() const
|
||||||
|
{
|
||||||
|
return m_backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SetBackgroundColor
|
||||||
|
* Sets new color for background.
|
||||||
|
* @param aColor is the new background color.
|
||||||
|
*/
|
||||||
|
void SetBackgroundColor( const COLOR4D& aColor )
|
||||||
|
{
|
||||||
|
m_backgroundColor = aColor;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Function update
|
* Function update
|
||||||
|
@ -203,6 +233,8 @@ protected:
|
||||||
float m_outlineWidth; ///< Line width used when drawing outlines
|
float m_outlineWidth; ///< Line width used when drawing outlines
|
||||||
float m_worksheetLineWidth; ///< Line width used when drawing worksheet
|
float m_worksheetLineWidth; ///< Line width used when drawing worksheet
|
||||||
|
|
||||||
|
COLOR4D m_backgroundColor; ///< The background color
|
||||||
|
|
||||||
/// Map of colors that were usually used for display
|
/// Map of colors that were usually used for display
|
||||||
std::map<EDA_COLOR_T, COLOR4D> m_legacyColorMap;
|
std::map<EDA_COLOR_T, COLOR4D> m_legacyColorMap;
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,8 @@ using namespace KIGFX;
|
||||||
|
|
||||||
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
|
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
|
||||||
{
|
{
|
||||||
|
m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
|
||||||
|
|
||||||
// By default everything should be displayed as filled
|
// By default everything should be displayed as filled
|
||||||
for( unsigned int i = 0; i < END_PCB_VISIBLE_LIST; ++i )
|
for( unsigned int i = 0; i < END_PCB_VISIBLE_LIST; ++i )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue