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