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, 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

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

Constructor & Destructor Documentation

PCB_PAINTER::PCB_PAINTER ( GAL aGal)

Definition at line 265 of file pcb_painter.cpp.

265  :
266  PAINTER( aGal )
267 {
268 }
PAINTER(GAL *aGal)
Constructor PAINTER( GAL* ) initializes this object for painting on any of the polymorphic GRAPHICS_A...
Definition: painter.cpp:68

Member Function Documentation

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

196  {
197  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
198  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:210
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 283 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().

284 {
285  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
286 
287  if( !item )
288  return false;
289 
290  // the "cast" applied in here clarifies which overloaded draw() is called
291  switch( item->Type() )
292  {
293  case PCB_ZONE_T:
294  case PCB_TRACE_T:
295  draw( static_cast<const TRACK*>( item ), aLayer );
296  break;
297 
298  case PCB_VIA_T:
299  draw( static_cast<const VIA*>( item ), aLayer );
300  break;
301 
302  case PCB_PAD_T:
303  draw( static_cast<const D_PAD*>( item ), aLayer );
304  break;
305 
306  case PCB_LINE_T:
307  case PCB_MODULE_EDGE_T:
308  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
309  break;
310 
311  case PCB_TEXT_T:
312  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
313  break;
314 
315  case PCB_MODULE_TEXT_T:
316  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
317  break;
318 
319  case PCB_MODULE_T:
320  draw( static_cast<const MODULE*>( item ), aLayer );
321  break;
322 
323  case PCB_ZONE_AREA_T:
324  draw( static_cast<const ZONE_CONTAINER*>( item ), aLayer );
325  break;
326 
327  case PCB_DIMENSION_T:
328  draw( static_cast<const DIMENSION*>( item ), aLayer );
329  break;
330 
331  case PCB_TARGET_T:
332  draw( static_cast<const PCB_TARGET*>( item ) );
333  break;
334 
335  case PCB_MARKER_T:
336  draw( static_cast<const MARKER_PCB*>( item ) );
337  break;
338 
339  default:
340  // Painter does not know how to draw the object
341  return false;
342  }
343 
344  return true;
345 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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 SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:97
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:151
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)
void PCB_PAINTER::draw ( const TRACK aTrack,
int  aLayer 
)
protected

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

349 {
350  VECTOR2D start( aTrack->GetStart() );
351  VECTOR2D end( aTrack->GetEnd() );
352  int width = aTrack->GetWidth();
353 
355  {
356  // If there is a net name - display it on the track
357  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
358  {
359  VECTOR2D line = ( end - start );
360  double length = line.EuclideanNorm();
361 
362  // Check if the track is long enough to have a netname displayed
363  if( length < 10 * width )
364  return;
365 
366  const wxString& netName = aTrack->GetShortNetname();
367  VECTOR2D textPosition = start + line / 2.0; // center of the track
368 
369  double textOrientation;
370 
371  if( end.y == start.y ) // horizontal
372  textOrientation = 0;
373  else if( end.x == start.x ) // vertical
374  textOrientation = M_PI / 2;
375  else
376  textOrientation = -atan( line.y / line.x );
377 
378  double textSize = width;
379 
380  m_gal->SetIsStroke( true );
381  m_gal->SetIsFill( false );
382  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
383  m_gal->SetLineWidth( width / 10.0 );
384  m_gal->SetFontBold( false );
385  m_gal->SetFontItalic( false );
386  m_gal->SetTextMirrored( false );
387  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
390  m_gal->BitmapText( netName, textPosition, textOrientation );
391  }
392  }
393  else if( IsCopperLayer( aLayer ) )
394  {
395  // Draw a regular track
396  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
397  m_gal->SetStrokeColor( color );
398  m_gal->SetIsStroke( true );
399 
401  {
402  // Outline mode
404  m_gal->SetIsFill( false );
405  }
406  else
407  {
408  // Filled mode
409  m_gal->SetFillColor( color );
410  m_gal->SetIsFill( true );
411  }
412 
413  m_gal->DrawSegment( start, end, width );
414 
415  // Clearance lines
416  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
417 
418  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
419  {
421  m_gal->SetIsFill( false );
422  m_gal->SetIsStroke( true );
423  m_gal->SetStrokeColor( color );
424  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
425  }
426  }
427 }
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:269
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:148
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:210
const wxPoint & GetEnd() const
Definition: class_track.h:119
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:342
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:292
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint & GetStart() const
Definition: class_track.h:122
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:166
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:178
int GetWidth() const
Definition: class_track.h:116
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:461
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 430 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, maxSize, 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.

431 {
432  VECTOR2D center( aVia->GetStart() );
433  double radius = 0.0;
434 
435  // Draw description layer
436  if( IsNetnameLayer( aLayer ) )
437  {
438  VECTOR2D position( center );
439 
440  // Is anything that we can display enabled?
442  {
443  bool displayNetname = ( !aVia->GetNetname().empty() );
445  double size = aVia->GetWidth();
446 
447  // Font size limits
448  if( size > maxSize )
449  size = maxSize;
450 
451  m_gal->Save();
452  m_gal->Translate( position );
453 
454  // Default font settings
456  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
457 
458  // Set the text position to the pad shape position (the pad position is not the best place)
459  VECTOR2D textpos( 0.0, 0.0 );
460 
461  if( displayNetname )
462  {
463  // calculate the size of net name text:
464  double tsize = 1.5 * size / aVia->GetShortNetname().Length();
465  tsize = std::min( tsize, size );
466  // Use a smaller text size to handle interline, pen size..
467  tsize *= 0.7;
468  VECTOR2D namesize( tsize, tsize );
469 
470  m_gal->SetGlyphSize( namesize );
471  m_gal->SetLineWidth( namesize.x / 12.0 );
472  m_gal->BitmapText( aVia->GetShortNetname(), textpos, 0.0 );
473  }
474 
475 
476  m_gal->Restore();
477  }
478  return;
479  }
480 
481  // Choose drawing settings depending on if we are drawing via's pad or hole
482  if( aLayer == LAYER_VIAS_HOLES )
483  radius = aVia->GetDrillValue() / 2.0;
484  else
485  radius = aVia->GetWidth() / 2.0;
486 
487  bool sketchMode = false;
488  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
489 
490  switch( aVia->GetViaType() )
491  {
492  case VIA_THROUGH:
494  break;
495 
496  case VIA_BLIND_BURIED:
498  break;
499 
500  case VIA_MICROVIA:
502  break;
503 
504  default:
505  assert( false );
506  break;
507  }
508 
509  if( aVia->GetViaType() == VIA_BLIND_BURIED )
510  {
511  // Buried vias are drawn in a special way to indicate the top and bottom layers
512  PCB_LAYER_ID layerTop, layerBottom;
513  aVia->LayerPair( &layerTop, &layerBottom );
514 
515  if( aLayer == LAYER_VIAS_HOLES )
516  { // TODO outline mode
517  m_gal->SetIsFill( true );
518  m_gal->SetIsStroke( false );
519  m_gal->SetFillColor( color );
520  m_gal->DrawCircle( center, radius );
521  }
522  else
523  {
524  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
525 
526  m_gal->SetLineWidth( width );
527  m_gal->SetIsFill( true );
528  m_gal->SetIsStroke( false );
529  m_gal->SetFillColor( color );
530 
531  if( aLayer == layerTop )
532  {
533  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
534  }
535  else if( aLayer == layerBottom )
536  {
537  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
538  }
539  else if( aLayer == LAYER_VIA_BBLIND )
540  {
541  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
542  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
543  }
544  }
545  }
546  else
547  {
548  // Regular vias
549  m_gal->SetIsFill( !sketchMode );
550  m_gal->SetIsStroke( sketchMode );
551 
552  if( sketchMode )
553  {
554  // Outline mode
556  m_gal->SetStrokeColor( color );
557  }
558  else
559  {
560  // Filled mode
561  m_gal->SetFillColor( color );
562  }
563 
564  m_gal->DrawCircle( center, radius );
565  }
566 
567  // Clearance lines
568  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
569 
570  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
571  && aLayer != LAYER_VIAS_HOLES )
572  {
574  m_gal->SetIsFill( false );
575  m_gal->SetIsStroke( true );
576  m_gal->SetStrokeColor( color );
577  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
578  }
579 }
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:269
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:148
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:210
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:342
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:454
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:172
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const int maxSize
const wxPoint & GetStart() const
Definition: class_track.h:122
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:178
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:116
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:169
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 582 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, DECIDEG2RAD(), KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawPolygon(), 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_PLATEDHOLES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH, KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::PCB_RENDER_SETTINGS::m_netNamesOnPads, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::PCB_RENDER_SETTINGS::m_padNumbers, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::PCB_RENDER_SETTINGS::MAX_FONT_SIZE, maxSize, 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(), 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.

583 {
584  PAD_SHAPE_T shape;
585  double m, n;
586  double orientation = aPad->GetOrientation();
587 
588  // Draw description layer
589  if( IsNetnameLayer( aLayer ) )
590  {
591  VECTOR2D position( aPad->ShapePos() );
592 
593  // Is anything that we can display enabled?
595  {
596  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
597  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
599  double size = padsize.y;
600 
601  // Keep the size ratio for the font, but make it smaller
602  if( padsize.x < padsize.y )
603  {
604  orientation += 900.0;
605  size = padsize.x;
606  std::swap( padsize.x, padsize.y );
607  }
608  else if( padsize.x == padsize.y )
609  {
610  // If the text is displayed on a symmetrical pad, do not rotate it
611  orientation = 0.0;
612  }
613 
614  // Font size limits
615  if( size > maxSize )
616  size = maxSize;
617 
618  m_gal->Save();
619  m_gal->Translate( position );
620 
621  // do not display descriptions upside down
622  NORMALIZE_ANGLE_90( orientation );
623  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
624 
625  // Default font settings
628  m_gal->SetFontBold( false );
629  m_gal->SetFontItalic( false );
630  m_gal->SetTextMirrored( false );
631  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
632  m_gal->SetIsStroke( true );
633  m_gal->SetIsFill( false );
634 
635  // Set the text position to the pad shape position (the pad position is not the best place)
636  VECTOR2D textpos( 0.0, 0.0 );
637 
638  // Divide the space, to display both pad numbers and netnames
639  // and set the Y text position to display 2 lines
640  if( displayNetname && m_pcbSettings.m_padNumbers )
641  {
642  size = size / 2.0;
643  textpos.y = size / 2.0;
644  }
645 
646  if( displayNetname )
647  {
648  // calculate the size of net name text:
649  double tsize = 1.5 * padsize.x / aPad->GetShortNetname().Length();
650  tsize = std::min( tsize, size );
651  // Use a smaller text size to handle interline, pen size..
652  tsize *= 0.7;
653  VECTOR2D namesize( tsize, tsize );
654 
655  m_gal->SetGlyphSize( namesize );
656  m_gal->SetLineWidth( namesize.x / 12.0 );
657  m_gal->BitmapText( aPad->GetShortNetname(), textpos, 0.0 );
658  }
659 
661  {
662  const wxString& padName = aPad->GetName();
663  textpos.y = -textpos.y;
664  double tsize = 1.5 * padsize.x / padName.Length();
665  tsize = std::min( tsize, size );
666  // Use a smaller text size to handle interline, pen size..
667  tsize *= 0.7;
668  tsize = std::min( tsize, size );
669  VECTOR2D numsize( tsize, tsize );
670 
671  m_gal->SetGlyphSize( numsize );
672  m_gal->SetLineWidth( numsize.x / 12.0 );
673  m_gal->BitmapText( padName, textpos, 0.0 );
674  }
675 
676  m_gal->Restore();
677  }
678  return;
679  }
680 
681  // Pad drawing
682  COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
683 
684  // Pad holes color is specific
685  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
686  {
687  // Hole color is the background color for plated holes, but a specific color
688  // for not plated holes (LAYER_NON_PLATEDHOLES color layer )
690  color = m_pcbSettings.GetColor( nullptr, LAYER_NON_PLATEDHOLES );
691  // Don't let pads that *should* be NPTH get lost
692  else if( aPad->PadShouldBeNPTH() )
693  color = m_pcbSettings.GetColor( aPad, aLayer );
694  else
696  }
697 
698  VECTOR2D size;
699 
701  {
702  // Outline mode
703  m_gal->SetIsFill( false );
704  m_gal->SetIsStroke( true );
706  m_gal->SetStrokeColor( color );
707  }
708  else
709  {
710  // Filled mode
711  m_gal->SetIsFill( true );
712  m_gal->SetIsStroke( false );
713  m_gal->SetFillColor( color );
714  }
715 
716  m_gal->Save();
717  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
718  m_gal->Rotate( -aPad->GetOrientationRadians() );
719 
720  int custom_margin = 0; // a clearance/margin for custom shape, for solder paste/mask
721 
722  // Choose drawing settings depending on if we are drawing a pad itself or a hole
723  if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
724  {
725  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
726  size = VECTOR2D( aPad->GetDrillSize() ) / 2.0;
728  }
729  else if( aLayer == F_Mask || aLayer == B_Mask )
730  {
731  // Drawing soldermask
732  int soldermaskMargin = aPad->GetSolderMaskMargin();
733  custom_margin = soldermaskMargin;
734 
735  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
736  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
737  aPad->GetSize().y / 2.0 + soldermaskMargin );
738  shape = aPad->GetShape();
739  }
740  else if( aLayer == F_Paste || aLayer == B_Paste )
741  {
742  // Drawing solderpaste
743  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
744  // try to find a clearance which can be used for custom shapes
745  custom_margin = solderpasteMargin.x;
746 
747  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
748  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
749  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
750  shape = aPad->GetShape();
751  }
752  else
753  {
754  // Drawing every kind of pad
755  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
756  size = VECTOR2D( aPad->GetSize() ) / 2.0;
757  shape = aPad->GetShape();
758  }
759 
760  switch( shape )
761  {
762  case PAD_SHAPE_OVAL:
763  if( size.y >= size.x )
764  {
765  m = ( size.y - size.x );
766  n = size.x;
767 
769  {
770  // Outline mode
771  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
772  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
773  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
774  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
775  }
776  else
777  {
778  // Filled mode
779  m_gal->DrawCircle( VECTOR2D( 0, -m ), n );
780  m_gal->DrawCircle( VECTOR2D( 0, m ), n );
781  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
782  }
783  }
784  else
785  {
786  m = ( size.x - size.y );
787  n = size.y;
788 
790  {
791  // Outline mode
792  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
793  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
794  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
795  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
796  }
797  else
798  {
799  // Filled mode
800  m_gal->DrawCircle( VECTOR2D( -m, 0 ), n );
801  m_gal->DrawCircle( VECTOR2D( m, 0 ), n );
802  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
803  }
804  }
805  break;
806 
807  case PAD_SHAPE_RECT:
808  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
809  break;
810 
811  case PAD_SHAPE_ROUNDRECT:
812  {
813  SHAPE_POLY_SET polySet;
814  wxSize prsize( size.x * 2, size.y * 2 );
815  const int segmentToCircleCount = 64;
816  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
817  TransformRoundRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
818  0.0, corner_radius, segmentToCircleCount );
819  m_gal->DrawPolygon( polySet );
820  break;
821  }
822 
823  case PAD_SHAPE_CUSTOM:
824  { // Draw the complex custom shape
825 
826  // Use solder[Paste/Mask]size or pad size to build pad shape
827  // however, solder[Paste/Mask] size has no actual meaning for a
828  // custom shape, because it is a set of basic shapes
829  // We use the custom_margin (good for solder mask, but approximative
830  // for solder paste).
831  if( custom_margin )
832  {
833  SHAPE_POLY_SET outline;
834  outline.Append( aPad->GetCustomShapeAsPolygon() );
835  const int segmentToCircleCount = 32;
836  outline.Inflate( custom_margin, segmentToCircleCount );
837  m_gal->DrawPolygon( outline );
838  }
839  else
840  {
841  // Draw the polygon: only one polygon is expected
842  // However we provide a multi polygon shape drawing
843  // ( for the future or to show even an incorrect shape
845  }
846  }
847  break;
848 
849  case PAD_SHAPE_TRAPEZOID:
850  {
851  std::deque<VECTOR2D> pointList;
852  wxPoint corners[4];
853 
854  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
855  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
856 
857  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
858  SHAPE_POLY_SET polySet;
859  polySet.NewOutline();
860  polySet.Append( VECTOR2I( corners[0] ) );
861  polySet.Append( VECTOR2I( corners[1] ) );
862  polySet.Append( VECTOR2I( corners[2] ) );
863  polySet.Append( VECTOR2I( corners[3] ) );
864 
865  m_gal->DrawPolygon( polySet );
866  }
867  break;
868 
869  case PAD_SHAPE_CIRCLE:
870  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
871  break;
872  }
873 
874  m_gal->Restore();
875 
876  // Clearance lines
877  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
878  // returns already transformed coordinates
879  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
880 
881  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
882  && ( aLayer == LAYER_PAD_FR
883  || aLayer == LAYER_PAD_BK
884  || aLayer == LAYER_PADS_TH ) )
885  {
886  SHAPE_POLY_SET polySet;
887  constexpr int SEGCOUNT = 64;
888  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
890  m_gal->SetIsStroke( true );
891  m_gal->SetIsFill( false );
892  m_gal->SetStrokeColor( color );
893  m_gal->DrawPolygon( polySet );
894  }
895 }
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.
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:269
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:148
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:528
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:160
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:388
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:210
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
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:163
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:342
virtual void Rotate(double aAngle)
Rotate the context.
void SetFontBold(const bool aBold)
Set bold property of current font.
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:586
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:172
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const int maxSize
Class SHAPE_POLY_SET.
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:585
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 TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
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:178
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
double DECIDEG2RAD(double deg)
Definition: trigo.h:203
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:628
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:554
wxPoint ShapePos() const
Definition: class_pad.cpp:508
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.
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:1241
const wxPoint & GetOffset() const
Definition: class_pad.h:278
const COLOR4D & GetBackgroundColor() const
Function GetBackgroundColor Returns current background color settings.
Definition: painter.h:196
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
#define min(a, b)
Definition: auxiliary.h:85
#define SEGCOUNT
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 898 of file pcb_painter.cpp.

References DRAWSEGMENT::BuildPolyPointsList(), color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawCurve(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawRectangle(), KIGFX::GAL::DrawSegment(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcAngleStart(), DRAWSEGMENT::GetBezControl1(), DRAWSEGMENT::GetBezControl2(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), DRAWSEGMENT::GetEnd(), BOARD_ITEM::GetLayer(), getLineThickness(), DRAWSEGMENT::GetParentModule(), DRAWSEGMENT::GetRadius(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), KIGFX::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().

899 {
900  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
901  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
902  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
903 
904  int thickness = getLineThickness( aSegment->GetWidth() );
905  VECTOR2D start( aSegment->GetStart() );
906  VECTOR2D end( aSegment->GetEnd() );
907 
908  m_gal->SetIsFill( !sketch );
909  m_gal->SetIsStroke( sketch );
910  m_gal->SetFillColor( color );
911  m_gal->SetStrokeColor( color );
913 
914  switch( aSegment->GetShape() )
915  {
916  case S_SEGMENT:
917  m_gal->DrawSegment( start, end, thickness );
918  break;
919 
920  case S_RECT:
921  wxASSERT_MSG( false, "Not tested yet" );
922  m_gal->DrawRectangle( start, end );
923  break;
924 
925  case S_ARC:
926  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
927  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
928  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
929  thickness );
930  break;
931 
932  case S_CIRCLE:
933  if( sketch )
934  {
935  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
936  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
937  }
938  else
939  {
940  m_gal->SetLineWidth( thickness );
941  m_gal->SetIsFill( false );
942  m_gal->SetIsStroke( true );
943  m_gal->DrawCircle( start, aSegment->GetRadius() );
944  }
945  break;
946 
947  case S_POLYGON:
948  {
949  const auto& points = aSegment->BuildPolyPointsList();
950  std::deque<VECTOR2D> pointsList;
951 
952  if( points.empty() )
953  break;
954 
955  m_gal->Save();
956 
957  if( MODULE* module = aSegment->GetParentModule() )
958  {
959  m_gal->Translate( module->GetPosition() );
960  m_gal->Rotate( -module->GetOrientationRadians() );
961  }
962 
963  std::copy( points.begin(), points.end(), std::back_inserter( pointsList ) );
964  pointsList.push_back( points[0] );
965 
966  m_gal->SetLineWidth( thickness );
967  m_gal->SetIsFill( true );
968  m_gal->SetIsStroke( true );
969  m_gal->DrawPolygon( pointsList );
970 
971  m_gal->Restore();
972  break;
973  }
974 
975  case S_CURVE:
976  m_gal->SetIsFill( false );
977  m_gal->SetIsStroke( true );
978  m_gal->SetLineWidth( thickness );
979  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
980  VECTOR2D( aSegment->GetBezControl1() ),
981  VECTOR2D( aSegment->GetBezControl2() ),
982  VECTOR2D( aSegment->GetEnd() ) );
983  break;
984 
985  case S_LAST:
986  break;
987  }
988 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
const wxPoint & GetBezControl2() const
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:269
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:151
usual segment : line with rounded ends
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:210
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:342
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:586
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:154
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 
)
protected

Definition at line 991 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.

992 {
993  wxString shownText( aText->GetShownText() );
994  if( shownText.Length() == 0 )
995  return;
996 
997  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
998  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
999 
1000  if( m_pcbSettings.m_sketchMode[aLayer] )
1001  {
1002  // Outline mode
1004  }
1005  else
1006  {
1007  // Filled mode
1009  }
1010 
1011  m_gal->SetStrokeColor( color );
1012  m_gal->SetIsFill( false );
1013  m_gal->SetIsStroke( true );
1014  m_gal->SetTextAttributes( aText );
1015  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
1016 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:269
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:148
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:210
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:342
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:133
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.
double GetTextAngleRadians() const
Definition: eda_text.h:165
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 1019 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(), EDA_ITEM::IsSelected(), KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchFpTxtfx, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), KIGFX::GAL::StrokeText(), wxPoint::x, and wxPoint::y.

1020 {
1021  wxString shownText( aText->GetShownText() );
1022  if( shownText.Length() == 0 )
1023  return;
1024 
1025  bool sketch = m_pcbSettings.m_sketchFpTxtfx;
1026 
1027  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
1028  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
1029 
1030  // Currently, draw text routines do not know the true outline mode.
1031  // so draw the text in "line" mode (no thickness)
1032  if( sketch )
1033  {
1034  // Outline mode
1036  }
1037  else
1038  {
1039  // Filled mode
1041  }
1042 
1043  m_gal->SetStrokeColor( color );
1044  m_gal->SetIsFill( false );
1045  m_gal->SetIsStroke( true );
1046  m_gal->SetTextAttributes( aText );
1047  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
1048 
1049  // Draw the umbilical line
1050  if( aText->IsSelected() )
1051  {
1053  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1054  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1055  }
1056 }
BOARD_ITEM_CONTAINER * GetParent() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:269
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:221
bool m_sketchFpTxtfx
Flag determining if footprint text items should be outlined or stroked
Definition: pcb_painter.h:157
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:210
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:342
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
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 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 
)
protected

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

1060 {
1061  if( aLayer == LAYER_ANCHOR )
1062  {
1063  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1064 
1065  // Draw anchor
1066  m_gal->SetStrokeColor( color );
1068 
1069  // Keep the size constant, not related to the scale
1070  double anchorSize = 5.0 / m_gal->GetWorldScale();
1071 
1072  VECTOR2D center = aModule->GetPosition();
1073  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1074  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1075  }
1076 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:269
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:210
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:342
virtual void SetLineWidth(double 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:184
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 
)
protected

Definition at line 1079 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, m_pcbSettings, ZONE_CONTAINER::Outline(), SHAPE_POLY_SET::OutlineCount(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

1080 {
1081  if( !aZone->IsOnLayer( (PCB_LAYER_ID) aLayer ) )
1082  return;
1083 
1084  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aLayer );
1085  std::deque<VECTOR2D> corners;
1087 
1088  // Draw the outline
1089  const SHAPE_POLY_SET* outline = aZone->Outline();
1090 
1091  if( outline )
1092  {
1093  m_gal->SetStrokeColor( color );
1094  m_gal->SetIsFill( false );
1095  m_gal->SetIsStroke( true );
1097 
1098  // Draw each contour (main contour and holes)
1099 
1100  /* This line:
1101  * m_gal->DrawPolygon( *outline );
1102  * should be enough, but currently does not work to draw holes contours in a complex polygon
1103  * so each contour is draw as a simple polygon
1104  */
1105 
1106  // Draw the main contour
1107  m_gal->DrawPolyline( outline->COutline( 0 ) );
1108 
1109  // Draw holes
1110  int holes_count = outline->HoleCount( 0 );
1111 
1112  for( int ii = 0; ii < holes_count; ++ii )
1113  m_gal->DrawPolyline( outline->CHole( 0, ii ) );
1114 
1115  // Draw hatch lines
1116  for( const SEG& hatchLine : aZone->GetHatchLines() )
1117  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1118  }
1119 
1120  // Draw the filling
1121  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1122  {
1123  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1124 
1125  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1126  return;
1127 
1128  // Set up drawing options
1129  m_gal->SetFillColor( color );
1130  m_gal->SetLineWidth( aZone->GetMinThickness() );
1131 
1132  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1133  {
1134  m_gal->SetIsFill( true );
1135  m_gal->SetIsStroke( true );
1136  }
1137  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1138  {
1139  m_gal->SetIsFill( false );
1140  m_gal->SetIsStroke( true );
1141  }
1142 
1143  m_gal->DrawPolygon( polySet );
1144  }
1145 
1146 }
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:269
int GetMinThickness() const
Definition: class_zone.h:198
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:236
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:175
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:210
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:659
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:342
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetLineWidth(double aLineWidth)
Set the line width.
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:534
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.
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 
)
protected

Definition at line 1149 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.

1150 {
1151  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1152 
1153  m_gal->SetStrokeColor( strokeColor );
1154  m_gal->SetIsFill( false );
1155  m_gal->SetIsStroke( true );
1156  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1157 
1158  // Draw an arrow
1159  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1160  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1161  VECTOR2D( aDimension->m_featureLineGF ) );
1162  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1163  VECTOR2D( aDimension->m_featureLineDF ) );
1164  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1165  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1166  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1167  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1168 
1169  // Draw text
1170  TEXTE_PCB& text = aDimension->Text();
1171  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1172 
1173  m_gal->SetLineWidth( text.GetThickness() );
1174  m_gal->SetTextAttributes( &text );
1175  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1176 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
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:210
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:342
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
wxPoint m_featureLineGO
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:133
virtual void SetLineWidth(double aLineWidth)
Set the line width.
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:165
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 1179 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().

1180 {
1181  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1182  VECTOR2D position( aTarget->GetPosition() );
1183  double size, radius;
1184 
1185  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1186  m_gal->SetStrokeColor( strokeColor );
1187  m_gal->SetIsFill( false );
1188  m_gal->SetIsStroke( true );
1189 
1190  m_gal->Save();
1191  m_gal->Translate( position );
1192 
1193  if( aTarget->GetShape() )
1194  {
1195  // shape x
1196  m_gal->Rotate( M_PI / 4.0 );
1197  size = 2.0 * aTarget->GetSize() / 3.0;
1198  radius = aTarget->GetSize() / 2.0;
1199  }
1200  else
1201  {
1202  // shape +
1203  size = aTarget->GetSize() / 2.0;
1204  radius = aTarget->GetSize() / 3.0;
1205  }
1206 
1207  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1208  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1209  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1210 
1211  m_gal->Restore();
1212 }
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:210
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:342
virtual void Rotate(double aAngle)
Rotate the context.
int GetShape() const
virtual void SetLineWidth(double aLineWidth)
Set the line width.
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)
protected

Definition at line 1215 of file pcb_painter.cpp.

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

1216 {
1217  // If you are changing this, update MARKER_PCB::ViewBBox()
1218  const int scale = 100000;
1219 
1220  const VECTOR2D arrow[] = {
1221  VECTOR2D( 0 * scale, 0 * scale ),
1222  VECTOR2D( 8 * scale, 1 * scale ),
1223  VECTOR2D( 4 * scale, 3 * scale ),
1224  VECTOR2D( 13 * scale, 8 * scale ),
1225  VECTOR2D( 9 * scale, 9 * scale ),
1226  VECTOR2D( 8 * scale, 13 * scale ),
1227  VECTOR2D( 3 * scale, 4 * scale ),
1228  VECTOR2D( 1 * scale, 8 * scale ),
1229  VECTOR2D( 0 * scale, 0 * scale )
1230  };
1231 
1232  auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
1233 
1234  m_gal->Save();
1235  m_gal->Translate( aMarker->GetPosition() );
1236  m_gal->SetFillColor( strokeColor );
1237  m_gal->SetIsFill( true );
1238  m_gal->SetIsStroke( false );
1239  m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
1240  m_gal->Restore();
1241 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
const wxPoint GetPosition() const override
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:210
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:342
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
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.
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 271 of file pcb_painter.cpp.

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

Referenced by draw().

272 {
273  // if items have 0 thickness, draw them with the outline
274  // width, otherwise respect the set value (which, no matter
275  // how small will produce something)
276  if( aActualThickness == 0 )
278 
279  return aActualThickness;
280 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:269
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:210
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 201 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().

202  {
203  return &m_pcbSettings;
204  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:210
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 310 of file painter.h.

311  {
312  m_gal = aGal;
313  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:342

Member Data Documentation

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 345 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 342 of file painter.h.

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

PCB_RENDER_SETTINGS KIGFX::PCB_PAINTER::m_pcbSettings
protected

Definition at line 210 of file pcb_painter.h.

Referenced by draw(), and getLineThickness().


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