KiCad PCB EDA Suite
KIGFX::PCB_PRINT_PAINTER Class Reference

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

#include <pcbnew_printout.h>

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

Public Member Functions

 PCB_PRINT_PAINTER (GAL *aGal)
 
void SetDrillMarks (bool aRealSize, unsigned int aSize=0)
 Set drill marks visibility and options. More...
 
virtual void ApplySettings (const RENDER_SETTINGS *aSettings) override
 Function ApplySettings Loads colors and display modes settings that are going to be used when drawing items. More...
 
virtual PCB_RENDER_SETTINGSGetSettings () override
 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

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

Protected Attributes

bool m_drillMarkReal
 

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

More...
 
int m_drillMarkSize
 

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

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

Detailed Description

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

Definition at line 83 of file pcbnew_printout.h.

Constructor & Destructor Documentation

KIGFX::PCB_PRINT_PAINTER::PCB_PRINT_PAINTER ( GAL aGal)

Definition at line 213 of file pcbnew_printout.cpp.

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

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

Member Function Documentation

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

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

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 217 of file pcb_painter.h.

218  {
219  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
220  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
bool PCB_PAINTER::Draw ( const VIEW_ITEM aItem,
int  aLayer 
)
overridevirtualinherited

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

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

Implements KIGFX::PAINTER.

Definition at line 302 of file pcb_painter.cpp.

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

303 {
304  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
305 
306  if( !item )
307  return false;
308 
309  // the "cast" applied in here clarifies which overloaded draw() is called
310  switch( item->Type() )
311  {
312  case PCB_SEGZONE_T:
313  case PCB_TRACE_T:
314  draw( static_cast<const TRACK*>( item ), aLayer );
315  break;
316 
317  case PCB_VIA_T:
318  draw( static_cast<const VIA*>( item ), aLayer );
319  break;
320 
321  case PCB_PAD_T:
322  draw( static_cast<const D_PAD*>( item ), aLayer );
323  break;
324 
325  case PCB_LINE_T:
326  case PCB_MODULE_EDGE_T:
327  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
328  break;
329 
330  case PCB_TEXT_T:
331  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
332  break;
333 
334  case PCB_MODULE_TEXT_T:
335  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
336  break;
337 
338  case PCB_MODULE_T:
339  draw( static_cast<const MODULE*>( item ), aLayer );
340  break;
341 
342  case PCB_ZONE_AREA_T:
343  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
344  break;
345 
346  case PCB_DIMENSION_T:
347  draw( static_cast<const DIMENSION*>( item ), aLayer );
348  break;
349 
350  case PCB_TARGET_T:
351  draw( static_cast<const PCB_TARGET*>( item ) );
352  break;
353 
354  case PCB_MARKER_T:
355  draw( static_cast<const MARKER_PCB*>( item ) );
356  break;
357 
358  default:
359  // Painter does not know how to draw the object
360  return false;
361  }
362 
363  return true;
364 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
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:95
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
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void draw(const TRACK *aTrack, int aLayer)
class SEGZONE, a segment used to fill a zone area (segment on a
Definition: typeinfo.h:97
void PCB_PAINTER::draw ( const TRACK aTrack,
int  aLayer 
)
protectedinherited

Definition at line 367 of file pcb_painter.cpp.

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, KIGFX::PCB_PAINTER::m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, 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, VECTOR2< T >::x, and VECTOR2< T >::y.

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

368 {
369  VECTOR2D start( aTrack->GetStart() );
370  VECTOR2D end( aTrack->GetEnd() );
371  int width = aTrack->GetWidth();
372 
374  {
375  // If there is a net name - display it on the track
376  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
377  {
378  VECTOR2D line = ( end - start );
379  double length = line.EuclideanNorm();
380 
381  // Check if the track is long enough to have a netname displayed
382  if( length < 10 * width )
383  return;
384 
385  const wxString& netName = aTrack->GetShortNetname();
386  VECTOR2D textPosition = start + line / 2.0; // center of the track
387 
388  double textOrientation;
389 
390  if( end.y == start.y ) // horizontal
391  textOrientation = 0;
392  else if( end.x == start.x ) // vertical
393  textOrientation = M_PI / 2;
394  else
395  textOrientation = -atan( line.y / line.x );
396 
397  double textSize = width;
398 
399  m_gal->SetIsStroke( true );
400  m_gal->SetIsFill( false );
401  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
402  m_gal->SetLineWidth( width / 10.0 );
403  m_gal->SetFontBold( false );
404  m_gal->SetFontItalic( false );
405  m_gal->SetTextMirrored( false );
406  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
409  m_gal->BitmapText( netName, textPosition, textOrientation );
410  }
411  }
412  else if( IsCopperLayer( aLayer ) )
413  {
414  // Draw a regular track
415  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
416  m_gal->SetStrokeColor( color );
417  m_gal->SetIsStroke( true );
418 
420  {
421  // Outline mode
423  m_gal->SetIsFill( false );
424  }
425  else
426  {
427  // Filled mode
428  m_gal->SetFillColor( color );
429  m_gal->SetIsFill( true );
430  }
431 
432  m_gal->DrawSegment( start, end, width );
433 
434  // Clearance lines
435  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
436 
437  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
438  {
440  m_gal->SetIsFill( false );
441  m_gal->SetIsStroke( true );
442  m_gal->SetStrokeColor( color );
443  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
444  }
445  }
446 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
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:167
int color
Definition: DXF_plotter.cpp:62
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:232
const wxPoint & GetEnd() const
Definition: class_track.h:123
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
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.
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:292
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint & GetStart() const
Definition: class_track.h:126
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.
int GetNetCode() const
Function GetNetCode.
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:185
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:200
int GetWidth() const
Definition: class_track.h:120
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.
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:469
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
const wxString & GetShortNetname() const
Function GetShortNetname.
void PCB_PAINTER::draw ( const VIA aVia,
int  aLayer 
)
protectedinherited

Definition at line 449 of file pcb_painter.cpp.

References KIGFX::GAL::BitmapText(), 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(), KIGFX::PCB_PAINTER::getDrillSize(), VIA::GetDrillValue(), BOARD_CONNECTED_ITEM::GetNetname(), BOARD_CONNECTED_ITEM::GetShortNetname(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), IsNetnameLayer(), LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, VIA::LayerPair(), KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnVias, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::PCB_RENDER_SETTINGS::MAX_FONT_SIZE, min, 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(), KIGFX::GAL::Translate(), VIA_BLIND_BURIED, VIA_MICROVIA, VIA_THROUGH, and VECTOR2< T >::x.

450 {
451  VECTOR2D center( aVia->GetStart() );
452  double radius = 0.0;
453 
454  // Draw description layer
455  if( IsNetnameLayer( aLayer ) )
456  {
457  VECTOR2D position( center );
458 
459  // Is anything that we can display enabled?
461  {
462  bool displayNetname = ( !aVia->GetNetname().empty() );
463  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
464  double size = aVia->GetWidth();
465 
466  // Font size limits
467  if( size > maxSize )
468  size = maxSize;
469 
470  m_gal->Save();
471  m_gal->Translate( position );
472 
473  // Default font settings
475  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
476 
477  // Set the text position to the pad shape position (the pad position is not the best place)
478  VECTOR2D textpos( 0.0, 0.0 );
479 
480  if( displayNetname )
481  {
482  // calculate the size of net name text:
483  double tsize = 1.5 * size / aVia->GetShortNetname().Length();
484  tsize = std::min( tsize, size );
485  // Use a smaller text size to handle interline, pen size..
486  tsize *= 0.7;
487  VECTOR2D namesize( tsize, tsize );
488 
489  m_gal->SetGlyphSize( namesize );
490  m_gal->SetLineWidth( namesize.x / 12.0 );
491  m_gal->BitmapText( aVia->GetShortNetname(), textpos, 0.0 );
492  }
493 
494 
495  m_gal->Restore();
496  }
497  return;
498  }
499 
500  // Choose drawing settings depending on if we are drawing via's pad or hole
501  if( aLayer == LAYER_VIAS_HOLES )
502  radius = getDrillSize( aVia ) / 2.0;
503  else
504  radius = aVia->GetWidth() / 2.0;
505 
506  bool sketchMode = false;
507  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
508 
509  switch( aVia->GetViaType() )
510  {
511  case VIA_THROUGH:
513  break;
514 
515  case VIA_BLIND_BURIED:
517  break;
518 
519  case VIA_MICROVIA:
521  break;
522 
523  default:
524  assert( false );
525  break;
526  }
527 
528  if( aVia->GetViaType() == VIA_BLIND_BURIED )
529  {
530  // Buried vias are drawn in a special way to indicate the top and bottom layers
531  PCB_LAYER_ID layerTop, layerBottom;
532  aVia->LayerPair( &layerTop, &layerBottom );
533 
534  if( aLayer == LAYER_VIAS_HOLES )
535  { // TODO outline mode
536  m_gal->SetIsFill( true );
537  m_gal->SetIsStroke( false );
538  m_gal->SetFillColor( color );
539  m_gal->DrawCircle( center, radius );
540  }
541  else
542  {
543  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
544 
545  m_gal->SetLineWidth( width );
546  m_gal->SetIsFill( true );
547  m_gal->SetIsStroke( false );
548  m_gal->SetFillColor( color );
549 
550  if( aLayer == layerTop )
551  {
552  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
553  }
554  else if( aLayer == layerBottom )
555  {
556  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
557  }
558  else if( aLayer == LAYER_VIA_BBLIND )
559  {
560  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
561  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
562  }
563  }
564  }
565  else
566  {
567  // Regular vias
568  m_gal->SetIsFill( !sketchMode );
569  m_gal->SetIsStroke( sketchMode );
570 
571  if( sketchMode )
572  {
573  // Outline mode
575  m_gal->SetStrokeColor( color );
576  }
577  else
578  {
579  // Filled mode
580  m_gal->SetFillColor( color );
581  }
582 
583  m_gal->DrawCircle( center, radius );
584  }
585 
586  // Clearance lines
587  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
588 
589  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
590  && aLayer != LAYER_VIAS_HOLES )
591  {
593  m_gal->SetIsFill( false );
594  m_gal->SetIsStroke( true );
595  m_gal->SetStrokeColor( color );
596  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
597  }
598 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
to draw blind/buried vias
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
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:167
int color
Definition: DXF_plotter.cpp:62
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...
to draw via holes (pad holes do not use this layer)
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
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.
VIATYPE_T GetViaType() const
Definition: class_track.h:461
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:194
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint & GetStart() const
Definition: class_track.h:126
to draw usual through hole vias
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
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...
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
const wxString & GetNetname() const
Function GetNetname.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:200
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
int GetWidth() const
Definition: class_track.h:120
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
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.
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:188
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
#define min(a, b)
Definition: auxiliary.h:85
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
const wxString & GetShortNetname() const
Function GetShortNetname.
void PCB_PAINTER::draw ( const D_PAD aPad,
int  aLayer 
)
protectedinherited

Definition at line 601 of file pcb_painter.cpp.

References SHAPE_POLY_SET::Append(), ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF, B_Mask, B_Paste, KIGFX::GAL::BitmapText(), D_PAD::BuildPadPolygon(), 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, D_PAD::GetAttribute(), KIGFX::PCB_RENDER_SETTINGS::GetBackgroundColor(), D_PAD::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), D_PAD::GetCustomShapeAsPolygon(), KIGFX::PCB_PAINTER::getDrillShape(), KIGFX::PCB_PAINTER::getDrillSize(), D_PAD::GetName(), BOARD_CONNECTED_ITEM::GetNetname(), D_PAD::GetOffset(), D_PAD::GetOrientation(), D_PAD::GetOrientationRadians(), D_PAD::GetPosition(), D_PAD::GetRoundRectCornerRadius(), D_PAD::GetShape(), BOARD_CONNECTED_ITEM::GetShortNetname(), D_PAD::GetSize(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, SHAPE_POLY_SET::Inflate(), IsNetnameLayer(), LAYER_NON_PLATEDHOLES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH, KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnPads, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_RENDER_SETTINGS::m_padNumbers, KIGFX::PCB_PAINTER::m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::PCB_RENDER_SETTINGS::MAX_FONT_SIZE, min, SHAPE_POLY_SET::NewOutline(), NORMALIZE_ANGLE_90(), PAD_ATTRIB_HOLE_NOT_PLATED, PAD_DRILL_SHAPE_OBLONG, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, 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(), TransformRoundRectToPolygon(), D_PAD::TransformShapeWithClearanceToPolygon(), KIGFX::GAL::Translate(), VECTOR2< T >::x, and VECTOR2< T >::y.

602 {
603  PAD_SHAPE_T shape;
604  double m, n;
605  double orientation = aPad->GetOrientation();
606 
607  // Draw description layer
608  if( IsNetnameLayer( aLayer ) )
609  {
610  VECTOR2D position( aPad->ShapePos() );
611 
612  // Is anything that we can display enabled?
614  {
615  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
616  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
617  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
618  double size = padsize.y;
619 
620  // Keep the size ratio for the font, but make it smaller
621  if( padsize.x < padsize.y )
622  {
623  orientation += 900.0;
624  size = padsize.x;
625  std::swap( padsize.x, padsize.y );
626  }
627  else if( padsize.x == padsize.y )
628  {
629  // If the text is displayed on a symmetrical pad, do not rotate it
630  orientation = 0.0;
631  }
632 
633  // Font size limits
634  if( size > maxSize )
635  size = maxSize;
636 
637  m_gal->Save();
638  m_gal->Translate( position );
639 
640  // do not display descriptions upside down
641  NORMALIZE_ANGLE_90( orientation );
642  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
643 
644  // Default font settings
647  m_gal->SetFontBold( false );
648  m_gal->SetFontItalic( false );
649  m_gal->SetTextMirrored( false );
650  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
651  m_gal->SetIsStroke( true );
652  m_gal->SetIsFill( false );
653 
654  // Set the text position to the pad shape position (the pad position is not the best place)
655  VECTOR2D textpos( 0.0, 0.0 );
656 
657  // Divide the space, to display both pad numbers and netnames
658  // and set the Y text position to display 2 lines
659  if( displayNetname && m_pcbSettings.m_padNumbers )
660  {
661  size = size / 2.0;
662  textpos.y = size / 2.0;
663  }
664 
665  if( displayNetname )
666  {
667  // calculate the size of net name text:
668  double tsize = 1.5 * padsize.x / aPad->GetShortNetname().Length();
669  tsize = std::min( tsize, size );
670  // Use a smaller text size to handle interline, pen size..
671  tsize *= 0.7;
672  VECTOR2D namesize( tsize, tsize );
673 
674  m_gal->SetGlyphSize( namesize );
675  m_gal->SetLineWidth( namesize.x / 12.0 );
676  m_gal->BitmapText( aPad->GetShortNetname(), textpos, 0.0 );
677  }
678 
680  {
681  const wxString& padName = aPad->GetName();
682  textpos.y = -textpos.y;
683  double tsize = 1.5 * padsize.x / padName.Length();
684  tsize = std::min( tsize, size );
685  // Use a smaller text size to handle interline, pen size..
686  tsize *= 0.7;
687  tsize = std::min( tsize, size );
688  VECTOR2D numsize( tsize, tsize );
689 
690  m_gal->SetGlyphSize( numsize );
691  m_gal->SetLineWidth( numsize.x / 12.0 );
692  m_gal->BitmapText( padName, textpos, 0.0 );
693  }
694 
695  m_gal->Restore();
696  }
697  return;
698  }
699 
700  // Pad drawing
701  COLOR4D color;
702 
703  // Pad holes color is type specific
704  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
705  {
706  // Hole color is the background color for plated holes, but a specific color
707  // for not plated holes (LAYER_NON_PLATEDHOLES color layer )
709  color = m_pcbSettings.GetColor( nullptr, LAYER_NON_PLATEDHOLES );
710  // Don't let pads that *should* be NPTH get lost
711  else if( aPad->PadShouldBeNPTH() )
712  color = m_pcbSettings.GetColor( aPad, aLayer );
713  else
715  }
716  else
717  {
718  color = m_pcbSettings.GetColor( aPad, aLayer );
719  }
720 
721  VECTOR2D size;
722 
724  {
725  // Outline mode
726  m_gal->SetIsFill( false );
727  m_gal->SetIsStroke( true );
729  m_gal->SetStrokeColor( color );
730  }
731  else
732  {
733  // Filled mode
734  m_gal->SetIsFill( true );
735  m_gal->SetIsStroke( false );
736  m_gal->SetFillColor( color );
737  }
738 
739  m_gal->Save();
740  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
741  m_gal->Rotate( -aPad->GetOrientationRadians() );
742 
743  int custom_margin = 0; // a clearance/margin for custom shape, for solder paste/mask
744 
745  // Choose drawing settings depending on if we are drawing a pad itself or a hole
746  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
747  {
748  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
749  size = getDrillSize( aPad ) / 2.0;
751  }
752  else if( aLayer == F_Mask || aLayer == B_Mask )
753  {
754  // Drawing soldermask
755  int soldermaskMargin = aPad->GetSolderMaskMargin();
756  custom_margin = soldermaskMargin;
757 
758  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
759  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
760  aPad->GetSize().y / 2.0 + soldermaskMargin );
761  shape = aPad->GetShape();
762  }
763  else if( aLayer == F_Paste || aLayer == B_Paste )
764  {
765  // Drawing solderpaste
766  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
767  // try to find a clearance which can be used for custom shapes
768  custom_margin = solderpasteMargin.x;
769 
770  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
771  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
772  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
773  shape = aPad->GetShape();
774  }
775  else
776  {
777  // Drawing every kind of pad
778  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
779  size = VECTOR2D( aPad->GetSize() ) / 2.0;
780  shape = aPad->GetShape();
781  }
782 
783  switch( shape )
784  {
785  case PAD_SHAPE_OVAL:
786  if( size.y >= size.x )
787  {
788  m = ( size.y - size.x );
789  n = size.x;
790 
792  {
793  // Outline mode
794  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
795  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
796  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
797  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
798  }
799  else
800  {
801  // Filled mode
802  m_gal->DrawCircle( VECTOR2D( 0, -m ), n );
803  m_gal->DrawCircle( VECTOR2D( 0, m ), n );
804  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
805  }
806  }
807  else
808  {
809  m = ( size.x - size.y );
810  n = size.y;
811 
813  {
814  // Outline mode
815  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
816  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
817  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
818  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
819  }
820  else
821  {
822  // Filled mode
823  m_gal->DrawCircle( VECTOR2D( -m, 0 ), n );
824  m_gal->DrawCircle( VECTOR2D( m, 0 ), n );
825  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
826  }
827  }
828  break;
829 
830  case PAD_SHAPE_RECT:
831  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
832  break;
833 
834  case PAD_SHAPE_ROUNDRECT:
835  {
836  SHAPE_POLY_SET polySet;
837  wxSize prsize( size.x * 2, size.y * 2 );
838  const int segmentToCircleCount = 64;
839  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
840  TransformRoundRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
841  0.0, corner_radius, segmentToCircleCount );
842  m_gal->DrawPolygon( polySet );
843  break;
844  }
845 
846  case PAD_SHAPE_CUSTOM:
847  { // Draw the complex custom shape
848 
849  // Use solder[Paste/Mask]size or pad size to build pad shape
850  // however, solder[Paste/Mask] size has no actual meaning for a
851  // custom shape, because it is a set of basic shapes
852  // We use the custom_margin (good for solder mask, but approximative
853  // for solder paste).
854  if( custom_margin )
855  {
856  SHAPE_POLY_SET outline;
857  outline.Append( aPad->GetCustomShapeAsPolygon() );
858  const int segmentToCircleCount = ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF;
859  outline.Inflate( custom_margin, segmentToCircleCount );
860  m_gal->DrawPolygon( outline );
861  }
862  else
863  {
864  // Draw the polygon: only one polygon is expected
865  // However we provide a multi polygon shape drawing
866  // ( for the future or to show even an incorrect shape
868  }
869  }
870  break;
871 
872  case PAD_SHAPE_TRAPEZOID:
873  {
874  std::deque<VECTOR2D> pointList;
875  wxPoint corners[4];
876 
877  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
878  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
879 
880  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
881  SHAPE_POLY_SET polySet;
882  polySet.NewOutline();
883  polySet.Append( VECTOR2I( corners[0] ) );
884  polySet.Append( VECTOR2I( corners[1] ) );
885  polySet.Append( VECTOR2I( corners[2] ) );
886  polySet.Append( VECTOR2I( corners[3] ) );
887 
888  m_gal->DrawPolygon( polySet );
889  }
890  break;
891 
892  case PAD_SHAPE_CIRCLE:
893  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
894  break;
895  }
896 
897  m_gal->Restore();
898 
899  // Clearance lines
900  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
901  // returns already transformed coordinates
902  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
903 
904  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
905  && ( aLayer == LAYER_PAD_FR
906  || aLayer == LAYER_PAD_BK
907  || aLayer == LAYER_PADS_TH ) )
908  {
909  SHAPE_POLY_SET polySet;
910  constexpr int SEGCOUNT = 64;
911  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
913  m_gal->SetIsStroke( true );
914  m_gal->SetIsFill( false );
915  m_gal->SetStrokeColor( color );
916  m_gal->DrawPolygon( polySet );
917  }
918 }
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.
virtual int getDrillShape(const D_PAD *aPad) const
Return drill shape of a pad.
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
multilayer pads, usually with holes
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:341
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
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:167
void TransformRoundRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, int aCircleToSegmentsCount)
Function TransformRoundRectToPolygon convert a rectangle with rounded corners to a polygon Convert ar...
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:531
int color
Definition: DXF_plotter.cpp:62
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...
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:179
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
smd pads, back layer
void NORMALIZE_ANGLE_90(T &Angle)
Definition: trigo.h:320
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:182
PAD_SHAPE_T
Enum PAD_SHAPE_T is the set of pad shapes, used with D_PAD::{Set,Get}Shape()
Definition: pad_shapes.h:31
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
void SetFontBold(const bool aBold)
Set bold property of current font.
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:194
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
Class SHAPE_POLY_SET.
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:593
double GetOrientationRadians() const
Definition: class_pad.h:384
const wxSize & GetSize() const
Definition: class_pad.h:269
const wxString & GetName() const
Definition: class_pad.h:190
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.
int NewOutline()
Creates a new empty polygon in the set and returns its index
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
smd pads, front layer
virtual void Restore()
Restore the context.
const wxString & GetNetname() const
Function GetNetname.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:200
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:382
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: pcb_painter.h:154
double DECIDEG2RAD(double deg)
Definition: trigo.h:203
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:636
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:562
wxPoint ShapePos() const
Definition: class_pad.cpp:516
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
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 wxPoint GetPosition() const override
Definition: class_pad.h:220
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF
Definition: pcbnew.h:42
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:1249
const wxPoint & GetOffset() const
Definition: class_pad.h:278
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
#define min(a, b)
Definition: auxiliary.h:85
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) ...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
const wxString & GetShortNetname() const
Function GetShortNetname.
void PCB_PAINTER::draw ( const DRAWSEGMENT aSegment,
int  aLayer 
)
protectedinherited

Definition at line 921 of file pcb_painter.cpp.

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

922 {
923  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
924  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
925  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
926 
927  int thickness = getLineThickness( aSegment->GetWidth() );
928  VECTOR2D start( aSegment->GetStart() );
929  VECTOR2D end( aSegment->GetEnd() );
930 
931  m_gal->SetIsFill( !sketch );
932  m_gal->SetIsStroke( sketch );
933  m_gal->SetFillColor( color );
934  m_gal->SetStrokeColor( color );
936 
937  switch( aSegment->GetShape() )
938  {
939  case S_SEGMENT:
940  m_gal->DrawSegment( start, end, thickness );
941  break;
942 
943  case S_RECT:
944  wxASSERT_MSG( false, "Not tested yet" );
945  m_gal->DrawRectangle( start, end );
946  break;
947 
948  case S_ARC:
949  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
950  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
951  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
952  thickness );
953  break;
954 
955  case S_CIRCLE:
956  if( sketch )
957  {
958  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
959  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
960  }
961  else
962  {
963  m_gal->SetLineWidth( thickness );
964  m_gal->SetIsFill( false );
965  m_gal->SetIsStroke( true );
966  m_gal->DrawCircle( start, aSegment->GetRadius() );
967  }
968  break;
969 
970  case S_POLYGON:
971  {
972  SHAPE_POLY_SET& shape = ((DRAWSEGMENT*)aSegment)->GetPolyShape();
973 
974  if( shape.OutlineCount() == 0 )
975  break;
976 
977  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
978  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
979  // on Opengl.
980  // GLU tesselation is much slower, so currently we are using our tesselation.
981  if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
982  {
983  shape.CacheTriangulation();
984  }
985 
986  m_gal->Save();
987 
988  if( MODULE* module = aSegment->GetParentModule() )
989  {
990  m_gal->Translate( module->GetPosition() );
991  m_gal->Rotate( -module->GetOrientationRadians() );
992  }
993 
994  m_gal->SetLineWidth( thickness );
995 
996  m_gal->SetIsFill( aSegment->IsPolygonFilled() );
997 
998  m_gal->SetIsStroke( true );
999  m_gal->DrawPolygon( shape );
1000 
1001  m_gal->Restore();
1002  break;
1003  }
1004 
1005  case S_CURVE:
1006  m_gal->SetIsFill( false );
1007  m_gal->SetIsStroke( true );
1008  m_gal->SetLineWidth( thickness );
1009  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
1010  VECTOR2D( aSegment->GetBezControl1() ),
1011  VECTOR2D( aSegment->GetBezControl2() ),
1012  VECTOR2D( aSegment->GetEnd() ) );
1013  break;
1014 
1015  case S_LAST:
1016  break;
1017  }
1018 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
const wxPoint & GetBezControl2() const
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int color
Definition: DXF_plotter.cpp:62
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...
double GetArcAngleStart() const
function GetArcAngleStart()
bool m_sketchBoardGfx
Flag determining if board graphic items should be outlined or stroked
Definition: pcb_painter.h:170
usual segment : line with rounded ends
bool IsTriangulationUpToDate() const
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
int OutlineCount() const
Returns the number of outlines in the set
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint)
Draw a cubic bezier spline.
segment with non rounded ends
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
last value for this list
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
const wxPoint & GetBezControl1() const
Bezier Curve.
bool IsPolygonFilled() const
Polygonal shape is not always filled.
bool m_sketchFpGfx
Flag determining if footprint graphic items should be outlined or stroked
Definition: pcb_painter.h:173
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
double GetAngle() const
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:203
int GetWidth() const
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
virtual void Save()
Save the context.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PCB_PAINTER::draw ( const TEXTE_PCB aText,
int  aLayer 
)
protectedinherited

Definition at line 1021 of file pcb_painter.cpp.

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

1022 {
1023  wxString shownText( aText->GetShownText() );
1024  if( shownText.Length() == 0 )
1025  return;
1026 
1027  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1028  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1029 
1030  if( m_pcbSettings.m_sketchMode[aLayer] )
1031  {
1032  // Outline mode
1034  }
1035  else
1036  {
1037  // Filled mode
1039  }
1040 
1041  m_gal->SetStrokeColor( color );
1042  m_gal->SetIsFill( false );
1043  m_gal->SetIsStroke( true );
1044  m_gal->SetTextAttributes( aText );
1045  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1046 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:167
int color
Definition: DXF_plotter.cpp:62
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:232
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
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.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
double GetTextAngleRadians() const
Definition: eda_text.h:180
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PCB_PAINTER::draw ( const TEXTE_MODULE aText,
int  aLayer 
)
protectedinherited

Definition at line 1049 of file pcb_painter.cpp.

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

1050 {
1051  wxString shownText( aText->GetShownText() );
1052  if( shownText.Length() == 0 )
1053  return;
1054 
1055  bool sketch = m_pcbSettings.m_sketchFpTxtfx;
1056 
1057  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1058  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1059 
1060  // Currently, draw text routines do not know the true outline mode.
1061  // so draw the text in "line" mode (no thickness)
1062  if( sketch )
1063  {
1064  // Outline mode
1066  }
1067  else
1068  {
1069  // Filled mode
1071  }
1072 
1073  m_gal->SetStrokeColor( color );
1074  m_gal->SetIsFill( false );
1075  m_gal->SetIsStroke( true );
1076  m_gal->SetTextAttributes( aText );
1077  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1078 
1079  // Draw the umbilical line
1080  if( aText->IsSelected() )
1081  {
1083  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1084  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1085  }
1086 }
BOARD_ITEM_CONTAINER * GetParent() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
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:62
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...
bool IsSelected() const
Definition: base_struct.h:224
bool m_sketchFpTxtfx
Flag determining if footprint text items should be outlined or stroked
Definition: pcb_painter.h:176
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
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:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
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.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual const wxPoint GetPosition() const =0
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
double GetDrawRotationRadians() const
void PCB_PAINTER::draw ( const MODULE aModule,
int  aLayer 
)
protectedinherited

Definition at line 1089 of file pcb_painter.cpp.

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

1090 {
1091  if( aLayer == LAYER_ANCHOR )
1092  {
1093  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1094 
1095  // Draw anchor
1096  m_gal->SetStrokeColor( color );
1098 
1099  // Keep the size constant, not related to the scale
1100  double anchorSize = 5.0 / m_gal->GetWorldScale();
1101 
1102  VECTOR2D center = aModule->GetPosition();
1103  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1104  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1105  }
1106 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
double GetWorldScale() const
Get the world scale.
anchor of items having an anchor point (texts, footprints)
int color
Definition: DXF_plotter.cpp:62
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:232
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:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint GetPosition() const override
Definition: class_module.h:183
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PCB_PAINTER::draw ( const ZONE_CONTAINER aZone,
int  aLayer 
)
protectedinherited

Definition at line 1109 of file pcb_painter.cpp.

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::GetHatchLines(), ZONE_CONTAINER::GetMinThickness(), SHAPE_POLY_SET::HoleCount(), ZONE_CONTAINER::IsOnLayer(), KIGFX::PCB_RENDER_SETTINGS::m_displayZone, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_PAINTER::m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_zoneOutlines, ZONE_CONTAINER::Outline(), SHAPE_POLY_SET::OutlineCount(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

1110 {
1111  if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
1112  return;
1113 
1114  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1115  std::deque<VECTOR2D> corners;
1117 
1118  // Draw the outline
1119  const SHAPE_POLY_SET* outline = aZone->Outline();
1120 
1121  if( m_pcbSettings.m_zoneOutlines && outline )
1122  {
1123  m_gal->SetStrokeColor( color );
1124  m_gal->SetIsFill( false );
1125  m_gal->SetIsStroke( true );
1127 
1128  // Draw each contour (main contour and holes)
1129 
1130  /* This line:
1131  * m_gal->DrawPolygon( *outline );
1132  * should be enough, but currently does not work to draw holes contours in a complex polygon
1133  * so each contour is draw as a simple polygon
1134  */
1135 
1136  // Draw the main contour
1137  m_gal->DrawPolyline( outline->COutline( 0 ) );
1138 
1139  // Draw holes
1140  int holes_count = outline->HoleCount( 0 );
1141 
1142  for( int ii = 0; ii < holes_count; ++ii )
1143  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1144 
1145  // Draw hatch lines
1146  for( const SEG& hatchLine : aZone->GetHatchLines() )
1147  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1148  }
1149 
1150  // Draw the filling
1151  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1152  {
1153  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1154 
1155  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1156  return;
1157 
1158  // Set up drawing options
1159  m_gal->SetFillColor( color );
1160  m_gal->SetLineWidth( aZone->GetMinThickness() );
1161 
1162  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1163  {
1164  m_gal->SetIsFill( true );
1165  m_gal->SetIsStroke( true );
1166  }
1167  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1168  {
1169  m_gal->SetIsFill( false );
1170  m_gal->SetIsStroke( true );
1171  }
1172 
1173  m_gal->DrawPolygon( polySet );
1174  }
1175 
1176 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
int GetMinThickness() const
Definition: class_zone.h:203
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:265
int color
Definition: DXF_plotter.cpp:62
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...
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:243
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:197
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:84
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
int OutlineCount() const
Returns the number of outlines in the set
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:687
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
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.
Class SHAPE_POLY_SET.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:559
Definition: seg.h:36
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool m_zoneOutlines
Flag determining if zones should have outlines drawn
Definition: pcb_painter.h:191
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PCB_PAINTER::draw ( const DIMENSION aDimension,
int  aLayer 
)
protectedinherited

Definition at line 1179 of file pcb_painter.cpp.

References KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), KIGFX::PCB_PAINTER::getLineThickness(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), 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, KIGFX::PCB_PAINTER::m_pcbSettings, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), KIGFX::GAL::StrokeText(), and DIMENSION::Text().

1180 {
1181  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1182 
1183  m_gal->SetStrokeColor( strokeColor );
1184  m_gal->SetIsFill( false );
1185  m_gal->SetIsStroke( true );
1186  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1187 
1188  // Draw an arrow
1189  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1190  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1191  VECTOR2D( aDimension->m_featureLineGF ) );
1192  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1193  VECTOR2D( aDimension->m_featureLineDF ) );
1194  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1195  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1196  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1197  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1198 
1199  // Draw text
1200  TEXTE_PCB& text = aDimension->Text();
1201  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1202 
1203  m_gal->SetLineWidth( text.GetThickness() );
1204  m_gal->SetTextAttributes( &text );
1205  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1206 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
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).
int GetWidth() const
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
wxPoint m_featureLineDF
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
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:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
wxPoint m_featureLineGO
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
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
wxPoint m_arrowD2F
wxPoint m_arrowG2F
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
TEXTE_PCB & Text()
wxPoint m_crossBarO
double GetTextAngleRadians() const
Definition: eda_text.h:180
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxPoint m_featureLineDO
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint m_featureLineGF
void PCB_PAINTER::draw ( const PCB_TARGET aTarget)
protectedinherited

Definition at line 1209 of file pcb_painter.cpp.

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

1210 {
1211  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1212  VECTOR2D position( aTarget->GetPosition() );
1213  double size, radius;
1214 
1215  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1216  m_gal->SetStrokeColor( strokeColor );
1217  m_gal->SetIsFill( false );
1218  m_gal->SetIsStroke( true );
1219 
1220  m_gal->Save();
1221  m_gal->Translate( position );
1222 
1223  if( aTarget->GetShape() )
1224  {
1225  // shape x
1226  m_gal->Rotate( M_PI / 4.0 );
1227  size = 2.0 * aTarget->GetSize() / 3.0;
1228  radius = aTarget->GetSize() / 2.0;
1229  }
1230  else
1231  {
1232  // shape +
1233  size = aTarget->GetSize() / 2.0;
1234  radius = aTarget->GetSize() / 3.0;
1235  }
1236 
1237  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1238  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1239  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1240 
1241  m_gal->Restore();
1242 }
int GetWidth() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is 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...
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
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:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void Rotate(double aAngle)
Rotate the context.
int GetShape() const
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
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 GetSize() 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.
const wxPoint GetPosition() const override
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PCB_PAINTER::draw ( const MARKER_PCB aMarker)
protectedinherited

Definition at line 1245 of file pcb_painter.cpp.

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

1246 {
1247  SHAPE_LINE_CHAIN polygon;
1248  aMarker->ShapeToPolygon( polygon );
1249 
1250  auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
1251 
1252  m_gal->Save();
1253  m_gal->Translate( aMarker->GetPosition() );
1254  m_gal->SetFillColor( strokeColor );
1255  m_gal->SetIsFill( true );
1256  m_gal->SetIsStroke( false );
1257  m_gal->DrawPolygon( polygon );
1258  m_gal->Restore();
1259 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
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...
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:232
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Class 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.
int KIGFX::PCB_PRINT_PAINTER::getDrillShape ( const D_PAD aPad) const
overrideprotectedvirtual

Return drill shape of a pad.

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 220 of file pcbnew_printout.cpp.

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

221 {
223 }
virtual int getDrillShape(const D_PAD *aPad) const
Return drill shape of a pad.
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks ...
VECTOR2D KIGFX::PCB_PRINT_PAINTER::getDrillSize ( const D_PAD aPad) const
overrideprotectedvirtual

Return drill size for a pad (internal units).

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 226 of file pcbnew_printout.cpp.

References KIGFX::PCB_PAINTER::getDrillSize(), m_drillMarkReal, and m_drillMarkSize.

227 {
228  // TODO should it depend on the pad size?
231 }
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks ...
int m_drillMarkSize
User-specified size for drill marks (expressed in internal units)
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
int KIGFX::PCB_PRINT_PAINTER::getDrillSize ( const VIA aVia) const
overrideprotectedvirtual

Return drill diameter for a via (internal units).

Reimplemented from KIGFX::PCB_PAINTER.

Definition at line 234 of file pcbnew_printout.cpp.

References KIGFX::PCB_PAINTER::getDrillSize(), m_drillMarkReal, and m_drillMarkSize.

235 {
236  // TODO should it depend on the via size?
238 }
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks ...
int m_drillMarkSize
User-specified size for drill marks (expressed in internal units)
virtual VECTOR2D getDrillSize(const D_PAD *aPad) const
Return drill size for a pad (internal units).
int PCB_PAINTER::getLineThickness ( int  aActualThickness) const
protectedinherited

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

0 thickness lines get a minimum value).

Parameters
aActualThicknessline own thickness
Returns
the thickness to draw

Definition at line 272 of file pcb_painter.cpp.

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

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

273 {
274  // if items have 0 thickness, draw them with the outline
275  // width, otherwise respect the set value (which, no matter
276  // how small will produce something)
277  if( aActualThickness == 0 )
279 
280  return aActualThickness;
281 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
virtual PCB_RENDER_SETTINGS* KIGFX::PCB_PAINTER::GetSettings ( )
inlineoverridevirtualinherited

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

Referenced by PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), PCB_LAYER_WIDGET::SyncLayerAlphaIndicators(), PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_PCBNEW_SETTINGS::TransferDataFromWindow(), and PCB_BASE_FRAME::UseGalCanvas().

224  {
225  return &m_pcbSettings;
226  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:232
void KIGFX::PCB_PRINT_PAINTER::SetDrillMarks ( bool  aRealSize,
unsigned int  aSize = 0 
)
inline

Set drill marks visibility and options.

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

Definition at line 94 of file pcbnew_printout.h.

95  {
96  m_drillMarkReal = aRealSize;
97  m_drillMarkSize = aSize;
98  }
bool m_drillMarkReal
Flag deciding whether use the actual hole size or user-specified size for drill marks ...
int m_drillMarkSize
User-specified size for drill marks (expressed in internal units)
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 328 of file painter.h.

329  {
330  m_gal = aGal;
331  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:360

Member Data Documentation

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 363 of file painter.h.

bool KIGFX::PCB_PRINT_PAINTER::m_drillMarkReal
protected

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

Definition at line 108 of file pcbnew_printout.h.

Referenced by getDrillShape(), and getDrillSize().

int KIGFX::PCB_PRINT_PAINTER::m_drillMarkSize
protected

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

Definition at line 111 of file pcbnew_printout.h.

Referenced by getDrillSize().

GAL* KIGFX::PAINTER::m_gal
protectedinherited

Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.

DrawLine, DrawCircle, etc.)

Definition at line 360 of file painter.h.

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawApertureMacro(), KIGFX::GERBVIEW_PAINTER::drawFlashedShape(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), KIGFX::SCH_PAINTER::setColors(), and KIGFX::SCH_PAINTER::triLine().

PCB_RENDER_SETTINGS KIGFX::PCB_PAINTER::m_pcbSettings
protectedinherited

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