KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rs274d.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
23
24#include <cmath>
25
27#include <gerbview.h>
28#include <gerbview_frame.h>
29#include <gerber_file_image.h>
30#include <trigo.h>
32
33
34/* Gerber: NOTES about some important commands found in RS274D and RS274X (G codes).
35 * Some are now deprecated, but deprecated commands must be known by the Gerber reader
36 * Gn =
37 * G01 linear interpolation (linear trace)
38 * G02, G20, G21 Circular interpolation, clockwise
39 * G03, G30, G31 Circular interpolation, counterclockwise
40 * G04 = comment. Since Sept 2014, file attributes and other X2 attributes can be found here
41 * if the line starts by G04 #@!
42 * G06 parabolic interpolation
43 * G07 Cubic Interpolation
44 * G10 linear interpolation (scale x10)
45 * G11 linear interpolation (0.1x range)
46 * G12 linear interpolation (0.01x scale)
47 * G36 Start polygon mode (called a region, because the "polygon" can include arcs)
48 * G37 Stop polygon mode (and close it)
49 * G54 Selection Tool (outdated)
50 * G60 linear interpolation (scale x100)
51 * G70 Select Units = Inches
52 * G71 Select Units = Millimeters
53 * G74 enable 90 deg mode for arcs (CW or CCW)
54 * G75 enable 360 degrees for arcs (CW or CCW)
55 * G90 mode absolute coordinates
56 *
57 * X, Y
58 * X and Y are followed by + or - and m + n digits (not separated)
59 * m = integer part
60 * n = part after the comma
61 *ic formats: m = 2, n = 3 (size 2.3)
62 * m = 3, n = 4 (size 3.4)
63 * eg
64 * GxxX00345Y-06123*
65 *
66 * Tools and D_CODES
67 * Tool number (identification of shapes)
68 * 10 to 999
69 * D_CODES:
70 * D01 ... D9 = command codes:
71 * D01 = activating light (pen down) when placement
72 * D02 = light extinction (pen up) when placement
73 * D03 = Flash
74 * D09 = VAPE Flash (I never see this command in Gerber file)
75 * D51 = G54 preceded by -> Select VAPE
76 *
77 * D10 ... D999 = Identification Tool: tool selection
78 */
79
80
81/* Local Functions (are lower case since they are private to this source file)
82**/
83
84
97 APERTURE_T aAperture,
98 int Dcode_index,
99 const VECTOR2I& aPos,
100 VECTOR2I aSize,
101 bool aLayerNegative )
102{
103 aGbrItem->m_Size = aSize;
104 aGbrItem->m_Start = aPos;
105 aGbrItem->m_End = aGbrItem->m_Start;
106 aGbrItem->m_DCode = Dcode_index;
107 aGbrItem->SetLayerPolarity( aLayerNegative );
108 aGbrItem->m_Flashed = true;
110
111 switch( aAperture )
112 {
113 case APT_POLYGON: // flashed regular polygon
114 aGbrItem->m_ShapeType = GBR_SPOT_POLY;
115 break;
116
117 case APT_CIRCLE:
118 aGbrItem->m_ShapeType = GBR_SPOT_CIRCLE;
119 aGbrItem->m_Size.y = aGbrItem->m_Size.x;
120 break;
121
122 case APT_OVAL:
123 aGbrItem->m_ShapeType = GBR_SPOT_OVAL;
124 break;
125
126 case APT_RECT:
127 aGbrItem->m_ShapeType = GBR_SPOT_RECT;
128 break;
129
130 case APT_MACRO:
131 aGbrItem->m_ShapeType = GBR_SPOT_MACRO;
132
133 // Cache the bounding box for aperture macros
134 aGbrItem->GetDcodeDescr()->GetMacro()->GetApertureMacroShape( aGbrItem, aPos );
135 break;
136 }
137}
138
139
151 int Dcode_index,
152 const VECTOR2I& aStart,
153 const VECTOR2I& aEnd,
154 VECTOR2I aPenSize,
155 bool aLayerNegative )
156{
157 aGbrItem->m_Flashed = false;
158
159 aGbrItem->m_Size = aPenSize;
160
161 aGbrItem->m_Start = aStart;
162 aGbrItem->m_End = aEnd;
163
164 aGbrItem->m_DCode = Dcode_index;
165 aGbrItem->SetLayerPolarity( aLayerNegative );
166
168}
169
170
199void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, const VECTOR2I& aStart,
200 const VECTOR2I& aEnd, const VECTOR2I& aRelCenter, VECTOR2I aPenSize,
201 bool aClockwise, bool aMultiquadrant, bool aLayerNegative )
202{
204
205 aGbrItem->m_ShapeType = GBR_ARC;
206 aGbrItem->m_Size = aPenSize;
207 aGbrItem->m_Flashed = false;
208
209 if( aGbrItem->m_GerberImageFile )
211
212 if( aMultiquadrant )
213 {
214 center = aStart + aRelCenter;
215 }
216 else
217 {
218 // in single quadrant mode the relative coordinate aRelCenter is always >= 0
219 // So we must recalculate the actual sign of aRelCenter.x and aRelCenter.y
220 center = aRelCenter;
221
222 // calculate arc end coordinate relative to the starting point,
223 // because center is relative to the center point
224 delta = aEnd - aStart;
225
226 // now calculate the relative to aStart center position, for a draw function
227 // that use trigonometric arc angle (or counter-clockwise)
228 /* Quadrants:
229 * Y
230 * 2 | 1
231 * -------X
232 * 3 | 4
233 * C = actual relative arc center, S = arc start (axis origin) E = relative arc end
234 */
235 if( (delta.x >= 0) && (delta.y >= 0) )
236 {
237 /* Quadrant 1 (trigo or cclockwise):
238 * C | E
239 * ---S---
240 * 3 | 4
241 */
242 center.x = -center.x;
243 }
244 else if( (delta.x >= 0) && (delta.y < 0) )
245 {
246 /* Quadrant 4 (trigo or cclockwise):
247 * 2 | C
248 * ---S---
249 * 3 | E
250 */
251 // Nothing to do
252 }
253 else if( (delta.x < 0) && (delta.y >= 0) )
254 {
255 /* Quadrant 2 (trigo or cclockwise):
256 * E | 1
257 * ---S---
258 * C | 4
259 */
260 center.x = -center.x;
261 center.y = -center.y;
262 }
263 else
264 {
265 /* Quadrant 3 (trigo or cclockwise):
266 * 2 | 1
267 * ---S---
268 * E | C
269 */
270 center.y = -center.y;
271 }
272
273 // Due to your draw arc function, we need this:
274 if( !aClockwise )
275 center = - center;
276
277 // Calculate actual arc center coordinate:
278 center += aStart;
279 }
280
281 if( aClockwise )
282 {
283 aGbrItem->m_Start = aStart;
284 aGbrItem->m_End = aEnd;
285 }
286 else
287 {
288 aGbrItem->m_Start = aEnd;
289 aGbrItem->m_End = aStart;
290 }
291
292 aGbrItem->m_ArcCentre = center;
293
294 aGbrItem->m_DCode = Dcode_index;
295 aGbrItem->SetLayerPolarity( aLayerNegative );
296}
297
298
325static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, const VECTOR2I& aStart, const VECTOR2I& aEnd,
326 const VECTOR2I& rel_center, bool aClockwise, bool aMultiquadrant,
327 bool aLayerNegative )
328{
329 /* in order to calculate arc parameters, we use fillArcGBRITEM
330 * so we muse create a dummy track and use its geometric parameters
331 */
332 static GERBER_DRAW_ITEM dummyGbrItem( nullptr );
333
334 aGbrItem->SetLayerPolarity( aLayerNegative );
335
336 fillArcGBRITEM( &dummyGbrItem, 0, aStart, aEnd, rel_center, VECTOR2I( 0, 0 ),
337 aClockwise, aMultiquadrant, aLayerNegative );
338
340
342 center = dummyGbrItem.m_ArcCentre;
343
344 // Calculate coordinates relative to arc center;
345 VECTOR2I start = dummyGbrItem.m_Start - center;
346 VECTOR2I end = dummyGbrItem.m_End - center;
347
348 /* Calculate angle arc
349 * angle is trigonometrical (counter-clockwise),
350 * and axis is the X,Y gerber coordinates
351 */
352 EDA_ANGLE start_angle( start );
353 EDA_ANGLE end_angle( end );
354
355 // dummyTrack has right geometric parameters, but
356 // fillArcGBRITEM calculates arc parameters for a draw function that expects
357 // start_angle < end_angle. So ensure this is the case here:
358 // Due to the fact atan2 returns angles between -180 to + 180 degrees,
359 // this is not always the case ( a modulo 360.0 degrees can be lost )
360 //
361 // Note also an arc with same start and end angle is a circle (360 deg arc)
362 // in gerber files
363 if( start_angle >= end_angle )
364 end_angle += ANGLE_360;
365
366 EDA_ANGLE arc_angle = start_angle - end_angle;
367
368 // Approximate arc by segments with a approximation error = err_max
369 // a max err = 5 microns looks good
370 const int approx_err_max = gerbIUScale.mmToIU( 0.005 );
371 int radius = VECTOR2I( aStart - rel_center ).EuclideanNorm();
372 int count = GetArcToSegmentCount( radius, approx_err_max, arc_angle );
373 EDA_ANGLE increment_angle = std::abs( arc_angle ) / count;
374
375 if( aGbrItem->m_ShapeAsPolygon.OutlineCount() == 0 )
376 aGbrItem->m_ShapeAsPolygon.NewOutline();
377
378 // calculate polygon corners
379 // when arc is counter-clockwise, dummyGbrItem arc goes from end to start
380 // and we must always create a polygon from start to end.
381 for( int ii = 0; ii <= count; ii++ )
382 {
383 EDA_ANGLE rot;
384 VECTOR2I end_arc = start;
385
386 if( aClockwise )
387 rot = increment_angle * ii;
388 else
389 rot = increment_angle * ( count - ii );
390
391 if( ii < count )
392 RotatePoint( end_arc, -rot );
393 else // last point
394 end_arc = aClockwise ? end : start;
395
396 aGbrItem->m_ShapeAsPolygon.Append( end_arc + center );
397 }
398}
399
400
402{
403 int retval;
404 char* endptr;
405
406 errno = 0;
407
408 retval = strtol( aText + 1, &endptr, 10 );
409
410 if( endptr == aText || errno != 0 )
411 return 0;
412
413 wxCHECK_MSG( retval < std::numeric_limits<int>::max(), 0, _( "Invalid Code Number" ) );
414
415 aText = endptr;
416
417 return static_cast<int>( retval );
418}
419
420
421bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command )
422{
423 switch( G_command )
424 {
425 case GC_PHOTO_MODE: // can starts a D03 flash command: redundant, can be safely ignored.
426 break;
427
430 break;
431
434 break;
435
438 break;
439
440 case GC_COMMENT:
441 // Skip comment, but only if the line does not start by "G04 #@! "
442 // which is a metadata, i.e. a X2 command inside the comment.
443 // this comment is called a "structured comment"
444 if( strncmp( text, " #@! ", 5 ) == 0 )
445 {
446 text += 5;
447
448 // The string starting at text is the same as the X2 attribute,
449 // but a X2 attribute ends by '%'. So we build the X2 attribute string
450 std::string x2buf;
451
452 while( *text && (*text != '*') )
453 {
454 x2buf += *text;
455 text++;
456 }
457
458 // add the end of X2 attribute string
459 x2buf += "*%";
460 x2buf += '\0';
461
462 char* cptr = (char*)x2buf.data();
463 int code_command = ReadXCommandID( cptr );
464 ExecuteRS274XCommand( code_command, nullptr, 0, cptr );
465 }
466
468
469 break;
470
471 case GC_SELECT_TOOL:
472 {
473 int D_commande = CodeNumber( text );
474
475 if( D_commande < FIRST_DCODE )
476 return false;
477
478 m_Current_Tool = D_commande;
479 D_CODE* pt_Dcode = GetDCODE( D_commande );
480
481 if( pt_Dcode )
482 pt_Dcode->m_InUse = true;
483
484 break;
485 }
486
488 m_GerbMetric = false; // false = Inches, true = metric
489 break;
490
492 m_GerbMetric = true; // false = Inches, true = metric
493 break;
494
495 case GC_TURN_OFF_360_INTERPOL: // disable Multi cadran arc and Arc interpol
496 m_360Arc_enbl = false;
497 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
498 m_AsArcG74G75Cmd = true;
499 break;
500
502 m_360Arc_enbl = true;
503 m_AsArcG74G75Cmd = true;
504 break;
505
507 m_Relative = false; // false = absolute Coord, true = relative
508 // Coord
509 break;
510
512 m_Relative = true; // false = absolute Coord, true = relative
513 // Coord
514 break;
515
517 m_PolygonFillMode = true;
518 m_Exposure = false;
519 break;
520
522 if( m_Exposure && GetLastItemInList() ) // End of polygon
523 {
525
526 if( gbritem->m_ShapeAsPolygon.VertexCount() )
527 gbritem->m_ShapeAsPolygon.Append( gbritem->m_ShapeAsPolygon.CVertex( 0 ) );
528
529 StepAndRepeatItem( *gbritem );
530 }
531
532 m_Exposure = false;
533 m_PolygonFillMode = false;
535 m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // not sure it should be done
536 break;
537
538 case GC_MOVE: // Non existent
539 default:
540 {
541 wxString msg;
542 msg.Printf( wxT( "G%0.2d command not handled" ), G_command );
543 AddMessageToList( msg );
544 return false;
545 }
546 }
547
548
549 return true;
550}
551
552
553bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
554{
555 VECTOR2I size( 15, 15 );
556
557 APERTURE_T aperture = APT_CIRCLE;
558 GERBER_DRAW_ITEM* gbritem;
559
560 int dcode = 0;
561 D_CODE* tool = nullptr;
562 wxString msg;
563
564 if( D_commande >= FIRST_DCODE ) // This is a "Set tool" command
565 {
566 // remember which tool is selected, nothing is done with it in this
567 // call
568 m_Current_Tool = D_commande;
569
570 D_CODE* pt_Dcode = GetDCODE( D_commande );
571
572 if( pt_Dcode )
573 pt_Dcode->m_InUse = true;
574 else
575 m_Has_MissingDCode = true;
576
577 return true;
578 }
579 else // D_commande = 0..9: this is a pen command (usually D1, D2 or D3)
580 {
581 m_Last_Pen_Command = D_commande;
582 }
583
584 if( m_PolygonFillMode ) // Enter a polygon description:
585 {
586 switch( D_commande )
587 {
588 case 1: // code D01 Draw line, exposure ON
589 if( !m_Exposure ) // Start a new polygon outline:
590 {
591 m_Exposure = true;
592 gbritem = new GERBER_DRAW_ITEM( this );
593 AddItemToList( gbritem );
594 gbritem->m_ShapeType = GBR_POLYGON;
595 gbritem->m_Flashed = false;
596 gbritem->m_DCode = 0; // No DCode for a Polygon (Region in Gerber dialect)
597
598
599 if( gbritem->m_GerberImageFile )
600 {
603 }
604 }
605
606 switch( m_Iterpolation )
607 {
610 // Before any arc command, a G74 or G75 command must be set.
611 // Otherwise the Gerber file is invalid
612 if( !m_AsArcG74G75Cmd )
613 {
614 AddMessageToList( _( "Invalid Gerber file: missing G74 or G75 arc command" ) );
615
616 // Disable further warning messages:
617 m_AsArcG74G75Cmd = true;
618 }
619
620 gbritem = GetLastItemInList();
621
622 fillArcPOLY( gbritem, m_PreviousPos,
624 ( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? false : true,
625 m_360Arc_enbl, GetLayerParams().m_LayerNegative );
626 break;
627
628 default:
629 gbritem = GetLastItemInList();
630
631 gbritem->m_Start = m_PreviousPos; // m_Start is used as temporary storage
632
633 if( gbritem->m_ShapeAsPolygon.OutlineCount() == 0 )
634 {
635 gbritem->m_ShapeAsPolygon.NewOutline();
636 gbritem->m_ShapeAsPolygon.Append( VECTOR2I( gbritem->m_Start ) );
637 }
638
639 gbritem->m_End = m_CurrentPos; // m_End is used as temporary storage
640 gbritem->m_ShapeAsPolygon.Append( VECTOR2I( gbritem->m_End ) );
641 break;
642 }
643
646 break;
647
648 case 2: // code D2: exposure OFF (i.e. "move to")
649 if( m_Exposure && GetLastItemInList() ) // End of polygon
650 {
651 gbritem = GetLastItemInList();
652 gbritem->m_ShapeAsPolygon.Append( gbritem->m_ShapeAsPolygon.CVertex( 0 ) );
653 StepAndRepeatItem( *gbritem );
654 }
655
656 m_Exposure = false;
659 break;
660
661 default:
662 return false;
663 }
664 }
665 else
666 {
667 switch( D_commande )
668 {
669 case 1: // code D01 Draw line, exposure ON
670 m_Exposure = true;
671
672 tool = GetDCODE( m_Current_Tool );
673
674 if( tool )
675 {
676 size = tool->m_Size;
677 dcode = tool->m_Num_Dcode;
678 aperture = tool->m_ApertType;
679 }
680
681 switch( m_Iterpolation )
682 {
684 gbritem = new GERBER_DRAW_ITEM( this );
685 AddItemToList( gbritem );
686
687 fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
688 m_CurrentPos, size, GetLayerParams().m_LayerNegative );
689 StepAndRepeatItem( *gbritem );
690 break;
691
694 gbritem = new GERBER_DRAW_ITEM( this );
695 AddItemToList( gbritem );
696
698 {
699 fillArcGBRITEM( gbritem, dcode, m_PreviousPos,
700 m_CurrentPos, m_IJPos, size,
702 false : true, m_360Arc_enbl, GetLayerParams().m_LayerNegative );
703 m_LastCoordIsIJPos = false;
704 }
705 else
706 {
707 fillLineGBRITEM( gbritem, dcode, m_PreviousPos,
708 m_CurrentPos, size, GetLayerParams().m_LayerNegative );
709 }
710
711 StepAndRepeatItem( *gbritem );
712
713 break;
714
715 default:
716 msg.Printf( wxT( "RS274D: DCODE Command: interpol error (type %X)" ),
718 AddMessageToList( msg );
719 break;
720 }
721
723 break;
724
725 case 2: // code D2: exposure OFF (i.e. "move to")
726 m_Exposure = false;
728 break;
729
730 case 3: // code D3: flash aperture
731 tool = GetDCODE( m_Current_Tool );
732
733 if( tool )
734 {
735 size = tool->m_Size;
736 dcode = tool->m_Num_Dcode;
737 aperture = tool->m_ApertType;
738 }
739
740 gbritem = new GERBER_DRAW_ITEM( this );
741 AddItemToList( gbritem );
742 fillFlashedGBRITEM( gbritem, aperture, dcode, m_CurrentPos,
743 size, GetLayerParams().m_LayerNegative );
744 StepAndRepeatItem( *gbritem );
746 break;
747
748 default:
749 return false;
750 }
751 }
752
753 return true;
754}
constexpr EDA_IU_SCALE gerbIUScale
Definition base_units.h:120
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const VECTOR2I &aShapePos)
Calculate the primitive shape for flashed items.
A gerber DCODE (also called Aperture) definition.
Definition dcode.h:76
APERTURE_MACRO * GetMacro() const
Definition dcode.h:132
int m_Num_Dcode
D code value ( >= 10 )
Definition dcode.h:200
VECTOR2I m_Size
Horizontal and vertical dimensions.
Definition dcode.h:197
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
Definition dcode.h:198
bool m_InUse
false if the aperture (previously defined) is not used to draw something
Definition dcode.h:207
void SetLayerPolarity(bool aNegative)
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
SHAPE_POLY_SET m_ShapeAsPolygon
GBR_BASIC_SHAPE_TYPE m_ShapeType
GERBER_FILE_IMAGE * m_GerberImageFile
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
bool Execute_G_Command(char *&text, int G_command)
Definition rs274d.cpp:421
int m_Last_Pen_Command
Current or last pen state (0..9, set by Dn option with n < 10.
GERBER_DRAW_ITEM * GetLastItemInList() const
static char m_LineBuffer[GERBER_BUFZ+1]
void StepAndRepeatItem(const GERBER_DRAW_ITEM &aItem)
Gerber format has a command Step an Repeat.
VECTOR2I m_PreviousPos
old current specified coord for plot
void AddMessageToList(const wxString &aMessage)
Add a message to the message list.
VECTOR2I m_IJPos
IJ coord (for arcs & circles )
bool m_Relative
false = absolute Coord, true = relative Coord.
bool Execute_DCODE_Command(char *&text, int D_command)
Definition rs274d.cpp:553
D_CODE * GetDCODE(int aDCODE) const
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
int m_PolygonFillModeState
a collection of APERTURE_MACROS, sorted by name
bool GetEndOfBlock(char *aBuff, unsigned int aBuffSize, char *&aText, FILE *aGerberFile)
Definition rs274x.cpp:928
int m_Current_Tool
Current Tool (Dcode) number selected.
void AddItemToList(GERBER_DRAW_ITEM *aItem)
Add a new GERBER_DRAW_ITEM item to the drawings list.
bool ExecuteRS274XCommand(int aCommand, char *aBuff, unsigned int aBuffSize, char *&aText)
Execute a RS274X command.
Definition rs274x.cpp:194
int ReadXCommandID(char *&text)
Read two bytes of data and assembles them into an int with the first byte in the sequence put into th...
Definition rs274x.cpp:110
bool m_GerbMetric
false = Inches, true = metric
GBR_NETLIST_METADATA m_NetAttributeDict
int m_Iterpolation
Linear, 90 arc, Circ.
VECTOR2I m_CurrentPos
current specified coord for plot
bool m_LastCoordIsIJPos
A value ( = radius in circular routing in Excellon files ).
int CodeNumber(char *&aText)
Reads the next number and returns the value.
Definition rs274d.cpp:401
GERBER_LAYER & GetLayerParams()
int VertexCount(int aOutline=-1, int aHole=-1) const
Return the number of vertices in a given outline/hole.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
int OutlineCount() const
Return the number of outlines in the set.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition vector2d.h:279
APERTURE_T
The set of all gerber aperture types allowed from ADD dcode command, like ADD11C,0....
Definition dcode.h:44
@ APT_RECT
Definition dcode.h:46
@ APT_OVAL
Definition dcode.h:47
@ APT_POLYGON
Definition dcode.h:48
@ APT_CIRCLE
Definition dcode.h:45
@ APT_MACRO
Definition dcode.h:50
#define FIRST_DCODE
Definition dcode.h:66
#define _(s)
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:417
void fillFlashedGBRITEM(GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const VECTOR2I &aPos, VECTOR2I aSize, bool aLayerNegative)
functions to read the rs274d commands from a rs274d/rs274x file
Definition rs274d.cpp:96
void fillArcGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aRelCenter, VECTOR2I aPenSize, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw an arc G code.
Definition rs274d.cpp:199
void fillLineGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, VECTOR2I aPenSize, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw a linear D code.
Definition rs274d.cpp:150
a few functions useful in geometry calculations.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
@ GBR_SPOT_OVAL
@ GBR_SPOT_POLY
@ GBR_SPOT_RECT
@ GBR_POLYGON
@ GBR_SPOT_CIRCLE
@ GBR_ARC
@ GBR_SPOT_MACRO
#define GERBER_BUFZ
@ GC_SPECIFY_MILLIMETERS
Definition gerbview.h:50
@ GC_SPECIFY_RELATIVEES_COORD
Definition gerbview.h:54
@ GC_COMMENT
Definition gerbview.h:44
@ GC_TURN_ON_360_INTERPOL
Definition gerbview.h:52
@ GC_LINEAR_INTERPOL_1X
Definition gerbview.h:41
@ GC_TURN_OFF_360_INTERPOL
Definition gerbview.h:51
@ GC_SELECT_TOOL
Definition gerbview.h:47
@ GC_TURN_OFF_POLY_FILL
Definition gerbview.h:46
@ GC_CIRCLE_POS_INTERPOL
Definition gerbview.h:43
@ GC_PHOTO_MODE
Definition gerbview.h:48
@ GC_MOVE
Definition gerbview.h:40
@ GC_SPECIFY_INCHES
Definition gerbview.h:49
@ GC_TURN_ON_POLY_FILL
Definition gerbview.h:45
@ GC_CIRCLE_NEG_INTERPOL
Definition gerbview.h:42
@ GC_SPECIFY_ABSOLUES_COORD
Definition gerbview.h:53
@ GERB_INTERPOL_ARC_NEG
Definition gerbview.h:32
@ GERB_INTERPOL_LINEAR_1X
Definition gerbview.h:31
@ GERB_INTERPOL_ARC_POS
Definition gerbview.h:33
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
void fillFlashedGBRITEM(GERBER_DRAW_ITEM *aGbrItem, APERTURE_T aAperture, int Dcode_index, const VECTOR2I &aPos, VECTOR2I aSize, bool aLayerNegative)
functions to read the rs274d commands from a rs274d/rs274x file
Definition rs274d.cpp:96
static void fillArcPOLY(GERBER_DRAW_ITEM *aGbrItem, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &rel_center, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Create an arc G code when found in polygon outlines.
Definition rs274d.cpp:325
void fillArcGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aRelCenter, VECTOR2I aPenSize, bool aClockwise, bool aMultiquadrant, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw an arc G code.
Definition rs274d.cpp:199
void fillLineGBRITEM(GERBER_DRAW_ITEM *aGbrItem, int Dcode_index, const VECTOR2I &aStart, const VECTOR2I &aEnd, VECTOR2I aPenSize, bool aLayerNegative)
Initialize a given GBRITEM so that it can draw a linear D code.
Definition rs274d.cpp:150
VECTOR2I center
int radius
VECTOR2I end
int delta
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition trigo.cpp:225
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683