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

Constructor & Destructor Documentation

PCB_PAINTER::PCB_PAINTER ( GAL aGal)

Definition at line 235 of file pcb_painter.cpp.

235  :
236  PAINTER( aGal )
237 {
238 }
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 169 of file pcb_painter.h.

References m_pcbSettings.

170  {
171  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
172  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:184
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 253 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().

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

References KIGFX::GAL::BitmapText(), KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_TRACKS, 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(), ITEM_GAL_LAYER, 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(), TRACKS_VISIBLE, NETINFO_LIST::UNCONNECTED, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Draw().

316 {
317  VECTOR2D start( aTrack->GetStart() );
318  VECTOR2D end( aTrack->GetEnd() );
319  int width = aTrack->GetWidth();
320 
322  {
323  // If there is a net name - display it on the track
324  if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
325  {
326  VECTOR2D line = ( end - start );
327  double length = line.EuclideanNorm();
328 
329  // Check if the track is long enough to have a netname displayed
330  if( length < 10 * width )
331  return;
332 
333  const wxString& netName = aTrack->GetShortNetname();
334  VECTOR2D textPosition = start + line / 2.0; // center of the track
335  double textOrientation = -atan( line.y / line.x );
336  double textSize = width;
337 
338  m_gal->SetIsStroke( true );
339  m_gal->SetIsFill( false );
340  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
341  m_gal->SetLineWidth( width / 10.0 );
342  m_gal->SetFontBold( false );
343  m_gal->SetFontItalic( false );
344  m_gal->SetTextMirrored( false );
345  m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
348  m_gal->BitmapText( netName, textPosition, textOrientation );
349  }
350  }
351  else if( IsCopperLayer( aLayer ) )
352  {
353  // Draw a regular track
354  const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
355  m_gal->SetStrokeColor( color );
356  m_gal->SetIsStroke( true );
357 
359  {
360  // Outline mode
362  m_gal->SetIsFill( false );
363  }
364  else
365  {
366  // Filled mode
367  m_gal->SetFillColor( color );
368  m_gal->SetIsFill( true );
369  }
370 
371  m_gal->DrawSegment( start, end, width );
372 
373  // Clearance lines
374  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_TRACKS;
375 
376  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags )
377  {
379  m_gal->SetIsFill( false );
380  m_gal->SetIsStroke( true );
381  m_gal->SetStrokeColor( color );
382  m_gal->DrawSegment( start, end, width + aTrack->GetClearance() * 2 );
383  }
384  }
385 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool m_sketchMode[TOTAL_LAYER_COUNT]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:131
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
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:184
const wxPoint & GetEnd() const
Definition: class_track.h:117
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:329
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:120
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.
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
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:155
int GetWidth() const
Definition: class_track.h:114
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 388 of file pcb_painter.cpp.

References KIGFX::PCB_RENDER_SETTINGS::CL_EXISTING, KIGFX::PCB_RENDER_SETTINGS::CL_VIAS, KIGFX::GAL::DrawArc(), KIGFX::GAL::DrawCircle(), BOARD_ITEM::GetBoard(), TRACK::GetClearance(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), VIA::GetDrillValue(), VIA::GetLayerSet(), TRACK::GetStart(), VIA::GetViaType(), BOARD::GetVisibleLayers(), TRACK::GetWidth(), ITEM_GAL_LAYER, VIA::LayerPair(), KIGFX::PCB_RENDER_SETTINGS::m_clearance, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_pcbSettings, KIGFX::PCB_RENDER_SETTINGS::m_sketchMode, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), VIA_BBLIND_VISIBLE, VIA_BLIND_BURIED, VIA_MICROVIA, VIA_MICROVIA_VISIBLE, VIA_THROUGH, VIA_THROUGH_VISIBLE, and VIAS_HOLES_VISIBLE.

389 {
390  VECTOR2D center( aVia->GetStart() );
391  double radius = 0.0;
392 
393  // Only draw the via if at least one of the layers it crosses is being displayed
394  BOARD* brd = aVia->GetBoard( );
395  if( !( brd->GetVisibleLayers() & aVia->GetLayerSet() ).any() )
396  return;
397 
398  // Choose drawing settings depending on if we are drawing via's pad or hole
399  if( aLayer == ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ) )
400  radius = aVia->GetDrillValue() / 2.0;
401  else
402  radius = aVia->GetWidth() / 2.0;
403 
404  bool sketchMode = false;
405  const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
406 
407  switch( aVia->GetViaType() )
408  {
409  case VIA_THROUGH:
411  break;
412 
413  case VIA_BLIND_BURIED:
415  break;
416 
417  case VIA_MICROVIA:
419  break;
420 
421  default:
422  assert( false );
423  break;
424  }
425 
426  if( aVia->GetViaType() == VIA_BLIND_BURIED )
427  {
428  // Buried vias are drawn in a special way to indicate the top and bottom layers
429  LAYER_ID layerTop, layerBottom;
430  aVia->LayerPair( &layerTop, &layerBottom );
431 
432  if( aLayer == ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ) )
433  { // TODO outline mode
434  m_gal->SetIsFill( true );
435  m_gal->SetIsStroke( false );
436  m_gal->SetFillColor( color );
437  m_gal->DrawCircle( center, radius );
438  }
439  else
440  {
441  double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
442 
443  m_gal->SetLineWidth( width );
444  m_gal->SetIsFill( true );
445  m_gal->SetIsStroke( false );
446  m_gal->SetFillColor( color );
447 
448  if( aLayer == layerTop )
449  {
450  m_gal->DrawArc( center, radius, 0.0, M_PI / 2.0 );
451  }
452  else if( aLayer == layerBottom )
453  {
454  m_gal->DrawArc( center, radius, M_PI, 3.0 * M_PI / 2.0 );
455  }
456  else if( aLayer == ITEM_GAL_LAYER( VIA_BBLIND_VISIBLE ) )
457  {
458  m_gal->DrawArc( center, radius, M_PI / 2.0, M_PI );
459  m_gal->DrawArc( center, radius, 3.0 * M_PI / 2.0, 2.0 * M_PI );
460  }
461  }
462  }
463  else
464  {
465  // Regular vias
466  m_gal->SetIsFill( !sketchMode );
467  m_gal->SetIsStroke( sketchMode );
468 
469  if( sketchMode )
470  {
471  // Outline mode
473  m_gal->SetStrokeColor( color );
474  }
475  else
476  {
477  // Filled mode
478  m_gal->SetFillColor( color );
479  }
480 
481  m_gal->DrawCircle( center, radius );
482  }
483 
484  // Clearance lines
485  constexpr int clearanceFlags = PCB_RENDER_SETTINGS::CL_EXISTING | PCB_RENDER_SETTINGS::CL_VIAS;
486 
487  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
488  && aLayer != ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ) )
489  {
491  m_gal->SetIsFill( false );
492  m_gal->SetIsStroke( true );
493  m_gal->SetStrokeColor( color );
494  m_gal->DrawCircle( center, radius + aVia->GetClearance() );
495  }
496 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool m_sketchMode[TOTAL_LAYER_COUNT]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:131
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
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:184
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:329
virtual void SetLineWidth(double aLineWidth)
Set the line width.
VIATYPE_T GetViaType() const
Definition: class_track.h:442
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint & GetStart() const
Definition: class_track.h:120
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void LayerPair(LAYER_ID *top_layer, LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:155
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 ...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
int GetWidth() const
Definition: class_track.h:114
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
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 D_PAD aPad,
int  aLayer 
)
protected

Definition at line 499 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, 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::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(), ITEM_GAL_LAYER, 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_BK_VISIBLE, PAD_DRILL_SHAPE_OBLONG, PAD_FR_VISIBLE, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, PADS_HOLES_VISIBLE, PADS_VISIBLE, 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.

500 {
501  PAD_SHAPE_T shape;
502  double m, n;
503  double orientation = aPad->GetOrientation();
504  wxString buffer;
505 
506  // Draw description layer
507  if( IsNetnameLayer( aLayer ) )
508  {
509  VECTOR2D position( aPad->ShapePos() );
510 
511  // Is anything that we can display enabled?
513  {
514  bool displayNetname = ( m_pcbSettings.m_netNamesOnPads && !aPad->GetNetname().empty() );
515  VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
516  double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
517  double size = padsize.y;
518 
519  // Keep the size ratio for the font, but make it smaller
520  if( padsize.x < padsize.y )
521  {
522  orientation += 900.0;
523  size = padsize.x;
524  std::swap( padsize.x, padsize.y );
525  }
526  else if( padsize.x == padsize.y )
527  {
528  // If the text is displayed on a symmetrical pad, do not rotate it
529  orientation = 0.0;
530  }
531 
532  // Font size limits
533  if( size > maxSize )
534  size = maxSize;
535 
536  m_gal->Save();
537  m_gal->Translate( position );
538 
539  // do not display descriptions upside down
540  NORMALIZE_ANGLE_90( orientation );
541  m_gal->Rotate( DECIDEG2RAD( -orientation ) );
542 
543  // Default font settings
546  m_gal->SetFontBold( false );
547  m_gal->SetFontItalic( false );
548  m_gal->SetTextMirrored( false );
549  m_gal->SetStrokeColor( m_pcbSettings.GetColor( NULL, aLayer ) );
550  m_gal->SetIsStroke( true );
551  m_gal->SetIsFill( false );
552 
553  // Set the text position to the pad shape position (the pad position is not the best place)
554  VECTOR2D textpos( 0.0, 0.0 );
555 
556  // Divide the space, to display both pad numbers and netnames
557  // and set the Y text position to display 2 lines
558  if( displayNetname && m_pcbSettings.m_padNumbers )
559  {
560  size = size / 2.0;
561  textpos.y = size / 2.0;
562  }
563 
564  if( displayNetname )
565  {
566  // calculate the size of net name text:
567  double tsize = 1.5 * padsize.x / aPad->GetShortNetname().Length();
568  tsize = std::min( tsize, size );
569  // Use a smaller text size to handle interline, pen size..
570  tsize *= 0.7;
571  VECTOR2D namesize( tsize, tsize );
572 
573  m_gal->SetGlyphSize( namesize );
574  m_gal->SetLineWidth( namesize.x / 12.0 );
575  m_gal->BitmapText( aPad->GetShortNetname(), textpos, 0.0 );
576  }
577 
579  {
580  textpos.y = -textpos.y;
581  aPad->StringPadName( buffer );
582  int len = buffer.Length();
583  double tsize = 1.5 * padsize.x / len;
584  tsize = std::min( tsize, size );
585  // Use a smaller text size to handle interline, pen size..
586  tsize *= 0.7;
587  tsize = std::min( tsize, size );
588  VECTOR2D numsize( tsize, tsize );
589 
590  m_gal->SetGlyphSize( numsize );
591  m_gal->SetLineWidth( numsize.x / 12.0 );
592  m_gal->BitmapText( aPad->GetPadName(), textpos, 0.0 );
593  }
594 
595  m_gal->Restore();
596  }
597  return;
598  }
599 
600  // Pad drawing
601  const COLOR4D& color = m_pcbSettings.GetColor( aPad, aLayer );
602  VECTOR2D size;
603 
605  {
606  // Outline mode
607  m_gal->SetIsFill( false );
608  m_gal->SetIsStroke( true );
610  m_gal->SetStrokeColor( color );
611  }
612  else
613  {
614  // Filled mode
615  m_gal->SetIsFill( true );
616  m_gal->SetIsStroke( false );
617  m_gal->SetFillColor( color );
618  }
619 
620  m_gal->Save();
621  m_gal->Translate( VECTOR2D( aPad->GetPosition() ) );
622  m_gal->Rotate( -aPad->GetOrientationRadians() );
623 
624  // Choose drawing settings depending on if we are drawing a pad itself or a hole
625  if( aLayer == ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ) )
626  {
627  // Drawing hole: has same shape as PAD_CIRCLE or PAD_OVAL
628  size = VECTOR2D( aPad->GetDrillSize() ) / 2.0;
630  }
631  else if( aLayer == F_Mask || aLayer == B_Mask )
632  {
633  // Drawing soldermask
634  int soldermaskMargin = aPad->GetSolderMaskMargin();
635 
636  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
637  size = VECTOR2D( aPad->GetSize().x / 2.0 + soldermaskMargin,
638  aPad->GetSize().y / 2.0 + soldermaskMargin );
639  shape = aPad->GetShape();
640  }
641  else if( aLayer == F_Paste || aLayer == B_Paste )
642  {
643  // Drawing solderpaste
644  wxSize solderpasteMargin = aPad->GetSolderPasteMargin();
645 
646  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
647  size = VECTOR2D( aPad->GetSize().x / 2.0 + solderpasteMargin.x,
648  aPad->GetSize().y / 2.0 + solderpasteMargin.y );
649  shape = aPad->GetShape();
650  }
651  else
652  {
653  // Drawing every kind of pad
654  m_gal->Translate( VECTOR2D( aPad->GetOffset() ) );
655  size = VECTOR2D( aPad->GetSize() ) / 2.0;
656  shape = aPad->GetShape();
657  }
658 
659  switch( shape )
660  {
661  case PAD_SHAPE_OVAL:
662  if( size.y >= size.x )
663  {
664  m = ( size.y - size.x );
665  n = size.x;
666 
668  {
669  // Outline mode
670  m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
671  m_gal->DrawArc( VECTOR2D( 0, m ), n, M_PI, 0 );
672  m_gal->DrawLine( VECTOR2D( -n, -m ), VECTOR2D( -n, m ) );
673  m_gal->DrawLine( VECTOR2D( n, -m ), VECTOR2D( n, m ) );
674  }
675  else
676  {
677  // Filled mode
678  m_gal->DrawCircle( VECTOR2D( 0, -m ), n );
679  m_gal->DrawCircle( VECTOR2D( 0, m ), n );
680  m_gal->DrawRectangle( VECTOR2D( -n, -m ), VECTOR2D( n, m ) );
681  }
682  }
683  else
684  {
685  m = ( size.x - size.y );
686  n = size.y;
687 
689  {
690  // Outline mode
691  m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
692  m_gal->DrawArc( VECTOR2D( m, 0 ), n, M_PI / 2, -M_PI / 2 );
693  m_gal->DrawLine( VECTOR2D( -m, -n ), VECTOR2D( m, -n ) );
694  m_gal->DrawLine( VECTOR2D( -m, n ), VECTOR2D( m, n ) );
695  }
696  else
697  {
698  // Filled mode
699  m_gal->DrawCircle( VECTOR2D( -m, 0 ), n );
700  m_gal->DrawCircle( VECTOR2D( m, 0 ), n );
701  m_gal->DrawRectangle( VECTOR2D( -m, -n ), VECTOR2D( m, n ) );
702  }
703  }
704  break;
705 
706  case PAD_SHAPE_RECT:
707  m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
708  break;
709 
710  case PAD_SHAPE_ROUNDRECT:
711  {
712  SHAPE_POLY_SET polySet;
713  wxSize prsize( size.x * 2, size.y * 2 );
714  const int segmentToCircleCount = 64;
715  const int corner_radius = aPad->GetRoundRectCornerRadius( prsize );
716  TransformRoundRectToPolygon( polySet, wxPoint( 0, 0 ), prsize,
717  0.0, corner_radius, segmentToCircleCount );
718 
720  {
721  if( polySet.OutlineCount() > 0 )
722  m_gal->DrawPolyline( polySet.Outline( 0 ) );
723  }
724  else
725  {
726  m_gal->DrawPolygon( polySet );
727  }
728  break;
729  }
730 
731  case PAD_SHAPE_TRAPEZOID:
732  {
733  std::deque<VECTOR2D> pointList;
734  wxPoint corners[4];
735 
736  VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
737  VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
738 
739  aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
740  SHAPE_POLY_SET polySet;
741  polySet.NewOutline();
742  polySet.Append( VECTOR2I( corners[0] ) );
743  polySet.Append( VECTOR2I( corners[1] ) );
744  polySet.Append( VECTOR2I( corners[2] ) );
745  polySet.Append( VECTOR2I( corners[3] ) );
746 
748  m_gal->DrawPolyline( polySet.COutline( 0 ) );
749  else
750  m_gal->DrawPolygon( polySet );
751  }
752  break;
753 
754  case PAD_SHAPE_CIRCLE:
755  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
756  break;
757  }
758 
759  m_gal->Restore();
760 
761  // Clearance lines
762  // It has to be called after GAL::Restore() as TransformShapeWithClearanceToPolygon()
763  // returns already transformed coordinates
764  constexpr int clearanceFlags = /*PCB_RENDER_SETTINGS::CL_EXISTING |*/ PCB_RENDER_SETTINGS::CL_PADS;
765 
766  if( ( m_pcbSettings.m_clearance & clearanceFlags ) == clearanceFlags
767  && ( aLayer == ITEM_GAL_LAYER( PAD_FR_VISIBLE )
768  || aLayer == ITEM_GAL_LAYER( PAD_BK_VISIBLE )
769  || aLayer == ITEM_GAL_LAYER( PADS_VISIBLE ) ) )
770  {
771  SHAPE_POLY_SET polySet;
772  constexpr int SEGCOUNT = 64;
773  aPad->TransformShapeWithClearanceToPolygon( polySet, aPad->GetClearance(), SEGCOUNT, 1.0 );
774 
775  if( polySet.OutlineCount() > 0 )
776  {
778  m_gal->SetIsStroke( true );
779  m_gal->SetIsFill( false );
780  m_gal->SetStrokeColor( color );
781  m_gal->DrawPolyline( polySet.COutline( 0 ) );
782  }
783  }
784 }
multilayer pads, usually with holes
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.
bool m_sketchMode[TOTAL_LAYER_COUNT]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:131
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
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.
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:184
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
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:329
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:149
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:486
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
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.
int NewOutline()
Creates a new empty polygon in the set and returns its index
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
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:155
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:214
double DECIDEG2RAD(double deg)
Definition: trigo.h:195
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:519
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_pad.cpp:455
wxPoint ShapePos() const
Definition: class_pad.cpp:367
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
wxString GetPadName() const
Definition: class_pad.cpp:382
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:391
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
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 787 of file pcb_painter.cpp.

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

788 {
789  const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
790  bool sketch = ( aSegment->Type() == PCB_LINE_T && m_pcbSettings.m_sketchBoardGfx )
791  || ( aSegment->Type() == PCB_MODULE_EDGE_T && m_pcbSettings.m_sketchFpGfx );
792 
793  int thickness = getLineThickness( aSegment->GetWidth() );
794  VECTOR2D start( aSegment->GetStart() );
795  VECTOR2D end( aSegment->GetEnd() );
796 
797  m_gal->SetIsFill( !sketch );
798  m_gal->SetIsStroke( sketch );
799  m_gal->SetFillColor( color );
800  m_gal->SetStrokeColor( color );
802 
803  switch( aSegment->GetShape() )
804  {
805  case S_SEGMENT:
806  m_gal->DrawSegment( start, end, thickness );
807  break;
808 
809  case S_RECT:
810  wxASSERT_MSG( false, wxT( "Not tested yet" ) );
811  m_gal->DrawRectangle( start, end );
812  break;
813 
814  case S_ARC:
815  m_gal->DrawArcSegment( start, aSegment->GetRadius(),
816  DECIDEG2RAD( aSegment->GetArcAngleStart() ),
817  DECIDEG2RAD( aSegment->GetArcAngleStart() + aSegment->GetAngle() ),
818  thickness );
819  break;
820 
821  case S_CIRCLE:
822  if( sketch )
823  {
824  m_gal->DrawCircle( start, aSegment->GetRadius() - thickness / 2 );
825  m_gal->DrawCircle( start, aSegment->GetRadius() + thickness / 2 );
826  }
827  else
828  {
829  m_gal->SetLineWidth( thickness );
830  m_gal->SetIsFill( false );
831  m_gal->SetIsStroke( true );
832  m_gal->DrawCircle( start, aSegment->GetRadius() );
833  }
834  break;
835 
836  case S_POLYGON:
837  {
838  std::deque<VECTOR2D> pointsList;
839 
840  m_gal->SetIsFill( true ); // draw polygons the legacy way
841  m_gal->SetIsStroke( false );
842  m_gal->Save();
843  m_gal->SetLineWidth( thickness );
844 
845  if( MODULE* module = aSegment->GetParentModule() )
846  {
847  m_gal->Translate( module->GetPosition() );
848  m_gal->Rotate( -module->GetOrientationRadians() );
849  }
850  else
851  {
852  m_gal->Translate( aSegment->GetPosition() );
853  m_gal->Rotate( DECIDEG2RAD( -aSegment->GetAngle() ) );
854  }
855 
856  std::copy( aSegment->GetPolyPoints().begin(), aSegment->GetPolyPoints().end(),
857  std::back_inserter( pointsList ) );
858 
859  m_gal->SetLineWidth( aSegment->GetWidth() );
860  m_gal->DrawPolyline( pointsList );
861  m_gal->DrawPolygon( pointsList );
862 
863  m_gal->Restore();
864  break;
865  }
866 
867  case S_CURVE:
868  m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
869  VECTOR2D( aSegment->GetBezControl1() ),
870  VECTOR2D( aSegment->GetBezControl2() ),
871  VECTOR2D( aSegment->GetEnd() ) );
872  break;
873 
874  case S_LAST:
875  break;
876  }
877 }
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:258
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:184
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:329
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.
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 880 of file pcb_painter.cpp.

References 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.

881 {
882  wxString shownText( aText->GetShownText() );
883  if( shownText.Length() == 0 )
884  return;
885 
886  const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
887  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
888 
889  if( m_pcbSettings.m_sketchMode[aLayer] )
890  {
891  // Outline mode
893  }
894  else
895  {
896  // Filled mode
898  }
899 
900  m_gal->SetStrokeColor( color );
901  m_gal->SetIsFill( false );
902  m_gal->SetIsStroke( true );
903  m_gal->SetTextAttributes( aText );
904  m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() );
905 }
bool m_sketchMode[TOTAL_LAYER_COUNT]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:131
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:184
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:329
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.
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 908 of file pcb_painter.cpp.

References 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.

909 {
910  wxString shownText( aText->GetShownText() );
911  if( shownText.Length() == 0 )
912  return;
913 
914  const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
915  VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
916 
917  if( m_pcbSettings.m_sketchMode[aLayer] )
918  {
919  // Outline mode
921  }
922  else
923  {
924  // Filled mode
926  }
927 
928  m_gal->SetStrokeColor( color );
929  m_gal->SetIsFill( false );
930  m_gal->SetIsStroke( true );
931  m_gal->SetTextAttributes( aText );
932  m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
933 
934  // Draw the umbilical line
935  if( aText->IsSelected() && aText->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
936  {
938  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
939  m_gal->DrawLine( position, aText->GetParent()->GetPosition() );
940  }
941 }
BOARD_ITEM_CONTAINER * GetParent() const
bool m_sketchMode[TOTAL_LAYER_COUNT]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:131
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
TEXT_TYPE GetType() const
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
bool IsSelected() const
Definition: base_struct.h:221
virtual const wxPoint & GetPosition() const =0
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:184
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:329
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 944 of file pcb_painter.cpp.

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

945 {
946  if( aLayer == ITEM_GAL_LAYER( ANCHOR_VISIBLE ) )
947  {
948  const COLOR4D color = m_pcbSettings.GetColor( aModule, ITEM_GAL_LAYER( ANCHOR_VISIBLE ) );
949 
950  // Draw anchor
951  m_gal->SetStrokeColor( color );
953 
954  // Keep the size constant, not related to the scale
955  double anchorSize = 5.0 / m_gal->GetWorldScale();
956 
957  VECTOR2D center = aModule->GetPosition();
958  m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
959  m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
960  }
961 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
double GetWorldScale() const
Get the world scale.
const wxPoint & GetPosition() const override
Definition: class_module.h:143
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:184
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:329
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.
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
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 964 of file pcb_painter.cpp.

References ZONE_CONTAINER::CIterateWithHoles(), 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().

965 {
966  const COLOR4D& color = m_pcbSettings.GetColor( aZone, aZone->GetLayer() );
967  std::deque<VECTOR2D> corners;
969 
970  // Draw the outline
971  m_gal->SetStrokeColor( color );
972  m_gal->SetIsFill( false );
973  m_gal->SetIsStroke( true );
975 
976  for( auto iterator = aZone->CIterateWithHoles(); iterator; iterator++ )
977  {
978  corners.push_back( VECTOR2D( *iterator ) );
979 
980  if( iterator.IsEndContour() )
981  {
982  // The last point for closing the polyline
983  corners.push_back( corners[0] );
984  m_gal->DrawPolyline( corners );
985  corners.clear();
986  }
987 
988  for( const SEG& hatchLine : aZone->GetHatchLines() )
989  m_gal->DrawLine( hatchLine.A, hatchLine.B );
990  }
991 
992  // Draw the filling
993  if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
994  {
995  const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList();
996 
997  if( polySet.OutlineCount() == 0 ) // Nothing to draw
998  return;
999 
1000  // Set up drawing options
1001  m_gal->SetFillColor( color );
1002  m_gal->SetLineWidth( aZone->GetMinThickness() );
1003 
1004  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1005  {
1006  m_gal->SetIsFill( true );
1007  m_gal->SetIsStroke( true );
1008  }
1009  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1010  {
1011  m_gal->SetIsFill( false );
1012  m_gal->SetIsStroke( true );
1013  }
1014 
1015  for( int i = 0; i < polySet.OutlineCount(); i++ )
1016  {
1017  const SHAPE_LINE_CHAIN& outline = polySet.COutline( i );
1018  // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion
1019  // is just a performance hog)
1020 
1021  for( int j = 0; j < outline.PointCount(); j++ )
1022  corners.push_back ( (VECTOR2D) outline.CPoint( j ) );
1023 
1024  corners.push_back( (VECTOR2D) outline.CPoint( 0 ) );
1025 
1026  if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
1027  {
1028  m_gal->DrawPolygon( corners );
1029  m_gal->DrawPolyline( corners );
1030  }
1031  else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
1032  {
1033  m_gal->DrawPolyline( corners );
1034  }
1035 
1036  corners.clear();
1037  }
1038  }
1039 }
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:258
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:152
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:84
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:184
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:496
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const std::vector< SEG > & GetHatchLines() const
Definition: class_zone.h:703
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:329
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:587
Definition: seg.h:37
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
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 1042 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.

1043 {
1044  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
1045 
1046  m_gal->SetStrokeColor( strokeColor );
1047  m_gal->SetIsFill( false );
1048  m_gal->SetIsStroke( true );
1049  m_gal->SetLineWidth( getLineThickness( aDimension->GetWidth() ) );
1050 
1051  // Draw an arrow
1052  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
1053  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
1054  VECTOR2D( aDimension->m_featureLineGF ) );
1055  m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
1056  VECTOR2D( aDimension->m_featureLineDF ) );
1057  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD1F ) );
1058  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarF ), VECTOR2D( aDimension->m_arrowD2F ) );
1059  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG1F ) );
1060  m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_arrowG2F ) );
1061 
1062  // Draw text
1063  TEXTE_PCB& text = aDimension->Text();
1064  VECTOR2D position( text.GetTextPos().x, text.GetTextPos().y );
1065 
1066  m_gal->SetLineWidth( text.GetThickness() );
1067  m_gal->SetTextAttributes( &text );
1068  m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() );
1069 }
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:184
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:329
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 1072 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().

1073 {
1074  const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
1075  VECTOR2D position( aTarget->GetPosition() );
1076  double size, radius;
1077 
1078  m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
1079  m_gal->SetStrokeColor( strokeColor );
1080  m_gal->SetIsFill( false );
1081  m_gal->SetIsStroke( true );
1082 
1083  m_gal->Save();
1084  m_gal->Translate( position );
1085 
1086  if( aTarget->GetShape() )
1087  {
1088  // shape x
1089  m_gal->Rotate( M_PI / 4.0 );
1090  size = 2.0 * aTarget->GetSize() / 3.0;
1091  radius = aTarget->GetSize() / 2.0;
1092  }
1093  else
1094  {
1095  // shape +
1096  size = aTarget->GetSize() / 2.0;
1097  radius = aTarget->GetSize() / 3.0;
1098  }
1099 
1100  m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
1101  m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
1102  m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
1103 
1104  m_gal->Restore();
1105 }
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:184
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:329
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.
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 1108 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().

1109 {
1110  // If you are changing this, update MARKER_PCB::ViewBBox()
1111  const int scale = 100000;
1112 
1113  const VECTOR2D arrow[] = {
1114  VECTOR2D( 0 * scale, 0 * scale ),
1115  VECTOR2D( 8 * scale, 1 * scale ),
1116  VECTOR2D( 4 * scale, 3 * scale ),
1117  VECTOR2D( 13 * scale, 8 * scale ),
1118  VECTOR2D( 9 * scale, 9 * scale ),
1119  VECTOR2D( 8 * scale, 13 * scale ),
1120  VECTOR2D( 3 * scale, 4 * scale ),
1121  VECTOR2D( 1 * scale, 8 * scale )
1122  };
1123 
1124  m_gal->Save();
1125  m_gal->Translate( aMarker->GetPosition() );
1126 
1127  if( aMarker->IsSelected() )
1128  {
1129  m_gal->SetFillColor( COLOR4D( 1.0, 0.5, 0.5, 1.0 ) );
1130  }
1131  else
1132  {
1133  m_gal->SetFillColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) );
1134  }
1135 
1136  m_gal->SetIsFill( true );
1137  m_gal->SetIsStroke( false );
1138  m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
1139  m_gal->Restore();
1140 }
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:329
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 241 of file pcb_painter.cpp.

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

Referenced by draw().

242 {
243  // if items have 0 thickness, draw them with the outline
244  // width, otherwise respect the set value (which, no matter
245  // how small will produce something)
246  if( aActualThickness == 0 )
248 
249  return aActualThickness;
250 }
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:258
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:184
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 175 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(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

176  {
177  return &m_pcbSettings;
178  }
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:184
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 297 of file painter.h.

References KIGFX::PAINTER::m_gal.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

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

Member Data Documentation

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

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

Referenced by draw(), and KIGFX::PAINTER::SetGAL().

PCB_RENDER_SETTINGS KIGFX::PCB_PAINTER::m_pcbSettings
protected

Definition at line 184 of file pcb_painter.h.

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


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