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
 Function ApplySettings Loads colors and display modes settings that are going to be used when drawing items. More...
 
virtual PCB_RENDER_SETTINGSGetSettings () override
 
virtual bool Draw (const VIEW_ITEM *aItem, int aLayer) override
 Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the item. More...
 
void SetGAL (GAL *aGal)
 Function SetGAL Changes Graphics Abstraction Layer used for drawing items for a new one. More...
 

Protected Member Functions

int getDrillShape (const D_PAD *aPad) const override
 Return drill shape of a pad. More...
 
VECTOR2D getDrillSize (const D_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 D_PAD *aPad, int aLayer)
 
void draw (const DRAWSEGMENT *aSegment, int aLayer)
 
void draw (const TEXTE_PCB *aText, int aLayer)
 
void draw (const TEXTE_MODULE *aText, int aLayer)
 
void draw (const MODULE *aModule, int aLayer)
 
void draw (const ZONE_CONTAINER *aZone, int aLayer)
 
void draw (const DIMENSION *aDimension, int aLayer)
 
void draw (const PCB_TARGET *aTarget)
 
void draw (const MARKER_PCB *aMarker)
 
int getLineThickness (int aActualThickness) const
 Function getLineThickness() Get the thickness to draw for a line (e.g. More...
 

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 83 of file pcbnew_printout.h.

Constructor & Destructor Documentation

◆ PCB_PRINT_PAINTER()

KIGFX::PCB_PRINT_PAINTER::PCB_PRINT_PAINTER ( GAL aGal)

Definition at line 223 of file pcbnew_printout.cpp.

224  : PCB_PAINTER( aGal ), m_drillMarkReal( false ), m_drillMarkSize( 0 )
225 {
227 }
void EnableZoneOutlines(bool aEnabled)
Turns on/off drawing outline and hatched lines for zones.
Definition: pcb_painter.h:159
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
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

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

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 280 of file pcb_painter.h.

281  {
282  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
283  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295

References KIGFX::PCB_PAINTER::m_pcbSettings.

◆ Draw()

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

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

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

Implements KIGFX::PAINTER.

Definition at line 372 of file pcb_painter.cpp.

373 {
374  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
375 
376  if( !item )
377  return false;
378 
379  // the "cast" applied in here clarifies which overloaded draw() is called
380  switch( item->Type() )
381  {
382  case PCB_TRACE_T:
383  draw( static_cast<const TRACK*>( item ), aLayer );
384  break;
385 
386  case PCB_ARC_T:
387  draw( static_cast<const ARC*>( item ), aLayer );
388  break;
389 
390  case PCB_VIA_T:
391  draw( static_cast<const VIA*>( item ), aLayer );
392  break;
393 
394  case PCB_PAD_T:
395  draw( static_cast<const D_PAD*>( item ), aLayer );
396  break;
397 
398  case PCB_LINE_T:
399  case PCB_MODULE_EDGE_T:
400  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
401  break;
402 
403  case PCB_TEXT_T:
404  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
405  break;
406 
407  case PCB_MODULE_TEXT_T:
408  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
409  break;
410 
411  case PCB_MODULE_T:
412  draw( static_cast<const MODULE*>( item ), aLayer );
413  break;
414 
415  case PCB_ZONE_AREA_T:
416  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
417  break;
418 
420  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
421  break;
422 
423  case PCB_DIMENSION_T:
424  draw( static_cast<const DIMENSION*>( item ), aLayer );
425  break;
426 
427  case PCB_TARGET_T:
428  draw( static_cast<const PCB_TARGET*>( item ) );
429  break;
430 
431  case PCB_MARKER_T:
432  draw( static_cast<const MARKER_PCB*>( item ) );
433  break;
434 
435  default:
436  // Painter does not know how to draw the object
437  return false;
438  }
439 
440  return true;
441 }
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
class MODULE, a footprint
Definition: typeinfo.h:89
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void draw(const TRACK *aTrack, int aLayer)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References KIGFX::PCB_PAINTER::draw(), PCB_ARC_T, PCB_DIMENSION_T, PCB_LINE_T, PCB_MARKER_T, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_MODULE_ZONE_AREA_T, PCB_PAD_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, and EDA_ITEM::Type().

◆ draw() [1/12]

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

Definition at line 444 of file pcb_painter.cpp.

445 {
446  VECTOR2D start( aTrack->GetStart() );
447  VECTOR2D end( aTrack->GetEnd() );
448  int width = aTrack->GetWidth();
449 
451  {
452  // If there is a net name - display it on the track
453  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
454  {
455  VECTOR2D line = ( end - start );
456  double length = line.EuclideanNorm();
457 
458  // Check if the track is long enough to have a netname displayed
459  if( length < 10 * width )
460  return;
461 
462  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
463  VECTOR2D textPosition = start + line / 2.0; // center of the track
464 
465  double textOrientation;
466 
467  if( end.y == start.y ) // horizontal
468  textOrientation = 0;
469  else if( end.x == start.x ) // vertical
470  textOrientation = M_PI / 2;
471  else
472  textOrientation = -atan( line.y / line.x );
473 
474  double textSize = width;
475 
476  m_gal->SetIsStroke( true );
477  m_gal->SetIsFill( false );
479  m_gal->SetLineWidth( width / 10.0 );
480  m_gal->SetFontBold( false );
481  m_gal->SetFontItalic( false );
482  m_gal->SetTextMirrored( false );
483  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
486  m_gal->BitmapText( netName, textPosition, textOrientation );
487  }
488  }
489  else if( IsCopperLayer( aLayer ) )
490  {
491  // Draw a regular track
492  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
493  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
496  m_gal->SetIsStroke( outline_mode );
497  m_gal->SetIsFill( not outline_mode );
499 
500  m_gal->DrawSegment( start, end, width );
501 
502  // Clearance lines
503  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
504 
505  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
506  {
508  m_gal->SetIsFill( false );
509  m_gal->SetIsStroke( true );
511  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
512  }
513  }
514 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int GetNetCode() const
Function GetNetCode.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
const wxPoint & GetStart() const
Definition: class_track.h:118
bool m_sketchMode[GAL_LAYER_ID_END]
Flag determining if items on a given layer should be drawn as an outline or a filled item
Definition: pcb_painter.h:210
int color
Definition: DXF_plotter.cpp:61
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetFontBold(const bool aBold)
Set bold property of current font.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
virtual int GetClearance(BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:225
int GetWidth() const
Definition: class_track.h:112
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:248
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:125
const wxPoint & GetEnd() const
Definition: class_track.h:115
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:299
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:478
const wxString & GetShortNetname() const
Function GetShortNetname.
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

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

◆ draw() [2/12]

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

Definition at line 517 of file pcb_painter.cpp.

518 {
519  VECTOR2D center( aArc->GetCenter() );
520  int width = aArc->GetWidth();
521 
522  if( IsCopperLayer( aLayer ) )
523  {
524  // Draw a regular track
525  const COLOR4D& color = m_pcbSettings.GetColor( aArc, aLayer );
526  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
529  m_gal->SetIsStroke( outline_mode );
530  m_gal->SetIsFill( not outline_mode );
532 
533  auto radius = aArc->GetRadius();
534  auto start_angle = DECIDEG2RAD( aArc->GetArcAngleStart() );
535  auto angle = DECIDEG2RAD( aArc->GetAngle() );
536 
537  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width );
538 
539  // Clearance lines
540  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
541 
542  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
543  {
545  m_gal->SetIsFill( false );
546  m_gal->SetIsStroke( true );
548 
549  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
550  width + aArc->GetClearance() * 2 );
551  }
552  }
553 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool m_sketchMode[GAL_LAYER_ID_END]
Flag determining if items on a given layer should be drawn as an outline or a filled item
Definition: pcb_painter.h:210
int color
Definition: DXF_plotter.cpp:61
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual wxPoint GetCenter() const
Function GetCenter()
double GetRadius() const
virtual int GetClearance(BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
double GetAngle() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetWidth() const
Definition: class_track.h:112
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:248
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double DECIDEG2RAD(double deg)
Definition: trigo.h:218
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
double GetArcAngleStart() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References PNS::angle(), KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_TRACKS, color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), ARC::GetAngle(), ARC::GetArcAngleStart(), BOARD_ITEM::GetCenter(), BOARD_CONNECTED_ITEM::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), ARC::GetRadius(), TRACK::GetWidth(), IsCopperLayer(), LAYER_TRACKS, KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, 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/12]

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

Definition at line 556 of file pcb_painter.cpp.

557 {
558  VECTOR2D center( aVia->GetStart() );
559  double radius = 0.0;
560 
561  // Draw description layer
562  if( IsNetnameLayer( aLayer ) )
563  {
564  VECTOR2D position( center );
565 
566  // Is anything that we can display enabled?
568  {
569  bool displayNetname = ( !aVia->GetNetname().empty() );
570  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
571  double size = aVia->GetWidth();
572 
573  // Font size limits
574  if( size > maxSize )
575  size = maxSize;
576 
577  m_gal->Save();
578  m_gal->Translate( position );
579 
580  // Default font settings
583 
584  // Set the text position to the pad shape position (the pad position is not the best place)
585  VECTOR2D textpos( 0.0, 0.0 );
586 
587  if( displayNetname )
588  {
589  wxString netname = UnescapeString( aVia->GetShortNetname() );
590  // calculate the size of net name text:
591  double tsize = 1.5 * size / netname.Length();
592  tsize = std::min( tsize, size );
593  // Use a smaller text size to handle interline, pen size..
594  tsize *= 0.7;
595  VECTOR2D namesize( tsize, tsize );
596 
597  m_gal->SetGlyphSize( namesize );
598  m_gal->SetLineWidth( namesize.x / 12.0 );
599  m_gal->BitmapText( netname, textpos, 0.0 );
600  }
601 
602 
603  m_gal->Restore();
604  }
605  return;
606  }
607 
608  // Choose drawing settings depending on if we are drawing via's pad or hole
609  if( aLayer == LAYER_VIAS_HOLES )
610  radius = getDrillSize( aVia ) / 2.0;
611  else
612  radius = aVia->GetWidth() / 2.0;
613 
614  bool sketchMode = false;
615  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
616 
617  switch( aVia->GetViaType() )
618  {
619  case VIATYPE::THROUGH:
621  break;
622 
625  break;
626 
627  case VIATYPE::MICROVIA:
629  break;
630 
631  default:
632  wxASSERT( false );
633  break;
634  }
635 
636  m_gal->SetIsFill( !sketchMode );
637  m_gal->SetIsStroke( sketchMode );
638 
639  if( sketchMode )
640  {
641  // Outline mode
644  }
645  else
646  {
647  // Filled mode
649  }
650 
651  if( ( aVia->GetViaType() == VIATYPE::BLIND_BURIED || aVia->GetViaType() == VIATYPE::MICROVIA )
652  && aLayer != LAYER_VIAS_HOLES
654  {
655  // Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
656  // top and bottom layers
657  PCB_LAYER_ID layerTop, layerBottom;
658  aVia->LayerPair( &layerTop, &layerBottom );
659 
660  if( !sketchMode )
661  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
662 
663  if( aLayer == layerTop )
664  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
665 
666  else if( aLayer == layerBottom )
667  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
668 
669  else if( aLayer == LAYER_VIA_BBLIND || aLayer == LAYER_VIA_MICROVIA )
670  {
671  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
672  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
673  }
674  }
675  else
676  {
677  // Draw the outer circles of normal vias and the holes for all vias
678  m_gal->DrawCircle( center, radius );
679  }
680 
681  // Clearance lines
682  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
683 
684  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
685  && aLayer != LAYER_VIAS_HOLES )
686  {
688  m_gal->SetIsFill( false );
689  m_gal->SetIsStroke( true );
691  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
692  }
693 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
to draw blind/buried vias
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
const wxPoint & GetStart() const
Definition: class_track.h:118
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
bool m_sketchMode[GAL_LAYER_ID_END]
Flag determining if items on a given layer should be drawn as an outline or a filled item
Definition: pcb_painter.h:210
int color
Definition: DXF_plotter.cpp:61
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
to draw via holes (pad holes do not use this layer)
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
PCB_LAYER_ID
A quick note on layer IDs:
bool GetDrawIndividualViaLayers() const
Definition: pcb_painter.h:195
void ResetTextAttributes()
Reset text attributes to default styling.
#define NULL
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:242
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
to draw usual through hole vias
const wxString & GetNetname() const
Function GetNetname.
virtual int GetClearance(BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
int GetWidth() const
Definition: class_track.h:112
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:248
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:125
VIATYPE GetViaType() const
Definition: class_track.h:378
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
const wxString & GetShortNetname() const
Function GetShortNetname.
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:228
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::GAL::BitmapText(), BLIND_BURIED, KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_VIAS, color, KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), BOARD_CONNECTED_ITEM::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetDrawIndividualViaLayers(), KIGFX::PCB_PAINTER::getDrillSize(), VIA::GetDrillValue(), BOARD_CONNECTED_ITEM::GetNetname(), BOARD_CONNECTED_ITEM::GetShortNetname(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), IsNetnameLayer(), LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, VIA::LayerPair(), KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnVias, KIGFX::RENDER_SETTINGS::m_outlineWidth, 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/12]

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

Definition at line 696 of file pcb_painter.cpp.

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

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

◆ draw() [5/12]

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

Definition at line 922 of file pcb_painter.cpp.

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

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

◆ draw() [6/12]

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

Definition at line 1045 of file pcb_painter.cpp.

1046 {
1047  wxString shownText( aText->GetShownText() );
1048 
1049  if( shownText.Length() == 0 )
1050  return;
1051 
1052  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1053  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1054 
1056  {
1057  // Outline mode
1059  }
1060  else
1061  {
1062  // Filled mode
1064  }
1065 
1067  m_gal->SetIsFill( false );
1068  m_gal->SetIsStroke( true );
1069  m_gal->SetTextAttributes( aText );
1070  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1071 }
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
bool m_sketchMode[GAL_LAYER_ID_END]
Flag determining if items on a given layer should be drawn as an outline or a filled item
Definition: pcb_painter.h:210
int color
Definition: DXF_plotter.cpp:61
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
bool m_sketchText
Flag determining if text items should be outlined or stroked
Definition: pcb_painter.h:216
double GetTextAngleRadians() const
Definition: eda_text.h:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [7/12]

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

Definition at line 1074 of file pcb_painter.cpp.

1075 {
1076  wxString shownText( aText->GetShownText() );
1077 
1078  if( shownText.Length() == 0 )
1079  return;
1080 
1081  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1082  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1083 
1085  {
1086  // Outline mode
1088  }
1089  else
1090  {
1091  // Filled mode
1093  }
1094 
1096  m_gal->SetIsFill( false );
1097  m_gal->SetIsStroke( true );
1098  m_gal->SetTextAttributes( aText );
1099  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1100 
1101  // Draw the umbilical line
1102  if( aText->IsSelected() )
1103  {
1105  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1106  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1107  }
1108 }
bool IsSelected() const
Definition: base_struct.h:203
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
int color
Definition: DXF_plotter.cpp:61
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
double GetDrawRotationRadians() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
bool m_sketchText
Flag determining if text items should be outlined or stroked
Definition: pcb_painter.h:216
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
BOARD_ITEM_CONTAINER * GetParent() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References color, KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), TEXTE_MODULE::GetDrawRotationRadians(), EDA_TEXT::GetEffectiveTextPenWidth(), KIGFX::PCB_PAINTER::getLineThickness(), BOARD_ITEM::GetParent(), EDA_ITEM::GetPosition(), TEXTE_MODULE::GetShownText(), EDA_TEXT::GetTextPos(), EDA_ITEM::IsSelected(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, 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(), KIGFX::GAL::StrokeText(), wxPoint::x, and wxPoint::y.

◆ draw() [8/12]

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

Definition at line 1111 of file pcb_painter.cpp.

1112 {
1113  if( aLayer == LAYER_ANCHOR )
1114  {
1115  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1116 
1117  // Draw anchor
1120 
1121  // Keep the size constant, not related to the scale
1122  double anchorSize = 5.0 / m_gal->GetWorldScale();
1123 
1124  VECTOR2D center = aModule->GetPosition();
1125  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1126  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1127  }
1128 }
anchor of items having an anchor point (texts, footprints)
int color
Definition: DXF_plotter.cpp:61
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
wxPoint GetPosition() const override
Definition: class_module.h:216
double GetWorldScale() const
Get the world scale.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [9/12]

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

Definition at line 1131 of file pcb_painter.cpp.

1132 {
1133  PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer );
1134 
1135  if( !aZone->IsOnLayer( layer ) )
1136  return;
1137 
1138  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1139  std::deque<VECTOR2D> corners;
1141 
1142  // Draw the outline
1143  const SHAPE_POLY_SET* outline = aZone->Outline();
1144 
1145  if( m_pcbSettings.m_zoneOutlines && outline && outline->OutlineCount() > 0 )
1146  {
1148  m_gal->SetIsFill( false );
1149  m_gal->SetIsStroke( true );
1151 
1152  // Draw each contour (main contour and holes)
1153 
1154  /* This line:
1155  * m_gal->DrawPolygon( *outline );
1156  * should be enough, but currently does not work to draw holes contours in a complex polygon
1157  * so each contour is draw as a simple polygon
1158  */
1159 
1160  // Draw the main contour
1161  m_gal->DrawPolyline( outline->COutline( 0 ) );
1162 
1163  // Draw holes
1164  int holes_count = outline->HoleCount( 0 );
1165 
1166  for( int ii = 0; ii < holes_count; ++ii )
1167  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1168 
1169  // Draw hatch lines
1170  for( const SEG& hatchLine : aZone->GetHatchLines() )
1171  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1172  }
1173 
1174  // Draw the filling
1175  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1176  {
1177  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer );
1178 
1179  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1180  return;
1181 
1182  // Set up drawing options
1183  int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
1185  m_gal->SetFillColor( color );
1186  m_gal->SetLineWidth( outline_thickness );
1187 
1188  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1189  {
1190  m_gal->SetIsFill( true );
1191  m_gal->SetIsStroke( outline_thickness > 0 );
1192  }
1193  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1194  {
1195  m_gal->SetIsFill( false );
1196  m_gal->SetIsStroke( true );
1197  }
1198 
1199  m_gal->DrawPolygon( polySet );
1200  }
1201 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
int OutlineCount() const
Returns the number of outlines in the set
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_zone.cpp:301
int color
Definition: DXF_plotter.cpp:61
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:276
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:672
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:613
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:245
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:85
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:790
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
int GetMinThickness() const
Definition: class_zone.h:206
bool m_zoneOutlines
Flag determining if zones should have outlines drawn
Definition: pcb_painter.h:231
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References SHAPE_POLY_SET::CHole(), color, SHAPE_POLY_SET::COutline(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawPolyline(), KIGFX::PCB_RENDER_SETTINGS::DZ_HIDE_FILLED, KIGFX::PCB_RENDER_SETTINGS::DZ_SHOW_FILLED, KIGFX::PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED, KIGFX::PCB_RENDER_SETTINGS::GetColor(), ZONE_CONTAINER::GetFilledPolysList(), ZONE_CONTAINER::GetFilledPolysUseThickness(), ZONE_CONTAINER::GetHatchLines(), ZONE_CONTAINER::GetMinThickness(), SHAPE_POLY_SET::HoleCount(), ZONE_CONTAINER::IsOnLayer(), KIGFX::PCB_RENDER_SETTINGS::m_displayZone, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_zoneOutlines, ZONE_CONTAINER::Outline(), SHAPE_POLY_SET::OutlineCount(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [10/12]

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

Definition at line 1204 of file pcb_painter.cpp.

1205 {
1206  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1207 
1208  m_gal->SetStrokeColor( strokeColor );
1209  m_gal->SetIsFill( false );
1210  m_gal->SetIsStroke( true );
1211 
1213  {
1214  // Outline mode
1216  }
1217  else
1218  {
1219  // Filled mode
1220  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1221  }
1222 
1223  // Draw an arrow
1224  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1225  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1226  VECTOR2D( aDimension->m_featureLineGF ) );
1227  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1228  VECTOR2D( aDimension->m_featureLineDF ) );
1229  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1230  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1231  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1232  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1233 
1234  // Draw text
1235  TEXTE_PCB& text = aDimension->Text();
1236  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1237 
1239  {
1240  // Outline mode
1242  }
1243  else
1244  {
1245  // Filled mode
1247  }
1248 
1249  m_gal->SetTextAttributes( &text );
1250  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1251 }
int GetWidth() const
wxPoint m_crossBarF
wxPoint m_arrowD1F
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
wxPoint m_featureLineDF
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
bool m_sketchGraphics
Flag determining if graphic items should be outlined or stroked
Definition: pcb_painter.h:213
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxPoint m_featureLineGO
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
wxPoint m_arrowG1F
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
wxPoint m_arrowD2F
wxPoint m_arrowG2F
bool m_sketchText
Flag determining if text items should be outlined or stroked
Definition: pcb_painter.h:216
double GetTextAngleRadians() const
Definition: eda_text.h:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
TEXTE_PCB & Text()
const wxPoint & GetTextPos() const
Definition: eda_text.h:248
wxPoint m_crossBarO
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxPoint m_featureLineDO
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
wxPoint m_featureLineGF

References KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), EDA_TEXT::GetEffectiveTextPenWidth(), KIGFX::PCB_PAINTER::getLineThickness(), TEXTE_PCB::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), DIMENSION::GetWidth(), DIMENSION::m_arrowD1F, DIMENSION::m_arrowD2F, DIMENSION::m_arrowG1F, DIMENSION::m_arrowG2F, DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, DIMENSION::m_featureLineDF, DIMENSION::m_featureLineDO, DIMENSION::m_featureLineGF, DIMENSION::m_featureLineGO, 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(), KIGFX::GAL::StrokeText(), DIMENSION::Text(), wxPoint::x, and wxPoint::y.

◆ draw() [11/12]

void PCB_PAINTER::draw ( const PCB_TARGET aTarget)
protectedinherited

Definition at line 1254 of file pcb_painter.cpp.

1255 {
1256  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1257  VECTOR2D position( aTarget->GetPosition() );
1258  double size, radius;
1259 
1260  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1261  m_gal->SetStrokeColor( strokeColor );
1262  m_gal->SetIsFill( false );
1263  m_gal->SetIsStroke( true );
1264 
1265  m_gal->Save();
1266  m_gal->Translate( position );
1267 
1268  if( aTarget->GetShape() )
1269  {
1270  // shape x
1271  m_gal->Rotate( M_PI / 4.0 );
1272  size = 2.0 * aTarget->GetSize() / 3.0;
1273  radius = aTarget->GetSize() / 2.0;
1274  }
1275  else
1276  {
1277  // shape +
1278  size = aTarget->GetSize() / 2.0;
1279  radius = aTarget->GetSize() / 3.0;
1280  }
1281 
1282  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1283  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1284  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1285 
1286  m_gal->Restore();
1287 }
int GetSize() const
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
wxPoint GetPosition() const override
int GetWidth() const
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int GetShape() const
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), BOARD_ITEM::GetLayer(), 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() [12/12]

void PCB_PAINTER::draw ( const MARKER_PCB aMarker)
protectedinherited

Definition at line 1290 of file pcb_painter.cpp.

1291 {
1292  SHAPE_LINE_CHAIN polygon;
1293  aMarker->ShapeToPolygon( polygon );
1294 
1295  auto strokeColor = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
1296 
1297  m_gal->Save();
1298  m_gal->Translate( aMarker->GetPosition() );
1299  m_gal->SetFillColor( strokeColor );
1300  m_gal->SetIsFill( true );
1301  m_gal->SetIsStroke( false );
1302  m_gal->DrawPolygon( polygon );
1303  m_gal->Restore();
1304 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
GAL_LAYER_ID GetColorLayer() const
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
wxPoint GetPosition() const override
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
SHAPE_LINE_CHAIN.
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.

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

◆ getDrillShape()

int KIGFX::PCB_PRINT_PAINTER::getDrillShape ( const D_PAD aPad) const
overrideprotectedvirtual

Return drill shape of a pad.

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 230 of file pcbnew_printout.cpp.

231 {
233 }
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks
virtual int getDrillShape(const D_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 D_PAD aPad) const
overrideprotectedvirtual

Return drill size for a pad (internal units).

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 236 of file pcbnew_printout.cpp.

237 {
238  // TODO should it depend on the pad size?
241 }
virtual VECTOR2D getDrillSize(const D_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 244 of file pcbnew_printout.cpp.

245 {
246  // TODO should it depend on the via size?
248 }
virtual VECTOR2D getDrillSize(const D_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 342 of file pcb_painter.cpp.

343 {
344  // if items have 0 thickness, draw them with the outline
345  // width, otherwise respect the set value (which, no matter
346  // how small will produce something)
347  if( aActualThickness == 0 )
349 
350  return aActualThickness;
351 }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:295

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 94 of file pcbnew_printout.h.

95  {
96  m_drillMarkReal = aRealSize;
97  m_drillMarkSize = aSize;
98  }
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

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

Parameters
aGalis the new GAL instance.

Definition at line 78 of file painter.h.

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

References KIGFX::PAINTER::m_gal.

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 113 of file painter.h.

◆ m_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 108 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 111 of file pcbnew_printout.h.

Referenced by SetDrillMarks().

◆ m_gal

◆ m_pcbSettings


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