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 <plotter.h>
33 #include <base_struct.h>
34 #include <draw_graphic_text.h>
35 #include <trigo.h>
36 #include <macros.h>
37 #include <pcb_base_frame.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 <gbr_metadata.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->Colors().GetLayerColor( aLayer );
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  TEXTE_MODULE* textModule = &aModule->Reference();
214  LAYER_NUM textLayer = textModule->GetLayer();
215 
216  if( GetPlotReference() && m_layerMask[textLayer]
217  && ( textModule->IsVisible() || GetPlotInvisibleText() ) )
218  {
219  PlotTextModule( textModule, getColor( textLayer ) );
220  }
221 
222  textModule = &aModule->Value();
223  textLayer = textModule->GetLayer();
224 
225  if( GetPlotValue() && m_layerMask[textLayer]
226  && ( textModule->IsVisible() || GetPlotInvisibleText() ) )
227  {
228  PlotTextModule( textModule, getColor( textLayer ) );
229  }
230 
231  for( BOARD_ITEM* item = aModule->GraphicalItemsList().GetFirst(); item; item = item->Next() )
232  {
233  textModule = dyn_cast<TEXTE_MODULE*>( item );
234 
235  if( !textModule )
236  continue;
237 
238  if( !textModule->IsVisible() )
239  continue;
240 
241  textLayer = textModule->GetLayer();
242 
243  if( textLayer >= PCB_LAYER_ID_COUNT )
244  return false;
245 
246  if( !m_layerMask[textLayer] )
247  continue;
248 
249  if( textModule->GetText() == wxT( "%R" ) && !GetPlotReference() )
250  continue;
251 
252  if( textModule->GetText() == wxT( "%V" ) && !GetPlotValue() )
253  continue;
254 
255  PlotTextModule( textModule, getColor( textLayer ) );
256  }
257 
258  return true;
259 }
260 
261 
262 // plot items like text and graphics, but not tracks and module
264 {
265  for( auto item : m_board->Drawings() )
266  {
267  switch( item->Type() )
268  {
269  case PCB_LINE_T:
270  PlotDrawSegment( (DRAWSEGMENT*) item);
271  break;
272 
273  case PCB_TEXT_T:
274  PlotTextePcb( (TEXTE_PCB*) item );
275  break;
276 
277  case PCB_DIMENSION_T:
278  PlotDimension( (DIMENSION*) item );
279  break;
280 
281  case PCB_TARGET_T:
282  PlotPcbTarget( (PCB_TARGET*) item );
283  break;
284 
285  case PCB_MARKER_T:
286  default:
287  break;
288  }
289  }
290 }
291 
293 {
294  wxSize size;
295  wxPoint pos;
296  double orient;
297  int thickness;
298 
299  if( aColor == COLOR4D::WHITE )
300  aColor = COLOR4D( LIGHTGRAY );
301 
302  m_plotter->SetColor( aColor );
303 
304  // calculate some text parameters :
305  size = pt_texte->GetTextSize();
306  pos = pt_texte->GetTextPos();
307 
308  orient = pt_texte->GetDrawRotation();
309 
310  thickness = pt_texte->GetThickness();
311 
312  if( pt_texte->IsMirrored() )
313  size.x = -size.x; // Text is mirrored
314 
315  // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
316  // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
317  // (like bold text) and we manage the thickness.
318  // So we set bold flag to true
319  bool allow_bold = pt_texte->IsBold() || thickness;
320 
321  GBR_METADATA gbr_metadata;
323  MODULE* parent = static_cast<MODULE*> ( pt_texte->GetParent() );
324  gbr_metadata.SetCmpReference( parent->GetReference() );
325 
326  m_plotter->Text( pos, aColor,
327  pt_texte->GetShownText(),
328  orient, size,
329  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
330  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
331 }
332 
333 
335 {
336  if( !m_layerMask[aDim->GetLayer()] )
337  return;
338 
339  DRAWSEGMENT draw;
340 
341  draw.SetWidth( aDim->GetWidth() );
342  draw.SetLayer( aDim->GetLayer() );
343 
345 
346  // Set plot color (change WHITE to LIGHTGRAY because
347  // the white items are not seen on a white paper or screen
348  m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
349 
350  PlotTextePcb( &aDim->Text() );
351 
352  draw.SetStart( aDim->m_crossBarO );
353  draw.SetEnd( aDim->m_crossBarF );
354  PlotDrawSegment( &draw );
355 
356  draw.SetStart( aDim->m_featureLineGO);
357  draw.SetEnd( aDim->m_featureLineGF );
358  PlotDrawSegment( &draw );
359 
360  draw.SetStart( aDim->m_featureLineDO );
361  draw.SetEnd( aDim->m_featureLineDF );
362  PlotDrawSegment( &draw );
363 
364  draw.SetStart( aDim->m_crossBarF );
365  draw.SetEnd( aDim->m_arrowD1F );
366  PlotDrawSegment( &draw );
367 
368  draw.SetStart( aDim->m_crossBarF );
369  draw.SetEnd( aDim->m_arrowD2F );
370  PlotDrawSegment( &draw );
371 
372  draw.SetStart( aDim->m_crossBarO );
373  draw.SetEnd( aDim->m_arrowG1F );
374  PlotDrawSegment( &draw );
375 
376  draw.SetStart( aDim->m_crossBarO );
377  draw.SetEnd( aDim->m_arrowG2F );
378  PlotDrawSegment( &draw );
379 }
380 
381 
383 {
384  int dx1, dx2, dy1, dy2, radius;
385 
386  if( !m_layerMask[aMire->GetLayer()] )
387  return;
388 
389  m_plotter->SetColor( getColor( aMire->GetLayer() ) );
390 
391  DRAWSEGMENT draw;
392 
393  draw.SetShape( S_CIRCLE );
394  draw.SetWidth( aMire->GetWidth() );
395  draw.SetLayer( aMire->GetLayer() );
396  draw.SetStart( aMire->GetPosition() );
397  radius = aMire->GetSize() / 3;
398 
399  if( aMire->GetShape() ) // shape X
400  radius = aMire->GetSize() / 2;
401 
402  // Draw the circle
403  draw.SetEnd( wxPoint( draw.GetStart().x + radius, draw.GetStart().y ));
404 
405  PlotDrawSegment( &draw );
406 
407  draw.SetShape( S_SEGMENT );
408 
409  radius = aMire->GetSize() / 2;
410  dx1 = radius;
411  dy1 = 0;
412  dx2 = 0;
413  dy2 = radius;
414 
415  if( aMire->GetShape() ) // Shape X
416  {
417  dx1 = dy1 = radius;
418  dx2 = dx1;
419  dy2 = -dy1;
420  }
421 
422  wxPoint mirePos( aMire->GetPosition() );
423 
424  // Draw the X or + shape:
425  draw.SetStart( wxPoint( mirePos.x - dx1, mirePos.y - dy1 ));
426  draw.SetEnd( wxPoint( mirePos.x + dx1, mirePos.y + dy1 ));
427  PlotDrawSegment( &draw );
428 
429  draw.SetStart( wxPoint( mirePos.x - dx2, mirePos.y - dy2 ));
430  draw.SetEnd( wxPoint( mirePos.x + dx2, mirePos.y + dy2 ));
431  PlotDrawSegment( &draw );
432 }
433 
434 
435 // Plot footprints graphic items (outlines)
437 {
438  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
439  {
440  for( BOARD_ITEM* item = module->GraphicalItemsList().GetFirst(); item; item = item->Next() )
441  {
442  EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item );
443 
444  if( edge && m_layerMask[edge->GetLayer()] )
445  Plot_1_EdgeModule( edge );
446  }
447  }
448 }
449 
450 
451 //* Plot a graphic item (outline) relative to a footprint
453 {
454  int type_trace; // Type of item to plot.
455  int thickness; // Segment thickness.
456  int radius; // Circle radius.
457 
458  if( aEdge->Type() != PCB_MODULE_EDGE_T )
459  return;
460 
461  m_plotter->SetColor( getColor( aEdge->GetLayer() ) );
462 
463  type_trace = aEdge->GetShape();
464  thickness = aEdge->GetWidth();
465 
466  wxPoint pos( aEdge->GetStart() );
467  wxPoint end( aEdge->GetEnd() );
468 
469  GBR_METADATA gbr_metadata;
471  MODULE* parent = static_cast<MODULE*> ( aEdge->GetParent() );
472  gbr_metadata.SetCmpReference( parent->GetReference() );
473 
474  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
475 
476  if( isOnCopperLayer )
477  {
478  gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP );
479  gbr_metadata.SetCopper( true );
480  }
481  else if( aEdge->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers
482  {
483  gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
484  }
485 
486  switch( type_trace )
487  {
488  case S_SEGMENT:
489  m_plotter->ThickSegment( pos, end, thickness, GetPlotMode(), &gbr_metadata );
490  break;
491 
492  case S_CIRCLE:
493  radius = KiROUND( GetLineLength( end, pos ) );
494  m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
495  break;
496 
497  case S_ARC:
498  {
499  radius = KiROUND( GetLineLength( end, pos ) );
500  double startAngle = ArcTangente( end.y - pos.y, end.x - pos.x );
501  double endAngle = startAngle + aEdge->GetAngle();
502 
503  // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
504  if( std::abs( aEdge->GetAngle() ) == 3600.0 )
505  m_plotter->ThickCircle( pos, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
506  else
507  m_plotter->ThickArc( pos, -endAngle, -startAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
508  }
509  break;
510 
511  case S_POLYGON:
512  if( aEdge->IsPolyShapeValid() )
513  {
514  const std::vector<wxPoint>& polyPoints = aEdge->BuildPolyPointsList();
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  COLOR4D color = getColor( pt_texte->GetLayer() );
567  m_plotter->SetColor( color );
568 
569  size = pt_texte->GetTextSize();
570  pos = pt_texte->GetTextPos();
571  orient = pt_texte->GetTextAngle();
572  thickness = pt_texte->GetThickness();
573 
574  if( pt_texte->IsMirrored() )
575  size.x = -size.x;
576 
577  // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
578  // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
579  // (like bold text) and we manage the thickness.
580  // So we set bold flag to true
581  bool allow_bold = pt_texte->IsBold() || thickness;
582 
583  if( pt_texte->IsMultilineAllowed() )
584  {
585  std::vector<wxPoint> positions;
586  wxArrayString strings_list;
587  wxStringSplit( shownText, strings_list, '\n' );
588  positions.reserve( strings_list.Count() );
589 
590  pt_texte->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
591 
592  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
593  {
594  wxString& txt = strings_list.Item( ii );
595  m_plotter->Text( positions[ii], color, txt, orient, size,
596  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
597  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
598  }
599  }
600  else
601  {
602  m_plotter->Text( pos, color, shownText, orient, size,
603  pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
604  thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
605  }
606 }
607 
608 
609 /* Plot areas (given by .m_FilledPolysList member) in a zone
610  */
612 {
613  const SHAPE_POLY_SET& polysList = aZone->GetFilledPolysList();
614 
615  if( polysList.IsEmpty() )
616  return;
617 
618  GBR_METADATA gbr_metadata;
619 
620  bool isOnCopperLayer = aZone->IsOnCopperLayer();
621 
622  if( isOnCopperLayer )
623  {
624  gbr_metadata.SetNetName( aZone->GetNetname() );
625  gbr_metadata.SetCopper( true );
626 
627  // Zones with no net name can exist.
628  // they are not used to connect items, so the aperture attribute cannot
629  // be set as conductor
630  if( aZone->GetNetname().IsEmpty() )
632  else
633  {
636  }
637  }
638 
639  // We need a buffer to store corners coordinates:
640  static std::vector< wxPoint > cornerList;
641  cornerList.clear();
642 
643  m_plotter->SetColor( getColor( aZone->GetLayer() ) );
644 
645  /* Plot all filled areas: filled areas have a filled area and a thick
646  * outline we must plot the filled area itself ( as a filled polygon
647  * OR a set of segments ) and plot the thick outline itself
648  *
649  * in non filled mode the outline is plotted, but not the filling items
650  */
651  for( auto ic = polysList.CIterate(); ic; ++ic )
652  {
653  wxPoint pos( ic->x, ic->y );
654  cornerList.push_back( pos );
655 
656  if( ic.IsEndContour() ) // Plot the current filled area outline
657  {
658  // First, close the outline
659  if( cornerList[0] != cornerList[cornerList.size() - 1] )
660  {
661  cornerList.push_back( cornerList[0] );
662  }
663 
664  // Plot the current filled area and its outline
665  if( GetPlotMode() == FILLED )
666  {
667  // Plot the filled area polygon.
668  // The area can be filled by segments or uses solid polygons
669  if( aZone->GetFillMode() == 0 ) // We are using solid polygons
670  {
671  m_plotter->PlotPoly( cornerList, FILLED_SHAPE, aZone->GetMinThickness(), &gbr_metadata );
672  }
673  else // We are using areas filled by segments: plot segments and outline
674  {
675  for( unsigned iseg = 0; iseg < aZone->FillSegments().size(); iseg++ )
676  {
677  wxPoint start = (wxPoint) aZone->FillSegments()[iseg].A;
678  wxPoint end = (wxPoint) aZone->FillSegments()[iseg].B;
679  m_plotter->ThickSegment( start, end,
680  aZone->GetMinThickness(),
681  GetPlotMode(), &gbr_metadata );
682  }
683 
684  // Plot the area outline only
685  if( aZone->GetMinThickness() > 0 )
686  m_plotter->PlotPoly( cornerList, NO_FILL, aZone->GetMinThickness() );
687  }
688  }
689  else
690  {
691  if( aZone->GetMinThickness() > 0 )
692  {
693  for( unsigned jj = 1; jj<cornerList.size(); jj++ )
694  m_plotter->ThickSegment( cornerList[jj -1], cornerList[jj],
695  aZone->GetMinThickness(),
696  GetPlotMode(), &gbr_metadata );
697  }
698 
700  }
701 
702  cornerList.clear();
703  }
704  }
705 }
706 
707 
708 /* Plot items type DRAWSEGMENT on layers allowed by aLayerMask
709  */
711 {
712  if( !m_layerMask[aSeg->GetLayer()] )
713  return;
714 
715  int radius = 0;
716  double StAngle = 0, EndAngle = 0;
717  int thickness = aSeg->GetWidth();
718 
719  m_plotter->SetColor( getColor( aSeg->GetLayer() ) );
720 
721  wxPoint start( aSeg->GetStart() );
722  wxPoint end( aSeg->GetEnd() );
723 
724  GBR_METADATA gbr_metadata;
725 
726  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
727 
728  if( isOnCopperLayer && aSeg->GetLayer() == Edge_Cuts ) // can happens when plotting copper layers
729  {
731  }
732 
733  switch( aSeg->GetShape() )
734  {
735  case S_CIRCLE:
736  radius = KiROUND( GetLineLength( end, start ) );
737  m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
738  break;
739 
740  case S_ARC:
741  radius = KiROUND( GetLineLength( end, start ) );
742  StAngle = ArcTangente( end.y - start.y, end.x - start.x );
743  EndAngle = StAngle + aSeg->GetAngle();
744 
745  // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
746  if( std::abs( aSeg->GetAngle() ) == 3600.0 )
747  m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata );
748  else
749  m_plotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, GetPlotMode(), &gbr_metadata );
750  break;
751 
752  case S_CURVE:
753  {
754  m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
755  const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints();
756 
757  for( unsigned i = 1; i < bezierPoints.size(); i++ )
758  m_plotter->ThickSegment( bezierPoints[i - 1], bezierPoints[i],
759  thickness, GetPlotMode(), &gbr_metadata );
760  }
761  break;
762 
763  case S_POLYGON:
764  {
765  m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
766  // Draw the polygon: only one polygon is expected
767  // However we provide a multi polygon shape drawing
768  // ( for the future or to show a non expected shape )
769  for( int jj = 0; jj < aSeg->GetPolyShape().OutlineCount(); ++jj )
770  {
771  SHAPE_LINE_CHAIN& poly = aSeg->GetPolyShape().Outline( jj );
772  m_plotter->PlotPoly( poly, FILLED_SHAPE, thickness, &gbr_metadata );
773  }
774  }
775  break;
776 
777  default:
778  m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata );
779  }
780 }
781 
782 
787  const wxPoint &aDrillPos, wxSize aDrillSize,
788  const wxSize &aPadSize,
789  double aOrientation, int aSmallDrill )
790 {
791  // Small drill marks have no significance when applied to slots
792  if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
793  aDrillSize.x = std::min( aSmallDrill, aDrillSize.x );
794 
795  // Round holes only have x diameter, slots have both
796  aDrillSize.x -= getFineWidthAdj();
797  aDrillSize.x = Clamp( 1, aDrillSize.x, aPadSize.x - 1 );
798 
799  if( aDrillShape == PAD_DRILL_SHAPE_OBLONG )
800  {
801  aDrillSize.y -= getFineWidthAdj();
802  aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 );
803  m_plotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, GetPlotMode(), NULL );
804  }
805  else
806  m_plotter->FlashPadCircle( aDrillPos, aDrillSize.x, GetPlotMode(), NULL );
807 }
808 
809 
811 {
812  /* If small drills marks were requested prepare a clamp value to pass
813  to the helper function */
814  int small_drill = (GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) ?
815  SMALL_DRILL : 0;
816 
817  /* In the filled trace mode drill marks are drawn white-on-black to scrape
818  the underlying pad. This works only for drivers supporting color change,
819  obviously... it means that:
820  - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
821  - In HPGL you can't see them
822  - In gerbers you can't see them, too. This is arguably the right thing to
823  do since having drill marks and high speed drill stations is a sure
824  recipe for broken tools and angry manufacturers. If you *really* want them
825  you could start a layer with negative polarity to scrape the film.
826  - In DXF they go into the 'WHITE' layer. This could be useful.
827  */
828  if( GetPlotMode() == FILLED )
830 
831  for( TRACK* pts = m_board->m_Track; pts != NULL; pts = pts->Next() )
832  {
833  const VIA* via = dyn_cast<const VIA*>( pts );
834 
835  if( via )
837  wxSize( via->GetDrillValue(), 0 ),
838  wxSize( via->GetWidth(), 0 ), 0, small_drill );
839  }
840 
841  for( MODULE* Module = m_board->m_Modules; Module != NULL; Module = Module->Next() )
842  {
843  for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() )
844  {
845  if( pad->GetDrillSize().x == 0 )
846  continue;
847 
848  plotOneDrillMark( pad->GetDrillShape(),
849  pad->GetPosition(), pad->GetDrillSize(),
850  pad->GetSize(), pad->GetOrientation(),
851  small_drill );
852  }
853  }
854 
855  if( GetPlotMode() == FILLED )
857 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:183
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:673
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
a class to handle special data (items attributes) during plot.
void SetPadName(const wxString &aPadname)
Definition: gbr_metadata.h:140
#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
aperture used for etched components
Definition: gbr_metadata.h:60
TEXTE_MODULE & Reference()
Definition: class_module.h:513
void SetShape(STROKE_T aShape)
aperture used for edge connecto pad (outer layers)
Definition: gbr_metadata.h:70
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:201
double GetDrawRotation() const
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...
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:405
TEXTE_PCB class definition.
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
bool IsItalic() const
Definition: eda_text.h:183
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:204
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)
Definition: plotter.cpp:511
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.
int GetWidth() const
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:129
Class BOARD to handle a board.
void PlotDimension(DIMENSION *Dimension)
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:531
int color
Definition: DXF_plotter.cpp:62
polygon (not yet used for tracks, but could be in microwave apps)
MODULE * Next() const
Definition: class_module.h:123
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:175
PLOTTER * m_plotter
Definition: pcbplot.h:78
ZONE_SEGMENT_FILL & FillSegments()
Definition: class_zone.h:239
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
Definition: gbr_metadata.h:65
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:216
bool IsPolyShapeValid() const
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.
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
#define abs(a)
Definition: auxiliary.h:84
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:203
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:177
bool IsBold() const
Definition: eda_text.h:186
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)
Definition: plotter.cpp:473
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:167
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.
void PlotFilledAreas(ZONE_CONTAINER *aZone)
Classes used in Pcbnew, CvPcb and GerbView.
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:148
BOARD_ITEM * Next() const
DIMENSION class definition.
aperture used for BGA pad with a solder mask defined by the solder mask
Definition: gbr_metadata.h:69
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
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:170
void PlotPcbTarget(PCB_TARGET *PtMire)
double GetOrientation() const
Definition: class_module.h:189
Class SHAPE_POLY_SET.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
EDA_DRAW_MODE_T
Definition: eda_text.h:77
const COLORS_DESIGN_SETTINGS & Colors() const
Function GetColorSettings.
Definition: class_board.h:569
void PlotBoardGraphicItems()
plot items like text and graphics, but not tracks and modules
const wxPoint & GetStart() const
Definition: class_track.h:122
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
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:402
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:181
static LSET ExternalCuMask()
Function ExternalCuMask returns a mask holding the Front and Bottom layers.
Definition: lset.cpp:703
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:315
const wxString & GetName() const
Definition: class_pad.h:190
aperture used for mechanical pads (NPTH)
Definition: gbr_metadata.h:71
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:561
COLOR4D GetColor() const
aperture used for connected items like tracks (not vias)
Definition: gbr_metadata.h:61
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:204
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:139
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:181
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
TRACK * Next() const
Definition: class_track.h:99
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:463
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:192
DLIST< MODULE > m_Modules
Definition: class_board.h:248
Class SHAPE_LINE_CHAIN.
bool IsVisible() const
Definition: eda_text.h:189
int GetWidth() const
Definition: class_track.h:116
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, EDA_DRAW_MODE_T tracemode, void *aData)
Definition: plotter.cpp:456
LSET m_layerMask
Definition: pcbplot.h:80
TEXTE_PCB & Text()
size_t i
Definition: json11.cpp:597
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:382
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
Definition: gbr_metadata.h:67
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:517
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...
static LSET AllBoardTechMask()
Function AllTechMask returns a mask holding board technical layers (no CU layer) on both side...
Definition: lset.cpp:750
wxPoint m_crossBarO
PCB_TARGET class definition.
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:119
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
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:249
GBR_NETLIST_METADATA m_NetlistMetadata
a item to handle object attribute:
Definition: gbr_metadata.h:158
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:228
Basic classes for most KiCad items.
aperture used for not connected items (texts, outlines on copper)
Definition: gbr_metadata.h:63
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)
Definition: gbr_metadata.h:148
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)
const wxPoint GetPosition() const override
Definition: class_module.h:184
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:141
COLOR4D getColor(LAYER_NUM aLayer)
Function getColor.
Class DIMENSION.
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:255
const wxPoint GetPosition() const override
#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)