KiCad PCB EDA Suite
board_items_to_polygon_shape_transform.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 (C) 2009-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <fctsys.h>
26 #include <vector>
27 #include <bezier_curves.h>
28 #include <base_units.h> // for IU_PER_MM
29 #include <gr_text.h>
30 #include <pcbnew.h>
31 #include <pcb_edit_frame.h>
32 #include <trigo.h>
33 #include <class_board.h>
34 #include <class_pad.h>
35 #include <class_track.h>
36 #include <class_drawsegment.h>
37 #include <class_pcb_text.h>
38 #include <class_zone.h>
39 #include <class_module.h>
40 #include <class_edge_mod.h>
43 #include <geometry/shape_segment.h>
44 #include <math/util.h> // for KiROUND
45 
46 
47 // A helper struct for the callback function
48 // These variables are parameters used in addTextSegmToPoly.
49 // But addTextSegmToPoly is a call-back function,
50 // so we cannot send them as arguments.
53  int m_error;
55 };
57 
58 // This is a call back function, used by GRText to draw the 3D text shape:
59 static void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData )
60 {
61  TSEGM_2_POLY_PRMS* prm = static_cast<TSEGM_2_POLY_PRMS*>( aData );
63  wxPoint( x0, y0 ), wxPoint( xf, yf ),
64  prm->m_error, prm->m_textWidth );
65 }
66 
67 
69 {
70  // convert tracks and vias:
71  for( auto track : m_tracks )
72  {
73  if( !track->IsOnLayer( aLayer ) )
74  continue;
75 
76  track->TransformShapeWithClearanceToPolygon( aOutlines, 0 );
77  }
78 
79  // convert pads
80  for( auto module : m_modules )
81  {
82  module->TransformPadsShapesWithClearanceToPolygon( aLayer, aOutlines, 0 );
83 
84  // Micro-wave modules may have items on copper layers
85  module->TransformGraphicShapesWithClearanceToPolygonSet( aLayer, aOutlines, 0 );
86  }
87 
88  // convert copper zones
89  for( int ii = 0; ii < GetAreaCount(); ii++ )
90  {
91  ZONE_CONTAINER* zone = GetArea( ii );
92 
93  if( zone->GetLayerSet().test( aLayer ) )
94  zone->TransformSolidAreasShapesToPolygonSet( aLayer, aOutlines );
95  }
96 
97  // convert graphic items on copper layers (texts)
98  for( auto item : m_drawings )
99  {
100  if( !item->IsOnLayer( aLayer ) )
101  continue;
102 
103  switch( item->Type() )
104  {
105  case PCB_LINE_T:
106  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( aOutlines, 0 );
107  break;
108 
109  case PCB_TEXT_T:
110  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet( aOutlines, 0 );
111  break;
112 
113  default:
114  break;
115  }
116  }
117 }
118 
119 
121  SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aMaxError,
122  bool aSkipNPTHPadsWihNoCopper ) const
123 {
124  for( auto pad : m_pads )
125  {
126  if( aLayer != UNDEFINED_LAYER && !pad->IsOnLayer(aLayer) )
127  continue;
128 
129  // NPTH pads are not drawn on layers if the shape size and pos is the same
130  // as their hole:
131  if( aSkipNPTHPadsWihNoCopper && pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
132  {
133  if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
134  {
135  switch( pad->GetShape() )
136  {
137  case PAD_SHAPE_CIRCLE:
138  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
139  continue;
140  break;
141 
142  case PAD_SHAPE_OVAL:
143  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
144  continue;
145  break;
146 
147  default:
148  break;
149  }
150  }
151  }
152 
153  wxSize margin;
154  int clearance = aInflateValue;
155 
156  switch( aLayer )
157  {
158  case F_Mask:
159  case B_Mask:
160  clearance += pad->GetSolderMaskMargin();
161  break;
162 
163  case F_Paste:
164  case B_Paste:
165  margin = pad->GetSolderPasteMargin();
166  clearance += ( margin.x + margin.y ) / 2;
167  break;
168 
169  default:
170  break;
171  }
172 
173  pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, clearance );
174  }
175 }
176 
186  SHAPE_POLY_SET& aCornerBuffer,
187  int aInflateValue,
188  int aError,
189  bool aIncludeText,
190  bool aIncludeEdges ) const
191 {
192  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
193 
194  for( auto item : GraphicalItems() )
195  {
196  if( item->Type() == PCB_MODULE_TEXT_T && aIncludeText )
197  {
198  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
199 
200  if( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer && text->IsVisible() )
201  texts.push_back( text );
202  }
203 
204  if( item->Type() == PCB_MODULE_EDGE_T && aIncludeEdges )
205  {
206  EDGE_MODULE* outline = (EDGE_MODULE*) item;
207 
208  if( aLayer != UNDEFINED_LAYER && outline->GetLayer() == aLayer )
209  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0, aError );
210  }
211  }
212 
213  if( aIncludeText )
214  {
215  if( Reference().GetLayer() == aLayer && Reference().IsVisible() )
216  texts.push_back( &Reference() );
217 
218  if( Value().GetLayer() == aLayer && Value().IsVisible() )
219  texts.push_back( &Value() );
220  }
221 
222  prms.m_cornerBuffer = &aCornerBuffer;
223 
224  for( TEXTE_MODULE* textmod : texts )
225  {
226  bool forceBold = true;
227  int penWidth = 0; // force max width for bold text
228 
229  prms.m_textWidth = textmod->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
230  prms.m_error = aError;
231  wxSize size = textmod->GetTextSize();
232 
233  if( textmod->IsMirrored() )
234  size.x = -size.x;
235 
236  GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(),
237  textmod->GetDrawRotation(), size, textmod->GetHorizJustify(),
238  textmod->GetVertJustify(), penWidth, textmod->IsItalic(), forceBold,
240  }
241 }
242 
243 
245  SHAPE_POLY_SET& aCornerBuffer,
246  int aError ) const
247 {
248  if( !m_FilledPolysList.count( aLayer ) || m_FilledPolysList.at( aLayer ).IsEmpty() )
249  return;
250 
251  const SHAPE_POLY_SET& polys = m_FilledPolysList.at( aLayer );
252 
253  // add filled areas polygons
254  aCornerBuffer.Append( polys );
255  auto board = GetBoard();
256  int maxError = ARC_HIGH_DEF;
257 
258  if( board )
259  maxError = board->GetDesignSettings().m_MaxError;
260 
261  // add filled areas outlines, which are drawn with thick lines
262  for( int i = 0; i < polys.OutlineCount(); i++ )
263  {
264  const SHAPE_LINE_CHAIN& path = polys.COutline( i );
265 
266  for( int j = 0; j < path.PointCount(); j++ )
267  {
268  const VECTOR2I& a = path.CPoint( j );
269  const VECTOR2I& b = path.CPoint( j + 1 );
270  int width = GetMinThickness();
271 
272  TransformSegmentToPolygon( aCornerBuffer, (wxPoint) a, (wxPoint) b, maxError, width );
273  }
274  }
275 }
276 
277 
279  int aClearanceValue ) const
280 {
281  if( GetText().Length() == 0 )
282  return;
283 
284  wxPoint corners[4]; // Buffer of polygon corners
285 
286  EDA_RECT rect = GetTextBox();
287  rect.Inflate( aClearanceValue + Millimeter2iu( DEFAULT_TEXT_WIDTH ) );
288  corners[0].x = rect.GetOrigin().x;
289  corners[0].y = rect.GetOrigin().y;
290  corners[1].y = corners[0].y;
291  corners[1].x = rect.GetRight();
292  corners[2].x = corners[1].x;
293  corners[2].y = rect.GetBottom();
294  corners[3].y = corners[2].y;
295  corners[3].x = corners[0].x;
296 
297  aCornerBuffer->NewOutline();
298 
299  for( wxPoint& corner : corners )
300  {
301  // Rotate polygon
302  RotatePoint( &corner.x, &corner.y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
303  aCornerBuffer->Append( corner.x, corner.y );
304  }
305 }
306 
307 
316  int aClearanceValue, int aError ) const
317 {
318  wxSize size = GetTextSize();
319 
320  if( IsMirrored() )
321  size.x = -size.x;
322 
323  bool forceBold = true;
324  int penWidth = GetEffectiveTextPenWidth();
325 
326  prms.m_cornerBuffer = &aCornerBuffer;
327  prms.m_textWidth = GetEffectiveTextPenWidth() + ( 2 * aClearanceValue );
328  prms.m_error = aError;
329  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
330 
331  if( IsMultilineAllowed() )
332  {
333  wxArrayString strings_list;
334  wxStringSplit( GetShownText(), strings_list, '\n' );
335  std::vector<wxPoint> positions;
336  positions.reserve( strings_list.Count() );
337  GetLinePositions( positions, strings_list.Count() );
338 
339  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
340  {
341  wxString txt = strings_list.Item( ii );
342  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
343  GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToPoly, &prms );
344  }
345  }
346  else
347  {
349  GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToPoly, &prms );
350  }
351 }
352 
353 
355  int aClearanceValue, int aError,
356  bool ignoreLineWidth ) const
357 {
358  int width = ignoreLineWidth ? 0 : m_Width;
359 
360  width += 2 * aClearanceValue;
361 
362  // Creating a reliable clearance shape for circles and arcs is not so easy, due to
363  // the error created by segment approximation.
364  // for a circle this is not so hard: create a polygon from a circle slightly bigger:
365  // thickness = width + s_error_max, and radius = initial radius + s_error_max/2
366  // giving a shape with a suitable internal radius and external radius
367  // For an arc this is more tricky: TODO
368 
369  switch( m_Shape )
370  {
371  case S_CIRCLE:
372  if( width == 0 )
373  TransformCircleToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError );
374  else
375  TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError, width );
376  break;
377 
378  case S_RECT:
379  {
380  std::vector<wxPoint> pts;
381  GetRectCorners( &pts );
382 
383  if( width == 0 )
384  {
385  aCornerBuffer.NewOutline();
386 
387  for( const wxPoint& pt : pts )
388  aCornerBuffer.Append( pt );
389  }
390 
391  if( width > 0 )
392  {
393  // Add in segments
394  TransformSegmentToPolygon( aCornerBuffer, pts[0], pts[1], aError, width );
395  TransformSegmentToPolygon( aCornerBuffer, pts[1], pts[2], aError, width );
396  TransformSegmentToPolygon( aCornerBuffer, pts[2], pts[3], aError, width );
397  TransformSegmentToPolygon( aCornerBuffer, pts[3], pts[0], aError, width );
398  }
399  }
400  break;
401 
402  case S_ARC:
403  TransformArcToPolygon( aCornerBuffer, GetCenter(), GetArcStart(), m_Angle, aError, width );
404  break;
405 
406  case S_SEGMENT:
407  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
408  break;
409 
410  case S_POLYGON:
411  if( IsPolyShapeValid() )
412  {
413  // The polygon is expected to be a simple polygon
414  // not self intersecting, no hole.
415  MODULE* module = GetParentModule(); // NULL for items not in footprints
416  double orientation = module ? module->GetOrientation() : 0.0;
417  wxPoint offset;
418 
419  if( module )
420  offset = module->GetPosition();
421 
422  // Build the polygon with the actual position and orientation:
423  std::vector< wxPoint> poly;
424  poly = BuildPolyPointsList();
425 
426  for( wxPoint& point : poly )
427  {
428  RotatePoint( &point, orientation );
429  point += offset;
430  }
431 
432  if( IsPolygonFilled() || width == 0 )
433  {
434  aCornerBuffer.NewOutline();
435 
436  for( wxPoint& point : poly )
437  aCornerBuffer.Append( point.x, point.y );
438  }
439 
440  if( width > 0 )
441  {
442  wxPoint pt1( poly[ poly.size() - 1] );
443 
444  for( wxPoint pt2 : poly )
445  {
446  if( pt2 != pt1 )
447  TransformSegmentToPolygon( aCornerBuffer, pt1, pt2, aError, width );
448 
449  pt1 = pt2;
450  }
451  }
452  }
453  break;
454 
455  case S_CURVE: // Bezier curve
456  {
457  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
458  BEZIER_POLY converter( ctrlPoints );
459  std::vector< wxPoint> poly;
460  converter.GetPoly( poly, m_Width );
461 
462  if( width != 0 )
463  {
464  for( unsigned ii = 1; ii < poly.size(); ii++ )
465  TransformSegmentToPolygon( aCornerBuffer, poly[ii-1], poly[ii], aError, width );
466  }
467  }
468  break;
469 
470  default:
471  wxFAIL_MSG( "DRAWSEGMENT::TransformShapeWithClearanceToPolygon no implementation for "
472  + STROKE_T_asString( m_Shape ) );
473  break;
474  }
475 }
476 
477 
479  int aClearanceValue, int aError,
480  bool ignoreLineWidth ) const
481 {
482  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for tracks." );
483 
484  int width = m_Width + ( 2 * aClearanceValue );
485 
486  switch( Type() )
487  {
488  case PCB_VIA_T:
489  {
490  int radius = ( m_Width / 2 ) + aClearanceValue;
491  TransformCircleToPolygon( aCornerBuffer, m_Start, radius, aError );
492  }
493  break;
494 
495  case PCB_ARC_T:
496  {
497  const ARC* arc = static_cast<const ARC*>( this );
498  VECTOR2D center( arc->GetCenter() );
499  double arc_angle = arc->GetAngle();
500  TransformArcToPolygon( aCornerBuffer, wxPoint( center.x, center.y ),
501  GetStart(), arc_angle, aError, width );
502  }
503  break;
504 
505  default:
506  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
507  break;
508  }
509 }
510 
511 
513  int aClearanceValue, int aError,
514  bool ignoreLineWidth ) const
515 {
516  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for pads." );
517 
518  // minimal segment count to approximate a circle to create the polygonal pad shape
519  // This minimal value is mainly for very small pads, like SM0402.
520  // Most of time pads are using the segment count given by aError value.
521  const int pad_min_seg_per_circle_count = 16;
522  double angle = m_Orient;
523  int dx = m_Size.x / 2;
524  int dy = m_Size.y / 2;
525 
526  wxPoint padShapePos = ShapePos(); // Note: for pad having a shape offset,
527  // the pad position is NOT the shape position
528 
529  switch( GetShape() )
530  {
531  case PAD_SHAPE_CIRCLE:
532  case PAD_SHAPE_OVAL:
533  if( dx == dy )
534  {
535  TransformCircleToPolygon( aCornerBuffer, padShapePos, dx + aClearanceValue, aError );
536  }
537  else
538  {
539  int half_width = std::min( dx, dy );
540  wxPoint delta( dx - half_width, dy - half_width );
541 
542  RotatePoint( &delta, angle );
543 
544  TransformOvalToPolygon( aCornerBuffer, padShapePos - delta, padShapePos + delta,
545  ( half_width + aClearanceValue ) * 2, aError );
546  }
547 
548  break;
549 
550  case PAD_SHAPE_TRAPEZOID:
551  case PAD_SHAPE_RECT:
552  {
553  int ddx = GetShape() == PAD_SHAPE_TRAPEZOID ? m_DeltaSize.x / 2 : 0;
554  int ddy = GetShape() == PAD_SHAPE_TRAPEZOID ? m_DeltaSize.y / 2 : 0;
555 
556  wxPoint corners[4];
557  corners[0] = wxPoint( -dx + ddy, dy + ddx );
558  corners[1] = wxPoint( dx - ddy, dy - ddx );
559  corners[2] = wxPoint( dx + ddy, -dy + ddx );
560  corners[3] = wxPoint( -dx - ddy, -dy - ddx );
561 
562  SHAPE_POLY_SET outline;
563  outline.NewOutline();
564 
565  for( wxPoint& corner : corners )
566  {
567  RotatePoint( &corner, angle );
568  corner += padShapePos;
569  outline.Append( corner.x, corner.y );
570  }
571 
572  if( aClearanceValue )
573  {
574  int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
575  pad_min_seg_per_circle_count );
576  double correction = GetCircletoPolyCorrectionFactor( numSegs );
577  int clearance = KiROUND( aClearanceValue * correction );
578  outline.Inflate( clearance, numSegs );
579  // TODO: clamp the inflated polygon, because it is slightly too big:
580  // it was inflated by a value slightly too big to keep rounded corners
581  // ouside the pad area.
582  }
583 
584  aCornerBuffer.Append( outline );
585  }
586  break;
587 
589  case PAD_SHAPE_ROUNDRECT:
590  {
591  int radius = GetRoundRectCornerRadius() + aClearanceValue;
592  int numSegs = std::max( GetArcToSegmentCount( radius, aError, 360.0 ),
593  pad_min_seg_per_circle_count );
594  double correction = GetCircletoPolyCorrectionFactor( numSegs );
595  int clearance = KiROUND( aClearanceValue * correction );
596  wxSize shapesize( m_Size );
597 
598  radius = KiROUND( radius * correction );
599  shapesize.x += clearance * 2;
600  shapesize.y += clearance * 2;
601  bool doChamfer = GetShape() == PAD_SHAPE_CHAMFERED_RECT;
602 
603  SHAPE_POLY_SET outline;
604  TransformRoundChamferedRectToPolygon( outline, padShapePos, shapesize, angle, radius,
605  doChamfer ? GetChamferRectRatio() : 0.0,
606  doChamfer ? GetChamferPositions() : 0, aError );
607 
608  aCornerBuffer.Append( outline );
609  }
610  break;
611 
612  case PAD_SHAPE_CUSTOM:
613  {
614  SHAPE_POLY_SET outline;
615  MergePrimitivesAsPolygon( &outline );
616  outline.Rotate( -DECIDEG2RAD( m_Orient ) );
617  outline.Move( VECTOR2I( m_Pos ) );
618 
619  // TODO: do we need the Simplify() & Fracture() if we're not inflating?
621 
622  if( aClearanceValue )
623  {
624  int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
625  pad_min_seg_per_circle_count );
626  double correction = GetCircletoPolyCorrectionFactor( numSegs );
627  int clearance = KiROUND( aClearanceValue * correction );
628 
629  outline.Inflate( clearance, numSegs );
630  }
631 
633  aCornerBuffer.Append( outline );
634  }
635  break;
636 
637  default:
638  wxFAIL_MSG( "D_PAD::TransformShapeWithClearanceToPolygon no implementation for "
640  break;
641  }
642 }
643 
644 
645 
646 bool D_PAD::TransformHoleWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aInflateValue,
647  int aError ) const
648 {
649  wxSize drillsize = GetDrillSize();
650 
651  if( !drillsize.x || !drillsize.y )
652  return false;
653 
654  const SHAPE_SEGMENT* seg = GetEffectiveHoleShape();
655 
656  TransformSegmentToPolygon( aCornerBuffer, (wxPoint) seg->GetSeg().A, (wxPoint) seg->GetSeg().B,
657  aError, seg->GetWidth() + aInflateValue * 2 );
658 
659  return true;
660 }
661 
662 
664  int aClearanceValue, int aError,
665  bool ignoreLineWidth ) const
666 {
667  // Now that zones are multilayer, we cannot implement this without a layer argument.
668  // But, at the time of adding multilayer zones, this is never called for zones anyway
669  // so let's just disable it and fail.
670  wxFAIL_MSG( "TransformShapeWithClearanceToPolygon is not supported for zones" );
671 
672 #if 0
673  if( !m_FilledPolysList.count( aLayer ) )
674  return;
675 
676  aCornerBuffer = m_FilledPolysList.at( aLayer );
678 #endif
679 }
MODULES m_modules
MODULES for components on the board, owned by pointer.
Definition: class_board.h:195
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:341
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
double GetOrientation() const
Definition: class_module.h:211
wxPoint GetArcStart() const
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon) const
Merge all basic shapes to a SHAPE_POLY_SET Note: The corners coordinates are relative to the pad posi...
TEXTE_MODULE & Reference()
Definition: class_module.h:474
wxPoint m_Start
Line start point.
Definition: class_track.h:257
int OutlineCount() const
Returns the number of outlines in the set
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsMirrored() const
Definition: eda_text.h:188
TEXTE_PCB class definition.
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
static std::string PAD_SHAPE_T_asString(PAD_SHAPE_T a)
Definition: pad_shapes.h:45
static void addTextSegmToPoly(int x0, int y0, int xf, int yf, void *aData)
Implementation of conversion functions that require both schematic and board internal units.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
const wxPoint & GetStart() const
Definition: class_track.h:118
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a list of SHAPE objects representing the pad's hole.
Definition: class_pad.cpp:203
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
bool IsVisible() const
Definition: eda_text.h:185
int color
Definition: DXF_plotter.cpp:61
polygon (not yet used for tracks, but could be in microwave apps)
EDA_RECT GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:217
wxSize m_Size
Definition: class_pad.h:641
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
void TransformGraphicShapesWithClearanceToPolygonSet(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aError=ARC_HIGH_DEF, bool aIncludeText=true, bool aIncludeEdges=true) const
function TransformGraphicShapesWithClearanceToPolygonSet generate shapes of graphic items (outlines) ...
double GetTextAngle() const
Definition: eda_text.h:173
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
PADS m_pads
Definition: class_module.h:678
usual segment : line with rounded ends
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Function Rotate rotates all vertices by a given angle.
void TransformArcToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, wxPoint aStart, double aArcAngle, int aError, int aWidth)
Function TransformArcToPolygon Creates a polygon from an Arc Convert arcs to multiple straight segmen...
Definition: color4d.h:44
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
void TransformBoundingBoxWithClearanceToPolygon(SHAPE_POLY_SET *aCornerBuffer, int aClearanceValue) const
Convert the text bounding box to a rectangular polygon depending on the text orientation,...
DRAWINGS & GraphicalItems()
Definition: class_module.h:179
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void Inflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Performs outline inflation/deflation.
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
TRACKS m_tracks
TRACKS for traces on the board, owned by pointer.
Definition: class_board.h:198
int PointCount() const
Function PointCount()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void TransformSolidAreasShapesToPolygonSet(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Function TransformSolidAreasShapesToPolygonSet Convert solid areas full shapes to polygon set (the fu...
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
const SEG & GetSeg() const
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
int m_Width
Thickness of track, or via diameter.
Definition: class_track.h:256
int GetBottom() const
Definition: eda_rect.h:124
wxPoint m_BezierC1
Bezier Control Point 1.
int GetChamferPositions() const
Definition: class_pad.h:491
bool IsItalic() const
Definition: eda_text.h:179
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:312
#define DEFAULT_TEXT_WIDTH
const VECTOR2I & CPoint(int aIndex) const
Function Point()
segment with non rounded ends
PCB_LAYER_ID
A quick note on layer IDs:
void TransformShapeWithClearanceToPolygonSet(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aError=ARC_HIGH_DEF) const
Function TransformShapeWithClearanceToPolygonSet Convert the text shape to a set of polygons (one by ...
wxPoint m_Start
Line start point or Circle and Arc center.
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:932
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
#define NULL
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aWidth, int aError)
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSeg...
void Move(const VECTOR2I &aVector) override
wxPoint m_End
Line end point or circle and arc start point.
double GetCircletoPolyCorrectionFactor(int aSegCountforCircle)
SHAPE_POLY_SET.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:473
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
TSEGM_2_POLY_PRMS prms
const wxSize & GetTextSize() const
Definition: eda_text.h:238
Arcs (with rounded ends)
wxPoint m_End
Line end point.
Definition: class_track.h:258
double GetChamferRectRatio() const
Definition: class_pad.h:483
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
int GetRight() const
Definition: eda_rect.h:121
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines)
Function ConvertBrdLayerToPolygonalContours Build a set of polygons which are the outlines of copper ...
virtual wxPoint GetCenter() const
Function GetCenter()
a few functions useful in geometry calculations.
STROKE_T m_Shape
Shape: line, Circle, Arc.
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Bezier Curve.
wxSize m_DeltaSize
Definition: class_pad.h:666
DRAWINGS m_drawings
BOARD_ITEMs for drawings on the board, owned by pointer.
Definition: class_board.h:192
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...
bool IsMultilineAllowed() const
Definition: eda_text.h:196
Pad object description.
void GRText(wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function GRText Draw a graphic text (like module texts)
Definition: gr_text.cpp:134
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
double GetAngle() const
static wxString STROKE_T_asString(STROKE_T a)
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
void TransformPadsShapesWithClearanceToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aMaxError=ARC_HIGH_DEF, bool aSkipNPTHPadsWihNoCopper=false) const
function TransformPadsShapesWithClearanceToPolygon generate pads shapes on layer aLayer as polygons a...
Class to handle a graphic segment.
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
const wxSize & GetDrillSize() const
Definition: class_pad.h:227
VECTOR2I A
Definition: seg.h:47
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aError)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
wxPoint ShapePos() const
Definition: class_pad.cpp:491
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
double DECIDEG2RAD(double deg)
Definition: trigo.h:218
wxPoint m_BezierC2
Bezier Control Point 2.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
int GetMinThickness() const
Definition: class_zone.h:201
bool IsPolyShapeValid() const
void TransformSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aError, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
void GetLinePositions(std::vector< wxPoint > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:418
int GetRoundRectCornerRadius() const
Definition: class_pad.cpp:163
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aError, int aWidth)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
wxPoint GetPosition() const override
Definition: class_module.h:206
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:154
int m_Width
thickness of lines ...
double m_Orient
Definition: class_pad.h:677
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:897
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aError)
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corner...
void GetRectCorners(std::vector< wxPoint > *pts) const
int GetWidth() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsPolygonFilled() const
Polygonal shape is not always filled.
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the zone shape to a closed polygon Used in fill...
wxPoint GetCenter() const override
Function GetCenter()
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
bool TransformHoleWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aError=ARC_HIGH_DEF) const
Function TransformHoleWithClearanceToPolygon Build the Corner list of the polygonal drill shape in th...
wxPoint m_Pos
Definition: class_pad.h:613
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)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_FilledPolysList
Definition: class_zone.h:922
VECTOR2I B
Definition: seg.h:48