From 739238659e52832af73055caaf87605cbe31f45f Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Sat, 6 Apr 2013 07:01:48 +0200 Subject: [PATCH] Cleanup of the eeschema 'layers' i.e. entitity colours. This also fixes the spurious warning about stuff that couldn't be seen when changing colours. NOTE that the 'net name' layer is present and configurable but non used anywhere! --- common/sch_item_struct.cpp | 2 +- eeschema/dialogs/dialog_color_config.cpp | 7 ++++--- eeschema/eeschema.cpp | 2 +- eeschema/eeschema_config.cpp | 9 +++------ eeschema/general.h | 20 ++++++++++---------- eeschema/sch_component.cpp | 4 ++-- eeschema/sch_screen.cpp | 2 +- include/class_bitmap_base.h | 2 +- include/sch_item_struct.h | 7 ++++--- polygon/PolyLine.cpp | 8 ++++---- 10 files changed, 31 insertions(+), 32 deletions(-) diff --git a/common/sch_item_struct.cpp b/common/sch_item_struct.cpp index 65a2fba58b..a0be20a0db 100644 --- a/common/sch_item_struct.cpp +++ b/common/sch_item_struct.cpp @@ -58,7 +58,7 @@ bool sort_schematic_items( const SCH_ITEM* aItem1, const SCH_ITEM* aItem2 ) SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) : EDA_ITEM( aParent, aType ) { - m_Layer = 0; + m_Layer = LAYER_WIRE; // It's only a default, in fact } diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp index e28842b048..baee49f6d3 100644 --- a/eeschema/dialogs/dialog_color_config.cpp +++ b/eeschema/dialogs/dialog_color_config.cpp @@ -67,7 +67,7 @@ static ButtonIndex buttonGroups[] = { }; -static EDA_COLOR_T currentColors[ MAX_LAYER ]; +static EDA_COLOR_T currentColors[ NB_SCH_LAYERS ]; IMPLEMENT_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG, wxDialog ) @@ -167,7 +167,8 @@ void DIALOG_COLOR_CONFIG::CreateControls() wxBitmap bitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); iconDC.SelectObject( bitmap ); - EDA_COLOR_T color = currentColors[ buttons->m_Layer ] = GetLayerColor( buttons->m_Layer ); + EDA_COLOR_T color = GetLayerColor( LayerNumber( buttons->m_Layer ) ); + currentColors[ buttons->m_Layer ] = color; iconDC.SetPen( *wxBLACK_PEN ); wxBrush brush; ColorSetBrush( &brush, color ); @@ -286,7 +287,7 @@ bool DIALOG_COLOR_CONFIG::UpdateColorsSettings() bool warning = false; - for( LAYER_NUM ii = FIRST_LAYER; ii < MAX_LAYERS; ++ii ) + for( LayerNumber ii = LAYER_WIRE; ii < NB_SCH_LAYERS; ++ii ) { SetLayerColor( currentColors[ ii ], ii ); diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 464c0451d1..2512d3cbd1 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -118,7 +118,7 @@ bool EDA_APP::OnInit() // Give a default colour for all layers // (actual color will beinitialized by config) - for( int ii = 0; ii < MAX_LAYERS; ii++ ) + for( int ii = 0; ii < NB_SCH_LAYERS; ii++ ) SetLayerColor( DARKGRAY, ii ); // read current setup and reopen last directory if no filename to open in diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 438d57c597..d6d9348073 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -53,7 +53,7 @@ #define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings. -static EDA_COLOR_T s_layerColor[MAX_LAYERS]; +static EDA_COLOR_T s_layerColor[NB_SCH_LAYERS]; // The width to draw busses that do not have a specific width static int s_defaultBusThickness; @@ -65,7 +65,7 @@ int GetDefaultBusThickness() void SetDefaultBusThickness( int aThickness) { - if( aThickness >=1 ) + if( aThickness >= 1 ) s_defaultBusThickness = aThickness; else s_defaultBusThickness = 1; @@ -90,7 +90,7 @@ void SetDefaultLineThickness( int aThickness) s_drawDefaultLineThickness = 1; } -EDA_COLOR_T GetLayerColor( int aLayer ) +EDA_COLOR_T GetLayerColor( LayerNumber aLayer ) { return s_layerColor[aLayer]; } @@ -478,9 +478,6 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void ) 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( "ColorPinFunEx" ), - &s_layerColor[LAYER_PINFUN], - MAGENTA ) ); m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNumEx" ), &s_layerColor[LAYER_PINNUM], RED ) ); diff --git a/eeschema/general.h b/eeschema/general.h index ddf0d5373b..41f7f478cf 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -18,8 +18,8 @@ class TRANSFORM; #define SCHEMATIC_HEAD_STRING "Schematic File Version" -#define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers. -#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */ +#define TXTMARGE 10 // Offset in mils for placement of labels and pin numbers +#define DEFAULT_TEXT_SIZE 50 // Default size for field texts #define GR_DEFAULT_DRAWMODE GR_COPY @@ -33,7 +33,6 @@ typedef enum { LAYER_LOCLABEL, LAYER_GLOBLABEL, LAYER_HIERLABEL, - LAYER_PINFUN, LAYER_PINNUM, LAYER_PINNAM, LAYER_REFERENCEPART, @@ -52,12 +51,15 @@ typedef enum { LAYER_ERC_ERR, LAYER_DEVICE_BACKGROUND, LAYER_GRID, - LAYER_ITEM_SELECTED, - LAYER_INVISIBLE_ITEM, - - MAX_LAYER // end of list + NB_SCH_LAYERS } LayerNumber; +inline LayerNumber operator++( LayerNumber& a ) +{ + a = LayerNumber( int( a ) + 1 ); + return a; +} + /* Rotation, mirror of graphic items in components bodies are handled by a * transform matrix. The default matrix is useful to draw lib entries with @@ -67,8 +69,6 @@ typedef enum { */ extern TRANSFORM DefaultTransform; -#define MAX_LAYERS (int) MAX_LAYER - extern wxSize g_RepeatStep; extern int g_RepeatDeltaLabel; @@ -90,7 +90,7 @@ void SetDefaultLineThickness( int aThickness); int GetDefaultBusThickness(); void SetDefaultBusThickness( int aThickness ); -EDA_COLOR_T GetLayerColor( int aLayer ); +EDA_COLOR_T GetLayerColor( LayerNumber aLayer ); // Color to draw selected items EDA_COLOR_T GetItemSelectedColor(); diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index c6efcda0dd..b04de25fab 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -218,9 +218,9 @@ void SCH_COMPONENT::Init( const wxPoint& pos ) { SCH_FIELD field( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) ); - if( i==REFERENCE ) + if( i == REFERENCE ) field.SetLayer( LAYER_REFERENCEPART ); - else if( i==VALUE ) + else if( i == VALUE ) field.SetLayer( LAYER_VALUEPART ); // else keep LAYER_FIELDS from SCH_FIELD constructor diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 2617401a5d..304e5dadef 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -508,7 +508,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const } // This section is not used, but written for file compatibility - if( fprintf( aFile, "EELAYER %d %d\n", MAX_LAYERS, 0 ) < 0 + if( fprintf( aFile, "EELAYER %d %d\n", NB_SCH_LAYERS, 0 ) < 0 || fprintf( aFile, "EELAYER END\n" ) < 0 ) return false; diff --git a/include/class_bitmap_base.h b/include/class_bitmap_base.h index 1ba129ca8e..a735c2772b 100644 --- a/include/class_bitmap_base.h +++ b/include/class_bitmap_base.h @@ -31,7 +31,7 @@ #define _BITMAP_BASE_H_ -#include +#include /** * This class handle bitmap images in KiCad. diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index 5ac910dab2..11b7d4866c 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -32,6 +32,7 @@ #include #include +#include using namespace std; @@ -117,7 +118,7 @@ public: class SCH_ITEM : public EDA_ITEM { protected: - int m_Layer; + LayerNumber m_Layer; EDA_ITEMS m_connections; ///< List of items connected to this item. public: @@ -147,14 +148,14 @@ public: * Function GetLayer * returns the layer this item is on. */ - int GetLayer() const { return m_Layer; } + LayerNumber GetLayer() const { return m_Layer; } /** * Function SetLayer * sets the layer this item is on. * @param aLayer The layer number. */ - void SetLayer( int aLayer ) { m_Layer = aLayer; } + void SetLayer( LayerNumber aLayer ) { m_Layer = aLayer; } /** * Function GetPenSize virtual pure diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 52241b5543..12b7b0f318 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -19,10 +19,10 @@ CPolyLine::CPolyLine() { - m_hatchStyle = NO_HATCH; - m_hatchPitch = 0; - m_layer = LAYER_N_FRONT; - m_utility = 0; + m_hatchStyle = NO_HATCH; + m_hatchPitch = 0; + m_layer = LAYER_N_FRONT; + m_utility = 0; }