KiCad PCB EDA Suite
plot_brditems_plotter.cpp
Go to the documentation of this file.
1 
7 /*
8  * This program source code file is part of KiCad, a free EDA CAD application.
9  *
10  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, you may find one here:
24  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25  * or you may search the http://www.gnu.org website for the version 2 license,
26  * or you may write to the Free Software Foundation, Inc.,
27  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28  */
29 
30 #include <fctsys.h>
31 #include <common.h>
32 #include <plot_common.h>
33 #include <base_struct.h>
34 #include <drawtxt.h>
35 #include <trigo.h>
36 #include <macros.h>
37 #include <wxBasePcbFrame.h>
38 
39 #include <class_board.h>
40 #include <class_module.h>
41 #include <class_track.h>
42 #include <class_edge_mod.h>
43 #include <class_pcb_text.h>
44 #include <class_zone.h>
45 #include <class_drawsegment.h>
46 #include <class_mire.h>
47 #include <class_dimension.h>
48 
49 #include <pcbnew.h>
50 #include <pcbplot.h>
51 #include <plot_auxiliary_data.h>
52 
53 /* class BRDITEMS_PLOTTER is a helper class to plot board items
54  * and a group of board items
55  */
56 
58 {
59  COLOR4D color = m_board->GetLayerColor( ToLAYER_ID( aLayer ) );
60  if( color == COLOR4D::WHITE )
61  color = COLOR4D( LIGHTGRAY );
62  return color;
63 }
64 
65 
66 void BRDITEMS_PLOTTER::PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode )
67 {
68  wxPoint shape_pos = aPad->ShapePos();
69  GBR_METADATA gbr_metadata;
70 
71  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
72  bool isOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
73  bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
74 
75  gbr_metadata.SetCmpReference( aPad->GetParent()->GetReference() );
76 
77  if( isOnCopperLayer )
78  {
79  gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
80 
81  if( isOnExternalCopperLayer )
82  gbr_metadata.SetPadName( aPad->GetPadName() );
83 
84  gbr_metadata.SetNetName( aPad->GetNetname() );
85 
86  // Some pads are mechanical pads ( through hole or smd )
87  // when this is the case, they have no pad name and/or are not plated.
88  // In this case gerber files have slightly different attributes.
90  aPad->GetPadName().IsEmpty() )
91  gbr_metadata.m_NetlistMetadata.m_NotInNet = true;
92 
93  if( !isOnExternalCopperLayer || !isPadOnBoardTechLayers )
94  {
95  // On internal layers one cannot use the GBR_NETLIST_METADATA::GBR_INFO_FLASHED_PAD
96  // attribute when the component is on an external layer (most of the case)
97  // Also, if a SMD pad is not on a tech layer (masks) use also net+cmp attribute, because
98  // it is not really a pad (can be a "pad", actually a node in a virtual component)
101 
102  if( !isPadOnBoardTechLayers )
103  // such a pad is not soldered and is not a connecting point.
104  // Just set aperture attribute as conductor
105  // If it is a through hole pad, it will be adjusted later
107 
108  switch( aPad->GetAttribute() )
109  {
110  case PAD_ATTRIB_HOLE_NOT_PLATED: // Mechanical pad through hole
112  break;
113 
114  case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
116  break;
117 
118  default:
119  break;
120  }
121  }
122  else // Some attributes are reserved to the external copper layers
123  {
124  switch( aPad->GetAttribute() )
125  {
126  case PAD_ATTRIB_HOLE_NOT_PLATED: // Mechanical pad through hole
128  break;
129 
130  case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
132  break;
133 
134  case PAD_ATTRIB_CONN: // Connector pads have no solder paste.
136  break;
137 
138  case PAD_ATTRIB_SMD: // SMD pads (One external copper layer only) with solder paste
139  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // perhaps a BGA pad
141  else
143  break;
144  }
145  }
146 
149  }
150  else
151  {
153  }
154 
155  // Set plot color (change WHITE to LIGHTGRAY because
156  // the white items are not seen on a white paper or screen
157  m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
158 
159  switch( aPad->GetShape() )
160  {
161  case PAD_SHAPE_CIRCLE:
162  m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &gbr_metadata );
163  break;
164 
165  case PAD_SHAPE_OVAL:
166  m_plotter->FlashPadOval( shape_pos, aPad->GetSize(),
167  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
168  break;
169 
170  case PAD_SHAPE_TRAPEZOID:
171  {
172  wxPoint coord[4];
173  aPad->BuildPadPolygon( coord, wxSize(0,0), 0 );
174  m_plotter->FlashPadTrapez( shape_pos, coord,
175  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
176  }
177  break;
178 
179  case PAD_SHAPE_ROUNDRECT:
180  m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
181  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
182  break;
183 
184  case PAD_SHAPE_RECT:
185  default:
186  m_plotter->FlashPadRect( shape_pos, aPad->GetSize(),
187  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
188  break;
189  }
190 }
191 
192 
194 {
195  // see if we want to plot VALUE and REF fields
196  bool trace_val = GetPlotValue();
197  bool trace_ref = GetPlotReference();
198 
199  TEXTE_MODULE* textModule = &aModule->Reference();
200  LAYER_NUM textLayer = textModule->GetLayer();
201 
202  if( textLayer >= LAYER_ID_COUNT ) // how will this ever be true?
203  return false;
204 
205  if( !m_layerMask[textLayer] )
206  trace_ref = false;
207 
208  if( !textModule->IsVisible() && !GetPlotInvisibleText() )
209  trace_ref = false;
210 
211  textModule = &aModule->Value();
212  textLayer = textModule->GetLayer();
213 
214  if( textLayer > LAYER_ID_COUNT ) // how will this ever be true?
215  return false;
216 
217  if( !m_layerMask[textLayer] )
218  trace_val = false;
219 
220  if( !textModule->IsVisible() && !GetPlotInvisibleText() )
221  trace_val = false;
222 
223  // Plot text fields, if allowed
224  if( trace_ref )
225  {
226  if( GetReferenceColor() == COLOR4D::UNSPECIFIED )
227  PlotTextModule( &aModule->Reference(), getColor( textLayer ) );
228  else
229  PlotTextModule( &aModule->Reference(), GetReferenceColor() );
230  }
231 
232  if( trace_val )
233  {
234  if( GetValueColor() == COLOR4D::UNSPECIFIED )
235  PlotTextModule( &aModule->Value(), getColor( textLayer ) );
236  else
237  PlotTextModule( &aModule->Value(), GetValueColor() );
238  }
239 
240  for( BOARD_ITEM *item = aModule->GraphicalItems().GetFirst(); item; item = item->Next() )
241  {
242  textModule = dyn_cast<TEXTE_MODULE*>( item );
243 
244  if( !textModule )
245  continue;
246 
247  if( !textModule->IsVisible() )
248  continue;
249 
250  textLayer = textModule->GetLayer();
251 
252  if( textLayer >= LAYER_ID_COUNT )
253  return false;
254 
255  if( !m_layerMask[textLayer] )
256  continue;
257 
258  PlotTextModule( textModule, getColor( textLayer ) );
259  }
260 
261  return true;
262 }
263 
264 
265 // plot items like text and graphics, but not tracks and module
267 {
268  for( BOARD_ITEM* item = m_board->m_Drawings; item; item = item->Next() )
269  {
270  switch( item->Type() )
271  {
272  case PCB_LINE_T:
273  PlotDrawSegment( (DRAWSEGMENT*) item);
274  break;
275 
276  case PCB_TEXT_T:
277  PlotTextePcb( (TEXTE_PCB*) item );
278  break;
279 
280  case PCB_DIMENSION_T:
281  PlotDimension( (DIMENSION*) item );
282  break;
283 
284  case PCB_TARGET_T:
285  PlotPcbTarget( (PCB_TARGET*) item );
286  break;
287 
288  case PCB_MARKER_T:
289  default:
290  break;
291  }
292  }
293 }
294 
296 {
297  wxSize size;
298  wxPoint pos;
299  double orient;
300  int thickness;
301 
302  if( aColor == COLOR4D::WHITE )
303  aColor = COLOR4D( LIGHTGRAY );
304 
305  m_plotter->SetColor( aColor );
306 
307  // calculate some text parameters :
308  size = pt_texte->GetTextSize();
309  pos = pt_texte->GetTextPos();
310 
311  orient = pt_texte->GetDrawRotation();
312 
313  thickness = pt_texte->GetThickness();
314 
315  if( pt_texte->IsMirrored() )
316  size.x = -size.x; // Text is mirrored
317 
318  // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
319  // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
320  // (like bold text) and we manage the thickness.
321  // So we set bold flag to true
322  bool allow_bold = pt_texte->IsBold() || thickness;
323 
324  GBR_METADATA gbr_metadata;
326  MODULE* parent = static_cast<MODULE*> ( pt_texte->GetParent() );
327  gbr_metadata.SetCmpReference( parent->GetReference() );
328 
329  m_plotter->Text( pos, aColor,
330  pt_texte->GetShownText(),
331  orient, size,
332  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
333  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
334 }
335 
336 
338 {
339  if( !m_layerMask[aDim->GetLayer()] )
340  return;
341 
342  DRAWSEGMENT draw;
343 
344  draw.SetWidth( aDim->GetWidth() );
345  draw.SetLayer( aDim->GetLayer() );
346 
347  COLOR4D color = aDim->GetBoard()->GetLayerColor( aDim->GetLayer() );
348 
349  // Set plot color (change WHITE to LIGHTGRAY because
350  // the white items are not seen on a white paper or screen
351  m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
352 
353  PlotTextePcb( &aDim->Text() );
354 
355  draw.SetStart( aDim->m_crossBarO );
356  draw.SetEnd( aDim->m_crossBarF );
357  PlotDrawSegment( &draw );
358 
359  draw.SetStart( aDim->m_featureLineGO);
360  draw.SetEnd( aDim->m_featureLineGF );
361  PlotDrawSegment( &draw );
362 
363  draw.SetStart( aDim->m_featureLineDO );
364  draw.SetEnd( aDim->m_featureLineDF );
365  PlotDrawSegment( &draw );
366 
367  draw.SetStart( aDim->m_crossBarF );
368  draw.SetEnd( aDim->m_arrowD1F );
369  PlotDrawSegment( &draw );
370 
371  draw.SetStart( aDim->m_crossBarF );
372  draw.SetEnd( aDim->m_arrowD2F );
373  PlotDrawSegment( &draw );
374 
375  draw.SetStart( aDim->m_crossBarO );
376  draw.SetEnd( aDim->m_arrowG1F );
377  PlotDrawSegment( &draw );
378 
379  draw.SetStart( aDim->m_crossBarO );
380  draw.SetEnd( aDim->m_arrowG2F );
381  PlotDrawSegment( &draw );
382 }
383 
384 
386 {
387  int dx1, dx2, dy1, dy2, radius;
388 
389  if( !m_layerMask[aMire->GetLayer()] )
390  return;
391 
392  m_plotter->SetColor( getColor( aMire->GetLayer() ) );
393 
394  DRAWSEGMENT draw;
395 
396  draw.SetShape( S_CIRCLE );
397  draw.SetWidth( aMire->GetWidth() );
398  draw.SetLayer( aMire->GetLayer() );
399  draw.SetStart( aMire->GetPosition() );
400  radius = aMire->GetSize() / 3;
401 
402  if( aMire->GetShape() ) // shape X
403  radius = aMire->GetSize() / 2;
404 
405  // Draw the circle
406  draw.SetEnd( wxPoint( draw.GetStart().x + radius, draw.GetStart().y ));
407 
408  PlotDrawSegment( &draw );
409 
410  draw.SetShape( S_SEGMENT );
411 
412  radius = aMire->GetSize() / 2;
413  dx1 = radius;
414  dy1 = 0;
415  dx2 = 0;
416  dy2 = radius;
417 
418  if( aMire->GetShape() ) // Shape X
419  {
420  dx1 = dy1 = radius;
421  dx2 = dx1;
422  dy2 = -dy1;
423  }
424 
425  wxPoint mirePos( aMire->GetPosition() );
426 
427  // Draw the X or + shape:
428  draw.SetStart( wxPoint( mirePos.x - dx1, mirePos.y - dy1 ));
429  draw.SetEnd( wxPoint( mirePos.x + dx1, mirePos.y + dy1 ));
430  PlotDrawSegment( &draw );
431 
432  draw.SetStart( wxPoint( mirePos.x - dx2, mirePos.y - dy2 ));
433  draw.SetEnd( wxPoint( mirePos.x + dx2, mirePos.y + dy2 ));
434  PlotDrawSegment( &draw );
435 }
436 
437 
438 // Plot footprints graphic items (outlines)
440 {
441  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
442  {
443  for( BOARD_ITEM* item = module->GraphicalItems().GetFirst(); item; item = item->Next() )
444  {
445  EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item );
446 
447  if( edge && m_layerMask[edge->GetLayer()] )
448  Plot_1_EdgeModule( edge );
449  }
450  }
451 }
452 
453 
454 //* Plot a graphic item (outline) relative to a footprint
456 {
457  int type_trace; // Type of item to plot.
458  int thickness; // Segment thickness.
459  int radius; // Circle radius.
460 
461  if( aEdge->Type() != PCB_MODULE_EDGE_T )
462  return;
463 
464  m_plotter->SetColor( getColor( aEdge->GetLayer() ) );
465 
466  type_trace = aEdge->GetShape();
467  thickness = aEdge->GetWidth();
468 
469  wxPoint pos( aEdge->GetStart() );
470  wxPoint end( aEdge->GetEnd() );
471 
472  GBR_METADATA gbr_metadata;
474  MODULE* parent = static_cast<MODULE*> ( aEdge->GetParent() );
475  gbr_metadata.SetCmpReference( parent->GetReference() );
476 
477  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
478 
479  if( isOnCopperLayer )
480  {
481  gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP );
482  }
483  else if( aEdge->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers
484  {
485  gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
486  }
487 
488  switch( type_trace )
489  {
490  case S_SEGMENT:
491  m_plotter->ThickSegment( pos, end, thickness, GetPlotMode(), &gbr_metadata );
492  break;
493 
494  case S_CIRCLE:
495  radius = KiROUND( GetLineLength( end, pos ) );
496  m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
497  break;
498 
499  case S_ARC:
500  {
501  radius = KiROUND( GetLineLength( end, pos ) );
502  double startAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
503  double endAngle = startAngle + aEdge->GetAngle();
504 
505  m_plotter->ThickArc( pos, -endAngle, -startAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
506  }
507  break;
508 
509  case S_POLYGON:
510  {
511  const std::vector<wxPoint>& polyPoints = aEdge->GetPolyPoints();
512 
513  if( polyPoints.size() <= 1 ) // Malformed polygon
514  break;
515 
516  // We must compute true coordinates from m_PolyList
517  // which are relative to module position, orientation 0
518  MODULE* module = aEdge->GetParentModule();
519 
520  std::vector< wxPoint > cornerList;
521 
522  cornerList.reserve( polyPoints.size() );
523 
524  for( unsigned ii = 0; ii < polyPoints.size(); ii++ )
525  {
526  wxPoint corner = polyPoints[ii];
527 
528  if( module )
529  {
530  RotatePoint( &corner, module->GetOrientation() );
531  corner += module->GetPosition();
532  }
533 
534  cornerList.push_back( corner );
535  }
536 
537  m_plotter->PlotPoly( cornerList, FILLED_SHAPE, thickness, &gbr_metadata );
538  }
539  break;
540  }
541 }
542 
543 
544 // Plot a PCB Text, i.e. a text found on a copper or technical layer
546 {
547  double orient;
548  int thickness;
549  wxPoint pos;
550  wxSize size;
551  wxString shownText( pt_texte->GetShownText() );
552 
553  if( shownText.IsEmpty() )
554  return;
555 
556  if( !m_layerMask[pt_texte->GetLayer()] )
557  return;
558 
559  GBR_METADATA gbr_metadata;
560 
561  if( IsCopperLayer( pt_texte->GetLayer() ) )
562  {
564  }
565 
566  m_plotter->SetColor( getColor( pt_texte->GetLayer() ) );
567 
568  size = pt_texte->GetTextSize();
569  pos = pt_texte->GetTextPos();
570  orient = pt_texte->GetTextAngle();
571  thickness = pt_texte->GetThickness();
572 
573  if( pt_texte->IsMirrored() )
574  size.x = -size.x;
575 
576  // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
577  // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
578  // (like bold text) and we manage the thickness.
579  // So we set bold flag to true
580  bool allow_bold = pt_texte->IsBold() || thickness;
581 
582  if( pt_texte->IsMultilineAllowed() )
583  {
584  std::vector<wxPoint> positions;
585  wxArrayString strings_list;
586  wxStringSplit( shownText, strings_list, '\n' );
587  positions.reserve( strings_list.Count() );
588 
589  pt_texte->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
590 
591  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
592  {
593  wxString& txt = strings_list.Item( ii );
594  m_plotter->Text( positions[ii], COLOR4D::UNSPECIFIED, txt, orient, size,
595  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
596  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
597  }
598  }
599  else
600  {
601  m_plotter->Text( pos, COLOR4D::UNSPECIFIED, shownText, orient, size,
602  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
603  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
604  }
605 }
606 
607 
608 /* Plot areas (given by .m_FilledPolysList member) in a zone
609  */
611 {
612  const SHAPE_POLY_SET& polysList = aZone->GetFilledPolysList();
613 
614  if( polysList.IsEmpty() )
615  return;
616 
617  GBR_METADATA gbr_metadata;
618 
619  bool isOnCopperLayer = aZone->IsOnCopperLayer();
620 
621  if( isOnCopperLayer )
622  {
623  gbr_metadata.SetNetName( aZone->GetNetname() );
624 
625  // Zones with no net name can exist.
626  // they are not used to connect items, so the aperture attribute cannot
627  // be set as conductor
628  if( aZone->GetNetname().IsEmpty() )
630  else
631  {
634  }
635  }
636 
637  // We need a buffer to store corners coordinates:
638  static std::vector< wxPoint > cornerList;
639  cornerList.clear();
640 
641  m_plotter->SetColor( getColor( aZone->GetLayer() ) );
642 
643  /* Plot all filled areas: filled areas have a filled area and a thick
644  * outline we must plot the filled area itself ( as a filled polygon
645  * OR a set of segments ) and plot the thick outline itself
646  *
647  * in non filled mode the outline is plotted, but not the filling items
648  */
649  for( auto ic = polysList.CIterate(); ic; ++ic )
650  {
651  wxPoint pos( ic->x, ic->y );
652  cornerList.push_back( pos );
653 
654  if( ic.IsEndContour() ) // Plot the current filled area outline
655  {
656  // First, close the outline
657  if( cornerList[0] != cornerList[cornerList.size() - 1] )
658  {
659  cornerList.push_back( cornerList[0] );
660  }
661 
662  // Plot the current filled area and its outline
663  if( GetPlotMode() == FILLED )
664  {
665  // Plot the filled area polygon.
666  // The area can be filled by segments or uses solid polygons
667  if( aZone->GetFillMode() == 0 ) // We are using solid polygons
668  {
669  m_plotter->PlotPoly( cornerList, FILLED_SHAPE, aZone->GetMinThickness(), &gbr_metadata );
670  }
671  else // We are using areas filled by segments: plot segments and outline
672  {
673  for( unsigned iseg = 0; iseg < aZone->FillSegments().size(); iseg++ )
674  {
675  wxPoint start = aZone->FillSegments()[iseg].m_Start;
676  wxPoint end = aZone->FillSegments()[iseg].m_End;
677  m_plotter->ThickSegment( start, end,
678  aZone->GetMinThickness(),
679  GetPlotMode(), &gbr_metadata );
680  }
681 
682  // Plot the area outline only
683  if( aZone->GetMinThickness() > 0 )
684  m_plotter->PlotPoly( cornerList, NO_FILL, aZone->GetMinThickness() );
685  }
686  }
687  else
688  {
689  if( aZone->GetMinThickness() > 0 )
690  {
691  for( unsigned jj = 1; jj<cornerList.size(); jj++ )
692  m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
693  aZone->GetMinThickness(),
694  GetPlotMode(), &gbr_metadata );
695  }
696 
698  }
699 
700  cornerList.clear();
701  }
702  }
703 }
704 
705 
706 /* Plot items type DRAWSEGMENT on layers allowed by aLayerMask
707  */
709 {
710  if( !m_layerMask[aSeg->GetLayer()] )
711  return;
712 
713  int radius = 0;
714  double StAngle = 0, EndAngle = 0;
715  int thickness = aSeg->GetWidth();
716 
717  m_plotter->SetColor( getColor( aSeg->GetLayer() ) );
718 
719  wxPoint start( aSeg->GetStart() );
720  wxPoint end( aSeg->GetEnd() );
721 
722  GBR_METADATA gbr_metadata;
723 
724  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
725 
726  if( isOnCopperLayer && aSeg->GetLayer() == Edge_Cuts ) // can happens when plotting copper layers
727  {
729  }
730 
731  switch( aSeg->GetShape() )
732  {
733  case S_CIRCLE:
734  radius = KiROUND( GetLineLength( end, start ) );
735  m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
736  break;
737 
738  case S_ARC:
739  radius = KiROUND( GetLineLength( end, start ) );
740  StAngle = ArcTangente( end.y - start.y, end.x - start.x );
741  EndAngle = StAngle + aSeg->GetAngle();
742  m_plotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
743  break;
744 
745  case S_CURVE:
746  {
747  m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
748  const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints();
749 
750  for( unsigned i = 1; i < bezierPoints.size(); i++ )
751  m_plotter->ThickSegment( bezierPoints[i - 1], bezierPoints[i],
752  thickness, GetPlotMode(), &gbr_metadata );
753  }
754  break;
755 
756  default:
757  m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata );
758  }
759 }
760 
761 
766  const wxPoint &aDrillPos, wxSize aDrillSize,
767  const wxSize &aPadSize,
768  double aOrientation, int aSmallDrill )
769 {
770  // Small drill marks have no significance when applied to slots
771  if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
772  aDrillSize.x = std::min( aSmallDrill, aDrillSize.x );
773 
774  // Round holes only have x diameter, slots have both
775  aDrillSize.x -= getFineWidthAdj();
776  aDrillSize.x = Clamp( 1, aDrillSize.x, aPadSize.x - 1 );
777 
778  if( aDrillShape == PAD_DRILL_SHAPE_OBLONG )
779  {
780  aDrillSize.y -= getFineWidthAdj();
781  aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 );
782  m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL );
783  }
784  else
785  m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL );
786 }
787 
788 
790 {
791  /* If small drills marks were requested prepare a clamp value to pass
792  to the helper function */
793  int small_drill = (GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) ?
794  SMALL_DRILL : 0;
795 
796  /* In the filled trace mode drill marks are drawn white-on-black to scrape
797  the underlying pad. This works only for drivers supporting color change,
798  obviously... it means that:
799  - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
800  - In HPGL you can't see them
801  - In gerbers you can't see them, too. This is arguably the right thing to
802  do since having drill marks and high speed drill stations is a sure
803  recipe for broken tools and angry manufacturers. If you *really* want them
804  you could start a layer with negative polarity to scrape the film.
805  - In DXF they go into the 'WHITE' layer. This could be useful.
806  */
807  if( GetPlotMode() == FILLED )
809 
810  for( TRACK *pts = m_board->m_Track; pts != NULL; pts = pts->Next() )
811  {
812  const VIA* via = dyn_cast<const VIA*>( pts );
813 
814  if( via )
816  wxSize( via->GetDrillValue(), 0 ),
817  wxSize( via->GetWidth(), 0 ), 0, small_drill );
818  }
819 
820  for( MODULE *Module = m_board->m_Modules; Module != NULL; Module = Module->Next() )
821  {
822  for( D_PAD *pad = Module->Pads(); pad != NULL; pad = pad->Next() )
823  {
824  if( pad->GetDrillSize().x == 0 )
825  continue;
826 
827  plotOneDrillMark( pad->GetDrillShape(),
828  pad->GetPosition(), pad->GetDrillSize(),
829  pad->GetSize(), pad->GetOrientation(),
830  small_drill );
831  }
832  }
833 
834  if( GetPlotMode() == FILLED )
836 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Function wxStringSplit splits aString to a string list separated at aSplitter.
Definition: common.cpp:137
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu LAYER_IDs.
Definition: lset.cpp:638
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void SetPadName(const wxString &aPadname)
#define SMALL_DRILL
Definition: pcbplot.h:72
BOARD_ITEM_CONTAINER * GetParent() const
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
TEXTE_MODULE & Reference()
Definition: class_module.h:455
void SetShape(STROKE_T aShape)
PCB_TARGET class definition.
aperture used for edge connecto pad (outer layers)
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Function GetLineLength returns the length of a line segment defined by aPointA and aPointB...
Definition: trigo.h:183
bool IsMultilineAllowed() const
Definition: eda_text.h:188
double GetDrawRotation() const
const T & Clamp(const T &lower, const T &value, const T &upper)
Function Clamp limits value within the range lower <= value <= upper.
Definition: macros.h:127
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:238
TEXTE_PCB class definition.
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
bool IsItalic() const
Definition: eda_text.h:170
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
int GetMinThickness() const
Definition: class_zone.h:209
wxPoint m_crossBarF
int GetWidth() const
Definition: class_mire.h:72
print info associated to a component (TO.C attribute)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
wxPoint m_arrowD1F
virtual void SetColor(COLOR4D color)=0
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
virtual void ThickCircle(const wxPoint &pos, int diametre, int width, EDA_DRAW_MODE_T tracemode, void *aData)
void PlotPad(D_PAD *aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode)
Plot a pad.
int GetWidth() const
void SetNetAttribType(int aNetAttribType)
Class BOARD to handle a board.
void PlotDimension(DIMENSION *Dimension)
const wxPoint & GetPosition() const override
Definition: class_module.h:143
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:351
polygon (not yet used for tracks, but could be in microwave apps)
COLOR4D GetLayerColor(LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
MODULE * Next() const
Definition: class_module.h:99
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
MODULE * GetParent() const
Definition: class_pad.h:108
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:59
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
PLOTTER * m_plotter
Definition: pcbplot.h:78
void PlotDrillMarks()
Function PlotDrillMarks Draw a drill mark for pads and vias.
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
aperture used for through hole component on outer layer
bool PlotAllTextsModule(MODULE *aModule)
Classes to handle copper zones.
usual segment : line with rounded ends
const std::vector< wxPoint > & GetPolyPoints() const
wxPoint m_featureLineDF
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
PAD_DRILL_SHAPE_T
Enum PAD_DRILL_SHAPE_T is the set of pad drill shapes, used with D_PAD::{Set,Get}DrillShape() ...
Definition: pad_shapes.h:44
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
bool GetPlotValue() const
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
BOARD * m_board
Definition: pcbplot.h:79
double GetTextAngle() const
Definition: eda_text.h:164
bool IsBold() const
Definition: eda_text.h:173
Functions relatives to tracks, vias and segments used to fill zones.
virtual void ThickArc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, int width, EDA_DRAW_MODE_T tracemode, void *aData)
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
This file contains miscellaneous commonly used macros and functions.
virtual void Text(const wxPoint &aPos, const 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, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: drawtxt.cpp:227
void PlotFilledAreas(ZONE_CONTAINER *aZone)
Board plot function definition file.
wxPoint m_featureLineGO
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
BOARD_ITEM * Next() const
std::vector< SEGMENT > & FillSegments()
Definition: class_zone.h:244
DIMENSION class definition.
aperture used for BGA pad with a solder mask defined by the solder mask
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadCircle
DrillMarksType GetDrillMarksType() const
STROKE_T GetShape() const
int GetShape() const
Definition: class_mire.h:66
Classes used in Pcbnew, CvPcb and GerbView.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:271
void PlotPcbTarget(PCB_TARGET *PtMire)
double GetOrientation() const
Definition: class_module.h:147
Class SHAPE_POLY_SET.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
EDA_DRAW_MODE_T
Definition: eda_text.h:62
void PlotBoardGraphicItems()
plot items like text and graphics, but not tracks and modules
const wxPoint & GetStart() const
Definition: class_track.h:120
Arcs (with rounded ends)
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadRoundRect
COLOR4D GetReferenceColor() const
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:235
wxPoint m_arrowG1F
void Plot_1_EdgeModule(EDGE_MODULE *aEdge)
wxPoint m_arrowD2F
wxPoint m_arrowG2F
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
D_PAD * Next() const
Definition: class_pad.h:106
static LSET ExternalCuMask()
Function ExternalCuMask returns a mask holding the Front and Bottom layers.
Definition: lset.cpp:668
const wxSize & GetSize() const
Definition: class_pad.h:182
DLIST< BOARD_ITEM > m_Drawings
Definition: class_board.h:242
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a ...
Definition: eda_text.cpp:327
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
aperture used for mechanical pads (NPTH)
Bezier Curve.
bool GetPlotReference() const
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:60
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:587
COLOR4D GetColor() const
aperture used for connected items like tracks (not vias)
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:113
void SetStart(const wxPoint &aStart)
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
const std::vector< wxPoint > & GetBezierPoints() const
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
void SetNetName(const wxString &aNetname)
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadRect
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.h:179
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:111
const wxPoint & GetPosition() const override
Definition: class_mire.h:63
TRACK * Next() const
Definition: class_track.h:97
double GetAngle() const
bool GetPlotInvisibleText() const
const wxString & GetNetname() const
Function GetNetname.
int GetFillMode() const
Definition: class_zone.h:186
LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:766
Class to handle a graphic segment.
void plotOneDrillMark(PAD_DRILL_SHAPE_T aDrillShape, const wxPoint &aDrillPos, wxSize aDrillSize, const wxSize &aPadSize, double aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:411
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadOval
bool IsMirrored() const
Definition: eda_text.h:179
DLIST< MODULE > m_Modules
Definition: class_board.h:243
bool IsVisible() const
Definition: eda_text.h:176
int GetWidth() const
Definition: class_track.h:114
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData)
LSET m_layerMask
Definition: pcbplot.h:80
TEXTE_PCB & Text()
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:214
EDA_DRAW_MODE_T GetPlotMode() const
Usual pad.
Definition: pad_shapes.h:58
aperture used for SMD pad with a solder mask defined by the solder mask
The common library.
int GetWidth() const
void PlotTextePcb(TEXTE_PCB *pt_texte)
Definition: colors.h:49
wxPoint ShapePos() const
Definition: class_pad.cpp:367
void SetEnd(const wxPoint &aEnd)
COLOR4D GetValueColor() const
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
int GetSize() const
Definition: class_mire.h:69
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
This file is part of the common libary.
static LSET AllBoardTechMask()
Function AllTechMask returns a mask holding board technical layers (no CU layer) on both side...
Definition: lset.cpp:715
wxPoint m_crossBarO
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
bool m_NotInNet
true if a pad of a footprint cannot be connected (for instance a mechanical NPTH, ot a not named pad)...
wxString GetPadName() const
Definition: class_pad.cpp:382
int getFineWidthAdj()
Definition: pcbplot.h:95
DLIST< TRACK > m_Track
Definition: class_board.h:244
GBR_NETLIST_METADATA m_NetlistMetadata
Module description (excepted pads)
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
const wxSize & GetTextSize() const
Definition: eda_text.h:215
Basic classes for most KiCad items.
aperture used for not connected items (texts, outlines on copper)
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadTrapez flash a trapezoidal pad
wxPoint m_featureLineDO
print info associated to a net (TO.N attribute)
void SetCmpReference(const wxString &aComponentRef)
COLOR4D getColor(LAYER_NUM aLayer)
Function getColor.
Class DIMENSION.
#define GBR_NETINFO_ALL
#define min(a, b)
Definition: auxiliary.h:85
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
void PlotDrawSegment(DRAWSEGMENT *PtSegm)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint m_featureLineGF
void SetWidth(int aWidth)
void PlotTextModule(TEXTE_MODULE *aTextMod, COLOR4D aColor)