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

Constructor & Destructor Documentation

PCB_PAINTER::PCB_PAINTER ( GAL aGal)

Definition at line 242 of file pcb_painter.cpp.

242  :
243  PAINTER( aGal )
244 {
245 }
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 172 of file pcb_painter.h.

References m_pcbSettings.

173  {
174  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
175  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:187
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 260 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().

261 {
262  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
263 
264  // the "cast" applied in here clarifies which overloaded draw() is called
265  switch( item->Type() )
266  {
267  case PCB_ZONE_T:
268  case PCB_TRACE_T:
269  draw( static_cast<const TRACK*>( item ), aLayer );
270  break;
271 
272  case PCB_VIA_T:
273  draw( static_cast<const VIA*>( item ), aLayer );
274  break;
275 
276  case PCB_PAD_T:
277  draw( static_cast<const D_PAD*>( item ), aLayer );
278  break;
279 
280  case PCB_LINE_T:
281  case PCB_MODULE_EDGE_T:
282  draw( static_cast<const DRAWSEGMENT*>( item ), aLayer );
283  break;
284 
285  case PCB_TEXT_T:
286  draw( static_cast<const TEXTE_PCB*>( item ), aLayer );
287  break;
288 
289  case PCB_MODULE_TEXT_T:
290  draw( static_cast<const TEXTE_MODULE*>( item ), aLayer );
291  break;
292 
293  case PCB_MODULE_T:
294  draw( static_cast<const MODULE*>( item ), aLayer );
295  break;
296 
297  case PCB_ZONE_AREA_T:
298  draw( static_cast<const ZONE_CONTAINER*>( item ) );
299  break;
300 
301  case PCB_DIMENSION_T:
302  draw( static_cast<const DIMENSION*>( item ), aLayer );
303  break;
304 
305  case PCB_TARGET_T:
306  draw( static_cast<const PCB_TARGET*>( item ) );
307  break;
308 
309  case PCB_MARKER_T:
310  draw( static_cast<const MARKER_PCB*>( item ) );
311  break;
312 
313  default:
314  // Painter does not know how to draw the object
315  return false;
316  }
317 
318  return true;
319 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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:151
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 322 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().

323 {
324  VECTOR2D start( aTrack->GetStart() );
325  VECTOR2D end( aTrack->GetEnd() );
326  int width = aTrack->GetWidth();
327 
329  {
330  // If there is a net name - display it on the track
331  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
332  {
333  VECTOR2D line = ( end - start );
334  double length = line.EuclideanNorm();
335 
336  // Check if the track is long enough to have a netname displayed
337  if( length < 10 * width )
338  return;
339 
340  const wxString& netName = aTrack->GetShortNetname();
341  VECTOR2D textPosition = start + line / 2.0; // center of the track
342  double textOrientation = -atan( line.y / line.x );
343  double textSize = width;
344 
345  m_gal->SetIsStroke( true );
346  m_gal->SetIsFill( false );
347  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
348  m_gal->SetLineWidth( width / 10.0 );
349  m_gal->SetFontBold( false );
350  m_gal->SetFontItalic( false );
351  m_gal->SetTextMirrored( false );
352  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
355  m_gal->BitmapText( netName, textPosition, textOrientation );
356  }
357  }
358  else if( IsCopperLayer( aLayer ) )
359  {
360  // Draw a regular track
361  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
362  m_gal->SetStrokeColor( color );
363  m_gal->SetIsStroke( true );
364 
366  {
367  // Outline mode
369  m_gal->SetIsFill( false );
370  }
371  else
372  {
373  // Filled mode
374  m_gal->SetFillColor( color );
375  m_gal->SetIsFill( true );
376  }
377 
378  m_gal->DrawSegment( start, end, width );
379 
380  // Clearance lines
381  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
382 
383  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
384  {
386  m_gal->SetIsFill( false );
387  m_gal->SetIsStroke( true );
388  m_gal->SetStrokeColor( color );
389  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
390  }
391  }
392 }
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:131
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:187
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:146
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:158
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 395 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.

396 {
397  VECTOR2D center( aVia->GetStart() );
398  double radius = 0.0;
399 
400  // Draw description layer
401  if( IsNetnameLayer( aLayer ) )
402  {
403  VECTOR2D position( center );
404 
405  // Is anything that we can display enabled?
407  {
408  bool displayNetname = ( !aVia->GetNetname().empty() );
409  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
410  double size = aVia->GetWidth();
411 
412  // Font size limits
413  if( size > maxSize )
414  size = maxSize;
415 
416  m_gal->Save();
417  m_gal->Translate( position );
418 
419  // Default font settings
421  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
422 
423  // Set the text position to the pad shape position (the pad position is not the best place)
424  VECTOR2D textpos( 0.0, 0.0 );
425 
426  if( displayNetname )
427  {
428  // calculate the size of net name text:
429  double tsize = 1.5 * size / aVia->GetShortNetname().Length();
430  tsize = std::min( tsize, size );
431  // Use a smaller text size to handle interline, pen size..
432  tsize *= 0.7;
433  VECTOR2D namesize( tsize, tsize );
434 
435  m_gal->SetGlyphSize( namesize );
436  m_gal->SetLineWidth( namesize.x / 12.0 );
437  m_gal->BitmapText( aVia->GetShortNetname(), textpos, 0.0 );
438  }
439 
440 
441  m_gal->Restore();
442  }
443  return;
444  }
445 
446  // Choose drawing settings depending on if we are drawing via's pad or hole
447  if( aLayer == LAYER_VIAS_HOLES )
448  radius = aVia->GetDrillValue() / 2.0;
449  else
450  radius = aVia->GetWidth() / 2.0;
451 
452  bool sketchMode = false;
453  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
454 
455  switch( aVia->GetViaType() )
456  {
457  case VIA_THROUGH:
459  break;
460 
461  case VIA_BLIND_BURIED:
463  break;
464 
465  case VIA_MICROVIA:
467  break;
468 
469  default:
470  assert( false );
471  break;
472  }
473 
474  if( aVia->GetViaType() == VIA_BLIND_BURIED )
475  {
476  // Buried vias are drawn in a special way to indicate the top and bottom layers
477  PCB_LAYER_ID layerTop, layerBottom;
478  aVia->LayerPair( &layerTop, &layerBottom );
479 
480  if( aLayer == LAYER_VIAS_HOLES )
481  { // TODO outline mode
482  m_gal->SetIsFill( true );
483  m_gal->SetIsStroke( false );
484  m_gal->SetFillColor( color );
485  m_gal->DrawCircle( center, radius );
486  }
487  else
488  {
489  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
490 
491  m_gal->SetLineWidth( width );
492  m_gal->SetIsFill( true );
493  m_gal->SetIsStroke( false );
494  m_gal->SetFillColor( color );
495 
496  if( aLayer == layerTop )
497  {
498  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
499  }
500  else if( aLayer == layerBottom )
501  {
502  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
503  }
504  else if( aLayer == LAYER_VIA_BBLIND )
505  {
506  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
507  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
508  }
509  }
510  }
511  else
512  {
513  // Regular vias
514  m_gal->SetIsFill( !sketchMode );
515  m_gal->SetIsStroke( sketchMode );
516 
517  if( sketchMode )
518  {
519  // Outline mode
521  m_gal->SetStrokeColor( color );
522  }
523  else
524  {
525  // Filled mode
526  m_gal->SetFillColor( color );
527  }
528 
529  m_gal->DrawCircle( center, radius );
530  }
531 
532  // Clearance lines
533  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
534 
535  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
536  && aLayer != LAYER_VIAS_HOLES )
537  {
539  m_gal->SetIsFill( false );
540  m_gal->SetIsStroke( true );
541  m_gal->SetStrokeColor( color );
542  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
543  }
544 }
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:131
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:187
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:152
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:158
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:149
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 547 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(), 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::GetDrillShape(), D_PAD::GetDrillSize(), BOARD_CONNECTED_ITEM::GetNetname(), D_PAD::GetOffset(), D_PAD::GetOrientation(), D_PAD::GetOrientationRadians(), D_PAD::GetPadName(), 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, 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_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, 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(), D_PAD::StringPadName(), TransformRoundRectToPolygon(), D_PAD::TransformShapeWithClearanceToPolygon(), KIGFX::GAL::Translate(), VECTOR2< T >::x, and VECTOR2< T >::y.

548 {
549  PAD_SHAPE_T shape;
550  double m, n;
551  double orientation = aPad->GetOrientation();
552  wxString buffer;
553 
554  // Draw description layer
555  if( IsNetnameLayer( aLayer ) )
556  {
557  VECTOR2D position( aPad->ShapePos() );
558 
559  // Is anything that we can display enabled?
561  {
562  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
563  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
564  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
565  double size = padsize.y;
566 
567  // Keep the size ratio for the font, but make it smaller
568  if( padsize.x < padsize.y )
569  {
570  orientation += 900.0;
571  size = padsize.x;
572  std::swap( padsize.x, padsize.y );
573  }
574  else if( padsize.x == padsize.y )
575  {
576  // If the text is displayed on a symmetrical pad, do not rotate it
577  orientation = 0.0;
578  }
579 
580  // Font size limits
581  if( size > maxSize )
582  size = maxSize;
583 
584  m_gal->Save();
585  m_gal->Translate( position );
586 
587  // do not display descriptions upside down
588  NORMALIZE_ANGLE_90( orientation );
589  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
590 
591  // Default font settings
594  m_gal->SetFontBold( false );
595  m_gal->SetFontItalic( false );
596  m_gal->SetTextMirrored( false );
597  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
598  m_gal->SetIsStroke( true );
599  m_gal->SetIsFill( false );
600 
601  // Set the text position to the pad shape position (the pad position is not the best place)
602  VECTOR2D textpos( 0.0, 0.0 );
603 
604  // Divide the space, to display both pad numbers and netnames
605  // and set the Y text position to display 2 lines
606  if( displayNetname && m_pcbSettings.m_padNumbers )
607  {
608  size = size / 2.0;
609  textpos.y = size / 2.0;
610  }
611 
612  if( displayNetname )
613  {
614  // calculate the size of net name text:
615  double tsize = 1.5 * padsize.x / aPad->GetShortNetname().Length();
616  tsize = std::min( tsize, size );
617  // Use a smaller text size to handle interline, pen size..
618  tsize *= 0.7;
619  VECTOR2D namesize( tsize, tsize );
620 
621  m_gal->SetGlyphSize( namesize );
622  m_gal->SetLineWidth( namesize.x / 12.0 );
623  m_gal->BitmapText( aPad->GetShortNetname(), textpos, 0.0 );
624  }
625 
627  {
628  textpos.y = -textpos.y;
629  aPad->StringPadName( buffer );
630  int len = buffer.Length();
631  double tsize = 1.5 * padsize.x / len;
632  tsize = std::min( tsize, size );
633  // Use a smaller text size to handle interline, pen size..
634  tsize *= 0.7;
635  tsize = std::min( tsize, size );
636  VECTOR2D numsize( tsize, tsize );
637 
638  m_gal->SetGlyphSize( numsize );
639  m_gal->SetLineWidth( numsize.x / 12.0 );
640  m_gal->BitmapText( aPad->GetPadName(), textpos, 0.0 );
641  }
642 
643  m_gal->Restore();
644  }
645  return;
646  }
647 
648  // Pad drawing
649  COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
650 
651  // Pad holes color is specific
652  if( aLayer == LAYER_PADS_HOLES || aLayer == LAYER_NON_PLATED )
653  {
654  // Hole color is the background color for plated holes, but a specific color
655  // for not plated holes (LAYER_NON_PLATED color layer )
656  if( aPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED /*&&
657  brd->IsElementVisible( LAYER_NON_PLATED )*/ )
658  color = m_pcbSettings.GetColor( nullptr, LAYER_NON_PLATED );
659  else
661  }
662 
663  VECTOR2D size;
664 
666  {
667  // Outline mode
668  m_gal->SetIsFill( false );
669  m_gal->SetIsStroke( true );
671  m_gal->SetStrokeColor( color );
672  }
673  else
674  {
675  // Filled mode
676  m_gal->SetIsFill( true );
677  m_gal->SetIsStroke( false );
678  m_gal->SetFillColor( color );
679  }
680 
681  m_gal->Save();
682  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
683  m_gal->Rotate( -aPad->GetOrientationRadians() );
684 
685  // Choose drawing settings depending on if we are drawing a pad itself or a hole
686  if( aLayer == LAYER_PADS_HOLES || aLayer == LAYER_NON_PLATED )
687  {
688  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
689  size = VECTOR2D( aPad->GetDrillSize() ) / 2.0;
691  }
692  else if( aLayer == F_Mask || aLayer == B_Mask )
693  {
694  // Drawing soldermask
695  int soldermaskMargin = aPad->GetSolderMaskMargin();
696 
697  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
698  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
699  aPad->GetSize().y / 2.0 + soldermaskMargin );
700  shape = aPad->GetShape();
701  }
702  else if( aLayer == F_Paste || aLayer == B_Paste )
703  {
704  // Drawing solderpaste
705  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
706 
707  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
708  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
709  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
710  shape = aPad->GetShape();
711  }
712  else
713  {
714  // Drawing every kind of pad
715  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
716  size = VECTOR2D( aPad->GetSize() ) / 2.0;
717  shape = aPad->GetShape();
718  }
719 
720  switch( shape )
721  {
722  case PAD_SHAPE_OVAL:
723  if( size.y >= size.x )
724  {
725  m = ( size.y - size.x );
726  n = size.x;
727 
729  {
730  // Outline mode
731  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
732  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
733  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
734  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
735  }
736  else
737  {
738  // Filled mode
739  m_gal->DrawCircle( VECTOR2D( 0, -m ), n );
740  m_gal->DrawCircle( VECTOR2D( 0, m ), n );
741  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
742  }
743  }
744  else
745  {
746  m = ( size.x - size.y );
747  n = size.y;
748 
750  {
751  // Outline mode
752  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
753  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
754  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
755  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
756  }
757  else
758  {
759  // Filled mode
760  m_gal->DrawCircle( VECTOR2D( -m, 0 ), n );
761  m_gal->DrawCircle( VECTOR2D( m, 0 ), n );
762  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
763  }
764  }
765  break;
766 
767  case PAD_SHAPE_RECT:
768  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
769  break;
770 
771  case PAD_SHAPE_ROUNDRECT:
772  {
773  SHAPE_POLY_SET polySet;
774  wxSize prsize( size.x * 2, size.y * 2 );
775  const int segmentToCircleCount = 64;
776  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
777  TransformRoundRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
778  0.0, corner_radius, segmentToCircleCount );
779 
781  {
782  if( polySet.OutlineCount() > 0 )
783  m_gal->DrawPolyline( polySet.Outline( 0 ) );
784  }
785  else
786  {
787  m_gal->DrawPolygon( polySet );
788  }
789  break;
790  }
791 
792  case PAD_SHAPE_TRAPEZOID:
793  {
794  std::deque<VECTOR2D> pointList;
795  wxPoint corners[4];
796 
797  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
798  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
799 
800  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
801  SHAPE_POLY_SET polySet;
802  polySet.NewOutline();
803  polySet.Append( VECTOR2I( corners[0] ) );
804  polySet.Append( VECTOR2I( corners[1] ) );
805  polySet.Append( VECTOR2I( corners[2] ) );
806  polySet.Append( VECTOR2I( corners[3] ) );
807 
809  m_gal->DrawPolyline( polySet.COutline( 0 ) );
810  else
811  m_gal->DrawPolygon( polySet );
812  }
813  break;
814 
815  case PAD_SHAPE_CIRCLE:
816  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
817  break;
818  }
819 
820  m_gal->Restore();
821 
822  // Clearance lines
823  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
824  // returns already transformed coordinates
825  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
826 
827  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
828  && ( aLayer == LAYER_PAD_FR
829  || aLayer == LAYER_PAD_BK
830  || aLayer == LAYER_PADS ) )
831  {
832  SHAPE_POLY_SET polySet;
833  constexpr int SEGCOUNT = 64;
834  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
835 
836  if( polySet.OutlineCount() > 0 )
837  {
839  m_gal->SetIsStroke( true );
840  m_gal->SetIsFill( false );
841  m_gal->SetStrokeColor( color );
842  m_gal->DrawPolyline( polySet.COutline( 0 ) );
843  }
844  }
845 }
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:238
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
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.
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
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:131
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:351
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:140
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:221
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:187
int OutlineCount() const
Returns the number of outlines in the set
const wxSize & GetDrillSize() const
Definition: class_pad.h:188
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:166
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:143
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.
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:152
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:537
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
multilayer pads, usually with holes
double GetOrientationRadians() const
Definition: class_pad.h:216
const wxSize & GetSize() const
Definition: class_pad.h:182
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:158
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
handle color for not plated holes
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:214
double DECIDEG2RAD(double deg)
Definition: trigo.h:195
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:570
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:506
wxPoint ShapePos() const
Definition: class_pad.cpp:418
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
wxString GetPadName() const
Definition: class_pad.cpp:433
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
void StringPadName(wxString &text) const
Definition: class_pad.cpp:442
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
const wxPoint & GetOffset() const
Definition: class_pad.h:191
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 848 of file pcb_painter.cpp.

References color, DECIDEG2RAD(), KIGFX::GAL::DrawArcSegment(), KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawCurve(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawPolyline(), 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().

849 {
850  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
851  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
852  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
853 
854  int thickness = getLineThickness( aSegment->GetWidth() );
855  VECTOR2D start( aSegment->GetStart() );
856  VECTOR2D end( aSegment->GetEnd() );
857 
858  m_gal->SetIsFill( !sketch );
859  m_gal->SetIsStroke( sketch );
860  m_gal->SetFillColor( color );
861  m_gal->SetStrokeColor( color );
863 
864  switch( aSegment->GetShape() )
865  {
866  case S_SEGMENT:
867  m_gal->DrawSegment( start, end, thickness );
868  break;
869 
870  case S_RECT:
871  wxASSERT_MSG( false, wxT( "Not tested yet" ) );
872  m_gal->DrawRectangle( start, end );
873  break;
874 
875  case S_ARC:
876  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
877  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
878  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
879  thickness );
880  break;
881 
882  case S_CIRCLE:
883  if( sketch )
884  {
885  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
886  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
887  }
888  else
889  {
890  m_gal->SetLineWidth( thickness );
891  m_gal->SetIsFill( false );
892  m_gal->SetIsStroke( true );
893  m_gal->DrawCircle( start, aSegment->GetRadius() );
894  }
895  break;
896 
897  case S_POLYGON:
898  {
899  std::deque<VECTOR2D> pointsList;
900 
901  m_gal->SetIsFill( true ); // draw polygons the legacy way
902  m_gal->SetIsStroke( false );
903  m_gal->Save();
904  m_gal->SetLineWidth( thickness );
905 
906  if( MODULE* module = aSegment->GetParentModule() )
907  {
908  m_gal->Translate( module->GetPosition() );
909  m_gal->Rotate( -module->GetOrientationRadians() );
910  }
911  else
912  {
913  m_gal->Translate( aSegment->GetPosition() );
914  m_gal->Rotate( DECIDEG2RAD( -aSegment->GetAngle() ) );
915  }
916 
917  std::copy( aSegment->GetPolyPoints().begin(), aSegment->GetPolyPoints().end(),
918  std::back_inserter( pointsList ) );
919 
920  m_gal->SetLineWidth( aSegment->GetWidth() );
921  m_gal->DrawPolyline( pointsList );
922  m_gal->DrawPolygon( pointsList );
923 
924  m_gal->Restore();
925  break;
926  }
927 
928  case S_CURVE:
929  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
930  VECTOR2D( aSegment->GetBezControl1() ),
931  VECTOR2D( aSegment->GetBezControl2() ),
932  VECTOR2D( aSegment->GetEnd() ) );
933  break;
934 
935  case S_LAST:
936  break;
937  }
938 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
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:134
usual segment : line with rounded ends
const std::vector< wxPoint > & GetPolyPoints() const
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:187
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:137
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 941 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.

942 {
943  wxString shownText( aText->GetShownText() );
944  if( shownText.Length() == 0 )
945  return;
946 
947  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
948  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
949 
950  if( m_pcbSettings.m_sketchMode[aLayer] )
951  {
952  // Outline mode
954  }
955  else
956  {
957  // Filled mode
959  }
960 
961  m_gal->SetStrokeColor( color );
962  m_gal->SetIsFill( false );
963  m_gal->SetIsStroke( true );
964  m_gal->SetTextAttributes( aText );
965  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
966 }
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:131
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:187
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 969 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.

970 {
971  wxString shownText( aText->GetShownText() );
972  if( shownText.Length() == 0 )
973  return;
974 
975  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
976  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
977 
978  if( m_pcbSettings.m_sketchMode[aLayer] )
979  {
980  // Outline mode
982  }
983  else
984  {
985  // Filled mode
987  }
988 
989  m_gal->SetStrokeColor( color );
990  m_gal->SetIsFill( false );
991  m_gal->SetIsStroke( true );
992  m_gal->SetTextAttributes( aText );
993  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
994 
995  // Draw the umbilical line
996  if( aText->IsSelected() && aText->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
997  {
999  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1000  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
1001  }
1002 }
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:131
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
virtual const wxPoint & GetPosition() const =0
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:187
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 1005 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().

1006 {
1007  if( aLayer == LAYER_ANCHOR )
1008  {
1009  const COLOR4D color = m_pcbSettings.GetColor( aModule, LAYER_ANCHOR );
1010 
1011  // Draw anchor
1012  m_gal->SetStrokeColor( color );
1014 
1015  // Keep the size constant, not related to the scale
1016  double anchorSize = 5.0 / m_gal->GetWorldScale();
1017 
1018  VECTOR2D center = aModule->GetPosition();
1019  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
1020  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
1021  }
1022 }
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:187
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 1025 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().

1026 {
1027  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aZone->GetLayer() );
1028  std::deque<VECTOR2D> corners;
1030 
1031  // Draw the outline
1032  m_gal->SetStrokeColor( color );
1033  m_gal->SetIsFill( false );
1034  m_gal->SetIsStroke( true );
1036 
1037  for( auto iterator = aZone->CIterateWithHoles(); iterator; iterator++ )
1038  {
1039  corners.push_back( VECTOR2D( *iterator ) );
1040 
1041  if( iterator.IsEndContour() )
1042  {
1043  // The last point for closing the polyline
1044  corners.push_back( corners[0] );
1045  m_gal->DrawPolyline( corners );
1046  corners.clear();
1047  }
1048 
1049  for( const SEG& hatchLine : aZone->GetHatchLines() )
1050  m_gal->DrawLine( hatchLine.A, hatchLine.B );
1051  }
1052 
1053  // Draw the filling
1054  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
1055  {
1056  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
1057 
1058  if( polySet.OutlineCount() == 0 ) // Nothing to draw
1059  return;
1060 
1061  // Set up drawing options
1062  m_gal->SetFillColor( color );
1063  m_gal->SetLineWidth( aZone->GetMinThickness() );
1064 
1065  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1066  {
1067  m_gal->SetIsFill( true );
1068  m_gal->SetIsStroke( true );
1069  }
1070  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1071  {
1072  m_gal->SetIsFill( false );
1073  m_gal->SetIsStroke( true );
1074  }
1075 
1076  for( int i = 0; i < polySet.OutlineCount(); i++ )
1077  {
1078  const SHAPE_LINE_CHAIN& outline = polySet.COutline( i );
1079  // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion
1080  // is just a performance hog)
1081 
1082  for( int j = 0; j < outline.PointCount(); j++ )
1083  corners.push_back ( (VECTOR2D) outline.CPoint( j ) );
1084 
1085  corners.push_back( (VECTOR2D) outline.CPoint( 0 ) );
1086 
1087  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1088  {
1089  m_gal->DrawPolygon( corners );
1090  m_gal->DrawPolyline( corners );
1091  }
1092  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1093  {
1094  m_gal->DrawPolyline( corners );
1095  }
1096 
1097  corners.clear();
1098  }
1099  }
1100 }
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:155
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:84
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:187
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 1103 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.

1104 {
1105  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1106 
1107  m_gal->SetStrokeColor( strokeColor );
1108  m_gal->SetIsFill( false );
1109  m_gal->SetIsStroke( true );
1110  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1111 
1112  // Draw an arrow
1113  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1114  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1115  VECTOR2D( aDimension->m_featureLineGF ) );
1116  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1117  VECTOR2D( aDimension->m_featureLineDF ) );
1118  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1119  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1120  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1121  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1122 
1123  // Draw text
1124  TEXTE_PCB& text = aDimension->Text();
1125  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1126 
1127  m_gal->SetLineWidth( text.GetThickness() );
1128  m_gal->SetTextAttributes( &text );
1129  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1130 }
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:187
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 1133 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().

1134 {
1135  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1136  VECTOR2D position( aTarget->GetPosition() );
1137  double size, radius;
1138 
1139  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1140  m_gal->SetStrokeColor( strokeColor );
1141  m_gal->SetIsFill( false );
1142  m_gal->SetIsStroke( true );
1143 
1144  m_gal->Save();
1145  m_gal->Translate( position );
1146 
1147  if( aTarget->GetShape() )
1148  {
1149  // shape x
1150  m_gal->Rotate( M_PI / 4.0 );
1151  size = 2.0 * aTarget->GetSize() / 3.0;
1152  radius = aTarget->GetSize() / 2.0;
1153  }
1154  else
1155  {
1156  // shape +
1157  size = aTarget->GetSize() / 2.0;
1158  radius = aTarget->GetSize() / 3.0;
1159  }
1160 
1161  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1162  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1163  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1164 
1165  m_gal->Restore();
1166 }
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:187
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 1169 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().

1170 {
1171  // If you are changing this, update MARKER_PCB::ViewBBox()
1172  const int scale = 100000;
1173 
1174  const VECTOR2D arrow[] = {
1175  VECTOR2D( 0 * scale, 0 * scale ),
1176  VECTOR2D( 8 * scale, 1 * scale ),
1177  VECTOR2D( 4 * scale, 3 * scale ),
1178  VECTOR2D( 13 * scale, 8 * scale ),
1179  VECTOR2D( 9 * scale, 9 * scale ),
1180  VECTOR2D( 8 * scale, 13 * scale ),
1181  VECTOR2D( 3 * scale, 4 * scale ),
1182  VECTOR2D( 1 * scale, 8 * scale )
1183  };
1184 
1185  m_gal->Save();
1186  m_gal->Translate( aMarker->GetPosition() );
1187 
1188  if( aMarker->IsSelected() )
1189  {
1190  m_gal->SetFillColor( COLOR4D( 1.0, 0.5, 0.5, 1.0 ) );
1191  }
1192  else
1193  {
1194  m_gal->SetFillColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) );
1195  }
1196 
1197  m_gal->SetIsFill( true );
1198  m_gal->SetIsStroke( false );
1199  m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
1200  m_gal->Restore();
1201 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:221
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 248 of file pcb_painter.cpp.

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

Referenced by draw().

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

179  {
180  return &m_pcbSettings;
181  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:187
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 draw(), and KIGFX::PAINTER::SetGAL().

PCB_RENDER_SETTINGS KIGFX::PCB_PAINTER::m_pcbSettings
protected

Definition at line 187 of file pcb_painter.h.

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


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