KiCad PCB EDA Suite
pcb_painter.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013-2019 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <class_board.h>
27 #include <class_track.h>
28 #include <class_module.h>
29 #include <class_pad.h>
30 #include <class_drawsegment.h>
31 #include <class_zone.h>
32 #include <class_pcb_text.h>
33 #include <colors_design_settings.h>
34 #include <class_marker_pcb.h>
35 #include <class_dimension.h>
36 #include <class_pcb_target.h>
37 #include <class_marker_pcb.h>
38 
40 #include <pcb_painter.h>
41 #include <pcb_display_options.h>
42 
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 
73  ImportLegacyColors( &dummyCds );
74 
75  update();
76 }
77 
78 
80 {
81  // Init board layers colors:
82  for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
83  {
84  m_layerColors[i] = aSettings->GetLayerColor( 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->GetItemColor( 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  m_layerColors[LAYER_DRC] = COLOR4D( 1.0, 0.0, 0.0, 0.8 );
104 
105  // LAYER_PADS_TH, LAYER_NON_PLATEDHOLES, LAYER_ANCHOR ,LAYER_RATSNEST,
106  // LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA
107  // are initialized from aSettings
108 
109  // These colors are not actually used. Set just in case...
112 
113  // Netnames for copper layers
114  for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
115  {
116  const COLOR4D lightLabel( 0.8, 0.8, 0.8, 0.7 );
117  const COLOR4D darkLabel = lightLabel.Inverted();
118  PCB_LAYER_ID layer = *cu;
119 
120  if( m_layerColors[layer].GetBrightness() > 0.5 )
121  m_layerColors[GetNetnameLayer( layer )] = darkLabel;
122  else
123  m_layerColors[GetNetnameLayer( layer )] = lightLabel;
124  }
125 
126  update();
127 }
128 
129 
131  bool aShowPageLimits )
132 {
134  m_padNumbers = aOptions.m_DisplayPadNum;
140 
141  // Whether to draw tracks, vias & pads filled or as outlines
147 
148  // Net names display settings
149  switch( aOptions.m_DisplayNetNamesMode )
150  {
151  case 0:
152  m_netNamesOnPads = false;
153  m_netNamesOnTracks = false;
154  m_netNamesOnVias = false;
155  break;
156 
157  case 1:
158  m_netNamesOnPads = true;
159  m_netNamesOnTracks = false;
160  m_netNamesOnVias = true; // Follow pads or tracks? For now we chose pads....
161  break;
162 
163  case 2:
164  m_netNamesOnPads = false;
165  m_netNamesOnTracks = true;
166  m_netNamesOnVias = false; // Follow pads or tracks? For now we chose pads....
167  break;
168 
169  case 3:
170  m_netNamesOnPads = true;
171  m_netNamesOnTracks = true;
172  m_netNamesOnVias = true;
173  break;
174  }
175 
176  // Zone display settings
177  switch( aOptions.m_DisplayZonesMode )
178  {
179  case 0:
181  break;
182 
183  case 1:
185  break;
186 
187  case 2:
189  break;
190  }
191 
192  // Clearance settings
193  switch( aOptions.m_ShowTrackClearanceMode )
194  {
197  break;
198 
201  break;
202 
205  break;
206 
209  break;
210 
213  break;
214  }
215 
216  if( aOptions.m_DisplayPadIsol )
217  m_clearance |= CL_PADS;
218 
219  m_showPageLimits = aShowPageLimits;
220 }
221 
222 
223 const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
224 {
225  int netCode = -1;
226  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
227 
228  if( item )
229  {
230  // Selection disambiguation
231  if( item->IsBrightened() )
232  {
234  }
235 
236  // Don't let pads that *should* be NPTHs get lost
237  if( item->Type() == PCB_PAD_T && dyn_cast<const D_PAD*>( item )->PadShouldBeNPTH() )
238  aLayer = LAYER_MOD_TEXT_INVISIBLE;
239 
240  if( item->IsSelected() )
241  {
242  return m_layerColorsSel[aLayer];
243  }
244 
246  {
247  if( item->IsHighlighted() )
248  return m_layerColorsHi[aLayer];
249  else
250  return m_layerColorsDark[aLayer];
251  }
252 
253  // Try to obtain the netcode for the item
254  if( const BOARD_CONNECTED_ITEM* conItem = dyn_cast<const BOARD_CONNECTED_ITEM*> ( item ) )
255  netCode = conItem->GetNetCode();
256 
257  if( item->Type() == PCB_MARKER_T )
258  return m_layerColors[aLayer];
259 
260  // For vias, some layers depend on other layers in high contrast mode
261  if( m_hiContrastEnabled && item->Type() == PCB_VIA_T &&
262  ( aLayer == LAYER_VIAS_HOLES ||
263  aLayer == LAYER_VIA_THROUGH ||
264  aLayer == LAYER_VIA_MICROVIA ||
265  aLayer == LAYER_VIA_BBLIND ) )
266  {
267  const VIA* via = static_cast<const VIA*>( item );
268  const BOARD* pcb = static_cast<const BOARD*>( item->GetParent() );
269  bool viaActiveLayer = false;
270 
271  for( auto activeLayer : m_activeLayers )
272  {
273  auto lay_id = static_cast<PCB_LAYER_ID>( activeLayer );
274  viaActiveLayer |= via->IsOnLayer( lay_id ) && pcb->IsLayerVisible( lay_id );
275  }
276 
277  if( viaActiveLayer )
278  return m_layerColors[aLayer];
279  else
280  return m_hiContrastColor[aLayer];
281  }
282  }
283 
284  // Single net highlight mode
285  if( m_highlightEnabled && netCode == m_highlightNetcode )
286  return m_layerColorsHi[aLayer];
287 
288  // Return grayish color for non-highlighted layers in the high contrast mode
289  if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
290  return m_hiContrastColor[aLayer];
291 
292  // Catch the case when highlight and high-contraste modes are enabled
293  // and we are drawing a not highlighted track
294  if( m_highlightEnabled )
295  return m_layerColorsDark[aLayer];
296 
297  // No special modificators enabled
298  return m_layerColors[aLayer];
299 }
300 
301 
303  PAINTER( aGal )
304 {
305 }
306 
307 
308 int PCB_PAINTER::getLineThickness( int aActualThickness ) const
309 {
310  // if items have 0 thickness, draw them with the outline
311  // width, otherwise respect the set value (which, no matter
312  // how small will produce something)
313  if( aActualThickness == 0 )
315 
316  return aActualThickness;
317 }
318 
319 
320 int PCB_PAINTER::getDrillShape( const D_PAD* aPad ) const
321 {
322  return aPad->GetDrillShape();
323 }
324 
325 
327 {
328  return VECTOR2D( aPad->GetDrillSize() );
329 }
330 
331 
332 int PCB_PAINTER::getDrillSize( const VIA* aVia ) const
333 {
334  return aVia->GetDrillValue();
335 }
336 
337 
338 bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
339 {
340  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
341 
342  if( !item )
343  return false;
344 
345  // the "cast" applied in here clarifies which overloaded draw() is called
346  switch( item->Type() )
347  {
348  case PCB_TRACE_T:
349  draw( static_cast<const TRACK*>( item ), aLayer );
350  break;
351 
352  case PCB_VIA_T:
353  draw( static_cast<const VIA*>( item ), aLayer );
354  break;
355 
356  case PCB_PAD_T:
357  draw( static_cast<const D_PAD*>( item ), aLayer );
358  break;
359 
360  case PCB_LINE_T:
361  case PCB_MODULE_EDGE_T:
362  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
363  break;
364 
365  case PCB_TEXT_T:
366  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
367  break;
368 
369  case PCB_MODULE_TEXT_T:
370  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
371  break;
372 
373  case PCB_MODULE_T:
374  draw( static_cast<const MODULE*>( item ), aLayer );
375  break;
376 
377  case PCB_ZONE_AREA_T:
378  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
379  break;
380 
382  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
383  break;
384 
385  case PCB_DIMENSION_T:
386  draw( static_cast<const DIMENSION*>( item ), aLayer );
387  break;
388 
389  case PCB_TARGET_T:
390  draw( static_cast<const PCB_TARGET*>( item ) );
391  break;
392 
393  case PCB_MARKER_T:
394  draw( static_cast<const MARKER_PCB*>( item ) );
395  break;
396 
397  default:
398  // Painter does not know how to draw the object
399  return false;
400  }
401 
402  return true;
403 }
404 
405 
406 void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
407 {
408  VECTOR2D start( aTrack->GetStart() );
409  VECTOR2D end( aTrack->GetEnd() );
410  int width = aTrack->GetWidth();
411 
413  {
414  // If there is a net name - display it on the track
415  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
416  {
417  VECTOR2D line = ( end - start );
418  double length = line.EuclideanNorm();
419 
420  // Check if the track is long enough to have a netname displayed
421  if( length < 10 * width )
422  return;
423 
424  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
425  VECTOR2D textPosition = start + line / 2.0; // center of the track
426 
427  double textOrientation;
428 
429  if( end.y == start.y ) // horizontal
430  textOrientation = 0;
431  else if( end.x == start.x ) // vertical
432  textOrientation = M_PI / 2;
433  else
434  textOrientation = -atan( line.y / line.x );
435 
436  double textSize = width;
437 
438  m_gal->SetIsStroke( true );
439  m_gal->SetIsFill( false );
441  m_gal->SetLineWidth( width / 10.0 );
442  m_gal->SetFontBold( false );
443  m_gal->SetFontItalic( false );
444  m_gal->SetTextMirrored( false );
445  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
448  m_gal->BitmapText( netName, textPosition, textOrientation );
449  }
450  }
451  else if( IsCopperLayer( aLayer ) )
452  {
453  // Draw a regular track
454  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
455  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
458  m_gal->SetIsStroke( outline_mode );
459  m_gal->SetIsFill( not outline_mode );
461 
462  m_gal->DrawSegment( start, end, width );
463 
464  // Clearance lines
465  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
466 
467  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
468  {
470  m_gal->SetIsFill( false );
471  m_gal->SetIsStroke( true );
473  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
474  }
475  }
476 }
477 
478 
479 void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
480 {
481  VECTOR2D center( aVia->GetStart() );
482  double radius = 0.0;
483 
484  // Draw description layer
485  if( IsNetnameLayer( aLayer ) )
486  {
487  VECTOR2D position( center );
488 
489  // Is anything that we can display enabled?
491  {
492  bool displayNetname = ( !aVia->GetNetname().empty() );
493  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
494  double size = aVia->GetWidth();
495 
496  // Font size limits
497  if( size > maxSize )
498  size = maxSize;
499 
500  m_gal->Save();
501  m_gal->Translate( position );
502 
503  // Default font settings
506 
507  // Set the text position to the pad shape position (the pad position is not the best place)
508  VECTOR2D textpos( 0.0, 0.0 );
509 
510  if( displayNetname )
511  {
512  wxString netname = UnescapeString( aVia->GetShortNetname() );
513  // calculate the size of net name text:
514  double tsize = 1.5 * size / netname.Length();
515  tsize = std::min( tsize, size );
516  // Use a smaller text size to handle interline, pen size..
517  tsize *= 0.7;
518  VECTOR2D namesize( tsize, tsize );
519 
520  m_gal->SetGlyphSize( namesize );
521  m_gal->SetLineWidth( namesize.x / 12.0 );
522  m_gal->BitmapText( netname, textpos, 0.0 );
523  }
524 
525 
526  m_gal->Restore();
527  }
528  return;
529  }
530 
531  // Choose drawing settings depending on if we are drawing via's pad or hole
532  if( aLayer == LAYER_VIAS_HOLES )
533  radius = getDrillSize( aVia ) / 2.0;
534  else
535  radius = aVia->GetWidth() / 2.0;
536 
537  bool sketchMode = false;
538  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
539 
540  switch( aVia->GetViaType() )
541  {
542  case VIATYPE::THROUGH:
544  break;
545 
548  break;
549 
550  case VIATYPE::MICROVIA:
552  break;
553 
554  default:
555  wxASSERT( false );
556  break;
557  }
558 
559  m_gal->SetIsFill( !sketchMode );
560  m_gal->SetIsStroke( sketchMode );
561 
562  if( sketchMode )
563  {
564  // Outline mode
567  }
568  else
569  {
570  // Filled mode
572  }
573 
574  if( aVia->GetViaType() == VIATYPE::BLIND_BURIED && aLayer != LAYER_VIAS_HOLES )
575  {
576  // Outer circles of blind/buried vias are drawn in a special way to indicate the
577  // top and bottom layers
578  PCB_LAYER_ID layerTop, layerBottom;
579  aVia->LayerPair( &layerTop, &layerBottom );
580 
581  if( !sketchMode )
582  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
583 
584  if( aLayer == layerTop )
585  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
586 
587  else if( aLayer == layerBottom )
588  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
589 
590  else if( aLayer == LAYER_VIA_BBLIND )
591  {
592  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
593  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
594  }
595  }
596  else
597  {
598  // Draw the outer circles of normal vias and the inner circles for all vias
599  m_gal->DrawCircle( center, radius );
600  }
601 
602  // Clearance lines
603  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
604 
605  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
606  && aLayer != LAYER_VIAS_HOLES )
607  {
609  m_gal->SetIsFill( false );
610  m_gal->SetIsStroke( true );
612  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
613  }
614 }
615 
616 
617 void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
618 {
619  double m, n;
620  double orientation = aPad->GetOrientation();
621 
622  // Draw description layer
623  if( IsNetnameLayer( aLayer ) )
624  {
625  VECTOR2D position( aPad->ShapePos() );
626 
627  // Is anything that we can display enabled?
629  {
630  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
631  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
632  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
633  double size = padsize.y;
634 
635  // Keep the size ratio for the font, but make it smaller
636  if( padsize.x < padsize.y )
637  {
638  orientation += 900.0;
639  size = padsize.x;
640  std::swap( padsize.x, padsize.y );
641  }
642  else if( padsize.x == padsize.y )
643  {
644  // If the text is displayed on a symmetrical pad, do not rotate it
645  orientation = 0.0;
646  }
647 
648  // Font size limits
649  if( size > maxSize )
650  size = maxSize;
651 
652  m_gal->Save();
653  m_gal->Translate( position );
654 
655  // do not display descriptions upside down
656  NORMALIZE_ANGLE_90( orientation );
657  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
658 
659  // Default font settings
662  m_gal->SetFontBold( false );
663  m_gal->SetFontItalic( false );
664  m_gal->SetTextMirrored( false );
666  m_gal->SetIsStroke( true );
667  m_gal->SetIsFill( false );
668 
669  // Set the text position to the pad shape position (the pad position is not the best place)
670  VECTOR2D textpos( 0.0, 0.0 );
671 
672  // Divide the space, to display both pad numbers and netnames
673  // and set the Y text position to display 2 lines
674  if( displayNetname && m_pcbSettings.m_padNumbers )
675  {
676  size = size / 2.0;
677  textpos.y = size / 2.0;
678  }
679 
680  if( displayNetname )
681  {
682  wxString netname = UnescapeString( aPad->GetShortNetname() );
683  // calculate the size of net name text:
684  double tsize = 1.5 * padsize.x / netname.Length();
685  tsize = std::min( tsize, size );
686  // Use a smaller text size to handle interline, pen size..
687  tsize *= 0.7;
688  VECTOR2D namesize( tsize, tsize );
689 
690  m_gal->SetGlyphSize( namesize );
691  m_gal->SetLineWidth( namesize.x / 12.0 );
692  m_gal->BitmapText( netname, textpos, 0.0 );
693  }
694 
696  {
697  const wxString& padName = aPad->GetName();
698  textpos.y = -textpos.y;
699  double tsize = 1.5 * padsize.x / padName.Length();
700  tsize = std::min( tsize, size );
701  // Use a smaller text size to handle interline, pen size..
702  tsize *= 0.7;
703  tsize = std::min( tsize, size );
704  VECTOR2D numsize( tsize, tsize );
705 
706  m_gal->SetGlyphSize( numsize );
707  m_gal->SetLineWidth( numsize.x / 12.0 );
708  m_gal->BitmapText( padName, textpos, 0.0 );
709  }
710 
711  m_gal->Restore();
712  }
713  return;
714  }
715 
716  // Pad drawing
717  COLOR4D color;
718 
719  // Pad holes color is type specific
720  // Hole color is the background color for plated holes, but only if the pad size is greater than the hole size.
721  // ( Don't let pads that *should* be NPTH get lost )
722  if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() )
723  {
725  }
726  else
727  {
728  color = m_pcbSettings.GetColor( aPad, aLayer );
729  }
730 
731  VECTOR2D size;
732 
734  {
735  // Outline mode
736  m_gal->SetIsFill( false );
737  m_gal->SetIsStroke( true );
740  }
741  else
742  {
743  // Filled mode
744  m_gal->SetIsFill( true );
745  m_gal->SetIsStroke( false );
747  }
748 
749  // Choose drawing settings depending on if we are drawing a pad itself or a hole
750  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
751  {
752  m_gal->Save();
753  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
754  m_gal->Rotate( -aPad->GetOrientationRadians() );
755 
756  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
757  size = getDrillSize( aPad ) / 2.0;
758 
759  if( getDrillShape( aPad ) == PAD_DRILL_SHAPE_OBLONG )
760  {
761  if( size.y >= size.x )
762  {
763  m = ( size.y - size.x );
764  n = size.x;
765 
766  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
767  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
768 
770  {
771  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
772  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
773  }
774  else
775  {
776  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
777  }
778  }
779  else
780  {
781  m = ( size.x - size.y );
782  n = size.y;
783  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
784  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
785 
787  {
788  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
789  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
790  }
791  else
792  {
793  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
794  }
795  }
796  }
797  else
798  {
799  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
800  }
801 
802  m_gal->Restore();
803  }
804  else
805  {
806  SHAPE_POLY_SET polySet;
807  wxSize margin;
808  int clearance = 0;
809 
810  switch( aLayer )
811  {
812  case F_Mask:
813  case B_Mask:
814  clearance += aPad->GetSolderMaskMargin();
815  break;
816 
817  case F_Paste:
818  case B_Paste:
819  margin = aPad->GetSolderPasteMargin();
820  clearance += ( margin.x + margin.y ) / 2;
821  break;
822 
823  default:
824  break;
825  }
826 
827  aPad->TransformShapeWithClearanceToPolygon( polySet, clearance );
828  m_gal->DrawPolygon( polySet );
829  }
830 
831  // Clearance lines
832  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
833 
834  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
835  && ( aLayer == LAYER_PAD_FR
836  || aLayer == LAYER_PAD_BK
837  || aLayer == LAYER_PADS_TH ) )
838  {
839  SHAPE_POLY_SET polySet;
840  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance() );
842  m_gal->SetIsStroke( true );
843  m_gal->SetIsFill( false );
845  m_gal->DrawPolygon( polySet );
846  }
847 }
848 
849 
850 void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
851 {
852  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
853  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
854  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
855 
856  int thickness = getLineThickness( aSegment->GetWidth() );
857  VECTOR2D start( aSegment->GetStart() );
858  VECTOR2D end( aSegment->GetEnd() );
859 
860  m_gal->SetIsFill( !sketch );
861  m_gal->SetIsStroke( sketch );
865 
866  switch( aSegment->GetShape() )
867  {
868  case S_SEGMENT:
869  m_gal->DrawSegment( start, end, thickness );
870  break;
871 
872  case S_RECT:
873  wxASSERT_MSG( false, "Not tested yet" );
874  m_gal->DrawRectangle( start, end );
875  break;
876 
877  case S_ARC:
878  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
879  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
880  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
881  thickness );
882  break;
883 
884  case S_CIRCLE:
885  if( sketch )
886  {
887  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
888  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
889  }
890  else
891  {
892  m_gal->SetLineWidth( thickness );
893  m_gal->SetIsFill( false );
894  m_gal->SetIsStroke( true );
895  m_gal->DrawCircle( start, aSegment->GetRadius() );
896  }
897  break;
898 
899  case S_POLYGON:
900  {
901  SHAPE_POLY_SET& shape = ((DRAWSEGMENT*)aSegment)->GetPolyShape();
902 
903  if( shape.OutlineCount() == 0 )
904  break;
905 
906  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
907  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
908  // on Opengl.
909  // GLU tesselation is much slower, so currently we are using our tesselation.
910  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
911  {
912  shape.CacheTriangulation();
913  }
914 
915  m_gal->Save();
916 
917  if( MODULE* module = aSegment->GetParentModule() )
918  {
919  m_gal->Translate( module->GetPosition() );
920  m_gal->Rotate( -module->GetOrientationRadians() );
921  }
922 
923  m_gal->SetLineWidth( thickness );
924 
925  if( sketch )
926  m_gal->SetIsFill( false );
927  else
928  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
929 
930  m_gal->SetIsStroke( true );
931  m_gal->DrawPolygon( shape );
932 
933  m_gal->Restore();
934  break;
935  }
936 
937  case S_CURVE:
938  m_gal->SetIsFill( false );
939  m_gal->SetIsStroke( true );
940  m_gal->SetLineWidth( thickness );
941  // Use thickness as filter value to convert the curve to polyline
942  // when the curve is not supported
943  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
944  VECTOR2D( aSegment->GetBezControl1() ),
945  VECTOR2D( aSegment->GetBezControl2() ),
946  VECTOR2D( aSegment->GetEnd() ), thickness );
947  break;
948 
949  case S_LAST:
950  break;
951  }
952 }
953 
954 
955 void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
956 {
957  wxString shownText( aText->GetShownText() );
958  if( shownText.Length() == 0 )
959  return;
960 
961  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
962  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
963 
964  if( m_pcbSettings.m_sketchMode[aLayer] )
965  {
966  // Outline mode
968  }
969  else
970  {
971  // Filled mode
973  }
974 
976  m_gal->SetIsFill( false );
977  m_gal->SetIsStroke( true );
978  m_gal->SetTextAttributes( aText );
979  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians(), GetTextMarkupFlags() );
980 }
981 
982 
983 void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
984 {
985  wxString shownText( aText->GetShownText() );
986  if( shownText.Length() == 0 )
987  return;
988 
989  bool sketch = m_pcbSettings.m_sketchFpTxtfx;
990 
991  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
992  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
993 
994  // Currently, draw text routines do not know the true outline mode.
995  // so draw the text in "line" mode (no thickness)
996  if( sketch )
997  {
998  // Outline mode
1000  }
1001  else
1002  {
1003  // Filled mode
1005  }
1006 
1008  m_gal->SetIsFill( false );
1009  m_gal->SetIsStroke( true );
1010  m_gal->SetTextAttributes( aText );
1011  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians(), GetTextMarkupFlags() );
1012 
1013  // Draw the umbilical line
1014  if( aText->IsSelected() )
1015  {
1017  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1018  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1019  }
1020 }
1021 
1022 
1023 void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
1024 {
1025  if( aLayer == LAYER_ANCHOR )
1026  {
1027  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1028 
1029  // Draw anchor
1032 
1033  // Keep the size constant, not related to the scale
1034  double anchorSize = 5.0 / m_gal->GetWorldScale();
1035 
1036  VECTOR2D center = aModule->GetPosition();
1037  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1038  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1039  }
1040 }
1041 
1042 
1043 void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer )
1044 {
1045  if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
1046  return;
1047 
1048  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1049  std::deque<VECTOR2D> corners;
1051 
1052  // Draw the outline
1053  const SHAPE_POLY_SET* outline = aZone->Outline();
1054 
1055  if( m_pcbSettings.m_zoneOutlines && outline )
1056  {
1058  m_gal->SetIsFill( false );
1059  m_gal->SetIsStroke( true );
1061 
1062  // Draw each contour (main contour and holes)
1063 
1064  /* This line:
1065  * m_gal->DrawPolygon( *outline );
1066  * should be enough, but currently does not work to draw holes contours in a complex polygon
1067  * so each contour is draw as a simple polygon
1068  */
1069 
1070  // Draw the main contour
1071  m_gal->DrawPolyline( outline->COutline( 0 ) );
1072 
1073  // Draw holes
1074  int holes_count = outline->HoleCount( 0 );
1075 
1076  for( int ii = 0; ii < holes_count; ++ii )
1077  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1078 
1079  // Draw hatch lines
1080  for( const SEG& hatchLine : aZone->GetHatchLines() )
1081  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1082  }
1083 
1084  // Draw the filling
1085  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1086  {
1087  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1088 
1089  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1090  return;
1091 
1092  // Set up drawing options
1093  int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
1095  m_gal->SetFillColor( color );
1096  m_gal->SetLineWidth( outline_thickness );
1097 
1098  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1099  {
1100  m_gal->SetIsFill( true );
1101  m_gal->SetIsStroke( outline_thickness > 0 );
1102  }
1103  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1104  {
1105  m_gal->SetIsFill( false );
1106  m_gal->SetIsStroke( true );
1107  }
1108 
1109  m_gal->DrawPolygon( polySet );
1110  }
1111 
1112 }
1113 
1114 
1115 void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
1116 {
1117  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1118 
1119  m_gal->SetStrokeColor( strokeColor );
1120  m_gal->SetIsFill( false );
1121  m_gal->SetIsStroke( true );
1122  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1123 
1124  // Draw an arrow
1125  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1126  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1127  VECTOR2D( aDimension->m_featureLineGF ) );
1128  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1129  VECTOR2D( aDimension->m_featureLineDF ) );
1130  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1131  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1132  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1133  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1134 
1135  // Draw text
1136  TEXTE_PCB& text = aDimension->Text();
1137  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1138 
1139  m_gal->SetLineWidth( text.GetThickness() );
1140  m_gal->SetTextAttributes( &text );
1141  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians(),
1142  GetTextMarkupFlags() );
1143 }
1144 
1145 
1146 void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
1147 {
1148  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1149  VECTOR2D position( aTarget->GetPosition() );
1150  double size, radius;
1151 
1152  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1153  m_gal->SetStrokeColor( strokeColor );
1154  m_gal->SetIsFill( false );
1155  m_gal->SetIsStroke( true );
1156 
1157  m_gal->Save();
1158  m_gal->Translate( position );
1159 
1160  if( aTarget->GetShape() )
1161  {
1162  // shape x
1163  m_gal->Rotate( M_PI / 4.0 );
1164  size = 2.0 * aTarget->GetSize() / 3.0;
1165  radius = aTarget->GetSize() / 2.0;
1166  }
1167  else
1168  {
1169  // shape +
1170  size = aTarget->GetSize() / 2.0;
1171  radius = aTarget->GetSize() / 3.0;
1172  }
1173 
1174  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1175  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1176  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1177 
1178  m_gal->Restore();
1179 }
1180 
1181 
1182 void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
1183 {
1184  SHAPE_LINE_CHAIN polygon;
1185  aMarker->ShapeToPolygon( polygon );
1186 
1187  auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
1188 
1189  m_gal->Save();
1190  m_gal->Translate( aMarker->GetPosition() );
1191  m_gal->SetFillColor( strokeColor );
1192  m_gal->SetIsFill( true );
1193  m_gal->SetIsStroke( false );
1194  m_gal->DrawPolygon( polygon );
1195  m_gal->Restore();
1196 }
1197 
1198 
1199 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:287
int GetNetCode() const
Function GetNetCode.
int OutlineCount() const
Returns the number of outlines in the set
int GetWidth() const
const wxPoint GetPosition() const override
TEXTE_PCB class definition.
COLOR4D Inverted() const
Function Inverted Returns an inverted color, alpha remains the same.
Definition: color4d.h:259
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:292
bool IsSelected() const
Definition: base_struct.h:223
multilayer pads, usually with holes
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
wxPoint m_crossBarF
Handle colors used to draw all items or layers.
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
Colors for all layers (highlighted)
Definition: painter.h:268
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:265
wxPoint m_arrowD1F
const wxPoint & GetStart() const
Definition: class_track.h:109
STROKE_T GetShape() const
handle color for not plated holes (holes, not pads)
anchor of items having an anchor point (texts, footprints)
int GetSize() const
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_zone.cpp:301
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:176
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:101
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:247
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:188
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:599
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
to draw via holes (pad holes do not use this layer)
bool m_sketchBoardGfx
Flag determining if board graphic items should be outlined or stroked
Definition: pcb_painter.h:179
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:283
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:212
bool IsBrightened() const
Definition: base_struct.h:226
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:185
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
wxPoint m_featureLineDF
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:83
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247
Add new GAL layers here.
COLOR4D m_selectionCandidateColor
Color used for highlighting selection candidates
Definition: pcb_painter.h:218
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.
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: pcb_painter.cpp:79
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:331
bool IsHighlighted() const
Definition: base_struct.h:225
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:191
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:365
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:277
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
wxPoint m_featureLineGO
DIMENSION class definition.
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:262
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
void SetFontBold(const bool aBold)
Set bold property of current font.
segment with non rounded ends
class MODULE, a footprint
Definition: typeinfo.h:89
Markers used to show a drc problem on boards.
int 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:313
double a
Alpha component.
Definition: color4d.h:304
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:274
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:209
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:280
virtual void update()
Function update Precalculates extra colors for layers (e.g.
Definition: painter.cpp:54
SHAPE_POLY_SET.
Arcs (with rounded ends)
to draw usual through hole vias
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:428
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:215
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.
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:99
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:688
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:203
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:182
int GetWidth() const
Pad object description.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:100
virtual const wxPoint GetPosition() const =0
double GetOrientationRadians() const
Definition: class_pad.h:424
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
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:194
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:449
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:297
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:98
smd pads, front layer
virtual void Restore()
Restore the context.
int GetWidth() const
Definition: class_track.h:103
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:215
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:160
SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:422
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,...
TEXTE_PCB & Text()
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: pcb_painter.h:153
const wxSize & GetDrillSize() const
Definition: class_pad.h:306
wxPoint ShapePos() const
Definition: class_pad.cpp:570
double DECIDEG2RAD(double deg)
Definition: trigo.h:214
int GetShape() const
VIATYPE GetViaType() const
Definition: class_track.h:336
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:163
int GetMinThickness() const
Definition: class_zone.h:186
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:106
PCB_PAINTER(GAL *aGal)
COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
wxPoint m_crossBarO
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
PCB_TARGET class definition.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h: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:284
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:200
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:463
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:197
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
Colors for all layers (selected)
Definition: painter.h:271
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:207
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:206
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:553
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:39
wxPoint m_featureLineGF