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