Commit d12a4592 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

More work on EDA_COLOR_T and layers.

In particular the new mechanism for handling extended color palettes is in place,
included renaming the ini keys and saving the color name instead of its index; this means better forward compatibility with palette changes.

Since ini keys are changed, colors will be reset
parent a47d36e3
......@@ -49,7 +49,7 @@
#include <3d_draw_basic_functions.h>
// Imported function:
extern void SetGLColor( int color );
extern void SetGLColor( EDA_COLOR_T color );
extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
extern void CheckGLError();
......@@ -326,8 +326,8 @@ void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
{
double zpos = 0.0;
int gridcolor = DARKGRAY; // Color of grid lines
int gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines
EDA_COLOR_T gridcolor = DARKGRAY; // Color of grid lines
EDA_COLOR_T gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines
double scale = g_Parm_3D_Visu.m_BiuTo3Dunits;
glNormal3f( 0.0, 0.0, 1.0 );
......@@ -457,7 +457,7 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
{
LAYER_NUM layer = aTrack->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer );
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
if( layer == LAST_COPPER_LAYER )
......@@ -476,7 +476,7 @@ void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
{
LAYER_NUM layer, top_layer, bottom_layer;
int color;
EDA_COLOR_T color;
double biu_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits ;
int outer_radius = via->GetWidth() / 2;
......@@ -531,7 +531,7 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
{
LAYER_NUM layer = segment->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer );
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
SetGLColor( color );
......@@ -625,7 +625,7 @@ static void Draw3dTextSegm( int x0, int y0, int xf, int yf )
void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
{
LAYER_NUM layer = text->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer );
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
SetGLColor( color );
s_Text3DZPos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
......
......@@ -122,10 +122,10 @@ static void Draw3D_VerticalPolygonalCylinder( const std::vector<CPolyPt>& aPolys
}
void SetGLColor( int color )
void SetGLColor( EDA_COLOR_T color )
{
double red, green, blue;
StructColors colordata = ColorRefs[color & MASKCOLOR];
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
red = colordata.m_Red / 255.0;
blue = colordata.m_Blue / 255.0;
......
......@@ -72,9 +72,9 @@ bool IsGOST()
* Please: if you change a value, remember these values are carefully chosen
* to have good results in Pcbnew, that uses the ORed value of basic colors
* when displaying superimposed objects
* This list must have exactly NBCOLOR items
* This list must have exactly NBCOLORS items
*/
StructColors ColorRefs[NBCOLOR] =
const StructColors g_ColorRefs[NBCOLORS] =
{
{ 0, 0, 0, BLACK, wxT( "BLACK" ), DARKDARKGRAY },
{ 192, 0, 0, BLUE, wxT( "BLUE" ), LIGHTBLUE },
......
......@@ -45,7 +45,7 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
SetDefaultLineWidth( 0 ); // No line width on DXF
plotMirror = false; // No mirroring on DXF
currentColor = BLACK;
m_currentColor = BLACK;
}
/**
......@@ -151,7 +151,7 @@ bool DXF_PLOTTER::StartPlot()
" 2\n"
"LAYER\n"
" 70\n"
"%d\n", NBCOLOR );
"%d\n", NBCOLORS );
/* The layer/colors palette. The acad/DXF palette is divided in 3 zones:
......@@ -159,7 +159,7 @@ bool DXF_PLOTTER::StartPlot()
- An HSV zone (10-250, 5 values x 2 saturations x 10 hues
- Greys (251 - 255)
The is *no* black... the white does it on paper, usually, and
There is *no* black... the white does it on paper, usually, and
anyway it depends on the plotter configuration, since DXF colors
are meant to be logical only (they represent *both* line color and
width); later version with plot styles only complicate the matter!
......@@ -170,7 +170,7 @@ bool DXF_PLOTTER::StartPlot()
static const struct {
const char *name;
int color;
} dxf_layer[NBCOLOR] = {
} dxf_layer[NBCOLORS] = {
{ "BLACK", 250 },
{ "BLUE", 5 },
{ "GREEN", 3 },
......@@ -197,9 +197,8 @@ bool DXF_PLOTTER::StartPlot()
{ "LIGHTYELLOW", 51 },
};
for( int i = 0; i < NBCOLOR; i++ )
for( EDA_COLOR_T i = BLACK; i < NBCOLORS; ++i )
{
wxString cname = ColorRefs[i].m_Name;
fprintf( outputFile,
" 0\n"
"LAYER\n"
......@@ -254,10 +253,10 @@ void DXF_PLOTTER::SetColor( EDA_COLOR_T color )
|| ( color == BLACK )
|| ( color == WHITE ) )
{
currentColor = color;
m_currentColor = color;
}
else
currentColor = BLACK;
m_currentColor = BLACK;
}
/**
......@@ -287,7 +286,7 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int
DPOINT centre_dev = userToDeviceCoordinates( centre );
if( radius > 0 )
{
wxString cname = ColorRefs[currentColor].m_Name;
wxString cname( ColorGetName( m_currentColor ) );
if (!fill)
{
fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
......@@ -349,7 +348,7 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
if( penLastpos != pos && plume == 'D' )
{
// DXF LINE
wxString cname = ColorRefs[currentColor].m_Name;
wxString cname( ColorGetName( m_currentColor ) );
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 );
......@@ -396,7 +395,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad
double radius_dev = userToDeviceSize( radius );
// Emit a DXF ARC entity
wxString cname = ColorRefs[currentColor].m_Name;
wxString cname( ColorGetName( m_currentColor ) );
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 ),
......@@ -570,7 +569,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
more useful as a CAD object */
DPOINT origin_dev = userToDeviceCoordinates( aPos );
SetColor( aColor );
wxString cname = ColorRefs[currentColor].m_Name;
wxString cname( ColorGetName( m_currentColor ) );
DPOINT size_dev = userToDeviceSize( aSize );
int h_code = 0, v_code = 0;
switch( aH_justify )
......
......@@ -39,9 +39,9 @@ void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
if( colorMode )
{
double r = ColorRefs[color].m_Red / 255.0;
double g = ColorRefs[color].m_Green / 255.0;
double b = ColorRefs[color].m_Blue / 255.0;
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 );
else
......
......@@ -162,9 +162,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
m_messagePanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red,
ColorRefs[LIGHTGRAY].m_Green,
ColorRefs[LIGHTGRAY].m_Blue ) );
m_messagePanel->SetBackgroundColour( MakeColour( LIGHTGRAY ) );
}
......
......@@ -1451,3 +1451,103 @@ void GRBezier( EDA_RECT* ClipBox,
std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 );
GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
}
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
{
/* Memoization storage. This could be potentially called for each
* color merge so a cache is useful (there are few colours anyway) */
static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];
// TODO how is alpha used? it's a mac only thing, I have no idea
aColor1 = ColorGetBase( aColor1 );
aColor2 = ColorGetBase( aColor2 );
// First easy thing: a black gives always the other colour
if( aColor1 == BLACK )
return aColor2;
if( aColor2 == BLACK)
return aColor1;
/* 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 */
EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];
if( candidate != BLACK )
return candidate;
// Blend the two colors (i.e. OR the RGB values)
const StructColors &c1 = g_ColorRefs[aColor1];
const StructColors &c2 = g_ColorRefs[aColor2];
// Ask the palette for the nearest color to the mix
wxColour mixed( c1.m_Red | c2.m_Red,
c1.m_Green | c2.m_Green,
c1.m_Blue | c2.m_Blue );
candidate = ColorFindNearest( 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 == BLACK)
candidate = DARKDARKGRAY;
// Store the result in the cache. The operation is commutative, too
mix_cache[aColor1][aColor2] = candidate;
mix_cache[aColor2][aColor1] = candidate;
return candidate;
}
EDA_COLOR_T ColorByName( const wxChar *aName )
{
// look for a match in the palette itself
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
{
if( 0 == wxStricmp( aName, g_ColorRefs[trying].m_Name ) )
return trying;
}
// Not found, no idea...
return UNSPECIFIED_COLOR;
}
EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{
EDA_COLOR_T candidate = BLACK;
// These are ints because we will subtract them later
int r = aColor.Red();
int g = aColor.Green();
int b = aColor.Blue();
/* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the
useful one is in the RGB color space. Who cares, this is a CAD,
not a photosomething...
I hereby declare that the distance is the sum of the square of the
component difference. Think about the RGB color cube. Now get the
euclidean distance, but without the square root... for ordering
purposes it's the same, obviously. Also each component can't be
less of the target one, since I found this currently work better...
*/
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
{
const StructColors &c = g_ColorRefs[trying];
int distance = (r - c.m_Red) * (r - c.m_Red) +
(g - c.m_Green) * (g - c.m_Green) +
(b - c.m_Blue) * (b - c.m_Blue);
if( distance < nearest_distance && c.m_Red >= r &&
c.m_Green >= g && c.m_Blue >= b )
{
nearest_distance = distance;
candidate = trying;
}
}
return candidate;
}
......@@ -205,9 +205,7 @@ void EDA_MSG_PANEL::showItem( wxDC& aDC, const MSG_PANEL_ITEM& aItem )
if( color >= 0 )
{
color = ColorGetBase( color );
aDC.SetTextForeground( wxColour( ColorRefs[color].m_Red,
ColorRefs[color].m_Green,
ColorRefs[color].m_Blue ) );
aDC.SetTextForeground( MakeColour( color ) );
}
if( !aItem.m_UpperText.IsEmpty() )
......
......@@ -371,13 +371,11 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
{
static const int MAX_COLOR = 0x8001F;
if( m_Pt_param == NULL || aConfig == NULL )
return;
EDA_COLOR_T itmp = ColorFromInt( aConfig->Read( m_Ident, m_Default ) );
EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT("NONE") ) );
if( (itmp < 0) || (itmp > MAX_COLOR) )
if( itmp == UNSPECIFIED_COLOR )
itmp = m_Default;
*m_Pt_param = itmp;
}
......@@ -388,7 +386,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL )
return;
aConfig->Write( m_Ident, (long) *m_Pt_param );
aConfig->Write( m_Ident, ColorGetName( *m_Pt_param ) );
}
......
......@@ -54,7 +54,7 @@ EDA_COLOR_T DisplayColorFrame( wxWindow* parent, int OldColor )
framepos, OldColor );
color = static_cast<EDA_COLOR_T>( frame->ShowModal() );
frame->Destroy();
if( color > NBCOLOR )
if( color > NBCOLORS )
color = UNSPECIFIED_COLOR;
return color;
}
......@@ -125,7 +125,7 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
wxStdDialogButtonSizer* StdDialogButtonSizer = NULL;
wxButton* Button = NULL;
int ii, butt_ID, buttcolor;
int ii, butt_ID;
int w = 20, h = 20;
bool ColorFound = false;
......@@ -137,7 +137,7 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
for( ii = 0; ColorRefs[ii].m_Name != NULL && ii < NBCOLOR; ii++ )
for( ii = 0; ii < NBCOLORS; ++ii )
{
// Provide a separate column for every eight buttons (and their
// associated text strings), so provide a FlexGrid Sizer with
......@@ -163,11 +163,9 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
wxBitmap ButtBitmap( w, h );
wxBrush Brush;
iconDC.SelectObject( ButtBitmap );
buttcolor = ColorRefs[ii].m_Numcolor;
EDA_COLOR_T buttcolor = g_ColorRefs[ii].m_Numcolor;
iconDC.SetPen( *wxBLACK_PEN );
Brush.SetColour( ColorRefs[buttcolor].m_Red,
ColorRefs[buttcolor].m_Green,
ColorRefs[buttcolor].m_Blue );
ColorSetBrush( &Brush, buttcolor );
Brush.SetStyle( wxSOLID );
iconDC.SetBrush( Brush );
......@@ -190,7 +188,7 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor )
BitmapButton->SetFocus();
}
Label = new wxStaticText( this, -1, ColorRefs[ii].m_Name,
Label = new wxStaticText( this, -1, ColorGetName( buttcolor ),
wxDefaultPosition, wxDefaultSize, 0 );
FlexColumnBoxSizer->Add( Label, 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
......
......@@ -67,7 +67,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
return;
segment = (SCH_LINE*) s_wires.begin();
EDA_COLOR_T color = ReturnLayerColor( segment->GetLayer() );
EDA_COLOR_T color = GetLayerColor( segment->GetLayer() );
ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) );
if( aErase )
......
......@@ -391,7 +391,7 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
continue;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
bool fill = aPlotter->GetColorMode();
item.Plot( aPlotter, aOffset, fill, aTransform );
......
......@@ -130,7 +130,6 @@ void DIALOG_COLOR_CONFIG::Init()
void DIALOG_COLOR_CONFIG::CreateControls()
{
wxStaticText* label;
int color;
int buttonId = 1800;
ButtonIndex* groups = buttonGroups;
......@@ -168,12 +167,10 @@ void DIALOG_COLOR_CONFIG::CreateControls()
wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
iconDC.SelectObject( bitmap );
color = currentColors[ buttons->m_Layer ] = ReturnLayerColor( buttons->m_Layer );
EDA_COLOR_T color = currentColors[ buttons->m_Layer ] = GetLayerColor( buttons->m_Layer );
iconDC.SetPen( *wxBLACK_PEN );
wxBrush brush;
brush.SetColour( ColorRefs[ color ].m_Red,
ColorRefs[ color ].m_Green,
ColorRefs[ color ].m_Blue );
ColorSetBrush( &brush, color );
brush.SetStyle( wxSOLID );
iconDC.SetBrush( brush );
......@@ -267,9 +264,7 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event )
iconDC.SelectObject( bitmap );
wxBrush brush;
iconDC.SetPen( *wxBLACK_PEN );
brush.SetColour( ColorRefs[ color ].m_Red,
ColorRefs[ color ].m_Green,
ColorRefs[ color ].m_Blue );
ColorSetBrush( &brush, color);
brush.SetStyle( wxSOLID );
iconDC.SetBrush( brush );
......@@ -295,13 +290,13 @@ bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
{
SetLayerColor( currentColors[ ii ], ii );
if( g_DrawBgColor == ReturnLayerColor( ii ) )
if( g_DrawBgColor == GetLayerColor( ii ) )
warning = true;
}
m_Parent->SetGridColor( ReturnLayerColor( LAYER_GRID ) );
m_Parent->SetGridColor( GetLayerColor( LAYER_GRID ) );
if( g_DrawBgColor == ReturnLayerColor( LAYER_GRID ) )
if( g_DrawBgColor == GetLayerColor( LAYER_GRID ) )
warning = true;
return warning;
......
......@@ -90,7 +90,7 @@ void SetDefaultLineThickness( int aThickness)
s_drawDefaultLineThickness = 1;
}
EDA_COLOR_T ReturnLayerColor( int aLayer )
EDA_COLOR_T GetLayerColor( int aLayer )
{
return s_layerColor[aLayer];
}
......@@ -460,80 +460,80 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ),
(int*)&g_UserUnit, MILLIMETRES ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColWire" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorWireEx" ),
&s_layerColor[LAYER_WIRE],
GREEN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBus" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBusEx" ),
&s_layerColor[LAYER_BUS],
BLUE ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConn" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConnEx" ),
&s_layerColor[LAYER_JUNCTION],
GREEN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLlab" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLLabelEx" ),
&s_layerColor[LAYER_LOCLABEL],
BLACK ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHlab" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHLabelEx" ),
&s_layerColor[LAYER_HIERLABEL],
BROWN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGbllab" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGLabelEx" ),
&s_layerColor[LAYER_GLOBLABEL],
RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinF" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinFunEx" ),
&s_layerColor[LAYER_PINFUN],
MAGENTA ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColPinN" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNumEx" ),
&s_layerColor[LAYER_PINNUM],
RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPNam" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNameEx" ),
&s_layerColor[LAYER_PINNAM],
CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorField" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorFieldEx" ),
&s_layerColor[LAYER_FIELDS],
MAGENTA ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorRef" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorReferenceEx" ),
&s_layerColor[LAYER_REFERENCEPART],
CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValue" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValueEx" ),
&s_layerColor[LAYER_VALUEPART],
CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNote" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoteEx" ),
&s_layerColor[LAYER_NOTES],
LIGHTBLUE ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBody" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyEx" ),
&s_layerColor[LAYER_DEVICE],
RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBg" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBgEx" ),
&s_layerColor[LAYER_DEVICE_BACKGROUND],
LIGHTYELLOW ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetN" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetNameEx" ),
&s_layerColor[LAYER_NETNAM],
DARKGRAY ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPin" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinEx" ),
&s_layerColor[LAYER_PIN],
RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheet" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetEx" ),
&s_layerColor[LAYER_SHEET],
MAGENTA ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
wxT( "ColorSheetFileName" ),
wxT( "ColorSheetFileNameEx" ),
&s_layerColor[LAYER_SHEETFILENAME],
BROWN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetName" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetNameEx" ),
&s_layerColor[LAYER_SHEETNAME],
CYAN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLab" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLabelEx" ),
&s_layerColor[LAYER_SHEETLABEL],
BROWN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoCo" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoConnectEx" ),
&s_layerColor[LAYER_NOCONNECT],
BLUE ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcW" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcWEx" ),
&s_layerColor[LAYER_ERC_WARN],
GREEN ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcE" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcEEx" ),
&s_layerColor[LAYER_ERC_ERR],
RED ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGrid" ),
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGridEx" ),
&s_layerColor[LAYER_GRID],
DARKGRAY ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ),
......@@ -558,7 +558,7 @@ void SCH_EDIT_FRAME::LoadSettings()
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
// This is required until someone gets rid of the global variable s_layerColor.
m_GridColor = ReturnLayerColor( LAYER_GRID );
m_GridColor = GetLayerColor( LAYER_GRID );
SetDefaultBusThickness( cfg->Read( DefaultBusWidthEntry, 12l ) );
SetDefaultLineThickness( cfg->Read( DefaultDrawLineWidthEntry, 6l ) );
......
......@@ -90,7 +90,7 @@ void SetDefaultLineThickness( int aThickness);
int GetDefaultBusThickness();
void SetDefaultBusThickness( int aThickness );
EDA_COLOR_T ReturnLayerColor( int aLayer );
EDA_COLOR_T GetLayerColor( int aLayer );
// Color to draw selected items
EDA_COLOR_T GetItemSelectedColor();
......
......@@ -370,12 +370,12 @@ void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_SHAPE, 0 );
}
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, GetPenSize() );
}
......@@ -416,7 +416,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
return;
wxPoint pos1, pos2, posc;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE );
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
{
......@@ -452,8 +452,8 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
{
GRFilledArc( aPanel->GetClipBox(), aDC, posc.x, posc.y, pt1, pt2,
m_Radius, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
}
else if( fill == FILLED_SHAPE && !aData )
{
......
......@@ -270,12 +270,12 @@ void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 );
}
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() );
}
......@@ -293,7 +293,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
wxPoint pos1;
std::vector<wxPoint> PolyPointsTraslated;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE );
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
m_PolyPoints = Bezier2Poly( m_BezierPoints[0],
m_BezierPoints[1],
......@@ -326,8 +326,8 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(),
&PolyPointsTraslated[0], 1, GetPenSize(),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(),
&PolyPointsTraslated[0], 1, GetPenSize(), color, color );
......
......@@ -194,12 +194,12 @@ void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->Circle( pos, m_Radius * 2, FILLED_SHAPE, 0 );
}
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->Circle( pos, m_Radius * 2, already_filled ? NO_FILL : m_Fill, GetPenSize() );
}
......@@ -216,7 +216,7 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
{
wxPoint pos1;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE );
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
{
......@@ -237,8 +237,8 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, GetPenSize(),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRFilledCircle( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, m_Radius, 0, color, color );
else
......
......@@ -156,5 +156,5 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
EDA_COLOR_T LIB_ITEM::GetDefaultColor()
{
return ReturnLayerColor( LAYER_DEVICE );
return GetLayerColor( LAYER_DEVICE );
}
......@@ -523,15 +523,15 @@ EDA_COLOR_T LIB_FIELD::GetDefaultColor()
switch( m_id )
{
case REFERENCE:
color = ReturnLayerColor( LAYER_REFERENCEPART );
color = GetLayerColor( LAYER_REFERENCEPART );
break;
case VALUE:
color = ReturnLayerColor( LAYER_VALUEPART );
color = GetLayerColor( LAYER_VALUEPART );
break;
default:
color = ReturnLayerColor( LAYER_FIELDS );
color = GetLayerColor( LAYER_FIELDS );
break;
}
......
......@@ -860,7 +860,7 @@ 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 = ReturnLayerColor( LAYER_PIN );
EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
if( aColor < 0 ) // Used normal color or selected color
{
......@@ -1090,9 +1090,9 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
Color = GetItemSelectedColor();
NameColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ?
ReturnLayerColor( LAYER_PINNAM ) : Color );
GetLayerColor( LAYER_PINNAM ) : Color );
NumColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ?
ReturnLayerColor( LAYER_PINNUM ) : Color );
GetLayerColor( LAYER_PINNUM ) : Color );
/* Create the pin num string */
ReturnPinStringNum( StringPinNum );
......@@ -1271,7 +1271,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
{
int MapX1, MapY1, x1, y1;
EDA_COLOR_T color = ReturnLayerColor( LAYER_PIN );
EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
aPlotter->SetColor( color );
......@@ -1385,8 +1385,8 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter,
wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize );
/* Get the num and name colors */
NameColor = ReturnLayerColor( LAYER_PINNAM );
NumColor = ReturnLayerColor( LAYER_PINNUM );
NameColor = GetLayerColor( LAYER_PINNAM );
NumColor = GetLayerColor( LAYER_PINNUM );
/* Create the pin num string */
ReturnPinStringNum( StringPinNum );
......
......@@ -242,13 +242,13 @@ void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->PlotPoly( cornerList, FILLED_WITH_BG_BODYCOLOR, 0 );
aFill = false; // body is now filled, do not fill it later.
}
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() );
}
......@@ -270,7 +270,7 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
const TRANSFORM& aTransform )
{
wxPoint pos1;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE );
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
wxPoint* buffer = NULL;
if( aColor < 0 ) // Used normal color or selected color
......@@ -299,8 +299,8 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRPoly( aPanel->GetClipBox(), aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
color, color );
......
......@@ -179,12 +179,12 @@ void LIB_RECTANGLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
{
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
aPlotter->Rect( pos, end, FILLED_WITH_BG_BODYCOLOR, 0 );
}
bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
aPlotter->SetColor( ReturnLayerColor( LAYER_DEVICE ) );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->Rect( pos, end, already_filled ? NO_FILL : m_Fill, GetPenSize() );
}
......@@ -201,7 +201,7 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
{
wxPoint pos1, pos2;
EDA_COLOR_T color = ReturnLayerColor( LAYER_DEVICE );
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
{
......@@ -225,8 +225,8 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( fill == FILLED_WITH_BG_BODYCOLOR && !aData )
GRFilledRect( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( m_Fill == FILLED_SHAPE && !aData )
GRFilledRect( aPanel->GetClipBox(), aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GetPenSize(), color, color );
......
......@@ -48,12 +48,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false );
void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, EDA_COLOR_T Color );
/***********************************/
/* dialogs/dialog_color_config.cpp */
/***********************************/
EDA_COLOR_T ReturnLayerColor( int Layer );
/***************/
/* SELPART.CPP */
/***************/
......
......@@ -301,5 +301,5 @@ bool SCH_BITMAP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
void SCH_BITMAP::Plot( PLOTTER* aPlotter )
{
m_Image->PlotImage( aPlotter, m_Pos, ReturnLayerColor( GetLayer() ), GetPenSize() );
m_Image->PlotImage( aPlotter, m_Pos, GetLayerColor( GetLayer() ), GetPenSize() );
}
......@@ -187,7 +187,7 @@ void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( m_Layer );
color = GetLayerColor( m_Layer );
GRSetDrawMode( aDC, aDrawMode );
......@@ -287,7 +287,7 @@ bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aA
void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter )
{
aPlotter->SetCurrentLineWidth( GetPenSize() );
aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
aPlotter->SetColor( GetLayerColor( GetLayer() ) );
aPlotter->MoveTo( m_pos );
aPlotter->FinishTo( m_End() );
}
......
......@@ -187,11 +187,11 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
else
{
if( m_id == REFERENCE )
color = ReturnLayerColor( LAYER_REFERENCEPART );
color = GetLayerColor( LAYER_REFERENCEPART );
else if( m_id == VALUE )
color = ReturnLayerColor( LAYER_VALUEPART );
color = GetLayerColor( LAYER_VALUEPART );
else
color = ReturnLayerColor( LAYER_FIELDS );
color = GetLayerColor( LAYER_FIELDS );
}
DrawGraphicText( panel, DC, textpos, color, GetFullyQualifiedText(), orient, m_Size,
......@@ -537,7 +537,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 = ReturnLayerColor( GetLayer() );
EDA_COLOR_T color = GetLayerColor( GetLayer() );
if( m_Attributs & TEXT_NO_VISIBLE )
return;
......
......@@ -125,7 +125,7 @@ void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffs
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( m_Layer );
color = GetLayerColor( m_Layer );
GRSetDrawMode( aDC, aDrawMode );
......@@ -242,6 +242,6 @@ bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const
void SCH_JUNCTION::Plot( PLOTTER* aPlotter )
{
aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
aPlotter->SetColor( GetLayerColor( GetLayer() ) );
aPlotter->Circle( m_pos, m_size.x, FILLED_SHAPE );
}
......@@ -224,7 +224,7 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( m_Layer );
color = GetLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
......@@ -596,7 +596,7 @@ bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const
void SCH_LINE::Plot( PLOTTER* aPlotter )
{
aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
aPlotter->SetColor( GetLayerColor( GetLayer() ) );
aPlotter->SetCurrentLineWidth( GetPenSize() );
if( m_Layer == LAYER_NOTES )
......
......@@ -111,8 +111,8 @@ void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( GetMarkerType() == MARK_ERC )
{
color = ( GetErrorLevel() == WAR ) ? ReturnLayerColor( LAYER_ERC_WARN ) :
ReturnLayerColor( LAYER_ERC_ERR );
color = ( GetErrorLevel() == WAR ) ? GetLayerColor( LAYER_ERC_WARN ) :
GetLayerColor( LAYER_ERC_ERR );
}
if( aColor < 0 )
......
......@@ -136,7 +136,7 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( LAYER_NOCONNECT );
color = GetLayerColor( LAYER_NOCONNECT );
GRSetDrawMode( aDC, aDrawMode );
......@@ -243,7 +243,7 @@ void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter )
pY = m_pos.y;
aPlotter->SetCurrentLineWidth( GetPenSize() );
aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
aPlotter->SetColor( GetLayerColor( GetLayer() ) );
aPlotter->MoveTo( wxPoint( pX - delta, pY - delta ) );
aPlotter->FinishTo( wxPoint( pX + delta, pY + delta ) );
aPlotter->MoveTo( wxPoint( pX + delta, pY - delta ) );
......
......@@ -577,7 +577,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aColor >= 0 )
color = aColor;
else
color = ReturnLayerColor( m_Layer );
color = GetLayerColor( m_Layer );
GRSetDrawMode( aDC, aDrawMode );
......@@ -596,7 +596,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aColor > 0 )
txtcolor = aColor;
else
txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
txtcolor = GetLayerColor( LAYER_SHEETNAME );
Text = wxT( "Sheet: " ) + m_name;
DrawGraphicText( aPanel, aDC, pos_sheetname,
......@@ -609,7 +609,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aColor >= 0 )
txtcolor = aColor;
else
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
txtcolor = GetLayerColor( LAYER_SHEETFILENAME );
Text = wxT( "File: " ) + m_fileName;
DrawGraphicText( aPanel, aDC, pos_filename,
......@@ -1106,7 +1106,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
wxPoint pos_sheetname, pos_filename;
wxPoint pos;
aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
aPlotter->SetColor( GetLayerColor( GetLayer() ) );
int thickness = GetPenSize();
aPlotter->SetCurrentLineWidth( thickness );
......@@ -1146,7 +1146,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
thickness = GetDefaultLineThickness();
thickness = Clamp_Text_PenSize( thickness, size, false );
aPlotter->SetColor( ReturnLayerColor( LAYER_SHEETNAME ) );
aPlotter->SetColor( GetLayerColor( LAYER_SHEETNAME ) );
bool italic = false;
aPlotter->Text( pos_sheetname, txtcolor, Text, name_orientation, size,
......@@ -1159,13 +1159,13 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
thickness = GetDefaultLineThickness();
thickness = Clamp_Text_PenSize( thickness, size, false );
aPlotter->SetColor( ReturnLayerColor( LAYER_SHEETFILENAME ) );
aPlotter->SetColor( GetLayerColor( LAYER_SHEETFILENAME ) );
aPlotter->Text( pos_filename, txtcolor, Text, name_orientation, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, false );
aPlotter->SetColor( ReturnLayerColor( GetLayer() ) );
aPlotter->SetColor( GetLayerColor( GetLayer() ) );
/* Draw texts : SheetLabel */
for( size_t i = 0; i < m_pins.size(); i++ )
......
......@@ -350,7 +350,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( m_Layer );
color = GetLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
......@@ -657,7 +657,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter )
{
static std::vector <wxPoint> Poly;
EDA_COLOR_T color = ReturnLayerColor( GetLayer() );
EDA_COLOR_T color = GetLayerColor( GetLayer() );
wxPoint textpos = m_Pos + GetSchematicTextOffset();
int thickness = GetPenSize();
......@@ -1276,7 +1276,7 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( m_Layer );
color = GetLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
......@@ -1614,7 +1614,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( m_Layer );
color = GetLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
......
......@@ -328,8 +328,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
if( aDrawMode & GR_HIGHLIGHT )
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
if( color & HIGHLIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
ColorApplyHighlightFlag( &color );
alt_color = gerbFrame->GetNegativeItemsColor();
......
......@@ -91,12 +91,12 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings()
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "DrawModeOption" ),
&m_displayMode, 2, 0, 2 ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
wxT( "DCodeColor" ),
wxT( "DCodeColorEx" ),
&g_ColorsSettings.m_ItemsColors[
DCODES_VISIBLE],
WHITE ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
wxT( "NegativeObjectsColor" ),
wxT( "NegativeObjectsColorEx" ),
&g_ColorsSettings.m_ItemsColors[
NEGATIVE_OBJECTS_VISIBLE],
DARKGRAY ) );
......@@ -122,15 +122,14 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings()
// because the parameter list that use these keywords does not store them,
// just points to them.
static const wxChar* keys[] = {
wxT("ColorLayer_0"), wxT("ColorLayer_1"), wxT("ColorLayer_2"), wxT("ColorLayer_3"),
wxT("ColorLayer_4"), wxT("ColorLayer_5"), wxT("ColorLayer_6"), wxT("ColorLayer_7"),
wxT("ColorLayer_8"), wxT("ColorLayer_9"), wxT("ColorLayer_10"), wxT("ColorLayer_11"),
wxT("ColorLayer_12"), wxT("ColorLayer_13"), wxT("ColorLayer_14"), wxT("ColorLayer_15"),
wxT("ColorLayer_16"), wxT("ColorLayer_17"), wxT("ColorLayer_18"), wxT("ColorLayer_19"),
wxT("ColorLayer_20"), wxT("ColorLayer_21"), wxT("ColorLayer_22"), wxT("ColorLayer_23"),
wxT("ColorLayer_24"), wxT("ColorLayer_25"), wxT("ColorLayer_26"), wxT("ColorLayer_27"),
wxT("ColorLayer_28"), wxT("ColorLayer_29"), wxT("ColorLayer_30"), wxT("ColorLayer_31"),
wxT("ColorLayer0Ex"), wxT("ColorLayer1Ex"), wxT("ColorLayer2Ex"), wxT("ColorLayer3Ex"),
wxT("ColorLayer4Ex"), wxT("ColorLayer5Ex"), wxT("ColorLayer6Ex"), wxT("ColorLayer7Ex"),
wxT("ColorLayer8Ex"), wxT("ColorLayer9Ex"), wxT("ColorLayer10Ex"), wxT("ColorLayer11Ex"),
wxT("ColorLayer12Ex"), wxT("ColorLayer13Ex"), wxT("ColorLayer14Ex"), wxT("ColorLayer15Ex"),
wxT("ColorLayer16Ex"), wxT("ColorLayer17Ex"), wxT("ColorLayer18Ex"), wxT("ColorLayer19Ex"),
wxT("ColorLayer20Ex"), wxT("ColorLayer21Ex"), wxT("ColorLayer22Ex"), wxT("ColorLayer23Ex"),
wxT("ColorLayer24Ex"), wxT("ColorLayer25Ex"), wxT("ColorLayer26Ex"), wxT("ColorLayer27Ex"),
wxT("ColorLayer28Ex"), wxT("ColorLayer29Ex"), wxT("ColorLayer30Ex"), wxT("ColorLayer31Ex"),
};
wxASSERT( DIM(keys) == DIM(color_default) );
......
......@@ -37,25 +37,37 @@ enum EDA_COLOR_T
DARKMAGENTA,
DARKBROWN,
LIGHTYELLOW,
LASTCOLOR,
NBCOLORS, ///< Number of colors
HIGHLIGHT_FLAG = ( 1<<19 ),
NBCOLOR = 24, ///< Number of colors
MASKCOLOR = 31 ///< mask for color index into ColorRefs[]
};
/// Checked cast. Use only when necessary (ex. I/O)
/// Checked cast. Use only when necessary (usually I/O)
inline EDA_COLOR_T ColorFromInt( int aColor )
{
wxASSERT( aColor >= UNSPECIFIED_COLOR && aColor < LASTCOLOR );
wxASSERT( aColor >= UNSPECIFIED_COLOR && aColor < NBCOLORS );
return static_cast<EDA_COLOR_T>( aColor );
}
inline EDA_COLOR_T operator++( EDA_COLOR_T& aColor )
{
// We have to accept NBCOLORS for loop termination conditions
wxASSERT( aColor >= UNSPECIFIED_COLOR && aColor <= NBCOLORS );
aColor = static_cast<EDA_COLOR_T>( int( aColor ) + 1 );
return aColor;
}
/// Return only the plain color part
inline EDA_COLOR_T ColorGetBase( EDA_COLOR_T aColor)
{
return static_cast<EDA_COLOR_T>( aColor & MASKCOLOR );
EDA_COLOR_T base = static_cast<EDA_COLOR_T>( aColor & MASKCOLOR );
return base;
}
/// Mix two colors in some way (hopefully like a logical OR)
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 );
/// Force the color part of a color to darkdarkgray
inline void ColorTurnToDarkDarkGray( EDA_COLOR_T *aColor )
{
......@@ -82,7 +94,6 @@ inline void SetAlpha( EDA_COLOR_T* aColor, unsigned char aBlend )
| ((aBlend & MASKALPHA) << 24));
}
/**
* Function GetAlpha
* returns the alpha blend parameter from a color index.
......@@ -105,8 +116,38 @@ struct StructColors
EDA_COLOR_T m_LightColor;
};
// list of existing Colors:
extern StructColors ColorRefs[NBCOLOR];
/// list of existing Colors
extern const StructColors g_ColorRefs[NBCOLORS];
/// Step a color to the highlighted version if the highlight flag is set
inline void ColorApplyHighlightFlag( EDA_COLOR_T *aColor )
{
EDA_COLOR_T base = ColorGetBase( *aColor );
wxASSERT( base > UNSPECIFIED_COLOR && base < NBCOLORS );
if( *aColor & HIGHLIGHT_FLAG )
*aColor = g_ColorRefs[base].m_LightColor;
}
/// Find a color by name
EDA_COLOR_T ColorByName( const wxChar *aName );
/// Find the nearest color match
EDA_COLOR_T ColorFindNearest( const wxColour &aColor );
inline const wxChar *ColorGetName( EDA_COLOR_T aColor )
{
EDA_COLOR_T base = ColorGetBase( aColor );
wxASSERT( base > UNSPECIFIED_COLOR && base < NBCOLORS );
return g_ColorRefs[base].m_Name;
}
inline void ColorSetBrush( wxBrush *aBrush, EDA_COLOR_T aColor )
{
EDA_COLOR_T base = ColorGetBase( aColor );
wxASSERT( base > UNSPECIFIED_COLOR && base < NBCOLORS );
const StructColors &col = g_ColorRefs[base];
aBrush->SetColour( col.m_Red, col.m_Green, col.m_Blue );
}
/**
* Function MakeColour
......@@ -123,11 +164,12 @@ inline wxColour MakeColour( EDA_COLOR_T aColor )
int alpha = GetAlpha( aColor );
alpha = alpha ? alpha : wxALPHA_OPAQUE;
#endif
int ndx = aColor & MASKCOLOR;
EDA_COLOR_T ndx = ColorGetBase( aColor );
wxASSERT( ndx > UNSPECIFIED_COLOR && ndx < NBCOLORS );
return wxColour( ColorRefs[ndx].m_Red,
ColorRefs[ndx].m_Green,
ColorRefs[ndx].m_Blue
return wxColour( g_ColorRefs[ndx].m_Red,
g_ColorRefs[ndx].m_Green,
g_ColorRefs[ndx].m_Blue
#if wxCHECK_VERSION(2,8,5)
,(unsigned char) alpha
#endif
......
......@@ -134,12 +134,26 @@ inline LAYER_MSK GetLayerMask( LAYER_NUM aLayerNumber )
return 1 << aLayerNumber;
}
/**
* Count the number of set layers in the mask
*/
inline int LayerMaskCountSet( LAYER_MSK aMask )
{
int count = 0;
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{
if( aMask & GetLayerMask( i ) )
++count;
}
return count;
}
// layers order in dialogs (plot, print and toolbars)
// in same order than in setup layers dialog
// (Front or Top to Back or Bottom)
#define DECLARE_LAYERS_ORDER_LIST(list) LAYER_NUM list[NB_LAYERS] =\
#define DECLARE_LAYERS_ORDER_LIST(list) const LAYER_NUM list[NB_LAYERS] =\
{ LAYER_N_FRONT,\
LAYER_N_15, LAYER_N_14, LAYER_N_13, LAYER_N_12,\
LAYER_N_11, LAYER_N_10, LAYER_N_9, LAYER_N_8,\
......@@ -223,4 +237,39 @@ inline bool IsValidNonCopperLayerIndex( LAYER_NUM aLayerIndex )
&& aLayerIndex <= LAST_NON_COPPER_LAYER;
}
/* IMPORTANT: If a layer is not a front layer not necessarily is true
the converse. The same hold for a back layer.
So a layer can be:
- Front
- Back
- Neither (internal or auxiliary)
The check most frequent is for back layers, since it involves flips */
/**
* Layer classification: check if it's a front layer
*/
inline bool IsFrontLayer( LAYER_NUM aLayer )
{
return ( aLayer == LAYER_N_FRONT ||
aLayer == ADHESIVE_N_FRONT ||
aLayer == SOLDERPASTE_N_FRONT ||
aLayer == SILKSCREEN_N_FRONT ||
aLayer == SOLDERPASTE_N_FRONT );
}
/**
* Layer classification: check if it's a back layer
*/
inline bool IsBackLayer( LAYER_NUM aLayer )
{
return ( aLayer == LAYER_N_BACK ||
aLayer == ADHESIVE_N_BACK ||
aLayer == SOLDERPASTE_N_BACK ||
aLayer == SILKSCREEN_N_BACK ||
aLayer == SOLDERPASTE_N_BACK );
}
#endif // _LAYERS_ID_AND_VISIBILITY_H_
......@@ -895,7 +895,7 @@ public:
protected:
bool textAsLines;
int currentColor;
EDA_COLOR_T m_currentColor;
};
class TITLE_BLOCK;
......
......@@ -34,6 +34,7 @@
#include <base_struct.h>
#include <layers_id_colors_and_visibility.h>
class BOARD;
......@@ -208,7 +209,7 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
/* Same as above, but the rectangle is inclined angle angle. */
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
int angle, int masque_layer, int color, int op_logic );
int angle, LAYER_MSK masque_layer, int color, int op_logic );
/* QUEUE.CPP */
void FreeQueue();
......
......@@ -43,32 +43,32 @@
#include <autorout.h>
#include <cell.h>
void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color );
void TracePcbLine( int x0, int y0, int x1, int y1, LAYER_NUM layer, int color );
void TraceArc( int ux0, int uy0,
int ux1, int uy1,
int ArcAngle,
int lg, int layer, int color,
int lg, LAYER_NUM layer, int color,
int op_logic );
static void DrawSegmentQcq( int ux0, int uy0,
int ux1, int uy1,
int lg, int layer, int color,
int lg, LAYER_NUM layer, int color,
int op_logic );
static void TraceFilledCircle( int cx, int cy, int radius,
int aLayerMask,
LAYER_MSK aLayerMask,
int color,
int op_logic );
static void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
static void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer,
int color, int op_logic );
// Macro call to update cell.
#define OP_CELL( layer, dy, dx ) \
{ \
if( layer < 0 ) \
if( layer == UNDEFINED_LAYER ) \
{ \
RoutingMatrix.WriteCell( dy, dx, BOTTOM, color ); \
if( RoutingMatrix.m_RoutingLayersCount > 1 ) \
......@@ -140,7 +140,7 @@ void PlacePad( D_PAD* aPad, int color, int marge, int op_logic )
* op_logic: type of writing in the cell (WRITE, OR)
*/
void TraceFilledCircle( int cx, int cy, int radius,
int aLayerMask,
LAYER_MSK aLayerMask,
int color,
int op_logic )
{
......@@ -273,32 +273,32 @@ void TraceSegmentPcb( TRACK* pt_segm, int color, int marge, int op_logic )
// Test if VIA (filled circle was drawn)
if( pt_segm->Type() == PCB_VIA_T )
{
int mask_layer = 0;
LAYER_MSK layer_mask = NO_LAYERS;
if( pt_segm->IsOnLayer( g_Route_Layer_BOTTOM ) )
mask_layer = 1 << g_Route_Layer_BOTTOM;
layer_mask = GetLayerMask( g_Route_Layer_BOTTOM );
if( pt_segm->IsOnLayer( g_Route_Layer_TOP ) )
{
if( mask_layer == 0 )
mask_layer = 1 << g_Route_Layer_TOP;
if( layer_mask == 0 )
layer_mask = GetLayerMask( g_Route_Layer_TOP );
else
mask_layer = -1;
layer_mask = FULL_LAYERS;
}
if( color == VIA_IMPOSSIBLE )
mask_layer = -1;
layer_mask = FULL_LAYERS;
if( mask_layer )
if( layer_mask )
TraceFilledCircle( pt_segm->GetStart().x, pt_segm->GetStart().y,
half_width, mask_layer, color, op_logic );
half_width, layer_mask, color, op_logic );
return;
}
int layer = pt_segm->GetLayer();
LAYER_NUM layer = pt_segm->GetLayer();
if( color == VIA_IMPOSSIBLE )
layer = -1;
layer = UNDEFINED_LAYER;
// The segment is here a straight line or a circle or an arc.:
if( pt_segm->GetShape() == S_CIRCLE )
......@@ -328,7 +328,7 @@ void TraceSegmentPcb( TRACK* pt_segm, int color, int marge, int op_logic )
/* Draws a line, if layer = -1 on all layers
*/
void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_logic )
void TracePcbLine( int x0, int y0, int x1, int y1, LAYER_NUM layer, int color, int op_logic )
{
int dx, dy, lim;
int cumul, inc, il, delta;
......@@ -531,7 +531,7 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
int angle, int aLayerMask, int color, int op_logic )
int angle, LAYER_MSK aLayerMask, int color, int op_logic )
{
int row, col;
int cx, cy; // Center of rectangle
......@@ -623,7 +623,7 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
* half-width = lg, org = ux0,uy0 end = ux1,uy1
* coordinates are in PCB units
*/
void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer,
int color, int op_logic )
{
int row, col;
......@@ -749,7 +749,7 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
* half-width = lg, center = ux0, uy0, ux1,uy1 is a point on the circle.
* coord are in PCB units.
*/
void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, LAYER_NUM layer,
int color, int op_logic )
{
int radius, nb_segm;
......@@ -794,7 +794,7 @@ void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
* PCB units.
*/
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg,
int layer, int color, int op_logic )
LAYER_NUM layer, int color, int op_logic )
{
int radius, nb_segm;
int x0, y0, // Starting point of the current segment trace
......
......@@ -198,7 +198,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
{
int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy;
int marge, via_marge;
int layerMask;
LAYER_MSK layerMask;
// use the default NETCLASS?
NETCLASS* nc = aPcb->m_NetClasses.GetDefault();
......
......@@ -138,7 +138,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
else
drawInfo.m_ShowPadFilled = false;
EDA_COLOR_T color = ColorFromInt(0); // XXX EVIL (it will be ORed later)
EDA_COLOR_T color = BLACK;
if( m_layerMask & LAYER_FRONT )
{
color = brd->GetVisibleElementColor( PAD_FR_VISIBLE );
......@@ -146,13 +146,12 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
if( m_layerMask & LAYER_BACK )
{
// XXX EVIL merge
color = ColorFromInt( color | brd->GetVisibleElementColor( PAD_BK_VISIBLE ) );
color = ColorMix( color, brd->GetVisibleElementColor( PAD_BK_VISIBLE ) );
}
if( color == 0 ) // Not on a visible copper layer XXX EVIL check
if( color == BLACK ) // Not on a visible copper layer (i.e. still nothing to show)
{
// If the pad in on only one tech layer, use the layer color else use DARKGRAY
// If the pad is on only one tech layer, use the layer color else use DARKGRAY
int mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS;
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
mask_non_copper_layers &= brd->GetVisibleLayers();
......@@ -328,8 +327,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
if( aDraw_mode & GR_HIGHLIGHT )
ColorChangeHighlightFlag( &color, !(aDraw_mode & GR_AND) );
if( color & HIGHLIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
ColorApplyHighlightFlag( &color );
bool DisplayIsol = DisplayOpt.DisplayPadIsol;
......@@ -362,7 +360,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
drawInfo.m_Display_netname = false;
// Display net names is restricted to pads that are on the active layer
// in hight contrast mode display
// in high contrast mode display
if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
!IsOnLayer( screen->m_Active_Layer ) && DisplayOpt.ContrastModeDisplay )
drawInfo.m_Display_netname = false;
......
......@@ -180,7 +180,7 @@ wxString TEXTE_PCB::GetSelectMenuText() const
if( m_Text.Len() < 12 )
shorttxt << m_Text;
else
shorttxt += m_Text.Left( 10 ) + wxT( ".." );
shorttxt += m_Text.Left( 10 ) + wxT( "..." );
text.Printf( _( "Pcb Text %s on %s"),
GetChars ( shorttxt ), GetChars( GetLayerName() ) );
......
......@@ -614,8 +614,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( draw_mode & GR_HIGHLIGHT )
ColorChangeHighlightFlag( &color, !(draw_mode & GR_AND) );
if( color & HIGHLIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
ColorApplyHighlightFlag( &color );
SetAlpha( &color, 150 );
......@@ -780,8 +779,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( draw_mode & GR_HIGHLIGHT )
ColorChangeHighlightFlag( &color, !(draw_mode & GR_AND) );
if( color & HIGHLIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
ColorApplyHighlightFlag( &color );
SetAlpha( &color, 150 );
......
......@@ -189,8 +189,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod
if( aDrawMode & GR_HIGHLIGHT )
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
if( color & HIGHLIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
ColorApplyHighlightFlag( &color );
SetAlpha( &color, 150 );
......@@ -272,8 +271,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
if( aDrawMode & GR_HIGHLIGHT )
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
if( color & HIGHLIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
ColorApplyHighlightFlag( &color );
SetAlpha( &color, 150 );
......
......@@ -163,7 +163,7 @@ void DIALOG_PLOT::Init_Dialog()
m_layerList.push_back( layer );
checkIndex = m_layerCheckListBox->Append( m_board->GetLayerName( layer ) );
if( m_plotOpts.GetLayerSelection() & ( 1 << layer ) )
if( m_plotOpts.GetLayerSelection() & GetLayerMask( layer ) )
m_layerCheckListBox->Check( checkIndex );
}
......@@ -241,7 +241,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
case ID_LAYER_FAB: // Select layers usually neede d to build a board
for( i = 0; i < m_layerList.size(); i++ )
{
long layermask = 1 << m_layerList[ i ];
LAYER_MSK layermask = GetLayerMask( m_layerList[ i ] );
if( ( layermask &
( ALL_CU_LAYERS | SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT |
SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT |
......@@ -675,7 +675,7 @@ void DIALOG_PLOT::applyPlotSettings()
for( i = 0; i < m_layerList.size(); i++ )
{
if( m_layerCheckListBox->IsChecked( i ) )
selectedLayers |= (1 << m_layerList[i]);
selectedLayers |= GetLayerMask( m_layerList[i] );
}
tempOptions.SetLayerSelection( selectedLayers );
......
......@@ -43,7 +43,7 @@ private:
BOARD* m_board;
BOARD_DESIGN_SETTINGS m_brdSettings;
wxConfig* m_config;
std::vector<int> m_layerList; // List to hold CheckListBox layer numbers
std::vector<LAYER_NUM> m_layerList; // List to hold CheckListBox layer numbers
double m_XScaleAdjust; // X scale factor adjust to compensate
// plotter X scaling error
double m_YScaleAdjust; // X scale factor adjust to compensate
......
......@@ -28,7 +28,7 @@
extern int g_DrawDefaultLineThickness;
// Local variables
static long s_SelectedLayers;
static LAYER_MSK s_SelectedLayers;
static double s_ScaleList[] =
{ 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 };
......@@ -144,7 +144,6 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( PCB_EDIT_FRAME* parent )
void DIALOG_PRINT_USING_PRINTER::InitValues( )
{
LAYER_NUM layer_max = NB_PCB_LAYERS;
wxString msg;
BOARD* board = m_parent->GetBoard();
......@@ -189,7 +188,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_BoxSelectLayer[layer]->SetValue( option );
else
{
long mask = 1 << layer;
LAYER_MSK mask = GetLayerMask( layer );
if( mask & s_SelectedLayers )
m_BoxSelectLayer[layer]->SetValue( true );
}
......@@ -220,8 +219,8 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
s_Parameters.m_YScaleAdjust > MAX_SCALE )
s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0;
s_SelectedLayers = 0;
for( int layer = 0; layer<layer_max; ++layer )
s_SelectedLayers = NO_LAYERS;
for( LAYER_NUM layer = FIRST_LAYER; layer< NB_PCB_LAYERS; ++layer )
{
if( m_BoxSelectLayer[layer] == NULL )
continue;
......@@ -236,7 +235,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
{
m_BoxSelectLayer[layer]->SetValue( option );
if( option )
s_SelectedLayers |= 1 << layer;
s_SelectedLayers |= GetLayerMask( layer );
}
}
}
......
......@@ -273,19 +273,19 @@ static void write_triangle_bag( FILE* output_file, int color_index, //{{{
case 1: // Material marker
fprintf( output_file,
" diffuseColor %g %g %g\n",
(double) ColorRefs[color_index].m_Red / 255.0,
(double) ColorRefs[color_index].m_Green / 255.0,
(double) ColorRefs[color_index].m_Blue / 255.0 );
(double) g_ColorRefs[color_index].m_Red / 255.0,
(double) g_ColorRefs[color_index].m_Green / 255.0,
(double) g_ColorRefs[color_index].m_Blue / 255.0 );
fprintf( output_file,
" specularColor %g %g %g\n",
(double) ColorRefs[color_index].m_Red / 255.0,
(double) ColorRefs[color_index].m_Green / 255.0,
(double) ColorRefs[color_index].m_Blue / 255.0 );
(double) g_ColorRefs[color_index].m_Red / 255.0,
(double) g_ColorRefs[color_index].m_Green / 255.0,
(double) g_ColorRefs[color_index].m_Blue / 255.0 );
fprintf( output_file,
" emissiveColor %g %g %g\n",
(double) ColorRefs[color_index].m_Red / 255.0,
(double) ColorRefs[color_index].m_Green / 255.0,
(double) ColorRefs[color_index].m_Blue / 255.0 );
(double) g_ColorRefs[color_index].m_Red / 255.0,
(double) g_ColorRefs[color_index].m_Green / 255.0,
(double) g_ColorRefs[color_index].m_Blue / 255.0 );
break;
case 2:
......
......@@ -424,12 +424,10 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
// Layers.
m_out->Print( aNestLevel, "(layers\n" );
unsigned mask = LAYER_FRONT;
LAYER_NUM layer = LAYER_N_FRONT;
// Save only the used copper layers from front to back.
while( mask != 0 )
for( LAYER_NUM layer = LAST_COPPER_LAYER; layer >= FIRST_COPPER_LAYER; --layer)
{
LAYER_MSK mask = GetLayerMask( layer );
if( mask & aBoard->GetEnabledLayers() )
{
m_out->Print( aNestLevel+1, "(%d %s %s", layer,
......@@ -441,17 +439,12 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( 0, ")\n" );
}
mask >>= 1;
--layer;
}
mask = ADHESIVE_LAYER_BACK;
layer = ADHESIVE_N_BACK;
// Save used non-copper layers in the order they are defined.
while( layer < NB_LAYERS )
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; ++layer)
{
LAYER_MSK mask = GetLayerMask( layer );
if( mask & aBoard->GetEnabledLayers() )
{
m_out->Print( aNestLevel+1, "(%d %s user", layer,
......@@ -462,9 +455,6 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( 0, ")\n" );
}
mask <<= 1;
++layer;
}
m_out->Print( aNestLevel, ")\n\n" );
......@@ -1029,16 +1019,14 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const
// output any individual layers not handled in wildcard combos above
unsigned layerMask = aLayerMask;
if( m_board )
layerMask &= m_board->GetEnabledLayers();
aLayerMask &= m_board->GetEnabledLayers();
wxString layerName;
for( LAYER_NUM layer = FIRST_LAYER; layerMask; ++layer, layerMask >>= 1 )
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{
if( layerMask & 1 )
if( aLayerMask & GetLayerMask( layer ) )
{
if( m_board && !(m_ctl & CTL_STD_LAYER_NAMES) )
layerName = m_board->GetLayerName( layer );
......
......@@ -434,18 +434,9 @@ void LEGACY_PLUGIN::loadGENERAL()
else if( TESTLINE( "Ly" ) ) // Old format for Layer count
{
int layer_mask = hexParse( line + SZ( "Ly" ) );
int layer_count = 0;
LAYER_MSK layer_mask = hexParse( line + SZ( "Ly" ) );
for( LAYER_NUM ii = FIRST_COPPER_LAYER;
ii < NB_COPPER_LAYERS && layer_mask;
++ii, layer_mask >>= 1 )
{
if( layer_mask & 1 )
layer_count++;
}
m_board->SetCopperLayerCount( layer_count );
m_board->SetCopperLayerCount( LayerMaskCountSet( layer_mask & ALL_CU_LAYERS ) );
}
else if( TESTLINE( "BoardThickness" ) )
......@@ -1550,6 +1541,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText )
// after switching to strtok, there's no easy coming back because of the
// embedded nul(s?) placed to the right of the current field.
// (that's the reason why strtok was deprecated...)
char* mirror = strtok( (char*) data, delims );
char* hide = strtok( NULL, delims );
char* tmp = strtok( NULL, delims );
......@@ -2984,9 +2976,9 @@ void LEGACY_PLUGIN::saveSETUP( const BOARD* aBoard ) const
unsigned layerMask = ALL_CU_LAYERS & aBoard->GetEnabledLayers();
for( LAYER_NUM layer = FIRST_LAYER; layerMask; ++layer, layerMask >>= 1 )
for( LAYER_NUM layer = FIRST_LAYER; layer <= LAST_COPPER_LAYER; ++layer )
{
if( layerMask & 1 )
if( layerMask & GetLayerMask( layer ) )
{
fprintf( m_fp, "Layer[%d] %s %s\n", layer,
TO_UTF8( aBoard->GetLayerName( layer ) ),
......
This diff is collapsed.
......@@ -90,9 +90,9 @@ BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aP
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
{
#ifdef PCBNEW
int layers_count = NB_PCB_LAYERS;
LAYER_NUM layers_count = NB_PCB_LAYERS;
#else
int layers_count = NB_LAYERS;
LAYER_NUM layers_count = NB_LAYERS;
#endif
LAYER_MSK mask_layer = m_PrintParams.m_PrintMaskLayer;
......@@ -100,10 +100,12 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
// compute layer mask from page number if we want one page per layer
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
{
int ii, jj, mask = 1;
int jj;
LAYER_NUM ii;
for( ii = 0, jj = 0; ii < layers_count; ii++ )
for( ii = FIRST_LAYER, jj = 0; ii < layers_count; ++ii )
{
LAYER_MSK mask = GetLayerMask( ii );
if( mask_layer & mask )
jj++;
......@@ -112,8 +114,6 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
m_PrintParams.m_PrintMaskLayer = mask;
break;
}
mask <<= 1;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment