KiCad PCB EDA Suite
KIGFX::PCB_PAINTER Class Reference

PCB_PAINTER Contains methods for drawing PCB-specific items. More...

#include <pcb_painter.h>

Inheritance diagram for KIGFX::PCB_PAINTER:
KIGFX::PAINTER KIGFX::PCB_PRINT_PAINTER

Public Member Functions

 PCB_PAINTER (GAL *aGal)
 
virtual void ApplySettings (const RENDER_SETTINGS *aSettings) override
 Function ApplySettings Loads colors and display modes settings that are going to be used when drawing items. More...
 
virtual PCB_RENDER_SETTINGSGetSettings () override
 
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 item. More...
 
void SetGAL (GAL *aGal)
 Function SetGAL Changes Graphics Abstraction Layer used for drawing items for a new one. More...
 

Protected Member Functions

void draw (const TRACK *aTrack, int aLayer)
 
void draw (const ARC *aArc, int aLayer)
 
void draw (const VIA *aVia, int aLayer)
 
void draw (const D_PAD *aPad, int aLayer)
 
void draw (const DRAWSEGMENT *aSegment, int aLayer)
 
void draw (const TEXTE_PCB *aText, int aLayer)
 
void draw (const TEXTE_MODULE *aText, int aLayer)
 
void draw (const MODULE *aModule, int aLayer)
 
void draw (const PCB_GROUP *aGroup, int aLayer)
 
void draw (const ZONE_CONTAINER *aZone, int aLayer)
 
void draw (const DIMENSION *aDimension, int aLayer)
 
void draw (const PCB_TARGET *aTarget)
 
void draw (const MARKER_PCB *aMarker)
 
int getLineThickness (int aActualThickness) const
 Function getLineThickness() Get the thickness to draw for a line (e.g. More...
 
virtual int getDrillShape (const D_PAD *aPad) const
 Return drill shape of a pad. More...
 
virtual VECTOR2D getDrillSize (const D_PAD *aPad) const
 Return drill size for a pad (internal units). More...
 
virtual int getDrillSize (const VIA *aVia) const
 Return drill diameter for a via (internal units). More...
 

Protected Attributes

PCB_RENDER_SETTINGS m_pcbSettings
 
GALm_gal
 Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg. More...
 
COLOR4D m_brightenedColor
 Color of brightened item frame. More...
 

Detailed Description

PCB_PAINTER Contains methods for drawing PCB-specific items.

Definition at line 260 of file pcb_painter.h.

Constructor & Destructor Documentation

◆ PCB_PAINTER()

PCB_PAINTER::PCB_PAINTER ( GAL aGal)

Definition at line 355 of file pcb_painter.cpp.

355  :
356  PAINTER( aGal )
357 {
358 }
PAINTER(GAL *aGal)
Constructor PAINTER( GAL* ) initializes this object for painting on any of the polymorphic GRAPHICS_A...
Definition: painter.cpp:32

Member Function Documentation

◆ ApplySettings()

virtual void KIGFX::PCB_PAINTER::ApplySettings ( const RENDER_SETTINGS aSettings)
inlineoverridevirtual

Function ApplySettings Loads colors and display modes settings that are going to be used when drawing items.

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 266 of file pcb_painter.h.

267  {
268  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
269  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281

References m_pcbSettings.

◆ Draw()

bool PCB_PAINTER::Draw ( const VIEW_ITEM aItem,
int  aLayer 
)
overridevirtual

Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the item.

Parameters
aItemis an item to be drawn.
aLayertells which layer is currently rendered so that draw functions may know what to draw (eg. for pads there are separate layers for holes, because they have other dimensions then the pad itself.

Implements KIGFX::PAINTER.

Definition at line 391 of file pcb_painter.cpp.

392 {
393  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
394 
395  if( !item )
396  return false;
397 
398  // the "cast" applied in here clarifies which overloaded draw() is called
399  switch( item->Type() )
400  {
401  case PCB_TRACE_T:
402  draw( static_cast<const TRACK*>( item ), aLayer );
403  break;
404 
405  case PCB_ARC_T:
406  draw( static_cast<const ARC*>( item ), aLayer );
407  break;
408 
409  case PCB_VIA_T:
410  draw( static_cast<const VIA*>( item ), aLayer );
411  break;
412 
413  case PCB_PAD_T:
414  draw( static_cast<const D_PAD*>( item ), aLayer );
415  break;
416 
417  case PCB_LINE_T:
418  case PCB_MODULE_EDGE_T:
419  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
420  break;
421 
422  case PCB_TEXT_T:
423  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
424  break;
425 
426  case PCB_MODULE_TEXT_T:
427  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
428  break;
429 
430  case PCB_MODULE_T:
431  draw( static_cast<const MODULE*>( item ), aLayer );
432  break;
433 
434  case PCB_GROUP_T:
435  draw( static_cast<const PCB_GROUP*>( item ), aLayer );
436  break;
437 
438  case PCB_ZONE_AREA_T:
439  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
440  break;
441 
443  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
444  break;
445 
446  case PCB_DIM_ALIGNED_T:
447  case PCB_DIM_CENTER_T:
449  case PCB_DIM_LEADER_T:
450  draw( static_cast<const DIMENSION*>( item ), aLayer );
451  break;
452 
453  case PCB_TARGET_T:
454  draw( static_cast<const PCB_TARGET*>( item ) );
455  break;
456 
457  case PCB_MARKER_T:
458  draw( static_cast<const MARKER_PCB*>( item ) );
459  break;
460 
461  default:
462  // Painter does not know how to draw the object
463  return false;
464  }
465 
466  return true;
467 }
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:109
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:103
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:106
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
class MODULE, a footprint
Definition: typeinfo.h:89
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:105
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
Definition: typeinfo.h:104
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void draw(const TRACK *aTrack, int aLayer)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References draw(), PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_GROUP_T, PCB_LINE_T, PCB_MARKER_T, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_MODULE_ZONE_AREA_T, PCB_PAD_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, and EDA_ITEM::Type().

◆ draw() [1/13]

void PCB_PAINTER::draw ( const TRACK aTrack,
int  aLayer 
)
protected

Definition at line 470 of file pcb_painter.cpp.

471 {
472  VECTOR2D start( aTrack->GetStart() );
473  VECTOR2D end( aTrack->GetEnd() );
474  int width = aTrack->GetWidth();
475 
477  {
478  // If there is a net name - display it on the track
479  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
480  {
481  VECTOR2D line = ( end - start );
482  double length = line.EuclideanNorm();
483 
484  // Check if the track is long enough to have a netname displayed
485  if( length < 10 * width )
486  return;
487 
488  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
489  VECTOR2D textPosition = start + line / 2.0; // center of the track
490 
491  double textOrientation;
492 
493  if( end.y == start.y ) // horizontal
494  textOrientation = 0;
495  else if( end.x == start.x ) // vertical
496  textOrientation = M_PI / 2;
497  else
498  textOrientation = -atan( line.y / line.x );
499 
500  double textSize = width;
501 
502  m_gal->SetIsStroke( true );
503  m_gal->SetIsFill( false );
505  m_gal->SetLineWidth( width / 10.0 );
506  m_gal->SetFontBold( false );
507  m_gal->SetFontItalic( false );
508  m_gal->SetTextMirrored( false );
509  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
512  m_gal->BitmapText( netName, textPosition, textOrientation );
513  }
514  }
515  else if( IsCopperLayer( aLayer ) )
516  {
517  // Draw a regular track
518  COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
519  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
522  m_gal->SetIsStroke( outline_mode );
523  m_gal->SetIsFill( not outline_mode );
525 
526  m_gal->DrawSegment( start, end, width );
527 
528  // Clearance lines
529  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
530 
531  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
532  {
534  m_gal->SetIsFill( false );
535  m_gal->SetIsStroke( true );
537  m_gal->DrawSegment( start, end,
538  width + aTrack->GetClearance( ToLAYER_ID( aLayer ) ) * 2 );
539  }
540  }
541 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int GetNetCode() const
Function GetNetCode.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
const wxPoint & GetStart() const
Definition: class_track.h:116
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:191
int color
Definition: DXF_plotter.cpp:61
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetFontBold(const bool aBold)
Set bold property of current font.
virtual int GetClearance(PCB_LAYER_ID aLayer, BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
wxString GetShortNetname() const
Function GetShortNetname.
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:206
int GetWidth() const
Definition: class_track.h:110
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:229
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
const wxPoint & GetEnd() const
Definition: class_track.h:113
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:299
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:478
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:856
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::GAL::BitmapText(), KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_TRACKS, color, KIGFX::GAL::DrawSegment(), VECTOR2< T >::EuclideanNorm(), BOARD_CONNECTED_ITEM::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), TRACK::GetEnd(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_CONNECTED_ITEM::GetShortNetname(), TRACK::GetStart(), TRACK::GetWidth(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, IsCopperLayer(), IsNetnameLayer(), LAYER_TRACKS, KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnTracks, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, NULL, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), ToLAYER_ID(), NETINFO_LIST::UNCONNECTED, UnescapeString(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Draw().

◆ draw() [2/13]

void PCB_PAINTER::draw ( const ARC aArc,
int  aLayer 
)
protected

Definition at line 544 of file pcb_painter.cpp.

545 {
546  VECTOR2D center( aArc->GetCenter() );
547  int width = aArc->GetWidth();
548 
549  if( IsCopperLayer( aLayer ) )
550  {
551  // Draw a regular track
552  COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
553  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
556  m_gal->SetIsStroke( outline_mode );
557  m_gal->SetIsFill( not outline_mode );
559 
560  auto radius = aArc->GetRadius();
561  auto start_angle = DECIDEG2RAD( aArc->GetArcAngleStart() );
562  auto angle = DECIDEG2RAD( aArc->GetAngle() );
563 
564  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width );
565 
566  // Clearance lines
567  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
568 
569  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
570  {
572  m_gal->SetIsFill( false );
573  m_gal->SetIsStroke( true );
575 
576  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
577  width + aArc->GetClearance( ToLAYER_ID( aLayer ) ) * 2 );
578  }
579  }
580 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
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:191
int color
Definition: DXF_plotter.cpp:61
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual int GetClearance(PCB_LAYER_ID aLayer, BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual wxPoint GetCenter() const
Function GetCenter()
double GetRadius() const
double GetAngle() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetWidth() const
Definition: class_track.h:110
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:229
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
double DECIDEG2RAD(double deg)
Definition: trigo.h:223
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
double GetArcAngleStart() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:856
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References PNS::angle(), KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_TRACKS, color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), ARC::GetAngle(), ARC::GetArcAngleStart(), BOARD_ITEM::GetCenter(), BOARD_CONNECTED_ITEM::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), ARC::GetRadius(), TRACK::GetWidth(), IsCopperLayer(), LAYER_TRACKS, KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and ToLAYER_ID().

◆ draw() [3/13]

void PCB_PAINTER::draw ( const VIA aVia,
int  aLayer 
)
protected

Vias not connected to copper are optionally not drawn We draw instead the hole size to ensure we show the proper clearance

Definition at line 583 of file pcb_painter.cpp.

584 {
585  VECTOR2D center( aVia->GetStart() );
586  double radius = 0.0;
587 
588  // Draw description layer
589  if( IsNetnameLayer( aLayer ) )
590  {
591  VECTOR2D position( center );
592 
593  // Is anything that we can display enabled?
595  {
596  bool displayNetname = ( !aVia->GetNetname().empty() );
597  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
598  double size = aVia->GetWidth();
599 
600  // Font size limits
601  if( size > maxSize )
602  size = maxSize;
603 
604  m_gal->Save();
605  m_gal->Translate( position );
606 
607  // Default font settings
610 
611  // Set the text position to the pad shape position (the pad position is not the best place)
612  VECTOR2D textpos( 0.0, 0.0 );
613 
614  if( displayNetname )
615  {
616  wxString netname = UnescapeString( aVia->GetShortNetname() );
617  // calculate the size of net name text:
618  double tsize = 1.5 * size / netname.Length();
619  tsize = std::min( tsize, size );
620  // Use a smaller text size to handle interline, pen size..
621  tsize *= 0.7;
622  VECTOR2D namesize( tsize, tsize );
623 
624  m_gal->SetGlyphSize( namesize );
625  m_gal->SetLineWidth( namesize.x / 12.0 );
626  m_gal->BitmapText( netname, textpos, 0.0 );
627  }
628 
629 
630  m_gal->Restore();
631  }
632  return;
633  }
634 
635  // Choose drawing settings depending on if we are drawing via's pad or hole
636  if( aLayer == LAYER_VIAS_HOLES )
637  radius = getDrillSize( aVia ) / 2.0;
638  else
639  radius = aVia->GetWidth() / 2.0;
640 
643  if( IsCopperLayer( aLayer ) && !aVia->IsPadOnLayer( aLayer ) )
644  radius = getDrillSize(aVia) / 2.0 ;
645 
646  bool sketchMode = false;
647  COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
648 
649  switch( aVia->GetViaType() )
650  {
651  case VIATYPE::THROUGH:
653  break;
654 
657  break;
658 
659  case VIATYPE::MICROVIA:
661  break;
662 
663  default:
664  wxASSERT( false );
665  break;
666  }
667 
668  m_gal->SetIsFill( !sketchMode );
669  m_gal->SetIsStroke( sketchMode );
670 
671  if( sketchMode )
672  {
673  // Outline mode
676  }
677  else
678  {
679  // Filled mode
681  }
682 
683  if( ( aVia->GetViaType() == VIATYPE::BLIND_BURIED || aVia->GetViaType() == VIATYPE::MICROVIA )
684  && aLayer != LAYER_VIAS_HOLES
686  {
687  // Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
688  // top and bottom layers
689  PCB_LAYER_ID layerTop, layerBottom;
690  aVia->LayerPair( &layerTop, &layerBottom );
691 
692  if( !sketchMode )
693  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
694 
695  if( aLayer == layerTop )
696  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
697 
698  else if( aLayer == layerBottom )
699  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
700 
701  else if( aLayer == LAYER_VIA_BBLIND || aLayer == LAYER_VIA_MICROVIA )
702  {
703  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
704  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
705  }
706  }
707  else
708  {
709  // Draw the outer circles of normal vias and the holes for all vias
710  m_gal->DrawCircle( center, radius );
711  }
712 
713  // Clearance lines
714  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
715 
716  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
717  && aLayer != LAYER_VIAS_HOLES )
718  {
720  m_gal->SetIsFill( false );
721  m_gal->SetIsStroke( true );
723  m_gal->DrawCircle( center, radius + aVia->GetClearance( aVia->GetLayer() ) );
724  }
725 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
to draw blind/buried vias
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
const wxPoint & GetStart() const
Definition: class_track.h:116
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
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:191
int color
Definition: DXF_plotter.cpp:61
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
to draw via holes (pad holes do not use this layer)
wxString GetNetname() const
Function GetNetname.
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual int GetClearance(PCB_LAYER_ID aLayer, BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
PCB_LAYER_ID
A quick note on layer IDs:
bool GetDrawIndividualViaLayers() const
Definition: pcb_painter.h:171
void ResetTextAttributes()
Reset text attributes to default styling.
wxString GetShortNetname() const
Function GetShortNetname.
#define NULL
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:223
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
to draw usual through hole vias
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
int GetWidth() const
Definition: class_track.h:110
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:229
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
VIATYPE GetViaType() const
Definition: class_track.h:381
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsPadOnLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:209
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::GAL::BitmapText(), BLIND_BURIED, KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_VIAS, color, KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), BOARD_CONNECTED_ITEM::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetDrawIndividualViaLayers(), getDrillSize(), VIA::GetDrillValue(), BOARD_ITEM::GetLayer(), BOARD_CONNECTED_ITEM::GetNetname(), BOARD_CONNECTED_ITEM::GetShortNetname(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), IsCopperLayer(), IsNetnameLayer(), VIA::IsPadOnLayer(), LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, VIA::LayerPair(), KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnVias, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::PCB_RENDER_SETTINGS::MAX_FONT_SIZE, MICROVIA, NULL, KIGFX::GAL::ResetTextAttributes(), KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), THROUGH, KIGFX::GAL::Translate(), UnescapeString(), and VECTOR2< T >::x.

◆ draw() [4/13]

void PCB_PAINTER::draw ( const D_PAD aPad,
int  aLayer 
)
protected

Definition at line 728 of file pcb_painter.cpp.

729 {
730  // Draw description layer
731  if( IsNetnameLayer( aLayer ) )
732  {
733  // Is anything that we can display enabled?
735  {
736  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
737  EDA_RECT padBBox = aPad->GetBoundingBox();
738  VECTOR2D position = padBBox.Centre();
739  VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
740 
741  if( aPad->GetShape() != PAD_SHAPE_CUSTOM )
742  {
743  // Don't allow a 45ยบ rotation to bloat a pad's bounding box unnecessarily
744  double limit = std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1;
745 
746  if( padsize.x > limit && padsize.y > limit )
747  {
748  padsize.x = limit;
749  padsize.y = limit;
750  }
751  }
752 
753  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
754  double size = padsize.y;
755 
756  m_gal->Save();
757  m_gal->Translate( position );
758 
759  // Keep the size ratio for the font, but make it smaller
760  if( padsize.x < padsize.y )
761  {
762  m_gal->Rotate( DECIDEG2RAD( -900.0 ) );
763  size = padsize.x;
764  std::swap( padsize.x, padsize.y );
765  }
766 
767  // Font size limits
768  if( size > maxSize )
769  size = maxSize;
770 
771  // Default font settings
774  m_gal->SetFontBold( false );
775  m_gal->SetFontItalic( false );
776  m_gal->SetTextMirrored( false );
778  m_gal->SetIsStroke( true );
779  m_gal->SetIsFill( false );
780 
781  // We have already translated the GAL to be centered at the center of the pad's
782  // bounding box
783  VECTOR2D textpos( 0.0, 0.0 );
784 
785  // Divide the space, to display both pad numbers and netnames and set the Y text
786  // position to display 2 lines
787  if( displayNetname && m_pcbSettings.m_padNumbers )
788  {
789  size = size / 2.0;
790  textpos.y = size / 2.0;
791  }
792 
793  if( displayNetname )
794  {
795  wxString netname = UnescapeString( aPad->GetShortNetname() );
796  // calculate the size of net name text:
797  double tsize = 1.5 * padsize.x / netname.Length();
798  tsize = std::min( tsize, size );
799  // Use a smaller text size to handle interline, pen size..
800  tsize *= 0.7;
801  VECTOR2D namesize( tsize, tsize );
802 
803  m_gal->SetGlyphSize( namesize );
804  m_gal->SetLineWidth( namesize.x / 12.0 );
805  m_gal->BitmapText( netname, textpos, 0.0 );
806  }
807 
809  {
810  const wxString& padName = aPad->GetName();
811  textpos.y = -textpos.y;
812  double tsize = 1.5 * padsize.x / padName.Length();
813  tsize = std::min( tsize, size );
814  // Use a smaller text size to handle interline, pen size..
815  tsize *= 0.7;
816  tsize = std::min( tsize, size );
817  VECTOR2D numsize( tsize, tsize );
818 
819  m_gal->SetGlyphSize( numsize );
820  m_gal->SetLineWidth( numsize.x / 12.0 );
821  m_gal->BitmapText( padName, textpos, 0.0 );
822  }
823 
824  m_gal->Restore();
825  }
826  return;
827  }
828 
829  // Pad drawing
830  COLOR4D color;
831 
832  // Pad hole color is pad-type-specific: the background color for plated holes and the
833  // pad color for NPTHs. Note the extra check for "should be" NPTHs to keep mis-marked
834  // holes with no annular ring from getting "lost" in the background.
835  if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() )
837  else
838  color = m_pcbSettings.GetColor( aPad, aLayer );
839 
841  {
842  // Outline mode
843  m_gal->SetIsFill( false );
844  m_gal->SetIsStroke( true );
847  }
848  else
849  {
850  // Filled mode
851  m_gal->SetIsFill( true );
852  m_gal->SetIsStroke( false );
854  }
855 
856  // Choose drawing settings depending on if we are drawing a pad itself or a hole
857  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
858  {
859  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
860 
861  if( seg->GetSeg().A == seg->GetSeg().B ) // Circular hole
862  m_gal->DrawCircle( seg->GetSeg().A, seg->GetWidth()/2 );
863  else
864  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() );
865  }
866  else
867  {
868  wxSize pad_size = aPad->GetSize();
869  wxSize margin;
870 
871  switch( aLayer )
872  {
873  case F_Mask:
874  case B_Mask:
875  margin.x = margin.y = aPad->GetSolderMaskMargin();
876  break;
877 
878  case F_Paste:
879  case B_Paste:
880  margin = aPad->GetSolderPasteMargin();
881  break;
882 
883  default:
884  margin.x = margin.y = 0;
885  break;
886  }
887 
888  if( margin.x != margin.y )
889  {
890  const_cast<D_PAD*>( aPad )->SetSize( pad_size + margin + margin );
891  margin.x = margin.y = 0;
892  }
893 
894  const std::shared_ptr<SHAPE_COMPOUND> shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
895 
896  if( shapes && shapes->Size() == 1 && shapes->Shapes()[0]->Type() == SH_SEGMENT )
897  {
898  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shapes->Shapes()[0];
899  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() + 2 * margin.x );
900  }
901  else if( shapes && shapes->Size() == 1 && shapes->Shapes()[0]->Type() == SH_CIRCLE )
902  {
903  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shapes->Shapes()[0];
904  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + margin.x );
905  }
906  else
907  {
908  SHAPE_POLY_SET polySet;
909  aPad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x );
910  m_gal->DrawPolygon( polySet );
911  }
912 
913  if( aPad->GetSize() != pad_size )
914  const_cast<D_PAD*>( aPad )->SetSize( pad_size );
915  }
916 
917  // Clearance outlines
918  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
919 
920  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
921  && ( aLayer == LAYER_PAD_FR
922  || aLayer == LAYER_PAD_BK
923  || aLayer == LAYER_PADS_TH ) )
924  {
926  m_gal->SetIsStroke( true );
927  m_gal->SetIsFill( false );
929  int clearance = aPad->GetClearance( aPad->GetLayer() );
930 
931  const std::shared_ptr<SHAPE_COMPOUND> shapes =
932  std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
933 
934  if( shapes && shapes->Size() == 1 && shapes->Shapes()[0]->Type() == SH_SEGMENT )
935  {
936  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shapes->Shapes()[0];
937  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() + 2 * clearance );
938  }
939  else if( shapes && shapes->Size() == 1 && shapes->Shapes()[0]->Type() == SH_CIRCLE )
940  {
941  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shapes->Shapes()[0];
942  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
943  }
944  else
945  {
946  SHAPE_POLY_SET polySet;
947  aPad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ), clearance );
948  m_gal->DrawPolygon( polySet );
949  }
950  }
951 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int GetRadius() const
Definition: shape_circle.h:94
multilayer pads, usually with holes
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a SHAPE object representing the pad's hole.
Definition: class_pad.cpp:273
handle color for not plated holes (holes, not pads)
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:191
int color
Definition: DXF_plotter.cpp:61
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:200
wxString GetNetname() const
Function GetNetname.
const VECTOR2I GetCenter() const
Definition: shape_circle.h:99
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:203
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
const SEG & GetSeg() const
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
void SetFontBold(const bool aBold)
Set bold property of current font.
virtual int GetClearance(PCB_LAYER_ID aLayer, BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:635
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
wxString GetShortNetname() const
Function GetShortNetname.
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:223
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
const wxString & GetName() const
Definition: class_pad.h:132
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Function GetEffectiveShape Some pad shapes can be complex (rounded/chamfered rectangle),...
Definition: class_pad.cpp:264
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
line chain (polyline)
Definition: shape.h:45
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
smd pads, front layer
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:229
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:680
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: pcb_painter.h:147
VECTOR2I A
Definition: seg.h:47
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
double DECIDEG2RAD(double deg)
Definition: trigo.h:223
wxPoint Centre() const
Definition: eda_rect.h:62
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
const wxSize & GetSize() const
Definition: class_pad.h:224
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetWidth() const
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:1091
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:856
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox The bounding box is cached, so this will be efficient most of the time.
Definition: class_pad.cpp:458
const wxSize GetSize() const
Definition: eda_rect.h:103
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
axis-aligned rectangle
Definition: shape.h:43
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, B_Mask, B_Paste, KIGFX::GAL::BitmapText(), EDA_RECT::Centre(), KIGFX::PCB_RENDER_SETTINGS::CL_PADS, color, DECIDEG2RAD(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawSegment(), F_Mask, F_Paste, KIGFX::PCB_RENDER_SETTINGS::GetBackgroundColor(), D_PAD::GetBoundingBox(), SHAPE_CIRCLE::GetCenter(), BOARD_CONNECTED_ITEM::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), D_PAD::GetEffectiveHoleShape(), D_PAD::GetEffectiveShape(), BOARD_ITEM::GetLayer(), D_PAD::GetName(), BOARD_CONNECTED_ITEM::GetNetname(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), D_PAD::GetShape(), BOARD_CONNECTED_ITEM::GetShortNetname(), EDA_RECT::GetSize(), D_PAD::GetSize(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), SHAPE_SEGMENT::GetWidth(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, IsNetnameLayer(), LAYER_NON_PLATEDHOLES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH, KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnPads, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_RENDER_SETTINGS::m_padNumbers, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::PCB_RENDER_SETTINGS::MAX_FONT_SIZE, NULL, PAD_SHAPE_CUSTOM, D_PAD::PadShouldBeNPTH(), KIGFX::GAL::Restore(), KIGFX::GAL::Rotate(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), SH_CIRCLE, SH_SEGMENT, ToLAYER_ID(), D_PAD::TransformShapeWithClearanceToPolygon(), KIGFX::GAL::Translate(), UnescapeString(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [5/13]

void PCB_PAINTER::draw ( const DRAWSEGMENT aSegment,
int  aLayer 
)
protected

Definition at line 954 of file pcb_painter.cpp.

955 {
956  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
957  bool sketch = m_pcbSettings.m_sketchGraphics;
958  int thickness = getLineThickness( aSegment->GetWidth() );
959  VECTOR2D start( aSegment->GetStart() );
960  VECTOR2D end( aSegment->GetEnd() );
961 
962  m_gal->SetIsFill( !sketch );
963  m_gal->SetIsStroke( sketch );
967 
968  switch( aSegment->GetShape() )
969  {
970  case S_SEGMENT:
971  m_gal->DrawSegment( start, end, thickness );
972  break;
973 
974  case S_RECT:
975  {
976  std::vector<wxPoint> pts = aSegment->GetRectCorners();
977 
978  if( aSegment->GetWidth() > 0 )
979  {
980  m_gal->DrawSegment( pts[0], pts[1], thickness );
981  m_gal->DrawSegment( pts[1], pts[2], thickness );
982  m_gal->DrawSegment( pts[2], pts[3], thickness );
983  m_gal->DrawSegment( pts[3], pts[0], thickness );
984  }
985  else
986  {
987  SHAPE_POLY_SET poly;
988  poly.NewOutline();
989 
990  for( const wxPoint& pt : pts )
991  poly.Append( pt );
992 
993  m_gal->DrawPolygon( poly );
994  }
995  }
996  break;
997 
998  case S_ARC:
999  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
1000  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
1001  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ), // Change this
1002  thickness );
1003  break;
1004 
1005  case S_CIRCLE:
1006  if( sketch )
1007  {
1008  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
1009  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
1010  }
1011  else
1012  {
1013  m_gal->SetLineWidth( thickness );
1014  m_gal->SetIsFill( aSegment->GetWidth() == 0 );
1015  m_gal->SetIsStroke( aSegment->GetWidth() > 0 );
1016  m_gal->DrawCircle( start, aSegment->GetRadius() );
1017  }
1018  break;
1019 
1020  case S_POLYGON:
1021  {
1022  SHAPE_POLY_SET& shape = const_cast<DRAWSEGMENT*>( aSegment )->GetPolyShape();
1023 
1024  if( shape.OutlineCount() == 0 )
1025  break;
1026 
1027  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
1028  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
1029  // on Opengl.
1030  // GLU tesselation is much slower, so currently we are using our tesselation.
1031  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
1032  {
1033  shape.CacheTriangulation();
1034  }
1035 
1036  m_gal->Save();
1037 
1038  if( MODULE* module = aSegment->GetParentModule() )
1039  {
1040  m_gal->Translate( module->GetPosition() );
1041  m_gal->Rotate( -module->GetOrientationRadians() );
1042  }
1043 
1044  m_gal->SetLineWidth( thickness );
1045 
1046  if( sketch )
1047  m_gal->SetIsFill( false );
1048  else
1049  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
1050 
1051  m_gal->SetIsStroke( true );
1052  m_gal->DrawPolygon( shape );
1053 
1054  m_gal->Restore();
1055  break;
1056  }
1057 
1058  case S_CURVE:
1059  m_gal->SetIsFill( false );
1060  m_gal->SetIsStroke( true );
1061  m_gal->SetLineWidth( thickness );
1062  // Use thickness as filter value to convert the curve to polyline
1063  // when the curve is not supported
1064  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
1065  VECTOR2D( aSegment->GetBezControl1() ),
1066  VECTOR2D( aSegment->GetBezControl2() ),
1067  VECTOR2D( aSegment->GetEnd() ), thickness );
1068  break;
1069 
1070  case S_LAST:
1071  break;
1072  }
1073 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
int OutlineCount() const
Returns the number of outlines in the set
STROKE_T GetShape() const
int color
Definition: DXF_plotter.cpp:61
polygon (not yet used for tracks, but could be in microwave apps)
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
double GetArcAngleStart() const
function GetArcAngleStart()
usual segment : line with rounded ends
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
bool IsTriangulationUpToDate() const
bool m_sketchGraphics
Flag determining if graphic items should be outlined or stroked
Definition: pcb_painter.h:194
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
segment with non rounded ends
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
std::vector< wxPoint > GetRectCorners() const
SHAPE_POLY_SET.
Arcs (with rounded ends)
last value for this list
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Bezier Curve.
int NewOutline()
Creates a new empty polygon in the set and returns its index
int GetWidth() const
double GetAngle() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
double DECIDEG2RAD(double deg)
Definition: trigo.h:223
const wxPoint & GetBezControl2() const
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
void CacheTriangulation(bool aPartition=true)
const wxPoint & GetBezControl1() const
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
Draw a cubic bezier spline.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsPolygonFilled() const
Polygonal shape is not always filled.
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)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References SHAPE_POLY_SET::Append(), SHAPE_POLY_SET::CacheTriangulation(), color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawCurve(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawSegment(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcAngleStart(), DRAWSEGMENT::GetBezControl1(), DRAWSEGMENT::GetBezControl2(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), DRAWSEGMENT::GetEnd(), BOARD_ITEM::GetLayer(), getLineThickness(), DRAWSEGMENT::GetParentModule(), DRAWSEGMENT::GetRadius(), DRAWSEGMENT::GetRectCorners(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), KIGFX::GAL::IsOpenGlEngine(), DRAWSEGMENT::IsPolygonFilled(), SHAPE_POLY_SET::IsTriangulationUpToDate(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchGraphics, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), KIGFX::GAL::Restore(), KIGFX::GAL::Rotate(), S_ARC, S_CIRCLE, S_CURVE, S_LAST, S_POLYGON, S_RECT, S_SEGMENT, KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and KIGFX::GAL::Translate().

◆ draw() [6/13]

void PCB_PAINTER::draw ( const TEXTE_PCB aText,
int  aLayer 
)
protected

Definition at line 1076 of file pcb_painter.cpp.

1077 {
1078  wxString shownText( aText->GetShownText() );
1079 
1080  if( shownText.Length() == 0 )
1081  return;
1082 
1083  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1084  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1085 
1087  {
1088  // Outline mode
1090  }
1091  else
1092  {
1093  // Filled mode
1095  }
1096 
1098  m_gal->SetIsFill( false );
1099  m_gal->SetIsStroke( true );
1100  m_gal->SetTextAttributes( aText );
1101  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1102 }
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
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:191
int color
Definition: DXF_plotter.cpp:61
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
bool m_sketchText
Flag determining if text items should be outlined or stroked
Definition: pcb_painter.h:197
double GetTextAngleRadians() const
Definition: eda_text.h:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References color, KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_TEXT::GetEffectiveTextPenWidth(), BOARD_ITEM::GetLayer(), getLineThickness(), TEXTE_PCB::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::PCB_RENDER_SETTINGS::m_sketchText, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), KIGFX::GAL::StrokeText(), wxPoint::x, and wxPoint::y.

◆ draw() [7/13]

void PCB_PAINTER::draw ( const TEXTE_MODULE aText,
int  aLayer 
)
protected

Definition at line 1105 of file pcb_painter.cpp.

1106 {
1107  wxString shownText( aText->GetShownText() );
1108 
1109  if( shownText.Length() == 0 )
1110  return;
1111 
1112  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1113  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1114 
1116  {
1117  // Outline mode
1119  }
1120  else
1121  {
1122  // Filled mode
1124  }
1125 
1127  m_gal->SetIsFill( false );
1128  m_gal->SetIsStroke( true );
1129  m_gal->SetTextAttributes( aText );
1130  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1131 
1132  // Draw the umbilical line
1133  if( aText->IsSelected() )
1134  {
1136  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1137  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1138  }
1139 }
bool IsSelected() const
Definition: base_struct.h:203
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
int color
Definition: DXF_plotter.cpp:61
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
double GetDrawRotationRadians() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
bool m_sketchText
Flag determining if text items should be outlined or stroked
Definition: pcb_painter.h:197
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
BOARD_ITEM_CONTAINER * GetParent() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References color, KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), TEXTE_MODULE::GetDrawRotationRadians(), EDA_TEXT::GetEffectiveTextPenWidth(), getLineThickness(), BOARD_ITEM::GetParent(), EDA_ITEM::GetPosition(), TEXTE_MODULE::GetShownText(), EDA_TEXT::GetTextPos(), EDA_ITEM::IsSelected(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchText, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), KIGFX::GAL::StrokeText(), wxPoint::x, and wxPoint::y.

◆ draw() [8/13]

void PCB_PAINTER::draw ( const MODULE aModule,
int  aLayer 
)
protected

Definition at line 1142 of file pcb_painter.cpp.

1143 {
1144  if( aLayer == LAYER_ANCHOR )
1145  {
1146  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1147 
1148  // Draw anchor
1151 
1152  // Keep the size constant, not related to the scale
1153  double anchorSize = 5.0 / m_gal->GetWorldScale();
1154 
1155  VECTOR2D center = aModule->GetPosition();
1156  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1157  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1158  }
1159 }
anchor of items having an anchor point (texts, footprints)
int color
Definition: DXF_plotter.cpp:61
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
wxPoint GetPosition() const override
Definition: class_module.h:212
double GetWorldScale() const
Get the world scale.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References color, KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), MODULE::GetPosition(), KIGFX::GAL::GetWorldScale(), LAYER_ANCHOR, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [9/13]

void PCB_PAINTER::draw ( const PCB_GROUP aGroup,
int  aLayer 
)
protected

Definition at line 1162 of file pcb_painter.cpp.

1163 {
1164  if( aLayer == LAYER_ANCHOR )
1165  {
1166  const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
1167 
1168  EDA_RECT bbox = aGroup->GetBoundingBox();
1171  wxPoint pos = bbox.GetPosition();
1172 
1173  m_gal->DrawLine( pos, pos + wxPoint( bbox.GetWidth(), 0 ) );
1174  m_gal->DrawLine( pos + wxPoint( bbox.GetWidth(), 0 ),
1175  pos + wxPoint( bbox.GetWidth(), bbox.GetHeight() ) );
1176  m_gal->DrawLine( pos + wxPoint( bbox.GetWidth(), bbox.GetHeight() ),
1177  pos + wxPoint( 0, bbox.GetHeight() ) );
1178  m_gal->DrawLine( pos + wxPoint( 0, bbox.GetHeight() ), pos );
1179  }
1180 }
anchor of items having an anchor point (texts, footprints)
int color
Definition: DXF_plotter.cpp:61
int GetWidth() const
Definition: eda_rect.h:119
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
const EDA_RECT GetBoundingBox() const override
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
const wxPoint GetPosition() const
Definition: eda_rect.h:115
int GetHeight() const
Definition: eda_rect.h:120
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References color, KIGFX::GAL::DrawLine(), PCB_GROUP::GetBoundingBox(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_RECT::GetHeight(), EDA_RECT::GetPosition(), EDA_RECT::GetWidth(), LAYER_ANCHOR, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [10/13]

void PCB_PAINTER::draw ( const ZONE_CONTAINER aZone,
int  aLayer 
)
protected

aLayer will be the virtual zone layer (LAYER_ZONE_START, ... in GAL_LAYER_ID) This is used for draw ordering in the GAL. The color for the zone comes from the associated copper layer ( aLayer - LAYER_ZONE_START ) and the visibility comes from the combination of that copper layer and LAYER_ZONES

Definition at line 1183 of file pcb_painter.cpp.

1184 {
1191  wxASSERT( IsZoneLayer( aLayer ) );
1192  PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer - LAYER_ZONE_START );
1193 
1194  if( !aZone->IsOnLayer( layer ) )
1195  return;
1196 
1197  COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
1198  std::deque<VECTOR2D> corners;
1200 
1201  // Draw the outline
1202  const SHAPE_POLY_SET* outline = aZone->Outline();
1203 
1204  if( m_pcbSettings.m_zoneOutlines && outline && outline->OutlineCount() > 0 )
1205  {
1207  m_gal->SetIsFill( false );
1208  m_gal->SetIsStroke( true );
1210 
1211  // Draw each contour (main contour and holes)
1212 
1213  /* This line:
1214  * m_gal->DrawPolygon( *outline );
1215  * should be enough, but currently does not work to draw holes contours in a complex polygon
1216  * so each contour is draw as a simple polygon
1217  */
1218 
1219  // Draw the main contour
1220  m_gal->DrawPolyline( outline->COutline( 0 ) );
1221 
1222  // Draw holes
1223  int holes_count = outline->HoleCount( 0 );
1224 
1225  for( int ii = 0; ii < holes_count; ++ii )
1226  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1227 
1228  // Draw hatch lines
1229  for( const SEG& hatchLine : aZone->GetHatchLines() )
1230  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1231  }
1232 
1233  // Draw the filling
1234  if( displayMode != ZONE_DISPLAY_MODE::HIDE_FILLED )
1235  {
1236  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer );
1237 
1238  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1239  return;
1240 
1241  // Set up drawing options
1242  int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
1244  m_gal->SetFillColor( color );
1245  m_gal->SetLineWidth( outline_thickness );
1246 
1247  if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
1248  {
1249  m_gal->SetIsFill( true );
1250  m_gal->SetIsStroke( outline_thickness > 0 );
1251  }
1252  else if( displayMode == ZONE_DISPLAY_MODE::SHOW_OUTLINED )
1253  {
1254  m_gal->SetIsFill( false );
1255  m_gal->SetIsStroke( true );
1256  }
1257 
1258  m_gal->DrawPolygon( polySet );
1259  }
1260 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
Virtual layers for stacking zones and tracks on a given copper layer.
Filled polygons are shown.
int OutlineCount() const
Returns the number of outlines in the set
ZONE_DISPLAY_MODE
Determines how zones should be displayed
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_zone.cpp:312
int color
Definition: DXF_plotter.cpp:61
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:293
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:675
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:620
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Only the zone outline is shown.
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
bool IsZoneLayer(LAYER_NUM aLayer)
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:785
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
Definition: seg.h:39
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
int GetMinThickness() const
Definition: class_zone.h:217
bool m_zoneOutlines
Flag determining if zones should have outlines drawn
Definition: pcb_painter.h:212
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
ZONE_DISPLAY_MODE m_zoneDisplayMode
Option for different display modes for zones
Definition: pcb_painter.h:226
Outlines of filled polygons are shown.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References SHAPE_POLY_SET::CHole(), color, SHAPE_POLY_SET::COutline(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawPolyline(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), ZONE_CONTAINER::GetFilledPolysList(), ZONE_CONTAINER::GetFilledPolysUseThickness(), ZONE_CONTAINER::GetHatchLines(), ZONE_CONTAINER::GetMinThickness(), HIDE_FILLED, SHAPE_POLY_SET::HoleCount(), ZONE_CONTAINER::IsOnLayer(), IsZoneLayer(), LAYER_ZONE_START, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_zoneDisplayMode, KIGFX::PCB_RENDER_SETTINGS::m_zoneOutlines, ZONE_CONTAINER::Outline(), SHAPE_POLY_SET::OutlineCount(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), SHOW_FILLED, and SHOW_OUTLINED.

◆ draw() [11/13]

void PCB_PAINTER::draw ( const DIMENSION aDimension,
int  aLayer 
)
protected

Definition at line 1263 of file pcb_painter.cpp.

1264 {
1265  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1266 
1267  m_gal->SetStrokeColor( strokeColor );
1268  m_gal->SetIsFill( false );
1269  m_gal->SetIsStroke( true );
1270 
1272  {
1273  // Outline mode
1275  }
1276  else
1277  {
1278  // Filled mode
1279  m_gal->SetLineWidth( getLineThickness( aDimension->GetLineThickness() ) );
1280  }
1281 
1282  // Draw dimension shapes
1283  // TODO(JE) lift this out
1284  for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
1285  {
1286  switch( shape->Type() )
1287  {
1288  case SH_SEGMENT:
1289  {
1290  const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
1291  m_gal->DrawLine( seg.A, seg.B );
1292  break;
1293  }
1294 
1295  case SH_CIRCLE:
1296  {
1297  int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
1298  m_gal->DrawCircle( shape->Centre(), radius );
1299  break;
1300  }
1301 
1302  default:
1303  break;
1304  }
1305  }
1306  // Draw text
1307  TEXTE_PCB& text = aDimension->Text();
1308  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1309 
1311  {
1312  // Outline mode
1314  }
1315  else
1316  {
1317  // Filled mode
1319  }
1320 
1321  m_gal->SetTextAttributes( &text );
1322  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1323 }
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
bool m_sketchGraphics
Flag determining if graphic items should be outlined or stroked
Definition: pcb_painter.h:194
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
line chain (polyline)
Definition: shape.h:45
bool m_sketchText
Flag determining if text items should be outlined or stroked
Definition: pcb_painter.h:197
Definition: seg.h:39
double GetTextAngleRadians() const
Definition: eda_text.h:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
TEXTE_PCB & Text()
VECTOR2I A
Definition: seg.h:47
int GetLineThickness() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
axis-aligned rectangle
Definition: shape.h:43
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_TEXT::GetEffectiveTextPenWidth(), DIMENSION::GetLineThickness(), getLineThickness(), DIMENSION::GetShapes(), TEXTE_PCB::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchGraphics, KIGFX::PCB_RENDER_SETTINGS::m_sketchText, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), SH_CIRCLE, SH_SEGMENT, KIGFX::GAL::StrokeText(), DIMENSION::Text(), wxPoint::x, and wxPoint::y.

◆ draw() [12/13]

void PCB_PAINTER::draw ( const PCB_TARGET aTarget)
protected

Definition at line 1326 of file pcb_painter.cpp.

1327 {
1328  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1329  VECTOR2D position( aTarget->GetPosition() );
1330  double size, radius;
1331 
1332  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1333  m_gal->SetStrokeColor( strokeColor );
1334  m_gal->SetIsFill( false );
1335  m_gal->SetIsStroke( true );
1336 
1337  m_gal->Save();
1338  m_gal->Translate( position );
1339 
1340  if( aTarget->GetShape() )
1341  {
1342  // shape x
1343  m_gal->Rotate( M_PI / 4.0 );
1344  size = 2.0 * aTarget->GetSize() / 3.0;
1345  radius = aTarget->GetSize() / 2.0;
1346  }
1347  else
1348  {
1349  // shape +
1350  size = aTarget->GetSize() / 2.0;
1351  radius = aTarget->GetSize() / 3.0;
1352  }
1353 
1354  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1355  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1356  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1357 
1358  m_gal->Restore();
1359 }
int GetSize() const
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
wxPoint GetPosition() const override
int GetWidth() const
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
int GetShape() const
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), BOARD_ITEM::GetLayer(), getLineThickness(), PCB_TARGET::GetPosition(), PCB_TARGET::GetShape(), PCB_TARGET::GetSize(), PCB_TARGET::GetWidth(), KIGFX::PAINTER::m_gal, m_pcbSettings, KIGFX::GAL::Restore(), KIGFX::GAL::Rotate(), KIGFX::GAL::Save(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and KIGFX::GAL::Translate().

◆ draw() [13/13]

void PCB_PAINTER::draw ( const MARKER_PCB aMarker)
protected

Definition at line 1362 of file pcb_painter.cpp.

1363 {
1364  SHAPE_LINE_CHAIN polygon;
1365  aMarker->ShapeToPolygon( polygon );
1366 
1367  auto strokeColor = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
1368 
1369  m_gal->Save();
1370  m_gal->Translate( aMarker->GetPosition() );
1371  m_gal->SetFillColor( strokeColor );
1372  m_gal->SetIsFill( true );
1373  m_gal->SetIsStroke( false );
1374  m_gal->DrawPolygon( polygon );
1375  m_gal->Restore();
1376 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
GAL_LAYER_ID GetColorLayer() const
wxPoint GetPosition() const override
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
SHAPE_LINE_CHAIN.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.

References KIGFX::GAL::DrawPolygon(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), MARKER_PCB::GetColorLayer(), MARKER_PCB::GetPosition(), KIGFX::PAINTER::m_gal, m_pcbSettings, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), MARKER_BASE::ShapeToPolygon(), and KIGFX::GAL::Translate().

◆ getDrillShape()

int PCB_PAINTER::getDrillShape ( const D_PAD aPad) const
protectedvirtual

Return drill shape of a pad.

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 373 of file pcb_painter.cpp.

374 {
375  return aPad->GetDrillShape();
376 }
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:326

References D_PAD::GetDrillShape().

Referenced by KIGFX::PCB_PRINT_PAINTER::getDrillShape().

◆ getDrillSize() [1/2]

VECTOR2D PCB_PAINTER::getDrillSize ( const D_PAD aPad) const
protectedvirtual

Return drill size for a pad (internal units).

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 379 of file pcb_painter.cpp.

380 {
381  return VECTOR2D( aPad->GetDrillSize() );
382 }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
const wxSize & GetDrillSize() const
Definition: class_pad.h:230

References D_PAD::GetDrillSize().

Referenced by draw(), and KIGFX::PCB_PRINT_PAINTER::getDrillSize().

◆ getDrillSize() [2/2]

int PCB_PAINTER::getDrillSize ( const VIA aVia) const
protectedvirtual

Return drill diameter for a via (internal units).

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 385 of file pcb_painter.cpp.

386 {
387  return aVia->GetDrillValue();
388 }
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...

References VIA::GetDrillValue().

◆ getLineThickness()

int PCB_PAINTER::getLineThickness ( int  aActualThickness) const
protected

Function getLineThickness() Get the thickness to draw for a line (e.g.

0 thickness lines get a minimum value).

Parameters
aActualThicknessline own thickness
Returns
the thickness to draw

Definition at line 361 of file pcb_painter.cpp.

362 {
363  // if items have 0 thickness, draw them with the outline
364  // width, otherwise respect the set value (which, no matter
365  // how small will produce something)
366  if( aActualThickness == 0 )
368 
369  return aActualThickness;
370 }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281

References KIGFX::RENDER_SETTINGS::m_outlineWidth, and m_pcbSettings.

Referenced by draw().

◆ GetSettings()

virtual PCB_RENDER_SETTINGS* KIGFX::PCB_PAINTER::GetSettings ( )
inlineoverridevirtual

◆ SetGAL()

void KIGFX::PAINTER::SetGAL ( GAL aGal)
inlineinherited

Function SetGAL Changes Graphics Abstraction Layer used for drawing items for a new one.

Parameters
aGalis the new GAL instance.

Definition at line 78 of file painter.h.

79  {
80  m_gal = aGal;
81  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110

References KIGFX::PAINTER::m_gal.

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 113 of file painter.h.

◆ m_gal

◆ m_pcbSettings

PCB_RENDER_SETTINGS KIGFX::PCB_PAINTER::m_pcbSettings
protected

The documentation for this class was generated from the following files: