From d12a45923b3ebf7fe73a252040ba18ead16f762b Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Thu, 4 Apr 2013 23:35:01 +0200 Subject: [PATCH] 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 --- 3d-viewer/3d_draw.cpp | 14 +-- 3d-viewer/3d_draw_basic_functions.cpp | 4 +- common/common.cpp | 4 +- common/common_plotDXF_functions.cpp | 23 ++-- common/common_plotPS_functions.cpp | 6 +- common/drawframe.cpp | 4 +- common/gr_basic.cpp | 100 ++++++++++++++++++ common/msgpanel.cpp | 4 +- common/projet_config.cpp | 8 +- common/selcolor.cpp | 14 ++- eeschema/bus-wire-junction.cpp | 2 +- eeschema/class_libentry.cpp | 2 +- eeschema/dialogs/dialog_color_config.cpp | 17 ++- eeschema/eeschema_config.cpp | 54 +++++----- eeschema/general.h | 2 +- eeschema/lib_arc.cpp | 10 +- eeschema/lib_bezier.cpp | 10 +- eeschema/lib_circle.cpp | 10 +- eeschema/lib_draw_item.cpp | 2 +- eeschema/lib_field.cpp | 6 +- eeschema/lib_pin.cpp | 12 +-- eeschema/lib_polyline.cpp | 10 +- eeschema/lib_rectangle.cpp | 10 +- eeschema/protos.h | 6 -- eeschema/sch_bitmap.cpp | 2 +- eeschema/sch_bus_entry.cpp | 4 +- eeschema/sch_field.cpp | 8 +- eeschema/sch_junction.cpp | 4 +- eeschema/sch_line.cpp | 4 +- eeschema/sch_marker.cpp | 4 +- eeschema/sch_no_connect.cpp | 4 +- eeschema/sch_sheet.cpp | 14 +-- eeschema/sch_text.cpp | 8 +- gerbview/class_gerber_draw_item.cpp | 3 +- gerbview/gerbview_config.cpp | 21 ++-- include/colors.h | 66 +++++++++--- include/layers_id_colors_and_visibility.h | 51 ++++++++- include/param_config.h | 2 +- include/plot_common.h | 2 +- pcbnew/autorouter/autorout.h | 3 +- pcbnew/autorouter/graphpcb.cpp | 44 ++++---- pcbnew/autorouter/routing_matrix.cpp | 2 +- pcbnew/class_pad_draw_functions.cpp | 14 ++- pcbnew/class_pcb_text.cpp | 2 +- pcbnew/class_track.cpp | 6 +- pcbnew/class_zone.cpp | 6 +- pcbnew/dialogs/dialog_plot.cpp | 6 +- pcbnew/dialogs/dialog_plot.h | 2 +- pcbnew/dialogs/dialog_print_using_printer.cpp | 11 +- pcbnew/export_vrml.cpp | 18 ++-- pcbnew/kicad_plugin.cpp | 26 ++--- pcbnew/legacy_plugin.cpp | 18 +--- pcbnew/pcbnew_config.cpp | 84 +++++++-------- pcbnew/printout_controler.cpp | 12 +-- 54 files changed, 464 insertions(+), 321 deletions(-) diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index d2ad04e200..56c17fac04 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -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 ); diff --git a/3d-viewer/3d_draw_basic_functions.cpp b/3d-viewer/3d_draw_basic_functions.cpp index 06fbd76100..e8cd9a2b61 100644 --- a/3d-viewer/3d_draw_basic_functions.cpp +++ b/3d-viewer/3d_draw_basic_functions.cpp @@ -122,10 +122,10 @@ static void Draw3D_VerticalPolygonalCylinder( const std::vector& 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; diff --git a/common/common.cpp b/common/common.cpp index b67dc35e68..6ce54a387d 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -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 }, diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index 09b07f5f19..88dc4d6013 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -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 ) diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index 2a012a9f06..43a8a27a90 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -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 diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 5c08e7ffe6..9ce99459b2 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -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 ) ); } diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 9706ad5016..eb38f55cd7 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -1451,3 +1451,103 @@ void GRBezier( EDA_RECT* ClipBox, std::vector 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; +} diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp index 7aeebbbb52..2ec882c3e8 100644 --- a/common/msgpanel.cpp +++ b/common/msgpanel.cpp @@ -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() ) diff --git a/common/projet_config.cpp b/common/projet_config.cpp index 5ebb436256..2a488b8aa0 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -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 ) ); } diff --git a/common/selcolor.cpp b/common/selcolor.cpp index f4b395bf09..13dec6c276 100644 --- a/common/selcolor.cpp +++ b/common/selcolor.cpp @@ -54,7 +54,7 @@ EDA_COLOR_T DisplayColorFrame( wxWindow* parent, int OldColor ) framepos, OldColor ); color = static_cast( 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 | diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 1072491a17..a2440f0800 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -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 ) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 3d2341d565..a525245cfe 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -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 ); diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp index 57ec480a0a..e28842b048 100644 --- a/eeschema/dialogs/dialog_color_config.cpp +++ b/eeschema/dialogs/dialog_color_config.cpp @@ -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; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 1ec9a4e2fa..438d57c597 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -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 ) ); diff --git a/eeschema/general.h b/eeschema/general.h index 16ee83ea5e..ddf0d5373b 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -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(); diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 2107bc715e..bc219fbb42 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -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 ) { diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 9ef49e9a78..2caa429e01 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -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 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 ); diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 9e957863fc..eba6999410 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -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 diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp index faafab2c1b..14c26e191e 100644 --- a/eeschema/lib_draw_item.cpp +++ b/eeschema/lib_draw_item.cpp @@ -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 ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index b52414e7cb..b4bafcc4f2 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -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; } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index a7e636c020..0861f79762 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -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 ); diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 072fdda345..86807d6b97 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -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 ); diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 019f6f20ec..5ac99ba5a2 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -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 ); diff --git a/eeschema/protos.h b/eeschema/protos.h index e19c93b8d4..47341416b5 100644 --- a/eeschema/protos.h +++ b/eeschema/protos.h @@ -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 */ /***************/ diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 7cce2b7d3b..a69ec64b45 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.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() ); } diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index e792949410..22b9cbde18 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -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() ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 7a86a35a3e..c2691c0780 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -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; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 4e715aa247..b41b28521f 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -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 ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index d1a36da083..c95de0a913 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -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 ) diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index c559c7449c..99af636539 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -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 ) diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index d375f842d1..8225ee6e40 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -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 ) ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 9335ce4eca..a94e7150b2 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -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++ ) diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 3cdf203175..9be8696555 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -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 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 ); diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index 39d8053eab..6020f2139e 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -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(); diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index 6db6f420dd..f3a06de0b2 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -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) ); diff --git a/include/colors.h b/include/colors.h index ee33edc137..feb9575ece 100644 --- a/include/colors.h +++ b/include/colors.h @@ -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( 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( int( aColor ) + 1 ); + return aColor; +} + + /// Return only the plain color part inline EDA_COLOR_T ColorGetBase( EDA_COLOR_T aColor) { - return static_cast( aColor & MASKCOLOR ); + EDA_COLOR_T base = static_cast( 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 diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index acae0e041f..28dacafee3 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -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_ diff --git a/include/param_config.h b/include/param_config.h index 65f8759779..59785fc088 100644 --- a/include/param_config.h +++ b/include/param_config.h @@ -161,7 +161,7 @@ public: public: PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptparam, - EDA_COLOR_T default_val, const wxChar* group = NULL ); + EDA_COLOR_T default_val, const wxChar* group = NULL ); PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, EDA_COLOR_T* ptparam, EDA_COLOR_T default_val, const wxChar* group = NULL ); diff --git a/include/plot_common.h b/include/plot_common.h index 437c676d8d..fce08c366b 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -895,7 +895,7 @@ public: protected: bool textAsLines; - int currentColor; + EDA_COLOR_T m_currentColor; }; class TITLE_BLOCK; diff --git a/pcbnew/autorouter/autorout.h b/pcbnew/autorouter/autorout.h index baa2074c65..b1c4f1ab84 100644 --- a/pcbnew/autorouter/autorout.h +++ b/pcbnew/autorouter/autorout.h @@ -34,6 +34,7 @@ #include +#include 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(); diff --git a/pcbnew/autorouter/graphpcb.cpp b/pcbnew/autorouter/graphpcb.cpp index fab7ca6b2e..d7182012d5 100644 --- a/pcbnew/autorouter/graphpcb.cpp +++ b/pcbnew/autorouter/graphpcb.cpp @@ -43,32 +43,32 @@ #include #include -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 diff --git a/pcbnew/autorouter/routing_matrix.cpp b/pcbnew/autorouter/routing_matrix.cpp index 5ed0f91e4b..48708e1088 100644 --- a/pcbnew/autorouter/routing_matrix.cpp +++ b/pcbnew/autorouter/routing_matrix.cpp @@ -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(); diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 5db58b736f..23c1706f9b 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -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; diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index a92b898a7c..d535f4a414 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -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() ) ); diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 0f8aa12aaa..d8f0cabb72 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -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 ); diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 6b161ad189..7a0fc5816a 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -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 ); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index cdf268ed5a..805bbe34af 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -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 ); diff --git a/pcbnew/dialogs/dialog_plot.h b/pcbnew/dialogs/dialog_plot.h index d9edce8ca4..14bb893fcc 100644 --- a/pcbnew/dialogs/dialog_plot.h +++ b/pcbnew/dialogs/dialog_plot.h @@ -43,7 +43,7 @@ private: BOARD* m_board; BOARD_DESIGN_SETTINGS m_brdSettings; wxConfig* m_config; - std::vector m_layerList; // List to hold CheckListBox layer numbers + std::vector 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 diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp index 21afdf456c..990a6c706c 100644 --- a/pcbnew/dialogs/dialog_print_using_printer.cpp +++ b/pcbnew/dialogs/dialog_print_using_printer.cpp @@ -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; layerSetValue( option ); if( option ) - s_SelectedLayers |= 1 << layer; + s_SelectedLayers |= GetLayerMask( layer ); } } } diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index 99e4e006d5..27948adb86 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -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: diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index d9c5ee4c49..e1950d7c57 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -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 ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 29669bec82..edbf0bc346 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -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 ) ), diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 358c0e89fa..b1289ecfda 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -351,95 +351,95 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() &DisplayOpt.DisplayZonesMode, 0, 0, 2 ) ); // Colors: - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay0" ), LOC_COLOR( 0 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer0Ex" ), LOC_COLOR( 0 ), GREEN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay1" ), LOC_COLOR( 1 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer1Ex" ), LOC_COLOR( 1 ), BLUE ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay2" ), LOC_COLOR( 2 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer2Ex" ), LOC_COLOR( 2 ), LIGHTGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay3" ), LOC_COLOR( 3 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer3Ex" ), LOC_COLOR( 3 ), MAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay4" ), LOC_COLOR( 4 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer4Ex" ), LOC_COLOR( 4 ), RED ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay5" ), LOC_COLOR( 5 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer5Ex" ), LOC_COLOR( 5 ), MAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay6" ), LOC_COLOR( 6 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer6Ex" ), LOC_COLOR( 6 ), BROWN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay7" ), LOC_COLOR( 7 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer7Ex" ), LOC_COLOR( 7 ), MAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay8" ), LOC_COLOR( 8 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer8Ex" ), LOC_COLOR( 8 ), LIGHTGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay9" ), LOC_COLOR( 9 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer9Ex" ), LOC_COLOR( 9 ), BLUE ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayA" ), LOC_COLOR( 10 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer10Ex" ), LOC_COLOR( 10 ), GREEN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayB" ), LOC_COLOR( 11 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer11Ex" ), LOC_COLOR( 11 ), CYAN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayC" ), LOC_COLOR( 12 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer12Ex" ), LOC_COLOR( 12 ), LIGHTRED ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayD" ), LOC_COLOR( 13 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer13Ex" ), LOC_COLOR( 13 ), LIGHTMAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayE" ), LOC_COLOR( 14 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer14Ex" ), LOC_COLOR( 14 ), YELLOW ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayF" ), LOC_COLOR( 15 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer15Ex" ), LOC_COLOR( 15 ), RED ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayG" ), LOC_COLOR( 16 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer16Ex" ), LOC_COLOR( 16 ), BLUE ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayH" ), LOC_COLOR( 17 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer17Ex" ), LOC_COLOR( 17 ), MAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayI" ), LOC_COLOR( 18 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer18Ex" ), LOC_COLOR( 18 ), LIGHTCYAN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayJ" ), LOC_COLOR( 19 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer19Ex" ), LOC_COLOR( 19 ), RED ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayK" ), LOC_COLOR( 20 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer20Ex" ), LOC_COLOR( 20 ), MAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayL" ), LOC_COLOR( 21 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer21Ex" ), LOC_COLOR( 21 ), CYAN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayM" ), LOC_COLOR( 22 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer22Ex" ), LOC_COLOR( 22 ), BROWN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayN" ), LOC_COLOR( 23 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer23Ex" ), LOC_COLOR( 23 ), MAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayO" ), LOC_COLOR( 24 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer24Ex" ), LOC_COLOR( 24 ), LIGHTGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayP" ), LOC_COLOR( 25 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer25Ex" ), LOC_COLOR( 25 ), BLUE ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayQ" ), LOC_COLOR( 26 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer26Ex" ), LOC_COLOR( 26 ), GREEN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayR" ), LOC_COLOR( 27 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer27Ex" ), LOC_COLOR( 27 ), YELLOW ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayS" ), LOC_COLOR( 28 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer28Ex" ), LOC_COLOR( 28 ), YELLOW ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayT" ), LOC_COLOR( 29 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer29Ex" ), LOC_COLOR( 29 ), LIGHTMAGENTA ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayU" ), LOC_COLOR( 30 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer30Ex" ), LOC_COLOR( 30 ), YELLOW ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLayV" ), LOC_COLOR( 31 ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLayer31Ex" ), LOC_COLOR( 31 ), LIGHTGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CTxtMoC" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorTxtFrontEx" ), ITEM_COLOR( MOD_TEXT_FR_VISIBLE ), LIGHTGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CTxtMoS" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorTxtBackEx" ), ITEM_COLOR( MOD_TEXT_BK_VISIBLE ), BLUE ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CTxtVis" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorTxtInvisEx" ), ITEM_COLOR( MOD_TEXT_INVISIBLE ), DARKGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CAncreM" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorAnchorEx" ), ITEM_COLOR( ANCHOR_VISIBLE ), BLUE ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CoPadCu" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPadBackEx" ), ITEM_COLOR( PAD_BK_VISIBLE ), GREEN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CoPadCm" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPadFrontEx" ), ITEM_COLOR( PAD_FR_VISIBLE ), RED ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CoViaTh" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorViaThruEx" ), ITEM_COLOR( VIA_THROUGH_VISIBLE ), LIGHTGRAY ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CoViaBu" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorViaBBlindEx" ), ITEM_COLOR( VIA_BBLIND_VISIBLE ), BROWN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CoViaMi" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorViaMicroEx" ), ITEM_COLOR( VIA_MICROVIA_VISIBLE ), CYAN ) ); - m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "CoRatsN" ), + m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorRatsEx" ), ITEM_COLOR( RATSNEST_VISIBLE ), WHITE ) ); diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 44eea74cc9..514d578f5e 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -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; } }