1) Add 32 Cu Layers and provisions for additional future layers.

2) Change from legacy Cu stack to counting down from top=(F_Cu or 0).
   The old Cu stack required knowing the count of Cu layers to make
   sense of the layer number when converting to many exported file types.
   The new Cu stack is more commonly used, although ours still gives
   B_Cu a fixed number.
3) Introduce class LSET and enum LAYER_ID.  LAYER_NUM is only advisory and
   can safely be replaced with int.
4) Change *.kicad_pcb file format version to 4 from 3.
5) Change fixed names Inner1_Cu-Inner14_Cu to In1_Cu-In30_Cu and their
   meanings are typically flipped.
6) Moved the #define LAYER_N_* stuff into legacy_plugin.cpp where they
   can die a quiet death, and switch to enum LAYER_ID symbols throughout.
7) Removed the LEGACY_PLUGIN::Save() and FootprintSave() functions.
   You will need to convert to the format immediately, *.kicad_pcb and
   *.kicad_mod (=pretty) since legacy format was never going to know
   about 32 Cu layers and additional technical layers and the reversed Cu
   stack.
This commit is contained in:
Dick Hollenbeck 2014-06-30 01:59:52 -05:00
commit d6d786eed8
228 changed files with 14706 additions and 6455 deletions

View File

@ -55,11 +55,11 @@ extern void CheckGLError();
/* Helper function
* returns true if aLayer should be displayed, false otherwise
*/
static bool Is3DLayerEnabled( LAYER_NUM aLayer );
static bool Is3DLayerEnabled( LAYER_ID 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
* B_Cu , B_Adhes, B_Paste ), B_SilkS
* used to calculate the Z orientation parameter for glNormal3f
*/
static GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
@ -205,18 +205,18 @@ static inline void SetGLTechLayersColor( LAYER_NUM aLayer )
{
switch( aLayer )
{
case SOLDERPASTE_N_BACK:
case SOLDERPASTE_N_FRONT:
case B_Paste:
case F_Paste:
SetGLColor( DARKGRAY, 0.7 );
break;
case SILKSCREEN_N_BACK:
case SILKSCREEN_N_FRONT:
case B_SilkS:
case F_SilkS:
SetGLColor( LIGHTGRAY, 0.9 );
break;
case SOLDERMASK_N_BACK:
case SOLDERMASK_N_FRONT:
case B_Mask:
case F_Mask:
SetGLEpoxyColor( 0.7 );
break;
@ -278,12 +278,21 @@ void EDA_3D_CANVAS::BuildBoard3DView()
bool throughHolesListBuilt = false; // flag to build the through hole polygon list only once
bool hightQualityMode = false;
for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER;
++layer )
LSET cu_set = LSET::AllCuMask( g_Parm_3D_Visu.m_CopperLayersCount );
#if 1
LAYER_ID cu_seq[MAX_CU_LAYERS]; // preferred sequence, could have called CuStack()
// but I assume that's backwards
for( unsigned i=0; i<DIM(cu_seq); ++i )
cu_seq[i] = ToLAYER_ID( B_Cu - i );
for( LSEQ cu = cu_set.Seq( cu_seq, DIM(cu_seq) ); cu; ++cu )
#else
for( LSEQ cu = cu_set.CuStack(); cu; ++cu )
#endif
{
if( layer != LAST_COPPER_LAYER
&& layer >= g_Parm_3D_Visu.m_CopperLayersCount )
continue;
LAYER_ID layer = *cu;
// Skip non enabled layers in normal mode,
// and internal layers in realistic mode
@ -295,7 +304,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
currLayerHoles.RemoveAllContours();
// Draw tracks:
for( TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
for( TRACK* track = pcb->m_Track; track; track = track->Next() )
{
if( !track->IsOnLayer( layer ) )
continue;
@ -325,7 +334,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
}
// draw pads
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys,
@ -345,7 +354,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
{
D_PAD* pad = module->Pads();
for( ; pad != NULL; pad = pad->Next() )
for( ; pad; pad = pad->Next() )
pad->BuildPadDrillShapePolygon( allLayerHoles, 0,
segcountLowQuality );
}
@ -439,7 +448,7 @@ void EDA_3D_CANVAS::BuildBoard3DView()
}
// Draw vias holes (vertical cylinders)
for( const TRACK* track = pcb->m_Track; track != NULL; track = track->Next() )
for( const TRACK* track = pcb->m_Track; track; track = track->Next() )
{
const VIA *via = dynamic_cast<const VIA*>(track);
@ -448,9 +457,9 @@ void EDA_3D_CANVAS::BuildBoard3DView()
}
// Draw pads holes (vertical cylinders)
for( const MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
for( const MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
Draw3DPadHole( pad );
}
@ -459,12 +468,14 @@ void EDA_3D_CANVAS::BuildBoard3DView()
( realistic_mode || g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) ) )
{
int copper_thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
// a small offset between substrate and external copper layer to avoid artifacts
// when drawing copper items on board
int epsilon = Millimeter2iu( 0.01 );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
int board_thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
- g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu );
int board_thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( F_Cu )
- g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu );
// items on copper layers and having a thickness = copper_thickness
// are drawn from zpos - copper_thickness/2 to zpos + copper_thickness
// therefore substrate position is copper_thickness/2 to
@ -476,11 +487,11 @@ void EDA_3D_CANVAS::BuildBoard3DView()
SetGLEpoxyColor();
else
{
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( EDGE_N );
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( Edge_Cuts );
SetGLColor( color, 0.7 );
}
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( LAYER_N_FRONT ) );
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( F_Cu ) );
KI_POLYGON_SET currLayerPolyset;
KI_POLYGON_SET polysetHoles;
@ -515,6 +526,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
// to reduce time calculations
// for holes and items which do not need
// a fine representation
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality * 2) );
CPOLYGONS_LIST bufferPolys;
@ -537,7 +549,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
// Add via holes
for( VIA* via = GetFirstVia( pcb->m_Track ); via != NULL;
for( VIA* via = GetFirstVia( pcb->m_Track ); via;
via = GetFirstVia( via->Next() ) )
{
VIATYPE_T viatype = via->GetViaType();
@ -551,12 +563,12 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
}
// draw pads holes
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
// Add pad hole, if any
D_PAD* pad = module->Pads();
for( ; pad != NULL; pad = pad->Next() )
for( ; pad; pad = pad->Next() )
pad->BuildPadDrillShapePolygon( allLayerHoles, 0,
segcountLowQuality );
}
@ -566,9 +578,21 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
KI_POLYGON_SET brdpolysetHoles;
allLayerHoles.ExportTo( brdpolysetHoles );
for( LAYER_NUM layer = FIRST_NON_COPPER_LAYER; layer <= LAST_NON_COPPER_LAYER;
++layer )
static const LAYER_ID sequence[] = {
B_Adhes,
F_Adhes,
B_Paste,
F_Paste,
B_SilkS,
F_SilkS,
B_Mask,
F_Mask,
};
for( LSEQ seq = pcb->GetEnabledLayers().Seq( sequence, DIM( sequence ) ); seq; ++seq )
{
LAYER_ID layer = *seq;
// Skip user layers, which are not drawn here
if( IsUserLayer( layer) )
continue;
@ -576,7 +600,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
if( !Is3DLayerEnabled( layer ) )
continue;
if( layer == EDGE_N && g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) )
if( layer == Edge_Cuts && g_Parm_3D_Visu.GetFlag( FL_SHOW_BOARD_BODY ) )
continue;
bufferPolys.RemoveAllContours();
@ -603,14 +627,14 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
}
}
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
if( layer == SILKSCREEN_N_FRONT || layer == SILKSCREEN_N_BACK )
if( layer == F_SilkS || layer == B_SilkS )
{
D_PAD* pad = module->Pads();
int linewidth = g_DrawDefaultLineThickness;
for( ; pad != NULL; pad = pad->Next() )
for( ; pad; pad = pad->Next() )
{
if( !pad->IsOnLayer( layer ) )
continue;
@ -651,7 +675,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
// Solder mask layers are "negative" layers.
// Shapes should be removed from the full board area.
if( layer == SOLDERMASK_N_BACK || layer == SOLDERMASK_N_FRONT )
if( layer == B_Mask || layer == F_Mask )
{
bufferPcbOutlines.ExportTo( currLayerPolyset );
bufferPolys.Append( allLayerHoles );
@ -659,8 +683,8 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
currLayerPolyset -= polyset;
}
// Remove holes from Solder paste layers and siklscreen
else if( layer == SOLDERPASTE_N_BACK || layer == SOLDERPASTE_N_FRONT
|| layer == SILKSCREEN_N_BACK || layer == SILKSCREEN_N_FRONT )
else if( layer == B_Paste || layer == F_Paste
|| layer == B_SilkS || layer == F_SilkS )
{
bufferPolys.ExportTo( currLayerPolyset );
currLayerPolyset -= brdpolysetHoles;
@ -674,11 +698,11 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
if( layer == EDGE_N )
if( layer == Edge_Cuts )
{
thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT )
- g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK )
thickness = g_Parm_3D_Visu.GetLayerZcoordBIU( F_Cu )
- g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu );
zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu )
+ (thickness / 2);
}
else
@ -703,6 +727,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
}
}
/**
* Function BuildBoard3DAuxLayers
* Called by CreateDrawGL_List()
@ -713,13 +738,25 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
{
const int segcountforcircle = 16;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) );
BOARD* pcb = GetBoard();
BOARD* pcb = GetBoard();
CPOLYGONS_LIST bufferPolys;
bufferPolys.reserve( 5000 ); // Reserve for items not on board
for( LAYER_NUM layer = FIRST_USER_LAYER; layer <= LAST_USER_LAYER;
++layer )
static const LAYER_ID sequence[] = {
Dwgs_User,
Cmts_User,
Eco1_User,
Eco2_User,
Edge_Cuts,
Margin
};
for( LSEQ aux( sequence, sequence+DIM(sequence) ); aux; ++aux )
{
LAYER_ID layer = *aux;
if( !Is3DLayerEnabled( layer ) )
continue;
@ -747,7 +784,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
}
}
for( MODULE* module = pcb->m_Modules; module != NULL; module = module->Next() )
for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys,
@ -1067,7 +1104,7 @@ void EDA_3D_CANVAS::Draw3DGrid( double aGriSizeMM )
void EDA_3D_CANVAS::Draw3DViaHole( const VIA* aVia )
{
LAYER_NUM top_layer, bottom_layer;
LAYER_ID top_layer, bottom_layer;
int inner_radius = aVia->GetDrillValue() / 2;
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
@ -1115,7 +1152,7 @@ void MODULE::ReadAndInsert3DComponentShape( EDA_3D_CANVAS* glcanvas,
glRotatef( 180.0, 0.0, 0.0, 1.0 );
}
for( ; shape3D != NULL; shape3D = shape3D->Next() )
for( ; shape3D; shape3D = shape3D->Next() )
{
shape3D->SetLoadNonTransparentObjects( aAllowNonTransparentObjects );
shape3D->SetLoadTransparentObjects( aAllowTransparentObjects );
@ -1141,15 +1178,15 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
// Store here the points to approximate hole by segments
CPOLYGONS_LIST holecornersBuffer;
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_FRONT ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK );
int height = g_Parm_3D_Visu.GetLayerZcoordBIU( F_Cu ) -
g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu );
if( g_Parm_3D_Visu.IsRealisticMode() )
SetGLCopperColor();
else
SetGLColor( DARKGRAY );
int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU( LAYER_N_BACK ) + thickness / 2;
int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU( B_Cu ) + thickness / 2;
int holeHeight = height - thickness;
if( drillsize.x == drillsize.y ) // usual round hole
@ -1187,7 +1224,7 @@ void EDA_3D_CANVAS::Draw3DPadHole( const D_PAD* aPad )
}
bool Is3DLayerEnabled( LAYER_NUM aLayer )
static bool Is3DLayerEnabled( LAYER_ID aLayer )
{
DISPLAY3D_FLG flg;
bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
@ -1196,44 +1233,44 @@ bool Is3DLayerEnabled( LAYER_NUM aLayer )
// check the flags
switch( aLayer )
{
case ADHESIVE_N_BACK:
case ADHESIVE_N_FRONT:
case B_Adhes:
case F_Adhes:
flg = FL_ADHESIVE;
break;
case SOLDERPASTE_N_BACK:
case SOLDERPASTE_N_FRONT:
case B_Paste:
case F_Paste:
flg = FL_SOLDERPASTE;
break;
case SILKSCREEN_N_BACK:
case SILKSCREEN_N_FRONT:
case B_SilkS:
case F_SilkS:
flg = FL_SILKSCREEN;
break;
case SOLDERMASK_N_BACK:
case SOLDERMASK_N_FRONT:
case B_Mask:
case F_Mask:
flg = FL_SOLDERMASK;
break;
case DRAW_N:
case COMMENT_N:
case Dwgs_User:
case Cmts_User:
if( realistic_mode )
return false;
flg = FL_COMMENTS;
break;
case ECO1_N:
case ECO2_N:
case Eco1_User:
case Eco2_User:
if( realistic_mode )
return false;
flg = FL_ECO;
break;
case LAYER_N_BACK:
case LAYER_N_FRONT:
case B_Cu:
case F_Cu:
return g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( aLayer )
|| realistic_mode;
break;
@ -1256,11 +1293,11 @@ GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer )
{
double nZ = 1.0;
if( ( aLayer == LAYER_N_BACK )
|| ( aLayer == ADHESIVE_N_BACK )
|| ( aLayer == SOLDERPASTE_N_BACK )
|| ( aLayer == SILKSCREEN_N_BACK )
|| ( aLayer == SOLDERMASK_N_BACK ) )
if( ( aLayer == B_Cu )
|| ( aLayer == B_Adhes )
|| ( aLayer == B_Paste )
|| ( aLayer == B_SilkS )
|| ( aLayer == B_Mask ) )
nZ = -1.0;
return nZ;

View File

@ -132,53 +132,52 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
// Fill remaining unused copper layers and front layer zpos
// with m_EpoxyThickness
// Solder mask and Solder paste have the same Z position
for( ; layer <= LAST_COPPER_LAYER; layer++ )
for( ; layer < MAX_CU_LAYERS; layer++ )
{
m_LayerZcoord[layer] = m_EpoxyThickness;
}
// calculate z position for each non copper layer
for( int layer_id = FIRST_NON_COPPER_LAYER; layer_id < NB_PCB_LAYERS; layer_id++ )
for( int layer_id = MAX_CU_LAYERS; layer_id < LAYER_ID_COUNT; layer_id++ )
{
double zpos;
switch( layer_id )
{
case ADHESIVE_N_BACK:
case B_Adhes:
zpos = zpos_copper_back - 3 * zpos_offset;
break;
case ADHESIVE_N_FRONT:
case F_Adhes:
zpos = zpos_copper_front + 3 * zpos_offset;
break;
case SOLDERPASTE_N_BACK:
case B_Paste:
zpos = zpos_copper_back - 1 * zpos_offset;
break;
case SOLDERPASTE_N_FRONT:
case F_Paste:
zpos = zpos_copper_front + 1 * zpos_offset;
break;
case SOLDERMASK_N_BACK:
case B_Mask:
zpos = zpos_copper_back - 1 * zpos_offset;
break;
case SOLDERMASK_N_FRONT:
case F_Mask:
zpos = zpos_copper_front + 1 * zpos_offset;
break;
case SILKSCREEN_N_BACK:
case B_SilkS:
zpos = zpos_copper_back - 2 * zpos_offset;
break;
case SILKSCREEN_N_FRONT:
case F_SilkS:
zpos = zpos_copper_front + 2 * zpos_offset;
break;
default:
zpos = zpos_copper_front +
(layer_id - FIRST_NON_COPPER_LAYER + 4) * zpos_offset;
zpos = zpos_copper_front + (layer_id - MAX_CU_LAYERS + 4) * zpos_offset;
break;
}
@ -196,8 +195,8 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard )
double INFO3D_VISU::GetModulesZcoord3DIU( bool aIsFlipped )
{
if( aIsFlipped )
return m_LayerZcoord[LAYER_N_BACK] - ( m_CopperThickness / 2 );
return m_LayerZcoord[B_Cu] - ( m_CopperThickness / 2 );
else
return m_LayerZcoord[LAYER_N_FRONT] + ( m_CopperThickness / 2 );
return m_LayerZcoord[F_Cu] + ( m_CopperThickness / 2 );
}

View File

@ -95,7 +95,7 @@ public:
double m_CurrentZpos; // temporary storage of current value of Z position,
// used in some calculation
private:
double m_LayerZcoord[NB_LAYERS]; // Z position of each layer (normalized)
double m_LayerZcoord[LAYER_ID_COUNT]; // 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
@ -188,11 +188,12 @@ public: INFO3D_VISU();
*
* Note: if m_drawFlags[FL_USE_COPPER_THICKNESS] is not set, returns 0
*/
int GetLayerObjectThicknessBIU( int aLayerId) const
int GetLayerObjectThicknessBIU( int aLayerId ) const
{
return aLayerId >= FIRST_NON_COPPER_LAYER ?
GetNonCopperLayerThicknessBIU() :
GetCopperThicknessBIU();
return IsCopperLayer( aLayerId ) ?
GetCopperThicknessBIU() :
GetNonCopperLayerThicknessBIU()
;
}
bool IsRealisticMode() { return GetFlag( FL_USE_REALISTIC_MODE ); }

View File

@ -60,6 +60,8 @@ PCBNew
*) Paste (module ...) from clipboard into module editor.
Dick's Final TODO List:
======================
*) Get licensing cleaned up.
@ -75,3 +77,5 @@ Dick's Final TODO List:
* Clear all/some? retained strings on project change.
* Clear the FP_LIB_TABLE when the last KIWAY_PLAYER using it is closed.
Fix export gencad

View File

@ -355,7 +355,7 @@ void BITMAPCONV_INFO::OuputOnePolygon( KPolygon & aPolygon )
case PCBNEW_LEGACY_EMP:
{
LAYER_NUM layer = SILKSCREEN_N_FRONT;
LAYER_NUM layer = F_SilkS;
int width = 1;
fprintf( m_Outfile, "DP %d %d %d %d %d %d %d\n",
0, 0, 0, 0,

View File

@ -250,6 +250,7 @@ set( PCB_COMMON_SRCS
eda_text.cpp
class_page_info.cpp
pcbcommon.cpp
lset.cpp
footprint_info.cpp
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp

View File

@ -15,8 +15,7 @@
/* Initial colors values: optimized for Pcbnew, but are also Ok for Eeschema
* these values are superseded by config reading
*/
static const EDA_COLOR_T default_layer_color[LAYERSCOLORSBUFFERSIZE] =
{
static const EDA_COLOR_T default_layer_color[] = {
GREEN, BLUE, LIGHTGRAY, BROWN,
RED, MAGENTA, LIGHTGRAY, MAGENTA,
DARKGRAY, BLUE, GREEN, CYAN,
@ -34,8 +33,8 @@ static const EDA_COLOR_T default_layer_color[LAYERSCOLORSBUFFERSIZE] =
DARKGRAY
};
static const EDA_COLOR_T default_items_color[LAYERSCOLORSBUFFERSIZE] =
{
static const EDA_COLOR_T default_items_color[] = {
LIGHTGRAY, // unused
CYAN, // VIA_MICROVIA_VISIBLE
BROWN, // VIA_BBLIND_VISIBLE
@ -56,13 +55,24 @@ static const EDA_COLOR_T default_items_color[LAYERSCOLORSBUFFERSIZE] =
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY
};
COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
{
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
m_LayersColors[ii] = default_layer_color[ii];
for( unsigned src = 0, dst = 0; dst < DIM(m_LayersColors); ++dst )
{
m_LayersColors[dst] = default_layer_color[src++];
for( unsigned ii = 0; ii < DIM(m_ItemsColors); ii++ )
m_ItemsColors[ii] = default_items_color[ii];
if( src >= DIM( default_layer_color ) )
src = 0; // wrap the source.
}
for( unsigned src = 0, dst = 0; dst < DIM(m_ItemsColors); ++dst )
{
m_ItemsColors[dst] = default_items_color[src++];
if( src >= DIM( default_items_color ) )
src = 0;
}
}

View File

@ -13,19 +13,11 @@
LAYER_SELECTOR::LAYER_SELECTOR()
{
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
}
bool LAYER_SELECTOR::SetLayersOrdered( bool value )
{
m_layerorder = value;
return m_layerorder;
}
bool LAYER_SELECTOR::SetLayersHotkeys( bool value )
{
m_layerhotkeys = value;
@ -120,12 +112,15 @@ int LAYER_BOX_SELECTOR::SetLayerSelection( LAYER_NUM layer )
return -1;
}
void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
{
LAYER_NUM elements = GetCount();
for( LAYER_NUM i = FIRST_LAYER; i < elements; ++i )
int elements = GetCount();
for( LAYER_NUM i = 0; i < elements; ++i )
{
wxBitmap layerbmp( 14, 14 );
SetBitmapLayer( layerbmp, i );
}
}

View File

@ -420,14 +420,14 @@ void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
switch( aFill )
{
case NO_FILL:
fprintf( outputFile, "<polyline fill=\"none;\"\n" );
break;
case NO_FILL:
fprintf( outputFile, "<polyline fill=\"none;\"\n" );
break;
case FILLED_WITH_BG_BODYCOLOR:
case FILLED_SHAPE:
fprintf( outputFile, "<polyline style=\"fill-rule:evenodd;\"\n" );
break;
case FILLED_WITH_BG_BODYCOLOR:
case FILLED_SHAPE:
fprintf( outputFile, "<polyline style=\"fill-rule:evenodd;\"\n" );
break;
}
DPOINT pos = userToDeviceCoordinates( aCornerList[0] );

View File

@ -47,7 +47,7 @@ void wxConfigSaveParams( wxConfigBase* aCfg,
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( param.m_Group )
if( !!param.m_Group )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
@ -57,7 +57,7 @@ void wxConfigSaveParams( wxConfigBase* aCfg,
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
if( !!param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
@ -75,7 +75,7 @@ void wxConfigLoadParams( wxConfigBase* aCfg,
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{
if( param.m_Group )
if( !!param.m_Group )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
@ -99,7 +99,7 @@ void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param.m_Ident )
if( !!param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
@ -137,7 +137,7 @@ void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double
}
PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
PARAM_CFG_BASE::PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type,
const wxChar* group )
{
m_Ident = ident;
@ -147,7 +147,7 @@ PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
}
PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam,
PARAM_CFG_INT::PARAM_CFG_INT( const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_INT, group )
@ -159,7 +159,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam,
}
PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_INT, group )
@ -195,7 +195,7 @@ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( const wxChar* ident, int* ptparam,
PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group, double aBiu2cfgunit ) :
PARAM_CFG_INT( ident, ptparam, default_val, min, max, group )
@ -206,7 +206,7 @@ PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( const wxChar* ident, int* pt
PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE( bool Insetup,
const wxChar* ident, int* ptparam,
const wxString& ident, int* ptparam,
int default_val, int min, int max,
const wxChar* group, double aBiu2cfgunit ) :
PARAM_CFG_INT( Insetup, ident, ptparam, default_val, min, max, group )
@ -246,7 +246,7 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptparam,
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
@ -257,7 +257,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptpara
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
const wxChar* ident,
const wxString& ident,
EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val,
const wxChar* group ) :
@ -291,7 +291,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
double default_val, double min, double max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
@ -304,7 +304,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
const wxChar* ident,
const wxString& ident,
double* ptparam,
double default_val,
double min,
@ -348,7 +348,7 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
int default_val, const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
{
@ -358,7 +358,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
const wxChar* ident,
const wxString& ident,
bool* ptparam,
int default_val,
const wxChar* group ) :
@ -390,7 +390,7 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxString& ident,
wxString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
@ -399,7 +399,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
}
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxString& ident,
wxString* ptparam,
const wxString& default_val,
const wxChar* group ) :
@ -407,7 +407,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
{
m_Pt_param = ptparam;
m_Setup = Insetup;
m_default = default_val;
m_default = default_val;
}
@ -429,7 +429,7 @@ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) const
}
PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxString& ident,
wxString* ptparam,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_FILENAME, group )

View File

@ -109,7 +109,8 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
dc.SetClippingRegion( DrawArea );
}
aFrame->PrintPage( &dc, FULL_LAYERS, false );
const LSET allLayersMask = LSET().set();
aFrame->PrintPage( &dc, allLayersMask, false );
screen->m_IsPrinting = false;
aFrame->GetCanvas()->SetClipBox( tmp );
wxMetafile* mf = dc.Close();

View File

@ -331,7 +331,7 @@ void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
}
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData )
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
{
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
}

654
common/lset.cpp Normal file
View File

@ -0,0 +1,654 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2014 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <assert.h>
#include <layers_id_colors_and_visibility.h>
#include <class_board.h>
LSET::LSET( const LAYER_ID* aArray, unsigned aCount ) :
BASE_SET()
{
for( unsigned i=0; i<aCount; ++i )
set( aArray[i] );
}
LSET::LSET( unsigned aIdCount, LAYER_ID aFirst, ... ) :
BASE_SET()
{
// The constructor, without the mandatory aFirst argument, could have been confused
// by the compiler with the LSET( LAYER_ID ). With aFirst, that ambiguity is not
// present. Therefore aIdCount must always be >=1.
wxASSERT_MSG( aIdCount > 0, wxT( "aIdCount must be >= 1" ) );
set( aFirst );
if( --aIdCount )
{
va_list ap;
va_start( ap, aFirst );
for( unsigned i=0; i<aIdCount; ++i )
{
LAYER_ID id = (LAYER_ID) va_arg( ap, int );
// printf( "%s: id:%d LAYER_ID_COUNT:%d\n", __func__, id, LAYER_ID_COUNT );
assert( unsigned( id ) < LAYER_ID_COUNT );
set( id );
}
va_end( ap );
}
}
const wxChar* LSET::Name( LAYER_ID aLayerId )
{
const wxChar* txt;
// using a switch to explicitly show the mapping more clearly
switch( aLayerId )
{
case F_Cu: txt = wxT( "F.Cu" ); break;
case In1_Cu: txt = wxT( "In1.Cu" ); break;
case In2_Cu: txt = wxT( "In2.Cu" ); break;
case In3_Cu: txt = wxT( "In3.Cu" ); break;
case In4_Cu: txt = wxT( "In4.Cu" ); break;
case In5_Cu: txt = wxT( "In5.Cu" ); break;
case In6_Cu: txt = wxT( "In6.Cu" ); break;
case In7_Cu: txt = wxT( "In7.Cu" ); break;
case In8_Cu: txt = wxT( "In8.Cu" ); break;
case In9_Cu: txt = wxT( "In9.Cu" ); break;
case In10_Cu: txt = wxT( "In10.Cu" ); break;
case In11_Cu: txt = wxT( "In11.Cu" ); break;
case In12_Cu: txt = wxT( "In12.Cu" ); break;
case In13_Cu: txt = wxT( "In13.Cu" ); break;
case In14_Cu: txt = wxT( "In14.Cu" ); break;
case In15_Cu: txt = wxT( "In15.Cu" ); break;
case In16_Cu: txt = wxT( "In16.Cu" ); break;
case In17_Cu: txt = wxT( "In17.Cu" ); break;
case In18_Cu: txt = wxT( "In18.Cu" ); break;
case In19_Cu: txt = wxT( "In19.Cu" ); break;
case In20_Cu: txt = wxT( "In20.Cu" ); break;
case In21_Cu: txt = wxT( "In21.Cu" ); break;
case In22_Cu: txt = wxT( "In22.Cu" ); break;
case In23_Cu: txt = wxT( "In23.Cu" ); break;
case In24_Cu: txt = wxT( "In24.Cu" ); break;
case In25_Cu: txt = wxT( "In25.Cu" ); break;
case In26_Cu: txt = wxT( "In26.Cu" ); break;
case In27_Cu: txt = wxT( "In27.Cu" ); break;
case In28_Cu: txt = wxT( "In28.Cu" ); break;
case In29_Cu: txt = wxT( "In29.Cu" ); break;
case In30_Cu: txt = wxT( "In30.Cu" ); break;
case B_Cu: txt = wxT( "B.Cu" ); break;
// Technicals
case B_Adhes: txt = wxT( "B.Adhes" ); break;
case F_Adhes: txt = wxT( "F.Adhes" ); break;
case B_Paste: txt = wxT( "B.Paste" ); break;
case F_Paste: txt = wxT( "F.Paste" ); break;
case B_SilkS: txt = wxT( "B.SilkS" ); break;
case F_SilkS: txt = wxT( "F.SilkS" ); break;
case B_Mask: txt = wxT( "B.Mask" ); break;
case F_Mask: txt = wxT( "F.Mask" ); break;
// Users
case Dwgs_User: txt = wxT( "Dwgs.User" ); break;
case Cmts_User: txt = wxT( "Cmts.User" ); break;
case Eco1_User: txt = wxT( "Eco1.User" ); break;
case Eco2_User: txt = wxT( "Eco2.User" ); break;
case Edge_Cuts: txt = wxT( "Edge.Cuts" ); break;
case Margin: txt = wxT( "Margin" ); break;
// Footprint
case F_CrtYd: txt = wxT( "F_CrtYd" ); break;
case B_CrtYd: txt = wxT( "B_CrtYd" ); break;
case F_Fab: txt = wxT( "F_Fab" ); break;
case B_Fab: txt = wxT( "B_Fab" ); break;
default:
wxASSERT_MSG( 0, wxT( "aLayerId out of range" ) );
txt = wxT( "BAD INDEX!" ); break;
}
return txt;
}
LSEQ LSET::CuStack() const
{
// desired sequence
static const LAYER_ID sequence[] = {
F_Cu,
In1_Cu,
In2_Cu,
In3_Cu,
In4_Cu,
In5_Cu,
In6_Cu,
In7_Cu,
In8_Cu,
In9_Cu,
In10_Cu,
In11_Cu,
In12_Cu,
In13_Cu,
In14_Cu,
In15_Cu,
In16_Cu,
In17_Cu,
In18_Cu,
In19_Cu,
In20_Cu,
In21_Cu,
In22_Cu,
In23_Cu,
In24_Cu,
In25_Cu,
In26_Cu,
In27_Cu,
In28_Cu,
In29_Cu,
In30_Cu,
B_Cu, // 31
};
return Seq( sequence, DIM( sequence ) );
}
LSEQ LSET::Technicals( LSET aSetToOmit ) const
{
// desired sequence
static const LAYER_ID sequence[] = {
B_Adhes,
F_Adhes,
B_Paste,
F_Paste,
B_SilkS,
F_SilkS,
B_Mask,
F_Mask,
B_CrtYd,
F_CrtYd,
B_Fab,
F_Fab,
};
LSET subset = ~aSetToOmit & *this;
return subset.Seq( sequence, DIM( sequence ) );
}
LSEQ LSET::Users() const
{
// desired
static const LAYER_ID sequence[] = {
Dwgs_User,
Cmts_User,
Eco1_User,
Eco2_User,
Edge_Cuts,
Margin,
};
return Seq( sequence, DIM( sequence ) );
}
std::string LSET::FmtBin() const
{
std::string ret;
int bit_count = size();
for( int bit=0; bit<bit_count; ++bit )
{
if( bit )
{
if( !( bit % 8 ) )
ret += '|';
else if( !( bit % 4 ) )
ret += '_';
}
ret += (*this)[bit] ? '1' : '0';
}
// reverse of string
return std::string( ret.rbegin(), ret.rend() );
}
std::string LSET::FmtHex() const
{
std::string ret;
static const char hex[] = "0123456789abcdef";
int nibble_count = ( size() + 3 ) / 4;
for( int nibble=0; nibble<nibble_count; ++nibble )
{
unsigned ndx = 0;
// test 4 consecutive bits and set ndx to 0-15:
for( int nibble_bit=0; nibble_bit<4; ++nibble_bit )
{
if( (*this)[nibble_bit + nibble*4] )
ndx |= (1 << nibble_bit);
}
if( nibble && !( nibble % 8 ) )
ret += '_';
assert( ndx < DIM( hex ) );
ret += hex[ndx];
}
// reverse of string
return std::string( ret.rbegin(), ret.rend() );
}
int LSET::ParseHex( const char* aStart, int aCount )
{
LSET tmp;
const char* rstart = aStart + aCount - 1;
const char* rend = aStart - 1;
const int bitcount = size();
int nibble_ndx = 0;
while( rstart > rend )
{
int cc = *rstart--;
if( cc == '_' )
continue;
int nibble;
if( cc >= '0' && cc <= '9' )
nibble = cc - '0';
else if( cc >= 'a' && cc <= 'f' )
nibble = cc - 'a' + 10;
else if( cc >= 'A' && cc <= 'F' )
nibble = cc - 'A' + 10;
else
break;
int bit = nibble_ndx * 4;
for( int ndx=0; bit<bitcount && ndx<4; ++bit, ++ndx )
if( nibble & (1<<ndx) )
tmp.set( bit );
if( bit >= bitcount )
break;
++nibble_ndx;
}
int byte_count = aStart + aCount - 1 - rstart;
assert( byte_count >= 0 );
if( byte_count > 0 )
*this = tmp;
return byte_count;
}
LSEQ LSET::Seq( const LAYER_ID* aWishListSequence, unsigned aCount ) const
{
LSEQ ret;
#if defined(DEBUG) && 0
LSET dup_detector;
for( unsigned i=0; i<aCount; ++i )
{
LAYER_ID id = aWishListSequence[i];
if( test( id ) )
{
wxASSERT_MSG( !dup_detector[id], wxT( "Duplicate in aWishListSequence" ) );
dup_detector[id] = true;
ret.push_back( id );
}
}
#else
for( unsigned i=0; i<aCount; ++i )
{
LAYER_ID id = aWishListSequence[i];
if( test( id ) )
ret.push_back( id );
}
#endif
return ret;
}
LSEQ LSET::Seq() const
{
LSEQ ret;
for( unsigned i=0; i<size(); ++i )
{
if( test(i) )
ret.push_back( LAYER_ID( i ) );
}
return ret;
}
LAYER_ID FlipLayer( LAYER_ID aLayerId )
{
switch( aLayerId )
{
case B_Cu: return F_Cu;
case F_Cu: return B_Cu;
case B_SilkS: return F_SilkS;
case F_SilkS: return B_SilkS;
case B_Adhes: return F_Adhes;
case F_Adhes: return B_Adhes;
case B_Mask: return F_Mask;
case F_Mask: return B_Mask;
case B_Paste: return F_Paste;
case F_Paste: return B_Paste;
case B_CrtYd: return F_CrtYd;
case F_CrtYd: return B_CrtYd;
case B_Fab: return F_Fab;
case F_Fab: return B_Fab;
// No change for the other layers
default:
return aLayerId;
}
}
LSET FlipLayerMask( LSET aMask )
{
// layers on physical outside of a board:
const static LSET and_mask( 16, // !! update count
B_Cu, F_Cu,
B_SilkS, F_SilkS,
B_Adhes, F_Adhes,
B_Mask, F_Mask,
B_Paste, F_Paste,
B_Adhes, F_Adhes,
B_CrtYd, F_CrtYd,
B_Fab, F_Fab
);
LSET newMask = aMask & ~and_mask;
if( aMask[B_Cu] )
newMask.set( F_Cu );
if( aMask[F_Cu] )
newMask.set( B_Cu );
if( aMask[B_SilkS] )
newMask.set( F_SilkS );
if( aMask[F_SilkS] )
newMask.set( B_SilkS );
if( aMask[B_Adhes] )
newMask.set( F_Adhes );
if( aMask[F_Adhes] )
newMask.set( B_Adhes );
if( aMask[B_Mask] )
newMask.set( F_Mask );
if( aMask[F_Mask] )
newMask.set( B_Mask );
if( aMask[B_Paste] )
newMask.set( F_Paste );
if( aMask[F_Paste] )
newMask.set( B_Paste );
if( aMask[B_Adhes] )
newMask.set( F_Adhes );
if( aMask[F_Adhes] )
newMask.set( B_Adhes );
if( aMask[B_CrtYd] )
newMask.set( F_CrtYd );
if( aMask[F_CrtYd] )
newMask.set( B_CrtYd );
if( aMask[B_Fab] )
newMask.set( F_Fab );
if( aMask[F_Fab] )
newMask.set( B_Fab );
return newMask;
}
LAYER_ID LSET::ExtractLayer() const
{
unsigned set_count = count();
if( !set_count )
return UNSELECTED_LAYER;
else if( set_count > 1 )
return UNDEFINED_LAYER;
for( unsigned i=0; i < size(); ++i )
{
if( test( i ) )
return LAYER_ID( i );
}
wxASSERT( 0 ); // set_count was verified as 1 above, what did you break?
return UNDEFINED_LAYER;
}
LSET LSET::InternalCuMask()
{
static const LAYER_ID cu_internals[] = {
In1_Cu,
In2_Cu,
In3_Cu,
In4_Cu,
In5_Cu,
In6_Cu,
In7_Cu,
In8_Cu,
In9_Cu,
In10_Cu,
In11_Cu,
In12_Cu,
In13_Cu,
In14_Cu,
In15_Cu,
In16_Cu,
In17_Cu,
In18_Cu,
In19_Cu,
In20_Cu,
In21_Cu,
In22_Cu,
In23_Cu,
In24_Cu,
In25_Cu,
In26_Cu,
In27_Cu,
In28_Cu,
In29_Cu,
In30_Cu,
};
static const LSET saved( cu_internals, DIM( cu_internals ) );
return saved;
}
LSET LSET::AllCuMask( int aCuLayerCount )
{
// retain all in static as the full set, which is a common case.
static const LSET all = InternalCuMask().set( F_Cu ).set( B_Cu );
if( aCuLayerCount == MAX_CU_LAYERS )
return all;
// subtract out some Cu layers not wanted in the mask.
LSET ret = all;
int clear_count = MAX_CU_LAYERS - aCuLayerCount;
clear_count = Clamp( 0, clear_count, MAX_CU_LAYERS - 2 );
for( LAYER_NUM elem=In30_Cu; clear_count; --elem, --clear_count )
{
ret.set( elem, false );
}
return ret;
}
LSET LSET::AllNonCuMask()
{
static const LSET saved = LSET().set() & ~AllCuMask();
return saved;
}
LSET LSET::AllLayersMask()
{
static const LSET saved = LSET().set();
return saved;
}
LSET LSET::BackTechMask()
{
// (SILKSCREEN_LAYER_BACK | SOLDERMASK_LAYER_BACK | ADHESIVE_LAYER_BACK | SOLDERPASTE_LAYER_BACK)
static const LSET saved( 6, B_SilkS, B_Mask, B_Adhes, B_Paste, B_CrtYd, B_Fab );
return saved;
}
LSET LSET::FrontTechMask()
{
// (SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT | ADHESIVE_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT)
static const LSET saved( 6, F_SilkS, F_Mask, F_Adhes, F_Paste, F_CrtYd, F_Fab );
return saved;
}
LSET LSET::AllTechMask()
{
static const LSET saved = BackTechMask() | FrontTechMask();
return saved;
}
LSET LSET::UserMask()
{
static const LSET saved( 6,
Dwgs_User,
Cmts_User,
Eco1_User,
Eco2_User,
Edge_Cuts,
Margin
);
return saved;
}
LSET LSET::FrontMask()
{
static const LSET saved = FrontTechMask().set( F_Cu );
return saved;
}
LSET LSET::BackMask()
{
static const LSET saved = BackTechMask().set( B_Cu );
return saved;
}
LSEQ LSET::UIOrder() const
{
LAYER_ID order[Margin+1];
// Assmuming that the LAYER_ID order is according to preferred UI order, as of
// today this is true. When that becomes not true, its easy to change the order
// in here to compensate.
for( unsigned i=0; i<DIM(order); ++i )
order[i] = LAYER_ID( i );
return Seq( order, DIM( order ) );
}
LAYER_ID ToLAYER_ID( int aLayer )
{
wxASSERT( unsigned( aLayer ) < LAYER_ID_COUNT );
return LAYER_ID( aLayer );
}

View File

@ -43,16 +43,6 @@
class MODULE;
/* Look up Table for conversion copper layer count -> general copper layer
* mask: */
LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {
0x0001, 0x8001, 0x8003, 0x8007,
0x800F, 0x801F, 0x803F, 0x807F,
0x80FF, 0x81FF, 0x83FF, 0x87FF,
0x8FFF, 0x9FFF, 0xCFFF, 0xFFFF
};
DISPLAY_OPTIONS DisplayOpt; // Display options for board items
int g_AnchorColor = BLUE;
@ -71,124 +61,20 @@ int g_PadCMPColor = RED;
*/
DLIST<TRACK> g_CurrentTrackList;
LAYER_NUM FlipLayer( LAYER_NUM oldlayer )
void AccumulateDescription( wxString &aDesc, const wxString &aItem )
{
switch( oldlayer )
{
case LAYER_N_BACK:
return LAYER_N_FRONT;
case LAYER_N_FRONT:
return LAYER_N_BACK;
case SILKSCREEN_N_BACK:
return SILKSCREEN_N_FRONT;
case SILKSCREEN_N_FRONT:
return SILKSCREEN_N_BACK;
case ADHESIVE_N_BACK:
return ADHESIVE_N_FRONT;
case ADHESIVE_N_FRONT:
return ADHESIVE_N_BACK;
case SOLDERMASK_N_BACK:
return SOLDERMASK_N_FRONT;
case SOLDERMASK_N_FRONT:
return SOLDERMASK_N_BACK;
case SOLDERPASTE_N_BACK:
return SOLDERPASTE_N_FRONT;
case SOLDERPASTE_N_FRONT:
return SOLDERPASTE_N_BACK;
// No change for the other layers
default:
return oldlayer;
}
if( !aDesc.IsEmpty() )
aDesc << wxT(", ");
aDesc << aItem;
}
LAYER_MSK FlipLayerMask( LAYER_MSK aMask )
{
LAYER_MSK newMask;
newMask = aMask & ~(LAYER_BACK | LAYER_FRONT |
SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT |
ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT |
SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT |
SOLDERPASTE_LAYER_BACK | SOLDERPASTE_LAYER_FRONT |
ADHESIVE_LAYER_BACK | ADHESIVE_LAYER_FRONT);
if( aMask & LAYER_BACK )
newMask |= LAYER_FRONT;
if( aMask & LAYER_FRONT )
newMask |= LAYER_BACK;
if( aMask & SILKSCREEN_LAYER_BACK )
newMask |= SILKSCREEN_LAYER_FRONT;
if( aMask & SILKSCREEN_LAYER_FRONT )
newMask |= SILKSCREEN_LAYER_BACK;
if( aMask & ADHESIVE_LAYER_BACK )
newMask |= ADHESIVE_LAYER_FRONT;
if( aMask & ADHESIVE_LAYER_FRONT )
newMask |= ADHESIVE_LAYER_BACK;
if( aMask & SOLDERMASK_LAYER_BACK )
newMask |= SOLDERMASK_LAYER_FRONT;
if( aMask & SOLDERMASK_LAYER_FRONT )
newMask |= SOLDERMASK_LAYER_BACK;
if( aMask & SOLDERPASTE_LAYER_BACK )
newMask |= SOLDERPASTE_LAYER_FRONT;
if( aMask & SOLDERPASTE_LAYER_FRONT )
newMask |= SOLDERPASTE_LAYER_BACK;
if( aMask & ADHESIVE_LAYER_BACK )
newMask |= ADHESIVE_LAYER_FRONT;
if( aMask & ADHESIVE_LAYER_FRONT )
newMask |= ADHESIVE_LAYER_BACK;
return newMask;
}
LAYER_NUM ExtractLayer( LAYER_MSK aMask )
{
if( aMask == NO_LAYERS )
return UNSELECTED_LAYER;
LAYER_NUM candidate = UNDEFINED_LAYER;
// Scan all the layers and take note of the first set; if other are
// then found return UNDEFINED_LAYER
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{
if( aMask & GetLayerMask( i ) )
{
if( candidate == UNDEFINED_LAYER )
candidate = i;
else
return UNDEFINED_LAYER;
}
}
return candidate;
}
wxString LayerMaskDescribe( const BOARD *aBoard, LAYER_MSK aMask )
wxString LayerMaskDescribe( const BOARD *aBoard, LSET aMask )
{
// Try the single or no- layer case (easy)
LAYER_NUM layer = ExtractLayer( aMask );
switch( layer )
LAYER_ID layer = aMask.ExtractLayer();
switch( (int) layer )
{
case UNSELECTED_LAYER:
return _( "No layers" );
@ -203,24 +89,19 @@ wxString LayerMaskDescribe( const BOARD *aBoard, LAYER_MSK aMask )
// Try to be smart and useful, starting with outer copper
// (which are more important than internal ones)
wxString layerInfo;
if( aMask & LAYER_FRONT )
AccumulateDescription( layerInfo, aBoard->GetLayerName( LAYER_N_FRONT ) );
if( aMask & LAYER_BACK )
AccumulateDescription( layerInfo, aBoard->GetLayerName( LAYER_N_BACK ) );
if( aMask[F_Cu] )
AccumulateDescription( layerInfo, aBoard->GetLayerName( F_Cu ) );
if( aMask & INTERNAL_CU_LAYERS )
if( aMask[B_Cu] )
AccumulateDescription( layerInfo, aBoard->GetLayerName( B_Cu ) );
if( ( aMask & LSET::InternalCuMask() ).any() )
AccumulateDescription( layerInfo, _("Internal" ) );
if( aMask & ALL_NO_CU_LAYERS )
if( ( aMask & LSET::AllNonCuMask() ).any() )
AccumulateDescription( layerInfo, _("Non-copper" ) );
return layerInfo;
}
void AccumulateDescription( wxString &aDesc, const wxString &aItem )
{
if( !aDesc.IsEmpty() )
aDesc << wxT(", ");
aDesc << aItem;
}

View File

@ -183,7 +183,7 @@ void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
delete plotter;
}
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData)
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData)
{
if( ! m_component )
return;

View File

@ -608,7 +608,7 @@ public:
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMask,
virtual void PrintPage( wxDC* aDC, LSET aPrintMask,
bool aPrintMirrorMode, void* aData = NULL );
/**

View File

@ -934,7 +934,7 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode,
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode,
void* aData )
{
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );

View File

@ -35,6 +35,7 @@
#include <gr_basic.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <wx/debug.h>

View File

@ -7,6 +7,7 @@
#include <wxstruct.h>
#include <class_drawpanel.h>
#include <gerbview.h>
#include <dcode.h>
#include <class_DCodeSelectionbox.h>

View File

@ -34,6 +34,7 @@
#include <macros.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>

View File

@ -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, LAYER_NUM layer ) :
public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) :
GERBER_IMAGE( aParent, layer )
{
m_State = READ_HEADER_STATE;

View File

@ -40,7 +40,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
{
Clear();
for( LAYER_NUM layerid = FIRST_LAYER; layerid < NB_LAYERS; ++layerid )
for( int layerid = 0; layerid < GERBER_DRAWLAYERS_COUNT; ++layerid )
{
wxBitmap layerbmp( 14, 14 );
wxString layername;
@ -59,7 +59,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
// Returns a color index from the layer id
EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
{
GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
@ -68,7 +68,7 @@ EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
// Returns the name of the layer id
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( LAYER_NUM aLayer ) const
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const
{
wxString name;
name.Printf( _( "Layer %d" ), aLayer + 1 );

View File

@ -9,14 +9,12 @@ class GBR_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
{
public:
GBR_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL )
:LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
{
m_layerhotkeys = false;
m_layerorder = false;
}
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL ) :
LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
{
m_layerhotkeys = false;
}
// Reload the Layers names and bitmaps
// Virtual function
@ -24,15 +22,14 @@ public:
// Returns a color index from the layer id
// Virtual function
EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
EDA_COLOR_T GetLayerColor( int aLayer ) const;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function
bool IsLayerEnabled( LAYER_NUM aLayer ) const { return true; };
bool IsLayerEnabled( int aLayer ) const { return true; };
// Returns the name of the layer id
// Virtual function
wxString GetLayerName( LAYER_NUM aLayer ) const;
wxString GetLayerName( int aLayer ) const;
};
#endif //CLASS_GBR_LAYER_BOX_SELECTOR_H

View File

@ -14,7 +14,9 @@ GBR_LAYOUT::GBR_LAYOUT()
{
PAGE_INFO pageInfo( wxT( "GERBER" ) );
SetPageSettings( pageInfo );
m_printLayersMask = FULL_LAYERS;
// no m_printLayersMask = -1;
m_printLayersMask.set();
}
@ -22,16 +24,6 @@ GBR_LAYOUT::~GBR_LAYOUT()
{
}
/* Function IsLayerVisible
* tests whether a given layer is visible
* param aLayer = The layer to be tested
* return bool - true if the layer is visible.
*/
bool GBR_LAYOUT::IsLayerVisible( LAYER_NUM aLayer ) const
{
return m_printLayersMask & GetLayerMask( aLayer );
}
EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
{

View File

@ -11,6 +11,7 @@
#include <class_colors_design_settings.h>
#include <common.h> // PAGE_INFO
#include <gerbview.h> // GERBER_DRAWLAYERS_COUNT
#include <class_title_block.h>
#include <class_gerber_draw_item.h>
@ -23,11 +24,11 @@
class GBR_LAYOUT
{
private:
EDA_RECT m_BoundingBox;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
wxPoint m_originAxisPosition;
LAYER_MSK m_printLayersMask; // When printing: the list of layers to print
EDA_RECT m_BoundingBox;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
wxPoint m_originAxisPosition;
std::bitset <GERBER_DRAWLAYERS_COUNT> m_printLayersMask; // When printing: the list of layers to print
public:
DLIST<GERBER_DRAW_ITEM> m_Drawings; // linked list of Gerber Items
@ -87,24 +88,35 @@ public:
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset,
bool aPrintBlackAndWhite = false );
/**
* Function SetVisibleLayers
* changes the bit-mask of visible layers
* @param aLayerMask = The new bit-mask of visible layers
* Function SetPrintableLayers
* changes the list of printable layers
* @param aLayerMask = The new bit-mask of printable layers
*/
void SetVisibleLayers( LAYER_MSK aLayerMask )
void SetPrintableLayers( const std::bitset <GERBER_DRAWLAYERS_COUNT>& aLayerMask )
{
m_printLayersMask = aLayerMask;
}
/**
* Function IsLayerVisible
* Function GetPrintableLayers
* @return the bit-mask of printable layers
*/
std::bitset <GERBER_DRAWLAYERS_COUNT> GetPrintableLayers()
{
return m_printLayersMask;
}
/**
* Function IsLayerPrintable
* tests whether a given layer is visible
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
*/
bool IsLayerVisible( LAYER_NUM aLayer ) const;
bool IsLayerPrintable( int aLayer ) const
{
return m_printLayersMask[ aLayer ];
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload

View File

@ -86,7 +86,7 @@ GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) :
// Set the working grid size to a reasonable value (in 1/10000 inch)
SetGrid( DMIL_GRID( 500 ) );
m_Active_Layer = LAYER_N_BACK; // default active layer = bottom layer
m_Active_Layer = B_Cu; // default active layer = bottom layer
SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom

View File

@ -36,6 +36,7 @@
#include <msgpanel.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
@ -44,7 +45,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 = FIRST_LAYER;
m_Layer = 0;
m_Shape = GBR_SEGMENT;
m_Flashed = false;
m_DCode = 0;

View File

@ -90,7 +90,7 @@ public:
* redundancy for these parameters
*/
private:
LAYER_NUM m_Layer;
int 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.
*/
LAYER_NUM GetLayer() const { return m_Layer; }
int GetLayer() const { return m_Layer; }
/**
* Function SetLayer
@ -132,12 +132,7 @@ public:
* is virtual because some items (in fact: class DIMENSION)
* have a slightly different initialization
*/
void SetLayer( LAYER_NUM aLayer ) { m_Layer = aLayer; }
LAYER_MSK GetLayerMask()
{
return ::GetLayerMask( m_Layer );
}
void SetLayer( int aLayer ) { m_Layer = aLayer; }
bool GetLayerPolarity()
{

View File

@ -37,6 +37,7 @@
#include <class_gbr_layer_box_selector.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <layer_widget.h>
#include <class_gerbview_layer_widget.h>
@ -166,10 +167,10 @@ void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
{
int rowCount;
int menuId = event.GetId();
bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;;
LAYER_MSK visibleLayers = NO_LAYERS;
int rowCount;
int menuId = event.GetId();
bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;;
long visibleLayers = 0;
bool force_active_layer_visible;
m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
@ -186,7 +187,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
for( int row=0; row < rowCount; ++row )
{
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
LAYER_NUM layer = getDecodedId( cb->GetId() );
int layer = getDecodedId( cb->GetId() );
bool loc_visible = visible;
if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) )
@ -195,9 +196,9 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
cb->SetValue( loc_visible );
if( loc_visible )
visibleLayers |= GetLayerMask( row );
visibleLayers |= 1 << row;
else
visibleLayers &= ~GetLayerMask( row );
visibleLayers &= ~( 1 << row );
}
myframe->SetVisibleLayers( visibleLayers );
@ -224,7 +225,7 @@ void GERBER_LAYER_WIDGET::ReFill()
{
ClearLayerRows();
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer )
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
{
wxString msg;
msg.Printf( _("Layer %d"), layer+1 );
@ -237,18 +238,18 @@ void GERBER_LAYER_WIDGET::ReFill()
//-----<LAYER_WIDGET callbacks>-------------------------------------------
void GERBER_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor )
void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
{
myframe->SetLayerColor( aLayer, aColor );
myframe->m_SelLayerBox->ResyncBitmapOnly();
myframe->GetCanvas()->Refresh();
}
bool GERBER_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
{
// the layer change from the GERBER_LAYER_WIDGET can be denied by returning
// false from this function.
LAYER_NUM layer = myframe->getActiveLayer( );
int layer = myframe->getActiveLayer( );
myframe->setActiveLayer( aLayer, false );
myframe->syncLayerBox();
@ -261,14 +262,14 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
return true;
}
void GERBER_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal )
void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
{
LAYER_MSK visibleLayers = myframe->GetVisibleLayers();
long visibleLayers = myframe->GetVisibleLayers();
if( isVisible )
visibleLayers |= GetLayerMask( aLayer );
visibleLayers |= 1 << aLayer;
else
visibleLayers &= ~GetLayerMask( aLayer );
visibleLayers &= ~( 1 << aLayer );
myframe->SetVisibleLayers( visibleLayers );

View File

@ -91,9 +91,9 @@ public:
void ReFillRender();
//-----<implement LAYER_WIDGET abstract callback functions>-----------
void OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor );
bool OnLayerSelect( LAYER_NUM aLayer );
void OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal );
void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor );
bool OnLayerSelect( int aLayer );
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
void OnRenderColorChange( int aId, EDA_COLOR_T aColor );
void OnRenderEnable( int aId, bool isEnabled );
/**

View File

@ -30,6 +30,7 @@
#include <common.h>
#include <class_drawpanel.h>
#include <gerbview.h>
#include <gerbview_frame.h>
void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )

View File

@ -38,6 +38,7 @@
#include <base_units.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>

View File

@ -6,7 +6,7 @@
#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <common.h>
#include <class_drawpanel.h>
@ -16,9 +16,9 @@
#include <printout_controler.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <pcbplot.h>
static long s_SelectedLayers;
static double s_ScaleList[] =
{ 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 };
@ -27,8 +27,8 @@ static double s_ScaleList[] =
#define MAX_SCALE 100.0
// static print data and page setup data, to remember settings during the session
static wxPrintData* g_PrintData;
static wxPageSetupDialogData* g_pageSetupData = (wxPageSetupDialogData*) NULL;
static wxPrintData* s_printData;
static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
// Variables locales
static PRINT_PARAMETERS s_Parameters;
@ -41,8 +41,8 @@ class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE
{
private:
GERBVIEW_FRAME* m_Parent;
wxConfigBase* m_Config;
wxCheckBox* m_BoxSelectLayer[32];
wxConfigBase* m_Config;
wxCheckBox* m_BoxSelectLayer[32];
public:
DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent );
@ -63,7 +63,10 @@ private:
public:
bool IsMirrored() { return m_Print_Mirror->IsChecked(); }
bool PrintUsingSinglePage() { return true; }
int SetLayerMaskFromListSelection();
int SetLayerSetFromListSelection();
// Prepare print parameters. return true if OK,
// false if there is an issue (mainly no printable layers)
bool PreparePrintPrms();
};
@ -75,17 +78,17 @@ void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event )
* Display the print dialog
*/
{
if( g_PrintData == NULL ) // First print
g_PrintData = new wxPrintData();
if( s_printData == NULL ) // First print
s_printData = new wxPrintData();
if( !g_PrintData->Ok() )
if( !s_printData->Ok() )
{
DisplayError( this, _( "Error Init Printer info" ) );
return;
}
g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH );
g_PrintData->SetOrientation( GetPageSettings().IsPortrait() ?
s_printData->SetQuality( wxPRINT_QUALITY_HIGH );
s_printData->SetOrientation( GetPageSettings().IsPortrait() ?
wxPORTRAIT : wxLANDSCAPE );
DIALOG_PRINT_USING_PRINTER* frame = new DIALOG_PRINT_USING_PRINTER( this );
@ -118,31 +121,29 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
/************************************************************************/
{
SetFocus();
LAYER_NUM layer_max = NB_GERBER_LAYERS;
wxString msg;
if( g_pageSetupData == NULL )
if( s_pageSetupData == NULL )
{
g_pageSetupData = new wxPageSetupDialogData;
s_pageSetupData = new wxPageSetupDialogData;
// Set initial page margins.
// Margins are already set in Pcbnew, so we can use 0
g_pageSetupData->SetMarginTopLeft(wxPoint(0, 0));
g_pageSetupData->SetMarginBottomRight(wxPoint(0, 0));
// Margins are already set in Gerbview, so we can use 0
s_pageSetupData->SetMarginTopLeft(wxPoint(0, 0));
s_pageSetupData->SetMarginBottomRight(wxPoint(0, 0));
}
s_Parameters.m_PageSetupData = g_pageSetupData;
s_Parameters.m_PageSetupData = s_pageSetupData;
layer_max = NB_LAYERS;
// Create layer list
for( LAYER_NUM ii = FIRST_LAYER; ii < layer_max; ++ii )
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
LAYER_MSK mask = GetLayerMask( ii );
msg = _( "Layer" );
msg << wxT( " " ) << ii + 1;
m_BoxSelectLayer[ii] = new wxCheckBox( this, -1, msg );
if( mask & s_SelectedLayers )
m_BoxSelectLayer[ii]->SetValue( true );
if( g_GERBER_List[ii] == NULL ) // Nothing loaded on this draw layer
m_BoxSelectLayer[ii]->Enable( false );
if( ii < 16 )
m_leftLayersBoxSizer->Add( m_BoxSelectLayer[ii],
wxGROW | wxLEFT | wxRIGHT | wxTOP );
@ -170,21 +171,14 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
s_Parameters.m_YScaleAdjust > MAX_SCALE )
s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0;
s_SelectedLayers = 0;
for( LAYER_NUM layer = FIRST_LAYER; layer < layer_max; ++layer )
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
{
wxString layerKey;
bool option;
layerKey.Printf( OPTKEY_LAYERBASE, layer );
option = false;
if( m_Config->Read( layerKey, &option ) )
{
m_BoxSelectLayer[layer]->SetValue( option );
if( option )
s_SelectedLayers |= GetLayerMask( layer );
}
m_Config->Read( layerKey, &option, false );
m_BoxSelectLayer[layer]->SetValue( option );
}
}
@ -214,30 +208,29 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_FineAdjustYscaleOpt->Enable(enable);
}
/**************************************************************/
int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
/**************************************************************/
int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection()
{
int page_count = 0;
s_Parameters.m_PrintMaskLayer = NO_LAYERS;
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
std::bitset <GERBER_DRAWLAYERS_COUNT> layerMask;
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
if( m_BoxSelectLayer[ii]->IsChecked() )
if( m_BoxSelectLayer[ii]->IsChecked() && m_BoxSelectLayer[ii]->IsEnabled() )
{
page_count++;
s_Parameters.m_PrintMaskLayer |= GetLayerMask( ii );
layerMask[ii] = true;
}
else
layerMask[ii] = false;
}
m_Parent->GetGerberLayout()->SetPrintableLayers( layerMask );
s_Parameters.m_PageCount = page_count;
return page_count;
}
/********************************************************************/
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
/********************************************************************/
{
SetPrintParameters();
@ -249,19 +242,18 @@ 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( LAYER_NUM layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer )
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
{
layerKey.Printf( OPTKEY_LAYERBASE, layer );
m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
}
}
EndModal( 0 );
}
/******************************************************************/
void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
/******************************************************************/
{
s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue();
s_Parameters.m_Print_Black_and_White =
@ -271,7 +263,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
// because these objects create artefact when they are printed on an existing image.
s_Parameters.m_OptionPrintPage = false;
SetLayerMaskFromListSelection();
SetLayerSetFromListSelection();
int idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[idx];
@ -303,38 +295,45 @@ void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
m_FineAdjustYscaleOpt->Enable(enable);
}
/**********************************************************/
// Open a dialog box for printer setup (printer options, page size ...)
void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event )
/**********************************************************/
/* Open a dialog box for printer setup (printer options, page size ...)
*/
{
*g_pageSetupData = *g_PrintData;
*s_pageSetupData = *s_printData;
wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
wxPageSetupDialog pageSetupDialog(this, s_pageSetupData);
pageSetupDialog.ShowModal();
(*g_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
(*g_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
(*s_printData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
}
/************************************************************/
void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
/************************************************************/
/* Open and display a previewer frame for printing
*/
bool DIALOG_PRINT_USING_PRINTER::PreparePrintPrms()
{
SetPrintParameters( );
// If no layer selected, we have no plot. prompt user if it happens
// because he could think there is a bug in Pcbnew:
if( m_Parent->GetGerberLayout()->GetPrintableLayers().none() )
{
DisplayError( this, _( "No layer selected" ) );
return false;
}
return true;
}
// Open and display a previewer frame for printing
void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
{
if( !PreparePrintPrms() )
return;
// Pass two printout objects: for preview, and possible printing.
wxString title = _( "Print Preview" );
wxPrintPreview* preview =
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_Parent, title ),
new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_Parent, title ),
g_PrintData );
s_printData );
if( preview == NULL )
{
@ -342,16 +341,6 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
return;
}
SetLayerMaskFromListSelection();
// If no layer selected, we have no plot. prompt user if it happens
// because he could think there is a bug in Pcbnew:
if( s_Parameters.m_PrintMaskLayer == 0 )
{
DisplayError( this, _( "No layer selected" ) );
return;
}
// Uses the parent position and size.
// @todo uses last position and size ans store them when exit in m_Config
@ -365,29 +354,16 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
}
/***************************************************************************/
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
/***************************************************************************/
/* Called on activate Print button
*/
{
SetPrintParameters( );
// If no layer selected, we have no plot. prompt user if it happens
// because he could think there is a bug in Pcbnew:
if( s_Parameters.m_PrintMaskLayer == 0 )
{
DisplayError( this, _( "No layer selected" ) );
if( !PreparePrintPrms() )
return;
}
wxPrintDialogData printDialogData( *g_PrintData );
wxPrintDialogData printDialogData( *s_printData );
wxPrinter printer( &printDialogData );
wxString title = _( "Print" );
BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_Parent, title );
wxPrinter printer( &printDialogData );
wxString title = _( "Print" );
BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_Parent, title );
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
wxDC* dc = printout.GetDC();
@ -402,7 +378,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
}
else
{
*g_PrintData = printer.GetPrintDialogData().GetPrintData();
*s_printData = printer.GetPrintDialogData().GetPrintData();
}
}

View File

@ -8,7 +8,7 @@
#include <select_layers_to_pcb.h>
// Exported function
const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber );
const wxString GetPCBDefaultLayerName( int aLayerNumber );
enum layer_sel_id {
@ -23,11 +23,11 @@ class SELECT_LAYER_DIALOG : public wxDialog
private:
GERBVIEW_FRAME* m_Parent;
wxRadioBox* m_LayerList;
LAYER_NUM m_LayerId[int(NB_LAYERS) + 1]; // One extra element for "(Deselect)" radiobutton
int m_LayerId[int(GERBER_DRAWLAYERS_COUNT) + 1]; // One extra element for "(Deselect)" radiobutton
public:
// Constructor and destructor
SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, LAYER_NUM aDefaultLayer,
SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer,
int aCopperLayerCount, bool aShowDeselectOption );
~SELECT_LAYER_DIALOG() { };
@ -47,10 +47,10 @@ END_EVENT_TABLE()
/** Install the dialog box for layer selection
* @param aDefaultLayer = Preselection (NB_LAYERS for "(Deselect)" layer)
* @param aDefaultLayer = Preselection (GERBER_DRAWLAYERS_COUNT 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 (GERBER_DRAWLAYERS_COUNT when "(Deselect)" radiobutton selected),
* or -1 if canceled
*
* Providing the option to also display a "(Deselect)" radiobutton makes the
@ -61,10 +61,10 @@ END_EVENT_TABLE()
* different radiobutton is clicked on) prior to then clicking on the "Deselect"
* button provided within the "Layer selection:" dialog box).
*/
LAYER_NUM GERBVIEW_FRAME::SelectPCBLayer( LAYER_NUM aDefaultLayer, int aCopperLayerCount,
int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount,
bool aShowDeselectOption )
{
LAYER_NUM layer;
int layer;
SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this, aDefaultLayer,
aCopperLayerCount,
aShowDeselectOption );
@ -82,14 +82,17 @@ LAYER_NUM GERBVIEW_FRAME::SelectPCBLayer( LAYER_NUM aDefaultLayer, int aCopperLa
* to the right of that radiobox.
*/
SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
LAYER_NUM aDefaultLayer, int aCopperLayerCount,
int aDefaultLayer, int aCopperLayerCount,
bool aShowDeselectOption ) :
wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ),
wxSize( 470, 250 ),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
#define NB_PCB_LAYERS 64
#define FIRST_COPPER_LAYER 0
#define LAST_COPPER_LAYER 31
wxButton* Button;
LAYER_NUM ii;
int ii;
wxString LayerList[NB_PCB_LAYERS + 1]; // One extra element for "(Deselect)"
// radiobutton
int LayerCount, LayerSelect = -1;
@ -98,9 +101,10 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
// Build the layer list; first build copper layers list
LayerCount = 0;
for( ii = FIRST_COPPER_LAYER; ii < NB_COPPER_LAYERS; ++ii )
for( ii = FIRST_COPPER_LAYER; ii <= LAST_COPPER_LAYER; ++ii )
{
m_LayerId[ii] = FIRST_LAYER;
m_LayerId[ii] = 0;
if( ii == FIRST_COPPER_LAYER || ii == LAST_COPPER_LAYER || ii < aCopperLayerCount-1 )
{
@ -113,10 +117,11 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
LayerCount++;
}
}
// Build the layer list; build non copper layers list
for( ; ii < NB_PCB_LAYERS; ++ii )
{
m_LayerId[ii] = FIRST_LAYER;
m_LayerId[ii] = 0;
LayerList[LayerCount] = GetPCBDefaultLayerName( ii );
@ -182,42 +187,42 @@ void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
EndModal( -1 );
}
const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber )
const wxString GetPCBDefaultLayerName( int aLayerNumber )
{
const wxChar* txt;
// Use a switch to explicitly show the mapping more clearly
switch( aLayerNumber )
{
case LAYER_N_FRONT: txt = wxT( "F.Cu" ); break;
case LAYER_N_2: txt = wxT( "Inner1.Cu" ); break;
case LAYER_N_3: txt = wxT( "Inner2.Cu" ); break;
case LAYER_N_4: txt = wxT( "Inner3.Cu" ); break;
case LAYER_N_5: txt = wxT( "Inner4.Cu" ); break;
case LAYER_N_6: txt = wxT( "Inner5.Cu" ); break;
case LAYER_N_7: txt = wxT( "Inner6.Cu" ); break;
case LAYER_N_8: txt = wxT( "Inner7.Cu" ); break;
case LAYER_N_9: txt = wxT( "Inner8.Cu" ); break;
case LAYER_N_10: txt = wxT( "Inner9.Cu" ); break;
case LAYER_N_11: txt = wxT( "Inner10.Cu" ); break;
case LAYER_N_12: txt = wxT( "Inner11.Cu" ); break;
case LAYER_N_13: txt = wxT( "Inner12.Cu" ); break;
case LAYER_N_14: txt = wxT( "Inner13.Cu" ); break;
case LAYER_N_15: txt = wxT( "Inner14.Cu" ); break;
case LAYER_N_BACK: txt = wxT( "B.Cu" ); break;
case ADHESIVE_N_BACK: txt = wxT( "B.Adhes" ); break;
case ADHESIVE_N_FRONT: txt = wxT( "F.Adhes" ); break;
case SOLDERPASTE_N_BACK: txt = wxT( "B.Paste" ); break;
case SOLDERPASTE_N_FRONT: txt = wxT( "F.Paste" ); break;
case SILKSCREEN_N_BACK: txt = wxT( "B.SilkS" ); break;
case SILKSCREEN_N_FRONT: txt = wxT( "F.SilkS" ); break;
case SOLDERMASK_N_BACK: txt = wxT( "B.Mask" ); break;
case SOLDERMASK_N_FRONT: txt = wxT( "F.Mask" ); break;
case DRAW_N: txt = wxT( "Dwgs.User" ); break;
case COMMENT_N: txt = wxT( "Cmts.User" ); break;
case ECO1_N: txt = wxT( "Eco1.User" ); break;
case ECO2_N: txt = wxT( "Eco2.User" ); break;
case EDGE_N: txt = wxT( "Edge.Cuts" ); break;
case F_Cu: txt = wxT( "F.Cu" ); break;
case In1_Cu: txt = wxT( "In1.Cu" ); break;
case In2_Cu: txt = wxT( "In2.Cu" ); break;
case In3_Cu: txt = wxT( "In3.Cu" ); break;
case In4_Cu: txt = wxT( "In4.Cu" ); break;
case In5_Cu: txt = wxT( "In5.Cu" ); break;
case In6_Cu: txt = wxT( "In6.Cu" ); break;
case In7_Cu: txt = wxT( "In7.Cu" ); break;
case In8_Cu: txt = wxT( "In8.Cu" ); break;
case In9_Cu: txt = wxT( "In9.Cu" ); break;
case In10_Cu: txt = wxT( "In10.Cu" ); break;
case In11_Cu: txt = wxT( "In11.Cu" ); break;
case In12_Cu: txt = wxT( "In12.Cu" ); break;
case In13_Cu: txt = wxT( "In13.Cu" ); break;
case In14_Cu: txt = wxT( "In14.Cu" ); break;
case B_Cu: txt = wxT( "B.Cu" ); break;
case B_Adhes: txt = wxT( "B.Adhes" ); break;
case F_Adhes: txt = wxT( "F.Adhes" ); break;
case B_Paste: txt = wxT( "B.Paste" ); break;
case F_Paste: txt = wxT( "F.Paste" ); break;
case B_SilkS: txt = wxT( "B.SilkS" ); break;
case F_SilkS: txt = wxT( "F.SilkS" ); break;
case B_Mask: txt = wxT( "B.Mask" ); break;
case F_Mask: txt = wxT( "F.Mask" ); break;
case Dwgs_User: txt = wxT( "Dwgs.User" ); break;
case Cmts_User: txt = wxT( "Cmts.User" ); break;
case Eco1_User: txt = wxT( "Eco1.User" ); break;
case Eco2_User: txt = wxT( "Eco2.User" ); break;
case Edge_Cuts: txt = wxT( "Edge.Cuts" ); break;
default: txt = wxT( "BAD_INDEX" ); break;
}

View File

@ -32,6 +32,7 @@
#include <macros.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <dialog_show_page_borders.h>

View File

@ -11,6 +11,7 @@
#include <pcbplot.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_dialog_display_options_frame_base.h>

View File

@ -36,21 +36,21 @@
#include <base_units.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <colors_selection.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <printout_controler.h>
void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
bool aPrintMirrorMode, void* aData )
{
// Save current draw options, because print mode has specific options:
LAYER_MSK visiblemask = GetVisibleLayers();
GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions;
std::bitset <GERBER_DRAWLAYERS_COUNT> printLayersMask = GetGerberLayout()->GetPrintableLayers();
// Set draw options for printing:
SetVisibleLayers( aPrintMasklayer );
m_DisplayOptions.m_DisplayFlashedItemsFill = true;
m_DisplayOptions.m_DisplayLinesFill = true;
m_DisplayOptions.m_DisplayPolygonsFill = true;
@ -58,7 +58,10 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
m_DisplayOptions.m_IsPrinting = true;
PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*)aData;
std::bitset <GERBER_DRAWLAYERS_COUNT> printCurrLayerMask;
printCurrLayerMask.reset();
printCurrLayerMask.set(printParameters->m_Flags); // m_Flags contains the draw layer number
GetGerberLayout()->SetPrintableLayers( printCurrLayerMask );
m_canvas->SetPrintMirrored( aPrintMirrorMode );
bool printBlackAndWhite = printParameters && printParameters->m_Print_Black_and_White;
@ -68,7 +71,7 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
m_canvas->SetPrintMirrored( false );
// Restore draw options:
SetVisibleLayers( visiblemask );
GetGerberLayout()->SetPrintableLayers( printLayersMask );
m_DisplayOptions = imgDisplayOptions;
}
@ -211,14 +214,14 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
bool end = false;
for( LAYER_NUM layer = FIRST_LAYER; !end; ++layer )
for( int layer = 0; !end; ++layer )
{
LAYER_NUM active_layer = gerbFrame->getActiveLayer();
int active_layer = gerbFrame->getActiveLayer();
if( layer == active_layer ) // active layer will be drawn after other layers
continue;
if( layer == NB_GERBER_LAYERS ) // last loop: draw active layer
if( layer == GERBER_DRAWLAYERS_COUNT ) // last loop: draw active layer
{
end = true;
layer = active_layer;

View File

@ -11,6 +11,7 @@
#include <gestfich.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <kicad_device_context.h>
#include <gerbview_id.h>
#include <class_GERBER.h>
@ -226,7 +227,7 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
{
LAYER_NUM layer = getActiveLayer();
int layer = getActiveLayer();
setActiveLayer( event.GetSelection() );
@ -240,7 +241,7 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
{
LAYER_NUM layer = getActiveLayer();
int layer = getActiveLayer();
GERBER_IMAGE* gerber_layer = g_GERBER_List[layer];
if( gerber_layer )

View File

@ -67,6 +67,7 @@
#include <confirm.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <trigo.h>
#include <macros.h>
#include <base_units.h>
@ -92,13 +93,13 @@ extern double ReadDouble( char*& text, bool aSkipSeparator = true );
extern void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
APERTURE_T aAperture,
int Dcode_index,
LAYER_NUM aLayer,
int aLayer,
const wxPoint& aPos,
wxSize aSize,
bool aLayerNegative );
void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
int Dcode_index,
LAYER_NUM aLayer,
int aLayer,
const wxPoint& aStart,
const wxPoint& aEnd,
wxSize aPenSize,
@ -167,7 +168,7 @@ static EXCELLON_CMD excellon_G_CmdList[] =
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
{
wxString msg;
LAYER_NUM layer = getActiveLayer(); // current layer used in GerbView
int layer = getActiveLayer(); // current layer used in GerbView
if( g_GERBER_List[layer] == NULL )
{

View File

@ -7,13 +7,13 @@
#include <fctsys.h>
#include <common.h>
// #include <class_drawpanel.h>
#include <confirm.h>
#include <macros.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <trigo.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <select_layers_to_pcb.h>
#include <build_version.h>
@ -123,7 +123,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
int layercount = 0;
// Count the Gerber layers which are actually currently used
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
for( LAYER_NUM ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
if( g_GERBER_List[ii] != NULL )
layercount++;
@ -190,16 +190,17 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* LayerLookUpTable, int aCopperLay
// create an image of gerber data
// First: non copper layers:
GERBER_DRAW_ITEM* gerb_item = m_gerbview_frame->GetItemsList();
int pcbCopperLayerMax = 31;
for( ; gerb_item; gerb_item = gerb_item->Next() )
{
LAYER_NUM layer = gerb_item->GetLayer();
int layer = gerb_item->GetLayer();
LAYER_NUM pcb_layer_number = LayerLookUpTable[layer];
if( !IsPcbLayer( pcb_layer_number ) )
continue;
if( pcb_layer_number > LAST_COPPER_LAYER )
if( pcb_layer_number > pcbCopperLayerMax )
export_non_copper_item( gerb_item, pcb_layer_number );
}
@ -209,10 +210,10 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* LayerLookUpTable, int aCopperLay
for( ; gerb_item; gerb_item = gerb_item->Next() )
{
LAYER_NUM layer = gerb_item->GetLayer();
int layer = gerb_item->GetLayer();
LAYER_NUM pcb_layer_number = LayerLookUpTable[layer];
if( pcb_layer_number < 0 || pcb_layer_number > LAST_COPPER_LAYER )
if( pcb_layer_number < 0 || pcb_layer_number > pcbCopperLayerMax )
continue;
else
@ -398,13 +399,7 @@ void GBR_TO_PCB_EXPORTER::writePcbHeader()
// Write copper layer count
fprintf( m_fp, "LayerCount %d\n", m_pcbCopperLayersCount );
// Write enabled layer mask:
int lmask = ALL_NO_CU_LAYERS | EXTERNAL_CU_LAYERS;
for( int ii = 0; ii < m_pcbCopperLayersCount - 2; ii++ )
lmask |= 2 << ii;
fprintf( m_fp, "EnabledLayers %08X\n", lmask );
fprintf( m_fp, "$EndGENERAL\n\n" );
// Creates void setup

View File

@ -33,6 +33,7 @@
#include <gestfich.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <class_gerbview_layer_widget.h>
#include <wildcards_and_files_ext.h>
@ -163,7 +164,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
}
// Read gerber files: each file is loaded on a new GerbView layer
LAYER_NUM layer = getActiveLayer();
int layer = getActiveLayer();
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
{
@ -244,7 +245,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
}
// Read gerber files: each file is loaded on a new GerbView layer
LAYER_NUM layer = getActiveLayer();
int layer = getActiveLayer();
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
{

View File

@ -36,6 +36,7 @@
#include <gerbview.h>
#include <gerbview_id.h>
#include <hotkeys.h>
#include <gerbview_frame.h>
#include <build_version.h>

View File

@ -8,9 +8,6 @@
#include <vector>
#include <set>
#include <dcode.h>
#include <class_gerber_draw_item.h>
#include <class_aperture_macro.h>
#define CURSEUR_ON_GRILLE 0
#define CURSEUR_OFF_GRILLE 1
@ -32,6 +29,8 @@ extern const wxChar* g_GerberPageSizeList[8];
#define GERB_STOP_DRAW 2 // Extinguish light (lift pen)
#define GERB_FLASH 3 // Flash
// number fo draw layers in Gerbview
#define GERBER_DRAWLAYERS_COUNT 32
/**
* Enum GERBER_VISIBLE_ID
@ -47,9 +46,6 @@ enum GERBER_VISIBLE_ID
END_GERBER_VISIBLE_LIST // sentinel
};
extern const wxString GerbviewProjectFileExt;
extern const wxString GerbviewProjectFileWildcard;
// Interpolation type
enum Gerb_Interpolation
{
@ -93,13 +89,6 @@ enum Gerb_Analyse_Cmd
ENTER_RS274X_CMD
};
/**************/
/* rs274x.cpp */
/**************/
bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file );
extern GERBER_IMAGE* g_GERBER_List[32];
#include <gerbview_frame.h>
extern GERBER_IMAGE* g_GERBER_List[GERBER_DRAWLAYERS_COUNT];
#endif // ifndef GERBVIEW_H

View File

@ -38,14 +38,13 @@
#include <colors_selection.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <hotkeys.h>
#include <dialog_hotkeys_editor.h>
#define GROUP wxT("/gerbview")
#define INSETUP true
void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event )
{

View File

@ -27,7 +27,6 @@
*/
#include <fctsys.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <wxstruct.h>
#include <class_drawpanel.h>
@ -40,6 +39,7 @@
#include <msgpanel.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <pcbplot.h>
#include <gerbview_id.h>
@ -92,7 +92,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
SetLayout( new GBR_LAYOUT() );
SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.
SetVisibleLayers( -1 ); // All draw layers visible.
SetScreen( new GBR_SCREEN( GetGerberLayout()->GetPageSettings().GetSizeIU() ) );
@ -167,6 +167,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
m_auimgr.Update();
setActiveLayer( 0, true );
Zoom_Automatique( true ); // Gives a default zoom value
}
@ -184,9 +185,9 @@ void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
const unsigned limit = std::min( unsigned( aFileSet.size() ), unsigned( NB_GERBER_LAYERS ) );
const unsigned limit = std::min( unsigned( aFileSet.size() ), unsigned( GERBER_DRAWLAYERS_COUNT ) );
LAYER_NUM layer = FIRST_LAYER;
int layer = 0;
for( unsigned i=0; i<limit; ++i, ++layer )
{
@ -338,11 +339,11 @@ void GERBVIEW_FRAME::SetElementVisibility( GERBER_VISIBLE_ID aItemIdVisible,
}
LAYER_NUM GERBVIEW_FRAME::getNextAvailableLayer( LAYER_NUM aLayer ) const
int GERBVIEW_FRAME::getNextAvailableLayer( int aLayer ) const
{
LAYER_NUM layer = aLayer;
int layer = aLayer;
for( LAYER_NUM i = FIRST_LAYER; i < NB_GERBER_LAYERS; ++i )
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; ++i )
{
GERBER_IMAGE* gerber = g_GERBER_List[ layer ];
@ -351,8 +352,8 @@ LAYER_NUM GERBVIEW_FRAME::getNextAvailableLayer( LAYER_NUM aLayer ) const
++layer;
if( layer >= NB_GERBER_LAYERS )
layer = FIRST_LAYER;
if( layer >= GERBER_DRAWLAYERS_COUNT )
layer = 0;
}
return NO_AVAILABLE_LAYERS;
@ -398,9 +399,9 @@ void GERBVIEW_FRAME::Liste_D_Codes()
wxArrayString list;
double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 :
IU_PER_MM;
LAYER_NUM curr_layer = getActiveLayer();
int curr_layer = getActiveLayer();
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
{
GERBER_IMAGE* gerber = g_GERBER_List[layer];
@ -551,9 +552,9 @@ void GERBVIEW_FRAME::SetVisibleAlls()
* Returns a bit-mask of all the layers that are visible
* @return int - the visible layers in bit-mapped form.
*/
LAYER_MSK GERBVIEW_FRAME::GetVisibleLayers() const
long GERBVIEW_FRAME::GetVisibleLayers() const
{
return FULL_LAYERS; // TODO
return -1; // TODO
}
@ -563,9 +564,9 @@ LAYER_MSK GERBVIEW_FRAME::GetVisibleLayers() const
* changes the bit-mask of visible layers
* @param aLayerMask = The new bit-mask of visible layers
*/
void GERBVIEW_FRAME::SetVisibleLayers( LAYER_MSK aLayerMask )
void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask )
{
GetGerberLayout()->SetVisibleLayers( aLayerMask );
// GetGerberLayout()->SetVisibleLayers( aLayerMask );
}
@ -575,12 +576,12 @@ void GERBVIEW_FRAME::SetVisibleLayers( LAYER_MSK aLayerMask )
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
*/
bool GERBVIEW_FRAME::IsLayerVisible( LAYER_NUM aLayer ) const
bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
{
if( ! m_DisplayOptions.m_IsPrinting )
return m_LayersManager->IsLayerVisible( aLayer );
else
return GetGerberLayout()->IsLayerVisible( aLayer );
return GetGerberLayout()->IsLayerPrintable( aLayer );
}
@ -664,7 +665,7 @@ EDA_COLOR_T GERBVIEW_FRAME::GetNegativeItemsColor() const
* Function GetLayerColor
* gets a layer color for any valid layer.
*/
EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( LAYER_NUM aLayer ) const
EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
{
return m_colorsSettings->GetLayerColor( aLayer );
}
@ -674,7 +675,7 @@ EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( LAYER_NUM aLayer ) const
* Function SetLayerColor
* changes a layer color for any valid layer.
*/
void GERBVIEW_FRAME::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
void GERBVIEW_FRAME::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
{
m_colorsSettings->SetLayerColor( aLayer, aColor );
}
@ -684,7 +685,7 @@ void GERBVIEW_FRAME::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
* Function getActiveLayer
* returns the active layer
*/
LAYER_NUM GERBVIEW_FRAME::getActiveLayer()
int GERBVIEW_FRAME::getActiveLayer()
{
return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
}
@ -695,7 +696,7 @@ LAYER_NUM GERBVIEW_FRAME::getActiveLayer()
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
void GERBVIEW_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate )
void GERBVIEW_FRAME::setActiveLayer( int aLayer, bool doLayerWidgetUpdate )
{
( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;

View File

@ -37,7 +37,6 @@
#include <gerbview.h>
#include <class_gbr_layout.h>
#include <class_gbr_screen.h>
#include <layers_id_colors_and_visibility.h>
#define NO_AVAILABLE_LAYERS UNDEFINED_LAYER
@ -167,7 +166,7 @@ public:
* different radiobutton is clicked on) prior to then clicking on the "Deselect"
* button provided within the "Layer selection:" dialog box).
*/
LAYER_NUM SelectPCBLayer( LAYER_NUM aDefaultLayer, int aOpperLayerCount, bool aNullLayer = false );
int SelectPCBLayer( int aDefaultLayer, int aOpperLayerCount, bool aNullLayer = false );
protected:
GERBER_LAYER_WIDGET* m_LayersManager;
@ -306,9 +305,9 @@ public:
* Function GetVisibleLayers
* is a proxy function that calls the correspondent function in m_BoardSettings
* Returns a bit-mask of all the layers that are visible
* @return int - the visible layers in bit-mapped form.
* @return long - the visible layers in bit-mapped form.
*/
LAYER_MSK GetVisibleLayers() const;
long GetVisibleLayers() const;
/**
* Function SetVisibleLayers
@ -316,7 +315,7 @@ public:
* changes the bit-mask of visible layers
* @param aLayerMask = The new bit-mask of visible layers
*/
void SetVisibleLayers( LAYER_MSK aLayerMask );
void SetVisibleLayers( long aLayerMask );
/**
* Function IsLayerVisible
@ -324,7 +323,7 @@ public:
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
*/
bool IsLayerVisible( LAYER_NUM aLayer ) const;
bool IsLayerVisible( int aLayer ) const;
/**
* Function GetVisibleElementColor
@ -338,13 +337,13 @@ public:
* Function GetLayerColor
* gets a layer color for any valid layer.
*/
EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
EDA_COLOR_T GetLayerColor( int aLayer ) const;
/**
* Function SetLayerColor
* changes a layer color for any valid layer.
*/
void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
void SetLayerColor( int aLayer, EDA_COLOR_T aColor );
/**
* Function GetNegativeItemsColor
@ -396,13 +395,13 @@ public:
* will change the currently active layer to \a aLayer and also
* update the GERBER_LAYER_WIDGET.
*/
void setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true );
void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true );
/**
* Function getActiveLayer
* returns the active layer
*/
LAYER_NUM getActiveLayer();
int getActiveLayer();
/**
* Function getNextAvailableLayer
@ -411,7 +410,7 @@ public:
* @param aLayer The first layer to search.
* @return The first empty layer found or NO_AVAILABLE_LAYERS.
*/
LAYER_NUM getNextAvailableLayer( LAYER_NUM aLayer = FIRST_LAYER ) const;
int getNextAvailableLayer( int aLayer = 0 ) const;
bool hasAvailableLayers() const
{
@ -667,7 +666,7 @@ public:
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer, bool aPrintMirrorMode,
virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode,
void* aData = NULL );
/**

View File

@ -8,6 +8,7 @@
#include <id.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_drawpanel.h>
#include <hotkeys.h>

View File

@ -32,6 +32,7 @@
#include <confirm.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <class_gerbview_layer_widget.h>
@ -39,7 +40,7 @@
bool GERBVIEW_FRAME::Clear_Pcb( bool query )
{
LAYER_NUM layer;
int layer;
if( GetGerberLayout() == NULL )
return false;
@ -52,7 +53,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
GetGerberLayout()->m_Drawings.DeleteAll();
for( layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer )
for( layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
{
if( g_GERBER_List[layer] )
{
@ -65,7 +66,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
setActiveLayer( FIRST_LAYER );
setActiveLayer( 0 );
m_LayersManager->UpdateLayerIcons();
syncLayerBox();
return true;
@ -74,7 +75,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
void GERBVIEW_FRAME::Erase_Current_Layer( bool query )
{
LAYER_NUM layer = getActiveLayer();
int layer = getActiveLayer();
wxString msg;
msg.Printf( _( "Clear layer %d?" ), layer + 1 );

View File

@ -31,6 +31,7 @@
#include <msgpanel.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
@ -46,7 +47,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
if( aTypeloc == CURSEUR_ON_GRILLE )
ref = GetNearestGridPosition( ref );
LAYER_NUM layer = getActiveLayer();
int layer = getActiveLayer();
// Search first on active layer
GERBER_DRAW_ITEM* gerb_item = GetItemsList();

View File

@ -32,6 +32,7 @@
#include <pgm_base.h>
#include <kiface_i.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <hotkeys.h>
#include <menus_helpers.h>

View File

@ -7,6 +7,7 @@
#include <common.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <class_GERBER.h>
#include <dialog_helpers.h>

View File

@ -8,6 +8,7 @@
#include <id.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <menus_helpers.h>

View File

@ -6,6 +6,7 @@
#include <common.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <pcbplot.h>
/** TODO */

View File

@ -8,6 +8,7 @@
#include <kicad_string.h>
#include <gestfich.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <html_messagebox.h>
@ -25,7 +26,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
wxString msg;
char* text;
LAYER_NUM layer; // current layer used in GerbView
int layer; // current layer used in GerbView
layer = getActiveLayer();

View File

@ -30,6 +30,7 @@
#include <common.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <trigo.h>
#include <macros.h>
#include <class_gerber_draw_item.h>
@ -107,7 +108,7 @@
void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
APERTURE_T aAperture,
int Dcode_index,
LAYER_NUM aLayer,
int aLayer,
const wxPoint& aPos,
wxSize aSize,
bool aLayerNegative )
@ -159,7 +160,7 @@ void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
*/
void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
int Dcode_index,
LAYER_NUM aLayer,
int aLayer,
const wxPoint& aStart,
const wxPoint& aEnd,
wxSize aPenSize,
@ -208,7 +209,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, LAYER_NUM aLayer,
static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aLayer,
const wxPoint& aStart, const wxPoint& aEnd,
const wxPoint& aRelCenter, wxSize aPenSize,
bool aClockwise, bool aMultiquadrant,
@ -344,10 +345,11 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem,
* so we muse create a dummy track and use its geometric parameters
*/
static GERBER_DRAW_ITEM dummyGbrItem( NULL, NULL );
static const int drawlayer = 0;
aGbrItem->SetLayerPolarity( aLayerNegative );
fillArcGBRITEM( &dummyGbrItem, 0, FIRST_LAYER,
fillArcGBRITEM( &dummyGbrItem, 0, drawlayer,
aStart, aEnd, rel_center, wxSize(0, 0),
aClockwise, aMultiquadrant, aLayerNegative );
@ -568,7 +570,7 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
GERBER_DRAW_ITEM* gbritem;
GBR_LAYOUT* layout = m_Parent->GetGerberLayout();
LAYER_NUM activeLayer = m_Parent->getActiveLayer();
int activeLayer = m_Parent->getActiveLayer();
int dcode = 0;
D_CODE* tool = NULL;

View File

@ -12,6 +12,7 @@
extern int ReadInt( char*& text, bool aSkipSeparator = true );
extern double ReadDouble( char*& text, bool aSkipSeparator = true );
extern bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file );
#define CODE( x, y ) ( ( (x) << 8 ) + (y) )

View File

@ -27,9 +27,9 @@
*/
#include <fctsys.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <class_GERBER.h>
@ -41,7 +41,7 @@ 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 + NB_GERBER_LAYERS
ID_TEXT_0 = ID_BUTTON_0 + GERBER_DRAWLAYERS_COUNT
};
@ -55,7 +55,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 + NB_GERBER_LAYERS-1,
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + GERBER_DRAWLAYERS_COUNT-1,
wxEVT_COMMAND_BUTTON_CLICKED,
LAYERS_MAP_DIALOG::OnSelectLayer )
END_EVENT_TABLE()
@ -102,8 +102,7 @@ void LAYERS_MAP_DIALOG::initDialog()
// version are also 26 pixels wide and 26 pixels high. If appropriate,
// the above code should be modified as required in the event that those
// buttons should be some other size in that version.
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
// Specify the default value for each member of these arrays.
m_buttonTable[ii] = -1;
@ -111,32 +110,31 @@ void LAYERS_MAP_DIALOG::initDialog()
}
// Ensure we have:
// at least 2 copper layers and BOARD_COPPER_LAYERS_MAX_COUNT copper layers max
// at least 2 copper layers and less than max pacb copper layers count
// and even layers count because a board *must* have even layers count
// and maxi BOARD_COPPER_LAYERS_MAX_COUNT copper layers count
normalizeBrdLayersCount();
int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
m_comboCopperLayersCount->SetSelection( idx );
LAYER_NUM pcb_layer_num = FIRST_LAYER;
m_itemsCount = 0;
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
LAYER_NUM pcb_layer_num = 0;
m_gerberActiveLayersCount = 0;
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
if( g_GERBER_List[ii] == NULL )
continue;
break;
if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1)
&& (m_exportBoardCopperLayersCount > 1) )
pcb_layer_num = LAYER_N_FRONT;
pcb_layer_num = F_Cu;
m_buttonTable[m_itemsCount] = ii;
m_buttonTable[m_gerberActiveLayersCount] = ii;
m_layersLookUpTable[ii] = pcb_layer_num;
m_itemsCount++;
m_gerberActiveLayersCount++;
++pcb_layer_num;
}
if( m_itemsCount <= NB_GERBER_LAYERS/2 ) // Only one list is enough
if( m_gerberActiveLayersCount <= GERBER_DRAWLAYERS_COUNT/2 ) // Only one list is enough
{
m_staticlineSep->Hide();
}
@ -151,7 +149,7 @@ void LAYERS_MAP_DIALOG::initDialog()
}
wxFlexGridSizer* flexColumnBoxSizer = m_flexLeftColumnBoxSizer;
for( int ii = 0; ii < m_itemsCount; ii++ )
for( int ii = 0; ii < m_gerberActiveLayersCount; ii++ )
{
// Each Gerber layer has an associated static text string (to
// identify that layer), a button (for invoking a child dialog
@ -178,7 +176,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 == NB_GERBER_LAYERS/2 )
if( ii == GERBER_DRAWLAYERS_COUNT/2 )
flexColumnBoxSizer = m_flexRightColumnBoxSizer;
// Provide a text string to identify the Gerber layer
@ -226,7 +224,7 @@ void LAYERS_MAP_DIALOG::initDialog()
wxDefaultSize, 0 );
goodSize = text->GetSize();
for( LAYER_NUM jj = FIRST_LAYER; jj < NB_LAYERS; ++jj )
for( LAYER_NUM jj = 0; jj < GERBER_DRAWLAYERS_COUNT; ++jj )
{
text->SetLabel( GetPCBDefaultLayerName( jj ) );
if( goodSize.x < text->GetSize().x )
@ -259,8 +257,8 @@ void LAYERS_MAP_DIALOG::normalizeBrdLayersCount()
if( ( m_exportBoardCopperLayersCount & 1 ) )
m_exportBoardCopperLayersCount++;
if( m_exportBoardCopperLayersCount > NB_LAYERS )
m_exportBoardCopperLayersCount = NB_LAYERS;
if( m_exportBoardCopperLayersCount > GERBER_DRAWLAYERS_COUNT )
m_exportBoardCopperLayersCount = GERBER_DRAWLAYERS_COUNT;
if( m_exportBoardCopperLayersCount < 2 )
m_exportBoardCopperLayersCount = 2;
@ -284,11 +282,11 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
wxString msg;
int ii;
LAYER_NUM layer;
for( ii = 0, layer = FIRST_LAYER; ii < m_itemsCount; ii++, ++layer )
for( ii = 0, layer = 0; ii < m_gerberActiveLayersCount; ii++, ++layer )
{
if( (layer == m_exportBoardCopperLayersCount - 1)
&& (m_exportBoardCopperLayersCount > 1) )
layer = LAYER_N_FRONT;
layer = F_Cu;
m_layersLookUpTable[ii] = layer;
msg = GetPCBDefaultLayerName( layer );
m_layersList[ii]->SetLabel( msg );
@ -306,7 +304,7 @@ void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
config->Write( wxT("BrdLayersCount"), m_exportBoardCopperLayersCount );
wxString key;
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
config->Write( key, m_layersLookUpTable[ii] );
@ -324,7 +322,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
m_comboCopperLayersCount->SetSelection( idx );
wxString key;
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
int ilayer;
@ -332,7 +330,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
m_layersLookUpTable[ii] = ilayer;
}
for( int ii = 0; ii < m_itemsCount; ii++ )
for( int ii = 0; ii < m_gerberActiveLayersCount; ii++ )
{
LAYER_NUM layer = m_layersLookUpTable[ii];
if( layer == UNSELECTED_LAYER )
@ -354,7 +352,7 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
ii = event.GetId() - ID_BUTTON_0;
if( (ii < FIRST_LAYER) || (ii >= NB_GERBER_LAYERS) )
if( (ii < 0) || (ii >= GERBER_DRAWLAYERS_COUNT) )
{
wxFAIL_MSG( wxT("Bad layer id") );
return;
@ -362,7 +360,7 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
LAYER_NUM jj = m_layersLookUpTable[m_buttonTable[ii]];
if( !IsValidLayer( jj ) )
jj = LAYER_N_BACK; // (Defaults to "Copper" layer.)
jj = B_Cu; // (Defaults to "Copper" layer.)
jj = m_Parent->SelectPCBLayer( jj, m_exportBoardCopperLayersCount, true );
@ -406,9 +404,9 @@ void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
normalizeBrdLayersCount();
int inner_layer_max = 0;
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
if( m_layersLookUpTable[ii] < LAYER_N_FRONT )
if( m_layersLookUpTable[ii] < F_Cu )
{
if( m_layersLookUpTable[ii ] > inner_layer_max )
inner_layer_max = m_layersLookUpTable[ii];

View File

@ -6,24 +6,23 @@
#define _SELECT_LAYERS_TO_PCB_H_
#include <dialogs/dialog_layers_select_to_pcb_base.h>
#include <layers_id_colors_and_visibility.h>
/*
* This dialog shows the gerber files loaded, and allows user to choose
* equivalence tbetween gerber layers and pcb layers
* equivalence between gerber layers and pcb layers
*/
class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE
{
private:
GERBVIEW_FRAME* m_Parent;
int m_itemsCount;
int m_gerberActiveLayersCount; // Number of initialized gerber layers
static int m_exportBoardCopperLayersCount;
wxFlexGridSizer* m_flexRightColumnBoxSizer; // An extra wxFlexGridSizer used
// when we have more than 16 gerber files loaded
LAYER_NUM m_layersLookUpTable[NB_GERBER_LAYERS]; // Indexes Gerber layers to PCB file layers
LAYER_NUM m_layersLookUpTable[GERBER_DRAWLAYERS_COUNT]; // Indexes Gerber layers to PCB file layers
// the last value in table is the number of copper layers
int m_buttonTable[int(NB_GERBER_LAYERS)+1]; // Indexes buttons to Gerber layers
wxStaticText* m_layersList[int(NB_GERBER_LAYERS)+1]; // Indexes text strings to buttons
int m_buttonTable[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes buttons to Gerber layers
wxStaticText* m_layersList[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes text strings to buttons
public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent );
~LAYERS_MAP_DIALOG() {};

View File

@ -33,6 +33,7 @@
#include <common.h>
#include <macros.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <bitmaps.h>
#include <gerbview_id.h>
#include <hotkeys.h>
@ -292,7 +293,7 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
{
LAYER_NUM layer = getActiveLayer();
int layer = getActiveLayer();
GERBER_IMAGE* gerber = g_GERBER_List[layer];
int selected = ( gerber ) ? gerber->m_Selected_Tool : 0;

View File

@ -47,6 +47,7 @@ struct VIA_DIMENSION
}
};
/**
* Class BOARD_DESIGN_SETTINGS
* contains design settings for a BOARD object.
@ -326,7 +327,7 @@ public:
* returns a bit-mask of all the layers that are visible
* @return int - the visible layers in bit-mapped form.
*/
inline LAYER_MSK GetVisibleLayers() const
inline LSET GetVisibleLayers() const
{
return m_visibleLayers;
}
@ -343,30 +344,30 @@ public:
* changes the bit-mask of visible layers
* @param aMask = The new bit-mask of visible layers
*/
inline void SetVisibleLayers( LAYER_MSK aMask )
inline void SetVisibleLayers( LSET aMask )
{
m_visibleLayers = aMask & m_enabledLayers & FULL_LAYERS;
m_visibleLayers = aMask & m_enabledLayers;
}
/**
* Function IsLayerVisible
* tests whether a given layer is visible
* @param aLayer = The layer to be tested
* @param aLayerId = The layer to be tested
* @return bool - true if the layer is visible.
*/
inline bool IsLayerVisible( LAYER_NUM aLayer ) const
inline bool IsLayerVisible( LAYER_ID aLayerId ) const
{
// If a layer is disabled, it is automatically invisible
return m_visibleLayers & m_enabledLayers & GetLayerMask( aLayer );
return (m_visibleLayers & m_enabledLayers)[aLayerId];
}
/**
* Function SetLayerVisibility
* changes the visibility of a given layer
* @param aLayer = The layer to be changed
* @param aLayerId = The layer to be changed
* @param aNewState = The new visibility state of the layer
*/
void SetLayerVisibility( LAYER_NUM aLayer, bool aNewState );
void SetLayerVisibility( LAYER_ID aLayerId, bool aNewState );
/**
* Function GetVisibleElements
@ -417,7 +418,7 @@ public:
* returns a bit-mask of all the layers that are enabled
* @return int - the enabled layers in bit-mapped form.
*/
inline LAYER_MSK GetEnabledLayers() const
inline LSET GetEnabledLayers() const
{
return m_enabledLayers;
}
@ -427,17 +428,17 @@ public:
* changes the bit-mask of enabled layers
* @param aMask = The new bit-mask of enabled layers
*/
void SetEnabledLayers( LAYER_MSK aMask );
void SetEnabledLayers( LSET aMask );
/**
* Function IsLayerEnabled
* tests whether a given layer is enabled
* @param aLayer = The of the layer to be tested
* @param aLayerId = The layer to be tested
* @return bool - true if the layer is enabled
*/
inline bool IsLayerEnabled( LAYER_NUM aLayer ) const
inline bool IsLayerEnabled( LAYER_ID aLayerId ) const
{
return m_enabledLayers & GetLayerMask( aLayer );
return m_enabledLayers[aLayerId];
}
/**
@ -485,11 +486,13 @@ private:
///> Custom via size (used after UseCustomTrackViaSize( true ) was called).
VIA_DIMENSION m_customViaSize;
int m_copperLayerCount; ///< Number of copper layers for this design
LAYER_MSK m_enabledLayers; ///< Bit-mask for layer enabling
LAYER_MSK m_visibleLayers; ///< Bit-mask for layer visibility
int m_visibleElements; ///< Bit-mask for element category visibility
int m_boardThickness; ///< Board thickness for 3D viewer
int m_copperLayerCount; ///< Number of copper layers for this design
LSET m_enabledLayers; ///< Bit-mask for layer enabling
LSET m_visibleLayers; ///< Bit-mask for layer visibility
int m_visibleElements; ///< Bit-mask for element category visibility
int m_boardThickness; ///< Board thickness for 3D viewer
/// Current net class name used to display netclass info.
/// This is also the last used netclass after starting a track.

View File

@ -76,12 +76,12 @@ class BOARD_ITEM : public EDA_ITEM
void SetBack( EDA_ITEM* aBack ) { Pback = aBack; }
protected:
LAYER_NUM m_Layer;
LAYER_ID m_Layer;
public:
BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
EDA_ITEM( aParent, idtype ), m_Layer( FIRST_LAYER )
EDA_ITEM( aParent, idtype ), m_Layer( F_Cu )
{
}
@ -114,7 +114,7 @@ public:
* Function GetLayer
* returns the layer this item is on.
*/
LAYER_NUM GetLayer() const { return m_Layer; }
LAYER_ID GetLayer() const { return m_Layer; }
/**
* Function SetLayer
@ -123,7 +123,7 @@ public:
* is virtual because some items (in fact: class DIMENSION)
* have a slightly different initialization
*/
virtual void SetLayer( LAYER_NUM aLayer )
virtual void SetLayer( LAYER_ID aLayer )
{
// trap any invalid layers, then go find the caller and fix it.
// wxASSERT( unsigned( aLayer ) < unsigned( NB_PCB_LAYERS ) );
@ -156,7 +156,7 @@ public:
* @param aLayer The layer to test for.
* @return bool - true if on given layer, else false.
*/
virtual bool IsOnLayer( LAYER_NUM aLayer ) const
virtual bool IsOnLayer( LAYER_ID aLayer ) const
{
return m_Layer == aLayer;
}

View File

@ -7,8 +7,6 @@
#define _COLORS_DESIGN_SETTING_H
#include <layers_id_colors_and_visibility.h>
#define LAYERSCOLORSBUFFERSIZE NB_LAYERS
#define ITEMSCOLORSBUFFERSIZE 32
/**
* Class COLORS_DESIGN_SETTINGS
@ -20,10 +18,10 @@ public:
// Color options for screen display of the Printed Board and schematic:
// Common to Eeschema, Pcbnew, GerbView
EDA_COLOR_T m_LayersColors[LAYERSCOLORSBUFFERSIZE]; ///< Layer colors (tracks and graphic items)
EDA_COLOR_T m_LayersColors[LAYER_ID_COUNT]; ///< Layer colors (tracks and graphic items)
// Common to Eeschema, Pcbnew
EDA_COLOR_T m_ItemsColors[ITEMSCOLORSBUFFERSIZE]; ///< All others items but layers
EDA_COLOR_T m_ItemsColors[32]; ///< All others items but layers
public:
COLORS_DESIGN_SETTINGS();

View File

@ -15,7 +15,6 @@ class LAYER_SELECTOR
{
protected:
bool m_layerhotkeys;
bool m_layerorder;
public:
// Hotkey Info
@ -36,17 +35,18 @@ public:
// Virtual function pure because GerbView uses its own functions in a derived class
virtual bool IsLayerEnabled( LAYER_NUM aLayer ) const = 0;
bool SetLayersOrdered(bool value);
bool SetLayersHotkeys(bool value);
bool SetLayersOrdered( bool value );
bool SetLayersHotkeys( bool value );
protected:
// Fills the layer bitmap aLayerbmp with the layer color
void SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer );
};
/* class to display a layer list in a wxBitmapComboBox.
*/
class LAYER_BOX_SELECTOR :public wxBitmapComboBox, public LAYER_SELECTOR
class LAYER_BOX_SELECTOR : public wxBitmapComboBox, public LAYER_SELECTOR
{
public:
// Hotkey Info
@ -69,7 +69,7 @@ public:
LAYER_NUM GetLayerSelection() const;
// Set Layer #
int SetLayerSelection(LAYER_NUM layer);
int SetLayerSelection( LAYER_NUM layer );
// Reload the Layers
// Virtual pure function because GerbView uses its own functions in a derived class
@ -79,23 +79,4 @@ public:
void ResyncBitmapOnly();
};
#define DECLARE_LAYERS_HOTKEY(list) int list[NB_LAYERS] = \
{ \
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_LAYER_BOX_SELECTOR_H
#endif // CLASS_LAYER_BOX_SELECTOR_H

View File

@ -17,9 +17,9 @@ class UNDO_REDO_CONTAINER;
class PCB_SCREEN : public BASE_SCREEN
{
public:
LAYER_NUM m_Active_Layer;
LAYER_NUM m_Route_Layer_TOP;
LAYER_NUM m_Route_Layer_BOTTOM;
LAYER_ID m_Active_Layer;
LAYER_ID m_Route_Layer_TOP;
LAYER_ID m_Route_Layer_BOTTOM;
public:

View File

@ -89,13 +89,14 @@ enum paramcfg_id {
class PARAM_CFG_BASE
{
public:
const wxChar* m_Ident; ///< Keyword in config data
paramcfg_id m_Type; ///< Type of parameter
const wxChar* m_Group; ///< Group name (this is like a path in the config data)
bool m_Setup; ///< Install or Project based parameter, true == install
wxString m_Ident; ///< Keyword in config data
paramcfg_id m_Type; ///< Type of parameter
wxString m_Group; ///< Group name (this is like a path in the config data)
bool m_Setup; ///< Install or Project based parameter, true == install
public:
PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL );
PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type,
const wxChar* group = NULL );
virtual ~PARAM_CFG_BASE() {}
/**
@ -126,12 +127,12 @@ public:
int m_Default; ///< The default value of the parameter
public:
PARAM_CFG_INT( const wxChar* ident, int* ptparam,
PARAM_CFG_INT( const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
const wxChar* group = NULL );
PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
@ -154,13 +155,13 @@ public:
double m_BIU_to_cfgunit; ///< the factor to convert the saved value in internal value
public:
PARAM_CFG_INT_WITH_SCALE( const wxChar* ident, int* ptparam,
PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
const wxChar* group = NULL,
double aBiu2cfgunit = 1.0);
PARAM_CFG_INT_WITH_SCALE( bool Insetup, const wxChar* ident, int* ptparam,
PARAM_CFG_INT_WITH_SCALE( bool Insetup, const wxString& ident, int* ptparam,
int default_val = 0,
int min = std::numeric_limits<int>::min(),
int max = std::numeric_limits<int>::max(),
@ -183,9 +184,9 @@ public:
EDA_COLOR_T m_Default; ///< The default value of the parameter
public:
PARAM_CFG_SETCOLOR( const wxChar* ident, EDA_COLOR_T* ptparam,
PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val, const wxChar* group = NULL );
PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, EDA_COLOR_T* ptparam,
PARAM_CFG_SETCOLOR( bool Insetup, const wxString& ident, EDA_COLOR_T* ptparam,
EDA_COLOR_T default_val, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
@ -205,10 +206,10 @@ public:
double m_Min, m_Max; ///< Minimum and maximum values of the param type
public:
PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
double default_val = 0.0, double min = 0.0, double max = 10000.0,
const wxChar* group = NULL );
PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam,
PARAM_CFG_DOUBLE( bool Insetup, const wxString& ident, double* ptparam,
double default_val = 0.0, double min = 0.0, double max = 10000.0,
const wxChar* group = NULL );
@ -228,9 +229,9 @@ public:
int m_Default; ///< The default value of the parameter
public:
PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
int default_val = false, const wxChar* group = NULL );
PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
int default_val = false, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
@ -242,19 +243,20 @@ public:
* Configuration parameter - wxString Class
*
*/
class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE
class PARAM_CFG_WXSTRING : public PARAM_CFG_BASE
{
public:
wxString* m_Pt_param; ///< Pointer to the parameter value
wxString m_default; ///< The default value of the parameter
public:
PARAM_CFG_WXSTRING( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group = NULL );
PARAM_CFG_WXSTRING( bool Insetup,
const wxChar* ident,
const wxString& ident,
wxString* ptparam,
const wxString& default_val = wxEmptyString,
const wxChar* group = NULL );
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
@ -273,7 +275,8 @@ public:
wxString* m_Pt_param; ///< Pointer to the parameter value
public:
PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam,
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};

View File

@ -636,7 +636,7 @@ public:
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMask, bool aPrintMirrorMode, void* aData = NULL );
virtual void PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData = NULL );
/**
* Function CoordinateToString

View File

@ -88,6 +88,8 @@ typedef int wxPenStyle;
extern GR_DRAWMODE g_XorMode;
extern EDA_COLOR_T g_DrawBgColor;
typedef enum {

View File

@ -27,188 +27,364 @@
* @brief Board layer functions and definitions.
*/
#ifndef _LAYERS_ID_AND_VISIBILITY_H_
#define _LAYERS_ID_AND_VISIBILITY_H_
#ifndef LAYERS_ID_AND_VISIBILITY_H_
#define LAYERS_ID_AND_VISIBILITY_H_
#include <stdint.h>
#include <vector>
#include <bitset>
#include <wx/string.h>
#include <macros.h>
class BOARD;
/* 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 FIRST_LAYER 0
#define FIRST_COPPER_LAYER 0
#define LAYER_N_BACK 0
#define LAYER_N_2 1
#define LAYER_N_3 2
#define LAYER_N_4 3
#define LAYER_N_5 4
#define LAYER_N_6 5
#define LAYER_N_7 6
#define LAYER_N_8 7
#define LAYER_N_9 8
#define LAYER_N_10 9
#define LAYER_N_11 10
#define LAYER_N_12 11
#define LAYER_N_13 12
#define LAYER_N_14 13
#define LAYER_N_15 14
#define LAYER_N_FRONT 15
#define LAST_COPPER_LAYER LAYER_N_FRONT
#define NB_COPPER_LAYERS (LAST_COPPER_LAYER - FIRST_COPPER_LAYER + 1)
#define FIRST_NON_COPPER_LAYER 16
#define FIRST_TECHNICAL_LAYER 16
#define FIRST_USER_LAYER 24
#define ADHESIVE_N_BACK 16
#define ADHESIVE_N_FRONT 17
#define SOLDERPASTE_N_BACK 18
#define SOLDERPASTE_N_FRONT 19
#define SILKSCREEN_N_BACK 20
#define SILKSCREEN_N_FRONT 21
#define SOLDERMASK_N_BACK 22
#define SOLDERMASK_N_FRONT 23
#define DRAW_N 24
#define COMMENT_N 25
#define ECO1_N 26
#define ECO2_N 27
#define EDGE_N 28
#define LAST_NON_COPPER_LAYER 28
#define LAST_TECHNICAL_LAYER 23
#define LAST_USER_LAYER 27
#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_GERBER_LAYERS 32
#define NB_LAYERS 32
#define UNSELECTED_LAYER 32
// Masks to identify a layer by a bit map
typedef unsigned LAYER_MSK;
#define LAYER_BACK (1 << LAYER_N_BACK) ///< bit mask for copper layer
#define LAYER_2 (1 << LAYER_N_2) ///< bit mask for layer 2
#define LAYER_3 (1 << LAYER_N_3) ///< bit mask for layer 3
#define LAYER_4 (1 << LAYER_N_4) ///< bit mask for layer 4
#define LAYER_5 (1 << LAYER_N_5) ///< bit mask for layer 5
#define LAYER_6 (1 << LAYER_N_6) ///< bit mask for layer 6
#define LAYER_7 (1 << LAYER_N_7) ///< bit mask for layer 7
#define LAYER_8 (1 << LAYER_N_8) ///< bit mask for layer 8
#define LAYER_9 (1 << LAYER_N_9) ///< bit mask for layer 9
#define LAYER_10 (1 << LAYER_N_10) ///< bit mask for layer 10
#define LAYER_11 (1 << LAYER_N_11) ///< bit mask for layer 11
#define LAYER_12 (1 << LAYER_N_12) ///< bit mask for layer 12
#define LAYER_13 (1 << LAYER_N_13) ///< bit mask for layer 13
#define LAYER_14 (1 << LAYER_N_14) ///< bit mask for layer 14
#define LAYER_15 (1 << LAYER_N_15) ///< bit mask for layer 15
#define LAYER_FRONT (1 << LAYER_N_FRONT) ///< bit mask for component layer
#define ADHESIVE_LAYER_BACK (1 << ADHESIVE_N_BACK)
#define ADHESIVE_LAYER_FRONT (1 << ADHESIVE_N_FRONT)
#define SOLDERPASTE_LAYER_BACK (1 << SOLDERPASTE_N_BACK)
#define SOLDERPASTE_LAYER_FRONT (1 << SOLDERPASTE_N_FRONT)
#define SILKSCREEN_LAYER_BACK (1 << SILKSCREEN_N_BACK)
#define SILKSCREEN_LAYER_FRONT (1 << SILKSCREEN_N_FRONT)
#define SOLDERMASK_LAYER_BACK (1 << SOLDERMASK_N_BACK)
#define SOLDERMASK_LAYER_FRONT (1 << SOLDERMASK_N_FRONT)
#define DRAW_LAYER (1 << DRAW_N)
#define COMMENT_LAYER (1 << COMMENT_N)
#define ECO1_LAYER (1 << ECO1_N)
#define ECO2_LAYER (1 << ECO2_N)
#define EDGE_LAYER (1 << EDGE_N)
// extra bits 0xE0000000
// Helpful global layer masks:
// ALL_AUX_LAYERS layers are technical layers, ALL_NO_CU_LAYERS has user
// and edge layers too!
#define ALL_LAYERS 0x1FFFFFFF // Pcbnew used 29 layers
#define FULL_LAYERS 0xFFFFFFFF // Gerbview used 32 layers
#define ALL_NO_CU_LAYERS 0x1FFF0000
#define ALL_CU_LAYERS 0x0000FFFF
#define INTERNAL_CU_LAYERS 0x00007FFE
#define EXTERNAL_CU_LAYERS 0x00008001
#define FRONT_TECH_LAYERS (SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT \
| ADHESIVE_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT)
#define BACK_TECH_LAYERS (SILKSCREEN_LAYER_BACK | SOLDERMASK_LAYER_BACK \
| ADHESIVE_LAYER_BACK | SOLDERPASTE_LAYER_BACK)
#define ALL_TECH_LAYERS (FRONT_TECH_LAYERS | BACK_TECH_LAYERS)
#define BACK_LAYERS (LAYER_BACK | BACK_TECH_LAYERS)
#define FRONT_LAYERS (LAYER_FRONT | FRONT_TECH_LAYERS)
#define ALL_USER_LAYERS (DRAW_LAYER | COMMENT_LAYER |\
ECO1_LAYER | ECO2_LAYER )
#define NO_LAYERS 0x00000000
/**
* @return a one bit layer mask from a layer number
* @param aLayerNumber = the layer number to convert (0 .. LAYERS-1)
* Type LAYER_NUM
* can be replaced with int and removed. Until then, it is something you can increment,
* and its meaning is only advisory but can extend beyond PCB layers into view layers
* and gerber layers.
*/
inline LAYER_MSK GetLayerMask( LAYER_NUM aLayerNumber )
{
return 1 << aLayerNumber;
}
typedef int LAYER_NUM;
/**
* @return bool if aLayerNumber is a layer contained in aMask
* @param aMask = a layer mask
* @param aLayerNumber is the layer id to test
* Enum LAYER_ID
* is the set of PCB layers. It has nothing to do with gerbers or view layers.
* One of these cannot be "incremented".
*/
inline bool IsLayerInList( LAYER_MSK aMask, LAYER_NUM aLayerNumber )
enum LAYER_ID
#if __cplusplus >= 201103L
: unsigned char
#endif
{
return (aMask & GetLayerMask( aLayerNumber )) != 0;
}
F_Cu, // 0
In1_Cu,
In2_Cu,
In3_Cu,
In4_Cu,
In5_Cu,
In6_Cu,
In7_Cu,
In8_Cu,
In9_Cu,
In10_Cu,
In11_Cu,
In12_Cu,
In13_Cu,
In14_Cu,
In15_Cu,
In16_Cu,
In17_Cu,
In18_Cu,
In19_Cu,
In20_Cu,
In21_Cu,
In22_Cu,
In23_Cu,
In24_Cu,
In25_Cu,
In26_Cu,
In27_Cu,
In28_Cu,
In29_Cu,
In30_Cu,
B_Cu, // 31
B_Adhes, // 32
F_Adhes,
B_Paste,
F_Paste,
B_SilkS,
F_SilkS,
B_Mask,
F_Mask,
Dwgs_User,
Cmts_User,
Eco1_User,
Eco2_User,
Edge_Cuts,
Margin,
F_CrtYd, // CrtYd & Body are footprint only
B_CrtYd,
F_Fab,
B_Fab,
LAYER_ID_COUNT
};
#define UNDEFINED_LAYER LAYER_ID(-1)
#define UNSELECTED_LAYER LAYER_ID(-2)
#define MAX_CU_LAYERS (B_Cu - F_Cu + 1)
/* These were moved to legacy_plugin.cpp, please don't ever use them
outside there. Now with the advent of class LSEQ, we don't iterate over
LAYER_ID any more, so therefore FIRST_COPPER_LAYER and LAST_COPPER_LAYER are
dead concepts. They in fact failed to do what they were intended to do because
they implied a particular sequence which in and of itself was subject to change
and actually did when we flipped the pretty and *.kicad_pcb copper layer stack.
LSEQ is the way to go, use it. It gives a level of manipulation between
LAYER_ID and iteration.
#define FIRST_COPPER_LAYER brain dead
#define LAST_COPPER_LAYER brain dead
#define FIRST_LAYER brain dead
#define NB_LAYERS use LAYER_ID_COUNT instead
#define NB_COPPER_LAYERS was always a max, not a number, use MAX_CU_COUNT now.
*/
/// A sequence of layers, a sequence provides a certain order.
typedef std::vector<LAYER_ID> BASE_SEQ;
/**
* @return bool if 2 layer masks have a comman layer
* @param aMask1 = a layer mask
* @param aMask2 = an other layer mask
* Class LSEQ
* is a sequence (and therefore also a set) of LAYER_IDs. A sequence provides
* a certain order.
* <p>
* It can also be used as an iterator:
* <code>
*
* for( LSEQ cu_stack = aSet.CuStack(); cu_stack; ++cu_stack )
* {
* layer_id = *cu_stack;
* :
* things to do with layer_id;
* }
*
* </code>
*/
inline bool IsLayerMasksIntersect( LAYER_MSK aMask1, LAYER_MSK aMask2 )
class LSEQ : public BASE_SEQ
{
return (aMask1 & aMask2) != 0;
}
unsigned m_index;
/**
* Count the number of set layers in the mask
*/
inline int LayerMaskCountSet( LAYER_MSK aMask )
{
int count = 0;
public:
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
LSEQ() :
m_index( 0 )
{}
template <class InputIterator>
LSEQ( InputIterator start, InputIterator end ) :
BASE_SEQ( start, end ),
m_index( 0 )
{}
void Rewind() { m_index = 0; }
void operator ++ () { ++m_index; } // returns nothing, used in simple statements only.
void operator ++ (int) { ++m_index; }
operator bool () { return m_index < size(); }
LAYER_ID operator * () const
{
if( aMask & GetLayerMask( i ) )
++count;
return at( m_index ); // throws std::out_of_range
}
return count;
}
};
// layers order in dialogs (plot, print and toolbars)
// in same order than in setup layers dialog
// (Front or Top to Back or Bottom)
#define DECLARE_LAYERS_ORDER_LIST(list) const LAYER_NUM list[NB_LAYERS] =\
{ LAYER_N_FRONT,\
LAYER_N_15, LAYER_N_14, LAYER_N_13, LAYER_N_12,\
LAYER_N_11, LAYER_N_10, LAYER_N_9, LAYER_N_8,\
LAYER_N_7, LAYER_N_6, LAYER_N_5, LAYER_N_4,\
LAYER_N_3, LAYER_N_2,\
LAYER_N_BACK,\
ADHESIVE_N_FRONT , ADHESIVE_N_BACK,\
SOLDERPASTE_N_FRONT, SOLDERPASTE_N_BACK,\
SILKSCREEN_N_FRONT, SILKSCREEN_N_BACK,\
SOLDERMASK_N_FRONT, SOLDERMASK_N_BACK,\
DRAW_N,\
COMMENT_N,\
ECO1_N, ECO2_N,\
EDGE_N,\
UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31\
typedef std::bitset<LAYER_ID_COUNT> BASE_SET;
/**
* Class LSET
* is a set of LAYER_IDs. It can be converted to numerous purpose LSEQs using
* the various member functions, most of which are based on Seq(). The advantage
* of converting to LSEQ using purposeful code, is it removes any dependency
* on order/sequence inherent in this set.
*/
class LSET : public BASE_SET
{
public:
// The constructor flavors are carefully chosen to prevent LSET( int ) from compiling.
// That excludes "LSET s = 0;" and excludes "LSET s = -1;", etc.
// LSET s = 0; needs to be removed from the code, this accomplishes that.
// Remember LSET( LAYER_ID(0) ) sets bit 0, so "LSET s = 0;" is illegal
// to prevent that surprize. Therefore LSET's constructor suite is significantly
// different than the base class from which it is derived.
// Other member functions (non-constructor functions) are identical to the base
// class's and therefore are re-used from the base class.
/**
* Constructor LSET()
* creates an empty (cleared) set.
*/
LSET() :
BASE_SET() // all bits are set to zero in BASE_SET()
{
}
LSET( const BASE_SET& aOther ) :
BASE_SET( aOther )
{
}
/**
* Constructor LSET( LAYER_ID )
* takes a LAYER_ID and sets that bit. This makes the following code into
* a bug:
*
* <code> LSET s = 0; </code>
*
* Instead use:
*
* <code>
* LSET s;
* </code>
*
* for an empty set.
*/
LSET( LAYER_ID aLayer ) : // LAYER_ID deliberately exludes int and relatives
BASE_SET()
{
set( aLayer );
}
/**
* Constructor LSET( const LAYER_ID* aArray, unsigned aCount )
* works well with an arry or LSEQ.
*/
LSET( const LAYER_ID* aArray, unsigned aCount );
/**
* Constructor LSET( unsigned, LAYER_ID, ...)
* takes one or more LAYER_IDs in the argument list to construct
* the set. Typically only used in static construction.
*
* @param aIdCount is the number of LAYER_IDs which follow.
* @param aFirst is the first included in @a aIdCount and must always be present, and can
* be followed by any number of additional LAYER_IDs so long as @a aIdCount accurately
* reflects the count.
*/
LSET( unsigned aIdCount, LAYER_ID aFirst, ... ); // args chosen to prevent LSET( int ) from compiling
/**
* Function Name
* returns the fixed name association with aLayerId.
*/
static const wxChar* Name( LAYER_ID aLayerId );
/**
* Function InternalCuMask()
* returns a complete set of internal copper layers, which is all Cu layers
* except F_Cu and B_Cu.
*/
static LSET InternalCuMask();
/**
* Function AllCuMask
* returns a mask holding the requested number of Cu LAYER_IDs.
*/
static LSET AllCuMask( int aCuLayerCount = MAX_CU_LAYERS );
/**
* Function AllNonCuMask
* returns a mask holding all layer minus CU layers.
*/
static LSET AllNonCuMask();
static LSET AllLayersMask();
static LSET FrontTechMask();
static LSET BackTechMask();
static LSET AllTechMask();
static LSET FrontMask();
static LSET BackMask();
static LSET UserMask();
/**
* Function CuStack
* returns a sequence of copper layers in starting from the front/top
* and extending to the back/bottom. This specific sequence is depended upon
* in numerous places.
*/
LSEQ CuStack() const;
/**
* Function Technicals
* returns a sequence of technical layers. A sequence provides a certain
* order.
* @param aSubToOmit is the subset of the techical layers to omit, defaults to none.
*/
LSEQ Technicals( LSET aSubToOmit = LSET() ) const;
/// *_User layers.
LSEQ Users() const;
LSEQ UIOrder() const;
/**
* Function Seq
* returns an LSEQ from the union of this LSET and a desired sequence. The LSEQ
* element will be in the same sequence as aWishListSequence if they are present.
* @param aWishListSequence establishes the order of the returned LSEQ, and the LSEQ will only
* contiain LAYER_IDs which are present in this set.
* @param aCount is the length of aWishListSequence array.
*/
LSEQ Seq( const LAYER_ID* aWishListSequence, unsigned aCount ) const;
/**
* Function Seq
* returns a LSEQ from this LSET in ascending LAYER_ID order. Each LSEQ
* element will be in the same sequence as in LAYER_ID and only present
* in the resultant LSEQ if present in this set. Therefore the sequence is
* subject to change, use it only when enumeration and not order is important.
*/
LSEQ Seq() const;
/**
* Function SVG
* returns the sequence used to output an SVG plot.
LSEQ SVG() const;
put this in the needed source file using Seq() there.
*/
/**
* Function FmtHex
* returns a hex string showing contents of this LSEQ.
*/
std::string FmtHex() const;
/**
* Function ParseHex
* understands the output of FmtHex() and replaces this set's values
* with those given in the input string. Parsing stops at the first
* non hex ASCII byte, except that marker bytes output from FmtHex are
* not terminators.
* @return int - number of bytes consumed
*/
int ParseHex( const char* aStart, int aCount );
/**
* Function FmtBin
* returns a binary string showing contents of this LSEQ.
*/
std::string FmtBin() const;
/**
* Find the first set LAYER_ID. Returns UNDEFINED_LAYER if more
* than one is set or UNSELECTED_LAYER if none is set.
*/
LAYER_ID ExtractLayer() const;
private:
/// Take this off the market, it may not be used because of LSET( LAYER_ID ).
LSET( unsigned long __val )
{
// not usable, it's private.
}
};
@ -253,12 +429,15 @@ enum PCB_VISIBLE
END_PCB_VISIBLE_LIST // sentinel
};
/**
* Enum NETNAMES_VISIBLE
* is a set of layers specific for displaying net names.
* Their visiblity is not supposed to be saved in a board file,
* they are only to be used by the GAL.
*/
#if 0
// was:
enum NETNAMES_VISIBLE
{
LAYER_1_NETNAMES_VISIBLE, // bottom layer
@ -284,26 +463,37 @@ enum NETNAMES_VISIBLE
END_NETNAMES_VISIBLE_LIST // sentinel
};
#else
enum NETNAMES_VISIBLE
{
PAD_FR_NETNAMES_VISIBLE = B_Cu+1,
PAD_BK_NETNAMES_VISIBLE,
PADS_NETNAMES_VISIBLE,
END_NETNAMES_VISIBLE_LIST // sentinel
};
#endif
/// macro for obtaining layer number for specific item (eg. pad or text)
#define ITEM_GAL_LAYER(layer) (NB_LAYERS + layer)
#define ITEM_GAL_LAYER(layer) (LAYER_ID_COUNT + layer)
#define NETNAMES_GAL_LAYER(layer) (NB_LAYERS + END_PCB_VISIBLE_LIST + layer )
#define NETNAMES_GAL_LAYER(layer) (LAYER_ID_COUNT + END_PCB_VISIBLE_LIST + layer )
/// number of *all* layers including PCB and item layers
#define TOTAL_LAYER_COUNT (NB_LAYERS + END_PCB_VISIBLE_LIST + END_NETNAMES_VISIBLE_LIST)
/// number of *all* GAL layers including PCB and item layers
#define TOTAL_LAYER_COUNT (LAYER_ID_COUNT + END_PCB_VISIBLE_LIST + END_NETNAMES_VISIBLE_LIST)
/**
* Function IsValidLayer
* tests whether a given integer is a valid layer index, i.e. can
* be safely put in a LAYER_NUM
* @param aLayerIndex = Layer index to test. It can be an int, so its
* be safely put in a LAYER_ID
* @param aLayerId = Layer index to test. It can be an int, so its
* useful during I/O
* @return true if aLayerIndex is a valid layer index
*/
inline bool IsValidLayer( int aLayerIndex )
inline bool IsValidLayer( LAYER_NUM aLayerId )
{
return aLayerIndex >= FIRST_LAYER && aLayerIndex < NB_LAYERS;
return unsigned( aLayerId ) < LAYER_ID_COUNT;
}
/**
@ -314,41 +504,40 @@ inline bool IsValidLayer( int aLayerIndex )
*/
inline bool IsPcbLayer( LAYER_NUM aLayer )
{
return aLayer >= FIRST_LAYER && aLayer < NB_PCB_LAYERS;
return aLayer >= F_Cu && aLayer < LAYER_ID_COUNT;
}
/**
* Function IsCopperLayer
* tests whether a layer is a copper layer
* @param aLayer = Layer to test
* @param aLayerId = Layer to test
* @return true if aLayer is a valid copper layer
*/
inline bool IsCopperLayer( LAYER_NUM aLayer )
inline bool IsCopperLayer( LAYER_NUM aLayerId )
{
return aLayer >= FIRST_COPPER_LAYER
&& aLayer <= LAST_COPPER_LAYER;
return aLayerId >= F_Cu && aLayerId <= B_Cu;
}
/**
* Function IsNonCopperLayer
* tests whether a layer is a non copper layer
* @param aLayer = Layer to test
* @param aLayerId = Layer to test
* @return true if aLayer is a non copper layer
*/
inline bool IsNonCopperLayer( LAYER_NUM aLayer )
inline bool IsNonCopperLayer( LAYER_NUM aLayerId )
{
return aLayer >= FIRST_NON_COPPER_LAYER && aLayer <= LAST_NON_COPPER_LAYER;
return aLayerId > B_Cu && aLayerId <= LAYER_ID_COUNT;
}
/**
* Function IsUserLayer
* tests whether a layer is a non copper and a non tech layer
* @param aLayer = Layer to test
* @param aLayerId = Layer to test
* @return true if aLayer is a user layer
*/
inline bool IsUserLayer( LAYER_NUM aLayer )
inline bool IsUserLayer( LAYER_ID aLayerId )
{
return aLayer >= FIRST_USER_LAYER && aLayer <= LAST_USER_LAYER;
return aLayerId >= Dwgs_User && aLayerId <= Eco2_User;
}
/* IMPORTANT: If a layer is not a front layer not necessarily is true
@ -364,58 +553,74 @@ inline bool IsUserLayer( LAYER_NUM aLayer )
/**
* Layer classification: check if it's a front layer
*/
inline bool IsFrontLayer( LAYER_NUM aLayer )
inline bool IsFrontLayer( LAYER_ID aLayerId )
{
return ( aLayer == LAYER_N_FRONT ||
aLayer == ADHESIVE_N_FRONT ||
aLayer == SOLDERPASTE_N_FRONT ||
aLayer == SILKSCREEN_N_FRONT ||
aLayer == SOLDERPASTE_N_FRONT );
switch( aLayerId )
{
case F_Cu:
case F_Adhes:
case F_Paste:
case F_SilkS:
case F_Mask:
case F_CrtYd:
case F_Fab:
return true;
default:
;
}
return false;
}
/**
* Layer classification: check if it's a back layer
*/
inline bool IsBackLayer( LAYER_NUM aLayer )
inline bool IsBackLayer( LAYER_ID aLayerId )
{
return ( aLayer == LAYER_N_BACK ||
aLayer == ADHESIVE_N_BACK ||
aLayer == SOLDERPASTE_N_BACK ||
aLayer == SILKSCREEN_N_BACK ||
aLayer == SOLDERPASTE_N_BACK );
switch( aLayerId )
{
case B_Cu:
case B_Adhes:
case B_Paste:
case B_SilkS:
case B_Mask:
case B_CrtYd:
case B_Fab:
return true;
default:
;
}
return false;
}
/**
* Function FlippedLayerNumber
* @return the layer number after flipping an item
* some (not all) layers: external copper, Mask, Paste, and solder
* are swapped between front and back sides
*/
LAYER_NUM FlipLayer( LAYER_NUM oldlayer );
LAYER_ID FlipLayer( LAYER_ID oldlayer );
/**
* Calculate the mask layer when flipping a footprint
* BACK and FRONT copper layers, mask, paste, solder layers are swapped
*/
LAYER_MSK FlipLayerMask( LAYER_MSK aMask );
/**
* Extract the set layer from a mask. Returns UNDEFINED_LAYER if more
* than one is set or UNSELECTED_LAYER if none is
*/
LAYER_NUM ExtractLayer( LAYER_MSK aMask );
LSET FlipLayerMask( LSET aMask );
/**
* Return a string (to be shown to the user) describing a layer mask.
* Useful for showing where is a pad, track, entity, etc.
* The BOARD is needed because layer names are (somewhat) customizable
*/
wxString LayerMaskDescribe( const BOARD *aBoard, LAYER_MSK aMask );
wxString LayerMaskDescribe( const BOARD* aBoard, LSET aMask );
/**
* Returns a netname layer corresponding to the given layer.
*/
inline LAYER_NUM GetNetnameLayer( LAYER_NUM aLayer )
inline int GetNetnameLayer( int aLayer )
{
if( IsCopperLayer( aLayer ) )
return NETNAMES_GAL_LAYER( aLayer );
@ -427,7 +632,7 @@ inline LAYER_NUM GetNetnameLayer( LAYER_NUM aLayer )
return NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE );
// Fallback
return COMMENT_N;
return Cmts_User;
}
/**
@ -438,8 +643,11 @@ inline LAYER_NUM GetNetnameLayer( LAYER_NUM aLayer )
*/
inline bool IsNetnameLayer( LAYER_NUM aLayer )
{
return aLayer >= NETNAMES_GAL_LAYER( LAYER_1_NETNAMES_VISIBLE ) &&
return aLayer >= NETNAMES_GAL_LAYER( F_Cu ) &&
aLayer < NETNAMES_GAL_LAYER( END_NETNAMES_VISIBLE_LIST );
}
#endif // _LAYERS_ID_AND_VISIBILITY_H_
LAYER_ID ToLAYER_ID( int aLayer );
#endif // LAYERS_ID_AND_VISIBILITY_H_

View File

@ -18,9 +18,6 @@ class TRACK;
class BOARD;
class DISPLAY_OPTIONS;
/// Look up Table for conversion copper layer count -> general copper layer mask:
extern LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS];
extern DISPLAY_OPTIONS DisplayOpt;
extern int g_CurrentVersionPCB;

View File

@ -507,7 +507,7 @@ public:
*/
void UpdateItems();
const BOX2I CalculateExtents() ;
const BOX2I CalculateExtents() ;
static const int VIEW_MAX_LAYERS = 128; ///< maximum number of layers that may be shown

View File

@ -606,16 +606,16 @@ public:
* @param aDlgPosition = position of dialog ( defualt = centered)
* @return the selected layer id
*/
LAYER_NUM SelectLayer( LAYER_NUM aDefaultLayer,
LAYER_MSK aNotAllowedLayersMask = 0,
wxPoint aDlgPosition = wxDefaultPosition );
LAYER_ID SelectLayer( LAYER_ID aDefaultLayer,
LSET aNotAllowedLayersMask = LSET(),
wxPoint aDlgPosition = wxDefaultPosition );
/* Display a list of two copper layers to choose a pair of copper layers
* the layer pair is used to fast switch between copper layers when placing vias
*/
void SelectCopperLayerPair();
virtual void SwitchLayer( wxDC* DC, LAYER_NUM layer );
virtual void SwitchLayer( wxDC* DC, LAYER_ID layer );
void LoadSettings( wxConfigBase* aCfg ); // override virtual
void SaveSettings( wxConfigBase* aCfg ); // override virtual

View File

@ -1264,7 +1264,7 @@ public:
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMask,
virtual void PrintPage( wxDC* aDC, LSET aPrintMask,
bool aPrintMirrorMode, void* aData = NULL );
void SetSimulatorCommand( const wxString& aCommand ) { m_simulatorCommand = aCommand; }

View File

@ -283,8 +283,8 @@ public:
* @param aPrintMirrorMode = true to plot mirrored
* @param aData = a pointer on an auxiliary data (NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMaskLayer, bool aPrintMirrorMode,
void * aData = NULL );
virtual void PrintPage( wxDC* aDC, LSET aPrintMaskLayer, bool aPrintMirrorMode,
void* aData = NULL );
void GetKicadAbout( wxCommandEvent& event );
@ -535,26 +535,26 @@ public:
* Function SetHighContrastLayer
* takes care of display settings for the given layer to be displayed in high contrast mode.
*/
void SetHighContrastLayer( LAYER_NUM aLayer );
void SetHighContrastLayer( LAYER_ID aLayer );
/**
* Function SetTopLayer
* moves the selected layer to the top, so it is displayed above all others.
*/
void SetTopLayer( LAYER_NUM aLayer );
void SetTopLayer( LAYER_ID aLayer );
/**
* Function SetActiveLayer
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
void SetActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true );
void SetActiveLayer( LAYER_ID aLayer, bool doLayerWidgetUpdate = true );
/**
* Function GetActiveLayer
* returns the active layer
*/
LAYER_NUM GetActiveLayer() const
LAYER_ID GetActiveLayer() const
{
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
}
@ -784,8 +784,6 @@ public:
void InstallDisplayOptionsDialog( wxCommandEvent& aEvent );
void InstallPcbGlobalDeleteFrame( const wxPoint& pos );
void InstallDialogLayerSetup();
/**
* Function GenFootprintsPositionFile
* Calls DoGenFootprintsPositionFile to create a footprint position file
@ -1263,7 +1261,7 @@ public:
bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
void SwitchLayer( wxDC* DC, LAYER_NUM layer );
void SwitchLayer( wxDC* DC, LAYER_ID layer );
/**
* Function Add45DegreeSegment
@ -1463,7 +1461,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( LAYER_NUM aLayer );
void Delete_Drawings_All_Layer( LAYER_ID aLayer );
// Dimension handling:
void ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* aDC );

View File

@ -503,7 +503,7 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
// Display units
}
void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
bool aPrintMirrorMode, void * aData )
{
GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;

View File

@ -263,7 +263,7 @@ public:
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer,
virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer,
bool aPrintMirrorMode, void * aData );
void OnFileHistory( wxCommandEvent& event );

View File

@ -122,7 +122,7 @@ static void drawPlacementRoutingMatrix( BOARD* aBrd, wxDC* DC );
static int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide );
static void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
int marge, int aKeepOut, int aLayerMask );
int marge, int aKeepOut, LSET aLayerMask );
static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC );
static int propagate();
@ -133,7 +133,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
wxPoint PosOK;
wxPoint memopos;
int error;
LAYER_NUM lay_tmp_TOP, lay_tmp_BOTTOM;
LAYER_ID lay_tmp_TOP, lay_tmp_BOTTOM;
// Undo: init list
PICKED_ITEMS_LIST newList;
@ -488,12 +488,12 @@ int genPlacementRoutingMatrix( BOARD* aBrd, EDA_MSG_PANEL* messagePanel )
msg.Printf( wxT( "%d" ), RoutingMatrix.m_MemSize / 1024 );
messagePanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN );
g_Route_Layer_BOTTOM = LAYER_N_FRONT;
g_Route_Layer_BOTTOM = F_Cu;
if( RoutingMatrix.m_RoutingLayersCount > 1 )
g_Route_Layer_BOTTOM = LAYER_N_BACK;
g_Route_Layer_BOTTOM = B_Cu;
g_Route_Layer_TOP = LAYER_N_FRONT;
g_Route_Layer_TOP = F_Cu;
// Place the edge layer segments
TRACK TmpSegm( NULL );
@ -513,7 +513,7 @@ int genPlacementRoutingMatrix( BOARD* aBrd, EDA_MSG_PANEL* messagePanel )
case PCB_LINE_T:
DrawSegm = (DRAWSEGMENT*) PtStruct;
if( DrawSegm->GetLayer() != EDGE_N )
if( DrawSegm->GetLayer() != Edge_Cuts )
break;
TraceSegmentPcb( DrawSegm, HOLE | CELL_is_EDGE,
@ -550,7 +550,7 @@ int genPlacementRoutingMatrix( BOARD* aBrd, EDA_MSG_PANEL* messagePanel )
void genModuleOnRoutingMatrix( MODULE* Module )
{
int ox, oy, fx, fy;
int layerMask;
LSET layerMask;
D_PAD* Pad;
EDA_RECT fpBBox = Module->GetBoundingBox();
@ -585,13 +585,11 @@ void genModuleOnRoutingMatrix( MODULE* Module )
if( fy > RoutingMatrix.m_BrdBox.GetBottom() )
fy = RoutingMatrix.m_BrdBox.GetBottom();
layerMask = 0;
if( Module->GetLayer() == F_Cu )
layerMask.set( F_Cu );
if( Module->GetLayer() == LAYER_N_FRONT )
layerMask = LAYER_FRONT;
if( Module->GetLayer() == LAYER_N_BACK )
layerMask = LAYER_BACK;
if( Module->GetLayer() == B_Cu )
layerMask.set( B_Cu );
TraceFilledRectangle( ox, oy, fx, fy, layerMask,
CELL_is_MODULE, WRITE_OR_CELL );
@ -666,15 +664,11 @@ int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aD
if( RoutingMatrix.m_RoutingLayersCount > 1 )
{
D_PAD* Pad;
int otherLayerMask = LAYER_BACK;
LSET other( aModule->GetLayer() == B_Cu ? F_Cu : B_Cu );
if( aModule->GetLayer() == LAYER_N_BACK )
otherLayerMask = LAYER_FRONT;
for( Pad = aModule->Pads(); Pad != NULL; Pad = Pad->Next() )
for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
{
if( ( Pad->GetLayerMask() & otherLayerMask ) == 0 )
if( !( pad->GetLayerSet() & other ).any() )
continue;
TstOtherSide = true;
@ -875,7 +869,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* aModule, bool TstOtherSide )
int side = TOP;
int otherside = BOTTOM;
if( aModule->GetLayer() == LAYER_N_BACK )
if( aModule->GetLayer() == B_Cu )
{
side = BOTTOM; otherside = TOP;
}
@ -966,7 +960,7 @@ double compute_Ratsnest_PlaceModule( BOARD* aBrd )
* Therefore the cost is high in rect x0,y0 to x1,y1, and decrease outside this rectangle
*/
void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
int marge, int aKeepOut, int aLayerMask )
int marge, int aKeepOut, LSET aLayerMask )
{
int row, col;
int row_min, row_max, col_min, col_max, pmarge;
@ -974,10 +968,10 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
DIST_CELL data, LocalKeepOut;
int lgain, cgain;
if( aLayerMask & GetLayerMask( g_Route_Layer_BOTTOM ) )
if( aLayerMask[g_Route_Layer_BOTTOM] )
trace = 1; // Trace on bottom layer.
if( ( aLayerMask & GetLayerMask( g_Route_Layer_TOP ) ) && RoutingMatrix.m_RoutingLayersCount )
if( aLayerMask[g_Route_Layer_TOP] && RoutingMatrix.m_RoutingLayersCount )
trace |= 2; // Trace on top layer.
if( trace == 0 )

View File

@ -66,7 +66,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
}
else
{
g_Route_Layer_TOP = g_Route_Layer_BOTTOM = LAYER_N_BACK;
g_Route_Layer_TOP = g_Route_Layer_BOTTOM = B_Cu;
}
switch( mode )

View File

@ -206,12 +206,12 @@ void TraceSegmentPcb( DRAWSEGMENT* pt_segm, int type, int marge, int op_logic );
* op_logic = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL
*/
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
int side, int color, int op_logic);
LSET side, int color, int op_logic);
/* Same as above, but the rectangle is inclined angle angle. */
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
double angle, LAYER_MSK masque_layer,
double angle, LSET masque_layer,
int color, int op_logic );
/* QUEUE.CPP */

View File

@ -59,7 +59,7 @@ static void DrawSegmentQcq( int ux0, int uy0,
int op_logic );
static void TraceFilledCircle( int cx, int cy, int radius,
LAYER_MSK aLayerMask,
LSET aLayerMask,
int color,
int op_logic );
@ -96,7 +96,7 @@ void PlacePad( D_PAD* aPad, int color, int marge, int op_logic )
if( aPad->GetShape() == PAD_CIRCLE )
{
TraceFilledCircle( shape_pos.x, shape_pos.y, dx,
aPad->GetLayerMask(), color, op_logic );
aPad->GetLayerSet(), color, op_logic );
return;
}
@ -120,14 +120,14 @@ void PlacePad( D_PAD* aPad, int color, int marge, int op_logic )
TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - dy,
shape_pos.x + dx, shape_pos.y + dy,
aPad->GetLayerMask(), color, op_logic );
aPad->GetLayerSet(), color, op_logic );
}
else
{
TraceFilledRectangle( shape_pos.x - dx, shape_pos.y - dy,
shape_pos.x + dx, shape_pos.y + dy,
aPad->GetOrientation(),
aPad->GetLayerMask(), color, op_logic );
aPad->GetLayerSet(), color, op_logic );
}
}
@ -140,10 +140,8 @@ void PlacePad( D_PAD* aPad, int color, int marge, int op_logic )
* color: mask write in cells
* op_logic: type of writing in the cell (WRITE, OR)
*/
void TraceFilledCircle( int cx, int cy, int radius,
LAYER_MSK aLayerMask,
int color,
int op_logic )
void TraceFilledCircle( int cx, int cy, int radius,
LSET aLayerMask, int color, int op_logic )
{
int row, col;
int ux0, uy0, ux1, uy1;
@ -153,10 +151,10 @@ void TraceFilledCircle( int cx, int cy, int radius,
int tstwrite = 0;
int distmin;
if( aLayerMask & GetLayerMask( g_Route_Layer_BOTTOM ) )
if( aLayerMask[g_Route_Layer_BOTTOM] )
trace = 1; // Trace on BOTTOM
if( aLayerMask & GetLayerMask( g_Route_Layer_TOP ) )
if( aLayerMask[g_Route_Layer_TOP] )
if( RoutingMatrix.m_RoutingLayersCount > 1 )
trace |= 2; // Trace on TOP
@ -297,23 +295,23 @@ void TraceSegmentPcb( TRACK* aTrack, int color, int marge, int op_logic )
// Test if VIA (filled circle need to be drawn)
if( aTrack->Type() == PCB_VIA_T )
{
LAYER_MSK layer_mask = NO_LAYERS;
LSET layer_mask;
if( aTrack->IsOnLayer( g_Route_Layer_BOTTOM ) )
layer_mask = GetLayerMask( g_Route_Layer_BOTTOM );
layer_mask.set( g_Route_Layer_BOTTOM );
if( aTrack->IsOnLayer( g_Route_Layer_TOP ) )
{
if( layer_mask == 0 )
layer_mask = GetLayerMask( g_Route_Layer_TOP );
if( !layer_mask.any() )
layer_mask = LSET( g_Route_Layer_TOP );
else
layer_mask = FULL_LAYERS;
layer_mask.set();
}
if( color == VIA_IMPOSSIBLE )
layer_mask = FULL_LAYERS;
layer_mask.set();
if( layer_mask )
if( layer_mask.any() )
TraceFilledCircle( aTrack->GetStart().x, aTrack->GetStart().y,
half_width, layer_mask, color, op_logic );
}
@ -326,7 +324,7 @@ void TraceSegmentPcb( TRACK* aTrack, int color, int marge, int op_logic )
int uy1 = aTrack->GetEnd().y - RoutingMatrix.GetBrdCoordOrigin().y;
// Ordinary track
LAYER_NUM layer = aTrack->GetLayer();
LAYER_ID layer = aTrack->GetLayer();
if( color == VIA_IMPOSSIBLE )
layer = UNDEFINED_LAYER;
@ -478,17 +476,16 @@ void TracePcbLine( int x0, int y0, int x1, int y1, LAYER_NUM layer, int color, i
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
int aLayerMask, int color, int op_logic )
LSET aLayerMask, int color, int op_logic )
{
int row, col;
int row_min, row_max, col_min, col_max;
int trace = 0;
if( ( aLayerMask & GetLayerMask( g_Route_Layer_BOTTOM ) ) )
if( aLayerMask[g_Route_Layer_BOTTOM] )
trace = 1; // Trace on BOTTOM
if( ( aLayerMask & GetLayerMask( g_Route_Layer_TOP ) ) &&
RoutingMatrix.m_RoutingLayersCount > 1 )
if( aLayerMask[g_Route_Layer_TOP] && RoutingMatrix.m_RoutingLayersCount > 1 )
trace |= 2; // Trace on TOP
if( trace == 0 )
@ -541,7 +538,7 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
double angle, LAYER_MSK aLayerMask, int color, int op_logic )
double angle, LSET aLayerMask, int color, int op_logic )
{
int row, col;
int cx, cy; // Center of rectangle
@ -550,10 +547,10 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
int rotrow, rotcol;
int trace = 0;
if( aLayerMask & GetLayerMask( g_Route_Layer_BOTTOM ) )
if( aLayerMask[g_Route_Layer_BOTTOM] )
trace = 1; // Trace on BOTTOM
if( aLayerMask & GetLayerMask( g_Route_Layer_TOP ) )
if( aLayerMask[g_Route_Layer_TOP] )
{
if( RoutingMatrix.m_RoutingLayersCount > 1 )
trace |= 2; // Trace on TOP

View File

@ -115,7 +115,7 @@ int MATRIX_ROUTING_HEAD::InitRoutingMatrix()
m_DistSide[side] = NULL;
m_DirSide[side] = NULL;
/* allocate matrix & initialize everything to empty */
// allocate matrix & initialize everything to empty
m_BoardSide[side] = (MATRIX_CELL*) operator new( ii * sizeof(MATRIX_CELL) );
memset( m_BoardSide[side], 0, ii * sizeof(MATRIX_CELL) );
@ -196,16 +196,16 @@ void MATRIX_ROUTING_HEAD::UnInitRoutingMatrix()
*/
void PlaceCells( BOARD* aPcb, int net_code, int flag )
{
int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy;
int marge, via_marge;
LAYER_MSK layerMask;
int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy;
int marge, via_marge;
LSET layerMask;
// use the default NETCLASS?
NETCLASSPTR nc = aPcb->GetDesignSettings().GetDefault();
int trackWidth = nc->GetTrackWidth();
int clearance = nc->GetClearance();
int viaSize = nc->GetViaDiameter();
int trackWidth = nc->GetTrackWidth();
int clearance = nc->GetClearance();
int viaSize = nc->GetViaDiameter();
marge = clearance + (trackWidth / 2);
via_marge = clearance + (viaSize / 2);
@ -237,7 +237,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
EDGE_MODULE* edge = (EDGE_MODULE*) item;
EDGE_MODULE tmpEdge( *edge );
if( tmpEdge.GetLayer() == EDGE_N )
if( tmpEdge.GetLayer() == Edge_Cuts )
tmpEdge.SetLayer( UNDEFINED_LAYER );
TraceSegmentPcb( &tmpEdge, HOLE, marge, WRITE_CELL );
@ -257,66 +257,65 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
switch( item->Type() )
{
case PCB_LINE_T:
{
DRAWSEGMENT* DrawSegm;
int type_cell = HOLE;
DrawSegm = (DRAWSEGMENT*) item;
DRAWSEGMENT tmpSegm( DrawSegm );
if( DrawSegm->GetLayer() == EDGE_N )
{
tmpSegm.SetLayer( UNDEFINED_LAYER );
type_cell |= CELL_is_EDGE;
}
DRAWSEGMENT* DrawSegm;
TraceSegmentPcb( &tmpSegm, type_cell, marge, WRITE_CELL );
}
break;
int type_cell = HOLE;
DrawSegm = (DRAWSEGMENT*) item;
DRAWSEGMENT tmpSegm( DrawSegm );
if( DrawSegm->GetLayer() == Edge_Cuts )
{
tmpSegm.SetLayer( UNDEFINED_LAYER );
type_cell |= CELL_is_EDGE;
}
TraceSegmentPcb( &tmpSegm, type_cell, marge, WRITE_CELL );
}
break;
case PCB_TEXT_T:
{
TEXTE_PCB* PtText;
PtText = (TEXTE_PCB*) item;
{
TEXTE_PCB* PtText = (TEXTE_PCB*) item;
if( PtText->GetText().Length() == 0 )
break;
if( PtText->GetText().Length() == 0 )
break;
EDA_RECT textbox = PtText->GetTextBox( -1 );
ux0 = textbox.GetX();
uy0 = textbox.GetY();
dx = textbox.GetWidth();
dy = textbox.GetHeight();
EDA_RECT textbox = PtText->GetTextBox( -1 );
ux0 = textbox.GetX();
uy0 = textbox.GetY();
dx = textbox.GetWidth();
dy = textbox.GetHeight();
/* Put bounding box (rectangle) on matrix */
dx /= 2;
dy /= 2;
// Put bounding box (rectangle) on matrix
dx /= 2;
dy /= 2;
ux1 = ux0 + dx;
uy1 = uy0 + dy;
ux1 = ux0 + dx;
uy1 = uy0 + dy;
ux0 -= dx;
uy0 -= dy;
ux0 -= dx;
uy0 -= dy;
layerMask = GetLayerMask( PtText->GetLayer() );
layerMask = LSET( PtText->GetLayer() );
TraceFilledRectangle( ux0 - marge, uy0 - marge, ux1 + marge,
uy1 + marge, PtText->GetOrientation(),
layerMask, HOLE, WRITE_CELL );
TraceFilledRectangle( ux0 - marge, uy0 - marge, ux1 + marge,
uy1 + marge, PtText->GetOrientation(),
layerMask, HOLE, WRITE_CELL );
TraceFilledRectangle( ux0 - via_marge, uy0 - via_marge,
ux1 + via_marge, uy1 + via_marge,
PtText->GetOrientation(),
layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL );
}
break;
TraceFilledRectangle( ux0 - via_marge, uy0 - via_marge,
ux1 + via_marge, uy1 + via_marge,
PtText->GetOrientation(),
layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL );
}
break;
default:
break;
}
}
/* Put tracks and vias on matrix */
// Put tracks and vias on matrix
for( TRACK* track = aPcb->m_Track; track; track = track->Next() )
{
if( net_code == track->GetNetCode() )
@ -337,7 +336,7 @@ int Build_Work( BOARD* Pcb )
int demi_pas = RoutingMatrix.m_GridRouting / 2;
wxString msg;
InitWork(); /* clear work list */
InitWork(); // clear work list
int cellCount = 0;
for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ )
@ -509,8 +508,8 @@ void MATRIX_ROUTING_HEAD::AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x
}
/* fetch distance cell */
DIST_CELL MATRIX_ROUTING_HEAD::GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
// fetch distance cell
DIST_CELL MATRIX_ROUTING_HEAD::GetDist( int aRow, int aCol, int aSide ) // fetch distance cell
{
DIST_CELL* p;
@ -519,7 +518,7 @@ DIST_CELL MATRIX_ROUTING_HEAD::GetDist( int aRow, int aCol, int aSide ) /* fetch
}
/* store distance cell */
// store distance cell
void MATRIX_ROUTING_HEAD::SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
{
DIST_CELL* p;
@ -529,7 +528,7 @@ void MATRIX_ROUTING_HEAD::SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
}
/* fetch direction cell */
// fetch direction cell
int MATRIX_ROUTING_HEAD::GetDir( int aRow, int aCol, int aSide )
{
DIR_CELL* p;
@ -539,7 +538,7 @@ int MATRIX_ROUTING_HEAD::GetDir( int aRow, int aCol, int aSide )
}
/* store direction cell */
// store direction cell
void MATRIX_ROUTING_HEAD::SetDir( int aRow, int aCol, int aSide, int x )
{
DIR_CELL* p;

View File

@ -86,10 +86,10 @@ static int s_Clearance; // Clearance value used in autorouter
static PICKED_ITEMS_LIST s_ItemsListPicker;
int OpenNodes; /* total number of nodes opened */
int ClosNodes; /* total number of nodes closed */
int MoveNodes; /* total number of nodes moved */
int MaxNodes; /* maximum number of nodes opened at one time */
int OpenNodes; // total number of nodes opened
int ClosNodes; // total number of nodes closed
int MoveNodes; // total number of nodes moved
int MaxNodes; // maximum number of nodes opened at one time
#define NOSUCCESS 0
#define STOP_FROM_ESC -1
@ -115,25 +115,25 @@ int MaxNodes; /* maximum number of nodes opened at one time */
*/
static const int delta[8][2] =
{
{ 1, -1 }, /* northwest */
{ 1, 0 }, /* north */
{ 1, 1 }, /* northeast */
{ 0, -1 }, /* west */
{ 0, 1 }, /* east */
{ -1, -1 }, /* southwest */
{ -1, 0 }, /* south */
{ -1, 1 } /* southeast */
{ 1, -1 }, // northwest
{ 1, 0 }, // north
{ 1, 1 }, // northeast
{ 0, -1 }, // west
{ 0, 1 }, // east
{ -1, -1 }, // southwest
{ -1, 0 }, // south
{ -1, 1 } // southeast
};
static const int ndir[8] =
{
/* for building paths back to source */
// for building paths back to source
FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST,
FROM_EAST, FROM_WEST,
FROM_NORTHEAST, FROM_NORTH, FROM_NORTHWEST
};
/* blocking masks for neighboring cells */
// blocking masks for neighboring cells
#define BLOCK_NORTHEAST ( DIAG_NEtoSW | BENT_StoNE | BENT_WtoNE \
| ANGLE_NEtoSE | ANGLE_NWtoNE \
| SHARP_NtoNE | SHARP_EtoNE | HOLE )
@ -187,7 +187,7 @@ struct block
long b2;
};
/* blocking masks for diagonal traces */
// blocking masks for diagonal traces
static struct block blocking[8] =
{ {
0, -1,
@ -230,7 +230,7 @@ static struct block blocking[8] =
BLOCK_SOUTHWEST
} };
/* mask for hole-related blocking effects */
// mask for hole-related blocking effects
static struct
{
long trace;
@ -249,7 +249,7 @@ static struct
static long newmask[8] =
{
/* patterns to mask out in neighbor cells */
// patterns to mask out in neighbor cells
0,
CORNER_NORTHWEST | CORNER_NORTHEAST,
0,
@ -285,7 +285,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )
// Prepare the undo command info
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but...
/* go until no more work to do */
// go until no more work to do
GetWork( &row_source, &col_source, &current_net_code,
&row_target, &col_target, &pt_cur_ch ); // First net to route.
@ -294,7 +294,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )
&col_target,
&pt_cur_ch ) )
{
/* Test to stop routing ( escape key pressed ) */
// Test to stop routing ( escape key pressed )
wxYield();
if( m_canvas->GetAbortRequest() )
@ -329,7 +329,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )
segm_fX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_target);
segm_fY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_target);
/* Draw segment. */
// Draw segment.
GRLine( m_canvas->GetClipBox(), DC,
segm_oX, segm_oY, segm_fX, segm_fY,
0, WHITE );
@ -367,7 +367,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )
msg.Printf( wxT( " %d" ), GetBoard()->GetUnconnectedNetCount() );
AppendMsgPanel( wxT( "Not Connected" ), msg, CYAN );
/* Delete routing from display. */
// Delete routing from display.
pt_cur_ch->m_PadStart->Draw( m_canvas, DC, GR_AND );
pt_cur_ch->m_PadEnd->Draw( m_canvas, DC, GR_AND );
@ -413,16 +413,23 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
int newdist, olddir, _self;
int current_net_code;
int marge;
int padLayerMaskStart; /* Mask layers belonging to the starting pad. */
int padLayerMaskEnd; /* Mask layers belonging to the ending pad. */
int topLayerMask = GetLayerMask( g_Route_Layer_TOP );
int bottomLayerMask = GetLayerMask( g_Route_Layer_BOTTOM );
int routeLayerMask; /* Mask two layers for routing. */
int tab_mask[2]; /* Enables the calculation of the mask layer being
* tested. (side = TOP or BOTTOM) */
LSET padLayerMaskStart; // Mask layers belonging to the starting pad.
LSET padLayerMaskEnd; // Mask layers belonging to the ending pad.
LSET topLayerMask( g_Route_Layer_TOP );
LSET bottomLayerMask( g_Route_Layer_BOTTOM );
LSET routeLayerMask; // Mask two layers for routing.
LSET tab_mask[2]; // Enables the calculation of the mask layer being
// tested. (side = TOP or BOTTOM)
int start_mask_layer = 0;
wxString msg;
// @todo this could be a bottle neck
LSET all_cu = LSET::AllCuMask( pcbframe->GetBoard()->GetCopperLayerCount() );
wxBusyCursor dummy_cursor; // Set an hourglass cursor while routing a
// track
@ -430,7 +437,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
marge = s_Clearance + ( pcbframe->GetDesignSettings().GetCurrentTrackWidth() / 2 );
/* clear direction flags */
// clear direction flags
i = RoutingMatrix.m_Nrows * RoutingMatrix.m_Ncols * sizeof(DIR_CELL);
if( two_sides )
@ -439,20 +446,20 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
lastopen = lastclos = lastmove = 0;
/* Set tab_masque[side] for final test of routing. */
// Set tab_masque[side] for final test of routing.
if( two_sides )
tab_mask[TOP] = topLayerMask;
tab_mask[TOP] = topLayerMask;
tab_mask[BOTTOM] = bottomLayerMask;
/* Set active layers mask. */
// Set active layers mask.
routeLayerMask = topLayerMask | bottomLayerMask;
pt_cur_ch = pt_rat;
current_net_code = pt_rat->GetNet();
padLayerMaskStart = pt_cur_ch->m_PadStart->GetLayerMask();
padLayerMaskStart = pt_cur_ch->m_PadStart->GetLayerSet();
padLayerMaskEnd = pt_cur_ch->m_PadEnd->GetLayerMask();
padLayerMaskEnd = pt_cur_ch->m_PadEnd->GetLayerSet();
/* First Test if routing possible ie if the pads are accessible
@ -499,23 +506,22 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
goto end_of_route;
}
/* Test the trivial case: direct connection overlay pads. */
if( ( row_source == row_target ) && ( col_source == col_target )
&& ( padLayerMaskEnd & padLayerMaskStart &
g_TabAllCopperLayerMask[pcbframe->GetBoard()->GetCopperLayerCount() - 1] ) )
// Test the trivial case: direct connection overlay pads.
if( row_source == row_target && col_source == col_target &&
( padLayerMaskEnd & padLayerMaskStart & all_cu ).any() )
{
result = TRIVIAL_SUCCESS;
goto end_of_route;
}
/* Placing the bit to remove obstacles on 2 pads to a link. */
// Placing the bit to remove obstacles on 2 pads to a link.
pcbframe->SetStatusText( wxT( "Gen Cells" ) );
PlacePad( pt_cur_ch->m_PadStart, CURRENT_PAD, marge, WRITE_OR_CELL );
PlacePad( pt_cur_ch->m_PadEnd, CURRENT_PAD, marge, WRITE_OR_CELL );
/* Regenerates the remaining barriers (which may encroach on the placement bits precedent)
*/
// Regenerates the remaining barriers (which may encroach on the
// placement bits precedent)
i = pcbframe->GetBoard()->GetPadCount();
for( unsigned ii = 0; ii < pcbframe->GetBoard()->GetPadCount(); ii++ )
@ -528,15 +534,15 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
}
InitQueue(); /* initialize the search queue */
InitQueue(); // initialize the search queue
apx_dist = RoutingMatrix.GetApxDist( row_source, col_source, row_target, col_target );
/* Initialize first search. */
if( two_sides ) /* Preferred orientation. */
// Initialize first search.
if( two_sides ) // Preferred orientation.
{
if( abs( row_target - row_source ) > abs( col_target - col_source ) )
{
if( padLayerMaskStart & topLayerMask )
if( ( padLayerMaskStart & topLayerMask ).any() )
{
start_mask_layer = 2;
@ -547,7 +553,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
}
if( padLayerMaskStart & bottomLayerMask )
if( ( padLayerMaskStart & bottomLayerMask ).any() )
{
start_mask_layer |= 1;
@ -560,7 +566,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
else
{
if( padLayerMaskStart & bottomLayerMask )
if( ( padLayerMaskStart & bottomLayerMask ).any() )
{
start_mask_layer = 1;
@ -571,7 +577,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
}
if( padLayerMaskStart & topLayerMask )
if( ( padLayerMaskStart & topLayerMask ).any() )
{
start_mask_layer |= 2;
@ -583,7 +589,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
}
}
else if( padLayerMaskStart & bottomLayerMask )
else if( ( padLayerMaskStart & bottomLayerMask ).any() )
{
start_mask_layer = 1;
@ -593,7 +599,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
}
/* search until success or we exhaust all possibilities */
// search until success or we exhaust all possibilities
GetQueue( &r, &c, &side, &d, &apx_dist );
for( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) )
@ -603,10 +609,10 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
if( curcell & CURRENT_PAD )
curcell &= ~HOLE;
if( (r == row_target) && (c == col_target) /* success if layer OK */
&& ( tab_mask[side] & padLayerMaskEnd) )
if( (r == row_target) && (c == col_target) // success if layer OK
&& (tab_mask[side] & padLayerMaskEnd).any() )
{
/* Remove link. */
// Remove link.
GRSetDrawMode( DC, GR_XOR );
GRLine( pcbframe->GetCanvas()->GetClipBox(),
DC,
@ -617,14 +623,14 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
0,
WHITE );
/* Generate trace. */
// Generate trace.
if( Retrace( pcbframe, DC, row_source, col_source,
row_target, col_target, side, current_net_code ) )
{
result = SUCCESS; /* Success : Route OK */
result = SUCCESS; // Success : Route OK
}
break; /* Routing complete. */
break; // Routing complete.
}
if( pcbframe->GetCanvas()->GetAbortRequest() )
@ -633,7 +639,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
break;
}
/* report every COUNT new nodes or so */
// report every COUNT new nodes or so
#define COUNT 20000
if( ( OpenNodes - lastopen > COUNT )
@ -654,7 +660,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
{
_self = 5;
/* set 'present' bits */
// set 'present' bits
for( i = 0; i < 8; i++ )
{
selfok2[i].present = 0;
@ -664,15 +670,15 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
}
for( i = 0; i < 8; i++ ) /* consider neighbors */
for( i = 0; i < 8; i++ ) // consider neighbors
{
nr = r + delta[i][0];
nc = c + delta[i][1];
/* off the edge? */
// off the edge?
if( nr < 0 || nr >= RoutingMatrix.m_Nrows ||
nc < 0 || nc >= RoutingMatrix.m_Ncols )
continue; /* off the edge */
continue; // off the edge
if( _self == 5 && selfok2[i].present )
continue;
@ -682,22 +688,22 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
if( newcell & CURRENT_PAD )
newcell &= ~HOLE;
/* check for non-target hole */
// check for non-target hole
if( newcell & HOLE )
{
if( nr != row_target || nc != col_target )
continue;
}
/* check for traces */
// check for traces
else if( newcell & HOLE & ~(newmask[i]) )
{
continue;
}
/* check blocking on corner neighbors */
// check blocking on corner neighbors
if( delta[i][0] && delta[i][1] )
{
/* check first buddy */
// check first buddy
buddy = RoutingMatrix.GetCell( r + blocking[i].r1, c + blocking[i].c1, side );
if( buddy & CURRENT_PAD )
@ -707,7 +713,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
continue;
// if (buddy & (blocking[i].b1)) continue;
/* check second buddy */
// check second buddy
buddy = RoutingMatrix.GetCell( r + blocking[i].r2, c + blocking[i].c2, side );
if( buddy & CURRENT_PAD )
@ -724,8 +730,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
( olddir == FROM_OTHERSIDE ) ?
RoutingMatrix.GetDir( r, c, 1 - side ) : 0, side );
/* if (a) not visited yet, or (b) we have */
/* found a better path, add it to queue */
// if (a) not visited yet, or (b) we have
// found a better path, add it to queue
if( !RoutingMatrix.GetDir( nr, nc, side ) )
{
RoutingMatrix.SetDir( nr, nc, side, ndir[i] );
@ -748,45 +754,45 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
}
}
/** Test the other layer. **/
//* Test the other layer. *
if( two_sides )
{
olddir = RoutingMatrix.GetDir( r, c, side );
if( olddir == FROM_OTHERSIDE )
continue; /* useless move, so don't bother */
continue; // useless move, so don't bother
if( curcell ) /* can't drill via if anything here */
if( curcell ) // can't drill via if anything here
continue;
/* check for holes or traces on other side */
// check for holes or traces on other side
if( ( newcell = RoutingMatrix.GetCell( r, c, 1 - side ) ) != 0 )
continue;
/* check for nearby holes or traces on both sides */
// check for nearby holes or traces on both sides
for( skip = 0, i = 0; i < 8; i++ )
{
nr = r + delta[i][0]; nc = c + delta[i][1];
if( nr < 0 || nr >= RoutingMatrix.m_Nrows ||
nc < 0 || nc >= RoutingMatrix.m_Ncols )
continue; /* off the edge !! */
continue; // off the edge !!
if( RoutingMatrix.GetCell( nr, nc, side ) /* & blocking2[i]*/ )
if( RoutingMatrix.GetCell( nr, nc, side ) /* & blocking2[i] */ )
{
skip = 1; /* can't drill via here */
skip = 1; // can't drill via here
break;
}
if( RoutingMatrix.GetCell( nr, nc, 1 - side ) /* & blocking2[i]*/ )
if( RoutingMatrix.GetCell( nr, nc, 1 - side ) /* & blocking2[i] */ )
{
skip = 1; /* can't drill via here */
skip = 1; // can't drill via here
break;
}
}
if( skip ) /* neighboring hole or trace? */
continue; /* yes, can't drill via here */
if( skip ) // neighboring hole or trace?
continue; // yes, can't drill via here
newdist = d + RoutingMatrix.CalcDist( FROM_OTHERSIDE, olddir, 0, side );
@ -814,7 +820,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
row_target,
col_target );
}
} /* Finished attempt to route on other layer. */
} // Finished attempt to route on other layer.
}
end_of_route:
@ -831,9 +837,9 @@ end_of_route:
static long bit[8][9] =
{
/* OT=Otherside */
/* N, NE, E, SE, S, SW, W, NW, OT */
/* N */
// OT=Otherside
// N, NE, E, SE, S, SW, W, NW, OT
// N
{ LINE_VERTICAL,
BENT_StoNE,
CORNER_SOUTHEAST,
@ -844,7 +850,7 @@ static long bit[8][9] =
BENT_StoNW,
( HOLE | HOLE_SOUTH )
},
/* NE */
// NE
{
BENT_NtoSW,
DIAG_NEtoSW,
@ -856,7 +862,7 @@ static long bit[8][9] =
ANGLE_SWtoNW,
( HOLE | HOLE_SOUTHWEST )
},
/* E */
// E
{
CORNER_NORTHWEST,
BENT_WtoNE,
@ -868,7 +874,7 @@ static long bit[8][9] =
SHARP_WtoNW,
( HOLE | HOLE_WEST )
},
/* SE */
// SE
{
SHARP_NtoNW,
ANGLE_NWtoNE,
@ -880,7 +886,7 @@ static long bit[8][9] =
0,
( HOLE | HOLE_NORTHWEST )
},
/* S */
// S
{
0,
SHARP_NtoNE,
@ -892,7 +898,7 @@ static long bit[8][9] =
SHARP_NtoNW,
( HOLE | HOLE_NORTH )
},
/* SW */
// SW
{
SHARP_NtoNE,
0,
@ -904,7 +910,7 @@ static long bit[8][9] =
ANGLE_NWtoNE,
( HOLE | HOLE_NORTHEAST )
},
/* W */
// W
{
CORNER_NORTHEAST,
SHARP_EtoNE,
@ -916,7 +922,7 @@ static long bit[8][9] =
BENT_EtoNW,
( HOLE | HOLE_EAST )
},
/* NW */
// NW
{
BENT_NtoSE,
ANGLE_NEtoSE,
@ -952,13 +958,13 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
int current_net_code )
{
int r0, c0, s0;
int r1, c1, s1; /* row, col, starting side. */
int r2, c2, s2; /* row, col, ending side. */
int r1, c1, s1; // row, col, starting side.
int r2, c2, s2; // row, col, ending side.
int x, y = -1;
long b;
r1 = row_target;
c1 = col_target; /* start point is target ( end point is source )*/
c1 = col_target; // start point is target ( end point is source )
s1 = target_side;
r0 = c0 = s0 = ILLEGAL;
@ -966,7 +972,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
do
{
/* find where we came from to get here */
// find where we came from to get here
r2 = r1; c2 = c1; s2 = s1;
x = RoutingMatrix.GetDir( r1, c1, s1 );
@ -1020,7 +1026,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
if( r0 != ILLEGAL )
y = RoutingMatrix.GetDir( r0, c0, s0 );
/* see if target or hole */
// see if target or hole
if( ( ( r1 == row_target ) && ( c1 == col_target ) ) || ( s1 != s0 ) )
{
int p_dir;
@ -1092,7 +1098,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
}
}
if( ( r2 == row_source ) && ( c2 == col_source ) ) /* see if source */
if( ( r2 == row_source ) && ( c2 == col_source ) ) // see if source
{
int p_dir;
@ -1139,7 +1145,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, p_dir, current_net_code );
}
/* move to next cell */
// move to next cell
r0 = r1;
c0 = c1;
s0 = s1;
@ -1166,7 +1172,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackList.PushBack( newVia );
g_CurrentTrackSegment->SetState( TRACK_AR, true );
g_CurrentTrackSegment->SetLayer( 0x0F );
g_CurrentTrackSegment->SetLayer( F_Cu );
g_CurrentTrackSegment->SetStart(wxPoint( pcb->GetBoundingBox().GetX() +
( RoutingMatrix.m_GridRouting * row ),
@ -1199,18 +1205,18 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
( RoutingMatrix.m_GridRouting * col )));
g_CurrentTrackSegment->SetNetCode( current_net_code );
if( g_CurrentTrackSegment->Back() == NULL ) /* Start trace. */
if( g_CurrentTrackSegment->Back() == NULL ) // Start trace.
{
g_CurrentTrackSegment->SetStart( wxPoint( segm_fX, segm_fY ) );
/* Placement on the center of the pad if outside grid. */
// Placement on the center of the pad if outside grid.
dx1 = g_CurrentTrackSegment->GetEnd().x - g_CurrentTrackSegment->GetStart().x;
dy1 = g_CurrentTrackSegment->GetEnd().y - g_CurrentTrackSegment->GetStart().y;
dx0 = pt_cur_ch->m_PadEnd->GetPosition().x - g_CurrentTrackSegment->GetStart().x;
dy0 = pt_cur_ch->m_PadEnd->GetPosition().y - g_CurrentTrackSegment->GetStart().y;
/* If aligned, change the origin point. */
// If aligned, change the origin point.
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
{
g_CurrentTrackSegment->SetStart( pt_cur_ch->m_PadEnd->GetPosition() );
@ -1237,7 +1243,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
if( g_CurrentTrackSegment->GetStart() != g_CurrentTrackSegment->GetEnd() )
{
/* Reduce aligned segments by one. */
// Reduce aligned segments by one.
TRACK* oldTrack = g_CurrentTrackSegment->Back();
if( oldTrack && oldTrack->Type() != PCB_VIA_T )
@ -1281,11 +1287,11 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
dx1 = g_CurrentTrackSegment->GetEnd().x - g_CurrentTrackSegment->GetStart().x;
dy1 = g_CurrentTrackSegment->GetEnd().y - g_CurrentTrackSegment->GetStart().y;
/* Place on center of pad if off grid. */
// Place on center of pad if off grid.
dx0 = pt_cur_ch->m_PadStart->GetPosition().x - g_CurrentTrackSegment->GetStart().x;
dy0 = pt_cur_ch->m_PadStart->GetPosition().y - g_CurrentTrackSegment->GetStart().y;
/* If aligned, change the origin point. */
// If aligned, change the origin point.
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
{
g_CurrentTrackSegment->SetEnd( pt_cur_ch->m_PadStart->GetPosition() );
@ -1312,7 +1318,7 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
if( g_CurrentTrackSegment->end )
g_CurrentTrackSegment->SetState( END_ONPAD, true );
/* Out the new track on the matrix board */
// Out the new track on the matrix board
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
{
TraceSegmentPcb( track, HOLE, marge, WRITE_CELL );

View File

@ -64,24 +64,26 @@
#include <tool/tool_dispatcher.h>
// Configuration entry names.
static const wxString UserGridSizeXEntry( wxT( "PcbUserGrid_X" ) );
static const wxString UserGridSizeYEntry( wxT( "PcbUserGrid_Y" ) );
static const wxString UserGridUnitsEntry( wxT( "PcbUserGrid_Unit" ) );
static const wxString DisplayPadFillEntry( wxT( "DiPadFi" ) );
static const wxString DisplayViaFillEntry( wxT( "DiViaFi" ) );
static const wxString DisplayPadNumberEntry( wxT( "DiPadNu" ) );
static const wxString DisplayModuleEdgeEntry( wxT( "DiModEd" ) );
static const wxString DisplayModuleTextEntry( wxT( "DiModTx" ) );
static const wxString FastGrid1Entry( wxT( "FastGrid1" ) );
static const wxString FastGrid2Entry( wxT( "FastGrid2" ) );
static const wxChar UserGridSizeXEntry[] = wxT( "PcbUserGrid_X" );
static const wxChar UserGridSizeYEntry[] = wxT( "PcbUserGrid_Y" );
static const wxChar UserGridUnitsEntry[] = wxT( "PcbUserGrid_Unit" );
static const wxChar DisplayPadFillEntry[] = wxT( "DiPadFi" );
static const wxChar DisplayViaFillEntry[] = wxT( "DiViaFi" );
static const wxChar DisplayPadNumberEntry[] = wxT( "DiPadNu" );
static const wxChar DisplayModuleEdgeEntry[] = wxT( "DiModEd" );
static const wxChar DisplayModuleTextEntry[] = wxT( "DiModTx" );
static const wxChar FastGrid1Entry[] = wxT( "FastGrid1" );
static const wxChar FastGrid2Entry[] = wxT( "FastGrid2" );
const LAYER_NUM PCB_BASE_FRAME::GAL_LAYER_ORDER[] =
{
ITEM_GAL_LAYER( GP_OVERLAY ),
ITEM_GAL_LAYER( DRC_VISIBLE ),
NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
DRAW_N, COMMENT_N, ECO1_N, ECO2_N, EDGE_N,
UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31,
Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts,
// UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31,
ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ),
ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE), ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ),
@ -89,9 +91,11 @@ const LAYER_NUM PCB_BASE_FRAME::GAL_LAYER_ORDER[] =
ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ),
ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ),
NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ), SOLDERMASK_N_FRONT,
NETNAMES_GAL_LAYER( LAYER_16_NETNAMES_VISIBLE ), LAYER_N_FRONT,
SILKSCREEN_N_FRONT, SOLDERPASTE_N_FRONT, ADHESIVE_N_FRONT,
NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ), F_Mask,
NETNAMES_GAL_LAYER( F_Cu ), F_Cu,
F_SilkS, F_Paste, F_Adhes,
#if 0 // was:
NETNAMES_GAL_LAYER( LAYER_15_NETNAMES_VISIBLE ), LAYER_N_15,
NETNAMES_GAL_LAYER( LAYER_14_NETNAMES_VISIBLE ), LAYER_N_14,
NETNAMES_GAL_LAYER( LAYER_13_NETNAMES_VISIBLE ), LAYER_N_13,
@ -106,14 +110,48 @@ const LAYER_NUM PCB_BASE_FRAME::GAL_LAYER_ORDER[] =
NETNAMES_GAL_LAYER( LAYER_4_NETNAMES_VISIBLE ), LAYER_N_4,
NETNAMES_GAL_LAYER( LAYER_3_NETNAMES_VISIBLE ), LAYER_N_3,
NETNAMES_GAL_LAYER( LAYER_2_NETNAMES_VISIBLE ), LAYER_N_2,
NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ), SOLDERMASK_N_BACK,
NETNAMES_GAL_LAYER( LAYER_1_NETNAMES_VISIBLE ), LAYER_N_BACK,
#else
ADHESIVE_N_BACK, SOLDERPASTE_N_BACK, SILKSCREEN_N_BACK,
NETNAMES_GAL_LAYER( In1_Cu ), In1_Cu,
NETNAMES_GAL_LAYER( In2_Cu ), In2_Cu,
NETNAMES_GAL_LAYER( In3_Cu ), In3_Cu,
NETNAMES_GAL_LAYER( In4_Cu ), In4_Cu,
NETNAMES_GAL_LAYER( In5_Cu ), In5_Cu,
NETNAMES_GAL_LAYER( In6_Cu ), In6_Cu,
NETNAMES_GAL_LAYER( In7_Cu ), In7_Cu,
NETNAMES_GAL_LAYER( In8_Cu ), In8_Cu,
NETNAMES_GAL_LAYER( In9_Cu ), In9_Cu,
NETNAMES_GAL_LAYER( In10_Cu ), In10_Cu,
NETNAMES_GAL_LAYER( In11_Cu ), In11_Cu,
NETNAMES_GAL_LAYER( In12_Cu ), In12_Cu,
NETNAMES_GAL_LAYER( In13_Cu ), In13_Cu,
NETNAMES_GAL_LAYER( In14_Cu ), In14_Cu,
NETNAMES_GAL_LAYER( In15_Cu ), In15_Cu,
NETNAMES_GAL_LAYER( In16_Cu ), In16_Cu,
NETNAMES_GAL_LAYER( In17_Cu ), In17_Cu,
NETNAMES_GAL_LAYER( In18_Cu ), In18_Cu,
NETNAMES_GAL_LAYER( In19_Cu ), In19_Cu,
NETNAMES_GAL_LAYER( In20_Cu ), In20_Cu,
NETNAMES_GAL_LAYER( In21_Cu ), In21_Cu,
NETNAMES_GAL_LAYER( In22_Cu ), In22_Cu,
NETNAMES_GAL_LAYER( In23_Cu ), In23_Cu,
NETNAMES_GAL_LAYER( In24_Cu ), In24_Cu,
NETNAMES_GAL_LAYER( In25_Cu ), In25_Cu,
NETNAMES_GAL_LAYER( In26_Cu ), In26_Cu,
NETNAMES_GAL_LAYER( In27_Cu ), In27_Cu,
NETNAMES_GAL_LAYER( In28_Cu ), In28_Cu,
NETNAMES_GAL_LAYER( In29_Cu ), In29_Cu,
NETNAMES_GAL_LAYER( In30_Cu ), In30_Cu,
#endif
NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ), B_Mask,
NETNAMES_GAL_LAYER( B_Cu ), B_Cu,
B_Adhes, B_Paste, B_SilkS,
ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ),
ITEM_GAL_LAYER( WORKSHEET )
};
BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
PCB_BASE_FRAME::ProcessItemSelection )
@ -417,9 +455,9 @@ void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
// Note: virtual, overridden in PCB_EDIT_FRAME;
void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_ID layer )
{
LAYER_NUM preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
LAYER_ID preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
// Check if the specified layer matches the present layer
if( layer == preslayer )
@ -434,7 +472,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
// selection of any other copper layer is disregarded).
if( m_Pcb->GetCopperLayerCount() < 2 )
{
if( layer != LAYER_N_BACK )
if( layer != B_Cu )
{
return;
}
@ -446,7 +484,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
// layers are also capable of being selected.
else
{
if( ( layer != LAYER_N_BACK ) && ( layer != LAYER_N_FRONT )
if( ( layer != B_Cu ) && ( layer != F_Cu )
&& ( layer >= m_Pcb->GetCopperLayerCount() - 1 ) )
{
return;
@ -813,7 +851,7 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
KIGFX::VIEW* view = GetGalCanvas()->GetView();
// Set rendering order and properties of layers
for( LAYER_NUM i = 0; (unsigned) i < sizeof(GAL_LAYER_ORDER) / sizeof(LAYER_NUM); ++i )
for( LAYER_NUM i = 0; i < (int) DIM(GAL_LAYER_ORDER); ++i )
{
LAYER_NUM layer = GAL_LAYER_ORDER[i];
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
@ -840,14 +878,14 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
view->SetRequired( NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
view->SetRequired( NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( ADHESIVE_N_FRONT, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( SOLDERPASTE_N_FRONT, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( SOLDERMASK_N_FRONT, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( F_Adhes, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( F_Paste, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( F_Mask, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( ADHESIVE_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( SOLDERPASTE_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( SOLDERMASK_N_BACK, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( B_Adhes, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( B_Paste, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( B_Mask, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_FR_VISIBLE ), ITEM_GAL_LAYER( MOD_FR_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_BK_VISIBLE ), ITEM_GAL_LAYER( MOD_BK_VISIBLE ) );

View File

@ -381,7 +381,7 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
void PCB_EDIT_FRAME::Block_SelectItems()
{
LAYER_MSK layerMask;
LSET layerMask;
bool selectOnlyComplete = GetScreen()->m_BlockLocate.GetWidth() > 0 ;
GetScreen()->m_BlockLocate.Normalize();
@ -392,9 +392,9 @@ void PCB_EDIT_FRAME::Block_SelectItems()
// Add modules
if( blockIncludeModules )
{
for( MODULE* module = m_Pcb->m_Modules; module != NULL; module = module->Next() )
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{
LAYER_NUM layer = module->GetLayer();
LAYER_ID layer = module->GetLayer();
if( module->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete )
&& ( !module->IsLocked() || blockIncludeLockedModules ) )
@ -418,7 +418,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
if( blockIncludeItemsOnInvisibleLayers
|| m_Pcb->IsLayerVisible( track->GetLayer() ) )
{
picker.SetItem ( track );
picker.SetItem( track );
itemsList->PushItem( picker );
}
}
@ -426,13 +426,13 @@ void PCB_EDIT_FRAME::Block_SelectItems()
}
// Add graphic items
layerMask = EDGE_LAYER;
layerMask = LSET( Edge_Cuts );
if( blockIncludeItemsOnTechLayers )
layerMask = ALL_LAYERS;
layerMask.set();
if( !blockIncludeBoardOutlineLayer )
layerMask &= ~EDGE_LAYER;
layerMask.set( Edge_Cuts, false );
for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
@ -444,7 +444,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
switch( PtStruct->Type() )
{
case PCB_LINE_T:
if( (GetLayerMask( PtStruct->GetLayer() ) & layerMask) == 0 )
if( !layerMask[PtStruct->GetLayer()] )
break;
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
@ -464,7 +464,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
break;
case PCB_TARGET_T:
if( ( GetLayerMask( PtStruct->GetLayer() ) & layerMask ) == 0 )
if( !layerMask[PtStruct->GetLayer()] )
break;
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
@ -474,7 +474,7 @@ void PCB_EDIT_FRAME::Block_SelectItems()
break;
case PCB_DIMENSION_T:
if( ( GetLayerMask( PtStruct->GetLayer() ) & layerMask ) == 0 )
if( !layerMask[PtStruct->GetLayer()] )
break;
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )

View File

@ -39,19 +39,8 @@ static void addTextSegmToPoly( int x0, int y0, int xf, int yf )
s_textCircle2SegmentCount, s_textWidth );
}
/**
* Function ConvertBrdLayerToPolygonalContours
* Build a set of polygons which are the outlines of copper items
* (pads, tracks, texts, zones)
* the holes in vias or pads are ignored
* Usefull to export the shape of copper layers to dxf polygons
* or 3D viewer
* the polygons are not merged.
* @param aLayer = A layer, like LAYER_N_BACK, etc.
* @param aOutlines The CPOLYGONS_LIST to fill in with main outlines.
* @return true if success, false if a contour is not valid
*/
void BOARD::ConvertBrdLayerToPolygonalContours( LAYER_NUM aLayer, CPOLYGONS_LIST& aOutlines )
void BOARD::ConvertBrdLayerToPolygonalContours( LAYER_ID aLayer, CPOLYGONS_LIST& aOutlines )
{
// Number of segments to convert a circle to a polygon
const int segcountforcircle = 18;
@ -82,7 +71,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( LAYER_NUM aLayer, CPOLYGONS_LIST
for( int ii = 0; ii < GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = GetArea( ii );
LAYER_NUM zonelayer = zone->GetLayer();
LAYER_ID zonelayer = zone->GetLayer();
if( zonelayer == aLayer )
zone->TransformSolidAreasShapesToPolygonSet(
@ -113,18 +102,8 @@ void BOARD::ConvertBrdLayerToPolygonalContours( LAYER_NUM aLayer, CPOLYGONS_LIST
}
}
/* generate pads shapes on layer aLayer as polygons,
* and adds these polygons to aCornerBuffer
* aCornerBuffer = the buffer to store polygons
* aInflateValue = an additionnal size to add to pad shapes
* aCircleToSegmentsCount = number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to a circle radius
* to generate the polygon.
* if aCorrectionFactor = 1.0, the polygon is inside the circle
* the radius of circle approximated by segments is
* initial radius * aCorrectionFactor
*/
void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_ID aLayer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
@ -141,13 +120,13 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
switch( aLayer )
{
case SOLDERMASK_N_FRONT:
case SOLDERMASK_N_BACK:
case F_Mask:
case B_Mask:
margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
break;
case SOLDERPASTE_N_FRONT:
case SOLDERPASTE_N_BACK:
case F_Paste:
case B_Paste:
margin = pad->GetSolderPasteMargin();
margin.x += aInflateValue;
margin.y += aInflateValue;
@ -175,7 +154,7 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
* initial radius * aCorrectionFactor
*/
void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer,
LAYER_ID aLayer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,

View File

@ -81,14 +81,14 @@ BOARD::BOARD() :
BuildListOfNets(); // prepare pad and netlist containers.
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer )
for( LAYER_NUM layer = 0; layer < LAYER_ID_COUNT; ++layer )
{
m_Layer[layer].m_Name = GetStandardLayerName( layer );
m_Layer[layer].m_name = GetStandardLayerName( ToLAYER_ID( layer ) );
if( layer <= LAST_COPPER_LAYER )
m_Layer[layer].m_Type = LT_SIGNAL;
if( IsCopperLayer( layer ) )
m_Layer[layer].m_type = LT_SIGNAL;
else
m_Layer[layer].m_Type = LT_UNDEFINED;
m_Layer[layer].m_type = LT_UNDEFINED;
}
NETCLASSPTR defaultClass = m_designSettings.GetDefault();
@ -188,14 +188,14 @@ void BOARD::Move( const wxPoint& aMoveVector ) // overload
}
void BOARD::chainMarkedSegments( wxPoint aPosition, LAYER_MSK aLayerMask, TRACK_PTRS* aList )
void BOARD::chainMarkedSegments( wxPoint aPosition, LSET aLayerMask, TRACK_PTRS* aList )
{
TRACK* segment; // The current segment being analyzed.
TRACK* via; // The via identified, eventually destroy
TRACK* candidate; // The end segment to destroy (or NULL = segment)
int NbSegm;
TRACK* segment; // The current segment being analyzed.
TRACK* via; // The via identified, eventually destroy
TRACK* candidate; // The end segment to destroy (or NULL = segment)
int NbSegm;
if( m_Track == NULL )
if( !m_Track )
return;
/* Set the BUSY flag of all connected segments, first search starting at
@ -227,7 +227,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, LAYER_MSK aLayerMask, TRACK_
if( via )
{
aLayerMask = via->GetLayerMask();
aLayerMask = via->GetLayerSet();
aList->push_back( via );
}
@ -273,7 +273,7 @@ void BOARD::chainMarkedSegments( wxPoint aPosition, LAYER_MSK aLayerMask, TRACK_
* candidate:
* we must analyze connections to its other end
*/
aLayerMask = candidate->GetLayerMask();
aLayerMask = candidate->GetLayerSet();
if( aPosition == candidate->GetStart() )
{
@ -311,9 +311,9 @@ void BOARD::PopHighLight()
}
bool BOARD::SetLayer( LAYER_NUM aIndex, const LAYER& aLayer )
bool BOARD::SetLayer( LAYER_ID aIndex, const LAYER& aLayer )
{
if( aIndex < NB_COPPER_LAYERS )
if( unsigned( aIndex ) < DIM( m_Layer ) )
{
m_Layer[ aIndex ] = aLayer;
return true;
@ -323,7 +323,7 @@ bool BOARD::SetLayer( LAYER_NUM aIndex, const LAYER& aLayer )
}
wxString BOARD::GetLayerName( LAYER_NUM aLayer ) const
wxString BOARD::GetLayerName( LAYER_ID aLayer ) const
{
if( !IsPcbLayer( aLayer ) )
return wxEmptyString;
@ -336,60 +336,14 @@ wxString BOARD::GetLayerName( LAYER_NUM aLayer ) const
// For copper layers, return the actual copper layer name,
// otherwise return the Standard English layer name.
if( IsCopperLayer( aLayer ) )
return m_Layer[aLayer].m_Name;
return m_Layer[aLayer].m_name;
}
return GetStandardLayerName( aLayer );
}
wxString BOARD::GetStandardLayerName( LAYER_NUM aLayerNumber )
{
const wxChar* txt;
// These are only default layer names. For Pcbnew the copper names
// may be over-ridden in the BOARD (*.brd) file.
// Use a switch to explicitly show the mapping more clearly
switch( aLayerNumber )
{
case LAYER_N_FRONT: txt = wxT( "F.Cu" ); break;
case LAYER_N_2: txt = wxT( "Inner1.Cu" ); break;
case LAYER_N_3: txt = wxT( "Inner2.Cu" ); break;
case LAYER_N_4: txt = wxT( "Inner3.Cu" ); break;
case LAYER_N_5: txt = wxT( "Inner4.Cu" ); break;
case LAYER_N_6: txt = wxT( "Inner5.Cu" ); break;
case LAYER_N_7: txt = wxT( "Inner6.Cu" ); break;
case LAYER_N_8: txt = wxT( "Inner7.Cu" ); break;
case LAYER_N_9: txt = wxT( "Inner8.Cu" ); break;
case LAYER_N_10: txt = wxT( "Inner9.Cu" ); break;
case LAYER_N_11: txt = wxT( "Inner10.Cu" ); break;
case LAYER_N_12: txt = wxT( "Inner11.Cu" ); break;
case LAYER_N_13: txt = wxT( "Inner12.Cu" ); break;
case LAYER_N_14: txt = wxT( "Inner13.Cu" ); break;
case LAYER_N_15: txt = wxT( "Inner14.Cu" ); break;
case LAYER_N_BACK: txt = wxT( "B.Cu" ); break;
case ADHESIVE_N_BACK: txt = wxT( "B.Adhes" ); break;
case ADHESIVE_N_FRONT: txt = wxT( "F.Adhes" ); break;
case SOLDERPASTE_N_BACK: txt = wxT( "B.Paste" ); break;
case SOLDERPASTE_N_FRONT: txt = wxT( "F.Paste" ); break;
case SILKSCREEN_N_BACK: txt = wxT( "B.SilkS" ); break;
case SILKSCREEN_N_FRONT: txt = wxT( "F.SilkS" ); break;
case SOLDERMASK_N_BACK: txt = wxT( "B.Mask" ); break;
case SOLDERMASK_N_FRONT: txt = wxT( "F.Mask" ); break;
case DRAW_N: txt = wxT( "Dwgs.User" ); break;
case COMMENT_N: txt = wxT( "Cmts.User" ); break;
case ECO1_N: txt = wxT( "Eco1.User" ); break;
case ECO2_N: txt = wxT( "Eco2.User" ); break;
case EDGE_N: txt = wxT( "Edge.Cuts" ); break;
default: txt = wxT( "BAD_INDEX" ); break;
}
return txt; // wxString constructed once here
}
bool BOARD::SetLayerName( LAYER_NUM aLayer, const wxString& aLayerName )
bool BOARD::SetLayerName( LAYER_ID aLayer, const wxString& aLayerName )
{
if( !IsCopperLayer( aLayer ) )
return false;
@ -401,20 +355,32 @@ bool BOARD::SetLayerName( LAYER_NUM aLayer, const wxString& aLayerName )
if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND )
return false;
wxString NameTemp = aLayerName;
wxString nameTemp = aLayerName;
// replace any spaces with underscores before we do any comparing
NameTemp.Replace( wxT( " " ), wxT( "_" ) );
nameTemp.Replace( wxT( " " ), wxT( "_" ) );
if( IsLayerEnabled( aLayer ) )
{
#if 0
for( LAYER_NUM i = FIRST_COPPER_LAYER; i < NB_COPPER_LAYERS; ++i )
{
if( i != aLayer && IsLayerEnabled( i ) && NameTemp == m_Layer[i].m_Name )
if( i != aLayer && IsLayerEnabled( i ) && nameTemp == m_Layer[i].m_Name )
return false;
}
#else
for( LSEQ cu = GetEnabledLayers().CuStack(); cu; ++cu )
{
LAYER_ID id = *cu;
m_Layer[aLayer].m_Name = NameTemp;
// veto changing the name if it exists elsewhere.
if( id != aLayer && nameTemp == m_Layer[id].m_name )
// if( id != aLayer && nameTemp == wxString( m_Layer[id].m_name ) )
return false;
}
#endif
m_Layer[aLayer].m_name = nameTemp;
return true;
}
@ -423,7 +389,7 @@ bool BOARD::SetLayerName( LAYER_NUM aLayer, const wxString& aLayerName )
}
LAYER_T BOARD::GetLayerType( LAYER_NUM aLayer ) const
LAYER_T BOARD::GetLayerType( LAYER_ID aLayer ) const
{
if( !IsCopperLayer( aLayer ) )
return LT_SIGNAL;
@ -431,13 +397,13 @@ LAYER_T BOARD::GetLayerType( LAYER_NUM aLayer ) const
//@@IMB: The original test was broken due to the discontinuity
// in the layer sequence.
if( IsLayerEnabled( aLayer ) )
return m_Layer[aLayer].m_Type;
return m_Layer[aLayer].m_type;
return LT_SIGNAL;
}
bool BOARD::SetLayerType( LAYER_NUM aLayer, LAYER_T aLayerType )
bool BOARD::SetLayerType( LAYER_ID aLayer, LAYER_T aLayerType )
{
if( !IsCopperLayer( aLayer ) )
return false;
@ -446,7 +412,7 @@ bool BOARD::SetLayerType( LAYER_NUM aLayer, LAYER_T aLayerType )
// in the layer sequence.
if( IsLayerEnabled( aLayer ) )
{
m_Layer[aLayer].m_Type = aLayerType;
m_Layer[aLayer].m_type = aLayerType;
return true;
}
@ -509,25 +475,25 @@ void BOARD::SetCopperLayerCount( int aCount )
}
LAYER_MSK BOARD::GetEnabledLayers() const
LSET BOARD::GetEnabledLayers() const
{
return m_designSettings.GetEnabledLayers();
}
LAYER_MSK BOARD::GetVisibleLayers() const
LSET BOARD::GetVisibleLayers() const
{
return m_designSettings.GetVisibleLayers();
}
void BOARD::SetEnabledLayers( LAYER_MSK aLayerMask )
void BOARD::SetEnabledLayers( LSET aLayerMask )
{
m_designSettings.SetEnabledLayers( aLayerMask );
}
void BOARD::SetVisibleLayers( LAYER_MSK aLayerMask )
void BOARD::SetVisibleLayers( LSET aLayerMask )
{
m_designSettings.SetVisibleLayers( aLayerMask );
}
@ -548,7 +514,7 @@ void BOARD::SetVisibleElements( int aMask )
void BOARD::SetVisibleAlls()
{
SetVisibleLayers( FULL_LAYERS );
SetVisibleLayers( LSET().set() );
// Call SetElementVisibility for each item,
// to ensure specific calculations that can be needed by some items
@ -652,26 +618,26 @@ void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, EDA_COLOR_T aColor )
}
void BOARD::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
void BOARD::SetLayerColor( LAYER_ID aLayer, EDA_COLOR_T aColor )
{
GetColorsSettings()->SetLayerColor( aLayer, aColor );
}
EDA_COLOR_T BOARD::GetLayerColor( LAYER_NUM aLayer ) const
EDA_COLOR_T BOARD::GetLayerColor( LAYER_ID aLayer ) const
{
return GetColorsSettings()->GetLayerColor( aLayer );
}
bool BOARD::IsModuleLayerVisible( LAYER_NUM layer )
bool BOARD::IsModuleLayerVisible( LAYER_ID layer )
{
switch( layer )
{
case LAYER_N_FRONT:
case F_Cu:
return IsElementVisible( PCB_VISIBLE(MOD_FR_VISIBLE) );
case LAYER_N_BACK:
case B_Cu:
return IsElementVisible( PCB_VISIBLE(MOD_BK_VISIBLE) );
default:
@ -873,7 +839,7 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
// Check segments, dimensions, texts, and fiducials
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( aBoardEdgesOnly && (item->Type() != PCB_LINE_T || item->GetLayer() != EDGE_N ) )
if( aBoardEdgesOnly && (item->Type() != PCB_LINE_T || item->GetLayer() != Edge_Cuts ) )
continue;
if( !hasItems )
@ -1198,7 +1164,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
* D_PAD* pad = (D_PAD*) item;
* if( pad->HitTest( refPos ) )
* {
* if( layer_mask & pad->GetLayerMask() )
* if( layer_mask & pad->GetLayerSet() )
* {
* found = item;
* return SEARCH_QUIT;
@ -1367,7 +1333,7 @@ int BOARD::SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
}
void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, LAYER_NUM aLayer )
void BOARD::RedrawAreasOutlines( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, LAYER_ID aLayer )
{
if( !aDC )
return;
@ -1382,7 +1348,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, LAYER_NUM aLayer )
void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, LAYER_ID aLayer )
{
if( !aDC )
return;
@ -1398,9 +1364,7 @@ void BOARD::RedrawFilledAreas( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDr
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
LAYER_NUM aStartLayer,
LAYER_NUM aEndLayer,
int aNetCode )
LAYER_ID aStartLayer, LAYER_ID aEndLayer, int aNetCode )
{
if( aEndLayer < 0 )
aEndLayer = aStartLayer;
@ -1413,7 +1377,7 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
ZONE_CONTAINER* area = m_ZoneDescriptorList[ia];
LAYER_NUM layer = area->GetLayer();
if( (layer < aStartLayer) || (layer > aEndLayer) )
if( layer < aStartLayer || layer > aEndLayer )
continue;
// In locate functions we must skip tagged items with BUSY flag set.
@ -1431,32 +1395,34 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
}
int BOARD::SetAreasNetCodesFromNetNames( void )
int BOARD::SetAreasNetCodesFromNetNames()
{
int error_count = 0;
for( int ii = 0; ii < GetAreaCount(); ii++ )
{
if( !GetArea( ii )->IsOnCopperLayer() )
ZONE_CONTAINER* it = GetArea( ii );
if( !it->IsOnCopperLayer() )
{
GetArea( ii )->SetNetCode( NETINFO_LIST::UNCONNECTED );
it->SetNetCode( NETINFO_LIST::UNCONNECTED );
continue;
}
if( GetArea( ii )->GetNetCode() != 0 ) // i.e. if this zone is connected to a net
if( it->GetNetCode() != 0 ) // i.e. if this zone is connected to a net
{
const NETINFO_ITEM* net = GetArea( ii )->GetNet();
const NETINFO_ITEM* net = it->GetNet();
if( net )
{
GetArea( ii )->SetNetCode( net->GetNet() );
it->SetNetCode( net->GetNet() );
}
else
{
error_count++;
// keep Net Name and set m_NetCode to -1 : error flag.
GetArea( ii )->SetNetCode( -1 );
it->SetNetCode( -1 );
}
}
}
@ -1465,7 +1431,7 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
}
VIA* BOARD::GetViaByPosition( const wxPoint& aPosition, LAYER_NUM aLayer) const
VIA* BOARD::GetViaByPosition( const wxPoint& aPosition, LAYER_ID aLayer) const
{
for( VIA *via = GetFirstVia( m_Track); via; via = GetFirstVia( via->Next() ) )
{
@ -1479,42 +1445,42 @@ VIA* BOARD::GetViaByPosition( const wxPoint& aPosition, LAYER_NUM aLayer) const
}
D_PAD* BOARD::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask )
D_PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerMask )
{
D_PAD* pad = NULL;
if( !aLayerMask.any() )
aLayerMask = LSET::AllCuMask();
for( MODULE* module = m_Modules; module && ( pad == NULL ); module = module->Next() )
for( MODULE* module = m_Modules; module; module = module->Next() )
{
if( aLayerMask )
pad = module->GetPad( aPosition, aLayerMask );
else
pad = module->GetPad( aPosition, ALL_LAYERS );
D_PAD* pad = module->GetPad( aPosition, aLayerMask );
if( pad )
return pad;
}
return pad;
return NULL;
}
D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint )
{
D_PAD* pad = NULL;
const wxPoint &aPosition = aTrace->GetEndPoint( aEndPoint );
const wxPoint& aPosition = aTrace->GetEndPoint( aEndPoint );
LAYER_MSK aLayerMask = GetLayerMask( aTrace->GetLayer() );
LSET aLayerMask( aTrace->GetLayer() );
for( MODULE* module = m_Modules; module; module = module->Next() )
{
pad = module->GetPad( aPosition, aLayerMask );
D_PAD* pad = module->GetPad( aPosition, aLayerMask );
if( pad != NULL )
break;
if( pad )
return pad;
}
return pad;
return NULL;
}
D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask )
D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerMask )
{
for( unsigned i=0; i<GetPadCount(); ++i )
{
@ -1523,8 +1489,8 @@ D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask )
if( pad->GetPosition() != aPosition )
continue;
/* Pad found, it must be on the correct layer */
if( pad->GetLayerMask() & aLayerMask )
// Pad found, it must be on the correct layer
if( ( pad->GetLayerSet() & aLayerMask ).any() )
return pad;
}
@ -1532,7 +1498,7 @@ D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask )
}
D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, LAYER_MSK aLayerMask )
D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask )
{
// Search the aPoint coordinates in aPadList
// aPadList is sorted by X then Y values, and a fast binary search is used
@ -1556,7 +1522,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, L
if( pad->GetPosition() == aPosition ) // candidate found
{
// The pad must match the layer mask:
if( aLayerMask & pad->GetLayerMask())
if( ( aLayerMask & pad->GetLayerSet() ).any() )
return pad;
// More than one pad can be at aPosition
@ -1570,7 +1536,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, L
if( pad->GetPosition() != aPosition )
break;
if( (aLayerMask & pad->GetLayerMask()) != 0 )
if( (aLayerMask & pad->GetLayerSet()) != 0 )
return pad;
}
// search previous
@ -1581,7 +1547,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, L
if( pad->GetPosition() != aPosition )
break;
if( (aLayerMask & pad->GetLayerMask()) != 0 )
if( (aLayerMask & pad->GetLayerSet()) != 0 )
return pad;
}
@ -1661,11 +1627,11 @@ void BOARD::GetSortedPadListByXthenYCoord( std::vector<D_PAD*>& aVector, int aNe
TRACK* BOARD::GetTrack( TRACK* aTrace, const wxPoint& aPosition,
LAYER_MSK aLayerMask ) const
LSET aLayerMask ) const
{
for( TRACK* track = aTrace; track; track = track->Next() )
{
LAYER_NUM layer = track->GetLayer();
LAYER_ID layer = track->GetLayer();
if( track->GetState( BUSY | IS_DELETED ) )
continue;
@ -1680,8 +1646,8 @@ TRACK* BOARD::GetTrack( TRACK* aTrace, const wxPoint& aPosition,
}
else
{
if( (GetLayerMask( layer ) & aLayerMask) == 0 )
continue; /* Segments on different layers. */
if( !aLayerMask[layer] )
continue; // Segments on different layers.
if( track->HitTest( aPosition ) )
return track;
@ -1714,9 +1680,9 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
for( TRACK* track = m_Track; track; track = track->Next() )
track->SetState( BUSY, false );
/* Set flags of the initial track segment */
// Set flags of the initial track segment
aTrace->SetState( BUSY, true );
LAYER_MSK layerMask = aTrace->GetLayerMask();
LSET layerMask = aTrace->GetLayerSet();
trackList.push_back( aTrace );
@ -1752,13 +1718,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
if( Segm1 ) // search for others segments connected to the initial segment start point
{
layerMask = Segm1->GetLayerMask();
layerMask = Segm1->GetLayerSet();
chainMarkedSegments( aTrace->GetStart(), layerMask, &trackList );
}
if( Segm2 ) // search for others segments connected to the initial segment end point
{
layerMask = Segm2->GetLayerMask();
layerMask = Segm2->GetLayerSet();
chainMarkedSegments( aTrace->GetStart(), layerMask, &trackList );
}
}
@ -1785,7 +1751,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
via->SetState( BUSY, true ); // Try to flag it. the flag will be cleared later if needed
layerMask = via->GetLayerMask();
layerMask = via->GetLayerSet();
TRACK* track = ::GetTrack( m_Track, NULL, via->GetStart(), layerMask );
@ -1932,7 +1898,7 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, int* aCount,
}
MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_ID aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked )
{
MODULE* pt_module;
@ -1952,12 +1918,13 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
if( aIgnoreLocked && pt_module->IsLocked() )
continue;
LAYER_NUM layer = pt_module->GetLayer();
LAYER_ID layer = pt_module->GetLayer();
// Filter non visible modules if requested
if( (!aVisibleOnly) || IsModuleLayerVisible( layer ) )
if( !aVisibleOnly || IsModuleLayerVisible( layer ) )
{
EDA_RECT bb = pt_module->GetFootprintRect();
int offx = bb.GetX() + bb.GetWidth() / 2;
int offy = bb.GetY() + bb.GetHeight() / 2;
@ -2000,7 +1967,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
}
BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LAYER_MSK aLayerMask )
BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LSET aLayerMask )
{
for( MODULE* module = m_Modules; module; module = module->Next() )
{
@ -2010,7 +1977,7 @@ BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, LAYER_MSK a
return pad;
}
/* No pad has been located so check for a segment of the trace. */
// No pad has been located so check for a segment of the trace.
TRACK* segment = ::GetTrack( m_Track, NULL, aPosition, aLayerMask );
if( segment == NULL )
@ -2030,7 +1997,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
if( aSegment->GetStart() == aPosition || aSegment->GetEnd() == aPosition )
return NULL;
/* A via is a good lock point */
// A via is a good lock point
if( aSegment->Type() == PCB_VIA_T )
{
aPosition = aSegment->GetStart();
@ -2046,7 +2013,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
// lockPoint must be on aSegment:
// Ensure lockPoint.y/lockPoint.y = delta.y/delta.x
if( delta.x == 0 )
lockPoint.x = 0; /* horizontal segment*/
lockPoint.x = 0; // horizontal segment
else
lockPoint.y = KiROUND( ( (double)lockPoint.x * delta.y ) / delta.x );
@ -2099,7 +2066,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
ZONE_CONTAINER* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode,
LAYER_NUM aLayer, wxPoint aStartPointPosition, int aHatch )
LAYER_ID aLayer, wxPoint aStartPointPosition, int aHatch )
{
ZONE_CONTAINER* new_area = InsertArea( aNetcode,
m_ZoneDescriptorList.size( ) - 1,
@ -2134,7 +2101,7 @@ void BOARD::RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to
}
ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, LAYER_NUM layer, int x, int y, int hatch )
ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, LAYER_ID layer, int x, int y, int hatch )
{
ZONE_CONTAINER* new_area = new ZONE_CONTAINER( this );

View File

@ -87,29 +87,32 @@ enum LAYER_T
* Class LAYER
* holds information pertinent to a layer of a BOARD.
*/
class LAYER
struct LAYER
{
public:
LAYER( const wxString& aName = wxEmptyString, LAYER_T aType = LT_SIGNAL,
bool aVisible = true ) :
m_Name( aName ),
m_Type( aType ),
LAYER() :
m_type( LT_SIGNAL ),
m_visible( true ),
m_number( 0 )
{}
/*
LAYER( const wxString& aName = wxEmptyString,
LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
m_name( aName ),
m_type( aType ),
m_visible( aVisible ),
m_fixedListIndex( UNDEFINED_LAYER )
m_number( aNumber )
{
}
*/
void SetVisible( bool aEnable ) { m_visible = aEnable; }
bool IsVisible() const { return m_visible; }
wxString m_name; ///< The name of the layer, there should be no spaces in this name.
void SetFixedListIndex( int aIndex ) { m_fixedListIndex = aIndex; }
int GetFixedListIndex() const { return m_fixedListIndex; }
LAYER_T m_type; ///< The type of the layer
/** The name of the layer, there should be no spaces in this name. */
wxString m_Name;
bool m_visible;
/** The type of the layer */
LAYER_T m_Type;
int m_number;
/**
* Function ShowType
@ -127,10 +130,6 @@ public:
* LAYER_T(-1) if the string is invalid
*/
static LAYER_T ParseType( const char* aType );
private:
bool m_visible;
int m_fixedListIndex;
};
@ -180,7 +179,7 @@ private:
/// edge zone descriptors, owned by pointer.
ZONE_CONTAINERS m_ZoneDescriptorList;
LAYER m_Layer[NB_LAYERS];
LAYER m_Layer[LAYER_ID_COUNT];
wxPoint m_grid_origin;
// if true m_highLight_NetCode is used
@ -217,7 +216,7 @@ private:
* @param aLayerMask The allowed layers for segments to search.
* @param aList The track list to fill with points of flagged segments.
*/
void chainMarkedSegments( wxPoint aPosition, LAYER_MSK aLayerMask, TRACK_PTRS* aList );
void chainMarkedSegments( wxPoint aPosition, LSET aLayerMask, TRACK_PTRS* aList );
public:
static inline bool ClassOf( const EDA_ITEM* aItem )
@ -440,11 +439,11 @@ public:
/**
* Function GetEnabledLayers
* is a proxy function that calls the correspondent function in m_BoardSettings
* is a proxy function that calls the corresponding function in m_BoardSettings
* Returns a bit-mask of all the layers that are enabled
* @return int - the enabled layers in bit-mapped form.
*/
LAYER_MSK GetEnabledLayers() const;
LSET GetEnabledLayers() const;
/**
* Function SetEnabledLayers
@ -452,7 +451,7 @@ public:
* Changes the bit-mask of enabled layers
* @param aLayerMask = The new bit-mask of enabled layers
*/
void SetEnabledLayers( LAYER_MSK aLayerMask );
void SetEnabledLayers( LSET aLayerMask );
/**
* Function IsLayerEnabled
@ -461,7 +460,7 @@ public:
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
*/
bool IsLayerEnabled( LAYER_NUM aLayer ) const
bool IsLayerEnabled( LAYER_ID aLayer ) const
{
return m_designSettings.IsLayerEnabled( aLayer );
}
@ -473,7 +472,7 @@ public:
* @param aLayer = The layer to be tested
* @return bool - true if the layer is visible.
*/
bool IsLayerVisible( LAYER_NUM aLayer ) const
bool IsLayerVisible( LAYER_ID aLayer ) const
{
return m_designSettings.IsLayerVisible( aLayer );
}
@ -484,7 +483,7 @@ public:
* Returns a bit-mask of all the layers that are visible
* @return int - the visible layers in bit-mapped form.
*/
LAYER_MSK GetVisibleLayers() const;
LSET GetVisibleLayers() const;
/**
* Function SetVisibleLayers
@ -492,7 +491,7 @@ public:
* changes the bit-mask of visible layers
* @param aLayerMask = The new bit-mask of visible layers
*/
void SetVisibleLayers( LAYER_MSK aLayerMask );
void SetVisibleLayers( LSET aLayerMask );
// these 2 functions are not tidy at this time, since there are PCB_VISIBLEs that
// are not stored in the bitmap.
@ -545,10 +544,10 @@ public:
* Function IsModuleLayerVisible
* expects either of the two layers on which a module can reside, and returns
* whether that layer is visible.
* @param layer One of the two allowed layers for modules: LAYER_N_FRONT or LAYER_N_BACK
* @param layer One of the two allowed layers for modules: F_Cu or B_Cu
* @return bool - true if the layer is visible, else false.
*/
bool IsModuleLayerVisible( LAYER_NUM layer );
bool IsModuleLayerVisible( LAYER_ID layer );
/**
* Function GetVisibleElementColor
@ -630,33 +629,33 @@ public:
* Usefull to export the shape of copper layers to dxf polygons
* or 3D viewer
* the polygons are not merged.
* @param aLayer = A copper layer, like LAYER_N_BACK, etc.
* @param aLayer = A copper layer, like B_Cu, etc.
* @param aOutlines The CPOLYGONS_LIST to fill in with items outline.
*/
void ConvertBrdLayerToPolygonalContours( LAYER_NUM aLayer, CPOLYGONS_LIST& aOutlines );
void ConvertBrdLayerToPolygonalContours( LAYER_ID aLayer, CPOLYGONS_LIST& aOutlines );
/**
* Function GetLayerName
* returns the name of a layer given by aLayer. Copper layers may
* have custom names.
*
* @param aLayer = A layer, like LAYER_N_BACK, etc.
* @param aLayer = A layer, like B_Cu, etc.
*
* @return wxString - the layer name, which for copper layers may
* be custom, else standard.
*/
wxString GetLayerName( LAYER_NUM aLayer ) const;
wxString GetLayerName( LAYER_ID aLayer ) const;
/**
* Function SetLayerName
* changes the name of the layer given by aLayer.
*
* @param aLayer A layer, like LAYER_N_BACK, etc.
* @param aLayer A layer, like B_Cu, etc.
* @param aLayerName The new layer name
* @return bool - true if aLayerName was legal and unique among other
* layer names at other layer indices and aLayer was within range, else false.
*/
bool SetLayerName( LAYER_NUM aLayer, const wxString& aLayerName );
bool SetLayerName( LAYER_ID aLayer, const wxString& aLayerName );
/**
* Function GetStandardLayerName
@ -666,44 +665,48 @@ public:
* be different than the default if the user has renamed any copper layers.
*
* @param aLayerNumber is the layer number to fetch
* @return wxString - containing the layer name or "BAD INDEX" if aLayerNumber
* @return const wxString - containing the layer name or "BAD INDEX" if aLayerNumber
* is not legal
*/
static wxString GetStandardLayerName( LAYER_NUM aLayerNumber );
static const wxString GetStandardLayerName( LAYER_ID aLayerId )
{
// a BOARD's standard layer name is the LAYER_ID fixed name
return LSET::Name( aLayerId );
}
bool SetLayer( LAYER_NUM aIndex, const LAYER& aLayer );
bool SetLayer( LAYER_ID aIndex, const LAYER& aLayer );
/**
* Function GetLayerType
* returns the type of the copper layer given by aLayer.
*
* @param aLayer A layer index, like LAYER_N_BACK, etc.
* @param aLayer A layer index, like B_Cu, etc.
* @return LAYER_T - the layer type, or LAYER_T(-1) if the
* index was out of range.
*/
LAYER_T GetLayerType( LAYER_NUM aLayer ) const;
LAYER_T GetLayerType( LAYER_ID aLayer ) const;
/**
* Function SetLayerType
* changes the type of the layer given by aLayer.
*
* @param aLayer A layer index, like LAYER_N_BACK, etc.
* @param aLayer A layer index, like B_Cu, etc.
* @param aLayerType The new layer type.
* @return bool - true if aLayerType was legal and aLayer was within range, else false.
*/
bool SetLayerType( LAYER_NUM aLayer, LAYER_T aLayerType );
bool SetLayerType( LAYER_ID aLayer, LAYER_T aLayerType );
/**
* Function SetLayerColor
* changes a layer color for any valid layer, including non-copper ones.
*/
void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
void SetLayerColor( LAYER_ID aLayer, EDA_COLOR_T aColor );
/**
* Function GetLayerColor
* gets a layer color for any valid layer, including non-copper ones.
*/
EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
EDA_COLOR_T GetLayerColor( LAYER_ID aLayer ) const;
/** Functions to get some items count */
int GetNumSegmTrack() const;
@ -998,8 +1001,8 @@ public:
* @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else NULL
*/
ZONE_CONTAINER* HitTestForAnyFilledArea( const wxPoint& aRefPos,
LAYER_NUM aStartLayer,
LAYER_NUM aEndLayer,
LAYER_ID aStartLayer,
LAYER_ID aEndLayer,
int aNetCode );
/**
@ -1009,14 +1012,14 @@ public:
void RedrawAreasOutlines( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
GR_DRAWMODE aDrawMode,
LAYER_NUM aLayer );
LAYER_ID 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,
LAYER_NUM aLayer );
LAYER_ID aLayer );
/**
* Function SetAreasNetCodesFromNetNames
@ -1084,14 +1087,14 @@ public:
* @return a reference to the new area
*/
ZONE_CONTAINER* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode,
LAYER_NUM aLayer, wxPoint aStartPointPosition, int aHatch );
LAYER_ID 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, LAYER_NUM layer, int x, int y, int hatch );
ZONE_CONTAINER* InsertArea( int netcode, int iarea, LAYER_ID layer, int x, int y, int hatch );
/**
* Function NormalizeAreaPolygon
@ -1207,7 +1210,7 @@ public:
* @param aLayer The layer to search. Use -1 for a don't care.
* @return VIA* A point a to the VIA object if found, else NULL.
*/
VIA* GetViaByPosition( const wxPoint& aPosition, LAYER_NUM aLayer = UNDEFINED_LAYER ) const;
VIA* GetViaByPosition( const wxPoint& aPosition, LAYER_ID aLayer = UNDEFINED_LAYER ) const;
/**
* Function GetPad
@ -1217,7 +1220,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a D_PAD object if found or NULL if not found.
*/
D_PAD* GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask = ALL_LAYERS );
D_PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask = LSET().set() );
/**
* Function GetPad
@ -1239,7 +1242,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a D_PAD object if found or NULL if not found.
*/
D_PAD* GetPadFast( const wxPoint& aPosition, LAYER_MSK aLayerMask );
D_PAD* GetPadFast( const wxPoint& aPosition, LSET aLayerMask );
/**
* Function GetPad
@ -1256,7 +1259,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return a D_PAD object pointer to the connected pad.
*/
D_PAD* GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, LAYER_MSK aLayerMask );
D_PAD* GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask );
/**
* Function GetSortedPadListByXthenYCoord
@ -1283,7 +1286,7 @@ public:
* layer mask.
* @return A TRACK object pointer if found otherwise NULL.
*/
TRACK* GetTrack( TRACK* aTrace, const wxPoint& aPosition, LAYER_MSK aLayerMask ) const;
TRACK* GetTrack( TRACK* aTrace, const wxPoint& aPosition, LSET aLayerMask ) const;
/**
* Function MarkTrace
@ -1326,7 +1329,7 @@ public:
* @param aIgnoreLocked Ignore locked modules when true.
* @return MODULE* The best module or NULL if none.
*/
MODULE* GetFootprint( const wxPoint& aPosition, LAYER_NUM aActiveLayer,
MODULE* GetFootprint( const wxPoint& aPosition, LAYER_ID aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked = false );
/**
@ -1342,7 +1345,7 @@ public:
* layer mask.
* @return A pointer to a BOARD_ITEM object if found otherwise NULL.
*/
BOARD_CONNECTED_ITEM* GetLockPoint( const wxPoint& aPosition, LAYER_MSK aLayerMask );
BOARD_CONNECTED_ITEM* GetLockPoint( const wxPoint& aPosition, LSET aLayerMask );
/**
* Function CreateLockPoint

View File

@ -54,10 +54,11 @@
BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() :
m_Pad_Master( NULL )
{
m_enabledLayers = ALL_LAYERS; // All layers enabled at first.
// SetCopperLayerCount() will adjust this.
LSET all_set = LSET().set();
SetVisibleLayers( FULL_LAYERS );
m_enabledLayers = all_set; // All layers enabled at first.
// SetCopperLayerCount() will adjust this.
SetVisibleLayers( all_set );
// set all but hidden text as visible.
m_visibleElements = ~( 1 << MOD_TEXT_INVISIBLE );
@ -305,17 +306,17 @@ void BOARD_DESIGN_SETTINGS::SetTrackWidthIndex( unsigned aIndex )
void BOARD_DESIGN_SETTINGS::SetVisibleAlls()
{
SetVisibleLayers( FULL_LAYERS );
SetVisibleLayers( LSET().set() );
m_visibleElements = -1;
}
void BOARD_DESIGN_SETTINGS::SetLayerVisibility( LAYER_NUM aLayer, bool aNewState )
void BOARD_DESIGN_SETTINGS::SetLayerVisibility( LAYER_ID aLayer, bool aNewState )
{
if( aNewState && IsLayerEnabled( aLayer ) )
m_visibleLayers |= GetLayerMask( aLayer );
m_visibleLayers.set( aLayer, true );
else
m_visibleLayers &= ~GetLayerMask( aLayer );
m_visibleLayers.set( aLayer, false );
}
@ -338,6 +339,8 @@ void BOARD_DESIGN_SETTINGS::SetCopperLayerCount( int aNewLayerCount )
m_copperLayerCount = aNewLayerCount;
// ensure consistency with the m_EnabledLayers member
#if 0
// was:
m_enabledLayers &= ~ALL_CU_LAYERS;
m_enabledLayers |= LAYER_BACK;
@ -345,14 +348,17 @@ void BOARD_DESIGN_SETTINGS::SetCopperLayerCount( int aNewLayerCount )
m_enabledLayers |= LAYER_FRONT;
for( LAYER_NUM ii = LAYER_N_2; ii < aNewLayerCount - 1; ++ii )
m_enabledLayers |= GetLayerMask( ii );
m_enabledLayers |= GetLayerSet( ii );
#else
m_enabledLayers = LSET::AllCuMask( aNewLayerCount );
#endif
}
void BOARD_DESIGN_SETTINGS::SetEnabledLayers( LAYER_MSK aMask )
void BOARD_DESIGN_SETTINGS::SetEnabledLayers( LSET aMask )
{
// Back and front layers are always enabled.
aMask |= LAYER_BACK | LAYER_FRONT;
aMask.set( B_Cu ).set( F_Cu );
m_enabledLayers = aMask;
@ -360,7 +366,7 @@ void BOARD_DESIGN_SETTINGS::SetEnabledLayers( LAYER_MSK aMask )
m_visibleLayers &= aMask;
// update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
m_copperLayerCount = LayerMaskCountSet( aMask & ALL_CU_LAYERS);
m_copperLayerCount = ( aMask & LSET::AllCuMask() ).count();
}

View File

@ -49,7 +49,7 @@ DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
BOARD_ITEM( aParent, PCB_DIMENSION_T ),
m_Width( Millimeter2iu( 0.2 ) ), m_Unit( INCHES ), m_Value( 0 ), m_Height( 0 ), m_Text( this )
{
m_Layer = DRAW_N;
m_Layer = Dwgs_User;
}
@ -82,7 +82,7 @@ const wxString DIMENSION::GetText() const
}
void DIMENSION::SetLayer( LAYER_NUM aLayer )
void DIMENSION::SetLayer( LAYER_ID aLayer )
{
m_Layer = aLayer;
m_Text.SetLayer( aLayer );

View File

@ -95,7 +95,7 @@ public:
m_Text.SetSize( aTextSize );
}
void SetLayer( LAYER_NUM aLayer );
void SetLayer( LAYER_ID aLayer );
void SetShape( int aShape ) { m_Shape = aShape; }
int GetShape() const { return m_Shape; }

View File

@ -173,7 +173,8 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
int l_trace;
int mode;
int radius;
LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
EDA_COLOR_T color;
BOARD * brd = GetBoard( );
@ -185,13 +186,12 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay )
{
if( !IsOnLayer( curr_layer ) && !IsOnLayer( EDGE_N ) )
if( !IsOnLayer( curr_layer ) && !IsOnLayer( Edge_Cuts ) )
ColorTurnToDarkDarkGray( &color );
}
GRSetDrawMode( DC, draw_mode );
l_trace = m_Width >> 1; /* half trace width */
l_trace = m_Width >> 1; // half trace width
// Line start point or Circle and Arc center
ux0 = m_Start.x + aOffset.x;
@ -247,7 +247,6 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
EXCHG( StAngle, EndAngle );
}
if( mode == LINE )
GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, radius, color );
@ -612,4 +611,3 @@ EDA_ITEM* DRAWSEGMENT::Clone() const
{
return new DRAWSEGMENT( *this );
}

View File

@ -57,7 +57,7 @@ EDGE_MODULE::EDGE_MODULE( MODULE* parent, STROKE_T aShape ) :
{
m_Shape = aShape;
m_Angle = 0;
m_Layer = SILKSCREEN_N_FRONT;
m_Layer = F_SilkS;
}
@ -111,18 +111,17 @@ void EDGE_MODULE::SetDrawCoord()
void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
const wxPoint& offset )
{
int ux0, uy0, dx, dy, radius, StAngle, EndAngle;
int type_trace;
int typeaff;
LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
PCB_BASE_FRAME* frame;
int ux0, uy0, dx, dy, radius, StAngle, EndAngle;
int type_trace;
int typeaff;
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
MODULE* module = (MODULE*) m_Parent;
if( module == NULL )
if( !module )
return;
BOARD * brd = GetBoard( );
BOARD* brd = GetBoard( );
if( brd->IsLayerVisible( m_Layer ) == false )
return;
@ -135,8 +134,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
ColorTurnToDarkDarkGray( &color );
}
frame = (PCB_BASE_FRAME*) panel->GetParent();
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
type_trace = m_Shape;
@ -149,7 +147,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
GRSetDrawMode( DC, draw_mode );
typeaff = frame->m_DisplayModEdge;
if( m_Layer <= LAST_COPPER_LAYER )
if( IsCopperLayer( m_Layer ) )
{
typeaff = frame->m_DisplayPcbTrackFill;

View File

@ -85,7 +85,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( LAYER_NUM aLayer ) const
bool MARKER_PCB::IsOnLayer( LAYER_ID aLayer ) const
{
return IsCopperLayer( aLayer );
}

View File

@ -79,7 +79,7 @@ public:
return HitTestMarker( aPosition );
}
bool IsOnLayer( LAYER_NUM aLayer ) const;
bool IsOnLayer( LAYER_ID aLayer ) const;
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );

View File

@ -51,11 +51,11 @@ PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :
m_Shape = 0;
m_Size = Millimeter2iu( 5 ); // Gives a decent size
m_Width = Millimeter2iu( 0.15 ); // Gives a decent width
m_Layer = EDGE_N; // a target is on all layers
m_Layer = Edge_Cuts; // a target is on all layers
}
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent, int aShape, LAYER_NUM aLayer,
const wxPoint& aPos, int aSize, int aWidth ) :
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent, int aShape, LAYER_ID aLayer,
const wxPoint& aPos, int aSize, int aWidth ) :
BOARD_ITEM( aParent, PCB_TARGET_T )
{
m_Shape = aShape;

View File

@ -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, LAYER_NUM aLayer,
PCB_TARGET( BOARD_ITEM* aParent, int aShape, LAYER_ID aLayer,
const wxPoint& aPos, int aSize, int aWidth );
~PCB_TARGET();

View File

@ -57,7 +57,7 @@ MODULE::MODULE( BOARD* parent ) :
m_initial_comments( 0 )
{
m_Attributs = MOD_DEFAULT;
m_Layer = LAYER_N_FRONT;
m_Layer = F_Cu;
m_Orient = 0;
m_ModuleStatus = 0;
flag = 0;
@ -424,7 +424,7 @@ EDA_RECT MODULE::GetFootprintRect() const
for( const BOARD_ITEM* item = m_Drawings.GetFirst(); item; item = item->Next() )
{
const EDGE_MODULE* edge = dyn_cast<const EDGE_MODULE*>( item );
const EDGE_MODULE* edge = dyn_cast<const EDGE_MODULE*>( item );
if( edge )
area.Merge( edge->GetBoundingBox() );
@ -590,12 +590,12 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
}
D_PAD* MODULE::GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask )
D_PAD* MODULE::GetPad( const wxPoint& aPosition, LSET aLayerMask )
{
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
// ... and on the correct layer.
if( ( pad->GetLayerMask() & aLayerMask ) == 0 )
if( !( pad->GetLayerSet() & aLayerMask ).any() )
continue;
if( pad->HitTest( aPosition ) )

View File

@ -189,7 +189,7 @@ public:
* function IsFlipped
* @return true if the module is flipped, i.e. on the back side of the board
*/
bool IsFlipped() const {return GetLayer() == LAYER_N_BACK; }
bool IsFlipped() const {return GetLayer() == B_Cu; }
// m_ModuleStatus bits:
#define MODULE_is_LOCKED 0x01 ///< module LOCKED: no autoplace allowed
@ -282,7 +282,7 @@ public:
* the radius of circle approximated by segments is
* initial radius * aCorrectionFactor
*/
void TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
void TransformPadsShapesWithClearanceToPolygon( LAYER_ID aLayer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
@ -306,13 +306,12 @@ public:
* initial radius * aCorrectionFactor
*/
void TransformGraphicShapesWithClearanceToPolygonSet(
LAYER_NUM aLayer,
LAYER_ID aLayer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor );
/**
* Function DrawEdgesOnly
* Draws the footprint edges only to the current Device Context
@ -400,7 +399,7 @@ public:
* @param aLayerMask A layer or layers to mask the hit test.
* @return A pointer to a D_PAD object if found otherwise NULL.
*/
D_PAD* GetPad( const wxPoint& aPosition, LAYER_MSK aLayerMask = ALL_LAYERS );
D_PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask = LSET::AllLayersMask() );
enum INCLUDE_NPTH_T
{

View File

@ -78,7 +78,7 @@ D_PAD::D_PAD( MODULE* parent ) :
m_ThermalGap = 0; // Use parent setting by default
// Set layers mask to default for a standard thru hole pad.
m_layerMask = PAD_STANDARD_DEFAULT_LAYERS;
m_layerMask = StandardMask();
SetSubRatsnest( 0 ); // used in ratsnest calculations
@ -86,6 +86,38 @@ D_PAD::D_PAD( MODULE* parent ) :
}
LSET D_PAD::StandardMask()
{
static LSET saved = LSET::AllCuMask() | LSET( 3, F_SilkS, B_Mask, F_Mask );
return saved;
}
LSET D_PAD::ConnMask()
{
// was: #define PAD_CONN_DEFAULT_LAYERS LAYER_FRONT | SOLDERPASTE_LAYER_FRONT | SOLDERMASK_LAYER_FRONT
static LSET saved( 3, F_Cu, F_Paste, F_Mask );
return saved;
}
LSET D_PAD::SMDMask()
{
// was: #define PAD_SMD_DEFAULT_LAYERS LAYER_FRONT | SOLDERMASK_LAYER_FRONT
static LSET saved( 2, F_Cu, F_Mask );
return saved;
}
LSET D_PAD::UnplatedHoleMask()
{
// was #define PAD_HOLE_NOT_PLATED_DEFAULT_LAYERS ALL_CU_LAYERS |
// SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT
static LSET saved = LSET::AllCuMask() | LSET( 3, F_SilkS, B_Mask, F_Mask );
return saved;
}
int D_PAD::boundingRadius() const
{
int x, y;
@ -231,7 +263,7 @@ void D_PAD::Flip( const wxPoint& aCentre )
SetOrientation( -GetOrientation() );
// flip pads layers
SetLayerMask( FlipLayerMask( m_layerMask ) );
SetLayerSet( FlipLayerMask( m_layerMask ) );
// m_boundingRadius = -1; the shape has not been changed
}
@ -630,13 +662,6 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
}
// see class_pad.h
bool D_PAD::IsOnLayer( LAYER_NUM aLayer ) const
{
return ::GetLayerMask( aLayer ) & m_layerMask;
}
void D_PAD::GetOblongDrillGeometry( wxPoint& aStartPoint,
wxPoint& aEndPoint, int& aWidth ) const
{
@ -773,10 +798,21 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
// Dick: specctra_export needs this
// Lorenzo: gencad also needs it to implement padstacks!
if( ( diff = padref->m_layerMask - padcmp->m_layerMask ) != 0 )
return diff;
#if __cplusplus >= 201103L
long long d = padref->m_layerMask.to_ullong() - padcmp->m_layerMask.to_ullong();
if( d < 0 )
return -1;
else if( d > 0 )
return 1;
return 0;
#else
// these strings are not typically constructed, since we don't get here often.
std::string s1 = padref->m_layerMask.to_string();
std::string s2 = padcmp->m_layerMask.to_string();
return s1.compare( s2 );
#endif
}
@ -861,40 +897,40 @@ void D_PAD::ViewGetLayers( int aLayers[], int& aCount ) const
if( m_Attribute == PAD_STANDARD || m_Attribute == PAD_HOLE_NOT_PLATED )
aLayers[aCount++] = ITEM_GAL_LAYER( PADS_HOLES_VISIBLE );
if( IsOnLayer( LAYER_N_FRONT ) && IsOnLayer( LAYER_N_BACK ) )
if( IsOnLayer( F_Cu ) && IsOnLayer( B_Cu ) )
{
// Multi layer pad
aLayers[aCount++] = ITEM_GAL_LAYER( PADS_VISIBLE );
aLayers[aCount++] = NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE );
}
else if( IsOnLayer( LAYER_N_FRONT ) )
else if( IsOnLayer( F_Cu ) )
{
aLayers[aCount++] = ITEM_GAL_LAYER( PAD_FR_VISIBLE );
aLayers[aCount++] = NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE );
}
else if( IsOnLayer( LAYER_N_BACK ) )
else if( IsOnLayer( B_Cu ) )
{
aLayers[aCount++] = ITEM_GAL_LAYER( PAD_BK_VISIBLE );
aLayers[aCount++] = NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE );
}
if( IsOnLayer( SOLDERMASK_N_FRONT ) )
aLayers[aCount++] = SOLDERMASK_N_FRONT;
if( IsOnLayer( F_Mask ) )
aLayers[aCount++] = F_Mask;
if( IsOnLayer( SOLDERMASK_N_BACK ) )
aLayers[aCount++] = SOLDERMASK_N_BACK;
if( IsOnLayer( B_Mask ) )
aLayers[aCount++] = B_Mask;
if( IsOnLayer( SOLDERPASTE_N_FRONT ) )
aLayers[aCount++] = SOLDERPASTE_N_FRONT;
if( IsOnLayer( F_Paste ) )
aLayers[aCount++] = F_Paste;
if( IsOnLayer( SOLDERPASTE_N_BACK ) )
aLayers[aCount++] = SOLDERPASTE_N_BACK;
if( IsOnLayer( B_Paste ) )
aLayers[aCount++] = B_Paste;
if( IsOnLayer( ADHESIVE_N_BACK ) )
aLayers[aCount++] = ADHESIVE_N_BACK;
if( IsOnLayer( B_Adhes ) )
aLayers[aCount++] = B_Adhes;
if( IsOnLayer( ADHESIVE_N_FRONT ) )
aLayers[aCount++] = ADHESIVE_N_FRONT;
if( IsOnLayer( F_Adhes ) )
aLayers[aCount++] = F_Adhes;
#ifdef __WXDEBUG__
if( aCount == 0 ) // Should not occur

View File

@ -47,25 +47,6 @@ class TRACK;
class MSG_PANEL_INFO;
/* Default layers used for pads, according to the pad type.
* this is default values only, they can be changed for a given pad
*/
// PAD_STANDARD:
#define PAD_STANDARD_DEFAULT_LAYERS ALL_CU_LAYERS | SILKSCREEN_LAYER_FRONT | \
SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT
// PAD_CONN:
#define PAD_CONN_DEFAULT_LAYERS LAYER_FRONT | SOLDERPASTE_LAYER_FRONT | SOLDERMASK_LAYER_FRONT
// PAD_SMD:
#define PAD_SMD_DEFAULT_LAYERS LAYER_FRONT | SOLDERMASK_LAYER_FRONT
//PAD_HOLE_NOT_PLATED:
#define PAD_HOLE_NOT_PLATED_DEFAULT_LAYERS ALL_CU_LAYERS | SILKSCREEN_LAYER_FRONT | \
SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT
// Helper class to store parameters used to draw a pad
class PAD_DRAWINFO
{
@ -104,6 +85,14 @@ public:
// Do not create a copy constructor. The one generated by the compiler is adequate.
// D_PAD( const D_PAD& o );
/* Default layers used for pads, according to the pad type.
* this is default values only, they can be changed for a given pad
*/
static LSET StandardMask();
static LSET ConnMask();
static LSET SMDMask();
static LSET UnplatedHoleMask();
void Copy( D_PAD* source );
D_PAD* Next() const { return static_cast<D_PAD*>( Pnext ); }
@ -180,8 +169,8 @@ public:
*/
void GetOblongDrillGeometry( wxPoint& aStartPoint, wxPoint& aEndPoint, int& aWidth ) const;
void SetLayerMask( LAYER_MSK aLayerMask ) { m_layerMask = aLayerMask; }
LAYER_MSK GetLayerMask() const { return m_layerMask; }
void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
LSET GetLayerSet() const { return m_layerMask; }
void SetAttribute( PAD_ATTR_T aAttribute );
PAD_ATTR_T GetAttribute() const { return m_Attribute; }
@ -189,7 +178,7 @@ public:
void SetPadToDieLength( int aLength ) { m_LengthPadToDie = aLength; }
int GetPadToDieLength() const { return m_LengthPadToDie; }
int GetLocalSolderMaskMargin() const { return m_LocalSolderMaskMargin; }
int GetLocalSolderMaskMargin() const { return m_LocalSolderMaskMargin; }
void SetLocalSolderMaskMargin( int aMargin ) { m_LocalSolderMaskMargin = aMargin; }
int GetLocalClearance() const { return m_LocalClearance; }
@ -371,13 +360,15 @@ public:
* Function GetSubRatsnest
* @return int - the netcode
*/
int GetSubRatsnest() const { return m_SubRatsnest; }
void SetSubRatsnest( int aSubRatsnest ) { m_SubRatsnest = aSubRatsnest; }
int GetSubRatsnest() const { return m_SubRatsnest; }
void SetSubRatsnest( int aSubRatsnest ) { m_SubRatsnest = aSubRatsnest; }
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
bool IsOnLayer( LAYER_NUM aLayer ) const;
bool IsOnLayer( LAYER_ID aLayer ) const
{
return m_layerMask[aLayer];
}
bool HitTest( const wxPoint& aPosition ) const;
@ -506,7 +497,7 @@ private:
*/
wxPoint m_Offset;
LAYER_MSK m_layerMask; ///< Bitwise layer :1= copper layer, 15= cmp,
LSET m_layerMask; ///< Bitwise layer :1= copper layer, 15= cmp,
///< 2..14 = internal layers
///< 16 .. 31 = technical layers

View File

@ -107,19 +107,16 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
if( !frontVisible && !backVisible )
return;
/* If pad are only on front side (no layer on back side)
* and if hide front side pads is enabled, do not draw
*/
if( !frontVisible && ( (m_layerMask & BACK_LAYERS) == 0 ) )
// If pad is only on front side (no layer on back side)
// and if hide front side pads is enabled, do not draw
if( !frontVisible && !( m_layerMask & LSET::BackMask() ).any() )
return;
/* If pad are only on back side (no layer on front side)
* and if hide back side pads is enabled, do not draw
*/
if( !backVisible && ( (m_layerMask & FRONT_LAYERS) == 0 ) )
// If pad is only on back side (no layer on front side)
// and if hide back side pads is enabled, do not draw
if( !backVisible && !( m_layerMask & LSET::FrontMask() ).any() )
return;
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
PCB_SCREEN* screen = frame->GetScreen();
@ -129,12 +126,12 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
drawInfo.m_ShowPadFilled = false;
EDA_COLOR_T color = BLACK;
if( m_layerMask & LAYER_FRONT )
if( ( m_layerMask & LSET::FrontMask() ).any() )
{
color = brd->GetVisibleElementColor( PAD_FR_VISIBLE );
}
if( m_layerMask & LAYER_BACK )
if( ( m_layerMask & LSET::BackMask() ).any() )
{
color = ColorMix( color, brd->GetVisibleElementColor( PAD_BK_VISIBLE ) );
}
@ -142,12 +139,14 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
if( color == BLACK ) // Not on a visible copper layer (i.e. still nothing to show)
{
// If the pad is on only one tech layer, use the layer color else use DARKGRAY
LAYER_MSK mask_non_copper_layers = m_layerMask & ~ALL_CU_LAYERS;
LSET mask_non_copper_layers = m_layerMask & ~LSET::AllCuMask();
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
mask_non_copper_layers &= brd->GetVisibleLayers();
#endif
LAYER_NUM pad_layer = ExtractLayer( mask_non_copper_layers );
switch( pad_layer )
LAYER_ID pad_layer = mask_non_copper_layers.ExtractLayer();
switch( (int) pad_layer )
{
case UNDEFINED_LAYER: // More than one layer
color = DARKGRAY;
@ -172,14 +171,16 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
// when routing tracks
if( frame && frame->GetToolId() == ID_TRACK_BUTT )
{
LAYER_NUM routeTop = screen->m_Route_Layer_TOP;
LAYER_NUM routeBot = screen->m_Route_Layer_BOTTOM;
LAYER_ID routeTop = screen->m_Route_Layer_TOP;
LAYER_ID 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,
// then highlight only the current layer.
if( ( ::GetLayerMask( routeTop ) | ::GetLayerMask( routeBot ) ) == ( LAYER_BACK | LAYER_FRONT )
|| ( ::GetLayerMask( screen->m_Active_Layer ) & ( LAYER_BACK | LAYER_FRONT ) ) )
if( ( screen->m_Active_Layer == F_Cu || screen->m_Active_Layer == B_Cu ) ||
( routeTop==F_Cu && routeBot==B_Cu ) ||
( routeTop==B_Cu && routeBot==F_Cu )
)
{
if( !IsOnLayer( screen->m_Active_Layer ) )
ColorTurnToDarkDarkGray( &color );
@ -208,13 +209,13 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
{
switch( showActualMaskSize )
{
case SOLDERMASK_N_BACK:
case SOLDERMASK_N_FRONT:
case B_Mask:
case F_Mask:
mask_margin.x = mask_margin.y = GetSolderMaskMargin();
break;
case SOLDERPASTE_N_BACK:
case SOLDERPASTE_N_FRONT:
case B_Paste:
case F_Paste:
mask_margin = GetSolderPasteMargin();
break;
@ -239,13 +240,13 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
// layer shows the pad size with the mask clearance
switch( screen->m_Active_Layer )
{
case SOLDERMASK_N_BACK:
case SOLDERMASK_N_FRONT:
case B_Mask:
case F_Mask:
mask_margin.x = mask_margin.y = GetSolderMaskMargin();
break;
case SOLDERPASTE_N_BACK:
case SOLDERPASTE_N_FRONT:
case B_Paste:
case F_Paste:
mask_margin = GetSolderPasteMargin();
break;
@ -265,7 +266,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
bool DisplayIsol = DisplayOpt.DisplayPadIsol;
if( ( m_layerMask & ALL_CU_LAYERS ) == 0 )
if( !( m_layerMask & LSET::AllCuMask() ).any() )
DisplayIsol = false;
if( ( GetAttribute() == PAD_HOLE_NOT_PLATED ) &&
@ -462,11 +463,11 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
int dx0 = std::min( halfsize.x, halfsize.y );
EDA_COLOR_T nc_color = BLUE;
if( m_layerMask & LAYER_FRONT ) /* Draw \ */
if( m_layerMask[F_Cu] ) /* Draw \ */
GRLine( aClipBox, aDC, holepos.x - dx0, holepos.y - dx0,
holepos.x + dx0, holepos.y + dx0, 0, nc_color );
if( m_layerMask & LAYER_BACK ) // Draw /
if( m_layerMask[B_Cu] ) // Draw /
GRLine( aClipBox, aDC, holepos.x + dx0, holepos.y - dx0,
holepos.x - dx0, holepos.y + dx0, 0, nc_color );
}

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