Commit d696ee8c authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: added support og regular polygon aperure definition.

parent 6417db15
...@@ -12,12 +12,11 @@ email address. ...@@ -12,12 +12,11 @@ email address.
graphics items are now specific to gerbview (added a GERBER_DRAW_ITEM class) graphics items are now specific to gerbview (added a GERBER_DRAW_ITEM class)
and do not use tracks from pcbnew. and do not use tracks from pcbnew.
The way used to draw them is also new. The way used to draw them is also new.
Apertures are now correctly drawn for round, oval and rectangular shapes Apertures are now correctly drawn for round, oval, rectangular and regular polygon shapes
(with or without holes) (with or without holes)
Aperture definition type Polygon is not yet handle. Aperture definition type Polygon is not yet handle.
Polygons are correctly drawn. Polygons are correctly drawn.
TODO: TODO:
Draw functions for aperture definition type Polygon.
Draw functions for aperture macros. Draw functions for aperture macros.
Work in progress. Work in progress.
......
...@@ -106,10 +106,13 @@ wxString GERBER_DRAW_ITEM::ShowGBRShape() ...@@ -106,10 +106,13 @@ wxString GERBER_DRAW_ITEM::ShowGBRShape()
case GBR_SPOT_RECT: case GBR_SPOT_RECT:
return wxT( "spot_rect" ); return wxT( "spot_rect" );
case GBR_SPOT_POLY:
return wxT( "spot_poly" );
case GBR_POLYGON: case GBR_POLYGON:
return wxT( "polygon" ); return wxT( "polygon" );
case GBR_MACRO: case GBR_SPOT_MACRO:
return wxT( "apt_macro" ); // TODO: add aperture macro name return wxT( "apt_macro" ); // TODO: add aperture macro name
default: default:
...@@ -276,6 +279,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, ...@@ -276,6 +279,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
case GBR_SPOT_CIRCLE: case GBR_SPOT_CIRCLE:
case GBR_SPOT_RECT: case GBR_SPOT_RECT:
case GBR_SPOT_OVAL: case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
isFilled = DisplayOpt.DisplayPadFill ? true : false; isFilled = DisplayOpt.DisplayPadFill ? true : false;
d_codeDescr->DrawFlashedShape( &panel->m_ClipBox, DC, color, d_codeDescr->DrawFlashedShape( &panel->m_ClipBox, DC, color,
m_Start, isFilled ); m_Start, isFilled );
......
...@@ -40,7 +40,8 @@ enum Gbr_Basic_Shapes { ...@@ -40,7 +40,8 @@ enum Gbr_Basic_Shapes {
GBR_SPOT_CIRCLE, // flashed shape: round shape (can have hole) GBR_SPOT_CIRCLE, // flashed shape: round shape (can have hole)
GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole) GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole)
GBR_SPOT_OVAL, // flashed shape: oval shape GBR_SPOT_OVAL, // flashed shape: oval shape
GBR_MACRO, // complex shape described by a macro GBR_SPOT_POLY, // flashed shape: regulat polygon, 3 to 12 edges
GBR_SPOT_MACRO, // complex shape described by a macro
GBR_LAST // last value for this list GBR_LAST // last value for this list
}; };
......
This diff is collapsed.
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
* is the set of all gerber aperture types allowed, according to page 16 of * is the set of all gerber aperture types allowed, according to page 16 of
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf * http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/ */
enum APERTURE_T enum APERTURE_T {
{
APT_CIRCLE = 'C', APT_CIRCLE = 'C',
APT_LINE = 'L', APT_LINE = 'L',
APT_RECT = 'R', APT_RECT = 'R',
...@@ -26,10 +25,21 @@ enum APERTURE_T ...@@ -26,10 +25,21 @@ enum APERTURE_T
APT_MACRO = 'M' APT_MACRO = 'M'
}; };
// In aperture definition, round, oval and rectangular flashed shapes
// can have a hole (ropund or rectangular)
// this option is stored in .m_DrillShape D_CODE member
enum APERTURE_DEF_HOLETYPE {
APT_DEF_NO_HOLE = 0,
APT_DEF_ROUND_HOLE,
APT_DEF_RECT_HOLE
};
/* define min and max values for D Codes values.
* note: values >= 0 and > FIRST_DCODE can be used for specila purposes
*/
#define FIRST_DCODE 10 #define FIRST_DCODE 10
#define LAST_DCODE 999 // dcodes values are from 10 to 999 #define LAST_DCODE 999
#define TOOLS_MAX_COUNT (LAST_DCODE+1) #define TOOLS_MAX_COUNT (LAST_DCODE + 1)
class D_CODE; class D_CODE;
...@@ -46,17 +56,19 @@ class DCODE_PARAM ...@@ -46,17 +56,19 @@ class DCODE_PARAM
{ {
public: public:
DCODE_PARAM() : DCODE_PARAM() :
index(-1), index( -1 ),
value(0.0) value( 0.0 )
{} {}
double GetValue( const D_CODE* aDcode ) const; double GetValue( const D_CODE* aDcode ) const;
void SetValue( double aValue ) void SetValue( double aValue )
{ {
value = aValue; value = aValue;
index = -1; index = -1;
} }
/** /**
* Function IsImmediate * Function IsImmediate
* tests if this DCODE_PARAM holds an immediate parameter or is a pointer * tests if this DCODE_PARAM holds an immediate parameter or is a pointer
...@@ -69,11 +81,13 @@ public: ...@@ -69,11 +81,13 @@ public:
return (unsigned) index; return (unsigned) index;
} }
void SetIndex( int aIndex ) void SetIndex( int aIndex )
{ {
index = aIndex; index = aIndex;
} }
private: private:
int index; ///< if -1, then \a value field is an immediate value, int index; ///< if -1, then \a value field is an immediate value,
// else this is an index into parent's // else this is an index into parent's
...@@ -88,8 +102,7 @@ private: ...@@ -88,8 +102,7 @@ private:
* is the set of all "aperture macro primitives" (primitive numbers). See * is the set of all "aperture macro primitives" (primitive numbers). See
* Table 3 in http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf * Table 3 in http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/ */
enum AM_PRIMITIVE_ID enum AM_PRIMITIVE_ID {
{
AMP_CIRCLE = 1, AMP_CIRCLE = 1,
AMP_LINE2 = 2, AMP_LINE2 = 2,
AMP_LINE20 = 20, AMP_LINE20 = 20,
...@@ -151,7 +164,7 @@ struct APERTURE_MACRO ...@@ -151,7 +164,7 @@ struct APERTURE_MACRO
struct APERTURE_MACRO_less_than struct APERTURE_MACRO_less_than
{ {
// a "less than" test on two APERTURE_MACROs (.name wxStrings) // a "less than" test on two APERTURE_MACROs (.name wxStrings)
bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2) const bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2 ) const
{ {
return am1.name.Cmp( am2.name ) < 0; // case specific wxString compare return am1.name.Cmp( am2.name ) < 0; // case specific wxString compare
} }
...@@ -194,8 +207,9 @@ public: ...@@ -194,8 +207,9 @@ public:
APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */ APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
int m_Num_Dcode; /* D code ( >= 10 ) */ int m_Num_Dcode; /* D code ( >= 10 ) */
wxSize m_Drill; /* dimension of the hole (if any) */ wxSize m_Drill; /* dimension of the hole (if any) */
int m_DrillShape; /* shape of the hole (round = 1, rect = 2) */ APERTURE_DEF_HOLETYPE m_DrillShape; /* shape of the hole (0 = no hole, round = 1, rect = 2) */
double m_Rotation; /* shape rotation in degrees */ double m_Rotation; /* shape rotation in degrees */
int m_EdgesCount; /* in apeture definition Polygon only: number of edges for the polygon */
bool m_InUse; /* FALSE if not used */ bool m_InUse; /* FALSE if not used */
bool m_Defined; /* FALSE if not defined */ bool m_Defined; /* FALSE if not defined */
wxString m_SpecialDescr; wxString m_SpecialDescr;
...@@ -214,10 +228,13 @@ public: ...@@ -214,10 +228,13 @@ public:
m_am_params.push_back( param ); m_am_params.push_back( param );
} }
void SetMacro( APERTURE_MACRO* aMacro ) void SetMacro( APERTURE_MACRO* aMacro )
{ {
m_Macro = aMacro; m_Macro = aMacro;
} }
APERTURE_MACRO* GetMacro() { return m_Macro; } APERTURE_MACRO* GetMacro() { return m_Macro; }
/** /**
...@@ -249,8 +266,7 @@ public: ...@@ -249,8 +266,7 @@ public:
* Useful when a shape is not a graphic primitive (shape with hole, * Useful when a shape is not a graphic primitive (shape with hole,
* rotated shape ... ) and cannot be easily drawn. * rotated shape ... ) and cannot be easily drawn.
*/ */
void ConvertShapeToPolygon( ); void ConvertShapeToPolygon();
}; };
...@@ -262,13 +278,14 @@ inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) const ...@@ -262,13 +278,14 @@ inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) const
{ {
// the first one was numbered 1, not zero, as in $1, see page 19 of spec. // the first one was numbered 1, not zero, as in $1, see page 19 of spec.
unsigned ndx = GetIndex() - 1; unsigned ndx = GetIndex() - 1;
wxASSERT(aDcode); wxASSERT( aDcode );
// get the parameter from the aDcode // get the parameter from the aDcode
if( ndx < aDcode->m_am_params.size() ) if( ndx < aDcode->m_am_params.size() )
return aDcode->m_am_params[ndx].GetValue( NULL ); return aDcode->m_am_params[ndx].GetValue( NULL );
else else
{ {
wxASSERT( GetIndex()-1 < aDcode->m_am_params.size() ); wxASSERT( GetIndex() - 1 < aDcode->m_am_params.size() );
return 0.0; return 0.0;
} }
} }
......
...@@ -1095,6 +1095,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, ...@@ -1095,6 +1095,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
switch( aperture ) switch( aperture )
{ {
case APT_POLYGON: // flashed regular polygon
case APT_CIRCLE: case APT_CIRCLE:
gbritem = new GERBER_DRAW_ITEM( pcb ); gbritem = new GERBER_DRAW_ITEM( pcb );
pcb->m_Drawings.Append( gbritem ); pcb->m_Drawings.Append( gbritem );
...@@ -1102,6 +1103,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, ...@@ -1102,6 +1103,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
fillRoundFlashGBRITEM( gbritem, dcode, activeLayer, fillRoundFlashGBRITEM( gbritem, dcode, activeLayer,
m_CurrentPos, size.x, m_CurrentPos, size.x,
!(m_LayerNegative ^ m_ImageNegative) ); !(m_LayerNegative ^ m_ImageNegative) );
if( aperture == APT_POLYGON )
gbritem->m_Shape = GBR_SPOT_POLY;
break; break;
case APT_OVAL: case APT_OVAL:
......
...@@ -360,10 +360,13 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -360,10 +360,13 @@ bool GERBER::ExecuteRS274XCommand( int command,
break; break;
case AP_DEFINITION: case AP_DEFINITION:
/* input example: %ADD30R,0.081800X0.101500*%
// input example: %ADD30R,0.081800X0.101500*% * Aperture definition has 4 options: C, R, O, P
// at this point, text points to 2nd 'D' * (Circle, Rect, Oval, regular Polygon)
* and shapes can have a hole (round or rectangular).
* All optional parameters values start by X
* at this point, text points to 2nd 'D'
*/
if( *text++ != 'D' ) if( *text++ != 'D' )
{ {
ok = FALSE; ok = FALSE;
...@@ -391,7 +394,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -391,7 +394,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
dcode->m_Size.x = dcode->m_Size.y = dcode->m_Size.x = dcode->m_Size.y =
wxRound( ReadDouble( text ) * conv_scale ); wxRound( ReadDouble( text ) * conv_scale );
switch( stdAperture ) switch( stdAperture ) // Aperture desceiption has optional parameters. Read them
{ {
case 'C': // Circle case 'C': // Circle
dcode->m_Shape = APT_CIRCLE; dcode->m_Shape = APT_CIRCLE;
...@@ -403,7 +406,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -403,7 +406,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
text++; text++;
dcode->m_Drill.x = dcode->m_Drill.y = dcode->m_Drill.x = dcode->m_Drill.y =
wxRound( ReadDouble( text ) * conv_scale ); wxRound( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = 1; dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
} }
while( *text == ' ' ) while( *text == ' ' )
...@@ -415,7 +418,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -415,7 +418,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
dcode->m_Drill.y = dcode->m_Drill.y =
wxRound( ReadDouble( text ) * conv_scale ); wxRound( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = 2; dcode->m_DrillShape = APT_DEF_RECT_HOLE;
} }
dcode->m_Defined = TRUE; dcode->m_Defined = TRUE;
break; break;
...@@ -442,7 +445,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -442,7 +445,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
text++; text++;
dcode->m_Drill.x = dcode->m_Drill.y = dcode->m_Drill.x = dcode->m_Drill.y =
wxRound( ReadDouble( text ) * conv_scale ); wxRound( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = 1; dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
} }
while( *text == ' ' ) while( *text == ' ' )
...@@ -453,13 +456,55 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -453,13 +456,55 @@ bool GERBER::ExecuteRS274XCommand( int command,
text++; text++;
dcode->m_Drill.y = dcode->m_Drill.y =
wxRound( ReadDouble( text ) * conv_scale ); wxRound( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = 2; dcode->m_DrillShape = APT_DEF_RECT_HOLE;
} }
dcode->m_Defined = TRUE; dcode->m_Defined = TRUE;
break; break;
case 'P': // Polygon case 'P':
/* Regular polygon: a command line like %ADD12P,0.040X10X25X0.025X0.025X0.0150*%
* params are: <diameter>, X<edge count>, X<Rotation>, X<X hole dim>, X<Y hole dim>
*/
dcode->m_Shape = APT_POLYGON; dcode->m_Shape = APT_POLYGON;
while( *text == ' ' )
text++;
if( *text == 'X' )
{
text++;
dcode->m_EdgesCount = ReadInt( text );
}
while( *text == ' ' )
text++;
if( *text == 'X' )
{
text++;
dcode->m_Rotation = ReadDouble( text );
}
while( *text == ' ' )
text++;
if( *text == 'X' )
{
text++;
dcode->m_Drill.x = dcode->m_Drill.y =
wxRound( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = APT_DEF_ROUND_HOLE;
}
while( *text == ' ' )
text++;
if( *text == 'X' )
{
text++;
dcode->m_Drill.y =
wxRound( ReadDouble( text ) * conv_scale );
dcode->m_DrillShape = APT_DEF_RECT_HOLE;
}
dcode->m_Defined = TRUE; dcode->m_Defined = TRUE;
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment