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 
39 #include <pcb_painter.h>
42 
43 using namespace KIGFX;
44 
46 {
47  m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
48  m_padNumbers = true;
49  m_netNamesOnPads = true;
50  m_netNamesOnTracks = true;
53  m_sketchBoardGfx = false;
54  m_sketchFpGfx = false;
55 
56  // By default everything should be displayed as filled
57  for( unsigned int i = 0; i < TOTAL_LAYER_COUNT; ++i )
58  {
59  m_sketchMode[i] = false;
60  }
61 
62  update();
63 }
64 
65 
67 {
68  for( int i = 0; i < LAYER_ID_COUNT; i++ )
69  {
70  m_layerColors[i] = aSettings->GetLayerColor( i );
71  m_layerColors[i].a = 0.8; // slightly transparent
72  }
73 
74  for( int i = 0; i < END_PCB_VISIBLE_LIST; i++ )
75  m_layerColors[ITEM_GAL_LAYER( i )] = aSettings->GetItemColor( i );
76 
79 
80  // Default colors for specific layers
81  m_layerColors[ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE )] = COLOR4D( 0.5, 0.4, 0.0, 0.8 );
82  m_layerColors[ITEM_GAL_LAYER( PADS_HOLES_VISIBLE )] = COLOR4D( 0.0, 0.5, 0.5, 0.8 );
83  m_layerColors[ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE )] = COLOR4D( 0.6, 0.6, 0.6, 0.8 );
84  m_layerColors[ITEM_GAL_LAYER( VIA_BBLIND_VISIBLE )] = COLOR4D( 0.6, 0.6, 0.6, 0.8 );
85  m_layerColors[ITEM_GAL_LAYER( VIA_MICROVIA_VISIBLE )] = COLOR4D( 0.4, 0.4, 0.8, 0.8 );
86  m_layerColors[ITEM_GAL_LAYER( PADS_VISIBLE )] = COLOR4D( 0.6, 0.6, 0.6, 0.8 );
90  m_layerColors[ITEM_GAL_LAYER( ANCHOR_VISIBLE )] = COLOR4D( 0.3, 0.3, 1.0, 0.9 );
91  m_layerColors[ITEM_GAL_LAYER( WORKSHEET )] = COLOR4D( 0.5, 0.0, 0.0, 0.8 );
92  m_layerColors[ITEM_GAL_LAYER( DRC_VISIBLE )] = COLOR4D( 1.0, 0.0, 0.0, 0.8 );
93 
94  // Make ratsnest lines slightly transparent
96 
97  // Netnames for copper layers
98  for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
99  {
100  const COLOR4D lightLabel( 0.8, 0.8, 0.8, 0.7 );
101  const COLOR4D darkLabel = lightLabel.Inverted();
102  LAYER_ID layer = *cu;
103 
104  if( m_layerColors[layer].GetBrightness() > 0.5 )
105  m_layerColors[GetNetnameLayer( layer )] = darkLabel;
106  else
107  m_layerColors[GetNetnameLayer( layer )] = lightLabel;
108  }
109 
110  update();
111 }
112 
113 
115 {
116  if( aOptions == NULL )
117  return;
118 
120  m_padNumbers = aOptions->m_DisplayPadNum;
122  m_sketchFpGfx = !aOptions->m_DisplayModEdgeFill;
123 
124  // Whether to draw tracks, vias & pads filled or as outlines
130 
131  // Net names display settings
132  switch( aOptions->m_DisplayNetNamesMode )
133  {
134  case 0:
135  m_netNamesOnPads = false;
136  m_netNamesOnTracks = false;
137  break;
138 
139  case 1:
140  m_netNamesOnPads = true;
141  m_netNamesOnTracks = false;
142  break;
143 
144  case 2:
145  m_netNamesOnPads = false;
146  m_netNamesOnTracks = true;
147  break;
148 
149  case 3:
150  m_netNamesOnPads = true;
151  m_netNamesOnTracks = true;
152  break;
153  }
154 
155  // Zone display settings
156  switch( aOptions->m_DisplayZonesMode )
157  {
158  case 0:
160  break;
161 
162  case 1:
164  break;
165 
166  case 2:
168  break;
169  }
170 
171  // Clearance settings
172  switch( aOptions->m_ShowTrackClearanceMode )
173  {
176  break;
177 
180  break;
181 
184  break;
185 
188  break;
189 
192  break;
193  }
194 
195  if( aOptions->m_DisplayPadIsol )
196  m_clearance |= CL_PADS;
197 }
198 
199 
200 const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
201 {
202  int netCode = -1;
203  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
204 
205  if( item )
206  {
207  if( item->IsSelected() )
208  {
209  return m_layerColorsSel[aLayer];
210  }
211 
212  // Try to obtain the netcode for the item
213  if( const BOARD_CONNECTED_ITEM* conItem = dyn_cast<const BOARD_CONNECTED_ITEM*> ( item ) )
214  netCode = conItem->GetNetCode();
215  }
216 
217  // Single net highlight mode
218  if( m_highlightEnabled && netCode == m_highlightNetcode )
219  return m_layerColorsHi[aLayer];
220 
221  // Return grayish color for non-highlighted layers in the high contrast mode
222  if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
223  return m_hiContrastColor;
224 
225  // Catch the case when highlight and high-contraste modes are enabled
226  // and we are drawing a not highlighted track
227  if( m_highlightEnabled )
228  return m_layerColorsDark[aLayer];
229 
230  // No special modificators enabled
231  return m_layerColors[aLayer];
232 }
233 
234 
236  PAINTER( aGal )
237 {
238 }
239 
240 
241 int PCB_PAINTER::getLineThickness( int aActualThickness ) const
242 {
243  // if items have 0 thickness, draw them with the outline
244  // width, otherwise respect the set value (which, no matter
245  // how small will produce something)
246  if( aActualThickness == 0 )
248 
249  return aActualThickness;
250 }
251 
252 
253 bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
254 {
255  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
256 
257  // the "cast" applied in here clarifies which overloaded draw() is called
258  switch( item->Type() )
259  {
260  case PCB_ZONE_T:
261  case PCB_TRACE_T:
262  draw( static_cast<const TRACK*>( item ), aLayer );
263  break;
264 
265  case PCB_VIA_T:
266  draw( static_cast<const VIA*>( item ), aLayer );
267  break;
268 
269  case PCB_PAD_T:
270  draw( static_cast<const D_PAD*>( item ), aLayer );
271  break;
272 
273  case PCB_LINE_T:
274  case PCB_MODULE_EDGE_T:
275  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
276  break;
277 
278  case PCB_TEXT_T:
279  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
280  break;
281 
282  case PCB_MODULE_TEXT_T:
283  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
284  break;
285 
286  case PCB_MODULE_T:
287  draw( static_cast<const MODULE*>( item ), aLayer );
288  break;
289 
290  case PCB_ZONE_AREA_T:
291  draw( static_cast<const ZONE_CONTAINER*>( item ) );
292  break;
293 
294  case PCB_DIMENSION_T:
295  draw( static_cast<const DIMENSION*>( item ), aLayer );
296  break;
297 
298  case PCB_TARGET_T:
299  draw( static_cast<const PCB_TARGET*>( item ) );
300  break;
301 
302  case PCB_MARKER_T:
303  draw( static_cast<const MARKER_PCB*>( item ) );
304  break;
305 
306  default:
307  // Painter does not know how to draw the object
308  return false;
309  }
310 
311  return true;
312 }
313 
314 
315 void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
316 {
317  VECTOR2D start( aTrack->GetStart() );
318  VECTOR2D end( aTrack->GetEnd() );
319  int width = aTrack->GetWidth();
320 
322  {
323  // If there is a net name - display it on the track
324  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
325  {
326  VECTOR2D line = ( end - start );
327  double length = line.EuclideanNorm();
328 
329  // Check if the track is long enough to have a netname displayed
330  if( length < 10 * width )
331  return;
332 
333  const wxString& netName = aTrack->GetShortNetname();
334  VECTOR2D textPosition = start + line / 2.0; // center of the track
335  double textOrientation = -atan( line.y / line.x );
336  double textSize = width;
337 
338  m_gal->SetIsStroke( true );
339  m_gal->SetIsFill( false );
340  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
341  m_gal->SetLineWidth( width / 10.0 );
342  m_gal->SetFontBold( false );
343  m_gal->SetFontItalic( false );
344  m_gal->SetTextMirrored( false );
345  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
348  m_gal->BitmapText( netName, textPosition, textOrientation );
349  }
350  }
351  else if( IsCopperLayer( aLayer ) )
352  {
353  // Draw a regular track
354  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
355  m_gal->SetStrokeColor( color );
356  m_gal->SetIsStroke( true );
357 
359  {
360  // Outline mode
362  m_gal->SetIsFill( false );
363  }
364  else
365  {
366  // Filled mode
367  m_gal->SetFillColor( color );
368  m_gal->SetIsFill( true );
369  }
370 
371  m_gal->DrawSegment( start, end, width );
372 
373  // Clearance lines
374  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
375 
376  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
377  {
379  m_gal->SetIsFill( false );
380  m_gal->SetIsStroke( true );
381  m_gal->SetStrokeColor( color );
382  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
383  }
384  }
385 }
386 
387 
388 void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
389 {
390  VECTOR2D center( aVia->GetStart() );
391  double radius = 0.0;
392 
393  // Only draw the via if at least one of the layers it crosses is being displayed
394  BOARD* brd = aVia->GetBoard( );
395  if( !( brd->GetVisibleLayers() & aVia->GetLayerSet() ).any() )
396  return;
397 
398  // Choose drawing settings depending on if we are drawing via's pad or hole
399  if( aLayer == ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ) )
400  radius = aVia->GetDrillValue() / 2.0;
401  else
402  radius = aVia->GetWidth() / 2.0;
403 
404  bool sketchMode = false;
405  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
406 
407  switch( aVia->GetViaType() )
408  {
409  case VIA_THROUGH:
411  break;
412 
413  case VIA_BLIND_BURIED:
415  break;
416 
417  case VIA_MICROVIA:
419  break;
420 
421  default:
422  assert( false );
423  break;
424  }
425 
426  if( aVia->GetViaType() == VIA_BLIND_BURIED )
427  {
428  // Buried vias are drawn in a special way to indicate the top and bottom layers
429  LAYER_ID layerTop, layerBottom;
430  aVia->LayerPair( &layerTop, &layerBottom );
431 
432  if( aLayer == ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ) )
433  { // TODO outline mode
434  m_gal->SetIsFill( true );
435  m_gal->SetIsStroke( false );
436  m_gal->SetFillColor( color );
437  m_gal->DrawCircle( center, radius );
438  }
439  else
440  {
441  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
442 
443  m_gal->SetLineWidth( width );
444  m_gal->SetIsFill( true );
445  m_gal->SetIsStroke( false );
446  m_gal->SetFillColor( color );
447 
448  if( aLayer == layerTop )
449  {
450  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
451  }
452  else if( aLayer == layerBottom )
453  {
454  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
455  }
456  else if( aLayer == ITEM_GAL_LAYER( VIA_BBLIND_VISIBLE ) )
457  {
458  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
459  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
460  }
461  }
462  }
463  else
464  {
465  // Regular vias
466  m_gal->SetIsFill( !sketchMode );
467  m_gal->SetIsStroke( sketchMode );
468 
469  if( sketchMode )
470  {
471  // Outline mode
473  m_gal->SetStrokeColor( color );
474  }
475  else
476  {
477  // Filled mode
478  m_gal->SetFillColor( color );
479  }
480 
481  m_gal->DrawCircle( center, radius );
482  }
483 
484  // Clearance lines
485  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
486 
487  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
488  && aLayer != ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ) )
489  {
491  m_gal->SetIsFill( false );
492  m_gal->SetIsStroke( true );
493  m_gal->SetStrokeColor( color );
494  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
495  }
496 }
497 
498 
499 void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
500 {
501  PAD_SHAPE_T shape;
502  double m, n;
503  double orientation = aPad->GetOrientation();
504  wxString buffer;
505 
506  // Draw description layer
507  if( IsNetnameLayer( aLayer ) )
508  {
509  VECTOR2D position( aPad->ShapePos() );
510 
511  // Is anything that we can display enabled?
513  {
514  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
515  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
516  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
517  double size = padsize.y;
518 
519  // Keep the size ratio for the font, but make it smaller
520  if( padsize.x < padsize.y )
521  {
522  orientation += 900.0;
523  size = padsize.x;
524  std::swap( padsize.x, padsize.y );
525  }
526  else if( padsize.x == padsize.y )
527  {
528  // If the text is displayed on a symmetrical pad, do not rotate it
529  orientation = 0.0;
530  }
531 
532  // Font size limits
533  if( size > maxSize )
534  size = maxSize;
535 
536  m_gal->Save();
537  m_gal->Translate( position );
538 
539  // do not display descriptions upside down
540  NORMALIZE_ANGLE_90( orientation );
541  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
542 
543  // Default font settings
546  m_gal->SetFontBold( false );
547  m_gal->SetFontItalic( false );
548  m_gal->SetTextMirrored( false );
549  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
550  m_gal->SetIsStroke( true );
551  m_gal->SetIsFill( false );
552 
553  // Set the text position to the pad shape position (the pad position is not the best place)
554  VECTOR2D textpos( 0.0, 0.0 );
555 
556  // Divide the space, to display both pad numbers and netnames
557  // and set the Y text position to display 2 lines
558  if( displayNetname && m_pcbSettings.m_padNumbers )
559  {
560  size = size / 2.0;
561  textpos.y = size / 2.0;
562  }
563 
564  if( displayNetname )
565  {
566  // calculate the size of net name text:
567  double tsize = 1.5 * padsize.x / aPad->GetShortNetname().Length();
568  tsize = std::min( tsize, size );
569  // Use a smaller text size to handle interline, pen size..
570  tsize *= 0.7;
571  VECTOR2D namesize( tsize, tsize );
572 
573  m_gal->SetGlyphSize( namesize );
574  m_gal->SetLineWidth( namesize.x / 12.0 );
575  m_gal->BitmapText( aPad->GetShortNetname(), textpos, 0.0 );
576  }
577 
579  {
580  textpos.y = -textpos.y;
581  aPad->StringPadName( buffer );
582  int len = buffer.Length();
583  double tsize = 1.5 * padsize.x / len;
584  tsize = std::min( tsize, size );
585  // Use a smaller text size to handle interline, pen size..
586  tsize *= 0.7;
587  tsize = std::min( tsize, size );
588  VECTOR2D numsize( tsize, tsize );
589 
590  m_gal->SetGlyphSize( numsize );
591  m_gal->SetLineWidth( numsize.x / 12.0 );
592  m_gal->BitmapText( aPad->GetPadName(), textpos, 0.0 );
593  }
594 
595  m_gal->Restore();
596  }
597  return;
598  }
599 
600  // Pad drawing
601  const COLOR4D& color = m_pcbSettings.GetColor( aPad, aLayer );
602  VECTOR2D size;
603 
605  {
606  // Outline mode
607  m_gal->SetIsFill( false );
608  m_gal->SetIsStroke( true );
610  m_gal->SetStrokeColor( color );
611  }
612  else
613  {
614  // Filled mode
615  m_gal->SetIsFill( true );
616  m_gal->SetIsStroke( false );
617  m_gal->SetFillColor( color );
618  }
619 
620  m_gal->Save();
621  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
622  m_gal->Rotate( -aPad->GetOrientationRadians() );
623 
624  // Choose drawing settings depending on if we are drawing a pad itself or a hole
625  if( aLayer == ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ) )
626  {
627  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
628  size = VECTOR2D( aPad->GetDrillSize() ) / 2.0;
630  }
631  else if( aLayer == F_Mask || aLayer == B_Mask )
632  {
633  // Drawing soldermask
634  int soldermaskMargin = aPad->GetSolderMaskMargin();
635 
636  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
637  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
638  aPad->GetSize().y / 2.0 + soldermaskMargin );
639  shape = aPad->GetShape();
640  }
641  else if( aLayer == F_Paste || aLayer == B_Paste )
642  {
643  // Drawing solderpaste
644  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
645 
646  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
647  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
648  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
649  shape = aPad->GetShape();
650  }
651  else
652  {
653  // Drawing every kind of pad
654  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
655  size = VECTOR2D( aPad->GetSize() ) / 2.0;
656  shape = aPad->GetShape();
657  }
658 
659  switch( shape )
660  {
661  case PAD_SHAPE_OVAL:
662  if( size.y >= size.x )
663  {
664  m = ( size.y - size.x );
665  n = size.x;
666 
668  {
669  // Outline mode
670  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
671  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
672  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
673  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
674  }
675  else
676  {
677  // Filled mode
678  m_gal->DrawCircle( VECTOR2D( 0, -m ), n );
679  m_gal->DrawCircle( VECTOR2D( 0, m ), n );
680  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
681  }
682  }
683  else
684  {
685  m = ( size.x - size.y );
686  n = size.y;
687 
689  {
690  // Outline mode
691  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
692  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
693  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
694  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
695  }
696  else
697  {
698  // Filled mode
699  m_gal->DrawCircle( VECTOR2D( -m, 0 ), n );
700  m_gal->DrawCircle( VECTOR2D( m, 0 ), n );
701  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
702  }
703  }
704  break;
705 
706  case PAD_SHAPE_RECT:
707  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
708  break;
709 
710  case PAD_SHAPE_ROUNDRECT:
711  {
712  SHAPE_POLY_SET polySet;
713  wxSize prsize( size.x * 2, size.y * 2 );
714  const int segmentToCircleCount = 64;
715  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
716  TransformRoundRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
717  0.0, corner_radius, segmentToCircleCount );
718 
720  {
721  if( polySet.OutlineCount() > 0 )
722  m_gal->DrawPolyline( polySet.Outline( 0 ) );
723  }
724  else
725  {
726  m_gal->DrawPolygon( polySet );
727  }
728  break;
729  }
730 
731  case PAD_SHAPE_TRAPEZOID:
732  {
733  std::deque<VECTOR2D> pointList;
734  wxPoint corners[4];
735 
736  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
737  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
738 
739  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
740  SHAPE_POLY_SET polySet;
741  polySet.NewOutline();
742  polySet.Append( VECTOR2I( corners[0] ) );
743  polySet.Append( VECTOR2I( corners[1] ) );
744  polySet.Append( VECTOR2I( corners[2] ) );
745  polySet.Append( VECTOR2I( corners[3] ) );
746 
748  m_gal->DrawPolyline( polySet.COutline( 0 ) );
749  else
750  m_gal->DrawPolygon( polySet );
751  }
752  break;
753 
754  case PAD_SHAPE_CIRCLE:
755  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
756  break;
757  }
758 
759  m_gal->Restore();
760 
761  // Clearance lines
762  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
763  // returns already transformed coordinates
764  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
765 
766  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
767  && ( aLayer == ITEM_GAL_LAYER( PAD_FR_VISIBLE )
768  || aLayer == ITEM_GAL_LAYER( PAD_BK_VISIBLE )
769  || aLayer == ITEM_GAL_LAYER( PADS_VISIBLE ) ) )
770  {
771  SHAPE_POLY_SET polySet;
772  constexpr int SEGCOUNT = 64;
773  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
774 
775  if( polySet.OutlineCount() > 0 )
776  {
778  m_gal->SetIsStroke( true );
779  m_gal->SetIsFill( false );
780  m_gal->SetStrokeColor( color );
781  m_gal->DrawPolyline( polySet.COutline( 0 ) );
782  }
783  }
784 }
785 
786 
787 void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
788 {
789  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
790  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
791  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
792 
793  int thickness = getLineThickness( aSegment->GetWidth() );
794  VECTOR2D start( aSegment->GetStart() );
795  VECTOR2D end( aSegment->GetEnd() );
796 
797  m_gal->SetIsFill( !sketch );
798  m_gal->SetIsStroke( sketch );
799  m_gal->SetFillColor( color );
800  m_gal->SetStrokeColor( color );
802 
803  switch( aSegment->GetShape() )
804  {
805  case S_SEGMENT:
806  m_gal->DrawSegment( start, end, thickness );
807  break;
808 
809  case S_RECT:
810  wxASSERT_MSG( false, wxT( "Not tested yet" ) );
811  m_gal->DrawRectangle( start, end );
812  break;
813 
814  case S_ARC:
815  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
816  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
817  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
818  thickness );
819  break;
820 
821  case S_CIRCLE:
822  if( sketch )
823  {
824  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
825  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
826  }
827  else
828  {
829  m_gal->SetLineWidth( thickness );
830  m_gal->SetIsFill( false );
831  m_gal->SetIsStroke( true );
832  m_gal->DrawCircle( start, aSegment->GetRadius() );
833  }
834  break;
835 
836  case S_POLYGON:
837  {
838  std::deque<VECTOR2D> pointsList;
839 
840  m_gal->SetIsFill( true ); // draw polygons the legacy way
841  m_gal->SetIsStroke( false );
842  m_gal->Save();
843  m_gal->SetLineWidth( thickness );
844 
845  if( MODULE* module = aSegment->GetParentModule() )
846  {
847  m_gal->Translate( module->GetPosition() );
848  m_gal->Rotate( -module->GetOrientationRadians() );
849  }
850  else
851  {
852  m_gal->Translate( aSegment->GetPosition() );
853  m_gal->Rotate( DECIDEG2RAD( -aSegment->GetAngle() ) );
854  }
855 
856  std::copy( aSegment->GetPolyPoints().begin(), aSegment->GetPolyPoints().end(),
857  std::back_inserter( pointsList ) );
858 
859  m_gal->SetLineWidth( aSegment->GetWidth() );
860  m_gal->DrawPolyline( pointsList );
861  m_gal->DrawPolygon( pointsList );
862 
863  m_gal->Restore();
864  break;
865  }
866 
867  case S_CURVE:
868  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
869  VECTOR2D( aSegment->GetBezControl1() ),
870  VECTOR2D( aSegment->GetBezControl2() ),
871  VECTOR2D( aSegment->GetEnd() ) );
872  break;
873 
874  case S_LAST:
875  break;
876  }
877 }
878 
879 
880 void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
881 {
882  wxString shownText( aText->GetShownText() );
883  if( shownText.Length() == 0 )
884  return;
885 
886  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
887  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
888 
889  if( m_pcbSettings.m_sketchMode[aLayer] )
890  {
891  // Outline mode
893  }
894  else
895  {
896  // Filled mode
898  }
899 
900  m_gal->SetStrokeColor( color );
901  m_gal->SetIsFill( false );
902  m_gal->SetIsStroke( true );
903  m_gal->SetTextAttributes( aText );
904  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
905 }
906 
907 
908 void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
909 {
910  wxString shownText( aText->GetShownText() );
911  if( shownText.Length() == 0 )
912  return;
913 
914  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
915  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
916 
917  if( m_pcbSettings.m_sketchMode[aLayer] )
918  {
919  // Outline mode
921  }
922  else
923  {
924  // Filled mode
926  }
927 
928  m_gal->SetStrokeColor( color );
929  m_gal->SetIsFill( false );
930  m_gal->SetIsStroke( true );
931  m_gal->SetTextAttributes( aText );
932  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
933 
934  // Draw the umbilical line
935  if( aText->IsSelected() && aText->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
936  {
938  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
939  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
940  }
941 }
942 
943 
944 void PCB_PAINTER::draw( const MODULE* aModule, int aLayer )
945 {
946  if( aLayer == ITEM_GAL_LAYER( ANCHOR_VISIBLE ) )
947  {
948  const COLOR4D color = m_pcbSettings.GetColor( aModule, ITEM_GAL_LAYER( ANCHOR_VISIBLE ) );
949 
950  // Draw anchor
951  m_gal->SetStrokeColor( color );
953 
954  // Keep the size constant, not related to the scale
955  double anchorSize = 5.0 / m_gal->GetWorldScale();
956 
957  VECTOR2D center = aModule->GetPosition();
958  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
959  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
960  }
961 }
962 
963 
964 void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
965 {
966  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aZone->GetLayer() );
967  std::deque<VECTOR2D> corners;
969 
970  // Draw the outline
971  m_gal->SetStrokeColor( color );
972  m_gal->SetIsFill( false );
973  m_gal->SetIsStroke( true );
975 
976  for( auto iterator = aZone->CIterateWithHoles(); iterator; iterator++ )
977  {
978  corners.push_back( VECTOR2D( *iterator ) );
979 
980  if( iterator.IsEndContour() )
981  {
982  // The last point for closing the polyline
983  corners.push_back( corners[0] );
984  m_gal->DrawPolyline( corners );
985  corners.clear();
986  }
987 
988  for( const SEG& hatchLine : aZone->GetHatchLines() )
989  m_gal->DrawLine( hatchLine.A, hatchLine.B );
990  }
991 
992  // Draw the filling
993  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
994  {
995  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
996 
997  if( polySet.OutlineCount() == 0 ) // Nothing to draw
998  return;
999 
1000  // Set up drawing options
1001  m_gal->SetFillColor( color );
1002  m_gal->SetLineWidth( aZone->GetMinThickness() );
1003 
1004  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1005  {
1006  m_gal->SetIsFill( true );
1007  m_gal->SetIsStroke( true );
1008  }
1009  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1010  {
1011  m_gal->SetIsFill( false );
1012  m_gal->SetIsStroke( true );
1013  }
1014 
1015  for( int i = 0; i < polySet.OutlineCount(); i++ )
1016  {
1017  const SHAPE_LINE_CHAIN& outline = polySet.COutline( i );
1018  // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion
1019  // is just a performance hog)
1020 
1021  for( int j = 0; j < outline.PointCount(); j++ )
1022  corners.push_back ( (VECTOR2D) outline.CPoint( j ) );
1023 
1024  corners.push_back( (VECTOR2D) outline.CPoint( 0 ) );
1025 
1026  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1027  {
1028  m_gal->DrawPolygon( corners );
1029  m_gal->DrawPolyline( corners );
1030  }
1031  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1032  {
1033  m_gal->DrawPolyline( corners );
1034  }
1035 
1036  corners.clear();
1037  }
1038  }
1039 }
1040 
1041 
1042 void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
1043 {
1044  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1045 
1046  m_gal->SetStrokeColor( strokeColor );
1047  m_gal->SetIsFill( false );
1048  m_gal->SetIsStroke( true );
1049  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1050 
1051  // Draw an arrow
1052  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1053  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1054  VECTOR2D( aDimension->m_featureLineGF ) );
1055  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1056  VECTOR2D( aDimension->m_featureLineDF ) );
1057  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1058  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1059  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1060  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1061 
1062  // Draw text
1063  TEXTE_PCB& text = aDimension->Text();
1064  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1065 
1066  m_gal->SetLineWidth( text.GetThickness() );
1067  m_gal->SetTextAttributes( &text );
1068  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1069 }
1070 
1071 
1072 void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
1073 {
1074  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1075  VECTOR2D position( aTarget->GetPosition() );
1076  double size, radius;
1077 
1078  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1079  m_gal->SetStrokeColor( strokeColor );
1080  m_gal->SetIsFill( false );
1081  m_gal->SetIsStroke( true );
1082 
1083  m_gal->Save();
1084  m_gal->Translate( position );
1085 
1086  if( aTarget->GetShape() )
1087  {
1088  // shape x
1089  m_gal->Rotate( M_PI / 4.0 );
1090  size = 2.0 * aTarget->GetSize() / 3.0;
1091  radius = aTarget->GetSize() / 2.0;
1092  }
1093  else
1094  {
1095  // shape +
1096  size = aTarget->GetSize() / 2.0;
1097  radius = aTarget->GetSize() / 3.0;
1098  }
1099 
1100  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1101  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1102  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1103 
1104  m_gal->Restore();
1105 }
1106 
1107 
1108 void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
1109 {
1110  // If you are changing this, update MARKER_PCB::ViewBBox()
1111  const int scale = 100000;
1112 
1113  const VECTOR2D arrow[] = {
1114  VECTOR2D( 0 * scale, 0 * scale ),
1115  VECTOR2D( 8 * scale, 1 * scale ),
1116  VECTOR2D( 4 * scale, 3 * scale ),
1117  VECTOR2D( 13 * scale, 8 * scale ),
1118  VECTOR2D( 9 * scale, 9 * scale ),
1119  VECTOR2D( 8 * scale, 13 * scale ),
1120  VECTOR2D( 3 * scale, 4 * scale ),
1121  VECTOR2D( 1 * scale, 8 * scale )
1122  };
1123 
1124  m_gal->Save();
1125  m_gal->Translate( aMarker->GetPosition() );
1126 
1127  if( aMarker->IsSelected() )
1128  {
1129  m_gal->SetFillColor( COLOR4D( 1.0, 0.5, 0.5, 1.0 ) );
1130  }
1131  else
1132  {
1133  m_gal->SetFillColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) );
1134  }
1135 
1136  m_gal->SetIsFill( true );
1137  m_gal->SetIsStroke( false );
1138  m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
1139  m_gal->Restore();
1140 }
1141 
1142 
1143 const double PCB_RENDER_SETTINGS::MAX_FONT_SIZE = Millimeter2iu( 10.0 );
multilayer pads, usually with holes
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu LAYER_IDs.
Definition: lset.cpp:638
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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:247
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
const wxPoint & GetBezControl2() const
PCB_TARGET class definition.
bool m_sketchMode[TOTAL_LAYER_COUNT]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:131
TEXTE_PCB class definition.
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:56
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
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
double GetWorldScale() const
Get the world scale.
wxPoint m_arrowD1F
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()
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.
const wxPoint & GetPosition() const override
Definition: class_module.h:143
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:351
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:221
virtual const wxPoint & GetPosition() const =0
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:140
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
bool m_sketchBoardGfx
Flag determining if board graphic items should be outlined or stroked
Definition: pcb_painter.h:134
bool m_DisplayModEdgeFill
Definition: pcbstruct.h:69
Classes to handle copper zones.
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:250
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:152
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:221
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:184
int OutlineCount() const
Returns the number of outlines in the set
const wxSize & GetDrillSize() const
Definition: class_pad.h:188
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:496
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...
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:166
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: pcb_painter.cpp:66
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
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:143
const wxPoint & GetEnd() const
Definition: class_track.h:117
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:703
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:329
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:231
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.
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:277
double a
Alpha component.
Definition: color4d.h:284
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.
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
VIATYPE_T GetViaType() const
Definition: class_track.h:442
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:149
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool m_hiContrastEnabled
Parameters for display modes.
Definition: painter.h:246
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:486
const wxPoint & GetStart() const
Definition: class_track.h:120
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
COLOR4D m_layerColors[TOTAL_LAYER_COUNT]
Colors for all layers (normal)
Definition: painter.h:234
Arcs (with rounded ends)
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:216
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:182
bool m_DisplayDrawItemsFill
Definition: pcbstruct.h:84
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
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:587
Class LSEQ is a sequence (and therefore also a set) of LAYER_IDs.
bool m_sketchFpGfx
Flag determining if footprint graphic items should be outlined or stroked
Definition: pcb_painter.h:137
Pad object description.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:113
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
void LayerPair(LAYER_ID *top_layer, LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:146
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:261
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
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:155
Class to handle a graphic segment.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
Class SHAPE_LINE_CHAIN.
int GetWidth() const
Definition: class_track.h:114
bool m_DisplayPadNum
Definition: pcbstruct.h:67
TEXTE_PCB & Text()
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:214
double DECIDEG2RAD(double deg)
Definition: trigo.h:195
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:519
#define TOTAL_LAYER_COUNT
number of all GAL layers including PCB and item layers
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
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:455
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:367
PCB_PAINTER(GAL *aGal)
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Eeschema, Pcbnew and GerbView...
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
int GetSize() const
Definition: class_mire.h:69
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
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
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:251
wxString GetPadName() const
Definition: class_pad.cpp:382
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.
void StringPadName(wxString &text) const
Definition: class_pad.cpp:391
COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT]
Colors for all layers (darkened)
Definition: painter.h:243
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.
COLOR4D m_layerColorsSel[TOTAL_LAYER_COUNT]
Colors for all layers (selected)
Definition: painter.h:240
Class DIMENSION.
const wxPoint & GetOffset() const
Definition: class_pad.h:191
COLOR4D m_layerColorsHi[TOTAL_LAYER_COUNT]
Colors for all layers (highlighted)
Definition: painter.h:237
#define NETNAMES_GAL_LAYER(layer)
const wxPoint & GetPosition() const override
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