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 <class_marker_pcb.h>
34 #include <class_dimension.h>
35 #include <class_pcb_target.h>
36 
38 #include <pcb_painter.h>
39 #include <pcb_display_options.h>
40 #include <project/net_settings.h>
42 
47 #include <geometry/shape_segment.h>
48 #include <geometry/shape_circle.h>
49 
50 using namespace KIGFX;
51 
53 {
54  m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
55  m_padNumbers = true;
56  m_netNamesOnPads = true;
57  m_netNamesOnTracks = true;
58  m_netNamesOnVias = true;
59  m_zoneOutlines = true;
62  m_sketchGraphics = false;
63  m_sketchText = false;
64  m_selectionCandidateColor = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
66 
67  // By default everything should be displayed as filled
68  for( unsigned int i = 0; i < arrayDim( m_sketchMode ); ++i )
69  {
70  m_sketchMode[i] = false;
71  }
72 
73  update();
74 }
75 
76 
78 {
80 
81  // Init board layers colors:
82  for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
83  {
84  m_layerColors[i] = aSettings->GetColor( i );
85 
86  // Guard: if the alpah channel is too small, the layer is not visible.
87  // clamp it to 0.2
88  if( m_layerColors[i].a < 0.2 )
89  m_layerColors[i].a = 0.2;
90  }
91 
92  // Init specific graphic layers colors:
93  for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
94  m_layerColors[i] = aSettings->GetColor( i );
95 
96  // Default colors for specific layers (not really board layers).
97  m_layerColors[LAYER_VIAS_HOLES] = COLOR4D( 0.5, 0.4, 0.0, 0.8 );
99  m_layerColors[LAYER_VIAS_NETNAMES] = COLOR4D( 0.2, 0.2, 0.2, 0.9 );
100  m_layerColors[LAYER_PADS_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
101  m_layerColors[LAYER_PAD_FR_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
102  m_layerColors[LAYER_PAD_BK_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
103 
104  // LAYER_PADS_TH, LAYER_NON_PLATEDHOLES, LAYER_ANCHOR ,LAYER_RATSNEST,
105  // LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA
106  // are initialized from aSettings
107 
108  // These colors are not actually used. Set just in case...
111 
112  // Netnames for copper layers
113  for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
114  {
115  const COLOR4D lightLabel( 0.8, 0.8, 0.8, 0.7 );
116  const COLOR4D darkLabel = lightLabel.Inverted();
117  PCB_LAYER_ID layer = *cu;
118 
119  if( m_layerColors[layer].GetBrightness() > 0.5 )
120  m_layerColors[GetNetnameLayer( layer )] = darkLabel;
121  else
122  m_layerColors[GetNetnameLayer( layer )] = lightLabel;
123  }
124 
125  update();
126 }
127 
128 
130  bool aShowPageLimits )
131 {
134  m_padNumbers = aOptions.m_DisplayPadNum;
136  m_sketchText = !aOptions.m_DisplayTextFill;
139 
140  // Whether to draw tracks, vias & pads filled or as outlines
146 
147  // Net names display settings
148  switch( aOptions.m_DisplayNetNamesMode )
149  {
150  case 0:
151  m_netNamesOnPads = false;
152  m_netNamesOnTracks = false;
153  m_netNamesOnVias = false;
154  break;
155 
156  case 1:
157  m_netNamesOnPads = true;
158  m_netNamesOnTracks = false;
159  m_netNamesOnVias = true; // Follow pads or tracks? For now we chose pads....
160  break;
161 
162  case 2:
163  m_netNamesOnPads = false;
164  m_netNamesOnTracks = true;
165  m_netNamesOnVias = false; // Follow pads or tracks? For now we chose pads....
166  break;
167 
168  case 3:
169  m_netNamesOnPads = true;
170  m_netNamesOnTracks = true;
171  m_netNamesOnVias = true;
172  break;
173  }
174 
175  // Zone display settings
176  switch( aOptions.m_DisplayZonesMode )
177  {
178  case 0:
180  break;
181 
182  case 1:
184  break;
185 
186  case 2:
188  break;
189  }
190 
191  // Clearance settings
192  switch( aOptions.m_ShowTrackClearanceMode )
193  {
196  break;
197 
200  break;
201 
204  break;
205 
208  break;
209 
212  break;
213  }
214 
215  if( aOptions.m_DisplayPadIsol )
216  m_clearance |= CL_PADS;
217 
219 
220  m_showPageLimits = aShowPageLimits;
221 }
222 
223 
225  const std::set<int>& aHiddenNets )
226 {
227  m_netColors.clear();
228 
229  for( const auto& pair : aSettings.m_PcbNetColors )
230  {
231  if( NETINFO_ITEM* net = aList.GetNetItem( pair.first ) )
232  m_netColors[net->GetNet()] = pair.second;
233  }
234 
235  m_netclassColors.clear();
236 
237  for( const auto& pair : aSettings.m_NetClasses )
238  {
239  if( pair.second->GetPcbColor() != COLOR4D::UNSPECIFIED )
240  m_netclassColors[pair.first] = pair.second->GetPcbColor();
241  }
242 
243  m_hiddenNets = aHiddenNets;
244 }
245 
246 
247 const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
248 {
249  int netCode = -1;
250  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
251  const BOARD_CONNECTED_ITEM* conItem = dynamic_cast<const BOARD_CONNECTED_ITEM*> ( aItem );
252 
253  // Make items invisible in "other layers hidden" contrast mode
254  if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN && m_activeLayers.count( aLayer ) == 0 )
255  return COLOR4D::CLEAR;
256 
257  // Hide net names in "dimmed" contrast mode
259  && m_activeLayers.count( aLayer ) == 0 )
260  return COLOR4D::CLEAR;
261 
262  if( item )
263  {
264  // Selection disambiguation
265  if( item->IsBrightened() )
266  {
268  }
269 
270  // Don't let pads that *should* be NPTHs get lost
271  if( item->Type() == PCB_PAD_T && dyn_cast<const D_PAD*>( item )->PadShouldBeNPTH() )
272  aLayer = LAYER_MOD_TEXT_INVISIBLE;
273 
274  if( item->IsSelected() )
275  return m_layerColorsSel[aLayer];
276 
277  if( item->Type() == PCB_MARKER_T )
278  return m_layerColors[aLayer];
279 
280  // For vias, some layers depend on other layers in high contrast mode
281  if( m_hiContrastEnabled && item->Type() == PCB_VIA_T &&
282  ( aLayer == LAYER_VIAS_HOLES ||
283  aLayer == LAYER_VIA_THROUGH ||
284  aLayer == LAYER_VIA_MICROVIA ||
285  aLayer == LAYER_VIA_BBLIND ) )
286  {
287  const VIA* via = static_cast<const VIA*>( item );
288  const BOARD* pcb = static_cast<const BOARD*>( item->GetParent() );
289  bool viaActiveLayer = false;
290 
291  for( auto activeLayer : m_activeLayers )
292  {
293  auto lay_id = static_cast<PCB_LAYER_ID>( activeLayer );
294  viaActiveLayer |= via->IsOnLayer( lay_id ) && pcb->IsLayerVisible( lay_id );
295  }
296 
297  if( viaActiveLayer )
298  return m_layerColors[aLayer];
299  else
300  return m_hiContrastColor[aLayer];
301  }
302  }
303 
304  // Try to obtain the netcode for the item
305  if( conItem )
306  netCode = conItem->GetNetCode();
307 
308  // Single net highlight mode
309  if( m_highlightEnabled && m_highlightNetcodes.count( netCode ) )
310  return m_layerColorsHi[aLayer];
311 
312  // Return grayish color for non-highlighted layers in the dimmed high contrast mode
313  if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::DIMMED && m_activeLayers.count( aLayer ) == 0 )
314  return m_hiContrastColor[aLayer];
315 
316  // Catch the case when highlight and high-contraste modes are enabled
317  // and we are drawing a not highlighted track
318  if( m_highlightEnabled )
319  return m_layerColorsDark[aLayer];
320 
321  // Apply net color overrides
322  if( conItem && m_netColorMode == NET_COLOR_MODE::ALL )
323  {
324  if( m_netColors.count( conItem->GetNetCode() ) )
325  return m_netColors.at( conItem->GetNetCode() );
326  else if( m_netclassColors.count( conItem->GetNetClassName() ) )
327  return m_netclassColors.at( conItem->GetNetClassName() );
328  }
329 
330  // No special modificators enabled
331  return m_layerColors[aLayer];
332 }
333 
334 
336  PAINTER( aGal )
337 {
338 }
339 
340 
341 int PCB_PAINTER::getLineThickness( int aActualThickness ) const
342 {
343  // if items have 0 thickness, draw them with the outline
344  // width, otherwise respect the set value (which, no matter
345  // how small will produce something)
346  if( aActualThickness == 0 )
348 
349  return aActualThickness;
350 }
351 
352 
353 int PCB_PAINTER::getDrillShape( const D_PAD* aPad ) const
354 {
355  return aPad->GetDrillShape();
356 }
357 
358 
360 {
361  return VECTOR2D( aPad->GetDrillSize() );
362 }
363 
364 
365 int PCB_PAINTER::getDrillSize( const VIA* aVia ) const
366 {
367  return aVia->GetDrillValue();
368 }
369 
370 
371 bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
372 {
373  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
374 
375  if( !item )
376  return false;
377 
378  // the "cast" applied in here clarifies which overloaded draw() is called
379  switch( item->Type() )
380  {
381  case PCB_TRACE_T:
382  draw( static_cast<const TRACK*>( item ), aLayer );
383  break;
384 
385  case PCB_ARC_T:
386  draw( static_cast<const ARC*>( item ), aLayer );
387  break;
388 
389  case PCB_VIA_T:
390  draw( static_cast<const VIA*>( item ), aLayer );
391  break;
392 
393  case PCB_PAD_T:
394  draw( static_cast<const D_PAD*>( item ), aLayer );
395  break;
396 
397  case PCB_LINE_T:
398  case PCB_MODULE_EDGE_T:
399  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
400  break;
401 
402  case PCB_TEXT_T:
403  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
404  break;
405 
406  case PCB_MODULE_TEXT_T:
407  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
408  break;
409 
410  case PCB_MODULE_T:
411  draw( static_cast<const MODULE*>( item ), aLayer );
412  break;
413 
414  case PCB_ZONE_AREA_T:
415  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
416  break;
417 
419  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
420  break;
421 
422  case PCB_DIMENSION_T:
423  draw( static_cast<const DIMENSION*>( item ), aLayer );
424  break;
425 
426  case PCB_TARGET_T:
427  draw( static_cast<const PCB_TARGET*>( item ) );
428  break;
429 
430  case PCB_MARKER_T:
431  draw( static_cast<const MARKER_PCB*>( item ) );
432  break;
433 
434  default:
435  // Painter does not know how to draw the object
436  return false;
437  }
438 
439  return true;
440 }
441 
442 
443 void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
444 {
445  VECTOR2D start( aTrack->GetStart() );
446  VECTOR2D end( aTrack->GetEnd() );
447  int width = aTrack->GetWidth();
448 
450  {
451  // If there is a net name - display it on the track
452  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
453  {
454  VECTOR2D line = ( end - start );
455  double length = line.EuclideanNorm();
456 
457  // Check if the track is long enough to have a netname displayed
458  if( length < 10 * width )
459  return;
460 
461  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
462  VECTOR2D textPosition = start + line / 2.0; // center of the track
463 
464  double textOrientation;
465 
466  if( end.y == start.y ) // horizontal
467  textOrientation = 0;
468  else if( end.x == start.x ) // vertical
469  textOrientation = M_PI / 2;
470  else
471  textOrientation = -atan( line.y / line.x );
472 
473  double textSize = width;
474 
475  m_gal->SetIsStroke( true );
476  m_gal->SetIsFill( false );
478  m_gal->SetLineWidth( width / 10.0 );
479  m_gal->SetFontBold( false );
480  m_gal->SetFontItalic( false );
481  m_gal->SetTextMirrored( false );
482  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
485  m_gal->BitmapText( netName, textPosition, textOrientation );
486  }
487  }
488  else if( IsCopperLayer( aLayer ) )
489  {
490  // Draw a regular track
491  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
492  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
495  m_gal->SetIsStroke( outline_mode );
496  m_gal->SetIsFill( not outline_mode );
498 
499  m_gal->DrawSegment( start, end, width );
500 
501  // Clearance lines
502  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
503 
504  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
505  {
507  m_gal->SetIsFill( false );
508  m_gal->SetIsStroke( true );
510  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
511  }
512  }
513 }
514 
515 
516 void PCB_PAINTER::draw( const ARC* aArc, int aLayer )
517 {
518  VECTOR2D center( aArc->GetCenter() );
519  int width = aArc->GetWidth();
520 
521  if( IsCopperLayer( aLayer ) )
522  {
523  // Draw a regular track
524  const COLOR4D& color = m_pcbSettings.GetColor( aArc, aLayer );
525  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
528  m_gal->SetIsStroke( outline_mode );
529  m_gal->SetIsFill( not outline_mode );
531 
532  auto radius = aArc->GetRadius();
533  auto start_angle = DECIDEG2RAD( aArc->GetArcAngleStart() );
534  auto angle = DECIDEG2RAD( aArc->GetAngle() );
535 
536  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width );
537 
538  // Clearance lines
539  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
540 
541  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
542  {
544  m_gal->SetIsFill( false );
545  m_gal->SetIsStroke( true );
547 
548  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
549  width + aArc->GetClearance() * 2 );
550  }
551  }
552 }
553 
554 
555 void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
556 {
557  VECTOR2D center( aVia->GetStart() );
558  double radius = 0.0;
559 
560  // Draw description layer
561  if( IsNetnameLayer( aLayer ) )
562  {
563  VECTOR2D position( center );
564 
565  // Is anything that we can display enabled?
567  {
568  bool displayNetname = ( !aVia->GetNetname().empty() );
569  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
570  double size = aVia->GetWidth();
571 
572  // Font size limits
573  if( size > maxSize )
574  size = maxSize;
575 
576  m_gal->Save();
577  m_gal->Translate( position );
578 
579  // Default font settings
582 
583  // Set the text position to the pad shape position (the pad position is not the best place)
584  VECTOR2D textpos( 0.0, 0.0 );
585 
586  if( displayNetname )
587  {
588  wxString netname = UnescapeString( aVia->GetShortNetname() );
589  // calculate the size of net name text:
590  double tsize = 1.5 * size / netname.Length();
591  tsize = std::min( tsize, size );
592  // Use a smaller text size to handle interline, pen size..
593  tsize *= 0.7;
594  VECTOR2D namesize( tsize, tsize );
595 
596  m_gal->SetGlyphSize( namesize );
597  m_gal->SetLineWidth( namesize.x / 12.0 );
598  m_gal->BitmapText( netname, textpos, 0.0 );
599  }
600 
601 
602  m_gal->Restore();
603  }
604  return;
605  }
606 
607  // Choose drawing settings depending on if we are drawing via's pad or hole
608  if( aLayer == LAYER_VIAS_HOLES )
609  radius = getDrillSize( aVia ) / 2.0;
610  else
611  radius = aVia->GetWidth() / 2.0;
612 
613  bool sketchMode = false;
614  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
615 
616  switch( aVia->GetViaType() )
617  {
618  case VIATYPE::THROUGH:
620  break;
621 
624  break;
625 
626  case VIATYPE::MICROVIA:
628  break;
629 
630  default:
631  wxASSERT( false );
632  break;
633  }
634 
635  m_gal->SetIsFill( !sketchMode );
636  m_gal->SetIsStroke( sketchMode );
637 
638  if( sketchMode )
639  {
640  // Outline mode
643  }
644  else
645  {
646  // Filled mode
648  }
649 
650  if( ( aVia->GetViaType() == VIATYPE::BLIND_BURIED || aVia->GetViaType() == VIATYPE::MICROVIA )
651  && aLayer != LAYER_VIAS_HOLES
653  {
654  // Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
655  // top and bottom layers
656  PCB_LAYER_ID layerTop, layerBottom;
657  aVia->LayerPair( &layerTop, &layerBottom );
658 
659  if( !sketchMode )
660  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
661 
662  if( aLayer == layerTop )
663  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
664 
665  else if( aLayer == layerBottom )
666  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
667 
668  else if( aLayer == LAYER_VIA_BBLIND || aLayer == LAYER_VIA_MICROVIA )
669  {
670  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
671  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
672  }
673  }
674  else
675  {
676  // Draw the outer circles of normal vias and the holes for all vias
677  m_gal->DrawCircle( center, radius );
678  }
679 
680  // Clearance lines
681  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
682 
683  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
684  && aLayer != LAYER_VIAS_HOLES )
685  {
687  m_gal->SetIsFill( false );
688  m_gal->SetIsStroke( true );
690  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
691  }
692 }
693 
694 
695 void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
696 {
697  // Draw description layer
698  if( IsNetnameLayer( aLayer ) )
699  {
700  // Is anything that we can display enabled?
702  {
703  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
704  EDA_RECT padBBox = aPad->GetBoundingBox();
705  VECTOR2D position = padBBox.Centre();
706  VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
707  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
708  double size = padsize.y;
709 
710  m_gal->Save();
711  m_gal->Translate( position );
712 
713  // Keep the size ratio for the font, but make it smaller
714  if( padsize.x < padsize.y )
715  {
716  m_gal->Rotate( DECIDEG2RAD( -900.0 ) );
717  size = padsize.x;
718  std::swap( padsize.x, padsize.y );
719  }
720 
721  // Font size limits
722  if( size > maxSize )
723  size = maxSize;
724 
725  // Default font settings
728  m_gal->SetFontBold( false );
729  m_gal->SetFontItalic( false );
730  m_gal->SetTextMirrored( false );
732  m_gal->SetIsStroke( true );
733  m_gal->SetIsFill( false );
734 
735  // We have already translated the GAL to be centered at the center of the pad's
736  // bounding box
737  VECTOR2D textpos( 0.0, 0.0 );
738 
739  // Divide the space, to display both pad numbers and netnames and set the Y text
740  // position to display 2 lines
741  if( displayNetname && m_pcbSettings.m_padNumbers )
742  {
743  size = size / 2.0;
744  textpos.y = size / 2.0;
745  }
746 
747  if( displayNetname )
748  {
749  wxString netname = UnescapeString( aPad->GetShortNetname() );
750  // calculate the size of net name text:
751  double tsize = 1.5 * padsize.x / netname.Length();
752  tsize = std::min( tsize, size );
753  // Use a smaller text size to handle interline, pen size..
754  tsize *= 0.7;
755  VECTOR2D namesize( tsize, tsize );
756 
757  m_gal->SetGlyphSize( namesize );
758  m_gal->SetLineWidth( namesize.x / 12.0 );
759  m_gal->BitmapText( netname, textpos, 0.0 );
760  }
761 
763  {
764  const wxString& padName = aPad->GetName();
765  textpos.y = -textpos.y;
766  double tsize = 1.5 * padsize.x / padName.Length();
767  tsize = std::min( tsize, size );
768  // Use a smaller text size to handle interline, pen size..
769  tsize *= 0.7;
770  tsize = std::min( tsize, size );
771  VECTOR2D numsize( tsize, tsize );
772 
773  m_gal->SetGlyphSize( numsize );
774  m_gal->SetLineWidth( numsize.x / 12.0 );
775  m_gal->BitmapText( padName, textpos, 0.0 );
776  }
777 
778  m_gal->Restore();
779  }
780  return;
781  }
782 
783  // Pad drawing
784  COLOR4D color;
785 
786  // Pad hole color is pad-type-specific: the background color for plated holes and the
787  // pad color for NPTHs. Note the extra check for "should be" NPTHs to keep mis-marked
788  // holes with no annular ring from getting "lost" in the background.
789  if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() )
791  else
792  color = m_pcbSettings.GetColor( aPad, aLayer );
793 
795  {
796  // Outline mode
797  m_gal->SetIsFill( false );
798  m_gal->SetIsStroke( true );
801  }
802  else
803  {
804  // Filled mode
805  m_gal->SetIsFill( true );
806  m_gal->SetIsStroke( false );
808  }
809 
810  // Choose drawing settings depending on if we are drawing a pad itself or a hole
811  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
812  {
813  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
814  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() );
815  }
816  else
817  {
818  wxSize pad_size = aPad->GetSize();
819  wxSize margin;
820 
821  switch( aLayer )
822  {
823  case F_Mask:
824  case B_Mask:
825  margin.x = margin.y = aPad->GetSolderMaskMargin();
826  break;
827 
828  case F_Paste:
829  case B_Paste:
830  margin = aPad->GetSolderPasteMargin();
831  break;
832 
833  default:
834  margin.x = margin.y = 0;
835  break;
836  }
837 
838  if( margin.x != margin.y )
839  {
840  const_cast<D_PAD*>( aPad )->SetSize( pad_size + margin + margin );
841  margin.x = margin.y = 0;
842  }
843 
844  const std::vector<std::shared_ptr<SHAPE>>& shapes = aPad->GetEffectiveShapes();
845 
846  if( shapes.size() == 1 && shapes[0]->Type() == SH_SEGMENT )
847  {
848  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shapes[0].get();
849  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() + 2 * margin.x );
850  }
851  else if( shapes.size() == 1 && shapes[0]->Type() == SH_CIRCLE )
852  {
853  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shapes[0].get();
854  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + margin.x );
855  }
856  else
857  {
858  SHAPE_POLY_SET polySet;
859  aPad->TransformShapeWithClearanceToPolygon( polySet, margin.x );
860  m_gal->DrawPolygon( polySet );
861  }
862 
863  if( aPad->GetSize() != pad_size )
864  const_cast<D_PAD*>( aPad )->SetSize( pad_size );
865  }
866 
867  // Clearance outlines
868  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
869 
870  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
871  && ( aLayer == LAYER_PAD_FR
872  || aLayer == LAYER_PAD_BK
873  || aLayer == LAYER_PADS_TH ) )
874  {
876  m_gal->SetIsStroke( true );
877  m_gal->SetIsFill( false );
879  int clearance = aPad->GetClearance();
880 
881  const std::vector<std::shared_ptr<SHAPE>>& shapes = aPad->GetEffectiveShapes();
882 
883  if( shapes.size() == 1 && shapes[0]->Type() == SH_SEGMENT )
884  {
885  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shapes[0].get();
886  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() + 2 * clearance );
887  }
888  else if( shapes.size() == 1 && shapes[0]->Type() == SH_CIRCLE )
889  {
890  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shapes[0].get();
891  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
892  }
893  else
894  {
895  SHAPE_POLY_SET polySet;
896  aPad->TransformShapeWithClearanceToPolygon( polySet, clearance );
897  m_gal->DrawPolygon( polySet );
898  }
899  }
900 }
901 
902 
903 void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
904 {
905  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
906  bool sketch = m_pcbSettings.m_sketchGraphics;
907  int thickness = getLineThickness( aSegment->GetWidth() );
908  VECTOR2D start( aSegment->GetStart() );
909  VECTOR2D end( aSegment->GetEnd() );
910 
911  m_gal->SetIsFill( !sketch );
912  m_gal->SetIsStroke( sketch );
916 
917  switch( aSegment->GetShape() )
918  {
919  case S_SEGMENT:
920  m_gal->DrawSegment( start, end, thickness );
921  break;
922 
923  case S_RECT:
924  {
925  std::vector<wxPoint> pts;
926  aSegment->GetRectCorners( &pts );
927 
928  if( aSegment->GetWidth() > 0 )
929  {
930  m_gal->DrawSegment( pts[0], pts[1], thickness );
931  m_gal->DrawSegment( pts[1], pts[2], thickness );
932  m_gal->DrawSegment( pts[2], pts[3], thickness );
933  m_gal->DrawSegment( pts[3], pts[0], thickness );
934  }
935  else
936  {
937  SHAPE_POLY_SET poly;
938  poly.NewOutline();
939 
940  for( const wxPoint& pt : pts )
941  poly.Append( pt );
942 
943  m_gal->DrawPolygon( poly );
944  }
945  }
946  break;
947 
948  case S_ARC:
949  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
950  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
951  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
952  thickness );
953  break;
954 
955  case S_CIRCLE:
956  if( sketch )
957  {
958  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
959  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
960  }
961  else
962  {
963  m_gal->SetLineWidth( thickness );
964  m_gal->SetIsFill( aSegment->GetWidth() == 0 );
965  m_gal->SetIsStroke( aSegment->GetWidth() > 0 );
966  m_gal->DrawCircle( start, aSegment->GetRadius() );
967  }
968  break;
969 
970  case S_POLYGON:
971  {
972  SHAPE_POLY_SET& shape = const_cast<DRAWSEGMENT*>( aSegment )->GetPolyShape();
973 
974  if( shape.OutlineCount() == 0 )
975  break;
976 
977  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
978  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
979  // on Opengl.
980  // GLU tesselation is much slower, so currently we are using our tesselation.
981  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
982  {
983  shape.CacheTriangulation();
984  }
985 
986  m_gal->Save();
987 
988  if( MODULE* module = aSegment->GetParentModule() )
989  {
990  m_gal->Translate( module->GetPosition() );
991  m_gal->Rotate( -module->GetOrientationRadians() );
992  }
993 
994  m_gal->SetLineWidth( thickness );
995 
996  if( sketch )
997  m_gal->SetIsFill( false );
998  else
999  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
1000 
1001  m_gal->SetIsStroke( true );
1002  m_gal->DrawPolygon( shape );
1003 
1004  m_gal->Restore();
1005  break;
1006  }
1007 
1008  case S_CURVE:
1009  m_gal->SetIsFill( false );
1010  m_gal->SetIsStroke( true );
1011  m_gal->SetLineWidth( thickness );
1012  // Use thickness as filter value to convert the curve to polyline
1013  // when the curve is not supported
1014  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
1015  VECTOR2D( aSegment->GetBezControl1() ),
1016  VECTOR2D( aSegment->GetBezControl2() ),
1017  VECTOR2D( aSegment->GetEnd() ), thickness );
1018  break;
1019 
1020  case S_LAST:
1021  break;
1022  }
1023 }
1024 
1025 
1026 void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
1027 {
1028  wxString shownText( aText->GetShownText() );
1029 
1030  if( shownText.Length() == 0 )
1031  return;
1032 
1033  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1034  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1035 
1037  {
1038  // Outline mode
1040  }
1041  else
1042  {
1043  // Filled mode
1045  }
1046 
1048  m_gal->SetIsFill( false );
1049  m_gal->SetIsStroke( true );
1050  m_gal->SetTextAttributes( aText );
1051  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1052 }
1053 
1054 
1055 void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
1056 {
1057  wxString shownText( aText->GetShownText() );
1058 
1059  if( shownText.Length() == 0 )
1060  return;
1061 
1062  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1063  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1064 
1066  {
1067  // Outline mode
1069  }
1070  else
1071  {
1072  // Filled mode
1074  }
1075 
1077  m_gal->SetIsFill( false );
1078  m_gal->SetIsStroke( true );
1079  m_gal->SetTextAttributes( aText );
1080  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1081 
1082  // Draw the umbilical line
1083  if( aText->IsSelected() )
1084  {
1086  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1087  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1088  }
1089 }
1090 
1091 
1092 void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
1093 {
1094  if( aLayer == LAYER_ANCHOR )
1095  {
1096  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1097 
1098  // Draw anchor
1101 
1102  // Keep the size constant, not related to the scale
1103  double anchorSize = 5.0 / m_gal->GetWorldScale();
1104 
1105  VECTOR2D center = aModule->GetPosition();
1106  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1107  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1108  }
1109 }
1110 
1111 
1112 void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer )
1113 {
1114  PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer );
1115 
1116  if( !aZone->IsOnLayer( layer ) )
1117  return;
1118 
1119  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1120  std::deque<VECTOR2D> corners;
1122 
1123  // Draw the outline
1124  const SHAPE_POLY_SET* outline = aZone->Outline();
1125 
1126  if( m_pcbSettings.m_zoneOutlines && outline && outline->OutlineCount() > 0 )
1127  {
1129  m_gal->SetIsFill( false );
1130  m_gal->SetIsStroke( true );
1132 
1133  // Draw each contour (main contour and holes)
1134 
1135  /* This line:
1136  * m_gal->DrawPolygon( *outline );
1137  * should be enough, but currently does not work to draw holes contours in a complex polygon
1138  * so each contour is draw as a simple polygon
1139  */
1140 
1141  // Draw the main contour
1142  m_gal->DrawPolyline( outline->COutline( 0 ) );
1143 
1144  // Draw holes
1145  int holes_count = outline->HoleCount( 0 );
1146 
1147  for( int ii = 0; ii < holes_count; ++ii )
1148  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1149 
1150  // Draw hatch lines
1151  for( const SEG& hatchLine : aZone->GetHatchLines() )
1152  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1153  }
1154 
1155  // Draw the filling
1156  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1157  {
1158  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer );
1159 
1160  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1161  return;
1162 
1163  // Set up drawing options
1164  int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
1166  m_gal->SetFillColor( color );
1167  m_gal->SetLineWidth( outline_thickness );
1168 
1169  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1170  {
1171  m_gal->SetIsFill( true );
1172  m_gal->SetIsStroke( outline_thickness > 0 );
1173  }
1174  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1175  {
1176  m_gal->SetIsFill( false );
1177  m_gal->SetIsStroke( true );
1178  }
1179 
1180  m_gal->DrawPolygon( polySet );
1181  }
1182 }
1183 
1184 
1185 void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
1186 {
1187  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1188 
1189  m_gal->SetStrokeColor( strokeColor );
1190  m_gal->SetIsFill( false );
1191  m_gal->SetIsStroke( true );
1192 
1194  {
1195  // Outline mode
1197  }
1198  else
1199  {
1200  // Filled mode
1201  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1202  }
1203 
1204  // Draw an arrow
1205  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1206  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1207  VECTOR2D( aDimension->m_featureLineGF ) );
1208  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1209  VECTOR2D( aDimension->m_featureLineDF ) );
1210  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1211  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1212  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1213  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1214 
1215  // Draw text
1216  TEXTE_PCB& text = aDimension->Text();
1217  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1218 
1220  {
1221  // Outline mode
1223  }
1224  else
1225  {
1226  // Filled mode
1228  }
1229 
1230  m_gal->SetTextAttributes( &text );
1231  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1232 }
1233 
1234 
1235 void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
1236 {
1237  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1238  VECTOR2D position( aTarget->GetPosition() );
1239  double size, radius;
1240 
1241  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1242  m_gal->SetStrokeColor( strokeColor );
1243  m_gal->SetIsFill( false );
1244  m_gal->SetIsStroke( true );
1245 
1246  m_gal->Save();
1247  m_gal->Translate( position );
1248 
1249  if( aTarget->GetShape() )
1250  {
1251  // shape x
1252  m_gal->Rotate( M_PI / 4.0 );
1253  size = 2.0 * aTarget->GetSize() / 3.0;
1254  radius = aTarget->GetSize() / 2.0;
1255  }
1256  else
1257  {
1258  // shape +
1259  size = aTarget->GetSize() / 2.0;
1260  radius = aTarget->GetSize() / 3.0;
1261  }
1262 
1263  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1264  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1265  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1266 
1267  m_gal->Restore();
1268 }
1269 
1270 
1271 void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
1272 {
1273  SHAPE_LINE_CHAIN polygon;
1274  aMarker->ShapeToPolygon( polygon );
1275 
1276  auto strokeColor = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
1277 
1278  m_gal->Save();
1279  m_gal->Translate( aMarker->GetPosition() );
1280  m_gal->SetFillColor( strokeColor );
1281  m_gal->SetIsFill( true );
1282  m_gal->SetIsStroke( false );
1283  m_gal->DrawPolygon( polygon );
1284  m_gal->Restore();
1285 }
1286 
1287 
1288 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:712
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.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
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
int GetNetCode() const
Function GetNetCode.
virtual void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: pcb_painter.cpp:77
int OutlineCount() const
Returns the number of outlines in the set
int GetWidth() const
TEXTE_PCB class definition.
COLOR4D Inverted() const
Function Inverted Returns an inverted color, alpha remains the same.
Definition: color4d.h:319
int GetRadius() const
Definition: shape_circle.h:94
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
bool IsSelected() const
Definition: base_struct.h:203
multilayer pads, usually with holes
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
std::map< wxString, KIGFX::COLOR4D > m_PcbNetColors
A map of fully-qualified net names to colors used in the board context.
Definition: net_settings.h:51
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
wxPoint m_crossBarF
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
COLOR4D m_layerColors[LAYER_ID_COUNT]
wxPoint m_arrowD1F
const wxPoint & GetStart() const
Definition: class_track.h:118
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a list of SHAPE objects representing the pad's hole.
Definition: class_pad.cpp:203
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).
GAL_LAYER_ID GetColorLayer() 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:329
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:201
int color
Definition: DXF_plotter.cpp:61
polygon (not yet used for tracks, but could be in microwave apps)
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
wxPoint GetPosition() const override
double GetArcAngleStart() const
function GetArcAngleStart()
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:271
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:210
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:661
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
to draw via holes (pad holes do not use this layer)
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:602
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:236
bool IsBrightened() const
Definition: base_struct.h:205
usual segment : line with rounded ends
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
const VECTOR2I GetCenter() const
Definition: shape_circle.h:99
wxPoint m_featureLineDF
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:85
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:286
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
Add new GAL layers here.
COLOR4D m_selectionCandidateColor
Color used for highlighting selection candidates
Definition: pcb_painter.h:242
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
const std::vector< std::shared_ptr< SHAPE > > & GetEffectiveShapes() const
Function GetEffectiveShapes Some pad shapes can be complex (rounded/chamfered rectangle),...
Definition: class_pad.cpp:194
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:213
double GetDrawRotationRadians() const
bool IsTriangulationUpToDate() const
wxString GetNetClassName() const
Function GetNetClassName returns a pointer to the netclass of the zone.
bool m_sketchGraphics
Flag determining if graphic items should be outlined or stroked
Definition: pcb_painter.h:204
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
const SEG & GetSeg() const
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:372
virtual void Rotate(double aAngle)
Rotate the context.
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
std::map< wxString, KIGFX::COLOR4D > m_netclassColors
Overrides for specific netclass colors
Definition: pcb_painter.h:248
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
wxPoint m_featureLineGO
wxPoint GetPosition() const override
NET_COLOR_MODE m_netColorMode
How to display nets and netclasses with color overrides
Definition: pcb_painter.h:245
DIMENSION class definition.
std::set< unsigned int > m_activeLayers
Stores active layers number.
void SetFontBold(const bool aBold)
Set bold property of current font.
segment with non rounded ends
class MODULE, a footprint
Definition: typeinfo.h:89
Net/netclass colors are shown on ratsnest lines only.
Markers used to show a drc problem on boards.
int GetWidth() const
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:531
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Non-active layers are shown normally (no high-contrast mode)
PCB_LAYER_ID
A quick note on layer IDs:
PAINTER contains all the knowledge about how to draw graphical object onto any particular output devi...
Definition: painter.h:58
double a
Alpha component.
Definition: color4d.h:369
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
bool GetDrawIndividualViaLayers() const
Definition: pcb_painter.h:186
NETCLASSES m_NetClasses
Definition: net_settings.h:39
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
void ResetTextAttributes()
Reset text attributes to default styling.
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:233
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.
NETINFO_LIST is a container class for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:422
virtual void update()
Function update Precalculates extra colors for layers (e.g.
SHAPE_POLY_SET.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
static const COLOR4D CLEAR
Definition: color4d.h:377
void SetBackgroundColor(const COLOR4D &aColor) override
Sets the background color.
Definition: pcb_painter.h:173
Arcs (with rounded ends)
void LoadNetSettings(const NET_SETTINGS &aSettings, const NETINFO_LIST &aList, const std::set< int > &aHiddenNets)
Loads net-specific render settings.
to draw usual through hole vias
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:320
wxPoint m_arrowG1F
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
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...
const wxString & GetName() const
Definition: class_pad.h:129
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:31
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
virtual wxPoint GetCenter() const
Function GetCenter()
a few functions useful in geometry calculations.
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.
double GetRadius() const
const wxString & GetNetname() const
Function GetNetname.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:779
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:225
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
int GetWidth() const
line chain (polyline)
Definition: shape.h:44
Pad object description.
bool m_sketchText
Flag determining if text items should be outlined or stroked
Definition: pcb_painter.h:207
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:160
virtual int GetClearance(BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Definition: seg.h:39
double GetTextAngleRadians() const
Definition: eda_text.h:176
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
double GetAngle() const
double GetAngle() const
COLOR4D GetColor(int aLayer) const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:216
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
smd pads, front layer
virtual void Restore()
Restore the context.
std::map< int, KIGFX::COLOR4D > m_netColors
Overrides for specific net colors, stored as netcodes for the ratsnest to access easily
Definition: pcb_painter.h:251
int GetWidth() const
Definition: class_track.h:112
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:239
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:576
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
SHAPE_LINE_CHAIN.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aShowPageLimits)
Function LoadDisplayOptions Loads settings related to display options (high-contrast mode,...
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
TEXTE_PCB & Text()
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: pcb_painter.h:171
const wxSize & GetDrillSize() const
Definition: class_pad.h:227
VECTOR2I A
Definition: seg.h:47
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
double DECIDEG2RAD(double deg)
Definition: trigo.h:218
int GetShape() const
HIGH_CONTRAST_MODE m_contrastModeDisplay
How to display inactive layers
Definition: pcb_painter.h:257
VIATYPE GetViaType() const
Definition: class_track.h:373
const wxPoint & GetBezControl2() const
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
int GetMinThickness() const
Definition: class_zone.h:201
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...
wxPoint Centre() const
Definition: eda_rect.h:62
const wxPoint & GetEnd() const
Definition: class_track.h:115
PCB_PAINTER(GAL *aGal)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
Color settings are a bit different than most of the settings objects in that there can be more than o...
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
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.
double GetArcAngleStart() const
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
const wxPoint & GetBezControl1() const
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:299
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:222
wxPoint GetPosition() const override
Definition: class_module.h:206
Non-active layers are dimmed (old high-contrast mode)
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
const wxSize & GetSize() const
Definition: class_pad.h:221
NETINFO_ITEM * GetNetItem(int aNetCode) const
Function GetItem.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void draw(const TRACK *aTrack, int aLayer)
void GetRectCorners(std::vector< wxPoint > *pts) const
double GetWorldScale() const
Get the world scale.
BOARD_ITEM_CONTAINER * GetParent() const
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
Draw a cubic bezier spline.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetWidth() const
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:1001
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:476
bool IsPolygonFilled() const
Polygonal shape is not always filled.
std::set< int > m_highlightNetcodes
Definition of PCB_DISPLAY_OPTIONS class.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox The bounding box is cached, so this will be efficient most of the time.
Definition: class_pad.cpp:371
DIMENSION.
Additional netnames layers (not associated with a PCB layer)
const wxString & GetShortNetname() const
Function GetShortNetname.
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:219
std::set< int > m_hiddenNets
Set of net codes that should not have their ratsnest displayed
Definition: pcb_painter.h:254
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
Net/netclass colors are shown on all net copper.
const wxSize GetSize() const
Definition: eda_rect.h:103
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:193
axis-aligned rectangle
Definition: shape.h:42
Class GAL is the abstract interface for drawing on a 2D-surface.
bool m_globalRatsnestlines
Flag determining if ratsnest lines are shown by default
Definition: pcb_painter.h:228
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)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
wxPoint m_featureLineGF
VECTOR2I B
Definition: seg.h:48