7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 18:19:17 +00:00
This commit is contained in:
Dick Hollenbeck 2014-06-30 00:46:18 -05:00
commit 1e7495e634
227 changed files with 14654 additions and 6394 deletions
3d-viewer
TODO.txt
bitmap2component
common
eeschema
gerbview
include
pagelayout_editor
pcbnew
autorouter
basepcbframe.cppblock.cppboard_items_to_polygon_shape_transform.cppclass_board.cppclass_board.hclass_board_design_settings.cppclass_dimension.cppclass_dimension.hclass_drawsegment.cppclass_edge_mod.cppclass_marker_pcb.cppclass_marker_pcb.hclass_mire.cppclass_mire.hclass_module.cppclass_module.hclass_pad.cppclass_pad.hclass_pad_draw_functions.cppclass_pcb_layer_box_selector.cppclass_pcb_layer_box_selector.hclass_pcb_layer_widget.cppclass_pcb_layer_widget.hclass_text_mod.cppclass_track.cppclass_track.hclass_zone.cppclass_zone.hclass_zone_settings.cppclass_zone_settings.hclasspcb.cppclean.cppcollectors.cppcollectors.hconnect.cppdeltrack.cpp
dialogs
dimension.cppdrag.hdragsegm.cppdrc.cppdrc_clearance_test_functions.cppeagle_plugin.cppeagle_plugin.hedgemod.cppedit.cppedit_pcb_text.cppeditedge.cppeditrack-part2.cppeditrack.cpp
exporters
files.cppglobaleditpad.cppgpcb_plugin.cpphotkeys.cpphotkeys_board_editor.cpp
import_dxf
initpcb.cppinvoke_pcb_dialog.hkicad_plugin.cppkicad_plugin.hlayer_widget.cpplayer_widget.hlegacy_plugin.cpplegacy_plugin.hloadcmp.cppmagnetic_tracks_functions.cppminimun_spanning_tree.cppmodule_editor_frame.hmodules.cppmove_or_drag_track.cppmuonde.cpponleftclick.cpppad_edition_functions.cpp
pcad2kicadpcb_plugin
pcb_painter.cpppcb_parser.cpppcb_parser.hpcb_plot_params.cpppcb_plot_params.hpcbframe.cpppcbnew.cpppcbnew.hpcbnew_config.cpppcbplot.cpppcbplot.hplot_board_layers.cppplot_brditems_plotter.cppprint_board_functions.cppprintout_controler.cppprintout_controler.hratsnest.cpp
router
sel_layer.cppspecctra.cppspecctra.hspecctra_export.cppspecctra_import.cppswap_layers.cpptarget_edit.cpptool_pcb.cpp
tools
tr_modif.cpptracepcb.cppzones_by_polygon.cppzones_convert_brd_items_to_polygons_with_Boost.cppzones_non_copper_type_functions.cppzones_polygons_test_connections.cpp
polygon

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,10 @@ 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.
Known Cu32 problems:
*) layer combo box does not show the first layer numbered 0.
*) ratsnest is broken

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 & INTERNAL_CU_LAYERS )
if( aMask[F_Cu] )
AccumulateDescription( layerInfo, aBoard->GetLayerName( F_Cu ) );
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

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