KiCad PCB EDA Suite
dcode.cpp File Reference

D_CODE class implementation. More...

#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <trigo.h>
#include <gerbview_frame.h>
#include <class_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

#define DCODE_DEFAULT_SIZE   Millimeter2iu( 0.1 )

Definition at line 41 of file dcode.cpp.

Referenced by D_CODE::Clear_D_CODE_Data().

#define SEGS_CNT   64

Definition at line 293 of file dcode.cpp.

Referenced by addHoleToPolygon(), and D_CODE::ConvertShapeToPolygon().

Function Documentation

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

Definition at line 430 of file dcode.cpp.

References SHAPE_POLY_SET::Append(), APT_DEF_RECT_HOLE, APT_DEF_ROUND_HOLE, SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::Fracture(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::PM_FAST, SEGS_CNT, TransformCircleToPolygon(), wxPoint::x, and wxPoint::y.

Referenced by D_CODE::ConvertShapeToPolygon().

434 {
435  wxPoint currpos;
436  SHAPE_POLY_SET holeBuffer;
437 
438  if( aHoleShape == APT_DEF_ROUND_HOLE )
439  {
440  TransformCircleToPolygon( holeBuffer, wxPoint( 0, 0 ), aSize.x / 2, SEGS_CNT );
441  }
442  else if( aHoleShape == APT_DEF_RECT_HOLE )
443  {
444  holeBuffer.NewOutline();
445  currpos.x = aSize.x / 2;
446  currpos.y = aSize.y / 2;
447  holeBuffer.Append( VECTOR2I( currpos ) ); // link to hole and begin hole
448  currpos.x -= aSize.x;
449  holeBuffer.Append( VECTOR2I( currpos ) );
450  currpos.y -= aSize.y;
451  holeBuffer.Append( VECTOR2I( currpos ) );
452  currpos.x += aSize.x;
453  holeBuffer.Append( VECTOR2I( currpos ) );
454  currpos.y += aSize.y;
455  holeBuffer.Append( VECTOR2I( currpos ) ); // close hole
456  }
457 
458  aPolygon->BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
459 
460  // Needed for legacy canvas only
461  aPolygon->Fracture( SHAPE_POLY_SET::PM_FAST );
462 }
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aCircleToSegmentsCount)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines...
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
Class SHAPE_POLY_SET.
#define SEGS_CNT
Definition: dcode.cpp:293
int NewOutline()
Creates a new empty polygon in the set and returns its index
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
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) ...