KiCad PCB EDA Suite
pcb_painter.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013-2017 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <class_board.h>
27 #include <class_track.h>
28 #include <class_module.h>
29 #include <class_pad.h>
30 #include <class_drawsegment.h>
31 #include <class_zone.h>
32 #include <class_pcb_text.h>
33 #include <colors_design_settings.h>
34 #include <class_marker_pcb.h>
35 #include <class_dimension.h>
36 #include <class_pcb_target.h>
37 #include <class_marker_pcb.h>
38 
40 #include <pcb_painter.h>
41 #include <pcb_display_options.h>
42 
45 
46 using namespace KIGFX;
47 
49 {
50  m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
51  m_padNumbers = true;
52  m_netNamesOnPads = true;
53  m_netNamesOnTracks = true;
54  m_netNamesOnVias = true;
55  m_zoneOutlines = true;
58  m_sketchBoardGfx = false;
59  m_sketchFpGfx = false;
60  m_sketchFpTxtfx = false;
61  m_selectionCandidateColor = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
62 
63  // By default everything should be displayed as filled
64  for( unsigned int i = 0; i < DIM( m_sketchMode ); ++i )
65  {
66  m_sketchMode[i] = false;
67  }
68 
70  ImportLegacyColors( &dummyCds );
71 
72  update();
73 }
74 
75 
77 {
78  // Init board layers colors:
79  for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
80  {
81  m_layerColors[i] = aSettings->GetLayerColor( i );
82 
83  // Guard: if the alpah channel is too small, the layer is not visible.
84  // clamp it to 0.2
85  if( m_layerColors[i].a < 0.2 )
86  m_layerColors[i].a = 0.2;
87  }
88 
89  // Init specific graphic layers colors:
90  for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
91  m_layerColors[i] = aSettings->GetItemColor( i );
92 
93  // Default colors for specific layers (not really board layers).
94  m_layerColors[LAYER_VIAS_HOLES] = COLOR4D( 0.5, 0.4, 0.0, 0.8 );
96  m_layerColors[LAYER_VIAS_NETNAMES] = COLOR4D( 0.2, 0.2, 0.2, 0.9 );
97  m_layerColors[LAYER_PADS_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
98  m_layerColors[LAYER_PAD_FR_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
99  m_layerColors[LAYER_PAD_BK_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
100  m_layerColors[LAYER_DRC] = COLOR4D( 1.0, 0.0, 0.0, 0.8 );
101 
102  // LAYER_PADS_TH, LAYER_NON_PLATEDHOLES, LAYER_ANCHOR ,LAYER_RATSNEST,
103  // LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA
104  // are initialized from aSettings
105 
106  // These colors are not actually used. Set just in case...
109 
110  // Netnames for copper layers
111  for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
112  {
113  const COLOR4D lightLabel( 0.8, 0.8, 0.8, 0.7 );
114  const COLOR4D darkLabel = lightLabel.Inverted();
115  PCB_LAYER_ID layer = *cu;
116 
117  if( m_layerColors[layer].GetBrightness() > 0.5 )
118  m_layerColors[GetNetnameLayer( layer )] = darkLabel;
119  else
120  m_layerColors[GetNetnameLayer( layer )] = lightLabel;
121  }
122 
123  update();
124 }
125 
126 
128  bool aShowPageLimits )
129 {
130  if( aOptions == NULL )
131  return;
132 
134  m_padNumbers = aOptions->m_DisplayPadNum;
136  m_sketchFpGfx = !aOptions->m_DisplayModEdgeFill;
138 
139  // Whether to draw tracks, vias & pads filled or as outlines
145 
146  // Net names display settings
147  switch( aOptions->m_DisplayNetNamesMode )
148  {
149  case 0:
150  m_netNamesOnPads = false;
151  m_netNamesOnTracks = false;
152  break;
153 
154  case 1:
155  m_netNamesOnPads = true;
156  m_netNamesOnTracks = false;
157  break;
158 
159  case 2:
160  m_netNamesOnPads = false;
161  m_netNamesOnTracks = true;
162  break;
163 
164  case 3:
165  m_netNamesOnPads = true;
166  m_netNamesOnTracks = true;
167  break;
168  }
169 
170  // Zone display settings
171  switch( aOptions->m_DisplayZonesMode )
172  {
173  case 0:
175  break;
176 
177  case 1:
179  break;
180 
181  case 2:
183  break;
184  }
185 
186  // Clearance settings
187  switch( aOptions->m_ShowTrackClearanceMode )
188  {
191  break;
192 
195  break;
196 
199  break;
200 
203  break;
204 
207  break;
208  }
209 
210  if( aOptions->m_DisplayPadIsol )
211  m_clearance |= CL_PADS;
212 
213  m_showPageLimits = aShowPageLimits;
214 }
215 
216 
217 const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
218 {
219  int netCode = -1;
220  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
221 
222  if( item )
223  {
224  // Selection disambiguation
225  if( item->IsBrightened() )
226  {
228  }
229 
230  // Don't let pads that *should* be NPTHs get lost
231  if( item->Type() == PCB_PAD_T && dyn_cast<const D_PAD*>( item )->PadShouldBeNPTH() )
232  aLayer = LAYER_MOD_TEXT_INVISIBLE;
233 
234  if( item->IsSelected() )
235  {
236  return m_layerColorsSel[aLayer];
237  }
238 
239  // Try to obtain the netcode for the item
240  if( const BOARD_CONNECTED_ITEM* conItem = dyn_cast<const BOARD_CONNECTED_ITEM*> ( item ) )
241  netCode = conItem->GetNetCode();
242 
243  if( item->Type() == PCB_MARKER_T )
244  return m_layerColors[aLayer];
245  }
246 
247  // Single net highlight mode
248  if( m_highlightEnabled && netCode == m_highlightNetcode )
249  return m_layerColorsHi[aLayer];
250 
251  // Return grayish color for non-highlighted layers in the high contrast mode
252  if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
253  return m_hiContrastColor;
254 
255  // Catch the case when highlight and high-contraste modes are enabled
256  // and we are drawing a not highlighted track
257  if( m_highlightEnabled )
258  return m_layerColorsDark[aLayer];
259 
260  // No special modificators enabled
261  return m_layerColors[aLayer];
262 }
263 
264 
266  PAINTER( aGal )
267 {
268 }
269 
270 
271 int PCB_PAINTER::getLineThickness( int aActualThickness ) const
272 {
273  // if items have 0 thickness, draw them with the outline
274  // width, otherwise respect the set value (which, no matter
275  // how small will produce something)
276  if( aActualThickness == 0 )
278 
279  return aActualThickness;
280 }
281 
282 
283 int PCB_PAINTER::getDrillShape( const D_PAD* aPad ) const
284 {
285  return aPad->GetDrillShape();
286 }
287 
288 
290 {
291  return VECTOR2D( aPad->GetDrillSize() );
292 }
293 
294 
295 int PCB_PAINTER::getDrillSize( const VIA* aVia ) const
296 {
297  return aVia->GetDrillValue();
298 }
299 
300 
301 bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
302 {
303  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
304 
305  if( !item )
306  return false;
307 
308  // the "cast" applied in here clarifies which overloaded draw() is called
309  switch( item->Type() )
310  {
311  case PCB_SEGZONE_T:
312  case PCB_TRACE_T:
313  draw( static_cast<const TRACK*>( item ), aLayer );
314  break;
315 
316  case PCB_VIA_T:
317  draw( static_cast<const VIA*>( item ), aLayer );
318  break;
319 
320  case PCB_PAD_T:
321  draw( static_cast<const D_PAD*>( item ), aLayer );
322  break;
323 
324  case PCB_LINE_T:
325  case PCB_MODULE_EDGE_T:
326  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
327  break;
328 
329  case PCB_TEXT_T:
330  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
331  break;
332 
333  case PCB_MODULE_TEXT_T:
334  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
335  break;
336 
337  case PCB_MODULE_T:
338  draw( static_cast<const MODULE*>( item ), aLayer );
339  break;
340 
341  case PCB_ZONE_AREA_T:
342  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
343  break;
344 
345  case PCB_DIMENSION_T:
346  draw( static_cast<const DIMENSION*>( item ), aLayer );
347  break;
348 
349  case PCB_TARGET_T:
350  draw( static_cast<const PCB_TARGET*>( item ) );
351  break;
352 
353  case PCB_MARKER_T:
354  draw( static_cast<const MARKER_PCB*>( item ) );
355  break;
356 
357  default:
358  // Painter does not know how to draw the object
359  return false;
360  }
361 
362  return true;
363 }
364 
365 
366 void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
367 {
368  VECTOR2D start( aTrack->GetStart() );
369  VECTOR2D end( aTrack->GetEnd() );
370  int width = aTrack->GetWidth();
371 
373  {
374  // If there is a net name - display it on the track
375  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
376  {
377  VECTOR2D line = ( end - start );
378  double length = line.EuclideanNorm();
379 
380  // Check if the track is long enough to have a netname displayed
381  if( length < 10 * width )
382  return;
383 
384  const wxString& netName = aTrack->GetShortNetname();
385  VECTOR2D textPosition = start + line / 2.0; // center of the track
386 
387  double textOrientation;
388 
389  if( end.y == start.y ) // horizontal
390  textOrientation = 0;
391  else if( end.x == start.x ) // vertical
392  textOrientation = M_PI / 2;
393  else
394  textOrientation = -atan( line.y / line.x );
395 
396  double textSize = width;
397 
398  m_gal->SetIsStroke( true );
399  m_gal->SetIsFill( false );
400  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
401  m_gal->SetLineWidth( width / 10.0 );
402  m_gal->SetFontBold( false );
403  m_gal->SetFontItalic( false );
404  m_gal->SetTextMirrored( false );
405  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
408  m_gal->BitmapText( netName, textPosition, textOrientation );
409  }
410  }
411  else if( IsCopperLayer( aLayer ) )
412  {
413  // Draw a regular track
414  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
415  m_gal->SetStrokeColor( color );
416  m_gal->SetIsStroke( true );
417 
419  {
420  // Outline mode
422  m_gal->SetIsFill( false );
423  }
424  else
425  {
426  // Filled mode
427  m_gal->SetFillColor( color );
428  m_gal->SetIsFill( true );
429  }
430 
431  m_gal->DrawSegment( start, end, width );
432 
433  // Clearance lines
434  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
435 
436  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
437  {
439  m_gal->SetIsFill( false );
440  m_gal->SetIsStroke( true );
441  m_gal->SetStrokeColor( color );
442  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
443  }
444  }
445 }
446 
447 
448 void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
449 {
450  VECTOR2D center( aVia->GetStart() );
451  double radius = 0.0;
452 
453  // Draw description layer
454  if( IsNetnameLayer( aLayer ) )
455  {
456  VECTOR2D position( center );
457 
458  // Is anything that we can display enabled?
460  {
461  bool displayNetname = ( !aVia->GetNetname().empty() );
463  double size = aVia->GetWidth();
464 
465  // Font size limits
466  if( size > maxSize )
467  size = maxSize;
468 
469  m_gal->Save();
470  m_gal->Translate( position );
471 
472  // Default font settings
474  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
475 
476  // Set the text position to the pad shape position (the pad position is not the best place)
477  VECTOR2D textpos( 0.0, 0.0 );
478 
479  if( displayNetname )
480  {
481  // calculate the size of net name text:
482  double tsize = 1.5 * size / aVia->GetShortNetname().Length();
483  tsize = std::min( tsize, size );
484  // Use a smaller text size to handle interline, pen size..
485  tsize *= 0.7;
486  VECTOR2D namesize( tsize, tsize );
487 
488  m_gal->SetGlyphSize( namesize );
489  m_gal->SetLineWidth( namesize.x / 12.0 );
490  m_gal->BitmapText( aVia->GetShortNetname(), textpos, 0.0 );
491  }
492 
493 
494  m_gal->Restore();
495  }
496  return;
497  }
498 
499  // Choose drawing settings depending on if we are drawing via's pad or hole
500  if( aLayer == LAYER_VIAS_HOLES )
501  radius = getDrillSize( aVia ) / 2.0;
502  else
503  radius = aVia->GetWidth() / 2.0;
504 
505  bool sketchMode = false;
506  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
507 
508  switch( aVia->GetViaType() )
509  {
510  case VIA_THROUGH:
512  break;
513 
514  case VIA_BLIND_BURIED:
516  break;
517 
518  case VIA_MICROVIA:
520  break;
521 
522  default:
523  assert( false );
524  break;
525  }
526 
527  if( aVia->GetViaType() == VIA_BLIND_BURIED )
528  {
529  // Buried vias are drawn in a special way to indicate the top and bottom layers
530  PCB_LAYER_ID layerTop, layerBottom;
531  aVia->LayerPair( &layerTop, &layerBottom );
532 
533  if( aLayer == LAYER_VIAS_HOLES )
534  { // TODO outline mode
535  m_gal->SetIsFill( true );
536  m_gal->SetIsStroke( false );
537  m_gal->SetFillColor( color );
538  m_gal->DrawCircle( center, radius );
539  }
540  else
541  {
542  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
543 
544  m_gal->SetLineWidth( width );
545  m_gal->SetIsFill( true );
546  m_gal->SetIsStroke( false );
547  m_gal->SetFillColor( color );
548 
549  if( aLayer == layerTop )
550  {
551  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
552  }
553  else if( aLayer == layerBottom )
554  {
555  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
556  }
557  else if( aLayer == LAYER_VIA_BBLIND )
558  {
559  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
560  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
561  }
562  }
563  }
564  else
565  {
566  // Regular vias
567  m_gal->SetIsFill( !sketchMode );
568  m_gal->SetIsStroke( sketchMode );
569 
570  if( sketchMode )
571  {
572  // Outline mode
574  m_gal->SetStrokeColor( color );
575  }
576  else
577  {
578  // Filled mode
579  m_gal->SetFillColor( color );
580  }
581 
582  m_gal->DrawCircle( center, radius );
583  }
584 
585  // Clearance lines
586  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
587 
588  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
589  && aLayer != LAYER_VIAS_HOLES )
590  {
592  m_gal->SetIsFill( false );
593  m_gal->SetIsStroke( true );
594  m_gal->SetStrokeColor( color );
595  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
596  }
597 }
598 
599 
600 void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
601 {
602  PAD_SHAPE_T shape;
603  double m, n;
604  double orientation = aPad->GetOrientation();
605 
606  // Draw description layer
607  if( IsNetnameLayer( aLayer ) )
608  {
609  VECTOR2D position( aPad->ShapePos() );
610 
611  // Is anything that we can display enabled?
613  {
614  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
615  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
617  double size = padsize.y;
618 
619  // Keep the size ratio for the font, but make it smaller
620  if( padsize.x < padsize.y )
621  {
622  orientation += 900.0;
623  size = padsize.x;
624  std::swap( padsize.x, padsize.y );
625  }
626  else if( padsize.x == padsize.y )
627  {
628  // If the text is displayed on a symmetrical pad, do not rotate it
629  orientation = 0.0;
630  }
631 
632  // Font size limits
633  if( size > maxSize )
634  size = maxSize;
635 
636  m_gal->Save();
637  m_gal->Translate( position );
638 
639  // do not display descriptions upside down
640  NORMALIZE_ANGLE_90( orientation );
641  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
642 
643  // Default font settings
646  m_gal->SetFontBold( false );
647  m_gal->SetFontItalic( false );
648  m_gal->SetTextMirrored( false );
649  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
650  m_gal->SetIsStroke( true );
651  m_gal->SetIsFill( false );
652 
653  // Set the text position to the pad shape position (the pad position is not the best place)
654  VECTOR2D textpos( 0.0, 0.0 );
655 
656  // Divide the space, to display both pad numbers and netnames
657  // and set the Y text position to display 2 lines
658  if( displayNetname && m_pcbSettings.m_padNumbers )
659  {
660  size = size / 2.0;
661  textpos.y = size / 2.0;
662  }
663 
664  if( displayNetname )
665  {
666  // calculate the size of net name text:
667  double tsize = 1.5 * padsize.x / aPad->GetShortNetname().Length();
668  tsize = std::min( tsize, size );
669  // Use a smaller text size to handle interline, pen size..
670  tsize *= 0.7;
671  VECTOR2D namesize( tsize, tsize );
672 
673  m_gal->SetGlyphSize( namesize );
674  m_gal->SetLineWidth( namesize.x / 12.0 );
675  m_gal->BitmapText( aPad->GetShortNetname(), textpos, 0.0 );
676  }
677 
679  {
680  const wxString& padName = aPad->GetName();
681  textpos.y = -textpos.y;
682  double tsize = 1.5 * padsize.x / padName.Length();
683  tsize = std::min( tsize, size );
684  // Use a smaller text size to handle interline, pen size..
685  tsize *= 0.7;
686  tsize = std::min( tsize, size );
687  VECTOR2D numsize( tsize, tsize );
688 
689  m_gal->SetGlyphSize( numsize );
690  m_gal->SetLineWidth( numsize.x / 12.0 );
691  m_gal->BitmapText( padName, textpos, 0.0 );
692  }
693 
694  m_gal->Restore();
695  }
696  return;
697  }
698 
699  // Pad drawing
700  COLOR4D color;
701 
702  // Pad holes color is type specific
703  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
704  {
705  // Hole color is the background color for plated holes, but a specific color
706  // for not plated holes (LAYER_NON_PLATEDHOLES color layer )
708  color = m_pcbSettings.GetColor( nullptr, LAYER_NON_PLATEDHOLES );
709  // Don't let pads that *should* be NPTH get lost
710  else if( aPad->PadShouldBeNPTH() )
711  color = m_pcbSettings.GetColor( aPad, aLayer );
712  else
714  }
715  else
716  {
717  color = m_pcbSettings.GetColor( aPad, aLayer );
718  }
719 
720  VECTOR2D size;
721 
723  {
724  // Outline mode
725  m_gal->SetIsFill( false );
726  m_gal->SetIsStroke( true );
728  m_gal->SetStrokeColor( color );
729  }
730  else
731  {
732  // Filled mode
733  m_gal->SetIsFill( true );
734  m_gal->SetIsStroke( false );
735  m_gal->SetFillColor( color );
736  }
737 
738  m_gal->Save();
739  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
740  m_gal->Rotate( -aPad->GetOrientationRadians() );
741 
742  int custom_margin = 0; // a clearance/margin for custom shape, for solder paste/mask
743 
744  // Choose drawing settings depending on if we are drawing a pad itself or a hole
745  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
746  {
747  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
748  size = getDrillSize( aPad ) / 2.0;
750  }
751  else if( aLayer == F_Mask || aLayer == B_Mask )
752  {
753  // Drawing soldermask
754  int soldermaskMargin = aPad->GetSolderMaskMargin();
755  custom_margin = soldermaskMargin;
756 
757  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
758  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
759  aPad->GetSize().y / 2.0 + soldermaskMargin );
760  shape = aPad->GetShape();
761  }
762  else if( aLayer == F_Paste || aLayer == B_Paste )
763  {
764  // Drawing solderpaste
765  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
766  // try to find a clearance which can be used for custom shapes
767  custom_margin = solderpasteMargin.x;
768 
769  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
770  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
771  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
772  shape = aPad->GetShape();
773  }
774  else
775  {
776  // Drawing every kind of pad
777  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
778  size = VECTOR2D( aPad->GetSize() ) / 2.0;
779  shape = aPad->GetShape();
780  }
781 
782  switch( shape )
783  {
784  case PAD_SHAPE_OVAL:
785  if( size.y >= size.x )
786  {
787  m = ( size.y - size.x );
788  n = size.x;
789 
791  {
792  // Outline mode
793  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
794  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
795  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
796  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
797  }
798  else
799  {
800  // Filled mode
801  m_gal->DrawCircle( VECTOR2D( 0, -m ), n );
802  m_gal->DrawCircle( VECTOR2D( 0, m ), n );
803  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
804  }
805  }
806  else
807  {
808  m = ( size.x - size.y );
809  n = size.y;
810 
812  {
813  // Outline mode
814  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
815  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
816  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
817  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
818  }
819  else
820  {
821  // Filled mode
822  m_gal->DrawCircle( VECTOR2D( -m, 0 ), n );
823  m_gal->DrawCircle( VECTOR2D( m, 0 ), n );
824  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
825  }
826  }
827  break;
828 
829  case PAD_SHAPE_RECT:
830  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
831  break;
832 
833  case PAD_SHAPE_ROUNDRECT:
834  {
835  SHAPE_POLY_SET polySet;
836  wxSize prsize( size.x * 2, size.y * 2 );
837  const int segmentToCircleCount = 64;
838  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
839  TransformRoundRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
840  0.0, corner_radius, segmentToCircleCount );
841  m_gal->DrawPolygon( polySet );
842  break;
843  }
844 
845  case PAD_SHAPE_CUSTOM:
846  { // Draw the complex custom shape
847 
848  // Use solder[Paste/Mask]size or pad size to build pad shape
849  // however, solder[Paste/Mask] size has no actual meaning for a
850  // custom shape, because it is a set of basic shapes
851  // We use the custom_margin (good for solder mask, but approximative
852  // for solder paste).
853  if( custom_margin )
854  {
855  SHAPE_POLY_SET outline;
856  outline.Append( aPad->GetCustomShapeAsPolygon() );
857  const int segmentToCircleCount = 32;
858  outline.Inflate( custom_margin, segmentToCircleCount );
859  m_gal->DrawPolygon( outline );
860  }
861  else
862  {
863  // Draw the polygon: only one polygon is expected
864  // However we provide a multi polygon shape drawing
865  // ( for the future or to show even an incorrect shape
867  }
868  }
869  break;
870 
871  case PAD_SHAPE_TRAPEZOID:
872  {
873  std::deque<VECTOR2D> pointList;
874  wxPoint corners[4];
875 
876  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
877  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
878 
879  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
880  SHAPE_POLY_SET polySet;
881  polySet.NewOutline();
882  polySet.Append( VECTOR2I( corners[0] ) );
883  polySet.Append( VECTOR2I( corners[1] ) );
884  polySet.Append( VECTOR2I( corners[2] ) );
885  polySet.Append( VECTOR2I( corners[3] ) );
886 
887  m_gal->DrawPolygon( polySet );
888  }
889  break;
890 
891  case PAD_SHAPE_CIRCLE:
892  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
893  break;
894  }
895 
896  m_gal->Restore();
897 
898  // Clearance lines
899  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
900  // returns already transformed coordinates
901  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
902 
903  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
904  && ( aLayer == LAYER_PAD_FR
905  || aLayer == LAYER_PAD_BK
906  || aLayer == LAYER_PADS_TH ) )
907  {
908  SHAPE_POLY_SET polySet;
909  constexpr int SEGCOUNT = 64;
910  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
912  m_gal->SetIsStroke( true );
913  m_gal->SetIsFill( false );
914  m_gal->SetStrokeColor( color );
915  m_gal->DrawPolygon( polySet );
916  }
917 }
918 
919 
920 void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
921 {
922  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
923  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
924  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
925 
926  int thickness = getLineThickness( aSegment->GetWidth() );
927  VECTOR2D start( aSegment->GetStart() );
928  VECTOR2D end( aSegment->GetEnd() );
929 
930  m_gal->SetIsFill( !sketch );
931  m_gal->SetIsStroke( sketch );
932  m_gal->SetFillColor( color );
933  m_gal->SetStrokeColor( color );
935 
936  switch( aSegment->GetShape() )
937  {
938  case S_SEGMENT:
939  m_gal->DrawSegment( start, end, thickness );
940  break;
941 
942  case S_RECT:
943  wxASSERT_MSG( false, "Not tested yet" );
944  m_gal->DrawRectangle( start, end );
945  break;
946 
947  case S_ARC:
948  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
949  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
950  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
951  thickness );
952  break;
953 
954  case S_CIRCLE:
955  if( sketch )
956  {
957  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
958  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
959  }
960  else
961  {
962  m_gal->SetLineWidth( thickness );
963  m_gal->SetIsFill( false );
964  m_gal->SetIsStroke( true );
965  m_gal->DrawCircle( start, aSegment->GetRadius() );
966  }
967  break;
968 
969  case S_POLYGON:
970  {
971  const auto& points = aSegment->BuildPolyPointsList();
972  std::deque<VECTOR2D> pointsList;
973 
974  if( points.empty() )
975  break;
976 
977  m_gal->Save();
978 
979  if( MODULE* module = aSegment->GetParentModule() )
980  {
981  m_gal->Translate( module->GetPosition() );
982  m_gal->Rotate( -module->GetOrientationRadians() );
983  }
984 
985  std::copy( points.begin(), points.end(), std::back_inserter( pointsList ) );
986  pointsList.push_back( points[0] );
987 
988  m_gal->SetLineWidth( thickness );
989  m_gal->SetIsFill( true );
990  m_gal->SetIsStroke( true );
991  m_gal->DrawPolygon( pointsList );
992 
993  m_gal->Restore();
994  break;
995  }
996 
997  case S_CURVE:
998  m_gal->SetIsFill( false );
999  m_gal->SetIsStroke( true );
1000  m_gal->SetLineWidth( thickness );
1001  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
1002  VECTOR2D( aSegment->GetBezControl1() ),
1003  VECTOR2D( aSegment->GetBezControl2() ),
1004  VECTOR2D( aSegment->GetEnd() ) );
1005  break;
1006 
1007  case S_LAST:
1008  break;
1009  }
1010 }
1011 
1012 
1013 void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
1014 {
1015  wxString shownText( aText->GetShownText() );
1016  if( shownText.Length() == 0 )
1017  return;
1018 
1019  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1020  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1021 
1022  if( m_pcbSettings.m_sketchMode[aLayer] )
1023  {
1024  // Outline mode
1026  }
1027  else
1028  {
1029  // Filled mode
1031  }
1032 
1033  m_gal->SetStrokeColor( color );
1034  m_gal->SetIsFill( false );
1035  m_gal->SetIsStroke( true );
1036  m_gal->SetTextAttributes( aText );
1037  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1038 }
1039 
1040 
1041 void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
1042 {
1043  wxString shownText( aText->GetShownText() );
1044  if( shownText.Length() == 0 )
1045  return;
1046 
1047  bool sketch = m_pcbSettings.m_sketchFpTxtfx;
1048 
1049  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1050  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1051 
1052  // Currently, draw text routines do not know the true outline mode.
1053  // so draw the text in "line" mode (no thickness)
1054  if( sketch )
1055  {
1056  // Outline mode
1058  }
1059  else
1060  {
1061  // Filled mode
1063  }
1064 
1065  m_gal->SetStrokeColor( color );
1066  m_gal->SetIsFill( false );
1067  m_gal->SetIsStroke( true );
1068  m_gal->SetTextAttributes( aText );
1069  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1070 
1071  // Draw the umbilical line
1072  if( aText->IsSelected() )
1073  {
1075  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1076  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1077  }
1078 }
1079 
1080 
1081 void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
1082 {
1083  if( aLayer == LAYER_ANCHOR )
1084  {
1085  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1086 
1087  // Draw anchor
1088  m_gal->SetStrokeColor( color );
1090 
1091  // Keep the size constant, not related to the scale
1092  double anchorSize = 5.0 / m_gal->GetWorldScale();
1093 
1094  VECTOR2D center = aModule->GetPosition();
1095  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1096  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1097  }
1098 }
1099 
1100 
1101 void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer )
1102 {
1103  if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
1104  return;
1105 
1106  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1107  std::deque<VECTOR2D> corners;
1109 
1110  // Draw the outline
1111  const SHAPE_POLY_SET* outline = aZone->Outline();
1112 
1113  if( m_pcbSettings.m_zoneOutlines && outline )
1114  {
1115  m_gal->SetStrokeColor( color );
1116  m_gal->SetIsFill( false );
1117  m_gal->SetIsStroke( true );
1119 
1120  // Draw each contour (main contour and holes)
1121 
1122  /* This line:
1123  * m_gal->DrawPolygon( *outline );
1124  * should be enough, but currently does not work to draw holes contours in a complex polygon
1125  * so each contour is draw as a simple polygon
1126  */
1127 
1128  // Draw the main contour
1129  m_gal->DrawPolyline( outline->COutline( 0 ) );
1130 
1131  // Draw holes
1132  int holes_count = outline->HoleCount( 0 );
1133 
1134  for( int ii = 0; ii < holes_count; ++ii )
1135  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1136 
1137  // Draw hatch lines
1138  for( const SEG& hatchLine : aZone->GetHatchLines() )
1139  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1140  }
1141 
1142  // Draw the filling
1143  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1144  {
1145  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1146 
1147  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1148  return;
1149 
1150  // Set up drawing options
1151  m_gal->SetFillColor( color );
1152  m_gal->SetLineWidth( aZone->GetMinThickness() );
1153 
1154  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1155  {
1156  m_gal->SetIsFill( true );
1157  m_gal->SetIsStroke( true );
1158  }
1159  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1160  {
1161  m_gal->SetIsFill( false );
1162  m_gal->SetIsStroke( true );
1163  }
1164 
1165  m_gal->DrawPolygon( polySet );
1166  }
1167 
1168 }
1169 
1170 
1171 void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
1172 {
1173  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1174 
1175  m_gal->SetStrokeColor( strokeColor );
1176  m_gal->SetIsFill( false );
1177  m_gal->SetIsStroke( true );
1178  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1179 
1180  // Draw an arrow
1181  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1182  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1183  VECTOR2D( aDimension->m_featureLineGF ) );
1184  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1185  VECTOR2D( aDimension->m_featureLineDF ) );
1186  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1187  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1188  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1189  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1190 
1191  // Draw text
1192  TEXTE_PCB& text = aDimension->Text();
1193  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1194 
1195  m_gal->SetLineWidth( text.GetThickness() );
1196  m_gal->SetTextAttributes( &text );
1197  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1198 }
1199 
1200 
1201 void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
1202 {
1203  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1204  VECTOR2D position( aTarget->GetPosition() );
1205  double size, radius;
1206 
1207  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1208  m_gal->SetStrokeColor( strokeColor );
1209  m_gal->SetIsFill( false );
1210  m_gal->SetIsStroke( true );
1211 
1212  m_gal->Save();
1213  m_gal->Translate( position );
1214 
1215  if( aTarget->GetShape() )
1216  {
1217  // shape x
1218  m_gal->Rotate( M_PI / 4.0 );
1219  size = 2.0 * aTarget->GetSize() / 3.0;
1220  radius = aTarget->GetSize() / 2.0;
1221  }
1222  else
1223  {
1224  // shape +
1225  size = aTarget->GetSize() / 2.0;
1226  radius = aTarget->GetSize() / 3.0;
1227  }
1228 
1229  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1230  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1231  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1232 
1233  m_gal->Restore();
1234 }
1235 
1236 
1237 void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
1238 {
1239  const int scale = MARKER_PCB::MarkerScale();
1240 
1241  // If you are changing this, update MARKER_PCB::ViewBBox()
1242  const VECTOR2D arrow[] = {
1243  VECTOR2D( 0 * scale, 0 * scale ),
1244  VECTOR2D( 8 * scale, 1 * scale ),
1245  VECTOR2D( 4 * scale, 3 * scale ),
1246  VECTOR2D( 13 * scale, 8 * scale ),
1247  VECTOR2D( 9 * scale, 9 * scale ),
1248  VECTOR2D( 8 * scale, 13 * scale ),
1249  VECTOR2D( 3 * scale, 4 * scale ),
1250  VECTOR2D( 1 * scale, 8 * scale ),
1251  VECTOR2D( 0 * scale, 0 * scale )
1252  };
1253 
1254  auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
1255 
1256  m_gal->Save();
1257  m_gal->Translate( aMarker->GetPosition() );
1258  m_gal->SetFillColor( strokeColor );
1259  m_gal->SetIsFill( true );
1260  m_gal->SetIsStroke( false );
1261  m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
1262  m_gal->Restore();
1263 }
1264 
1265 
1266 const double PCB_RENDER_SETTINGS::MAX_FONT_SIZE = Millimeter2iu( 10.0 );
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
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
#define DIM(x)
of elements in an array
Definition: macros.h:98
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
BOARD_ITEM_CONTAINER * GetParent() const
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
COLOR4D m_hiContrastColor
Color used for high contrast display mode.
Definition: painter.h:276
to draw blind/buried vias
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
virtual int getDrillShape(const D_PAD *aPad) const
Return drill shape of a pad.
const wxPoint & GetBezControl2() const
const wxPoint GetPosition() const override
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...
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
TEXTE_PCB class definition.
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool IsBrightened() const
Definition: base_struct.h:227
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
multilayer pads, usually with holes
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
int GetMinThickness() const
Definition: class_zone.h:204
wxPoint m_crossBarF
Handle colors used to draw all items or layers.
int GetWidth() const
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
Colors for all layers (highlighted)
Definition: painter.h:266
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:263
double GetWorldScale() const
Get the world scale.
wxPoint m_arrowD1F
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:341
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 PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
handle color for not plated holes (holes, not pads)
anchor of items having an anchor point (texts, footprints)
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
int GetWidth() const
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_zone.cpp:265
Class BOARD to handle a board.
bool m_sketchMode[GAL_LAYER_ID_END]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:167
void TransformRoundRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, int aCircleToSegmentsCount)
Function TransformRoundRectToPolygon convert a rectangle with rounded corners to a polygon Convert ar...
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)
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
double GetArcAngleStart() const
function GetArcAngleStart()
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:242
bool IsSelected() const
Definition: base_struct.h:224
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:179
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
to draw via holes (pad holes do not use this layer)
bool m_sketchBoardGfx
Flag determining if board graphic items should be outlined or stroked
Definition: pcb_painter.h:170
Classes to handle copper zones.
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:279
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:197
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:388
usual segment : line with rounded ends
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
bool m_sketchFpTxtfx
Flag determining if footprint text items should be outlined or stroked
Definition: pcb_painter.h:176
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
wxPoint m_featureLineDF
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:84
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
int OutlineCount() const
Returns the number of outlines in the set
Add new GAL layers here.
COLOR4D m_selectionCandidateColor
Color used for highlighting selection candidates
Definition: pcb_painter.h:203
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW...
Definition: view_item.h:84
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
#define cu(a)
Definition: auxiliary.h:88
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: pcb_painter.cpp:76
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
smd pads, back layer
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void NORMALIZE_ANGLE_90(T &Angle)
Definition: trigo.h:320
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:182
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
const wxPoint & GetEnd() const
Definition: class_track.h:119
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:680
PAD_SHAPE_T
Enum PAD_SHAPE_T is the set of pad shapes, used with D_PAD::{Set,Get}Shape()
Definition: pad_shapes.h:31
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
virtual void Rotate(double aAngle)
Rotate the context.
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint)
Draw a cubic bezier spline.
wxPoint m_featureLineGO
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
DIMENSION class definition.
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:260
void SetFontBold(const bool aBold)
Set bold property of current font.
segment with non rounded ends
class MODULE, a footprint
Definition: typeinfo.h:89
Markers used to show a drc problem on boards.
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:308
double a
Alpha component.
Definition: color4d.h:290
STROKE_T GetShape() const
int GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
Colors for all layers (darkened)
Definition: painter.h:272
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:292
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
void ResetTextAttributes()
Reset text attributes to default styling.
VIATYPE_T GetViaType() const
Definition: class_track.h:457
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:194
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool m_hiContrastEnabled
Parameters for display modes.
Definition: painter.h:275
const int maxSize
virtual void update()
Function update Precalculates extra colors for layers (e.g.
Definition: painter.cpp:53
Class SHAPE_POLY_SET.
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:594
const wxPoint & GetStart() const
Definition: class_track.h:122
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
static int MarkerScale()
A scaling factor to create the marker symbol.
Arcs (with rounded ends)
to draw usual through hole vias
wxPoint m_arrowG1F
wxPoint m_arrowD2F
wxPoint m_arrowG2F
last value for this list
double GetOrientationRadians() const
Definition: class_pad.h:384
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
const wxSize & GetSize() const
Definition: class_pad.h:269
const wxString & GetName() const
Definition: class_pad.h:190
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const wxPoint & GetBezControl1() const
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
Bezier Curve.
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
int NewOutline()
Creates a new empty polygon in the set and returns its index
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:555
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
bool m_sketchFpGfx
Flag determining if footprint graphic items should be outlined or stroked
Definition: pcb_painter.h:173
Pad object description.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
virtual const wxPoint GetPosition() const =0
int GetNetCode() const
Function GetNetCode.
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS *aOptions, bool aShowPageLimits)
Function LoadDisplayOptions Loads settings related to display options (high-contrast mode...
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Definition: seg.h:36
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:185
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:292
COLOR4D Inverted() const
Function Inverted Returns an inverted color, alpha remains the same.
Definition: color4d.h:245
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
const int scale
double GetAngle() const
smd pads, front layer
virtual void Restore()
Restore the context.
const wxString & GetNetname() const
Function GetNetname.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:200
Board layer functions and definitions.
Class to handle a graphic segment.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
int GetWidth() const
Definition: class_track.h:116
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
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: pcb_painter.h:154
double DECIDEG2RAD(double deg)
Definition: trigo.h:203
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:637
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:563
int GetWidth() const
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
wxPoint ShapePos() const
Definition: class_pad.cpp:517
PCB_PAINTER(GAL *aGal)
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
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...
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
wxPoint m_crossBarO
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
PCB_TARGET class definition.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
int m_highlightNetcode
Net number that is displayed in highlight -1 means that there is no specific net, and whole active la...
Definition: painter.h:280
bool m_zoneOutlines
Flag determining if zones should have outlines drawn
Definition: pcb_painter.h:191
Module description (excepted pads)
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
const wxPoint GetPosition() const override
Definition: class_pad.h:220
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void draw(const TRACK *aTrack, int aLayer)
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
double GetTextAngleRadians() const
Definition: eda_text.h:180
class SEGZONE, a segment used to fill a zone area (segment on a
Definition: typeinfo.h:97
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxPoint m_featureLineDO
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:469
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:1250
Definition of PCB_DISPLAY_OPTIONS class.
const wxPoint GetPosition() const override
Definition: class_module.h:184
Class DIMENSION.
const wxPoint & GetOffset() const
Definition: class_pad.h:278
Additional netnames layers (not associated with a PCB layer)
const wxPoint GetPosition() const override
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:188
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
Colors for all layers (selected)
Definition: painter.h:269
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
#define min(a, b)
Definition: auxiliary.h:85
Class GAL is the abstract interface for drawing on a 2D-surface.
#define SEGCOUNT
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
const wxString & GetShortNetname() const
Function GetShortNetname.
wxPoint m_featureLineGF
double GetDrawRotationRadians() const