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 <math/util.h> // for KiROUND
44 
45 // A helper struct for the callback function
46 // These variables are parameters used in addTextSegmToPoly.
47 // But addTextSegmToPoly is a call-back function,
48 // so we cannot send them as arguments.
51  int m_error;
53 };
55 
56 // This is a call back function, used by GRText to draw the 3D text shape:
57 static void addTextSegmToPoly( int x0, int y0, int xf, int yf, void* aData )
58 {
59  TSEGM_2_POLY_PRMS* prm = static_cast<TSEGM_2_POLY_PRMS*>( aData );
61  wxPoint( x0, y0 ), wxPoint( xf, yf ),
62  prm->m_error, prm->m_textWidth );
63 }
64 
65 
67 {
68  // convert tracks and vias:
69  for( auto track : m_tracks )
70  {
71  if( !track->IsOnLayer( aLayer ) )
72  continue;
73 
74  track->TransformShapeWithClearanceToPolygon( aOutlines, 0 );
75  }
76 
77  // convert pads
78  for( auto module : m_modules )
79  {
80  module->TransformPadsShapesWithClearanceToPolygon( aLayer, aOutlines, 0 );
81 
82  // Micro-wave modules may have items on copper layers
83  module->TransformGraphicShapesWithClearanceToPolygonSet( aLayer, aOutlines, 0 );
84  }
85 
86  // convert copper zones
87  for( int ii = 0; ii < GetAreaCount(); ii++ )
88  {
89  ZONE_CONTAINER* zone = GetArea( ii );
90  PCB_LAYER_ID zonelayer = zone->GetLayer();
91 
92  if( zonelayer == aLayer )
93  zone->TransformSolidAreasShapesToPolygonSet( aOutlines );
94  }
95 
96  // convert graphic items on copper layers (texts)
97  for( auto item : m_drawings )
98  {
99  if( !item->IsOnLayer( aLayer ) )
100  continue;
101 
102  switch( item->Type() )
103  {
104  case PCB_LINE_T:
105  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( aOutlines, 0 );
106  break;
107 
108  case PCB_TEXT_T:
109  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet( aOutlines, 0 );
110  break;
111 
112  default:
113  break;
114  }
115  }
116 }
117 
118 
120  SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aMaxError,
121  bool aSkipNPTHPadsWihNoCopper ) const
122 {
123  for( auto pad : m_pads )
124  {
125  if( aLayer != UNDEFINED_LAYER && !pad->IsOnLayer(aLayer) )
126  continue;
127 
128  // NPTH pads are not drawn on layers if the shape size and pos is the same
129  // as their hole:
130  if( aSkipNPTHPadsWihNoCopper && pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
131  {
132  if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
133  {
134  switch( pad->GetShape() )
135  {
136  case PAD_SHAPE_CIRCLE:
137  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
138  continue;
139  break;
140 
141  case PAD_SHAPE_OVAL:
142  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
143  continue;
144  break;
145 
146  default:
147  break;
148  }
149  }
150  }
151 
152  wxSize margin;
153  int clearance = aInflateValue;
154 
155  switch( aLayer )
156  {
157  case F_Mask:
158  case B_Mask:
159  clearance += pad->GetSolderMaskMargin();
160  break;
161 
162  case F_Paste:
163  case B_Paste:
164  margin = pad->GetSolderPasteMargin();
165  clearance += ( margin.x + margin.y ) / 2;
166  break;
167 
168  default:
169  break;
170  }
171 
172  pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, clearance );
173  }
174 }
175 
185  SHAPE_POLY_SET& aCornerBuffer,
186  int aInflateValue,
187  int aError, bool aIncludeText ) const
188 {
189  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
190 
191  for( auto item : GraphicalItems() )
192  {
193  switch( item->Type() )
194  {
195  case PCB_MODULE_TEXT_T:
196  {
197  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
198 
199  if( ( aLayer != UNDEFINED_LAYER && text->GetLayer() == aLayer ) && text->IsVisible() )
200  texts.push_back( text );
201  }
202  break;
203 
204  case PCB_MODULE_EDGE_T:
205  {
206  EDGE_MODULE* outline = (EDGE_MODULE*) item;
207 
208  if( aLayer != UNDEFINED_LAYER && outline->GetLayer() != aLayer )
209  break;
210 
211  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, 0, aError );
212  }
213  break;
214 
215  default:
216  break;
217  }
218  }
219 
220  if( !aIncludeText )
221  return;
222 
223  // Convert texts sur modules
224  if( Reference().GetLayer() == aLayer && Reference().IsVisible() )
225  texts.push_back( &Reference() );
226 
227  if( Value().GetLayer() == aLayer && Value().IsVisible() )
228  texts.push_back( &Value() );
229 
230  prms.m_cornerBuffer = &aCornerBuffer;
231 
232  for( TEXTE_MODULE* textmod : texts )
233  {
234  prms.m_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
235  prms.m_error = aError;
236  wxSize size = textmod->GetTextSize();
237 
238  if( textmod->IsMirrored() )
239  size.x = -size.x;
240 
241  GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(),
242  textmod->GetDrawRotation(), size, textmod->GetHorizJustify(),
243  textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(),
244  true, addTextSegmToPoly, &prms );
245  }
246 
247 }
248 
249 
250 // Same as function TransformGraphicShapesWithClearanceToPolygonSet but this only for text
252  SHAPE_POLY_SET& aCornerBuffer,
253  int aInflateValue, int aError ) const
254 {
255  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
256 
257  for( auto item : GraphicalItems() )
258  {
259  switch( item->Type() )
260  {
261  case PCB_MODULE_TEXT_T:
262  {
263  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
264 
265  if( text->GetLayer() == aLayer && text->IsVisible() )
266  texts.push_back( text );
267  }
268  break;
269 
270  case PCB_MODULE_EDGE_T:
271  // This function does not render this
272  break;
273 
274  default:
275  break;
276  }
277  }
278 
279  // Convert texts sur modules
280  if( Reference().GetLayer() == aLayer && Reference().IsVisible() )
281  texts.push_back( &Reference() );
282 
283  if( Value().GetLayer() == aLayer && Value().IsVisible() )
284  texts.push_back( &Value() );
285 
286  prms.m_cornerBuffer = &aCornerBuffer;
287 
288  for( TEXTE_MODULE* textmod : texts )
289  {
290  prms.m_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
291  prms.m_error = aError;
292  wxSize size = textmod->GetTextSize();
293 
294  if( textmod->IsMirrored() )
295  size.x = -size.x;
296 
297  GRText( NULL, textmod->GetTextPos(), BLACK, textmod->GetShownText(),
298  textmod->GetDrawRotation(), size, textmod->GetHorizJustify(),
299  textmod->GetVertJustify(), textmod->GetThickness(), textmod->IsItalic(),
300  true, addTextSegmToPoly, &prms );
301  }
302 
303 }
304 
305 
307  int aError ) const
308 {
309  if( GetFilledPolysList().IsEmpty() )
310  return;
311 
312  // add filled areas polygons
313  aCornerBuffer.Append( m_FilledPolysList );
314  auto board = GetBoard();
315  int maxError = ARC_HIGH_DEF;
316 
317  if( board )
318  maxError = board->GetDesignSettings().m_MaxError;
319 
320  // add filled areas outlines, which are drawn with thick lines
321  for( int i = 0; i < m_FilledPolysList.OutlineCount(); i++ )
322  {
323  const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( i );
324 
325  for( int j = 0; j < path.PointCount(); j++ )
326  {
327  const VECTOR2I& a = path.CPoint( j );
328  const VECTOR2I& b = path.CPoint( j + 1 );
329  int width = GetMinThickness();
330 
331  TransformSegmentToPolygon( aCornerBuffer, (wxPoint) a, (wxPoint) b, maxError, width );
332  }
333  }
334 }
335 
336 
338  int aClearanceValue ) const
339 {
340  if( GetText().Length() == 0 )
341  return;
342 
343  wxPoint corners[4]; // Buffer of polygon corners
344 
345  EDA_RECT rect = GetTextBox( -1 );
346  rect.Inflate( aClearanceValue );
347  corners[0].x = rect.GetOrigin().x;
348  corners[0].y = rect.GetOrigin().y;
349  corners[1].y = corners[0].y;
350  corners[1].x = rect.GetRight();
351  corners[2].x = corners[1].x;
352  corners[2].y = rect.GetBottom();
353  corners[3].y = corners[2].y;
354  corners[3].x = corners[0].x;
355 
356  aCornerBuffer->NewOutline();
357 
358  for( wxPoint& corner : corners )
359  {
360  // Rotate polygon
361  RotatePoint( &corner.x, &corner.y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
362  aCornerBuffer->Append( corner.x, corner.y );
363  }
364 }
365 
366 
375  int aClearanceValue, int aError ) const
376 {
377  wxSize size = GetTextSize();
378 
379  if( IsMirrored() )
380  size.x = -size.x;
381 
382  prms.m_cornerBuffer = &aCornerBuffer;
383  prms.m_textWidth = GetThickness() + ( 2 * aClearanceValue );
384  prms.m_error = aError;
385  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
386 
387  if( IsMultilineAllowed() )
388  {
389  wxArrayString strings_list;
390  wxStringSplit( GetShownText(), strings_list, '\n' );
391  std::vector<wxPoint> positions;
392  positions.reserve( strings_list.Count() );
393  GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
394 
395  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
396  {
397  wxString txt = strings_list.Item( ii );
398  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
400  }
401  }
402  else
403  {
406  }
407 }
408 
409 
411  int aClearanceValue, int aError,
412  bool ignoreLineWidth ) const
413 {
414  int width = ignoreLineWidth ? 0 : m_Width;
415 
416  width += 2 * aClearanceValue;
417 
418  // Creating a reliable clearance shape for circles and arcs is not so easy, due to
419  // the error created by segment approximation.
420  // for a circle this is not so hard: create a polygon from a circle slightly bigger:
421  // thickness = width + s_error_max, and radius = initial radius + s_error_max/2
422  // giving a shape with a suitable internal radius and external radius
423  // For an arc this is more tricky: TODO
424 
425  switch( m_Shape )
426  {
427  case S_CIRCLE:
428  TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError, width );
429  break;
430 
431  case S_ARC:
432  TransformArcToPolygon( aCornerBuffer, GetCenter(), GetArcStart(), m_Angle, aError, width );
433  break;
434 
435  case S_SEGMENT:
436  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
437  break;
438 
439  case S_POLYGON:
440  if( IsPolyShapeValid() )
441  {
442  // The polygon is expected to be a simple polygon
443  // not self intersecting, no hole.
444  MODULE* module = GetParentModule(); // NULL for items not in footprints
445  double orientation = module ? module->GetOrientation() : 0.0;
446  wxPoint offset;
447 
448  if( module )
449  offset = module->GetPosition();
450 
451  // Build the polygon with the actual position and orientation:
452  std::vector< wxPoint> poly;
453  poly = BuildPolyPointsList();
454 
455  for( wxPoint& point : poly )
456  {
457  RotatePoint( &point, orientation );
458  point += offset;
459  }
460 
461  // If the polygon is not filled, treat it as a closed set of lines
462  if( !IsPolygonFilled() )
463  {
464  for( size_t ii = 1; ii < poly.size(); ii++ )
465  TransformOvalToPolygon( aCornerBuffer, poly[ii-1], poly[ii], width, aError );
466 
467  TransformOvalToPolygon( aCornerBuffer, poly.back(), poly.front(), width, aError );
468  break;
469  }
470 
471  // Generate polygons for the outline + clearance
472  // This code is compatible with a polygon with holes linked to external outline
473  // by overlapping segments.
474 
475  // Insert the initial polygon:
476  aCornerBuffer.NewOutline();
477 
478  for( wxPoint& point : poly )
479  aCornerBuffer.Append( point.x, point.y );
480 
481  if( width != 0 ) // Add thick outlines
482  {
483  wxPoint pt1( poly[ poly.size() - 1] );
484 
485  for( wxPoint pt2 : poly )
486  {
487  if( pt2 != pt1 )
488  TransformSegmentToPolygon( aCornerBuffer, pt1, pt2, aError, width );
489 
490  pt1 = pt2;
491  }
492  }
493  }
494  break;
495 
496  case S_CURVE: // Bezier curve
497  {
498  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
499  BEZIER_POLY converter( ctrlPoints );
500  std::vector< wxPoint> poly;
501  converter.GetPoly( poly, m_Width );
502 
503  if( width != 0 )
504  {
505  for( unsigned ii = 1; ii < poly.size(); ii++ )
506  TransformSegmentToPolygon( aCornerBuffer, poly[ii-1], poly[ii], aError, width );
507  }
508  }
509  break;
510 
511  default:
512  break;
513  }
514 }
515 
516 
518  int aClearanceValue, int aError,
519  bool ignoreLineWidth ) const
520 {
521  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for tracks." );
522 
523  switch( Type() )
524  {
525  case PCB_VIA_T:
526  {
527  int radius = ( m_Width / 2 ) + aClearanceValue;
528  TransformCircleToPolygon( aCornerBuffer, m_Start, radius, aError );
529  }
530  break;
531 
532  default:
533  {
534  int width = m_Width + ( 2 * aClearanceValue );
535  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
536  }
537  break;
538  }
539 }
540 
541 
543  int aClearanceValue, int aError,
544  bool ignoreLineWidth ) const
545 {
546  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for pads." );
547 
548  // minimal segment count to approximate a circle to create the polygonal pad shape
549  // This minimal value is mainly for very small pads, like SM0402.
550  // Most of time pads are using the segment count given by aError value.
551  const int pad_min_seg_per_circle_count = 16;
552  double angle = m_Orient;
553  int dx = (m_Size.x / 2) + aClearanceValue;
554  int dy = (m_Size.y / 2) + aClearanceValue;
555 
556  wxPoint padShapePos = ShapePos(); // Note: for pad having a shape offset,
557  // the pad position is NOT the shape position
558 
559  switch( GetShape() )
560  {
561  case PAD_SHAPE_CIRCLE:
562  TransformCircleToPolygon( aCornerBuffer, padShapePos, dx, aError );
563  break;
564 
565  case PAD_SHAPE_OVAL:
566 
567  // If the oval is actually a circle (same x/y size), treat it the same
568  if( dx == dy )
569  {
570  TransformCircleToPolygon( aCornerBuffer, padShapePos, dx, aError );
571  }
572  else
573  {
574  int width;
575  wxPoint shape_offset;
576  if( dy > dx ) // Oval pad X/Y ratio for choosing translation axis
577  {
578  shape_offset.y = dy - dx;
579  width = dx * 2;
580  }
581  else //if( dy <= dx )
582  {
583  shape_offset.x = dy - dx;
584  width = dy * 2;
585  }
586 
587  RotatePoint( &shape_offset, angle );
588  wxPoint start = padShapePos - shape_offset;
589  wxPoint end = padShapePos + shape_offset;
590  TransformOvalToPolygon( aCornerBuffer, start, end, width, aError );
591  }
592 
593  break;
594 
595  case PAD_SHAPE_TRAPEZOID:
596  case PAD_SHAPE_RECT:
597  {
598  wxPoint corners[4];
599  BuildPadPolygon( corners, wxSize( 0, 0 ), angle );
600 
601  SHAPE_POLY_SET outline;
602  outline.NewOutline();
603 
604  for( wxPoint& corner : corners )
605  {
606  corner += padShapePos;
607  outline.Append( corner.x, corner.y );
608  }
609 
610  if( aClearanceValue )
611  {
612  int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
613  pad_min_seg_per_circle_count );
614  double correction = GetCircletoPolyCorrectionFactor( numSegs );
615  int clearance = KiROUND( aClearanceValue * correction );
616  outline.Inflate( clearance, numSegs );
617  }
618 
619  aCornerBuffer.Append( outline );
620  }
621  break;
622 
624  case PAD_SHAPE_ROUNDRECT:
625  {
626  int radius = GetRoundRectCornerRadius() + aClearanceValue;
627  int numSegs = std::max( GetArcToSegmentCount( radius, aError, 360.0 ),
628  pad_min_seg_per_circle_count );
629  double correction = GetCircletoPolyCorrectionFactor( numSegs );
630  int clearance = KiROUND( aClearanceValue * correction );
631  wxSize shapesize( m_Size );
632 
633  radius = KiROUND( radius * correction );
634  shapesize.x += clearance * 2;
635  shapesize.y += clearance * 2;
636  bool doChamfer = GetShape() == PAD_SHAPE_CHAMFERED_RECT;
637 
638  SHAPE_POLY_SET outline;
639  TransformRoundChamferedRectToPolygon( outline, padShapePos, shapesize, angle, radius,
640  doChamfer ? GetChamferRectRatio() : 0.0,
641  doChamfer ? GetChamferPositions() : 0, aError );
642 
643  aCornerBuffer.Append( outline );
644  }
645  break;
646 
647  case PAD_SHAPE_CUSTOM:
648  {
649  SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
650  outline.Append( m_customShapeAsPolygon );
652  // TODO: do we need the Simplify() & Fracture() if we're not inflating?
654 
655  if( aClearanceValue )
656  {
657  int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
658  pad_min_seg_per_circle_count );
659  double correction = GetCircletoPolyCorrectionFactor( numSegs );
660  int clearance = KiROUND( aClearanceValue * correction );
661 
662  outline.Inflate( clearance, numSegs );
663  }
664 
666  aCornerBuffer.Append( outline );
667  }
668  break;
669  }
670 }
671 
672 
673 
674 /*
675  * Function BuildPadShapePolygon
676  * Build the corner list of the polygonal shape, depending on shape, clearance and orientation
677  * Note: for round & oval pads this function is equivalent to TransformShapeWithClearanceToPolygon,
678  * but not for other shapes
679  */
680 void D_PAD::BuildPadShapePolygon( SHAPE_POLY_SET& aCornerBuffer, wxSize aInflateValue,
681  int aError ) const
682 {
683  switch( GetShape() )
684  {
685  case PAD_SHAPE_CIRCLE:
686  case PAD_SHAPE_OVAL:
687  case PAD_SHAPE_ROUNDRECT:
689  {
690  // We are using TransformShapeWithClearanceToPolygon to build the shape.
691  // Currently, this method uses only the same inflate value for X and Y dirs.
692  // so because here this is not the case, we use a inflated dummy pad to build
693  // the polygonal shape
694  // TODO: remove this dummy pad when TransformShapeWithClearanceToPolygon will use
695  // a wxSize to inflate the pad size
696  D_PAD dummy( *this );
697  dummy.SetSize( GetSize() + aInflateValue + aInflateValue );
698  dummy.TransformShapeWithClearanceToPolygon( aCornerBuffer, 0 );
699  }
700  break;
701 
702  case PAD_SHAPE_TRAPEZOID:
703  case PAD_SHAPE_RECT:
704  {
705  wxPoint corners[4];
706  wxPoint padShapePos = ShapePos(); // Note: for pad having a shape offset,
707  // the pad position is NOT the shape position
708 
709  aCornerBuffer.NewOutline();
710  BuildPadPolygon( corners, aInflateValue, m_Orient );
711 
712  for( wxPoint& corner : corners )
713  {
714  corner += padShapePos; // Shift origin to position
715  aCornerBuffer.Append( corner.x, corner.y );
716  }
717  }
718  break;
719 
720  case PAD_SHAPE_CUSTOM:
721  {
722  // For a custom shape, that is in fact a polygon (with holes), we use only a single
723  // inflate value (different values for X and Y have no definition for a custom pad).
724  int inflate = ( aInflateValue.x + aInflateValue.y ) / 2;
725 
726  TransformShapeWithClearanceToPolygon( aCornerBuffer, inflate );
727  }
728  break;
729  }
730 }
731 
732 
734  SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aError ) const
735 {
736  wxSize drillsize = GetDrillSize();
737 
738  if( !drillsize.x || !drillsize.y )
739  return false;
740 
741  if( drillsize.x == drillsize.y ) // usual round hole
742  {
743  int radius = ( drillsize.x / 2 ) + aInflateValue;
744  TransformCircleToPolygon( aCornerBuffer, GetPosition(), radius, aError );
745  }
746  else // Oblong hole
747  {
748  wxPoint start, end;
749  int width;
750 
751  GetOblongDrillGeometry( start, end, width );
752 
753  start += GetPosition();
754  end += GetPosition();
755  width += aInflateValue * 2;
756 
757  TransformSegmentToPolygon( aCornerBuffer, start, end, aError, width );
758  }
759 
760  return true;
761 }
762 
763 
765  int aClearanceValue, int aError,
766  bool ignoreLineWidth ) const
767 {
768  wxASSERT_MSG( !ignoreLineWidth, "IgnoreLineWidth has no meaning for zones." );
769 
770  aCornerBuffer = m_FilledPolysList;
772 }
MODULES m_modules
MODULES for components on the board, owned by pointer.
Definition: class_board.h:175
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:186
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
double GetOrientation() const
Definition: class_module.h:215
TEXTE_MODULE & Reference()
Definition: class_module.h:477
wxPoint m_Start
Line start point.
Definition: class_track.h:254
int OutlineCount() const
Returns the number of outlines in the set
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:184
bool IsMirrored() const
Definition: eda_text.h:173
TEXTE_PCB class definition.
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:66
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 GetCenter() const override
Function GetCenter()
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...
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
bool IsVisible() const
Definition: eda_text.h:170
void GetOblongDrillGeometry(wxPoint &aStartPoint, wxPoint &aEndPoint, int &aWidth) const
Function GetOblongDrillGeometry calculates the start point, end point and width of an equivalent segm...
Definition: class_pad.cpp:846
bool BuildPadDrillShapePolygon(SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aError=ARC_HIGH_DEF) const
Function BuildPadDrillShapePolygon Build the Corner list of the polygonal drill shape,...
int color
Definition: DXF_plotter.cpp:61
polygon (not yet used for tracks, but could be in microwave apps)
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:887
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:204
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...
double GetTextAngle() const
Definition: eda_text.h:158
void BuildPadShapePolygon(SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aError=ARC_HIGH_DEF) const
Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape,...
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
PADS m_pads
Definition: class_module.h:686
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
usual segment : line with rounded ends
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...
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:183
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...
TRACKS m_tracks
TRACKS for traces on the board, owned by pointer.
Definition: class_board.h:178
int PointCount() const
Function PointCount()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
Definitions for tracks, vias and zones.
int m_Width
Thickness of track, or via diameter.
Definition: class_track.h:253
int GetBottom() const
Definition: eda_rect.h:124
wxPoint m_BezierC1
Bezier Control Point 1.
int GetChamferPositions() const
has meaning only for chamfered rect pads
Definition: class_pad.h:720
bool IsItalic() const
Definition: eda_text.h:164
const VECTOR2I & CPoint(int aIndex) const
Function Point()
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:948
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:183
#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...
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:476
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:184
TSEGM_2_POLY_PRMS prms
const wxSize & GetTextSize() const
Definition: eda_text.h:223
Arcs (with rounded ends)
wxPoint m_End
Line end point.
Definition: class_track.h:255
double GetChamferRectRatio() const
has meaning only for chamfered rect pads
Definition: class_pad.h:697
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
void TransformSolidAreasShapesToPolygonSet(SHAPE_POLY_SET &aCornerBuffer, int aError=ARC_HIGH_DEF) const
Function TransformSolidAreasShapesToPolygonSet Convert solid areas full shapes to polygon set (the fu...
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 ...
a few functions useful in geometry calculations.
STROKE_T m_Shape
Shape: line, Circle, Arc.
const wxPoint & GetArcStart() const
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.
SHAPE_POLY_SET m_customShapeAsPolygon
for free shape pads: the set of basic shapes, merged as one polygon, in local coordinates,...
Definition: class_pad.h:870
Bezier Curve.
DRAWINGS m_drawings
BOARD_ITEMs for drawings on the board, owned by pointer.
Definition: class_board.h:172
int NewOutline()
Creates a new empty polygon in the set and returns its index
SHAPE_POLY_SET m_FilledPolysList
Definition: class_zone.h:806
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:181
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:143
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aApproxErrorMax, int aMinSegPerCircleCount=16)
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corner...
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
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 Used in filli...
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,...
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.
SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:422
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0,...
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:306
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:570
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
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:61
int GetMinThickness() const
Definition: class_zone.h:186
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...
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:573
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
void GetPositionsOfLinesOfMultilineText(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:384
void TransformGraphicShapesWithClearanceToPolygonSet(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aError=ARC_HIGH_DEF, bool aIncludeText=true) const
function TransformGraphicShapesWithClearanceToPolygonSet generate shapes of graphic items (outlines) ...
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
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:237
int m_Width
thickness of lines ...
Module description (excepted pads)
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
Definition: colors.h:45
double m_Orient
in 1/10 degrees
Definition: class_pad.h:929
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:913
void TransformGraphicTextWithClearanceToPolygonSet(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aError=ARC_HIGH_DEF) const
TransformGraphicTextWithClearanceToPolygonSet This function is the same as TransformGraphicShapesWith...
const wxSize & GetSize() const
Definition: class_pad.h:300
const wxPoint GetPosition() const override
Definition: class_pad.h:241
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
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.
const wxPoint GetPosition() const override
Definition: class_module.h:210
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:123
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...
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:553
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:39