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;
140 
141  // Whether to draw tracks, vias & pads filled or as outlines
147 
148  // Net names display settings
149  switch( aOptions->m_DisplayNetNamesMode )
150  {
151  case 0:
152  m_netNamesOnPads = false;
153  m_netNamesOnTracks = false;
154  break;
155 
156  case 1:
157  m_netNamesOnPads = true;
158  m_netNamesOnTracks = false;
159  break;
160 
161  case 2:
162  m_netNamesOnPads = false;
163  m_netNamesOnTracks = true;
164  break;
165 
166  case 3:
167  m_netNamesOnPads = true;
168  m_netNamesOnTracks = true;
169  break;
170  }
171 
172  // Zone display settings
173  switch( aOptions->m_DisplayZonesMode )
174  {
175  case 0:
177  break;
178 
179  case 1:
181  break;
182 
183  case 2:
185  break;
186  }
187 
188  // Clearance settings
189  switch( aOptions->m_ShowTrackClearanceMode )
190  {
193  break;
194 
197  break;
198 
201  break;
202 
205  break;
206 
209  break;
210  }
211 
212  if( aOptions->m_DisplayPadIsol )
213  m_clearance |= CL_PADS;
214 
215  m_showPageLimits = aShowPageLimits;
216 }
217 
218 
219 const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
220 {
221  int netCode = -1;
222  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
223 
224  if( item )
225  {
226  // Selection disambiguation
227  if( item->IsBrightened() )
228  {
230  }
231 
232  // Don't let pads that *should* be NPTHs get lost
233  if( item->Type() == PCB_PAD_T && dyn_cast<const D_PAD*>( item )->PadShouldBeNPTH() )
234  aLayer = LAYER_MOD_TEXT_INVISIBLE;
235 
236  if( item->IsSelected() )
237  {
238  return m_layerColorsSel[aLayer];
239  }
240 
241  // Try to obtain the netcode for the item
242  if( const BOARD_CONNECTED_ITEM* conItem = dyn_cast<const BOARD_CONNECTED_ITEM*> ( item ) )
243  netCode = conItem->GetNetCode();
244 
245  if( item->Type() == PCB_MARKER_T )
246  return m_layerColors[aLayer];
247  }
248 
249  // Single net highlight mode
250  if( m_highlightEnabled && netCode == m_highlightNetcode )
251  return m_layerColorsHi[aLayer];
252 
253  // Return grayish color for non-highlighted layers in the high contrast mode
254  if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
255  return m_hiContrastColor;
256 
257  // Catch the case when highlight and high-contraste modes are enabled
258  // and we are drawing a not highlighted track
259  if( m_highlightEnabled )
260  return m_layerColorsDark[aLayer];
261 
262  // No special modificators enabled
263  return m_layerColors[aLayer];
264 }
265 
266 
268  PAINTER( aGal )
269 {
270 }
271 
272 
273 int PCB_PAINTER::getLineThickness( int aActualThickness ) const
274 {
275  // if items have 0 thickness, draw them with the outline
276  // width, otherwise respect the set value (which, no matter
277  // how small will produce something)
278  if( aActualThickness == 0 )
280 
281  return aActualThickness;
282 }
283 
284 
285 int PCB_PAINTER::getDrillShape( const D_PAD* aPad ) const
286 {
287  return aPad->GetDrillShape();
288 }
289 
290 
292 {
293  return VECTOR2D( aPad->GetDrillSize() );
294 }
295 
296 
297 int PCB_PAINTER::getDrillSize( const VIA* aVia ) const
298 {
299  return aVia->GetDrillValue();
300 }
301 
302 
303 bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
304 {
305  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
306 
307  if( !item )
308  return false;
309 
310  // the "cast" applied in here clarifies which overloaded draw() is called
311  switch( item->Type() )
312  {
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 = UnescapeString( 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  wxString netname = UnescapeString( aVia->GetShortNetname() );
474  // calculate the size of net name text:
475  double tsize = 1.5 * size / netname.Length();
476  tsize = std::min( tsize, size );
477  // Use a smaller text size to handle interline, pen size..
478  tsize *= 0.7;
479  VECTOR2D namesize( tsize, tsize );
480 
481  m_gal->SetGlyphSize( namesize );
482  m_gal->SetLineWidth( namesize.x / 12.0 );
483  m_gal->BitmapText( netname, textpos, 0.0 );
484  }
485 
486 
487  m_gal->Restore();
488  }
489  return;
490  }
491 
492  // Choose drawing settings depending on if we are drawing via's pad or hole
493  if( aLayer == LAYER_VIAS_HOLES )
494  radius = getDrillSize( aVia ) / 2.0;
495  else
496  radius = aVia->GetWidth() / 2.0;
497 
498  bool sketchMode = false;
499  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
500 
501  switch( aVia->GetViaType() )
502  {
503  case VIA_THROUGH:
505  break;
506 
507  case VIA_BLIND_BURIED:
509  break;
510 
511  case VIA_MICROVIA:
513  break;
514 
515  default:
516  assert( false );
517  break;
518  }
519 
520  if( aVia->GetViaType() == VIA_BLIND_BURIED )
521  {
522  // Buried vias are drawn in a special way to indicate the top and bottom layers
523  PCB_LAYER_ID layerTop, layerBottom;
524  aVia->LayerPair( &layerTop, &layerBottom );
525 
526  if( aLayer == LAYER_VIAS_HOLES )
527  { // TODO outline mode
528  m_gal->SetIsFill( true );
529  m_gal->SetIsStroke( false );
531  m_gal->DrawCircle( center, radius );
532  }
533  else
534  {
535  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
536 
537  m_gal->SetLineWidth( width );
538  m_gal->SetIsFill( true );
539  m_gal->SetIsStroke( false );
541 
542  if( aLayer == layerTop )
543  {
544  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
545  }
546  else if( aLayer == layerBottom )
547  {
548  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
549  }
550  else if( aLayer == LAYER_VIA_BBLIND )
551  {
552  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
553  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
554  }
555  }
556  }
557  else
558  {
559  // Regular vias
560  m_gal->SetIsFill( !sketchMode );
561  m_gal->SetIsStroke( sketchMode );
562 
563  if( sketchMode )
564  {
565  // Outline mode
568  }
569  else
570  {
571  // Filled mode
573  }
574 
575  m_gal->DrawCircle( center, radius );
576  }
577 
578  // Clearance lines
579  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
580 
581  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
582  && aLayer != LAYER_VIAS_HOLES )
583  {
585  m_gal->SetIsFill( false );
586  m_gal->SetIsStroke( true );
588  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
589  }
590 }
591 
592 
593 void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
594 {
595  PAD_SHAPE_T shape;
596  double m, n;
597  double orientation = aPad->GetOrientation();
598 
599  // Draw description layer
600  if( IsNetnameLayer( aLayer ) )
601  {
602  VECTOR2D position( aPad->ShapePos() );
603 
604  // Is anything that we can display enabled?
606  {
607  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
608  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
609  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
610  double size = padsize.y;
611 
612  // Keep the size ratio for the font, but make it smaller
613  if( padsize.x < padsize.y )
614  {
615  orientation += 900.0;
616  size = padsize.x;
617  std::swap( padsize.x, padsize.y );
618  }
619  else if( padsize.x == padsize.y )
620  {
621  // If the text is displayed on a symmetrical pad, do not rotate it
622  orientation = 0.0;
623  }
624 
625  // Font size limits
626  if( size > maxSize )
627  size = maxSize;
628 
629  m_gal->Save();
630  m_gal->Translate( position );
631 
632  // do not display descriptions upside down
633  NORMALIZE_ANGLE_90( orientation );
634  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
635 
636  // Default font settings
639  m_gal->SetFontBold( false );
640  m_gal->SetFontItalic( false );
641  m_gal->SetTextMirrored( false );
642  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
643  m_gal->SetIsStroke( true );
644  m_gal->SetIsFill( false );
645 
646  // Set the text position to the pad shape position (the pad position is not the best place)
647  VECTOR2D textpos( 0.0, 0.0 );
648 
649  // Divide the space, to display both pad numbers and netnames
650  // and set the Y text position to display 2 lines
651  if( displayNetname && m_pcbSettings.m_padNumbers )
652  {
653  size = size / 2.0;
654  textpos.y = size / 2.0;
655  }
656 
657  if( displayNetname )
658  {
659  wxString netname = UnescapeString( aPad->GetShortNetname() );
660  // calculate the size of net name text:
661  double tsize = 1.5 * padsize.x / netname.Length();
662  tsize = std::min( tsize, size );
663  // Use a smaller text size to handle interline, pen size..
664  tsize *= 0.7;
665  VECTOR2D namesize( tsize, tsize );
666 
667  m_gal->SetGlyphSize( namesize );
668  m_gal->SetLineWidth( namesize.x / 12.0 );
669  m_gal->BitmapText( netname, textpos, 0.0 );
670  }
671 
673  {
674  const wxString& padName = aPad->GetName();
675  textpos.y = -textpos.y;
676  double tsize = 1.5 * padsize.x / padName.Length();
677  tsize = std::min( tsize, size );
678  // Use a smaller text size to handle interline, pen size..
679  tsize *= 0.7;
680  tsize = std::min( tsize, size );
681  VECTOR2D numsize( tsize, tsize );
682 
683  m_gal->SetGlyphSize( numsize );
684  m_gal->SetLineWidth( numsize.x / 12.0 );
685  m_gal->BitmapText( padName, textpos, 0.0 );
686  }
687 
688  m_gal->Restore();
689  }
690  return;
691  }
692 
693  // Pad drawing
694  COLOR4D color;
695 
696  // Pad holes color is type specific
697  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
698  {
699  // Hole color is the background color for plated holes, but a specific color
700  // for not plated holes (LAYER_NON_PLATEDHOLES color layer )
703  // Don't let pads that *should* be NPTH get lost
704  else if( aPad->PadShouldBeNPTH() )
705  color = m_pcbSettings.GetColor( aPad, aLayer );
706  else
708  }
709  else
710  {
711  color = m_pcbSettings.GetColor( aPad, aLayer );
712  }
713 
714  VECTOR2D size;
715 
717  {
718  // Outline mode
719  m_gal->SetIsFill( false );
720  m_gal->SetIsStroke( true );
723  }
724  else
725  {
726  // Filled mode
727  m_gal->SetIsFill( true );
728  m_gal->SetIsStroke( false );
730  }
731 
732  m_gal->Save();
733  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
734  m_gal->Rotate( -aPad->GetOrientationRadians() );
735 
736  int custom_margin = 0; // a clearance/margin for custom shape, for solder paste/mask
737 
738  // Choose drawing settings depending on if we are drawing a pad itself or a hole
739  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
740  {
741  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
742  size = getDrillSize( aPad ) / 2.0;
744  }
745  else if( aLayer == F_Mask || aLayer == B_Mask )
746  {
747  // Drawing soldermask
748  int soldermaskMargin = aPad->GetSolderMaskMargin();
749  custom_margin = soldermaskMargin;
750 
751  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
752  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
753  aPad->GetSize().y / 2.0 + soldermaskMargin );
754  shape = aPad->GetShape();
755  }
756  else if( aLayer == F_Paste || aLayer == B_Paste )
757  {
758  // Drawing solderpaste
759  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
760  // try to find a clearance which can be used for custom shapes
761  custom_margin = solderpasteMargin.x;
762 
763  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
764  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
765  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
766  shape = aPad->GetShape();
767  }
768  else
769  {
770  // Drawing every kind of pad
771  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
772  size = VECTOR2D( aPad->GetSize() ) / 2.0;
773  shape = aPad->GetShape();
774  }
775 
776  switch( shape )
777  {
778  case PAD_SHAPE_OVAL:
779  if( size.y >= size.x )
780  {
781  m = ( size.y - size.x );
782  n = size.x;
783 
784  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
785  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
786 
788  {
789  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
790  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
791  }
792  else
793  {
794  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
795  }
796  }
797  else
798  {
799  m = ( size.x - size.y );
800  n = size.y;
801  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
802  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
803 
805  {
806  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
807  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
808  }
809  else
810  {
811  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
812  }
813  }
814  break;
815 
816  case PAD_SHAPE_RECT:
817  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
818  break;
819 
820  case PAD_SHAPE_ROUNDRECT:
822  {
823  SHAPE_POLY_SET polySet;
824  wxSize prsize( size.x * 2, size.y * 2 ); // size is the half pad area size)
825  const int segmentToCircleCount = 64;
826  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
827  bool doChamfer = shape == PAD_SHAPE_CHAMFERED_RECT;
828 
829  TransformRoundChamferedRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
830  0.0, corner_radius, aPad->GetChamferRectRatio(),
831  doChamfer ? aPad->GetChamferPositions() : 0, segmentToCircleCount );
832  m_gal->DrawPolygon( polySet );
833  break;
834  }
835 
836  case PAD_SHAPE_CUSTOM:
837  { // Draw the complex custom shape
838 
839  // Use solder[Paste/Mask]size or pad size to build pad shape
840  // however, solder[Paste/Mask] size has no actual meaning for a
841  // custom shape, because it is a set of basic shapes
842  // We use the custom_margin (good for solder mask, but approximative
843  // for solder paste).
844  if( custom_margin )
845  {
846  SHAPE_POLY_SET outline;
847  outline.Append( aPad->GetCustomShapeAsPolygon() );
848  const int segmentToCircleCount = ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF;
849  // outline polygon can have holes linked to the main outline.
850  // So use InflateWithLinkedHoles(), not Inflate() that can create
851  // bad shapes if custom_margin is < 0
852  outline.InflateWithLinkedHoles( custom_margin, segmentToCircleCount, SHAPE_POLY_SET::PM_FAST );
853  m_gal->DrawPolygon( outline );
854  }
855  else
856  {
857  // Draw the polygon: only one polygon is expected
858  // However we provide a multi polygon shape drawing
859  // ( for the future or to show even an incorrect shape
861  }
862  }
863  break;
864 
865  case PAD_SHAPE_TRAPEZOID:
866  {
867  std::deque<VECTOR2D> pointList;
868  wxPoint corners[4];
869 
870  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
871  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
872 
873  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
874  SHAPE_POLY_SET polySet;
875  polySet.NewOutline();
876  polySet.Append( VECTOR2I( corners[0] ) );
877  polySet.Append( VECTOR2I( corners[1] ) );
878  polySet.Append( VECTOR2I( corners[2] ) );
879  polySet.Append( VECTOR2I( corners[3] ) );
880 
881  m_gal->DrawPolygon( polySet );
882  }
883  break;
884 
885  case PAD_SHAPE_CIRCLE:
886  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
887  break;
888  }
889 
890  m_gal->Restore();
891 
892  // Clearance lines
893  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
894  // returns already transformed coordinates
895  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
896 
897  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
898  && ( aLayer == LAYER_PAD_FR
899  || aLayer == LAYER_PAD_BK
900  || aLayer == LAYER_PADS_TH ) )
901  {
902  SHAPE_POLY_SET polySet;
903  constexpr int SEGCOUNT = 64;
904  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
906  m_gal->SetIsStroke( true );
907  m_gal->SetIsFill( false );
909  m_gal->DrawPolygon( polySet );
910  }
911 }
912 
913 
914 void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
915 {
916  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
917  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
918  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
919 
920  int thickness = getLineThickness( aSegment->GetWidth() );
921  VECTOR2D start( aSegment->GetStart() );
922  VECTOR2D end( aSegment->GetEnd() );
923 
924  m_gal->SetIsFill( !sketch );
925  m_gal->SetIsStroke( sketch );
929 
930  switch( aSegment->GetShape() )
931  {
932  case S_SEGMENT:
933  m_gal->DrawSegment( start, end, thickness );
934  break;
935 
936  case S_RECT:
937  wxASSERT_MSG( false, "Not tested yet" );
938  m_gal->DrawRectangle( start, end );
939  break;
940 
941  case S_ARC:
942  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
943  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
944  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
945  thickness );
946  break;
947 
948  case S_CIRCLE:
949  if( sketch )
950  {
951  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
952  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
953  }
954  else
955  {
956  m_gal->SetLineWidth( thickness );
957  m_gal->SetIsFill( false );
958  m_gal->SetIsStroke( true );
959  m_gal->DrawCircle( start, aSegment->GetRadius() );
960  }
961  break;
962 
963  case S_POLYGON:
964  {
965  SHAPE_POLY_SET& shape = ((DRAWSEGMENT*)aSegment)->GetPolyShape();
966 
967  if( shape.OutlineCount() == 0 )
968  break;
969 
970  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
971  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
972  // on Opengl.
973  // GLU tesselation is much slower, so currently we are using our tesselation.
974  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
975  {
976  shape.CacheTriangulation();
977  }
978 
979  m_gal->Save();
980 
981  if( MODULE* module = aSegment->GetParentModule() )
982  {
983  m_gal->Translate( module->GetPosition() );
984  m_gal->Rotate( -module->GetOrientationRadians() );
985  }
986 
987  m_gal->SetLineWidth( thickness );
988 
989  if( sketch )
990  m_gal->SetIsFill( false );
991  else
992  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
993 
994  m_gal->SetIsStroke( true );
995  m_gal->DrawPolygon( shape );
996 
997  m_gal->Restore();
998  break;
999  }
1000 
1001  case S_CURVE:
1002  m_gal->SetIsFill( false );
1003  m_gal->SetIsStroke( true );
1004  m_gal->SetLineWidth( thickness );
1005  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
1006  VECTOR2D( aSegment->GetBezControl1() ),
1007  VECTOR2D( aSegment->GetBezControl2() ),
1008  VECTOR2D( aSegment->GetEnd() ) );
1009  break;
1010 
1011  case S_LAST:
1012  break;
1013  }
1014 }
1015 
1016 
1017 void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
1018 {
1019  wxString shownText( aText->GetShownText() );
1020  if( shownText.Length() == 0 )
1021  return;
1022 
1023  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1024  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1025 
1026  if( m_pcbSettings.m_sketchMode[aLayer] )
1027  {
1028  // Outline mode
1030  }
1031  else
1032  {
1033  // Filled mode
1035  }
1036 
1038  m_gal->SetIsFill( false );
1039  m_gal->SetIsStroke( true );
1040  m_gal->SetTextAttributes( aText );
1041  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1042 }
1043 
1044 
1045 void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
1046 {
1047  wxString shownText( aText->GetShownText() );
1048  if( shownText.Length() == 0 )
1049  return;
1050 
1051  bool sketch = m_pcbSettings.m_sketchFpTxtfx;
1052 
1053  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1054  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1055 
1056  // Currently, draw text routines do not know the true outline mode.
1057  // so draw the text in "line" mode (no thickness)
1058  if( sketch )
1059  {
1060  // Outline mode
1062  }
1063  else
1064  {
1065  // Filled mode
1067  }
1068 
1070  m_gal->SetIsFill( false );
1071  m_gal->SetIsStroke( true );
1072  m_gal->SetTextAttributes( aText );
1073  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1074 
1075  // Draw the umbilical line
1076  if( aText->IsSelected() )
1077  {
1079  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1080  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1081  }
1082 }
1083 
1084 
1085 void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
1086 {
1087  if( aLayer == LAYER_ANCHOR )
1088  {
1089  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1090 
1091  // Draw anchor
1094 
1095  // Keep the size constant, not related to the scale
1096  double anchorSize = 5.0 / m_gal->GetWorldScale();
1097 
1098  VECTOR2D center = aModule->GetPosition();
1099  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1100  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1101  }
1102 }
1103 
1104 
1105 void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer )
1106 {
1107  if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
1108  return;
1109 
1110  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1111  std::deque<VECTOR2D> corners;
1113 
1114  // Draw the outline
1115  const SHAPE_POLY_SET* outline = aZone->Outline();
1116 
1117  if( m_pcbSettings.m_zoneOutlines && outline )
1118  {
1120  m_gal->SetIsFill( false );
1121  m_gal->SetIsStroke( true );
1123 
1124  // Draw each contour (main contour and holes)
1125 
1126  /* This line:
1127  * m_gal->DrawPolygon( *outline );
1128  * should be enough, but currently does not work to draw holes contours in a complex polygon
1129  * so each contour is draw as a simple polygon
1130  */
1131 
1132  // Draw the main contour
1133  m_gal->DrawPolyline( outline->COutline( 0 ) );
1134 
1135  // Draw holes
1136  int holes_count = outline->HoleCount( 0 );
1137 
1138  for( int ii = 0; ii < holes_count; ++ii )
1139  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1140 
1141  // Draw hatch lines
1142  for( const SEG& hatchLine : aZone->GetHatchLines() )
1143  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1144  }
1145 
1146  // Draw the filling
1147  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1148  {
1149  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1150 
1151  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1152  return;
1153 
1154  // Set up drawing options
1156  m_gal->SetFillColor( color );
1157  m_gal->SetLineWidth( aZone->GetMinThickness() );
1158 
1159  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1160  {
1161  m_gal->SetIsFill( true );
1162  m_gal->SetIsStroke( true );
1163  }
1164  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1165  {
1166  m_gal->SetIsFill( false );
1167  m_gal->SetIsStroke( true );
1168  }
1169 
1170  m_gal->DrawPolygon( polySet );
1171  }
1172 
1173 }
1174 
1175 
1176 void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
1177 {
1178  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1179 
1180  m_gal->SetStrokeColor( strokeColor );
1181  m_gal->SetIsFill( false );
1182  m_gal->SetIsStroke( true );
1183  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1184 
1185  // Draw an arrow
1186  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1187  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1188  VECTOR2D( aDimension->m_featureLineGF ) );
1189  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1190  VECTOR2D( aDimension->m_featureLineDF ) );
1191  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1192  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1193  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1194  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1195 
1196  // Draw text
1197  TEXTE_PCB& text = aDimension->Text();
1198  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1199 
1200  m_gal->SetLineWidth( text.GetThickness() );
1201  m_gal->SetTextAttributes( &text );
1202  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1203 }
1204 
1205 
1206 void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
1207 {
1208  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1209  VECTOR2D position( aTarget->GetPosition() );
1210  double size, radius;
1211 
1212  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1213  m_gal->SetStrokeColor( strokeColor );
1214  m_gal->SetIsFill( false );
1215  m_gal->SetIsStroke( true );
1216 
1217  m_gal->Save();
1218  m_gal->Translate( position );
1219 
1220  if( aTarget->GetShape() )
1221  {
1222  // shape x
1223  m_gal->Rotate( M_PI / 4.0 );
1224  size = 2.0 * aTarget->GetSize() / 3.0;
1225  radius = aTarget->GetSize() / 2.0;
1226  }
1227  else
1228  {
1229  // shape +
1230  size = aTarget->GetSize() / 2.0;
1231  radius = aTarget->GetSize() / 3.0;
1232  }
1233 
1234  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1235  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1236  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1237 
1238  m_gal->Restore();
1239 }
1240 
1241 
1242 void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
1243 {
1244  SHAPE_LINE_CHAIN polygon;
1245  aMarker->ShapeToPolygon( polygon );
1246 
1247  auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
1248 
1249  m_gal->Save();
1250  m_gal->Translate( aMarker->GetPosition() );
1251  m_gal->SetFillColor( strokeColor );
1252  m_gal->SetIsFill( true );
1253  m_gal->SetIsStroke( false );
1254  m_gal->DrawPolygon( polygon );
1255  m_gal->Restore();
1256 }
1257 
1258 
1259 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:227
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:133
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:278
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:171
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:100
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:260
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:183
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:174
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:204
bool IsBrightened() const
Definition: base_struct.h:230
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
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:180
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:83
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:239
Add new GAL layers here.
COLOR4D m_selectionCandidateColor
Color used for highlighting selection candidates
Definition: pcb_painter.h:210
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:329
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:186
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:417
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:695
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 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:201
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:280
to draw usual through hole vias
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:400
double GetChamferRectRatio() const
has meaning only for chamfered rect pads
Definition: class_pad.h:672
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:437
const wxString & GetName() const
Definition: class_pad.h:192
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:98
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:708
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
bool m_curvedRatsnestlines
Flag determining if ratsnest lines should be drawn curved
Definition: pcb_painter.h:198
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:177
int GetWidth() const
Pad object description.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:99
virtual const wxPoint GetPosition() const =0
double GetOrientationRadians() const
Definition: class_pad.h:396
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:107
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:184
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:189
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:292
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:97
smd pads, front layer
virtual void Restore()
Restore the context.
int GetWidth() const
Definition: class_track.h:127
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:207
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:394
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123
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:153
const wxSize & GetDrillSize() const
Definition: class_pad.h:277
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:346
double DECIDEG2RAD(double deg)
Definition: trigo.h:212
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:157
void InflateWithLinkedHoles(int aFactor, int aCircleSegmentsCount, POLYGON_MODE aFastMode)
Performs outline inflation/deflation, using round corners.
int GetMinThickness() const
Definition: class_zone.h:199
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:130
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:543
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:241
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:195
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:218
Module description (excepted pads)
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:152
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:271
const wxPoint GetPosition() const override
Definition: class_pad.h:222
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
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:465
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:192
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:204
#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:580
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