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