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