KiCad PCB EDA Suite
KIGFX::PCB_PAINTER Class Reference

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

#include <pcb_painter.h>

Inheritance diagram for KIGFX::PCB_PAINTER:
KIGFX::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)
 
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

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

Class PCB_PAINTER Contains methods for drawing PCB-specific items.

Definition at line 176 of file pcb_painter.h.

Constructor & Destructor Documentation

PCB_PAINTER::PCB_PAINTER ( GAL aGal)

Definition at line 248 of file pcb_painter.cpp.

248  :
249  PAINTER( aGal )
250 {
251 }
PAINTER(GAL *aGal)
Definition: painter.cpp:67

Member Function Documentation

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

References m_pcbSettings.

183  {
184  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
185  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:197
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 266 of file pcb_painter.cpp.

References 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_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, PCB_ZONE_T, and EDA_ITEM::Type().

267 {
268  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
269 
270  // the "cast" applied in here clarifies which overloaded draw() is called
271  switch( item->Type() )
272  {
273  case PCB_ZONE_T:
274  case PCB_TRACE_T:
275  draw( static_cast<const TRACK*>( item ), aLayer );
276  break;
277 
278  case PCB_VIA_T:
279  draw( static_cast<const VIA*>( item ), aLayer );
280  break;
281 
282  case PCB_PAD_T:
283  draw( static_cast<const D_PAD*>( item ), aLayer );
284  break;
285 
286  case PCB_LINE_T:
287  case PCB_MODULE_EDGE_T:
288  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
289  break;
290 
291  case PCB_TEXT_T:
292  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
293  break;
294 
295  case PCB_MODULE_TEXT_T:
296  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
297  break;
298 
299  case PCB_MODULE_T:
300  draw( static_cast<const MODULE*>( item ), aLayer );
301  break;
302 
303  case PCB_ZONE_AREA_T:
304  draw( static_cast<const ZONE_CONTAINER*>( item ) );
305  break;
306 
307  case PCB_DIMENSION_T:
308  draw( static_cast<const DIMENSION*>( item ), aLayer );
309  break;
310 
311  case PCB_TARGET_T:
312  draw( static_cast<const PCB_TARGET*>( item ) );
313  break;
314 
315  case PCB_MARKER_T:
316  draw( static_cast<const MARKER_PCB*>( item ) );
317  break;
318 
319  default:
320  // Painter does not know how to draw the object
321  return false;
322  }
323 
324  return true;
325 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
class MODULE, a footprint
Definition: typeinfo.h:101
class SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:109
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:113
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:111
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
void draw(const TRACK *aTrack, int aLayer)
void PCB_PAINTER::draw ( const TRACK aTrack,
int  aLayer 
)
protected

Definition at line 328 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, 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 Draw().

329 {
330  VECTOR2D start( aTrack->GetStart() );
331  VECTOR2D end( aTrack->GetEnd() );
332  int width = aTrack->GetWidth();
333 
335  {
336  // If there is a net name - display it on the track
337  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
338  {
339  VECTOR2D line = ( end - start );
340  double length = line.EuclideanNorm();
341 
342  // Check if the track is long enough to have a netname displayed
343  if( length < 10 * width )
344  return;
345 
346  const wxString& netName = aTrack->GetShortNetname();
347  VECTOR2D textPosition = start + line / 2.0; // center of the track
348  double textOrientation = -atan( line.y / line.x );
349  double textSize = width;
350 
351  m_gal->SetIsStroke( true );
352  m_gal->SetIsFill( false );
353  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
354  m_gal->SetLineWidth( width / 10.0 );
355  m_gal->SetFontBold( false );
356  m_gal->SetFontItalic( false );
357  m_gal->SetTextMirrored( false );
358  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
361  m_gal->BitmapText( netName, textPosition, textOrientation );
362  }
363  }
364  else if( IsCopperLayer( aLayer ) )
365  {
366  // Draw a regular track
367  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
368  m_gal->SetStrokeColor( color );
369  m_gal->SetIsStroke( true );
370 
372  {
373  // Outline mode
375  m_gal->SetIsFill( false );
376  }
377  else
378  {
379  // Filled mode
380  m_gal->SetFillColor( color );
381  m_gal->SetIsFill( true );
382  }
383 
384  m_gal->DrawSegment( start, end, width );
385 
386  // Clearance lines
387  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
388 
389  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
390  {
392  m_gal->SetIsFill( false );
393  m_gal->SetIsStroke( true );
394  m_gal->SetStrokeColor( color );
395  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
396  }
397  }
398 }
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:259
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:138
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:197
const wxPoint & GetEnd() const
Definition: class_track.h:118
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:330
void SetFontBold(const bool aBold)
Set bold property of current font.
virtual void SetLineWidth(double aLineWidth)
Set the line width.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:295
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint & GetStart() const
Definition: class_track.h:121
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:153
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:165
int GetWidth() const
Definition: class_track.h:115
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
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 ...
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 
)
protected

Definition at line 401 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(), 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, 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.

402 {
403  VECTOR2D center( aVia->GetStart() );
404  double radius = 0.0;
405 
406  // Draw description layer
407  if( IsNetnameLayer( aLayer ) )
408  {
409  VECTOR2D position( center );
410 
411  // Is anything that we can display enabled?
413  {
414  bool displayNetname = ( !aVia->GetNetname().empty() );
415  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
416  double size = aVia->GetWidth();
417 
418  // Font size limits
419  if( size > maxSize )
420  size = maxSize;
421 
422  m_gal->Save();
423  m_gal->Translate( position );
424 
425  // Default font settings
427  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
428 
429  // Set the text position to the pad shape position (the pad position is not the best place)
430  VECTOR2D textpos( 0.0, 0.0 );
431 
432  if( displayNetname )
433  {
434  // calculate the size of net name text:
435  double tsize = 1.5 * size / aVia->GetShortNetname().Length();
436  tsize = std::min( tsize, size );
437  // Use a smaller text size to handle interline, pen size..
438  tsize *= 0.7;
439  VECTOR2D namesize( tsize, tsize );
440 
441  m_gal->SetGlyphSize( namesize );
442  m_gal->SetLineWidth( namesize.x / 12.0 );
443  m_gal->BitmapText( aVia->GetShortNetname(), textpos, 0.0 );
444  }
445 
446 
447  m_gal->Restore();
448  }
449  return;
450  }
451 
452  // Choose drawing settings depending on if we are drawing via's pad or hole
453  if( aLayer == LAYER_VIAS_HOLES )
454  radius = aVia->GetDrillValue() / 2.0;
455  else
456  radius = aVia->GetWidth() / 2.0;
457 
458  bool sketchMode = false;
459  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
460 
461  switch( aVia->GetViaType() )
462  {
463  case VIA_THROUGH:
465  break;
466 
467  case VIA_BLIND_BURIED:
469  break;
470 
471  case VIA_MICROVIA:
473  break;
474 
475  default:
476  assert( false );
477  break;
478  }
479 
480  if( aVia->GetViaType() == VIA_BLIND_BURIED )
481  {
482  // Buried vias are drawn in a special way to indicate the top and bottom layers
483  PCB_LAYER_ID layerTop, layerBottom;
484  aVia->LayerPair( &layerTop, &layerBottom );
485 
486  if( aLayer == LAYER_VIAS_HOLES )
487  { // TODO outline mode
488  m_gal->SetIsFill( true );
489  m_gal->SetIsStroke( false );
490  m_gal->SetFillColor( color );
491  m_gal->DrawCircle( center, radius );
492  }
493  else
494  {
495  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
496 
497  m_gal->SetLineWidth( width );
498  m_gal->SetIsFill( true );
499  m_gal->SetIsStroke( false );
500  m_gal->SetFillColor( color );
501 
502  if( aLayer == layerTop )
503  {
504  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
505  }
506  else if( aLayer == layerBottom )
507  {
508  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
509  }
510  else if( aLayer == LAYER_VIA_BBLIND )
511  {
512  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
513  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
514  }
515  }
516  }
517  else
518  {
519  // Regular vias
520  m_gal->SetIsFill( !sketchMode );
521  m_gal->SetIsStroke( sketchMode );
522 
523  if( sketchMode )
524  {
525  // Outline mode
527  m_gal->SetStrokeColor( color );
528  }
529  else
530  {
531  // Filled mode
532  m_gal->SetFillColor( color );
533  }
534 
535  m_gal->DrawCircle( center, radius );
536  }
537 
538  // Clearance lines
539  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
540 
541  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
542  && aLayer != LAYER_VIAS_HOLES )
543  {
545  m_gal->SetIsFill( false );
546  m_gal->SetIsStroke( true );
547  m_gal->SetStrokeColor( color );
548  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
549  }
550 }
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:259
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:138
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:197
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:330
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetLineWidth(double aLineWidth)
Set the line width.
void ResetTextAttributes()
Reset text attributes to default styling.
VIATYPE_T GetViaType() const
Definition: class_track.h:439
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:159
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint & GetStart() const
Definition: class_track.h:121
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:165
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:115
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:156
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 
)
protected

Definition at line 553 of file pcb_painter.cpp.

References SHAPE_POLY_SET::Append(), B_Mask, B_Paste, KIGFX::GAL::BitmapText(), D_PAD::BuildPadPolygon(), KIGFX::PCB_RENDER_SETTINGS::CL_PADS, color, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), DECIDEG2RAD(), KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawPolyline(), KIGFX::GAL::DrawRectangle(), F_Mask, F_Paste, D_PAD::GetAttribute(), KIGFX::RENDER_SETTINGS::GetBackgroundColor(), D_PAD::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), D_PAD::GetCustomShapeAsPolygon(), D_PAD::GetDrillShape(), D_PAD::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_PLATED, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS, LAYER_PADS_HOLES, 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, min, SHAPE_POLY_SET::NewOutline(), NORMALIZE_ANGLE_90(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), 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, SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), KIGFX::GAL::Restore(), KIGFX::GAL::Rotate(), KIGFX::GAL::Save(), SEGCOUNT, 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.

554 {
555  PAD_SHAPE_T shape;
556  double m, n;
557  double orientation = aPad->GetOrientation();
558 
559  // Draw description layer
560  if( IsNetnameLayer( aLayer ) )
561  {
562  VECTOR2D position( aPad->ShapePos() );
563 
564  // Is anything that we can display enabled?
566  {
567  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
568  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
569  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
570  double size = padsize.y;
571 
572  // Keep the size ratio for the font, but make it smaller
573  if( padsize.x < padsize.y )
574  {
575  orientation += 900.0;
576  size = padsize.x;
577  std::swap( padsize.x, padsize.y );
578  }
579  else if( padsize.x == padsize.y )
580  {
581  // If the text is displayed on a symmetrical pad, do not rotate it
582  orientation = 0.0;
583  }
584 
585  // Font size limits
586  if( size > maxSize )
587  size = maxSize;
588 
589  m_gal->Save();
590  m_gal->Translate( position );
591 
592  // do not display descriptions upside down
593  NORMALIZE_ANGLE_90( orientation );
594  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
595 
596  // Default font settings
599  m_gal->SetFontBold( false );
600  m_gal->SetFontItalic( false );
601  m_gal->SetTextMirrored( false );
602  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
603  m_gal->SetIsStroke( true );
604  m_gal->SetIsFill( false );
605 
606  // Set the text position to the pad shape position (the pad position is not the best place)
607  VECTOR2D textpos( 0.0, 0.0 );
608 
609  // Divide the space, to display both pad numbers and netnames
610  // and set the Y text position to display 2 lines
611  if( displayNetname && m_pcbSettings.m_padNumbers )
612  {
613  size = size / 2.0;
614  textpos.y = size / 2.0;
615  }
616 
617  if( displayNetname )
618  {
619  // calculate the size of net name text:
620  double tsize = 1.5 * padsize.x / aPad->GetShortNetname().Length();
621  tsize = std::min( tsize, size );
622  // Use a smaller text size to handle interline, pen size..
623  tsize *= 0.7;
624  VECTOR2D namesize( tsize, tsize );
625 
626  m_gal->SetGlyphSize( namesize );
627  m_gal->SetLineWidth( namesize.x / 12.0 );
628  m_gal->BitmapText( aPad->GetShortNetname(), textpos, 0.0 );
629  }
630 
632  {
633  const wxString& padName = aPad->GetName();
634  textpos.y = -textpos.y;
635  double tsize = 1.5 * padsize.x / padName.Length();
636  tsize = std::min( tsize, size );
637  // Use a smaller text size to handle interline, pen size..
638  tsize *= 0.7;
639  tsize = std::min( tsize, size );
640  VECTOR2D numsize( tsize, tsize );
641 
642  m_gal->SetGlyphSize( numsize );
643  m_gal->SetLineWidth( numsize.x / 12.0 );
644  m_gal->BitmapText( padName, textpos, 0.0 );
645  }
646 
647  m_gal->Restore();
648  }
649  return;
650  }
651 
652  // Pad drawing
653  COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
654 
655  // Pad holes color is specific
656  if( aLayer == LAYER_PADS_HOLES || aLayer == LAYER_NON_PLATED )
657  {
658  // Hole color is the background color for plated holes, but a specific color
659  // for not plated holes (LAYER_NON_PLATED color layer )
660  if( aPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED /*&&
661  brd->IsElementVisible( LAYER_NON_PLATED )*/ )
662  color = m_pcbSettings.GetColor( nullptr, LAYER_NON_PLATED );
663  else
665  }
666 
667  VECTOR2D size;
668 
670  {
671  // Outline mode
672  m_gal->SetIsFill( false );
673  m_gal->SetIsStroke( true );
675  m_gal->SetStrokeColor( color );
676  }
677  else
678  {
679  // Filled mode
680  m_gal->SetIsFill( true );
681  m_gal->SetIsStroke( false );
682  m_gal->SetFillColor( color );
683  }
684 
685  m_gal->Save();
686  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
687  m_gal->Rotate( -aPad->GetOrientationRadians() );
688 
689  int custom_margin = 0; // a clearance/margin for custom shape, for solder paste/mask
690 
691  // Choose drawing settings depending on if we are drawing a pad itself or a hole
692  if( aLayer == LAYER_PADS_HOLES || aLayer == LAYER_NON_PLATED )
693  {
694  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
695  size = VECTOR2D( aPad->GetDrillSize() ) / 2.0;
697  }
698  else if( aLayer == F_Mask || aLayer == B_Mask )
699  {
700  // Drawing soldermask
701  int soldermaskMargin = aPad->GetSolderMaskMargin();
702  custom_margin = soldermaskMargin;
703 
704  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
705  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
706  aPad->GetSize().y / 2.0 + soldermaskMargin );
707  shape = aPad->GetShape();
708  }
709  else if( aLayer == F_Paste || aLayer == B_Paste )
710  {
711  // Drawing solderpaste
712  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
713  // try to find a clearance which can be used for custom shapes
714  custom_margin = solderpasteMargin.x;
715 
716  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
717  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
718  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
719  shape = aPad->GetShape();
720  }
721  else
722  {
723  // Drawing every kind of pad
724  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
725  size = VECTOR2D( aPad->GetSize() ) / 2.0;
726  shape = aPad->GetShape();
727  }
728 
729  switch( shape )
730  {
731  case PAD_SHAPE_OVAL:
732  if( size.y >= size.x )
733  {
734  m = ( size.y - size.x );
735  n = size.x;
736 
738  {
739  // Outline mode
740  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
741  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
742  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
743  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
744  }
745  else
746  {
747  // Filled mode
748  m_gal->DrawCircle( VECTOR2D( 0, -m ), n );
749  m_gal->DrawCircle( VECTOR2D( 0, m ), n );
750  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
751  }
752  }
753  else
754  {
755  m = ( size.x - size.y );
756  n = size.y;
757 
759  {
760  // Outline mode
761  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
762  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
763  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
764  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
765  }
766  else
767  {
768  // Filled mode
769  m_gal->DrawCircle( VECTOR2D( -m, 0 ), n );
770  m_gal->DrawCircle( VECTOR2D( m, 0 ), n );
771  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
772  }
773  }
774  break;
775 
776  case PAD_SHAPE_RECT:
777  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
778  break;
779 
780  case PAD_SHAPE_ROUNDRECT:
781  {
782  SHAPE_POLY_SET polySet;
783  wxSize prsize( size.x * 2, size.y * 2 );
784  const int segmentToCircleCount = 64;
785  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
786  TransformRoundRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
787  0.0, corner_radius, segmentToCircleCount );
788 
790  {
791  if( polySet.OutlineCount() > 0 )
792  m_gal->DrawPolyline( polySet.Outline( 0 ) );
793  }
794  else
795  {
796  m_gal->DrawPolygon( polySet );
797  }
798  break;
799  }
800 
801  case PAD_SHAPE_CUSTOM:
802  { // Draw the complex custom shape
803  std::deque<VECTOR2D> pointList;
804 
805  // Use solder[Paste/Mask]size or pad size to build pad shape
806  // however, solder[Paste/Mask] size has no actual meaning for a
807  // custom shape, because it is a set of basic shapes
808  // We use the custom_margin (good for solder mask, but approximative
809  // for solder paste).
810  if( custom_margin )
811  {
812  SHAPE_POLY_SET outline;
813  outline.Append( aPad->GetCustomShapeAsPolygon() );
814  const int segmentToCircleCount = 32;
815  outline.Inflate( custom_margin, segmentToCircleCount );
816 
817  // Draw the polygon: only one polygon is expected
818  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
819 
820  for( int ii = 0; ii < poly.PointCount(); ii++ )
821  pointList.push_back( poly.Point( ii ) );
822  }
823  else
824  {
825  // Draw the polygon: only one polygon is expected
826  // However we provide a multi polygon shape drawing
827  // ( for the future or to show even an incorrect shape
828  const SHAPE_POLY_SET& outline = aPad->GetCustomShapeAsPolygon();
829 
830  for( int jj = 0; jj < outline.OutlineCount(); ++jj )
831  {
832  const SHAPE_LINE_CHAIN& poly = outline.COutline( jj );
833 
834  for( int ii = 0; ii < poly.PointCount(); ii++ )
835  pointList.push_back( poly.CPoint( ii ) );
836  }
837  }
838 
840  {
841  // Add the beginning point to close the outline
842  pointList.push_back( pointList.front() );
843  m_gal->DrawPolyline( pointList );
844  }
845  else
846  m_gal->DrawPolygon( pointList );
847  }
848  break;
849 
850  case PAD_SHAPE_TRAPEZOID:
851  {
852  std::deque<VECTOR2D> pointList;
853  wxPoint corners[4];
854 
855  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
856  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
857 
858  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
859  SHAPE_POLY_SET polySet;
860  polySet.NewOutline();
861  polySet.Append( VECTOR2I( corners[0] ) );
862  polySet.Append( VECTOR2I( corners[1] ) );
863  polySet.Append( VECTOR2I( corners[2] ) );
864  polySet.Append( VECTOR2I( corners[3] ) );
865 
867  m_gal->DrawPolyline( polySet.COutline( 0 ) );
868  else
869  m_gal->DrawPolygon( polySet );
870  }
871  break;
872 
873  case PAD_SHAPE_CIRCLE:
874  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
875  break;
876  }
877 
878  m_gal->Restore();
879 
880  // Clearance lines
881  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
882  // returns already transformed coordinates
883  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
884 
885  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
886  && ( aLayer == LAYER_PAD_FR
887  || aLayer == LAYER_PAD_BK
888  || aLayer == LAYER_PADS ) )
889  {
890  SHAPE_POLY_SET polySet;
891  constexpr int SEGCOUNT = 64;
892  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
893 
894  if( polySet.OutlineCount() > 0 )
895  {
897  m_gal->SetIsStroke( true );
898  m_gal->SetIsFill( false );
899  m_gal->SetStrokeColor( color );
900  m_gal->DrawPolyline( polySet.COutline( 0 ) );
901  }
902  }
903 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:380
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:259
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:323
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
int PointCount() const
Function PointCount()
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:138
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:493
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...
#define SEGCOUNT
bool m_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:147
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:363
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:197
int OutlineCount() const
Returns the number of outlines in the set
const wxSize & GetDrillSize() const
Definition: class_pad.h:260
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:201
smd pads, back layer
void NORMALIZE_ANGLE_90(T &Angle)
Definition: trigo.h:277
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:150
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:330
virtual void Rotate(double aAngle)
Rotate the context.
void SetFontBold(const bool aBold)
Set bold property of current font.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
virtual void SetLineWidth(double aLineWidth)
Set the line width.
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:159
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:577
const wxPoint & GetPosition() const override
Definition: class_pad.h:205
multilayer pads, usually with holes
double GetOrientationRadians() const
Definition: class_pad.h:359
const wxSize & GetSize() const
Definition: class_pad.h:254
const wxString & GetName() const
Definition: class_pad.h:175
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
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.
to draw pad holes (plated or not plated)
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:165
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
handle color for not plated holes
Class SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:357
double DECIDEG2RAD(double deg)
Definition: trigo.h:195
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:610
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:546
wxPoint ShapePos() const
Definition: class_pad.cpp:500
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
VECTOR2I & Point(int aIndex)
Function Point()
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
const wxPoint & GetOffset() const
Definition: class_pad.h:263
const COLOR4D & GetBackgroundColor() const
Function GetBackgroundColor Returns current background color settings.
Definition: painter.h:186
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 
)
protected

Definition at line 906 of file pcb_painter.cpp.

References 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::GetPolyPoints(), DRAWSEGMENT::GetPosition(), DRAWSEGMENT::GetRadius(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchBoardGfx, KIGFX::PCB_RENDER_SETTINGS::m_sketchFpGfx, 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().

907 {
908  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
909  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
910  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
911 
912  int thickness = getLineThickness( aSegment->GetWidth() );
913  VECTOR2D start( aSegment->GetStart() );
914  VECTOR2D end( aSegment->GetEnd() );
915 
916  m_gal->SetIsFill( !sketch );
917  m_gal->SetIsStroke( sketch );
918  m_gal->SetFillColor( color );
919  m_gal->SetStrokeColor( color );
921 
922  switch( aSegment->GetShape() )
923  {
924  case S_SEGMENT:
925  m_gal->DrawSegment( start, end, thickness );
926  break;
927 
928  case S_RECT:
929  wxASSERT_MSG( false, wxT( "Not tested yet" ) );
930  m_gal->DrawRectangle( start, end );
931  break;
932 
933  case S_ARC:
934  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
935  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
936  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
937  thickness );
938  break;
939 
940  case S_CIRCLE:
941  if( sketch )
942  {
943  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
944  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
945  }
946  else
947  {
948  m_gal->SetLineWidth( thickness );
949  m_gal->SetIsFill( false );
950  m_gal->SetIsStroke( true );
951  m_gal->DrawCircle( start, aSegment->GetRadius() );
952  }
953  break;
954 
955  case S_POLYGON:
956  {
957  const auto& points = aSegment->GetPolyPoints();
958  std::deque<VECTOR2D> pointsList;
959 
960  if( points.empty() )
961  break;
962 
963  m_gal->Save();
964 
965  if( MODULE* module = aSegment->GetParentModule() )
966  {
967  m_gal->Translate( module->GetPosition() );
968  m_gal->Rotate( -module->GetOrientationRadians() );
969  }
970  else
971  {
972  m_gal->Translate( aSegment->GetPosition() );
973  m_gal->Rotate( DECIDEG2RAD( -aSegment->GetAngle() ) );
974  }
975 
976  std::copy( points.begin(), points.end(), std::back_inserter( pointsList ) );
977  pointsList.push_back( points[0] );
978 
979  m_gal->SetLineWidth( aSegment->GetWidth() );
980  m_gal->SetIsFill( true ); // draw polygons the legacy way
981  m_gal->SetIsStroke( true );
982  m_gal->DrawPolygon( pointsList );
983 
984  m_gal->Restore();
985  break;
986  }
987 
988  case S_CURVE:
989  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
990  VECTOR2D( aSegment->GetBezControl1() ),
991  VECTOR2D( aSegment->GetBezControl2() ),
992  VECTOR2D( aSegment->GetEnd() ) );
993  break;
994 
995  case S_LAST:
996  break;
997  }
998 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:259
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:141
usual segment : line with rounded ends
const std::vector< wxPoint > & GetPolyPoints() const
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:197
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:330
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 SetLineWidth(double aLineWidth)
Set the line width.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
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.
const wxPoint & GetBezControl1() const
Bezier Curve.
bool m_sketchFpGfx
Flag determining if footprint graphic items should be outlined or stroked
Definition: pcb_painter.h:144
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:195
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:103
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.
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 TEXTE_PCB aText,
int  aLayer 
)
protected

Definition at line 1001 of file pcb_painter.cpp.

References color, KIGFX::PCB_RENDER_SETTINGS::GetColor(), BOARD_ITEM::GetLayer(), getLineThickness(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), 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.

1002 {
1003  wxString shownText( aText->GetShownText() );
1004  if( shownText.Length() == 0 )
1005  return;
1006 
1007  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1008  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1009 
1010  if( m_pcbSettings.m_sketchMode[aLayer] )
1011  {
1012  // Outline mode
1014  }
1015  else
1016  {
1017  // Filled mode
1019  }
1020 
1021  m_gal->SetStrokeColor( color );
1022  m_gal->SetIsFill( false );
1023  m_gal->SetIsStroke( true );
1024  m_gal->SetTextAttributes( aText );
1025  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1026 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:259
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:138
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:197
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:330
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
virtual void SetLineWidth(double aLineWidth)
Set the line width.
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.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
double GetTextAngleRadians() const
Definition: eda_text.h:167
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 
)
protected

Definition at line 1029 of file pcb_painter.cpp.

References color, KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), TEXTE_MODULE::GetDrawRotationRadians(), getLineThickness(), BOARD_ITEM::GetParent(), BOARD_ITEM::GetPosition(), TEXTE_MODULE::GetShownText(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetThickness(), TEXTE_MODULE::GetType(), EDA_ITEM::IsSelected(), 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(), TEXTE_MODULE::TEXT_is_DIVERS, wxPoint::x, and wxPoint::y.

1030 {
1031  wxString shownText( aText->GetShownText() );
1032  if( shownText.Length() == 0 )
1033  return;
1034 
1035  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1036  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1037 
1038  if( m_pcbSettings.m_sketchMode[aLayer] )
1039  {
1040  // Outline mode
1042  }
1043  else
1044  {
1045  // Filled mode
1047  }
1048 
1049  m_gal->SetStrokeColor( color );
1050  m_gal->SetIsFill( false );
1051  m_gal->SetIsStroke( true );
1052  m_gal->SetTextAttributes( aText );
1053  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1054 
1055  // Draw the umbilical line
1056  if( aText->IsSelected() && aText->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
1057  {
1059  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1060  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1061  }
1062 }
BOARD_ITEM_CONTAINER * GetParent() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:259
TEXT_TYPE GetType() const
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:138
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:235
virtual const wxPoint & GetPosition() const =0
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:197
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:330
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
virtual void SetLineWidth(double aLineWidth)
Set the line width.
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.
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 
)
protected

Definition at line 1065 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, m_pcbSettings, KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

1066 {
1067  if( aLayer == LAYER_ANCHOR )
1068  {
1069  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1070 
1071  // Draw anchor
1072  m_gal->SetStrokeColor( color );
1074 
1075  // Keep the size constant, not related to the scale
1076  double anchorSize = 5.0 / m_gal->GetWorldScale();
1077 
1078  VECTOR2D center = aModule->GetPosition();
1079  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1080  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1081  }
1082 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:259
double GetWorldScale() const
Get the world scale.
anchor of items having an anchor point (texts, footprints)
const wxPoint & GetPosition() const override
Definition: class_module.h:155
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:197
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:330
virtual void SetLineWidth(double aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
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)
protected

Definition at line 1085 of file pcb_painter.cpp.

References ZONE_CONTAINER::CIterateWithHoles(), color, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), 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(), BOARD_ITEM::GetLayer(), ZONE_CONTAINER::GetMinThickness(), KIGFX::PCB_RENDER_SETTINGS::m_displayZone, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

1086 {
1087  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aZone->GetLayer() );
1088  std::deque<VECTOR2D> corners;
1090 
1091  // Draw the outline
1092  m_gal->SetStrokeColor( color );
1093  m_gal->SetIsFill( false );
1094  m_gal->SetIsStroke( true );
1096 
1097  for( auto iterator = aZone->CIterateWithHoles(); iterator; iterator++ )
1098  {
1099  corners.push_back( VECTOR2D( *iterator ) );
1100 
1101  if( iterator.IsEndContour() )
1102  {
1103  // The last point for closing the polyline
1104  corners.push_back( corners[0] );
1105  m_gal->DrawPolyline( corners );
1106  corners.clear();
1107  }
1108 
1109  for( const SEG& hatchLine : aZone->GetHatchLines() )
1110  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1111  }
1112 
1113  // Draw the filling
1114  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1115  {
1116  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1117 
1118  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1119  return;
1120 
1121  // Set up drawing options
1122  m_gal->SetFillColor( color );
1123  m_gal->SetLineWidth( aZone->GetMinThickness() );
1124 
1125  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1126  {
1127  m_gal->SetIsFill( true );
1128  m_gal->SetIsStroke( true );
1129  }
1130  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1131  {
1132  m_gal->SetIsFill( false );
1133  m_gal->SetIsStroke( true );
1134  }
1135 
1136  for( int i = 0; i < polySet.OutlineCount(); i++ )
1137  {
1138  const SHAPE_LINE_CHAIN& outline = polySet.COutline( i );
1139  // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion
1140  // is just a performance hog)
1141 
1142  for( int j = 0; j < outline.PointCount(); j++ )
1143  corners.push_back ( (VECTOR2D) outline.CPoint( j ) );
1144 
1145  corners.push_back( (VECTOR2D) outline.CPoint( 0 ) );
1146 
1147  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1148  {
1149  m_gal->DrawPolygon( corners );
1150  m_gal->DrawPolyline( corners );
1151  }
1152  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1153  {
1154  m_gal->DrawPolyline( corners );
1155  }
1156 
1157  corners.clear();
1158  }
1159  }
1160 }
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:259
int GetMinThickness() const
Definition: class_zone.h:209
int PointCount() const
Function PointCount()
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...
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:162
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:84
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:197
int OutlineCount() const
Returns the number of outlines in the set
SHAPE_POLY_SET::CONST_ITERATOR CIterateWithHoles() const
Function CIterateWithHoles returns an iterator to visit all points of the zone's main outline with ho...
Definition: class_zone.h:495
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:711
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:330
virtual void SetLineWidth(double aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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:582
Definition: seg.h:37
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Class SHAPE_LINE_CHAIN.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
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 
)
protected

Definition at line 1163 of file pcb_painter.cpp.

References KIGFX::GAL::DrawLine(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), 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, 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.

1164 {
1165  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1166 
1167  m_gal->SetStrokeColor( strokeColor );
1168  m_gal->SetIsFill( false );
1169  m_gal->SetIsStroke( true );
1170  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1171 
1172  // Draw an arrow
1173  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1174  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1175  VECTOR2D( aDimension->m_featureLineGF ) );
1176  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1177  VECTOR2D( aDimension->m_featureLineDF ) );
1178  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1179  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1180  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1181  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1182 
1183  // Draw text
1184  TEXTE_PCB& text = aDimension->Text();
1185  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1186 
1187  m_gal->SetLineWidth( text.GetThickness() );
1188  m_gal->SetTextAttributes( &text );
1189  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1190 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
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:197
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:330
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
wxPoint m_featureLineGO
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
virtual void SetLineWidth(double aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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:167
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)
protected

Definition at line 1193 of file pcb_painter.cpp.

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().

1194 {
1195  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1196  VECTOR2D position( aTarget->GetPosition() );
1197  double size, radius;
1198 
1199  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1200  m_gal->SetStrokeColor( strokeColor );
1201  m_gal->SetIsFill( false );
1202  m_gal->SetIsStroke( true );
1203 
1204  m_gal->Save();
1205  m_gal->Translate( position );
1206 
1207  if( aTarget->GetShape() )
1208  {
1209  // shape x
1210  m_gal->Rotate( M_PI / 4.0 );
1211  size = 2.0 * aTarget->GetSize() / 3.0;
1212  radius = aTarget->GetSize() / 2.0;
1213  }
1214  else
1215  {
1216  // shape +
1217  size = aTarget->GetSize() / 2.0;
1218  radius = aTarget->GetSize() / 3.0;
1219  }
1220 
1221  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1222  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1223  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1224 
1225  m_gal->Restore();
1226 }
int GetWidth() const
Definition: class_mire.h:72
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:197
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:330
virtual void Rotate(double aAngle)
Rotate the context.
int GetShape() const
Definition: class_mire.h:66
virtual void SetLineWidth(double aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const wxPoint & GetPosition() const override
Definition: class_mire.h:63
virtual void Restore()
Restore the context.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int GetSize() const
Definition: class_mire.h:69
virtual void Save()
Save the context.
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 MARKER_PCB aMarker)
protected

Definition at line 1229 of file pcb_painter.cpp.

References KIGFX::GAL::DrawPolygon(), MARKER_PCB::GetPosition(), EDA_ITEM::IsSelected(), KIGFX::PAINTER::m_gal, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), scale, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), and KIGFX::GAL::Translate().

1230 {
1231  // If you are changing this, update MARKER_PCB::ViewBBox()
1232  const int scale = 100000;
1233 
1234  const VECTOR2D arrow[] = {
1235  VECTOR2D( 0 * scale, 0 * scale ),
1236  VECTOR2D( 8 * scale, 1 * scale ),
1237  VECTOR2D( 4 * scale, 3 * scale ),
1238  VECTOR2D( 13 * scale, 8 * scale ),
1239  VECTOR2D( 9 * scale, 9 * scale ),
1240  VECTOR2D( 8 * scale, 13 * scale ),
1241  VECTOR2D( 3 * scale, 4 * scale ),
1242  VECTOR2D( 1 * scale, 8 * scale )
1243  };
1244 
1245  m_gal->Save();
1246  m_gal->Translate( aMarker->GetPosition() );
1247 
1248  if( aMarker->IsSelected() )
1249  {
1250  m_gal->SetFillColor( COLOR4D( 1.0, 0.5, 0.5, 1.0 ) );
1251  }
1252  else
1253  {
1254  m_gal->SetFillColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) );
1255  }
1256 
1257  m_gal->SetIsFill( true );
1258  m_gal->SetIsStroke( false );
1259  m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
1260  m_gal->Restore();
1261 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:235
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:330
const wxPoint & GetPosition() const override
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const int scale
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void Save()
Save the context.
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
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 254 of file pcb_painter.cpp.

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

Referenced by draw().

255 {
256  // if items have 0 thickness, draw them with the outline
257  // width, otherwise respect the set value (which, no matter
258  // how small will produce something)
259  if( aActualThickness == 0 )
261 
262  return aActualThickness;
263 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:259
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:197
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 188 of file pcb_painter.h.

References m_pcbSettings.

Referenced by PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::TrackDisplayMode(), DIALOG_DISPLAY_OPTIONS::TransferDataFromWindow(), PCB_BASE_FRAME::UseGalCanvas(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

189  {
190  return &m_pcbSettings;
191  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:197
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 298 of file painter.h.

References KIGFX::PAINTER::m_gal.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

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

Member Data Documentation

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 333 of file painter.h.

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

Referenced by KIGFX::GERBVIEW_PAINTER::draw(), draw(), KIGFX::GERBVIEW_PAINTER::drawApertureMacro(), KIGFX::GERBVIEW_PAINTER::drawFlashedShape(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), and KIGFX::PAINTER::SetGAL().

PCB_RENDER_SETTINGS KIGFX::PCB_PAINTER::m_pcbSettings
protected

Definition at line 197 of file pcb_painter.h.

Referenced by ApplySettings(), draw(), getLineThickness(), and GetSettings().


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