KiCad PCB EDA Suite
KIGFX::PCB_PAINTER Class Reference

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

#include <pcb_painter.h>

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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

PCB_PAINTER Contains methods for drawing PCB-specific items.

Definition at line 220 of file pcb_painter.h.

Constructor & Destructor Documentation

◆ PCB_PAINTER()

PCB_PAINTER::PCB_PAINTER ( GAL aGal)

Definition at line 290 of file pcb_painter.cpp.

290  :
291  PAINTER( aGal )
292 {
293 }
PAINTER(GAL *aGal)
Constructor PAINTER( GAL* ) initializes this object for painting on any of the polymorphic GRAPHICS_A...
Definition: painter.cpp:32

Member Function Documentation

◆ ApplySettings()

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

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

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 226 of file pcb_painter.h.

227  {
228  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
229  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:241

References m_pcbSettings.

◆ Draw()

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

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

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

Implements KIGFX::PAINTER.

Definition at line 326 of file pcb_painter.cpp.

327 {
328  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
329 
330  if( !item )
331  return false;
332 
333  // the "cast" applied in here clarifies which overloaded draw() is called
334  switch( item->Type() )
335  {
336  case PCB_TRACE_T:
337  draw( static_cast<const TRACK*>( item ), aLayer );
338  break;
339 
340  case PCB_ARC_T:
341  draw( static_cast<const ARC*>( item ), aLayer );
342  break;
343 
344  case PCB_VIA_T:
345  draw( static_cast<const VIA*>( item ), aLayer );
346  break;
347 
348  case PCB_PAD_T:
349  draw( static_cast<const D_PAD*>( item ), aLayer );
350  break;
351 
352  case PCB_LINE_T:
353  case PCB_MODULE_EDGE_T:
354  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
355  break;
356 
357  case PCB_TEXT_T:
358  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
359  break;
360 
361  case PCB_MODULE_TEXT_T:
362  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
363  break;
364 
365  case PCB_MODULE_T:
366  draw( static_cast<const MODULE*>( item ), aLayer );
367  break;
368 
369  case PCB_ZONE_AREA_T:
370  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
371  break;
372 
374  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
375  break;
376 
377  case PCB_DIMENSION_T:
378  draw( static_cast<const DIMENSION*>( item ), aLayer );
379  break;
380 
381  case PCB_TARGET_T:
382  draw( static_cast<const PCB_TARGET*>( item ) );
383  break;
384 
385  case PCB_MARKER_T:
386  draw( static_cast<const MARKER_PCB*>( item ) );
387  break;
388 
389  default:
390  // Painter does not know how to draw the object
391  return false;
392  }
393 
394  return true;
395 }
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 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 
)
protected

Definition at line 398 of file pcb_painter.cpp.

399 {
400  VECTOR2D start( aTrack->GetStart() );
401  VECTOR2D end( aTrack->GetEnd() );
402  int width = aTrack->GetWidth();
403 
405  {
406  // If there is a net name - display it on the track
407  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
408  {
409  VECTOR2D line = ( end - start );
410  double length = line.EuclideanNorm();
411 
412  // Check if the track is long enough to have a netname displayed
413  if( length < 10 * width )
414  return;
415 
416  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
417  VECTOR2D textPosition = start + line / 2.0; // center of the track
418 
419  double textOrientation;
420 
421  if( end.y == start.y ) // horizontal
422  textOrientation = 0;
423  else if( end.x == start.x ) // vertical
424  textOrientation = M_PI / 2;
425  else
426  textOrientation = -atan( line.y / line.x );
427 
428  double textSize = width;
429 
430  m_gal->SetIsStroke( true );
431  m_gal->SetIsFill( false );
433  m_gal->SetLineWidth( width / 10.0 );
434  m_gal->SetFontBold( false );
435  m_gal->SetFontItalic( false );
436  m_gal->SetTextMirrored( false );
437  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
440  m_gal->BitmapText( netName, textPosition, textOrientation );
441  }
442  }
443  else if( IsCopperLayer( aLayer ) )
444  {
445  // Draw a regular track
446  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
447  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
450  m_gal->SetIsStroke( outline_mode );
451  m_gal->SetIsFill( not outline_mode );
453 
454  m_gal->DrawSegment( start, end, width );
455 
456  // Clearance lines
457  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
458 
459  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
460  {
462  m_gal->SetIsFill( false );
463  m_gal->SetIsStroke( true );
465  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
466  }
467  }
468 }
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:171
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:241
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:186
int GetWidth() const
Definition: class_track.h:112
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:209
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
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:461
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, 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 Draw().

◆ draw() [2/12]

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

Definition at line 471 of file pcb_painter.cpp.

472 {
473  VECTOR2D center( aArc->GetCenter() );
474  int width = aArc->GetWidth();
475 
476  if( IsCopperLayer( aLayer ) )
477  {
478  // Draw a regular track
479  const COLOR4D& color = m_pcbSettings.GetColor( aArc, aLayer );
480  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
483  m_gal->SetIsStroke( outline_mode );
484  m_gal->SetIsFill( not outline_mode );
486 
487  auto radius = aArc->GetRadius();
488  auto start_angle = DECIDEG2RAD( aArc->GetArcAngleStart() );
489  auto angle = DECIDEG2RAD( aArc->GetAngle() );
490 
491  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width );
492 
493  // Clearance lines
494  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
495 
496  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
497  {
499  m_gal->SetIsFill( false );
500  m_gal->SetIsStroke( true );
502 
503  m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
504  width + aArc->GetClearance() * 2 );
505  }
506  }
507 }
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:171
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:241
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.
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:209
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 const wxPoint GetCenter() const
Function GetCenter()
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, 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 
)
protected

Definition at line 510 of file pcb_painter.cpp.

511 {
512  VECTOR2D center( aVia->GetStart() );
513  double radius = 0.0;
514 
515  // Draw description layer
516  if( IsNetnameLayer( aLayer ) )
517  {
518  VECTOR2D position( center );
519 
520  // Is anything that we can display enabled?
522  {
523  bool displayNetname = ( !aVia->GetNetname().empty() );
524  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
525  double size = aVia->GetWidth();
526 
527  // Font size limits
528  if( size > maxSize )
529  size = maxSize;
530 
531  m_gal->Save();
532  m_gal->Translate( position );
533 
534  // Default font settings
537 
538  // Set the text position to the pad shape position (the pad position is not the best place)
539  VECTOR2D textpos( 0.0, 0.0 );
540 
541  if( displayNetname )
542  {
543  wxString netname = UnescapeString( aVia->GetShortNetname() );
544  // calculate the size of net name text:
545  double tsize = 1.5 * size / netname.Length();
546  tsize = std::min( tsize, size );
547  // Use a smaller text size to handle interline, pen size..
548  tsize *= 0.7;
549  VECTOR2D namesize( tsize, tsize );
550 
551  m_gal->SetGlyphSize( namesize );
552  m_gal->SetLineWidth( namesize.x / 12.0 );
553  m_gal->BitmapText( netname, textpos, 0.0 );
554  }
555 
556 
557  m_gal->Restore();
558  }
559  return;
560  }
561 
562  // Choose drawing settings depending on if we are drawing via's pad or hole
563  if( aLayer == LAYER_VIAS_HOLES )
564  radius = getDrillSize( aVia ) / 2.0;
565  else
566  radius = aVia->GetWidth() / 2.0;
567 
568  bool sketchMode = false;
569  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
570 
571  switch( aVia->GetViaType() )
572  {
573  case VIATYPE::THROUGH:
575  break;
576 
579  break;
580 
581  case VIATYPE::MICROVIA:
583  break;
584 
585  default:
586  wxASSERT( false );
587  break;
588  }
589 
590  m_gal->SetIsFill( !sketchMode );
591  m_gal->SetIsStroke( sketchMode );
592 
593  if( sketchMode )
594  {
595  // Outline mode
598  }
599  else
600  {
601  // Filled mode
603  }
604 
605  if( ( aVia->GetViaType() == VIATYPE::BLIND_BURIED || aVia->GetViaType() == VIATYPE::MICROVIA )
606  && aLayer != LAYER_VIAS_HOLES
608  {
609  // Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
610  // top and bottom layers
611  PCB_LAYER_ID layerTop, layerBottom;
612  aVia->LayerPair( &layerTop, &layerBottom );
613 
614  if( !sketchMode )
615  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
616 
617  if( aLayer == layerTop )
618  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
619 
620  else if( aLayer == layerBottom )
621  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
622 
623  else if( aLayer == LAYER_VIA_BBLIND || aLayer == LAYER_VIA_MICROVIA )
624  {
625  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
626  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
627  }
628  }
629  else
630  {
631  // Draw the outer circles of normal vias and the holes for all vias
632  m_gal->DrawCircle( center, radius );
633  }
634 
635  // Clearance lines
636  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
637 
638  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
639  && aLayer != LAYER_VIAS_HOLES )
640  {
642  m_gal->SetIsFill( false );
643  m_gal->SetIsStroke( true );
645  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
646  }
647 }
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:171
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:241
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:166
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:203
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:209
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
VIATYPE GetViaType() const
Definition: class_track.h:368
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:189
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References KIGFX::GAL::BitmapText(), BLIND_BURIED, KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_VIAS, color, KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), BOARD_CONNECTED_ITEM::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetDrawIndividualViaLayers(), getDrillSize(), VIA::GetDrillValue(), BOARD_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, 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 
)
protected

Definition at line 650 of file pcb_painter.cpp.

651 {
652  // Draw description layer
653  if( IsNetnameLayer( aLayer ) )
654  {
655  // Is anything that we can display enabled?
657  {
658  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
659  EDA_RECT padBBox = aPad->GetBoundingBox();
660  VECTOR2D position = padBBox.Centre();
661  VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
662  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
663  double size = padsize.y;
664 
665  m_gal->Save();
666  m_gal->Translate( position );
667 
668  // Keep the size ratio for the font, but make it smaller
669  if( padsize.x < padsize.y )
670  {
671  m_gal->Rotate( DECIDEG2RAD( -900.0 ) );
672  size = padsize.x;
673  std::swap( padsize.x, padsize.y );
674  }
675 
676  // Font size limits
677  if( size > maxSize )
678  size = maxSize;
679 
680  // Default font settings
683  m_gal->SetFontBold( false );
684  m_gal->SetFontItalic( false );
685  m_gal->SetTextMirrored( false );
687  m_gal->SetIsStroke( true );
688  m_gal->SetIsFill( false );
689 
690  // We have already translated the GAL to be centered at the center of the pad's
691  // bounding box
692  VECTOR2D textpos( 0.0, 0.0 );
693 
694  // Divide the space, to display both pad numbers and netnames and set the Y text
695  // position to display 2 lines
696  if( displayNetname && m_pcbSettings.m_padNumbers )
697  {
698  size = size / 2.0;
699  textpos.y = size / 2.0;
700  }
701 
702  if( displayNetname )
703  {
704  wxString netname = UnescapeString( aPad->GetShortNetname() );
705  // calculate the size of net name text:
706  double tsize = 1.5 * padsize.x / netname.Length();
707  tsize = std::min( tsize, size );
708  // Use a smaller text size to handle interline, pen size..
709  tsize *= 0.7;
710  VECTOR2D namesize( tsize, tsize );
711 
712  m_gal->SetGlyphSize( namesize );
713  m_gal->SetLineWidth( namesize.x / 12.0 );
714  m_gal->BitmapText( netname, textpos, 0.0 );
715  }
716 
718  {
719  const wxString& padName = aPad->GetName();
720  textpos.y = -textpos.y;
721  double tsize = 1.5 * padsize.x / padName.Length();
722  tsize = std::min( tsize, size );
723  // Use a smaller text size to handle interline, pen size..
724  tsize *= 0.7;
725  tsize = std::min( tsize, size );
726  VECTOR2D numsize( tsize, tsize );
727 
728  m_gal->SetGlyphSize( numsize );
729  m_gal->SetLineWidth( numsize.x / 12.0 );
730  m_gal->BitmapText( padName, textpos, 0.0 );
731  }
732 
733  m_gal->Restore();
734  }
735  return;
736  }
737 
738  // Pad drawing
739  COLOR4D color;
740 
741  // Pad hole color is pad-type-specific: the background color for plated holes and the
742  // pad color for NPTHs. Note the extra check for "should be" NPTHs to keep mis-marked
743  // holes with no annular ring from getting "lost" in the background.
744  if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() )
746  else
747  color = m_pcbSettings.GetColor( aPad, aLayer );
748 
750  {
751  // Outline mode
752  m_gal->SetIsFill( false );
753  m_gal->SetIsStroke( true );
756  }
757  else
758  {
759  // Filled mode
760  m_gal->SetIsFill( true );
761  m_gal->SetIsStroke( false );
763  }
764 
765  // Choose drawing settings depending on if we are drawing a pad itself or a hole
766  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
767  {
768  const std::shared_ptr<SHAPE_SEGMENT>& seg = aPad->GetEffectiveHoleShape();
769 
770  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() );
771  }
772  else
773  {
774  wxSize pad_size = aPad->GetSize();
775  wxSize margin;
776 
777  switch( aLayer )
778  {
779  case F_Mask:
780  case B_Mask:
781  margin.x = margin.y = aPad->GetSolderMaskMargin();
782  break;
783 
784  case F_Paste:
785  case B_Paste:
786  margin = aPad->GetSolderPasteMargin();
787  break;
788 
789  default:
790  margin.x = margin.y = 0;
791  break;
792  }
793 
794  if( margin.x != margin.y )
795  {
796  const_cast<D_PAD*>( aPad )->SetSize( pad_size + margin + margin );
797  margin.x = margin.y = 0;
798  }
799 
800  const std::vector<std::shared_ptr<SHAPE>>& shapes = aPad->GetEffectiveShapes();
801 
802  if( shapes.size() == 1 && shapes[0]->Type() == SH_SEGMENT )
803  {
804  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shapes[0].get();
805  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() + 2 * margin.x );
806  }
807  else if( shapes.size() == 1 && shapes[0]->Type() == SH_CIRCLE )
808  {
809  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shapes[0].get();
810  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + margin.x );
811  }
812  else
813  {
814  SHAPE_POLY_SET polySet;
815  aPad->TransformShapeWithClearanceToPolygon( polySet, margin.x );
816  m_gal->DrawPolygon( polySet );
817  }
818 
819  if( aPad->GetSize() != pad_size )
820  const_cast<D_PAD*>( aPad )->SetSize( pad_size );
821  }
822 
823  // Clearance outlines
824  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
825 
826  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
827  && ( aLayer == LAYER_PAD_FR
828  || aLayer == LAYER_PAD_BK
829  || aLayer == LAYER_PADS_TH ) )
830  {
832  m_gal->SetIsStroke( true );
833  m_gal->SetIsFill( false );
835  int clearance = aPad->GetClearance();
836 
837  const std::vector<std::shared_ptr<SHAPE>>& shapes = aPad->GetEffectiveShapes();
838 
839  if( shapes.size() == 1 && shapes[0]->Type() == SH_SEGMENT )
840  {
841  const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shapes[0].get();
842  m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() + 2 * clearance );
843  }
844  else if( shapes.size() == 1 && shapes[0]->Type() == SH_CIRCLE )
845  {
846  const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shapes[0].get();
847  m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
848  }
849  else
850  {
851  SHAPE_POLY_SET polySet;
852  aPad->TransformShapeWithClearanceToPolygon( polySet, clearance );
853  m_gal->DrawPolygon( polySet );
854  }
855  }
856 }
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:92
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)
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:171
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:180
const VECTOR2I GetCenter() const
Definition: shape_circle.h:97
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:241
const std::vector< std::shared_ptr< SHAPE > > & GetEffectiveShapes() const
Function GetEffectiveShapes Returns a list of SHAPE objects representing the pad's copper.
Definition: class_pad.cpp:194
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:183
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
Definition: shape_segment.h:94
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:531
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:203
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
const std::shared_ptr< SHAPE_SEGMENT > & GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a list of SHAPE objects representing the pad's hole.
Definition: class_pad.cpp:203
const wxString & GetName() const
Definition: class_pad.h:128
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:209
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:576
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: pcb_painter.h:151
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.
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:220
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:965
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: class_pad.cpp:371
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::GetEffectiveShapes(), D_PAD::GetName(), BOARD_CONNECTED_ITEM::GetNetname(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), BOARD_CONNECTED_ITEM::GetShortNetname(), EDA_RECT::GetSize(), D_PAD::GetSize(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), SHAPE_SEGMENT::GetWidth(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, IsNetnameLayer(), LAYER_NON_PLATEDHOLES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH, KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnPads, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_RENDER_SETTINGS::m_padNumbers, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::PCB_RENDER_SETTINGS::MAX_FONT_SIZE, NULL, 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 
)
protected

Definition at line 859 of file pcb_painter.cpp.

860 {
861  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
862  bool sketch = m_pcbSettings.m_sketchGraphics;
863  int thickness = getLineThickness( aSegment->GetWidth() );
864  VECTOR2D start( aSegment->GetStart() );
865  VECTOR2D end( aSegment->GetEnd() );
866 
867  m_gal->SetIsFill( !sketch );
868  m_gal->SetIsStroke( sketch );
872 
873  switch( aSegment->GetShape() )
874  {
875  case S_SEGMENT:
876  m_gal->DrawSegment( start, end, thickness );
877  break;
878 
879  case S_RECT:
880  {
881  std::vector<wxPoint> pts;
882  aSegment->GetRectCorners( &pts );
883 
884  if( aSegment->GetWidth() > 0 )
885  {
886  m_gal->DrawSegment( pts[0], pts[1], thickness );
887  m_gal->DrawSegment( pts[1], pts[2], thickness );
888  m_gal->DrawSegment( pts[2], pts[3], thickness );
889  m_gal->DrawSegment( pts[3], pts[0], thickness );
890  }
891  else
892  {
893  SHAPE_POLY_SET poly;
894  poly.NewOutline();
895 
896  for( const wxPoint& pt : pts )
897  poly.Append( pt );
898 
899  m_gal->DrawPolygon( poly );
900  }
901  }
902  break;
903 
904  case S_ARC:
905  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
906  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
907  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
908  thickness );
909  break;
910 
911  case S_CIRCLE:
912  if( sketch )
913  {
914  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
915  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
916  }
917  else
918  {
919  m_gal->SetLineWidth( thickness );
920  m_gal->SetIsFill( aSegment->GetWidth() == 0 );
921  m_gal->SetIsStroke( aSegment->GetWidth() > 0 );
922  m_gal->DrawCircle( start, aSegment->GetRadius() );
923  }
924  break;
925 
926  case S_POLYGON:
927  {
928  SHAPE_POLY_SET& shape = const_cast<DRAWSEGMENT*>( aSegment )->GetPolyShape();
929 
930  if( shape.OutlineCount() == 0 )
931  break;
932 
933  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
934  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
935  // on Opengl.
936  // GLU tesselation is much slower, so currently we are using our tesselation.
937  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
938  {
939  shape.CacheTriangulation();
940  }
941 
942  m_gal->Save();
943 
944  if( MODULE* module = aSegment->GetParentModule() )
945  {
946  m_gal->Translate( module->GetPosition() );
947  m_gal->Rotate( -module->GetOrientationRadians() );
948  }
949 
950  m_gal->SetLineWidth( thickness );
951 
952  if( sketch )
953  m_gal->SetIsFill( false );
954  else
955  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
956 
957  m_gal->SetIsStroke( true );
958  m_gal->DrawPolygon( shape );
959 
960  m_gal->Restore();
961  break;
962  }
963 
964  case S_CURVE:
965  m_gal->SetIsFill( false );
966  m_gal->SetIsStroke( true );
967  m_gal->SetLineWidth( thickness );
968  // Use thickness as filter value to convert the curve to polyline
969  // when the curve is not supported
970  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
971  VECTOR2D( aSegment->GetBezControl1() ),
972  VECTOR2D( aSegment->GetBezControl2() ),
973  VECTOR2D( aSegment->GetEnd() ), thickness );
974  break;
975 
976  case S_LAST:
977  break;
978  }
979 }
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:241
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:174
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(), getLineThickness(), DRAWSEGMENT::GetParentModule(), DRAWSEGMENT::GetRadius(), DRAWSEGMENT::GetRectCorners(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), KIGFX::GAL::IsOpenGlEngine(), DRAWSEGMENT::IsPolygonFilled(), SHAPE_POLY_SET::IsTriangulationUpToDate(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchGraphics, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), KIGFX::GAL::Restore(), KIGFX::GAL::Rotate(), S_ARC, S_CIRCLE, S_CURVE, S_LAST, S_POLYGON, S_RECT, S_SEGMENT, KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and KIGFX::GAL::Translate().

◆ draw() [6/12]

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

Definition at line 982 of file pcb_painter.cpp.

983 {
984  wxString shownText( aText->GetShownText() );
985 
986  if( shownText.Length() == 0 )
987  return;
988 
989  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
990  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
991 
993  {
994  // Outline mode
996  }
997  else
998  {
999  // Filled mode
1001  }
1002 
1004  m_gal->SetIsFill( false );
1005  m_gal->SetIsStroke( true );
1006  m_gal->SetTextAttributes( aText );
1007  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1008 }
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:171
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:241
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:152
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:177
double GetTextAngleRadians() const
Definition: eda_text.h:176
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [7/12]

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

Definition at line 1011 of file pcb_painter.cpp.

1012 {
1013  wxString shownText( aText->GetShownText() );
1014 
1015  if( shownText.Length() == 0 )
1016  return;
1017 
1018  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1019  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1020 
1022  {
1023  // Outline mode
1025  }
1026  else
1027  {
1028  // Filled mode
1030  }
1031 
1033  m_gal->SetIsFill( false );
1034  m_gal->SetIsStroke( true );
1035  m_gal->SetTextAttributes( aText );
1036  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1037 
1038  // Draw the umbilical line
1039  if( aText->IsSelected() )
1040  {
1042  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1043  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1044  }
1045 }
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:241
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:152
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual const wxPoint GetPosition() const
Definition: base_struct.h:337
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:177
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:247
BOARD_ITEM_CONTAINER * GetParent() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [8/12]

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

Definition at line 1048 of file pcb_painter.cpp.

1049 {
1050  if( aLayer == LAYER_ANCHOR )
1051  {
1052  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1053 
1054  // Draw anchor
1057 
1058  // Keep the size constant, not related to the scale
1059  double anchorSize = 5.0 / m_gal->GetWorldScale();
1060 
1061  VECTOR2D center = aModule->GetPosition();
1062  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1063  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1064  }
1065 }
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:241
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.
double GetWorldScale() const
Get the world scale.
const wxPoint GetPosition() const override
Definition: class_module.h:206
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [9/12]

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

Definition at line 1068 of file pcb_painter.cpp.

1069 {
1070  PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer );
1071 
1072  if( !aZone->IsOnLayer( layer ) )
1073  return;
1074 
1075  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1076  std::deque<VECTOR2D> corners;
1078 
1079  // Draw the outline
1080  const SHAPE_POLY_SET* outline = aZone->Outline();
1081 
1082  if( m_pcbSettings.m_zoneOutlines && outline && outline->OutlineCount() > 0 )
1083  {
1085  m_gal->SetIsFill( false );
1086  m_gal->SetIsStroke( true );
1088 
1089  // Draw each contour (main contour and holes)
1090 
1091  /* This line:
1092  * m_gal->DrawPolygon( *outline );
1093  * should be enough, but currently does not work to draw holes contours in a complex polygon
1094  * so each contour is draw as a simple polygon
1095  */
1096 
1097  // Draw the main contour
1098  m_gal->DrawPolyline( outline->COutline( 0 ) );
1099 
1100  // Draw holes
1101  int holes_count = outline->HoleCount( 0 );
1102 
1103  for( int ii = 0; ii < holes_count; ++ii )
1104  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1105 
1106  // Draw hatch lines
1107  for( const SEG& hatchLine : aZone->GetHatchLines() )
1108  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1109  }
1110 
1111  // Draw the filling
1112  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1113  {
1114  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer );
1115 
1116  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1117  return;
1118 
1119  // Set up drawing options
1120  int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
1122  m_gal->SetFillColor( color );
1123  m_gal->SetLineWidth( outline_thickness );
1124 
1125  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1126  {
1127  m_gal->SetIsFill( true );
1128  m_gal->SetIsStroke( outline_thickness > 0 );
1129  }
1130  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1131  {
1132  m_gal->SetIsFill( false );
1133  m_gal->SetIsStroke( true );
1134  }
1135 
1136  m_gal->DrawPolygon( polySet );
1137  }
1138 }
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:329
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:271
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:661
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:602
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:206
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:82
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:241
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:779
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:201
bool m_zoneOutlines
Flag determining if zones should have outlines drawn
Definition: pcb_painter.h:192
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, 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 
)
protected

Definition at line 1141 of file pcb_painter.cpp.

1142 {
1143  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1144 
1145  m_gal->SetStrokeColor( strokeColor );
1146  m_gal->SetIsFill( false );
1147  m_gal->SetIsStroke( true );
1148 
1150  {
1151  // Outline mode
1153  }
1154  else
1155  {
1156  // Filled mode
1157  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1158  }
1159 
1160  // Draw an arrow
1161  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1162  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1163  VECTOR2D( aDimension->m_featureLineGF ) );
1164  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1165  VECTOR2D( aDimension->m_featureLineDF ) );
1166  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1167  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1168  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1169  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1170 
1171  // Draw text
1172  TEXTE_PCB& text = aDimension->Text();
1173  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1174 
1176  {
1177  // Outline mode
1179  }
1180  else
1181  {
1182  // Filled mode
1184  }
1185 
1186  m_gal->SetTextAttributes( &text );
1187  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1188 }
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:241
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:174
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:152
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:177
double GetTextAngleRadians() const
Definition: eda_text.h:176
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
TEXTE_PCB & Text()
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
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(), 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, 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)
protected

Definition at line 1191 of file pcb_painter.cpp.

1192 {
1193  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1194  VECTOR2D position( aTarget->GetPosition() );
1195  double size, radius;
1196 
1197  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1198  m_gal->SetStrokeColor( strokeColor );
1199  m_gal->SetIsFill( false );
1200  m_gal->SetIsStroke( true );
1201 
1202  m_gal->Save();
1203  m_gal->Translate( position );
1204 
1205  if( aTarget->GetShape() )
1206  {
1207  // shape x
1208  m_gal->Rotate( M_PI / 4.0 );
1209  size = 2.0 * aTarget->GetSize() / 3.0;
1210  radius = aTarget->GetSize() / 2.0;
1211  }
1212  else
1213  {
1214  // shape +
1215  size = aTarget->GetSize() / 2.0;
1216  radius = aTarget->GetSize() / 3.0;
1217  }
1218 
1219  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1220  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1221  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1222 
1223  m_gal->Restore();
1224 }
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:241
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.
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.
const wxPoint GetPosition() const override
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [12/12]

void PCB_PAINTER::draw ( const MARKER_PCB aMarker)
protected

Definition at line 1227 of file pcb_painter.cpp.

1228 {
1229  SHAPE_LINE_CHAIN polygon;
1230  aMarker->ShapeToPolygon( polygon );
1231 
1232  auto strokeColor = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
1233 
1234  m_gal->Save();
1235  m_gal->Translate( aMarker->GetPosition() );
1236  m_gal->SetFillColor( strokeColor );
1237  m_gal->SetIsFill( true );
1238  m_gal->SetIsStroke( false );
1239  m_gal->DrawPolygon( polygon );
1240  m_gal->Restore();
1241 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
const wxPoint GetPosition() const override
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...
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:241
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, m_pcbSettings, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), MARKER_BASE::ShapeToPolygon(), and KIGFX::GAL::Translate().

◆ getDrillShape()

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

Return drill shape of a pad.

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 308 of file pcb_painter.cpp.

309 {
310  return aPad->GetDrillShape();
311 }
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:318

References D_PAD::GetDrillShape().

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

◆ getDrillSize() [1/2]

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

Return drill size for a pad (internal units).

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 314 of file pcb_painter.cpp.

315 {
316  return VECTOR2D( aPad->GetDrillSize() );
317 }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
const wxSize & GetDrillSize() const
Definition: class_pad.h:226

References D_PAD::GetDrillSize().

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

◆ getDrillSize() [2/2]

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

Return drill diameter for a via (internal units).

Reimplemented in KIGFX::PCB_PRINT_PAINTER.

Definition at line 320 of file pcb_painter.cpp.

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

References VIA::GetDrillValue().

◆ getLineThickness()

int PCB_PAINTER::getLineThickness ( int  aActualThickness) const
protected

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

0 thickness lines get a minimum value).

Parameters
aActualThicknessline own thickness
Returns
the thickness to draw

Definition at line 296 of file pcb_painter.cpp.

297 {
298  // if items have 0 thickness, draw them with the outline
299  // width, otherwise respect the set value (which, no matter
300  // how small will produce something)
301  if( aActualThickness == 0 )
303 
304  return aActualThickness;
305 }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:241

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

Referenced by draw().

◆ GetSettings()

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

◆ SetGAL()

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

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

Parameters
aGalis the new GAL instance.

Definition at line 78 of file painter.h.

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

References KIGFX::PAINTER::m_gal.

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 113 of file painter.h.

◆ m_gal

◆ m_pcbSettings

PCB_RENDER_SETTINGS KIGFX::PCB_PAINTER::m_pcbSettings
protected

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