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 #include <class_marker_pcb.h>
37 
39 #include <pcb_painter.h>
40 #include <pcb_display_options.h>
42 
47 
48 
49 using namespace KIGFX;
50 
52 {
53  m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
54  m_padNumbers = true;
55  m_netNamesOnPads = true;
56  m_netNamesOnTracks = true;
57  m_netNamesOnVias = true;
58  m_zoneOutlines = true;
61  m_sketchBoardGfx = false;
62  m_sketchFpGfx = false;
63  m_sketchFpTxtfx = false;
64  m_selectionCandidateColor = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
65 
66  // By default everything should be displayed as filled
67  for( unsigned int i = 0; i < arrayDim( m_sketchMode ); ++i )
68  {
69  m_sketchMode[i] = false;
70  }
71 
72  update();
73 }
74 
75 
77 {
79 
80  // Init board layers colors:
81  for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
82  {
83  m_layerColors[i] = aSettings->GetColor( i );
84 
85  // Guard: if the alpah channel is too small, the layer is not visible.
86  // clamp it to 0.2
87  if( m_layerColors[i].a < 0.2 )
88  m_layerColors[i].a = 0.2;
89  }
90 
91  // Init specific graphic layers colors:
92  for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
93  m_layerColors[i] = aSettings->GetColor( i );
94 
95  // Default colors for specific layers (not really board layers).
96  m_layerColors[LAYER_VIAS_HOLES] = COLOR4D( 0.5, 0.4, 0.0, 0.8 );
98  m_layerColors[LAYER_VIAS_NETNAMES] = COLOR4D( 0.2, 0.2, 0.2, 0.9 );
99  m_layerColors[LAYER_PADS_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
100  m_layerColors[LAYER_PAD_FR_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
101  m_layerColors[LAYER_PAD_BK_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
102 
103  // LAYER_PADS_TH, LAYER_NON_PLATEDHOLES, LAYER_ANCHOR ,LAYER_RATSNEST,
104  // LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA
105  // are initialized from aSettings
106 
107  // These colors are not actually used. Set just in case...
110 
111  // Netnames for copper layers
112  for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
113  {
114  const COLOR4D lightLabel( 0.8, 0.8, 0.8, 0.7 );
115  const COLOR4D darkLabel = lightLabel.Inverted();
116  PCB_LAYER_ID layer = *cu;
117 
118  if( m_layerColors[layer].GetBrightness() > 0.5 )
119  m_layerColors[GetNetnameLayer( layer )] = darkLabel;
120  else
121  m_layerColors[GetNetnameLayer( layer )] = lightLabel;
122  }
123 
124  update();
125 }
126 
127 
129  bool aShowPageLimits )
130 {
132  m_padNumbers = aOptions.m_DisplayPadNum;
138 
139  // Whether to draw tracks, vias & pads filled or as outlines
145 
146  // Net names display settings
147  switch( aOptions.m_DisplayNetNamesMode )
148  {
149  case 0:
150  m_netNamesOnPads = false;
151  m_netNamesOnTracks = false;
152  m_netNamesOnVias = false;
153  break;
154 
155  case 1:
156  m_netNamesOnPads = true;
157  m_netNamesOnTracks = false;
158  m_netNamesOnVias = true; // Follow pads or tracks? For now we chose pads....
159  break;
160 
161  case 2:
162  m_netNamesOnPads = false;
163  m_netNamesOnTracks = true;
164  m_netNamesOnVias = false; // Follow pads or tracks? For now we chose pads....
165  break;
166 
167  case 3:
168  m_netNamesOnPads = true;
169  m_netNamesOnTracks = true;
170  m_netNamesOnVias = true;
171  break;
172  }
173 
174  // Zone display settings
175  switch( aOptions.m_DisplayZonesMode )
176  {
177  case 0:
179  break;
180 
181  case 1:
183  break;
184 
185  case 2:
187  break;
188  }
189 
190  // Clearance settings
191  switch( aOptions.m_ShowTrackClearanceMode )
192  {
195  break;
196 
199  break;
200 
203  break;
204 
207  break;
208 
211  break;
212  }
213 
214  if( aOptions.m_DisplayPadIsol )
215  m_clearance |= CL_PADS;
216 
217  m_showPageLimits = aShowPageLimits;
218 }
219 
220 
221 const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
222 {
223  int netCode = -1;
224  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
225 
226  if( item )
227  {
228  // Selection disambiguation
229  if( item->IsBrightened() )
230  {
232  }
233 
234  // Don't let pads that *should* be NPTHs get lost
235  if( item->Type() == PCB_PAD_T && dyn_cast<const D_PAD*>( item )->PadShouldBeNPTH() )
236  aLayer = LAYER_MOD_TEXT_INVISIBLE;
237 
238  if( item->IsSelected() )
239  {
240  return m_layerColorsSel[aLayer];
241  }
242 
244  {
245  if( item->IsHighlighted() )
246  return m_layerColorsHi[aLayer];
247  else
248  return m_layerColorsDark[aLayer];
249  }
250 
251  // Try to obtain the netcode for the item
252  if( const BOARD_CONNECTED_ITEM* conItem = dyn_cast<const BOARD_CONNECTED_ITEM*> ( item ) )
253  netCode = conItem->GetNetCode();
254 
255  if( item->Type() == PCB_MARKER_T )
256  return m_layerColors[aLayer];
257 
258  // For vias, some layers depend on other layers in high contrast mode
259  if( m_hiContrastEnabled && item->Type() == PCB_VIA_T &&
260  ( aLayer == LAYER_VIAS_HOLES ||
261  aLayer == LAYER_VIA_THROUGH ||
262  aLayer == LAYER_VIA_MICROVIA ||
263  aLayer == LAYER_VIA_BBLIND ) )
264  {
265  const VIA* via = static_cast<const VIA*>( item );
266  const BOARD* pcb = static_cast<const BOARD*>( item->GetParent() );
267  bool viaActiveLayer = false;
268 
269  for( auto activeLayer : m_activeLayers )
270  {
271  auto lay_id = static_cast<PCB_LAYER_ID>( activeLayer );
272  viaActiveLayer |= via->IsOnLayer( lay_id ) && pcb->IsLayerVisible( lay_id );
273  }
274 
275  if( viaActiveLayer )
276  return m_layerColors[aLayer];
277  else
278  return m_hiContrastColor[aLayer];
279  }
280  }
281 
282  // Single net highlight mode
283  if( m_highlightEnabled && netCode == m_highlightNetcode )
284  return m_layerColorsHi[aLayer];
285 
286  // Return grayish color for non-highlighted layers in the high contrast mode
287  if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
288  return m_hiContrastColor[aLayer];
289 
290  // Catch the case when highlight and high-contraste modes are enabled
291  // and we are drawing a not highlighted track
292  if( m_highlightEnabled )
293  return m_layerColorsDark[aLayer];
294 
295  // No special modificators enabled
296  return m_layerColors[aLayer];
297 }
298 
299 
301  PAINTER( aGal )
302 {
303 }
304 
305 
306 int PCB_PAINTER::getLineThickness( int aActualThickness ) const
307 {
308  // if items have 0 thickness, draw them with the outline
309  // width, otherwise respect the set value (which, no matter
310  // how small will produce something)
311  if( aActualThickness == 0 )
313 
314  return aActualThickness;
315 }
316 
317 
318 int PCB_PAINTER::getDrillShape( const D_PAD* aPad ) const
319 {
320  return aPad->GetDrillShape();
321 }
322 
323 
325 {
326  return VECTOR2D( aPad->GetDrillSize() );
327 }
328 
329 
330 int PCB_PAINTER::getDrillSize( const VIA* aVia ) const
331 {
332  return aVia->GetDrillValue();
333 }
334 
335 
336 bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
337 {
338  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
339 
340  if( !item )
341  return false;
342 
343  // the "cast" applied in here clarifies which overloaded draw() is called
344  switch( item->Type() )
345  {
346  case PCB_TRACE_T:
347  draw( static_cast<const TRACK*>( item ), aLayer );
348  break;
349 
350  case PCB_ARC_T:
351  draw( static_cast<const ARC*>( item ), aLayer );
352  break;
353 
354  case PCB_VIA_T:
355  draw( static_cast<const VIA*>( item ), aLayer );
356  break;
357 
358  case PCB_PAD_T:
359  draw( static_cast<const D_PAD*>( item ), aLayer );
360  break;
361 
362  case PCB_LINE_T:
363  case PCB_MODULE_EDGE_T:
364  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
365  break;
366 
367  case PCB_TEXT_T:
368  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
369  break;
370 
371  case PCB_MODULE_TEXT_T:
372  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
373  break;
374 
375  case PCB_MODULE_T:
376  draw( static_cast<const MODULE*>( item ), aLayer );
377  break;
378 
379  case PCB_ZONE_AREA_T:
380  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
381  break;
382 
384  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
385  break;
386 
387  case PCB_DIMENSION_T:
388  draw( static_cast<const DIMENSION*>( item ), aLayer );
389  break;
390 
391  case PCB_TARGET_T:
392  draw( static_cast<const PCB_TARGET*>( item ) );
393  break;
394 
395  case PCB_MARKER_T:
396  draw( static_cast<const MARKER_PCB*>( item ) );
397  break;
398 
399  default:
400  // Painter does not know how to draw the object
401  return false;
402  }
403 
404  return true;
405 }
406 
407 
408 void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
409 {
410  VECTOR2D start( aTrack->GetStart() );
411  VECTOR2D end( aTrack->GetEnd() );
412  int width = aTrack->GetWidth();
413 
415  {
416  // If there is a net name - display it on the track
417  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
418  {
419  VECTOR2D line = ( end - start );
420  double length = line.EuclideanNorm();
421 
422  // Check if the track is long enough to have a netname displayed
423  if( length < 10 * width )
424  return;
425 
426  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
427  VECTOR2D textPosition = start + line / 2.0; // center of the track
428 
429  double textOrientation;
430 
431  if( end.y == start.y ) // horizontal
432  textOrientation = 0;
433  else if( end.x == start.x ) // vertical
434  textOrientation = M_PI / 2;
435  else
436  textOrientation = -atan( line.y / line.x );
437 
438  double textSize = width;
439 
440  m_gal->SetIsStroke( true );
441  m_gal->SetIsFill( false );
443  m_gal->SetLineWidth( width / 10.0 );
444  m_gal->SetFontBold( false );
445  m_gal->SetFontItalic( false );
446  m_gal->SetTextMirrored( false );
447  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
450  m_gal->BitmapText( netName, textPosition, textOrientation );
451  }
452  }
453  else if( IsCopperLayer( aLayer ) )
454  {
455  // Draw a regular track
456  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
457  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
460  m_gal->SetIsStroke( outline_mode );
461  m_gal->SetIsFill( not outline_mode );
463 
464  m_gal->DrawSegment( start, end, width );
465 
466  // Clearance lines
467  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
468 
469  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
470  {
472  m_gal->SetIsFill( false );
473  m_gal->SetIsStroke( true );
475  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
476  }
477  }
478 }
479 
480 
481 void PCB_PAINTER::draw( const ARC* aArc, int aLayer )
482 {
483  VECTOR2D center( aArc->GetCenter() );
484  int width = aArc->GetWidth();
485 
486  if( IsCopperLayer( aLayer ) )
487  {
488  // Draw a regular track
489  const COLOR4D& color = m_pcbSettings.GetColor( aArc, aLayer );
490  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
493  m_gal->SetIsStroke( outline_mode );
494  m_gal->SetIsFill( not outline_mode );
496 
497  auto radius = aArc->GetRadius();
498  auto start_angle = DECIDEG2RAD( aArc->GetArcAngleStart() );
499  auto angle = DECIDEG2RAD( aArc->GetAngle() );
500 
501  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width );
502 
503  // Clearance lines
504  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
505 
506  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
507  {
509  m_gal->SetIsFill( false );
510  m_gal->SetIsStroke( true );
512 
513  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
514  width + aArc->GetClearance() * 2 );
515  }
516  }
517 }
518 
519 
520 void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
521 {
522  VECTOR2D center( aVia->GetStart() );
523  double radius = 0.0;
524 
525  // Draw description layer
526  if( IsNetnameLayer( aLayer ) )
527  {
528  VECTOR2D position( center );
529 
530  // Is anything that we can display enabled?
532  {
533  bool displayNetname = ( !aVia->GetNetname().empty() );
534  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
535  double size = aVia->GetWidth();
536 
537  // Font size limits
538  if( size > maxSize )
539  size = maxSize;
540 
541  m_gal->Save();
542  m_gal->Translate( position );
543 
544  // Default font settings
547 
548  // Set the text position to the pad shape position (the pad position is not the best place)
549  VECTOR2D textpos( 0.0, 0.0 );
550 
551  if( displayNetname )
552  {
553  wxString netname = UnescapeString( aVia->GetShortNetname() );
554  // calculate the size of net name text:
555  double tsize = 1.5 * size / netname.Length();
556  tsize = std::min( tsize, size );
557  // Use a smaller text size to handle interline, pen size..
558  tsize *= 0.7;
559  VECTOR2D namesize( tsize, tsize );
560 
561  m_gal->SetGlyphSize( namesize );
562  m_gal->SetLineWidth( namesize.x / 12.0 );
563  m_gal->BitmapText( netname, textpos, 0.0 );
564  }
565 
566 
567  m_gal->Restore();
568  }
569  return;
570  }
571 
572  // Choose drawing settings depending on if we are drawing via's pad or hole
573  if( aLayer == LAYER_VIAS_HOLES )
574  radius = getDrillSize( aVia ) / 2.0;
575  else
576  radius = aVia->GetWidth() / 2.0;
577 
578  bool sketchMode = false;
579  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
580 
581  switch( aVia->GetViaType() )
582  {
583  case VIATYPE::THROUGH:
585  break;
586 
589  break;
590 
591  case VIATYPE::MICROVIA:
593  break;
594 
595  default:
596  wxASSERT( false );
597  break;
598  }
599 
600  m_gal->SetIsFill( !sketchMode );
601  m_gal->SetIsStroke( sketchMode );
602 
603  if( sketchMode )
604  {
605  // Outline mode
608  }
609  else
610  {
611  // Filled mode
613  }
614 
615  if( aVia->GetViaType() == VIATYPE::BLIND_BURIED && aLayer != LAYER_VIAS_HOLES )
616  {
617  // Outer circles of blind/buried vias are drawn in a special way to indicate the
618  // top and bottom layers
619  PCB_LAYER_ID layerTop, layerBottom;
620  aVia->LayerPair( &layerTop, &layerBottom );
621 
622  if( !sketchMode )
623  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
624 
625  if( aLayer == layerTop )
626  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
627 
628  else if( aLayer == layerBottom )
629  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
630 
631  else if( aLayer == LAYER_VIA_BBLIND )
632  {
633  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
634  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
635  }
636  }
637  else
638  {
639  // Draw the outer circles of normal vias and the inner circles for all vias
640  m_gal->DrawCircle( center, radius );
641  }
642 
643  // Clearance lines
644  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
645 
646  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
647  && aLayer != LAYER_VIAS_HOLES )
648  {
650  m_gal->SetIsFill( false );
651  m_gal->SetIsStroke( true );
653  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
654  }
655 }
656 
657 
658 void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
659 {
660  double m, n;
661  double orientation = aPad->GetOrientation();
662 
663  // Draw description layer
664  if( IsNetnameLayer( aLayer ) )
665  {
666  VECTOR2D position( aPad->ShapePos() );
667 
668  // Is anything that we can display enabled?
670  {
671  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
672  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
673  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
674  double size = padsize.y;
675 
676  // Keep the size ratio for the font, but make it smaller
677  if( padsize.x < padsize.y )
678  {
679  orientation += 900.0;
680  size = padsize.x;
681  std::swap( padsize.x, padsize.y );
682  }
683  else if( padsize.x == padsize.y )
684  {
685  // If the text is displayed on a symmetrical pad, do not rotate it
686  orientation = 0.0;
687  }
688 
689  // Font size limits
690  if( size > maxSize )
691  size = maxSize;
692 
693  m_gal->Save();
694  m_gal->Translate( position );
695 
696  // do not display descriptions upside down
697  NORMALIZE_ANGLE_90( orientation );
698  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
699 
700  // Default font settings
703  m_gal->SetFontBold( false );
704  m_gal->SetFontItalic( false );
705  m_gal->SetTextMirrored( false );
707  m_gal->SetIsStroke( true );
708  m_gal->SetIsFill( false );
709 
710  // Set the text position to the pad shape position (the pad position is not the best place)
711  VECTOR2D textpos( 0.0, 0.0 );
712 
713  // Divide the space, to display both pad numbers and netnames
714  // and set the Y text position to display 2 lines
715  if( displayNetname && m_pcbSettings.m_padNumbers )
716  {
717  size = size / 2.0;
718  textpos.y = size / 2.0;
719  }
720 
721  if( displayNetname )
722  {
723  wxString netname = UnescapeString( aPad->GetShortNetname() );
724  // calculate the size of net name text:
725  double tsize = 1.5 * padsize.x / netname.Length();
726  tsize = std::min( tsize, size );
727  // Use a smaller text size to handle interline, pen size..
728  tsize *= 0.7;
729  VECTOR2D namesize( tsize, tsize );
730 
731  m_gal->SetGlyphSize( namesize );
732  m_gal->SetLineWidth( namesize.x / 12.0 );
733  m_gal->BitmapText( netname, textpos, 0.0 );
734  }
735 
737  {
738  const wxString& padName = aPad->GetName();
739  textpos.y = -textpos.y;
740  double tsize = 1.5 * padsize.x / padName.Length();
741  tsize = std::min( tsize, size );
742  // Use a smaller text size to handle interline, pen size..
743  tsize *= 0.7;
744  tsize = std::min( tsize, size );
745  VECTOR2D numsize( tsize, tsize );
746 
747  m_gal->SetGlyphSize( numsize );
748  m_gal->SetLineWidth( numsize.x / 12.0 );
749  m_gal->BitmapText( padName, textpos, 0.0 );
750  }
751 
752  m_gal->Restore();
753  }
754  return;
755  }
756 
757  // Pad drawing
758  COLOR4D color;
759 
760  // Pad holes color is type specific
761  // Hole color is the background color for plated holes, but only if the pad size is greater than the hole size.
762  // ( Don't let pads that *should* be NPTH get lost )
763  if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() )
764  {
766  }
767  else
768  {
769  color = m_pcbSettings.GetColor( aPad, aLayer );
770  }
771 
772  VECTOR2D size;
773 
775  {
776  // Outline mode
777  m_gal->SetIsFill( false );
778  m_gal->SetIsStroke( true );
781  }
782  else
783  {
784  // Filled mode
785  m_gal->SetIsFill( true );
786  m_gal->SetIsStroke( false );
788  }
789 
790  // Choose drawing settings depending on if we are drawing a pad itself or a hole
791  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
792  {
793  m_gal->Save();
794  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
795  m_gal->Rotate( -aPad->GetOrientationRadians() );
796 
797  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
798  size = getDrillSize( aPad ) / 2.0;
799 
800  if( getDrillShape( aPad ) == PAD_DRILL_SHAPE_OBLONG )
801  {
802  if( size.y >= size.x )
803  {
804  m = ( size.y - size.x );
805  n = size.x;
806 
807  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
808  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
809 
811  {
812  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
813  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
814  }
815  else
816  {
817  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
818  }
819  }
820  else
821  {
822  m = ( size.x - size.y );
823  n = size.y;
824  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
825  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
826 
828  {
829  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
830  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
831  }
832  else
833  {
834  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
835  }
836  }
837  }
838  else
839  {
840  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
841  }
842 
843  m_gal->Restore();
844  }
845  else
846  {
847  SHAPE_POLY_SET polySet;
848  wxSize margin;
849  int clearance = 0;
850 
851  switch( aLayer )
852  {
853  case F_Mask:
854  case B_Mask:
855  clearance += aPad->GetSolderMaskMargin();
856  break;
857 
858  case F_Paste:
859  case B_Paste:
860  margin = aPad->GetSolderPasteMargin();
861  clearance += ( margin.x + margin.y ) / 2;
862  break;
863 
864  default:
865  break;
866  }
867 
868  aPad->TransformShapeWithClearanceToPolygon( polySet, clearance );
869  m_gal->DrawPolygon( polySet );
870  }
871 
872  // Clearance lines
873  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
874 
875  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
876  && ( aLayer == LAYER_PAD_FR
877  || aLayer == LAYER_PAD_BK
878  || aLayer == LAYER_PADS_TH ) )
879  {
880  SHAPE_POLY_SET polySet;
881  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance() );
883  m_gal->SetIsStroke( true );
884  m_gal->SetIsFill( false );
886  m_gal->DrawPolygon( polySet );
887  }
888 }
889 
890 
891 void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
892 {
893  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
894  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
895  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
896 
897  int thickness = getLineThickness( aSegment->GetWidth() );
898  VECTOR2D start( aSegment->GetStart() );
899  VECTOR2D end( aSegment->GetEnd() );
900 
901  m_gal->SetIsFill( !sketch );
902  m_gal->SetIsStroke( sketch );
906 
907  switch( aSegment->GetShape() )
908  {
909  case S_SEGMENT:
910  m_gal->DrawSegment( start, end, thickness );
911  break;
912 
913  case S_RECT:
914  wxASSERT_MSG( false, "Not tested yet" );
915  m_gal->DrawRectangle( start, end );
916  break;
917 
918  case S_ARC:
919  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
920  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
921  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
922  thickness );
923  break;
924 
925  case S_CIRCLE:
926  if( sketch )
927  {
928  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
929  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
930  }
931  else
932  {
933  m_gal->SetLineWidth( thickness );
934  m_gal->SetIsFill( false );
935  m_gal->SetIsStroke( true );
936  m_gal->DrawCircle( start, aSegment->GetRadius() );
937  }
938  break;
939 
940  case S_POLYGON:
941  {
942  SHAPE_POLY_SET& shape = ((DRAWSEGMENT*)aSegment)->GetPolyShape();
943 
944  if( shape.OutlineCount() == 0 )
945  break;
946 
947  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
948  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
949  // on Opengl.
950  // GLU tesselation is much slower, so currently we are using our tesselation.
951  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
952  {
953  shape.CacheTriangulation();
954  }
955 
956  m_gal->Save();
957 
958  if( MODULE* module = aSegment->GetParentModule() )
959  {
960  m_gal->Translate( module->GetPosition() );
961  m_gal->Rotate( -module->GetOrientationRadians() );
962  }
963 
964  m_gal->SetLineWidth( thickness );
965 
966  if( sketch )
967  m_gal->SetIsFill( false );
968  else
969  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
970 
971  m_gal->SetIsStroke( true );
972  m_gal->DrawPolygon( shape );
973 
974  m_gal->Restore();
975  break;
976  }
977 
978  case S_CURVE:
979  m_gal->SetIsFill( false );
980  m_gal->SetIsStroke( true );
981  m_gal->SetLineWidth( thickness );
982  // Use thickness as filter value to convert the curve to polyline
983  // when the curve is not supported
984  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
985  VECTOR2D( aSegment->GetBezControl1() ),
986  VECTOR2D( aSegment->GetBezControl2() ),
987  VECTOR2D( aSegment->GetEnd() ), thickness );
988  break;
989 
990  case S_LAST:
991  break;
992  }
993 }
994 
995 
996 void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
997 {
998  wxString shownText( aText->GetShownText() );
999  if( shownText.Length() == 0 )
1000  return;
1001 
1002  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1003  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1004 
1005  if( m_pcbSettings.m_sketchMode[aLayer] )
1006  {
1007  // Outline mode
1009  }
1010  else
1011  {
1012  // Filled mode
1014  }
1015 
1017  m_gal->SetIsFill( false );
1018  m_gal->SetIsStroke( true );
1019  m_gal->SetTextAttributes( aText );
1020  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians(), GetTextMarkupFlags() );
1021 }
1022 
1023 
1024 void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
1025 {
1026  wxString shownText( aText->GetShownText() );
1027  if( shownText.Length() == 0 )
1028  return;
1029 
1030  bool sketch = m_pcbSettings.m_sketchFpTxtfx;
1031 
1032  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1033  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1034 
1035  // Currently, draw text routines do not know the true outline mode.
1036  // so draw the text in "line" mode (no thickness)
1037  if( sketch )
1038  {
1039  // Outline mode
1041  }
1042  else
1043  {
1044  // Filled mode
1046  }
1047 
1049  m_gal->SetIsFill( false );
1050  m_gal->SetIsStroke( true );
1051  m_gal->SetTextAttributes( aText );
1052  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians(), GetTextMarkupFlags() );
1053 
1054  // Draw the umbilical line
1055  if( aText->IsSelected() )
1056  {
1058  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1059  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1060  }
1061 }
1062 
1063 
1064 void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
1065 {
1066  if( aLayer == LAYER_ANCHOR )
1067  {
1068  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1069 
1070  // Draw anchor
1073 
1074  // Keep the size constant, not related to the scale
1075  double anchorSize = 5.0 / m_gal->GetWorldScale();
1076 
1077  VECTOR2D center = aModule->GetPosition();
1078  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1079  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1080  }
1081 }
1082 
1083 
1084 void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer )
1085 {
1086  if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
1087  return;
1088 
1089  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1090  std::deque<VECTOR2D> corners;
1092 
1093  // Draw the outline
1094  const SHAPE_POLY_SET* outline = aZone->Outline();
1095 
1096  if( m_pcbSettings.m_zoneOutlines && outline )
1097  {
1099  m_gal->SetIsFill( false );
1100  m_gal->SetIsStroke( true );
1102 
1103  // Draw each contour (main contour and holes)
1104 
1105  /* This line:
1106  * m_gal->DrawPolygon( *outline );
1107  * should be enough, but currently does not work to draw holes contours in a complex polygon
1108  * so each contour is draw as a simple polygon
1109  */
1110 
1111  // Draw the main contour
1112  m_gal->DrawPolyline( outline->COutline( 0 ) );
1113 
1114  // Draw holes
1115  int holes_count = outline->HoleCount( 0 );
1116 
1117  for( int ii = 0; ii < holes_count; ++ii )
1118  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1119 
1120  // Draw hatch lines
1121  for( const SEG& hatchLine : aZone->GetHatchLines() )
1122  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1123  }
1124 
1125  // Draw the filling
1126  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1127  {
1128  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1129 
1130  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1131  return;
1132 
1133  // Set up drawing options
1134  int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
1136  m_gal->SetFillColor( color );
1137  m_gal->SetLineWidth( outline_thickness );
1138 
1139  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1140  {
1141  m_gal->SetIsFill( true );
1142  m_gal->SetIsStroke( outline_thickness > 0 );
1143  }
1144  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1145  {
1146  m_gal->SetIsFill( false );
1147  m_gal->SetIsStroke( true );
1148  }
1149 
1150  m_gal->DrawPolygon( polySet );
1151  }
1152 
1153 }
1154 
1155 
1156 void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
1157 {
1158  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1159 
1160  m_gal->SetStrokeColor( strokeColor );
1161  m_gal->SetIsFill( false );
1162  m_gal->SetIsStroke( true );
1163  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1164 
1165  // Draw an arrow
1166  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1167  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1168  VECTOR2D( aDimension->m_featureLineGF ) );
1169  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1170  VECTOR2D( aDimension->m_featureLineDF ) );
1171  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1172  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1173  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1174  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1175 
1176  // Draw text
1177  TEXTE_PCB& text = aDimension->Text();
1178  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1179 
1180  m_gal->SetLineWidth( text.GetThickness() );
1181  m_gal->SetTextAttributes( &text );
1182  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians(),
1183  GetTextMarkupFlags() );
1184 }
1185 
1186 
1187 void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
1188 {
1189  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1190  VECTOR2D position( aTarget->GetPosition() );
1191  double size, radius;
1192 
1193  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1194  m_gal->SetStrokeColor( strokeColor );
1195  m_gal->SetIsFill( false );
1196  m_gal->SetIsStroke( true );
1197 
1198  m_gal->Save();
1199  m_gal->Translate( position );
1200 
1201  if( aTarget->GetShape() )
1202  {
1203  // shape x
1204  m_gal->Rotate( M_PI / 4.0 );
1205  size = 2.0 * aTarget->GetSize() / 3.0;
1206  radius = aTarget->GetSize() / 2.0;
1207  }
1208  else
1209  {
1210  // shape +
1211  size = aTarget->GetSize() / 2.0;
1212  radius = aTarget->GetSize() / 3.0;
1213  }
1214 
1215  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1216  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1217  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1218 
1219  m_gal->Restore();
1220 }
1221 
1222 
1223 void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
1224 {
1225  SHAPE_LINE_CHAIN polygon;
1226  aMarker->ShapeToPolygon( polygon );
1227 
1228  auto strokeColor = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
1229 
1230  m_gal->Save();
1231  m_gal->Translate( aMarker->GetPosition() );
1232  m_gal->SetFillColor( strokeColor );
1233  m_gal->SetIsFill( true );
1234  m_gal->SetIsStroke( false );
1235  m_gal->DrawPolygon( polygon );
1236  m_gal->Restore();
1237 }
1238 
1239 
1240 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:686
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:60
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
to draw blind/buried vias
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool m_highlightItems
Highlight items with their HIGHLIGHT flags set.
Definition: painter.h:282
int GetNetCode() const
Function GetNetCode.
virtual void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: pcb_painter.cpp:76
int OutlineCount() const
Returns the number of outlines in the set
int GetWidth() const
const wxPoint GetPosition() const override
TEXTE_PCB class definition.
COLOR4D Inverted() const
Function Inverted Returns an inverted color, alpha remains the same.
Definition: color4d.h:260
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:131
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
bool IsSelected() const
Definition: base_struct.h:225
multilayer pads, usually with holes
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
wxPoint m_crossBarF
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
Colors for all layers (highlighted)
Definition: painter.h:263
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:260
wxPoint m_arrowD1F
const wxPoint & GetStart() const
Definition: class_track.h:111
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:310
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:174
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).
double GetArcAngleStart() const
function GetArcAngleStart()
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:265
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:186
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:617
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
to draw via holes (pad holes do not use this layer)
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
bool m_sketchBoardGfx
Flag determining if board graphic items should be outlined or stroked
Definition: pcb_painter.h:177
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:278
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:210
bool IsBrightened() const
Definition: base_struct.h:228
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
usual segment : line with rounded ends
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
bool m_sketchFpTxtfx
Flag determining if footprint text items should be outlined or stroked
Definition: pcb_painter.h:183
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
wxPoint m_featureLineDF
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:82
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:245
Add new GAL layers here.
COLOR4D m_selectionCandidateColor
Color used for highlighting selection candidates
Definition: pcb_painter.h:216
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
virtual wxString GetShownText() const override
Return the string actually shown after processing of the base text.
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.
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
void NORMALIZE_ANGLE_90(T &Angle)
Definition: trigo.h:338
bool IsHighlighted() const
Definition: base_struct.h:227
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:189
double GetDrawRotationRadians() const
bool IsTriangulationUpToDate() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
Definitions for tracks, vias and zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
Definition: painter.h:272
wxPoint m_featureLineGO
DIMENSION class definition.
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:257
void SetFontBold(const bool aBold)
Set bold property of current font.
segment with non rounded ends
class MODULE, a footprint
Definition: typeinfo.h:89
Markers used to show a drc problem on boards.
int GetTextMarkupFlags()
Definition: gr_text.cpp:55
int GetWidth() const
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:627
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
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:308
double a
Alpha component.
Definition: color4d.h:305
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
Colors for all layers (darkened)
Definition: painter.h:269
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:207
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
bool m_hiContrastEnabled
Parameters for display modes.
Definition: painter.h:275
virtual void update()
Function update Precalculates extra colors for layers (e.g.
Definition: painter.cpp:54
SHAPE_POLY_SET.
void SetBackgroundColor(const COLOR4D &aColor) override
Sets the background color.
Definition: pcb_painter.h:153
Arcs (with rounded ends)
to draw usual through hole vias
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:432
wxPoint m_arrowG1F
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
wxPoint m_arrowD2F
wxPoint m_arrowG2F
last value for this list
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
const wxString & GetName() const
Definition: class_pad.h:203
EDA_ITEM * GetParent() const
Definition: base_struct.h:217
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
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.
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:706
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:201
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:180
int GetWidth() const
Pad object description.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
virtual const wxPoint GetPosition() const =0
double GetOrientationRadians() const
Definition: class_pad.h:428
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Definition: seg.h:39
double GetTextAngleRadians() const
Definition: eda_text.h:161
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 Used in filli...
double GetAngle() const
double GetAngle() const
COLOR4D GetColor(int aLayer) const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:192
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:431
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:292
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
smd pads, front layer
virtual void Restore()
Restore the context.
int GetWidth() const
Definition: class_track.h:105
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:213
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:673
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:426
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:151
const wxSize & GetDrillSize() const
Definition: class_pad.h:306
wxPoint ShapePos() const
Definition: class_pad.cpp:570
double DECIDEG2RAD(double deg)
Definition: trigo.h:218
int GetShape() const
VIATYPE GetViaType() const
Definition: class_track.h:416
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:166
int GetMinThickness() const
Definition: class_zone.h:204
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:596
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
const wxPoint & GetEnd() const
Definition: class_track.h:108
PCB_PAINTER(GAL *aGal)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
wxPoint m_crossBarO
virtual const wxPoint GetCenter() const
Function GetCenter()
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
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:279
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:198
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Module description (excepted pads)
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
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:300
const wxPoint GetPosition() const override
Definition: class_pad.h:241
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void draw(const TRACK *aTrack, int aLayer)
double GetWorldScale() const
Get the world scale.
BOARD_ITEM_CONTAINER * GetParent() const
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void 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.
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:1321
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:462
bool IsPolygonFilled() const
Polygonal shape is not always filled.
Definition of PCB_DISPLAY_OPTIONS class.
const wxPoint GetPosition() const override
Definition: class_module.h:210
DIMENSION.
Additional netnames layers (not associated with a PCB layer)
const wxPoint GetPosition() const override
const wxString & GetShortNetname() const
Function GetShortNetname.
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:195
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
Colors for all layers (selected)
Definition: painter.h:266
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:212
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:204
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:571
virtual int getDrillShape(const D_PAD *aPad) const
Return drill shape of a pad.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
wxPoint m_featureLineGF