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