KiCad PCB EDA Suite
dcode.cpp File Reference

D_CODE class implementation. More...

#include <fctsys.h>
#include <common.h>
#include <trigo.h>
#include <gerbview_frame.h>
#include <gerber_file_image.h>
#include <convert_to_biu.h>
#include <convert_basic_shapes_to_polygon.h>

Go to the source code of this file.

Macros

#define DCODE_DEFAULT_SIZE   Millimeter2iu( 0.1 )
 
#define SEGS_CNT   64
 

Functions

static void addHoleToPolygon (SHAPE_POLY_SET *aPolygon, APERTURE_DEF_HOLETYPE aHoleShape, wxSize aSize, wxPoint aAnchorPos)
 

Detailed Description

D_CODE class implementation.

Definition in file dcode.cpp.

Macro Definition Documentation

◆ DCODE_DEFAULT_SIZE

#define DCODE_DEFAULT_SIZE   Millimeter2iu( 0.1 )

Definition at line 39 of file dcode.cpp.

◆ SEGS_CNT

#define SEGS_CNT   64

Definition at line 291 of file dcode.cpp.

Function Documentation

◆ addHoleToPolygon()

static void addHoleToPolygon ( SHAPE_POLY_SET aPolygon,
APERTURE_DEF_HOLETYPE  aHoleShape,
wxSize  aSize,
wxPoint  aAnchorPos 
)
static

Definition at line 426 of file dcode.cpp.

430 {
431  wxPoint currpos;
432  SHAPE_POLY_SET holeBuffer;
433 
434  if( aHoleShape == APT_DEF_ROUND_HOLE )
435  {
436  TransformCircleToPolygon( holeBuffer, wxPoint( 0, 0 ), aSize.x / 2, ARC_HIGH_DEF );
437  }
438  else if( aHoleShape == APT_DEF_RECT_HOLE )
439  {
440  holeBuffer.NewOutline();
441  currpos.x = aSize.x / 2;
442  currpos.y = aSize.y / 2;
443  holeBuffer.Append( VECTOR2I( currpos ) ); // link to hole and begin hole
444  currpos.x -= aSize.x;
445  holeBuffer.Append( VECTOR2I( currpos ) );
446  currpos.y -= aSize.y;
447  holeBuffer.Append( VECTOR2I( currpos ) );
448  currpos.x += aSize.x;
449  holeBuffer.Append( VECTOR2I( currpos ) );
450  currpos.y += aSize.y;
451  holeBuffer.Append( VECTOR2I( currpos ) ); // close hole
452  }
453 
454  aPolygon->BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
455 }
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, wxPoint aCenter, int aRadius, int aError)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
Class SHAPE_POLY_SET.
int NewOutline()
Creates a new empty polygon in the set and returns its index
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset difference For aFastMode meaning, see function booleanOp
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)

References SHAPE_POLY_SET::Append(), APT_DEF_RECT_HOLE, APT_DEF_ROUND_HOLE, SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::PM_FAST, and TransformCircleToPolygon().

Referenced by D_CODE::ConvertShapeToPolygon().