KiCad PCB EDA Suite
KIGFX::PCB_PRINT_PAINTER Class Reference

Special flavor of PCB_PAINTER that contains modifications to handle printing options. More...

#include <pcbnew_printout.h>

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

Public Member Functions

 PCB_PRINT_PAINTER (GAL *aGal)
 
void SetDrillMarks (bool aRealSize, unsigned int aSize=0)
 Set drill marks visibility and options. More...
 
virtual void ApplySettings (const RENDER_SETTINGS *aSettings) override
 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
 Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item. More...
 
void SetGAL (GAL *aGal)
 Changes Graphics Abstraction Layer used for drawing items for a new one. More...
 

Protected Member Functions

int getDrillShape (const PAD *aPad) const override
 Return drill shape of a pad. More...
 
VECTOR2D getDrillSize (const PAD *aPad) const override
 Return drill size for a pad (internal units). More...
 
int getDrillSize (const VIA *aVia) const override
 Return drill diameter for a via (internal units). More...
 
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...
 

Protected Attributes

bool m_drillMarkReal
 

Flag deciding whether use the actual hole size or user-specified size for drill marks

More...
 
int m_drillMarkSize
 

User-specified size for drill marks (expressed in internal units)

More...
 
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

Special flavor of PCB_PAINTER that contains modifications to handle printing options.

Definition at line 84 of file pcbnew_printout.h.

Constructor & Destructor Documentation

◆ PCB_PRINT_PAINTER()

KIGFX::PCB_PRINT_PAINTER::PCB_PRINT_PAINTER ( GAL aGal)

Definition at line 282 of file pcbnew_printout.cpp.

282  :
283  PCB_PAINTER( aGal ),
284  m_drillMarkReal( false ),
285  m_drillMarkSize( 0 )
286 {
288 }
void EnableZoneOutlines(bool aEnabled)
Turns on/off drawing outline and hatched lines for zones.
Definition: pcb_painter.h:135
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks
int m_drillMarkSize
User-specified size for drill marks (expressed in internal units)
PCB_PAINTER(GAL *aGal)

References KIGFX::PCB_RENDER_SETTINGS::EnableZoneOutlines(), and KIGFX::PCB_PAINTER::m_pcbSettings.

Member Function Documentation

◆ ApplySettings()

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

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 245 of file pcb_painter.h.

246  {
247  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
248  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300

References KIGFX::PCB_PAINTER::m_pcbSettings.

◆ Draw()

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

Takes an instance of VIEW_ITEM and passes it to a function that knows 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 424 of file pcb_painter.cpp.

425 {
426  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
427 
428  if( !item )
429  return false;
430 
431  // the "cast" applied in here clarifies which overloaded draw() is called
432  switch( item->Type() )
433  {
434  case PCB_TRACE_T:
435  draw( static_cast<const TRACK*>( item ), aLayer );
436  break;
437 
438  case PCB_ARC_T:
439  draw( static_cast<const ARC*>( item ), aLayer );
440  break;
441 
442  case PCB_VIA_T:
443  draw( static_cast<const VIA*>( item ), aLayer );
444  break;
445 
446  case PCB_PAD_T:
447  draw( static_cast<const PAD*>( item ), aLayer );
448  break;
449 
450  case PCB_SHAPE_T:
451  case PCB_FP_SHAPE_T:
452  draw( static_cast<const PCB_SHAPE*>( item ), aLayer );
453  break;
454 
455  case PCB_TEXT_T:
456  draw( static_cast<const PCB_TEXT*>( item ), aLayer );
457  break;
458 
459  case PCB_FP_TEXT_T:
460  draw( static_cast<const FP_TEXT*>( item ), aLayer );
461  break;
462 
463  case PCB_FOOTPRINT_T:
464  draw( static_cast<const FOOTPRINT*>( item ), aLayer );
465  break;
466 
467  case PCB_GROUP_T:
468  draw( static_cast<const PCB_GROUP*>( item ), aLayer );
469  break;
470 
471  case PCB_ZONE_T:
472  draw( static_cast<const ZONE*>( item ), aLayer );
473  break;
474 
475  case PCB_FP_ZONE_T:
476  draw( static_cast<const ZONE*>( item ), aLayer );
477  break;
478 
479  case PCB_DIM_ALIGNED_T:
480  case PCB_DIM_CENTER_T:
482  case PCB_DIM_LEADER_T:
483  draw( static_cast<const DIMENSION_BASE*>( item ), aLayer );
484  break;
485 
486  case PCB_TARGET_T:
487  draw( static_cast<const PCB_TARGET*>( item ) );
488  break;
489 
490  case PCB_MARKER_T:
491  draw( static_cast<const PCB_MARKER*>( item ), aLayer );
492  break;
493 
494  default:
495  // Painter does not know how to draw the object
496  return false;
497  }
498 
499  return true;
500 }
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:100
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:102
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class ZONE, a copper pour area
Definition: typeinfo.h:105
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:98
class ZONE, managed by a footprint
Definition: typeinfo.h:94
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:103
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void draw(const TRACK *aTrack, int aLayer)
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:161

References KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 503 of file pcb_painter.cpp.

504 {
505  VECTOR2D start( aTrack->GetStart() );
506  VECTOR2D end( aTrack->GetEnd() );
507  int width = aTrack->GetWidth();
508 
510  {
511  // If there is a net name - display it on the track
512  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
513  {
514  VECTOR2D line = ( end - start );
515  double length = line.EuclideanNorm();
516 
517  // Check if the track is long enough to have a netname displayed
518  if( length < 10 * width )
519  return;
520 
521  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
522  VECTOR2D textPosition = start + line / 2.0; // center of the track
523 
524  double textOrientation;
525 
526  if( end.y == start.y ) // horizontal
527  textOrientation = 0;
528  else if( end.x == start.x ) // vertical
529  textOrientation = M_PI / 2;
530  else
531  textOrientation = -atan( line.y / line.x );
532 
533  double textSize = width;
534 
535  m_gal->SetIsStroke( true );
536  m_gal->SetIsFill( false );
537  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aTrack, aLayer ) );
538  m_gal->SetLineWidth( width / 10.0 );
539  m_gal->SetFontBold( false );
540  m_gal->SetFontItalic( false );
541  m_gal->SetFontUnderlined( false );
542  m_gal->SetTextMirrored( false );
543  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
546  m_gal->BitmapText( netName, textPosition, textOrientation );
547  }
548  }
549  else if( IsCopperLayer( aLayer ) )
550  {
551  // Draw a regular track
552  COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
553  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
556  m_gal->SetIsStroke( outline_mode );
557  m_gal->SetIsFill( not outline_mode );
559 
560  m_gal->DrawSegment( start, end, width );
561 
562  // Clearance lines
563  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
564 
565  if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags )
566  {
567  int clearance = aTrack->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
568 
570  m_gal->SetIsFill( false );
571  m_gal->SetIsStroke( true );
573  m_gal->DrawSegment( start, end, width + clearance * 2 );
574  }
575  }
576 }
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]
Definition: pcb_painter.h:193
int color
Definition: DXF_plotter.cpp:60
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:108
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:629
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.
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
int GetWidth() const
Definition: track.h:110
void SetFontUnderlined(bool aUnderlined)
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:150
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:300
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:382
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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_clearanceDisplayFlags, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnTracks, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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 KIGFX::PCB_PAINTER::Draw(), and KIGFX::PCB_PAINTER::draw().

◆ draw() [2/13]

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

Definition at line 579 of file pcb_painter.cpp.

580 {
581  VECTOR2D center( aArc->GetCenter() );
582  int width = aArc->GetWidth();
583 
584  if( IsCopperLayer( aLayer ) )
585  {
586  // Draw a regular track
587  COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
588  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
591  m_gal->SetIsStroke( outline_mode );
592  m_gal->SetIsFill( not outline_mode );
594 
595  auto radius = aArc->GetRadius();
596  auto start_angle = DECIDEG2RAD( aArc->GetArcAngleStart() );
597  auto angle = DECIDEG2RAD( aArc->GetAngle() );
598 
599  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width );
600 
601  // Clearance lines
602  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
603 
604  if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags )
605  {
606  int clearance = aArc->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
607 
609  m_gal->SetIsFill( false );
610  m_gal->SetIsStroke( true );
612 
613  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
614  width + clearance * 2 );
615  }
616  }
617 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: track.h:302
bool m_sketchMode[GAL_LAYER_ID_END]
Definition: pcb_painter.h:193
int color
Definition: DXF_plotter.cpp:60
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:108
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
double GetRadius() const
Definition: track.cpp:894
double GetAngle() const
Definition: track.cpp:900
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetWidth() const
Definition: track.h:110
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:912
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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_clearanceDisplayFlags, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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 
)
protectedinherited

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

621 {
622  VECTOR2D center( aVia->GetStart() );
623  double radius = 0.0;
624 
625  // Draw description layer
626  if( IsNetnameLayer( aLayer ) )
627  {
628  VECTOR2D position( center );
629 
630  // Is anything that we can display enabled?
631  if( !m_pcbSettings.m_netNamesOnVias || aVia->GetNetname().empty() )
632  return;
633 
634  // We won't get CLEAR from GetColor below for a non-through via on an inactive layer in
635  // high contrast mode because LAYER_VIAS_NETNAMES will always be part of the high-contrast
636  // set. So we do another check here to prevent drawing netnames for these vias.
638  {
639  bool draw = false;
640 
641  for( unsigned int layer : m_pcbSettings.GetHighContrastLayers() )
642  {
643  if( aVia->FlashLayer( static_cast<PCB_LAYER_ID>( layer ), true ) )
644  {
645  draw = true;
646  break;
647  }
648  }
649 
650  if( !draw )
651  return;
652  }
653 
654  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
655  double size = aVia->GetWidth();
656 
657  // Font size limits
658  if( size > maxSize )
659  size = maxSize;
660 
661  m_gal->Save();
662  m_gal->Translate( position );
663 
664  // Default font settings
667 
668  // Set the text position to the pad shape position (the pad position is not the best place)
669  VECTOR2D textpos( 0.0, 0.0 );
670 
671  wxString netname = UnescapeString( aVia->GetShortNetname() );
672  // calculate the size of net name text:
673  double tsize = 1.5 * size / netname.Length();
674  tsize = std::min( tsize, size );
675  // Use a smaller text size to handle interline, pen size..
676  tsize *= 0.7;
677  VECTOR2D namesize( tsize, tsize );
678 
679  m_gal->SetGlyphSize( namesize );
680  m_gal->SetLineWidth( namesize.x / 12.0 );
681  m_gal->BitmapText( netname, textpos, 0.0 );
682 
683  m_gal->Restore();
684 
685  return;
686  }
687  else if( aLayer == LAYER_VIAS_HOLES )
688  {
689  radius = getDrillSize( aVia ) / 2.0;
690  }
691  else if( ( aLayer == LAYER_VIA_THROUGH && aVia->GetViaType() == VIATYPE::THROUGH )
692  || ( aLayer == LAYER_VIA_BBLIND && aVia->GetViaType() == VIATYPE::BLIND_BURIED )
693  || ( aLayer == LAYER_VIA_MICROVIA && aVia->GetViaType() == VIATYPE::MICROVIA ) )
694  {
695  radius = aVia->GetWidth() / 2.0;
696  }
697  else
698  {
699  return;
700  }
701 
704  if( IsCopperLayer( aLayer ) && !aVia->FlashLayer( aLayer, true ) )
705  radius = getDrillSize( aVia ) / 2.0 ;
706 
707  bool sketchMode = false;
708  COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
709 
710  if( color == COLOR4D::CLEAR )
711  return;
712 
713  switch( aVia->GetViaType() )
714  {
718  default: wxASSERT( false ); break;
719  }
720 
721  m_gal->SetIsFill( !sketchMode );
722  m_gal->SetIsStroke( sketchMode );
723 
724  if( sketchMode )
725  {
726  // Outline mode
729  }
730  else
731  {
732  // Filled mode
734  }
735 
736  if( ( aVia->GetViaType() == VIATYPE::BLIND_BURIED || aVia->GetViaType() == VIATYPE::MICROVIA )
737  && aLayer != LAYER_VIAS_HOLES
739  {
740  // Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
741  // top and bottom layers
742  PCB_LAYER_ID layerTop, layerBottom;
743  aVia->LayerPair( &layerTop, &layerBottom );
744 
745  if( !sketchMode )
746  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
747 
748  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
749  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
750 
751  if( sketchMode )
752  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerTop ) );
753  else
754  m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
755 
756  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
757 
758  if( sketchMode )
759  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
760  else
761  m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
762 
763  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
764  }
765  else
766  {
767  // Draw the outer circles of normal vias and the holes for all vias
768  m_gal->DrawCircle( center, radius );
769  }
770 
771  // Clearance lines
772  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
773 
774  if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags
775  && aLayer != LAYER_VIAS_HOLES )
776  {
777  PCB_LAYER_ID activeLayer = m_pcbSettings.GetActiveLayer();
778 
779  if( !aVia->FlashLayer( activeLayer ) )
780  {
781  radius = getDrillSize( aVia ) / 2.0 +
783  }
784 
786  m_gal->SetIsFill( false );
787  m_gal->SetIsStroke( true );
789  m_gal->DrawCircle( center, radius + aVia->GetOwnClearance( activeLayer ) );
790  }
791 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
const std::set< unsigned int > GetHighContrastLayers() const
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:423
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]
Definition: pcb_painter.h:193
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:574
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:108
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual VECTOR2D getDrillSize(const PAD *aPad) const
Return drill size for a pad (internal units).
bool FlashLayer(int aLayer, bool aIncludeZones=false) const
Checks to see whether the via should have a pad on the specific layer.
Definition: track.cpp:482
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:191
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:171
static const COLOR4D CLEAR
Definition: color4d.h:369
to draw usual through hole vias
virtual BOARD * GetBoard() const
Return 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
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:150
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:374
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 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 IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References KIGFX::GAL::BitmapText(), BLIND_BURIED, KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_VIAS, KIGFX::COLOR4D::CLEAR, color, KIGFX::PCB_PAINTER::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(), KIGFX::PCB_PAINTER::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(), LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, VIA::LayerPair(), KIGFX::PCB_RENDER_SETTINGS::m_clearanceDisplayFlags, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnVias, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 794 of file pcb_painter.cpp.

795 {
796  // Draw description layer
797  if( IsNetnameLayer( aLayer ) )
798  {
799  // Is anything that we can display enabled?
801  {
802  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
803  EDA_RECT padBBox = aPad->GetBoundingBox();
804  VECTOR2D position = padBBox.Centre();
805  VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
806 
807  if( aPad->GetShape() != PAD_SHAPE_CUSTOM )
808  {
809  // Don't allow a 45ยบ rotation to bloat a pad's bounding box unnecessarily
810  double limit = std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1;
811 
812  if( padsize.x > limit && padsize.y > limit )
813  {
814  padsize.x = limit;
815  padsize.y = limit;
816  }
817  }
818 
819  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
820  double size = padsize.y;
821 
822  m_gal->Save();
823  m_gal->Translate( position );
824 
825  // Keep the size ratio for the font, but make it smaller
826  if( padsize.x < padsize.y )
827  {
828  m_gal->Rotate( DECIDEG2RAD( -900.0 ) );
829  size = padsize.x;
830  std::swap( padsize.x, padsize.y );
831  }
832 
833  // Font size limits
834  if( size > maxSize )
835  size = maxSize;
836 
837  // Default font settings
840  m_gal->SetFontBold( false );
841  m_gal->SetFontItalic( false );
842  m_gal->SetFontUnderlined( false );
843  m_gal->SetTextMirrored( false );
844  m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) );
845  m_gal->SetIsStroke( true );
846  m_gal->SetIsFill( false );
847 
848  // We have already translated the GAL to be centered at the center of the pad's
849  // bounding box
850  VECTOR2D textpos( 0.0, 0.0 );
851 
852  // Divide the space, to display both pad numbers and netnames and set the Y text
853  // position to display 2 lines
854  if( displayNetname && m_pcbSettings.m_padNumbers )
855  {
856  size = size / 2.0;
857  textpos.y = size / 2.0;
858  }
859 
860  if( displayNetname )
861  {
862  wxString netname = UnescapeString( aPad->GetShortNetname() );
863 
864  if( netname.StartsWith( "no_connect_" ) )
865  netname = "x";
866 
867  // calculate the size of net name text:
868  double tsize = 1.5 * padsize.x / netname.Length();
869  tsize = std::min( tsize, size );
870  // Use a smaller text size to handle interline, pen size..
871  tsize *= 0.7;
872  VECTOR2D namesize( tsize, tsize );
873 
874  m_gal->SetGlyphSize( namesize );
875  m_gal->SetLineWidth( namesize.x / 12.0 );
876  m_gal->BitmapText( netname, textpos, 0.0 );
877  }
878 
880  {
881  const wxString& padName = aPad->GetName();
882  textpos.y = -textpos.y;
883  double tsize = 1.5 * padsize.x / padName.Length();
884  tsize = std::min( tsize, size );
885  // Use a smaller text size to handle interline, pen size..
886  tsize *= 0.7;
887  tsize = std::min( tsize, size );
888  VECTOR2D numsize( tsize, tsize );
889 
890  m_gal->SetGlyphSize( numsize );
891  m_gal->SetLineWidth( numsize.x / 12.0 );
892  m_gal->BitmapText( padName, textpos, 0.0 );
893  }
894 
895  m_gal->Restore();
896  }
897  return;
898  }
899 
900  // Pad drawing
902  COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
903 
905  {
906  // Outline mode
907  m_gal->SetIsFill( false );
908  m_gal->SetIsStroke( true );
911  }
912  else
913  {
914  // Filled mode
915  m_gal->SetIsFill( true );
916  m_gal->SetIsStroke( false );
918  }
919 
920  // Choose drawing settings depending on if we are drawing a pad itself or a hole
921  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
922  {
923  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
924 
925  if( seg->GetSeg().A == seg->GetSeg().B ) // Circular hole
926  m_gal->DrawCircle( seg->GetSeg().A, getDrillSize( aPad ).x / 2 );
927  else
928  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() );
929  }
930  else if( aLayer == LAYER_PADS_TH
931  && aPad->GetShape() != PAD_SHAPE_CUSTOM
932  && aPad->GetSizeX() <= aPad->GetDrillSizeX()
933  && aPad->GetSizeY() <= aPad->GetDrillSizeY() )
934  {
935  // no annular ring to draw
936  }
937  else
938  {
939  wxSize pad_size = aPad->GetSize();
940  wxSize margin;
941 
942  switch( aLayer )
943  {
944  case F_Mask:
945  case B_Mask:
946  margin.x = margin.y = aPad->GetSolderMaskMargin();
947  break;
948 
949  case F_Paste:
950  case B_Paste:
951  margin = aPad->GetSolderPasteMargin();
952  break;
953 
954  default:
955  margin.x = margin.y = 0;
956  break;
957  }
958 
959  std::unique_ptr<PAD> dummyPad;
960  std::shared_ptr<SHAPE_COMPOUND> shapes;
961  bool simpleShapes = true;
962 
963  if( margin.x != margin.y && aPad->GetShape() != PAD_SHAPE_CUSTOM )
964  {
965  // Our algorithms below (polygon inflation in particular) can't handle differential
966  // inflation along separate axes. So for those cases we build a dummy pad instead,
967  // and inflate it.
968 
969  // Margin is added to both sides. If the total margin is larger than the pad
970  // then don't display this layer
971  if( pad_size.x + 2 * margin.x <= 0 || pad_size.y + 2 * margin.y <= 0 )
972  return;
973 
974  dummyPad.reset( static_cast<PAD*>( aPad->Duplicate() ) );
975  dummyPad->SetSize( pad_size + margin + margin );
976  shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( dummyPad->GetEffectiveShape() );
977  margin.x = margin.y = 0;
978  }
979  else
980  {
981  shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
982  }
983 
984  for( SHAPE* shape : shapes->Shapes() )
985  {
986  // Drawing components of compound shapes in outline mode produces a mess.
988  simpleShapes = false;
989 
990  if( !simpleShapes )
991  break;
992 
993  switch( shape->Type() )
994  {
995  case SH_SEGMENT:
996  case SH_CIRCLE:
997  case SH_RECT:
998  case SH_SIMPLE:
999  // OK so far
1000  break;
1001 
1002  default:
1003  // Not OK
1004  simpleShapes = false;
1005  break;
1006  }
1007  }
1008 
1009  if( simpleShapes )
1010  {
1011  for( SHAPE* shape : shapes->Shapes() )
1012  {
1013  switch( shape->Type() )
1014  {
1015  case SH_SEGMENT:
1016  {
1017  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape;
1018  int effectiveWidth = seg->GetWidth() + 2 * margin.x;
1019 
1020  if( effectiveWidth > 0 )
1021  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, effectiveWidth );
1022  }
1023  break;
1024 
1025  case SH_CIRCLE:
1026  {
1027  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape;
1028  int effectiveRadius = circle->GetRadius() + margin.x;
1029 
1030  if( effectiveRadius > 0 )
1031  m_gal->DrawCircle( circle->GetCenter(), effectiveRadius );
1032  }
1033  break;
1034 
1035  case SH_RECT:
1036  {
1037  const SHAPE_RECT* r = (SHAPE_RECT*) shape;
1038  VECTOR2I position = r->GetPosition();
1039  VECTOR2I effectiveSize = r->GetSize() + margin;
1040 
1041  // At this point, if margin.x < 0 the actual rectangle size is
1042  // smaller than SHAPE_RECT r (the pad size was not modifed)
1043  if( margin.x < 0 )
1044  {
1045  if( effectiveSize.x > 0 && effectiveSize.y > 0 )
1046  m_gal->DrawRectangle( position - margin, position + effectiveSize );
1047  }
1048  else
1049  {
1050  m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
1051  }
1052 
1053  // Now add on a rounded margin (using segments) if the margin > 0
1054  if( margin.x > 0 )
1055  {
1056  m_gal->DrawSegment( position,
1057  position + VECTOR2I( r->GetWidth(), 0 ),
1058  margin.x * 2 );
1059  m_gal->DrawSegment( position + VECTOR2I( r->GetWidth(), 0 ),
1060  position + r->GetSize(),
1061  margin.x * 2 );
1062  m_gal->DrawSegment( position + r->GetSize(),
1063  position + VECTOR2I( 0, r->GetHeight() ),
1064  margin.x * 2 );
1065  m_gal->DrawSegment( position + VECTOR2I( 0, r->GetHeight() ),
1066  position,
1067  margin.x * 2 );
1068  }
1069  }
1070  break;
1071 
1072  case SH_SIMPLE:
1073  {
1074  const SHAPE_SIMPLE* poly = static_cast<const SHAPE_SIMPLE*>( shape );
1075  m_gal->DrawPolygon( poly->Vertices() );
1076 
1077  // Now add on a rounded margin (using segments) if the margin > 0
1078  if( margin.x > 0 )
1079  {
1080  for( size_t ii = 0; ii < poly->GetSegmentCount(); ++ii )
1081  {
1082  SEG seg = poly->GetSegment( ii );
1083  m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
1084  }
1085  }
1086  }
1087  break;
1088 
1089  default:
1090  // Better not get here; we already pre-flighted the shapes...
1091  break;
1092  }
1093  }
1094  }
1095  else
1096  {
1097  // This is expensive. Avoid if possible.
1098 
1099  SHAPE_POLY_SET polySet;
1100  aPad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x,
1101  bds.m_MaxError, ERROR_INSIDE );
1102  m_gal->DrawPolygon( polySet );
1103  }
1104  }
1105 
1106  // Draw clearance outlines
1107  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
1108 
1109  if( ( m_pcbSettings.m_clearanceDisplayFlags & clearanceFlags ) == clearanceFlags
1110  && ( aLayer == LAYER_PAD_FR || aLayer == LAYER_PAD_BK || aLayer == LAYER_PADS_TH ) )
1111  {
1112  /* Showing the clearance area is not obvious.
1113  * - A pad can be removed from some copper layers.
1114  * - For non copper layers, what is the clearance area?
1115  * So for copper layers, the clearance area is the shape if the pad is flashed on this
1116  * layer and the hole clearance area for other copper layers.
1117  * For other layers, use the pad shape, although one can use an other criteria,
1118  * depending on the non copper layer.
1119  */
1120  int activeLayer = m_pcbSettings.GetActiveLayer();
1121  bool flashActiveLayer = IsCopperLayer( activeLayer ) ?
1122  aPad->FlashLayer( activeLayer ) : true;
1123 
1124  if( flashActiveLayer || aPad->GetDrillSize().x )
1125  {
1127  m_gal->SetIsStroke( true );
1128  m_gal->SetIsFill( false );
1130 
1131  int clearance = aPad->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
1132 
1133  if( flashActiveLayer && clearance > 0 )
1134  {
1135  auto shape = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
1136 
1137  if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_SEGMENT )
1138  {
1139  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape->Shapes()[0];
1140  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
1141  seg->GetWidth() + 2 * clearance );
1142  }
1143  else if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_CIRCLE )
1144  {
1145  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape->Shapes()[0];
1146  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
1147  }
1148  else
1149  {
1150  SHAPE_POLY_SET polySet;
1151  aPad->TransformShapeWithClearanceToPolygon( polySet, ToLAYER_ID( aLayer ),
1152  clearance,
1153  bds.m_MaxError, ERROR_OUTSIDE );
1154  m_gal->DrawPolygon( polySet );
1155  }
1156  }
1157  else if( aPad->GetEffectiveHoleShape() && clearance > 0 )
1158  {
1159  clearance += bds.GetHolePlatingThickness();
1160 
1161  const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape();
1162  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
1163  seg->GetWidth() + 2 * clearance );
1164  }
1165  }
1166  }
1167 }
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:233
SHAPE_SIMPLE.
Definition: shape_simple.h:43
const int GetDrillSizeX() const
Definition: pad.h:241
int GetRadius() const
Definition: shape_circle.h:102
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]
Definition: pcb_painter.h:193
int color
Definition: DXF_plotter.cpp:60
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a SHAPE object representing the pad's hole.
Definition: pcbnew/pad.cpp:292
wxString GetNetname() const
Function GetNetname.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:574
PAD_SHAPE_T GetShape() const
Definition: pad.h:162
const VECTOR2I GetCenter() const
Definition: shape_circle.h:107
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
VECTOR2< int > VECTOR2I
Definition: vector2d.h:630
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:108
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:131
void SetFontBold(const bool aBold)
Set bold property of current font.
const wxSize & GetDrillSize() const
Definition: pad.h:239
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:629
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:191
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
const VECTOR2I & GetPosition() const
Function GetPosition()
Definition: shape_rect.h:121
const wxSize & GetSize() const
Definition: pad.h:229
virtual BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
const wxString & GetName() const
Definition: pad.h:130
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:524
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
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcbnew/pad.cpp:283
SHAPE.
Definition: shape.h:123
bool FlashLayer(int aLayer, bool aIncludeZones=false) const
Checks to see whether the pad should be flashed on the specific layer.
Definition: pcbnew/pad.cpp:198
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:703
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.
void SetFontUnderlined(bool aUnderlined)
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: pcbnew/pad.cpp:748
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
const int GetDrillSizeY() const
Definition: pad.h:243
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:150
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
Handle the component boundary box.
Definition: eda_rect.h:42
double DECIDEG2RAD(double deg)
Definition: trigo.h:221
const int GetSizeX() const
Definition: pad.h:231
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:60
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
virtual BOARD_ITEM * Duplicate() const
Create a copy of a of this BOARD_ITEM.
Definition: board_item.h:202
const int GetHeight() const
Function GetHeight()
Definition: shape_rect.h:151
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:141
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:96
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
axis-aligned rectangle
Definition: shape.h:44
Container for design settings for a BOARD object.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
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(), BOARD_ITEM::Duplicate(), 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(), KIGFX::PCB_PAINTER::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, IsCopperLayer(), IsNetnameLayer(), LAYER_NON_PLATEDHOLES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH, KIGFX::PCB_RENDER_SETTINGS::m_clearanceDisplayFlags, 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, KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 1170 of file pcb_painter.cpp.

1171 {
1172  const COLOR4D& color = m_pcbSettings.GetColor( aShape, aShape->GetLayer() );
1173  bool sketch = m_pcbSettings.m_sketchGraphics;
1174  int thickness = getLineThickness( aShape->GetWidth() );
1175  VECTOR2D start( aShape->GetStart() );
1176  VECTOR2D end( aShape->GetEnd() );
1177 
1178  if( sketch )
1179  {
1180  m_gal->SetIsFill( false );
1181  m_gal->SetIsStroke( true );
1183  }
1184 
1185  m_gal->SetFillColor( color );
1187 
1188  switch( aShape->GetShape() )
1189  {
1190  case S_SEGMENT:
1191  if( sketch )
1192  {
1193  m_gal->DrawSegment( start, end, thickness );
1194  }
1195  else
1196  {
1197  m_gal->SetIsFill( true );
1198  m_gal->SetIsStroke( false );
1199 
1200  m_gal->DrawSegment( start, end, thickness );
1201  }
1202  break;
1203 
1204  case S_RECT:
1205  {
1206  std::vector<wxPoint> pts = aShape->GetRectCorners();
1207 
1208  if( sketch )
1209  {
1210  m_gal->DrawSegment( pts[0], pts[1], thickness );
1211  m_gal->DrawSegment( pts[1], pts[2], thickness );
1212  m_gal->DrawSegment( pts[2], pts[3], thickness );
1213  m_gal->DrawSegment( pts[3], pts[0], thickness );
1214  }
1215  else
1216  {
1217  m_gal->SetIsFill( true );
1218  m_gal->SetIsStroke( false );
1219 
1220  if( thickness > 0 )
1221  {
1222  m_gal->DrawSegment( pts[0], pts[1], thickness );
1223  m_gal->DrawSegment( pts[1], pts[2], thickness );
1224  m_gal->DrawSegment( pts[2], pts[3], thickness );
1225  m_gal->DrawSegment( pts[3], pts[0], thickness );
1226  }
1227 
1228  if( aShape->IsFilled() )
1229  {
1230  SHAPE_POLY_SET poly;
1231  poly.NewOutline();
1232 
1233  for( const wxPoint& pt : pts )
1234  poly.Append( pt );
1235 
1236  m_gal->DrawPolygon( poly );
1237  }
1238  }
1239  }
1240  break;
1241 
1242  case S_ARC:
1243  if( sketch )
1244  {
1245  m_gal->DrawArcSegment( start, aShape->GetRadius(),
1246  DECIDEG2RAD( aShape->GetArcAngleStart() ),
1247  DECIDEG2RAD( aShape->GetArcAngleStart() + aShape->GetAngle() ), // Change this
1248  thickness );
1249  }
1250  else
1251  {
1252  m_gal->SetIsFill( true );
1253  m_gal->SetIsStroke( false );
1254 
1255  m_gal->DrawArcSegment( start, aShape->GetRadius(),
1256  DECIDEG2RAD( aShape->GetArcAngleStart() ),
1257  DECIDEG2RAD( aShape->GetArcAngleStart() + aShape->GetAngle() ), // Change this
1258  thickness );
1259  }
1260  break;
1261 
1262  case S_CIRCLE:
1263  if( sketch )
1264  {
1265  m_gal->DrawCircle( start, aShape->GetRadius() - thickness / 2 );
1266  m_gal->DrawCircle( start, aShape->GetRadius() + thickness / 2 );
1267  }
1268  else
1269  {
1270  m_gal->SetIsFill( aShape->IsFilled() );
1271  m_gal->SetIsStroke( thickness > 0 );
1272  m_gal->SetLineWidth( thickness );
1273 
1274  m_gal->DrawCircle( start, aShape->GetRadius() );
1275  }
1276  break;
1277 
1278  case S_POLYGON:
1279  {
1280  SHAPE_POLY_SET& shape = const_cast<PCB_SHAPE*>( aShape )->GetPolyShape();
1281  FOOTPRINT* parentFootprint = aShape->GetParentFootprint();
1282 
1283  if( shape.OutlineCount() == 0 )
1284  break;
1285 
1286  if( parentFootprint )
1287  {
1288  m_gal->Save();
1289  m_gal->Translate( parentFootprint->GetPosition() );
1290  m_gal->Rotate( -parentFootprint->GetOrientationRadians() );
1291  }
1292 
1293  if( sketch )
1294  {
1295  for( int ii = 0; ii < shape.Outline( 0 ).SegmentCount(); ++ii )
1296  {
1297  SEG seg = shape.Outline( 0 ).Segment( ii );
1298  m_gal->DrawSegment( seg.A, seg.B, thickness );
1299  }
1300  }
1301  else
1302  {
1303  m_gal->SetIsFill( true );
1304  m_gal->SetIsStroke( false );
1305 
1306  if( thickness > 0 )
1307  {
1308  for( int ii = 0; ii < shape.Outline( 0 ).SegmentCount(); ++ii )
1309  {
1310  SEG seg = shape.Outline( 0 ).Segment( ii );
1311  m_gal->DrawSegment( seg.A, seg.B, thickness );
1312  }
1313  }
1314 
1315  if( aShape->IsFilled() )
1316  {
1317  // On Opengl, a not convex filled polygon is usually drawn by using triangles
1318  // as primitives. CacheTriangulation() can create basic triangle primitives to
1319  // draw the polygon solid shape on Opengl. GLU tesselation is much slower, so
1320  // currently we are using our tesselation.
1321  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
1322  shape.CacheTriangulation();
1323 
1324  m_gal->DrawPolygon( shape );
1325  }
1326  }
1327 
1328  if( parentFootprint )
1329  m_gal->Restore();
1330  }
1331  break;
1332 
1333  case S_CURVE:
1334  if( sketch )
1335  {
1336  // Use thickness as filter value to convert the curve to polyline when the curve
1337  // is not supported
1338  m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
1339  VECTOR2D( aShape->GetBezControl1() ),
1340  VECTOR2D( aShape->GetBezControl2() ),
1341  VECTOR2D( aShape->GetEnd() ), thickness );
1342  }
1343  else
1344  {
1345  m_gal->SetIsFill( aShape->IsFilled() );
1346  m_gal->SetIsStroke( thickness > 0 );
1347  m_gal->SetLineWidth( thickness );
1348 
1349  // Use thickness as filter value to convert the curve to polyline when the curve
1350  // is not supported
1351  m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
1352  VECTOR2D( aShape->GetBezControl1() ),
1353  VECTOR2D( aShape->GetBezControl2() ),
1354  VECTOR2D( aShape->GetEnd() ), thickness );
1355  }
1356  break;
1357 
1358  case S_LAST:
1359  break;
1360  }
1361 }
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:54
usual segment : line with rounded ends
Definition: board_item.h:50
Arcs (with rounded ends)
Definition: board_item.h:52
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
segment with non rounded ends
Definition: board_item.h:51
bool IsTriangulationUpToDate() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:108
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:629
last value for this list
Definition: board_item.h:56
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:53
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:55
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)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
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(), KIGFX::PCB_PAINTER::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, KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 1364 of file pcb_painter.cpp.

1365 {
1366  wxString shownText( aText->GetShownText() );
1367 
1368  if( shownText.Length() == 0 )
1369  return;
1370 
1371  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1372  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1373 
1375  {
1376  // Outline mode
1378  }
1379  else
1380  {
1381  // Filled mode
1383  }
1384 
1386  m_gal->SetIsFill( false );
1387  m_gal->SetIsStroke( true );
1388  m_gal->SetTextAttributes( aText );
1389  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1390 }
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]
Definition: pcb_painter.h:193
int color
Definition: DXF_plotter.cpp:60
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:108
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.
double GetTextAngleRadians() const
Definition: eda_text.h:184
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
Return the primary layer this item is on.
Definition: board_item.h:173
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References color, KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_TEXT::GetEffectiveTextPenWidth(), BOARD_ITEM::GetLayer(), KIGFX::PCB_PAINTER::getLineThickness(), PCB_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 1393 of file pcb_painter.cpp.

1394 {
1395  wxString shownText( aText->GetShownText() );
1396 
1397  if( shownText.Length() == 0 )
1398  return;
1399 
1400  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1401  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1402 
1404  {
1405  // Outline mode
1407  }
1408  else
1409  {
1410  // Filled mode
1412  }
1413 
1415  m_gal->SetIsFill( false );
1416  m_gal->SetIsStroke( true );
1417  m_gal->SetTextAttributes( aText );
1418  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1419 
1420  // Draw the umbilical line
1421  if( aText->IsSelected() )
1422  {
1425  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1426  }
1427 }
bool IsSelected() const
Definition: eda_item.h:171
anchor of items having an anchor point (texts, footprints)
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
int color
Definition: DXF_plotter.cpp:60
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
virtual wxPoint GetPosition() const
Definition: eda_item.h:300
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:108
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.
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:168
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:408
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References color, KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), FP_TEXT::GetDrawRotationRadians(), EDA_TEXT::GetEffectiveTextPenWidth(), KIGFX::PCB_PAINTER::getLineThickness(), BOARD_ITEM::GetParent(), EDA_ITEM::GetPosition(), FP_TEXT::GetShownText(), EDA_TEXT::GetTextPos(), EDA_ITEM::IsSelected(), LAYER_ANCHOR, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 1430 of file pcb_painter.cpp.

1431 {
1432  if( aLayer == LAYER_ANCHOR )
1433  {
1434  const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
1435 
1436  // Keep the size and width constant, not related to the scale because the anchor
1437  // is just a marker on screen
1438  double anchorSize = 5.0 / m_gal->GetWorldScale(); // 5 pixels size
1439  double anchorThickness = 1.0 / m_gal->GetWorldScale(); // 1 pixels width
1440 
1441  // Draw anchor
1442  m_gal->SetIsFill( false );
1443  m_gal->SetIsStroke( true );
1445  m_gal->SetLineWidth( anchorThickness );
1446 
1447  VECTOR2D center = aFootprint->GetPosition();
1448  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1449  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1450 
1451 #if 0 // For debug purpose only: draw the footing bounding box
1452  double bboxThickness = 1.0 / m_gal->GetWorldScale();
1453  m_gal->SetLineWidth( bboxThickness );
1454  EDA_RECT rect = aFootprint->GetBoundingBoxBase();
1455  m_gal->DrawRectangle( VECTOR2D( rect.GetOrigin() ), VECTOR2D( rect.GetEnd() ) );
1456 #endif
1457  }
1458 }
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:300
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:108
virtual void SetLineWidth(float aLineWidth)
Set the line width.
const wxPoint GetEnd() const
Definition: eda_rect.h:108
VECTOR2< double > VECTOR2D
Definition: vector2d.h:629
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint GetOrigin() const
Definition: eda_rect.h:106
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...
Handle the component boundary box.
Definition: eda_rect.h:42
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
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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, KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 1461 of file pcb_painter.cpp.

1462 {
1463  if( aLayer == LAYER_ANCHOR )
1464  {
1465  if( aGroup->IsSelected() && !( aGroup->GetParent() && aGroup->GetParent()->IsSelected() ) )
1466  {
1467  // Selected on our own; draw enclosing box
1468  }
1469  else if( aGroup->IsEntered() )
1470  {
1471  // Entered group; draw enclosing box
1472  }
1473  else
1474  {
1475  return;
1476  }
1477 
1478  const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
1479 
1480  EDA_RECT bbox = aGroup->GetBoundingBox();
1483  wxPoint topLeft = bbox.GetPosition();
1484  wxPoint width = wxPoint( bbox.GetWidth(), 0 );
1485  wxPoint height = wxPoint( 0, bbox.GetHeight() );
1486 
1487  m_gal->DrawLine( topLeft, topLeft + width );
1488  m_gal->DrawLine( topLeft + width, topLeft + width + height );
1489  m_gal->DrawLine( topLeft + width + height, topLeft + height );
1490  m_gal->DrawLine( topLeft + height, topLeft );
1491 
1492  wxString name = aGroup->GetName();
1493 
1494  int ptSize = 12;
1495  int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
1496  int unscaledSize = Mils2iu( ptSize );
1497 
1498  // Scale by zoom a bit, but not too much
1499  int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
1500  int penWidth = textSize / 10;
1501  wxPoint textOffset = wxPoint( width.x / 2, - KiROUND( textSize * 0.5 ) );
1502  wxPoint titleHeight = wxPoint( 0, KiROUND( textSize * 2.0 ) );
1503 
1504  if( !name.IsEmpty() && (int) aGroup->GetName().Length() * textSize < bbox.GetWidth() )
1505  {
1506  m_gal->DrawLine( topLeft, topLeft - titleHeight );
1507  m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
1508  m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
1509 
1510  m_gal->SetFontBold( false );
1511  m_gal->SetFontItalic( true );
1512  m_gal->SetFontUnderlined( false );
1516  m_gal->SetIsFill( false );
1517  m_gal->SetGlyphSize( VECTOR2D( textSize, textSize ) );
1518  m_gal->SetLineWidth( penWidth );
1519  m_gal->StrokeText( aGroup->GetName(), topLeft + textOffset, 0.0 );
1520  }
1521  }
1522 }
bool IsSelected() const
Definition: eda_item.h:171
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:114
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
const EDA_RECT GetBoundingBox() const override
Definition: pcb_group.cpp:193
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:108
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetFontBold(const bool aBold)
Set bold property of current font.
bool IsEntered() const
Definition: eda_item.h:172
VECTOR2< double > VECTOR2D
Definition: vector2d.h:629
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:107
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:115
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...
Handle the component boundary box.
Definition: eda_rect.h:42
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.
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:168
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References color, KIGFX::GAL::DrawLine(), PCB_GROUP::GetBoundingBox(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_RECT::GetHeight(), PCB_GROUP::GetName(), BOARD_ITEM::GetParent(), EDA_RECT::GetPosition(), MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), EDA_RECT::GetWidth(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, EDA_ITEM::IsEntered(), KIGFX::GAL::IsFlippedX(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_ANCHOR, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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 
)
protectedinherited

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

1526 {
1533  wxASSERT( IsZoneLayer( aLayer ) );
1534  PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer - LAYER_ZONE_START );
1535 
1536  if( !aZone->IsOnLayer( layer ) )
1537  return;
1538 
1539  COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
1540  std::deque<VECTOR2D> corners;
1542 
1543  // Draw the outline
1544  const SHAPE_POLY_SET* outline = aZone->Outline();
1545 
1546  if( m_pcbSettings.m_zoneOutlines && outline && outline->OutlineCount() > 0 )
1547  {
1549  m_gal->SetIsFill( false );
1550  m_gal->SetIsStroke( true );
1552 
1553  // Draw each contour (main contour and holes)
1554 
1555  /* This line:
1556  * m_gal->DrawPolygon( *outline );
1557  * should be enough, but currently does not work to draw holes contours in a complex polygon
1558  * so each contour is draw as a simple polygon
1559  */
1560 
1561  // Draw the main contour
1562  m_gal->DrawPolyline( outline->COutline( 0 ) );
1563 
1564  // Draw holes
1565  int holes_count = outline->HoleCount( 0 );
1566 
1567  for( int ii = 0; ii < holes_count; ++ii )
1568  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1569 
1570  // Draw hatch lines
1571  for( const SEG& hatchLine : aZone->GetHatchLines() )
1572  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1573  }
1574 
1575  // Draw the filling
1576  if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED
1577  || displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE )
1578  {
1579  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer );
1580 
1581  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1582  return;
1583 
1584  // Set up drawing options
1585  int outline_thickness = 0;
1586 
1587  if( aZone->GetFilledPolysUseThickness( layer ) )
1588  outline_thickness = aZone->GetMinThickness();
1589 
1591  m_gal->SetFillColor( color );
1592  m_gal->SetLineWidth( outline_thickness );
1593 
1594  if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
1595  {
1596  m_gal->SetIsFill( true );
1597  m_gal->SetIsStroke( outline_thickness > 0 );
1598  }
1599  else if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE )
1600  {
1601  m_gal->SetIsFill( false );
1602  m_gal->SetIsStroke( true );
1603  }
1604 
1605  m_gal->DrawPolygon( polySet );
1606  }
1607 }
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
Outlines of filled polygons are shown.
SHAPE_POLY_SET * Outline()
Definition: zone.h:323
int color
Definition: DXF_plotter.cpp:60
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test 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:655
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
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:108
virtual void SetLineWidth(float aLineWidth)
Set the line width.
PCB_LAYER_ID
A quick note on layer IDs:
int GetMinThickness() const
Definition: zone.h:247
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:823
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...
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
ZONE_DISPLAY_MODE m_zoneDisplayMode
Definition: pcb_painter.h:209
bool GetFilledPolysUseThickness() const
Definition: zone.h:712
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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(), SHAPE_POLY_SET::HoleCount(), ZONE::IsOnLayer(), IsZoneLayer(), LAYER_ZONE_START, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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_FILLED_OUTLINE.

◆ draw() [11/13]

void PCB_PAINTER::draw ( const DIMENSION_BASE aDimension,
int  aLayer 
)
protectedinherited

Definition at line 1610 of file pcb_painter.cpp.

1611 {
1612  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1613 
1614  m_gal->SetStrokeColor( strokeColor );
1615  m_gal->SetIsFill( false );
1616  m_gal->SetIsStroke( true );
1617 
1619  {
1620  // Outline mode
1622  }
1623  else
1624  {
1625  // Filled mode
1626  m_gal->SetLineWidth( getLineThickness( aDimension->GetLineThickness() ) );
1627  }
1628 
1629  // Draw dimension shapes
1630  // TODO(JE) lift this out
1631  for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
1632  {
1633  switch( shape->Type() )
1634  {
1635  case SH_SEGMENT:
1636  {
1637  const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
1638  m_gal->DrawLine( seg.A, seg.B );
1639  break;
1640  }
1641 
1642  case SH_CIRCLE:
1643  {
1644  int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
1645  m_gal->DrawCircle( shape->Centre(), radius );
1646  break;
1647  }
1648 
1649  default:
1650  break;
1651  }
1652  }
1653  // Draw text
1654  PCB_TEXT& text = aDimension->Text();
1655  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1656 
1658  {
1659  // Outline mode
1661  }
1662  else
1663  {
1664  // Filled mode
1666  }
1667 
1668  m_gal->SetTextAttributes( &text );
1669  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1670 }
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:300
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:108
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
Definition: seg.h:39
double GetTextAngleRadians() const
Definition: eda_text.h:184
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
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
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(), KIGFX::PCB_PAINTER::getLineThickness(), DIMENSION_BASE::GetShapes(), PCB_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::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)
protectedinherited

Definition at line 1673 of file pcb_painter.cpp.

1674 {
1675  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1676  VECTOR2D position( aTarget->GetPosition() );
1677  double size, radius;
1678 
1679  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1680  m_gal->SetStrokeColor( strokeColor );
1681  m_gal->SetIsFill( false );
1682  m_gal->SetIsStroke( true );
1683 
1684  m_gal->Save();
1685  m_gal->Translate( position );
1686 
1687  if( aTarget->GetShape() )
1688  {
1689  // shape x
1690  m_gal->Rotate( M_PI / 4.0 );
1691  size = 2.0 * aTarget->GetSize() / 3.0;
1692  radius = aTarget->GetSize() / 2.0;
1693  }
1694  else
1695  {
1696  // shape +
1697  size = aTarget->GetSize() / 2.0;
1698  radius = aTarget->GetSize() / 3.0;
1699  }
1700 
1701  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1702  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1703  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1704 
1705  m_gal->Restore();
1706 }
int GetSize() const
Definition: pcb_target.h:67
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300
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:108
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:629
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
Return the primary layer this item is on.
Definition: board_item.h:173
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), BOARD_ITEM::GetLayer(), KIGFX::PCB_PAINTER::getLineThickness(), PCB_TARGET::GetPosition(), PCB_TARGET::GetShape(), PCB_TARGET::GetSize(), PCB_TARGET::GetWidth(), KIGFX::PAINTER::m_gal, KIGFX::PCB_PAINTER::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 
)
protectedinherited

Definition at line 1709 of file pcb_painter.cpp.

1710 {
1711  bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
1712 
1713  // Don't paint shadows for invisible markers.
1714  // It would be nice to do this through layer dependencies but we can't do an "or" there today
1715  if( isShadow && aMarker->GetBoard() &&
1716  !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
1717  return;
1718 
1719  SHAPE_LINE_CHAIN polygon;
1720  aMarker->ShapeToPolygon( polygon );
1721 
1722 
1723 
1725  : aMarker->GetColorLayer() );
1726 
1727  m_gal->Save();
1728  m_gal->Translate( aMarker->GetPosition() );
1729 
1730  if( isShadow )
1731  {
1733  m_gal->SetIsStroke( true );
1734  m_gal->SetLineWidth( aMarker->MarkerScale() );
1735  }
1736  else
1737  {
1738  m_gal->SetFillColor( color );
1739  m_gal->SetIsFill( true );
1740  }
1741 
1742  m_gal->DrawPolygon( polygon );
1743  m_gal->Restore();
1744 }
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:300
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:108
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual BOARD * GetBoard() const
Return 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:179
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:507
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:66
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
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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, KIGFX::PCB_PAINTER::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 KIGFX::PCB_PRINT_PAINTER::getDrillShape ( const PAD aPad) const
overrideprotectedvirtual

Return drill shape of a pad.

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 291 of file pcbnew_printout.cpp.

292 {
294 }
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks
virtual int getDrillShape(const PAD *aPad) const
Return drill shape of a pad.

References KIGFX::PCB_PAINTER::getDrillShape(), and PAD_DRILL_SHAPE_CIRCLE.

◆ getDrillSize() [1/2]

VECTOR2D KIGFX::PCB_PRINT_PAINTER::getDrillSize ( const PAD aPad) const
overrideprotectedvirtual

Return drill size for a pad (internal units).

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 297 of file pcbnew_printout.cpp.

298 {
299  // TODO should it depend on the pad size?
302 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:62
virtual VECTOR2D getDrillSize(const PAD *aPad) const
Return drill size for a pad (internal units).
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks
int m_drillMarkSize
User-specified size for drill marks (expressed in internal units)

References KIGFX::PCB_PAINTER::getDrillSize().

◆ getDrillSize() [2/2]

int KIGFX::PCB_PRINT_PAINTER::getDrillSize ( const VIA aVia) const
overrideprotectedvirtual

Return drill diameter for a via (internal units).

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 305 of file pcbnew_printout.cpp.

306 {
307  // TODO should it depend on the via size?
309 }
virtual VECTOR2D getDrillSize(const PAD *aPad) const
Return drill size for a pad (internal units).
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks
int m_drillMarkSize
User-specified size for drill marks (expressed in internal units)

References KIGFX::PCB_PAINTER::getDrillSize().

◆ getLineThickness()

int PCB_PAINTER::getLineThickness ( int  aActualThickness) const
protectedinherited

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

395 {
396  // if items have 0 thickness, draw them with the outline
397  // width, otherwise respect the set value (which, no matter
398  // how small will produce something)
399  if( aActualThickness == 0 )
401 
402  return aActualThickness;
403 }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:300

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

Referenced by KIGFX::PCB_PAINTER::draw().

◆ GetSettings()

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

◆ SetDrillMarks()

void KIGFX::PCB_PRINT_PAINTER::SetDrillMarks ( bool  aRealSize,
unsigned int  aSize = 0 
)
inline

Set drill marks visibility and options.

Parameters
aRealSizewhen enabled, drill marks represent actual holes. Otherwise aSize parameter is used.
aSizeis drill mark size (internal units), valid only when aRealSize == false.

Definition at line 95 of file pcbnew_printout.h.

96  {
97  m_drillMarkReal = aRealSize;
98  m_drillMarkSize = aSize;
99  }
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks
int m_drillMarkSize
User-specified size for drill marks (expressed in internal units)

References m_drillMarkReal, and m_drillMarkSize.

Referenced by PCBNEW_PRINTOUT::setupPainter().

◆ SetGAL()

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

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

Parameters
aGalis the new GAL instance.

Definition at line 75 of file painter.h.

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

References KIGFX::PAINTER::m_gal.

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 111 of file painter.h.

◆ m_drillMarkReal

bool KIGFX::PCB_PRINT_PAINTER::m_drillMarkReal
protected

Flag deciding whether use the actual hole size or user-specified size for drill marks

Definition at line 109 of file pcbnew_printout.h.

Referenced by SetDrillMarks().

◆ m_drillMarkSize

int KIGFX::PCB_PRINT_PAINTER::m_drillMarkSize
protected

User-specified size for drill marks (expressed in internal units)

Definition at line 112 of file pcbnew_printout.h.

Referenced by SetDrillMarks().

◆ m_gal

◆ m_pcbSettings


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