Loading gerbview/gerbview.h +12 −0 Original line number Original line Diff line number Diff line Loading @@ -179,6 +179,17 @@ struct AM_PRIMITIVE { { AM_PRIMITIVE_ID primitive_id; ///< The primitive type AM_PRIMITIVE_ID primitive_id; ///< The primitive type DCODE_PARAMS params; ///< A sequence of parameters used by the primitive DCODE_PARAMS params; ///< A sequence of parameters used by the primitive /** * Function GetExposure * returns the first parameter in integer form. Some but not all primitives * use the first parameter as an exposure control. */ int GetExposure() { wxASSERT( params.size() && params[0].IsImmediate() ); // we have no D_CODE* for GetValue() return (int) params[0].GetValue( NULL ); } }; }; Loading Loading @@ -290,6 +301,7 @@ inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) class GERBER class GERBER { { D_CODE* m_Aperture_List[MAX_TOOLS]; ///< Dcode (Aperture) List for this layer D_CODE* m_Aperture_List[MAX_TOOLS]; ///< Dcode (Aperture) List for this layer bool m_Exposure; ///< whether an aperture macro tool is flashed on or off public: public: Loading gerbview/rs274d.cpp +122 −37 Original line number Original line Diff line number Diff line Loading @@ -80,22 +80,25 @@ static wxPoint LastPosition; static void Append_1_Line_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, static void Append_1_Line_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, int largeur ); int largeur, bool isDark ); static void Append_1_Flash_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, static void Append_1_Flash_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, const wxSize& size, int forme ); const wxPoint& pos, const wxSize& size, int form, bool isDark ); static void Append_1_Flash_ROND_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, static void Append_1_Flash_ROND_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, int diametre ); const wxPoint& pos, int diameter, bool isDark ); static void Append_1_SEG_ARC_GERBER( int Dcode_index, static void Append_1_SEG_ARC_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& rel_center, int largeur, const wxPoint& rel_center, int largeur, bool trigo_sens, bool multiquadrant ); bool trigo_sens, bool multiquadrant, bool isDark ); /****************************************************************/ /****************************************************************/ static void Append_1_Flash_ROND_GERBER( int Dcode_tool, static void Append_1_Flash_ROND_GERBER( int Dcode_tool, WinEDA_GerberFrame* frame, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, int diametre ) wxDC* DC, const wxPoint& pos, int diameter, bool isDark ) /****************************************************************/ /****************************************************************/ /* Trace 1 flash ROND en position pos /* Trace 1 flash ROND en position pos Loading @@ -108,7 +111,7 @@ static void Append_1_Flash_ROND_GERBER( int Dcode_tool, track->Insert( frame->m_Pcb, NULL ); track->Insert( frame->m_Pcb, NULL ); track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->m_Width = diametre; track->m_Width = diameter; track->m_Start = track->m_End = pos; track->m_Start = track->m_End = pos; NEGATE( track->m_Start.y ); NEGATE( track->m_Start.y ); NEGATE( track->m_End.y ); NEGATE( track->m_End.y ); Loading @@ -122,7 +125,7 @@ static void Append_1_Flash_ROND_GERBER( int Dcode_tool, /**********************************************************************/ /**********************************************************************/ static void Append_1_Flash_GERBER( int Dcode_index, static void Append_1_Flash_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, const wxSize& size, int forme ) const wxPoint& pos, const wxSize& size, int forme, bool isDark ) /*********************************************************************/ /*********************************************************************/ /* /* Loading Loading @@ -172,11 +175,14 @@ static void Append_1_Flash_GERBER( int Dcode_index, static void Append_1_Line_GERBER( int Dcode_index, static void Append_1_Line_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, int largeur ) int largeur, bool isDark ) /********************************************************************/ /********************************************************************/ { { TRACK* track; TRACK* track; // @todo: need to handle isDark = false case. This means using the background color. // Best way to do this? track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb ); track->Insert( frame->m_Pcb, NULL ); track->Insert( frame->m_Pcb, NULL ); Loading @@ -198,7 +204,7 @@ static void Append_1_SEG_ARC_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& rel_center, int largeur, const wxPoint& rel_center, int largeur, bool trigo_sens, bool multiquadrant ) bool trigo_sens, bool multiquadrant, bool isDark ) /*****************************************************************/ /*****************************************************************/ /* creation d'un arc: /* creation d'un arc: Loading Loading @@ -462,7 +468,8 @@ wxPoint GERBER::ReadIJCoord( char*& Text ) { { type_coord = *Text; type_coord = *Text; Text++; Text++; text = line; nbchar = 0; text = line; nbchar = 0; while( IsNumber( *Text ) ) while( IsNumber( *Text ) ) { { if( *Text == '.' ) if( *Text == '.' ) Loading @@ -488,7 +495,8 @@ wxPoint GERBER::ReadIJCoord( char*& Text ) int min_digit = (type_coord == 'I') ? m_FmtLen.x : m_FmtLen.y; int min_digit = (type_coord == 'I') ? m_FmtLen.x : m_FmtLen.y; while( nbchar < min_digit ) while( nbchar < min_digit ) { { *(text++) = '0'; nbchar++; *(text++) = '0'; nbchar++; } } *text = 0; *text = 0; Loading Loading @@ -703,6 +711,59 @@ bool GERBER::Execute_G_Command( char*& text, int G_commande ) } } /** * Function scale * converts a distance given in floating point to our deci-mils */ static int scale( double aCoord, bool isMetric ) { int ret; if( isMetric ) ret = (int) round( aCoord / 0.00254 ); else ret = (int) round( aCoord * PCB_INTERNAL_UNIT ); return ret; } /** * Function mapPt * translates a point from the aperture macro coordinate system to our * deci-mils coordinate system. * @return wxSize - The gerbview coordinate system vector. */ static wxSize mapPt( double x, double y, bool isMetric ) { wxSize ret( scale( x, isMetric ), scale( y, isMetric ) ); return ret; } static bool mapExposure( int param1, bool curExposure ) { bool exposure; switch( param1 ) { case 0: exposure = false; break; default: case 1: exposure = true; break; case 2: exposure = !curExposure; } return exposure; } /*****************************************************************************/ /*****************************************************************************/ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, char*& text, int D_commande ) char*& text, int D_commande ) Loading @@ -713,7 +774,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, APERTURE_T aperture = APT_CIRCLE; APERTURE_T aperture = APT_CIRCLE; int dcode = 0; int dcode = 0; D_CODE* pt_Tool = NULL; D_CODE* tool = NULL; wxString msg; wxString msg; if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command Loading @@ -721,7 +782,9 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, if( D_commande > (MAX_TOOLS - 1) ) if( D_commande > (MAX_TOOLS - 1) ) D_commande = MAX_TOOLS - 1; D_commande = MAX_TOOLS - 1; // remember which tool it selected, nothing is done with it in this call m_Current_Tool = D_commande; m_Current_Tool = D_commande; D_CODE* pt_Dcode = GetDCODE( D_commande, false ); D_CODE* pt_Dcode = GetDCODE( D_commande, false ); if( pt_Dcode ) if( pt_Dcode ) pt_Dcode->m_InUse = TRUE; pt_Dcode->m_InUse = TRUE; Loading @@ -739,6 +802,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, { { case 1: // code D01 Draw line, exposure ON case 1: // code D01 Draw line, exposure ON { { m_Exposure = true; SEGZONE* edge_poly, * last; SEGZONE* edge_poly, * last; edge_poly = new SEGZONE( frame->m_Pcb ); edge_poly = new SEGZONE( frame->m_Pcb ); Loading @@ -763,6 +827,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, } } case 2: // code D2: exposure OFF (i.e. "move to") case 2: // code D2: exposure OFF (i.e. "move to") m_Exposure = false; m_PreviousPos = m_CurrentPos; m_PreviousPos = m_CurrentPos; m_PolygonFillModeState = 0; m_PolygonFillModeState = 0; break; break; Loading @@ -775,12 +840,14 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, switch( D_commande ) switch( D_commande ) { { case 1: // code D01 Draw line, exposure ON case 1: // code D01 Draw line, exposure ON pt_Tool = GetDCODE( m_Current_Tool, false ); m_Exposure = true; if( pt_Tool ) tool = GetDCODE( m_Current_Tool, false ); if( tool ) { { size = pt_Tool->m_Size; size = tool->m_Size; dcode = pt_Tool->m_Num_Dcode; dcode = tool->m_Num_Dcode; aperture = pt_Tool->m_Shape; aperture = tool->m_Shape; } } switch( m_Iterpolation ) switch( m_Iterpolation ) Loading @@ -789,7 +856,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, Append_1_Line_GERBER( dcode, Append_1_Line_GERBER( dcode, frame, DC, frame, DC, m_PreviousPos, m_CurrentPos, m_PreviousPos, m_CurrentPos, size.x ); size.x, m_Exposure ^ m_ImageNegative ); break; break; case GERB_INTERPOL_LINEAR_01X: case GERB_INTERPOL_LINEAR_01X: Loading @@ -802,14 +869,16 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, Append_1_SEG_ARC_GERBER( dcode, Append_1_SEG_ARC_GERBER( dcode, frame, DC, frame, DC, m_PreviousPos, m_CurrentPos, m_IJPos, m_PreviousPos, m_CurrentPos, m_IJPos, size.x, FALSE, m_360Arc_enbl ); size.x, FALSE, m_360Arc_enbl, m_Exposure ^ m_ImageNegative ); break; break; case GERB_INTERPOL_ARC_POS: case GERB_INTERPOL_ARC_POS: Append_1_SEG_ARC_GERBER( dcode, Append_1_SEG_ARC_GERBER( dcode, frame, DC, frame, DC, m_PreviousPos, m_CurrentPos, m_IJPos, m_PreviousPos, m_CurrentPos, m_IJPos, size.x, TRUE, m_360Arc_enbl ); size.x, TRUE, m_360Arc_enbl, m_Exposure ^ m_ImageNegative ); break; break; default: default: Loading @@ -823,16 +892,17 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, break; break; case 2: // code D2: exposure OFF (i.e. "move to") case 2: // code D2: exposure OFF (i.e. "move to") m_Exposure = false; m_PreviousPos = m_CurrentPos; m_PreviousPos = m_CurrentPos; break; break; case 3: // code D3: flash aperture case 3: // code D3: flash aperture pt_Tool = GetDCODE( m_Current_Tool, false ); tool = GetDCODE( m_Current_Tool, false ); if( pt_Tool ) if( tool ) { { size = pt_Tool->m_Size; size = tool->m_Size; dcode = pt_Tool->m_Num_Dcode; dcode = tool->m_Num_Dcode; aperture = pt_Tool->m_Shape; aperture = tool->m_Shape; } } switch( aperture ) switch( aperture ) Loading @@ -842,47 +912,61 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, Append_1_Flash_ROND_GERBER( dcode, Append_1_Flash_ROND_GERBER( dcode, frame, DC, frame, DC, m_CurrentPos, m_CurrentPos, size.x ); size.x, true ^ m_ImageNegative ); break; break; case APT_OVAL: case APT_OVAL: Append_1_Flash_GERBER( dcode, Append_1_Flash_GERBER( dcode, frame, DC, m_CurrentPos, frame, DC, m_CurrentPos, size, size, PAD_OVAL ); PAD_OVAL, true ^ m_ImageNegative ); break; break; case APT_RECT: case APT_RECT: Append_1_Flash_GERBER( dcode, Append_1_Flash_GERBER( dcode, frame, DC, m_CurrentPos, frame, DC, m_CurrentPos, size, size, PAD_RECT ); PAD_RECT, true ^ m_ImageNegative ); break; break; case APT_MACRO: case APT_MACRO: { { APERTURE_MACRO* macro = pt_Tool->GetMacro(); wxPoint curPos = m_CurrentPos; APERTURE_MACRO* macro = tool->GetMacro(); wxASSERT( macro ); wxASSERT( macro ); // split the macro primitives up into multiple normal TRACK elements // split the macro primitives up into multiple normal TRACK elements for( AM_PRIMITIVES::iterator i=macro->primitives.begin(); i!=macro->primitives.end(); ++i ) for( AM_PRIMITIVES::iterator p=macro->primitives.begin(); p!=macro->primitives.end(); ++p ) { { switch( i->primitive_id ) bool exposure; switch( p->primitive_id ) { { case AMP_CIRCLE: case AMP_CIRCLE: /* exposure = mapExposure( p->GetExposure(), m_Exposure ); Append_1_Flash_ROND_GERBER( dcode, curPos += mapPt( p->params[2].GetValue( tool ), p->params[3].GetValue( tool ), m_GerbMetric ); frame, DC, Append_1_Flash_ROND_GERBER( dcode, frame, DC, m_CurrentPos, curPos, size.x ); scale( p->params[1].GetValue( tool ), m_GerbMetric ), // diameter */ exposure ^ m_ImageNegative ); break; break; case AMP_LINE2: case AMP_LINE2: case AMP_LINE20: case AMP_LINE20: break; break; case AMP_LINE_CENTER: case AMP_LINE_CENTER: break; case AMP_LINE_LOWER_LEFT: case AMP_LINE_LOWER_LEFT: exposure = mapExposure( p->GetExposure(), m_Exposure ); curPos += mapPt( p->params[3].GetValue( tool ), p->params[4].GetValue( tool ), m_GerbMetric ); size = mapPt( p->params[1].GetValue( tool ), p->params[2].GetValue( tool ), m_GerbMetric ); Append_1_Flash_GERBER( dcode, frame, DC, curPos, size, PAD_RECT, exposure ^ m_ImageNegative ); break; case AMP_EOF: case AMP_EOF: case AMP_OUTLINE: case AMP_OUTLINE: case AMP_POLYGON: case AMP_POLYGON: Loading @@ -908,3 +992,4 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, return TRUE; return TRUE; } } gerbview/rs274x.cpp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -486,6 +486,8 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t break; break; } } dcode->m_Shape = APT_MACRO; D(printf("pam has %d parameters\n", pam->primitives.size() );) D(printf("pam has %d parameters\n", pam->primitives.size() );) dcode->SetMacro( (APERTURE_MACRO*) pam ); dcode->SetMacro( (APERTURE_MACRO*) pam ); Loading Loading
gerbview/gerbview.h +12 −0 Original line number Original line Diff line number Diff line Loading @@ -179,6 +179,17 @@ struct AM_PRIMITIVE { { AM_PRIMITIVE_ID primitive_id; ///< The primitive type AM_PRIMITIVE_ID primitive_id; ///< The primitive type DCODE_PARAMS params; ///< A sequence of parameters used by the primitive DCODE_PARAMS params; ///< A sequence of parameters used by the primitive /** * Function GetExposure * returns the first parameter in integer form. Some but not all primitives * use the first parameter as an exposure control. */ int GetExposure() { wxASSERT( params.size() && params[0].IsImmediate() ); // we have no D_CODE* for GetValue() return (int) params[0].GetValue( NULL ); } }; }; Loading Loading @@ -290,6 +301,7 @@ inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) class GERBER class GERBER { { D_CODE* m_Aperture_List[MAX_TOOLS]; ///< Dcode (Aperture) List for this layer D_CODE* m_Aperture_List[MAX_TOOLS]; ///< Dcode (Aperture) List for this layer bool m_Exposure; ///< whether an aperture macro tool is flashed on or off public: public: Loading
gerbview/rs274d.cpp +122 −37 Original line number Original line Diff line number Diff line Loading @@ -80,22 +80,25 @@ static wxPoint LastPosition; static void Append_1_Line_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, static void Append_1_Line_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, int largeur ); int largeur, bool isDark ); static void Append_1_Flash_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, static void Append_1_Flash_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, const wxSize& size, int forme ); const wxPoint& pos, const wxSize& size, int form, bool isDark ); static void Append_1_Flash_ROND_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, static void Append_1_Flash_ROND_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, int diametre ); const wxPoint& pos, int diameter, bool isDark ); static void Append_1_SEG_ARC_GERBER( int Dcode_index, static void Append_1_SEG_ARC_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& rel_center, int largeur, const wxPoint& rel_center, int largeur, bool trigo_sens, bool multiquadrant ); bool trigo_sens, bool multiquadrant, bool isDark ); /****************************************************************/ /****************************************************************/ static void Append_1_Flash_ROND_GERBER( int Dcode_tool, static void Append_1_Flash_ROND_GERBER( int Dcode_tool, WinEDA_GerberFrame* frame, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, int diametre ) wxDC* DC, const wxPoint& pos, int diameter, bool isDark ) /****************************************************************/ /****************************************************************/ /* Trace 1 flash ROND en position pos /* Trace 1 flash ROND en position pos Loading @@ -108,7 +111,7 @@ static void Append_1_Flash_ROND_GERBER( int Dcode_tool, track->Insert( frame->m_Pcb, NULL ); track->Insert( frame->m_Pcb, NULL ); track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->SetLayer( frame->GetScreen()->m_Active_Layer ); track->m_Width = diametre; track->m_Width = diameter; track->m_Start = track->m_End = pos; track->m_Start = track->m_End = pos; NEGATE( track->m_Start.y ); NEGATE( track->m_Start.y ); NEGATE( track->m_End.y ); NEGATE( track->m_End.y ); Loading @@ -122,7 +125,7 @@ static void Append_1_Flash_ROND_GERBER( int Dcode_tool, /**********************************************************************/ /**********************************************************************/ static void Append_1_Flash_GERBER( int Dcode_index, static void Append_1_Flash_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& pos, const wxSize& size, int forme ) const wxPoint& pos, const wxSize& size, int forme, bool isDark ) /*********************************************************************/ /*********************************************************************/ /* /* Loading Loading @@ -172,11 +175,14 @@ static void Append_1_Flash_GERBER( int Dcode_index, static void Append_1_Line_GERBER( int Dcode_index, static void Append_1_Line_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, int largeur ) int largeur, bool isDark ) /********************************************************************/ /********************************************************************/ { { TRACK* track; TRACK* track; // @todo: need to handle isDark = false case. This means using the background color. // Best way to do this? track = new TRACK( frame->m_Pcb ); track = new TRACK( frame->m_Pcb ); track->Insert( frame->m_Pcb, NULL ); track->Insert( frame->m_Pcb, NULL ); Loading @@ -198,7 +204,7 @@ static void Append_1_SEG_ARC_GERBER( int Dcode_index, WinEDA_GerberFrame* frame, wxDC* DC, WinEDA_GerberFrame* frame, wxDC* DC, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& startpoint, const wxPoint& endpoint, const wxPoint& rel_center, int largeur, const wxPoint& rel_center, int largeur, bool trigo_sens, bool multiquadrant ) bool trigo_sens, bool multiquadrant, bool isDark ) /*****************************************************************/ /*****************************************************************/ /* creation d'un arc: /* creation d'un arc: Loading Loading @@ -462,7 +468,8 @@ wxPoint GERBER::ReadIJCoord( char*& Text ) { { type_coord = *Text; type_coord = *Text; Text++; Text++; text = line; nbchar = 0; text = line; nbchar = 0; while( IsNumber( *Text ) ) while( IsNumber( *Text ) ) { { if( *Text == '.' ) if( *Text == '.' ) Loading @@ -488,7 +495,8 @@ wxPoint GERBER::ReadIJCoord( char*& Text ) int min_digit = (type_coord == 'I') ? m_FmtLen.x : m_FmtLen.y; int min_digit = (type_coord == 'I') ? m_FmtLen.x : m_FmtLen.y; while( nbchar < min_digit ) while( nbchar < min_digit ) { { *(text++) = '0'; nbchar++; *(text++) = '0'; nbchar++; } } *text = 0; *text = 0; Loading Loading @@ -703,6 +711,59 @@ bool GERBER::Execute_G_Command( char*& text, int G_commande ) } } /** * Function scale * converts a distance given in floating point to our deci-mils */ static int scale( double aCoord, bool isMetric ) { int ret; if( isMetric ) ret = (int) round( aCoord / 0.00254 ); else ret = (int) round( aCoord * PCB_INTERNAL_UNIT ); return ret; } /** * Function mapPt * translates a point from the aperture macro coordinate system to our * deci-mils coordinate system. * @return wxSize - The gerbview coordinate system vector. */ static wxSize mapPt( double x, double y, bool isMetric ) { wxSize ret( scale( x, isMetric ), scale( y, isMetric ) ); return ret; } static bool mapExposure( int param1, bool curExposure ) { bool exposure; switch( param1 ) { case 0: exposure = false; break; default: case 1: exposure = true; break; case 2: exposure = !curExposure; } return exposure; } /*****************************************************************************/ /*****************************************************************************/ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, char*& text, int D_commande ) char*& text, int D_commande ) Loading @@ -713,7 +774,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, APERTURE_T aperture = APT_CIRCLE; APERTURE_T aperture = APT_CIRCLE; int dcode = 0; int dcode = 0; D_CODE* pt_Tool = NULL; D_CODE* tool = NULL; wxString msg; wxString msg; if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command Loading @@ -721,7 +782,9 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, if( D_commande > (MAX_TOOLS - 1) ) if( D_commande > (MAX_TOOLS - 1) ) D_commande = MAX_TOOLS - 1; D_commande = MAX_TOOLS - 1; // remember which tool it selected, nothing is done with it in this call m_Current_Tool = D_commande; m_Current_Tool = D_commande; D_CODE* pt_Dcode = GetDCODE( D_commande, false ); D_CODE* pt_Dcode = GetDCODE( D_commande, false ); if( pt_Dcode ) if( pt_Dcode ) pt_Dcode->m_InUse = TRUE; pt_Dcode->m_InUse = TRUE; Loading @@ -739,6 +802,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, { { case 1: // code D01 Draw line, exposure ON case 1: // code D01 Draw line, exposure ON { { m_Exposure = true; SEGZONE* edge_poly, * last; SEGZONE* edge_poly, * last; edge_poly = new SEGZONE( frame->m_Pcb ); edge_poly = new SEGZONE( frame->m_Pcb ); Loading @@ -763,6 +827,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, } } case 2: // code D2: exposure OFF (i.e. "move to") case 2: // code D2: exposure OFF (i.e. "move to") m_Exposure = false; m_PreviousPos = m_CurrentPos; m_PreviousPos = m_CurrentPos; m_PolygonFillModeState = 0; m_PolygonFillModeState = 0; break; break; Loading @@ -775,12 +840,14 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, switch( D_commande ) switch( D_commande ) { { case 1: // code D01 Draw line, exposure ON case 1: // code D01 Draw line, exposure ON pt_Tool = GetDCODE( m_Current_Tool, false ); m_Exposure = true; if( pt_Tool ) tool = GetDCODE( m_Current_Tool, false ); if( tool ) { { size = pt_Tool->m_Size; size = tool->m_Size; dcode = pt_Tool->m_Num_Dcode; dcode = tool->m_Num_Dcode; aperture = pt_Tool->m_Shape; aperture = tool->m_Shape; } } switch( m_Iterpolation ) switch( m_Iterpolation ) Loading @@ -789,7 +856,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, Append_1_Line_GERBER( dcode, Append_1_Line_GERBER( dcode, frame, DC, frame, DC, m_PreviousPos, m_CurrentPos, m_PreviousPos, m_CurrentPos, size.x ); size.x, m_Exposure ^ m_ImageNegative ); break; break; case GERB_INTERPOL_LINEAR_01X: case GERB_INTERPOL_LINEAR_01X: Loading @@ -802,14 +869,16 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, Append_1_SEG_ARC_GERBER( dcode, Append_1_SEG_ARC_GERBER( dcode, frame, DC, frame, DC, m_PreviousPos, m_CurrentPos, m_IJPos, m_PreviousPos, m_CurrentPos, m_IJPos, size.x, FALSE, m_360Arc_enbl ); size.x, FALSE, m_360Arc_enbl, m_Exposure ^ m_ImageNegative ); break; break; case GERB_INTERPOL_ARC_POS: case GERB_INTERPOL_ARC_POS: Append_1_SEG_ARC_GERBER( dcode, Append_1_SEG_ARC_GERBER( dcode, frame, DC, frame, DC, m_PreviousPos, m_CurrentPos, m_IJPos, m_PreviousPos, m_CurrentPos, m_IJPos, size.x, TRUE, m_360Arc_enbl ); size.x, TRUE, m_360Arc_enbl, m_Exposure ^ m_ImageNegative ); break; break; default: default: Loading @@ -823,16 +892,17 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, break; break; case 2: // code D2: exposure OFF (i.e. "move to") case 2: // code D2: exposure OFF (i.e. "move to") m_Exposure = false; m_PreviousPos = m_CurrentPos; m_PreviousPos = m_CurrentPos; break; break; case 3: // code D3: flash aperture case 3: // code D3: flash aperture pt_Tool = GetDCODE( m_Current_Tool, false ); tool = GetDCODE( m_Current_Tool, false ); if( pt_Tool ) if( tool ) { { size = pt_Tool->m_Size; size = tool->m_Size; dcode = pt_Tool->m_Num_Dcode; dcode = tool->m_Num_Dcode; aperture = pt_Tool->m_Shape; aperture = tool->m_Shape; } } switch( aperture ) switch( aperture ) Loading @@ -842,47 +912,61 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, Append_1_Flash_ROND_GERBER( dcode, Append_1_Flash_ROND_GERBER( dcode, frame, DC, frame, DC, m_CurrentPos, m_CurrentPos, size.x ); size.x, true ^ m_ImageNegative ); break; break; case APT_OVAL: case APT_OVAL: Append_1_Flash_GERBER( dcode, Append_1_Flash_GERBER( dcode, frame, DC, m_CurrentPos, frame, DC, m_CurrentPos, size, size, PAD_OVAL ); PAD_OVAL, true ^ m_ImageNegative ); break; break; case APT_RECT: case APT_RECT: Append_1_Flash_GERBER( dcode, Append_1_Flash_GERBER( dcode, frame, DC, m_CurrentPos, frame, DC, m_CurrentPos, size, size, PAD_RECT ); PAD_RECT, true ^ m_ImageNegative ); break; break; case APT_MACRO: case APT_MACRO: { { APERTURE_MACRO* macro = pt_Tool->GetMacro(); wxPoint curPos = m_CurrentPos; APERTURE_MACRO* macro = tool->GetMacro(); wxASSERT( macro ); wxASSERT( macro ); // split the macro primitives up into multiple normal TRACK elements // split the macro primitives up into multiple normal TRACK elements for( AM_PRIMITIVES::iterator i=macro->primitives.begin(); i!=macro->primitives.end(); ++i ) for( AM_PRIMITIVES::iterator p=macro->primitives.begin(); p!=macro->primitives.end(); ++p ) { { switch( i->primitive_id ) bool exposure; switch( p->primitive_id ) { { case AMP_CIRCLE: case AMP_CIRCLE: /* exposure = mapExposure( p->GetExposure(), m_Exposure ); Append_1_Flash_ROND_GERBER( dcode, curPos += mapPt( p->params[2].GetValue( tool ), p->params[3].GetValue( tool ), m_GerbMetric ); frame, DC, Append_1_Flash_ROND_GERBER( dcode, frame, DC, m_CurrentPos, curPos, size.x ); scale( p->params[1].GetValue( tool ), m_GerbMetric ), // diameter */ exposure ^ m_ImageNegative ); break; break; case AMP_LINE2: case AMP_LINE2: case AMP_LINE20: case AMP_LINE20: break; break; case AMP_LINE_CENTER: case AMP_LINE_CENTER: break; case AMP_LINE_LOWER_LEFT: case AMP_LINE_LOWER_LEFT: exposure = mapExposure( p->GetExposure(), m_Exposure ); curPos += mapPt( p->params[3].GetValue( tool ), p->params[4].GetValue( tool ), m_GerbMetric ); size = mapPt( p->params[1].GetValue( tool ), p->params[2].GetValue( tool ), m_GerbMetric ); Append_1_Flash_GERBER( dcode, frame, DC, curPos, size, PAD_RECT, exposure ^ m_ImageNegative ); break; case AMP_EOF: case AMP_EOF: case AMP_OUTLINE: case AMP_OUTLINE: case AMP_POLYGON: case AMP_POLYGON: Loading @@ -908,3 +992,4 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, return TRUE; return TRUE; } }
gerbview/rs274x.cpp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -486,6 +486,8 @@ bool GERBER::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& t break; break; } } dcode->m_Shape = APT_MACRO; D(printf("pam has %d parameters\n", pam->primitives.size() );) D(printf("pam has %d parameters\n", pam->primitives.size() );) dcode->SetMacro( (APERTURE_MACRO*) pam ); dcode->SetMacro( (APERTURE_MACRO*) pam ); Loading