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 );
62  TransformOvalToPolygon( *prm->m_cornerBuffer, wxPoint( x0, y0 ), wxPoint( xf, yf ),
63  prm->m_textWidth, prm->m_error );
64 }
65 
66 
68 {
69  // convert tracks and vias:
70  for( auto track : m_tracks )
71  {
72  if( !track->IsOnLayer( aLayer ) )
73  continue;
74 
75  track->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0 );
76  }
77 
78  // convert pads
79  for( auto module : m_modules )
80  {
81  module->TransformPadsShapesWithClearanceToPolygon( aLayer, aOutlines, 0 );
82 
83  // Micro-wave modules may have items on copper layers
84  module->TransformGraphicShapesWithClearanceToPolygonSet( aLayer, aOutlines, 0 );
85  }
86 
87  // convert copper zones
88  for( ZONE_CONTAINER* zone : Zones() )
89  {
90  if( zone->GetLayerSet().test( aLayer ) )
91  zone->TransformSolidAreasShapesToPolygon( aLayer, aOutlines );
92  }
93 
94  // convert graphic items on copper layers (texts)
95  for( auto item : m_drawings )
96  {
97  if( !item->IsOnLayer( aLayer ) )
98  continue;
99 
100  switch( item->Type() )
101  {
102  case PCB_LINE_T:
103  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( aOutlines, aLayer, 0 );
104  break;
105 
106  case PCB_TEXT_T:
107  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet( aOutlines, 0 );
108  break;
109 
110  default:
111  break;
112  }
113  }
114 }
115 
116 
118  SHAPE_POLY_SET& aCornerBuffer,
119  int aInflateValue, int aMaxError,
120  bool aSkipNPTHPadsWihNoCopper,
121  bool aSkipPlatedPads,
122  bool aSkipNonPlatedPads ) const
123 {
124  for( D_PAD* pad : m_pads )
125  {
126  if( aLayer != UNDEFINED_LAYER && !pad->IsOnLayer(aLayer) )
127  continue;
128 
129  if( !pad->IsPadOnLayer( aLayer ) && IsCopperLayer( aLayer ) )
130  continue;
131 
132  // NPTH pads are not drawn on layers if the shape size and pos is the same
133  // as their hole:
134  if( aSkipNPTHPadsWihNoCopper && pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
135  {
136  if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
137  {
138  switch( pad->GetShape() )
139  {
140  case PAD_SHAPE_CIRCLE:
141  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
142  continue;
143  break;
144 
145  case PAD_SHAPE_OVAL:
146  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
147  continue;
148  break;
149 
150  default:
151  break;
152  }
153  }
154  }
155 
156  const bool isPlated = ( ( aLayer == F_Cu ) && pad->IsPadOnLayer( F_Mask ) ) ||
157  ( ( aLayer == B_Cu ) && pad->IsPadOnLayer( B_Mask ) );
158 
159  if( aSkipPlatedPads && isPlated )
160  continue;
161 
162  if( aSkipNonPlatedPads && !isPlated )
163  continue;
164 
165  wxSize clearance( aInflateValue, aInflateValue );
166 
167  switch( aLayer )
168  {
169  case F_Mask:
170  case B_Mask:
171  clearance.x += pad->GetSolderMaskMargin();
172  clearance.y += pad->GetSolderMaskMargin();
173  break;
174 
175  case F_Paste:
176  case B_Paste:
177  clearance += pad->GetSolderPasteMargin();
178  break;
179 
180  default:
181  break;
182  }
183 
184  // Our standard TransformShapeWithClearanceToPolygon() routines can't handle differing
185  // x:y clearance values (which get generated when a relative paste margin is used with
186  // an oblong pad). So we apply this huge hack and fake a larger pad to run the transform
187  // on.
188  // Of course being a hack it falls down when dealing with custom shape pads (where the
189  // size is only the size of the anchor), so for those we punt and just use clearance.x.
190 
191  if( ( clearance.x < 0 || clearance.x != clearance.y )
192  && pad->GetShape() != PAD_SHAPE_CUSTOM )
193  {
194  D_PAD dummy( *pad );
195  dummy.SetSize( pad->GetSize() + clearance + clearance );
196  dummy.TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0, aMaxError );
197  }
198  else
199  {
200  pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, clearance.x,
201  aMaxError );
202  }
203  }
204 }
205 
215  SHAPE_POLY_SET& aCornerBuffer,
216  int aInflateValue,
217  int aError,
218  bool aIncludeText,
219  bool aIncludeEdges ) const
220 {
221  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
222 
223  for( auto item : GraphicalItems() )
224  {
225  if( item->Type() == PCB_MODULE_TEXT_T && aIncludeText )
226  {
227  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
228 
229  if( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer && text->IsVisible() )
230  texts.push_back( text );
231  }
232 
233  if( item->Type() == PCB_MODULE_EDGE_T && aIncludeEdges )
234  {
235  EDGE_MODULE* outline = (EDGE_MODULE*) item;
236 
237  if( aLayer != UNDEFINED_LAYER && outline->GetLayer() == aLayer )
238  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0, aError );
239  }
240  }
241 
242  if( aIncludeText )
243  {
244  if( Reference().GetLayer() == aLayer && Reference().IsVisible() )
245  texts.push_back( &Reference() );
246 
247  if( Value().GetLayer() == aLayer && Value().IsVisible() )
248  texts.push_back( &Value() );
249  }
250 
251  prms.m_cornerBuffer = &aCornerBuffer;
252 
253  for( TEXTE_MODULE* textmod : texts )
254  {
255  bool forceBold = true;
256  int penWidth = 0; // force max width for bold text
257 
258  prms.m_textWidth = textmod->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
259  prms.m_error = aError;
260  wxSize size = textmod->GetTextSize();
261 
262  if( textmod->IsMirrored() )
263  size.x = -size.x;
264 
265  GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(),
266  textmod->GetDrawRotation(), size, textmod->GetHorizJustify(),
267  textmod->GetVertJustify(), penWidth, textmod->IsItalic(), forceBold,
269  }
270 }
271 
272 
274  SHAPE_POLY_SET& aCornerBuffer,
275  int aError ) const
276 {
277  if( !m_FilledPolysList.count( aLayer ) || m_FilledPolysList.at( aLayer ).IsEmpty() )
278  return;
279 
280  // Just add filled areas if filled polygons outlines have no thickness
282  {
283  const SHAPE_POLY_SET& polys = m_FilledPolysList.at( aLayer );
284  aCornerBuffer.Append( polys );
285  return;
286  }
287 
288  // Filled areas have polygons with outline thickness.
289  // we must create the polygons and add inflated polys
290  SHAPE_POLY_SET polys = m_FilledPolysList.at( aLayer );
291 
292  auto board = GetBoard();
293  int maxError = ARC_HIGH_DEF;
294 
295  if( board )
296  maxError = board->GetDesignSettings().m_MaxError;
297 
298  int numSegs = GetArcToSegmentCount( GetMinThickness(), maxError, 360.0 );
299 
301 
302  aCornerBuffer.Append( polys );
303 }
304 
305 
307  int aClearanceValue ) const
308 {
309  if( GetText().Length() == 0 )
310  return;
311 
312  wxPoint corners[4]; // Buffer of polygon corners
313 
314  EDA_RECT rect = GetTextBox();
315  rect.Inflate( aClearanceValue + Millimeter2iu( DEFAULT_TEXT_WIDTH ) );
316  corners[0].x = rect.GetOrigin().x;
317  corners[0].y = rect.GetOrigin().y;
318  corners[1].y = corners[0].y;
319  corners[1].x = rect.GetRight();
320  corners[2].x = corners[1].x;
321  corners[2].y = rect.GetBottom();
322  corners[3].y = corners[2].y;
323  corners[3].x = corners[0].x;
324 
325  aCornerBuffer->NewOutline();
326 
327  for( wxPoint& corner : corners )
328  {
329  // Rotate polygon
330  RotatePoint( &corner.x, &corner.y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
331  aCornerBuffer->Append( corner.x, corner.y );
332  }
333 }
334 
335 
344  int aClearanceValue, int aError ) const
345 {
346  wxSize size = GetTextSize();
347 
348  if( IsMirrored() )
349  size.x = -size.x;
350 
351  bool forceBold = true;
352  int penWidth = GetEffectiveTextPenWidth();
353 
354  prms.m_cornerBuffer = &aCornerBuffer;
355  prms.m_textWidth = GetEffectiveTextPenWidth() + ( 2 * aClearanceValue );
356  prms.m_error = aError;
357  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
358 
359  if( IsMultilineAllowed() )
360  {
361  wxArrayString strings_list;
362  wxStringSplit( GetShownText(), strings_list, '\n' );
363  std::vector<wxPoint> positions;
364  positions.reserve( strings_list.Count() );
365  GetLinePositions( positions, strings_list.Count() );
366 
367  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
368  {
369  wxString txt = strings_list.Item( ii );
370  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
371  GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToPoly, &prms );
372  }
373  }
374  else
375  {
377  GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToPoly, &prms );
378  }
379 }
380 
381 
383  PCB_LAYER_ID aLayer,
384  int aClearanceValue, int aError,
385  bool ignoreLineWidth ) const
386 {
387  int width = ignoreLineWidth ? 0 : m_Width;
388 
389  width += 2 * aClearanceValue;
390 
391  // Creating a reliable clearance shape for circles and arcs is not so easy, due to
392  // the error created by segment approximation.
393  // for a circle this is not so hard: create a polygon from a circle slightly bigger:
394  // thickness = width + s_error_max, and radius = initial radius + s_error_max/2
395  // giving a shape with a suitable internal radius and external radius
396  // For an arc this is more tricky: TODO
397 
398  switch( m_Shape )
399  {
400  case S_CIRCLE:
401  if( width == 0 )
402  TransformCircleToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError );
403  else
404  TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError, width );
405  break;
406 
407  case S_RECT:
408  {
409  std::vector<wxPoint> pts = GetRectCorners();
410 
411  if( width == 0 )
412  {
413  aCornerBuffer.NewOutline();
414 
415  for( const wxPoint& pt : pts )
416  aCornerBuffer.Append( pt );
417  }
418 
419  if( width > 0 )
420  {
421  // Add in segments
422  TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError );
423  TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError );
424  TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError );
425  TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError );
426  }
427  }
428  break;
429 
430  case S_ARC:
431  TransformArcToPolygon( aCornerBuffer, GetCenter(), GetArcStart(), m_Angle, aError, width );
432  break;
433 
434  case S_SEGMENT:
435  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
436  break;
437 
438  case S_POLYGON:
439  if( IsPolyShapeValid() )
440  {
441  // The polygon is expected to be a simple polygon
442  // not self intersecting, no hole.
443  MODULE* module = GetParentModule(); // NULL for items not in footprints
444  double orientation = module ? module->GetOrientation() : 0.0;
445  wxPoint offset;
446 
447  if( module )
448  offset = module->GetPosition();
449 
450  // Build the polygon with the actual position and orientation:
451  std::vector< wxPoint> poly;
452  poly = BuildPolyPointsList();
453 
454  for( wxPoint& point : poly )
455  {
456  RotatePoint( &point, orientation );
457  point += offset;
458  }
459 
460  if( IsPolygonFilled() || width == 0 )
461  {
462  aCornerBuffer.NewOutline();
463 
464  for( wxPoint& point : poly )
465  aCornerBuffer.Append( point.x, point.y );
466  }
467 
468  if( width > 0 )
469  {
470  wxPoint pt1( poly[ poly.size() - 1] );
471 
472  for( wxPoint pt2 : poly )
473  {
474  if( pt2 != pt1 )
475  TransformOvalToPolygon( aCornerBuffer, pt1, pt2, width, aError );
476 
477  pt1 = pt2;
478  }
479  }
480  }
481  break;
482 
483  case S_CURVE: // Bezier curve
484  {
485  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
486  BEZIER_POLY converter( ctrlPoints );
487  std::vector< wxPoint> poly;
488  converter.GetPoly( poly, m_Width );
489 
490  if( width != 0 )
491  {
492  for( unsigned ii = 1; ii < poly.size(); ii++ )
493  TransformOvalToPolygon( aCornerBuffer, poly[ii-1], poly[ii], width, aError );
494  }
495  }
496  break;
497 
498  default:
499  wxFAIL_MSG( "DRAWSEGMENT::TransformShapeWithClearanceToPolygon no implementation for "
500  + STROKE_T_asString( m_Shape ) );
501  break;
502  }
503 }
504 
505 
507  PCB_LAYER_ID aLayer,
508  int aClearanceValue, int aError,
509  bool ignoreLineWidth ) const
510 {
511  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for tracks." );
512 
513 
514  switch( Type() )
515  {
516  case PCB_VIA_T:
517  {
518  int radius = ( m_Width / 2 ) + aClearanceValue;
519  TransformCircleToPolygon( aCornerBuffer, m_Start, radius, aError );
520  }
521  break;
522 
523  case PCB_ARC_T:
524  {
525  const ARC* arc = static_cast<const ARC*>( this );
526  int width = m_Width + ( 2 * aClearanceValue );
527  VECTOR2D center( arc->GetCenter() );
528  double angle = arc->GetAngle();
529 
530  TransformArcToPolygon( aCornerBuffer, (wxPoint) center, GetStart(), angle, aError, width );
531  }
532  break;
533 
534  default:
535  {
536  int width = m_Width + ( 2 * aClearanceValue );
537 
538  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
539  }
540  break;
541  }
542 }
543 
544 
546  PCB_LAYER_ID aLayer,
547  int aClearanceValue, int aError,
548  bool ignoreLineWidth ) const
549 {
550  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for pads." );
551 
552  // minimal segment count to approximate a circle to create the polygonal pad shape
553  // This minimal value is mainly for very small pads, like SM0402.
554  // Most of time pads are using the segment count given by aError value.
555  const int pad_min_seg_per_circle_count = 16;
556  double angle = m_orient;
557  int dx = m_size.x / 2;
558  int dy = m_size.y / 2;
559 
560  wxPoint padShapePos = ShapePos(); // Note: for pad having a shape offset,
561  // the pad position is NOT the shape position
562 
563  switch( GetShape() )
564  {
565  case PAD_SHAPE_CIRCLE:
566  case PAD_SHAPE_OVAL:
567  if( dx == dy )
568  {
569  TransformCircleToPolygon( aCornerBuffer, padShapePos, dx + aClearanceValue, aError );
570  }
571  else
572  {
573  int half_width = std::min( dx, dy );
574  wxPoint delta( dx - half_width, dy - half_width );
575 
576  RotatePoint( &delta, angle );
577 
578  TransformOvalToPolygon( aCornerBuffer, padShapePos - delta, padShapePos + delta,
579  ( half_width + aClearanceValue ) * 2, aError );
580  }
581 
582  break;
583 
584  case PAD_SHAPE_TRAPEZOID:
585  case PAD_SHAPE_RECT:
586  {
587  int ddx = GetShape() == PAD_SHAPE_TRAPEZOID ? m_deltaSize.x / 2 : 0;
588  int ddy = GetShape() == PAD_SHAPE_TRAPEZOID ? m_deltaSize.y / 2 : 0;
589 
590  wxPoint corners[4];
591  corners[0] = wxPoint( -dx - ddy, dy + ddx );
592  corners[1] = wxPoint( dx + ddy, dy - ddx );
593  corners[2] = wxPoint( dx - ddy, -dy + ddx );
594  corners[3] = wxPoint( -dx + ddy, -dy - ddx );
595 
596  SHAPE_POLY_SET outline;
597  outline.NewOutline();
598 
599  for( wxPoint& corner : corners )
600  {
601  RotatePoint( &corner, angle );
602  corner += padShapePos;
603  outline.Append( corner.x, corner.y );
604  }
605 
606  if( aClearanceValue )
607  {
608  int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
609  pad_min_seg_per_circle_count );
610  int clearance = aClearanceValue + GetCircleToPolyCorrection( aError );
611  outline.Inflate( clearance, numSegs );
612  // TODO: clamp the inflated polygon, because it is slightly too big:
613  // it was inflated by a value slightly too big to keep rounded corners
614  // ouside the pad area.
615  }
616 
617  aCornerBuffer.Append( outline );
618  }
619  break;
620 
622  case PAD_SHAPE_ROUNDRECT:
623  {
624  int radius = GetRoundRectCornerRadius() + aClearanceValue;
625  int clearance = aClearanceValue + GetCircleToPolyCorrection( aError );
626  wxSize shapesize( m_size );
627 
628  radius = radius + GetCircleToPolyCorrection( aError );
629  shapesize.x += clearance * 2;
630  shapesize.y += clearance * 2;
631  bool doChamfer = GetShape() == PAD_SHAPE_CHAMFERED_RECT;
632 
633  SHAPE_POLY_SET outline;
634  TransformRoundChamferedRectToPolygon( outline, padShapePos, shapesize, angle, radius,
635  doChamfer ? GetChamferRectRatio() : 0.0,
636  doChamfer ? GetChamferPositions() : 0, aError );
637 
638  aCornerBuffer.Append( outline );
639  }
640  break;
641 
642  case PAD_SHAPE_CUSTOM:
643  {
644  SHAPE_POLY_SET outline;
645  MergePrimitivesAsPolygon( &outline, aLayer );
646  outline.Rotate( -DECIDEG2RAD( m_orient ) );
647  outline.Move( VECTOR2I( m_pos ) );
648 
649  if( aClearanceValue )
650  {
651  int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
652  pad_min_seg_per_circle_count );
653  int clearance = aClearanceValue + GetCircleToPolyCorrection( aError );
654 
655  outline.Inflate( clearance, numSegs );
658  }
659 
660  aCornerBuffer.Append( outline );
661  }
662  break;
663 
664  default:
665  wxFAIL_MSG( "D_PAD::TransformShapeWithClearanceToPolygon no implementation for "
667  break;
668  }
669 }
670 
671 
672 
673 bool D_PAD::TransformHoleWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aInflateValue,
674  int aError ) const
675 {
676  wxSize drillsize = GetDrillSize();
677 
678  if( !drillsize.x || !drillsize.y )
679  return false;
680 
681  const SHAPE_SEGMENT* seg = GetEffectiveHoleShape();
682 
683  TransformOvalToPolygon( aCornerBuffer, (wxPoint) seg->GetSeg().A, (wxPoint) seg->GetSeg().B,
684  seg->GetWidth() + aInflateValue * 2, aError );
685 
686  return true;
687 }
688 
689 
691  PCB_LAYER_ID aLayer, int aClearance,
692  int aError, bool ignoreLineWidth ) const
693 {
694  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for zones." );
695 
696  if( !m_FilledPolysList.count( aLayer ) )
697  return;
698 
699  aCornerBuffer = m_FilledPolysList.at( aLayer );
700 
701  int numSegs = GetArcToSegmentCount( aClearance, aError, 360.0 );
702  aCornerBuffer.Inflate( aClearance, numSegs );
704 }
MODULES m_modules
Definition: class_board.h:184
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:343
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, PCB_LAYER_ID aLayer) const
Merge all basic shapes to a SHAPE_POLY_SET Note: The results are relative to the pad position,...
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
double GetOrientation() const
Definition: class_module.h:224
wxPoint GetArcStart() const
TEXTE_MODULE & Reference()
Definition: class_module.h:492
wxPoint m_Start
Line start point.
Definition: class_track.h:265
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:200
bool IsMirrored() const
Definition: eda_text.h:189
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.
const wxPoint & GetStart() const
Definition: class_track.h:116
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a SHAPE object representing the pad's hole.
Definition: class_pad.cpp:273
void TransformSolidAreasShapesToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Function TransformSolidAreasShapesToPolygon Convert solid areas full shapes to polygon set (the full ...
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
bool IsVisible() const
Definition: eda_text.h:186
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:222
double m_orient
Definition: class_pad.h:703
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) ...
static void isPlated(LIBEVAL::CONTEXT *aCtx, void *self)
double GetTextAngle() const
Definition: eda_text.h:174
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:682
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:714
wxSize m_size
Definition: class_pad.h:667
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:191
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
Definition: class_board.h:185
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
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:157
int m_Width
Thickness of track, or via diameter.
Definition: class_track.h:264
int GetBottom() const
Definition: eda_rect.h:124
wxPoint m_BezierC1
Bezier Control Point 1.
int GetChamferPositions() const
Definition: class_pad.h:503
bool IsItalic() const
Definition: eda_text.h:180
#define DEFAULT_TEXT_WIDTH
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.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:199
#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
std::vector< wxPoint > GetRectCorners() const
wxPoint m_End
Line end point or circle and arc start point.
SHAPE_POLY_SET.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:491
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
TSEGM_2_POLY_PRMS prms
const wxSize & GetTextSize() const
Definition: eda_text.h:239
Arcs (with rounded ends)
wxPoint m_End
Line end point.
Definition: class_track.h:266
double GetChamferRectRatio() const
Definition: class_pad.h:495
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 TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, 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...
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines)
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
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.
int GetCircleToPolyCorrection(int aMaxError)
DRAWINGS m_drawings
Definition: class_board.h:183
int NewOutline()
Creates a new empty polygon in the set and returns its index
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
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:197
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
double GetAngle() const
static wxString STROKE_T_asString(STROKE_T a)
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
Class to handle a graphic segment.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
const wxSize & GetDrillSize() const
Definition: class_pad.h:230
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:609
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
double DECIDEG2RAD(double deg)
Definition: trigo.h:223
wxPoint m_BezierC2
Bezier Control Point 2.
void InflateWithLinkedHoles(int aFactor, int aCircleSegmentsCount, POLYGON_MODE aFastMode)
Performs outline inflation/deflation, using round corners.
int GetMinThickness() const
Definition: class_zone.h:224
bool IsPolyShapeValid() const
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:423
int GetRoundRectCornerRadius() const
Definition: class_pad.cpp:224
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
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:219
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
int m_Width
thickness of lines ...
wxPoint m_pos
Definition: class_pad.h:637
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...
int GetWidth() const
static constexpr int Millimeter2iu(double mm)
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:127
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, 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...
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
wxSize m_deltaSize
Definition: class_pad.h:692
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...
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
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, 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 TransformPadsShapesWithClearanceToPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aMaxError=ARC_HIGH_DEF, bool aSkipNPTHPadsWihNoCopper=false, bool aSkipPlatedPads=false, bool aSkipNonPlatedPads=false) const
function TransformPadsShapesWithClearanceToPolygon generate pads shapes on layer aLayer as polygons a...
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_FilledPolysList
Definition: class_zone.h:920
VECTOR2I B
Definition: seg.h:48