2009-11-09 14:00:22 +00:00
|
|
|
|
/***************************/
|
|
|
|
|
/**** Read GERBER files ****/
|
|
|
|
|
/***************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
#include "confirm.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
|
#include "macros.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "gerbview.h"
|
|
|
|
|
#include "pcbplot.h"
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_SIZE 100
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
|
|
|
|
/* Format Gerber: NOTES:
|
|
|
|
|
* Features history:
|
|
|
|
|
* Gn =
|
|
|
|
|
* G01 linear interpolation (right trace)
|
|
|
|
|
* G02, G20, G21 Circular interpolation, meaning trig < 0
|
|
|
|
|
* G03, G30, G31 Circular interpolation, meaning trig > 0
|
|
|
|
|
* G04 review
|
|
|
|
|
* G06 parabolic interpolation
|
|
|
|
|
* G07 Cubic Interpolation
|
|
|
|
|
* G10 linear interpolation (scale x10)
|
|
|
|
|
* G11 linear interpolation (0.1x range)
|
|
|
|
|
* G12 linear interpolation (0.01x scale)
|
|
|
|
|
* G52 plot symbol reference code by Dnn
|
|
|
|
|
* G53 plot symbol reference by Dnn; symbol rotates from -90 degrees
|
|
|
|
|
* G54 Selection Tool
|
|
|
|
|
* G55 Fashion photo exhibition
|
|
|
|
|
* G56 plot symbol reference code for DNN
|
|
|
|
|
* G57 displays the symbol link to the console
|
|
|
|
|
* G58 plot displays the symbol and link to the console
|
|
|
|
|
* G60 linear interpolation (scale x100)
|
|
|
|
|
* G70 Units = Inches
|
|
|
|
|
* G71 Units = Millimeters
|
|
|
|
|
* G74 circular interpolation removes 360 degree, has returned G01
|
|
|
|
|
* G75 circular interpolation Active 360 degree
|
|
|
|
|
* G90 mode absolute coordinates
|
|
|
|
|
* G91 Fashion Related Contacts
|
|
|
|
|
*
|
|
|
|
|
* Coordinates X, Y
|
|
|
|
|
* X and Y are followed by + or - and m + n digits (not separated)
|
|
|
|
|
* m = integer part
|
|
|
|
|
* n = part after the comma
|
|
|
|
|
* conventional formats: m = 2, n = 3 (size 2.3)
|
|
|
|
|
* m = 3, n = 4 (size 3.4)
|
|
|
|
|
* eg
|
|
|
|
|
* G__ X00345Y-06123 * D__
|
|
|
|
|
*
|
|
|
|
|
* Tools and D_CODES
|
|
|
|
|
* tool number (identification of shapes)
|
|
|
|
|
* 1 to 99 (Classical)
|
|
|
|
|
* 1 to 999
|
|
|
|
|
*
|
|
|
|
|
* D_CODES:
|
|
|
|
|
* D01 ... D9 = action codes:
|
|
|
|
|
* D01 = activating light (lower pen) when di <EFBFBD><EFBFBD> placement
|
|
|
|
|
* D02 = light extinction (lift pen) when di <EFBFBD><EFBFBD> placement
|
|
|
|
|
* D03 Flash
|
|
|
|
|
* D09 = VAPE Flash
|
|
|
|
|
* D10 ... = Indentification Tool (Opening)
|
|
|
|
|
*/
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
GERBER::GERBER( int aLayer )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
m_Layer = aLayer; // Layer Number
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_Selected_Tool = FIRST_DCODE;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
ResetDefaultValues();
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
|
2008-11-09 02:57:42 +00:00
|
|
|
|
m_Aperture_List[ii] = 0;
|
2009-01-05 05:21:35 +00:00
|
|
|
|
|
|
|
|
|
m_Pcb = 0;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
GERBER::~GERBER()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
|
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
|
2008-11-09 02:57:42 +00:00
|
|
|
|
{
|
|
|
|
|
delete m_Aperture_List[ii];
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
// m_Aperture_List[ii] = NULL;
|
|
|
|
|
}
|
2009-01-05 05:21:35 +00:00
|
|
|
|
|
|
|
|
|
delete m_Pcb;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
D_CODE* GERBER::GetDCODE( int aDCODE, bool create )
|
|
|
|
|
{
|
|
|
|
|
unsigned ndx = aDCODE - FIRST_DCODE;
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
if( ndx < (unsigned) DIM( m_Aperture_List ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
// lazily create the D_CODE if it does not exist.
|
|
|
|
|
if( create )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
if( m_Aperture_List[ndx] == NULL )
|
|
|
|
|
m_Aperture_List[ndx] = new D_CODE( ndx + FIRST_DCODE );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
|
|
|
|
return m_Aperture_List[ndx];
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
2008-11-09 02:57:42 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup )
|
|
|
|
|
{
|
|
|
|
|
APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup );
|
|
|
|
|
|
|
|
|
|
if( iter != m_aperture_macros.end() )
|
|
|
|
|
{
|
|
|
|
|
APERTURE_MACRO* pam = (APERTURE_MACRO*) &(*iter);
|
|
|
|
|
return pam;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL; // not found
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
void GERBER::ResetDefaultValues()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_FileName.Empty();
|
|
|
|
|
m_Name = wxT( "no name" ); // Layer name
|
|
|
|
|
m_LayerNegative = FALSE; // TRUE = Negative Layer
|
|
|
|
|
m_ImageNegative = FALSE; // TRUE = Negative image
|
|
|
|
|
m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric
|
2009-11-09 14:00:22 +00:00
|
|
|
|
m_Relative = FALSE; // FALSE = absolute Coord, RUE =
|
|
|
|
|
// relative Coord
|
|
|
|
|
m_NoTrailingZeros = FALSE; // True: trailing zeros deleted
|
|
|
|
|
m_MirorA = FALSE; // True: miror / axe A (X)
|
|
|
|
|
m_MirorB = FALSE; // True: miror / axe B (Y)
|
|
|
|
|
m_Has_DCode = FALSE; // TRUE = DCodes in file (FALSE = no
|
|
|
|
|
// DCode->
|
2008-11-09 02:57:42 +00:00
|
|
|
|
// separate DCode file
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_Offset.x = m_Offset.y = 0; // Coord Offset
|
|
|
|
|
|
|
|
|
|
m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10;
|
|
|
|
|
m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10);
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
m_LayerScale.x = m_LayerScale.y = 1.0; // scale (X and Y) this
|
|
|
|
|
// layer
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_Rotation = 0;
|
|
|
|
|
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ.
|
2009-11-09 14:00:22 +00:00
|
|
|
|
m_360Arc_enbl = FALSE; // 360 deg circular
|
|
|
|
|
// interpolation disable
|
|
|
|
|
m_Current_Tool = 0; // Current Tool (Dcode)
|
|
|
|
|
// number selected
|
|
|
|
|
m_CommandState = 0; // gives tate of the
|
|
|
|
|
// stacking order analysis
|
|
|
|
|
m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord
|
|
|
|
|
// for plot
|
|
|
|
|
m_PreviousPos.x = m_PreviousPos.y = 0; // old current specified
|
|
|
|
|
// coord for plot
|
|
|
|
|
m_IJPos.x = m_IJPos.y = 0; // current centre coord for
|
|
|
|
|
// plot arcs & circles
|
|
|
|
|
m_Current_File = NULL; // File to read
|
|
|
|
|
m_FilesPtr = 0;
|
|
|
|
|
m_Transform[0][0] = m_Transform[1][1] = 1;
|
|
|
|
|
m_Transform[0][1] = m_Transform[1][0] = 0; // Rotation/mirror = Normal
|
|
|
|
|
m_PolygonFillMode = FALSE;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_PolygonFillModeState = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
int GERBER::ReturnUsedDcodeNumber()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
int count = 0;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
if( m_Aperture_List[ii] )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined )
|
2008-11-09 02:57:42 +00:00
|
|
|
|
++count;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
return count;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
void GERBER::InitToolTable()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
for( int count = 0; count < MAX_TOOLS; count++ )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( m_Aperture_List[count] == NULL )
|
|
|
|
|
continue;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE;
|
|
|
|
|
m_Aperture_List[count]->Clear_D_CODE_Data();
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
/***************/
|
|
|
|
|
/* Class DCODE */
|
|
|
|
|
/***************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
D_CODE::D_CODE( int num_dcode )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_Num_Dcode = num_dcode;
|
|
|
|
|
Clear_D_CODE_Data();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
D_CODE::~D_CODE()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
void D_CODE::Clear_D_CODE_Data()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_Size.x = DEFAULT_SIZE;
|
|
|
|
|
m_Size.y = DEFAULT_SIZE;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
m_Shape = APT_CIRCLE;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
m_Drill.x = m_Drill.y = 0;
|
|
|
|
|
m_DrillShape = 0;
|
2009-11-09 14:00:22 +00:00
|
|
|
|
m_InUse = FALSE;
|
|
|
|
|
m_Defined = FALSE;
|
|
|
|
|
m_Macro = 0;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
|
|
|
|
|
{
|
|
|
|
|
const wxChar* ret;
|
|
|
|
|
|
|
|
|
|
switch( aType )
|
|
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
|
case APT_CIRCLE:
|
|
|
|
|
ret = wxT( "Round" ); break;
|
|
|
|
|
|
|
|
|
|
case APT_LINE:
|
|
|
|
|
ret = wxT( "Line" ); break;
|
|
|
|
|
|
|
|
|
|
case APT_RECT:
|
|
|
|
|
ret = wxT( "Rect" ); break;
|
|
|
|
|
|
|
|
|
|
case APT_OVAL:
|
|
|
|
|
ret = wxT( "Oval" ); break;
|
|
|
|
|
|
|
|
|
|
case APT_POLYGON:
|
|
|
|
|
ret = wxT( "Poly" ); break;
|
|
|
|
|
|
|
|
|
|
case APT_MACRO:
|
|
|
|
|
ret = wxT( "Macro" ); break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
ret = wxT( "???" ); break;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
|
int current_Dcode, ii, dcode_scale;
|
|
|
|
|
char* ptcar;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
int dimH, dimV, drill, dummy;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
float fdimH, fdimV, fdrill;
|
|
|
|
|
char c_type_outil[256];
|
2008-11-08 06:44:07 +00:00
|
|
|
|
char line[GERBER_BUFZ];
|
2008-04-17 16:25:29 +00:00
|
|
|
|
wxString msg;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
D_CODE* dcode;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
FILE* dest;
|
|
|
|
|
int layer = GetScreen()->m_Active_Layer;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
int type_outil;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
if( g_GERBER_List[layer] == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
|
g_GERBER_List[layer] = new GERBER( layer );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
GERBER* gerber = g_GERBER_List[layer];
|
|
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
/* Updating gerber scale: */
|
|
|
|
|
dcode_scale = 10; /* By uniting dCode = mil, internal unit = 0.1 mil
|
|
|
|
|
* -> 1 unite dcode = 10 unit PCB */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
current_Dcode = 0;
|
|
|
|
|
|
|
|
|
|
if( D_Code_FullFileName.IsEmpty() )
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
dest = wxFopen( D_Code_FullFileName, wxT( "rt" ) );
|
|
|
|
|
if( dest == 0 )
|
|
|
|
|
{
|
|
|
|
|
msg = _( "File " ) + D_Code_FullFileName + _( " not found" );
|
|
|
|
|
DisplayError( this, msg, 10 );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
gerber->InitToolTable();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
while( fgets( line, sizeof(line) - 1, dest ) != NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
|
if( *line == ';' )
|
2009-11-09 14:00:22 +00:00
|
|
|
|
continue;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
if( strlen( line ) < 10 )
|
2009-11-09 14:00:22 +00:00
|
|
|
|
continue; /* Skip blank line. */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
dcode = NULL;
|
|
|
|
|
current_Dcode = 0;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
/* Determine of the type of file from D_Code. */
|
2008-11-08 06:44:07 +00:00
|
|
|
|
ptcar = line;
|
2009-11-09 14:00:22 +00:00
|
|
|
|
ii = 0;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
while( *ptcar )
|
|
|
|
|
if( *(ptcar++) == ',' )
|
|
|
|
|
ii++;
|
|
|
|
|
|
|
|
|
|
if( ii >= 6 ) /* valeurs en mils */
|
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
|
sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii,
|
2009-11-09 14:00:22 +00:00
|
|
|
|
&dimH, &dimV, &drill,
|
|
|
|
|
&dummy, &dummy,
|
|
|
|
|
&type_outil );
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
dimH = (int) ( (dimH * dcode_scale) + 0.5 );
|
|
|
|
|
dimV = (int) ( (dimV * dcode_scale) + 0.5 );
|
|
|
|
|
drill = (int) ( (drill * dcode_scale) + 0.5 );
|
|
|
|
|
if( ii < 1 )
|
|
|
|
|
ii = 1;
|
|
|
|
|
current_Dcode = ii - 1 + FIRST_DCODE;
|
|
|
|
|
}
|
2009-11-09 14:00:22 +00:00
|
|
|
|
else /* Values in inches are converted to mils. */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
fdrill = 0;
|
|
|
|
|
current_Dcode = 0;
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
sscanf( line, "%f,%f,%1s", &fdimV, &fdimH, c_type_outil );
|
|
|
|
|
ptcar = line;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
while( *ptcar )
|
|
|
|
|
{
|
|
|
|
|
if( *ptcar == 'D' )
|
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
|
sscanf( ptcar + 1, "%d,%f", ¤t_Dcode, &fdrill );
|
|
|
|
|
break;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ptcar++;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
dimH = (int) ( (fdimH * dcode_scale * 1000) + 0.5 );
|
|
|
|
|
dimV = (int) ( (fdimV * dcode_scale * 1000) + 0.5 );
|
|
|
|
|
drill = (int) ( (fdrill * dcode_scale * 1000) + 0.5 );
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
|
|
|
|
if( strchr( "CLROP", c_type_outil[0] ) )
|
|
|
|
|
type_outil = (APERTURE_T) c_type_outil[0];
|
|
|
|
|
else
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
|
fclose( dest );
|
|
|
|
|
return -2;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
/* Update the list of d_codes if consistant. */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( current_Dcode < FIRST_DCODE )
|
|
|
|
|
continue;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( current_Dcode >= MAX_TOOLS )
|
|
|
|
|
continue;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
dcode = gerber->GetDCODE( current_Dcode );
|
|
|
|
|
dcode->m_Size.x = dimH;
|
|
|
|
|
dcode->m_Size.y = dimV;
|
|
|
|
|
dcode->m_Shape = (APERTURE_T) type_outil;
|
|
|
|
|
dcode->m_Drill.x = dcode->m_Drill.y = drill;
|
|
|
|
|
dcode->m_Defined = TRUE;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose( dest );
|
|
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set Size Items (Lines, Flashes) from DCodes List
|
2008-04-17 16:25:29 +00:00
|
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
|
void WinEDA_GerberFrame::CopyDCodesSizeToItems()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
|
static D_CODE dummy( 999 ); //Used if D_CODE not found in list
|
2008-12-17 14:51:39 +00:00
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
GERBER* gerber = g_GERBER_List[track->GetLayer()];
|
|
|
|
|
wxASSERT( gerber );
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
|
D_CODE* dcode = gerber->GetDCODE( track->GetNet(), false );
|
2008-11-09 02:57:42 +00:00
|
|
|
|
wxASSERT( dcode );
|
2009-11-09 14:00:22 +00:00
|
|
|
|
if( dcode == NULL )
|
2008-12-17 14:51:39 +00:00
|
|
|
|
dcode = &dummy;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
|
|
|
|
|
dcode->m_InUse = TRUE;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
if( // Line Item
|
2009-11-09 14:00:22 +00:00
|
|
|
|
(track->m_Shape == S_SEGMENT ) /* rectilinear segment */
|
|
|
|
|
|| (track->m_Shape == S_RECT ) /* rect segment form (i.e.
|
|
|
|
|
* non-rounded ends) */
|
|
|
|
|
|| (track->m_Shape == S_ARC ) /* segment arc (rounded tips) */
|
|
|
|
|
|| (track->m_Shape == S_CIRCLE ) /* segment in a circle (ring) */
|
|
|
|
|
|| (track->m_Shape == S_ARC_RECT ) /* segment arc (stretches)
|
|
|
|
|
* (GERBER)*/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
)
|
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
track->m_Width = dcode->m_Size.x;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
else // Spots ( Flashed Items )
|
|
|
|
|
{
|
|
|
|
|
int width, len;
|
2008-11-09 02:57:42 +00:00
|
|
|
|
wxSize size = dcode->m_Size;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
width = MIN( size.x, size.y );
|
|
|
|
|
len = MAX( size.x, size.y ) - width;
|
|
|
|
|
|
|
|
|
|
track->m_Width = width;
|
|
|
|
|
|
|
|
|
|
track->m_Start.x = (track->m_Start.x + track->m_End.x) / 2;
|
|
|
|
|
track->m_Start.y = (track->m_Start.y + track->m_End.y) / 2;
|
2009-11-09 14:00:22 +00:00
|
|
|
|
track->m_End = track->m_Start; // m_Start = m_End = Spot center
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
switch( dcode->m_Shape )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
|
case APT_LINE: // might not appears here, but some broken
|
|
|
|
|
// gerber files use it
|
|
|
|
|
case APT_CIRCLE: /* spot round (for GERBER) */
|
2008-04-17 16:25:29 +00:00
|
|
|
|
track->m_Shape = S_SPOT_CIRCLE;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
case APT_OVAL: /* spot oval (for GERBER)*/
|
2008-04-17 16:25:29 +00:00
|
|
|
|
track->m_Shape = S_SPOT_OVALE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: /* spot rect (for GERBER)*/
|
|
|
|
|
track->m_Shape = S_SPOT_RECT;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
len >>= 1;
|
|
|
|
|
if( size.x > size.y )
|
|
|
|
|
{
|
|
|
|
|
track->m_Start.x -= len;
|
|
|
|
|
track->m_End.x += len;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
track->m_Start.y -= len;
|
|
|
|
|
track->m_End.y += len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
|
void WinEDA_GerberFrame::Liste_D_Codes( )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
|
int ii, jj;
|
|
|
|
|
D_CODE* pt_D_code;
|
|
|
|
|
wxString Line;
|
|
|
|
|
WinEDA_TextFrame* List;
|
|
|
|
|
int scale = 10000;
|
|
|
|
|
int curr_layer = GetScreen()->m_Active_Layer;
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
List = new WinEDA_TextFrame( this, _( "List D codes" ) );
|
|
|
|
|
|
2008-11-09 02:57:42 +00:00
|
|
|
|
for( int layer = 0; layer < 32; layer++ )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
GERBER* gerber = g_GERBER_List[layer];
|
2008-11-08 06:44:07 +00:00
|
|
|
|
if( gerber == NULL )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
continue;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
|
|
|
|
if( gerber->ReturnUsedDcodeNumber() == 0 )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
continue;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( layer == curr_layer )
|
|
|
|
|
Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
|
|
|
|
|
else
|
|
|
|
|
Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
|
|
|
|
|
List->Append( Line );
|
|
|
|
|
|
|
|
|
|
for( ii = 0, jj = 1; ii < MAX_TOOLS; ii++ )
|
|
|
|
|
{
|
2008-11-09 02:57:42 +00:00
|
|
|
|
pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( pt_D_code == NULL )
|
|
|
|
|
continue;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
|
|
|
|
|
continue;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
Line.Printf( wxT(
|
2009-11-09 14:00:22 +00:00
|
|
|
|
"tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ),
|
|
|
|
|
jj,
|
|
|
|
|
pt_D_code->m_Num_Dcode,
|
|
|
|
|
(float) pt_D_code->m_Size.y / scale,
|
|
|
|
|
(float) pt_D_code->m_Size.x / scale,
|
|
|
|
|
D_CODE::ShowApertureType( pt_D_code->m_Shape )
|
|
|
|
|
);
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
if( !pt_D_code->m_Defined )
|
|
|
|
|
Line += wxT( " ?" );
|
|
|
|
|
|
|
|
|
|
if( !pt_D_code->m_InUse )
|
|
|
|
|
Line += wxT( " *" );
|
|
|
|
|
|
|
|
|
|
List->Append( Line );
|
|
|
|
|
jj++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-08 06:44:07 +00:00
|
|
|
|
ii = List->ShowModal();
|
|
|
|
|
List->Destroy();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( ii < 0 )
|
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|