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
 Function GetSettings Returns pointer to current settings that are going to be used when drawing items. More...
 
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 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 226 of file pcb_painter.h.

Constructor & Destructor Documentation

◆ PCB_PAINTER()

PCB_PAINTER::PCB_PAINTER ( GAL aGal)

Definition at line 302 of file pcb_painter.cpp.

302  :
303  PAINTER( aGal )
304 {
305 }
PAINTER(GAL *aGal)
Constructor PAINTER( GAL* ) initializes this object for painting on any of the polymorphic GRAPHICS_A...
Definition: painter.cpp:68

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

233  {
234  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
235  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247

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

339 {
340  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
341 
342  if( !item )
343  return false;
344 
345  // the "cast" applied in here clarifies which overloaded draw() is called
346  switch( item->Type() )
347  {
348  case PCB_TRACE_T:
349  draw( static_cast<const TRACK*>( item ), aLayer );
350  break;
351 
352  case PCB_VIA_T:
353  draw( static_cast<const VIA*>( item ), aLayer );
354  break;
355 
356  case PCB_PAD_T:
357  draw( static_cast<const D_PAD*>( item ), aLayer );
358  break;
359 
360  case PCB_LINE_T:
361  case PCB_MODULE_EDGE_T:
362  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
363  break;
364 
365  case PCB_TEXT_T:
366  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
367  break;
368 
369  case PCB_MODULE_TEXT_T:
370  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
371  break;
372 
373  case PCB_MODULE_T:
374  draw( static_cast<const MODULE*>( item ), aLayer );
375  break;
376 
377  case PCB_ZONE_AREA_T:
378  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
379  break;
380 
382  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
383  break;
384 
385  case PCB_DIMENSION_T:
386  draw( static_cast<const DIMENSION*>( item ), aLayer );
387  break;
388 
389  case PCB_TARGET_T:
390  draw( static_cast<const PCB_TARGET*>( item ) );
391  break;
392 
393  case PCB_MARKER_T:
394  draw( static_cast<const MARKER_PCB*>( item ) );
395  break;
396 
397  default:
398  // Painter does not know how to draw the object
399  return false;
400  }
401 
402  return true;
403 }
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:101
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
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:99
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:100
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:98
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
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:207

References draw(), 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/11]

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

Definition at line 406 of file pcb_painter.cpp.

407 {
408  VECTOR2D start( aTrack->GetStart() );
409  VECTOR2D end( aTrack->GetEnd() );
410  int width = aTrack->GetWidth();
411 
413  {
414  // If there is a net name - display it on the track
415  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
416  {
417  VECTOR2D line = ( end - start );
418  double length = line.EuclideanNorm();
419 
420  // Check if the track is long enough to have a netname displayed
421  if( length < 10 * width )
422  return;
423 
424  const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
425  VECTOR2D textPosition = start + line / 2.0; // center of the track
426 
427  double textOrientation;
428 
429  if( end.y == start.y ) // horizontal
430  textOrientation = 0;
431  else if( end.x == start.x ) // vertical
432  textOrientation = M_PI / 2;
433  else
434  textOrientation = -atan( line.y / line.x );
435 
436  double textSize = width;
437 
438  m_gal->SetIsStroke( true );
439  m_gal->SetIsFill( false );
441  m_gal->SetLineWidth( width / 10.0 );
442  m_gal->SetFontBold( false );
443  m_gal->SetFontItalic( false );
444  m_gal->SetTextMirrored( false );
445  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
448  m_gal->BitmapText( netName, textPosition, textOrientation );
449  }
450  }
451  else if( IsCopperLayer( aLayer ) )
452  {
453  // Draw a regular track
454  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
455  bool outline_mode = m_pcbSettings.m_sketchMode[LAYER_TRACKS];
458  m_gal->SetIsStroke( outline_mode );
459  m_gal->SetIsFill( not outline_mode );
461 
462  m_gal->DrawSegment( start, end, width );
463 
464  // Clearance lines
465  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
466 
467  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
468  {
470  m_gal->SetIsFill( false );
471  m_gal->SetIsStroke( true );
473  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
474  }
475  }
476 }
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.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
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:109
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:176
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:247
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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.
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:194
int GetWidth() const
Definition: class_track.h:103
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:215
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
const wxPoint & GetEnd() const
Definition: class_track.h:106
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:463
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:39

References KIGFX::GAL::BitmapText(), KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_TRACKS, color, KIGFX::GAL::DrawSegment(), VECTOR2< T >::EuclideanNorm(), TRACK::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/11]

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

Definition at line 479 of file pcb_painter.cpp.

480 {
481  VECTOR2D center( aVia->GetStart() );
482  double radius = 0.0;
483 
484  // Draw description layer
485  if( IsNetnameLayer( aLayer ) )
486  {
487  VECTOR2D position( center );
488 
489  // Is anything that we can display enabled?
491  {
492  bool displayNetname = ( !aVia->GetNetname().empty() );
493  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
494  double size = aVia->GetWidth();
495 
496  // Font size limits
497  if( size > maxSize )
498  size = maxSize;
499 
500  m_gal->Save();
501  m_gal->Translate( position );
502 
503  // Default font settings
506 
507  // Set the text position to the pad shape position (the pad position is not the best place)
508  VECTOR2D textpos( 0.0, 0.0 );
509 
510  if( displayNetname )
511  {
512  wxString netname = UnescapeString( aVia->GetShortNetname() );
513  // calculate the size of net name text:
514  double tsize = 1.5 * size / netname.Length();
515  tsize = std::min( tsize, size );
516  // Use a smaller text size to handle interline, pen size..
517  tsize *= 0.7;
518  VECTOR2D namesize( tsize, tsize );
519 
520  m_gal->SetGlyphSize( namesize );
521  m_gal->SetLineWidth( namesize.x / 12.0 );
522  m_gal->BitmapText( netname, textpos, 0.0 );
523  }
524 
525 
526  m_gal->Restore();
527  }
528  return;
529  }
530 
531  // Choose drawing settings depending on if we are drawing via's pad or hole
532  if( aLayer == LAYER_VIAS_HOLES )
533  radius = getDrillSize( aVia ) / 2.0;
534  else
535  radius = aVia->GetWidth() / 2.0;
536 
537  bool sketchMode = false;
538  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
539 
540  switch( aVia->GetViaType() )
541  {
542  case VIATYPE::THROUGH:
544  break;
545 
548  break;
549 
550  case VIATYPE::MICROVIA:
552  break;
553 
554  default:
555  wxASSERT( false );
556  break;
557  }
558 
559  m_gal->SetIsFill( !sketchMode );
560  m_gal->SetIsStroke( sketchMode );
561 
562  if( sketchMode )
563  {
564  // Outline mode
567  }
568  else
569  {
570  // Filled mode
572  }
573 
574  if( aVia->GetViaType() == VIATYPE::BLIND_BURIED && aLayer != LAYER_VIAS_HOLES )
575  {
576  // Outer circles of blind/buried vias are drawn in a special way to indicate the
577  // top and bottom layers
578  PCB_LAYER_ID layerTop, layerBottom;
579  aVia->LayerPair( &layerTop, &layerBottom );
580 
581  if( !sketchMode )
582  m_gal->SetLineWidth( ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0 );
583 
584  if( aLayer == layerTop )
585  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
586 
587  else if( aLayer == layerBottom )
588  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
589 
590  else if( aLayer == LAYER_VIA_BBLIND )
591  {
592  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
593  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
594  }
595  }
596  else
597  {
598  // Draw the outer circles of normal vias and the inner circles for all vias
599  m_gal->DrawCircle( center, radius );
600  }
601 
602  // Clearance lines
603  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
604 
605  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
606  && aLayer != LAYER_VIAS_HOLES )
607  {
609  m_gal->SetIsFill( false );
610  m_gal->SetIsStroke( true );
612  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
613  }
614 }
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
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
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:109
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:176
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:247
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
PCB_LAYER_ID
A quick note on layer IDs:
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:209
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_CONNECTED_ITEM *aItem=NULL) const override
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:103
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:215
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:336
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:197
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:39

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(), TRACK::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), 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() [3/11]

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

Definition at line 617 of file pcb_painter.cpp.

618 {
619  double m, n;
620  double orientation = aPad->GetOrientation();
621 
622  // Draw description layer
623  if( IsNetnameLayer( aLayer ) )
624  {
625  VECTOR2D position( aPad->ShapePos() );
626 
627  // Is anything that we can display enabled?
629  {
630  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
631  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
632  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
633  double size = padsize.y;
634 
635  // Keep the size ratio for the font, but make it smaller
636  if( padsize.x < padsize.y )
637  {
638  orientation += 900.0;
639  size = padsize.x;
640  std::swap( padsize.x, padsize.y );
641  }
642  else if( padsize.x == padsize.y )
643  {
644  // If the text is displayed on a symmetrical pad, do not rotate it
645  orientation = 0.0;
646  }
647 
648  // Font size limits
649  if( size > maxSize )
650  size = maxSize;
651 
652  m_gal->Save();
653  m_gal->Translate( position );
654 
655  // do not display descriptions upside down
656  NORMALIZE_ANGLE_90( orientation );
657  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
658 
659  // Default font settings
662  m_gal->SetFontBold( false );
663  m_gal->SetFontItalic( false );
664  m_gal->SetTextMirrored( false );
666  m_gal->SetIsStroke( true );
667  m_gal->SetIsFill( false );
668 
669  // Set the text position to the pad shape position (the pad position is not the best place)
670  VECTOR2D textpos( 0.0, 0.0 );
671 
672  // Divide the space, to display both pad numbers and netnames
673  // and set the Y text position to display 2 lines
674  if( displayNetname && m_pcbSettings.m_padNumbers )
675  {
676  size = size / 2.0;
677  textpos.y = size / 2.0;
678  }
679 
680  if( displayNetname )
681  {
682  wxString netname = UnescapeString( aPad->GetShortNetname() );
683  // calculate the size of net name text:
684  double tsize = 1.5 * padsize.x / netname.Length();
685  tsize = std::min( tsize, size );
686  // Use a smaller text size to handle interline, pen size..
687  tsize *= 0.7;
688  VECTOR2D namesize( tsize, tsize );
689 
690  m_gal->SetGlyphSize( namesize );
691  m_gal->SetLineWidth( namesize.x / 12.0 );
692  m_gal->BitmapText( netname, textpos, 0.0 );
693  }
694 
696  {
697  const wxString& padName = aPad->GetName();
698  textpos.y = -textpos.y;
699  double tsize = 1.5 * padsize.x / padName.Length();
700  tsize = std::min( tsize, size );
701  // Use a smaller text size to handle interline, pen size..
702  tsize *= 0.7;
703  tsize = std::min( tsize, size );
704  VECTOR2D numsize( tsize, tsize );
705 
706  m_gal->SetGlyphSize( numsize );
707  m_gal->SetLineWidth( numsize.x / 12.0 );
708  m_gal->BitmapText( padName, textpos, 0.0 );
709  }
710 
711  m_gal->Restore();
712  }
713  return;
714  }
715 
716  // Pad drawing
717  COLOR4D color;
718 
719  // Pad holes color is type specific
720  // Hole color is the background color for plated holes, but only if the pad size is greater than the hole size.
721  // ( Don't let pads that *should* be NPTH get lost )
722  if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() )
723  {
725  }
726  else
727  {
728  color = m_pcbSettings.GetColor( aPad, aLayer );
729  }
730 
731  VECTOR2D size;
732 
734  {
735  // Outline mode
736  m_gal->SetIsFill( false );
737  m_gal->SetIsStroke( true );
740  }
741  else
742  {
743  // Filled mode
744  m_gal->SetIsFill( true );
745  m_gal->SetIsStroke( false );
747  }
748 
749  // Choose drawing settings depending on if we are drawing a pad itself or a hole
750  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
751  {
752  m_gal->Save();
753  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
754  m_gal->Rotate( -aPad->GetOrientationRadians() );
755 
756  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
757  size = getDrillSize( aPad ) / 2.0;
758 
759  if( getDrillShape( aPad ) == PAD_DRILL_SHAPE_OBLONG )
760  {
761  if( size.y >= size.x )
762  {
763  m = ( size.y - size.x );
764  n = size.x;
765 
766  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
767  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
768 
770  {
771  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
772  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
773  }
774  else
775  {
776  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
777  }
778  }
779  else
780  {
781  m = ( size.x - size.y );
782  n = size.y;
783  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
784  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
785 
787  {
788  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
789  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
790  }
791  else
792  {
793  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
794  }
795  }
796  }
797  else
798  {
799  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
800  }
801 
802  m_gal->Restore();
803  }
804  else
805  {
806  SHAPE_POLY_SET polySet;
807  wxSize margin;
808  int clearance = 0;
809 
810  switch( aLayer )
811  {
812  case F_Mask:
813  case B_Mask:
814  clearance += aPad->GetSolderMaskMargin();
815  break;
816 
817  case F_Paste:
818  case B_Paste:
819  margin = aPad->GetSolderPasteMargin();
820  clearance += ( margin.x + margin.y ) / 2;
821  break;
822 
823  default:
824  break;
825  }
826 
827  aPad->TransformShapeWithClearanceToPolygon( polySet, clearance );
828  m_gal->DrawPolygon( polySet );
829  }
830 
831  // Clearance lines
832  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_PADS;
833 
834  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
835  && ( aLayer == LAYER_PAD_FR
836  || aLayer == LAYER_PAD_BK
837  || aLayer == LAYER_PADS_TH ) )
838  {
839  SHAPE_POLY_SET polySet;
840  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance() );
842  m_gal->SetIsStroke( true );
843  m_gal->SetIsFill( false );
845  m_gal->DrawPolygon( polySet );
846  }
847 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
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)
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:176
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).
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:188
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void NORMALIZE_ANGLE_90(T &Angle)
Definition: trigo.h:331
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:191
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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:627
#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:209
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SHAPE_POLY_SET.
const wxString & GetName() const
Definition: class_pad.h:203
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.
double GetOrientationRadians() const
Definition: class_pad.h:424
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 Used in filli...
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:215
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:673
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:422
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: pcb_painter.h:153
wxPoint ShapePos() const
Definition: class_pad.cpp:570
double DECIDEG2RAD(double deg)
Definition: trigo.h:214
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:596
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:300
const wxPoint GetPosition() const override
Definition: class_pad.h:241
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:1321
const wxString & GetShortNetname() const
Function GetShortNetname.
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
virtual int getDrillShape(const D_PAD *aPad) const
Return drill shape of a pad.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References B_Mask, B_Paste, KIGFX::GAL::BitmapText(), KIGFX::PCB_RENDER_SETTINGS::CL_PADS, color, DECIDEG2RAD(), KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawRectangle(), F_Mask, F_Paste, KIGFX::PCB_RENDER_SETTINGS::GetBackgroundColor(), D_PAD::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), getDrillShape(), getDrillSize(), D_PAD::GetName(), BOARD_CONNECTED_ITEM::GetNetname(), D_PAD::GetOrientation(), D_PAD::GetOrientationRadians(), D_PAD::GetPosition(), BOARD_CONNECTED_ITEM::GetShortNetname(), D_PAD::GetSize(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), 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, NORMALIZE_ANGLE_90(), NULL, PAD_DRILL_SHAPE_OBLONG, 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(), D_PAD::ShapePos(), D_PAD::TransformShapeWithClearanceToPolygon(), KIGFX::GAL::Translate(), UnescapeString(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [4/11]

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

Definition at line 850 of file pcb_painter.cpp.

851 {
852  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
853  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
854  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
855 
856  int thickness = getLineThickness( aSegment->GetWidth() );
857  VECTOR2D start( aSegment->GetStart() );
858  VECTOR2D end( aSegment->GetEnd() );
859 
860  m_gal->SetIsFill( !sketch );
861  m_gal->SetIsStroke( sketch );
865 
866  switch( aSegment->GetShape() )
867  {
868  case S_SEGMENT:
869  m_gal->DrawSegment( start, end, thickness );
870  break;
871 
872  case S_RECT:
873  wxASSERT_MSG( false, "Not tested yet" );
874  m_gal->DrawRectangle( start, end );
875  break;
876 
877  case S_ARC:
878  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
879  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
880  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
881  thickness );
882  break;
883 
884  case S_CIRCLE:
885  if( sketch )
886  {
887  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
888  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
889  }
890  else
891  {
892  m_gal->SetLineWidth( thickness );
893  m_gal->SetIsFill( false );
894  m_gal->SetIsStroke( true );
895  m_gal->DrawCircle( start, aSegment->GetRadius() );
896  }
897  break;
898 
899  case S_POLYGON:
900  {
901  SHAPE_POLY_SET& shape = ((DRAWSEGMENT*)aSegment)->GetPolyShape();
902 
903  if( shape.OutlineCount() == 0 )
904  break;
905 
906  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
907  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
908  // on Opengl.
909  // GLU tesselation is much slower, so currently we are using our tesselation.
910  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
911  {
912  shape.CacheTriangulation();
913  }
914 
915  m_gal->Save();
916 
917  if( MODULE* module = aSegment->GetParentModule() )
918  {
919  m_gal->Translate( module->GetPosition() );
920  m_gal->Rotate( -module->GetOrientationRadians() );
921  }
922 
923  m_gal->SetLineWidth( thickness );
924 
925  if( sketch )
926  m_gal->SetIsFill( false );
927  else
928  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
929 
930  m_gal->SetIsStroke( true );
931  m_gal->DrawPolygon( shape );
932 
933  m_gal->Restore();
934  break;
935  }
936 
937  case S_CURVE:
938  m_gal->SetIsFill( false );
939  m_gal->SetIsStroke( true );
940  m_gal->SetLineWidth( thickness );
941  // Use thickness as filter value to convert the curve to polyline
942  // when the curve is not supported
943  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
944  VECTOR2D( aSegment->GetBezControl1() ),
945  VECTOR2D( aSegment->GetBezControl2() ),
946  VECTOR2D( aSegment->GetEnd() ), thickness );
947  break;
948 
949  case S_LAST:
950  break;
951  }
952 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
int OutlineCount() const
Returns the number of outlines in the set
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
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()
bool m_sketchBoardGfx
Flag determining if board graphic items should be outlined or stroked
Definition: pcb_painter.h:179
usual segment : line with rounded ends
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
bool IsTriangulationUpToDate() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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.
bool m_sketchFpGfx
Flag determining if footprint graphic items should be outlined or stroked
Definition: pcb_painter.h:182
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:214
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.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
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.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References SHAPE_POLY_SET::CacheTriangulation(), color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawCurve(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawRectangle(), 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::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_sketchBoardGfx, KIGFX::PCB_RENDER_SETTINGS::m_sketchFpGfx, SHAPE_POLY_SET::OutlineCount(), PCB_LINE_T, PCB_MODULE_EDGE_T, 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(), KIGFX::GAL::Translate(), and EDA_ITEM::Type().

◆ draw() [5/11]

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

Definition at line 955 of file pcb_painter.cpp.

956 {
957  wxString shownText( aText->GetShownText() );
958  if( shownText.Length() == 0 )
959  return;
960 
961  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
962  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
963 
964  if( m_pcbSettings.m_sketchMode[aLayer] )
965  {
966  // Outline mode
968  }
969  else
970  {
971  // Filled mode
973  }
974 
976  m_gal->SetIsFill( false );
977  m_gal->SetIsStroke( true );
978  m_gal->SetTextAttributes( aText );
979  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians(), GetTextMarkupFlags() );
980 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
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:176
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
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetTextMarkupFlags()
Definition: gr_text.cpp:55
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, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.
double GetTextAngleRadians() const
Definition: eda_text.h:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
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:39

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

◆ draw() [6/11]

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

Definition at line 983 of file pcb_painter.cpp.

984 {
985  wxString shownText( aText->GetShownText() );
986  if( shownText.Length() == 0 )
987  return;
988 
989  bool sketch = m_pcbSettings.m_sketchFpTxtfx;
990 
991  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
992  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
993 
994  // Currently, draw text routines do not know the true outline mode.
995  // so draw the text in "line" mode (no thickness)
996  if( sketch )
997  {
998  // Outline mode
1000  }
1001  else
1002  {
1003  // Filled mode
1005  }
1006 
1008  m_gal->SetIsFill( false );
1009  m_gal->SetIsStroke( true );
1010  m_gal->SetTextAttributes( aText );
1011  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians(), GetTextMarkupFlags() );
1012 
1013  // Draw the umbilical line
1014  if( aText->IsSelected() )
1015  {
1017  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1018  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1019  }
1020 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:223
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
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
bool m_sketchFpTxtfx
Flag determining if footprint text items should be outlined or stroked
Definition: pcb_painter.h:185
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247
virtual wxString GetShownText() const override
Return the string actually shown after processing of the base text.
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetTextMarkupFlags()
Definition: gr_text.cpp:55
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, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.
virtual const wxPoint GetPosition() const =0
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
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:39

References color, KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), TEXTE_MODULE::GetDrawRotationRadians(), getLineThickness(), BOARD_ITEM::GetParent(), BOARD_ITEM::GetPosition(), TEXTE_MODULE::GetShownText(), GetTextMarkupFlags(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetThickness(), EDA_ITEM::IsSelected(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchFpTxtfx, 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/11]

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

Definition at line 1023 of file pcb_painter.cpp.

1024 {
1025  if( aLayer == LAYER_ANCHOR )
1026  {
1027  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1028 
1029  // Draw anchor
1032 
1033  // Keep the size constant, not related to the scale
1034  double anchorSize = 5.0 / m_gal->GetWorldScale();
1035 
1036  VECTOR2D center = aModule->GetPosition();
1037  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1038  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1039  }
1040 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
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:247
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:365
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:210
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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() [8/11]

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

Definition at line 1043 of file pcb_painter.cpp.

1044 {
1045  if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
1046  return;
1047 
1048  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1049  std::deque<VECTOR2D> corners;
1051 
1052  // Draw the outline
1053  const SHAPE_POLY_SET* outline = aZone->Outline();
1054 
1055  if( m_pcbSettings.m_zoneOutlines && outline )
1056  {
1058  m_gal->SetIsFill( false );
1059  m_gal->SetIsStroke( true );
1061 
1062  // Draw each contour (main contour and holes)
1063 
1064  /* This line:
1065  * m_gal->DrawPolygon( *outline );
1066  * should be enough, but currently does not work to draw holes contours in a complex polygon
1067  * so each contour is draw as a simple polygon
1068  */
1069 
1070  // Draw the main contour
1071  m_gal->DrawPolyline( outline->COutline( 0 ) );
1072 
1073  // Draw holes
1074  int holes_count = outline->HoleCount( 0 );
1075 
1076  for( int ii = 0; ii < holes_count; ++ii )
1077  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1078 
1079  // Draw hatch lines
1080  for( const SEG& hatchLine : aZone->GetHatchLines() )
1081  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1082  }
1083 
1084  // Draw the filling
1085  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1086  {
1087  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1088 
1089  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1090  return;
1091 
1092  // Set up drawing options
1093  int outline_thickness = aZone->GetFilledPolysUseThickness() ? aZone->GetMinThickness() : 0;
1095  m_gal->SetFillColor( color );
1096  m_gal->SetLineWidth( outline_thickness );
1097 
1098  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1099  {
1100  m_gal->SetIsFill( true );
1101  m_gal->SetIsStroke( outline_thickness > 0 );
1102  }
1103  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1104  {
1105  m_gal->SetIsFill( false );
1106  m_gal->SetIsStroke( true );
1107  }
1108 
1109  m_gal->DrawPolygon( polySet );
1110  }
1111 
1112 }
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
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
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:247
bool GetFilledPolysUseThickness() const
Definition: class_zone.h:599
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:212
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:83
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247
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:365
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:688
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:186
bool m_zoneOutlines
Flag determining if zones should have outlines drawn
Definition: pcb_painter.h:200
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:553
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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() [9/11]

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

Definition at line 1115 of file pcb_painter.cpp.

1116 {
1117  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1118 
1119  m_gal->SetStrokeColor( strokeColor );
1120  m_gal->SetIsFill( false );
1121  m_gal->SetIsStroke( true );
1122  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1123 
1124  // Draw an arrow
1125  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1126  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1127  VECTOR2D( aDimension->m_featureLineGF ) );
1128  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1129  VECTOR2D( aDimension->m_featureLineDF ) );
1130  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1131  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1132  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1133  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1134 
1135  // Draw text
1136  TEXTE_PCB& text = aDimension->Text();
1137  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1138 
1139  m_gal->SetLineWidth( text.GetThickness() );
1140  m_gal->SetTextAttributes( &text );
1141  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians(),
1142  GetTextMarkupFlags() );
1143 }
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
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
wxPoint m_featureLineDF
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxPoint m_featureLineGO
int GetTextMarkupFlags()
Definition: gr_text.cpp:55
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.
wxPoint m_arrowG1F
wxPoint m_arrowD2F
wxPoint m_arrowG2F
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.
double GetTextAngleRadians() const
Definition: eda_text.h:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
TEXTE_PCB & Text()
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
wxPoint m_crossBarO
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
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:39
wxPoint m_featureLineGF

References KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), getLineThickness(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), GetTextMarkupFlags(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetThickness(), 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, m_pcbSettings, 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() [10/11]

void PCB_PAINTER::draw ( const PCB_TARGET aTarget)
protected

Definition at line 1146 of file pcb_painter.cpp.

1147 {
1148  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1149  VECTOR2D position( aTarget->GetPosition() );
1150  double size, radius;
1151 
1152  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1153  m_gal->SetStrokeColor( strokeColor );
1154  m_gal->SetIsFill( false );
1155  m_gal->SetIsStroke( true );
1156 
1157  m_gal->Save();
1158  m_gal->Translate( position );
1159 
1160  if( aTarget->GetShape() )
1161  {
1162  // shape x
1163  m_gal->Rotate( M_PI / 4.0 );
1164  size = 2.0 * aTarget->GetSize() / 3.0;
1165  radius = aTarget->GetSize() / 2.0;
1166  }
1167  else
1168  {
1169  // shape +
1170  size = aTarget->GetSize() / 2.0;
1171  radius = aTarget->GetSize() / 3.0;
1172  }
1173 
1174  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1175  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1176  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1177 
1178  m_gal->Restore();
1179 }
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:247
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:365
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:39

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() [11/11]

void PCB_PAINTER::draw ( const MARKER_PCB aMarker)
protected

Definition at line 1182 of file pcb_painter.cpp.

1183 {
1184  SHAPE_LINE_CHAIN polygon;
1185  aMarker->ShapeToPolygon( polygon );
1186 
1187  auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
1188 
1189  m_gal->Save();
1190  m_gal->Translate( aMarker->GetPosition() );
1191  m_gal->SetFillColor( strokeColor );
1192  m_gal->SetIsFill( true );
1193  m_gal->SetIsStroke( false );
1194  m_gal->DrawPolygon( polygon );
1195  m_gal->Restore();
1196 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
const wxPoint GetPosition() const override
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:247
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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::GetPosition(), LAYER_DRC, 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 320 of file pcb_painter.cpp.

321 {
322  return aPad->GetDrillShape();
323 }
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:428

References D_PAD::GetDrillShape().

Referenced by draw(), and 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 326 of file pcb_painter.cpp.

327 {
328  return VECTOR2D( aPad->GetDrillSize() );
329 }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
const wxSize & GetDrillSize() const
Definition: class_pad.h:306

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

333 {
334  return aVia->GetDrillValue();
335 }
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 308 of file pcb_painter.cpp.

309 {
310  // if items have 0 thickness, draw them with the outline
311  // width, otherwise respect the set value (which, no matter
312  // how small will produce something)
313  if( aActualThickness == 0 )
315 
316  return aActualThickness;
317 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247

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

Referenced by draw().

◆ GetSettings()

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

Function GetSettings Returns pointer to current settings that are going to be used when drawing items.

Returns
Current rendering settings.

Implements KIGFX::PAINTER.

Definition at line 238 of file pcb_painter.h.

239  {
240  return &m_pcbSettings;
241  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:247

References m_pcbSettings.

Referenced by PCB_LAYER_WIDGET::SyncLayerAlphaIndicators(), PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow(), and PANEL_PCBNEW_SETTINGS::TransferDataFromWindow().

◆ 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 333 of file painter.h.

334  {
335  m_gal = aGal;
336  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365

References KIGFX::PAINTER::m_gal.

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

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