Commit 3144853b authored by jean-pierre charras's avatar jean-pierre charras

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

finished Draw functions for aperture macros.  Now aperture macros are drawn correctly.  Known bug: aperture macros having parameters are incorrect: parameters are not read correctly. Work still in progress.
parents 98303013 bc0d79d5
......@@ -4,6 +4,14 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
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>
================================================================================
++gerbview:
......
......@@ -1163,6 +1163,9 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
if( ! ClipBox )
return true;
if( n <= 0 )
return false;
int Xmin, Xmax, Ymin, Ymax;
Xmin = Xmax = Points[0].x;
......
......@@ -15,6 +15,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
###
set(GERBVIEW_SRCS
block.cpp
class_aperture_macro.cpp
class_GERBER.cpp
class_gerber_draw_item.cpp
class_gerbview_layer_widget.cpp
......
This diff is collapsed.
/**************************/
/* class_aperture_macro.h */
/**************************/
#ifndef _APERTURE_MACRO_H_
#define _APERTURE_MACRO_H_
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2010 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <vector>
#include <set>
#include "base_struct.h"
/**
* Enum AM_PRIMITIVE_ID
* is the set of all "aperture macro primitives" (primitive numbers). See
* Table 3 in http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
* aperture macro primitives are basic shapes which can be combined to create a complex shape
* This complex shape is flashed.
*/
enum AM_PRIMITIVE_ID {
AMP_UNKNOWN = 0, // A value for uninitialized AM_PRIMITIVE.
AMP_CIRCLE = 1, // Circle. (diameter and position)
AMP_LINE2 = 2, // Line with rectangle ends. (Width, start and end pos + rotation)
AMP_LINE20 = 20, // Same as AMP_LINE2
AMP_LINE_CENTER = 21, // Rectangle. (height, width and center pos + rotation)
AMP_LINE_LOWER_LEFT = 22, // Rectangle. (height, width and left bottom corner pos + rotation)
AMP_EOF = 3, // End Of File marquer: not really a shape
AMP_OUTLINE = 4, // Free polyline (n corners + rotation)
AMP_POLYGON = 5, // Closed regular polygon(diameter, number of vertices (3 to 10), rotation)
AMP_MOIRE = 6, // A cross hair with n concentric circles + rotation
AMP_THERMAL = 7, // Thermal shape (pos, outer and inner diameter, cross hair thickness + rotation)
};
/**
* Struct AM_PRIMITIVE
* holds an aperture macro primitive as given in Table 3 of
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/
class AM_PRIMITIVE
{
public:
AM_PRIMITIVE_ID primitive_id; ///< The primitive type
DCODE_PARAMS params; ///< A sequence of parameters used by
// the primitive
public:
AM_PRIMITIVE( AM_PRIMITIVE_ID aId = AMP_UNKNOWN )
{
primitive_id = aId;
}
~AM_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() const;
/**
* 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: */
/** function DrawBasicShape
* 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,
int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape );
private:
/** function ConvertShapeToPolygon
* convert a shape to an equivalent polygon.
* Arcs and circles are approximated by segments
* Useful when a shape is not a graphic primitive (shape with hole,
* rotated shape ... ) and cannot be easily drawn.
*/
void ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent, std::vector<wxPoint>& aBuffer, bool aUnitsMetric);
};
typedef std::vector<AM_PRIMITIVE> AM_PRIMITIVES;
/**
* Struct APERTURE_MACRO
* helps support the "aperture macro" defined within standard RS274X.
*/
struct APERTURE_MACRO
{
wxString name; ///< The name of the aperture macro
AM_PRIMITIVES primitives; ///< A sequence of AM_PRIMITIVEs
/** function DrawApertureMacroShape
* Draw the primitive shape for flashed items.
* 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,
int aColor, int aAltColor, wxPoint aShapePos, bool aFilledShape );
};
/**
* Struct APERTURE_MACRO_less_than
* is used by std:set<APERTURE_MACRO> instantiation which uses
* APERTURE_MACRO.name as its key.
*/
struct APERTURE_MACRO_less_than
{
// a "less than" test on two APERTURE_MACROs (.name wxStrings)
bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2 ) const
{
return am1.name.Cmp( am2.name ) < 0; // case specific wxString compare
}
};
/**
* Type APERTURE_MACRO_SET
* is a sorted collection of APERTURE_MACROS whose key is the name field in
* the APERTURE_MACRO.
*/
typedef std::set<APERTURE_MACRO, APERTURE_MACRO_less_than> APERTURE_MACRO_SET;
typedef std::pair<APERTURE_MACRO_SET::iterator, bool> APERTURE_MACRO_SET_PAIR;
#endif // ifndef _APERTURE_MACRO_H_
......@@ -49,6 +49,9 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) :
m_Shape = GBR_SEGMENT;
m_Flashed = false;
m_DCode = 0;
m_UnitsMetric = false;
m_ImageNegative = false;
m_LayerNegative = false;
}
......@@ -70,6 +73,10 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
m_Flashed = aSource.m_Flashed;
m_DCode = aSource.m_DCode;
m_PolyCorners = aSource.m_PolyCorners;
m_UnitsMetric = aSource.m_UnitsMetric;
m_ImageNegative = aSource.m_ImageNegative;
m_LayerNegative = aSource.m_LayerNegative;
}
......@@ -176,12 +183,12 @@ bool GERBER_DRAW_ITEM::Save( FILE* aFile ) const
/*********************************************************************/
void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
const wxPoint& aOffset )
/*********************************************************************/
{
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;
int radius;
int halfPenWidth;
......@@ -192,29 +199,29 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
if( d_codeDescr == NULL )
d_codeDescr = &dummyD_CODE;
if( m_Flags & DRAW_ERASED ) // draw in background color ("negative" color)
if( brd->IsLayerVisible( GetLayer() ) == false )
return;
color = brd->GetLayerColor( GetLayer() );
if( aDrawMode & GR_SURBRILL )
{
color = g_DrawBgColor;
if( aDrawMode & GR_AND )
color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
}
else
{
if( brd->IsLayerVisible( GetLayer() ) == false )
return;
if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
color = brd->GetLayerColor( GetLayer() );
alt_color = g_DrawBgColor ;
if( draw_mode & GR_SURBRILL )
{
if( draw_mode & GR_AND )
color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
}
if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
if( m_Flags & DRAW_ERASED ) // draw in background color ("negative" color)
{
EXCHG(color, alt_color);
}
GRSetDrawMode( DC, draw_mode );
GRSetDrawMode( aDC, aDrawMode );
isFilled = DisplayOpt.DisplayPcbTrackFill ? true : false;
......@@ -224,7 +231,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
isFilled = (g_DisplayPolygonsModeSketch == false);
if( m_Flags & DRAW_ERASED )
isFilled = true;
DrawGbrPoly( &panel->m_ClipBox, DC, color, aOffset, isFilled );
DrawGbrPoly( &aPanel->m_ClipBox, aDC, color, aOffset, isFilled );
break;
case GBR_CIRCLE:
......@@ -236,14 +243,14 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
if( !isFilled )
{
// draw the border of the pen's path using two circles, each as narrow as possible
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
radius - halfPenWidth, 0, color );
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
radius + halfPenWidth, 0, color );
}
else // Filled mode
{
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
radius, m_Size.x, color );
}
break;
......@@ -251,13 +258,13 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
case GBR_ARC:
if( !isFilled )
{
GRArc1( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
m_End.x, m_End.y,
m_ArcCentre.x, m_ArcCentre.y, 0, color );
}
else
{
GRArc1( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
m_End.x, m_End.y,
m_ArcCentre.x, m_ArcCentre.y,
m_Size.x, color );
......@@ -268,17 +275,18 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
case GBR_SPOT_RECT:
case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
isFilled = DisplayOpt.DisplayPadFill ? true : false;
d_codeDescr->DrawFlashedShape( &panel->m_ClipBox, DC, color,
d_codeDescr->DrawFlashedShape( this, &aPanel->m_ClipBox, aDC, color, alt_color,
m_Start, isFilled );
break;
case GBR_SEGMENT:
if( !isFilled )
GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
GRCSegm( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Size.x, color );
else
GRFillCSegm( &panel->m_ClipBox, DC, m_Start.x,
GRFillCSegm( &aPanel->m_ClipBox, aDC, m_Start.x,
m_Start.y, m_End.x, m_End.y, m_Size.x, color );
break;
......
......@@ -30,6 +30,7 @@
*/
#include "base_struct.h"
#include "class_board_item.h"
/* Shapes id for basic shapes ( .m_Shape member ) */
enum Gbr_Basic_Shapes {
......@@ -57,6 +58,8 @@ private:
public:
bool m_UnitsMetric; /* store here the gerber units (inch/mm).
* Used only to calculate aperture macros shapes sizes */
int m_Shape; // Shape and type of this gerber item
wxPoint m_Start; // Line or arc start point or position of the shape
// for flashed items
......@@ -71,6 +74,8 @@ public:
// 0 for items that do not use DCodes (polygons)
// or when unknown and normal values are 10 to 999
// 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:
GERBER_DRAW_ITEM( BOARD_ITEM* aParent );
......
......@@ -96,10 +96,11 @@ const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
return ret;
}
/** Function Read_D_Code_File
* Can be useful only with old RS274D Gerber file format.
* Is not needed with RS274X files format.
* These files need an auxiliary DCode file description. Ther is no defined file format for this.
* These files need an auxiliary DCode file description. There is no defined file format for this.
* This function read a file format I needed a long time ago.
* reads in a dcode file assuming ALSPCB file format with ';' indicating comments.
* Format is like CSV but with optional ';' delineated comments:
......@@ -165,7 +166,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
if( ii >= 6 ) /* valeurs en mils */
{
sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii,
&dimH, &dimV, &drill, &dummy, &dummy, &type_outil );
&dimH, &dimV, &drill, &dummy, &dummy, &type_outil );
dimH = wxRound( dimH * dcode_scale );
dimV = wxRound( dimV * dcode_scale );
......@@ -279,7 +280,7 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
break;
default:
wxMessageBox( wxT("WinEDA_GerberFrame::CopyDCodesSizeToItems() error" ) );
wxMessageBox( wxT( "WinEDA_GerberFrame::CopyDCodesSizeToItems() error" ) );
break;
}
}
......@@ -291,15 +292,19 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
* Draw the dcode shape for flashed items.
* When an item is flashed, the DCode shape is the shape of the item
*/
void D_CODE::DrawFlashedShape( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
wxPoint aShapePos, bool aFilledShape )
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
EDA_Rect* aClipBox, wxDC* aDC, int aColor, int aAltColor,
wxPoint aShapePos, bool aFilledShape )
{
int radius;
switch( m_Shape )
{
case APT_MACRO:
GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor, aAltColor,
aShapePos, aFilledShape);
break;
case APT_MACRO: // TODO: current a round shape
case APT_CIRCLE:
radius = m_Size.x >> 1;
if( !aFilledShape )
......@@ -427,7 +432,7 @@ void D_CODE::DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC,
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
APERTURE_DEF_HOLETYPE aHoleShape,
wxSize aSize,
wxPoint aAnchorPos );
wxPoint aAnchorPos );
/** function ConvertShapeToPolygon
* convert a shape to an equivalent polygon.
......@@ -439,6 +444,7 @@ void D_CODE::ConvertShapeToPolygon()
{
wxPoint initialpos;
wxPoint currpos;;
m_PolyCorners.clear();
switch( m_Shape )
......@@ -530,6 +536,7 @@ void D_CODE::ConvertShapeToPolygon()
case APT_POLYGON:
currpos.x = m_Size.x >> 1; // first point is on X axis
initialpos = currpos;
// rs274x said: m_EdgesCount = 3 ... 12
if( m_EdgesCount < 3 )
m_EdgesCount = 3;
......@@ -541,15 +548,16 @@ void D_CODE::ConvertShapeToPolygon()
RotatePoint( &currpos, ii * 3600 / m_EdgesCount );
m_PolyCorners.push_back( currpos );
}
addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
if( m_Rotation ) // vertical oval, rotate polygon.
{
int angle = wxRound( m_Rotation*10 );
int angle = wxRound( m_Rotation * 10 );
for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
{
// Remember the Y axis is from top to bottom when draw items.
RotatePoint( &m_PolyCorners[jj], -angle );
NEGATE(m_PolyCorners[jj].y);
NEGATE( m_PolyCorners[jj].y );
}
}
break;
......@@ -561,6 +569,7 @@ void D_CODE::ConvertShapeToPolygon()
}
}
// The helper function for D_CODE::ConvertShapeToPolygon().
// Add a hole to a polygon
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
......@@ -569,6 +578,7 @@ static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
wxPoint aAnchorPos )
{
wxPoint currpos;
if( aHoleShape == APT_DEF_ROUND_HOLE ) // build a round hole
{
for( int ii = 0; ii <= SEGS_CNT; ii++ )
......@@ -579,9 +589,9 @@ static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
aBuffer.push_back( currpos );
}
aBuffer.push_back( aAnchorPos ); // link to outline
aBuffer.push_back( aAnchorPos ); // link to outline
}
if( aHoleShape == APT_DEF_RECT_HOLE ) // Create rectangular hole
if( aHoleShape == APT_DEF_RECT_HOLE ) // Create rectangular hole
{
currpos.x = aSize.x / 2;
currpos.y = aSize.y / 2;
......@@ -593,7 +603,7 @@ static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
currpos.x += aSize.x;
aBuffer.push_back( currpos );
currpos.y += aSize.y;
aBuffer.push_back( currpos ); // close hole
aBuffer.push_back( aAnchorPos ); // link to outline
aBuffer.push_back( currpos ); // close hole
aBuffer.push_back( aAnchorPos ); // link to outline
}
}
......@@ -2,6 +2,31 @@
/* dcode.h */
/**************/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2010 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _DCODE_H_
#define _DCODE_H_
......@@ -9,7 +34,7 @@
#include <set>
#include "base_struct.h"
class GERBER_DRAW_ITEM;
/**
* Enum APERTURE_T
......@@ -42,6 +67,7 @@ enum APERTURE_DEF_HOLETYPE {
#define LAST_DCODE 999
#define TOOLS_MAX_COUNT (LAST_DCODE + 1)
class APERTURE_MACRO;
class D_CODE;
......@@ -97,91 +123,8 @@ private:
// not used.
};
/**
* Enum AM_PRIMITIVE_ID
* is the set of all "aperture macro primitives" (primitive numbers). See
* Table 3 in http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
* aperture macro primitives are basic shapes which can be combined to create a complex shape
* This complex shape is flashed.
*/
enum AM_PRIMITIVE_ID {
AMP_CIRCLE = 1, // Circle. (diameter and position)
AMP_LINE2 = 2, // Line with rectangle ends. (Width, start and end pos + rotation)
AMP_LINE20 = 20, // Same as AMP_LINE2
AMP_LINE_CENTER = 21, // Rectangle. (height, width and center pos + rotation)
AMP_LINE_LOWER_LEFT = 22, // Rectangle. (height, width and lrft bottom corner pos + rotation)
AMP_EOF = 3, // End Of File marquer: not really a shape
AMP_OUTLINE = 4, // Free polyline (n corners + rotation)
AMP_POLYGON = 5, // Closed regular polygon(diameter, number of vertices (3 to 10), rotation)
AMP_MOIRE = 6, // A cross hair with n concentric circles + rotation
AMP_THERMAL = 7, // Thermal shape (pos, outer and inner dioameter, cross hair thickness + rotation)
};
typedef std::vector<DCODE_PARAM> DCODE_PARAMS;
/**
* Struct AM_PRIMITIVE
* holds an aperture macro primitive as given in Table 3 of
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/
struct AM_PRIMITIVE
{
AM_PRIMITIVE_ID primitive_id; ///< The primitive type
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() const
{
// No D_CODE* for GetValue()
wxASSERT( params.size() && params[0].IsImmediate() );
return (int) params[0].GetValue( NULL );
}
};
typedef std::vector<AM_PRIMITIVE> AM_PRIMITIVES;
/**
* Struct APERTURE_MACRO
* helps support the "aperture macro" defined within standard RS274X.
*/
struct APERTURE_MACRO
{
wxString name; ///< The name of the aperture macro
AM_PRIMITIVES primitives; ///< A sequence of AM_PRIMITIVEs
};
/**
* Struct APERTURE_MACRO_less_than
* is used by std:set<APERTURE_MACRO> instantiation which uses
* APERTURE_MACRO.name as its key.
*/
struct APERTURE_MACRO_less_than
{
// a "less than" test on two APERTURE_MACROs (.name wxStrings)
bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2 ) const
{
return am1.name.Cmp( am2.name ) < 0; // case specific wxString compare
}
};
/**
* Type APERTURE_MACRO_SET
* is a sorted collection of APERTURE_MACROS whose key is the name field in
* the APERTURE_MACRO.
*/
typedef std::set<APERTURE_MACRO, APERTURE_MACRO_less_than> APERTURE_MACRO_SET;
typedef std::pair<APERTURE_MACRO_SET::iterator, bool> APERTURE_MACRO_SET_PAIR;
/**
* Class D_CODE
......@@ -206,15 +149,15 @@ class D_CODE
*/
public:
wxSize m_Size; /* Horizontal and vertical dimensions. */
APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
int m_Num_Dcode; /* D code ( >= 10 ) */
wxSize m_Drill; /* dimension of the hole (if any) */
APERTURE_DEF_HOLETYPE m_DrillShape; /* shape of the hole (0 = no hole, round = 1, rect = 2) */
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_Defined; /* FALSE if not defined */
wxSize m_Size; /* Horizontal and vertical dimensions. */
APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
int m_Num_Dcode; /* D code ( >= 10 ) */
wxSize m_Drill; /* dimension of the hole (if any) */
APERTURE_DEF_HOLETYPE m_DrillShape; /* shape of the hole (0 = no hole, round = 1, rect = 2) */
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_Defined; /* FALSE if not defined */
wxString m_SpecialDescr;
public:
......@@ -250,16 +193,28 @@ public:
/** function DrawFlashedShape
* Draw the dcode shape for flashed items.
* 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( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
wxPoint aShapePos, bool aFilledShape );
void DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
EDA_Rect* aClipBox, wxDC* aDC, int aColor, int aAltColor,
wxPoint aShapePos, bool aFilledShape );
/** function DrawFlashedPolygon
* a helper function used id ::Draw to draw the polygon stored ion m_PolyCorners
* 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
* 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,
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*
......@@ -9,6 +9,8 @@
#include <set>
#include "dcode.h"
#include "class_gerber_draw_item.h"
#include "class_aperture_macro.h"
class WinEDA_GerberFrame;
class BOARD;
......
This diff is collapsed.
......@@ -173,8 +173,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT /
25.4 : PCB_INTERNAL_UNIT;
D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF,
command & 0xFF ); )
// D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); )
switch( command )
{
......@@ -663,7 +662,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
break;
case AMP_POLYGON:
paramCount = 4;
paramCount = 6;
break;
case AMP_MOIRE:
......@@ -703,7 +702,8 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
if( i < paramCount ) // maybe some day we can throw an exception and
// 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
if( prim.primitive_id == AMP_OUTLINE )
......
/* Bits characterizing cell */
#define HOLE (char)0x01 /* a conducting hole or obstacle */
#define CELL_is_MODULE (char)0x02 /* auto placement occupied by a module */
#define CELL_is_EDGE (char)0x20 /* Area and auto-placement: limiting cell
#define HOLE 0x01 /* a conducting hole or obstacle */
#define CELL_is_MODULE 0x02 /* auto placement occupied by a module */
#define CELL_is_EDGE 0x20 /* Area and auto-placement: limiting cell
* 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 */
#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 */
#define OCCUPE 1 /* Autorouting: obstacle tracks and vias. */
......
......@@ -65,7 +65,7 @@ void WinEDA_BasePcbFrame::Plot_Serigraphie( PLOTTER* plotter,
Plot_Edges_Modules( plotter, m_Pcb, masque_layer, trace_mode );
/* 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
if( !g_pcb_plot_options.PlotPadsOnSilkLayer )
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