2013-06-27 19:12:01 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-02-10 09:04:52 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-06-27 19:12:01 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2023-11-08 09:45:13 +00:00
|
|
|
/**
|
|
|
|
* @brief functions to read the rs274d commands from a rs274d/rs274x file
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <trigo.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gerber_file_image.h>
|
|
|
|
#include <X2_gerber_attributes.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-21 17:02:54 +00:00
|
|
|
#include <cmath>
|
2010-01-08 12:28:13 +00:00
|
|
|
|
2018-11-28 17:46:25 +00:00
|
|
|
/* Gerber: NOTES about some important commands found in RS274D and RS274X (G codes).
|
|
|
|
* Some are now deprecated, but deprecated commands must be known by the Gerber reader
|
2009-11-09 14:00:22 +00:00
|
|
|
* Gn =
|
2018-11-28 17:46:25 +00:00
|
|
|
* G01 linear interpolation (linear trace)
|
|
|
|
* G02, G20, G21 Circular interpolation, clockwise
|
|
|
|
* G03, G30, G31 Circular interpolation, counterclockwise
|
2018-05-13 16:22:09 +00:00
|
|
|
* G04 = comment. Since Sept 2014, file attributes and other X2 attributes can be found here
|
2014-11-22 11:52:57 +00:00
|
|
|
* if the line starts by G04 #@!
|
2009-11-09 14:00:22 +00:00
|
|
|
* G06 parabolic interpolation
|
|
|
|
* G07 Cubic Interpolation
|
|
|
|
* G10 linear interpolation (scale x10)
|
|
|
|
* G11 linear interpolation (0.1x range)
|
|
|
|
* G12 linear interpolation (0.01x scale)
|
2018-11-28 17:46:25 +00:00
|
|
|
* G36 Start polygon mode (called a region, because the "polygon" can include arcs)
|
2010-09-29 19:00:35 +00:00
|
|
|
* G37 Stop polygon mode (and close it)
|
2018-11-28 17:46:25 +00:00
|
|
|
* G54 Selection Tool (outdated)
|
2009-11-09 14:00:22 +00:00
|
|
|
* G60 linear interpolation (scale x100)
|
2010-09-29 19:00:35 +00:00
|
|
|
* G70 Select Units = Inches
|
|
|
|
* G71 Select Units = Millimeters
|
2018-11-28 17:46:25 +00:00
|
|
|
* G74 enable 90 deg mode for arcs (CW or CCW)
|
|
|
|
* G75 enable 360 degrees for arcs (CW or CCW)
|
2009-11-09 14:00:22 +00:00
|
|
|
* G90 mode absolute coordinates
|
2008-04-17 16:25:29 +00:00
|
|
|
*
|
2009-11-09 14:00:22 +00:00
|
|
|
* X, Y
|
|
|
|
* X and Y are followed by + or - and m + n digits (not separated)
|
|
|
|
* m = integer part
|
|
|
|
* n = part after the comma
|
2020-01-10 14:31:00 +00:00
|
|
|
*ic formats: m = 2, n = 3 (size 2.3)
|
2009-11-09 14:00:22 +00:00
|
|
|
* m = 3, n = 4 (size 3.4)
|
|
|
|
* eg
|
2010-09-29 19:00:35 +00:00
|
|
|
* GxxX00345Y-06123*
|
2008-04-17 16:25:29 +00:00
|
|
|
*
|
2009-11-09 14:00:22 +00:00
|
|
|
* Tools and D_CODES
|
|
|
|
* Tool number (identification of shapes)
|
2010-09-29 19:00:35 +00:00
|
|
|
* 10 to 999
|
2009-11-09 14:00:22 +00:00
|
|
|
* D_CODES:
|
2010-09-29 19:00:35 +00:00
|
|
|
* D01 ... D9 = command codes:
|
|
|
|
* D01 = activating light (pen down) when placement
|
|
|
|
* D02 = light extinction (pen up) when placement
|
|
|
|
* D03 = Flash
|
2021-07-16 20:13:26 +00:00
|
|
|
* D09 = VAPE Flash (I never see this command in Gerber file)
|
2010-09-29 19:00:35 +00:00
|
|
|
* D51 = G54 preceded by -> Select VAPE
|
2008-04-17 16:25:29 +00:00
|
|
|
*
|
2010-09-29 19:00:35 +00:00
|
|
|
* D10 ... D999 = Identification Tool: tool selection
|
2007-09-26 04:09:22 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-16 02:20:21 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Local Functions (are lower case since they are private to this source file)
|
2010-09-28 14:42:05 +00:00
|
|
|
**/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-11-14 07:46:43 +00:00
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
/**
|
2021-07-16 20:13:26 +00:00
|
|
|
* Initializes a given GBRITEM so that it can draw a circle which is filled and
|
2008-12-29 18:02:54 +00:00
|
|
|
* has no pen border.
|
2008-11-14 17:49:38 +00:00
|
|
|
*
|
2010-09-28 14:42:05 +00:00
|
|
|
* @param aGbrItem The GBRITEM to fill in.
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param aAperture the associated type of aperture.
|
|
|
|
* @param Dcode_index The DCODE value, like D14.
|
|
|
|
* @param aPos The center point of the flash.
|
|
|
|
* @param aSize The diameter of the round flash.
|
|
|
|
* @param aLayerNegative set to true if the current layer is negative.
|
2007-09-26 04:09:22 +00:00
|
|
|
*/
|
2011-03-16 20:51:20 +00:00
|
|
|
void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
|
2016-05-26 11:57:43 +00:00
|
|
|
APERTURE_T aAperture,
|
|
|
|
int Dcode_index,
|
2022-01-01 18:08:03 +00:00
|
|
|
const VECTOR2I& aPos,
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I aSize,
|
2016-05-26 11:57:43 +00:00
|
|
|
bool aLayerNegative )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-10-03 15:39:06 +00:00
|
|
|
aGbrItem->m_Size = aSize;
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_Start = aPos;
|
2010-10-03 15:39:06 +00:00
|
|
|
aGbrItem->m_End = aGbrItem->m_Start;
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_DCode = Dcode_index;
|
2010-10-16 14:51:22 +00:00
|
|
|
aGbrItem->SetLayerPolarity( aLayerNegative );
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_Flashed = true;
|
2016-08-16 10:56:20 +00:00
|
|
|
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
|
2016-07-27 13:27:19 +00:00
|
|
|
|
2010-10-03 15:39:06 +00:00
|
|
|
switch( aAperture )
|
2008-12-04 04:28:11 +00:00
|
|
|
{
|
2010-10-03 15:39:06 +00:00
|
|
|
case APT_POLYGON: // flashed regular polygon
|
2023-02-10 09:04:52 +00:00
|
|
|
aGbrItem->m_ShapeType = GBR_SPOT_POLY;
|
2010-10-03 15:39:06 +00:00
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-10-03 15:39:06 +00:00
|
|
|
case APT_CIRCLE:
|
2023-02-10 09:04:52 +00:00
|
|
|
aGbrItem->m_ShapeType = GBR_SPOT_CIRCLE;
|
2010-10-03 15:39:06 +00:00
|
|
|
aGbrItem->m_Size.y = aGbrItem->m_Size.x;
|
|
|
|
break;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2010-10-03 15:39:06 +00:00
|
|
|
case APT_OVAL:
|
2023-02-10 09:04:52 +00:00
|
|
|
aGbrItem->m_ShapeType = GBR_SPOT_OVAL;
|
2010-10-03 15:39:06 +00:00
|
|
|
break;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2010-10-03 15:39:06 +00:00
|
|
|
case APT_RECT:
|
2023-02-10 09:04:52 +00:00
|
|
|
aGbrItem->m_ShapeType = GBR_SPOT_RECT;
|
2010-10-03 15:39:06 +00:00
|
|
|
break;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2010-10-03 15:39:06 +00:00
|
|
|
case APT_MACRO:
|
2023-02-10 09:04:52 +00:00
|
|
|
aGbrItem->m_ShapeType = GBR_SPOT_MACRO;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
// Cache the bounding box for aperture macros
|
|
|
|
aGbrItem->GetDcodeDescr()->GetMacro()->GetApertureMacroShape( aGbrItem, aPos );
|
2010-10-03 15:39:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-14 17:49:38 +00:00
|
|
|
/**
|
2021-07-16 20:13:26 +00:00
|
|
|
* Initialize a given GBRITEM so that it can draw a linear D code.
|
2008-11-14 17:49:38 +00:00
|
|
|
*
|
2010-09-28 14:42:05 +00:00
|
|
|
* @param aGbrItem The GERBER_DRAW_ITEM to fill in.
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param Dcode_index The DCODE value, like D14.
|
|
|
|
* @param aStart The starting point of the line.
|
|
|
|
* @param aEnd The ending point of the line.
|
2010-10-25 07:43:50 +00:00
|
|
|
* @param aPenSize The size of the flash. Note rectangular shapes are legal.
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param aLayerNegative set to true if the current layer is negative.
|
2008-11-14 17:49:38 +00:00
|
|
|
*/
|
2011-03-16 20:51:20 +00:00
|
|
|
void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
|
2021-07-16 20:13:26 +00:00
|
|
|
int Dcode_index,
|
2022-01-01 18:08:03 +00:00
|
|
|
const VECTOR2I& aStart,
|
|
|
|
const VECTOR2I& aEnd,
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I aPenSize,
|
2021-07-16 20:13:26 +00:00
|
|
|
bool aLayerNegative )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_Flashed = false;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-10-25 07:43:50 +00:00
|
|
|
aGbrItem->m_Size = aPenSize;
|
2008-11-14 07:46:43 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_Start = aStart;
|
2010-10-11 20:57:25 +00:00
|
|
|
aGbrItem->m_End = aEnd;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_DCode = Dcode_index;
|
2010-10-16 14:51:22 +00:00
|
|
|
aGbrItem->SetLayerPolarity( aLayerNegative );
|
2016-07-27 13:27:19 +00:00
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2008-11-14 17:49:38 +00:00
|
|
|
/**
|
2021-07-16 20:13:26 +00:00
|
|
|
* Initialize a given GBRITEM so that it can draw an arc G code.
|
|
|
|
*
|
|
|
|
* If multiquadrant == true : arc can be 0 to 360 degrees
|
2009-11-09 14:00:22 +00:00
|
|
|
* and \a rel_center is the center coordinate relative to start point.
|
2021-07-16 20:13:26 +00:00
|
|
|
*
|
|
|
|
* If multiquadrant == false arc can be only 0 to 90 deg,
|
2008-12-29 20:05:47 +00:00
|
|
|
* and only in the same quadrant :
|
|
|
|
* <ul>
|
|
|
|
* <li> absolute angle 0 to 90 (quadrant 1) or
|
|
|
|
* <li> absolute angle 90 to 180 (quadrant 2) or
|
|
|
|
* <li> absolute angle 180 to 270 (quadrant 3) or
|
|
|
|
* <li> absolute angle 270 to 0 (quadrant 4)
|
2021-07-16 20:13:26 +00:00
|
|
|
* </ul>
|
|
|
|
*
|
2010-12-18 18:47:58 +00:00
|
|
|
* @param aGbrItem is the GBRITEM to fill in.
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param Dcode_index is the DCODE value, like D14.
|
|
|
|
* @param aStart is the starting point.
|
|
|
|
* @param aEnd is the ending point.
|
2010-12-18 18:47:58 +00:00
|
|
|
* @param aRelCenter is the center coordinate relative to start point,
|
2009-11-09 14:00:22 +00:00
|
|
|
* given in ABSOLUTE VALUE and the sign of values x et y de rel_center
|
2017-06-15 09:28:36 +00:00
|
|
|
* must be calculated from the previously given constraint: arc only in the same quadrant.
|
2010-12-18 18:47:58 +00:00
|
|
|
* @param aClockwise true if arc must be created clockwise
|
2010-10-25 07:43:50 +00:00
|
|
|
* @param aPenSize The size of the flash. Note rectangular shapes are legal.
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param aMultiquadrant set to true to create arcs up to 360 degrees,
|
2010-12-18 18:47:58 +00:00
|
|
|
* false when arc is inside one quadrant
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param aLayerNegative set to true if the current layer is negative.
|
2008-11-14 17:49:38 +00:00
|
|
|
*/
|
2022-01-01 18:08:03 +00:00
|
|
|
void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, const VECTOR2I& aStart,
|
2023-02-19 03:40:07 +00:00
|
|
|
const VECTOR2I& aEnd, const VECTOR2I& aRelCenter, VECTOR2I aPenSize,
|
2022-01-01 18:08:03 +00:00
|
|
|
bool aClockwise, bool aMultiquadrant, bool aLayerNegative )
|
2008-11-14 17:49:38 +00:00
|
|
|
{
|
2022-01-01 18:08:03 +00:00
|
|
|
VECTOR2I center, delta;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2023-02-10 09:04:52 +00:00
|
|
|
aGbrItem->m_ShapeType = GBR_ARC;
|
2010-10-25 07:43:50 +00:00
|
|
|
aGbrItem->m_Size = aPenSize;
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_Flashed = false;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2016-09-07 08:28:16 +00:00
|
|
|
if( aGbrItem->m_GerberImageFile )
|
|
|
|
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
|
2016-07-27 13:27:19 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
if( aMultiquadrant )
|
2021-07-16 20:13:26 +00:00
|
|
|
{
|
2010-10-11 20:57:25 +00:00
|
|
|
center = aStart + aRelCenter;
|
2021-07-16 20:13:26 +00:00
|
|
|
}
|
2007-09-26 04:09:22 +00:00
|
|
|
else
|
|
|
|
{
|
2010-10-11 20:57:25 +00:00
|
|
|
// in single quadrant mode the relative coordinate aRelCenter is always >= 0
|
|
|
|
// So we must recalculate the actual sign of aRelCenter.x and aRelCenter.y
|
|
|
|
center = aRelCenter;
|
|
|
|
|
2010-12-18 18:47:58 +00:00
|
|
|
// calculate arc end coordinate relative to the starting point,
|
2010-10-11 20:57:25 +00:00
|
|
|
// because center is relative to the center point
|
2010-09-28 14:42:05 +00:00
|
|
|
delta = aEnd - aStart;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
// now calculate the relative to aStart center position, for a draw function
|
|
|
|
// that use trigonometric arc angle (or counter-clockwise)
|
|
|
|
/* Quadrants:
|
|
|
|
* Y
|
|
|
|
* 2 | 1
|
|
|
|
* -------X
|
|
|
|
* 3 | 4
|
|
|
|
* C = actual relative arc center, S = arc start (axis origin) E = relative arc end
|
|
|
|
*/
|
2009-05-10 15:43:41 +00:00
|
|
|
if( (delta.x >= 0) && (delta.y >= 0) )
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
/* Quadrant 1 (trigo or cclockwise):
|
|
|
|
* C | E
|
|
|
|
* ---S---
|
|
|
|
* 3 | 4
|
|
|
|
*/
|
2015-06-26 13:41:56 +00:00
|
|
|
center.x = -center.x;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
2009-05-10 15:43:41 +00:00
|
|
|
else if( (delta.x >= 0) && (delta.y < 0) )
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
/* Quadrant 4 (trigo or cclockwise):
|
|
|
|
* 2 | C
|
|
|
|
* ---S---
|
|
|
|
* 3 | E
|
|
|
|
*/
|
|
|
|
// Nothing to do
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
2009-05-10 15:43:41 +00:00
|
|
|
else if( (delta.x < 0) && (delta.y >= 0) )
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
/* Quadrant 2 (trigo or cclockwise):
|
|
|
|
* E | 1
|
|
|
|
* ---S---
|
|
|
|
* C | 4
|
|
|
|
*/
|
2015-06-26 13:41:56 +00:00
|
|
|
center.x = -center.x;
|
|
|
|
center.y = -center.y;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
2009-05-10 15:43:41 +00:00
|
|
|
else
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
/* Quadrant 3 (trigo or cclockwise):
|
|
|
|
* 2 | 1
|
|
|
|
* ---S---
|
|
|
|
* E | C
|
|
|
|
*/
|
2015-06-26 13:41:56 +00:00
|
|
|
center.y = -center.y;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
// Due to your draw arc function, we need this:
|
|
|
|
if( !aClockwise )
|
|
|
|
center = - center;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
// Calculate actual arc center coordinate:
|
|
|
|
center += aStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aClockwise )
|
|
|
|
{
|
|
|
|
aGbrItem->m_Start = aStart;
|
|
|
|
aGbrItem->m_End = aEnd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aGbrItem->m_Start = aEnd;
|
|
|
|
aGbrItem->m_End = aStart;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
aGbrItem->m_ArcCentre = center;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
aGbrItem->m_DCode = Dcode_index;
|
2010-10-16 14:51:22 +00:00
|
|
|
aGbrItem->SetLayerPolarity( aLayerNegative );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-08 12:28:13 +00:00
|
|
|
/**
|
2021-07-16 20:13:26 +00:00
|
|
|
* Create an arc G code when found in polygon outlines.
|
|
|
|
*
|
|
|
|
* If multiquadrant == true : arc can be 0 to 360 degrees and \a rel_center is the center
|
|
|
|
* coordinate relative to start point. If not multiquadrant, the arc can be only 0 to 90 deg,
|
|
|
|
* and only in the same quadrant:
|
|
|
|
*
|
2010-01-08 12:28:13 +00:00
|
|
|
* <ul>
|
|
|
|
* <li> absolute angle 0 to 90 (quadrant 1) or
|
|
|
|
* <li> absolute angle 90 to 180 (quadrant 2) or
|
|
|
|
* <li> absolute angle 180 to 270 (quadrant 3) or
|
|
|
|
* <li> absolute angle 270 to 0 (quadrant 4)
|
2021-07-16 20:13:26 +00:00
|
|
|
* </ul>
|
|
|
|
*
|
2010-12-18 18:47:58 +00:00
|
|
|
* @param aGbrItem is the GBRITEM to fill in.
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param aStart is the starting point.
|
|
|
|
* @param aEnd is the ending point.
|
2010-01-08 12:28:13 +00:00
|
|
|
* @param rel_center is the center coordinate relative to start point,
|
|
|
|
* given in ABSOLUTE VALUE and the sign of values x et y de rel_center
|
|
|
|
* must be calculated from the previously given constraint: arc only in the
|
|
|
|
* same quadrant.
|
2010-12-18 18:47:58 +00:00
|
|
|
* @param aClockwise true if arc must be created clockwise
|
2021-07-16 20:13:26 +00:00
|
|
|
* @param aMultiquadrant set to true to create arcs up to 360 deg or
|
|
|
|
* false when arc is inside one quadrant
|
|
|
|
* @param aLayerNegative set to true if the current layer is negative
|
2007-09-26 04:09:22 +00:00
|
|
|
*/
|
2022-01-01 18:08:03 +00:00
|
|
|
static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, const VECTOR2I& aStart, const VECTOR2I& aEnd,
|
|
|
|
const VECTOR2I& rel_center, bool aClockwise, bool aMultiquadrant,
|
2022-01-18 02:14:09 +00:00
|
|
|
bool aLayerNegative )
|
2010-01-08 12:28:13 +00:00
|
|
|
{
|
2010-09-28 14:42:05 +00:00
|
|
|
/* in order to calculate arc parameters, we use fillArcGBRITEM
|
|
|
|
* so we muse create a dummy track and use its geometric parameters
|
2010-01-08 12:28:13 +00:00
|
|
|
*/
|
2021-07-16 20:13:26 +00:00
|
|
|
static GERBER_DRAW_ITEM dummyGbrItem( nullptr );
|
2010-01-08 12:28:13 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
aGbrItem->SetLayerPolarity( aLayerNegative );
|
2010-10-03 15:39:06 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
fillArcGBRITEM( &dummyGbrItem, 0, aStart, aEnd, rel_center, VECTOR2I( 0, 0 ),
|
2021-07-16 20:13:26 +00:00
|
|
|
aClockwise, aMultiquadrant, aLayerNegative );
|
2010-01-08 12:28:13 +00:00
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
|
2016-08-01 17:47:35 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I center;
|
2010-09-28 14:42:05 +00:00
|
|
|
center = dummyGbrItem.m_ArcCentre;
|
2010-01-08 12:28:13 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
// Calculate coordinates relative to arc center;
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I start = dummyGbrItem.m_Start - center;
|
|
|
|
VECTOR2I end = dummyGbrItem.m_End - center;
|
2010-01-08 12:28:13 +00:00
|
|
|
|
|
|
|
/* Calculate angle arc
|
2010-10-11 20:57:25 +00:00
|
|
|
* angle is trigonometrical (counter-clockwise),
|
|
|
|
* and axis is the X,Y gerber coordinates
|
2010-01-08 12:28:13 +00:00
|
|
|
*/
|
2022-01-18 02:14:09 +00:00
|
|
|
EDA_ANGLE start_angle( start );
|
|
|
|
EDA_ANGLE end_angle( end );
|
2010-10-11 20:57:25 +00:00
|
|
|
|
|
|
|
// dummyTrack has right geometric parameters, but
|
2010-10-12 10:28:30 +00:00
|
|
|
// fillArcGBRITEM calculates arc parameters for a draw function that expects
|
2010-10-11 20:57:25 +00:00
|
|
|
// start_angle < end_angle. So ensure this is the case here:
|
|
|
|
// Due to the fact atan2 returns angles between -180 to + 180 degrees,
|
2010-10-12 10:28:30 +00:00
|
|
|
// this is not always the case ( a modulo 360.0 degrees can be lost )
|
2022-02-10 08:56:27 +00:00
|
|
|
//
|
|
|
|
// Note also an arc with same start and end angle is a circle (360 deg arc)
|
|
|
|
// in gerber files
|
|
|
|
if( start_angle >= end_angle )
|
2022-01-18 02:14:09 +00:00
|
|
|
end_angle += ANGLE_360;
|
2010-10-11 20:57:25 +00:00
|
|
|
|
2022-01-18 02:14:09 +00:00
|
|
|
EDA_ANGLE arc_angle = start_angle - end_angle;
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
// Approximate arc by 36 segments per 360 degree
|
2022-01-18 02:14:09 +00:00
|
|
|
EDA_ANGLE increment_angle = ANGLE_360 / 36;
|
|
|
|
int count = std::abs( arc_angle.AsDegrees() / increment_angle.AsDegrees() );
|
2010-01-08 12:28:13 +00:00
|
|
|
|
2023-02-10 10:50:20 +00:00
|
|
|
if( aGbrItem->m_ShapeAsPolygon.OutlineCount() == 0 )
|
|
|
|
aGbrItem->m_ShapeAsPolygon.NewOutline();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
// calculate polygon corners
|
2010-10-12 10:28:30 +00:00
|
|
|
// when arc is counter-clockwise, dummyGbrItem arc goes from end to start
|
|
|
|
// and we must always create a polygon from start to end.
|
2010-10-11 20:57:25 +00:00
|
|
|
for( int ii = 0; ii <= count; ii++ )
|
2010-01-08 12:28:13 +00:00
|
|
|
{
|
2022-01-18 02:14:09 +00:00
|
|
|
EDA_ANGLE rot;
|
|
|
|
VECTOR2I end_arc = start;
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2010-12-18 18:47:58 +00:00
|
|
|
if( aClockwise )
|
2022-01-18 02:14:09 +00:00
|
|
|
rot = increment_angle * ii;
|
2010-01-08 12:28:13 +00:00
|
|
|
else
|
2022-01-18 02:14:09 +00:00
|
|
|
rot = increment_angle * ( count - ii );
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2010-10-11 20:57:25 +00:00
|
|
|
if( ii < count )
|
2022-01-01 06:04:08 +00:00
|
|
|
RotatePoint( end_arc, -rot );
|
2010-10-11 20:57:25 +00:00
|
|
|
else // last point
|
2010-12-18 18:47:58 +00:00
|
|
|
end_arc = aClockwise ? end : start;
|
2010-01-08 12:28:13 +00:00
|
|
|
|
2023-02-10 10:50:20 +00:00
|
|
|
aGbrItem->m_ShapeAsPolygon.Append( end_arc + center );
|
2010-01-08 12:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2022-02-01 23:49:29 +00:00
|
|
|
int GERBER_FILE_IMAGE::CodeNumber( char*& aText )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2022-02-01 23:49:29 +00:00
|
|
|
int retval;
|
|
|
|
char* endptr;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2022-02-01 23:49:29 +00:00
|
|
|
errno = 0;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2022-02-01 23:49:29 +00:00
|
|
|
retval = strtol( aText + 1, &endptr, 10 );
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2022-02-01 23:49:29 +00:00
|
|
|
if( endptr == aText || errno != 0 )
|
2007-09-26 04:09:22 +00:00
|
|
|
return 0;
|
2008-12-16 02:20:21 +00:00
|
|
|
|
2022-02-01 23:49:29 +00:00
|
|
|
wxCHECK_MSG( retval < std::numeric_limits<int>::max(), 0, _( "Invalid Code Number" ) );
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2022-02-01 23:49:29 +00:00
|
|
|
aText = endptr;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2022-02-01 23:49:29 +00:00
|
|
|
return static_cast<int>( retval );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2016-05-25 14:48:38 +00:00
|
|
|
bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-16 10:47:15 +00:00
|
|
|
switch( G_command )
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can be safely ignored.
|
2008-12-17 14:51:39 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
case GC_LINEAR_INTERPOL_1X:
|
|
|
|
m_Iterpolation = GERB_INTERPOL_LINEAR_1X;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_CIRCLE_NEG_INTERPOL:
|
|
|
|
m_Iterpolation = GERB_INTERPOL_ARC_NEG;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_CIRCLE_POS_INTERPOL:
|
|
|
|
m_Iterpolation = GERB_INTERPOL_ARC_POS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_COMMENT:
|
2018-05-13 16:22:09 +00:00
|
|
|
// Skip comment, but only if the line does not start by "G04 #@! "
|
|
|
|
// which is a metadata, i.e. a X2 command inside the comment.
|
|
|
|
// this comment is called a "structured comment"
|
|
|
|
if( strncmp( text, " #@! ", 5 ) == 0 )
|
2014-11-22 11:52:57 +00:00
|
|
|
{
|
2018-05-13 16:22:09 +00:00
|
|
|
text += 5;
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2018-05-13 16:22:09 +00:00
|
|
|
// The string starting at text is the same as the X2 attribute,
|
|
|
|
// but a X2 attribute ends by '%'. So we build the X2 attribute string
|
|
|
|
std::string x2buf;
|
|
|
|
|
|
|
|
while( *text && (*text != '*') )
|
2014-11-22 11:52:57 +00:00
|
|
|
{
|
2018-05-13 16:22:09 +00:00
|
|
|
x2buf += *text;
|
|
|
|
text++;
|
2014-11-22 11:52:57 +00:00
|
|
|
}
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2018-05-13 16:22:09 +00:00
|
|
|
// add the end of X2 attribute string
|
|
|
|
x2buf += "*%";
|
|
|
|
x2buf += '\0';
|
|
|
|
|
|
|
|
char* cptr = (char*)x2buf.data();
|
|
|
|
int code_command = ReadXCommandID( cptr );
|
2021-07-16 20:13:26 +00:00
|
|
|
ExecuteRS274XCommand( code_command, nullptr, 0, cptr );
|
2014-11-22 11:52:57 +00:00
|
|
|
}
|
|
|
|
|
2023-11-08 09:45:13 +00:00
|
|
|
GetEndOfBlock( m_LineBuffer, GERBER_BUFZ, text, m_Current_File );
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_SELECT_TOOL:
|
|
|
|
{
|
2022-02-01 23:49:29 +00:00
|
|
|
int D_commande = CodeNumber( text );
|
2019-10-31 20:03:17 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
if( D_commande < FIRST_DCODE )
|
2008-11-14 17:49:38 +00:00
|
|
|
return false;
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
if( D_commande > (TOOLS_MAX_COUNT - 1) )
|
|
|
|
D_commande = TOOLS_MAX_COUNT - 1;
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
m_Current_Tool = D_commande;
|
2017-09-17 22:43:20 +00:00
|
|
|
D_CODE* pt_Dcode = GetDCODE( D_commande );
|
2019-10-31 20:03:17 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
if( pt_Dcode )
|
2008-11-14 17:49:38 +00:00
|
|
|
pt_Dcode->m_InUse = true;
|
2019-10-31 20:03:17 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GC_SPECIFY_INCHES:
|
2008-11-14 17:49:38 +00:00
|
|
|
m_GerbMetric = false; // false = Inches, true = metric
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_SPECIFY_MILLIMETERS:
|
2008-11-14 17:49:38 +00:00
|
|
|
m_GerbMetric = true; // false = Inches, true = metric
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
2010-10-04 15:20:37 +00:00
|
|
|
case GC_TURN_OFF_360_INTERPOL: // disable Multi cadran arc and Arc interpol
|
2010-10-11 20:57:25 +00:00
|
|
|
m_360Arc_enbl = false;
|
|
|
|
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
|
2020-04-10 10:57:29 +00:00
|
|
|
m_AsArcG74G75Cmd = true;
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_TURN_ON_360_INTERPOL:
|
2008-11-14 17:49:38 +00:00
|
|
|
m_360Arc_enbl = true;
|
2020-04-10 10:57:29 +00:00
|
|
|
m_AsArcG74G75Cmd = true;
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_SPECIFY_ABSOLUES_COORD:
|
2010-01-08 12:28:13 +00:00
|
|
|
m_Relative = false; // false = absolute Coord, true = relative
|
2009-11-09 14:00:22 +00:00
|
|
|
// Coord
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_SPECIFY_RELATIVEES_COORD:
|
2010-01-08 12:28:13 +00:00
|
|
|
m_Relative = true; // false = absolute Coord, true = relative
|
2009-11-09 14:00:22 +00:00
|
|
|
// Coord
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_TURN_ON_POLY_FILL:
|
2008-11-14 17:49:38 +00:00
|
|
|
m_PolygonFillMode = true;
|
2016-02-15 13:16:49 +00:00
|
|
|
m_Exposure = false;
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GC_TURN_OFF_POLY_FILL:
|
2019-12-30 13:23:33 +00:00
|
|
|
if( m_Exposure && GetLastItemInList() ) // End of polygon
|
2010-10-15 18:59:26 +00:00
|
|
|
{
|
2019-12-30 13:23:33 +00:00
|
|
|
GERBER_DRAW_ITEM * gbritem = GetLastItemInList();
|
2020-05-06 15:50:04 +00:00
|
|
|
|
2023-02-10 10:50:20 +00:00
|
|
|
if( gbritem->m_ShapeAsPolygon.VertexCount() )
|
|
|
|
gbritem->m_ShapeAsPolygon.Append( gbritem->m_ShapeAsPolygon.CVertex( 0 ) );
|
2020-05-06 15:50:04 +00:00
|
|
|
|
2010-10-15 18:59:26 +00:00
|
|
|
StepAndRepeatItem( *gbritem );
|
|
|
|
}
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2010-10-15 18:59:26 +00:00
|
|
|
m_Exposure = false;
|
2009-04-29 17:09:00 +00:00
|
|
|
m_PolygonFillMode = false;
|
2007-09-26 04:09:22 +00:00
|
|
|
m_PolygonFillModeState = 0;
|
2018-11-28 17:46:25 +00:00
|
|
|
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
case GC_MOVE: // Non existent
|
2007-09-26 04:09:22 +00:00
|
|
|
default:
|
|
|
|
{
|
2010-10-06 17:28:07 +00:00
|
|
|
wxString msg;
|
2011-03-16 10:47:15 +00:00
|
|
|
msg.Printf( wxT( "G%0.2d command not handled" ), G_command );
|
2016-06-05 12:26:39 +00:00
|
|
|
AddMessageToList( msg );
|
2008-11-14 17:49:38 +00:00
|
|
|
return false;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-14 17:49:38 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2016-05-25 14:48:38 +00:00
|
|
|
bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I size( 15, 15 );
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
APERTURE_T aperture = APT_CIRCLE;
|
|
|
|
GERBER_DRAW_ITEM* gbritem;
|
2008-11-08 06:44:07 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
int dcode = 0;
|
2021-07-16 20:13:26 +00:00
|
|
|
D_CODE* tool = nullptr;
|
2010-09-28 14:42:05 +00:00
|
|
|
wxString msg;
|
2007-09-26 04:09:22 +00:00
|
|
|
|
|
|
|
if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command
|
|
|
|
{
|
2010-09-28 14:42:05 +00:00
|
|
|
if( D_commande > (TOOLS_MAX_COUNT - 1) )
|
|
|
|
D_commande = TOOLS_MAX_COUNT - 1;
|
2008-11-10 07:13:37 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// remember which tool is selected, nothing is done with it in this
|
|
|
|
// call
|
2007-09-26 04:09:22 +00:00
|
|
|
m_Current_Tool = D_commande;
|
2008-11-14 07:46:43 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
D_CODE* pt_Dcode = GetDCODE( D_commande );
|
2019-10-31 20:03:17 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
if( pt_Dcode )
|
2008-11-14 17:49:38 +00:00
|
|
|
pt_Dcode->m_InUse = true;
|
2019-10-31 20:03:17 +00:00
|
|
|
else
|
|
|
|
m_Has_MissingDCode = true;
|
2008-11-10 07:13:37 +00:00
|
|
|
|
2008-11-14 17:49:38 +00:00
|
|
|
return true;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
2009-11-09 14:00:22 +00:00
|
|
|
else // D_commande = 0..9: this is a pen command (usually D1, D2 or D3)
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
|
|
|
m_Last_Pen_Command = D_commande;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_PolygonFillMode ) // Enter a polygon description:
|
|
|
|
{
|
|
|
|
switch( D_commande )
|
|
|
|
{
|
2008-11-10 07:13:37 +00:00
|
|
|
case 1: // code D01 Draw line, exposure ON
|
2016-02-15 13:16:49 +00:00
|
|
|
if( !m_Exposure ) // Start a new polygon outline:
|
2010-09-28 14:42:05 +00:00
|
|
|
{
|
|
|
|
m_Exposure = true;
|
2016-05-26 11:57:43 +00:00
|
|
|
gbritem = new GERBER_DRAW_ITEM( this );
|
2019-12-30 13:23:33 +00:00
|
|
|
AddItemToList( gbritem );
|
2023-02-10 09:04:52 +00:00
|
|
|
gbritem->m_ShapeType = GBR_POLYGON;
|
2010-10-11 20:57:25 +00:00
|
|
|
gbritem->m_Flashed = false;
|
2019-10-12 11:56:59 +00:00
|
|
|
gbritem->m_DCode = 0; // No DCode for a Polygon (Region in Gerber dialect)
|
2019-10-06 15:34:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
if( gbritem->m_GerberImageFile )
|
2019-10-12 11:56:59 +00:00
|
|
|
{
|
2019-10-06 15:34:35 +00:00
|
|
|
gbritem->SetNetAttributes( gbritem->m_GerberImageFile->m_NetAttributeDict );
|
2019-10-12 11:56:59 +00:00
|
|
|
gbritem->m_AperFunction = gbritem->m_GerberImageFile->m_AperFunction;
|
|
|
|
}
|
2010-09-28 14:42:05 +00:00
|
|
|
}
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2010-01-08 12:28:13 +00:00
|
|
|
switch( m_Iterpolation )
|
2008-12-29 18:02:54 +00:00
|
|
|
{
|
2010-01-08 12:28:13 +00:00
|
|
|
case GERB_INTERPOL_ARC_NEG:
|
|
|
|
case GERB_INTERPOL_ARC_POS:
|
2020-04-10 10:57:29 +00:00
|
|
|
// Before any arc command, a G74 or G75 command must be set.
|
|
|
|
// Otherwise the Gerber file is invalid
|
|
|
|
if( !m_AsArcG74G75Cmd )
|
|
|
|
{
|
2020-04-10 11:41:33 +00:00
|
|
|
AddMessageToList( _( "Invalid Gerber file: missing G74 or G75 arc command" ) );
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2020-04-10 10:57:29 +00:00
|
|
|
// Disable further warning messages:
|
|
|
|
m_AsArcG74G75Cmd = true;
|
|
|
|
}
|
|
|
|
|
2019-12-30 13:23:33 +00:00
|
|
|
gbritem = GetLastItemInList();
|
2010-10-11 20:57:25 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
fillArcPOLY( gbritem, m_PreviousPos,
|
2010-10-11 20:57:25 +00:00
|
|
|
m_CurrentPos, m_IJPos,
|
|
|
|
( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? false : true,
|
2010-10-16 14:51:22 +00:00
|
|
|
m_360Arc_enbl, GetLayerParams().m_LayerNegative );
|
2010-01-08 12:28:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-12-30 13:23:33 +00:00
|
|
|
gbritem = GetLastItemInList();
|
2010-10-11 20:57:25 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
gbritem->m_Start = m_PreviousPos; // m_Start is used as temporary storage
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2023-02-10 10:50:20 +00:00
|
|
|
if( gbritem->m_ShapeAsPolygon.OutlineCount() == 0 )
|
2017-09-17 22:43:20 +00:00
|
|
|
{
|
2023-02-10 10:50:20 +00:00
|
|
|
gbritem->m_ShapeAsPolygon.NewOutline();
|
|
|
|
gbritem->m_ShapeAsPolygon.Append( VECTOR2I( gbritem->m_Start ) );
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
2010-01-08 12:28:13 +00:00
|
|
|
|
2010-09-28 14:42:05 +00:00
|
|
|
gbritem->m_End = m_CurrentPos; // m_End is used as temporary storage
|
2023-02-10 10:50:20 +00:00
|
|
|
gbritem->m_ShapeAsPolygon.Append( VECTOR2I( gbritem->m_End ) );
|
2010-01-08 12:28:13 +00:00
|
|
|
break;
|
2008-12-29 18:02:54 +00:00
|
|
|
}
|
2008-12-29 20:05:47 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
m_PreviousPos = m_CurrentPos;
|
|
|
|
m_PolygonFillModeState = 1;
|
|
|
|
break;
|
|
|
|
|
2008-11-10 07:13:37 +00:00
|
|
|
case 2: // code D2: exposure OFF (i.e. "move to")
|
2019-12-30 13:23:33 +00:00
|
|
|
if( m_Exposure && GetLastItemInList() ) // End of polygon
|
2010-10-15 18:59:26 +00:00
|
|
|
{
|
2019-12-30 13:23:33 +00:00
|
|
|
gbritem = GetLastItemInList();
|
2023-02-10 10:50:20 +00:00
|
|
|
gbritem->m_ShapeAsPolygon.Append( gbritem->m_ShapeAsPolygon.CVertex( 0 ) );
|
2010-10-15 18:59:26 +00:00
|
|
|
StepAndRepeatItem( *gbritem );
|
|
|
|
}
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
m_Exposure = false;
|
2007-09-26 04:09:22 +00:00
|
|
|
m_PreviousPos = m_CurrentPos;
|
|
|
|
m_PolygonFillModeState = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-11-14 17:49:38 +00:00
|
|
|
return false;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-12-16 02:20:21 +00:00
|
|
|
{
|
2007-09-26 04:09:22 +00:00
|
|
|
switch( D_commande )
|
|
|
|
{
|
2008-11-10 07:13:37 +00:00
|
|
|
case 1: // code D01 Draw line, exposure ON
|
2008-11-14 07:46:43 +00:00
|
|
|
m_Exposure = true;
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
tool = GetDCODE( m_Current_Tool );
|
2019-10-06 15:34:35 +00:00
|
|
|
|
2008-11-14 07:46:43 +00:00
|
|
|
if( tool )
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
2008-11-14 07:46:43 +00:00
|
|
|
size = tool->m_Size;
|
|
|
|
dcode = tool->m_Num_Dcode;
|
2023-02-10 10:18:09 +00:00
|
|
|
aperture = tool->m_ApertType;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch( m_Iterpolation )
|
|
|
|
{
|
|
|
|
case GERB_INTERPOL_LINEAR_1X:
|
2016-05-26 11:57:43 +00:00
|
|
|
gbritem = new GERBER_DRAW_ITEM( this );
|
2019-12-30 13:23:33 +00:00
|
|
|
AddItemToList( gbritem );
|
2010-10-11 20:57:25 +00:00
|
|
|
|
2016-05-26 11:57:43 +00:00
|
|
|
fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
|
2010-10-25 07:43:50 +00:00
|
|
|
m_CurrentPos, size, GetLayerParams().m_LayerNegative );
|
2010-10-15 18:59:26 +00:00
|
|
|
StepAndRepeatItem( *gbritem );
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GERB_INTERPOL_ARC_NEG:
|
|
|
|
case GERB_INTERPOL_ARC_POS:
|
2016-05-26 11:57:43 +00:00
|
|
|
gbritem = new GERBER_DRAW_ITEM( this );
|
2019-12-30 13:23:33 +00:00
|
|
|
AddItemToList( gbritem );
|
2016-05-26 11:57:43 +00:00
|
|
|
|
2018-11-28 17:46:25 +00:00
|
|
|
if( m_LastCoordIsIJPos )
|
|
|
|
{
|
|
|
|
fillArcGBRITEM( gbritem, dcode, m_PreviousPos,
|
|
|
|
m_CurrentPos, m_IJPos, size,
|
|
|
|
( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ?
|
|
|
|
false : true, m_360Arc_enbl, GetLayerParams().m_LayerNegative );
|
|
|
|
m_LastCoordIsIJPos = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
|
|
|
|
m_CurrentPos, size, GetLayerParams().m_LayerNegative );
|
|
|
|
}
|
|
|
|
|
2010-10-15 18:59:26 +00:00
|
|
|
StepAndRepeatItem( *gbritem );
|
2018-11-28 17:46:25 +00:00
|
|
|
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-10-05 19:54:27 +00:00
|
|
|
msg.Printf( wxT( "RS274D: DCODE Command: interpol error (type %X)" ),
|
2009-05-21 17:42:42 +00:00
|
|
|
m_Iterpolation );
|
2016-06-05 12:26:39 +00:00
|
|
|
AddMessageToList( msg );
|
2007-09-26 04:09:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_PreviousPos = m_CurrentPos;
|
|
|
|
break;
|
|
|
|
|
2008-11-10 07:13:37 +00:00
|
|
|
case 2: // code D2: exposure OFF (i.e. "move to")
|
2010-10-11 20:57:25 +00:00
|
|
|
m_Exposure = false;
|
2007-09-26 04:09:22 +00:00
|
|
|
m_PreviousPos = m_CurrentPos;
|
|
|
|
break;
|
|
|
|
|
2008-11-10 07:13:37 +00:00
|
|
|
case 3: // code D3: flash aperture
|
2017-09-17 22:43:20 +00:00
|
|
|
tool = GetDCODE( m_Current_Tool );
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2008-11-14 07:46:43 +00:00
|
|
|
if( tool )
|
2007-09-26 04:09:22 +00:00
|
|
|
{
|
2008-11-14 07:46:43 +00:00
|
|
|
size = tool->m_Size;
|
|
|
|
dcode = tool->m_Num_Dcode;
|
2023-02-10 10:18:09 +00:00
|
|
|
aperture = tool->m_ApertType;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
|
|
|
|
2016-05-26 11:57:43 +00:00
|
|
|
gbritem = new GERBER_DRAW_ITEM( this );
|
2019-12-30 13:23:33 +00:00
|
|
|
AddItemToList( gbritem );
|
2016-05-26 11:57:43 +00:00
|
|
|
fillFlashedGBRITEM( gbritem, aperture, dcode, m_CurrentPos,
|
2010-10-16 14:51:22 +00:00
|
|
|
size, GetLayerParams().m_LayerNegative );
|
2010-10-15 18:59:26 +00:00
|
|
|
StepAndRepeatItem( *gbritem );
|
2007-09-26 04:09:22 +00:00
|
|
|
m_PreviousPos = m_CurrentPos;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-11-14 17:49:38 +00:00
|
|
|
return false;
|
2007-09-26 04:09:22 +00:00
|
|
|
}
|
2008-12-16 02:20:21 +00:00
|
|
|
}
|
2007-09-26 04:09:22 +00:00
|
|
|
|
2008-11-14 17:49:38 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|