diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp index 1031fa85c5..cd948196e1 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp +++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp @@ -1,8 +1,8 @@ - + - + C++ 1 source_name @@ -16,9 +16,9 @@ none 1 dialog_layers_select_to_pcb_base - + . - + 1 1 1 @@ -29,67 +29,67 @@ 0 wxAUI_MGR_DEFAULT - + wxBOTH - + 1 1 impl_virtual - - - + + + 0 ID_LAYERS_MAP_DIALOG_BASE - - + + LAYERS_MAP_DIALOG_BASE - + 386,333 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Layer Selection - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bSizerMain wxVERTICAL none @@ -98,7 +98,7 @@ wxEXPAND 1 - + sbUpperSizer wxHORIZONTAL none @@ -107,7 +107,7 @@ wxEXPAND 1 - + bSizerLayerSelection wxVERTICAL none @@ -120,78 +120,78 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Layer selection: - + 0 - - + + 0 - + 1 m_staticTextLayerSel 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -199,7 +199,7 @@ wxEXPAND 1 - + m_bSizerLayerList wxHORIZONTAL protected @@ -221,9 +221,9 @@ 4 wxBOTH 0,1,2,3 - + 0 - + m_flexLeftColumnBoxSizer wxFLEX_GROWMODE_SPECIFIED protected @@ -240,76 +240,76 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 ID_M_STATICLINESEP - + 0 - - + + 0 - + 1 m_staticlineSep 1 - - + + protected 1 - + Resizable 1 - + wxLI_VERTICAL - + 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -320,9 +320,9 @@ 4 wxBOTH 0,1,2,3 - + 0 - + m_flexRightColumnBoxSizer wxFLEX_GROWMODE_SPECIFIED protected @@ -339,7 +339,7 @@ wxALIGN_CENTER_VERTICAL 0 - + bRightSizer wxVERTICAL none @@ -348,7 +348,7 @@ wxEXPAND 0 - + bSizerLyrCnt wxVERTICAL none @@ -361,78 +361,78 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 ID_M_STATICTEXTCOPPERLAYERCOUNT Copper layers count: - + 0 - - + + 0 - + 1 m_staticTextCopperlayerCount 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -444,88 +444,88 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 "2 Layers" "4 Layers" "6 Layers" "8 Layers" "10 Layers" "12 Layers" "14 Layers" "16 Layers" 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 ID_M_COMBOCOPPERLAYERSCOUNT - + 0 - - + + 0 - + 1 m_comboCopperLayersCount 1 - - + + protected 1 - + Resizable -1 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - + 2 Layers - - - - + + + + OnBrdLayersCountSelection - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -545,7 +545,7 @@ wxEXPAND 0 - + bSizerButtons wxVERTICAL none @@ -558,17 +558,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 0 @@ -576,65 +576,65 @@ 0 Left 1 - + 1 - + 0 0 ID_STORE_CHOICE Store Choice - + 0 - - + + 0 - + 1 m_buttonStore 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnStoreSetup - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -646,17 +646,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 0 @@ -664,65 +664,65 @@ 0 Left 1 - + 1 - + 0 0 ID_GET_PREVIOUS_CHOICE Get Stored Choice - + 0 - - + + 0 - + 1 m_buttonRetrieve 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnGetSetup - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -734,17 +734,17 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 0 @@ -752,65 +752,65 @@ 0 Left 1 - + 1 - + 0 0 ID_RESET_CHOICE Reset - + 0 - - + + 0 - + 1 m_buttonReset 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnResetClick - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -828,76 +828,76 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 - + 1 m_staticline1 1 - - + + protected 1 - + Resizable 1 - + wxLI_HORIZONTAL - + 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -913,17 +913,17 @@ 1 0 0 - + m_sdbSizerButtons protected - - - - - + + + + + OnOkClick - - + + diff --git a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp index 4bd125573a..963141f611 100644 --- a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp +++ b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp @@ -137,8 +137,11 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, } // Build the layer list; build non copper layers list - for( ; ii < NB_PCB_LAYERS; ++ii ) + for( ; ; ++ii ) { + if( GetPCBDefaultLayerName( ii ) == "" ) // End of list + break; + layerList.Add( GetPCBDefaultLayerName( ii ) ); if( ii == aDefaultLayer ) @@ -260,17 +263,11 @@ const wxString GetPCBDefaultLayerName( int aLayerId ) 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; + // Pcbnew konws some oter layers. But any other layer is not suitable for export. - default: - wxASSERT_MSG( 0, wxT( "aLayerId out of range" ) ); - txt = wxT( "BAD INDEX!" ); break; + default: // Sentinel + txt = wxT( "" ); break; } return wxString( txt ); diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index f428f8d76f..59ebce744f 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -46,7 +46,6 @@ // Imported function extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber ); -#define TO_PCB_UNIT( x ) ( x / IU_PER_MM) /* A helper class to export a Gerber set of files to Pcbnew */ @@ -137,6 +136,15 @@ private: * Write a very basic header to the board file */ void writePcbHeader( LAYER_NUM* aLayerLookUpTable ); + + /** In Pcbnew files units are mm for coordinates. + * So MapToPcbUnits converts internal gerbview to mm any pcbnew value + * @param aValue is a coordinate value to convert in mm + */ + double MapToPcbUnits( int aValue ) + { + return aValue / IU_PER_MM; + } }; @@ -362,11 +370,11 @@ void GBR_TO_PCB_EXPORTER::writeCopperLineItem( wxPoint& aStart, wxPoint& aEnd, int aWidth, LAYER_NUM aLayer ) { fprintf( m_fp, "(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n", - Double2Str( TO_PCB_UNIT(aStart.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aStart.y) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.y) ).c_str(), - Double2Str( TO_PCB_UNIT( aWidth ) ).c_str(), + Double2Str( MapToPcbUnits(aStart.x) ).c_str(), + Double2Str( MapToPcbUnits(aStart.y) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.x) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.y) ).c_str(), + Double2Str( MapToPcbUnits( aWidth ) ).c_str(), TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) ); } @@ -447,9 +455,9 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem // Layers are Front to Back fprintf( m_fp, " (via (at %s %s) (size %s)", - Double2Str( TO_PCB_UNIT(via_pos.x) ).c_str(), - Double2Str( TO_PCB_UNIT(via_pos.y) ).c_str(), - Double2Str( TO_PCB_UNIT( width ) ).c_str() ); + Double2Str( MapToPcbUnits(via_pos.x) ).c_str(), + Double2Str( MapToPcbUnits(via_pos.y) ).c_str(), + Double2Str( MapToPcbUnits( width ) ).c_str() ); fprintf( m_fp, " (layers %s %s))\n", TO_UTF8( GetPCBDefaultLayerName( F_Cu ) ), @@ -476,6 +484,9 @@ void GBR_TO_PCB_EXPORTER::writePcbHeader( LAYER_NUM* aLayerLookUpTable ) for( int ii = B_Adhes; ii < PCB_LAYER_ID_COUNT; ii++ ) { + if( GetPCBDefaultLayerName( ii ).IsEmpty() ) // Layer not available for export + continue; + fprintf( m_fp, " (%d %s user)\n", ii, TO_UTF8( GetPCBDefaultLayerName( ii ) ) ); } @@ -489,35 +500,35 @@ void GBR_TO_PCB_EXPORTER::writePcbLineItem( bool aIsArc, wxPoint& aStart, wxPoin if( aIsArc && ( aAngle == 360.0 || aAngle == 0 ) ) { fprintf( m_fp, "(gr_circle (center %s %s) (end %s %s)(layer %s) (width %s))\n", - Double2Str( TO_PCB_UNIT(aStart.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aStart.y) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.y) ).c_str(), + Double2Str( MapToPcbUnits(aStart.x) ).c_str(), + Double2Str( MapToPcbUnits(aStart.y) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.x) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.y) ).c_str(), TO_UTF8( GetPCBDefaultLayerName( aLayer ) ), - Double2Str( TO_PCB_UNIT( aWidth ) ).c_str() + Double2Str( MapToPcbUnits( aWidth ) ).c_str() ); } else if( aIsArc ) { fprintf( m_fp, "(gr_arc (start %s %s) (end %s %s) (angle %s)(layer %s) (width %s))\n", - Double2Str( TO_PCB_UNIT(aStart.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aStart.y) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.y) ).c_str(), + Double2Str( MapToPcbUnits(aStart.x) ).c_str(), + Double2Str( MapToPcbUnits(aStart.y) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.x) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.y) ).c_str(), Double2Str( aAngle ).c_str(), TO_UTF8( GetPCBDefaultLayerName( aLayer ) ), - Double2Str( TO_PCB_UNIT( aWidth ) ).c_str() + Double2Str( MapToPcbUnits( aWidth ) ).c_str() ); } else { fprintf( m_fp, "(gr_line (start %s %s) (end %s %s)(layer %s) (width %s))\n", - Double2Str( TO_PCB_UNIT(aStart.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aStart.y) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.x) ).c_str(), - Double2Str( TO_PCB_UNIT(aEnd.y) ).c_str(), + Double2Str( MapToPcbUnits(aStart.x) ).c_str(), + Double2Str( MapToPcbUnits(aStart.y) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.x) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.y) ).c_str(), TO_UTF8( GetPCBDefaultLayerName( aLayer ) ), - Double2Str( TO_PCB_UNIT( aWidth ) ).c_str() + Double2Str( MapToPcbUnits( aWidth ) ).c_str() ); } } @@ -547,8 +558,8 @@ void GBR_TO_PCB_EXPORTER::writePcbPolygonItem( GERBER_DRAW_ITEM* aGbrItem, LAYER } fprintf( m_fp, " (xy %s %s)", - Double2Str( TO_PCB_UNIT( poly.Point( ii ).x ) ).c_str(), - Double2Str( TO_PCB_UNIT( -poly.Point( ii ).y ) ).c_str() ); + Double2Str( MapToPcbUnits( poly.Point( ii ).x ) ).c_str(), + Double2Str( MapToPcbUnits( -poly.Point( ii ).y ) ).c_str() ); } fprintf( m_fp, ")" );