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