Commit 9f4e57d4 authored by jean-pierre charras's avatar jean-pierre charras

Some cleanup and fixes in gerbview. Cleanup gr_basic.* and added in gr_basic.*...

Some cleanup and fixes in gerbview. Cleanup gr_basic.* and added in gr_basic.* a minor modification coming from "EEschema selection.patch".
parent 0267b059
...@@ -26,6 +26,24 @@ email address. ...@@ -26,6 +26,24 @@ email address.
One example might be: One example might be:
(inherit (footprint library_uri ftprintname)) (inherit (footprint library_uri ftprintname))
2010-oct-04 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
Initial work on new component library stucture.
* Use C++ map in component library instead of boost::ptr_vector.
* Drop Boost pointer containers for standard C++ containers.
* Moved duplicate name user interface elements from library object to
library editor.
* Added code to support direct addition and replacement of component
alias objects into libraries.
* Removed temporary strings used to add and remove alias objects.
* Libraries only store alias objects, components now accessed thru alias.
* Simplify library API for adding, removing, and replacing components.
* Updated edit component in library dialog and library editor to reflect
component library object changes.
* Fixed bug in library viewer when displaying alias name.
* Made a few header files compile stand alone per the new coding policy.
* Remove some dead code and the usual code formatting fixes.
2010-oct-03, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2010-oct-03, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
......
...@@ -58,16 +58,40 @@ int g_DrawBgColor = WHITE; ...@@ -58,16 +58,40 @@ int g_DrawBgColor = WHITE;
void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n ); void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n );
#endif #endif
static void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color ); /* These functions are used by corresponding functions
* ( GRSCircle is called by GRCircle for instance) after mapping coordinates
* from user units to screen units(pixels coordinates)
*/
static void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color );
static void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, static void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor ); int width, int Color, int BgColor );
static void GRSMixedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
static void GRSDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width,
int Color );
static void GRSDashedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2,
int y2, int width, int Color );
static void GRSLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
static void GRSMoveTo( int x, int y );
static void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color );
static void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int width, int Color );
static void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int width, int Color, int BgColor );
static void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, int Color );
static void GRSFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
/**/
extern BASE_SCREEN* ActiveScreen; extern BASE_SCREEN* ActiveScreen;
static int GRLastMoveToX, GRLastMoveToY; static int GRLastMoveToX, GRLastMoveToY;
static bool ForceBlackPen; /* if true: draws in black instead of static bool s_ForceBlackPen; /* if true: draws in black instead of
* color for printing. */ * color for printing. */
static int xcliplo = 0, static int xcliplo = 0,
ycliplo = 0, ycliplo = 0,
...@@ -83,23 +107,18 @@ static wxDC* s_DC_lastDC = NULL; ...@@ -83,23 +107,18 @@ static wxDC* s_DC_lastDC = NULL;
/* Local functions: */ /* Local functions: */
static void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, static void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1,
int x2, int y2, int Color ); int x2, int y2, int aWidth, int aColor,
static void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, wxPenStyle aStyle = wxPENSTYLE_SOLID );
int x2, int y2, int width, int Color );
/* /*
* Macro clipping the trace of a line: * Macro clipping the trace of a line:
* Line (x1, y1 x2, y2) is clipped to remain within * Line (x1, y1 x2, y2) is clipped to remain within
* (Xcliplo, ycliplo xcliphi, ycliphi) (global variables, local to this file) * (Xcliplo, ycliplo xcliphi, ycliphi) (global variables, local to this file)
* This is necessary because under WIN95 coord trace * This is necessary because under WIN95 coord trace
* (Though an int 32 bits) are truncated to 16 bits (stupid BG) * (Although an int has 32 bits) are truncated to 16 bits (stupid)
*/ */
#ifndef us static inline int USCALE( unsigned int arg, unsigned int num, unsigned int den )
#define us unsigned int
#endif
static inline int USCALE( us arg, us num, us den )
{ {
#ifndef USE_WX_ZOOM #ifndef USE_WX_ZOOM
int ii; int ii;
...@@ -543,7 +562,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style ) ...@@ -543,7 +562,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style )
if( width < 0 ) if( width < 0 )
width = 0; width = 0;
if( ForceBlackPen ) if( s_ForceBlackPen )
{ {
Color = BLACK; Color = BLACK;
} }
...@@ -574,7 +593,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style ) ...@@ -574,7 +593,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style )
void GRSetBrush( wxDC* DC, int Color, int fill ) void GRSetBrush( wxDC* DC, int Color, int fill )
{ {
if( ForceBlackPen ) if( s_ForceBlackPen )
Color = BLACK; Color = BLACK;
if( s_DC_lastbrushcolor != Color || if( s_DC_lastbrushcolor != Color ||
...@@ -604,16 +623,16 @@ void GRSetBrush( wxDC* DC, int Color, int fill ) ...@@ -604,16 +623,16 @@ void GRSetBrush( wxDC* DC, int Color, int fill )
*/ */
void GRForceBlackPen( bool flagforce ) void GRForceBlackPen( bool flagforce )
{ {
ForceBlackPen = flagforce; s_ForceBlackPen = flagforce;
} }
/** function GetGRForceBlackPenState /** function GetGRForceBlackPenState
* @return ForceBlackPen (True if a black pen was forced) * @return s_ForceBlackPen (True if a black pen was forced)
*/ */
bool GetGRForceBlackPenState( void ) bool GetGRForceBlackPenState( void )
{ {
return ForceBlackPen; return s_ForceBlackPen;
} }
...@@ -643,6 +662,12 @@ void GRSetDrawMode( wxDC* DC, int draw_mode ) ...@@ -643,6 +662,12 @@ void GRSetDrawMode( wxDC* DC, int draw_mode )
DC->SetLogicalFunction( wxCOPY ); DC->SetLogicalFunction( wxCOPY );
#else #else
DC->SetLogicalFunction( wxEQUIV ); DC->SetLogicalFunction( wxEQUIV );
#endif
else if( draw_mode & GR_INVERT )
#if defined( USE_WX_GRAPHICS_CONTEXT )
DC->SetLogicalFunction( wxCOPY );
#else
DC->SetLogicalFunction( wxINVERT );
#endif #endif
else else
DC->SetLogicalFunction( wxCOPY ); DC->SetLogicalFunction( wxCOPY );
...@@ -837,21 +862,6 @@ void GRSMoveTo( int x, int y ) ...@@ -837,21 +862,6 @@ void GRSMoveTo( int x, int y )
} }
/*
* Draw line to a new position, in screen (pixels) space.
*/
void GRSLineTo( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int width,
int Color )
{
GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
GRLastMoveToX = x;
GRLastMoveToY = y;
}
/* /*
* Draw line to a new position, in screen (pixels) space. * Draw line to a new position, in screen (pixels) space.
...@@ -908,44 +918,6 @@ void GRLineRel( EDA_Rect* ClipBox, ...@@ -908,44 +918,6 @@ void GRLineRel( EDA_Rect* ClipBox,
} }
/*
* Move to a new position relative to current one, in screen space
* (pixel coords.).
*/
void GRSMoveRel( int x, int y )
{
GRLastMoveToX += x;
GRLastMoveToY += y;
}
/*
* Draw line to a new position relative to current one, in screen space
* (pixel coords.).
*/
void GRSLineRel( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int width,
int Color )
{
long GRLineToX = GRLastMoveToX + x,
GRLineToY = GRLastMoveToY + y;
GRSLine( ClipBox,
DC,
GRLastMoveToX,
GRLastMoveToY,
GRLineToX,
GRLineToY,
width,
Color );
GRLastMoveToX = GRLineToX;
GRLastMoveToY = GRLineToY;
}
/* /*
* Draw segment with rounded ends in object space. * Draw segment with rounded ends in object space.
*/ */
...@@ -1689,28 +1661,28 @@ void GRArc( EDA_Rect* ClipBox, ...@@ -1689,28 +1661,28 @@ void GRArc( EDA_Rect* ClipBox,
/* /*
* Draw a rectangle in drawing space. * Draw a rectangle in drawing space.
*/ */
void GRRect( EDA_Rect* ClipBox, wxDC* DC, void GRRect( EDA_Rect* aClipBox, wxDC* aDC,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
int Color ) int aColor )
{ {
x1 = GRMapX( x1 ); x1 = GRMapX( x1 );
y1 = GRMapY( y1 ); y1 = GRMapY( y1 );
x2 = GRMapX( x2 ); x2 = GRMapX( x2 );
y2 = GRMapY( y2 ); y2 = GRMapY( y2 );
GRSRect( ClipBox, DC, x1, y1, x2, y2, Color ); GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
} }
void GRRect( EDA_Rect* aClipBox, wxDC* aDC, void GRRect( EDA_Rect* aClipBox, wxDC* aDC,
const EDA_Rect& aRect, const EDA_Rect& aRect,
int aColor ) int aColor, wxPenStyle aStyle )
{ {
int x1 = GRMapX( aRect.GetX() ); int x1 = GRMapX( aRect.GetX() );
int y1 = GRMapY( aRect.GetY() ); int y1 = GRMapY( aRect.GetY() );
int x2 = GRMapX( aRect.GetRight() ); int x2 = GRMapX( aRect.GetRight() );
int y2 = GRMapY( aRect.GetBottom() ); int y2 = GRMapY( aRect.GetBottom() );
GRSRect( aClipBox, aDC, x1, y1, x2, y2, aColor ); GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor, aStyle );
} }
...@@ -1779,32 +1751,21 @@ void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -1779,32 +1751,21 @@ void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
/* /*
* Draw a rectangle in screen space. * Draw a rectangle in screen space.
*/ */
void GRSRect( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int Color )
{
GRSRect( ClipBox, DC, x1, y1, x2, y2, 0, Color );
}
void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
int width, int Color ) int aWidth, int aColor, wxPenStyle aStyle )
{ {
if( x1 > x2 ) if( x1 > x2 )
EXCHG( x1, x2 ); EXCHG( x1, x2 );
if( y1 > y2 ) if( y1 > y2 )
EXCHG( y1, y2 ); EXCHG( y1, y2 );
if( ClipBox ) if( aClipBox )
{ {
int xmin = ClipBox->GetX(); int xmin = aClipBox->GetX();
int ymin = ClipBox->GetY(); int ymin = aClipBox->GetY();
int xmax = ClipBox->GetRight(); int xmax = aClipBox->GetRight();
int ymax = ClipBox->GetBottom(); int ymax = aClipBox->GetBottom();
if( x1 > xmax ) if( x1 > xmax )
return; return;
...@@ -1816,13 +1777,13 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -1816,13 +1777,13 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
return; return;
} }
GRSetColorPen( DC, Color, width ); GRSetColorPen( aDC, aColor, aWidth, aStyle );
if( ( x1 == x2 ) || ( y1 == y2 ) ) if( ( x1 == x2 ) || ( y1 == y2 ) )
DC->DrawLine( x1, y1, x2, y2 ); aDC->DrawLine( x1, y1, x2, y2 );
else else
{ {
GRSetBrush( DC, BLACK ); GRSetBrush( aDC, BLACK );
DC->DrawRectangle( x1, y1, x2 - x1, y2 - y1 ); aDC->DrawRectangle( x1, y1, x2 - x1, y2 - y1 );
} }
} }
......
...@@ -53,8 +53,9 @@ ...@@ -53,8 +53,9 @@
*/ */
GERBER::GERBER( int aLayer ) GERBER::GERBER( WinEDA_GerberFrame * aParent, int aLayer )
{ {
m_Parent = aParent;
m_Layer = aLayer; // Layer Number m_Layer = aLayer; // Layer Number
m_Selected_Tool = FIRST_DCODE; m_Selected_Tool = FIRST_DCODE;
...@@ -130,8 +131,6 @@ void GERBER::ResetDefaultValues() ...@@ -130,8 +131,6 @@ void GERBER::ResetDefaultValues()
// DCode-> // DCode->
// separate DCode file // separate DCode file
m_Offset.x = m_Offset.y = 0; // Coord Offset
m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10; 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); m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10);
...@@ -153,8 +152,6 @@ void GERBER::ResetDefaultValues() ...@@ -153,8 +152,6 @@ void GERBER::ResetDefaultValues()
// plot arcs & circles // plot arcs & circles
m_Current_File = NULL; // File to read m_Current_File = NULL; // File to read
m_FilesPtr = 0; 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; m_PolygonFillMode = FALSE;
m_PolygonFillModeState = 0; m_PolygonFillModeState = 0;
} }
...@@ -187,4 +184,22 @@ void GERBER::InitToolTable() ...@@ -187,4 +184,22 @@ void GERBER::InitToolTable()
} }
} }
/** function ReportMessage
* Add a message (a string) in message list
* for instance when reading a Gerber file
* @param aMessage = the straing to add in list
*/
void GERBER::ReportMessage(const wxString aMessage )
{
m_Parent->ReportMessage( aMessage );
}
/** function ClearMessageList
* Clear the message list
* Call it before reading a Gerber file
*/
void GERBER::ClearMessageList( )
{
m_Parent->ClearMessageList( );
}
...@@ -149,7 +149,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ...@@ -149,7 +149,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric ); curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric );
int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2; int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2;
if( !aFilledShape ) if( !aFilledShape )
GRCircle( aClipBox, aDC, curPos.x, curPos.y, radius, aColor ); GRCircle( aClipBox, aDC, curPos, radius, 0, aColor );
else else
GRFilledCircle( aClipBox, aDC, curPos, radius, aColor ); GRFilledCircle( aClipBox, aDC, curPos, radius, aColor );
} }
...@@ -242,12 +242,6 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ...@@ -242,12 +242,6 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
* type is not stored in parameters list, so the first parameter is center.x * type is not stored in parameters list, so the first parameter is center.x
*/ */
curPos += mapPt( params[0].GetValue( tool ), params[1].GetValue( tool ), gerberMetric ); curPos += mapPt( params[0].GetValue( tool ), params[1].GetValue( tool ), gerberMetric );
/* int outerRadius = scale( params[2].GetValue( tool ), gerberMetric ) / 2;
if( !aFilledShape )
GRCircle( aClipBox, aDC, curPos.x, curPos.y, outerRadius, aColor );
else
GRFilledCircle( aClipBox, aDC, curPos, outerRadius, aColor );
*/
ConvertShapeToPolygon( aParent, polybuffer, gerberMetric ); ConvertShapeToPolygon( aParent, polybuffer, gerberMetric );
// shape rotation: // shape rotation:
...@@ -298,13 +292,12 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ...@@ -298,13 +292,12 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
if( !aFilledShape ) if( !aFilledShape )
{ {
// draw the border of the pen's path using two circles, each as narrow as possible // draw the border of the pen's path using two circles, each as narrow as possible
GRCircle( aClipBox, aDC, curPos.x, curPos.y, outerDiam / 2, 0, aColor ); GRCircle( aClipBox, aDC, curPos, outerDiam / 2, 0, aColor );
GRCircle( aClipBox, aDC, curPos.x, curPos.y, GRCircle( aClipBox, aDC, curPos, outerDiam / 2 - penThickness, 0, aColor );
outerDiam / 2 - penThickness, 0, aColor );
} }
else // Filled mode else // Filled mode
{ {
GRCircle( aClipBox, aDC, curPos.x, curPos.y, GRCircle( aClipBox, aDC, curPos,
(outerDiam - penThickness) / 2, penThickness, aColor ); (outerDiam - penThickness) / 2, penThickness, aColor );
} }
} }
......
...@@ -243,15 +243,12 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, ...@@ -243,15 +243,12 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
if( !isFilled ) if( !isFilled )
{ {
// draw the border of the pen's path using two circles, each as narrow as possible // draw the border of the pen's path using two circles, each as narrow as possible
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y, GRCircle( &aPanel->m_ClipBox, aDC, m_Start, radius - halfPenWidth, 0, color );
radius - halfPenWidth, 0, color ); GRCircle( &aPanel->m_ClipBox, aDC, m_Start, radius + halfPenWidth, 0, color );
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
radius + halfPenWidth, 0, color );
} }
else // Filled mode else // Filled mode
{ {
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y, GRCircle( &aPanel->m_ClipBox, aDC, m_Start, radius, m_Size.x, color );
radius, m_Size.x, color );
} }
break; break;
......
...@@ -62,6 +62,7 @@ void D_CODE::Clear_D_CODE_Data() ...@@ -62,6 +62,7 @@ void D_CODE::Clear_D_CODE_Data()
m_Macro = NULL; m_Macro = NULL;
m_Rotation = 0.0; m_Rotation = 0.0;
m_EdgesCount = 0; m_EdgesCount = 0;
m_PolyCorners.clear();
} }
...@@ -122,7 +123,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName ) ...@@ -122,7 +123,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
int type_outil; int type_outil;
if( g_GERBER_List[layer] == NULL ) if( g_GERBER_List[layer] == NULL )
g_GERBER_List[layer] = new GERBER( layer ); g_GERBER_List[layer] = new GERBER( this, layer );
GERBER* gerber = g_GERBER_List[layer]; GERBER* gerber = g_GERBER_List[layer];
......
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
wxSize m_Drill; /* dimension of the hole (if any) */ 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) */ 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 */ int m_EdgesCount; /* in aperture 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;
......
...@@ -109,6 +109,7 @@ class D_CODE; ...@@ -109,6 +109,7 @@ class D_CODE;
*/ */
class GERBER class GERBER
{ {
WinEDA_GerberFrame * m_Parent; // the parent WinEDA_GerberFrame (used to display messages...)
D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer
bool m_Exposure; ///< whether an aperture macro tool is flashed on or off bool m_Exposure; ///< whether an aperture macro tool is flashed on or off
...@@ -146,7 +147,6 @@ public: ...@@ -146,7 +147,6 @@ public:
int m_Selected_Tool; // Pour editions: Tool (Dcode) selectionn� int m_Selected_Tool; // Pour editions: Tool (Dcode) selectionn�
int m_Transform[2][2]; // The rotation/mirror transformation matrix.
bool m_360Arc_enbl; // Enbl 360 deg circular interpolation bool m_360Arc_enbl; // Enbl 360 deg circular interpolation
bool m_PolygonFillMode; // Enbl polygon mode (read coord as a polygon descr) bool m_PolygonFillMode; // Enbl polygon mode (read coord as a polygon descr)
int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm
...@@ -154,12 +154,24 @@ public: ...@@ -154,12 +154,24 @@ public:
APERTURE_MACRO_SET m_aperture_macros; ///< a collection of APERTURE_MACROS, sorted by name APERTURE_MACRO_SET m_aperture_macros; ///< a collection of APERTURE_MACROS, sorted by name
public: public:
GERBER( int layer ); GERBER( WinEDA_GerberFrame * aParent, int layer );
~GERBER(); ~GERBER();
void Clear_GERBER(); void Clear_GERBER();
int ReturnUsedDcodeNumber(); int ReturnUsedDcodeNumber();
void ResetDefaultValues(); void ResetDefaultValues();
/** function ReportMessage
* Add a message (a string) in message list
* for instance when reading a Gerber file
* @param aMessage = the straing to add in list
*/
void ReportMessage(const wxString aMessage );
/** function ClearMessageList
* Clear the message list
* Call it before reading a Gerber file
*/
void ClearMessageList( );
/** /**
* Function InitToolTable * Function InitToolTable
......
...@@ -11,86 +11,8 @@ ...@@ -11,86 +11,8 @@
#include "pcbplot.h" #include "pcbplot.h"
#include "protos.h" #include "protos.h"
/* Format Gerber: NOTES:
* Functions history:
* Gn =
* G01 linear interpolation (right trace)
* G02, G20, G21 Circular interpolation, meaning trig <0
* G03, G30, G31 Circular interpolation, meaning trigo> 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 Active circular interpolation on 360 degree
* G90 mode absolute coordinates
* G91 Fashion Related Contacts
*
* X, Y coordinates
* X and Y are followed by + or - and m + n digits (not separated)
* m = integer part
* n = part after the comma
* Classic 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 999
* D_CODES:
*
* D01 ... D9 = action codes:
* D01 = activating light (lower pen) when placement
* D02 = light extinction (lift pen) when placement
* D03 = Flash
* D09 = VAPE Flash
* D51 = G54 preceded by -> Select VAPE
*
* D10 ... D999 = Identification Tool (shapes id)
*/
/* Routine to Read a file D Codes.
* Accepts standard format or ALSPCB
* A ';' starts a comment.
*
* Standard Format:
* Tool, Horiz, Vert, drill, speed, acc. Type; [dCode (comment)]
* Ex: 1, 12, 12, 0, 0, 0, 3; D10
*
* Format: ALSPCB
* Ver, Hor, Type, Tool, [Drill]
* Eg 0012, 0012, L, D10
*
* Rank the characters in buf_tmp tabular structures D_CODE.
* Returns:
* <0 if error:
* -1 = File not found
* -2 = Error reading file
* Rank D_code max lu (nbr of dCode)
*/
/* Read a gerber file (RS274D gold RS274X format). /* Read a gerber file, RS274D or RS274X format.
* Normal size:
* Imperial
* Absolute
* End of block = *
* CrLf after each command
* G codes BROKE
*/ */
bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName ) const wxString& D_Code_FullFileName )
...@@ -111,10 +33,11 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName, ...@@ -111,10 +33,11 @@ bool WinEDA_GerberFrame::Read_GERBER_File( const wxString& GERBER_FullFileName,
if( g_GERBER_List[layer] == NULL ) if( g_GERBER_List[layer] == NULL )
{ {
g_GERBER_List[layer] = new GERBER( layer ); g_GERBER_List[layer] = new GERBER( this, layer );
} }
gerber = g_GERBER_List[layer]; gerber = g_GERBER_List[layer];
ClearMessageList( );
/* Set the gerber scale: */ /* Set the gerber scale: */
gerber->ResetDefaultValues(); gerber->ResetDefaultValues();
......
...@@ -36,8 +36,12 @@ ...@@ -36,8 +36,12 @@
* G70 Select Units = Inches * G70 Select Units = Inches
* G71 Select Units = Millimeters * G71 Select Units = Millimeters
* G74 disable 360 degrees circular interpolation (return to 90 deg mode) * G74 disable 360 degrees circular interpolation (return to 90 deg mode)
* and circular interpolation (return t linear) * and perhaps circular interpolation (return to linear interpolation )
* G75 enable 360 degrees circular interpolation * see rs274xrevd_e.pdf pages 47 and 48
* Unfortunately page 47 said G74 disable G02 or G03
* and page 48 said G01 must be used to disable G02 or G03.
* Currently Gerbview disable G02 or G03 after a G74 command (tests using 2 gerber files).
* G75 enable 360 degrees circular interpolation
* G90 mode absolute coordinates * G90 mode absolute coordinates
* *
* X, Y * X, Y
...@@ -973,7 +977,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int ...@@ -973,7 +977,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int
default: default:
msg.Printf( wxT( "Execute_DCODE_Command: interpol error (type %X)" ), msg.Printf( wxT( "Execute_DCODE_Command: interpol error (type %X)" ),
m_Iterpolation ); m_Iterpolation );
DisplayError( frame, msg ); ReportMessage( msg );
break; break;
} }
......
...@@ -295,10 +295,11 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -295,10 +295,11 @@ bool GERBER::ExecuteRS274XCommand( int command,
case KNOCKOUT: case KNOCKOUT:
case STEP_AND_REPEAT: case STEP_AND_REPEAT:
case ROTATE: case ROTATE:
{
msg.Printf( _( "Command <%c%c> ignored by Gerbview" ), msg.Printf( _( "Command <%c%c> ignored by Gerbview" ),
(command >> 8) & 0xFF, command & 0xFF ); (command >> 8) & 0xFF, command & 0xFF );
if( g_DebugLevel > 0 ) ReportMessage( msg );
wxMessageBox( msg ); }
break; break;
case IMAGE_NAME: case IMAGE_NAME:
...@@ -342,7 +343,6 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -342,7 +343,6 @@ bool GERBER::ExecuteRS274XCommand( int command,
m_Current_File = fopen( line, "rt" ); m_Current_File = fopen( line, "rt" );
if( m_Current_File == 0 ) if( m_Current_File == 0 )
{ {
wxString msg;
msg.Printf( wxT( "file <%s> not found." ), line ); msg.Printf( wxT( "file <%s> not found." ), line );
DisplayError( NULL, msg, 10 ); DisplayError( NULL, msg, 10 );
ok = FALSE; ok = FALSE;
...@@ -531,9 +531,9 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -531,9 +531,9 @@ bool GERBER::ExecuteRS274XCommand( int command,
APERTURE_MACRO* pam = FindApertureMacro( am_lookup ); APERTURE_MACRO* pam = FindApertureMacro( am_lookup );
if( !pam ) if( !pam )
{ {
// @todo not found, don't know how to report an error msg.Printf( "aperture macro %s not found\n",
D( printf( "aperture macro %s not found\n", CONV_TO_UTF8( am_lookup.name ) );
CONV_TO_UTF8( am_lookup.name ) ); ) ReportMessage( msg );
ok = false; ok = false;
break; break;
} }
...@@ -603,6 +603,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -603,6 +603,7 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
char*& text, char*& text,
FILE* gerber_file ) FILE* gerber_file )
{ {
wxString msg;
APERTURE_MACRO am; APERTURE_MACRO am;
// read macro name // read macro name
...@@ -674,10 +675,9 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -674,10 +675,9 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
break; break;
default: default:
// @todo, there needs to be a way of reporting the line number // @todo, there needs to be a way of reporting the line number
// and character offset. msg.Printf( "Invalid primitive id code %d\n", prim.primitive_id );
D( printf( "Invalid primitive id code %d\n", prim.primitive_id ); ) ReportMessage( msg );
return false; return false;
} }
...@@ -700,10 +700,12 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ], ...@@ -700,10 +700,12 @@ bool GERBER::ReadApertureMacro( char buff[GERBER_BUFZ],
param.SetValue( ReadDouble( text ) ); param.SetValue( ReadDouble( text ) );
} }
if( i < paramCount ) // maybe some day we can throw an exception and if( i < paramCount )
// track a line number { // maybe some day we can throw an exception and track a line number
printf( "read macro descr type %d: read %d parameters, insufficient parameters\n", msg.Printf( "read macro descr type %d: read %d parameters, insufficient parameters\n",
prim.primitive_id, i ); prim.primitive_id, i );
ReportMessage( msg );
}
// 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 )
......
...@@ -49,6 +49,7 @@ public: ...@@ -49,6 +49,7 @@ public:
private: private:
bool m_show_layer_manager_tools; bool m_show_layer_manager_tools;
wxArrayString m_Messages; // An array sting to store warning messages when reaging a gerber file
public: public:
WinEDA_GerberFrame( wxWindow* father, const wxString& title, WinEDA_GerberFrame( wxWindow* father, const wxString& title,
...@@ -60,6 +61,24 @@ public: ...@@ -60,6 +61,24 @@ public:
void Update_config(); void Update_config();
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
/** function ReportMessage
* Add a message (a string) in message list
* for instance when reading a Gerber file
* @param aMessage = the straing to add in list
*/
void ReportMessage(const wxString aMessage )
{
m_Messages.Add( aMessage );
}
/** function ClearMessageList
* Clear the message list
* Call it before reading a Gerber file
*/
void ClearMessageList( )
{
m_Messages.Clear( );
}
/** Function IsGridVisible() , virtual /** Function IsGridVisible() , virtual
* @return true if the grid must be shown * @return true if the grid must be shown
*/ */
......
...@@ -15,6 +15,7 @@ class EDA_Rect; ...@@ -15,6 +15,7 @@ class EDA_Rect;
#define GR_XOR 0x02000000 #define GR_XOR 0x02000000
#define GR_AND 0x04000000 #define GR_AND 0x04000000
#define GR_NXOR 0x08000000 #define GR_NXOR 0x08000000
#define GR_INVERT 0x10000000
#define GR_SURBRILL 0x80000000 #define GR_SURBRILL 0x80000000
...@@ -58,8 +59,6 @@ void GRForceBlackPen( bool flagforce ); ...@@ -58,8 +59,6 @@ void GRForceBlackPen( bool flagforce );
bool GetGRForceBlackPenState( void ); bool GetGRForceBlackPenState( void );
void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int color ); void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int color );
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color, int BgColor );
void GRLine( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, void GRLine( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, int aColor ); int aWidth, int aColor );
...@@ -67,31 +66,16 @@ void GRLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, ...@@ -67,31 +66,16 @@ void GRLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2,
int y2, int width, int Color ); int y2, int width, int Color );
void GRMixedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRMixedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color ); int width, int Color );
void GRSMixedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
void GRDashedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRDashedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color ); int width, int Color );
void GRSDashedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2,
int y2, int width, int Color );
void GRDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width, void GRDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width,
int Color ); int Color );
void GRSDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width,
int Color );
void GRSLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
void GRMoveTo( int x, int y ); void GRMoveTo( int x, int y );
void GRSMoveTo( int x, int y );
void GRLineTo( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, void GRLineTo( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width,
int Color ); int Color );
void GRSLineTo( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width,
int Color );
void GRMoveRel( int x, int y ); void GRMoveRel( int x, int y );
void GRSMoveRel( int x, int y );
void GRLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, void GRLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width,
int Color ); int Color );
void GRSLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width,
int Color );
void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill, void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
int width, int Color, int BgColor ); int width, int Color, int BgColor );
...@@ -183,16 +167,10 @@ void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -183,16 +167,10 @@ void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int Color ); int xc, int yc, int Color );
void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color ); int xc, int yc, int width, int Color );
void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color );
void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int width, int Color );
void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y,
int StAngle, int EndAngle, int r, int Color, int BgColor ); int StAngle, int EndAngle, int r, int Color, int BgColor );
void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle, void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int width, int Color, int BgColor ); int EndAngle, int r, int width, int Color, int BgColor );
void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int width, int Color, int BgColor );
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color ); int width, int Color );
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
...@@ -201,10 +179,6 @@ void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, ...@@ -201,10 +179,6 @@ void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color ); int width, int Color );
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, int Color ); int width, int aPenSize, int Color );
void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, int Color );
void GRSFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
void GRSetColor( int Color ); void GRSetColor( int Color );
void GRSetDefaultPalette(); void GRSetDefaultPalette();
...@@ -221,7 +195,9 @@ void GRRect( EDA_Rect* ClipBox, wxDC* DC,const EDA_Rect& aRect, ...@@ -221,7 +195,9 @@ void GRRect( EDA_Rect* ClipBox, wxDC* DC,const EDA_Rect& aRect,
void GRRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, void GRRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color ); int x2, int y2, int width, int Color );
void GRRect( EDA_Rect* aClipBox, wxDC* aDC,const EDA_Rect& aRect, void GRRect( EDA_Rect* aClipBox, wxDC* aDC,const EDA_Rect& aRect,
int aWidth, int aColor ); int aWidth, int aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color, int BgColor );
#endif /* define GR_BASIC */ #endif /* define GR_BASIC */
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