mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 11:20:09 +00:00
Clean up a few gerbview export to pcbnew layers
There's a lot of hard coded stuff in gerbview. This removes a few duplicated functions and gets the layer export back into working shape Fixes https://gitlab.com/kicad/code/kicad/-/issues/19552
This commit is contained in:
parent
162d87f271
commit
066380ffeb
@ -30,14 +30,13 @@
|
||||
#include <gerbview_settings.h>
|
||||
#include <kiface_base.h>
|
||||
#include <layer_ids.h>
|
||||
#include <lset.h>
|
||||
|
||||
#include <dialogs/dialog_layers_select_to_pcb.h>
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
#include <gestfich.h>
|
||||
|
||||
extern const wxString GetPCBDefaultLayerName( int aLayerNumber );
|
||||
|
||||
|
||||
enum swap_layer_id {
|
||||
ID_LAYERS_MAP_DIALOG = ID_GERBER_END_LIST,
|
||||
@ -185,7 +184,7 @@ void LAYERS_MAP_DIALOG::initDialog()
|
||||
|
||||
for( int jj = 0; jj < GERBER_DRAWLAYERS_COUNT; ++jj )
|
||||
{
|
||||
text->SetLabel( GetPCBDefaultLayerName( jj ) );
|
||||
text->SetLabel( LSET::Name( PCB_LAYER_ID( jj ) ) );
|
||||
|
||||
if( goodSize.x < text->GetSize().x )
|
||||
goodSize.x = text->GetSize().x;
|
||||
@ -213,16 +212,21 @@ void LAYERS_MAP_DIALOG::initDialog()
|
||||
{
|
||||
// See if the user wants to map the Altium Gerbers to known KiCad PCB layers
|
||||
int returnVal = wxMessageBox(
|
||||
_( "Gerbers with known layers: " + wxString::Format( wxT( "%i" ), numMappedGerbers )
|
||||
+ "\n\nAssign to matching KiCad PCB layers?" ),
|
||||
wxString::Format( _( "Gerbers with known layers: %d" ), numMappedGerbers ) + wxT( "\n\n" )
|
||||
+ _( "Assign to matching PCB layers?" ),
|
||||
_( "Automatic Layer Assignment" ), wxOK | wxCANCEL | wxOK_DEFAULT );
|
||||
|
||||
if( returnVal == wxOK )
|
||||
{
|
||||
int total_copper = 0;
|
||||
|
||||
for( int ii = 0; ii < m_gerberActiveLayersCount; ii++ )
|
||||
{
|
||||
int currLayer = gerber2KicadMapping[ii];
|
||||
|
||||
if( IsCopperLayer( currLayer ) )
|
||||
total_copper++;
|
||||
|
||||
// Default to "Do Not Export" for unselected or undefined layer
|
||||
if( currLayer == UNSELECTED_LAYER )
|
||||
{
|
||||
@ -234,13 +238,17 @@ void LAYERS_MAP_DIALOG::initDialog()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layersList[ii]->SetLabel( GetPCBDefaultLayerName( currLayer ) );
|
||||
m_layersList[ii]->SetLabel( LSET::Name( PCB_LAYER_ID( currLayer ) ) );
|
||||
m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
|
||||
|
||||
// Set the layer internally to the matching KiCad layer
|
||||
m_layersLookUpTable[ii] = currLayer;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the number of copper layers to the total found
|
||||
m_exportBoardCopperLayersCount = std::max( total_copper, 2 );
|
||||
m_comboCopperLayersCount->SetSelection( ( m_exportBoardCopperLayersCount / 2 ) - 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -334,7 +342,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layersList[ii]->SetLabel( GetPCBDefaultLayerName( layer ) );
|
||||
m_layersList[ii]->SetLabel( LSET::Name( PCB_LAYER_ID( layer ) ) );
|
||||
m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
|
||||
}
|
||||
}
|
||||
@ -390,7 +398,7 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layersList[ii]->SetLabel( GetPCBDefaultLayerName( jj ) );
|
||||
m_layersList[ii]->SetLabel( LSET::Name( PCB_LAYER_ID( jj ) ) );
|
||||
|
||||
// Change the text color to fuchsia (to highlight
|
||||
// that this layer *is* being exported)
|
||||
@ -440,13 +448,7 @@ int LAYERS_MAP_DIALOG::findKnownGerbersLoaded( std::vector<int>& aGerber2KicadMa
|
||||
{
|
||||
int numKnownGerbers = 0;
|
||||
|
||||
// We can automatically map Gerbers using different techniques. The first thing we
|
||||
// try is to see if any of the loaded Gerbers were created by or use the
|
||||
// Altium/Protel file extensions
|
||||
numKnownGerbers += findNumAltiumGerbersLoaded( aGerber2KicadMapping );
|
||||
|
||||
// Next we check if any of the loaded Gerbers are X2 Gerbers and if they contain
|
||||
|
||||
// Check if any of the loaded Gerbers are X2 Gerbers and if they contain
|
||||
// layer information in "File Functions". For info about X2 Gerbers see
|
||||
// http://www.ucamco.com/files/downloads/file/81/the_gerber_file_format_specification.pdf
|
||||
numKnownGerbers += findNumX2GerbersLoaded( aGerber2KicadMapping );
|
||||
@ -454,6 +456,10 @@ int LAYERS_MAP_DIALOG::findKnownGerbersLoaded( std::vector<int>& aGerber2KicadMa
|
||||
// Finally, check if any of the loaded Gerbers use the KiCad naming conventions
|
||||
numKnownGerbers += findNumKiCadGerbersLoaded( aGerber2KicadMapping );
|
||||
|
||||
// The last option is to match using just the file extension
|
||||
// This checkes for known Altium/Protel file extensions
|
||||
numKnownGerbers += findNumAltiumGerbersLoaded( aGerber2KicadMapping );
|
||||
|
||||
return numKnownGerbers;
|
||||
}
|
||||
|
||||
@ -573,51 +579,60 @@ int LAYERS_MAP_DIALOG::findNumKiCadGerbersLoaded( std::vector<int>& aGerber2Kica
|
||||
// along with their corresponding KiCad layer
|
||||
std::map<wxString, PCB_LAYER_ID> kicadLayers
|
||||
{
|
||||
{ "-F_Cu", F_Cu },
|
||||
{ "-In1_Cu", In1_Cu },
|
||||
{ "-In2_Cu", In2_Cu },
|
||||
{ "-In3_Cu", In3_Cu },
|
||||
{ "-In4_Cu", In4_Cu },
|
||||
{ "-In5_Cu", In5_Cu },
|
||||
{ "-In6_Cu", In6_Cu },
|
||||
{ "-In7_Cu", In7_Cu },
|
||||
{ "-In8_Cu", In8_Cu },
|
||||
{ "-In9_Cu", In9_Cu },
|
||||
{ "-In10_Cu", In10_Cu },
|
||||
{ "-In11_Cu", In11_Cu },
|
||||
{ "-In12_Cu", In12_Cu },
|
||||
{ "-In13_Cu", In13_Cu },
|
||||
{ "-In14_Cu", In14_Cu },
|
||||
{ "-In15_Cu", In15_Cu },
|
||||
{ "-In16_Cu", In16_Cu },
|
||||
{ "-In17_Cu", In17_Cu },
|
||||
{ "-In18_Cu", In18_Cu },
|
||||
{ "-In19_Cu", In19_Cu },
|
||||
{ "-In20_Cu", In20_Cu },
|
||||
{ "-In21_Cu", In21_Cu },
|
||||
{ "-In22_Cu", In22_Cu },
|
||||
{ "-In23_Cu", In23_Cu },
|
||||
{ "-In24_Cu", In24_Cu },
|
||||
{ "-In25_Cu", In25_Cu },
|
||||
{ "-In26_Cu", In26_Cu },
|
||||
{ "-In27_Cu", In27_Cu },
|
||||
{ "-In28_Cu", In28_Cu },
|
||||
{ "-In29_Cu", In29_Cu },
|
||||
{ "-In30_Cu", In30_Cu },
|
||||
{ "-B_Cu", B_Cu },
|
||||
{ "-B_Adhes", B_Adhes },
|
||||
{ "-F_Adhes", F_Adhes },
|
||||
{ "-B_Paste", B_Paste },
|
||||
{ "-F_Paste", F_Paste },
|
||||
{ "-B_SilkS", B_SilkS },
|
||||
{ "-F_SilkS", F_SilkS },
|
||||
{ "-B_Mask", B_Mask },
|
||||
{ "-F_Mask", F_Mask },
|
||||
{ "-Dwgs_User", Dwgs_User },
|
||||
{ "-Cmts_User", Cmts_User },
|
||||
{ "-Eco1_User", Eco1_User },
|
||||
{ "-Eco2_User", Eco2_User },
|
||||
{ "-Edge_Cuts", Edge_Cuts }
|
||||
{ "-F_Cu", F_Cu },
|
||||
{ "-In1_Cu", In1_Cu },
|
||||
{ "-In2_Cu", In2_Cu },
|
||||
{ "-In3_Cu", In3_Cu },
|
||||
{ "-In4_Cu", In4_Cu },
|
||||
{ "-In5_Cu", In5_Cu },
|
||||
{ "-In6_Cu", In6_Cu },
|
||||
{ "-In7_Cu", In7_Cu },
|
||||
{ "-In8_Cu", In8_Cu },
|
||||
{ "-In9_Cu", In9_Cu },
|
||||
{ "-In10_Cu", In10_Cu },
|
||||
{ "-In11_Cu", In11_Cu },
|
||||
{ "-In12_Cu", In12_Cu },
|
||||
{ "-In13_Cu", In13_Cu },
|
||||
{ "-In14_Cu", In14_Cu },
|
||||
{ "-In15_Cu", In15_Cu },
|
||||
{ "-In16_Cu", In16_Cu },
|
||||
{ "-In17_Cu", In17_Cu },
|
||||
{ "-In18_Cu", In18_Cu },
|
||||
{ "-In19_Cu", In19_Cu },
|
||||
{ "-In20_Cu", In20_Cu },
|
||||
{ "-In21_Cu", In21_Cu },
|
||||
{ "-In22_Cu", In22_Cu },
|
||||
{ "-In23_Cu", In23_Cu },
|
||||
{ "-In24_Cu", In24_Cu },
|
||||
{ "-In25_Cu", In25_Cu },
|
||||
{ "-In26_Cu", In26_Cu },
|
||||
{ "-In27_Cu", In27_Cu },
|
||||
{ "-In28_Cu", In28_Cu },
|
||||
{ "-In29_Cu", In29_Cu },
|
||||
{ "-In30_Cu", In30_Cu },
|
||||
{ "-B_Cu", B_Cu },
|
||||
{ "-B_Adhes", B_Adhes },
|
||||
{ "-F_Adhes", F_Adhes },
|
||||
{ "-B_Adhesive", B_Adhes },
|
||||
{ "-F_Adhesive", F_Adhes },
|
||||
{ "-B_Paste", B_Paste },
|
||||
{ "-F_Paste", F_Paste },
|
||||
{ "-B_SilkS", B_SilkS },
|
||||
{ "-F_SilkS", F_SilkS },
|
||||
{ "-B_Silkscreen",B_SilkS },
|
||||
{ "-F_Silkscreen",F_SilkS },
|
||||
{ "-B_Mask", B_Mask },
|
||||
{ "-F_Mask", F_Mask },
|
||||
{ "-F_Fab", F_Fab },
|
||||
{ "-B_Fab", B_Fab },
|
||||
{ "-Dwgs_User", Dwgs_User },
|
||||
{ "-Cmts_User", Cmts_User },
|
||||
{ "-Eco1_User", Eco1_User },
|
||||
{ "-Eco2_User", Eco2_User },
|
||||
{ "-Edge_Cuts", Edge_Cuts },
|
||||
{ "-Margin", Margin },
|
||||
{ "-F_Courtyard", F_CrtYd },
|
||||
{ "-B_Courtyard", B_CrtYd },
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@ -736,8 +751,8 @@ int LAYERS_MAP_DIALOG::findNumX2GerbersLoaded( std::vector<int>& aGerber2KicadMa
|
||||
{ wxT( "TopSoldermask" ), F_Mask },
|
||||
{ wxT( "FabricationDrawing" ), Dwgs_User },
|
||||
{ wxT( "OtherDrawing" ), Cmts_User },
|
||||
{ wxT( "TopAssemblyDrawing" ), Eco1_User },
|
||||
{ wxT( "BotAssemblyDrawing" ), Eco2_User },
|
||||
{ wxT( "TopAssemblyDrawing" ), F_Fab },
|
||||
{ wxT( "BotAssemblyDrawing" ), B_Fab },
|
||||
{ wxT( "PProfile" ), Edge_Cuts }, // Plated PCB outline
|
||||
{ wxT( "NPProfile" ), Edge_Cuts } // Non-plated PCB outline
|
||||
};
|
||||
|
@ -28,17 +28,12 @@
|
||||
*/
|
||||
|
||||
#include <gerbview_frame.h>
|
||||
#include <layer_range.h>
|
||||
#include <lset.h>
|
||||
#include <dialogs/dialog_layers_select_to_pcb.h>
|
||||
|
||||
#include <wx/radiobox.h>
|
||||
|
||||
#define NB_PCB_LAYERS PCB_LAYER_ID_COUNT
|
||||
#define FIRST_COPPER_LAYER 0
|
||||
#define LAST_COPPER_LAYER 31
|
||||
|
||||
// Exported function
|
||||
const wxString GetPCBDefaultLayerName( int aLayerId );
|
||||
|
||||
|
||||
enum layer_sel_id {
|
||||
ID_LAYER_SELECT_TOP = 1800,
|
||||
@ -93,7 +88,6 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLa
|
||||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
|
||||
{
|
||||
wxButton* button;
|
||||
int ii;
|
||||
wxArrayString layerList;
|
||||
int selected = -1;
|
||||
|
||||
@ -101,55 +95,44 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLa
|
||||
m_selectedLayer = aDefaultLayer;
|
||||
|
||||
// Build the layer list; first build copper layers list
|
||||
int layerCount = 0;
|
||||
LSET layers = LSET::AllCuMask( aCopperLayerCount ) | LSET::AllTechMask() | LSET::UserMask();
|
||||
|
||||
for( ii = FIRST_COPPER_LAYER; ii <= LAST_COPPER_LAYER; ++ii )
|
||||
for( auto copper_it = layers.copper_layers_begin(); copper_it != layers.copper_layers_end(); ++copper_it )
|
||||
{
|
||||
if( ii == FIRST_COPPER_LAYER || ii == LAST_COPPER_LAYER || ii < aCopperLayerCount-1 )
|
||||
{
|
||||
layerList.Add( GetPCBDefaultLayerName( ii ) );
|
||||
layerList.Add( LSET::Name( *copper_it ) );
|
||||
|
||||
if( aDefaultLayer == ii )
|
||||
selected = layerCount;
|
||||
if( aDefaultLayer == *copper_it )
|
||||
selected = m_layerId.size();
|
||||
|
||||
m_layerId.push_back( ii );
|
||||
layerCount++;
|
||||
}
|
||||
m_layerId.push_back( *copper_it );
|
||||
}
|
||||
|
||||
// Build the layer list; build non copper layers list
|
||||
for( ; ; ++ii )
|
||||
for( auto non_copper_it = layers.non_copper_layers_begin(); non_copper_it != layers.non_copper_layers_end(); ++non_copper_it )
|
||||
{
|
||||
if( GetPCBDefaultLayerName( ii ) == "" ) // End of list
|
||||
break;
|
||||
layerList.Add( LSET::Name( *non_copper_it ) );
|
||||
|
||||
layerList.Add( GetPCBDefaultLayerName( ii ) );
|
||||
if( aDefaultLayer == *non_copper_it )
|
||||
selected = m_layerId.size();
|
||||
|
||||
if( aDefaultLayer == ii )
|
||||
selected = layerCount;
|
||||
|
||||
m_layerId.push_back( ii );
|
||||
layerCount++;
|
||||
m_layerId.push_back( *non_copper_it );
|
||||
}
|
||||
|
||||
layerList.Add( _( "Hole data" ) );
|
||||
|
||||
if( aDefaultLayer == UNDEFINED_LAYER )
|
||||
selected = layerCount;
|
||||
selected = m_layerId.size();
|
||||
|
||||
m_layerId.push_back( UNDEFINED_LAYER );
|
||||
layerCount++;
|
||||
|
||||
layerList.Add( _( "Do not export" ) );
|
||||
|
||||
if( aDefaultLayer == UNSELECTED_LAYER )
|
||||
selected = layerCount;
|
||||
selected = m_layerId.size();
|
||||
|
||||
m_layerId.push_back( UNSELECTED_LAYER );
|
||||
layerCount++;
|
||||
|
||||
m_layerRadioBox = new wxRadioBox( this, ID_LAYER_SELECT, _( "Layer" ), wxDefaultPosition,
|
||||
wxDefaultSize, layerList, std::min( layerCount, 12 ),
|
||||
wxDefaultSize, layerList, std::min( int( m_layerId.size() ), 12 ),
|
||||
wxRA_SPECIFY_ROWS );
|
||||
|
||||
if( selected >= 0 )
|
||||
@ -194,73 +177,3 @@ bool SELECT_LAYER_DIALOG::TransferDataFromWindow()
|
||||
m_selectedLayer = m_layerId[m_layerRadioBox->GetSelection()];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// This function is a duplicate of
|
||||
// const wxChar* LSET::Name( PCB_LAYER_ID aLayerId )
|
||||
// However it avoids a dependency to Pcbnew code.
|
||||
const wxString GetPCBDefaultLayerName( int 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;
|
||||
|
||||
// Pcbnew knows some other layers, but any other layer is not suitable for export.
|
||||
|
||||
default: // Sentinel
|
||||
txt = wxT( "" ); break;
|
||||
}
|
||||
|
||||
return wxString( txt );
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <confirm.h>
|
||||
#include <string_utils.h>
|
||||
#include <locale_io.h>
|
||||
#include <lset.h>
|
||||
#include <macros.h>
|
||||
#include <trigo.h>
|
||||
#include <gerbview_frame.h>
|
||||
@ -39,9 +40,6 @@
|
||||
#include "excellon_image.h"
|
||||
#include <wx/log.h>
|
||||
|
||||
// Imported function
|
||||
extern const wxString GetPCBDefaultLayerName( int aLayerNumber );
|
||||
|
||||
|
||||
GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME* aFrame, const wxString& aFileName )
|
||||
{
|
||||
@ -112,10 +110,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( const int* aLayerLookUpTable, int aCopperLa
|
||||
|
||||
int pcb_layer_number = aLayerLookUpTable[layer];
|
||||
|
||||
if( !IsPcbLayer( pcb_layer_number ) )
|
||||
continue;
|
||||
|
||||
if( IsCopperLayer( pcb_layer_number ) )
|
||||
if( !IsPcbLayer( pcb_layer_number ) || IsCopperLayer( pcb_layer_number ) )
|
||||
continue;
|
||||
|
||||
for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
|
||||
@ -135,9 +130,6 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( const int* aLayerLookUpTable, int aCopperLa
|
||||
if( !IsCopperLayer( pcb_layer_number ) )
|
||||
continue;
|
||||
|
||||
if( pcb_layer_number > m_pcbCopperLayersCount*2 )
|
||||
continue;
|
||||
|
||||
for( GERBER_DRAW_ITEM* gerb_item : gerber->GetItems() )
|
||||
export_copper_item( gerb_item, pcb_layer_number );
|
||||
}
|
||||
@ -209,7 +201,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrIt
|
||||
FormatDouble2Str( MapToPcbUnits( seg_start.y ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.x ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.y ) ).c_str(),
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
export_stroke_info( aGbrItem->m_Size.x );
|
||||
fprintf( m_fp, "\t)\n" );
|
||||
break;
|
||||
@ -224,7 +216,8 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrIt
|
||||
FormatDouble2Str( MapToPcbUnits( seg_start.y ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.x ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.y ) ).c_str(),
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
|
||||
export_stroke_info( aGbrItem->m_Size.x );
|
||||
fprintf( m_fp, "\t)\n" );
|
||||
break;
|
||||
@ -257,7 +250,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_arc( const GERBER_DRAW_ITEM* aGbrIte
|
||||
FormatDouble2Str( MapToPcbUnits( arc_center.y ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.x ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.y ) ).c_str(),
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
export_stroke_info( aGbrItem->m_Size.x );
|
||||
fprintf( m_fp, "\t)\n" );
|
||||
}
|
||||
@ -278,7 +271,8 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_arc( const GERBER_DRAW_ITEM* aGbrIte
|
||||
FormatDouble2Str( MapToPcbUnits( seg_middle.y ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.x ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.y ) ).c_str(),
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
|
||||
export_stroke_info( aGbrItem->m_Size.x );
|
||||
fprintf( m_fp, "\t)\n" );
|
||||
}
|
||||
@ -307,8 +301,8 @@ void GBR_TO_PCB_EXPORTER::export_via( const EXPORT_VIA& aVia )
|
||||
FormatDouble2Str( MapToPcbUnits( aVia.m_Drill ) ).c_str() );
|
||||
|
||||
fprintf( m_fp, " (layers %s %s))\n",
|
||||
TO_UTF8( GetPCBDefaultLayerName( F_Cu ) ),
|
||||
TO_UTF8( GetPCBDefaultLayerName( B_Cu ) ) );
|
||||
LSET::Name( F_Cu ).ToStdString().c_str(),
|
||||
LSET::Name( B_Cu ).ToStdString().c_str() );
|
||||
}
|
||||
|
||||
|
||||
@ -391,7 +385,7 @@ void GBR_TO_PCB_EXPORTER::writeCopperLineItem( const VECTOR2I& aStart, const VEC
|
||||
FormatDouble2Str( MapToPcbUnits(aEnd.x) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits(aEnd.y) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( aWidth ) ).c_str(),
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
}
|
||||
|
||||
|
||||
@ -431,7 +425,7 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( const GERBER_DRAW_ITEM* aGb
|
||||
FormatDouble2Str( MapToPcbUnits( seg_middle.y ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.x ) ).c_str(),
|
||||
FormatDouble2Str( MapToPcbUnits( seg_end.y ) ).c_str(),
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
|
||||
fprintf( m_fp, "\t\t(width %s) (net 0 )\n",
|
||||
FormatDouble2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str() );
|
||||
@ -505,7 +499,7 @@ void GBR_TO_PCB_EXPORTER::writePcbFilledCircle( const VECTOR2I& aCenterPosition,
|
||||
|
||||
export_stroke_info( 0 );
|
||||
fprintf( m_fp, "\t\t(fill yes) (layer %s)",
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
fprintf( m_fp, "\n\t)\n" );
|
||||
}
|
||||
|
||||
@ -520,32 +514,18 @@ void GBR_TO_PCB_EXPORTER::writePcbHeader( const int* aLayerLookUpTable )
|
||||
// Write layers section
|
||||
fprintf( m_fp, "\t(layers \n" );
|
||||
|
||||
for( int ii = 0; ii < m_pcbCopperLayersCount; ii++ )
|
||||
LSET layer_set = LSET::AllCuMask( m_pcbCopperLayersCount ) | LSET::AllTechMask() | LSET::UserMask();
|
||||
|
||||
for( auto cu_it = layer_set.copper_layers_begin(); cu_it != layer_set.copper_layers_end(); ++cu_it )
|
||||
{
|
||||
// copper layer IDs are even numbers: F_Cu = 0, B_Cu = 2, Inner = 4,6,8..
|
||||
int ly_id = ii * 2;
|
||||
|
||||
if( ii != 0 )
|
||||
ly_id += B_Cu;
|
||||
|
||||
if( ii == m_pcbCopperLayersCount-1)
|
||||
ly_id = B_Cu;
|
||||
|
||||
fprintf( m_fp, "\t\t(%d %s signal)\n",
|
||||
ly_id, TO_UTF8( GetPCBDefaultLayerName( ly_id ) ) );
|
||||
*cu_it, LSET::Name( *cu_it ).ToStdString().c_str() );
|
||||
}
|
||||
|
||||
// Non copper layer IDs are odd numbers (starting at F_Mask = 1)
|
||||
// All usuel non copper layers (but not all possible layers) are enabled
|
||||
for( int ii = 1; ii < PCB_LAYER_ID_COUNT; ii += 2 )
|
||||
for( auto non_cu_it = layer_set.non_copper_layers_begin(); non_cu_it != layer_set.non_copper_layers_end(); ++non_cu_it )
|
||||
{
|
||||
// GetPCBDefaultLayerName() return empty name for layers not available
|
||||
// for export (because they have a specific purpose)
|
||||
if( GetPCBDefaultLayerName( ii ).IsEmpty() )
|
||||
continue;
|
||||
|
||||
fprintf( m_fp, "\t\t(%d %s user)\n",
|
||||
ii, TO_UTF8( GetPCBDefaultLayerName( ii ) ) );
|
||||
*non_cu_it, LSET::Name( *non_cu_it ).ToStdString().c_str() );
|
||||
}
|
||||
|
||||
fprintf( m_fp, "\t)\n\n" );
|
||||
@ -590,7 +570,8 @@ void GBR_TO_PCB_EXPORTER::writePcbPolygon( const SHAPE_POLY_SET& aPolys, int aLa
|
||||
|
||||
fprintf( m_fp, "\n" );
|
||||
export_stroke_info( 0 );
|
||||
fprintf( m_fp, "\t\t(fill yes) (layer %s)", TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
fprintf( m_fp, "\t\t(fill yes) (layer %s)",
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
fprintf( m_fp, "\n\t)\n" );
|
||||
}
|
||||
|
||||
@ -604,7 +585,7 @@ void GBR_TO_PCB_EXPORTER::writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, in
|
||||
return;
|
||||
|
||||
fprintf( m_fp, "\t(zone (net 0) (net_name \"\") (layer %s) (tstamp 0000000) (hatch edge 0.508)\n",
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
LSET::Name( PCB_LAYER_ID( aLayer ) ).ToStdString().c_str() );
|
||||
|
||||
fprintf( m_fp, " (connect_pads (clearance 0.0))\n" );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user