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-2017 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 <class_plotter.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_pcb_target.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 {
60 
61  // A hack to avoid plotting ahite itmen in white color, expecting the paper
62  // is also white: use a non white color:
63  if( color == COLOR4D::WHITE )
64  color = COLOR4D( LIGHTGRAY );
65 
66  return color;
67 }
68 
69 
70 void BRDITEMS_PLOTTER::PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode )
71 {
72  wxPoint shape_pos = aPad->ShapePos();
73  GBR_METADATA gbr_metadata;
74 
75  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
76  bool isOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
77  bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
78 
79  gbr_metadata.SetCmpReference( aPad->GetParent()->GetReference() );
80 
81  if( isOnCopperLayer )
82  {
83  gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
84  gbr_metadata.SetCopper( true );
85 
86  if( isOnExternalCopperLayer )
87  gbr_metadata.SetPadName( aPad->GetName() );
88 
89  gbr_metadata.SetNetName( aPad->GetNetname() );
90 
91  // Some pads are mechanical pads ( through hole or smd )
92  // when this is the case, they have no pad name and/or are not plated.
93  // In this case gerber files have slightly different attributes.
95  aPad->GetName().IsEmpty() )
96  gbr_metadata.m_NetlistMetadata.m_NotInNet = true;
97 
98  if( !isOnExternalCopperLayer || !isPadOnBoardTechLayers )
99  {
100  // On internal layers one cannot use the GBR_NETLIST_METADATA::GBR_INFO_FLASHED_PAD
101  // attribute when the component is on an external layer (most of the case)
102  // Also, if a SMD pad is not on a tech layer (masks) use also net+cmp attribute, because
103  // it is not really a pad (can be a "pad", actually a node in a virtual component)
106 
107  if( !isPadOnBoardTechLayers )
108  // such a pad is not soldered and is not a connecting point.
109  // Just set aperture attribute as conductor
110  // If it is a through hole pad, it will be adjusted later
112 
113  switch( aPad->GetAttribute() )
114  {
115  case PAD_ATTRIB_HOLE_NOT_PLATED: // Mechanical pad through hole
117  break;
118 
119  case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
121  break;
122 
123  default:
124  break;
125  }
126  }
127  else // Some attributes are reserved to the external copper layers
128  {
129  switch( aPad->GetAttribute() )
130  {
131  case PAD_ATTRIB_HOLE_NOT_PLATED: // Mechanical pad through hole
133  break;
134 
135  case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
137  break;
138 
139  case PAD_ATTRIB_CONN: // Connector pads have no solder paste.
141  break;
142 
143  case PAD_ATTRIB_SMD: // SMD pads (One external copper layer only) with solder paste
144  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // perhaps a BGA pad
146  else
148  break;
149  }
150  }
151 
154  }
155  else
156  {
158  }
159 
160  // Set plot color (change WHITE to LIGHTGRAY because
161  // the white items are not seen on a white paper or screen
162  m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
163 
164  switch( aPad->GetShape() )
165  {
166  case PAD_SHAPE_CIRCLE:
167  m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &gbr_metadata );
168  break;
169 
170  case PAD_SHAPE_OVAL:
171  m_plotter->FlashPadOval( shape_pos, aPad->GetSize(),
172  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
173  break;
174 
175  case PAD_SHAPE_TRAPEZOID:
176  {
177  wxPoint coord[4];
178  aPad->BuildPadPolygon( coord, wxSize(0,0), 0 );
179  m_plotter->FlashPadTrapez( shape_pos, coord,
180  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
181  }
182  break;
183 
184  case PAD_SHAPE_ROUNDRECT:
185  m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
186  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
187  break;
188 
189  case PAD_SHAPE_CUSTOM:
190  {
191  SHAPE_POLY_SET polygons;
192  aPad->MergePrimitivesAsPolygon(&polygons, 64 );
193 
194  if( polygons.OutlineCount() == 0 )
195  break;
196 
197  aPad->CustomShapeAsPolygonToBoardPosition( &polygons, shape_pos, aPad->GetOrientation() );
198  m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), &polygons, aPlotMode, &gbr_metadata );
199  }
200  break;
201 
202  case PAD_SHAPE_RECT:
203  default:
204  m_plotter->FlashPadRect( shape_pos, aPad->GetSize(),
205  aPad->GetOrientation(), aPlotMode, &gbr_metadata );
206  break;
207  }
208 }
209 
210 
212 {
213  // see if we want to plot VALUE and REF fields
214  bool trace_val = GetPlotValue();
215  bool trace_ref = GetPlotReference();
216 
217  TEXTE_MODULE* textModule = &aModule->Reference();
218  LAYER_NUM textLayer = textModule->GetLayer();
219 
220  if( textLayer >= PCB_LAYER_ID_COUNT ) // how will this ever be true?
221  return false;
222 
223  if( !m_layerMask[textLayer] )
224  trace_ref = false;
225 
226  if( !textModule->IsVisible() && !GetPlotInvisibleText() )
227  trace_ref = false;
228 
229  textModule = &aModule->Value();
230  textLayer = textModule->GetLayer();
231 
232  if( textLayer > PCB_LAYER_ID_COUNT ) // how will this ever be true?
233  return false;
234 
235  if( !m_layerMask[textLayer] )
236  trace_val = false;
237 
238  if( !textModule->IsVisible() && !GetPlotInvisibleText() )
239  trace_val = false;
240 
241  // Plot text fields, if allowed
242  if( trace_ref )
243  {
244  PlotTextModule( &aModule->Reference(), getColor( textLayer ) );
245  }
246 
247  if( trace_val )
248  {
249  PlotTextModule( &aModule->Value(), getColor( textLayer ) );
250  }
251 
252  for( BOARD_ITEM* item = aModule->GraphicalItemsList().GetFirst(); item; item = item->Next() )
253  {
254  textModule = dyn_cast<TEXTE_MODULE*>( item );
255 
256  if( !textModule )
257  continue;
258 
259  if( !textModule->IsVisible() )
260  continue;
261 
262  textLayer = textModule->GetLayer();
263 
264  if( textLayer >= PCB_LAYER_ID_COUNT )
265  return false;
266 
267  if( !m_layerMask[textLayer] )
268  continue;
269 
270  PlotTextModule( textModule, getColor( textLayer ) );
271  }
272 
273  return true;
274 }
275 
276 
277 // plot items like text and graphics, but not tracks and module
279 {
280  for( auto item : m_board->Drawings() )
281  {
282  switch( item->Type() )
283  {
284  case PCB_LINE_T:
285  PlotDrawSegment( (DRAWSEGMENT*) item);
286  break;
287 
288  case PCB_TEXT_T:
289  PlotTextePcb( (TEXTE_PCB*) item );
290  break;
291 
292  case PCB_DIMENSION_T:
293  PlotDimension( (DIMENSION*) item );
294  break;
295 
296  case PCB_TARGET_T:
297  PlotPcbTarget( (PCB_TARGET*) item );
298  break;
299 
300  case PCB_MARKER_T:
301  default:
302  break;
303  }
304  }
305 }
306 
308 {
309  wxSize size;
310  wxPoint pos;
311  double orient;
312  int thickness;
313 
314  if( aColor == COLOR4D::WHITE )
315  aColor = COLOR4D( LIGHTGRAY );
316 
317  m_plotter->SetColor( aColor );
318 
319  // calculate some text parameters :
320  size = pt_texte->GetTextSize();
321  pos = pt_texte->GetTextPos();
322 
323  orient = pt_texte->GetDrawRotation();
324 
325  thickness = pt_texte->GetThickness();
326 
327  if( pt_texte->IsMirrored() )
328  size.x = -size.x; // Text is mirrored
329 
330  // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
331  // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
332  // (like bold text) and we manage the thickness.
333  // So we set bold flag to true
334  bool allow_bold = pt_texte->IsBold() || thickness;
335 
336  GBR_METADATA gbr_metadata;
338  MODULE* parent = static_cast<MODULE*> ( pt_texte->GetParent() );
339  gbr_metadata.SetCmpReference( parent->GetReference() );
340 
341  m_plotter->Text( pos, aColor,
342  pt_texte->GetShownText(),
343  orient, size,
344  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
345  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
346 }
347 
348 
350 {
351  if( !m_layerMask[aDim->GetLayer()] )
352  return;
353 
354  DRAWSEGMENT draw;
355 
356  draw.SetWidth( aDim->GetWidth() );
357  draw.SetLayer( aDim->GetLayer() );
358 
360 
361  // Set plot color (change WHITE to LIGHTGRAY because
362  // the white items are not seen on a white paper or screen
363  m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
364 
365  PlotTextePcb( &aDim->Text() );
366 
367  draw.SetStart( aDim->m_crossBarO );
368  draw.SetEnd( aDim->m_crossBarF );
369  PlotDrawSegment( &draw );
370 
371  draw.SetStart( aDim->m_featureLineGO);
372  draw.SetEnd( aDim->m_featureLineGF );
373  PlotDrawSegment( &draw );
374 
375  draw.SetStart( aDim->m_featureLineDO );
376  draw.SetEnd( aDim->m_featureLineDF );
377  PlotDrawSegment( &draw );
378 
379  draw.SetStart( aDim->m_crossBarF );
380  draw.SetEnd( aDim->m_arrowD1F );
381  PlotDrawSegment( &draw );
382 
383  draw.SetStart( aDim->m_crossBarF );
384  draw.SetEnd( aDim->m_arrowD2F );
385  PlotDrawSegment( &draw );
386 
387  draw.SetStart( aDim->m_crossBarO );
388  draw.SetEnd( aDim->m_arrowG1F );
389  PlotDrawSegment( &draw );
390 
391  draw.SetStart( aDim->m_crossBarO );
392  draw.SetEnd( aDim->m_arrowG2F );
393  PlotDrawSegment( &draw );
394 }
395 
396 
398 {
399  int dx1, dx2, dy1, dy2, radius;
400 
401  if( !m_layerMask[aMire->GetLayer()] )
402  return;
403 
404  m_plotter->SetColor( getColor( aMire->GetLayer() ) );
405 
406  DRAWSEGMENT draw;
407 
408  draw.SetShape( S_CIRCLE );
409  draw.SetWidth( aMire->GetWidth() );
410  draw.SetLayer( aMire->GetLayer() );
411  draw.SetStart( aMire->GetPosition() );
412  radius = aMire->GetSize() / 3;
413 
414  if( aMire->GetShape() ) // shape X
415  radius = aMire->GetSize() / 2;
416 
417  // Draw the circle
418  draw.SetEnd( wxPoint( draw.GetStart().x + radius, draw.GetStart().y ));
419 
420  PlotDrawSegment( &draw );
421 
422  draw.SetShape( S_SEGMENT );
423 
424  radius = aMire->GetSize() / 2;
425  dx1 = radius;
426  dy1 = 0;
427  dx2 = 0;
428  dy2 = radius;
429 
430  if( aMire->GetShape() ) // Shape X
431  {
432  dx1 = dy1 = radius;
433  dx2 = dx1;
434  dy2 = -dy1;
435  }
436 
437  wxPoint mirePos( aMire->GetPosition() );
438 
439  // Draw the X or + shape:
440  draw.SetStart( wxPoint( mirePos.x - dx1, mirePos.y - dy1 ));
441  draw.SetEnd( wxPoint( mirePos.x + dx1, mirePos.y + dy1 ));
442  PlotDrawSegment( &draw );
443 
444  draw.SetStart( wxPoint( mirePos.x - dx2, mirePos.y - dy2 ));
445  draw.SetEnd( wxPoint( mirePos.x + dx2, mirePos.y + dy2 ));
446  PlotDrawSegment( &draw );
447 }
448 
449 
450 // Plot footprints graphic items (outlines)
452 {
453  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
454  {
455  for( BOARD_ITEM* item = module->GraphicalItemsList().GetFirst(); item; item = item->Next() )
456  {
457  EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item );
458 
459  if( edge && m_layerMask[edge->GetLayer()] )
460  Plot_1_EdgeModule( edge );
461  }
462  }
463 }
464 
465 
466 //* Plot a graphic item (outline) relative to a footprint
468 {
469  int type_trace; // Type of item to plot.
470  int thickness; // Segment thickness.
471  int radius; // Circle radius.
472 
473  if( aEdge->Type() != PCB_MODULE_EDGE_T )
474  return;
475 
476  m_plotter->SetColor( getColor( aEdge->GetLayer() ) );
477 
478  type_trace = aEdge->GetShape();
479  thickness = aEdge->GetWidth();
480 
481  wxPoint pos( aEdge->GetStart() );
482  wxPoint end( aEdge->GetEnd() );
483 
484  GBR_METADATA gbr_metadata;
486  MODULE* parent = static_cast<MODULE*> ( aEdge->GetParent() );
487  gbr_metadata.SetCmpReference( parent->GetReference() );
488 
489  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
490 
491  if( isOnCopperLayer )
492  {
493  gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP );
494  gbr_metadata.SetCopper( true );
495  }
496  else if( aEdge->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers
497  {
498  gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
499  }
500 
501  switch( type_trace )
502  {
503  case S_SEGMENT:
504  m_plotter->ThickSegment( pos, end, thickness, GetPlotMode(), &gbr_metadata );
505  break;
506 
507  case S_CIRCLE:
508  radius = KiROUND( GetLineLength( end, pos ) );
509  m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
510  break;
511 
512  case S_ARC:
513  {
514  radius = KiROUND( GetLineLength( end, pos ) );
515  double startAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
516  double endAngle = startAngle + aEdge->GetAngle();
517 
518  m_plotter->ThickArc( pos, -endAngle, -startAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
519  }
520  break;
521 
522  case S_POLYGON:
523  {
524  const std::vector<wxPoint>& polyPoints = aEdge->GetPolyPoints();
525 
526  if( polyPoints.size() <= 1 ) // Malformed polygon
527  break;
528 
529  // We must compute true coordinates from m_PolyList
530  // which are relative to module position, orientation 0
531  MODULE* module = aEdge->GetParentModule();
532 
533  std::vector< wxPoint > cornerList;
534 
535  cornerList.reserve( polyPoints.size() );
536 
537  for( unsigned ii = 0; ii < polyPoints.size(); ii++ )
538  {
539  wxPoint corner = polyPoints[ii];
540 
541  if( module )
542  {
543  RotatePoint( &corner, module->GetOrientation() );
544  corner += module->GetPosition();
545  }
546 
547  cornerList.push_back( corner );
548  }
549 
550  m_plotter->PlotPoly( cornerList, FILLED_SHAPE, thickness, &gbr_metadata );
551  }
552  break;
553  }
554 }
555 
556 
557 // Plot a PCB Text, i.e. a text found on a copper or technical layer
559 {
560  double orient;
561  int thickness;
562  wxPoint pos;
563  wxSize size;
564  wxString shownText( pt_texte->GetShownText() );
565 
566  if( shownText.IsEmpty() )
567  return;
568 
569  if( !m_layerMask[pt_texte->GetLayer()] )
570  return;
571 
572  GBR_METADATA gbr_metadata;
573 
574  if( IsCopperLayer( pt_texte->GetLayer() ) )
575  {
577  }
578 
579  COLOR4D color = getColor( pt_texte->GetLayer() );
580  m_plotter->SetColor( color );
581 
582  size = pt_texte->GetTextSize();
583  pos = pt_texte->GetTextPos();
584  orient = pt_texte->GetTextAngle();
585  thickness = pt_texte->GetThickness();
586 
587  if( pt_texte->IsMirrored() )
588  size.x = -size.x;
589 
590  // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
591  // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
592  // (like bold text) and we manage the thickness.
593  // So we set bold flag to true
594  bool allow_bold = pt_texte->IsBold() || thickness;
595 
596  if( pt_texte->IsMultilineAllowed() )
597  {
598  std::vector<wxPoint> positions;
599  wxArrayString strings_list;
600  wxStringSplit( shownText, strings_list, '\n' );
601  positions.reserve( strings_list.Count() );
602 
603  pt_texte->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
604 
605  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
606  {
607  wxString& txt = strings_list.Item( ii );
608  m_plotter->Text( positions[ii], color, txt, orient, size,
609  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
610  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
611  }
612  }
613  else
614  {
615  m_plotter->Text( pos, color, shownText, orient, size,
616  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
617  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
618  }
619 }
620 
621 
622 /* Plot areas (given by .m_FilledPolysList member) in a zone
623  */
625 {
626  const SHAPE_POLY_SET& polysList = aZone->GetFilledPolysList();
627 
628  if( polysList.IsEmpty() )
629  return;
630 
631  GBR_METADATA gbr_metadata;
632 
633  bool isOnCopperLayer = aZone->IsOnCopperLayer();
634 
635  if( isOnCopperLayer )
636  {
637  gbr_metadata.SetNetName( aZone->GetNetname() );
638  gbr_metadata.SetCopper( true );
639 
640  // Zones with no net name can exist.
641  // they are not used to connect items, so the aperture attribute cannot
642  // be set as conductor
643  if( aZone->GetNetname().IsEmpty() )
645  else
646  {
649  }
650  }
651 
652  // We need a buffer to store corners coordinates:
653  static std::vector< wxPoint > cornerList;
654  cornerList.clear();
655 
656  m_plotter->SetColor( getColor( aZone->GetLayer() ) );
657 
658  /* Plot all filled areas: filled areas have a filled area and a thick
659  * outline we must plot the filled area itself ( as a filled polygon
660  * OR a set of segments ) and plot the thick outline itself
661  *
662  * in non filled mode the outline is plotted, but not the filling items
663  */
664  for( auto ic = polysList.CIterate(); ic; ++ic )
665  {
666  wxPoint pos( ic->x, ic->y );
667  cornerList.push_back( pos );
668 
669  if( ic.IsEndContour() ) // Plot the current filled area outline
670  {
671  // First, close the outline
672  if( cornerList[0] != cornerList[cornerList.size() - 1] )
673  {
674  cornerList.push_back( cornerList[0] );
675  }
676 
677  // Plot the current filled area and its outline
678  if( GetPlotMode() == FILLED )
679  {
680  // Plot the filled area polygon.
681  // The area can be filled by segments or uses solid polygons
682  if( aZone->GetFillMode() == 0 ) // We are using solid polygons
683  {
684  m_plotter->PlotPoly( cornerList, FILLED_SHAPE, aZone->GetMinThickness(), &gbr_metadata );
685  }
686  else // We are using areas filled by segments: plot segments and outline
687  {
688  for( unsigned iseg = 0; iseg < aZone->FillSegments().size(); iseg++ )
689  {
690  wxPoint start = (wxPoint) aZone->FillSegments()[iseg].A;
691  wxPoint end = (wxPoint) aZone->FillSegments()[iseg].B;
692  m_plotter->ThickSegment( start, end,
693  aZone->GetMinThickness(),
694  GetPlotMode(), &gbr_metadata );
695  }
696 
697  // Plot the area outline only
698  if( aZone->GetMinThickness() > 0 )
699  m_plotter->PlotPoly( cornerList, NO_FILL, aZone->GetMinThickness() );
700  }
701  }
702  else
703  {
704  if( aZone->GetMinThickness() > 0 )
705  {
706  for( unsigned jj = 1; jj<cornerList.size(); jj++ )
707  m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
708  aZone->GetMinThickness(),
709  GetPlotMode(), &gbr_metadata );
710  }
711 
713  }
714 
715  cornerList.clear();
716  }
717  }
718 }
719 
720 
721 /* Plot items type DRAWSEGMENT on layers allowed by aLayerMask
722  */
724 {
725  if( !m_layerMask[aSeg->GetLayer()] )
726  return;
727 
728  int radius = 0;
729  double StAngle = 0, EndAngle = 0;
730  int thickness = aSeg->GetWidth();
731 
732  m_plotter->SetColor( getColor( aSeg->GetLayer() ) );
733 
734  wxPoint start( aSeg->GetStart() );
735  wxPoint end( aSeg->GetEnd() );
736 
737  GBR_METADATA gbr_metadata;
738 
739  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
740 
741  if( isOnCopperLayer && aSeg->GetLayer() == Edge_Cuts ) // can happens when plotting copper layers
742  {
744  }
745 
746  switch( aSeg->GetShape() )
747  {
748  case S_CIRCLE:
749  radius = KiROUND( GetLineLength( end, start ) );
750  m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
751  break;
752 
753  case S_ARC:
754  radius = KiROUND( GetLineLength( end, start ) );
755  StAngle = ArcTangente( end.y - start.y, end.x - start.x );
756  EndAngle = StAngle + aSeg->GetAngle();
757  m_plotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
758  break;
759 
760  case S_CURVE:
761  {
762  m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
763  const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints();
764 
765  for( unsigned i = 1; i < bezierPoints.size(); i++ )
766  m_plotter->ThickSegment( bezierPoints[i - 1], bezierPoints[i],
767  thickness, GetPlotMode(), &gbr_metadata );
768  }
769  break;
770 
771  case S_POLYGON:
772  {
773  m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
774  // Draw the polygon: only one polygon is expected
775  // However we provide a multi polygon shape drawing
776  // ( for the future or to show a non expected shape )
777  for( int jj = 0; jj < aSeg->GetPolyShape().OutlineCount(); ++jj )
778  {
779  SHAPE_LINE_CHAIN& poly = aSeg->GetPolyShape().Outline( jj );
780  m_plotter->PlotPoly( poly, FILLED_SHAPE, thickness, &gbr_metadata );
781  }
782  }
783  break;
784 
785  default:
786  m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata );
787  }
788 }
789 
790 
795  const wxPoint &aDrillPos, wxSize aDrillSize,
796  const wxSize &aPadSize,
797  double aOrientation, int aSmallDrill )
798 {
799  // Small drill marks have no significance when applied to slots
800  if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
801  aDrillSize.x = std::min( aSmallDrill, aDrillSize.x );
802 
803  // Round holes only have x diameter, slots have both
804  aDrillSize.x -= getFineWidthAdj();
805  aDrillSize.x = Clamp( 1, aDrillSize.x, aPadSize.x - 1 );
806 
807  if( aDrillShape == PAD_DRILL_SHAPE_OBLONG )
808  {
809  aDrillSize.y -= getFineWidthAdj();
810  aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 );
811  m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL );
812  }
813  else
814  m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL );
815 }
816 
817 
819 {
820  /* If small drills marks were requested prepare a clamp value to pass
821  to the helper function */
822  int small_drill = (GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) ?
823  SMALL_DRILL : 0;
824 
825  /* In the filled trace mode drill marks are drawn white-on-black to scrape
826  the underlying pad. This works only for drivers supporting color change,
827  obviously... it means that:
828  - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
829  - In HPGL you can't see them
830  - In gerbers you can't see them, too. This is arguably the right thing to
831  do since having drill marks and high speed drill stations is a sure
832  recipe for broken tools and angry manufacturers. If you *really* want them
833  you could start a layer with negative polarity to scrape the film.
834  - In DXF they go into the 'WHITE' layer. This could be useful.
835  */
836  if( GetPlotMode() == FILLED )
838 
839  for( TRACK* pts = m_board->m_Track; pts != NULL; pts = pts->Next() )
840  {
841  const VIA* via = dyn_cast<const VIA*>( pts );
842 
843  if( via )
845  wxSize( via->GetDrillValue(), 0 ),
846  wxSize( via->GetWidth(), 0 ), 0, small_drill );
847  }
848 
849  for( MODULE* Module = m_board->m_Modules; Module != NULL; Module = Module->Next() )
850  {
851  for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() )
852  {
853  if( pad->GetDrillSize().x == 0 )
854  continue;
855 
856  plotOneDrillMark( pad->GetDrillShape(),
857  pad->GetPosition(), pad->GetDrillSize(),
858  pad->GetSize(), pad->GetOrientation(),
859  small_drill );
860  }
861  }
862 
863  if( GetPlotMode() == FILLED )
865 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Function wxStringSplit splits aString to a string list separated at aSplitter.
Definition: common.cpp:137
bool MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon=NULL, int aCircleToSegmentsCount=32)
Merge all basic shapes, converted to a polygon in one polygon, in m_customShapeAsPolygon.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:646
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
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:60
TEXTE_MODULE & Reference()
Definition: class_module.h:483
void SetShape(STROKE_T aShape)
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:191
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:398
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:65
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
int GetMinThickness() const
Definition: class_zone.h:198
wxPoint m_crossBarF
int GetWidth() const
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)
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void PlotPad(D_PAD *aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode)
Plot a pad.
a class to handle special data during plot.
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:175
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:511
polygon (not yet used for tracks, but could be in microwave apps)
MODULE * Next() const
Definition: class_module.h:120
MODULE * GetParent() const
Definition: class_pad.h:162
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:178
PLOTTER * m_plotter
Definition: pcbplot.h:78
ZONE_SEGMENT_FILL & FillSegments()
Definition: class_zone.h:233
void PlotDrillMarks()
Function PlotDrillMarks Draw a drill mark for pads and vias.
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
aperture used for through hole component on outer layer
bool PlotAllTextsModule(MODULE *aModule)
Classes to handle copper zones.
usual segment : line with rounded ends
wxPoint m_featureLineDF
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
int OutlineCount() const
Returns the number of outlines in the set
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.
const std::vector< wxPoint > GetPolyPoints() const
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
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:46
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
bool GetPlotValue() const
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
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)
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, SHAPE_POLY_SET *aPolygons, EDA_DRAW_MODE_T aTraceMode, void *aData)=0
virtual function FlashPadCustom
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:229
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
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
Classes used in Pcbnew, CvPcb and GerbView.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:271
void PlotPcbTarget(PCB_TARGET *PtMire)
double GetOrientation() const
Definition: class_module.h:180
Class SHAPE_POLY_SET.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:482
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
EDA_DRAW_MODE_T
Definition: eda_text.h:62
const COLORS_DESIGN_SETTINGS & Colors() const
Function GetColorSettings.
Definition: class_board.h:563
void PlotBoardGraphicItems()
plot items like text and graphics, but not tracks and modules
const wxPoint & GetStart() const
Definition: class_track.h:123
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
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:395
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:160
ZONE_FILL_MODE GetFillMode() const
Definition: class_zone.h:175
static LSET ExternalCuMask()
Function ExternalCuMask returns a mask holding the Front and Bottom layers.
Definition: lset.cpp:676
const wxSize & GetSize() const
Definition: class_pad.h:269
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:314
const wxString & GetName() const
Definition: class_pad.h:190
aperture used for mechanical pads (NPTH)
SHAPE_POLY_SET & GetPolyShape()
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:62
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:534
COLOR4D GetColor() const
aperture used for connected items like tracks (not vias)
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
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.cpp:184
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
const wxPoint & GetPosition() const override
TRACK * Next() const
Definition: class_track.h:100
double GetAngle() const
bool GetPlotInvisibleText() const
const wxString & GetNetname() const
Function GetNetname.
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:439
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:245
Class SHAPE_LINE_CHAIN.
bool IsVisible() const
Definition: eda_text.h:176
int GetWidth() const
Definition: class_track.h:117
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:375
EDA_DRAW_MODE_T GetPlotMode() const
Usual pad.
Definition: pad_shapes.h:60
aperture used for SMD pad with a solder mask defined by the solder mask
The common library.
int GetWidth() const
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
void PlotTextePcb(TEXTE_PCB *pt_texte)
Definition: colors.h:49
wxPoint ShapePos() const
Definition: class_pad.cpp:500
void SetEnd(const wxPoint &aEnd)
int GetSize() const
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:723
wxPoint m_crossBarO
PCB_TARGET class definition.
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
bool m_NotInNet
true if a pad of a footprint cannot be connected (for instance a mechanical NPTH, ot a not named pad)...
int getFineWidthAdj()
Definition: pcbplot.h:95
DLIST< TRACK > m_Track
Definition: class_board.h:246
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
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:91
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
void SetCopper(bool aValue)
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)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:774
void SetCmpReference(const wxString &aComponentRef)
COLOR4D getColor(LAYER_NUM aLayer)
Function getColor.
Class DIMENSION.
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:251
#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)