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

finished Draw functions for aperture macros. Now aperture macros are drawn correctly.

 Known bug: aperture macros having parameters are incorrect: parameters are not transmited correctly. Work still in progress.
parent e0617666
...@@ -4,6 +4,14 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,14 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2010-oct-03, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++gerbview:
finished Draw functions for aperture macros.
Now aperture macros are draww correctly.
Known bug: aperture macros having parameters are incorrect: parameters are not transmited correctly.
Work still in progress.
2010-sept-28, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2010-sept-28, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++gerbview: ++gerbview:
......
This diff is collapsed.
...@@ -84,21 +84,37 @@ public: ...@@ -84,21 +84,37 @@ public:
* returns the first parameter in integer form. Some but not all primitives * returns the first parameter in integer form. Some but not all primitives
* use the first parameter as an exposure control. * use the first parameter as an exposure control.
*/ */
int GetExposure() const int GetExposure() const;
{
// No D_CODE* for GetValue()
wxASSERT( params.size() && params[0].IsImmediate() );
return (int) params[0].GetValue( NULL );
}
/**
* Function mapExposure
* translates the first parameter from an aperture macro into a current
* exposure setting.
* @param aParent = a GERBER_DRAW_ITEM that handle:
* ** m_Exposure A dynamic setting which can change throughout the
* reading of the gerber file, and it indicates whether the current tool
* is lit or not.
* ** m_ImageNegative A dynamic setting which can change throughout the reading
* of the gerber file, and it indicates whether the current D codes are to
* be interpreted as erasures or not.
* @return true to draw with current color, false to draw with alt color (erase)
*/
bool mapExposure( GERBER_DRAW_ITEM* aParent );
/* Draw functions: */ /* Draw functions: */
/** function DrawBasicShape /** function DrawBasicShape
* Draw the primitive shape for flashed items. * Draw the primitive shape for flashed items.
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @param aClipBox = DC clip box (NULL is no clip)
* @param aDC = device context
* @param aColor = the normal color to use
* @param aAltColor = the color used to draw with "reverse" exposure mode (used in aperture macros only)
* @param aShapePos = the actual shape position
* @param aFilledShape = true to draw in filled mode, false to draw in skecth mode
*/ */
void DrawBasicShape( GERBER_DRAW_ITEM* aParent, EDA_Rect* aClipBox, wxDC* aDC, void DrawBasicShape( GERBER_DRAW_ITEM* aParent, EDA_Rect* aClipBox, wxDC* aDC,
int aColor, wxPoint aShapePos, bool aFilledShape ); int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape );
private: private:
...@@ -126,9 +142,16 @@ struct APERTURE_MACRO ...@@ -126,9 +142,16 @@ struct APERTURE_MACRO
/** function DrawApertureMacroShape /** function DrawApertureMacroShape
* Draw the primitive shape for flashed items. * Draw the primitive shape for flashed items.
* When an item is flashed, this is the shape of the item * When an item is flashed, this is the shape of the item
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @param aClipBox = DC clip box (NULL is no clip)
* @param aDC = device context
* @param aColor = the normal color to use
* @param aAltColor = the color used to draw with "reverse" exposure mode (used in aperture macros only)
* @param aShapePos = the actual shape position
* @param aFilledShape = true to draw in filled mode, false to draw in skecth mode
*/ */
void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_Rect* aClipBox, wxDC* aDC, void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_Rect* aClipBox, wxDC* aDC,
int aColor, wxPoint aShapePos, bool aFilledShape ); int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape );
}; };
......
...@@ -50,6 +50,8 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) : ...@@ -50,6 +50,8 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) :
m_Flashed = false; m_Flashed = false;
m_DCode = 0; m_DCode = 0;
m_UnitsMetric = false; m_UnitsMetric = false;
m_ImageNegative = false;
m_LayerNegative = false;
} }
...@@ -72,6 +74,9 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) : ...@@ -72,6 +74,9 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
m_DCode = aSource.m_DCode; m_DCode = aSource.m_DCode;
m_PolyCorners = aSource.m_PolyCorners; m_PolyCorners = aSource.m_PolyCorners;
m_UnitsMetric = aSource.m_UnitsMetric; m_UnitsMetric = aSource.m_UnitsMetric;
m_ImageNegative = aSource.m_ImageNegative;
m_LayerNegative = aSource.m_LayerNegative;
} }
...@@ -183,7 +188,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, ...@@ -183,7 +188,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
/*********************************************************************/ /*********************************************************************/
{ {
static D_CODE dummyD_CODE( 0 ); // used when a D_CODE is not found. default D_CODE to draw a flashed item static D_CODE dummyD_CODE( 0 ); // used when a D_CODE is not found. default D_CODE to draw a flashed item
int color; int color, alt_color;
bool isFilled; bool isFilled;
int radius; int radius;
int halfPenWidth; int halfPenWidth;
...@@ -194,12 +199,6 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, ...@@ -194,12 +199,6 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
if( d_codeDescr == NULL ) if( d_codeDescr == NULL )
d_codeDescr = &dummyD_CODE; d_codeDescr = &dummyD_CODE;
if( m_Flags & DRAW_ERASED ) // draw in background color ("negative" color)
{
color = g_DrawBgColor;
}
else
{
if( brd->IsLayerVisible( GetLayer() ) == false ) if( brd->IsLayerVisible( GetLayer() ) == false )
return; return;
...@@ -214,6 +213,12 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, ...@@ -214,6 +213,12 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
} }
if( color & HIGHT_LIGHT_FLAG ) if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor; color = ColorRefs[color & MASKCOLOR].m_LightColor;
alt_color = g_DrawBgColor ;
if( m_Flags & DRAW_ERASED ) // draw in background color ("negative" color)
{
EXCHG(color, alt_color);
} }
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
...@@ -272,7 +277,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, ...@@ -272,7 +277,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
case GBR_SPOT_POLY: case GBR_SPOT_POLY:
case GBR_SPOT_MACRO: case GBR_SPOT_MACRO:
isFilled = DisplayOpt.DisplayPadFill ? true : false; isFilled = DisplayOpt.DisplayPadFill ? true : false;
d_codeDescr->DrawFlashedShape( this, &aPanel->m_ClipBox, aDC, color, d_codeDescr->DrawFlashedShape( this, &aPanel->m_ClipBox, aDC, color, alt_color,
m_Start, isFilled ); m_Start, isFilled );
break; break;
......
...@@ -74,6 +74,8 @@ public: ...@@ -74,6 +74,8 @@ public:
// 0 for items that do not use DCodes (polygons) // 0 for items that do not use DCodes (polygons)
// or when unknown and normal values are 10 to 999 // or when unknown and normal values are 10 to 999
// values 0 to 9 can be used for special purposes // values 0 to 9 can be used for special purposes
bool m_ImageNegative; // true = item in negative image
bool m_LayerNegative; // TRUE = item in negative Layer
public: public:
GERBER_DRAW_ITEM( BOARD_ITEM* aParent ); GERBER_DRAW_ITEM( BOARD_ITEM* aParent );
......
...@@ -293,7 +293,7 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems() ...@@ -293,7 +293,7 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
* When an item is flashed, the DCode shape is the shape of the item * When an item is flashed, the DCode shape is the shape of the item
*/ */
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
EDA_Rect* aClipBox, wxDC* aDC, int aColor, EDA_Rect* aClipBox, wxDC* aDC, int aColor, int aAltColor,
wxPoint aShapePos, bool aFilledShape ) wxPoint aShapePos, bool aFilledShape )
{ {
int radius; int radius;
...@@ -301,7 +301,8 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, ...@@ -301,7 +301,8 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
switch( m_Shape ) switch( m_Shape )
{ {
case APT_MACRO: case APT_MACRO:
GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor, aShapePos, aFilledShape); GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor, aAltColor,
aShapePos, aFilledShape);
break; break;
case APT_CIRCLE: case APT_CIRCLE:
......
...@@ -193,9 +193,15 @@ public: ...@@ -193,9 +193,15 @@ public:
/** function DrawFlashedShape /** function DrawFlashedShape
* Draw the dcode shape for flashed items. * Draw the dcode shape for flashed items.
* When an item is flashed, the DCode shape is the shape of the item * When an item is flashed, the DCode shape is the shape of the item
* @param aClipBox = DC clip box (NULL is no clip)
* @param aDC = device context
* @param aColor = the normal color to use
* @param aAltColor = the color used to draw with "reverse" exposure mode (used in aperture macros only)
* @param aFilled = true to draw in filled mode, false to draw in skecth mode
* @param aPosition = the actual shape position
*/ */
void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, void DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
EDA_Rect* aClipBox, wxDC* aDC, int aColor, EDA_Rect* aClipBox, wxDC* aDC, int aColor, int aAltColor,
wxPoint aShapePos, bool aFilledShape ); wxPoint aShapePos, bool aFilledShape );
/** function DrawFlashedPolygon /** function DrawFlashedPolygon
...@@ -203,6 +209,11 @@ public: ...@@ -203,6 +209,11 @@ public:
* Draw some Apertures shapes when they are defined as filled polygons. * Draw some Apertures shapes when they are defined as filled polygons.
* APT_POLYGON is always a polygon, but some complex shapes are also converted to * APT_POLYGON is always a polygon, but some complex shapes are also converted to
* polygons (shapes with holes, some rotated shapes) * polygons (shapes with holes, some rotated shapes)
* @param aClipBox = DC clip box (NULL is no clip)
* @param aDC = device context
* @param aColor = the normal color to use
* @param aFilled = true to draw in filled mode, false to draw in skecth mode
* @param aPosition = the actual shape position
*/ */
void DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC, int aColor, void DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
bool aFilled, const wxPoint& aPosition ); bool aFilled, const wxPoint& aPosition );
......
G04 Verification of all aperture macros *
G04 Handcoded by Stefan Petersen *
%MOIN*%
%FSLAX23Y23*%
%OFA0.0000B0.0000*%
G90*
%AMCIRCLE*
1,1,0.5,0,0*
%
%AMVECTOR*
2,1,0.3,0,0,1,1,-15*
%
%AMLINE*
21,1,0.3,0.05,0,0,-135*
%
%AMLINE2*
22,1,0.8,0.5,0,0,-45*
%
%AMOUTLINE*
4,1,3,0.0,0.0,0.0,0.5,0.5,0.5,0.5,0.0,-25*
%
%AMPOLYGON*
5,1,5,0,0,0.5,25*
%
%AMMOIRE*
6,0,0,1.0,0.1,0.4,2,0.01,1,20*
%
%AMTHERMAL*
7,0,0,1.0,0.3,0.04,-13*
%
%ADD10C,0.0650*%
%ADD11CIRCLE*%
%ADD12VECTOR*%
%ADD13LINE*%
%ADD14LINE2*%
%ADD15OUTLINE*%
%ADD16POLYGON*%
%ADD18MOIRE*%
%ADD19THERMAL*%
G04 Outline*
X0Y0D02*
G54D10*
X0Y0D01*
X10000D01*
Y10000D01*
X0D01*
Y0D01*
G04 Dots *
X2000Y5000D03*
X3000D03*
X4000D03*
X5000D03*
X6000D03*
X7000D03*
X8000D03*
X9000D03*
Y6200X9000D03*
G04 Draw circle*
G54D11*
X2000Y5000D03*
G04 Draw line vector *
G54D12*
X3000D03*
G04 Draw line center *
G54D13*
X4000D03*
G04 Draw line lower left *
G54D14*
X5000D03*
G04 Draw outline *
G54D15*
X6000D03*
G04 Draw polygon 1 *
G54D16*
X7000D03*
G04 Draw Moire *
G54D18*
X9000D03*
G04 Draw Thermal *
G54D19*
Y6200X9000D03*
M02*
This diff is collapsed.
...@@ -173,8 +173,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -173,8 +173,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT /
25.4 : PCB_INTERNAL_UNIT; 25.4 : PCB_INTERNAL_UNIT;
D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, // D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); )
command & 0xFF ); )
switch( command ) switch( command )
{ {
...@@ -663,7 +662,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -663,7 +662,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
break; break;
case AMP_POLYGON: case AMP_POLYGON:
paramCount = 4; paramCount = 6;
break; break;
case AMP_MOIRE: case AMP_MOIRE:
...@@ -703,7 +702,8 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -703,7 +702,8 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
if( i < paramCount ) // maybe some day we can throw an exception and if( i < paramCount ) // maybe some day we can throw an exception and
// track a line number // track a line number
printf( "i=%d, insufficient parameters\n", i ); printf( "read macro descr type %d: read %d parameters, insufficient parameters\n",
prim.primitive_id, i );
// there are more parameters to read if this is an AMP_OUTLINE // there are more parameters to read if this is an AMP_OUTLINE
if( prim.primitive_id == AMP_OUTLINE ) if( prim.primitive_id == AMP_OUTLINE )
......
/* Bits characterizing cell */ /* Bits characterizing cell */
#define HOLE (char)0x01 /* a conducting hole or obstacle */ #define HOLE 0x01 /* a conducting hole or obstacle */
#define CELL_is_MODULE (char)0x02 /* auto placement occupied by a module */ #define CELL_is_MODULE 0x02 /* auto placement occupied by a module */
#define CELL_is_EDGE (char)0x20 /* Area and auto-placement: limiting cell #define CELL_is_EDGE 0x20 /* Area and auto-placement: limiting cell
* contour (Board, Zone) */ * contour (Board, Zone) */
#define CELL_is_FRIEND (char)0x40 /* Area and auto-placement: cell part of the #define CELL_is_FRIEND 0x40 /* Area and auto-placement: cell part of the
* net */ * net */
#define CELL_is_ZONE (char)0x80 /* Area and auto-placement: cell available */ #define CELL_is_ZONE 0x80 /* Area and auto-placement: cell available */
/* Bit masks for presence of obstacles to autorouting */ /* Bit masks for presence of obstacles to autorouting */
#define OCCUPE 1 /* Autorouting: obstacle tracks and vias. */ #define OCCUPE 1 /* Autorouting: obstacle tracks and vias. */
......
...@@ -65,7 +65,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter, ...@@ -65,7 +65,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
Plot_Edges_Modules( plotter, m_Pcb, masque_layer, trace_mode ); Plot_Edges_Modules( plotter, m_Pcb, masque_layer, trace_mode );
/* Plot pads (creates pads outlines, for pads on silkscreen layers) */ /* Plot pads (creates pads outlines, for pads on silkscreen layers) */
bool layersmask_plotpads = masque_layer; int layersmask_plotpads = masque_layer;
// Calculate the mask layers of allowed layers for pads // Calculate the mask layers of allowed layers for pads
if( !g_pcb_plot_options.PlotPadsOnSilkLayer ) if( !g_pcb_plot_options.PlotPadsOnSilkLayer )
layersmask_plotpads &= ~(SILKSCREEN_LAYER_BACK || SILKSCREEN_LAYER_FRONT); layersmask_plotpads &= ~(SILKSCREEN_LAYER_BACK || SILKSCREEN_LAYER_FRONT);
......
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