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 PAD *aPad, int aLayer)
 
void draw (const PCB_SHAPE *aSegment, int aLayer)
 
void draw (const PCB_TEXT *aText, int aLayer)
 
void draw (const FP_TEXT *aText, int aLayer)
 
void draw (const FOOTPRINT *aFootprint, int aLayer)
 
void draw (const PCB_GROUP *aGroup, int aLayer)
 
void draw (const ZONE *aZone, int aLayer)
 
void draw (const DIMENSION_BASE *aDimension, int aLayer)
 
void draw (const PCB_TARGET *aTarget)
 
void draw (const PCB_MARKER *aMarker, int aLayer)
 
int getLineThickness (int aActualThickness) const
 Function getLineThickness() Get the thickness to draw for a line (e.g. More...
 
virtual int getDrillShape (const PAD *aPad) const
 Return drill shape of a pad. More...
 
virtual VECTOR2D getDrillSize (const 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 374 of file pcb_painter.cpp.

374  :
375  PAINTER( aGal )
376 {
377 }
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 410 of file pcb_painter.cpp.

411 {
412  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
413 
414  if( !item )
415  return false;
416 
417  // the "cast" applied in here clarifies which overloaded draw() is called
418  switch( item->Type() )
419  {
420  case PCB_TRACE_T:
421  draw( static_cast<const TRACK*>( item ), aLayer );
422  break;
423 
424  case PCB_ARC_T:
425  draw( static_cast<const ARC*>( item ), aLayer );
426  break;
427 
428  case PCB_VIA_T:
429  draw( static_cast<const VIA*>( item ), aLayer );
430  break;
431 
432  case PCB_PAD_T:
433  draw( static_cast<const PAD*>( item ), aLayer );
434  break;
435 
436  case PCB_SHAPE_T:
437  case PCB_FP_SHAPE_T:
438  draw( static_cast<const PCB_SHAPE*>( item ), aLayer );
439  break;
440 
441  case PCB_TEXT_T:
442  draw( static_cast<const PCB_TEXT*>( item ), aLayer );
443  break;
444 
445  case PCB_FP_TEXT_T:
446  draw( static_cast<const FP_TEXT*>( item ), aLayer );
447  break;
448 
449  case PCB_FOOTPRINT_T:
450  draw( static_cast<const FOOTPRINT*>( item ), aLayer );
451  break;
452 
453  case PCB_GROUP_T:
454  draw( static_cast<const PCB_GROUP*>( item ), aLayer );
455  break;
456 
457  case PCB_ZONE_T:
458  draw( static_cast<const ZONE*>( item ), aLayer );
459  break;
460 
461  case PCB_FP_ZONE_T:
462  draw( static_cast<const ZONE*>( item ), aLayer );
463  break;
464 
465  case PCB_DIM_ALIGNED_T:
466  case PCB_DIM_CENTER_T:
468  case PCB_DIM_LEADER_T:
469  draw( static_cast<const DIMENSION_BASE*>( item ), aLayer );
470  break;
471 
472  case PCB_TARGET_T:
473  draw( static_cast<const PCB_TARGET*>( item ) );
474  break;
475 
476  case PCB_MARKER_T:
477  draw( static_cast<const PCB_MARKER*>( item ), aLayer );
478  break;
479 
480  default:
481  // Painter does not know how to draw the object
482  return false;
483  }
484 
485  return true;
486 }
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:101
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
class FP_TEXT, text in a footprint
Definition: typeinfo.h:93
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 PCB_TEXT, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
class PAD, a pad in a footprint
Definition: typeinfo.h:90
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
class ZONE, a copper pour area
Definition: typeinfo.h:106
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:105
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
class ZONE, managed by a footprint
Definition: typeinfo.h:95
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
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
void draw(const TRACK *aTrack, int aLayer)
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References draw(), PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_MARKER_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, and EDA_ITEM::Type().

◆ draw() [1/13]

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

Definition at line 489 of file pcb_painter.cpp.

490 {
491  VECTOR2D start( aTrack->GetStart() );
492  VECTOR2D end( aTrack->GetEnd() );
493  int width = aTrack->GetWidth();
494 
496  {
497  // If there is a net name - display it on the track
498  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
499  {
500  VECTOR2D line = ( end - start );
501  double length = line.EuclideanNorm();
502 
503  // Check if the track is long enough to have a netname displayed
504  if( length < 10 * width )
505  return;
506 
507  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
508  VECTOR2D textPosition = start + line / 2.0; // center of the track
509 
510  double textOrientation;
511 
512  if( end.y == start.y ) // horizontal
513  textOrientation = 0;
514  else if( end.x == start.x ) // vertical
515  textOrientation = M_PI / 2;
516  else
517  textOrientation = -atan( line.y / line.x );
518 
519  double textSize = width;
520 
521  m_gal->SetIsStroke( true );
522  m_gal->SetIsFill( false );
523  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aTrack, aLayer ) );
524  m_gal->SetLineWidth( width / 10.0 );
525  m_gal->SetFontBold( false );
526  m_gal->SetFontItalic( false );
527  m_gal->SetFontUnderlined( false );
528  m_gal->SetTextMirrored( false );
529  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
532  m_gal->BitmapText( netName, textPosition, textOrientation );
533  }
534  }
535  else if( IsCopperLayer( aLayer ) )
536  {
537  // Draw a regular track
538  COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
539  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
542  m_gal->SetIsStroke( outline_mode );
543  m_gal->SetIsFill( not outline_mode );
545 
546  m_gal->DrawSegment( start, end, width );
547 
548  // Clearance lines
549  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
550 
551  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
552  {
553  int clearance = aTrack->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
554 
556  m_gal->SetIsFill( false );
557  m_gal->SetIsStroke( true );
559  m_gal->DrawSegment( start, end, width + clearance * 2 );
560  }
561  }
562 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
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: 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:60
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetFontBold(const bool aBold)
Set bold property of current font.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
wxString GetShortNetname() const
Function GetShortNetname.
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.
void SetFontItalic(bool aItalic)
Set italic property of current font.
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
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
int GetWidth() const
Definition: track.h:110
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:229
void SetFontUnderlined(bool aUnderlined)
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...
PCB_LAYER_ID GetActiveLayer() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Function GetClearance returns an item's "own" clearance in internal units.
const wxPoint & GetEnd() const
Definition: track.h:113
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
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
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References KIGFX::GAL::BitmapText(), KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_TRACKS, color, KIGFX::GAL::DrawSegment(), VECTOR2< T >::EuclideanNorm(), KIGFX::RENDER_SETTINGS::GetActiveLayer(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), TRACK::GetEnd(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_CONNECTED_ITEM::GetOwnClearance(), 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, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), NETINFO_LIST::UNCONNECTED, UnescapeString(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Draw(), and draw().

◆ draw() [2/13]

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

Definition at line 565 of file pcb_painter.cpp.

566 {
567  VECTOR2D center( aArc->GetCenter() );
568  int width = aArc->GetWidth();
569 
570  if( IsCopperLayer( aLayer ) )
571  {
572  // Draw a regular track
573  COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
574  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
577  m_gal->SetIsStroke( outline_mode );
578  m_gal->SetIsFill( not outline_mode );
580 
581  auto radius = aArc->GetRadius();
582  auto start_angle = DECIDEG2RAD( aArc->GetArcAngleStart() );
583  auto angle = DECIDEG2RAD( aArc->GetAngle() );
584 
585  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width );
586 
587  // Clearance lines
588  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
589 
590  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
591  {
592  int clearance = aArc->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
593 
595  m_gal->SetIsFill( false );
596  m_gal->SetIsStroke( true );
598 
599  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
600  width + clearance * 2 );
601  }
602  }
603 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual wxPoint GetCenter() const override
Function GetCenter()
Definition: track.h:312
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:60
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
double GetRadius() const
Definition: track.cpp:918
double GetAngle() const
Definition: track.cpp:924
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetWidth() const
Definition: 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:221
PCB_LAYER_ID GetActiveLayer() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Function GetClearance returns an item's "own" clearance in internal units.
bool IsCopperLayer(LAYER_NUM aLayerId)
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
Definition: track.cpp:936
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References PNS::angle(), KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_TRACKS, color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), KIGFX::RENDER_SETTINGS::GetActiveLayer(), ARC::GetAngle(), ARC::GetArcAngleStart(), ARC::GetCenter(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), BOARD_CONNECTED_ITEM::GetOwnClearance(), 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(), and KIGFX::GAL::SetStrokeColor().

◆ 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 606 of file pcb_painter.cpp.

607 {
608  VECTOR2D center( aVia->GetStart() );
609  double radius = 0.0;
610 
611  // Draw description layer
612  if( IsNetnameLayer( aLayer ) )
613  {
614  VECTOR2D position( center );
615 
616  // Is anything that we can display enabled?
617  if( !m_pcbSettings.m_netNamesOnVias || aVia->GetNetname().empty() )
618  return;
619 
620  // We won't get CLEAR from GetColor below for a non-through via on an inactive layer in
621  // high contrast mode because LAYER_VIAS_NETNAMES will always be part of the high-contrast
622  // set. So we do another check here to prevent drawing netnames for these vias.
624  {
625  bool draw = false;
626 
627  for( unsigned int layer : m_pcbSettings.GetHighContrastLayers() )
628  {
629  if( aVia->IsOnLayer( static_cast<PCB_LAYER_ID>( layer ) ) )
630  {
631  draw = true;
632  break;
633  }
634  }
635 
636  if( !draw )
637  return;
638  }
639 
640  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
641  double size = aVia->GetWidth();
642 
643  // Font size limits
644  if( size > maxSize )
645  size = maxSize;
646 
647  m_gal->Save();
648  m_gal->Translate( position );
649 
650  // Default font settings
653 
654  // Set the text position to the pad shape position (the pad position is not the best place)
655  VECTOR2D textpos( 0.0, 0.0 );
656 
657  wxString netname = UnescapeString( aVia->GetShortNetname() );
658  // calculate the size of net name text:
659  double tsize = 1.5 * size / netname.Length();
660  tsize = std::min( tsize, size );
661  // Use a smaller text size to handle interline, pen size..
662  tsize *= 0.7;
663  VECTOR2D namesize( tsize, tsize );
664 
665  m_gal->SetGlyphSize( namesize );
666  m_gal->SetLineWidth( namesize.x / 12.0 );
667  m_gal->BitmapText( netname, textpos, 0.0 );
668 
669  m_gal->Restore();
670 
671  return;
672  }
673  else if( aLayer == LAYER_VIAS_HOLES )
674  {
675  radius = getDrillSize( aVia ) / 2.0;
676  }
677  else if( ( aLayer == LAYER_VIA_THROUGH && aVia->GetViaType() == VIATYPE::THROUGH )
678  || ( aLayer == LAYER_VIA_BBLIND && aVia->GetViaType() == VIATYPE::BLIND_BURIED )
679  || ( aLayer == LAYER_VIA_MICROVIA && aVia->GetViaType() == VIATYPE::MICROVIA ) )
680  {
681  radius = aVia->GetWidth() / 2.0;
682  }
683  else
684  {
685  return;
686  }
687 
690  if( IsCopperLayer( aLayer ) && !aVia->FlashLayer( aLayer ) )
691  radius = getDrillSize( aVia ) / 2.0 ;
692 
693  bool sketchMode = false;
694  COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
695 
696  if( color == COLOR4D::CLEAR )
697  return;
698 
699  switch( aVia->GetViaType() )
700  {
704  default: wxASSERT( false ); break;
705  }
706 
707  m_gal->SetIsFill( !sketchMode );
708  m_gal->SetIsStroke( sketchMode );
709 
710  if( sketchMode )
711  {
712  // Outline mode
715  }
716  else
717  {
718  // Filled mode
720  }
721 
722  if( ( aVia->GetViaType() == VIATYPE::BLIND_BURIED || aVia->GetViaType() == VIATYPE::MICROVIA )
723  && aLayer != LAYER_VIAS_HOLES
725  {
726  // Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
727  // top and bottom layers
728  PCB_LAYER_ID layerTop, layerBottom;
729  aVia->LayerPair( &layerTop, &layerBottom );
730 
731  if( !sketchMode )
732  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
733 
734  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
735  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
736 
737  if( sketchMode )
738  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerTop ) );
739  else
740  m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
741 
742  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
743 
744  if( sketchMode )
745  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
746  else
747  m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
748 
749  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
750  }
751  else
752  {
753  // Draw the outer circles of normal vias and the holes for all vias
754  m_gal->DrawCircle( center, radius );
755  }
756 
757  // Clearance lines
758  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
759 
760  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
761  && aLayer != LAYER_VIAS_HOLES )
762  {
763  PCB_LAYER_ID activeLayer = m_pcbSettings.GetActiveLayer();
764 
765  if( !aVia->FlashLayer( activeLayer ) )
766  {
767  radius = getDrillSize( aVia ) / 2.0 +
769  }
770 
772  m_gal->SetIsFill( false );
773  m_gal->SetIsStroke( true );
775  m_gal->DrawCircle( center, radius + aVia->GetOwnClearance( activeLayer ) );
776  }
777 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
const std::set< unsigned int > GetHighContrastLayers() const
Function GetHighContrastLayers() Returns the set of currently high-contrast layers.
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...
Definition: track.cpp:422
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: track.h:116
int GetHolePlatingThickness() const
Pad & via drills are finish size.
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:60
to draw via holes (pad holes do not use this layer)
wxString GetNetname() const
Function GetNetname.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual VECTOR2D getDrillSize(const PAD *aPad) const
Return drill size for a pad (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 ...
Definition: track.cpp:170
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
Definition: track.cpp:481
static const COLOR4D CLEAR
Definition: color4d.h:385
to draw usual through hole vias
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
bool GetHighContrast() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
virtual void Restore()
Restore the context.
int GetWidth() const
Definition: 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: track.h:384
PCB_LAYER_ID GetActiveLayer() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Function GetClearance returns an item's "own" clearance in internal units.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: track.cpp:348
virtual void Save()
Save the context.
void draw(const TRACK *aTrack, int aLayer)
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:209
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References KIGFX::GAL::BitmapText(), BLIND_BURIED, KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_VIAS, KIGFX::COLOR4D::CLEAR, color, draw(), KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), VIA::FlashLayer(), KIGFX::RENDER_SETTINGS::GetActiveLayer(), BOARD_ITEM::GetBoard(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), BOARD::GetDesignSettings(), KIGFX::PCB_RENDER_SETTINGS::GetDrawIndividualViaLayers(), getDrillSize(), VIA::GetDrillValue(), KIGFX::RENDER_SETTINGS::GetHighContrast(), KIGFX::RENDER_SETTINGS::GetHighContrastLayers(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), BOARD_CONNECTED_ITEM::GetNetname(), BOARD_CONNECTED_ITEM::GetOwnClearance(), BOARD_CONNECTED_ITEM::GetShortNetname(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), IsCopperLayer(), IsNetnameLayer(), VIA::IsOnLayer(), 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 PAD aPad,
int  aLayer 
)
protected

Definition at line 780 of file pcb_painter.cpp.

781 {
782  // Draw description layer
783  if( IsNetnameLayer( aLayer ) )
784  {
785  // Is anything that we can display enabled?
787  {
788  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
789  EDA_RECT padBBox = aPad->GetBoundingBox();
790  VECTOR2D position = padBBox.Centre();
791  VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
792 
793  if( aPad->GetShape() != PAD_SHAPE_CUSTOM )
794  {
795  // Don't allow a 45ยบ rotation to bloat a pad's bounding box unnecessarily
796  double limit = std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1;
797 
798  if( padsize.x > limit && padsize.y > limit )
799  {
800  padsize.x = limit;
801  padsize.y = limit;
802  }
803  }
804 
805  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
806  double size = padsize.y;
807 
808  m_gal->Save();
809  m_gal->Translate( position );
810 
811  // Keep the size ratio for the font, but make it smaller
812  if( padsize.x < padsize.y )
813  {
814  m_gal->Rotate( DECIDEG2RAD( -900.0 ) );
815  size = padsize.x;
816  std::swap( padsize.x, padsize.y );
817  }
818 
819  // Font size limits
820  if( size > maxSize )
821  size = maxSize;
822 
823  // Default font settings
826  m_gal->SetFontBold( false );
827  m_gal->SetFontItalic( false );
828  m_gal->SetFontUnderlined( false );
829  m_gal->SetTextMirrored( false );
830  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) );
831  m_gal->SetIsStroke( true );
832  m_gal->SetIsFill( false );
833 
834  // We have already translated the GAL to be centered at the center of the pad's
835  // bounding box
836  VECTOR2D textpos( 0.0, 0.0 );
837 
838  // Divide the space, to display both pad numbers and netnames and set the Y text
839  // position to display 2 lines
840  if( displayNetname && m_pcbSettings.m_padNumbers )
841  {
842  size = size / 2.0;
843  textpos.y = size / 2.0;
844  }
845 
846  if( displayNetname )
847  {
848  wxString netname = UnescapeString( aPad->GetShortNetname() );
849  // calculate the size of net name text:
850  double tsize = 1.5 * padsize.x / netname.Length();
851  tsize = std::min( tsize, size );
852  // Use a smaller text size to handle interline, pen size..
853  tsize *= 0.7;
854  VECTOR2D namesize( tsize, tsize );
855 
856  m_gal->SetGlyphSize( namesize );
857  m_gal->SetLineWidth( namesize.x / 12.0 );
858  m_gal->BitmapText( netname, textpos, 0.0 );
859  }
860 
862  {
863  const wxString& padName = aPad->GetName();
864  textpos.y = -textpos.y;
865  double tsize = 1.5 * padsize.x / padName.Length();
866  tsize = std::min( tsize, size );
867  // Use a smaller text size to handle interline, pen size..
868  tsize *= 0.7;
869  tsize = std::min( tsize, size );
870  VECTOR2D numsize( tsize, tsize );
871 
872  m_gal->SetGlyphSize( numsize );
873  m_gal->SetLineWidth( numsize.x / 12.0 );
874  m_gal->BitmapText( padName, textpos, 0.0 );
875  }
876 
877  m_gal->Restore();
878  }
879  return;
880  }
881 
882  // Pad drawing
884  COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
885 
887  {
888  // Outline mode
889  m_gal->SetIsFill( false );
890  m_gal->SetIsStroke( true );
893  }
894  else
895  {
896  // Filled mode
897  m_gal->SetIsFill( true );
898  m_gal->SetIsStroke( false );
900  }
901 
902  // Choose drawing settings depending on if we are drawing a pad itself or a hole
903  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
904  {
905  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
906 
907  if( seg->GetSeg().A == seg->GetSeg().B ) // Circular hole
908  m_gal->DrawCircle( seg->GetSeg().A, getDrillSize( aPad ).x / 2 );
909  else
910  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() );
911  }
912  else if( aLayer == LAYER_PADS_TH
913  && aPad->GetSizeX() <= aPad->GetDrillSizeX()
914  && aPad->GetSizeY() <= aPad->GetDrillSizeY() )
915  {
916  // no annular ring to draw
917  }
918  else
919  {
920  wxSize pad_size = aPad->GetSize();
921  wxSize margin;
922 
923  switch( aLayer )
924  {
925  case F_Mask:
926  case B_Mask:
927  margin.x = margin.y = aPad->GetSolderMaskMargin();
928  break;
929 
930  case F_Paste:
931  case B_Paste:
932  margin = aPad->GetSolderPasteMargin();
933  break;
934 
935  default:
936  margin.x = margin.y = 0;
937  break;
938  }
939 
940  if( margin.x != margin.y )
941  {
942  const_cast<PAD*>( aPad )->SetSize( pad_size + margin + margin );
943  margin.x = margin.y = 0;
944  }
945 
946  // Once we change the size of the pad, check that there is still a pad remaining
947  if( !aPad->GetSize().x || !aPad->GetSize().y )
948  {
949  // Reset the stored pad size
950  if( aPad->GetSize() != pad_size )
951  const_cast<PAD*>( aPad )->SetSize( pad_size );
952 
953  return;
954  }
955 
956  auto shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
957  bool simpleShapes = true;
958 
959  for( SHAPE* shape : shapes->Shapes() )
960  {
961  // Drawing components of compound shapes in outline mode produces a mess.
963  simpleShapes = false;
964 
965  if( !simpleShapes )
966  break;
967 
968  switch( shape->Type() )
969  {
970  case SH_SEGMENT:
971  case SH_CIRCLE:
972  case SH_RECT:
973  case SH_SIMPLE:
974  // OK so far
975  break;
976 
977  default:
978  // Not OK
979  simpleShapes = false;
980  break;
981  }
982  }
983 
984  if( simpleShapes )
985  {
986  for( SHAPE* shape : shapes->Shapes() )
987  {
988  switch( shape->Type() )
989  {
990  case SH_SEGMENT:
991  {
992  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape;
993  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
994  seg->GetWidth() + 2 * margin.x );
995  }
996  break;
997 
998  case SH_CIRCLE:
999  {
1000  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape;
1001  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + margin.x );
1002  }
1003  break;
1004 
1005  case SH_RECT:
1006  {
1007  const SHAPE_RECT* r = (SHAPE_RECT*) shape;
1008 
1009  m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
1010 
1011  if( margin.x > 0 )
1012  {
1013  m_gal->DrawSegment( r->GetPosition(),
1014  r->GetPosition() + VECTOR2I( r->GetWidth(), 0 ),
1015  margin.x * 2 );
1016  m_gal->DrawSegment( r->GetPosition() + VECTOR2I( r->GetWidth(), 0 ),
1017  r->GetPosition() + r->GetSize(),
1018  margin.x * 2 );
1019  m_gal->DrawSegment( r->GetPosition() + r->GetSize(),
1020  r->GetPosition() + VECTOR2I( 0, r->GetHeight() ),
1021  margin.x * 2 );
1022  m_gal->DrawSegment( r->GetPosition() + VECTOR2I( 0, r->GetHeight() ),
1023  r->GetPosition(),
1024  margin.x * 2 );
1025  }
1026  }
1027  break;
1028 
1029  case SH_SIMPLE:
1030  {
1031  const SHAPE_SIMPLE* poly = static_cast<const SHAPE_SIMPLE*>( shape );
1032  m_gal->DrawPolygon( poly->Vertices() );
1033 
1034  if( margin.x > 0 )
1035  {
1036  for( size_t ii = 0; ii < poly->GetSegmentCount(); ++ii )
1037  {
1038  SEG seg = poly->GetSegment( ii );
1039  m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
1040  }
1041  }
1042  }
1043  break;
1044 
1045  default:
1046  // Better not get here; we already pre-flighted the shapes...
1047  break;
1048  }
1049  }
1050  }
1051  else
1052  {
1053  // This is expensive. Avoid if possible.
1054 
1055  SHAPE_POLY_SET polySet;
1056  aPad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x,
1057  bds.m_MaxError, ERROR_INSIDE );
1058  m_gal->DrawPolygon( polySet );
1059  }
1060 
1061  if( aPad->GetSize() != pad_size )
1062  const_cast<PAD*>( aPad )->SetSize( pad_size );
1063  }
1064 
1065  // Clearance outlines
1066  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
1067 
1068  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
1069  && ( aLayer == LAYER_PAD_FR || aLayer == LAYER_PAD_BK || aLayer == LAYER_PADS_TH ) )
1070  {
1071  bool flashActiveLayer = aPad->FlashLayer( m_pcbSettings.GetActiveLayer() );
1072 
1073  if( flashActiveLayer || aPad->GetDrillSize().x )
1074  {
1076  m_gal->SetIsStroke( true );
1077  m_gal->SetIsFill( false );
1079 
1080  int clearance = aPad->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
1081 
1082  if( flashActiveLayer && clearance > 0 )
1083  {
1084  auto shape = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
1085 
1086  if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_SEGMENT )
1087  {
1088  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape->Shapes()[0];
1089  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
1090  seg->GetWidth() + 2 * clearance );
1091  }
1092  else if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_CIRCLE )
1093  {
1094  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape->Shapes()[0];
1095  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
1096  }
1097  else
1098  {
1099  SHAPE_POLY_SET polySet;
1100  aPad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ),
1101  clearance,
1102  bds.m_MaxError, ERROR_OUTSIDE );
1103  m_gal->DrawPolygon( polySet );
1104  }
1105  }
1106  else if( aPad->GetEffectiveHoleShape() && clearance > 0 )
1107  {
1108  clearance += bds.GetHolePlatingThickness();
1109 
1110  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
1111  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
1112  seg->GetWidth() + 2 * clearance );
1113  }
1114  }
1115  }
1116 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual const SEG GetSegment(int aIndex) const override
Definition: shape_simple.h:185
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
const int GetSizeY() const
Definition: pad.h:230
SHAPE_SIMPLE.
Definition: shape_simple.h:43
const int GetDrillSizeX() const
Definition: pad.h:238
int GetRadius() const
Definition: shape_circle.h:99
multilayer pads, usually with holes
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
handle color for not plated holes (holes, not pads)
int GetHolePlatingThickness() const
Pad & via drills are finish size.
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:60
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:200
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a SHAPE object representing the pad's hole.
Definition: pcbnew/pad.cpp:270
wxString GetNetname() const
Function GetNetname.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
PAD_SHAPE_T GetShape() const
Definition: pad.h:159
const VECTOR2I GetCenter() const
Definition: shape_circle.h:104
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
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:109
const SEG & GetSeg() const
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
virtual VECTOR2D getDrillSize(const PAD *aPad) const
Return drill size for a pad (internal units).
const VECTOR2I GetSize() const
Function GetSize()
Definition: shape_rect.h:123
void SetFontBold(const bool aBold)
Set bold property of current font.
const wxSize & GetDrillSize() const
Definition: pad.h:236
bool FlashLayer(int aLayer) const
Definition: pcbnew/pad.cpp:189
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
wxString GetShortNetname() const
Function GetShortNetname.
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 VECTOR2I & GetPosition() const
Function GetPosition()
Definition: shape_rect.h:113
const wxSize & GetSize() const
Definition: pad.h:226
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
const wxString & GetName() const
Definition: pad.h:127
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox The bounding box is cached, so this will be efficient most of the time.
Definition: pcbnew/pad.cpp:470
const SHAPE_LINE_CHAIN & Vertices() const
Function Vertices()
Definition: shape_simple.h:133
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: pcbnew/pad.cpp:261
SHAPE.
Definition: shape.h:122
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 SetFontItalic(bool aItalic)
Set italic property of current font.
line chain (polyline)
Definition: shape.h:46
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: pcbnew/pad.cpp:649
Definition: seg.h:39
virtual size_t GetSegmentCount() const override
Definition: shape_simple.h:187
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
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
void SetFontUnderlined(bool aUnderlined)
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: pcbnew/pad.cpp:694
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
const int GetDrillSizeY() const
Definition: pad.h:240
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...
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:221
const int GetSizeX() const
Definition: pad.h:228
PCB_LAYER_ID GetActiveLayer() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Function GetClearance returns an item's "own" clearance in internal units.
wxPoint Centre() const
Definition: eda_rect.h:62
const int GetHeight() const
Function GetHeight()
Definition: shape_rect.h:143
Definition: shape.h:43
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
const int GetWidth() const
Function GetWidth()
Definition: shape_rect.h:133
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetWidth() const
circle
Definition: shape.h:47
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:898
const wxSize GetSize() const
Definition: eda_rect.h:103
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
axis-aligned rectangle
Definition: shape.h:44
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
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::DrawRectangle(), KIGFX::GAL::DrawSegment(), ERROR_INSIDE, ERROR_OUTSIDE, F_Mask, F_Paste, PAD::FlashLayer(), KIGFX::RENDER_SETTINGS::GetActiveLayer(), BOARD_ITEM::GetBoard(), PAD::GetBoundingBox(), SHAPE_CIRCLE::GetCenter(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), BOARD::GetDesignSettings(), PAD::GetDrillSize(), getDrillSize(), PAD::GetDrillSizeX(), PAD::GetDrillSizeY(), PAD::GetEffectiveHoleShape(), PAD::GetEffectiveShape(), SHAPE_RECT::GetHeight(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), PAD::GetName(), BOARD_CONNECTED_ITEM::GetNetname(), BOARD_CONNECTED_ITEM::GetOwnClearance(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), SHAPE_SIMPLE::GetSegment(), SHAPE_SIMPLE::GetSegmentCount(), PAD::GetShape(), BOARD_CONNECTED_ITEM::GetShortNetname(), EDA_RECT::GetSize(), SHAPE_RECT::GetSize(), PAD::GetSize(), PAD::GetSizeX(), PAD::GetSizeY(), PAD::GetSolderMaskMargin(), PAD::GetSolderPasteMargin(), SHAPE_SEGMENT::GetWidth(), SHAPE_RECT::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, BOARD_DESIGN_SETTINGS::m_MaxError, 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, PAD_SHAPE_CUSTOM, KIGFX::GAL::Restore(), KIGFX::GAL::Rotate(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), 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_RECT, SH_SEGMENT, SH_SIMPLE, ToLAYER_ID(), PAD::TransformShapeWithClearanceToPolygon(), KIGFX::GAL::Translate(), UnescapeString(), SHAPE_SIMPLE::Vertices(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [5/13]

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

Definition at line 1119 of file pcb_painter.cpp.

1120 {
1121  const COLOR4D& color = m_pcbSettings.GetColor( aShape, aShape->GetLayer() );
1122  bool sketch = m_pcbSettings.m_sketchGraphics;
1123  int thickness = getLineThickness( aShape->GetWidth() );
1124  VECTOR2D start( aShape->GetStart() );
1125  VECTOR2D end( aShape->GetEnd() );
1126 
1127  if( sketch )
1128  {
1129  m_gal->SetIsFill( false );
1130  m_gal->SetIsStroke( true );
1132  }
1133 
1134  m_gal->SetFillColor( color );
1136 
1137  switch( aShape->GetShape() )
1138  {
1139  case S_SEGMENT:
1140  if( sketch )
1141  {
1142  m_gal->DrawSegment( start, end, thickness );
1143  }
1144  else
1145  {
1146  m_gal->SetIsFill( true );
1147  m_gal->SetIsStroke( false );
1148 
1149  m_gal->DrawSegment( start, end, thickness );
1150  }
1151  break;
1152 
1153  case S_RECT:
1154  {
1155  std::vector<wxPoint> pts = aShape->GetRectCorners();
1156 
1157  if( sketch )
1158  {
1159  m_gal->DrawSegment( pts[0], pts[1], thickness );
1160  m_gal->DrawSegment( pts[1], pts[2], thickness );
1161  m_gal->DrawSegment( pts[2], pts[3], thickness );
1162  m_gal->DrawSegment( pts[3], pts[0], thickness );
1163  }
1164  else
1165  {
1166  m_gal->SetIsFill( true );
1167  m_gal->SetIsStroke( false );
1168 
1169  if( thickness > 0 )
1170  {
1171  m_gal->DrawSegment( pts[0], pts[1], thickness );
1172  m_gal->DrawSegment( pts[1], pts[2], thickness );
1173  m_gal->DrawSegment( pts[2], pts[3], thickness );
1174  m_gal->DrawSegment( pts[3], pts[0], thickness );
1175  }
1176 
1177  if( aShape->IsFilled() )
1178  {
1179  SHAPE_POLY_SET poly;
1180  poly.NewOutline();
1181 
1182  for( const wxPoint& pt : pts )
1183  poly.Append( pt );
1184 
1185  m_gal->DrawPolygon( poly );
1186  }
1187  }
1188  }
1189  break;
1190 
1191  case S_ARC:
1192  if( sketch )
1193  {
1194  m_gal->DrawArcSegment( start, aShape->GetRadius(),
1195  DECIDEG2RAD( aShape->GetArcAngleStart() ),
1196  DECIDEG2RAD( aShape->GetArcAngleStart() + aShape->GetAngle() ), // Change this
1197  thickness );
1198  }
1199  else
1200  {
1201  m_gal->SetIsFill( true );
1202  m_gal->SetIsStroke( false );
1203 
1204  m_gal->DrawArcSegment( start, aShape->GetRadius(),
1205  DECIDEG2RAD( aShape->GetArcAngleStart() ),
1206  DECIDEG2RAD( aShape->GetArcAngleStart() + aShape->GetAngle() ), // Change this
1207  thickness );
1208  }
1209  break;
1210 
1211  case S_CIRCLE:
1212  if( sketch )
1213  {
1214  m_gal->DrawCircle( start, aShape->GetRadius() - thickness / 2 );
1215  m_gal->DrawCircle( start, aShape->GetRadius() + thickness / 2 );
1216  }
1217  else
1218  {
1219  m_gal->SetIsFill( aShape->IsFilled() );
1220  m_gal->SetIsStroke( thickness > 0 );
1221  m_gal->SetLineWidth( thickness );
1222 
1223  m_gal->DrawCircle( start, aShape->GetRadius() );
1224  }
1225  break;
1226 
1227  case S_POLYGON:
1228  {
1229  SHAPE_POLY_SET& shape = const_cast<PCB_SHAPE*>( aShape )->GetPolyShape();
1230  FOOTPRINT* parentFootprint = aShape->GetParentFootprint();
1231 
1232  if( shape.OutlineCount() == 0 )
1233  break;
1234 
1235  if( parentFootprint )
1236  {
1237  m_gal->Save();
1238  m_gal->Translate( parentFootprint->GetPosition() );
1239  m_gal->Rotate( -parentFootprint->GetOrientationRadians() );
1240  }
1241 
1242  if( sketch )
1243  {
1244  for( int ii = 0; ii < shape.Outline( 0 ).SegmentCount(); ++ii )
1245  {
1246  SEG seg = shape.Outline( 0 ).Segment( ii );
1247  m_gal->DrawSegment( seg.A, seg.B, thickness );
1248  }
1249  }
1250  else
1251  {
1252  m_gal->SetIsFill( true );
1253  m_gal->SetIsStroke( false );
1254 
1255  if( thickness > 0 )
1256  {
1257  for( int ii = 0; ii < shape.Outline( 0 ).SegmentCount(); ++ii )
1258  {
1259  SEG seg = shape.Outline( 0 ).Segment( ii );
1260  m_gal->DrawSegment( seg.A, seg.B, thickness );
1261  }
1262  }
1263 
1264  if( aShape->IsFilled() )
1265  {
1266  // On Opengl, a not convex filled polygon is usually drawn by using triangles
1267  // as primitives. CacheTriangulation() can create basic triangle primitives to
1268  // draw the polygon solid shape on Opengl. GLU tesselation is much slower, so
1269  // currently we are using our tesselation.
1270  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
1271  shape.CacheTriangulation();
1272 
1273  m_gal->DrawPolygon( shape );
1274  }
1275  }
1276 
1277  if( parentFootprint )
1278  m_gal->Restore();
1279  }
1280  break;
1281 
1282  case S_CURVE:
1283  if( sketch )
1284  {
1285  // Use thickness as filter value to convert the curve to polyline when the curve
1286  // is not supported
1287  m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
1288  VECTOR2D( aShape->GetBezControl1() ),
1289  VECTOR2D( aShape->GetBezControl2() ),
1290  VECTOR2D( aShape->GetEnd() ), thickness );
1291  }
1292  else
1293  {
1294  m_gal->SetIsFill( aShape->IsFilled() );
1295  m_gal->SetIsStroke( thickness > 0 );
1296  m_gal->SetLineWidth( thickness );
1297 
1298  // Use thickness as filter value to convert the curve to polyline when the curve
1299  // is not supported
1300  m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
1301  VECTOR2D( aShape->GetBezControl1() ),
1302  VECTOR2D( aShape->GetBezControl2() ),
1303  VECTOR2D( aShape->GetEnd() ), thickness );
1304  }
1305  break;
1306 
1307  case S_LAST:
1308  break;
1309  }
1310 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
double GetOrientationRadians() const
Definition: footprint.h:206
int OutlineCount() const
Returns the number of outlines in the set
int color
Definition: DXF_plotter.cpp:60
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
segment with non rounded ends
Definition: board_item.h:53
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
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
last value for this list
Definition: board_item.h:58
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
int NewOutline()
Creates a new empty polygon in the set and returns its index
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
SEG Segment(int aIndex)
Function Segment()
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...
VECTOR2I A
Definition: seg.h:47
double DECIDEG2RAD(double deg)
Definition: trigo.h:221
wxPoint GetPosition() const override
Definition: footprint.h:200
ring
Definition: board_item.h:55
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
void CacheTriangulation(bool aPartition=true)
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.
Bezier Curve.
Definition: board_item.h:57
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:100
VECTOR2I B
Definition: seg.h:48

References SEG::A, SHAPE_POLY_SET::Append(), SEG::B, SHAPE_POLY_SET::CacheTriangulation(), color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawCurve(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawSegment(), PCB_SHAPE::GetAngle(), PCB_SHAPE::GetArcAngleStart(), PCB_SHAPE::GetBezControl1(), PCB_SHAPE::GetBezControl2(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), PCB_SHAPE::GetEnd(), BOARD_ITEM::GetLayer(), getLineThickness(), FOOTPRINT::GetOrientationRadians(), PCB_SHAPE::GetParentFootprint(), FOOTPRINT::GetPosition(), PCB_SHAPE::GetRadius(), PCB_SHAPE::GetRectCorners(), PCB_SHAPE::GetShape(), PCB_SHAPE::GetStart(), PCB_SHAPE::GetWidth(), PCB_SHAPE::IsFilled(), KIGFX::GAL::IsOpenGlEngine(), 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::Outline(), 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(), SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), 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 PCB_TEXT aText,
int  aLayer 
)
protected

Definition at line 1313 of file pcb_painter.cpp.

1314 {
1315  wxString shownText( aText->GetShownText() );
1316 
1317  if( shownText.Length() == 0 )
1318  return;
1319 
1320  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1321  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1322 
1324  {
1325  // Outline mode
1327  }
1328  else
1329  {
1330  // Filled mode
1332  }
1333 
1335  m_gal->SetIsFill( false );
1336  m_gal->SetIsStroke( true );
1337  m_gal->SetTextAttributes( aText );
1338  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1339 }
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:60
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:109
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.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:52
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
double GetTextAngleRadians() const
Definition: eda_text.h:183
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:254
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.
Definition: board_item.h:185
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References color, KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_TEXT::GetEffectiveTextPenWidth(), BOARD_ITEM::GetLayer(), getLineThickness(), PCB_TEXT::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(), and KIGFX::GAL::StrokeText().

◆ draw() [7/13]

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

Definition at line 1342 of file pcb_painter.cpp.

1343 {
1344  wxString shownText( aText->GetShownText() );
1345 
1346  if( shownText.Length() == 0 )
1347  return;
1348 
1349  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1350  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1351 
1353  {
1354  // Outline mode
1356  }
1357  else
1358  {
1359  // Filled mode
1361  }
1362 
1364  m_gal->SetIsFill( false );
1365  m_gal->SetIsStroke( true );
1366  m_gal->SetTextAttributes( aText );
1367  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1368 
1369  // Draw the umbilical line
1370  if( aText->IsSelected() )
1371  {
1373  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1374  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1375  }
1376 }
bool IsSelected() const
Definition: eda_item.h:191
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:60
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
virtual wxPoint GetPosition() const
Definition: eda_item.h:325
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:109
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.
double GetDrawRotationRadians() const
Definition: fp_text.h:175
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 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:254
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:179
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:422
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References color, KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), FP_TEXT::GetDrawRotationRadians(), EDA_TEXT::GetEffectiveTextPenWidth(), getLineThickness(), BOARD_ITEM::GetParent(), EDA_ITEM::GetPosition(), FP_TEXT::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(), and KIGFX::GAL::StrokeText().

◆ draw() [8/13]

void PCB_PAINTER::draw ( const FOOTPRINT aFootprint,
int  aLayer 
)
protected

Definition at line 1379 of file pcb_painter.cpp.

1380 {
1381  if( aLayer == LAYER_ANCHOR )
1382  {
1383  const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
1384 
1385  // Keep the size and width constant, not related to the scale because the anchor
1386  // is just a marker on screen
1387  double anchorSize = 5.0 / m_gal->GetWorldScale(); // 5 pixels size
1388  double anchorThickness = 1.0 / m_gal->GetWorldScale(); // 1 pixels width
1389 
1390  // Draw anchor
1391  m_gal->SetIsFill( false );
1392  m_gal->SetIsStroke( true );
1394  m_gal->SetLineWidth( anchorThickness );
1395 
1396  VECTOR2D center = aFootprint->GetPosition();
1397  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1398  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1399 
1400 #if 0 // For debug purpose only: draw the footing bounding box
1401  double bboxThickness = 1.0 / m_gal->GetWorldScale();
1402  m_gal->SetLineWidth( bboxThickness );
1403  EDA_RECT rect = aFootprint->GetBoundingBoxBase();
1404  m_gal->DrawRectangle( VECTOR2D( rect.GetOrigin() ), VECTOR2D( rect.GetEnd() ) );
1405 #endif
1406  }
1407 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
anchor of items having an anchor point (texts, footprints)
int color
Definition: DXF_plotter.cpp:60
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
const wxPoint GetEnd() const
Definition: eda_rect.h:116
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
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
wxPoint GetPosition() const override
Definition: footprint.h:200
double GetWorldScale() const
Get the world scale.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
EDA_RECT GetBoundingBoxBase() const
Returns the last calculated bounding box of the footprint (does not recalculate it).
Definition: footprint.h:161
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References color, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), FOOTPRINT::GetBoundingBoxBase(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_RECT::GetEnd(), EDA_RECT::GetOrigin(), FOOTPRINT::GetPosition(), KIGFX::GAL::GetWorldScale(), LAYER_ANCHOR, KIGFX::PAINTER::m_gal, m_pcbSettings, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [9/13]

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

Definition at line 1410 of file pcb_painter.cpp.

1411 {
1412  if( aLayer == LAYER_ANCHOR )
1413  {
1414  const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
1415 
1416  EDA_RECT bbox = aGroup->GetBoundingBox();
1419  wxPoint topLeft = bbox.GetPosition();
1420  wxPoint width = wxPoint( bbox.GetWidth(), 0 );
1421  wxPoint height = wxPoint( 0, bbox.GetHeight() );
1422 
1423  m_gal->DrawLine( topLeft, topLeft + width );
1424  m_gal->DrawLine( topLeft + width, topLeft + width + height );
1425  m_gal->DrawLine( topLeft + width + height, topLeft + height );
1426  m_gal->DrawLine( topLeft + height, topLeft );
1427 
1428  wxString name = aGroup->GetName();
1429 
1430  int ptSize = 12;
1431  int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
1432  int unscaledSize = Mils2iu( ptSize );
1433 
1434  // Scale by zoom a bit, but not too much
1435  int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
1436  int penWidth = textSize / 10;
1437  wxPoint textOffset = wxPoint( width.x / 2, - KiROUND( textSize * 0.5 ) );
1438  wxPoint titleHeight = wxPoint( 0, KiROUND( textSize * 2.0 ) );
1439 
1440  if( !name.IsEmpty() && (int) aGroup->GetName().Length() * textSize < bbox.GetWidth() )
1441  {
1442  m_gal->DrawLine( topLeft, topLeft - titleHeight );
1443  m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
1444  m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
1445 
1446  m_gal->SetFontBold( false );
1447  m_gal->SetFontItalic( true );
1448  m_gal->SetFontUnderlined( false );
1452  m_gal->SetIsFill( false );
1453  m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) );
1454  m_gal->SetLineWidth( penWidth );
1455  m_gal->StrokeText( aGroup->GetName(), topLeft + textOffset, 0.0 );
1456  }
1457  }
1458 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
anchor of items having an anchor point (texts, footprints)
bool IsFlippedX() const
Return true if flip flag for the X axis is set.
int color
Definition: DXF_plotter.cpp:60
int GetWidth() const
Definition: eda_rect.h:119
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
const EDA_RECT GetBoundingBox() const override
Definition: pcb_group.cpp:180
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxString GetName() const
Definition: pcb_group.h:65
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxPoint GetPosition() const
Definition: eda_rect.h:115
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 SetFontItalic(bool aItalic)
Set italic property of current font.
int GetHeight() const
Definition: eda_rect.h:120
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
void SetFontUnderlined(bool aUnderlined)
const char * name
Definition: DXF_plotter.cpp:59
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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References color, KIGFX::GAL::DrawLine(), PCB_GROUP::GetBoundingBox(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_RECT::GetHeight(), PCB_GROUP::GetName(), EDA_RECT::GetPosition(), MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), EDA_RECT::GetWidth(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, KIGFX::GAL::IsFlippedX(), KiROUND(), LAYER_ANCHOR, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, name, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), KIGFX::GAL::StrokeText(), and VECTOR2< T >::x.

◆ draw() [10/13]

void PCB_PAINTER::draw ( const ZONE 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 1461 of file pcb_painter.cpp.

1462 {
1469  wxASSERT( IsZoneLayer( aLayer ) );
1470  PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer - LAYER_ZONE_START );
1471 
1472  if( !aZone->IsOnLayer( layer ) )
1473  return;
1474 
1475  COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
1476  std::deque<VECTOR2D> corners;
1478 
1479  // Draw the outline
1480  const SHAPE_POLY_SET* outline = aZone->Outline();
1481 
1482  if( m_pcbSettings.m_zoneOutlines && outline && outline->OutlineCount() > 0 )
1483  {
1485  m_gal->SetIsFill( false );
1486  m_gal->SetIsStroke( true );
1488 
1489  // Draw each contour (main contour and holes)
1490 
1491  /* This line:
1492  * m_gal->DrawPolygon( *outline );
1493  * should be enough, but currently does not work to draw holes contours in a complex polygon
1494  * so each contour is draw as a simple polygon
1495  */
1496 
1497  // Draw the main contour
1498  m_gal->DrawPolyline( outline->COutline( 0 ) );
1499 
1500  // Draw holes
1501  int holes_count = outline->HoleCount( 0 );
1502 
1503  for( int ii = 0; ii < holes_count; ++ii )
1504  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1505 
1506  // Draw hatch lines
1507  for( const SEG& hatchLine : aZone->GetHatchLines() )
1508  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1509  }
1510 
1511  // Draw the filling
1512  if( displayMode != ZONE_DISPLAY_MODE::HIDE_FILLED )
1513  {
1514  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer );
1515 
1516  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1517  return;
1518 
1519  // Set up drawing options
1520  int outline_thickness = 0;
1521 
1522  if( aZone->GetFilledPolysUseThickness( layer ) )
1523  outline_thickness = aZone->GetMinThickness();
1524 
1526  m_gal->SetFillColor( color );
1527  m_gal->SetLineWidth( outline_thickness );
1528 
1529  if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
1530  {
1531  m_gal->SetIsFill( true );
1532  m_gal->SetIsStroke( outline_thickness > 0 );
1533  }
1534  else if( displayMode == ZONE_DISPLAY_MODE::SHOW_OUTLINED )
1535  {
1536  m_gal->SetIsFill( false );
1537  m_gal->SetIsStroke( true );
1538  }
1539 
1540  m_gal->DrawPolygon( polySet );
1541  }
1542 }
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
SHAPE_POLY_SET * Outline()
Definition: zone.h:318
int color
Definition: DXF_plotter.cpp:60
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: zone.cpp:313
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: zone.h:647
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Only the zone outline is shown.
PCB_LAYER_ID
A quick note on layer IDs:
int GetMinThickness() const
Definition: zone.h:242
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:815
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
bool IsZoneLayer(LAYER_NUM aLayer)
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...
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.
bool GetFilledPolysUseThickness() const
Definition: zone.h:704
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

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::GetFilledPolysList(), ZONE::GetFilledPolysUseThickness(), ZONE::GetHatchLines(), ZONE::GetMinThickness(), HIDE_FILLED, SHAPE_POLY_SET::HoleCount(), ZONE::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::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_BASE aDimension,
int  aLayer 
)
protected

Definition at line 1545 of file pcb_painter.cpp.

1546 {
1547  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1548 
1549  m_gal->SetStrokeColor( strokeColor );
1550  m_gal->SetIsFill( false );
1551  m_gal->SetIsStroke( true );
1552 
1554  {
1555  // Outline mode
1557  }
1558  else
1559  {
1560  // Filled mode
1561  m_gal->SetLineWidth( getLineThickness( aDimension->GetLineThickness() ) );
1562  }
1563 
1564  // Draw dimension shapes
1565  // TODO(JE) lift this out
1566  for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
1567  {
1568  switch( shape->Type() )
1569  {
1570  case SH_SEGMENT:
1571  {
1572  const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
1573  m_gal->DrawLine( seg.A, seg.B );
1574  break;
1575  }
1576 
1577  case SH_CIRCLE:
1578  {
1579  int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
1580  m_gal->DrawCircle( shape->Centre(), radius );
1581  break;
1582  }
1583 
1584  default:
1585  break;
1586  }
1587  }
1588  // Draw text
1589  PCB_TEXT& text = aDimension->Text();
1590  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1591 
1593  {
1594  // Outline mode
1596  }
1597  else
1598  {
1599  // Filled mode
1601  }
1602 
1603  m_gal->SetTextAttributes( &text );
1604  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1605 }
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:281
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
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:109
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() const
Definition: dimension.h:187
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:52
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
Definition: dimension.h:215
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.
PCB_TEXT & Text()
Definition: dimension.h:209
line chain (polyline)
Definition: shape.h:46
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:183
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...
VECTOR2I A
Definition: seg.h:47
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
axis-aligned rectangle
Definition: shape.h:44
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
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_BASE::GetLineThickness(), getLineThickness(), DIMENSION_BASE::GetShapes(), PCB_TEXT::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(), and DIMENSION_BASE::Text().

◆ draw() [12/13]

void PCB_PAINTER::draw ( const PCB_TARGET aTarget)
protected

Definition at line 1608 of file pcb_painter.cpp.

1609 {
1610  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1611  VECTOR2D position( aTarget->GetPosition() );
1612  double size, radius;
1613 
1614  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1615  m_gal->SetStrokeColor( strokeColor );
1616  m_gal->SetIsFill( false );
1617  m_gal->SetIsStroke( true );
1618 
1619  m_gal->Save();
1620  m_gal->Translate( position );
1621 
1622  if( aTarget->GetShape() )
1623  {
1624  // shape x
1625  m_gal->Rotate( M_PI / 4.0 );
1626  size = 2.0 * aTarget->GetSize() / 3.0;
1627  radius = aTarget->GetSize() / 2.0;
1628  }
1629  else
1630  {
1631  // shape +
1632  size = aTarget->GetSize() / 2.0;
1633  radius = aTarget->GetSize() / 3.0;
1634  }
1635 
1636  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1637  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1638  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1639 
1640  m_gal->Restore();
1641 }
int GetSize() const
Definition: pcb_target.h:67
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
wxPoint GetPosition() const override
Definition: pcb_target.h:61
int GetWidth() const
Definition: pcb_target.h:70
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
Definition: pcb_target.h:64
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.
Definition: board_item.h:185
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

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 PCB_MARKER aMarker,
int  aLayer 
)
protected

Definition at line 1644 of file pcb_painter.cpp.

1645 {
1646  bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
1647 
1648  // Don't paint shadows for invisible markers.
1649  // It would be nice to do this through layer dependencies but we can't do an "or" there today
1650  if( isShadow && aMarker->GetBoard() &&
1651  !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
1652  return;
1653 
1654  SHAPE_LINE_CHAIN polygon;
1655  aMarker->ShapeToPolygon( polygon );
1656 
1657 
1658 
1660  : aMarker->GetColorLayer() );
1661 
1662  m_gal->Save();
1663  m_gal->Translate( aMarker->GetPosition() );
1664 
1665  if( isShadow )
1666  {
1668  m_gal->SetIsStroke( true );
1669  m_gal->SetLineWidth( aMarker->MarkerScale() );
1670  }
1671  else
1672  {
1673  m_gal->SetFillColor( color );
1674  m_gal->SetIsFill( true );
1675  }
1676 
1677  m_gal->DrawPolygon( polygon );
1678  m_gal->Restore();
1679 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
int color
Definition: DXF_plotter.cpp:60
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:109
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
GAL_LAYER_ID GetColorLayer() const
Definition: pcb_marker.cpp:182
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:497
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:81
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.
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.
wxPoint GetPosition() const override
Definition: pcb_marker.h:67
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

References color, KIGFX::GAL::DrawPolygon(), BOARD_ITEM::GetBoard(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), PCB_MARKER::GetColorLayer(), PCB_MARKER::GetPosition(), BOARD::IsElementVisible(), LAYER_MARKER_SHADOWS, KIGFX::PAINTER::m_gal, m_pcbSettings, MARKER_BASE::MarkerScale(), KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), MARKER_BASE::ShapeToPolygon(), and KIGFX::GAL::Translate().

◆ getDrillShape()

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

Return drill shape of a pad.

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 392 of file pcb_painter.cpp.

393 {
394  return aPad->GetDrillShape();
395 }
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:339

References PAD::GetDrillShape().

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

◆ getDrillSize() [1/2]

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

Return drill size for a pad (internal units).

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 398 of file pcb_painter.cpp.

399 {
400  return VECTOR2D( aPad->GetDrillSize() );
401 }
const wxSize & GetDrillSize() const
Definition: pad.h:236
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593

References 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 404 of file pcb_painter.cpp.

405 {
406  return aVia->GetDrillValue();
407 }
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: track.cpp:170

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 380 of file pcb_painter.cpp.

381 {
382  // if items have 0 thickness, draw them with the outline
383  // width, otherwise respect the set value (which, no matter
384  // how small will produce something)
385  if( aActualThickness == 0 )
387 
388  return aActualThickness;
389 }
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 77 of file painter.h.

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

References KIGFX::PAINTER::m_gal.

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 112 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: