Change from EDA_COLOR_T to COLOR4D globally; arbitrary color support

eeschema now supports arbitrary colors for all object types, and
pcbnew does in GAL canvas.  When switching from GAL to legacy canvas,
pcbnew will convert colors to the nearest legacy color.
This commit is contained in:
Jon Evans 2017-02-20 17:57:41 +01:00 committed by Maciej Suminski
parent 4c83b0a94d
commit a52250a91e
197 changed files with 1332 additions and 983 deletions

View File

@ -532,16 +532,9 @@ SFVEC3F CINFO3D_VISU::GetLayerColor( LAYER_ID aLayerId ) const
{
wxASSERT( aLayerId < LAYER_ID_COUNT );
const EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayerId );
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
const COLOR4D color = g_ColorsSettings.GetLayerColor( aLayerId );
static const float inv_255 = 1.0f / 255.0f;
const float red = colordata.m_Red * inv_255;
const float green = colordata.m_Green * inv_255;
const float blue = colordata.m_Blue * inv_255;
return SFVEC3F( red, green, blue );
return SFVEC3F( color.r, color.g, color.b );
}
@ -551,15 +544,7 @@ SFVEC3F CINFO3D_VISU::GetItemColor( int aItemId ) const
}
SFVEC3F CINFO3D_VISU::GetColor( EDA_COLOR_T aColor ) const
SFVEC3F CINFO3D_VISU::GetColor( COLOR4D aColor ) const
{
const StructColors &colordata = g_ColorRefs[ColorGetBase( aColor )];
static const float inv_255 = 1.0f / 255.0f;
const float red = colordata.m_Red * inv_255;
const float green = colordata.m_Green * inv_255;
const float blue = colordata.m_Blue * inv_255;
return SFVEC3F( red, green, blue );
return SFVEC3F( aColor.r, aColor.g, aColor.b );
}

View File

@ -270,7 +270,7 @@ class CINFO3D_VISU
* @param aColor: the color mapped
* @return the color in SFVEC3F format
*/
SFVEC3F GetColor( EDA_COLOR_T aColor ) const;
SFVEC3F GetColor( COLOR4D aColor ) const;
/**
* @brief GetLayerTopZpos3DU - Get the top z position

View File

@ -106,7 +106,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
s_boardBBox3DU = &m_board2dBBox3DU;
// not actually used, but needed by DrawGraphicText
const EDA_COLOR_T dummy_color = BLACK;
const COLOR4D dummy_color = COLOR4D_BLACK;
if( aTextPCB->IsMultilineAllowed() )
{

View File

@ -111,6 +111,11 @@ set(3D-VIEWER_SRCS
add_library(3d-viewer STATIC ${3D-VIEWER_SRCS})
add_dependencies( 3d-viewer pcbcommon )
target_link_libraries( 3d-viewer ${Boost_} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} kicad_3dsg )
target_link_libraries( 3d-viewer
gal
${Boost_}
${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES}
kicad_3dsg )
add_subdirectory( 3d_cache )

View File

@ -47,6 +47,7 @@ target_link_libraries( bitmap2component
common
polygon
bitmaps
gal
${wxWidgets_LIBRARIES}
potrace
)

View File

@ -122,7 +122,7 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
if( !aDC )
return;

View File

@ -287,7 +287,7 @@ void BITMAP_BASE::Rotate( bool aRotateCCW )
void BITMAP_BASE::PlotImage( PLOTTER* aPlotter,
const wxPoint& aPos,
EDA_COLOR_T aDefaultColor,
COLOR4D aDefaultColor,
int aDefaultPensize )
{
if( m_image == NULL )

View File

@ -27,7 +27,6 @@
* @brief Handle colors used to draw all items or layers.
*/
#include <fctsys.h>
#include <colors.h>
#include <macros.h>
#include <class_colors_design_settings.h>
@ -91,7 +90,7 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
{
for( unsigned src = 0, dst = 0; dst < DIM(m_LayersColors); ++dst )
{
m_LayersColors[dst] = default_layer_color[src++];
m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
if( src >= DIM( default_layer_color ) )
src = 0; // wrap the source.
@ -99,7 +98,7 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
for( unsigned src = 0, dst = 0; dst < DIM(m_ItemsColors); ++dst )
{
m_ItemsColors[dst] = default_items_color[src++];
m_ItemsColors[dst] = COLOR4D( default_items_color[src++] );
if( src >= DIM( default_items_color ) )
src = 0;
@ -107,17 +106,17 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
}
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
{
if( (unsigned) aLayer < DIM(m_LayersColors) )
{
return m_LayersColors[aLayer];
}
return UNSPECIFIED_COLOR;
return UNSPECIFIED_COLOR4D;
}
void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
{
if( (unsigned) aLayer < DIM(m_LayersColors) )
{
@ -126,18 +125,18 @@ void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor
}
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
{
if( (unsigned) aItemIdx < DIM( m_ItemsColors ) )
{
return m_ItemsColors[aItemIdx];
}
return UNSPECIFIED_COLOR;
return UNSPECIFIED_COLOR4D;
}
void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, EDA_COLOR_T aColor )
void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, COLOR4D aColor )
{
if( (unsigned) aItemIdx < DIM(m_ItemsColors) )
{
@ -146,7 +145,7 @@ void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, EDA_COLOR_T aColor )
}
void COLORS_DESIGN_SETTINGS::SetAllColorsAs( EDA_COLOR_T aColor )
void COLORS_DESIGN_SETTINGS::SetAllColorsAs( COLOR4D aColor )
{
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
m_LayersColors[ii] = aColor;

View File

@ -26,7 +26,6 @@
#include <colors_selection.h>
#include <layers_id_colors_and_visibility.h>
#include <bitmaps.h>
#include <colors.h>
#include <wx/wx.h>
#include <wx/ownerdrw.h>
@ -56,7 +55,7 @@ void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetColour( GetLayerColor( aLayer ).ToColour() );
brush.SetStyle( wxBRUSHSTYLE_SOLID );
bmpDC.SetBrush( brush );

View File

@ -42,6 +42,8 @@
#include <pgm_base.h>
using KIGFX::COLOR4D;
/**
* Global variables definitions.
@ -53,7 +55,7 @@
bool g_ShowPageLimits = true;
EDA_UNITS_T g_UserUnit;
EDA_COLOR_T g_GhostColor;
COLOR4D g_GhostColor;
/* Class LOCALE_IO

View File

@ -25,6 +25,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <trigo.h>
@ -68,7 +69,7 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
SetDefaultLineWidth( 0 ); // No line width on DXF
m_plotMirror = false; // No mirroring on DXF
m_currentColor = BLACK;
m_currentColor = COLOR4D_BLACK;
}
/**
@ -275,17 +276,17 @@ bool DXF_PLOTTER::EndPlot()
/**
* The DXF exporter handles 'colors' as layers...
*/
void DXF_PLOTTER::SetColor( EDA_COLOR_T color )
void DXF_PLOTTER::SetColor( COLOR4D color )
{
wxASSERT( outputFile );
if( ( color >= 0 && colorMode )
|| ( color == BLACK )
|| ( color == WHITE ) )
if( ( colorMode )
|| ( color == COLOR4D_BLACK )
|| ( color == COLOR4D_WHITE ) )
{
m_currentColor = color;
}
else
m_currentColor = BLACK;
m_currentColor = COLOR4D_BLACK;
}
/**
@ -315,14 +316,16 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int
DPOINT centre_dev = userToDeviceCoordinates( centre );
if( radius > 0 )
{
wxString cname( ColorGetName( m_currentColor ) );
if (!fill)
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
if( !fill )
{
fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
TO_UTF8( cname ),
centre_dev.x, centre_dev.y, radius );
}
if (fill == FILLED_SHAPE)
if( fill == FILLED_SHAPE )
{
double r = radius*0.5;
fprintf( outputFile, "0\nPOLYLINE\n");
@ -462,7 +465,7 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
if( penLastpos != pos && plume == 'D' )
{
// DXF LINE
wxString cname( ColorGetName( m_currentColor ) );
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
TO_UTF8( cname ),
pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
@ -509,7 +512,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
double radius_dev = userToDeviceSize( radius );
// Emit a DXF ARC entity
wxString cname( ColorGetName( m_currentColor ) );
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
fprintf( outputFile,
"0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
TO_UTF8( cname ),
@ -699,7 +702,7 @@ bool containsNonAsciiChars( const wxString& string )
}
void DXF_PLOTTER::Text( const wxPoint& aPos,
enum EDA_COLOR_T aColor,
COLOR4D aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
@ -729,7 +732,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
more useful as a CAD object */
DPOINT origin_dev = userToDeviceCoordinates( aPos );
SetColor( aColor );
wxString cname( ColorGetName( m_currentColor ) );
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
DPOINT size_dev = userToDeviceSize( aSize );
int h_code = 0, v_code = 0;
switch( aH_justify )

View File

@ -938,7 +938,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCo
}
void GERBER_PLOTTER::Text( const wxPoint& aPos, enum EDA_COLOR_T aColor,
void GERBER_PLOTTER::Text( const wxPoint& aPos, const COLOR4D aColor,
const wxString& aText, double aOrient, const wxSize& aSize,
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed,

View File

@ -755,7 +755,7 @@ bool PDF_PLOTTER::EndPlot()
}
void PDF_PLOTTER::Text( const wxPoint& aPos,
enum EDA_COLOR_T aColor,
const COLOR4D aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,

View File

@ -56,21 +56,14 @@ void PSLIKE_PLOTTER::SetDefaultLineWidth( int width )
}
void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
void PSLIKE_PLOTTER::SetColor( COLOR4D color )
{
// Return at invalid color index
if( color < 0 )
return;
if( colorMode )
{
double r = g_ColorRefs[color].m_Red / 255.0;
double g = g_ColorRefs[color].m_Green / 255.0;
double b = g_ColorRefs[color].m_Blue / 255.0;
if( negativeMode )
emitSetRGBColor( 1 - r, 1 - g, 1 - b );
emitSetRGBColor( 1 - color.r, 1 - color.g, 1 - color.b );
else
emitSetRGBColor( r, g, b );
emitSetRGBColor( color.r, color.g, color.b );
}
else
{
@ -79,7 +72,7 @@ void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
* holes in white on pads in black
*/
double k = 1; // White
if( color != WHITE )
if( color != COLOR4D_WHITE )
k = 0;
if( negativeMode )
emitSetRGBColor( 1 - k, 1 - k, 1 - k );
@ -927,7 +920,7 @@ bool PS_PLOTTER::EndPlot()
void PS_PLOTTER::Text( const wxPoint& aPos,
enum EDA_COLOR_T aColor,
const COLOR4D aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,

View File

@ -187,7 +187,7 @@ void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
}
void SVG_PLOTTER::SetColor( EDA_COLOR_T color )
void SVG_PLOTTER::SetColor( COLOR4D color )
{
PSLIKE_PLOTTER::SetColor( color );
@ -602,7 +602,7 @@ bool SVG_PLOTTER::EndPlot()
void SVG_PLOTTER::Text( const wxPoint& aPos,
enum EDA_COLOR_T aColor,
const COLOR4D aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,

View File

@ -79,7 +79,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
*/
double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
EDA_COLOR_T plotColor = plotter->GetColorMode() ? RED : BLACK;
COLOR4D plotColor = plotter->GetColorMode() ? COLOR4D( RED ) : COLOR4D_BLACK;
plotter->SetColor( plotColor );
WS_DRAW_ITEM_LIST drawList;

View File

@ -243,8 +243,8 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val,
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, COLOR4D* ptparam,
COLOR4D default_val,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
{
@ -255,8 +255,8 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptpa
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
const wxString& ident,
EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val,
COLOR4D* ptparam,
COLOR4D default_val,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
{
@ -271,11 +271,22 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
if( !m_Pt_param || !aConfig )
return;
EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT("NONE") ) );
// First try reading old format
EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT( "NONE" ) ) );
COLOR4D wtmp = UNSPECIFIED_COLOR4D;
if( itmp == UNSPECIFIED_COLOR )
itmp = m_Default;
*m_Pt_param = itmp;
{
// Next try reading new format
if( !wtmp.SetFromWxString( aConfig->Read( m_Ident, wxT( "NONE" ) ) ) )
wtmp = m_Default;
}
else
{
wtmp = COLOR4D( itmp );
}
*m_Pt_param = wtmp;
}
@ -284,7 +295,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
if( !m_Pt_param || !aConfig )
return;
aConfig->Write( m_Ident, ColorGetName( *m_Pt_param ) );
aConfig->Write( m_Ident, m_Pt_param->ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
}

View File

@ -157,10 +157,10 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_cursorShape = 0;
m_LastGridSizeId = 0;
m_drawGrid = true; // hide/Show grid. default = show
m_gridColor = DARKGRAY; // Default grid color
m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
m_showPageLimits = false;
m_drawBgColor = BLACK; // the background color of the draw canvas:
// BLACK for Pcbnew, BLACK or WHITE for eeschema
m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
// BLACK for Pcbnew, BLACK or WHITE for eeschema
m_snapToGrid = true;
m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
m_movingCursorWithKeyboard = false;
@ -210,7 +210,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
m_messagePanel->SetBackgroundColour( MakeColour( LIGHTGRAY ) );
m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
}
@ -728,7 +728,8 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( baseCfgName + CursorShapeEntryKeyword, m_cursorShape );
aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
aCfg->Write( baseCfgName + GridColorEntryKeyword, ( long ) GetGridColor() );
aCfg->Write( baseCfgName + GridColorEntryKeyword,
GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
if( GetScreen() )
@ -740,7 +741,7 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
const wxString& textLower,
EDA_COLOR_T color, int pad )
COLOR4D color, int pad )
{
if( m_messagePanel == NULL )
return;

View File

@ -109,7 +109,7 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
SetLayoutDirection( wxLayout_LeftToRight );
SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );
SetBackgroundColour( parent->GetDrawBgColor().ToColour() );
#if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
@ -212,7 +212,7 @@ wxPoint EDA_DRAW_PANEL::ToLogicalXY( const wxPoint& pos )
}
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor )
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, COLOR4D aColor )
{
if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
return;
@ -554,7 +554,7 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
{
GRSetDrawMode( DC, GR_COPY );
EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
COLOR4D bgColor = GetParent()->GetDrawBgColor();
GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
@ -611,12 +611,10 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
if( Screen == NULL )
return;
EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
COLOR4D bgColor = GetParent()->GetDrawBgColor();
if( ( bgColor != WHITE ) && ( bgColor != BLACK ) )
bgColor = BLACK;
if( bgColor == WHITE )
// TODO(JE): Is this correct?
if( bgColor.GetBrightness() > 0.5 )
{
g_XorMode = GR_NXOR;
g_GhostColor = BLACK;
@ -629,7 +627,7 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
GRResetPenAndBrush( DC );
DC->SetBackground( bgColor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
DC->SetBackground( wxBrush( bgColor.ToColour() ) );
DC->SetBackgroundMode( wxSOLID );
if( erasebg )
@ -666,7 +664,7 @@ void EDA_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable )
void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC )
{
EDA_COLOR_T axis_color = BLUE;
COLOR4D axis_color = COLOR4D( BLUE );
GRSetDrawMode( DC, GR_COPY );
@ -756,7 +754,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
const double h = aDC->DeviceToLogicalYRel( gsz );
// Use our own pen
wxPen pen( MakeColour( GetParent()->GetGridColor() ), h );
wxPen pen( GetParent()->GetGridColor(), h );
pen.SetCap( wxCAP_BUTT );
gc->SetPen( pen );
@ -801,7 +799,7 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode )
if( origin == wxPoint( 0, 0 ) )
return;
EDA_COLOR_T color = RED;
COLOR4D color = COLOR4D( RED );
GRSetDrawMode( aDC, aDrawMode );
@ -837,7 +835,7 @@ void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoi
if( !GetParent()->m_showGridAxis || ( !aGridOrigin.x && !aGridOrigin.y ) )
return;
EDA_COLOR_T color = GetParent()->GetGridColor();
COLOR4D color = GetParent()->GetGridColor();
GRSetDrawMode( aDC, aDrawMode );

View File

@ -103,7 +103,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
* @param aClipBox = the clipping rect, or NULL if no clipping
* @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas
* @param aPos = text position (according to h_justify, v_justify)
* @param aColor (enum EDA_COLOR_T) = text color
* @param aColor (COLOR4D) = text color
* @param aText = text to draw
* @param aOrient = angle in 0.1 degree
* @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
@ -122,7 +122,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
void DrawGraphicText( EDA_RECT* aClipBox,
wxDC* aDC,
const wxPoint& aPos,
EDA_COLOR_T aColor,
COLOR4D aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
@ -175,9 +175,9 @@ void DrawGraphicText( EDA_RECT* aClipBox,
void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
const wxPoint &aPos,
enum EDA_COLOR_T aBgColor,
enum EDA_COLOR_T aColor1,
enum EDA_COLOR_T aColor2,
const COLOR4D aBgColor,
COLOR4D aColor1,
COLOR4D aColor2,
const wxString &aText,
double aOrient,
const wxSize &aSize,
@ -188,9 +188,10 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
PLOTTER * aPlotter )
{
// Swap color if contrast would be better
if( ColorIsLight( aBgColor ) )
// TODO: Maybe calculate contrast some way other than brightness
if( aBgColor.GetBrightness() > 0.5 )
{
EDA_COLOR_T c = aColor1;
COLOR4D c = aColor1;
aColor1 = aColor2;
aColor2 = c;
}
@ -210,7 +211,7 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
* Function PLOTTER::Text
* same as DrawGraphicText, but plot graphic text insteed of draw it
* @param aPos = text position (according to aH_justify, aV_justify)
* @param aColor (enum EDA_COLOR_T) = text color
* @param aColor (COLOR4D) = text color
* @param aText = text to draw
* @param aOrient = angle in 0.1 degree
* @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
@ -224,7 +225,7 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
* @param aMultilineAllowed = true to plot text as multiline, otherwise single line
*/
void PLOTTER::Text( const wxPoint& aPos,
enum EDA_COLOR_T aColor,
const COLOR4D aColor,
const wxString& aText,
double aOrient,
const wxSize& aSize,
@ -248,8 +249,7 @@ void PLOTTER::Text( const wxPoint& aPos,
SetCurrentLineWidth( textPensize, aData );
if( aColor >= 0 )
SetColor( aColor );
SetColor( aColor );
DrawGraphicText( NULL, NULL, aPos, aColor, aText,
aOrient, aSize,

View File

@ -289,8 +289,8 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
COLOR4D aColor, GR_DRAWMODE aDrawMode,
EDA_DRAW_MODE_T aFillMode, COLOR4D aAnchor_color )
{
if( IsMultilineAllowed() )
{
@ -314,7 +314,7 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
aDrawMode, aFillMode, GetShownText(), GetTextPos() );
// Draw text anchor, if requested
if( aAnchor_color != UNSPECIFIED_COLOR )
if( aAnchor_color != UNSPECIFIED_COLOR4D )
{
GRDrawAnchor( aClipBox, aDC,
GetTextPos().x + aOffset.x, GetTextPos().y + aOffset.y,
@ -366,7 +366,7 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
}
void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
const wxPoint& aOffset, COLOR4D aColor,
GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
const wxString& aText, const wxPoint &aPos )
{
@ -511,7 +511,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
size.x = -size.x;
s_cornerBuffer = &aCornerBuffer;
EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText
COLOR4D color = COLOR4D_BLACK; // not actually used, but needed by DrawGraphicText
if( IsMultilineAllowed() )
{

View File

@ -24,6 +24,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <map>
#include <gal/color4d.h>
using namespace KIGFX;
@ -40,23 +42,251 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
#ifdef WX_COMPATIBILITY
COLOR4D::COLOR4D( const wxColour& aColor )
{
r = aColor.Red();
g = aColor.Green();
b = aColor.Blue();
a = aColor.Alpha();
r = aColor.Red() / 255.0;
g = aColor.Green() / 255.0;
b = aColor.Blue() / 255.0;
a = aColor.Alpha() / 255.0;
}
bool COLOR4D::SetFromWxString( const wxString& aColorString )
{
wxColour c;
if( c.Set( aColorString ) )
{
r = c.Red() / 255.0;
g = c.Green() / 255.0;
b = c.Blue() / 255.0;
a = c.Alpha() / 255.0;
return true;
}
return false;
}
wxString COLOR4D::ToWxString( long flags )
{
wxColour c = ToColour();
return c.GetAsString( flags );
}
COLOR4D COLOR4D::LegacyMix( COLOR4D aColor ) const
{
/* Memoization storage. This could be potentially called for each
* color merge so a cache is useful (there are few colours anyway) */
static std::map< std::pair< uint32_t, uint32_t >, uint32_t > mix_cache;
// First easy thing: a black gives always the other colour
if( *this == COLOR4D_BLACK )
return aColor;
if( aColor == COLOR4D_BLACK )
return *this;
uint32_t myPackedColor = ToU32();
uint32_t aPackedColor = aColor.ToU32();
/* Now we are sure that black can't occur, so the rule is:
* BLACK means not computed yet. If we're lucky we already have
* an answer */
auto search = mix_cache.find( std::pair< uint32_t, uint32_t >( myPackedColor,
aPackedColor ) );
COLOR4D candidate = COLOR4D_BLACK;
if( search != mix_cache.end() )
candidate.FromU32( search->second );
if( candidate != COLOR4D_BLACK )
return candidate;
// Blend the two colors (i.e. OR the RGB values)
COLOR4D mixed( ( (uint8_t)( 255.0 * this->r ) | (uint8_t)( 255.0 * aColor.r ) ) / 255.0,
( (uint8_t)( 255.0 * this->g ) | (uint8_t)( 255.0 * aColor.g ) ) / 255.0,
( (uint8_t)( 255.0 * this->b ) | (uint8_t)( 255.0 * aColor.b ) ) / 255.0,
1.0 );
candidate = mixed;
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
* Even theorically its not possible (with the current rules), but
* maybe the metric will change in the future */
if( candidate == COLOR4D_BLACK )
candidate = COLOR4D( DARKDARKGRAY );
// Store the result in the cache. The operation is commutative, too
mix_cache.insert( std::pair< std::pair< uint32_t, uint32_t >, uint32_t >
( std::pair< uint32_t, uint32_t >( myPackedColor, aPackedColor ),
candidate.ToU32() ) );
mix_cache.insert( std::pair< std::pair< uint32_t, uint32_t >, uint32_t >
( std::pair< uint32_t, uint32_t >( aPackedColor, myPackedColor ),
candidate.ToU32() ) );
return candidate;
}
COLOR4D& COLOR4D::SetToLegacyHighlightColor()
{
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
EDA_COLOR_T highlightColor = g_ColorRefs[legacyColor].m_LightColor;
r = g_ColorRefs[highlightColor].m_Red / 255.0;
g = g_ColorRefs[highlightColor].m_Green / 255.0;
b = g_ColorRefs[highlightColor].m_Blue / 255.0;
a = 1.0;
return *this;
}
COLOR4D& COLOR4D::SetToNearestLegacyColor()
{
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
r = g_ColorRefs[legacyColor].m_Red / 255.0;
g = g_ColorRefs[legacyColor].m_Green / 255.0;
b = g_ColorRefs[legacyColor].m_Blue / 255.0;
a = 1.0;
return *this;
}
unsigned int COLOR4D::ToU32() const
{
return ToColour().GetRGB();
}
void COLOR4D::FromU32( unsigned int aPackedColor )
{
wxColour c;
c.SetRGB( aPackedColor );
r = c.Red();
g = c.Green();
b = c.Blue();
a = c.Alpha();
}
EDA_COLOR_T COLOR4D::GetNearestLegacyColor( COLOR4D &aColor )
{
// Cache layer implemented here, because all callers are using wxColour
static std::map< unsigned int, unsigned int > nearestCache;
static double hues[NBCOLORS];
static double values[NBCOLORS];
unsigned int colorInt = aColor.ToU32();
auto search = nearestCache.find( colorInt );
if( search != nearestCache.end() )
return static_cast<EDA_COLOR_T>( search->second );
// First use ColorFindNearest to check for exact matches
EDA_COLOR_T nearest = ColorFindNearest( aColor.r * 255.0, aColor.g * 255.0, aColor.b * 255.0 );
if( COLOR4D( nearest ) == aColor )
{
nearestCache.insert( std::pair< unsigned int, unsigned int >(
colorInt, static_cast<unsigned int>( nearest ) ) );
return nearest;
}
// If not, use hue and value to match.
// Hue will be NAN for grayscale colors.
// The legacy color palette is a grid across hue and value.
// We can exploit that to find a good match -- hue is most apparent to the user.
// So, first we determine the closest hue match, and then the closest value from that
// "grid row" in the legacy palette.
double h, s, v;
aColor.ToHSV( h, s, v );
double minDist = 360.0;
double legacyHue = 0.0;
if( std::isnan( h ) )
{
legacyHue = NAN;
}
else
{
for( EDA_COLOR_T candidate = BLACK; candidate < NBCOLORS; candidate = NextColor(candidate) )
{
double ch, cs, cv;
if( hues[candidate] == 0.0 && values[candidate] == 0.0 )
{
COLOR4D candidate4d( candidate );
candidate4d.ToHSV( ch, cs, cv );
values[candidate] = cv;
// Set the hue to non-zero for black so that we won't do this more than once
hues[candidate] = ( cv == 0.0 ) ? 1.0 : ch;
}
else
{
ch = hues[candidate];
cv = values[candidate];
cv = 0.0;
}
if( fabs( ch - h ) < minDist )
{
minDist = fabs( ch - h );
legacyHue = ch;
}
}
}
// Now we have the desired hue; let's find the nearest value
minDist = 1.0;
for( EDA_COLOR_T candidate = BLACK; candidate < NBCOLORS; candidate = NextColor(candidate) )
{
// If the target hue is NAN, we didn't extract the value for any colors above
if( std::isnan( legacyHue ) )
{
double ch, cs, cv;
COLOR4D candidate4d( candidate );
candidate4d.ToHSV( ch, cs, cv );
values[candidate] = cv;
hues[candidate] = ( cv == 0.0 ) ? 1.0 : ch;
}
if( ( std::isnan( legacyHue ) != std::isnan( hues[candidate] ) ) || hues[candidate] != legacyHue )
continue;
if( fabs( values[candidate] - v ) < minDist )
{
minDist = fabs( values[candidate] - v );
nearest = candidate;
}
}
nearestCache.insert( std::pair< unsigned int, unsigned int >(
colorInt, static_cast<unsigned int>( nearest ) ) );
return nearest;
}
#endif
namespace KIGFX {
const bool COLOR4D::operator==( const COLOR4D& aColor )
const bool operator==( const COLOR4D& lhs, const COLOR4D& rhs )
{
return a == aColor.a && r == aColor.r && g == aColor.g && b == aColor.b;
return lhs.a == rhs.a && lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b;
}
const bool COLOR4D::operator!=( const COLOR4D& aColor )
const bool operator!=( const COLOR4D& lhs, const COLOR4D& rhs )
{
return a != aColor.a || r != aColor.r || g != aColor.g || b != aColor.b;
return !( lhs == rhs );
}
}

View File

@ -59,7 +59,7 @@ static void ClipAndDrawPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points[],
* from user units to screen units(pixels coordinates)
*/
static void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1,
int x2, int y2, int aWidth, EDA_COLOR_T aColor,
int x2, int y2, int aWidth, COLOR4D aColor,
wxPenStyle aStyle = wxPENSTYLE_SOLID );
/**/
@ -72,8 +72,8 @@ static int xcliplo = 0,
xcliphi = 2000,
ycliphi = 2000;
static EDA_COLOR_T s_DC_lastcolor = UNSPECIFIED_COLOR;
static EDA_COLOR_T s_DC_lastbrushcolor = UNSPECIFIED_COLOR;
static COLOR4D s_DC_lastcolor( 0, 0, 0, 0 );
static COLOR4D s_DC_lastbrushcolor( 0, 0, 0, 0 );
static bool s_DC_lastbrushfill = false;
static wxDC* s_DC_lastDC = NULL;
@ -196,8 +196,8 @@ static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int
void GRResetPenAndBrush( wxDC* DC )
{
GRSetBrush( DC, BLACK ); // Force no fill
s_DC_lastbrushcolor = UNSPECIFIED_COLOR;
s_DC_lastcolor = UNSPECIFIED_COLOR;
s_DC_lastbrushcolor = UNSPECIFIED_COLOR4D;
s_DC_lastcolor = UNSPECIFIED_COLOR4D;
s_DC_lastDC = NULL;
}
@ -206,7 +206,7 @@ void GRResetPenAndBrush( wxDC* DC )
* Function GRSetColorPen
* sets a pen style, width, color, and alpha into the given device context.
*/
void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
void GRSetColorPen( wxDC* DC, COLOR4D Color, int width, wxPenStyle style )
{
// Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
// nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
@ -214,17 +214,16 @@ void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
width = DC->DeviceToLogicalXRel( 1 );
if( s_ForceBlackPen )
Color = BLACK;
Color = COLOR4D_BLACK;
wxColour wx_color = MakeColour( Color );
const wxPen& curr_pen = DC->GetPen();
if( !curr_pen.IsOk() || curr_pen.GetColour() != wx_color
if( !curr_pen.IsOk() || curr_pen.GetColour() != Color.ToColour()
|| curr_pen.GetWidth() != width
|| curr_pen.GetStyle() != style )
{
wxPen pen;
pen.SetColour( wx_color );
pen.SetColour( Color.ToColour() );
pen.SetWidth( width );
pen.SetStyle( style );
DC->SetPen( pen );
@ -238,10 +237,10 @@ void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
}
void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill )
void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill )
{
if( s_ForceBlackPen )
Color = BLACK;
Color = COLOR4D_BLACK;
if( s_DC_lastbrushcolor != Color
|| s_DC_lastbrushfill != fill
@ -249,7 +248,7 @@ void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill )
{
wxBrush brush;
brush.SetColour( MakeColour( Color ) );
brush.SetColour( Color.ToColour() );
if( fill )
brush.SetStyle( wxBRUSHSTYLE_SOLID );
@ -337,7 +336,7 @@ void GRSetDrawMode( wxDC* DC, GR_DRAWMODE draw_mode )
}
void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, EDA_COLOR_T Color )
void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D Color )
{
if( ClipBox && !ClipBox->Contains( x, y ) )
return;
@ -357,7 +356,7 @@ void GRLine( EDA_RECT* ClipBox,
int x2,
int y2,
int width,
EDA_COLOR_T Color )
COLOR4D Color )
{
GRSetColorPen( DC, Color, width );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
@ -366,7 +365,7 @@ void GRLine( EDA_RECT* ClipBox,
}
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor )
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor )
{
GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
}
@ -374,14 +373,14 @@ void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aW
void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int width, EDA_COLOR_T Color )
int width, COLOR4D Color )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
s_DC_lastcolor = UNSPECIFIED_COLOR;
s_DC_lastcolor = UNSPECIFIED_COLOR4D;
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
s_DC_lastcolor = UNSPECIFIED_COLOR;
s_DC_lastcolor = UNSPECIFIED_COLOR4D;
GRSetColorPen( DC, Color, width );
}
@ -399,14 +398,14 @@ void GRMoveTo( int x, int y )
/*
* Draw line to a new position, in object space.
*/
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, EDA_COLOR_T Color )
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, COLOR4D Color )
{
GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
}
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, EDA_COLOR_T Color )
int width, COLOR4D Color )
{
GRSetColorPen( DC, Color, width, wxPENSTYLE_DOT_DASH );
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
@ -422,11 +421,11 @@ void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
* @param aDC = the device context into which drawing should occur.
* @param aLines = a list of pair of coordinate in user space: a pair for each line.
* @param aWidth = the width of each line.
* @param aColor = an index into our color table of RGB colors.
* @see EDA_COLOR_T and colors.h
* @param aColor = color to draw the lines
* @see COLOR4D
*/
void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
int aWidth, EDA_COLOR_T aColor )
int aWidth, COLOR4D aColor )
{
if( aLines.empty() )
return;
@ -480,7 +479,7 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
// Draw the outline of a thick segment wih rounded ends
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, EDA_COLOR_T Color )
int width, int aPenSize, COLOR4D Color )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
@ -566,14 +565,14 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, EDA_COLOR_T Color )
int width, COLOR4D Color )
{
GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
}
void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, EDA_COLOR_T aColor )
int aWidth, COLOR4D aColor )
{
GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
}
@ -583,7 +582,7 @@ void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
* Draw segment (full) with rounded ends in object space (real coords.).
*/
void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, EDA_COLOR_T Color )
int width, COLOR4D Color )
{
GRSetColorPen( DC, Color, width );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
@ -591,7 +590,7 @@ void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, EDA_COLOR_T aColor )
int aWidth, COLOR4D aColor )
{
GRSetColorPen( aDC, aColor, aWidth );
WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
@ -642,7 +641,7 @@ static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, wxPoint Points[] )
*/
static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width,
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
COLOR4D Color, COLOR4D BgColor )
{
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
return;
@ -701,8 +700,8 @@ static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
int aPointCount, wxPoint aPoints[],
bool aFill, int aWidth,
EDA_COLOR_T aColor,
EDA_COLOR_T aBgColor )
COLOR4D aColor,
COLOR4D aBgColor )
{
if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
return;
@ -766,7 +765,7 @@ static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
* Draw a new polyline and fill it if Fill, in drawing space.
*/
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
{
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
}
@ -776,20 +775,20 @@ void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
* Draw a closed polyline and fill it if Fill, in object space.
*/
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
bool Fill, COLOR4D Color, COLOR4D BgColor )
{
GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
}
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
{
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
}
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, EDA_COLOR_T Color )
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, COLOR4D Color )
{
/* Clip circles off screen. */
if( ClipBox )
@ -819,20 +818,20 @@ void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, ED
}
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, EDA_COLOR_T Color )
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, COLOR4D Color )
{
GRCircle( ClipBox, DC, x, y, r, 0, Color );
}
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, EDA_COLOR_T aColor )
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor )
{
GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
}
void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r,
int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
int width, COLOR4D Color, COLOR4D BgColor )
{
/* Clip circles off screen. */
if( ClipBox )
@ -862,7 +861,7 @@ void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r,
}
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, EDA_COLOR_T aColor )
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor )
{
GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
}
@ -872,7 +871,7 @@ void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, E
* Draw an arc in user space.
*/
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, EDA_COLOR_T Color )
int xc, int yc, COLOR4D Color )
{
GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
}
@ -882,7 +881,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
* Draw an arc, width = width in user space.
*/
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, EDA_COLOR_T Color )
int xc, int yc, int width, COLOR4D Color )
{
/* Clip arcs off screen. */
if( ClipBox )
@ -910,7 +909,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
wxPoint aCenter, int aWidth, EDA_COLOR_T aColor )
wxPoint aCenter, int aWidth, COLOR4D aColor )
{
GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
aWidth, aColor );
@ -928,8 +927,8 @@ void GRFilledArc( EDA_RECT* ClipBox,
double EndAngle,
int r,
int width,
EDA_COLOR_T Color,
EDA_COLOR_T BgColor )
COLOR4D Color,
COLOR4D BgColor )
{
int x1, y1, x2, y2;
@ -971,7 +970,7 @@ void GRFilledArc( EDA_RECT* ClipBox,
void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
double StAngle, double EndAngle, int r,
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
COLOR4D Color, COLOR4D BgColor )
{
GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
}
@ -981,7 +980,7 @@ void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
* Draw an arc in drawing space.
*/
void GRArc( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, double StAngle,
double EndAngle, int r, EDA_COLOR_T Color )
double EndAngle, int r, COLOR4D Color )
{
int x1, y1, x2, y2;
@ -1032,7 +1031,7 @@ void GRArc( EDA_RECT* ClipBox,
double EndAngle,
int r,
int width,
EDA_COLOR_T Color )
COLOR4D Color )
{
int x1, y1, x2, y2;
@ -1075,13 +1074,13 @@ void GRArc( EDA_RECT* ClipBox,
/*
* Draw a rectangle in drawing space.
*/
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, EDA_COLOR_T aColor )
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, COLOR4D aColor )
{
GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
}
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, EDA_COLOR_T aColor, wxPenStyle aStyle )
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, COLOR4D aColor, wxPenStyle aStyle )
{
int x1 = aRect.GetX();
int y1 = aRect.GetY();
@ -1095,13 +1094,13 @@ void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, EDA_COLOR_T
/*
* Draw a rectangle (thick lines) in drawing space.
*/
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color )
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color )
{
GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
}
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, EDA_COLOR_T aColor )
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, COLOR4D aColor )
{
int x1 = aRect.GetX();
int y1 = aRect.GetY();
@ -1116,7 +1115,7 @@ void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, E
* Draw a rectangle (filled with AreaColor) in drawing space.
*/
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
COLOR4D Color, COLOR4D BgColor )
{
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
}
@ -1126,7 +1125,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
* Draw a rectangle (filled with AreaColor) in drawing space.
*/
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
int width, COLOR4D Color, COLOR4D BgColor )
{
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
}
@ -1137,7 +1136,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
*/
void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle )
int aWidth, COLOR4D aColor, wxPenStyle aStyle )
{
wxPoint points[5];
points[0] = wxPoint(x1, y1);
@ -1151,7 +1150,7 @@ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
int aWidth, EDA_COLOR_T aColor, EDA_COLOR_T aBgColor )
int aWidth, COLOR4D aColor, COLOR4D aBgColor )
{
wxPoint points[5];
points[0] = wxPoint(x1, y1);
@ -1232,7 +1231,7 @@ void GRBezier( EDA_RECT* ClipBox,
int x3,
int y3,
int width,
EDA_COLOR_T Color )
COLOR4D Color )
{
std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3 );
GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
@ -1250,7 +1249,7 @@ void GRBezier( EDA_RECT* ClipBox,
int x4,
int y4,
int width,
EDA_COLOR_T Color )
COLOR4D Color )
{
std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 );
GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
@ -1258,7 +1257,7 @@ void GRBezier( EDA_RECT* ClipBox,
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
int aSize, EDA_COLOR_T aColor )
int aSize, COLOR4D aColor )
{
int anchor_size = aDC->DeviceToLogicalXRel( aSize );

View File

@ -109,7 +109,7 @@ void EDA_MSG_PANEL::OnPaint( wxPaintEvent& aEvent )
void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText,
const wxString& aLowerText,
EDA_COLOR_T aColor, int aPad )
COLOR4D aColor, int aPad )
{
wxString text;
wxSize drawSize = GetClientSize();
@ -143,7 +143,7 @@ void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText,
void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
const wxString& aLowerText, EDA_COLOR_T aColor )
const wxString& aLowerText, COLOR4D aColor )
{
wxPoint pos;
wxSize drawSize = GetClientSize();
@ -196,13 +196,9 @@ void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
void EDA_MSG_PANEL::showItem( wxDC& aDC, const MSG_PANEL_ITEM& aItem )
{
EDA_COLOR_T color = aItem.m_Color;
COLOR4D color = aItem.m_Color;
if( color >= 0 )
{
color = ColorGetBase( color );
aDC.SetTextForeground( MakeColour( color ) );
}
aDC.SetTextForeground( color.ToColour() );
if( !aItem.m_UpperText.IsEmpty() )
{
@ -230,7 +226,7 @@ void EDA_MSG_PANEL::erase( wxDC* aDC )
wxBrush brush;
wxSize size = GetClientSize();
wxColor color = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
pen.SetColour( color );

View File

@ -61,6 +61,8 @@
#include <worksheet_shape_builder.h>
#include <class_worksheet_dataitem.h>
using KIGFX::COLOR4D;
// Static members of class WORKSHEET_DATAITEM:
double WORKSHEET_DATAITEM::m_WSunits2Iu = 1.0;
@ -70,9 +72,9 @@ double WORKSHEET_DATAITEM::m_DefaultLineWidth = 0.0;
DSIZE WORKSHEET_DATAITEM::m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
double WORKSHEET_DATAITEM::m_DefaultTextThickness = 0.0;
bool WORKSHEET_DATAITEM::m_SpecialMode = false;
EDA_COLOR_T WORKSHEET_DATAITEM::m_Color = RED; // the default color to draw items
EDA_COLOR_T WORKSHEET_DATAITEM::m_AltColor = RED; // an alternate color to draw items
EDA_COLOR_T WORKSHEET_DATAITEM::m_SelectedColor = BROWN; // the color to draw selected items
COLOR4D WORKSHEET_DATAITEM::m_Color = COLOR4D( RED ); // the default color to draw items
COLOR4D WORKSHEET_DATAITEM::m_AltColor = COLOR4D( RED ); // an alternate color to draw items
COLOR4D WORKSHEET_DATAITEM::m_SelectedColor = COLOR4D( BROWN ); // the color to draw selected items
// The constructor:

View File

@ -175,7 +175,7 @@ void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
wxString& aText, wxPoint aPos, wxSize aSize,
int aPenWidth, EDA_COLOR_T aColor,
int aPenWidth, COLOR4D aColor,
bool aItalic, bool aBold ) :
WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText )
{
@ -188,12 +188,12 @@ WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
Draw( aClipBox, aDC, aOffset,
aColor == UNSPECIFIED_COLOR ? GetColor() : aColor,
aColor == UNSPECIFIED_COLOR4D ? GetColor() : aColor,
aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode,
FILLED, UNSPECIFIED_COLOR );
FILLED, UNSPECIFIED_COLOR4D );
}
@ -222,7 +222,7 @@ bool WS_DRAW_ITEM_TEXT::HitTestStartPoint( const wxPoint& aPosition)
void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
std::vector<wxPoint> points_moved;
wxPoint *points;
@ -238,7 +238,7 @@ void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPo
points = &m_Corners[0];
}
auto color = ( aColor == UNSPECIFIED_COLOR ) ? GetColor() : aColor;
auto color = ( aColor == UNSPECIFIED_COLOR4D ) ? GetColor() : aColor;
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
GRPoly( aClipBox, aDC,
@ -288,14 +288,14 @@ bool WS_DRAW_ITEM_POLYGON::HitTestStartPoint( const wxPoint& aPosition)
void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
GRRect( aClipBox, aDC,
GetStart().x + aOffset.x, GetStart().y + aOffset.y,
GetEnd().x + aOffset.x, GetEnd().y + aOffset.y,
GetPenWidth(),
( aColor == UNSPECIFIED_COLOR ) ? GetColor() : aColor );
( aColor == UNSPECIFIED_COLOR4D ) ? GetColor() : aColor );
GRSetDrawMode( aDC, GR_COPY );
}
@ -393,12 +393,12 @@ bool WS_DRAW_ITEM_RECT::HitTestEndPoint( const wxPoint& aPosition)
void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset,
GetPenWidth(),
( aColor == UNSPECIFIED_COLOR ) ? GetColor() : aColor );
( aColor == UNSPECIFIED_COLOR4D ) ? GetColor() : aColor );
GRSetDrawMode( aDC, GR_COPY );
}
@ -468,7 +468,7 @@ void WS_DRAW_ITEM_LIST::Locate( std::vector <WS_DRAW_ITEM_BASE*>& aList,
void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();

View File

@ -66,7 +66,7 @@
void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
const PAGE_INFO& aPageInfo,
const TITLE_BLOCK& aTitleBlock,
EDA_COLOR_T aColor, EDA_COLOR_T aAltColor )
COLOR4D aColor, COLOR4D aAltColor )
{
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
@ -122,7 +122,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
&& m_sheetNumber > 1 )
continue;
EDA_COLOR_T color = wsItem->GetItemColor();
COLOR4D color = wsItem->GetItemColor();
pensize = wsItem->GetPenSizeUi();

View File

@ -41,15 +41,6 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_highlightNetcode = -1;
m_outlineWidth = 1;
m_worksheetLineWidth = 100000;
// Store the predefined colors used in KiCad in format used by GAL
for( int i = 0; i < NBCOLORS; i++ )
{
m_legacyColorMap[g_ColorRefs[i].m_Numcolor] = COLOR4D( (double) g_ColorRefs[i].m_Red / 255.0,
(double) g_ColorRefs[i].m_Green / 255.0,
(double) g_ColorRefs[i].m_Blue / 255.0,
m_layerOpacity );
}
}

View File

@ -26,14 +26,17 @@
/* Dialog for selecting color from the palette of available colors.
*/
#include <fctsys.h>
#include <common.h>
#include <colors.h>
#include <gal/color4d.h>
#include <wx/statline.h>
#include <algorithm>
using KIGFX::COLOR4D;
enum colors_id {
ID_COLOR_BLACK = 2000 // colors_id = ID_COLOR_BLACK a ID_COLOR_BLACK + NBCOLORS-1
@ -43,16 +46,16 @@ enum colors_id {
class CHOOSE_COLOR_DLG : public wxDialog
{
public:
CHOOSE_COLOR_DLG( wxWindow* aParent, EDA_COLOR_T aOldColor );
CHOOSE_COLOR_DLG( wxWindow* aParent, COLOR4D aOldColor );
~CHOOSE_COLOR_DLG() {};
EDA_COLOR_T GetSelectedColor() { return m_color; }
COLOR4D GetSelectedColor() { return m_color; }
private:
void init_Dialog();
void selColor( wxCommandEvent& event );
EDA_COLOR_T m_color;
COLOR4D m_color;
DECLARE_EVENT_TABLE()
};
@ -65,7 +68,7 @@ BEGIN_EVENT_TABLE( CHOOSE_COLOR_DLG, wxDialog )
END_EVENT_TABLE()
EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor )
COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor )
{
CHOOSE_COLOR_DLG dlg( aParent, aOldColor );
@ -74,11 +77,11 @@ EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor )
return dlg.GetSelectedColor();
}
return UNSPECIFIED_COLOR;
return UNSPECIFIED_COLOR4D;
}
CHOOSE_COLOR_DLG::CHOOSE_COLOR_DLG( wxWindow* aParent, EDA_COLOR_T aOldColor ) :
CHOOSE_COLOR_DLG::CHOOSE_COLOR_DLG( wxWindow* aParent, COLOR4D aOldColor ) :
wxDialog( aParent, wxID_ANY, _( "Colors" ), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
@ -131,10 +134,10 @@ void CHOOSE_COLOR_DLG::init_Dialog()
iconDC.SelectObject( ButtBitmap );
EDA_COLOR_T buttcolor = g_ColorRefs[ii].m_Numcolor;
COLOR4D buttcolor = COLOR4D( g_ColorRefs[ii].m_Numcolor );
iconDC.SetPen( *wxBLACK_PEN );
ColorSetBrush( &brush, buttcolor );
brush.SetColour( buttcolor.ToColour() );
brush.SetStyle( wxBRUSHSTYLE_SOLID );
iconDC.SetBrush( brush );
@ -154,7 +157,8 @@ void CHOOSE_COLOR_DLG::init_Dialog()
if( m_color == buttcolor )
focusedButton = bitmapButton;
wxStaticText* label = new wxStaticText( this, -1, wxGetTranslation( ColorGetName( buttcolor ) ),
EDA_COLOR_T edaColor = ColorFindNearest( buttcolor.ToColour() );
wxStaticText* label = new wxStaticText( this, -1, wxGetTranslation( ColorGetName( edaColor ) ),
wxDefaultPosition, wxDefaultSize, 0 );
FlexColumnBoxSizer->Add( label, 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |

View File

@ -106,6 +106,7 @@ principle should be easily implemented by adapting the current STL containers.
%include class_eda_rect.h
%include common.h
%include class_title_block.h
%include gal/color4d.h
%include class_colors_design_settings.h
%include class_marker_base.h
%include eda_text.h

View File

@ -53,7 +53,7 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
TITLE_BLOCK& aTitleBlock,
int aSheetCount, int aSheetNumber,
int aPenWidth, double aScalar,
EDA_COLOR_T aColor, EDA_COLOR_T aAltColor,
COLOR4D aColor, COLOR4D aAltColor,
const wxString& aSheetLayer )
{
WS_DRAW_ITEM_LIST drawList;
@ -94,7 +94,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
}
TITLE_BLOCK t_block = GetTitleBlock();
EDA_COLOR_T color = RED;
COLOR4D color = COLOR4D( RED );
wxPoint origin = aDC->GetDeviceOrigin();

View File

@ -92,8 +92,7 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
drawList.SetSheetName( sheetName );
COLOR4D color = settings->GetColor( this, aLayer );
EDA_COLOR_T edaColor = ColorFindNearest( color.r * 255, color.g * 255, color.b * 255 );
drawList.BuildWorkSheetGraphicList( *m_pageInfo, *m_titleBlock, edaColor, edaColor );
drawList.BuildWorkSheetGraphicList( *m_pageInfo, *m_titleBlock, color, color );
// Draw all the components that make the page layout
WS_DRAW_ITEM_BASE* item = drawList.GetFirst();

View File

@ -432,9 +432,9 @@ void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible)
}
EDA_COLOR_T DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const
COLOR4D DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const
{
return DARKGRAY;
return COLOR4D( DARKGRAY );
}

View File

@ -87,7 +87,7 @@ public:
* Function GetGridColor() , virtual
* @return the color of the grid
*/
virtual EDA_COLOR_T GetGridColor() const override;
virtual COLOR4D GetGridColor() const override;
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;

View File

@ -276,6 +276,7 @@ target_link_libraries( eeschema
# There's way too much crap coming in from common yet.
common
bitmaps
gal
${wxWidgets_LIBRARIES}
)

View File

@ -121,8 +121,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
return;
segment = (SCH_LINE*) s_wires.begin();
EDA_COLOR_T color = GetLayerColor( segment->GetLayer() );
ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) );
COLOR4D color = GetLayerColor( segment->GetLayer() );
if( aErase )
{

View File

@ -326,8 +326,8 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
* printing in black and white
* If the color is not the default color (aColor != -1 )
*/
if( ! (screen && screen->m_IsPrinting && GetGRForceBlackPenState())
&& ( aOpts.color == UNSPECIFIED_COLOR ) )
if( ! ( screen && screen->m_IsPrinting && GetGRForceBlackPenState() )
&& ( aOpts.color == UNSPECIFIED_COLOR4D ) )
{
for( LIB_ITEM& drawItem : drawings )
{
@ -560,7 +560,7 @@ void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aD
if( *i == aItem )
{
if( aDc != NULL )
aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR,
aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D,
g_XorMode, NULL, DefaultTransform );
drawings.erase( i );

View File

@ -177,7 +177,7 @@ extern int LibraryEntryCompare( const LIB_ALIAS* aItem1, const LIB_ALIAS* aItem2
struct PART_DRAW_OPTIONS
{
GR_DRAWMODE draw_mode; ///< Device context drawing mode, see wxDC
EDA_COLOR_T color; ///< Color to draw part in
COLOR4D color; ///< Color to draw part in
TRANSFORM transform; ///< Coordinate adjustment settings
bool show_pin_text; ///< Whether to show pin texts
bool draw_visible_fields; ///< Whether to draw "visible" fields

View File

@ -218,7 +218,7 @@ public:
* @param aColor The drawing color.
*/
void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
COLOR4D aColor = UNSPECIFIED_COLOR4D );
/**
* Function Plot

View File

@ -331,9 +331,9 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
GRResetPenAndBrush( &dc );
EDA_COLOR_T bgcolor = m_parent->GetDrawBgColor();
COLOR4D bgColor = m_parent->GetDrawBgColor();
dc.SetBackground( bgcolor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
dc.SetBackground( wxBrush( bgColor.ToColour() ) );
dc.Clear();
if( aComponent == NULL )

View File

@ -45,7 +45,7 @@ DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( EDA_DRAW_FRAME* parent, LIB_PIN* aPin
m_dummyPin->SetParent( NULL );
m_dummyPin->ClearFlags();
m_panelShowPin->SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );
m_panelShowPin->SetBackgroundColour( parent->GetDrawBgColor().ToColour() );
// Set tab order
m_textPadName->MoveAfterInTabOrder(m_textPinName);
@ -104,7 +104,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
// This is a flag for m_dummyPin->Draw
uintptr_t flags = uintptr_t( PIN_DRAW_TEXTS | PIN_DRAW_DANGLING );
m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR, GR_COPY,
m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR4D, GR_COPY,
(void*)flags, DefaultTransform );
m_dummyPin->SetParent(NULL);

View File

@ -455,7 +455,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->m_IsPrinting = true;
EDA_COLOR_T bg_color = m_parent->GetDrawBgColor();
COLOR4D bgColor = m_parent->GetDrawBgColor();
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
@ -463,7 +463,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
IU_PER_MILS, aScreen->GetFileName() );
m_parent->SetDrawBgColor( bg_color );
m_parent->SetDrawBgColor( bgColor );
aScreen->m_IsPrinting = false;
panel->SetClipBox( oldClipBox );

View File

@ -207,9 +207,9 @@ void DIALOG_RESCUE_EACH::OnDialogResize( wxSizeEvent& aSizeEvent )
void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* aPanel )
{
wxPaintDC dc( aPanel );
EDA_COLOR_T bgcolor = m_Parent->GetDrawBgColor();
wxColour bgColor = m_Parent->GetDrawBgColor().ToColour();
dc.SetBackground( bgcolor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
dc.SetBackground( wxBrush( bgColor ) );
dc.Clear();
if( aComponent == NULL )

View File

@ -34,7 +34,7 @@
#include <general.h>
void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, EDA_COLOR_T Color )
void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, COLOR4D Color )
{
BASE_SCREEN* screen = panel->GetScreen();

View File

@ -161,15 +161,15 @@ PGM_BASE& Pgm()
}
static EDA_COLOR_T s_layerColor[LAYERSCH_ID_COUNT];
static COLOR4D s_layerColor[LAYERSCH_ID_COUNT];
EDA_COLOR_T GetLayerColor( LAYERSCH_ID aLayer )
COLOR4D GetLayerColor( LAYERSCH_ID aLayer )
{
wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
return s_layerColor[aLayer];
}
void SetLayerColor( EDA_COLOR_T aColor, LAYERSCH_ID aLayer )
void SetLayerColor( COLOR4D aColor, LAYERSCH_ID aLayer )
{
wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
s_layerColor[aLayer] = aColor;
@ -188,32 +188,32 @@ static PARAM_CFG_ARRAY& cfg_params()
#define CLR(x, y, z)\
ca.push_back( new PARAM_CFG_SETCOLOR( true, wxT( x ), &s_layerColor[y], z ) );
CLR( "ColorWireEx", LAYER_WIRE, GREEN )
CLR( "ColorBusEx", LAYER_BUS, BLUE )
CLR( "ColorConnEx", LAYER_JUNCTION, GREEN )
CLR( "ColorLLabelEx", LAYER_LOCLABEL, BLACK )
CLR( "ColorHLabelEx", LAYER_HIERLABEL, BROWN )
CLR( "ColorGLabelEx", LAYER_GLOBLABEL, RED )
CLR( "ColorPinNumEx", LAYER_PINNUM, RED )
CLR( "ColorPinNameEx", LAYER_PINNAM, CYAN )
CLR( "ColorFieldEx", LAYER_FIELDS, MAGENTA )
CLR( "ColorReferenceEx", LAYER_REFERENCEPART, CYAN )
CLR( "ColorValueEx", LAYER_VALUEPART, CYAN )
CLR( "ColorNoteEx", LAYER_NOTES, LIGHTBLUE )
CLR( "ColorBodyEx", LAYER_DEVICE, RED )
CLR( "ColorBodyBgEx", LAYER_DEVICE_BACKGROUND,LIGHTYELLOW )
CLR( "ColorNetNameEx", LAYER_NETNAM, DARKGRAY )
CLR( "ColorPinEx", LAYER_PIN, RED )
CLR( "ColorSheetEx", LAYER_SHEET, MAGENTA )
CLR( "ColorSheetFileNameEx", LAYER_SHEETFILENAME, BROWN )
CLR( "ColorSheetNameEx", LAYER_SHEETNAME, CYAN )
CLR( "ColorSheetLabelEx", LAYER_SHEETLABEL, BROWN )
CLR( "ColorNoConnectEx", LAYER_NOCONNECT, BLUE )
CLR( "ColorErcWEx", LAYER_ERC_WARN, GREEN )
CLR( "ColorErcEEx", LAYER_ERC_ERR, RED )
CLR( "ColorGridEx", LAYER_GRID, DARKGRAY )
CLR( "ColorBgCanvasEx", LAYER_BACKGROUND, WHITE )
CLR( "ColorBrighenedEx", LAYER_BRIGHTENED, PUREMAGENTA )
CLR( "ColorWireEx", LAYER_WIRE, COLOR4D( GREEN ) )
CLR( "ColorBusEx", LAYER_BUS, COLOR4D( BLUE ) )
CLR( "ColorConnEx", LAYER_JUNCTION, COLOR4D( GREEN ) )
CLR( "ColorLLabelEx", LAYER_LOCLABEL, COLOR4D( BLACK ) )
CLR( "ColorHLabelEx", LAYER_HIERLABEL, COLOR4D( BROWN ) )
CLR( "ColorGLabelEx", LAYER_GLOBLABEL, COLOR4D( RED ) )
CLR( "ColorPinNumEx", LAYER_PINNUM, COLOR4D( RED ) )
CLR( "ColorPinNameEx", LAYER_PINNAM, COLOR4D( CYAN ) )
CLR( "ColorFieldEx", LAYER_FIELDS, COLOR4D( MAGENTA ) )
CLR( "ColorReferenceEx", LAYER_REFERENCEPART, COLOR4D( CYAN ) )
CLR( "ColorValueEx", LAYER_VALUEPART, COLOR4D( CYAN ) )
CLR( "ColorNoteEx", LAYER_NOTES, COLOR4D( LIGHTBLUE ) )
CLR( "ColorBodyEx", LAYER_DEVICE, COLOR4D( RED ) )
CLR( "ColorBodyBgEx", LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) )
CLR( "ColorNetNameEx", LAYER_NETNAM, COLOR4D( DARKGRAY ) )
CLR( "ColorPinEx", LAYER_PIN, COLOR4D( RED ) )
CLR( "ColorSheetEx", LAYER_SHEET, COLOR4D( MAGENTA ) )
CLR( "ColorSheetFileNameEx", LAYER_SHEETFILENAME, COLOR4D( BROWN ) )
CLR( "ColorSheetNameEx", LAYER_SHEETNAME, COLOR4D( CYAN ) )
CLR( "ColorSheetLabelEx", LAYER_SHEETLABEL, COLOR4D( BROWN ) )
CLR( "ColorNoConnectEx", LAYER_NOCONNECT, COLOR4D( BLUE ) )
CLR( "ColorErcWEx", LAYER_ERC_WARN, COLOR4D( GREEN ) )
CLR( "ColorErcEEx", LAYER_ERC_ERR, COLOR4D( RED ) )
CLR( "ColorGridEx", LAYER_GRID, COLOR4D( DARKGRAY ) )
CLR( "ColorBgCanvasEx", LAYER_BACKGROUND, COLOR4D( WHITE ) )
CLR( "ColorBrighenedEx", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) )
}
return ca;
@ -231,9 +231,9 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
// Give a default colour for all layers
// (actual color will be initialized by config)
for( LAYERSCH_ID ii = LAYER_FIRST; ii < LAYERSCH_ID_COUNT; ++ii )
SetLayerColor( DARKGRAY, ii );
SetLayerColor( COLOR4D( DARKGRAY ), ii );
SetLayerColor( WHITE, LAYER_BACKGROUND );
SetLayerColor( COLOR4D_WHITE, LAYER_BACKGROUND );
// Must be called before creating the main frame in order to
// display the real hotkeys in menus or tool tips

View File

@ -112,17 +112,17 @@ void SetDefaultLineThickness( int aThickness )
// Color to draw selected items
EDA_COLOR_T GetItemSelectedColor()
COLOR4D GetItemSelectedColor()
{
return BROWN;
return COLOR4D( BROWN );
}
// Color to draw items flagged invisible, in libedit (they are invisible
// in Eeschema
EDA_COLOR_T GetInvisibleItemColor()
COLOR4D GetInvisibleItemColor()
{
return DARKGRAY;
return COLOR4D( DARKGRAY );
}

View File

@ -29,7 +29,9 @@
#ifndef _GENERAL_H_
#define _GENERAL_H_
#include <colors.h> // for EDA_COLOR_T
#include <gal/color4d.h>
using KIGFX::COLOR4D;
class TRANSFORM;
class SCH_SHEET;
@ -138,13 +140,13 @@ void SetDefaultTextSize( int aSize );
int GetDefaultBusThickness();
void SetDefaultBusThickness( int aThickness );
EDA_COLOR_T GetLayerColor( LAYERSCH_ID aLayer );
void SetLayerColor( EDA_COLOR_T aColor, LAYERSCH_ID aLayer );
COLOR4D GetLayerColor( LAYERSCH_ID aLayer );
void SetLayerColor( COLOR4D aColor, LAYERSCH_ID aLayer );
// Color to draw selected items
EDA_COLOR_T GetItemSelectedColor();
COLOR4D GetItemSelectedColor();
// Color to draw items flagged invisible, in libedit (they are invisible in Eeschema
EDA_COLOR_T GetInvisibleItemColor();
COLOR4D GetInvisibleItemColor();
#endif // _GENERAL_H_

View File

@ -389,7 +389,7 @@ int LIB_ARC::GetPenSize() const
}
void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor )
void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor )
{
// The edit indicators only get drawn when a new arc is being drawn.
if( !IsNew() )
@ -410,7 +410,7 @@ void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColo
void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
// Don't draw the arc until the end point is selected. Only the edit indicators
@ -419,9 +419,9 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
return;
wxPoint pos1, pos2, posc;
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
COLOR4D color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
if( aColor == UNSPECIFIED_COLOR4D ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
@ -448,7 +448,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
fill = NO_FILL;
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;

View File

@ -61,13 +61,13 @@ class LIB_ARC : public LIB_ITEM
* Draws the arc.
*/
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
/**
* Draw the graphics when the arc is being edited.
*/
void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor ) override;
void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) override;
/**
* Calculates the center, radius, and angles at \a aPosition when the arc is being edited.

View File

@ -285,12 +285,12 @@ int LIB_BEZIER::GetPenSize() const
void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
std::vector<wxPoint> PolyPointsTraslated;
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
COLOR4D color = GetLayerColor( LAYER_DEVICE );
m_PolyPoints = Bezier2Poly( m_BezierPoints[0],
m_BezierPoints[1],
@ -303,7 +303,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
PolyPointsTraslated.push_back( aTransform.TransformCoordinate( m_PolyPoints[i] ) +
aOffset );
if( aColor < 0 ) // Used normal color or selected color
if( aColor == UNSPECIFIED_COLOR4D ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
@ -315,7 +315,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
fill = NO_FILL;
GRSetDrawMode( aDC, aDrawMode );

View File

@ -43,7 +43,7 @@ class LIB_BEZIER : public LIB_ITEM
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
public:

View File

@ -208,14 +208,14 @@ int LIB_CIRCLE::GetPenSize() const
void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
wxPoint pos1;
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
COLOR4D color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
if( aColor == UNSPECIFIED_COLOR4D ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
@ -229,7 +229,7 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
GRSetDrawMode( aDC, aDrawMode );
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
fill = NO_FILL;
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;

View File

@ -39,7 +39,7 @@ class LIB_CIRCLE : public LIB_ITEM
int m_Width; // Line width.
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
void calcEdit( const wxPoint& aPosition ) override;

View File

@ -115,7 +115,7 @@ bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const
void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
const wxPoint& aOffset, COLOR4D aColor,
GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
@ -123,7 +123,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
{
// Temporarily disable filling while the item is being edited.
FILL_T fillMode = m_Fill;
EDA_COLOR_T color = GetDefaultColor();
COLOR4D color = GetDefaultColor();
m_Fill = NO_FILL;
@ -154,7 +154,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
}
EDA_COLOR_T LIB_ITEM::GetDefaultColor()
COLOR4D LIB_ITEM::GetDefaultColor()
{
return GetLayerColor( LAYER_DEVICE );
}

View File

@ -84,14 +84,14 @@ class LIB_ITEM : public EDA_ITEM
* @param aDC A pointer to the device context used to draw the object.
* @param aOffset A reference to a wxPoint object containing the offset where to draw
* from the object's current position.
* @param aColor An #EDA_COLOR_T to draw the object or -1 to draw the object in it's
* default color.
* @param aColor A COLOR4D to draw the object or UNSPECIFIED_COLOR4D to draw
* the object in it's default color.
* @param aDrawMode The mode used to perform the draw (#GR_OR, #GR_COPY, etc.).
* @param aData A pointer to any object specific data required to perform the draw.
* @param aTransform A reference to a #TRANSFORM object containing drawing transform.
*/
virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor,
const wxPoint& aOffset, COLOR4D aColor,
GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) = 0;
@ -100,9 +100,9 @@ class LIB_ITEM : public EDA_ITEM
*
* @param aClipBox Clip box of the current device context.
* @param aDC The device context to draw on.
* @param aColor The index of the color to draw.
* @param aColor Draw color
*/
virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor ) {}
virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) {}
/**
* Calculates the attributes of an item at \a aPosition when it is being edited.
@ -207,7 +207,7 @@ public:
* @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
* @param aDC Device Context (can be null)
* @param aOffset Offset to draw
* @param aColor -1 to use the normal body item color, or use this color if >= 0
* @param aColor Draw color, or UNSPECIFIED_COLOR4D to use the normal body item color
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aData Value or pointer used to pass others parameters, depending on body items.
* Used for some items to force to force no fill mode ( has meaning only for
@ -216,7 +216,7 @@ public:
* @param aTransform Transform Matrix (rotation, mirror ..)
*/
virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint &aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform );
/**
@ -405,7 +405,7 @@ public:
void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; }
virtual EDA_COLOR_T GetDefaultColor();
virtual COLOR4D GetDefaultColor();
void SetUnit( int aUnit ) { m_Unit = aUnit; }

View File

@ -287,11 +287,11 @@ int LIB_FIELD::GetPenSize() const
void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
wxPoint text_pos;
int color;
COLOR4D color = UNSPECIFIED_COLOR4D;
int linewidth = GetPenSize();
if( IsBold() )
@ -299,11 +299,11 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
else
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
if( !IsVisible() && aColor < 0 )
if( !IsVisible() && ( aColor == UNSPECIFIED_COLOR4D ) )
{
color = GetInvisibleItemColor();
}
else if( IsSelected() && aColor < 0 )
else if( IsSelected() && ( aColor == UNSPECIFIED_COLOR4D ) )
{
color = GetItemSelectedColor();
}
@ -312,7 +312,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
color = aColor;
}
if( color < 0 )
if( color == UNSPECIFIED_COLOR4D )
color = GetDefaultColor();
text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
@ -326,7 +326,8 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text,
DrawGraphicText( clipbox, aDC, text_pos, color, text,
GetTextAngle(), GetTextSize(),
GetHorizJustify(), GetVertJustify(),
linewidth, IsItalic(), IsBold() );
@ -569,9 +570,9 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
}
EDA_COLOR_T LIB_FIELD::GetDefaultColor()
COLOR4D LIB_FIELD::GetDefaultColor()
{
EDA_COLOR_T color;
COLOR4D color;
switch( m_id )
{

View File

@ -74,7 +74,7 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
* </p>
*/
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
/**
@ -191,7 +191,7 @@ public:
*/
wxString GetFullText( int unit = 1 ) const;
EDA_COLOR_T GetDefaultColor() override;
COLOR4D GetDefaultColor() override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;

View File

@ -905,7 +905,7 @@ int LIB_PIN::GetPenSize() const
void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
EDA_COLOR_T aColor,
COLOR4D aColor,
GR_DRAWMODE aDrawMode,
void* aData,
const TRANSFORM& aTransform )
@ -982,7 +982,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
const wxPoint& aPinPos,
int aOrient,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor,
COLOR4D aColor,
bool aDrawDangling,
bool aOnlyTarget )
{
@ -991,9 +991,9 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
int posX = aPinPos.x, posY = aPinPos.y, len = m_length;
EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
COLOR4D color = GetLayerColor( LAYER_PIN );
if( aColor < 0 ) // Used normal color or selected color
if( aColor == UNSPECIFIED_COLOR4D ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
@ -1183,7 +1183,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
int TextInside,
bool DrawPinNum,
bool DrawPinName,
EDA_COLOR_T Color,
COLOR4D Color,
GR_DRAWMODE DrawMode )
{
if( !DrawPinName && !DrawPinNum )
@ -1210,13 +1210,13 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
/* Get the num and name colors */
if( (Color < 0) && IsSelected() )
if( ( Color == UNSPECIFIED_COLOR4D ) && IsSelected() )
Color = GetItemSelectedColor();
EDA_COLOR_T NameColor = Color == UNSPECIFIED_COLOR ?
GetLayerColor( LAYER_PINNAM ) : Color;
EDA_COLOR_T NumColor = Color == UNSPECIFIED_COLOR ?
GetLayerColor( LAYER_PINNUM ) : Color;
COLOR4D NameColor = Color == UNSPECIFIED_COLOR4D ?
GetLayerColor( LAYER_PINNAM ) : Color;
COLOR4D NumColor = Color == UNSPECIFIED_COLOR4D ?
GetLayerColor( LAYER_PINNUM ) : Color;
/* Create the pin num string */
PinStringNum( StringPinNum );
@ -1396,7 +1396,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
wxPoint& aPosition, int aOrientation,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode )
COLOR4D aColor, GR_DRAWMODE aDrawMode )
{
wxString etypeName = GetElectricalTypeName();
@ -1411,7 +1411,7 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
int pensize = etextSize/6;
// Get a suitable color
if( (aColor < 0) && IsSelected() )
if( ( aColor == UNSPECIFIED_COLOR4D ) && IsSelected() )
aColor = GetItemSelectedColor();
else if( !IsVisible() )
aColor = GetInvisibleItemColor();
@ -1459,7 +1459,7 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
{
int MapX1, MapY1, x1, y1;
EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
COLOR4D color = GetLayerColor( LAYER_PIN );
aPlotter->SetColor( color );
aPlotter->SetCurrentLineWidth( GetPenSize() );
@ -1639,8 +1639,8 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
( numLineWidth + GetDefaultLineThickness() ) / 2;
/* Get the num and name colors */
EDA_COLOR_T NameColor = GetLayerColor( LAYER_PINNAM );
EDA_COLOR_T NumColor = GetLayerColor( LAYER_PINNUM );
COLOR4D NameColor = GetLayerColor( LAYER_PINNAM );
COLOR4D NumColor = GetLayerColor( LAYER_PINNUM );
int x1 = pin_pos.x;
int y1 = pin_pos.y;

View File

@ -85,7 +85,7 @@ class LIB_PIN : public LIB_ITEM
* @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
* @param aDC Device Context (can be null)
* @param aOffset Offset to draw
* @param aColor -1 to use the normal body item color, or use this color if >= 0
* @param aColor UNSPECIFIED_COLOR4D to use the normal body item color, or else use this color
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aData = used here as uintptr_t containing bitwise OR'd flags:
* PIN_DRAW_TEXTS, -- false to draw only pin shape, useful for fast mode
@ -95,7 +95,7 @@ class LIB_PIN : public LIB_ITEM
* @param aTransform Transform Matrix (rotation, mirror ..)
*/
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
public:
@ -385,7 +385,7 @@ public:
*/
void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
int aOrientation, GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR,
COLOR4D aColor = UNSPECIFIED_COLOR4D,
bool aDrawDangling = true,
bool aOnlyTarget = false );
@ -401,7 +401,7 @@ public:
*/
void DrawPinTexts( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition,
int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode );
COLOR4D aColor, GR_DRAWMODE aDrawMode );
/**
* Function DrawPinElectricalTypeName
@ -409,7 +409,7 @@ public:
* aDrawMode = GR_OR, XOR ...
*/
void DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition,
int aOrientation, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode );
int aOrientation, COLOR4D aColor, GR_DRAWMODE aDrawMode );
/**
* Function PlotPinTexts

View File

@ -263,14 +263,14 @@ int LIB_POLYLINE::GetPenSize() const
void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
wxPoint pos1;
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
COLOR4D color = GetLayerColor( LAYER_DEVICE );
wxPoint* buffer = NULL;
if( aColor < 0 ) // Used normal color or selected color
if( aColor == UNSPECIFIED_COLOR4D ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
@ -289,7 +289,7 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
fill = NO_FILL;
GRSetDrawMode( aDC, aDrawMode );

View File

@ -40,7 +40,7 @@ class LIB_POLYLINE : public LIB_ITEM
int m_ModifyIndex; // Index of the polyline point to modify
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
void calcEdit( const wxPoint& aPosition ) override;

View File

@ -196,14 +196,14 @@ int LIB_RECTANGLE::GetPenSize() const
void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
const wxPoint& aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode,
void* aData, const TRANSFORM& aTransform )
{
wxPoint pos1, pos2;
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
COLOR4D color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
if( aColor == UNSPECIFIED_COLOR4D ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
@ -218,7 +218,7 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
fill = NO_FILL;
GRSetDrawMode( aDC, aDrawMode );

View File

@ -42,7 +42,7 @@ class LIB_RECTANGLE : public LIB_ITEM
bool m_isStartPointSelected; // Flag: is the upper left edge selected?
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
void calcEdit( const wxPoint& aPosition ) override;

View File

@ -334,12 +334,12 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
// Get color
EDA_COLOR_T color;
COLOR4D color;
if( plotter->GetColorMode() ) // Used normal color or selected color
color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor();
else
color = BLACK;
color = COLOR4D_BLACK;
plotter->Text( pos, color, GetShownText(),
t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT,
@ -367,12 +367,12 @@ int LIB_TEXT::GetPenSize() const
void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
EDA_COLOR_T color = GetDefaultColor();
COLOR4D color = GetDefaultColor();
if( aColor < 0 ) // Used normal color or selected color
if( aColor == UNSPECIFIED_COLOR4D ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();

View File

@ -49,7 +49,7 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
bool m_updateText; ///< Flag to indicate text change occurred while editing.
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ) override;
void calcEdit( const wxPoint& aPosition ) override;

View File

@ -801,10 +801,10 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair();
STATUS_FLAGS oldFlags = m_drawItem->GetFlags();
m_drawItem->ClearFlags();
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
DefaultTransform );
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetCrossHairPosition( true ) );
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
DefaultTransform );
m_drawItem->SetFlags( oldFlags );
m_lastDrawItem = NULL;
@ -1048,7 +1048,7 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
// Deleting old text
if( DC && !DrawItem->InEditMode() )
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
DefaultTransform );
DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem );
@ -1058,7 +1058,7 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
// Display new text
if( DC && !DrawItem->InEditMode() )
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, NULL,
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, GR_DEFAULT_DRAWMODE, NULL,
DefaultTransform );
}

View File

@ -400,13 +400,13 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
if( aErase )
{
cur_pin->Move( PinPreviousPos );
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode,
showOptions, DefaultTransform );
}
// Redraw pin in new position
cur_pin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode,
showOptions, DefaultTransform );
PinPreviousPos = cur_pin->GetPosition();
@ -480,7 +480,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
// Build it:
void* showOptions = reinterpret_cast<void*>( show_opts );
pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_COPY,
pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, GR_COPY,
showOptions, DefaultTransform );
}

View File

@ -26,8 +26,6 @@
#ifndef __PROTOS_H__
#define __PROTOS_H__
#include <colors.h>
class EDA_DRAW_PANEL;
class PICKED_ITEMS_LIST;
class SCH_ITEM;
@ -52,7 +50,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false );
/* EEREDRAW.CPP */
/****************/
void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC,
const wxPoint& pos, EDA_COLOR_T Color );
const wxPoint& pos, COLOR4D Color );
#endif /* __PROTOS_H__ */

View File

@ -63,12 +63,12 @@ void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
}
// Virtual from EDA_DRAW_FRAME
EDA_COLOR_T SCH_BASE_FRAME::GetDrawBgColor() const
COLOR4D SCH_BASE_FRAME::GetDrawBgColor() const
{
return GetLayerColor( LAYER_BACKGROUND );
}
void SCH_BASE_FRAME::SetDrawBgColor( EDA_COLOR_T aColor)
void SCH_BASE_FRAME::SetDrawBgColor( COLOR4D aColor)
{
m_drawBgColor= aColor;
SetLayerColor( aColor, LAYER_BACKGROUND );

View File

@ -114,8 +114,8 @@ public:
// Virtual from EDA_DRAW_FRAME
// the background color of the draw canvas:
EDA_COLOR_T GetDrawBgColor() const override;
void SetDrawBgColor( EDA_COLOR_T aColor) override;
COLOR4D GetDrawBgColor() const override;
void SetDrawBgColor( COLOR4D aColor) override;
const TITLE_BLOCK& GetTitleBlock() const override;
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;

View File

@ -191,11 +191,11 @@ const EDA_RECT SCH_BITMAP::GetBoundingBox() const
void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
wxPoint pos = m_pos + aOffset;
if( aColor < 0 ) // Use normal drawing function
if( aColor == UNSPECIFIED_COLOR4D ) // Use normal drawing function
{
// https://bugs.launchpad.net/kicad/+bug/1529163
// "Moving images in eeschema on OS X uses

View File

@ -99,7 +99,7 @@ public:
void SwapData( SCH_ITEM* aItem ) override;
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
/**
* Function ReadImageFile

View File

@ -182,12 +182,12 @@ int SCH_BUS_BUS_ENTRY::GetPenSize() const
void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
EDA_COLOR_T color;
COLOR4D color;
EDA_RECT* clipbox = aPanel->GetClipBox();
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
color = aColor;
else
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );

View File

@ -83,7 +83,7 @@ public:
void SwapData( SCH_ITEM* aItem ) override;
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
static bool Load( LINE_READER& aLine, wxString& aErrorMsg, SCH_ITEM **out );

View File

@ -347,7 +347,7 @@ int SCH_COMPONENT::GetUnitCount() const
void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
GR_DRAWMODE aDrawMode, COLOR4D aColor,
bool aDrawPinText )
{
auto opts = PART_DRAW_OPTIONS::Default();

View File

@ -379,7 +379,7 @@ public:
* Virtual function, from the base class SCH_ITEM::Draw
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override
{
Draw( aPanel, aDC, aOffset, aDrawMode, aColor, true );
}
@ -392,12 +392,12 @@ public:
* @param aOffset drawing Offset (usually wxPoint(0,0),
* but can be different when moving an object)
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aColor UNSPECIFIED_COLOR to use the normal body item color, or use this color if >= 0
* @param aColor UNSPECIFIED_COLOR4D to use the normal body item color, or use this color if >= 0
* @param aDrawPinText = true to draw pin texts, false to draw only the pin shape
* usually false to draw a component when moving it, and true otherwise.
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
GR_DRAWMODE aDrawMode, COLOR4D aColor,
bool aDrawPinText );
void SwapData( SCH_ITEM* aItem ) override;

View File

@ -116,10 +116,10 @@ int SCH_FIELD::GetPenSize() const
void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
int orient;
EDA_COLOR_T color;
COLOR4D color;
wxPoint textpos;
SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
int lineWidth = GetThickness();
@ -167,7 +167,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
if( m_forceVisible )
{
color = DARKGRAY;
color = COLOR4D( DARKGRAY );
}
else
{
@ -534,7 +534,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
wxT( "Cannot plot field with invalid parent." ) );
EDA_COLOR_T color = GetLayerColor( GetLayer() );
COLOR4D color = GetLayerColor( GetLayer() );
if( !IsVisible() )
return;

View File

@ -141,7 +141,7 @@ public:
int GetPenSize() const override;
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
bool Save( FILE* aFile ) const override;

View File

@ -184,11 +184,11 @@ public:
* @param aOffset drawing Offset (usually wxPoint(0,0),
* but can be different when moving an object)
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aColor UNSPECIFIED_COLOR to use the normal body item color,
* @param aColor UNSPECIFIED_COLOR4D to use the normal body item color,
* or force this color if it is a valid color
*/
virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) = 0;
/**
* Function Move

View File

@ -111,11 +111,11 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const
void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
EDA_COLOR_T color;
COLOR4D color;
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
color = aColor;
else
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );

View File

@ -58,7 +58,7 @@ public:
const EDA_RECT GetBoundingBox() const override;
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
bool Save( FILE* aFile ) const override;

View File

@ -212,12 +212,12 @@ int SCH_LINE::GetPenSize() const
void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE DrawMode, EDA_COLOR_T Color )
GR_DRAWMODE DrawMode, COLOR4D Color )
{
EDA_COLOR_T color;
COLOR4D color;
int width = GetPenSize();
if( Color >= 0 )
if( Color != UNSPECIFIED_COLOR4D )
color = Color;
else
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );

View File

@ -85,7 +85,7 @@ public:
double GetLength() const;
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
bool Save( FILE* aFile ) const override;

View File

@ -85,10 +85,10 @@ bool SCH_MARKER::Save( FILE* aFile ) const
void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
EDA_COLOR_T color = m_Color;
EDA_COLOR_T tmp = color;
COLOR4D color = m_Color;
COLOR4D tmp = color;
if( GetMarkerType() == MARKER_BASE::MARKER_ERC )
{
@ -96,7 +96,7 @@ void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN );
}
if( aColor < 0 )
if( aColor == UNSPECIFIED_COLOR4D )
m_Color = color;
else
m_Color = aColor;

View File

@ -53,7 +53,7 @@ public:
}
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDraw_mode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDraw_mode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
void Plot( PLOTTER* aPlotter ) override
{

View File

@ -128,7 +128,7 @@ int SCH_NO_CONNECT::GetPenSize() const
void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
int pX, pY;
int delta = m_size.x / 2;
@ -137,8 +137,9 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
pX = m_pos.x + aOffset.x;
pY = m_pos.y + aOffset.y;
EDA_COLOR_T color;
if( aColor >= 0 )
COLOR4D color;
if( aColor != UNSPECIFIED_COLOR4D )
color = aColor;
else
color = GetLayerColor( LAYER_NOCONNECT );

View File

@ -56,7 +56,7 @@ public:
void SwapData( SCH_ITEM* aItem ) override;
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
bool Save( FILE* aFile ) const override;

View File

@ -558,7 +558,7 @@ void SCH_SCREEN::CheckComponentsToPartsLinks()
}
void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
/* note: SCH_SCREEN::Draw is useful only for schematic.
* library editor and library viewer do not use m_drawList, and therefore
@ -927,7 +927,9 @@ bool SCH_SCREEN::TestDanglingEnds()
for( item = m_drawList.begin(); item; item = item->Next() )
{
if( item->IsDanglingStateChanged( endPoints ) )
{
hasStateChanged = true;
}
}
return hasStateChanged;

View File

@ -581,18 +581,18 @@ wxPoint SCH_SHEET::GetFileNamePosition()
void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
EDA_COLOR_T txtcolor;
COLOR4D txtcolor;
wxString Text;
EDA_COLOR_T color;
COLOR4D color;
int name_orientation;
wxPoint pos_sheetname,pos_filename;
wxPoint pos = m_pos + aOffset;
int lineWidth = GetPenSize();
EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
color = aColor;
else
color = GetLayerColor( m_Layer );
@ -611,7 +611,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
name_orientation = TEXT_ANGLE_HORIZ;
/* Draw text : SheetName */
if( aColor > 0 )
if( aColor != UNSPECIFIED_COLOR4D )
txtcolor = aColor;
else
txtcolor = GetLayerColor( LAYER_SHEETNAME );
@ -624,7 +624,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
false, false );
/* Draw text : FileName */
if( aColor >= 0 )
if( aColor != UNSPECIFIED_COLOR4D )
txtcolor = aColor;
else
txtcolor = GetLayerColor( LAYER_SHEETFILENAME );
@ -1138,7 +1138,7 @@ void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
void SCH_SHEET::Plot( PLOTTER* aPlotter )
{
EDA_COLOR_T txtcolor = UNSPECIFIED_COLOR;
COLOR4D txtcolor = UNSPECIFIED_COLOR4D;
wxSize size;
wxString Text;
int name_orientation;

View File

@ -113,7 +113,7 @@ public:
bool IsMovableFromAnchorPoint() override { return true; }
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
/**
* Function CreateGraphicShape (virtual)
@ -429,7 +429,7 @@ public:
int GetPenSize() const override;
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
EDA_RECT const GetBoundingBox() const override;

View File

@ -72,7 +72,7 @@ void SCH_SHEET_PIN::Draw( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
GR_DRAWMODE aDraw_mode,
EDA_COLOR_T aColor )
COLOR4D aColor )
{
// The icon selection is handle by the virtual method CreateGraphicShape
// called by ::Draw

View File

@ -342,15 +342,15 @@ int SCH_TEXT::GetPenSize() const
void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
GR_DRAWMODE DrawMode, EDA_COLOR_T Color )
GR_DRAWMODE DrawMode, COLOR4D Color )
{
EDA_COLOR_T color;
COLOR4D color;
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
if( Color >= 0 )
if( Color != UNSPECIFIED_COLOR4D )
color = Color;
else
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
@ -362,7 +362,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
int savedWidth = GetThickness();
SetThickness( linewidth ); // Set the minimum width
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR4D );
SetThickness( savedWidth );
@ -676,8 +676,8 @@ bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
void SCH_TEXT::Plot( PLOTTER* aPlotter )
{
static std::vector <wxPoint> Poly;
EDA_COLOR_T color = GetLayerColor( GetLayer() );
int thickness = GetPenSize();
COLOR4D color = GetLayerColor( GetLayer() );
int thickness = GetPenSize();
aPlotter->SetCurrentLineWidth( thickness );
@ -979,7 +979,7 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE DrawMode, EDA_COLOR_T Color )
GR_DRAWMODE DrawMode, COLOR4D Color )
{
SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
}
@ -1269,13 +1269,13 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
wxDC* DC,
const wxPoint& aOffset,
GR_DRAWMODE DrawMode,
EDA_COLOR_T Color )
COLOR4D Color )
{
static std::vector <wxPoint> Poly;
EDA_COLOR_T color;
COLOR4D color;
wxPoint text_offset = aOffset + GetSchematicTextOffset();
if( Color >= 0 )
if( Color != UNSPECIFIED_COLOR4D )
color = Color;
else
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
@ -1290,7 +1290,7 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
SetThickness( linewidth );
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR4D );
SetThickness( save_width ); // restore initial value
@ -1636,16 +1636,16 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
wxDC* DC,
const wxPoint& offset,
GR_DRAWMODE DrawMode,
EDA_COLOR_T Color )
COLOR4D Color )
{
static std::vector <wxPoint> Poly;
EDA_COLOR_T color;
COLOR4D color;
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
if( Color >= 0 )
if( Color != UNSPECIFIED_COLOR4D )
color = Color;
else
color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
@ -1656,7 +1656,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
SetThickness( linewidth );
wxPoint text_offset = offset + GetSchematicTextOffset();
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR4D );
SetThickness( save_width ); // restore initial value

View File

@ -132,7 +132,7 @@ public:
virtual wxPoint GetSchematicTextOffset() const;
virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
/**
* Function CreateGraphicShape
@ -228,7 +228,7 @@ public:
~SCH_LABEL() { }
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
wxString GetClass() const override
{
@ -274,7 +274,7 @@ public:
~SCH_GLOBALLABEL() { }
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
wxString GetClass() const override
{
@ -324,7 +324,7 @@ public:
~SCH_HIERLABEL() { }
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
wxString GetClass() const override
{

View File

@ -708,7 +708,7 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aErase )
{
if( cmp ) // Use fast mode (do not draw pin texts)
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR4D, false );
else
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
}
@ -723,7 +723,7 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
item->SetWireImage(); // While moving, the item may choose to render differently
if( cmp ) // Use fast mode (do not draw pin texts)
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR4D, false );
else
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
}

View File

@ -561,7 +561,7 @@ void SIM_PLOT_FRAME::updateSignalList()
{
wxBitmap bitmap( isize, isize );
bmDC.SelectObject( bitmap );
wxColor tcolor = trace.second->GetTraceColour();
wxColour tcolor = trace.second->GetTraceColour();
wxColour bgColor = m_signals->wxWindow::GetBackgroundColour();
bmDC.SetPen( wxPen( bgColor ) );

View File

@ -240,7 +240,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
if( m_drawItem->ContinueEdit( pos ) )
{
m_drawItem->Draw( m_canvas, DC, pos, UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
m_drawItem->Draw( m_canvas, DC, pos, UNSPECIFIED_COLOR4D, g_XorMode, NULL, DefaultTransform );
return;
}
@ -270,12 +270,12 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
UNSPECIFIED_COLOR, g_XorMode, &text,
UNSPECIFIED_COLOR4D, g_XorMode, &text,
DefaultTransform );
}
else
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
UNSPECIFIED_COLOR, g_XorMode, NULL,
UNSPECIFIED_COLOR4D, g_XorMode, NULL,
DefaultTransform );
}
@ -323,7 +323,7 @@ static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
return;
item->SetEraseLastDrawItem( aErase );
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL,
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
DefaultTransform );
}

View File

@ -33,9 +33,6 @@
#include "widget_eeschema_color_config.h"
// See selcolor.cpp:
extern EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor );
// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 16;
const int BUTT_SIZE_Y = 16;
@ -107,8 +104,9 @@ static BUTTONINDEX buttonGroups[] = {
{ wxT( "" ), NULL }
};
static COLORBUTTON bgColorButton = { _( "" ), LAYER_BACKGROUND };
static EDA_COLOR_T currentColors[ LAYERSCH_ID_COUNT ];
static COLOR4D currentColors[ LAYERSCH_ID_COUNT ];
WIDGET_EESCHEMA_COLOR_CONFIG::WIDGET_EESCHEMA_COLOR_CONFIG( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ) :
@ -153,28 +151,16 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls()
rowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxALL, 0 );
wxMemoryDC iconDC;
wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
iconDC.SelectObject( bitmap );
EDA_COLOR_T color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) );
COLOR4D color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) );
currentColors[ buttons->m_Layer ] = color;
iconDC.SetPen( *wxBLACK_PEN );
wxColourPickerCtrl* colourPicker = new wxColourPickerCtrl(
this, buttonId, color.ToColour(), wxDefaultPosition,
wxSize( BUTT_SIZE_X+20, BUTT_SIZE_Y+20 ) );
wxBrush brush;
ColorSetBrush( &brush, color );
brush.SetStyle( wxBRUSHSTYLE_SOLID );
iconDC.SetBrush( brush );
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
colourPicker->SetClientData( (void*) buttons );
wxBitmapButton* bitmapButton = new wxBitmapButton(
this, buttonId, bitmap, wxDefaultPosition,
wxSize( BUTT_SIZE_X+8, BUTT_SIZE_Y+6 ) );
bitmapButton->SetClientData( (void*) buttons );
rowBoxSizer->Add( bitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
rowBoxSizer->Add( colourPicker, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
label = new wxStaticText( this, wxID_ANY, wxGetTranslation( buttons->m_Name ) );
rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
@ -185,25 +171,38 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls()
groups++;
}
Connect( 1800, buttonId - 1, wxEVT_COMMAND_BUTTON_CLICKED,
Connect( 1800, buttonId - 1, wxEVT_COLOURPICKER_CHANGED,
wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) );
wxArrayString selBgColorStrings;
/*wxArrayString selBgColorStrings;
selBgColorStrings.Add( _( "White" ) );
selBgColorStrings.Add( _( "Black" ) );
m_SelBgColor = new wxRadioBox( this, wxID_ANY, _( "Background Color" ),
wxDefaultPosition, wxDefaultSize,
selBgColorStrings, 1, wxRA_SPECIFY_COLS );
m_SelBgColor->SetSelection( ( GetDrawFrame()->GetDrawBgColor() == BLACK ) ? 1 : 0 );
*/
COLOR4D bgColor = GetDrawFrame()->GetDrawBgColor();
m_SelBgColor = new wxColourPickerCtrl(
this, buttonId, bgColor.ToColour(), wxDefaultPosition,
wxSize( BUTT_SIZE_X+20, BUTT_SIZE_Y+20 ) );
wxStaticText* bgColorLabel = new wxStaticText( this, wxID_ANY, _( "Background Color" ) );
wxFont font( bgColorLabel->GetFont() );
font.SetWeight( wxFONTWEIGHT_BOLD );
bgColorLabel->SetFont( font );
if( columnBoxSizer )
{
// Add a spacer to improve appearance.
columnBoxSizer->AddSpacer( 5 );
columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 );
columnBoxSizer->Add( bgColorLabel, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
columnBoxSizer->Add( m_SelBgColor, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
}
currentColors[ LAYER_BACKGROUND ] = GetDrawFrame()->GetDrawBgColor();
// TODO(jon) fix currentColors
//currentColors[ LAYER_BACKGROUND ] = GetDrawFrame()->GetDrawBgColor();
// Dialog now needs to be resized, but the associated command is found elsewhere.
}
@ -211,38 +210,22 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls()
void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event )
{
wxBitmapButton* button = (wxBitmapButton*) event.GetEventObject();
wxColourPickerCtrl* picker = (wxColourPickerCtrl*) event.GetEventObject();
wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) );
wxCHECK_RET( picker != NULL, wxT( "Color picker event object is NULL." ) );
COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData();
COLORBUTTON* colorButton = (COLORBUTTON*) picker->GetClientData();
wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) );
EDA_COLOR_T color = DisplayColorFrame( this, currentColors[colorButton->m_Layer] );
// DisplayColorFrame( this, currentColors[colorButton->m_Layer] );
COLOR4D color = COLOR4D( picker->GetColour() );
if( color < 0 || currentColors[ colorButton->m_Layer ] == color )
if( color == UNSPECIFIED_COLOR4D || currentColors[ colorButton->m_Layer ] == color )
return;
currentColors[ colorButton->m_Layer ] = color;
wxMemoryDC iconDC;
wxBitmap bitmap = button->GetBitmapLabel();
iconDC.SelectObject( bitmap );
iconDC.SetPen( *wxBLACK_PEN );
wxBrush brush;
ColorSetBrush( &brush, color);
brush.SetStyle( wxBRUSHSTYLE_SOLID );
iconDC.SetBrush( brush );
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
button->SetBitmapLabel( bitmap );
button->Refresh();
Refresh( false );
}
@ -254,10 +237,7 @@ bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl()
// Check for color conflicts with background color to give user a chance to bail
// out before making changes.
EDA_COLOR_T bgcolor = WHITE;
if( m_SelBgColor->GetSelection() > 0 )
bgcolor = BLACK;
COLOR4D bgcolor = m_SelBgColor->GetColour();
for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
{

View File

@ -27,6 +27,8 @@
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/colordlg.h>
#include <wx/clrpicker.h>
class wxBoxSizer;
class wxStaticLine;
@ -41,7 +43,7 @@ class WIDGET_EESCHEMA_COLOR_CONFIG : public wxPanel
{
private:
EDA_DRAW_FRAME* m_drawFrame;
wxRadioBox* m_SelBgColor;
wxColourPickerCtrl* m_SelBgColor;
wxBoxSizer* m_mainBoxSizer;
// Creates the controls and sizers

View File

@ -102,6 +102,7 @@ target_link_libraries( gerbview
# There's way too much crap coming in from common yet.
common
bitmaps
gal
${wxWidgets_LIBRARIES}
)

View File

@ -148,7 +148,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
{
BASE_SCREEN* screen = aPanel->GetScreen();
EDA_COLOR_T Color = YELLOW;
COLOR4D Color = COLOR4D( YELLOW );
if( aErase )
{

Some files were not shown because too many files have changed in this diff Show More