diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp
index b97701bd75..d2ad04e200 100644
--- a/3d-viewer/3d_draw.cpp
+++ b/3d-viewer/3d_draw.cpp
@@ -56,14 +56,14 @@ extern void CheckGLError();
/* returns true if aLayer should be displayed, false otherwise
*/
-static bool Is3DLayerEnabled( int aLayer );
+static bool Is3DLayerEnabled( LAYER_NUM aLayer );
/* returns the Z orientation parameter 1.0 or -1.0 for aLayer
* Z orientation is 1.0 for all layers but "back" layers:
* LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK
* used to calculate the Z orientation parameter for glNormal3f
*/
-static GLfloat Get3DLayer_Z_Orientation( int aLayer );
+static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
void EDA_3D_CANVAS::Redraw( bool finish )
{
@@ -163,7 +163,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
Draw3D_Via( (SEGVIA*) track );
else
{
- int layer = track->GetLayer();
+ LAYER_NUM layer = track->GetLayer();
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
Draw3D_Track( track );
@@ -174,7 +174,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
{
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{
- int layer = pcb->GetArea( ii )->GetLayer();
+ LAYER_NUM layer = pcb->GetArea( ii )->GetLayer();
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
Draw3D_Zone( pcb->GetArea( ii ) );
@@ -236,8 +236,8 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
*/
void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
{
- int layer = aZone->GetLayer();
- int color = g_ColorsSettings.GetLayerColor( layer );
+ LAYER_NUM layer = aZone->GetLayer();
+ EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
if( layer == LAST_COPPER_LAYER )
@@ -456,7 +456,7 @@ void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
{
- int layer = aTrack->GetLayer();
+ LAYER_NUM layer = aTrack->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
@@ -475,7 +475,7 @@ void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
{
- int layer, top_layer, bottom_layer;
+ LAYER_NUM layer, top_layer, bottom_layer;
int color;
double biu_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits ;
@@ -486,7 +486,7 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
via->ReturnLayerPair( &top_layer, &bottom_layer );
// Drawing horizontal thick rings:
- for( layer = bottom_layer; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
+ for( layer = bottom_layer; layer < g_Parm_3D_Visu.m_CopperLayersCount; ++layer )
{
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
@@ -530,7 +530,7 @@ void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
{
- int layer = segment->GetLayer();
+ LAYER_NUM layer = segment->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer );
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
@@ -538,7 +538,7 @@ void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
if( layer == EDGE_N )
{
- for( layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
+ for( layer = FIRST_LAYER; layer < g_Parm_3D_Visu.m_CopperLayersCount; ++layer )
{
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(layer);
@@ -624,7 +624,7 @@ static void Draw3dTextSegm( int x0, int y0, int xf, int yf )
void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
{
- int layer = text->GetLayer();
+ LAYER_NUM layer = text->GetLayer();
int color = g_ColorsSettings.GetLayerColor( layer );
SetGLColor( color );
@@ -754,7 +754,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( m_Layer ) == false )
return;
- int color = g_ColorsSettings.GetLayerColor( m_Layer );
+ EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( m_Layer );
SetGLColor( color );
// for outline shape = S_POLYGON:
@@ -790,7 +790,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
if( m_Layer == EDGE_N )
{
- for( int layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < g_Parm_3D_Visu.m_CopperLayersCount; ++layer )
{
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
@@ -948,7 +948,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
switch( GetShape() )
{
case PAD_CIRCLE:
- for( int layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ )
+ for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer )
{
if( layer && (layer == nlmax) )
layer = LAYER_N_FRONT;
@@ -1007,7 +1007,6 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
wxPoint coord[5];
BuildPadPolygon( coord, wxSize(0,0), m_Orient );
for( int ii = 0; ii < 4; ii ++ )
-
{
CPolyPt pt( coord[ii].x + shape_pos.x, coord[ii].y+ shape_pos.y );
polyPadShape.push_back( pt );
@@ -1027,7 +1026,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
if( polyPadShape.size() )
{
- for( int layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ )
+ for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer )
{
if( layer && (layer == nlmax) )
layer = LAYER_N_FRONT;
@@ -1061,41 +1060,41 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
}
-bool Is3DLayerEnabled( int aLayer )
+bool Is3DLayerEnabled( LAYER_NUM aLayer )
{
- int flg = -1;
+ int flg;
// see if layer needs to be shown
// check the flags
switch (aLayer)
{
case DRAW_N:
- flg=g_Parm_3D_Visu.FL_DRAWINGS;
+ flg = g_Parm_3D_Visu.FL_DRAWINGS;
break;
case COMMENT_N:
- flg=g_Parm_3D_Visu.FL_COMMENTS;
+ flg = g_Parm_3D_Visu.FL_COMMENTS;
break;
case ECO1_N:
- flg=g_Parm_3D_Visu.FL_ECO1;
+ flg = g_Parm_3D_Visu.FL_ECO1;
break;
case ECO2_N:
- flg=g_Parm_3D_Visu.FL_ECO2;
+ flg = g_Parm_3D_Visu.FL_ECO2;
break;
- }
+ default:
// the layer was not a layer with a flag, so show it
- if( flg < 0 )
return true;
+ }
// if the layer has a flag, return the flag
return g_Parm_3D_Visu.m_DrawFlags[flg];
}
-GLfloat Get3DLayer_Z_Orientation( int aLayer )
+GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer )
{
double nZ;
diff --git a/3d-viewer/info3d_visu.cpp b/3d-viewer/info3d_visu.cpp
index 6fe6c9248b..4047783b4d 100644
--- a/3d-viewer/info3d_visu.cpp
+++ b/3d-viewer/info3d_visu.cpp
@@ -135,7 +135,7 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
}
// calculate z position for each non copper layer
- for( int layer_id = FIRST_NO_COPPER_LAYER; layer_id < NB_LAYERS; layer_id++ )
+ for( int layer_id = FIRST_NON_COPPER_LAYER; layer_id < NB_PCB_LAYERS; layer_id++ )
{
double zpos;
#define NonCopperLayerThicknessMargin 1.1
@@ -184,7 +184,7 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
default:
zpos = zpos_copper_front +
- (layer_id - FIRST_NO_COPPER_LAYER + 5) *
+ (layer_id - FIRST_NON_COPPER_LAYER + 5) *
m_NonCopperLayerThickness * NonCopperLayerThicknessMargin;
break;
}
diff --git a/3d-viewer/info3d_visu.h b/3d-viewer/info3d_visu.h
index ec2aa74d86..a6b0456ef1 100644
--- a/3d-viewer/info3d_visu.h
+++ b/3d-viewer/info3d_visu.h
@@ -93,7 +93,7 @@ public:
double m_CurrentZpos; // temporary storage of current value of Z position,
// used in some calculation
private:
- double m_LayerZcoord[LAYER_COUNT]; // Z position of each layer (normalized)
+ double m_LayerZcoord[NB_LAYERS]; // Z position of each layer (normalized)
double m_CopperThickness; // Copper thickness (normalized)
double m_EpoxyThickness; // Epoxy thickness (normalized)
double m_NonCopperLayerThickness; // Non copper layers thickness
@@ -173,7 +173,7 @@ public: INFO3D_VISU();
*/
int GetLayerObjectThicknessBIU( int aLayerId) const
{
- return aLayerId >= FIRST_NO_COPPER_LAYER ?
+ return aLayerId >= FIRST_NON_COPPER_LAYER ?
GetNonCopperLayerThicknessBIU() :
GetCopperThicknessBIU();
}
diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp
index 7c5ac02efa..bbb64cd5a8 100644
--- a/bitmap2component/bitmap2component.cpp
+++ b/bitmap2component/bitmap2component.cpp
@@ -32,7 +32,7 @@
#include
#include
#include
-
+#include
#include
#include
@@ -310,8 +310,7 @@ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon )
case PCBNEW_FMT:
{
- #define SILKSCREEN_N_FRONT 21
- int layer = SILKSCREEN_N_FRONT;
+ LAYER_NUM layer = SILKSCREEN_N_FRONT;
int width = 1;
fprintf( m_Outfile, "DP %d %d %d %d %d %d %d\n",
0, 0, 0, 0,
diff --git a/common/class_colors_design_settings.cpp b/common/class_colors_design_settings.cpp
index 8901544c58..21835b80e5 100644
--- a/common/class_colors_design_settings.cpp
+++ b/common/class_colors_design_settings.cpp
@@ -78,7 +78,7 @@ COLORS_DESIGN_SETTINGS:: COLORS_DESIGN_SETTINGS()
* @return the color for aLayer which is one of the layer indices given
* in pcbstruct.h or in schematic
*/
-EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer ) const
+EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
{
if( (unsigned) aLayer < DIM(m_LayersColors) )
{
@@ -93,7 +93,7 @@ EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer ) const
* sets the color for aLayer which is one of the layer indices given
* in pcbstruct.h or in schematic
*/
-void COLORS_DESIGN_SETTINGS::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
+void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{
if( (unsigned) aLayer < DIM(m_LayersColors) )
{
diff --git a/common/class_layer_box_selector.cpp b/common/class_layer_box_selector.cpp
index d38943a7bb..3ec360025b 100644
--- a/common/class_layer_box_selector.cpp
+++ b/common/class_layer_box_selector.cpp
@@ -65,14 +65,14 @@ int LAYER_BOX_SELECTOR::GetChoice()
// Get Current Layer
-int LAYER_BOX_SELECTOR::GetLayerSelection()
+LAYER_NUM LAYER_BOX_SELECTOR::GetLayerSelection() const
{
- return (long) GetClientData( GetSelection() );
+ return (LAYER_NUM)((unsigned long) GetClientData( GetSelection() ) );
}
// Set Layer #
-int LAYER_BOX_SELECTOR::SetLayerSelection( int layer )
+int LAYER_BOX_SELECTOR::SetLayerSelection( LAYER_NUM layer )
{
int elements = GetCount();
@@ -97,8 +97,8 @@ int LAYER_BOX_SELECTOR::SetLayerSelection( int layer )
void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
{
- int elements = GetCount();
- for( int i = 0; i < elements; i++ )
+ LAYER_NUM elements = GetCount();
+ for( LAYER_NUM i = FIRST_LAYER; i < elements; ++i )
{
wxBitmap layerbmp( 14, 14 );
SetBitmapLayer( layerbmp, i );
@@ -106,7 +106,7 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
}
-void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, int aLayerIndex )
+void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayerIndex )
{
wxMemoryDC bmpDC;
wxBrush brush;
diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp
index 92b5e0b9d1..57ec480a0a 100644
--- a/eeschema/dialogs/dialog_color_config.cpp
+++ b/eeschema/dialogs/dialog_color_config.cpp
@@ -11,6 +11,7 @@
#include
#include
+#include
#define ID_COLOR_SETUP 1800
@@ -290,7 +291,7 @@ bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
bool warning = false;
- for( int ii = 0; ii < MAX_LAYERS; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < MAX_LAYERS; ++ii )
{
SetLayerColor( currentColors[ ii ], ii );
diff --git a/gerbview/class_excellon.h b/gerbview/class_excellon.h
index 7f8b5b9df3..0bc3e26449 100644
--- a/gerbview/class_excellon.h
+++ b/gerbview/class_excellon.h
@@ -76,7 +76,7 @@ private:
excellon_state m_State; // state of excellon file analysis
bool m_SlotOn; // true during an oval driil definition
-public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) :
+public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, LAYER_NUM layer ) :
GERBER_IMAGE( aParent, layer )
{
m_State = READ_HEADER_STATE;
diff --git a/gerbview/class_gbr_layer_box_selector.cpp b/gerbview/class_gbr_layer_box_selector.cpp
index 45918ec131..038aac142f 100644
--- a/gerbview/class_gbr_layer_box_selector.cpp
+++ b/gerbview/class_gbr_layer_box_selector.cpp
@@ -46,7 +46,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
{
Clear();
- for( int layerid = 0; layerid < LAYER_COUNT; layerid++ )
+ for( LAYER_NUM layerid = FIRST_LAYER; layerid < NB_LAYERS; ++layerid )
{
wxBitmap layerbmp( 14, 14 );
wxString layername;
@@ -65,7 +65,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
// Returns a color index from the layer id
-EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) const
+EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayerIndex ) const
{
GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
@@ -74,7 +74,7 @@ EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) const
// Returns the name of the layer id
-wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex ) const
+wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( LAYER_NUM aLayerIndex ) const
{
wxString name;
name.Printf( _( "Layer %d" ), aLayerIndex + 1 );
diff --git a/gerbview/class_gbr_layer_box_selector.h b/gerbview/class_gbr_layer_box_selector.h
index 64812e5a57..0ba19a2647 100644
--- a/gerbview/class_gbr_layer_box_selector.h
+++ b/gerbview/class_gbr_layer_box_selector.h
@@ -37,15 +37,15 @@ public:
// Returns a color index from the layer id
// Virtual function
- EDA_COLOR_T GetLayerColor( int aLayerIndex ) const;
+ EDA_COLOR_T GetLayerColor( LAYER_NUM aLayerIndex ) const;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function
- bool IsLayerEnabled( int aLayerIndex ) const { return true; };
+ bool IsLayerEnabled( LAYER_NUM aLayerIndex ) const { return true; };
// Returns the name of the layer id
// Virtual function
- wxString GetLayerName( int aLayerIndex ) const;
+ wxString GetLayerName( LAYER_NUM aLayerIndex ) const;
};
#endif //CLASS_GBR_LAYER_BOX_SELECTOR_H
diff --git a/gerbview/class_gbr_layout.cpp b/gerbview/class_gbr_layout.cpp
index abd461876a..345722f2f5 100644
--- a/gerbview/class_gbr_layout.cpp
+++ b/gerbview/class_gbr_layout.cpp
@@ -27,7 +27,7 @@ GBR_LAYOUT::~GBR_LAYOUT()
* param aLayerIndex = The index of the layer to be tested
* return bool - true if the layer is visible.
*/
-bool GBR_LAYOUT::IsLayerVisible( int aLayerIndex ) const
+bool GBR_LAYOUT::IsLayerVisible( LAYER_NUM aLayerIndex ) const
{
return m_printLayersMask & GetLayerMask( aLayerIndex );
}
diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h
index 8967357e38..cc497703b5 100644
--- a/gerbview/class_gbr_layout.h
+++ b/gerbview/class_gbr_layout.h
@@ -102,7 +102,7 @@ public:
* @param aLayerIndex = The index of the layer to be tested
* @return bool - true if the layer is visible.
*/
- bool IsLayerVisible( int aLayerIndex ) const;
+ bool IsLayerVisible( LAYER_NUM aLayerIndex ) const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
diff --git a/gerbview/class_gbr_screen.h b/gerbview/class_gbr_screen.h
index 77640a1a2a..8be96b21d5 100644
--- a/gerbview/class_gbr_screen.h
+++ b/gerbview/class_gbr_screen.h
@@ -17,7 +17,7 @@
class GBR_SCREEN : public BASE_SCREEN
{
public:
- int m_Active_Layer;
+ LAYER_NUM m_Active_Layer;
/**
* Constructor
* @param aPageSizeIU is the size of the initial paper page in internal units.
diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp
index f9fb900284..39d8053eab 100644
--- a/gerbview/class_gerber_draw_item.cpp
+++ b/gerbview/class_gerber_draw_item.cpp
@@ -44,7 +44,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_IMAGE* aGerberpa
EDA_ITEM( (EDA_ITEM*)aParent, TYPE_GERBER_DRAW_ITEM )
{
m_imageParams = aGerberparams;
- m_Layer = 0;
+ m_Layer = FIRST_LAYER;
m_Shape = GBR_SEGMENT;
m_Flashed = false;
m_DCode = 0;
diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h
index 3d6cfda162..cb304dbc64 100644
--- a/gerbview/class_gerber_draw_item.h
+++ b/gerbview/class_gerber_draw_item.h
@@ -90,7 +90,7 @@ public:
* redundancy for these parameters
*/
private:
- int m_Layer;
+ LAYER_NUM m_Layer;
// These values are used to draw this item, according to gerber layers parameters
// Because they can change inside a gerber image, they are stored here
@@ -123,7 +123,7 @@ public:
* Function GetLayer
* returns the layer this item is on.
*/
- int GetLayer() const { return m_Layer; }
+ LAYER_NUM GetLayer() const { return m_Layer; }
/**
* Function SetLayer
@@ -132,7 +132,7 @@ public:
* is virtual because some items (in fact: class DIMENSION)
* have a slightly different initialization
*/
- void SetLayer( int aLayer ) { m_Layer = aLayer; }
+ void SetLayer( LAYER_NUM aLayer ) { m_Layer = aLayer; }
LAYER_MSK GetLayerMask()
{
diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp
index eea92f7d16..bb6a3a57df 100644
--- a/gerbview/class_gerbview_layer_widget.cpp
+++ b/gerbview/class_gerbview_layer_widget.cpp
@@ -196,10 +196,9 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
void GERBER_LAYER_WIDGET::ReFill()
{
- int layer;
ClearLayerRows();
- for( layer = 0; layer < GERBVIEW_LAYER_COUNT; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer )
{
wxString msg;
msg.Printf( _("Layer %d"), layer+1 );
@@ -212,18 +211,18 @@ void GERBER_LAYER_WIDGET::ReFill()
//------------------------------------------------
-void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
+void GERBER_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{
myframe->SetLayerColor( aLayer, aColor );
myframe->m_SelLayerBox->ResyncBitmapOnly();
myframe->GetCanvas()->Refresh();
}
-bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
+bool GERBER_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
{
// the layer change from the GERBER_LAYER_WIDGET can be denied by returning
// false from this function.
- int layer = myframe->getActiveLayer( );
+ LAYER_NUM layer = myframe->getActiveLayer( );
myframe->setActiveLayer( aLayer, false );
myframe->syncLayerBox();
@@ -233,7 +232,7 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
return true;
}
-void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
+void GERBER_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal )
{
LAYER_MSK visibleLayers = myframe->GetVisibleLayers();
diff --git a/gerbview/class_gerbview_layer_widget.h b/gerbview/class_gerbview_layer_widget.h
index 60349aba6b..cd974e08ea 100644
--- a/gerbview/class_gerbview_layer_widget.h
+++ b/gerbview/class_gerbview_layer_widget.h
@@ -88,9 +88,9 @@ public:
void ReFillRender();
//----------------
- void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor );
- bool OnLayerSelect( int aLayer );
- void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
+ void OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor );
+ bool OnLayerSelect( LAYER_NUM aLayer );
+ void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal );
void OnRenderColorChange( int aId, EDA_COLOR_T aColor );
void OnRenderEnable( int aId, bool isEnabled );
/**
diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp
index 8bfa1c4c8b..7cc851c5b1 100644
--- a/gerbview/dcode.cpp
+++ b/gerbview/dcode.cpp
@@ -165,7 +165,7 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
wxString msg;
D_CODE* dcode;
FILE* dest;
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
int type_outil;
if( g_GERBER_List[layer] == NULL )
diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp
index 27749d4df4..31d21469ad 100644
--- a/gerbview/dialogs/dialog_print_using_printer.cpp
+++ b/gerbview/dialogs/dialog_print_using_printer.cpp
@@ -123,7 +123,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
/************************************************************************/
{
SetFocus();
- int layer_max = GERBVIEW_LAYER_COUNT;
+ LAYER_NUM layer_max = NB_GERBER_LAYERS;
wxString msg;
if( g_pageSetupData == NULL )
@@ -137,11 +137,11 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
s_Parameters.m_PageSetupData = g_pageSetupData;
- layer_max = 32;
+ layer_max = NB_LAYERS;
// Create layer list
- int mask = 1, ii;
- for( ii = 0; ii < layer_max; ii++, mask <<= 1 )
+ for(LAYER_NUM ii = FIRST_LAYER; ii < layer_max; ++ii )
{
+ LAYER_MSK mask = GetLayerMask( ii );
msg = _( "Layer" );
msg << wxT( " " ) << ii + 1;
m_BoxSelectLayer[ii] = new wxCheckBox( this, -1, msg );
@@ -176,7 +176,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0;
s_SelectedLayers = 0;
- for( int layer = 0; layerIsChecked() )
{
@@ -255,7 +254,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
m_Config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
m_Config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
wxString layerKey;
- for( int layer = 0; layer < GERBVIEW_LAYER_COUNT; ++layer )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer )
{
layerKey.Printf( OPTKEY_LAYERBASE, layer );
m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
diff --git a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp
index 6c6e06f329..4da2ad218a 100644
--- a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp
+++ b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp
@@ -8,7 +8,7 @@
#include
// Exported function
-const wxString GetPCBDefaultLayerName( int aLayerNumber );
+const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber );
enum layer_sel_id {
@@ -23,11 +23,11 @@ class SELECT_LAYER_DIALOG : public wxDialog
private:
GERBVIEW_FRAME* m_Parent;
wxRadioBox* m_LayerList;
- int m_LayerId[NB_LAYERS + 1]; // One extra element for "(Deselect)" radiobutton
+ LAYER_NUM m_LayerId[int(NB_LAYERS) + 1]; // One extra element for "(Deselect)" radiobutton
public:
// Constructor and destructor
- SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer,
+ SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, LAYER_NUM aDefaultLayer,
int aCopperLayerCount, bool aShowDeselectOption );
~SELECT_LAYER_DIALOG() { };
@@ -61,9 +61,9 @@ END_EVENT_TABLE()
* different radiobutton is clicked on) prior to then clicking on the "Deselect"
* button provided within the "Layer selection:" dialog box).
*/
-int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, bool aShowDeselectOption )
+LAYER_NUM GERBVIEW_FRAME::SelectPCBLayer( LAYER_NUM aDefaultLayer, int aCopperLayerCount, bool aShowDeselectOption )
{
- int layer;
+ LAYER_NUM layer;
SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this, aDefaultLayer,
aCopperLayerCount,
aShowDeselectOption );
@@ -81,14 +81,14 @@ int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, bo
* to the right of that radiobox.
*/
SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
- int aDefaultLayer, int aCopperLayerCount,
+ LAYER_NUM aDefaultLayer, int aCopperLayerCount,
bool aShowDeselectOption ) :
wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ),
wxSize( 470, 250 ),
DIALOG_STYLE )
{
wxButton* Button;
- int ii;
+ LAYER_NUM ii;
wxString LayerList[NB_LAYERS + 1]; // One extra element for "(Deselect)"
// radiobutton
int LayerCount, LayerSelect = -1;
@@ -97,11 +97,11 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
// Build the layer list; first build copper layers list
LayerCount = 0;
- for( ii = 0; ii < BOARD_COPPER_LAYERS_MAX_COUNT; ii++ )
+ for( ii = FIRST_COPPER_LAYER; ii < NB_COPPER_LAYERS; ++ii )
{
- m_LayerId[ii] = 0;
+ m_LayerId[ii] = FIRST_LAYER;
- if( ii == 0 || ii == BOARD_COPPER_LAYERS_MAX_COUNT-1 || ii < aCopperLayerCount-1 )
+ if( ii == FIRST_COPPER_LAYER || ii == LAST_COPPER_LAYER || ii < aCopperLayerCount-1 )
{
LayerList[LayerCount] = GetPCBDefaultLayerName( ii );
@@ -113,9 +113,9 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
}
}
// Build the layer list; build copper layers list
- for( ; ii < NB_LAYERS; ii++ )
+ for( ; ii < NB_LAYERS; ++ii )
{
- m_LayerId[ii] = 0;
+ m_LayerId[ii] = FIRST_LAYER;
LayerList[LayerCount] = GetPCBDefaultLayerName( ii );
@@ -131,10 +131,10 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
{
LayerList[LayerCount] = _( "(Deselect)" );
- if( NB_LAYERS == aDefaultLayer )
+ if( NB_PCB_LAYERS == aDefaultLayer )
LayerSelect = LayerCount;
- m_LayerId[LayerCount] = NB_LAYERS;
+ m_LayerId[LayerCount] = NB_PCB_LAYERS;
LayerCount++;
}
@@ -181,7 +181,7 @@ void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
EndModal( -1 );
}
-const wxString GetPCBDefaultLayerName( int aLayerNumber )
+const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber )
{
const wxChar* txt;
diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp
index 42aa4d79dd..198eb78efd 100644
--- a/gerbview/draw_gerber_screen.cpp
+++ b/gerbview/draw_gerber_screen.cpp
@@ -193,9 +193,9 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
bool end = false;
- for( int layer = 0; !end; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; !end; ++layer )
{
- int active_layer = gerbFrame->getActiveLayer();
+ LAYER_NUM active_layer = gerbFrame->getActiveLayer();
if( layer == active_layer ) // active layer will be drawn after other layers
continue;
diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp
index 46b69c1385..28df5efb48 100644
--- a/gerbview/events_called_functions.cpp
+++ b/gerbview/events_called_functions.cpp
@@ -235,7 +235,7 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
*/
void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
{
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
setActiveLayer( event.GetSelection() );
@@ -249,7 +249,7 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
*/
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
{
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
GERBER_IMAGE* gerber_layer = g_GERBER_List[layer];
if( gerber_layer )
diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp
index 7d6a07e32e..2057432fae 100644
--- a/gerbview/excellon_read_drill_file.cpp
+++ b/gerbview/excellon_read_drill_file.cpp
@@ -78,13 +78,13 @@ extern double ReadDouble( char*& text, bool aSkipSeparator = true );
extern void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
APERTURE_T aAperture,
int Dcode_index,
- int aLayer,
+ LAYER_NUM aLayer,
const wxPoint& aPos,
wxSize aSize,
bool aLayerNegative );
void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
int Dcode_index,
- int aLayer,
+ LAYER_NUM aLayer,
const wxPoint& aStart,
const wxPoint& aEnd,
wxSize aPenSize,
@@ -153,7 +153,7 @@ static EXCELLON_CMD excellon_G_CmdList[] =
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
{
wxString msg;
- int layer = getActiveLayer(); // current layer used in GerbView
+ LAYER_NUM layer = getActiveLayer(); // current layer used in GerbView
if( g_GERBER_List[layer] == NULL )
{
diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp
index 73510a082b..c7c2c6d018 100644
--- a/gerbview/export_to_pcbnew.cpp
+++ b/gerbview/export_to_pcbnew.cpp
@@ -44,7 +44,7 @@ public:
* Function ExportPcb
* saves a board from a set of Gerber images.
*/
- bool ExportPcb( int* LayerLookUpTable );
+ bool ExportPcb( LAYER_NUM* LayerLookUpTable );
private:
/**
@@ -53,7 +53,7 @@ private:
* @param aGbrItem = the Gerber item (line, arc) to export
* @param aLayer = the technical layer to use
*/
- void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
+ void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Function export_copper_item
@@ -61,7 +61,7 @@ private:
* @param aGbrItem = the Gerber item (line, arc, flashed) to export
* @param aLayer = the copper layer to use
*/
- void export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
+ void export_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Function export_flashed_copper_item
@@ -76,7 +76,7 @@ private:
* @param aGbrItem = the Gerber item (line only) to export
* @param aLayer = the copper layer to use
*/
- void export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
+ void export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* Function export_segarc_copper_item
@@ -85,7 +85,7 @@ private:
* @param aGbrItem = the Gerber item (arc only) to export
* @param aLayer = the copper layer to use
*/
- void export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
+ void export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
/**
* function writePcbLineItem
@@ -93,7 +93,7 @@ private:
* to the board file
*/
void writePcbLineItem( int aShape, int aType, wxPoint& aStart, wxPoint& aEnd,
- int aWidth, int aLayer, int aDrill, int aAngle = 0 );
+ int aWidth, LAYER_NUM aLayer, int aDrill, int aAngle = 0 );
/**
* function writePcbHeader
@@ -123,7 +123,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
int layercount = 0;
// Count the Gerber layers which are actually currently used
- for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
{
if( g_GERBER_List[ii] != NULL )
layercount++;
@@ -170,7 +170,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
}
-bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
+bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* LayerLookUpTable )
{
m_fp = wxFopen( m_pcb_file_name, wxT( "wt" ) );
@@ -182,7 +182,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
return false;
}
- m_pcbCopperLayersCount = LayerLookUpTable[GERBVIEW_LAYER_COUNT];
+ m_pcbCopperLayersCount = LayerLookUpTable[NB_GERBER_LAYERS];
writePcbHeader();
@@ -192,10 +192,10 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
for( ; gerb_item; gerb_item = gerb_item->Next() )
{
- int layer = gerb_item->GetLayer();
- int pcb_layer_number = LayerLookUpTable[layer];
+ LAYER_NUM layer = gerb_item->GetLayer();
+ LAYER_NUM pcb_layer_number = LayerLookUpTable[layer];
- if( pcb_layer_number < 0 || pcb_layer_number > LAST_NO_COPPER_LAYER )
+ if( pcb_layer_number < FIRST_LAYER || pcb_layer_number > LAST_NON_COPPER_LAYER )
continue;
if( pcb_layer_number > LAST_COPPER_LAYER )
@@ -208,8 +208,8 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
for( ; gerb_item; gerb_item = gerb_item->Next() )
{
- int layer = gerb_item->GetLayer();
- int pcb_layer_number = LayerLookUpTable[layer];
+ LAYER_NUM layer = gerb_item->GetLayer();
+ LAYER_NUM pcb_layer_number = LayerLookUpTable[layer];
if( pcb_layer_number < 0 || pcb_layer_number > LAST_COPPER_LAYER )
continue;
@@ -227,7 +227,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
}
-void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
+void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{
#define SEG_SHAPE 0
#define ARC_SHAPE 2
@@ -263,7 +263,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, in
}
-void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
+void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{
switch( aGbrItem->m_Shape )
{
@@ -285,7 +285,7 @@ void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aL
}
-void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
+void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{
wxPoint seg_start, seg_end;
@@ -300,7 +300,7 @@ void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem
}
-void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
+void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{
double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
(double) ( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
@@ -378,7 +378,9 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem
// Layers are 0 to 15 (Cu/Cmp) = 0x0F
#define IS_VIA 1
#define SHAPE_VIA_THROUGH 3
- writePcbLineItem( SHAPE_VIA_THROUGH, IS_VIA, via_pos, via_pos, width, 0x0F, -1 );
+ // XXX EVIL usage of LAYER
+ writePcbLineItem( SHAPE_VIA_THROUGH, IS_VIA, via_pos, via_pos, width,
+ 0x0F, -1 );
}
@@ -408,7 +410,7 @@ void GBR_TO_PCB_EXPORTER::writePcbHeader()
void GBR_TO_PCB_EXPORTER::writePcbLineItem( int aShape, int aType, wxPoint& aStart, wxPoint& aEnd,
- int aWidth, int aLayer, int aDrill, int aAngle )
+ int aWidth, LAYER_NUM aLayer, int aDrill, int aAngle )
{
if( aDrill <= -2 )
fprintf( m_fp, "$DRAWSEGMENT\n" );
diff --git a/gerbview/files.cpp b/gerbview/files.cpp
index 5d0a8aaf7d..14cb8fc4df 100644
--- a/gerbview/files.cpp
+++ b/gerbview/files.cpp
@@ -168,7 +168,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
}
// Read gerber files: each file is loaded on a new GerbView layer
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
{
@@ -249,7 +249,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
}
// Read gerber files: each file is loaded on a new GerbView layer
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
{
diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp
index 36bbd91341..a79cf2038a 100644
--- a/gerbview/gerbview.cpp
+++ b/gerbview/gerbview.cpp
@@ -126,15 +126,16 @@ bool EDA_APP::OnInit()
wxSetWorkingDirectory( fn.GetPath() );
// Load all files specified on the command line.
- int jj = 0;
+ LAYER_NUM jj = FIRST_LAYER;
- for( int ii = 1; ii < argc && ii <= GERBVIEW_LAYER_COUNT; ++ii )
+ for( LAYER_NUM ii = LAYER_N_2; ii < argc && ii <= NB_GERBER_LAYERS; ++ii )
{
fn = wxFileName( argv[ii] );
if( fn.FileExists() )
{
- frame->setActiveLayer( jj++ );
+ frame->setActiveLayer( jj );
+ ++jj;
frame->LoadGerberFiles( fn.GetFullPath() );
}
}
diff --git a/gerbview/gerbview.h b/gerbview/gerbview.h
index 48fd793af5..42a469a631 100644
--- a/gerbview/gerbview.h
+++ b/gerbview/gerbview.h
@@ -24,8 +24,6 @@ class PAGE_INFO;
*/
#define GERBER_BUFZ 4000
-#define GERBVIEW_LAYER_COUNT 32 // Number of different layers shown by GerbView
-
/// List of page sizes
extern const wxChar* g_GerberPageSizeList[8];
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
index b1b9945afb..ab0c0e8217 100644
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -92,7 +92,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle,
SetLayout( new GBR_LAYOUT() );
- SetVisibleLayers( -1 ); // All 32 layers visible.
+ SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.
SetScreen( new GBR_SCREEN( GetLayout()->GetPageSettings().GetSizeIU() ) );
@@ -325,21 +325,21 @@ void GERBVIEW_FRAME::SetElementVisibility( GERBER_VISIBLE_ID aItemIdVisible,
}
-int GERBVIEW_FRAME::getNextAvailableLayer( int aLayer ) const
+LAYER_NUM GERBVIEW_FRAME::getNextAvailableLayer( LAYER_NUM aLayer ) const
{
- int layer = aLayer;
+ LAYER_NUM layer = aLayer;
- for( int i = 0; i < GERBVIEW_LAYER_COUNT; i++ )
+ for( LAYER_NUM i = FIRST_LAYER; i < NB_GERBER_LAYERS; ++i )
{
GERBER_IMAGE* gerber = g_GERBER_List[ layer ];
if( gerber == NULL || gerber->m_FileName.IsEmpty() )
return layer;
- layer++;
+ ++layer;
- if( layer >= GERBVIEW_LAYER_COUNT )
- layer = 0;
+ if( layer >= NB_GERBER_LAYERS )
+ layer = FIRST_LAYER;
}
return NO_AVAILABLE_LAYERS;
@@ -385,9 +385,9 @@ void GERBVIEW_FRAME::Liste_D_Codes()
wxString Line;
wxArrayString list;
double scale = IU_PER_MILS * 1000;
- int curr_layer = getActiveLayer();
+ LAYER_NUM curr_layer = getActiveLayer();
- for( int layer = 0; layer < 32; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
{
GERBER_IMAGE* gerber = g_GERBER_List[layer];
@@ -539,7 +539,7 @@ void GERBVIEW_FRAME::SetVisibleAlls()
*/
LAYER_MSK GERBVIEW_FRAME::GetVisibleLayers() const
{
- return -1; // TODO
+ return FULL_LAYERS; // TODO
}
@@ -561,7 +561,7 @@ void GERBVIEW_FRAME::SetVisibleLayers( LAYER_MSK aLayerMask )
* @param aLayerIndex = The index of the layer to be tested
* @return bool - true if the layer is visible.
*/
-bool GERBVIEW_FRAME::IsLayerVisible( int aLayerIndex ) const
+bool GERBVIEW_FRAME::IsLayerVisible( LAYER_NUM aLayerIndex ) const
{
if( ! m_DisplayOptions.m_IsPrinting )
return m_LayersManager->IsLayerVisible( aLayerIndex );
@@ -650,7 +650,7 @@ EDA_COLOR_T GERBVIEW_FRAME::GetNegativeItemsColor() const
* Function GetLayerColor
* gets a layer color for any valid layer.
*/
-EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
+EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( LAYER_NUM aLayer ) const
{
return m_colorsSettings->GetLayerColor( aLayer );
}
@@ -660,7 +660,7 @@ EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
* Function SetLayerColor
* changes a layer color for any valid layer.
*/
-void GERBVIEW_FRAME::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
+void GERBVIEW_FRAME::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{
m_colorsSettings->SetLayerColor( aLayer, aColor );
}
@@ -670,7 +670,7 @@ void GERBVIEW_FRAME::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
* Function getActiveLayer
* returns the active layer
*/
-int GERBVIEW_FRAME::getActiveLayer()
+LAYER_NUM GERBVIEW_FRAME::getActiveLayer()
{
return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
}
@@ -681,7 +681,7 @@ int GERBVIEW_FRAME::getActiveLayer()
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
-void GERBVIEW_FRAME::setActiveLayer( int aLayer, bool doLayerWidgetUpdate )
+void GERBVIEW_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate )
{
( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h
index bc69fd4915..36ccf8e7e3 100644
--- a/gerbview/gerbview_frame.h
+++ b/gerbview/gerbview_frame.h
@@ -39,7 +39,7 @@
#include
#include
-#define NO_AVAILABLE_LAYERS -1
+#define NO_AVAILABLE_LAYERS UNDEFINED_LAYER
class DCODE_SELECTION_BOX;
class GERBER_LAYER_WIDGET;
@@ -145,10 +145,10 @@ public:
void SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo = true );
/** Install the dialog box for layer selection
- * @param aDefaultLayer = Preselection (NB_LAYERS for "(Deselect)" layer)
+ * @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer)
* @param aCopperLayerCount = number of copper layers
* @param aShowDeselectOption = display a "(Deselect)" radiobutton (when set to true)
- * @return new layer value (NB_LAYERS when "(Deselect)" radiobutton selected),
+ * @return new layer value (NB_PCB_LAYERS when "(Deselect)" radiobutton selected),
* or -1 if canceled
*
* Providing the option to also display a "(Deselect)" radiobutton makes the
@@ -159,7 +159,7 @@ public:
* different radiobutton is clicked on) prior to then clicking on the "Deselect"
* button provided within the "Layer selection:" dialog box).
*/
- int SelectPCBLayer( int aDefaultLayer, int aOpperLayerCount, bool aNullLayer = false );
+ LAYER_NUM SelectPCBLayer( LAYER_NUM aDefaultLayer, int aOpperLayerCount, bool aNullLayer = false );
protected:
GERBER_LAYER_WIDGET* m_LayersManager;
@@ -316,7 +316,7 @@ public:
* @param aLayerIndex = The index of the layer to be tested
* @return bool - true if the layer is visible.
*/
- bool IsLayerVisible( int aLayerIndex ) const;
+ bool IsLayerVisible( LAYER_NUM aLayerIndex ) const;
/**
* Function GetVisibleElementColor
@@ -330,13 +330,13 @@ public:
* Function GetLayerColor
* gets a layer color for any valid layer.
*/
- EDA_COLOR_T GetLayerColor( int aLayer ) const;
+ EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
/**
* Function SetLayerColor
* changes a layer color for any valid layer.
*/
- void SetLayerColor( int aLayer, EDA_COLOR_T aColor );
+ void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
/**
* Function GetNegativeItemsColor
@@ -388,13 +388,13 @@ public:
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
- void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true );
+ void setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true );
/**
* Function getActiveLayer
* returns the active layer
*/
- int getActiveLayer();
+ LAYER_NUM getActiveLayer();
/**
* Function getNextAvailableLayer
@@ -403,7 +403,7 @@ public:
* @param aLayer The first layer to search.
* @return The first empty layer found or NO_AVAILABLE_LAYERS.
*/
- int getNextAvailableLayer( int aLayer = 0 ) const;
+ LAYER_NUM getNextAvailableLayer( LAYER_NUM aLayer = FIRST_LAYER ) const;
bool hasAvailableLayers() const
{
diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp
index 2c84644919..0efef5b750 100644
--- a/gerbview/initpcb.cpp
+++ b/gerbview/initpcb.cpp
@@ -39,7 +39,7 @@
bool GERBVIEW_FRAME::Clear_Pcb( bool query )
{
- int layer;
+ LAYER_NUM layer;
if( GetLayout() == NULL )
return false;
@@ -52,7 +52,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
GetLayout()->m_Drawings.DeleteAll();
- for( layer = 0; layer < GERBVIEW_LAYER_COUNT; layer++ )
+ for( layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer )
{
if( g_GERBER_List[layer] )
{
@@ -65,7 +65,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
- setActiveLayer(0);
+ setActiveLayer( FIRST_LAYER );
m_LayersManager->UpdateLayerIcons();
syncLayerBox();
return true;
@@ -74,7 +74,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
void GERBVIEW_FRAME::Erase_Current_Layer( bool query )
{
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
wxString msg;
msg.Printf( _( "Clear layer %d?" ), layer + 1 );
diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp
index 38261076a4..4a16337f68 100644
--- a/gerbview/locate.cpp
+++ b/gerbview/locate.cpp
@@ -46,7 +46,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
if( aTypeloc == CURSEUR_ON_GRILLE )
ref = GetScreen()->GetNearestGridPosition( ref );
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
// Search first on active layer
GERBER_DRAW_ITEM* gerb_item = GetItemsList();
diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp
index 3c89f21c08..45f0541b32 100644
--- a/gerbview/readgerb.cpp
+++ b/gerbview/readgerb.cpp
@@ -24,7 +24,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
wxString msg;
char* text;
- int layer; /* current layer used in GerbView */
+ LAYER_NUM layer; // current layer used in GerbView
layer = getActiveLayer();
diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp
index 1256aeaae3..e7681bbedd 100644
--- a/gerbview/rs274d.cpp
+++ b/gerbview/rs274d.cpp
@@ -88,7 +88,7 @@
void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
APERTURE_T aAperture,
int Dcode_index,
- int aLayer,
+ LAYER_NUM aLayer,
const wxPoint& aPos,
wxSize aSize,
bool aLayerNegative )
@@ -140,7 +140,7 @@ void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
*/
void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
int Dcode_index,
- int aLayer,
+ LAYER_NUM aLayer,
const wxPoint& aStart,
const wxPoint& aEnd,
wxSize aPenSize,
@@ -189,7 +189,7 @@ void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
* false when arc is inside one quadrant
* @param aLayerNegative = true if the current layer is negative
*/
-static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aLayer,
+static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, LAYER_NUM aLayer,
const wxPoint& aStart, const wxPoint& aEnd,
const wxPoint& aRelCenter, wxSize aPenSize,
bool aClockwise, bool aMultiquadrant,
@@ -328,7 +328,7 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem,
aGbrItem->SetLayerPolarity( aLayerNegative );
- fillArcGBRITEM( &dummyGbrItem, 0, 0,
+ fillArcGBRITEM( &dummyGbrItem, 0, FIRST_LAYER,
aStart, aEnd, rel_center, wxSize(0, 0),
aClockwise, aMultiquadrant, aLayerNegative );
@@ -549,7 +549,7 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
GERBER_DRAW_ITEM* gbritem;
GBR_LAYOUT* layout = m_Parent->GetLayout();
- int activeLayer = m_Parent->getActiveLayer();
+ LAYER_NUM activeLayer = m_Parent->getActiveLayer();
int dcode = 0;
D_CODE* tool = NULL;
diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp
index a8a3c8d756..def5128ef1 100644
--- a/gerbview/select_layers_to_pcb.cpp
+++ b/gerbview/select_layers_to_pcb.cpp
@@ -35,12 +35,12 @@
#include
// Imported function
-extern const wxString GetPCBDefaultLayerName( int aLayerNumber );
+extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber );
enum swap_layer_id {
ID_LAYERS_MAP_DIALOG = ID_GERBER_END_LIST,
ID_BUTTON_0,
- ID_TEXT_0 = ID_BUTTON_0 + GERBVIEW_LAYER_COUNT
+ ID_TEXT_0 = ID_BUTTON_0 + NB_GERBER_LAYERS
};
@@ -54,7 +54,7 @@ int LAYERS_MAP_DIALOG::m_exportBoardCopperLayersCount = 2;
BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG, LAYERS_MAP_DIALOG_BASE )
- EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + GERBVIEW_LAYER_COUNT-1,
+ EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_GERBER_LAYERS-1,
wxEVT_COMMAND_BUTTON_CLICKED,
LAYERS_MAP_DIALOG::OnSelectLayer )
END_EVENT_TABLE()
@@ -102,11 +102,11 @@ void LAYERS_MAP_DIALOG::initDialog()
// the above code should be modified as required in the event that those
// buttons should be some other size in that version.
- for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
{
// Specify the default value for each member of these arrays.
m_buttonTable[ii] = -1;
- m_layersLookUpTable[ii] = LAYER_UNSELECTED;
+ m_layersLookUpTable[ii] = UNSELECTED_LAYER;
}
// Ensure we have:
@@ -118,9 +118,9 @@ void LAYERS_MAP_DIALOG::initDialog()
int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
m_comboCopperLayersCount->SetSelection( idx );
- int pcb_layer_num = 0;
+ LAYER_NUM pcb_layer_num = FIRST_LAYER;
m_itemsCount = 0;
- for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
{
if( g_GERBER_List[ii] == NULL )
continue;
@@ -132,10 +132,10 @@ void LAYERS_MAP_DIALOG::initDialog()
m_buttonTable[m_itemsCount] = ii;
m_layersLookUpTable[ii] = pcb_layer_num;
m_itemsCount++;
- pcb_layer_num++;
+ ++pcb_layer_num;
}
- if( m_itemsCount <= GERBVIEW_LAYER_COUNT/2 ) // Only one list is enough
+ if( m_itemsCount <= NB_GERBER_LAYERS/2 ) // Only one list is enough
{
m_staticlineSep->Hide();
}
@@ -177,7 +177,7 @@ void LAYERS_MAP_DIALOG::initDialog()
// is nb_items; otherwise, the number of rows is 16 (with two
// separate columns of controls being used if nb_items > 16).
- if( ii == GERBVIEW_LAYER_COUNT/2 )
+ if( ii == NB_GERBER_LAYERS/2 )
flexColumnBoxSizer = m_flexRightColumnBoxSizer;
// Provide a text string to identify the Gerber layer
@@ -225,7 +225,7 @@ void LAYERS_MAP_DIALOG::initDialog()
wxDefaultSize, 0 );
goodSize = text->GetSize();
- for( int jj = 0; jj < BOARD_LAYERS_MAX_COUNT; jj++ )
+ for( LAYER_NUM jj = FIRST_LAYER; jj < NB_LAYERS; ++jj )
{
text->SetLabel( GetPCBDefaultLayerName( jj ) );
if( goodSize.x < text->GetSize().x )
@@ -258,8 +258,8 @@ void LAYERS_MAP_DIALOG::normalizeBrdLayersCount()
if( ( m_exportBoardCopperLayersCount & 1 ) )
m_exportBoardCopperLayersCount++;
- if( m_exportBoardCopperLayersCount > BOARD_COPPER_LAYERS_MAX_COUNT )
- m_exportBoardCopperLayersCount = BOARD_COPPER_LAYERS_MAX_COUNT;
+ if( m_exportBoardCopperLayersCount > NB_LAYERS )
+ m_exportBoardCopperLayersCount = NB_LAYERS;
if( m_exportBoardCopperLayersCount < 2 )
m_exportBoardCopperLayersCount = 2;
@@ -281,8 +281,9 @@ void LAYERS_MAP_DIALOG::OnBrdLayersCountSelection( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
{
wxString msg;
- int ii, layer;
- for( ii = 0, layer = 0; ii < m_itemsCount; ii++, layer++ )
+ int ii;
+ LAYER_NUM layer;
+ for( ii = 0, layer = FIRST_LAYER; ii < m_itemsCount; ii++, ++layer )
{
if( (layer == m_exportBoardCopperLayersCount - 1)
&& (m_exportBoardCopperLayersCount > 1) )
@@ -304,7 +305,7 @@ void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
config->Write( wxT("BrdLayersCount"), m_exportBoardCopperLayersCount );
wxString key;
- for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
config->Write( key, m_layersLookUpTable[ii] );
@@ -322,16 +323,18 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
m_comboCopperLayersCount->SetSelection( idx );
wxString key;
- for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
- config->Read( key, &m_layersLookUpTable[ii] );
+ int ilayer;
+ config->Read( key, &ilayer);
+ m_layersLookUpTable[ii] = ilayer;
}
for( int ii = 0; ii < m_itemsCount; ii++ )
{
- int layer = m_layersLookUpTable[ii];
- if( layer == LAYER_UNSELECTED )
+ LAYER_NUM layer = m_layersLookUpTable[ii];
+ if( layer == UNSELECTED_LAYER )
{
m_layersList[ii]->SetLabel( _( "Do not export" ) );
m_layersList[ii]->SetForegroundColour( *wxBLUE );
@@ -346,29 +349,29 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
{
- int ii, jj;
+ int ii;
ii = event.GetId() - ID_BUTTON_0;
- if( (ii < 0) || (ii >= GERBVIEW_LAYER_COUNT) )
+ if( (ii < FIRST_LAYER) || (ii >= NB_GERBER_LAYERS) )
{
wxFAIL_MSG( wxT("Bad layer id") );
return;
}
- jj = m_layersLookUpTable[m_buttonTable[ii]];
- if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
+ LAYER_NUM jj = m_layersLookUpTable[m_buttonTable[ii]];
+ if( ( jj < FIRST_LAYER ) || ( jj > NB_LAYERS ) )
jj = LAYER_N_BACK; // (Defaults to "Copper" layer.)
jj = m_Parent->SelectPCBLayer( jj, m_exportBoardCopperLayersCount, true );
- if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
+ if( ( jj < FIRST_LAYER ) || ( jj > NB_LAYERS ) )
return;
if( jj != m_layersLookUpTable[m_buttonTable[ii]] )
{
m_layersLookUpTable[m_buttonTable[ii]] = jj;
- if( jj == LAYER_UNSELECTED )
+ if( jj == UNSELECTED_LAYER )
{
m_layersList[ii]->SetLabel( _( "Do not export" ) );
@@ -402,7 +405,7 @@ void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
normalizeBrdLayersCount();
int inner_layer_max = 0;
- for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
{
if( m_layersLookUpTable[ii] < LAYER_N_FRONT )
{
@@ -420,6 +423,7 @@ void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
_("The exported board has not enough copper layers to handle selected inner layers") );
return;
}
- m_layersLookUpTable[GERBVIEW_LAYER_COUNT] = m_exportBoardCopperLayersCount;
+ // XXX EVIL usage of LAYER
+ m_layersLookUpTable[NB_GERBER_LAYERS] = m_exportBoardCopperLayersCount;
EndModal( wxID_OK );
}
diff --git a/gerbview/select_layers_to_pcb.h b/gerbview/select_layers_to_pcb.h
index 47d3155743..b2040c9354 100644
--- a/gerbview/select_layers_to_pcb.h
+++ b/gerbview/select_layers_to_pcb.h
@@ -24,7 +24,7 @@ private:
static int m_exportBoardCopperLayersCount;
wxFlexGridSizer* m_flexRightColumnBoxSizer; // An extra wxFlexGridSizer used
// when we have more than 16 gerber files loaded
- int m_layersLookUpTable[32+1]; // Indexes Gerber layers to PCB file layers
+ LAYER_NUM m_layersLookUpTable[int(NB_LAYERS)+1]; // Indexes Gerber layers to PCB file layers
// the last value in table is the number of copper layers
int m_buttonTable[32]; // Indexes buttons to Gerber layers
wxStaticText* m_layersList[32]; // Indexes text strings to buttons
@@ -32,7 +32,7 @@ private:
public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent );
~LAYERS_MAP_DIALOG() {};
- int * GetLayersLookUpTable() { return m_layersLookUpTable; }
+ LAYER_NUM * GetLayersLookUpTable() { return m_layersLookUpTable; }
int GetCopperLayersCount() { return m_exportBoardCopperLayersCount; }
private:
diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp
index 820980ee1c..2247e83f51 100644
--- a/gerbview/toolbars_gerber.cpp
+++ b/gerbview/toolbars_gerber.cpp
@@ -291,7 +291,7 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
{
- int layer = getActiveLayer();
+ LAYER_NUM layer = getActiveLayer();
GERBER_IMAGE* gerber = g_GERBER_List[layer];
int selected = ( gerber ) ? gerber->m_Selected_Tool : 0;
diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h
index bcf6e6b651..3fed1d53c5 100644
--- a/include/class_board_design_settings.h
+++ b/include/class_board_design_settings.h
@@ -78,10 +78,10 @@ public:
* @param aLayerIndex = The index of the layer to be tested
* @return bool - true if the layer is visible.
*/
- bool IsLayerVisible( int aLayerIndex ) const
+ bool IsLayerVisible( LAYER_NUM aLayerIndex ) const
{
// @@IMB: Altough Pcbnew uses only 29, GerbView uses all 32 layers
- if( aLayerIndex < 0 || aLayerIndex >= 32 )
+ if( aLayerIndex < FIRST_LAYER || aLayerIndex >= NB_LAYERS )
return false;
// If a layer is disabled, it is automatically invisible
@@ -94,7 +94,7 @@ public:
* @param aLayerIndex = The index of the layer to be changed
* @param aNewState = The new visibility state of the layer
*/
- void SetLayerVisibility( int aLayerIndex, bool aNewState );
+ void SetLayerVisibility( LAYER_NUM aLayerIndex, bool aNewState );
/**
* Function GetVisibleElements
@@ -161,7 +161,7 @@ public:
* @param aLayerIndex = The index of the layer to be tested
* @return bool - true if the layer is enabled
*/
- bool IsLayerEnabled( int aLayerIndex ) const
+ bool IsLayerEnabled( LAYER_NUM aLayerIndex ) const
{
return bool( m_EnabledLayers & GetLayerMask( aLayerIndex ) );
}
diff --git a/include/class_board_item.h b/include/class_board_item.h
index 99b36d54f7..586490e5f6 100644
--- a/include/class_board_item.h
+++ b/include/class_board_item.h
@@ -78,13 +78,13 @@ class BOARD_ITEM : public EDA_ITEM
void SetBack( EDA_ITEM* aBack ) { Pback = aBack; }
protected:
- int m_Layer;
+ LAYER_NUM m_Layer;
public:
BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
EDA_ITEM( aParent, idtype )
- , m_Layer( 0 )
+ , m_Layer( FIRST_LAYER )
{
}
@@ -103,7 +103,7 @@ public:
* Function GetLayer
* returns the layer this item is on.
*/
- int GetLayer() const { return m_Layer; }
+ LAYER_NUM GetLayer() const { return m_Layer; }
/**
* Function SetLayer
@@ -112,7 +112,7 @@ public:
* is virtual because some items (in fact: class DIMENSION)
* have a slightly different initialization
*/
- virtual void SetLayer( int aLayer ) { m_Layer = aLayer; }
+ virtual void SetLayer( LAYER_NUM aLayer ) { m_Layer = aLayer; }
/**
* Function Draw
@@ -129,7 +129,7 @@ public:
* @param aLayer The layer to test for.
* @return bool - true if on given layer, else false.
*/
- virtual bool IsOnLayer( int aLayer ) const
+ virtual bool IsOnLayer( LAYER_NUM aLayer ) const
{
return m_Layer == aLayer;
}
diff --git a/include/class_colors_design_settings.h b/include/class_colors_design_settings.h
index b2149a1149..5813b82676 100644
--- a/include/class_colors_design_settings.h
+++ b/include/class_colors_design_settings.h
@@ -7,6 +7,7 @@
#define _COLORS_DESIGN_SETTING_H
#include
+// XXX shouldn't these come from somewhere else?
#define LAYERSCOLORSBUFFERSIZE 32
#define ITEMSCOLORSBUFFERSIZE 32
@@ -33,14 +34,14 @@ public:
* @return the color for aLayer which is one of the layer indices given
* in pcbstruct.h or in schematic
*/
- EDA_COLOR_T GetLayerColor( int aLayer ) const;
+ EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
/**
* Function SetLayerColor
* sets the color for aLayer which is one of the layer indices given
* in pcbstruct.h or in schematic
*/
- void SetLayerColor( int aLayer, EDA_COLOR_T aColor );
+ void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
/**
* Function GetItemColor
diff --git a/include/class_layer_box_selector.h b/include/class_layer_box_selector.h
index 23ba970766..e7248584aa 100644
--- a/include/class_layer_box_selector.h
+++ b/include/class_layer_box_selector.h
@@ -35,24 +35,24 @@ public:
// Returns a color index from the layer id
// Virtual function because GerbView uses its own functions in a derived class
- virtual EDA_COLOR_T GetLayerColor( int aLayerIndex ) const = 0;
+ virtual EDA_COLOR_T GetLayerColor( LAYER_NUM aLayerIndex ) const = 0;
// Returns the name of the layer id
// Virtual pure function because GerbView uses its own functions in a derived class
- virtual wxString GetLayerName( int aLayerIndex ) const = 0;
+ virtual wxString GetLayerName( LAYER_NUM aLayerIndex ) const = 0;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function pure because GerbView uses its own functions in a derived class
- virtual bool IsLayerEnabled( int aLayerIndex ) const = 0;
+ virtual bool IsLayerEnabled( LAYER_NUM aLayerIndex ) const = 0;
// Get Current Item #
int GetChoice();
// Get Current Layer
- int GetLayerSelection();
+ LAYER_NUM GetLayerSelection() const;
// Set Layer #
- int SetLayerSelection(int layer);
+ int SetLayerSelection(LAYER_NUM layer);
// Reload the Layers
// Virtual pure function because GerbView uses its own functions in a derived class
@@ -66,10 +66,10 @@ public:
protected:
// Fills the layer bitmap aLayerbmp with the layer color
- void SetBitmapLayer( wxBitmap& aLayerbmp, int aLayerIndex );
+ void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayerIndex );
};
-#define DECLARE_LAYERS_HOTKEY(list) int list[LAYER_COUNT] = \
+#define DECLARE_LAYERS_HOTKEY(list) int list[NB_LAYERS] = \
{ \
HK_SWITCH_LAYER_TO_COPPER, \
HK_SWITCH_LAYER_TO_INNER1, \
diff --git a/include/class_pcb_screen.h b/include/class_pcb_screen.h
index c7381f32af..e15082be40 100644
--- a/include/class_pcb_screen.h
+++ b/include/class_pcb_screen.h
@@ -17,9 +17,9 @@ class UNDO_REDO_CONTAINER;
class PCB_SCREEN : public BASE_SCREEN
{
public:
- int m_Active_Layer;
- int m_Route_Layer_TOP;
- int m_Route_Layer_BOTTOM;
+ LAYER_NUM m_Active_Layer;
+ LAYER_NUM m_Route_Layer_TOP;
+ LAYER_NUM m_Route_Layer_BOTTOM;
public:
diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h
index c6e703fa8f..acae0e041f 100644
--- a/include/layers_id_colors_and_visibility.h
+++ b/include/layers_id_colors_and_visibility.h
@@ -30,10 +30,17 @@
#ifndef _LAYERS_ID_AND_VISIBILITY_H_
#define _LAYERS_ID_AND_VISIBILITY_H_
-#include // wxASSERT
+/* NOTE: the idea here is to have LAYER_NUM and LAYER_MSK as abstract
+ * type as possible (even if they're currently implemented as int and
+ * unsigned int, respectively). In this way it would be reasonably easy
+ * to overcome the current 32 layer limit. For example switching to a 64
+ * bit mask or even some kind of bit array */
/* Layer identification (layer number) */
+typedef int LAYER_NUM;
#define UNDEFINED_LAYER -1
+#define NO_LAYER 0
+#define FIRST_LAYER 0
#define FIRST_COPPER_LAYER 0
#define LAYER_N_BACK 0
#define LAYER_N_2 1
@@ -52,9 +59,9 @@
#define LAYER_N_15 14
#define LAYER_N_FRONT 15
#define LAST_COPPER_LAYER LAYER_N_FRONT
-#define NB_COPPER_LAYERS (LAST_COPPER_LAYER + 1)
+#define NB_COPPER_LAYERS (LAST_COPPER_LAYER - FIRST_COPPER_LAYER + 1)
-#define FIRST_NO_COPPER_LAYER 16
+#define FIRST_NON_COPPER_LAYER 16
#define ADHESIVE_N_BACK 16
#define ADHESIVE_N_FRONT 17
#define SOLDERPASTE_N_BACK 18
@@ -68,13 +75,14 @@
#define ECO1_N 26
#define ECO2_N 27
#define EDGE_N 28
-#define LAST_NO_COPPER_LAYER 28
+#define LAST_NON_COPPER_LAYER 28
+#define NB_PCB_LAYERS (LAST_NON_COPPER_LAYER + 1)
#define UNUSED_LAYER_29 29
#define UNUSED_LAYER_30 30
#define UNUSED_LAYER_31 31
-#define NB_LAYERS (LAST_NO_COPPER_LAYER + 1)
-
-#define LAYER_COUNT 32
+#define NB_GERBER_LAYERS 32
+#define NB_LAYERS 32
+#define UNSELECTED_LAYER 32
// Masks to identify a layer by a bit map
typedef unsigned LAYER_MSK;
@@ -108,9 +116,6 @@ typedef unsigned LAYER_MSK;
#define ECO2_LAYER (1 << ECO2_N)
#define EDGE_LAYER (1 << EDGE_N)
-#define FIRST_NON_COPPER_LAYER ADHESIVE_N_BACK
-#define LAST_NON_COPPER_LAYER EDGE_N
-
// extra bits 0xE0000000
/* Helpful global layers mask : */
#define ALL_LAYERS 0x1FFFFFFF // Pcbnew used 29 layers
@@ -124,9 +129,8 @@ typedef unsigned LAYER_MSK;
/** return a one bit layer mask from a layer number
* aLayerNumber = the layer number to convert (0 .. LAYERS-1)
*/
-inline LAYER_MSK GetLayerMask( unsigned aLayerNumber )
+inline LAYER_MSK GetLayerMask( LAYER_NUM aLayerNumber )
{
- wxASSERT( aLayerNumber < LAYER_COUNT && aLayerNumber >= 0 );
return 1 << aLayerNumber;
}
@@ -135,7 +139,7 @@ inline LAYER_MSK GetLayerMask( unsigned aLayerNumber )
// 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) int list[LAYER_COUNT] =\
+#define DECLARE_LAYERS_ORDER_LIST(list) 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,\
@@ -186,14 +190,14 @@ enum PCB_VISIBLE
/**
- * Function IsValidLayerIndex
+ * Function IsValidPcbLayerIndex
* tests whether a given integer is a valid layer index
* @param aLayerIndex = Layer index to test
* @return true if aLayerIndex is a valid layer index
*/
-inline bool IsValidLayerIndex( int aLayerIndex )
+inline bool IsValidPcbLayerIndex( LAYER_NUM aLayerIndex )
{
- return aLayerIndex >= 0 && aLayerIndex < NB_LAYERS;
+ return aLayerIndex >= FIRST_LAYER && aLayerIndex < NB_PCB_LAYERS;
}
/**
@@ -202,7 +206,7 @@ inline bool IsValidLayerIndex( int aLayerIndex )
* @param aLayerIndex = Layer index to test
* @return true if aLayerIndex is a valid copper layer index
*/
-inline bool IsValidCopperLayerIndex( int aLayerIndex )
+inline bool IsValidCopperLayerIndex( LAYER_NUM aLayerIndex )
{
return aLayerIndex >= FIRST_COPPER_LAYER && aLayerIndex <= LAST_COPPER_LAYER;
}
@@ -213,10 +217,10 @@ inline bool IsValidCopperLayerIndex( int aLayerIndex )
* @param aLayerIndex = Layer index to test
* @return true if aLayerIndex is a valid non copper layer index
*/
-inline bool IsValidNonCopperLayerIndex( int aLayerIndex )
+inline bool IsValidNonCopperLayerIndex( LAYER_NUM aLayerIndex )
{
- return aLayerIndex >= FIRST_NO_COPPER_LAYER
- && aLayerIndex <= LAST_NO_COPPER_LAYER;
+ return aLayerIndex >= FIRST_NON_COPPER_LAYER
+ && aLayerIndex <= LAST_NON_COPPER_LAYER;
}
#endif // _LAYERS_ID_AND_VISIBILITY_H_
diff --git a/include/macros.h b/include/macros.h
index c72863456a..f7c370f464 100644
--- a/include/macros.h
+++ b/include/macros.h
@@ -17,7 +17,7 @@
#define TO_UTF8( wxstring ) ( (const char*) (wxstring).utf8_str() )
/**
- * Macro FROM_UTF8
+ * function FROM_UTF8
* converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
*/
//#define FROM_UTF8( cstring ) wxString::FromUTF8( cstring )
diff --git a/include/pcbcommon.h b/include/pcbcommon.h
index 6ce9572123..8f4af14fc0 100644
--- a/include/pcbcommon.h
+++ b/include/pcbcommon.h
@@ -7,7 +7,7 @@
#include
-#include // LAYER_COUNT and NB_COPPER_LAYERS definitions.
+#include
#define MIN_DRAW_WIDTH 1 ///< Minimum trace drawing width.
diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h
index 42e6496715..3f71041b4d 100644
--- a/include/sch_item_struct.h
+++ b/include/sch_item_struct.h
@@ -83,6 +83,7 @@ enum DANGLING_END_T {
*/
class DANGLING_END_ITEM
{
+private:
/// A pointer to the connectable object.
const void* m_item;
diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h
index 8903f6f904..cdc7b19cf7 100644
--- a/include/wxBasePcbFrame.h
+++ b/include/wxBasePcbFrame.h
@@ -597,9 +597,9 @@ public:
// layerhandling:
// (See pcbnew/sel_layer.cpp for description of why null_layer parameter
// is provided)
- int SelectLayer( int default_layer, int min_layer, int max_layer, bool null_layer = false );
+ LAYER_NUM SelectLayer( LAYER_NUM default_layer, LAYER_NUM min_layer, LAYER_NUM max_layer, bool null_layer = false );
void SelectLayerPair();
- virtual void SwitchLayer( wxDC* DC, int layer );
+ virtual void SwitchLayer( wxDC* DC, LAYER_NUM layer );
void InstallGridFrame( const wxPoint& pos );
diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h
index fdd36da6a0..5ba16dc3e6 100644
--- a/include/wxPcbStruct.h
+++ b/include/wxPcbStruct.h
@@ -113,7 +113,7 @@ protected:
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
- void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true )
+ void setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true )
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
@@ -125,7 +125,7 @@ protected:
* Function getActiveLayer
* returns the active layer
*/
- int getActiveLayer()
+ LAYER_NUM getActiveLayer()
{
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
}
@@ -1206,7 +1206,7 @@ public:
bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
- void SwitchLayer( wxDC* DC, int layer );
+ void SwitchLayer( wxDC* DC, LAYER_NUM layer );
/**
* Function Add45DegreeSegment
@@ -1406,7 +1406,7 @@ public:
DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T shape, wxDC* DC );
void End_Edge( DRAWSEGMENT* Segment, wxDC* DC );
void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC );
- void Delete_Drawings_All_Layer( int aLayer );
+ void Delete_Drawings_All_Layer( LAYER_NUM aLayer );
// Dimension handling:
void ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* aDC );
diff --git a/pcbnew/autorouter/autoplac.cpp b/pcbnew/autorouter/autoplac.cpp
index 431e25bf8a..ce7d5bb9d8 100644
--- a/pcbnew/autorouter/autoplac.cpp
+++ b/pcbnew/autorouter/autoplac.cpp
@@ -99,7 +99,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
wxPoint PosOK;
wxPoint memopos;
int error;
- int lay_tmp_TOP, lay_tmp_BOTTOM;
+ LAYER_NUM lay_tmp_TOP, lay_tmp_BOTTOM;
// Undo: init list
PICKED_ITEMS_LIST newList;
@@ -457,7 +457,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
/* Place the edge layer segments */
TRACK TmpSegm( NULL );
- TmpSegm.SetLayer( -1 );
+ TmpSegm.SetLayer( UNDEFINED_LAYER );
TmpSegm.SetNet( -1 );
TmpSegm.SetWidth( RoutingMatrix.m_GridRouting / 2 );
diff --git a/pcbnew/autorouter/routing_matrix.cpp b/pcbnew/autorouter/routing_matrix.cpp
index 5508ffda70..5ed0f91e4b 100644
--- a/pcbnew/autorouter/routing_matrix.cpp
+++ b/pcbnew/autorouter/routing_matrix.cpp
@@ -240,7 +240,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
tmpSegm.SetLayer( edge->GetLayer() );
if( tmpSegm.GetLayer() == EDGE_N )
- tmpSegm.SetLayer( -1 );
+ tmpSegm.SetLayer( UNDEFINED_LAYER );
tmpSegm.SetStart( edge->GetStart() );
tmpSegm.SetEnd( edge->GetEnd() );
@@ -275,7 +275,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
if( DrawSegm->GetLayer() == EDGE_N )
{
- tmpSegm.SetLayer( -1 );
+ tmpSegm.SetLayer( UNDEFINED_LAYER );
type_cell |= CELL_is_EDGE;
}
diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp
index c35d951f86..a4eedd1c48 100644
--- a/pcbnew/basepcbframe.cpp
+++ b/pcbnew/basepcbframe.cpp
@@ -305,9 +305,9 @@ void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
// Note: virtual, overridden in PCB_EDIT_FRAME;
-void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, int layer )
+void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
{
- int preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
+ LAYER_NUM preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
// Check if the specified layer matches the present layer
if( layer == preslayer )
diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp
index a95a6c159e..88e96f8abf 100644
--- a/pcbnew/block.cpp
+++ b/pcbnew/block.cpp
@@ -393,7 +393,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
{
for( MODULE* module = m_Pcb->m_Modules; module != NULL; module = module->Next() )
{
- int layer = module->GetLayer();
+ LAYER_NUM layer = module->GetLayer();
if( module->HitTest( GetScreen()->m_BlockLocate )
&& ( !module->IsLocked() || blockIncludeLockedModules ) )
diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp
index 8a03a3002f..88cfaa49b1 100644
--- a/pcbnew/board_undo_redo.cpp
+++ b/pcbnew/board_undo_redo.cpp
@@ -198,7 +198,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
if( aItem->Type() != PCB_MODULE_T && aItem->Type() != PCB_ZONE_AREA_T )
{
// These items have a global swap function.
- int layer, layerimg;
+ LAYER_NUM layer, layerimg;
layer = aItem->GetLayer();
layerimg = aImage->GetLayer();
aItem->SetLayer( layerimg );
diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp
index 7ccfdb71d8..a71bbef987 100644
--- a/pcbnew/class_board.cpp
+++ b/pcbnew/class_board.cpp
@@ -75,7 +75,7 @@ BOARD::BOARD() :
BuildListOfNets(); // prepare pad and netlist containers.
- for( int layer = 0; layer < LAYER_COUNT; ++layer )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
{
m_Layer[layer].m_Name = GetStandardLayerName( layer );
@@ -344,7 +344,7 @@ int BOARD::GetCurrentMicroViaDrill()
}
-bool BOARD::SetLayer( int aIndex, const LAYER& aLayer )
+bool BOARD::SetLayer( LAYER_NUM aIndex, const LAYER& aLayer )
{
if( aIndex < NB_COPPER_LAYERS )
{
@@ -356,9 +356,9 @@ bool BOARD::SetLayer( int aIndex, const LAYER& aLayer )
}
-wxString BOARD::GetLayerName( int aLayerIndex ) const
+wxString BOARD::GetLayerName( LAYER_NUM aLayerIndex ) const
{
- if( !IsValidLayerIndex( aLayerIndex ) )
+ if( !IsValidPcbLayerIndex( aLayerIndex ) )
return wxEmptyString;
// All layer names are stored in the BOARD.
@@ -368,7 +368,7 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const
// over-ridden by BOARD::SetLayerName().
// For copper layers, return the actual copper layer name,
// otherwise return the Standard English layer name.
- if( aLayerIndex < FIRST_NO_COPPER_LAYER )
+ if( aLayerIndex < FIRST_NON_COPPER_LAYER )
return m_Layer[aLayerIndex].m_Name;
}
@@ -376,7 +376,7 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const
}
-wxString BOARD::GetStandardLayerName( int aLayerNumber )
+wxString BOARD::GetStandardLayerName( LAYER_NUM aLayerNumber )
{
const wxChar* txt;
@@ -422,7 +422,7 @@ wxString BOARD::GetStandardLayerName( int aLayerNumber )
}
-bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
+bool BOARD::SetLayerName( LAYER_NUM aLayerIndex, const wxString& aLayerName )
{
if( !IsValidCopperLayerIndex( aLayerIndex ) )
return false;
@@ -441,7 +441,7 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
if( IsLayerEnabled( aLayerIndex ) )
{
- for( int i = 0; i < NB_COPPER_LAYERS; i++ )
+ for( LAYER_NUM i = FIRST_COPPER_LAYER; i < NB_COPPER_LAYERS; ++i )
{
if( i != aLayerIndex && IsLayerEnabled( i ) && NameTemp == m_Layer[i].m_Name )
return false;
@@ -456,7 +456,7 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
}
-LAYER_T BOARD::GetLayerType( int aLayerIndex ) const
+LAYER_T BOARD::GetLayerType( LAYER_NUM aLayerIndex ) const
{
if( !IsValidCopperLayerIndex( aLayerIndex ) )
return LT_SIGNAL;
@@ -470,7 +470,7 @@ LAYER_T BOARD::GetLayerType( int aLayerIndex ) const
}
-bool BOARD::SetLayerType( int aLayerIndex, LAYER_T aLayerType )
+bool BOARD::SetLayerType( LAYER_NUM aLayerIndex, LAYER_T aLayerType )
{
if( !IsValidCopperLayerIndex( aLayerIndex ) )
return false;
@@ -574,7 +574,7 @@ void BOARD::SetVisibleElements( int aMask )
for( int ii = 0; ii < PCB_VISIBLE( END_PCB_VISIBLE_LIST ); ii++ )
{
int item_mask = 1 << ii;
- SetElementVisibility( ii, bool( aMask & item_mask ) );
+ SetElementVisibility( ii, aMask & item_mask );
}
}
@@ -683,19 +683,19 @@ void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, EDA_COLOR_T aColor )
}
-void BOARD::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
+void BOARD::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{
GetColorsSettings()->SetLayerColor( aLayer, aColor );
}
-EDA_COLOR_T BOARD::GetLayerColor( int aLayer ) const
+EDA_COLOR_T BOARD::GetLayerColor( LAYER_NUM aLayer ) const
{
return GetColorsSettings()->GetLayerColor( aLayer );
}
-bool BOARD::IsModuleLayerVisible( int layer )
+bool BOARD::IsModuleLayerVisible( LAYER_NUM layer )
{
if( layer==LAYER_N_FRONT )
return IsElementVisible( PCB_VISIBLE(MOD_FR_VISIBLE) );
@@ -1195,16 +1195,16 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
/* now using PcbGeneralLocateAndDisplay(), but this remains a useful example
* of how the INSPECTOR can be used in a lightweight way.
* // see pcbstruct.h
- * BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer )
+ * BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, LAYER_NUM layer )
* {
* class PadOrModule : public INSPECTOR
* {
* public:
* BOARD_ITEM* found;
- * int layer;
+ * LAYER_NUM layer;
* int layer_mask;
*
- * PadOrModule( int alayer ) :
+ * PadOrModule( LAYER_NUM alayer ) :
* found(0), layer(alayer), layer_mask( g_TabOneLayerMask[alayer] )
* {}
*
@@ -1437,7 +1437,7 @@ int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCoun
}
-void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, int aLayer )
+void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, LAYER_NUM aLayer )
{
if( !aDC )
return;
@@ -1452,7 +1452,7 @@ void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE a
}
-void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, int aLayer )
+void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, LAYER_NUM aLayer )
{
if( !aDC )
return;
@@ -1468,8 +1468,8 @@ void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDr
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
- int aStartLayer,
- int aEndLayer )
+ LAYER_NUM aStartLayer,
+ LAYER_NUM aEndLayer )
{
if( aEndLayer < 0 )
aEndLayer = aStartLayer;
@@ -1480,7 +1480,7 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
{
ZONE_CONTAINER* area = m_ZoneDescriptorList[ia];
- int layer = area->GetLayer();
+ LAYER_NUM layer = area->GetLayer();
if( (layer < aStartLayer) || (layer > aEndLayer) )
continue;
@@ -1531,7 +1531,7 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
}
-TRACK* BOARD::GetViaByPosition( const wxPoint& aPosition, int aLayerMask )
+TRACK* BOARD::GetViaByPosition( const wxPoint& aPosition, LAYER_NUM aLayer)
{
TRACK* track;
@@ -1546,10 +1546,10 @@ TRACK* BOARD::GetViaByPosition( const wxPoint& aPosition, int aLayerMask )
if( track->GetState( BUSY | IS_DELETED ) )
continue;
- if( aLayerMask < 0 )
+ if( aLayer == UNDEFINED_LAYER )
break;
- if( track->IsOnLayer( aLayerMask ) )
+ if( track->IsOnLayer( aLayer ) )
break;
}
@@ -1751,7 +1751,7 @@ TRACK* BOARD::GetTrace( TRACK* aTrace, const wxPoint& aPosition, LAYER_MSK aLaye
{
for( TRACK* track = aTrace; track; track = track->Next() )
{
- int layer = track->GetLayer();
+ LAYER_NUM layer = track->GetLayer();
if( track->GetState( BUSY | IS_DELETED ) )
continue;
@@ -1893,7 +1893,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
* if there are on the same layer, the via is on the selected track
* if there are on different layers, the via is on an other track
*/
- int layer = track->GetLayer();
+ LAYER_NUM layer = track->GetLayer();
while( ( track = ::GetTrace( track->Next(), NULL, via->GetStart(), layerMask ) ) != NULL )
{
@@ -2018,7 +2018,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
}
-MODULE* BOARD::GetFootprint( const wxPoint& aPosition, int aActiveLayer,
+MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked )
{
MODULE* pt_module;
@@ -2026,7 +2026,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, int aActiveLayer,
MODULE* Altmodule = NULL;
int min_dim = 0x7FFFFFFF;
int alt_min_dim = 0x7FFFFFFF;
- int layer;
+ LAYER_NUM layer;
for( pt_module = m_Modules; pt_module; pt_module = (MODULE*) pt_module->Next() )
{
@@ -2213,7 +2213,7 @@ void BOARD::SetTrackWidthIndex( unsigned aIndex )
ZONE_CONTAINER* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode,
- int aLayer, wxPoint aStartPointPosition, int aHatch )
+ LAYER_NUM aLayer, wxPoint aStartPointPosition, int aHatch )
{
ZONE_CONTAINER* new_area = InsertArea( aNetcode,
m_ZoneDescriptorList.size( ) - 1,
@@ -2248,7 +2248,7 @@ void BOARD::RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to
}
-ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch )
+ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, LAYER_NUM layer, int x, int y, int hatch )
{
ZONE_CONTAINER* new_area = new ZONE_CONTAINER( this );
diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h
index c397e3d05b..bd2885df42 100644
--- a/pcbnew/class_board.h
+++ b/pcbnew/class_board.h
@@ -188,7 +188,7 @@ private:
/// edge zone descriptors, owned by pointer.
ZONE_CONTAINERS m_ZoneDescriptorList;
- LAYER m_Layer[LAYER_COUNT];
+ LAYER m_Layer[NB_LAYERS];
// if true m_highLight_NetCode is used
HIGH_LIGHT_INFO m_highLight; // current high light data
HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
@@ -442,7 +442,7 @@ public:
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
*/
- bool IsLayerEnabled( int aLayer ) const
+ bool IsLayerEnabled( LAYER_NUM aLayer ) const
{
return m_designSettings.IsLayerEnabled( aLayer );
}
@@ -454,7 +454,7 @@ public:
* @param aLayerIndex = The index of the layer to be tested
* @return bool - true if the layer is visible.
*/
- bool IsLayerVisible( int aLayerIndex ) const
+ bool IsLayerVisible( LAYER_NUM aLayerIndex ) const
{
return m_designSettings.IsLayerVisible( aLayerIndex );
}
@@ -529,7 +529,7 @@ public:
* @param layer One of the two allowed layers for modules: LAYER_N_FRONT or LAYER_N_BACK
* @return bool - true if the layer is visible, else false.
*/
- bool IsModuleLayerVisible( int layer );
+ bool IsModuleLayerVisible( LAYER_NUM layer );
/**
* Function GetVisibleElementColor
@@ -596,7 +596,7 @@ public:
* @return wxString - the layer name, which for copper layers may
* be custom, else standard.
*/
- wxString GetLayerName( int aLayerIndex ) const;
+ wxString GetLayerName( LAYER_NUM aLayerIndex ) const;
/**
* Function SetLayerName
@@ -607,7 +607,7 @@ public:
* @return bool - true if aLayerName was legal and unique among other
* layer names at other layer indices and aLayerIndex was within range, else false.
*/
- bool SetLayerName( int aLayerIndex, const wxString& aLayerName );
+ bool SetLayerName( LAYER_NUM aLayerIndex, const wxString& aLayerName );
/**
* Function GetStandardLayerName
@@ -620,9 +620,9 @@ public:
* @return wxString - containing the layer name or "BAD INDEX" if aLayerNumber
* is not legal
*/
- static wxString GetStandardLayerName( int aLayerNumber );
+ static wxString GetStandardLayerName( LAYER_NUM aLayerNumber );
- bool SetLayer( int aIndex, const LAYER& aLayer );
+ bool SetLayer( LAYER_NUM aIndex, const LAYER& aLayer );
/**
* Function GetLayerType
@@ -632,7 +632,7 @@ public:
* @return LAYER_T - the layer type, or LAYER_T(-1) if the
* index was out of range.
*/
- LAYER_T GetLayerType( int aLayerIndex ) const;
+ LAYER_T GetLayerType( LAYER_NUM aLayerIndex ) const;
/**
* Function SetLayerType
@@ -642,19 +642,19 @@ public:
* @param aLayerType The new layer type.
* @return bool - true if aLayerType was legal and aLayerIndex was within range, else false.
*/
- bool SetLayerType( int aLayerIndex, LAYER_T aLayerType );
+ bool SetLayerType( LAYER_NUM aLayerIndex, LAYER_T aLayerType );
/**
* Function SetLayerColor
* changes a layer color for any valid layer, including non-copper ones.
*/
- void SetLayerColor( int aLayer, EDA_COLOR_T aColor );
+ void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
/**
* Function GetLayerColor
* gets a layer color for any valid layer, including non-copper ones.
*/
- EDA_COLOR_T GetLayerColor( int aLayer ) const;
+ EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
/**
* Function ReturnFlippedLayerNumber
@@ -662,7 +662,7 @@ public:
* some (not all) layers: external copper, Mask, Paste, and solder
* are swapped between front and back sides
*/
- static int ReturnFlippedLayerNumber( int oldlayer );
+ static LAYER_NUM ReturnFlippedLayerNumber( LAYER_NUM oldlayer );
/** Functions to get some items count */
int GetNumSegmTrack() const;
@@ -1005,8 +1005,8 @@ public:
* @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else NULL
*/
ZONE_CONTAINER* HitTestForAnyFilledArea( const wxPoint& aRefPos,
- int aStartLayer,
- int aEndLayer = -1 );
+ LAYER_NUM aStartLayer,
+ LAYER_NUM aEndLayer = UNDEFINED_LAYER );
/**
* Function RedrawAreasOutlines
@@ -1015,14 +1015,14 @@ public:
void RedrawAreasOutlines( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
GR_DRAWMODE aDrawMode,
- int aLayer );
+ LAYER_NUM aLayer );
/**
* Function RedrawFilledAreas
* Redraw all filled areas on layer aLayer ( redraw all if aLayer < 0 )
*/
void RedrawFilledAreas( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
- int aLayer );
+ LAYER_NUM aLayer );
/**
* Function SetAreasNetCodesFromNetNames
@@ -1090,14 +1090,14 @@ public:
* @return a reference to the new area
*/
ZONE_CONTAINER* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode,
- int aLayer, wxPoint aStartPointPosition, int aHatch );
+ LAYER_NUM aLayer, wxPoint aStartPointPosition, int aHatch );
/**
* Function InsertArea
* add empty copper area to net, inserting after m_ZoneDescriptorList[iarea]
* @return pointer to the new area
*/
- ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch );
+ ZONE_CONTAINER* InsertArea( int netcode, int iarea, LAYER_NUM layer, int x, int y, int hatch );
/**
* Function NormalizeAreaPolygon
@@ -1210,10 +1210,10 @@ public:
* of the via.
*
* @param aPosition The wxPoint to HitTest() against.
- * @param aLayerMask The layers to search. Use -1 for a don't care.
+ * @param aLayer The layer to search. Use -1 for a don't care.
* @return TRACK* A point a to the SEGVIA object if found, else NULL.
*/
- TRACK* GetViaByPosition( const wxPoint& aPosition, int aLayerMask = -1 );
+ TRACK* GetViaByPosition( const wxPoint& aPosition, LAYER_NUM aLayer = UNDEFINED_LAYER );
/**
* Function GetPad
@@ -1332,7 +1332,7 @@ public:
* @param aIgnoreLocked Ignore locked modules when true.
* @return MODULE* The best module or NULL if none.
*/
- MODULE* GetFootprint( const wxPoint& aPosition, int aActiveLayer,
+ MODULE* GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked = false );
/**
diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp
index a7764d807f..633a685507 100644
--- a/pcbnew/class_board_design_settings.cpp
+++ b/pcbnew/class_board_design_settings.cpp
@@ -191,7 +191,7 @@ void BOARD_DESIGN_SETTINGS::SetVisibleLayers( LAYER_MSK aMask )
}
-void BOARD_DESIGN_SETTINGS::SetLayerVisibility( int aLayerIndex, bool aNewState )
+void BOARD_DESIGN_SETTINGS::SetLayerVisibility( LAYER_NUM aLayerIndex, bool aNewState )
{
// Altough Pcbnew uses only 29, GerbView uses all 32 layers
if( aLayerIndex < 0 || aLayerIndex >= 32 )
@@ -229,7 +229,7 @@ void BOARD_DESIGN_SETTINGS::SetCopperLayerCount( int aNewLayerCount )
if( m_CopperLayerCount > 1 )
m_EnabledLayers |= LAYER_FRONT;
- for( int ii = LAYER_N_2; ii < aNewLayerCount - 1; ++ii )
+ for( LAYER_NUM ii = LAYER_N_2; ii < aNewLayerCount - 1; ++ii )
m_EnabledLayers |= GetLayerMask( ii );
}
@@ -247,9 +247,10 @@ void BOARD_DESIGN_SETTINGS::SetEnabledLayers( LAYER_MSK aMask )
// update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
m_CopperLayerCount = 0;
- for( int ii = 0; aMask && ii < NB_COPPER_LAYERS; ii++, aMask >>= 1 )
+ unsigned shiftMask = aMask;
+ for( LAYER_NUM ii = FIRST_LAYER; aMask && ii < NB_COPPER_LAYERS; ++ii, shiftMask >>= 1 )
{
- if( aMask & 1 )
+ if( shiftMask & 1 )
m_CopperLayerCount++;
}
}
diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp
index 6d3183107d..1b77f73417 100644
--- a/pcbnew/class_dimension.cpp
+++ b/pcbnew/class_dimension.cpp
@@ -49,7 +49,7 @@ DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, PCB_DIMENSION_T ),
m_Text( this )
{
- m_Layer = DRAW_LAYER;
+ m_Layer = DRAW_N;
m_Width = Millimeter2iu( 0.2 );
m_Value = 0;
m_Shape = 0;
@@ -86,7 +86,7 @@ const wxString DIMENSION::GetText() const
}
-void DIMENSION::SetLayer( int aLayer )
+void DIMENSION::SetLayer( LAYER_NUM aLayer )
{
m_Layer = aLayer;
m_Text.SetLayer( aLayer );
diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h
index 42b32930e0..26f17d72b1 100644
--- a/pcbnew/class_dimension.h
+++ b/pcbnew/class_dimension.h
@@ -80,7 +80,7 @@ public:
m_Text.SetSize( aTextSize );
}
- void SetLayer( int aLayer );
+ void SetLayer( LAYER_NUM aLayer );
void SetShape( int aShape ) { m_Shape = aShape; }
int GetShape() const { return m_Shape; }
diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp
index 746442fea9..9e23534245 100644
--- a/pcbnew/class_drawsegment.cpp
+++ b/pcbnew/class_drawsegment.cpp
@@ -55,7 +55,8 @@
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_ITEM( aParent, idtype )
{
- m_Width = m_Flags = m_Type = m_Angle = 0;
+ m_Width = m_Type = m_Angle = 0;
+ m_Flags = 0;
m_Shape = S_SEGMENT;
}
@@ -175,7 +176,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
int l_trace;
int mode;
int radius;
- int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
+ LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
EDA_COLOR_T color;
BOARD * brd = GetBoard( );
diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp
index 1d73a2f9be..5ea8860864 100644
--- a/pcbnew/class_edge_mod.cpp
+++ b/pcbnew/class_edge_mod.cpp
@@ -103,7 +103,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
int ux0, uy0, dx, dy, radius, StAngle, EndAngle;
int type_trace;
int typeaff;
- int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
+ LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
PCB_BASE_FRAME* frame;
MODULE* module = (MODULE*) m_Parent;
diff --git a/pcbnew/class_marker_pcb.cpp b/pcbnew/class_marker_pcb.cpp
index d16c973855..d7c4beb2e4 100644
--- a/pcbnew/class_marker_pcb.cpp
+++ b/pcbnew/class_marker_pcb.cpp
@@ -86,7 +86,7 @@ MARKER_PCB::~MARKER_PCB()
* param aLayer The layer to test for.
* return bool - true if on given layer, else false.
*/
-bool MARKER_PCB::IsOnLayer( int aLayer ) const
+bool MARKER_PCB::IsOnLayer( LAYER_NUM aLayer ) const
{
return IsValidCopperLayerIndex( aLayer );
}
diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h
index d1fc47ec7a..7728b152c0 100644
--- a/pcbnew/class_marker_pcb.h
+++ b/pcbnew/class_marker_pcb.h
@@ -69,7 +69,7 @@ public:
return HitTestMarker( aPosition );
}
- bool IsOnLayer( int aLayer ) const;
+ bool IsOnLayer( LAYER_NUM aLayer ) const;
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp
index 340d2020f5..c05a03dfee 100644
--- a/pcbnew/class_mire.cpp
+++ b/pcbnew/class_mire.cpp
@@ -53,7 +53,7 @@ PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :
m_Size = 5000;
}
-PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent, int aShape, int aLayer,
+PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent, int aShape, LAYER_NUM aLayer,
const wxPoint& aPos, int aSize, int aWidth ) :
BOARD_ITEM( aParent, PCB_TARGET_T )
{
diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h
index e454c3431c..32f02dd103 100644
--- a/pcbnew/class_mire.h
+++ b/pcbnew/class_mire.h
@@ -51,7 +51,7 @@ public:
// Do not create a copy constructor. The one generated by the compiler is adequate.
- PCB_TARGET( BOARD_ITEM* aParent, int aShape, int aLayer,
+ PCB_TARGET( BOARD_ITEM* aParent, int aShape, LAYER_NUM aLayer,
const wxPoint& aPos, int aSize, int aWidth );
~PCB_TARGET();
diff --git a/pcbnew/class_module_transform_functions.cpp b/pcbnew/class_module_transform_functions.cpp
index be9bb14dc8..159b83697d 100644
--- a/pcbnew/class_module_transform_functions.cpp
+++ b/pcbnew/class_module_transform_functions.cpp
@@ -22,9 +22,9 @@
* some layers: external copper, Mask, Paste, and solder
* are swapped between front and back sides
*/
-int BOARD::ReturnFlippedLayerNumber( int oldlayer )
+LAYER_NUM BOARD::ReturnFlippedLayerNumber( LAYER_NUM oldlayer )
{
- int newlayer;
+ LAYER_NUM newlayer;
switch( oldlayer )
{
diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp
index d80ff222ae..ee52e4ad20 100644
--- a/pcbnew/class_pad.cpp
+++ b/pcbnew/class_pad.cpp
@@ -688,7 +688,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
// see class_pad.h
-bool D_PAD::IsOnLayer( int aLayer ) const
+bool D_PAD::IsOnLayer( LAYER_NUM aLayer ) const
{
return ::GetLayerMask( aLayer ) & m_layerMask;
}
diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h
index a7003f9cfb..55387f4378 100644
--- a/pcbnew/class_pad.h
+++ b/pcbnew/class_pad.h
@@ -345,7 +345,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
- bool IsOnLayer( int aLayer ) const;
+ bool IsOnLayer( LAYER_NUM aLayer ) const;
bool HitTest( const wxPoint& aPosition );
diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp
index 09d1862a71..5db58b736f 100644
--- a/pcbnew/class_pad_draw_functions.cpp
+++ b/pcbnew/class_pad_draw_functions.cpp
@@ -240,8 +240,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
// when routing tracks
if( frame && frame->GetToolId() == ID_TRACK_BUTT )
{
- int routeTop = screen->m_Route_Layer_TOP;
- int routeBot = screen->m_Route_Layer_BOTTOM;
+ LAYER_NUM routeTop = screen->m_Route_Layer_TOP;
+ LAYER_NUM routeBot = screen->m_Route_Layer_BOTTOM;
// if routing between copper and component layers,
// or the current layer is one of said 2 external copper layers,
diff --git a/pcbnew/class_pcb_layer_box_selector.cpp b/pcbnew/class_pcb_layer_box_selector.cpp
index e44dabaa7d..be7c847f33 100644
--- a/pcbnew/class_pcb_layer_box_selector.cpp
+++ b/pcbnew/class_pcb_layer_box_selector.cpp
@@ -58,11 +58,11 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
static DECLARE_LAYERS_ORDER_LIST( layertranscode );
static DECLARE_LAYERS_HOTKEY( layerhk );
- for( int i = 0; i < LAYER_COUNT; i++ )
+ for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{
wxBitmap layerbmp( 14, 14 );
wxString layername;
- int layerid = i;
+ LAYER_NUM layerid = i;
if( m_layerorder )
layerid = layertranscode[i];
@@ -83,7 +83,7 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
// Returns true if the layer id is enabled (i.e. is it should be displayed)
-bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( int aLayerIndex ) const
+bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( LAYER_NUM aLayerIndex ) const
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
@@ -94,7 +94,7 @@ bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( int aLayerIndex ) const
// Returns a color index from the layer id
-EDA_COLOR_T PCB_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) const
+EDA_COLOR_T PCB_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayerIndex ) const
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
@@ -105,7 +105,7 @@ EDA_COLOR_T PCB_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex ) const
// Returns the name of the layer id
-wxString PCB_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex ) const
+wxString PCB_LAYER_BOX_SELECTOR::GetLayerName( LAYER_NUM aLayerIndex ) const
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
diff --git a/pcbnew/class_pcb_layer_box_selector.h b/pcbnew/class_pcb_layer_box_selector.h
index 790988fd07..ef75213cc4 100644
--- a/pcbnew/class_pcb_layer_box_selector.h
+++ b/pcbnew/class_pcb_layer_box_selector.h
@@ -40,34 +40,15 @@ public:
// Returns a color index from the layer id
// Virtual function
- EDA_COLOR_T GetLayerColor( int aLayerIndex ) const;
+ EDA_COLOR_T GetLayerColor( LAYER_NUM aLayerIndex ) const;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function
- bool IsLayerEnabled( int aLayerIndex ) const;
+ bool IsLayerEnabled( LAYER_NUM aLayerIndex ) const;
// Returns the name of the layer id
// Virtual function
- wxString GetLayerName( int aLayerIndex ) const;
+ wxString GetLayerName( LAYER_NUM aLayerIndex ) const;
};
-#define DECLARE_LAYERS_HOTKEY(list) int list[LAYER_COUNT] = \
- { \
- HK_SWITCH_LAYER_TO_COPPER, \
- HK_SWITCH_LAYER_TO_INNER1, \
- HK_SWITCH_LAYER_TO_INNER2, \
- HK_SWITCH_LAYER_TO_INNER3, \
- HK_SWITCH_LAYER_TO_INNER4, \
- HK_SWITCH_LAYER_TO_INNER5, \
- HK_SWITCH_LAYER_TO_INNER6, \
- HK_SWITCH_LAYER_TO_INNER7, \
- HK_SWITCH_LAYER_TO_INNER8, \
- HK_SWITCH_LAYER_TO_INNER9, \
- HK_SWITCH_LAYER_TO_INNER10, \
- HK_SWITCH_LAYER_TO_INNER11, \
- HK_SWITCH_LAYER_TO_INNER12, \
- HK_SWITCH_LAYER_TO_INNER13, \
- HK_SWITCH_LAYER_TO_INNER14, \
- HK_SWITCH_LAYER_TO_COMPONENT \
- };
#endif //CLASS_PCB_PCB_LAYER_BOX_SELECTOR_H
diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp
index 6de78f808d..a852a2723d 100644
--- a/pcbnew/class_pcb_layer_widget.cpp
+++ b/pcbnew/class_pcb_layer_widget.cpp
@@ -151,7 +151,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
for( int row=rowCount-1; row>=0; --row )
{
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
- int layer = getDecodedId( cb->GetId() );
+ LAYER_NUM layer = getDecodedId( cb->GetId() );
if( IsValidCopperLayerIndex( layer ) )
{
lastCu = row;
@@ -162,7 +162,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
for( int row=0; rowGetId() );
+ LAYER_NUM layer = getDecodedId( cb->GetId() );
if( IsValidCopperLayerIndex( layer ) )
{
@@ -241,7 +241,7 @@ void PCB_LAYER_WIDGET::SyncLayerVisibilities()
wxWindow* w = getLayerComp( row, 0 );
- int layerId = getDecodedId( w->GetId() );
+ LAYER_NUM layerId = getDecodedId( w->GetId() );
// this does not fire a UI event
SetLayerVisible( layerId, board->IsLayerVisible( layerId ) );
@@ -252,7 +252,7 @@ void PCB_LAYER_WIDGET::SyncLayerVisibilities()
void PCB_LAYER_WIDGET::ReFill()
{
BOARD* brd = myframe->GetBoard();
- int layer;
+ LAYER_NUM layer;
int enabledLayers = brd->GetEnabledLayers();
@@ -269,7 +269,7 @@ void PCB_LAYER_WIDGET::ReFill()
brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ), _("Front copper layer"), true ) );
}
- for( layer = LAYER_N_FRONT-1; layer >= 1; --layer )
+ for( layer = LAYER_N_FRONT-1; layer >= 1; --layer )
{
if( enabledLayers & GetLayerMask( layer ) )
{
@@ -287,7 +287,7 @@ void PCB_LAYER_WIDGET::ReFill()
// technical layers are shown in this order:
static const struct {
- int layerId;
+ LAYER_NUM layerId;
wxString tooltip;
} techLayerSeq[] = {
{ ADHESIVE_N_FRONT, _( "Adhesive on board's front" ) },
@@ -324,7 +324,7 @@ void PCB_LAYER_WIDGET::ReFill()
//------------------------------------------------
-void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
+void PCB_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{
myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->ReCreateLayerBox( NULL );
@@ -332,7 +332,7 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
}
-bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
+bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
{
// the layer change from the PCB_LAYER_WIDGET can be denied by returning
// false from this function.
@@ -345,7 +345,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
}
-void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
+void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal )
{
BOARD* brd = myframe->GetBoard();
diff --git a/pcbnew/class_pcb_layer_widget.h b/pcbnew/class_pcb_layer_widget.h
index 8fa09595b5..dd8d8ade01 100644
--- a/pcbnew/class_pcb_layer_widget.h
+++ b/pcbnew/class_pcb_layer_widget.h
@@ -82,9 +82,9 @@ public:
void SetLayersManagerTabsText();
//----------------
- void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor );
- bool OnLayerSelect( int aLayer );
- void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
+ void OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor );
+ bool OnLayerSelect( LAYER_NUM aLayer );
+ void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal );
void OnRenderColorChange( int aId, EDA_COLOR_T aColor );
void OnRenderEnable( int aId, bool isEnabled );
//---------------
diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp
index bbcacd4f8b..bd0b9790e3 100644
--- a/pcbnew/class_text_mod.cpp
+++ b/pcbnew/class_text_mod.cpp
@@ -71,7 +71,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
{
m_Pos = module->GetPosition();
- int moduleLayer = module->GetLayer();
+ LAYER_NUM moduleLayer = module->GetLayer();
if( moduleLayer == LAYER_N_BACK )
SetLayer( SILKSCREEN_N_BACK );
@@ -397,7 +397,7 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
BOARD* board = NULL;
board = (BOARD*) module->GetParent();
- if( m_Layer < NB_LAYERS && board )
+ if( m_Layer < NB_PCB_LAYERS && board )
msg = board->GetLayerName( m_Layer );
else
msg.Printf( wxT( "%d" ), m_Layer );
@@ -426,7 +426,7 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
// see class_text_mod.h
-bool TEXTE_MODULE::IsOnLayer( int aLayer ) const
+bool TEXTE_MODULE::IsOnLayer( LAYER_NUM aLayer ) const
{
if( m_Layer == aLayer )
return true;
diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h
index 6394f0a7c8..e5087c9ed5 100644
--- a/pcbnew/class_text_mod.h
+++ b/pcbnew/class_text_mod.h
@@ -130,7 +130,7 @@ public:
bool HitTest( const wxPoint& aPosition );
- bool IsOnLayer( int aLayer ) const;
+ bool IsOnLayer( LAYER_NUM aLayer ) const;
wxString GetClass() const
diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp
index 514c091529..0f8aa12aaa 100644
--- a/pcbnew/class_track.cpp
+++ b/pcbnew/class_track.cpp
@@ -222,8 +222,8 @@ wxString SEGVIA::GetSelectMenuText() const
if( shape != VIA_THROUGH )
{
// say which layers, only two for now
- int topLayer;
- int botLayer;
+ LAYER_NUM topLayer;
+ LAYER_NUM botLayer;
ReturnLayerPair( &topLayer, &botLayer );
text << _( " on " ) << board->GetLayerName( topLayer ).Trim() << wxT( " <-> " )
<< board->GetLayerName( botLayer ).Trim();
@@ -416,9 +416,9 @@ SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData,
}
-bool SEGVIA::IsOnLayer( int layer_number ) const
+bool SEGVIA::IsOnLayer( LAYER_NUM layer_number ) const
{
- int bottom_layer, top_layer;
+ LAYER_NUM bottom_layer, top_layer;
ReturnLayerPair( &top_layer, &bottom_layer );
@@ -440,7 +440,7 @@ LAYER_MSK TRACK::GetLayerMask() const
// VIA_BLIND_BURIED or VIA_MICRVIA:
- int bottom_layer, top_layer;
+ LAYER_NUM bottom_layer, top_layer;
// ReturnLayerPair() knows how layers are stored
( (SEGVIA*) this )->ReturnLayerPair( &top_layer, &bottom_layer );
@@ -462,7 +462,7 @@ LAYER_MSK TRACK::GetLayerMask() const
}
-void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
+void SEGVIA::SetLayerPair( LAYER_NUM top_layer, LAYER_NUM bottom_layer )
{
if( GetShape() == VIA_THROUGH )
{
@@ -473,17 +473,19 @@ void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
if( bottom_layer > top_layer )
EXCHG( bottom_layer, top_layer );
+ // XXX EVIL usage of LAYER
m_Layer = (top_layer & 15) + ( (bottom_layer & 15) << 4 );
}
-void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
+void SEGVIA::ReturnLayerPair( LAYER_NUM* top_layer, LAYER_NUM* bottom_layer ) const
{
- int b_layer = LAYER_N_BACK;
- int t_layer = LAYER_N_FRONT;
+ LAYER_NUM b_layer = LAYER_N_BACK;
+ LAYER_NUM t_layer = LAYER_N_FRONT;
if( GetShape() != VIA_THROUGH )
{
+ // XXX EVIL usage of LAYER
b_layer = (m_Layer >> 4) & 15;
t_layer = m_Layer & 15;
@@ -586,7 +588,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
{
int l_trace;
int radius;
- int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
+ LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
if( Type() == PCB_ZONE_T && DisplayOpt.DisplayZonesMode != 0 )
return;
@@ -751,7 +753,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
const wxPoint& aOffset )
{
int radius;
- int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
+ LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
int fillvia = 0;
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
@@ -906,7 +908,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( GetShape() == VIA_BLIND_BURIED )
{
int ax = 0, ay = radius, bx = 0, by = drill_radius;
- int layer_top, layer_bottom;
+ LAYER_NUM layer_top, layer_bottom;
( (SEGVIA*) this )->ReturnLayerPair( &layer_top, &layer_bottom );
@@ -1114,7 +1116,7 @@ void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
if( Type() == PCB_VIA_T )
{
SEGVIA* Via = (SEGVIA*) this;
- int top_layer, bottom_layer;
+ LAYER_NUM top_layer, bottom_layer;
Via->ReturnLayerPair( &top_layer, &bottom_layer );
msg = board->GetLayerName( top_layer ) + wxT( "/" ) + board->GetLayerName( bottom_layer );
@@ -1191,7 +1193,7 @@ bool TRACK::HitTest( const EDA_RECT& aRect ) const
}
-TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayer )
+TRACK* TRACK::GetVia( const wxPoint& aPosition, LAYER_NUM aLayer)
{
TRACK* track;
@@ -1206,7 +1208,7 @@ TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayer )
if( track->GetState( BUSY | IS_DELETED ) )
continue;
- if( aLayer < 0 )
+ if( aLayer == UNDEFINED_LAYER )
break;
if( track->IsOnLayer( aLayer ) )
@@ -1580,8 +1582,8 @@ void SEGVIA::Show( int nestLevel, std::ostream& os ) const
break;
}
- int topLayer;
- int botLayer;
+ LAYER_NUM topLayer;
+ LAYER_NUM botLayer;
BOARD* board = (BOARD*) m_Parent;
diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h
index 14d6eac95e..7bc1eff36b 100644
--- a/pcbnew/class_track.h
+++ b/pcbnew/class_track.h
@@ -268,7 +268,7 @@ public:
* @param aLayer The layer to match, pass -1 for a don't care.
* @return A pointer to a SEGVIA object if found, else NULL.
*/
- TRACK* GetVia( const wxPoint& aPosition, int aLayer = -1 );
+ TRACK* GetVia( const wxPoint& aPosition, LAYER_NUM aLayer = UNDEFINED_LAYER );
/**
* Function GetVia
@@ -377,7 +377,7 @@ public:
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset );
- bool IsOnLayer( int aLayer ) const;
+ bool IsOnLayer( LAYER_NUM aLayer ) const;
/**
* Function SetLayerPair
@@ -389,7 +389,7 @@ public:
* @param top_layer = first layer connected by the via
* @param bottom_layer = last layer connected by the via
*/
- void SetLayerPair( int top_layer, int bottom_layer );
+ void SetLayerPair( LAYER_NUM top_layer, LAYER_NUM bottom_layer );
/**
* Function ReturnLayerPair
@@ -398,7 +398,7 @@ public:
* @param top_layer = pointer to the first layer (can be null)
* @param bottom_layer = pointer to the last layer (can be null)
*/
- void ReturnLayerPair( int* top_layer, int* bottom_layer ) const;
+ void ReturnLayerPair( LAYER_NUM* top_layer, LAYER_NUM* bottom_layer ) const;
const wxPoint& GetPosition() const { return m_Start; } // was overload
void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } // was overload
diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp
index d3ad2608ea..6b161ad189 100644
--- a/pcbnew/class_zone.cpp
+++ b/pcbnew/class_zone.cpp
@@ -170,7 +170,7 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod
return;
wxPoint seg_start, seg_end;
- int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
+ LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
BOARD* brd = GetBoard();
EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
@@ -255,7 +255,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
return;
BOARD* brd = GetBoard();
- int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
+ LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
@@ -400,7 +400,7 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
if( DC == NULL )
return;
- int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
+ LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
BOARD* brd = GetBoard();
EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h
index 7b14356c49..c06d3076ab 100644
--- a/pcbnew/class_zone.h
+++ b/pcbnew/class_zone.h
@@ -183,7 +183,7 @@ public:
*/
bool IsOnCopperLayer( void ) const
{
- return ( GetLayer() < FIRST_NO_COPPER_LAYER ) ? true : false;
+ return ( GetLayer() < FIRST_NON_COPPER_LAYER ) ? true : false;
}
/**
diff --git a/pcbnew/class_zone_settings.cpp b/pcbnew/class_zone_settings.cpp
index af0d0e5d44..bdf85dbbd6 100644
--- a/pcbnew/class_zone_settings.cpp
+++ b/pcbnew/class_zone_settings.cpp
@@ -44,7 +44,7 @@ ZONE_SETTINGS::ZONE_SETTINGS()
// Min thickness value in filled areas (this is the minimum width of copper to fill solid areas) :
m_ZoneMinThickness = Mils2iu( ZONE_THICKNESS_MIL );
m_NetcodeSelection = 0; // Net code selection for the current zone
- m_CurrentZone_Layer = 0; // Layer used to create the current zone
+ m_CurrentZone_Layer = FIRST_LAYER; // Layer used to create the current zone
m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE; // Option to show the zone area (outlines only, short hatches or full hatches
m_ArcToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; // Option to select number of segments to approximate a circle
diff --git a/pcbnew/class_zone_settings.h b/pcbnew/class_zone_settings.h
index b26db0c7b8..0ec12f32df 100644
--- a/pcbnew/class_zone_settings.h
+++ b/pcbnew/class_zone_settings.h
@@ -39,7 +39,7 @@ public:
int m_ZoneClearance; ///< Clearance value
int m_ZoneMinThickness; ///< Min thickness value in filled areas
int m_NetcodeSelection; ///< Net code selection for the current zone
- int m_CurrentZone_Layer; ///< Layer used to create the current zone
+ LAYER_NUM m_CurrentZone_Layer; ///< Layer used to create the current zone
/// Option to show the zone area (outlines only, short hatches or full hatches
int m_Zone_HatchingStyle;
diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp
index b2b5e7a1fe..dc426d0c6c 100644
--- a/pcbnew/clean.cpp
+++ b/pcbnew/clean.cpp
@@ -182,7 +182,7 @@ void TRACKS_CLEANER::buildTrackConnectionInfo()
track->start = NULL;
track->end = NULL;
track->m_PadsConnected.clear();
- track->SetState( START_ON_PAD|END_ON_PAD|BUSY, OFF );
+ track->SetState( START_ON_PAD|END_ON_PAD|BUSY, false );
}
// Build connections info tracks to pads
@@ -197,13 +197,13 @@ void TRACKS_CLEANER::buildTrackConnectionInfo()
if( pad->HitTest( track->GetStart() ) )
{
track->start = pad;
- track->SetState( START_ON_PAD, ON );
+ track->SetState( START_ON_PAD, true );
}
if( pad->HitTest( track->GetEnd() ) )
{
track->end = pad;
- track->SetState( END_ON_PAD, ON );
+ track->SetState( END_ON_PAD, true );
}
}
}
@@ -309,7 +309,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
// For via test, an enhancement could be to test if connected
// to 2 items on different layers.
// Currently a via must be connected to 2 items, that can be on the same layer
- int top_layer, bottom_layer;
+ LAYER_NUM top_layer, bottom_layer;
ZONE_CONTAINER* zone;
if( (type_end & START_ON_PAD ) == 0 )
diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp
index 965f35a9ef..5970de7ef7 100644
--- a/pcbnew/collectors.cpp
+++ b/pcbnew/collectors.cpp
@@ -350,7 +350,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
if( item->IsOnLayer( m_Guide->GetPreferredLayer() ) || m_Guide->IgnorePreferredLayer() )
{
- int layer = item->GetLayer();
+ LAYER_NUM layer = item->GetLayer();
// Modules and their subcomponents: text and pads are not sensitive to the layer
// visibility controls. They all have their own separate visibility controls
@@ -378,7 +378,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
// no effect on other criteria, since there is a separate "ignore" control for
// those in the COLLECTORS_GUIDE
- int layer = item->GetLayer();
+ LAYER_NUM layer = item->GetLayer();
// Modules and their subcomponents: text and pads are not sensitive to the layer
// visibility controls. They all have their own separate visibility controls
diff --git a/pcbnew/collectors.h b/pcbnew/collectors.h
index b958b82e98..8eef56af40 100644
--- a/pcbnew/collectors.h
+++ b/pcbnew/collectors.h
@@ -71,13 +71,13 @@ public:
* Function IsLayerLocked
* @return bool - true if the given layer is locked, else false.
*/
- virtual bool IsLayerLocked( int layer ) const = 0;
+ virtual bool IsLayerLocked( LAYER_NUM layer ) const = 0;
/**
* Function IsLayerVisible
* @return bool - true if the given layer is visible, else false.
*/
- virtual bool IsLayerVisible( int layer ) const = 0;
+ virtual bool IsLayerVisible( LAYER_NUM layer ) const = 0;
/**
* Function IgnoreLockedLayers
@@ -95,7 +95,7 @@ public:
* Function GetPreferredLayer
* @return int - the preferred layer for HitTest()ing.
*/
- virtual int GetPreferredLayer() const = 0;
+ virtual LAYER_NUM GetPreferredLayer() const = 0;
/**
* Function IgnorePreferredLayer
@@ -376,7 +376,7 @@ private:
// the storage architecture here is not important, since this is only
// a carrier object and its functions are what is used, and data only indirectly.
- int m_PreferredLayer;
+ LAYER_NUM m_PreferredLayer;
bool m_IgnorePreferredLayer;
LAYER_MSK m_LayerLocked; ///< bit-mapped layer locked bits
@@ -407,7 +407,7 @@ public:
* @param aVisibleLayerMask = current visible layers (bit mask)
* @param aPreferredLayer = the layer to search first
*/
- GENERAL_COLLECTORS_GUIDE( LAYER_MSK aVisibleLayerMask, int aPreferredLayer )
+ GENERAL_COLLECTORS_GUIDE( LAYER_MSK aVisibleLayerMask, LAYER_NUM aPreferredLayer )
{
m_PreferredLayer = LAYER_N_FRONT;
m_IgnorePreferredLayer = false;
@@ -443,11 +443,11 @@ public:
* Function IsLayerLocked
* @return bool - true if the given layer is locked, else false.
*/
- bool IsLayerLocked( int aLayer ) const
+ bool IsLayerLocked( LAYER_NUM aLayer ) const
{
return GetLayerMask( aLayer ) & m_LayerLocked;
}
- void SetLayerLocked( int aLayer, bool isLocked )
+ void SetLayerLocked( LAYER_NUM aLayer, bool isLocked )
{
if( isLocked )
m_LayerLocked |= GetLayerMask( aLayer );
@@ -460,11 +460,11 @@ public:
* Function IsLayerVisible
* @return bool - true if the given layer is visible, else false.
*/
- bool IsLayerVisible( int aLayer ) const
+ bool IsLayerVisible( LAYER_NUM aLayer ) const
{
return GetLayerMask( aLayer ) & m_LayerVisible;
}
- void SetLayerVisible( int aLayer, bool isVisible )
+ void SetLayerVisible( LAYER_NUM aLayer, bool isVisible )
{
if( isVisible )
m_LayerVisible |= GetLayerMask( aLayer );
@@ -494,8 +494,8 @@ public:
* Function GetPreferredLayer
* @return int - the preferred layer for HitTest()ing.
*/
- int GetPreferredLayer() const { return m_PreferredLayer; }
- void SetPreferredLayer( int aLayer ) { m_PreferredLayer = aLayer; }
+ LAYER_NUM GetPreferredLayer() const { return m_PreferredLayer; }
+ void SetPreferredLayer( LAYER_NUM aLayer ) { m_PreferredLayer = aLayer; }
/**
diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp
index b69e4bd487..f85c787f69 100644
--- a/pcbnew/deltrack.cpp
+++ b/pcbnew/deltrack.cpp
@@ -53,7 +53,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
{
if( g_CurrentTrackList.GetCount() > 0 )
{
- int previous_layer = getActiveLayer();
+ LAYER_NUM previous_layer = getActiveLayer();
D( g_CurrentTrackList.VerifyListIntegrity(); )
@@ -216,7 +216,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
tracksegment->SetState( BUSY, false );
D( std::cout << __func__ << ": track " << tracksegment << " status=" \
- << TO_UTF8( TRACK::ShowState( tracksegment->GetState( -1 ) ) ) \
+ << TO_UTF8( TRACK::ShowState( tracksegment->GetStatus() ) ) \
<< std::endl; )
GetBoard()->m_Track.Remove( tracksegment );
diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp
index 9b9e7052bb..39eab85e9d 100644
--- a/pcbnew/dialogs/dialog_SVG_print.cpp
+++ b/pcbnew/dialogs/dialog_SVG_print.cpp
@@ -103,8 +103,8 @@ void DIALOG_SVG_PRINT::initDialog()
ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) );
// Create layers list
- int layer;
- for( layer = 0; layer < NB_LAYERS; ++layer )
+ LAYER_NUM layer;
+ for( layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{
if( !m_board->IsLayerEnabled( layer ) )
m_boxSelectLayer[layer] = NULL;
@@ -118,7 +118,7 @@ void DIALOG_SVG_PRINT::initDialog()
// (Front or Top to Back or Bottom)
DECLARE_LAYERS_ORDER_LIST( layersOrder );
- for( int layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx )
+ for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_LAYERS; ++layer_idx )
{
layer = layersOrder[layer_idx];
@@ -132,7 +132,7 @@ void DIALOG_SVG_PRINT::initDialog()
if( mask & s_SelectedLayers )
m_boxSelectLayer[layer]->SetValue( true );
- if( layer < 16 )
+ if( layer <= LAST_COPPER_LAYER )
m_CopperLayersBoxSizer->Add( m_boxSelectLayer[layer],
0,
wxGROW | wxALL,
@@ -148,7 +148,7 @@ void DIALOG_SVG_PRINT::initDialog()
{
wxString layerKey;
- for( int layer = 0; layerGetValue() )
- printMaskLayer |= 1 << layer;
+ printMaskLayer |= GetLayerMask( layer );
}
wxString msg;
- for( int layer = 0; layer // needed for wx/listctrl.h, in wxGTK 2.8.12
#include
-
+#include
/**
@@ -70,7 +70,7 @@ private:
///< true = pad count sort.
long m_NetFiltering;
- std::vector m_LayerId; ///< Handle the real layer number from layer
+ std::vector m_LayerId; ///< Handle the real layer number from layer
///< name position in m_LayerSelectionCtrl
static wxString m_netNameShowFilter; ///< the filter to show nets (default * "*").
@@ -250,9 +250,9 @@ void DIALOG_COPPER_ZONE::initDialog()
int layerCount = board->GetCopperLayerCount();
wxImageList* imageList = new wxImageList( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL );
- for( int ii = 0; ii < layerCount; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < layerCount; ++ii )
{
- int layerNumber = LAYER_N_BACK;
+ LAYER_NUM layerNumber = LAYER_N_BACK;
if( layerCount <= 1 || ii < layerCount - 1 )
layerNumber = ii;
diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp
index 5be3fe9a6e..0481490122 100644
--- a/pcbnew/dialogs/dialog_global_deletion.cpp
+++ b/pcbnew/dialogs/dialog_global_deletion.cpp
@@ -22,7 +22,7 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent )
: DIALOG_GLOBAL_DELETION_BASE( parent )
{
m_Parent = parent;
- m_currentLayer = 0;
+ m_currentLayer = FIRST_LAYER;
m_TrackFilterAR->Enable( m_DelTracks->GetValue() );
m_TrackFilterLocked->Enable( m_DelTracks->GetValue() );
m_TrackFilterNormal->Enable( m_DelTracks->GetValue() );
@@ -42,7 +42,7 @@ void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos )
dlg.ShowModal();
}
-void DIALOG_GLOBAL_DELETION::SetCurrentLayer( int aLayer )
+void DIALOG_GLOBAL_DELETION::SetCurrentLayer( LAYER_NUM aLayer )
{
m_currentLayer = aLayer;
m_textCtrlCurrLayer->SetValue( m_Parent->GetBoard()->GetLayerName( aLayer ) );
diff --git a/pcbnew/dialogs/dialog_global_deletion.h b/pcbnew/dialogs/dialog_global_deletion.h
index c5bbaac03b..1983409708 100644
--- a/pcbnew/dialogs/dialog_global_deletion.h
+++ b/pcbnew/dialogs/dialog_global_deletion.h
@@ -11,11 +11,11 @@ class DIALOG_GLOBAL_DELETION: public DIALOG_GLOBAL_DELETION_BASE
{
private:
PCB_EDIT_FRAME * m_Parent;
- int m_currentLayer;
+ LAYER_NUM m_currentLayer;
public:
DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent );
- void SetCurrentLayer( int aLayer );
+ void SetCurrentLayer( LAYER_NUM aLayer );
private:
void OnOkClick( wxCommandEvent& event )
diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp
index 6dddab0eee..9b4525e962 100644
--- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp
+++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp
@@ -156,18 +156,18 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( )
PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness );
- for( int layer=FIRST_NO_COPPER_LAYER; layer <= LAST_NO_COPPER_LAYER; ++layer )
+ for( LAYER_NUM layer=FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; ++layer )
{
m_LayerSelectionCtrl->Append( m_parent->GetBoard()->GetLayerName( layer ) );
}
- int layer = m_Item->GetLayer();
+ LAYER_NUM layer = m_Item->GetLayer();
// Control:
- if ( layer < FIRST_NO_COPPER_LAYER )
- layer = FIRST_NO_COPPER_LAYER;
- if ( layer > LAST_NO_COPPER_LAYER )
- layer = LAST_NO_COPPER_LAYER;
- m_LayerSelectionCtrl->SetSelection( layer - FIRST_NO_COPPER_LAYER );
+ if ( layer < FIRST_NON_COPPER_LAYER )
+ layer = FIRST_NON_COPPER_LAYER;
+ if ( layer > LAST_NON_COPPER_LAYER )
+ layer = LAST_NON_COPPER_LAYER;
+ m_LayerSelectionCtrl->SetSelection( layer - FIRST_NON_COPPER_LAYER );
}
@@ -177,7 +177,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnLayerChoice( wxCommandEvent& event )
{
int thickness;
- if( (m_LayerSelectionCtrl->GetCurrentSelection() + FIRST_NO_COPPER_LAYER) == EDGE_N )
+ if( (m_LayerSelectionCtrl->GetCurrentSelection() + FIRST_NON_COPPER_LAYER) == EDGE_N )
thickness = m_brdSettings.m_EdgeSegmentWidth;
else
thickness = m_brdSettings.m_DrawSegmentWidth;
@@ -216,7 +216,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event )
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ReturnValueFromString( g_UserUnit, msg );
- m_Item->SetLayer( m_LayerSelectionCtrl->GetCurrentSelection() + FIRST_NO_COPPER_LAYER);
+ m_Item->SetLayer( FIRST_NON_COPPER_LAYER + m_LayerSelectionCtrl->GetCurrentSelection() );
if( m_Item->GetLayer() == EDGE_N )
m_brdSettings.m_EdgeSegmentWidth = thickness;
diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp
index 677a3ff7cc..a7ed5de1e0 100644
--- a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp
+++ b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp
@@ -32,7 +32,7 @@ private:
EDGE_MODULE* m_item;
BOARD_DESIGN_SETTINGS m_brdSettings;
MODULE * m_module;
- std::vector m_layerId; // the layer Id with the same order as m_LayerSelectionCtrl widget
+ std::vector m_layerId; // the layer Id with the same order as m_LayerSelectionCtrl widget
public:
DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES( FOOTPRINT_EDIT_FRAME* aParent,
@@ -155,7 +155,7 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg()
m_layerId.push_back( LAYER_N_BACK );
m_LayerSelectionCtrl->Append( m_parent->GetBoard()->GetLayerName( LAYER_N_FRONT ) );
m_layerId.push_back( LAYER_N_FRONT );
- for( int layer = FIRST_NO_COPPER_LAYER; layer <= LAST_NO_COPPER_LAYER; ++layer )
+ for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER; ++layer )
{
if( layer == EDGE_N )
// Do not use pcb edge layer for footprints, this is a special layer
@@ -195,7 +195,7 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event )
return;
}
- int layer = m_layerId[idx];
+ LAYER_NUM layer = m_layerId[idx];
if( IsValidCopperLayerIndex( layer ) )
{
/* an edge is put on a copper layer, and it is very dangerous. a
diff --git a/pcbnew/dialogs/dialog_keepout_area_properties.cpp b/pcbnew/dialogs/dialog_keepout_area_properties.cpp
index 98c587d5bd..7a5f105196 100644
--- a/pcbnew/dialogs/dialog_keepout_area_properties.cpp
+++ b/pcbnew/dialogs/dialog_keepout_area_properties.cpp
@@ -60,7 +60,7 @@ private:
ZONE_SETTINGS m_zonesettings;
ZONE_SETTINGS* m_ptr;
- std::vector m_layerId; ///< Handle the real layer number from layer
+ std::vector m_layerId; ///< Handle the real layer number from layer
///< name position in m_LayerSelectionCtrl
/**
@@ -153,7 +153,7 @@ void DIALOG_KEEPOUT_AREA_PROPERTIES::initDialog()
m_LayerSelectionCtrl->AssignImageList( imageList, wxIMAGE_LIST_SMALL );
for( int ii = 0; ii < layerCount; ii++ )
{
- int layerNumber = LAYER_N_BACK;
+ LAYER_NUM layerNumber = LAYER_N_BACK;
if( layerCount <= 1 || ii < layerCount - 1 )
layerNumber = ii;
diff --git a/pcbnew/dialogs/dialog_layers_setup.cpp b/pcbnew/dialogs/dialog_layers_setup.cpp
index 7d7d836410..a1825fc194 100644
--- a/pcbnew/dialogs/dialog_layers_setup.cpp
+++ b/pcbnew/dialogs/dialog_layers_setup.cpp
@@ -85,7 +85,7 @@ private:
wxStaticText* m_TypeStaticText;
- void setLayerCheckBox( int layer, bool isChecked );
+ void setLayerCheckBox( LAYER_NUM layer, bool isChecked );
void setCopperLayerCheckBoxes( int copperCount );
void showCopperChoice( int copperCount );
@@ -96,8 +96,8 @@ private:
/** return the selected layer mask within the UI checkboxes */
LAYER_MSK getUILayerMask();
- wxString getLayerName( int layer );
- int getLayerTypeIndex( int layer );
+ wxString getLayerName( LAYER_NUM layer );
+ int getLayerTypeIndex( LAYER_NUM layer );
void OnCancelButtonClick( wxCommandEvent& event );
@@ -114,19 +114,19 @@ private:
* maps \a aLayerNumber to the wx IDs for that layer which are
* the layer name control ID, checkbox control ID, and choice control ID
*/
- CTLs getCTLs( int aLayerNumber );
+ CTLs getCTLs( LAYER_NUM aLayerNumber );
- wxControl* getName( int aLayer )
+ wxControl* getName( LAYER_NUM aLayer )
{
return getCTLs( aLayer ).name;
}
- wxCheckBox* getCheckBox( int aLayer )
+ wxCheckBox* getCheckBox( LAYER_NUM aLayer )
{
return getCTLs( aLayer ).checkbox;
}
- wxChoice* getChoice( int aLayer )
+ wxChoice* getChoice( LAYER_NUM aLayer )
{
return (wxChoice*) getCTLs( aLayer ).choice;
}
@@ -198,7 +198,7 @@ static const LAYER_MSK presets[] =
};
-CTLs DIALOG_LAYERS_SETUP::getCTLs( int aLayerNumber )
+CTLs DIALOG_LAYERS_SETUP::getCTLs( LAYER_NUM aLayerNumber )
{
#define RETCOP(x) return CTLs( x##Name, x##CheckBox, x##Choice, x##Panel );
#define RETAUX(x) return CTLs( x##Name, x##CheckBox, x##StaticText, x##Panel );
@@ -327,7 +327,7 @@ void DIALOG_LAYERS_SETUP::showBoardLayerNames()
// obtaining them from BOARD::GetLayerName() which calls
// BOARD::GetStandardLayerName() for non-coppers.
- for( int layer=0; layerGetValue() )
@@ -402,7 +402,7 @@ LAYER_MSK DIALOG_LAYERS_SETUP::getUILayerMask()
}
-void DIALOG_LAYERS_SETUP::setLayerCheckBox( int aLayer, bool isChecked )
+void DIALOG_LAYERS_SETUP::setLayerCheckBox( LAYER_NUM aLayer, bool isChecked )
{
wxCheckBox* ctl = getCheckBox( aLayer );
ctl->SetValue( isChecked );
@@ -427,8 +427,7 @@ void DIALOG_LAYERS_SETUP::setCopperLayerCheckBoxes( int copperCount )
setLayerCheckBox( LAYER_N_FRONT, false );
}
- int layer;
- for( layer=LAYER_N_2; layer < NB_COPPER_LAYERS-1; ++layer, --copperCount )
+ for( LAYER_NUM layer=LAYER_N_2; layer < NB_COPPER_LAYERS-1; ++layer, --copperCount )
{
bool state = copperCount > 0;
@@ -548,10 +547,10 @@ void DIALOG_LAYERS_SETUP::OnOkButtonClick( wxCommandEvent& event )
*/
m_Pcb->SetVisibleLayers( m_EnabledLayers );
- for( int layer = FIRST_COPPER_LAYER;
+ for( LAYER_NUM layer = FIRST_COPPER_LAYER;
layer <= LAST_COPPER_LAYER; ++layer )
{
- if( (1<GetEnabledLayers() ) == 0 )
+ if( !( GetLayerMask( getActiveLayer() ) & GetBoard()->GetEnabledLayers() ) )
{
- for( int i = 0; i < LAYER_COUNT; i++ )
+ for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{
- int tmp = i;
+ LAYER_NUM tmp = i;
- if( i >= LAYER_COUNT )
- tmp = i - LAYER_COUNT;
+ if( i >= NB_LAYERS )
+ tmp = i - NB_LAYERS;
- if( ( 1 << tmp ) & GetBoard()->GetEnabledLayers() )
+ if( GetLayerMask( tmp ) & GetBoard()->GetEnabledLayers() )
{
wxLogDebug( wxT( "Setting current layer to %d." ), getActiveLayer() );
setActiveLayer( tmp, true );
diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp
index dfcc221af1..7a78102c41 100644
--- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp
+++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp
@@ -56,7 +56,7 @@ private:
PCB_EDIT_FRAME* m_Parent;
wxDC* m_DC;
TEXTE_PCB* m_SelectedPCBText;
- std::vector layerList;
+ std::vector layerList;
void MyInit();
@@ -128,7 +128,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit()
LAYER_MSK enabledLayers = m_Parent->GetBoard()->GetEnabledLayers();
- for( int layer = 0; layer < NB_LAYERS; ++layer )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{
if( enabledLayers & GetLayerMask( layer ) )
{
diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp
index fff9f9bbf7..cdf268ed5a 100644
--- a/pcbnew/dialogs/dialog_plot.cpp
+++ b/pcbnew/dialogs/dialog_plot.cpp
@@ -148,7 +148,8 @@ void DIALOG_PLOT::Init_Dialog()
// List layers in same order than in setup layers dialog
// (Front or Top to Back or Bottom)
DECLARE_LAYERS_ORDER_LIST( layersOrder );
- int layerIndex, checkIndex, layer;
+ int layerIndex, checkIndex;
+ LAYER_NUM layer;
for( layerIndex = 0; layerIndex < NB_LAYERS; layerIndex++ )
{
diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index 7d711ae9f1..21afdf456c 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -144,16 +144,16 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( PCB_EDIT_FRAME* parent )
void DIALOG_PRINT_USING_PRINTER::InitValues( )
{
- int layer_max = NB_LAYERS;
+ LAYER_NUM layer_max = NB_PCB_LAYERS;
wxString msg;
BOARD* board = m_parent->GetBoard();
s_Parameters.m_PageSetupData = s_pageSetupData;
// Create layer list.
- int layer;
+ LAYER_NUM layer;
wxString layerKey;
- for( layer = 0; layer < NB_LAYERS; ++layer )
+ for( layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{
if( !board->IsLayerEnabled( layer ) )
m_BoxSelectLayer[layer] = NULL;
@@ -166,16 +166,16 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
// List layers in same order than in setup layers dialog
// (Front or Top to Back or Bottom)
DECLARE_LAYERS_ORDER_LIST(layersOrder);
- for( int layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx )
+ for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_PCB_LAYERS; ++layer_idx )
{
layer = layersOrder[layer_idx];
- wxASSERT(layer < NB_LAYERS);
+ wxASSERT(layer < NB_PCB_LAYERS);
if( m_BoxSelectLayer[layer] == NULL )
continue;
- if( layer < NB_COPPER_LAYERS )
+ if( layer <= LAST_COPPER_LAYER )
m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer],
0, wxGROW | wxALL, 1 );
else
@@ -280,11 +280,10 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
{
int page_count;
- int layers_count = NB_LAYERS;
s_Parameters.m_PrintMaskLayer = NO_LAYERS;
- int ii;
- for( ii = 0, page_count = 0; ii < layers_count; ii++ )
+ LAYER_NUM ii;
+ for( ii = FIRST_LAYER, page_count = 0; ii < NB_PCB_LAYERS; ++ii )
{
if( m_BoxSelectLayer[ii] == NULL )
continue;
@@ -324,7 +323,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
m_config->Write( OPTKEY_PRINT_PAGE_PER_LAYER, s_Parameters.m_OptionPrintPage );
m_config->Write( OPTKEY_PRINT_PADS_DRILL, (long) s_Parameters.m_DrillShapeOpt );
wxString layerKey;
- for( int layer = 0; layer < NB_LAYERS; ++layer )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{
if( m_BoxSelectLayer[layer] == NULL )
continue;
diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp
index adc6c49a2a..45d76f83cd 100644
--- a/pcbnew/dimension.cpp
+++ b/pcbnew/dimension.cpp
@@ -132,12 +132,12 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
PutValueInLocalUnits( *m_textCtrlPosY, aDimension->Text().GetTextPosition().y );
AddUnitSymbol( *m_staticTextPosY );
- for( int layer = FIRST_NO_COPPER_LAYER; layerAppend( aParent->GetBoard()->GetLayerName( layer ) );
}
- m_SelLayerBox->SetSelection( aDimension->GetLayer() - FIRST_NO_COPPER_LAYER );
+ m_SelLayerBox->SetSelection( aDimension->GetLayer() - FIRST_NON_COPPER_LAYER );
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
@@ -199,7 +199,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
- CurrentDimension->SetLayer( m_SelLayerBox->GetCurrentSelection() + FIRST_NO_COPPER_LAYER );
+ CurrentDimension->SetLayer( FIRST_NON_COPPER_LAYER + m_SelLayerBox->GetCurrentSelection() );
if( m_DC ) // Display new text
{
diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp
index 5df8dcfe95..640f4a4639 100644
--- a/pcbnew/drc_clearance_test_functions.cpp
+++ b/pcbnew/drc_clearance_test_functions.cpp
@@ -205,7 +205,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
// and **only one layer** can be drilled
if( aRefSeg->GetShape() == VIA_MICROVIA )
{
- int layer1, layer2;
+ LAYER_NUM layer1, layer2;
bool err = true;
( (SEGVIA*) aRefSeg )->ReturnLayerPair( &layer1, &layer2 );
diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp
index a1b0f61443..fd2384fe2d 100644
--- a/pcbnew/eagle_plugin.cpp
+++ b/pcbnew/eagle_plugin.cpp
@@ -256,7 +256,7 @@ struct EWIRE
double x2;
double y2;
double width;
- int layer;
+ LAYER_NUM layer;
// for style: (continuous | longdash | shortdash | dashdot)
enum {
@@ -388,7 +388,7 @@ struct ECIRCLE
double y;
double radius;
double width;
- int layer;
+ LAYER_NUM layer;
ECIRCLE( CPTREE& aCircle );
};
@@ -1312,7 +1312,7 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers )
for( EITER it = cu.begin(); it != cu.end(); ++it )
{
- int layer = kicad_layer( it->number );
+ LAYER_NUM layer = kicad_layer( it->number );
m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) );
m_board->SetLayerType( layer, LT_SIGNAL );
@@ -1333,9 +1333,9 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
{
m_xpath->push( "wire" );
EWIRE w( gr->second );
- int layer = kicad_layer( w.layer );
+ LAYER_NUM layer = kicad_layer( w.layer );
- if( layer != -1 )
+ if( layer != UNDEFINED_LAYER )
{
DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
m_board->Add( dseg, ADD_APPEND );
@@ -1360,7 +1360,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
#endif
m_xpath->push( "text" );
ETEXT t( gr->second );
- int layer = kicad_layer( t.layer );
+ LAYER_NUM layer = kicad_layer( t.layer );
if( layer != -1 ) // supported layer
{
@@ -1450,9 +1450,9 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
{
m_xpath->push( "circle" );
ECIRCLE c( gr->second );
- int layer = kicad_layer( c.layer );
+ LAYER_NUM layer = kicad_layer( c.layer );
- if( layer != -1 ) // unsupported layer
+ if( layer != UNDEFINED_LAYER ) // unsupported layer
{
DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
m_board->Add( dseg, ADD_APPEND );
@@ -1473,7 +1473,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
{
m_xpath->push( "rectangle" );
ERECT r( gr->second );
- int layer = kicad_layer( r.layer );
+ LAYER_NUM layer = kicad_layer( r.layer );
if( IsValidCopperLayerIndex( layer ) )
{
@@ -1908,7 +1908,7 @@ MODULE* EAGLE_PLUGIN::makeModule( CPTREE& aPackage, const std::string& aPkgName
void EAGLE_PLUGIN::packageWire( MODULE* aModule, CPTREE& aTree ) const
{
EWIRE w( aTree );
- int layer = kicad_layer( w.layer );
+ LAYER_NUM layer = kicad_layer( w.layer );
if( IsValidNonCopperLayerIndex( layer ) ) // skip copper package wires
{
@@ -2015,7 +2015,7 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, CPTREE& aTree ) const
void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const
{
ETEXT t( aTree );
- int layer = kicad_layer( t.layer );
+ LAYER_NUM layer = kicad_layer( t.layer );
TEXTE_MODULE* txt;
@@ -2118,7 +2118,7 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const
void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, CPTREE& aTree ) const
{
ERECT r( aTree );
- int layer = kicad_layer( r.layer );
+ LAYER_NUM layer = kicad_layer( r.layer );
if( IsValidNonCopperLayerIndex( layer ) ) // skip copper "package.rectangle"s
{
@@ -2151,7 +2151,7 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, CPTREE& aTree ) const
void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, CPTREE& aTree ) const
{
EPOLYGON p( aTree );
- int layer = kicad_layer( p.layer );
+ LAYER_NUM layer = kicad_layer( p.layer );
if( IsValidNonCopperLayerIndex( layer ) ) // skip copper "package.rectangle"s
{
@@ -2200,7 +2200,7 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, CPTREE& aTree ) const
void EAGLE_PLUGIN::packageCircle( MODULE* aModule, CPTREE& aTree ) const
{
ECIRCLE e( aTree );
- int layer = kicad_layer( e.layer );
+ LAYER_NUM layer = kicad_layer( e.layer );
EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE );
aModule->GraphicalItems().PushBack( gr );
@@ -2257,7 +2257,7 @@ void EAGLE_PLUGIN::packageHole( MODULE* aModule, CPTREE& aTree ) const
void EAGLE_PLUGIN::packageSMD( MODULE* aModule, CPTREE& aTree ) const
{
ESMD e( aTree );
- int layer = kicad_layer( e.layer );
+ LAYER_NUM layer = kicad_layer( e.layer );
if( !IsValidCopperLayerIndex( layer ) )
{
@@ -2349,7 +2349,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
{
m_xpath->push( "wire" );
EWIRE w( it->second );
- int layer = kicad_layer( w.layer );
+ LAYER_NUM layer = kicad_layer( w.layer );
if( IsValidCopperLayerIndex( layer ) )
{
@@ -2383,8 +2383,8 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
m_xpath->push( "via" );
EVIA v( it->second );
- int layer_front_most = kicad_layer( v.layer_front_most );
- int layer_back_most = kicad_layer( v.layer_back_most );
+ LAYER_NUM layer_front_most = kicad_layer( v.layer_front_most );
+ LAYER_NUM layer_back_most = kicad_layer( v.layer_back_most );
if( IsValidCopperLayerIndex( layer_front_most ) &&
IsValidCopperLayerIndex( layer_back_most ) )
@@ -2462,7 +2462,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
{
m_xpath->push( "polygon" );
EPOLYGON p( it->second );
- int layer = kicad_layer( p.layer );
+ LAYER_NUM layer = kicad_layer( p.layer );
if( IsValidCopperLayerIndex( layer ) )
{
@@ -2545,7 +2545,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
}
-int EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
+LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
{
/* will assume this is a valid mapping for all eagle boards until I get paid more:
@@ -2625,7 +2625,7 @@ int EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
else
{
/*
-#define FIRST_NO_COPPER_LAYER 16
+#define FIRST_NON_COPPER_LAYER 16
#define ADHESIVE_N_BACK 16
#define ADHESIVE_N_FRONT 17
#define SOLDERPASTE_N_BACK 18
@@ -2639,7 +2639,7 @@ int EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
#define ECO1_N 26
#define ECO2_N 27
#define EDGE_N 28
-#define LAST_NO_COPPER_LAYER 28
+#define LAST_NON_COPPER_LAYER 28
#define UNUSED_LAYER_29 29
#define UNUSED_LAYER_30 30
#define UNUSED_LAYER_31 31
diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h
index a84b2af6bd..077bb942aa 100644
--- a/pcbnew/eagle_plugin.h
+++ b/pcbnew/eagle_plugin.h
@@ -159,7 +159,7 @@ private:
wxSize kicad_fontz( double d ) const;
/// Convert an Eagle layer to a KiCad layer.
- int kicad_layer( int aLayer ) const;
+ LAYER_NUM kicad_layer( int aLayer ) const;
/// Convert a KiCad distance to an Eagle distance.
double eagle( BIU d ) const { return mm_per_biu * d; }
diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp
index 620ae55961..2b5f52b82d 100644
--- a/pcbnew/edgemod.cpp
+++ b/pcbnew/edgemod.cpp
@@ -191,7 +191,7 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge )
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge )
{
MODULE* module = GetBoard()->m_Modules;
- int new_layer = SILKSCREEN_N_FRONT;
+ LAYER_NUM new_layer = SILKSCREEN_N_FRONT;
if( aEdge )
new_layer = aEdge->GetLayer();
diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp
index 13d0908dc5..51f4c5f8e8 100755
--- a/pcbnew/edit.cpp
+++ b/pcbnew/edit.cpp
@@ -62,7 +62,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
int id = event.GetId();
wxPoint pos;
- int itmp;
+ LAYER_NUM itmp;
INSTALL_UNBUFFERED_DC( dc, m_canvas );
MODULE* module;
@@ -916,7 +916,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_LAYER:
- itmp = SelectLayer( getActiveLayer(), -1, -1 );
+ itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, UNDEFINED_LAYER );
if( itmp >= 0 )
setActiveLayer( itmp );
@@ -929,7 +929,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
- itmp = SelectLayer( getActiveLayer(), FIRST_NO_COPPER_LAYER, -1 );
+ itmp = SelectLayer( getActiveLayer(), FIRST_NON_COPPER_LAYER, UNDEFINED_LAYER );
if( itmp >= 0 )
setActiveLayer( itmp );
@@ -938,7 +938,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_CU_LAYER:
- itmp = SelectLayer( getActiveLayer(), -1, LAST_COPPER_LAYER );
+ itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, LAST_COPPER_LAYER );
if( itmp >= 0 )
setActiveLayer( itmp );
@@ -951,7 +951,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_TOOLBARH_PCB_SELECT_LAYER:
- setActiveLayer( (size_t) m_SelLayerBox->GetLayerSelection());
+ setActiveLayer( m_SelLayerBox->GetLayerSelection() );
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh( true );
@@ -1238,9 +1238,9 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
}
-void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, int layer )
+void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
{
- int curLayer = getActiveLayer();
+ LAYER_NUM curLayer = getActiveLayer();
// Check if the specified layer matches the present layer
if( layer == curLayer )
diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp
index 3930ab6026..3037184890 100644
--- a/pcbnew/edit_pcb_text.cpp
+++ b/pcbnew/edit_pcb_text.cpp
@@ -203,7 +203,7 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText )
{
GetBoard()->Add( textePcb );
textePcb->SetFlags( IS_NEW );
- int layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
+ LAYER_NUM layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
textePcb->SetLayer( layer );
// Set the mirrored option for layers on the BACK side of the board
diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp
index 685bf7a916..39bd894238 100644
--- a/pcbnew/editedge.cpp
+++ b/pcbnew/editedge.cpp
@@ -144,7 +144,7 @@ void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
}
-void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( int aLayer )
+void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( LAYER_NUM aLayer )
{
if( aLayer <= LAST_COPPER_LAYER )
{
diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp
index 6f89d66e60..e36a3a92a1 100644
--- a/pcbnew/editrack-part2.cpp
+++ b/pcbnew/editrack-part2.cpp
@@ -109,8 +109,8 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
via->SetLayerPair( LAYER_N_BACK, LAYER_N_FRONT );
via->SetDrill( GetBoard()->GetCurrentViaDrill() );
- int first_layer = getActiveLayer();
- int last_layer;
+ LAYER_NUM first_layer = getActiveLayer();
+ LAYER_NUM last_layer;
// prepare switch to new active layer:
if( first_layer != GetScreen()->m_Route_Layer_TOP )
@@ -127,7 +127,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
case VIA_MICROVIA: // from external to the near neighbor inner layer
{
- int last_inner_layer = GetBoard()->GetCopperLayerCount() - 2;
+ LAYER_NUM last_inner_layer = FIRST_LAYER + (GetBoard()->GetCopperLayerCount() - 2);
if ( first_layer == LAYER_N_BACK )
last_layer = LAYER_N_2;
else if ( first_layer == LAYER_N_FRONT )
diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp
index 7064aceac4..651f26dd0c 100644
--- a/pcbnew/editrack.cpp
+++ b/pcbnew/editrack.cpp
@@ -535,7 +535,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
}
-TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, int aLayer, const wxPoint& aRef )
+TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, LAYER_NUM aLayer, const wxPoint& aRef )
{
int net = aTrack->GetNet();
int width = aTrack->GetWidth();
diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp
index 06001dcdd7..4d19b63a34 100644
--- a/pcbnew/export_gencad.cpp
+++ b/pcbnew/export_gencad.cpp
@@ -439,7 +439,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
via->GetWidth(), via->GetDrillValue(), mask,
via->GetDrillValue() / SCALE_FACTOR );
- for( int layer = 0; layer < 32; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
{
if( mask & GetLayerMask( layer ) )
{
@@ -463,7 +463,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
// Straight padstack
fprintf( aFile, "PADSTACK PAD%d %g\n", i,
pad->GetDrillSize().x / SCALE_FACTOR );
- for( int layer = 0; layer < 32; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
{
if( pad->GetLayerMask() & GetLayerMask( layer ) & master_layermask )
{
@@ -475,7 +475,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
// Flipped padstack
fprintf( aFile, "PADSTACK PAD%dF %g\n", i,
pad->GetDrillSize().x / SCALE_FACTOR );
- for( int layer = 0; layer < 32; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
{
if( pad->GetLayerMask() & GetLayerMask( layer ) & master_layermask )
{
diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp
index b1706d069a..99e4e006d5 100644
--- a/pcbnew/export_vrml.cpp
+++ b/pcbnew/export_vrml.cpp
@@ -96,7 +96,7 @@ struct FLAT_FAN
{
pts.push_back( POINT_2D( x, y ) );
}
- void bag( int layer, bool close = true );
+ void bag( LAYER_NUM layer, bool close = true );
};
// A flat quad ring
@@ -114,7 +114,7 @@ struct FLAT_RING
outer.push_back( POINT_2D( x, y ) );
}
- void bag( int layer, bool close = true );
+ void bag( LAYER_NUM layer, bool close = true );
};
// A vertical quad loop
@@ -131,11 +131,11 @@ struct VLoop
};
// The bags for all the layers
-static TRIANGLEBAG layer_triangles[LAYER_COUNT];
+static TRIANGLEBAG layer_triangles[NB_LAYERS];
static TRIANGLEBAG via_triangles[4];
-static double layer_z[LAYER_COUNT];
+static double layer_z[NB_LAYERS];
-static void bag_flat_triangle( int layer, //{{{
+static void bag_flat_triangle( LAYER_NUM layer, //{{{
double x1, double y1,
double x2, double y2,
double x3, double y3 )
@@ -146,7 +146,7 @@ static void bag_flat_triangle( int layer, //{{{
}
-void FLAT_FAN::bag( int layer, bool close ) //{{{
+void FLAT_FAN::bag( LAYER_NUM layer, bool close ) //{{{
{
unsigned i;
@@ -158,7 +158,7 @@ void FLAT_FAN::bag( int layer, bool close ) //{{{
}
-static void bag_flat_quad( int layer, //{{{
+static void bag_flat_quad( LAYER_NUM layer, //{{{
double x1, double y1,
double x2, double y2,
double x3, double y3,
@@ -169,7 +169,7 @@ static void bag_flat_quad( int layer, //{{{
}
-void FLAT_RING::bag( int layer, bool close ) //{{{
+void FLAT_RING::bag( LAYER_NUM layer, bool close ) //{{{
{
unsigned i;
@@ -343,7 +343,7 @@ static void compute_layer_Zs( BOARD* pcb ) //{{{
double half_thickness = board_thickness / 2;
// Compute each layer's Z value, more or less like the 3d view
- for( int i = 0; i <= LAYER_N_FRONT; i++ )
+ for( LAYER_NUM i = FIRST_LAYER; i <= LAYER_N_FRONT; ++i )
{
if( i < copper_layers )
layer_z[i] = board_thickness * i / (copper_layers - 1) - half_thickness;
@@ -370,7 +370,7 @@ static void compute_layer_Zs( BOARD* pcb ) //{{{
}
-static void export_vrml_line( int layer, double startx, double starty, //{{{
+static void export_vrml_line( LAYER_NUM layer, double startx, double starty, //{{{
double endx, double endy, double width, int divisions )
{
double r = width / 2;
@@ -399,7 +399,7 @@ static void export_vrml_line( int layer, double startx, double starty, //{{{
}
-static void export_vrml_circle( int layer, double startx, double starty,
+static void export_vrml_circle( LAYER_NUM layer, double startx, double starty, //{{{
double endx, double endy, double width )
{
double hole, radius;
@@ -419,7 +419,7 @@ static void export_vrml_circle( int layer, double startx, double starty,
static void export_vrml_slot( TRIANGLEBAG& triangles, //{{{
- int top_layer, int bottom_layer, double xc, double yc,
+ LAYER_NUM top_layer, LAYER_NUM bottom_layer, double xc, double yc,
double dx, double dy, int orient )
{
double capx, capy; // Cap center
@@ -478,7 +478,7 @@ static void export_vrml_hole( TRIANGLEBAG& triangles,
}
-static void export_vrml_oval_pad( int layer, double xc, double yc,
+static void export_vrml_oval_pad( LAYER_NUM layer, double xc, double yc,
double dx, double dy, int orient )
{
double capx, capy; // Cap center
@@ -521,7 +521,7 @@ static void export_vrml_oval_pad( int layer, double xc, double yc,
}
-static void export_vrml_arc( int layer, double centerx, double centery,
+static void export_vrml_arc( LAYER_NUM layer, double centerx, double centery,
double arc_startx, double arc_starty,
double width, double arc_angle )
{
@@ -557,7 +557,7 @@ static void export_vrml_arc( int layer, double centerx, double centery,
static void export_vrml_varc( TRIANGLEBAG& triangles,
- int top_layer, int bottom_layer,
+ LAYER_NUM top_layer, LAYER_NUM bottom_layer,
double centerx, double centery,
double arc_startx, double arc_starty,
double arc_angle )
@@ -594,7 +594,7 @@ static void export_vrml_varc( TRIANGLEBAG& triangles,
static void export_vrml_drawsegment( DRAWSEGMENT* drawseg ) //{{{
{
- int layer = drawseg->GetLayer();
+ LAYER_NUM layer = drawseg->GetLayer();
double w = drawseg->GetWidth();
double x = drawseg->GetStart().x;
double y = drawseg->GetStart().y;
@@ -658,7 +658,7 @@ static void export_vrml_drawsegment( DRAWSEGMENT* drawseg ) //{{{
/* C++ doesn't have closures and neither continuation forms... this is
* for coupling the vrml_text_callback with the common parameters */
-static int s_text_layer;
+static LAYER_NUM s_text_layer;
static int s_text_width;
static void vrml_text_callback( int x0, int y0, int xf, int yf )
{
@@ -735,13 +735,12 @@ static void export_vrml_drawings( BOARD* pcb ) //{{{
}
-static void export_round_padstack( BOARD* pcb, double x, double y,
- double r,
- int bottom_layer, int top_layer )
+static void export_round_padstack( BOARD* pcb, double x, double y, double r, //{{{
+ LAYER_NUM bottom_layer, LAYER_NUM top_layer )
{
int copper_layers = pcb->GetCopperLayerCount( );
- for( int layer = bottom_layer; layer < copper_layers; layer++ )
+ for( LAYER_NUM layer = bottom_layer; layer < copper_layers; ++layer )
{
// The last layer is always the component one, unless it's single face
if( (layer > FIRST_COPPER_LAYER) && (layer == copper_layers - 1) )
@@ -756,7 +755,7 @@ static void export_round_padstack( BOARD* pcb, double x, double y,
static void export_vrml_via( BOARD* pcb, SEGVIA* via ) //{{{
{
double x, y, r, hole;
- int top_layer, bottom_layer;
+ LAYER_NUM top_layer, bottom_layer;
r = via->GetWidth() / 2;
hole = via->GetDrillValue() / 2;
@@ -813,7 +812,7 @@ static void export_vrml_zones( BOARD* pcb )
if( width > 0 )
{
int imax = zone->m_FilledPolysList.size() - 1;
- int layer = zone->GetLayer();
+ LAYER_NUM layer = zone->GetLayer();
CPolyPt* firstcorner = &zone->m_FilledPolysList[0];
CPolyPt* begincorner = firstcorner;
@@ -866,7 +865,7 @@ static void export_vrml_text_module( TEXTE_MODULE* module ) //{{{
static void export_vrml_edge_module( EDGE_MODULE* aOutline ) //{{{
{
- int layer = aOutline->GetLayer();
+ LAYER_NUM layer = aOutline->GetLayer();
double x = aOutline->GetStart().x;
double y = aOutline->GetStart().y;
double xf = aOutline->GetEnd().x;
@@ -933,7 +932,7 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* aPad ) //{{{
double pad_w = aPad->GetSize().x / 2;
double pad_h = aPad->GetSize().y / 2;
- for( int layer = FIRST_COPPER_LAYER; layer < copper_layers; layer++ )
+ for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer < copper_layers; ++layer )
{
// The last layer is always the component one, unless it's single face
if( (layer > FIRST_COPPER_LAYER) && (layer == copper_layers - 1) )
@@ -1267,7 +1266,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName,
/* Output the bagged triangles for each layer
* Each layer will be a separate shape */
- for( int layer = 0; layer < LAYER_COUNT; layer++ )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
write_and_empty_triangle_bag( output_file,
layer_triangles[layer],
pcb->GetLayerColor(layer),
diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp
index ce0d15e015..462cf2a60f 100644
--- a/pcbnew/gen_drill_report_files.cpp
+++ b/pcbnew/gen_drill_report_files.cpp
@@ -336,8 +336,8 @@ bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
{
unsigned totalHoleCount;
char line[1024];
- int layer1 = LAYER_N_BACK;
- int layer2 = LAYER_N_FRONT;
+ LAYER_NUM layer1 = LAYER_N_BACK;
+ LAYER_NUM layer2 = LAYER_N_FRONT;
bool gen_through_holes = true;
bool gen_NPTH_holes = false;
@@ -443,7 +443,7 @@ bool EXCELLON_WRITER::GenDrillReportFile( const wxString& aFullFileName )
continue;
}
- layer1++; layer2++; // use next layer pair
+ ++layer1; ++layer2; // use next layer pair
if( layer2 == m_pcb->GetCopperLayerCount() - 1 )
layer2 = LAYER_N_FRONT; // the last layer is always the
diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp
index f6cbbe1afa..eaf18bb680 100644
--- a/pcbnew/gen_modules_placefile.cpp
+++ b/pcbnew/gen_modules_placefile.cpp
@@ -57,7 +57,7 @@ public:
MODULE* m_Module; // Link to the actual footprint
const wxChar* m_Reference; // Its schematic reference
const wxChar* m_Value; // Its schematic value
- int m_Layer; // its side (LAYER_N_BACK, or LAYER_N_FRONT)
+ LAYER_NUM m_Layer; // its side (LAYER_N_BACK, or LAYER_N_FRONT)
};
@@ -486,7 +486,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
-module_pos.y * conv_unit,
double(list[ii].m_Module->GetOrientation()) / 10 );
- int layer = list[ii].m_Module->GetLayer();
+ LAYER_NUM layer = list[ii].m_Module->GetLayer();
wxASSERT( layer==LAYER_N_FRONT || layer==LAYER_N_BACK );
diff --git a/pcbnew/gendrill_Excellon_writer.h b/pcbnew/gendrill_Excellon_writer.h
index 0e1318a39c..0803066f44 100644
--- a/pcbnew/gendrill_Excellon_writer.h
+++ b/pcbnew/gendrill_Excellon_writer.h
@@ -70,8 +70,8 @@ public:
int m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes
int m_Hole_Shape; // hole shape: round (0) or oval (1)
wxPoint m_Hole_Pos; // hole position
- int m_Hole_Bottom_Layer; // hole starting layer (usually back layer)
- int m_Hole_Top_Layer; // hole ending layer (usually front layer):
+ LAYER_NUM m_Hole_Bottom_Layer; // hole starting layer (usually back layer)
+ LAYER_NUM m_Hole_Top_Layer; // hole ending layer (usually front layer):
// m_Hole_First_Layer < m_Hole_Last_Layer
bool m_Hole_NotPlated; // hole not plated. Must be in a specific drill file
public:
diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp
index 2593994d4f..f1ef2fa000 100644
--- a/pcbnew/hotkeys_board_editor.cpp
+++ b/pcbnew/hotkeys_board_editor.cpp
@@ -129,7 +129,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
- int ll;
+ LAYER_NUM ll;
unsigned int cnt;
switch( hk_id )
@@ -249,9 +249,9 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
if( GetBoard()->GetCopperLayerCount() < 2 ) // Single layer
ll = LAYER_N_BACK;
else if( ll == LAYER_N_FRONT )
- ll = std::max( LAYER_N_BACK, GetBoard()->GetCopperLayerCount() - 2 );
+ ll = std::max( LAYER_N_BACK, FIRST_COPPER_LAYER + GetBoard()->GetCopperLayerCount() - 2 );
else
- ll--;
+ --ll;
SwitchLayer( aDC, ll );
break;
@@ -267,7 +267,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
else if( ll >= GetBoard()->GetCopperLayerCount() - 2 )
ll = LAYER_N_FRONT;
else
- ll++;
+ ++ll;
SwitchLayer( aDC, ll );
break;
@@ -585,7 +585,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
if( ItemFree )
{
wxPoint pos = GetScreen()->RefPos( false );
- MODULE* module = GetBoard()->GetFootprint( pos, ALL_LAYERS, false );
+ MODULE* module = GetBoard()->GetFootprint( pos, UNDEFINED_LAYER, false );
if( module == NULL )
return false;
diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp
index a047e644fa..d9c5ee4c49 100644
--- a/pcbnew/kicad_plugin.cpp
+++ b/pcbnew/kicad_plugin.cpp
@@ -383,7 +383,7 @@ void PCB_IO::formatLayer( const BOARD_ITEM* aItem ) const
{
if( m_ctl & CTL_STD_LAYER_NAMES )
{
- int layer = aItem->GetLayer();
+ LAYER_NUM layer = aItem->GetLayer();
// English layer names should never need quoting.
m_out->Print( 0, " (layer %s)", TO_UTF8( BOARD::GetStandardLayerName( layer ) ) );
@@ -425,7 +425,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
m_out->Print( aNestLevel, "(layers\n" );
unsigned mask = LAYER_FRONT;
- int layer = LAYER_N_FRONT;
+ LAYER_NUM layer = LAYER_N_FRONT;
// Save only the used copper layers from front to back.
while( mask != 0 )
@@ -443,14 +443,14 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
}
mask >>= 1;
- layer--;
+ --layer;
}
mask = ADHESIVE_LAYER_BACK;
layer = ADHESIVE_N_BACK;
// Save used non-copper layers in the order they are defined.
- while( layer < LAYER_COUNT )
+ while( layer < NB_LAYERS )
{
if( mask & aBoard->GetEnabledLayers() )
{
@@ -464,7 +464,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const
}
mask <<= 1;
- layer++;
+ ++layer;
}
m_out->Print( aNestLevel, ")\n\n" );
@@ -1036,7 +1036,7 @@ void PCB_IO::formatLayers( LAYER_MSK aLayerMask, int aNestLevel ) const
wxString layerName;
- for( int layer = 0; layerMask; ++layer, layerMask >>= 1 )
+ for( LAYER_NUM layer = FIRST_LAYER; layerMask; ++layer, layerMask >>= 1 )
{
if( layerMask & 1 )
{
@@ -1236,7 +1236,7 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const
{
if( aTrack->Type() == PCB_VIA_T )
{
- int layer1, layer2;
+ LAYER_NUM layer1, layer2;
SEGVIA* via = (SEGVIA*) aTrack;
BOARD* board = (BOARD*) via->GetParent();
diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp
index 63f372ae15..3d028f2ead 100644
--- a/pcbnew/layer_widget.cpp
+++ b/pcbnew/layer_widget.cpp
@@ -223,7 +223,7 @@ wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, EDA_COLOR_T aC
void LAYER_WIDGET::OnLeftDownLayers( wxMouseEvent& event )
{
int row;
- int layer;
+ LAYER_NUM layer;
wxWindow* eventSource = (wxWindow*) event.GetEventObject();
@@ -284,7 +284,7 @@ void LAYER_WIDGET::OnMiddleDownLayerColor( wxMouseEvent& event )
wxBitmap bm = makeBitmap( newColor );
eventSource->SetBitmapLabel( bm );
- int layer = getDecodedId( eventSource->GetId() );
+ LAYER_NUM layer = getDecodedId( eventSource->GetId() );
// tell the client code.
OnLayerColorChange( layer, newColor );
@@ -297,7 +297,7 @@ void LAYER_WIDGET::OnMiddleDownLayerColor( wxMouseEvent& event )
void LAYER_WIDGET::OnLayerCheckBox( wxCommandEvent& event )
{
wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
- int layer = getDecodedId( eventSource->GetId() );
+ LAYER_NUM layer = getDecodedId( eventSource->GetId() );
OnLayerVisible( layer, eventSource->IsChecked() );
passOnFocus();
}
@@ -348,14 +348,14 @@ void LAYER_WIDGET::OnTabChange( wxNotebookEvent& event )
wxWindow* LAYER_WIDGET::getLayerComp( int aRow, int aColumn ) const
{
- int ndx = aRow * LYR_COLUMN_COUNT + aColumn;
- if( (unsigned) ndx < m_LayersFlexGridSizer->GetChildren().GetCount() )
+ unsigned ndx = aRow * LYR_COLUMN_COUNT + aColumn;
+ if( ndx < m_LayersFlexGridSizer->GetChildren().GetCount() )
return m_LayersFlexGridSizer->GetChildren()[ndx]->GetWindow();
return NULL;
}
-int LAYER_WIDGET::findLayerRow( int aLayer ) const
+int LAYER_WIDGET::findLayerRow( LAYER_NUM aLayer ) const
{
int count = GetLayerRowCount();
for( int row=0; rowGetId() );
- return -1;
+ return UNDEFINED_LAYER;
}
-void LAYER_WIDGET::SetLayerVisible( int aLayer, bool isVisible )
+void LAYER_WIDGET::SetLayerVisible( LAYER_NUM aLayer, bool isVisible )
{
int row = findLayerRow( aLayer );
if( row >= 0 )
@@ -768,7 +768,7 @@ void LAYER_WIDGET::SetLayerVisible( int aLayer, bool isVisible )
}
-bool LAYER_WIDGET::IsLayerVisible( int aLayer )
+bool LAYER_WIDGET::IsLayerVisible( LAYER_NUM aLayer )
{
int row = findLayerRow( aLayer );
if( row >= 0 )
@@ -781,7 +781,7 @@ bool LAYER_WIDGET::IsLayerVisible( int aLayer )
}
-void LAYER_WIDGET::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
+void LAYER_WIDGET::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
{
int row = findLayerRow( aLayer );
if( row >= 0 )
@@ -798,7 +798,7 @@ void LAYER_WIDGET::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
}
-EDA_COLOR_T LAYER_WIDGET::GetLayerColor( int aLayer ) const
+EDA_COLOR_T LAYER_WIDGET::GetLayerColor( LAYER_NUM aLayer ) const
{
int row = findLayerRow( aLayer );
if( row >= 0 )
@@ -875,7 +875,7 @@ class MYFRAME : public wxFrame
{
}
- void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
+ void OnLayerColorChange( LAYER aLayer, EDA_COLOR_T aColor )
{
printf( "OnLayerColorChange( aLayer:%d, aColor:%d )\n", aLayer, aColor );
@@ -888,13 +888,13 @@ class MYFRAME : public wxFrame
*/
}
- bool OnLayerSelect( int aLayer )
+ bool OnLayerSelect( LAYER aLayer )
{
printf( "OnLayerSelect( aLayer:%d )\n", aLayer );
return true;
}
- void OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
+ void OnLayerVisible( LAYER aLayer, bool isVisible, bool isFinal )
{
printf( "OnLayerVisible( aLayer:%d, isVisible:%d isFinal:%d)\n", aLayer, isVisible, isFinal );
}
diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h
index a39fe8644b..a74a9e186b 100644
--- a/pcbnew/layer_widget.h
+++ b/pcbnew/layer_widget.h
@@ -181,7 +181,7 @@ protected:
* Function findLayerRow
* returns the row index that \a aLayer resides in, or -1 if not found.
*/
- int findLayerRow( int aLayer ) const;
+ int findLayerRow( LAYER_NUM aLayer ) const;
int findRenderRow( int aId ) const;
/**
@@ -296,37 +296,37 @@ public:
* Function SelectLayer
* changes the row selection in the layer list to \a aLayer provided.
*/
- void SelectLayer( int aLayer );
+ void SelectLayer( LAYER_NUM aLayer );
/**
* Function GetSelectedLayer
* returns the selected layer or -1 if none.
*/
- int GetSelectedLayer();
+ LAYER_NUM GetSelectedLayer();
/**
* Function SetLayerVisible
* sets \a aLayer visible or not. This does not invoke OnLayerVisible().
*/
- void SetLayerVisible( int aLayer, bool isVisible );
+ void SetLayerVisible( LAYER_NUM aLayer, bool isVisible );
/**
* Function IsLayerVisible
* returns the visible state of the layer ROW associated with \a aLayer id.
*/
- bool IsLayerVisible( int aLayer );
+ bool IsLayerVisible( LAYER_NUM aLayer );
/**
* Function SetLayerColor
* changes the color of \a aLayer
*/
- void SetLayerColor( int aLayer, EDA_COLOR_T aColor );
+ void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
/**
* Function GetLayerColor
* returns the color of the layer ROW associated with \a aLayer id.
*/
- EDA_COLOR_T GetLayerColor( int aLayer ) const;
+ EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
/**
* Function SetRenderState
@@ -374,7 +374,7 @@ public:
* @param aLayer is the board layer to change
* @param aColor is the new color
*/
- virtual void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) = 0;
+ virtual void OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor ) = 0;
/**
* Function OnLayerSelect
@@ -383,7 +383,7 @@ public:
* the change by returning false.
* @param aLayer is the board layer to select
*/
- virtual bool OnLayerSelect( int aLayer ) = 0;
+ virtual bool OnLayerSelect( LAYER_NUM aLayer ) = 0;
/**
* Function OnLayerVisible
@@ -395,7 +395,7 @@ public:
* such calls, and can be used to decide when to update the screen only
* one time instead of several times in the midst of a multiple layer change.
*/
- virtual void OnLayerVisible( int aLayer, bool isVisible, bool isFinal = true ) = 0;
+ virtual void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal = true ) = 0;
/**
* Function OnRenderColorChange
diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp
index 3a945691a3..29669bec82 100644
--- a/pcbnew/legacy_plugin.cpp
+++ b/pcbnew/legacy_plugin.cpp
@@ -208,6 +208,14 @@ static inline int intParse( const char* next, const char** out = NULL )
return (int) strtol( next, (char**) out, 10 );
}
+/**
+ * Function layerParse
+ * Like intParse but returns a LAYER_NUM
+ */
+static inline LAYER_NUM layerParse( const char* next, const char** out = NULL )
+{
+ return intParse( next, out );
+}
/**
* Function hexParse
@@ -429,7 +437,9 @@ void LEGACY_PLUGIN::loadGENERAL()
int layer_mask = hexParse( line + SZ( "Ly" ) );
int layer_count = 0;
- for( int ii = 0; ii < NB_COPPER_LAYERS && layer_mask; ++ii, layer_mask >>= 1 )
+ for( LAYER_NUM ii = FIRST_COPPER_LAYER;
+ ii < NB_COPPER_LAYERS && layer_mask;
+ ++ii, layer_mask >>= 1 )
{
if( layer_mask & 1 )
layer_count++;
@@ -657,7 +667,7 @@ void LEGACY_PLUGIN::loadSETUP()
{
// eg: "Layer[n] "
- int layer = intParse( line + SZ( "Layer[" ), &data );
+ LAYER_NUM layer = layerParse( line + SZ( "Layer[" ), &data );
data = strtok( (char*) data+1, delims ); // +1 for ']'
if( data )
@@ -970,7 +980,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
BIU pos_x = biuParse( line + SZ( "Po" ), &data );
BIU pos_y = biuParse( data, &data );
int orient = intParse( data, &data );
- int layer = intParse( data, &data );
+ LAYER_NUM layer = layerParse( data, &data );
long edittime = hexParse( data, &data );
time_t timestamp = hexParse( data, &data );
@@ -1377,7 +1387,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
// common to all cases, and we have to check their values uniformly at end
BIU width = 1;
- int layer = FIRST_NON_COPPER_LAYER;
+ LAYER_NUM layer = FIRST_NON_COPPER_LAYER;
switch( shape )
{
@@ -1391,7 +1401,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
double angle = degParse( data, &data );
width = biuParse( data, &data );
- layer = intParse( data );
+ layer = layerParse( data );
dwg->SetAngle( angle );
dwg->m_Start0 = wxPoint( start0_x, start0_y );
@@ -1411,7 +1421,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
BIU end0_y = biuParse( data, &data );
width = biuParse( data, &data );
- layer = intParse( data );
+ layer = layerParse( data );
dwg->m_Start0 = wxPoint( start0_x, start0_y );
dwg->m_End0 = wxPoint( end0_x, end0_y );
@@ -1430,7 +1440,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
int ptCount = intParse( data, &data );
width = biuParse( data, &data );
- layer = intParse( data );
+ layer = layerParse( data );
dwg->m_Start0 = wxPoint( start0_x, start0_y );
dwg->m_End0 = wxPoint( end0_x, end0_y );
@@ -1481,7 +1491,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
// can use the copper layers m_Layer < FIRST_NON_COPPER_LAYER is allowed.
// @todo: changes use of EDGE_MODULE these footprints and allows only
// m_Layer >= FIRST_NON_COPPER_LAYER
- if( layer < 0 || layer > LAST_NON_COPPER_LAYER )
+ if( layer < FIRST_LAYER || layer > LAST_NON_COPPER_LAYER )
layer = SILKSCREEN_N_FRONT;
dwg->SetWidth( width );
@@ -1543,7 +1553,7 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText )
char* mirror = strtok( (char*) data, delims );
char* hide = strtok( NULL, delims );
char* tmp = strtok( NULL, delims );
- int layer = tmp ? intParse( tmp ) : SILKSCREEN_N_FRONT;
+ LAYER_NUM layer = tmp ? layerParse( tmp ) : SILKSCREEN_N_FRONT;
char* italic = strtok( NULL, delims );
char* hjust = strtok( (char*) txt_end, delims );
@@ -1584,10 +1594,10 @@ void LEGACY_PLUGIN::loadMODULE_TEXT( TEXTE_MODULE* aText )
if( vjust )
aText->SetVertJustify( vertJustify( vjust ) );
- if( layer < 0 )
- layer = 0;
- else if( layer > LAST_NO_COPPER_LAYER )
- layer = LAST_NO_COPPER_LAYER;
+ if( layer < FIRST_LAYER )
+ layer = FIRST_LAYER;
+ else if( layer > LAST_NON_COPPER_LAYER )
+ layer = LAST_NON_COPPER_LAYER;
else if( layer == LAYER_N_BACK )
layer = SILKSCREEN_N_BACK;
else if( layer == LAYER_N_FRONT )
@@ -1701,14 +1711,14 @@ void LEGACY_PLUGIN::loadPCB_LINE()
switch( i )
{
case 0:
- int layer;
- layer = intParse( data );
+ LAYER_NUM layer;
+ layer = layerParse( data );
- if( layer < FIRST_NO_COPPER_LAYER )
- layer = FIRST_NO_COPPER_LAYER;
+ if( layer < FIRST_NON_COPPER_LAYER )
+ layer = FIRST_NON_COPPER_LAYER;
- else if( layer > LAST_NO_COPPER_LAYER )
- layer = LAST_NO_COPPER_LAYER;
+ else if( layer > LAST_NON_COPPER_LAYER )
+ layer = LAST_NON_COPPER_LAYER;
dseg->SetLayer( layer );
break;
@@ -1893,7 +1903,7 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
// e.g. "De 21 1 0 Normal C\r\n"
// sscanf( line + 2, " %d %d %lX %s %c\n", &m_Layer, &normal_display, &m_TimeStamp, style, &hJustify );
- int layer = intParse( line + SZ( "De" ), &data );
+ LAYER_NUM layer = layerParse( line + SZ( "De" ), &data );
int notMirrored = intParse( data, &data );
time_t timestamp = hexParse( data, &data );
char* style = strtok( (char*) data, delims );
@@ -1917,8 +1927,8 @@ void LEGACY_PLUGIN::loadPCB_TEXT()
if( layer < FIRST_COPPER_LAYER )
layer = FIRST_COPPER_LAYER;
- else if( layer > LAST_NO_COPPER_LAYER )
- layer = LAST_NO_COPPER_LAYER;
+ else if( layer > LAST_NON_COPPER_LAYER )
+ layer = LAST_NON_COPPER_LAYER;
pcbtxt->SetLayer( layer );
}
@@ -2200,7 +2210,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
else if( TESTLINE( "ZLayer" ) ) // layer found
{
- int layer = intParse( line + SZ( "ZLayer" ) );
+ LAYER_NUM layer = layerParse( line + SZ( "ZLayer" ) );
zc->SetLayer( layer );
}
@@ -2435,17 +2445,18 @@ void LEGACY_PLUGIN::loadDIMENSION()
else if( TESTLINE( "Ge" ) )
{
- int layer;
+ LAYER_NUM layer;
time_t timestamp;
int shape;
+ int ilayer;
- sscanf( line + SZ( "Ge" ), " %d %d %lX", &shape, &layer, ×tamp );
+ sscanf( line + SZ( "Ge" ), " %d %d %lX", &shape, &ilayer, ×tamp );
- if( layer < FIRST_NO_COPPER_LAYER )
- layer = FIRST_NO_COPPER_LAYER;
-
- else if( layer > LAST_NO_COPPER_LAYER )
- layer = LAST_NO_COPPER_LAYER;
+ if( ilayer < FIRST_NON_COPPER_LAYER )
+ layer = FIRST_NON_COPPER_LAYER;
+ else if( ilayer > LAST_NON_COPPER_LAYER )
+ layer = LAST_NON_COPPER_LAYER;
+ else layer = ilayer;
dim->SetLayer( layer );
dim->SetTimeStamp( timestamp );
@@ -2625,18 +2636,18 @@ void LEGACY_PLUGIN::loadPCB_TARGET()
// sscanf( Line + 2, " %X %d %d %d %d %d %lX", &m_Shape, &m_Layer, &m_Pos.x, &m_Pos.y, &m_Size, &m_Width, &m_TimeStamp );
int shape = intParse( line + SZ( "Po" ), &data );
- int layer = intParse( data, &data );
+ LAYER_NUM layer = layerParse( data, &data );
BIU pos_x = biuParse( data, &data );
BIU pos_y = biuParse( data, &data );
BIU size = biuParse( data, &data );
BIU width = biuParse( data, &data );
time_t timestamp = hexParse( data );
- if( layer < FIRST_NO_COPPER_LAYER )
- layer = FIRST_NO_COPPER_LAYER;
+ if( layer < FIRST_NON_COPPER_LAYER )
+ layer = FIRST_NON_COPPER_LAYER;
- else if( layer > LAST_NO_COPPER_LAYER )
- layer = LAST_NO_COPPER_LAYER;
+ else if( layer > LAST_NON_COPPER_LAYER )
+ layer = LAST_NON_COPPER_LAYER;
PCB_TARGET* t = new PCB_TARGET( m_board, shape, layer, wxPoint( pos_x, pos_y ), size, width );
m_board->Add( t, ADD_APPEND );
@@ -2973,7 +2984,7 @@ void LEGACY_PLUGIN::saveSETUP( const BOARD* aBoard ) const
unsigned layerMask = ALL_CU_LAYERS & aBoard->GetEnabledLayers();
- for( int layer = 0; layerMask; ++layer, layerMask >>= 1 )
+ for( LAYER_NUM layer = FIRST_LAYER; layerMask; ++layer, layerMask >>= 1 )
{
if( layerMask & 1 )
{
diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp
index 4edb3d416c..87ad7bff83 100644
--- a/pcbnew/magnetic_tracks_functions.cpp
+++ b/pcbnew/magnetic_tracks_functions.cpp
@@ -173,7 +173,7 @@ bool Magnetize( PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize,
// after pads, only track & via tests remain, skip them if not desired
if( doTrack )
{
- int layer = screen->m_Active_Layer;
+ LAYER_NUM layer = screen->m_Active_Layer;
for( TRACK* via = m_Pcb->m_Track;
via && (via = via->GetVia( *curpos, layer )) != NULL;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb.cpp
index 393ab9da63..39a65ebf33 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb.cpp
@@ -48,7 +48,7 @@
namespace PCAD2KICAD {
-int PCB::GetKiCadLayer( int aPCadLayer )
+LAYER_NUM PCB::GetKiCadLayer( int aPCadLayer )
{
wxASSERT( aPCadLayer >= 0 && aPCadLayer < MAX_PCAD_LAYER_QTY );
return m_layersMap[aPCadLayer].KiCadLayer;
@@ -447,9 +447,7 @@ void PCB::ConnectPinToNet( wxString aCompRef, wxString aPinRef, wxString aNetNam
int PCB::FindLayer( wxString aLayerName )
{
- int i;
-
- for ( i = 0; i < (int) m_layersStackup.GetCount(); i++ )
+ for ( LAYER_NUM i = FIRST_COPPER_LAYER; i < (int)m_layersStackup.GetCount(); ++i )
{
if( m_layersStackup[i] == aLayerName )
return i;
@@ -479,7 +477,7 @@ int PCB::FindLayer( wxString aLayerName )
void PCB::MapLayer( XNODE* aNode )
{
wxString lName, layerType;
- int KiCadLayer;
+ LAYER_NUM KiCadLayer;
long num = 0;
aNode->GetAttribute( wxT( "Name" ), &lName );
@@ -509,12 +507,12 @@ void PCB::MapLayer( XNODE* aNode )
KiCadLayer = EDGE_N;
else
{
- KiCadLayer = FindLayer( lName );
+ int layernum = FindLayer( lName );
- if( KiCadLayer == -1 )
+ if( layernum == -1 )
KiCadLayer = DRAW_N; // default
else
- KiCadLayer = FIRST_COPPER_LAYER + m_layersStackup.GetCount() - 1 - KiCadLayer;
+ KiCadLayer = FIRST_COPPER_LAYER + m_layersStackup.GetCount() - 1 - layernum;
}
if( FindNode( aNode, wxT( "layerNum" ) ) )
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb.h b/pcbnew/pcad2kicadpcb_plugin/pcb.h
index 91b76cd6c4..baedea0e55 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb.h
@@ -53,7 +53,7 @@ public:
PCB( BOARD* aBoard );
~PCB();
- int GetKiCadLayer( int aPCadLayer );
+ LAYER_NUM GetKiCadLayer( int aPCadLayer );
LAYER_TYPE_T GetLayerType( int aPCadLayer );
wxString GetLayerNetNameRef( int aPCadLayer );
int GetNewTimestamp();
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h b/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h
index 05b4837ee5..a12dc70343 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_callbacks.h
@@ -42,7 +42,7 @@ enum LAYER_TYPE_T
typedef struct _TLAYER
{
- int KiCadLayer;
+ LAYER_NUM KiCadLayer;
LAYER_TYPE_T layerType;
wxString netNameRef;
} TLAYER;
@@ -53,7 +53,7 @@ namespace PCAD2KICAD
class PCB_CALLBACKS
{
public:
- virtual int GetKiCadLayer( int aPCadLayer ) = 0;
+ virtual LAYER_NUM GetKiCadLayer( int aPCadLayer ) = 0;
virtual LAYER_TYPE_T GetLayerType( int aPCadLayer ) = 0;
virtual wxString GetLayerNetNameRef( int aPCadLayer ) = 0;
virtual int GetNewTimestamp() = 0;
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp
index 2e59042f43..0bcb43984b 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_component.cpp
@@ -43,7 +43,7 @@ PCB_COMPONENT::PCB_COMPONENT( PCB_CALLBACKS* aCallbacks,
m_tag = 0;
m_objType = wxT( '?' );
m_PCadLayer = 0;
- m_KiCadLayer = 0;
+ m_KiCadLayer = NO_LAYER;
m_timestamp = 0;
m_positionX = 0;
m_positionY = 0;
@@ -77,9 +77,9 @@ void PCB_COMPONENT::Flip()
m_positionX = -m_positionX;
}
-int PCB_COMPONENT::FlipLayers( int aLayer )
+LAYER_NUM PCB_COMPONENT::FlipLayers( LAYER_NUM aLayer )
{
- int result = aLayer; // dafault is no swap
+ LAYER_NUM result = aLayer; // dafault is no swap
// routed layers
if( aLayer == LAYER_N_BACK )
diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_component.h b/pcbnew/pcad2kicadpcb_plugin/pcb_component.h
index a89deb9062..48700318d0 100644
--- a/pcbnew/pcad2kicadpcb_plugin/pcb_component.h
+++ b/pcbnew/pcad2kicadpcb_plugin/pcb_component.h
@@ -51,7 +51,7 @@ public:
int m_tag;
char m_objType;
int m_PCadLayer;
- int m_KiCadLayer;
+ LAYER_NUM m_KiCadLayer;
int m_timestamp;
int m_positionX;
int m_positionY;
@@ -70,7 +70,7 @@ public:
virtual void AddToModule( MODULE* aModule );
virtual void AddToBoard() = 0;
- int GetKiCadLayer() { return m_callbacks->GetKiCadLayer( m_PCadLayer ); }
+ LAYER_NUM GetKiCadLayer() { return m_callbacks->GetKiCadLayer( m_PCadLayer ); }
int GetNewTimestamp() { return m_callbacks->GetNewTimestamp(); }
int GetNetCode( wxString aNetName ) { return m_callbacks->GetNetCode( aNetName ); }
@@ -78,7 +78,7 @@ protected:
PCB_CALLBACKS* m_callbacks;
BOARD* m_board;
- int FlipLayers( int aLayer );
+ LAYER_NUM FlipLayers( LAYER_NUM aLayer );
};
WX_DEFINE_ARRAY( PCB_COMPONENT*, PCB_COMPONENTS_ARRAY );
diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp
index 8f45cec82a..ecf7ddac85 100644
--- a/pcbnew/pcb_parser.cpp
+++ b/pcbnew/pcb_parser.cpp
@@ -61,7 +61,7 @@ void PCB_PARSER::init()
// Add untranslated default (i.e. english) layernames.
// Some may be overridden later if parsing a board rather than a footprint.
// The english name will survive if parsing only a footprint.
- for( int layerNdx = 0; layerNdx < NB_LAYERS; ++layerNdx )
+ for( LAYER_NUM layerNdx = FIRST_LAYER; layerNdx < NB_PCB_LAYERS; ++layerNdx )
{
std::string untranslated = TO_UTF8( BOARD::GetStandardLayerName( layerNdx ) );
@@ -665,7 +665,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
T token;
std::string name;
std::string type;
- int layerIndex;
+ LAYER_NUM layerIndex;
bool isVisible = true;
LAYER_MSK visibleLayers = NO_LAYERS;
LAYER_MSK enabledLayers = NO_LAYERS;
@@ -765,14 +765,14 @@ T PCB_PARSER::lookUpLayer( const M& aMap ) throw( PARSE_ERROR, IO_ERROR )
}
-int PCB_PARSER::parseBoardItemLayer() throw( PARSE_ERROR, IO_ERROR )
+LAYER_NUM PCB_PARSER::parseBoardItemLayer() throw( PARSE_ERROR, IO_ERROR )
{
wxCHECK_MSG( CurTok() == T_layer, UNDEFINED_LAYER,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as layer." ) );
NextTok();
- int layerIndex = lookUpLayer( m_layerIndices );
+ LAYER_NUM layerIndex = lookUpLayer( m_layerIndices );
// Handle closing ) in object parser.
@@ -2323,11 +2323,11 @@ SEGVIA* PCB_PARSER::parseSEGVIA() throw( IO_ERROR, PARSE_ERROR )
case T_layers:
{
- int layer1, layer2;
+ LAYER_NUM layer1, layer2;
NextTok();
- layer1 = lookUpLayer( m_layerIndices );
+ layer1 = lookUpLayer( m_layerIndices );
NextTok();
- layer2 = lookUpLayer( m_layerIndices );
+ layer2 = lookUpLayer( m_layerIndices );
via->SetLayerPair( layer1, layer2 );
NeedRIGHT();
}
diff --git a/pcbnew/pcb_parser.h b/pcbnew/pcb_parser.h
index e1f89e839e..92574af4e4 100644
--- a/pcbnew/pcb_parser.h
+++ b/pcbnew/pcb_parser.h
@@ -58,7 +58,7 @@ class FPL_CACHE;
*/
class PCB_PARSER : public PCB_LEXER
{
- typedef boost::unordered_map< std::string, int > LAYER_NUM_MAP;
+ typedef boost::unordered_map< std::string, LAYER_NUM > LAYER_NUM_MAP;
typedef boost::unordered_map< std::string, LAYER_MSK > LAYER_MSK_MAP;
BOARD* m_board;
@@ -117,7 +117,7 @@ class PCB_PARSER : public PCB_LEXER
* @throw PARSE_ERROR if the layer syntax is incorrect.
* @return The index the parsed #BOARD_ITEM layer.
*/
- int parseBoardItemLayer() throw( IO_ERROR, PARSE_ERROR );
+ LAYER_NUM parseBoardItemLayer() throw( IO_ERROR, PARSE_ERROR );
/**
* Function parseBoardItemLayersAsMask
diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp
index 5ee7f1a2f1..9a72c1078c 100644
--- a/pcbnew/pcbframe.cpp
+++ b/pcbnew/pcbframe.cpp
@@ -658,7 +658,7 @@ void PCB_EDIT_FRAME::SetGridColor(EDA_COLOR_T aColor)
bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
{
int copperlayercnt = GetBoard()->GetCopperLayerCount( );
- int currLayer = getActiveLayer();
+ LAYER_NUM currLayer = getActiveLayer();
if( !GetDesignSettings().m_MicroViasAllowed )
return false; // Obvious..
diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp
index 199ff3a537..279829bb44 100644
--- a/pcbnew/pcbnew.cpp
+++ b/pcbnew/pcbnew.cpp
@@ -65,8 +65,8 @@ bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. an
bool g_Segments_45_Only; // True to allow horiz, vert. and 45deg only graphic segments
bool g_TwoSegmentTrackBuild = true;
-int g_Route_Layer_TOP;
-int g_Route_Layer_BOTTOM;
+LAYER_NUM g_Route_Layer_TOP;
+LAYER_NUM g_Route_Layer_BOTTOM;
int g_MaxLinksShowed;
int g_MagneticPadOption = capture_cursor_in_track_tool;
int g_MagneticTrackOption = capture_cursor_in_track_tool;
diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h
index aeeb6a9a61..bea9f057bf 100644
--- a/pcbnew/pcbnew.h
+++ b/pcbnew/pcbnew.h
@@ -59,8 +59,8 @@ extern bool g_Alternate_Track_Posture;
extern bool g_Segments_45_Only;
/* Layer pair for auto routing and switch layers by hotkey */
-extern int g_Route_Layer_TOP;
-extern int g_Route_Layer_BOTTOM;
+extern LAYER_NUM g_Route_Layer_TOP;
+extern LAYER_NUM g_Route_Layer_BOTTOM;
extern int g_MaxLinksShowed; // Max count links showed in routing
extern bool g_TwoSegmentTrackBuild;
diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp
index 503e44f31e..1a508a4265 100644
--- a/pcbnew/pcbplot.cpp
+++ b/pcbnew/pcbplot.cpp
@@ -44,7 +44,7 @@
/** Get the 'traditional' gerber extension depending on the layer
*/
-static wxString GetGerberExtension( int layer )/*{{{*/
+static wxString GetGerberExtension( LAYER_NUM layer )/*{{{*/
{
switch( layer )
{
@@ -190,8 +190,6 @@ bool EnsureOutputDirectory( wxFileName *aOutputDir,
*/
void DIALOG_PLOT::Plot( wxCommandEvent& event )
{
- int layer;
-
applyPlotSettings();
// Create output directory if it does not exist (also transform it in
@@ -255,7 +253,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
// Save the current plot options in the board
m_parent->SetPlotSettings( m_plotOpts );
- for( layer = 0; layer < NB_LAYERS; ++layer )
+ for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
{
if( m_plotOpts.GetLayerSelection() & GetLayerMask( layer ) )
{
@@ -372,7 +370,7 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, /*{{{*/
}/*}}}*/
/** Plot a single layer on the current plotfile */
-bool PLOT_CONTROLLER::PlotLayer( int aLayer )/*{{{*/
+bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )/*{{{*/
{
LOCALE_IO toggle;
diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h
index a4e71ee323..21c352e994 100644
--- a/pcbnew/pcbplot.h
+++ b/pcbnew/pcbplot.h
@@ -148,7 +148,7 @@ public:
* and in B&W mode, is plotted as white but other colors are plotted in BLACK
* so the returned color is LIGHTGRAY when the layer color is WHITE
*/
- EDA_COLOR_T getColor( int aLayer );
+ EDA_COLOR_T getColor( LAYER_NUM aLayer );
private:
/** Helper function to plot a single drill mark. It compensate and clamp
@@ -176,7 +176,7 @@ PLOTTER* StartPlotBoard( BOARD* aBoard,
* @param aLayer = the layer id to plot
* @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only
*/
-void PlotOneBoardLayer( BOARD* aBoard, PLOTTER* aPlotter, int aLayer,
+void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer,
const PCB_PLOT_PARAMS& aPlotOpt );
/**
diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp
index 8e9ec9ad72..7b8b9c9ad3 100644
--- a/pcbnew/plot_board_layers.cpp
+++ b/pcbnew/plot_board_layers.cpp
@@ -142,7 +142,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LAYER_MSK aLayerMask,
}
}
-void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int aLayer,
+void PlotOneBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, LAYER_NUM aLayer,
const PCB_PLOT_PARAMS& aPlotOpt )
{
PCB_PLOT_PARAMS plotOpt = aPlotOpt;
@@ -468,7 +468,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter,
long aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt,
int aMinThickness )
{
- int layer = ( aLayerMask & SOLDERMASK_LAYER_BACK ) ?
+ LAYER_NUM layer = ( aLayerMask & SOLDERMASK_LAYER_BACK ) ?
SOLDERMASK_N_BACK : SOLDERMASK_N_FRONT;
int inflate = aMinThickness/2;
diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp
index a549acde42..f1c271de6f 100644
--- a/pcbnew/plot_brditems_plotter.cpp
+++ b/pcbnew/plot_brditems_plotter.cpp
@@ -54,7 +54,7 @@
*/
-EDA_COLOR_T BRDITEMS_PLOTTER::getColor( int aLayer )
+EDA_COLOR_T BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer )
{
EDA_COLOR_T color = m_board->GetLayerColor( aLayer );
if (color == WHITE)
@@ -107,9 +107,9 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
bool trace_ref = GetPlotReference();
TEXTE_MODULE* textModule = &aModule->Reference();
- unsigned textLayer = textModule->GetLayer();
+ LAYER_NUM textLayer = textModule->GetLayer();
- if( textLayer >= LAYER_COUNT )
+ if( textLayer >= NB_LAYERS )
return false;
if( ( GetLayerMask( textLayer ) & m_layerMask ) == 0 )
@@ -121,7 +121,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
textModule = &aModule->Value();
textLayer = textModule->GetLayer();
- if( textLayer > LAYER_COUNT )
+ if( textLayer > NB_LAYERS )
return false;
if( ( GetLayerMask( textLayer ) & m_layerMask ) == 0 )
@@ -161,7 +161,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
textLayer = textModule->GetLayer();
- if( textLayer >= LAYER_COUNT )
+ if( textLayer >= NB_LAYERS )
return false;
if( !( GetLayerMask( textLayer ) & m_layerMask ) )
diff --git a/pcbnew/plotcontroller.h b/pcbnew/plotcontroller.h
index b4afbc77b4..89e0028d0b 100644
--- a/pcbnew/plotcontroller.h
+++ b/pcbnew/plotcontroller.h
@@ -25,7 +25,7 @@ public:
void ClosePlot();
bool OpenPlotfile( const wxString &aSuffix, PlotFormat aFormat,
const wxString &aSheetDesc );
- bool PlotLayer( int layer );
+ bool PlotLayer( LAYER_NUM layer );
private:
/// Option bank
diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp
index 09c4a3f9d0..9fb8bdb7f1 100644
--- a/pcbnew/print_board_functions.cpp
+++ b/pcbnew/print_board_functions.cpp
@@ -156,7 +156,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
}
save_opt = DisplayOpt;
- int activeLayer = GetScreen()->m_Active_Layer;
+ LAYER_NUM activeLayer = GetScreen()->m_Active_Layer;
DisplayOpt.ContrastModeDisplay = false;
DisplayOpt.DisplayPadFill = true;
@@ -172,9 +172,9 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
DisplayOpt.DisplayPadFill = true;
// Calculate the active layer number to print from its mask layer:
- GetScreen()->m_Active_Layer = 0;
+ GetScreen()->m_Active_Layer = FIRST_LAYER;
- for(int kk = 0; kk < 32; kk ++ )
+ for( LAYER_NUM kk = FIRST_LAYER; kk < NB_LAYERS; ++kk )
{
if( GetLayerMask( kk ) & aPrintMaskLayer )
{
diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp
index 74fd538310..44eea74cc9 100644
--- a/pcbnew/printout_controler.cpp
+++ b/pcbnew/printout_controler.cpp
@@ -65,7 +65,7 @@ PRINT_PARAMETERS::PRINT_PARAMETERS()
m_XScaleAdjust = 1.0;
m_YScaleAdjust = 1.0;
m_Print_Sheet_Ref = false;
- m_PrintMaskLayer = 0xFFFFFFFF;
+ m_PrintMaskLayer = FULL_LAYERS;
m_PrintMirror = false;
m_Print_Black_and_White = true;
m_OptionPrintPage = 1;
@@ -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_LAYERS;
+ int layers_count = NB_PCB_LAYERS;
#else
- int layers_count = LAYER_COUNT;
+ int layers_count = NB_LAYERS;
#endif
LAYER_MSK mask_layer = m_PrintParams.m_PrintMaskLayer;
diff --git a/pcbnew/protos.h b/pcbnew/protos.h
index 0ae8f2e77b..a906b947df 100644
--- a/pcbnew/protos.h
+++ b/pcbnew/protos.h
@@ -65,7 +65,7 @@ void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module );
/* EDITRACK.C : */
/****************/
-TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, int aLayer, const wxPoint& aRef );
+TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, LAYER_NUM aLayer, const wxPoint& aRef );
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase );
diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp
index d1e739ebe9..0985c06a41 100644
--- a/pcbnew/sel_layer.cpp
+++ b/pcbnew/sel_layer.cpp
@@ -25,12 +25,12 @@ class SELECT_LAYER_DIALOG : public wxDialog
private:
PCB_BASE_FRAME* m_Parent;
wxRadioBox* m_LayerList;
- int m_LayerId[NB_LAYERS + 1]; // One extra element for "(Deselect)" radiobutton
+ LAYER_NUM m_LayerId[int(NB_PCB_LAYERS) + 1]; // One extra element for "(Deselect)" radiobutton
public:
// Constructor and destructor
- SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent, int default_layer,
- int min_layer, int max_layer, bool null_layer );
+ SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent, LAYER_NUM default_layer,
+ LAYER_NUM min_layer, LAYER_NUM max_layer, bool null_layer );
~SELECT_LAYER_DIALOG() { };
private:
@@ -49,11 +49,11 @@ END_EVENT_TABLE()
/** Install the dialog box for layer selection
- * @param default_layer = Preselection (NB_LAYERS for "(Deselect)" layer)
+ * @param default_layer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer)
* @param min_layer = min layer value (-1 if no min value)
* @param max_layer = max layer value (-1 if no max value)
* @param null_layer = display a "(Deselect)" radiobutton (when set to true)
- * @return new layer value (NB_LAYERS when "(Deselect)" radiobutton selected),
+ * @return new layer value (NB_PCB_LAYERS when "(Deselect)" radiobutton selected),
* or -1 if canceled
*
* Providing the option to also display a "(Deselect)" radiobutton makes the
@@ -65,19 +65,18 @@ END_EVENT_TABLE()
* "Deselect"
* button provided within the "Swap Layers:" or "Layer selection:" dialog box).
*/
-int PCB_BASE_FRAME::SelectLayer( int default_layer,
- int min_layer,
- int max_layer,
+LAYER_NUM PCB_BASE_FRAME::SelectLayer( LAYER_NUM default_layer,
+ LAYER_NUM min_layer,
+ LAYER_NUM max_layer,
bool null_layer )
{
- int layer;
SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this,
default_layer,
min_layer,
max_layer,
null_layer );
- layer = frame->ShowModal();
+ LAYER_NUM layer = frame->ShowModal();
frame->Destroy();
return layer;
}
@@ -90,16 +89,16 @@ int PCB_BASE_FRAME::SelectLayer( int default_layer,
* to the right of that radiobox.
*/
SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent,
- int default_layer, int min_layer,
- int max_layer, bool null_layer ) :
+ LAYER_NUM default_layer, LAYER_NUM min_layer,
+ LAYER_NUM max_layer, bool null_layer ) :
wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ),
wxSize( 470, 250 ),
DIALOG_STYLE )
{
BOARD* board = parent->GetBoard();
wxButton* Button;
- int ii;
- wxString LayerList[NB_LAYERS + 1]; // One extra element for "(Deselect)"
+ LAYER_NUM ii;
+ wxString LayerList[NB_PCB_LAYERS + 1]; // One extra element for "(Deselect)"
// radiobutton
int LayerCount, LayerSelect = -1;
@@ -110,9 +109,9 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent,
LAYER_MSK Masque_Layer = g_TabAllCopperLayerMask[board->GetCopperLayerCount() - 1];
Masque_Layer |= ALL_NO_CU_LAYERS;
- for( ii = 0; ii < NB_LAYERS; ii++ )
+ for( ii = FIRST_LAYER; ii < NB_PCB_LAYERS; ++ii )
{
- m_LayerId[ii] = 0;
+ m_LayerId[ii] = FIRST_LAYER;
if( GetLayerMask( ii ) & Masque_Layer )
{
@@ -137,10 +136,10 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent,
{
LayerList[LayerCount] = _( "(Deselect)" );
- if( NB_LAYERS == default_layer )
+ if( NB_PCB_LAYERS == default_layer )
LayerSelect = LayerCount;
- m_LayerId[LayerCount] = NB_LAYERS;
+ m_LayerId[LayerCount] = NB_PCB_LAYERS;
LayerCount++;
}
@@ -198,7 +197,7 @@ private:
PCB_BASE_FRAME* m_Parent;
wxRadioBox* m_LayerListTOP;
wxRadioBox* m_LayerListBOTTOM;
- int m_LayerId[NB_COPPER_LAYERS];
+ LAYER_NUM m_LayerId[NB_COPPER_LAYERS];
public: SELECT_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* parent );
~SELECT_LAYERS_PAIR_DIALOG() { };
@@ -255,9 +254,8 @@ SELECT_LAYERS_PAIR_DIALOG::SELECT_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* parent ) :
{
BOARD* board = parent->GetBoard();
wxButton* Button;
- int ii, LayerCount;
wxString LayerList[NB_COPPER_LAYERS];
- int LayerTopSelect = 0, LayerBottomSelect = 0;
+ LAYER_NUM LayerTopSelect = FIRST_LAYER, LayerBottomSelect = FIRST_LAYER;
m_Parent = parent;
@@ -265,9 +263,10 @@ SELECT_LAYERS_PAIR_DIALOG::SELECT_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* parent ) :
LAYER_MSK Masque_Layer = g_TabAllCopperLayerMask[board->GetCopperLayerCount() - 1];
Masque_Layer |= ALL_NO_CU_LAYERS;
- for( ii = 0, LayerCount = 0; ii < NB_COPPER_LAYERS; ii++ )
+ LAYER_NUM LayerCount = FIRST_LAYER;
+ for( LAYER_NUM ii = FIRST_COPPER_LAYER; ii < NB_COPPER_LAYERS; ++ii )
{
- m_LayerId[ii] = 0;
+ m_LayerId[ii] = FIRST_LAYER;
if( (GetLayerMask( ii ) & Masque_Layer) )
{
@@ -280,7 +279,7 @@ SELECT_LAYERS_PAIR_DIALOG::SELECT_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* parent ) :
LayerBottomSelect = LayerCount;
m_LayerId[LayerCount] = ii;
- LayerCount++;
+ ++LayerCount;
}
}
diff --git a/pcbnew/specctra.cpp b/pcbnew/specctra.cpp
index 398297f1b4..cc2c8cfc1d 100644
--- a/pcbnew/specctra.cpp
+++ b/pcbnew/specctra.cpp
@@ -79,11 +79,12 @@ void SPECCTRA_DB::buildLayerMaps( BOARD* aBoard )
layerIds.clear();
pcbLayer2kicad.resize( layerCount );
- kicadLayer2pcb.resize( LAYER_N_FRONT+1 );
+ kicadLayer2pcb.resize( LAYER_N_FRONT + 1 );
- for( int kiNdx=layerCount-1, pcbNdx=0; kiNdx >= 0; --kiNdx, ++pcbNdx )
+ for( LAYER_NUM kiNdx = layerCount - 1, pcbNdx=FIRST_LAYER;
+ kiNdx >= 0; --kiNdx, ++pcbNdx )
{
- int kilayer = kiNdx>0 && kiNdx==layerCount-1 ? LAYER_N_FRONT : kiNdx;
+ LAYER_NUM kilayer = (kiNdx>0 && kiNdx==layerCount-1) ? LAYER_N_FRONT : kiNdx;
// establish bi-directional mapping between KiCad's BOARD layer and PCB layer
pcbLayer2kicad[pcbNdx] = kilayer;
@@ -95,14 +96,14 @@ void SPECCTRA_DB::buildLayerMaps( BOARD* aBoard )
}
-int SPECCTRA_DB::findLayerName( const std::string& aLayerName ) const
+LAYER_NUM SPECCTRA_DB::findLayerName( const std::string& aLayerName ) const
{
- for( unsigned i=0; i kicadLayer2pcb;
+ std::vector kicadLayer2pcb;
/// maps PCB layer number to BOARD layer numbers
- std::vector pcbLayer2kicad;
+ std::vector pcbLayer2kicad;
/// used during FromSESSION() only, memory for it is not owned here.
UNIT_RES* routeResolution;
@@ -3608,7 +3608,7 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
* Function findLayerName
* returns the PCB layer index for a given layer name
*/
- int findLayerName( const std::string& aLayerName ) const;
+ LAYER_NUM findLayerName( const std::string& aLayerName ) const;
/**
* Function readCOMPnPIN
@@ -3740,7 +3740,7 @@ class SPECCTRA_DB : public SPECCTRA_LEXER
* or delete it.
*/
PADSTACK* makeVia( int aCopperDiameter, int aDrillDiameter,
- int aTopLayer, int aBotLayer );
+ LAYER_NUM aTopLayer, LAYER_NUM aBotLayer );
/**
* Function makeVia
diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp
index 1faabd2388..de4fe71b55 100644
--- a/pcbnew/specctra_export.cpp
+++ b/pcbnew/specctra_export.cpp
@@ -330,9 +330,9 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
uniqifier += 'A'; // A for all layers
const int copperCount = aBoard->GetCopperLayerCount();
- for( int layer=0; layerIsOnLayer( kilayer ) )
{
@@ -376,7 +376,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
{
double diameter = scale(aPad->GetSize().x);
- for( int ndx=0; ndxAppend( shape );
@@ -409,7 +409,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
lowerLeft += dsnOffset;
upperRight += dsnOffset;
- for( int ndx=0; ndxAppend( shape );
@@ -460,7 +460,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
start += dsnOffset;
stop += dsnOffset;
- for( int ndx=0; ndxAppend( shape );
@@ -569,7 +569,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
POINT vertex = mapPt( pad->GetPos0() );
int layerCount = aBoard->GetCopperLayerCount();
- for( int layer=0; layerkeepouts.push_back( keepout );
@@ -716,14 +716,14 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
PADSTACK* SPECCTRA_DB::makeVia( int aCopperDiameter, int aDrillDiameter,
- int aTopLayer, int aBotLayer )
+ LAYER_NUM aTopLayer, LAYER_NUM aBotLayer )
{
char name[48];
PADSTACK* padstack = new PADSTACK();
double dsnDiameter = scale( aCopperDiameter );
- for( int layer=aTopLayer; layer<=aBotLayer; ++layer )
+ for( LAYER_NUM layer=aTopLayer; layer<=aBotLayer; ++layer )
{
SHAPE* shape = new SHAPE( padstack );
padstack->Append( shape );
@@ -750,8 +750,8 @@ PADSTACK* SPECCTRA_DB::makeVia( int aCopperDiameter, int aDrillDiameter,
PADSTACK* SPECCTRA_DB::makeVia( const SEGVIA* aVia )
{
- int topLayer;
- int botLayer;
+ LAYER_NUM topLayer;
+ LAYER_NUM botLayer;
aVia->ReturnLayerPair( &topLayer, &botLayer );
@@ -991,7 +991,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
int layerCount = aBoard->GetCopperLayerCount();
- for( int pcbNdx=0; pcbNdxstructure );
pcb->structure->layers.push_back( layer );
@@ -1415,7 +1415,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
NETCLASS* netclass = nclasses.GetDefault();
PADSTACK* via = makeVia( netclass->GetViaDiameter(), netclass->GetViaDrill(),
- 0, aBoard->GetCopperLayerCount()-1 );
+ FIRST_LAYER, aBoard->GetCopperLayerCount()-1 );
// we AppendVia() this first one, there is no way it can be a duplicate,
// the pcb->library via container is empty at this point. After this,
@@ -1431,7 +1431,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
int viaDrill = aBoard->m_ViasDimensionsList[i].m_Drill;
via = makeVia( viaSize, viaDrill,
- 0, aBoard->GetCopperLayerCount()-1 );
+ FIRST_LAYER, aBoard->GetCopperLayerCount()-1 );
// maybe add 'via' to the library, but only if unique.
PADSTACK* registered = pcb->library->LookupVia( via );
@@ -1448,7 +1448,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
netclass = nc->second;
via = makeVia( netclass->GetViaDiameter(), netclass->GetViaDrill(),
- 0, aBoard->GetCopperLayerCount()-1 );
+ FIRST_LAYER, aBoard->GetCopperLayerCount()-1 );
// maybe add 'via' to the library, but only if unique.
PADSTACK* registered = pcb->library->LookupVia( via );
@@ -1474,7 +1474,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
int old_netcode = -1;
int old_width = -1;
- int old_layer = -1;
+ LAYER_NUM old_layer = UNDEFINED_LAYER;
for( int i=0; iwire_type = T_protect; // @todo, this should be configurable
- int kiLayer = track->GetLayer();
- int pcbLayer = kicadLayer2pcb[kiLayer];
+ LAYER_NUM kiLayer = track->GetLayer();
+ LAYER_NUM pcbLayer = kicadLayer2pcb[kiLayer];
path = new PATH( wire );
wire->SetShape( path );
@@ -1666,7 +1666,7 @@ void SPECCTRA_DB::exportNETCLASS( NETCLASS* aNetClass, BOARD* aBoard )
// this should never become a performance issue.
PADSTACK* via = makeVia( aNetClass->GetViaDiameter(), aNetClass->GetViaDrill(),
- 0, aBoard->GetCopperLayerCount()-1 );
+ FIRST_LAYER, aBoard->GetCopperLayerCount()-1 );
snprintf( text, sizeof(text), "(use_via %s)", via->GetPadstackId().c_str() );
clazz->circuit.push_back( text );
diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp
index e96be41bf4..5a495ca4f3 100644
--- a/pcbnew/specctra_import.cpp
+++ b/pcbnew/specctra_import.cpp
@@ -224,7 +224,7 @@ static wxPoint mapPt( const POINT& aPoint, UNIT_RES* aResolution )
TRACK* SPECCTRA_DB::makeTRACK( PATH* aPath, int aPointIndex, int aNetcode ) throw( IO_ERROR )
{
- int layerNdx = findLayerName( aPath->layer_id );
+ LAYER_NUM layerNdx = findLayerName( aPath->layer_id );
if( layerNdx == -1 )
{
@@ -319,8 +319,8 @@ SEGVIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNet
}
else // VIA_MICROVIA or VIA_BLIND_BURIED
{
- int topLayerNdx = -1;
- int botLayerNdx = 7000;
+ LAYER_NUM topLayerNdx = UNDEFINED_LAYER;
+ LAYER_NUM botLayerNdx = 7000;
int viaDiam = -1;
for( int i=0; ishape;
- int layerNdx = findLayerName( circle->layer_id );
- if( layerNdx == -1 )
+ LAYER_NUM layerNdx = findLayerName( circle->layer_id );
+ if( layerNdx == UNDEFINED_LAYER )
{
wxString layerName = FROM_UTF8( circle->layer_id.c_str() );
ThrowIOError( _("Session file uses invalid layer id \"%s\""),
diff --git a/pcbnew/specctra_test.cpp b/pcbnew/specctra_test.cpp
index 713c9b15a0..c0b95f7d72 100644
--- a/pcbnew/specctra_test.cpp
+++ b/pcbnew/specctra_test.cpp
@@ -100,7 +100,7 @@ int BOARD::GetCopperLayerCount() const
}
// a dummy to satisfy link of specctra_test without pulling in BOARD stuff.
-wxString BOARD::GetLayerName( int aLayer ) const
+wxString BOARD::GetLayerName( LAYER_NUM aLayer ) const
{
return wxEmptyString;
}
diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp
index bf9f0c5789..58be1f5469 100644
--- a/pcbnew/swap_layers.cpp
+++ b/pcbnew/swap_layers.cpp
@@ -20,14 +20,14 @@
#define LAYER_NO_CHANGE NB_LAYERS
-static int New_Layer[NB_LAYERS];
-wxStaticText* layer_list[NB_LAYERS];
+static LAYER_NUM New_Layer[NB_PCB_LAYERS];
+wxStaticText* layer_list[NB_PCB_LAYERS];
enum swap_layer_id {
ID_WINEDA_SWAPLAYERFRAME = 1800,
ID_BUTTON_0,
- ID_TEXT_0 = ID_BUTTON_0 + NB_LAYERS
+ ID_TEXT_0 = ID_BUTTON_0 + NB_PCB_LAYERS
};
@@ -59,7 +59,7 @@ private:
BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog )
- EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_LAYERS - 1,
+ EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_PCB_LAYERS - 1,
wxEVT_COMMAND_BUTTON_CLICKED,
WinEDA_SwapLayerFrame::Sel_Layer )
EVT_BUTTON( wxID_OK, WinEDA_SwapLayerFrame::OnOkClick )
@@ -114,7 +114,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) :
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
- for( int ii = 0; ii < NB_LAYERS; ii++ )
+ for( LAYER_NUM ii = FIRST_LAYER; ii < NB_PCB_LAYERS; ++ii )
{
// Provide a vertical line to separate the two FlexGrid sizers
if( ii == 16 )
@@ -204,11 +204,11 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) :
*/
if( ii == 0 )
{
- text = new wxStaticText( this, item_ID, board->GetLayerName( 0 ),
+ text = new wxStaticText( this, item_ID, board->GetLayerName( FIRST_LAYER ),
wxDefaultPosition, wxDefaultSize, 0 );
goodSize = text->GetSize();
- for( int jj = 1; jj < NB_LAYERS; jj++ )
+ for( LAYER_NUM jj = LAYER_N_2; jj < NB_PCB_LAYERS; ++jj )
{
text->SetLabel( board->GetLayerName( jj ) );
@@ -238,7 +238,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) :
* FlexGrid sizer. (As it incorporates three columns, three spacers
* are thus required for each otherwise unused row.)
*/
- for( int ii = 3 * NB_LAYERS; ii < 96; ii++ )
+ for( int ii = 3 * NB_PCB_LAYERS; ii < 96; ii++ )
{
FlexColumnBoxSizer->Add( 5, h, 0, wxALIGN_CENTER_HORIZONTAL |
wxALIGN_CENTER_VERTICAL | wxLEFT |
@@ -275,23 +275,23 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) :
void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event )
{
- int ii, jj;
+ int ii;
ii = event.GetId();
- if( ii < ID_BUTTON_0 || ii >= ID_BUTTON_0 + NB_LAYERS )
+ if( ii < ID_BUTTON_0 || ii >= ID_BUTTON_0 + NB_PCB_LAYERS )
return;
ii = event.GetId() - ID_BUTTON_0;
- jj = New_Layer[ii];
+ LAYER_NUM jj = New_Layer[ii];
- if( (jj < 0) || (jj > NB_LAYERS) )
+ if( (jj < 0) || (jj > NB_PCB_LAYERS) )
jj = LAYER_NO_CHANGE; // (Defaults to "No Change".)
- jj = m_Parent->SelectLayer( jj, -1, -1, true );
+ jj = m_Parent->SelectLayer( jj, UNDEFINED_LAYER, UNDEFINED_LAYER, true );
- if( (jj < 0) || (jj > NB_LAYERS) )
+ if( (jj < FIRST_LAYER) || (jj > NB_PCB_LAYERS) )
return;
// No change if the selected layer matches the layer being edited.
@@ -350,7 +350,7 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event )
EDA_ITEM* PtStruct;
/* Init default values */
- for( ii = 0; ii < NB_LAYERS; ii++ )
+ for( ii = FIRST_LAYER; ii < NB_PCB_LAYERS; ii++ )
New_Layer[ii] = LAYER_NO_CHANGE;
WinEDA_SwapLayerFrame* frame = new WinEDA_SwapLayerFrame( this );
@@ -375,7 +375,7 @@ void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event )
if( Via->GetShape() == VIA_THROUGH )
continue;
- int top_layer, bottom_layer;
+ LAYER_NUM top_layer, bottom_layer;
Via->ReturnLayerPair( &top_layer, &bottom_layer );
diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp
index f8a5a6592f..fd48f024ee 100644
--- a/pcbnew/zones_by_polygon.cpp
+++ b/pcbnew/zones_by_polygon.cpp
@@ -372,7 +372,7 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone )
return;
}
- int layer = aZone->GetLayer();
+ LAYER_NUM layer = aZone->GetLayer();
if( DC )
{
@@ -620,7 +620,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
}
// Show the Net for zones on copper layers
- if( zoneInfo.m_CurrentZone_Layer < FIRST_NO_COPPER_LAYER &&
+ if( zoneInfo.m_CurrentZone_Layer < FIRST_NON_COPPER_LAYER &&
! zoneInfo.GetIsKeepout() )
{
if( s_CurrentZone )
@@ -739,7 +739,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
m_canvas->SetMouseCapture( NULL, NULL );
// Undraw old drawings, because they can have important changes
- int layer = zone->GetLayer();
+ LAYER_NUM layer = zone->GetLayer();
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
@@ -851,7 +851,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
// note the net name and the layer can be changed, so we must save all zones
s_AuxiliaryList.ClearListAndDeleteItems();
s_PickedList.ClearListAndDeleteItems();
- SaveCopyOfZones(s_PickedList, GetBoard(), -1, -1 );
+ SaveCopyOfZones(s_PickedList, GetBoard(), -1, UNDEFINED_LAYER );
if( aZone->GetIsKeepout() )
{
@@ -859,7 +859,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
zoneInfo << *aZone;
edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
}
- else if( aZone->GetLayer() < FIRST_NO_COPPER_LAYER )
+ else if( aZone->GetLayer() < FIRST_NON_COPPER_LAYER )
{
// edit a zone on a copper layer
@@ -910,7 +910,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
// Redraw the real new zone outlines
- GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, -1 );
+ GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, UNDEFINED_LAYER );
UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
diff --git a/pcbnew/zones_functions_for_undo_redo.cpp b/pcbnew/zones_functions_for_undo_redo.cpp
index e113f7a61a..922e955c41 100644
--- a/pcbnew/zones_functions_for_undo_redo.cpp
+++ b/pcbnew/zones_functions_for_undo_redo.cpp
@@ -134,7 +134,7 @@ bool ZONE_CONTAINER::IsSame( const ZONE_CONTAINER& aZoneToCompare )
* @param aLayer = the layer of zones. if aLayer < 0, all layers are used
* @return the count of saved copies
*/
-int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, int aLayer )
+int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, LAYER_NUM aLayer )
{
int copyCount = 0;
diff --git a/pcbnew/zones_functions_for_undo_redo.h b/pcbnew/zones_functions_for_undo_redo.h
index 7ef0ae2a9d..a5260a3fa8 100644
--- a/pcbnew/zones_functions_for_undo_redo.h
+++ b/pcbnew/zones_functions_for_undo_redo.h
@@ -56,7 +56,7 @@
* @param aLayer = the layer of zones. if aLayer < 0, all layers are used
* @return the count of saved copies
*/
-int SaveCopyOfZones(PICKED_ITEMS_LIST & aPickList, BOARD* aPcb, int aNetCode, int aLayer );
+int SaveCopyOfZones(PICKED_ITEMS_LIST & aPickList, BOARD* aPcb, int aNetCode, LAYER_NUM aLayer );
/**
diff --git a/pcbnew/zones_non_copper_type_functions.cpp b/pcbnew/zones_non_copper_type_functions.cpp
index 5305c4e137..f6b2594bff 100644
--- a/pcbnew/zones_non_copper_type_functions.cpp
+++ b/pcbnew/zones_non_copper_type_functions.cpp
@@ -98,9 +98,11 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::Init()
break;
}
- for( int layer_number = FIRST_NO_COPPER_LAYER, ii = 0;
- layer_number <= LAST_NO_COPPER_LAYER;
- layer_number++, ii++ )
+ int ii;
+ LAYER_NUM layer_number;
+ for( layer_number = FIRST_NON_COPPER_LAYER, ii = 0;
+ layer_number <= LAST_NON_COPPER_LAYER;
+ ++layer_number, ++ii )
{
wxString msg;
@@ -171,7 +173,7 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::OnOkClick( wxCommandEvent& event )
return;
}
- m_settings.m_CurrentZone_Layer = ii + FIRST_NO_COPPER_LAYER;
+ m_settings.m_CurrentZone_Layer = FIRST_NON_COPPER_LAYER + ii;
*m_ptr = m_settings;
diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp
index 718661e8a2..c476d79bf5 100644
--- a/pcbnew/zones_test_and_combine_areas.cpp
+++ b/pcbnew/zones_test_and_combine_areas.cpp
@@ -53,7 +53,7 @@ bool BOARD::OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList,
bool modified = NormalizeAreaPolygon( aModifiedZonesList, modified_area );
// now see if we need to clip against other areas
- int layer = modified_area->GetLayer();
+ LAYER_NUM layer = modified_area->GetLayer();
bool bCheckAllAreas = TestAreaIntersections( modified_area );
if( bCheckAllAreas )
@@ -62,7 +62,7 @@ bool BOARD::OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList,
CombineAllAreasInNet( aModifiedZonesList, modified_area->GetNet(), true );
}
- if( layer >= FIRST_NO_COPPER_LAYER ) // Refill non copper zones on this layer
+ if( layer >= FIRST_NON_COPPER_LAYER ) // Refill non copper zones on this layer
{
for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
if( m_ZoneDescriptorList[ia]->GetLayer() == layer )
diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp
index 1475f4c755..5ed3951842 100644
--- a/polygon/PolyLine.cpp
+++ b/polygon/PolyLine.cpp
@@ -21,7 +21,7 @@ CPolyLine::CPolyLine()
{
m_hatchStyle = NO_HATCH;
m_hatchPitch = 0;
- m_layer = 0;
+ m_layer = NO_LAYER;
m_utility = 0;
}
@@ -207,7 +207,7 @@ void CPolyLine::ImportSettings( const CPolyLine * aPoly )
/* initialize a contour
* set layer, hatch style, and starting point
*/
-void CPolyLine::Start( int layer, int x, int y, int hatch )
+void CPolyLine::Start( LAYER_NUM layer, int x, int y, int hatch )
{
m_layer = layer;
SetHatchStyle( (enum HATCH_STYLE) hatch );
@@ -795,7 +795,7 @@ void CPolyLine::Hatch()
double hatch_line_len = m_hatchPitch;
// To have a better look, give a slope depending on the layer
- int layer = GetLayer();
+ LAYER_NUM layer = GetLayer();
int slope_flag = (layer & 1) ? 1 : -1; // 1 or -1
double slope = 0.707106 * slope_flag; // 45 degrees slope
int max_a, min_a;
diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h
index 39368bf003..15f2cb49d9 100644
--- a/polygon/PolyLine.h
+++ b/polygon/PolyLine.h
@@ -98,7 +98,7 @@ public:
/* initialize a contour
* set layer, hatch style, and starting point
*/
- void Start( int layer, int x, int y, int hatch );
+ void Start( LAYER_NUM layer, int x, int y, int hatch );
void AppendCorner( int x, int y );
void InsertCorner( int ic, int x, int y );
@@ -175,8 +175,8 @@ public:
void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
// access functions
- void SetLayer( int aLayer ) { m_layer = aLayer; }
- int GetLayer() const { return m_layer; }
+ void SetLayer( LAYER_NUM aLayer ) { m_layer = aLayer; }
+ LAYER_NUM GetLayer() const { return m_layer; }
int GetNumCorners();
int GetNumSides();
int GetClosed();
@@ -254,7 +254,7 @@ public:
int Distance( wxPoint aStart, wxPoint aEnd, int aWidth );
private:
- int m_layer; // layer to draw on
+ LAYER_NUM m_layer; // layer to draw on
enum HATCH_STYLE m_hatchStyle; // hatch style, see enum above
int m_hatchPitch; // for DIAGONAL_EDGE hatched outlines, basic distance between 2 hatch lines
// and the len of eacvh segment