KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rs274d.cpp File Reference
#include <cmath>
#include <geometry/geometry_utils.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerber_file_image.h>
#include <trigo.h>
#include <X2_gerber_attributes.h>

Go to the source code of this file.

Functions

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
 
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.
 
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.
 
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.
 

Function Documentation

◆ fillArcGBRITEM()

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.

If multiquadrant == true : arc can be 0 to 360 degrees and rel_center is the center coordinate relative to start point.

If multiquadrant == false arc can be only 0 to 90 deg, and only in the same quadrant :

  • absolute angle 0 to 90 (quadrant 1) or
  • absolute angle 90 to 180 (quadrant 2) or
  • absolute angle 180 to 270 (quadrant 3) or
  • absolute angle 270 to 0 (quadrant 4)
Parameters
aGbrItemis the GBRITEM to fill in.
Dcode_indexis the DCODE value, like D14.
aStartis the starting point.
aEndis the ending point.
aRelCenteris 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.
aClockwisetrue if arc must be created clockwise
aPenSizeThe size of the flash. Note rectangular shapes are legal.
aMultiquadrantset to true to create arcs up to 360 degrees, false when arc is inside one quadrant
aLayerNegativeset to true if the current layer is negative.

Definition at line 203 of file rs274d.cpp.

References delta, GBR_ARC, GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_NetAttributeDict, GERBER_DRAW_ITEM::m_ShapeType, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, GERBER_DRAW_ITEM::SetLayerPolarity(), GERBER_DRAW_ITEM::SetNetAttributes(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), fillArcPOLY(), and EXCELLON_IMAGE::FinishRouteCommand().

◆ fillArcPOLY()

static void fillArcPOLY ( GERBER_DRAW_ITEM aGbrItem,
const VECTOR2I aStart,
const VECTOR2I aEnd,
const VECTOR2I rel_center,
bool  aClockwise,
bool  aMultiquadrant,
bool  aLayerNegative 
)
static

Create an arc G code when found in polygon outlines.

If multiquadrant == true : arc can be 0 to 360 degrees and 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:

  • absolute angle 0 to 90 (quadrant 1) or
  • absolute angle 90 to 180 (quadrant 2) or
  • absolute angle 180 to 270 (quadrant 3) or
  • absolute angle 270 to 0 (quadrant 4)
Parameters
aGbrItemis the GBRITEM to fill in.
aStartis the starting point.
aEndis the ending point.
rel_centeris 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.
aClockwisetrue if arc must be created clockwise
aMultiquadrantset to true to create arcs up to 360 deg or false when arc is inside one quadrant
aLayerNegativeset to true if the current layer is negative

Definition at line 329 of file rs274d.cpp.

References std::abs(), ANGLE_360, SHAPE_POLY_SET::Append(), VECTOR2< T >::EuclideanNorm(), fillArcGBRITEM(), gerbIUScale, GetArcToSegmentCount(), GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_NetAttributeDict, GERBER_DRAW_ITEM::m_ShapeAsPolygon, GERBER_DRAW_ITEM::m_Start, EDA_IU_SCALE::mmToIU(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), RotatePoint(), GERBER_DRAW_ITEM::SetLayerPolarity(), and GERBER_DRAW_ITEM::SetNetAttributes().

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command().

◆ fillFlashedGBRITEM()

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

Initializes a given GBRITEM so that it can draw a circle which is filled and has no pen border.

Parameters
aGbrItemThe GBRITEM to fill in.
aAperturethe associated type of aperture.
Dcode_indexThe DCODE value, like D14.
aPosThe center point of the flash.
aSizeThe diameter of the round flash.
aLayerNegativeset to true if the current layer is negative.

Definition at line 100 of file rs274d.cpp.

References APT_CIRCLE, APT_MACRO, APT_OVAL, APT_POLYGON, APT_RECT, GBR_SPOT_CIRCLE, GBR_SPOT_MACRO, GBR_SPOT_OVAL, GBR_SPOT_POLY, GBR_SPOT_RECT, APERTURE_MACRO::GetApertureMacroShape(), GERBER_DRAW_ITEM::GetDcodeDescr(), D_CODE::GetMacro(), GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_NetAttributeDict, GERBER_DRAW_ITEM::m_ShapeType, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, GERBER_DRAW_ITEM::SetLayerPolarity(), GERBER_DRAW_ITEM::SetNetAttributes(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), and EXCELLON_IMAGE::Execute_Drill_Command().

◆ fillLineGBRITEM()

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.

Parameters
aGbrItemThe GERBER_DRAW_ITEM to fill in.
Dcode_indexThe DCODE value, like D14.
aStartThe starting point of the line.
aEndThe ending point of the line.
aPenSizeThe size of the flash. Note rectangular shapes are legal.
aLayerNegativeset to true if the current layer is negative.

Definition at line 154 of file rs274d.cpp.

References GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, GERBER_DRAW_ITEM::m_Flashed, GERBER_DRAW_ITEM::m_GerberImageFile, GERBER_FILE_IMAGE::m_NetAttributeDict, GERBER_DRAW_ITEM::m_Size, GERBER_DRAW_ITEM::m_Start, GERBER_DRAW_ITEM::SetLayerPolarity(), and GERBER_DRAW_ITEM::SetNetAttributes().

Referenced by GERBER_FILE_IMAGE::Execute_DCODE_Command(), EXCELLON_IMAGE::Execute_Drill_Command(), and EXCELLON_IMAGE::FinishRouteCommand().