KiCad PCB EDA Suite
KIGFX::GERBVIEW_PAINTER Class Reference

Class GERBVIEW_PAINTER Contains methods for drawing GerbView-specific items. More...

#include <gerbview_painter.h>

Inheritance diagram for KIGFX::GERBVIEW_PAINTER:
KIGFX::PAINTER

Public Member Functions

 GERBVIEW_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 GERBVIEW_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 (GERBER_DRAW_ITEM *aVia, int aLayer)
 
void drawPolygon (GERBER_DRAW_ITEM *aParent, SHAPE_POLY_SET &aPolygon, bool aFilled)
 Helper routine to draw a polygon. More...
 
void drawFlashedShape (GERBER_DRAW_ITEM *aItem, bool aFilled)
 Helper to draw a flashed shape (aka spot) More...
 
void drawApertureMacro (GERBER_DRAW_ITEM *aParent, bool aFilled)
 Helper to draw an aperture macro shape. More...
 
int getLineThickness (int aActualThickness) const
 Function getLineThickness() Get the thickness to draw for a line (e.g. More...
 

Protected Attributes

GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
 
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 GERBVIEW_PAINTER Contains methods for drawing GerbView-specific items.

Definition at line 163 of file gerbview_painter.h.

Constructor & Destructor Documentation

GERBVIEW_PAINTER::GERBVIEW_PAINTER ( GAL aGal)

Definition at line 148 of file gerbview_painter.cpp.

148  :
149  PAINTER( aGal )
150 {
151 }
PAINTER(GAL *aGal)
Constructor PAINTER( GAL* ) initializes this object for painting on any of the polymorphic GRAPHICS_A...
Definition: painter.cpp:68

Member Function Documentation

virtual void KIGFX::GERBVIEW_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 gerbview_painter.h.

170  {
171  m_gerbviewSettings = *static_cast<const GERBVIEW_RENDER_SETTINGS*>( aSettings );
172  }
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
bool GERBVIEW_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 167 of file gerbview_painter.cpp.

References draw(), GERBER_DRAW_ITEM_T, and EDA_ITEM::Type().

168 {
169  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
170 
171  // the "cast" applied in here clarifies which overloaded draw() is called
172  switch( item->Type() )
173  {
174  case GERBER_DRAW_ITEM_T:
175  draw( static_cast<GERBER_DRAW_ITEM*>( const_cast<EDA_ITEM*>( item ) ), aLayer );
176  break;
177 
178  default:
179  // Painter does not know how to draw the object
180  return false;
181  }
182 
183  return true;
184 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void draw(GERBER_DRAW_ITEM *aVia, int aLayer)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
void GERBVIEW_PAINTER::draw ( GERBER_DRAW_ITEM aVia,
int  aLayer 
)
protected

Definition at line 189 of file gerbview_painter.cpp.

References VECTOR2< T >::Angle(), APT_RECT, KIGFX::GAL::BitmapText(), color, GERBER_DRAW_ITEM::ConvertSegmentToPolygon(), SHAPE_POLY_SET::COutline(), KIGFX::GAL::DrawArcSegment(), KIGFX::GAL::DrawCircle(), drawFlashedShape(), KIGFX::GAL::DrawPolygon(), drawPolygon(), KIGFX::GAL::DrawPolyline(), KIGFX::GAL::DrawRectangle(), KIGFX::GAL::DrawSegment(), GBR_ARC, GBR_CIRCLE, GBR_POLYGON, GBR_SEGMENT, GBR_SPOT_CIRCLE, GBR_SPOT_MACRO, GBR_SPOT_OVAL, GBR_SPOT_POLY, GBR_SPOT_RECT, GERBER_DRAW_ITEM::GetABPosition(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), GERBER_DRAW_ITEM::GetDcodeDescr(), BOX2< Vec >::GetEnd(), GERBER_DRAW_ITEM::GetLayerPolarity(), GetLineLength(), BOX2< Vec >::GetOrigin(), GetSettings(), GERBER_DRAW_ITEM::GetTextD_CodePrms(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_ITEM::IsBrightened(), IsDCodeLayer(), SHAPE_POLY_SET::Iterate(), GERBER_DRAW_ITEM::m_ArcCentre, GERBER_DRAW_ITEM::m_DCode, GERBER_DRAW_ITEM::m_End, KIGFX::PAINTER::m_gal, GERBER_DRAW_ITEM::m_GerberImageFile, m_gerbviewSettings, GERBER_FILE_IMAGE::m_ImageNegative, KIGFX::GERBVIEW_RENDER_SETTINGS::m_lineFill, KIGFX::RENDER_SETTINGS::m_outlineWidth, GERBER_DRAW_ITEM::m_Polygon, KIGFX::GERBVIEW_RENDER_SETTINGS::m_polygonFill, GERBER_DRAW_ITEM::m_Shape, D_CODE::m_Shape, GERBER_DRAW_ITEM::m_Size, KIGFX::GERBVIEW_RENDER_SETTINGS::m_spotFill, GERBER_DRAW_ITEM::m_Start, SHAPE_POLY_SET::OutlineCount(), 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::SetNegativeDrawMode(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), and GERBER_DRAW_ITEM::ViewBBox().

Referenced by Draw().

190 {
191  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) ); // TODO(JE) Getter
192  VECTOR2D end( aItem->GetABPosition( aItem->m_End ) ); // TODO(JE) Getter
193  int width = aItem->m_Size.x; // TODO(JE) Getter
194  bool isFilled = true;
195  COLOR4D color;
196  // TODO(JE) This doesn't actually work properly for ImageNegative
197  bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative );
198 
199  // Draw DCODE overlay text
200  if( IsDCodeLayer( aLayer ) )
201  {
202  wxString codeText;
203  VECTOR2D textPosition;
204  double textSize;
205  double orient;
206 
207  if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
208  return;
209 
210  color = m_gerbviewSettings.GetColor( aItem, aLayer );
211  codeText.Printf( "D%d", aItem->m_DCode );
212 
213  m_gal->SetIsStroke( true );
214  m_gal->SetIsFill( false );
215  m_gal->SetStrokeColor( color );
216  m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) );
217  m_gal->SetLineWidth( 2 );
218  m_gal->SetFontBold( false );
219  m_gal->SetFontItalic( false );
220  m_gal->SetTextMirrored( false );
221  m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
224  m_gal->BitmapText( codeText, textPosition, orient );
225 
226  return;
227  }
228 
229  color = m_gerbviewSettings.GetColor( aItem, aLayer );
230 
231  // TODO: Should brightened color be a preference?
232  if( aItem->IsBrightened() )
233  color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
234 
235  m_gal->SetNegativeDrawMode( isNegative );
236  m_gal->SetStrokeColor( color );
237  m_gal->SetFillColor( color );
238  m_gal->SetIsFill( isFilled );
239  m_gal->SetIsStroke( !isFilled );
240 
241  switch( aItem->m_Shape )
242  {
243  case GBR_POLYGON:
244  {
246  m_gal->SetIsFill( isFilled );
247  m_gal->SetIsStroke( !isFilled );
248 
249  if( isNegative && !isFilled )
250  {
251  m_gal->SetNegativeDrawMode( false );
252  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
253  }
254 
255  if( !isFilled )
257 
258  SHAPE_POLY_SET absolutePolygon = aItem->m_Polygon;
259 
260  for( auto it = absolutePolygon.Iterate( 0 ); it; ++it )
261  *it = aItem->GetABPosition( *it );
262 
263  if( !isFilled )
264  m_gal->DrawPolyline( absolutePolygon.COutline( 0 ) );
265  else
266  m_gal->DrawPolygon( absolutePolygon );
267  break;
268  }
269 
270  case GBR_CIRCLE:
271  {
272  isFilled = m_gerbviewSettings.m_lineFill;
273  double radius = GetLineLength( aItem->m_Start, aItem->m_End );
274  m_gal->DrawCircle( start, radius );
275  break;
276  }
277 
278  case GBR_ARC:
279  {
280  isFilled = m_gerbviewSettings.m_lineFill;
281 
282  // These are swapped because wxDC fills arcs counterclockwise and GAL
283  // fills them clockwise.
284  wxPoint arcStart = aItem->m_End;
285  wxPoint arcEnd = aItem->m_Start;
286 
287  // Gerber arcs are 3-point (start, center, end)
288  // GAL needs center, radius, start angle, end angle
289  double radius = GetLineLength( arcStart, aItem->m_ArcCentre );
290  VECTOR2D center = aItem->GetABPosition( aItem->m_ArcCentre );
291  VECTOR2D startVec = VECTOR2D( aItem->GetABPosition( arcStart ) ) - center;
292  VECTOR2D endVec = VECTOR2D( aItem->GetABPosition( arcEnd ) ) - center;
293 
294  m_gal->SetIsFill( isFilled );
295  m_gal->SetIsStroke( !isFilled );
296  m_gal->SetLineWidth( isFilled ? width : m_gerbviewSettings.m_outlineWidth );
297 
298  double startAngle = startVec.Angle();
299  double endAngle = endVec.Angle();
300 
301  // GAL fills in direction of increasing angle, so we have to convert
302  // the angle from the -PI to PI domain of atan2() to ensure that
303  // the arc goes in the right direction
304  if( startAngle > endAngle )
305  endAngle += (2 * M_PI);
306 
307  // 360-degree arcs are stored in the file with start equal to end
308  if( arcStart == arcEnd )
309  {
310  startAngle = 0;
311  endAngle = 2 * M_PI;
312  }
313 
314  m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width );
315 
316  // Arc Debugging
317  // m_gal->SetLineWidth( 5 );
318  // m_gal->SetStrokeColor( COLOR4D( 0.0, 1.0, 0.0, 1.0 ) );
319  // m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) );
320  // m_gal->SetStrokeColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) );
321  // m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) );
322  break;
323  }
324 
325  case GBR_SPOT_CIRCLE:
326  case GBR_SPOT_RECT:
327  case GBR_SPOT_OVAL:
328  case GBR_SPOT_POLY:
329  case GBR_SPOT_MACRO:
330  {
331  isFilled = m_gerbviewSettings.m_spotFill;
332  drawFlashedShape( aItem, isFilled );
333  break;
334  }
335 
336  case GBR_SEGMENT:
337  {
338  /* Plot a line from m_Start to m_End.
339  * Usually, a round pen is used, but some gerber files use a rectangular pen
340  * In fact, any aperture can be used to plot a line.
341  * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
342  */
343  isFilled = m_gerbviewSettings.m_lineFill;
344  m_gal->SetIsFill( isFilled );
345  m_gal->SetIsStroke( !isFilled );
346 
347  if( isNegative && !isFilled )
348  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
349 
350  // TODO(JE) Refactor this to allow const aItem
351  D_CODE* code = aItem->GetDcodeDescr();
352  if( code && code->m_Shape == APT_RECT )
353  {
354  if( aItem->m_Polygon.OutlineCount() == 0 )
355  aItem->ConvertSegmentToPolygon();
356  drawPolygon( aItem, aItem->m_Polygon, isFilled );
357  }
358  else
359  {
360  if( !isFilled )
362 
363  m_gal->DrawSegment( start, end, width );
364  }
365  break;
366  }
367 
368  default:
369  wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
370  break;
371  }
372 
373  // Enable for bounding box debugging
374  #if 0
375  const BOX2I& bb = aItem->ViewBBox();
376  m_gal->SetIsStroke( true );
377  m_gal->SetIsFill( true );
378  m_gal->SetLineWidth( 3 );
379  m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
380  m_gal->SetFillColor( COLOR4D(0.9, 0.9, 0, 0.1) );
381  m_gal->DrawRectangle( bb.GetOrigin(), bb.GetEnd() );
382  #endif
383 }
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
const Vec & GetOrigin() const
Definition: box2.h:191
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 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...
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsDCodeLayer(int aLayer)
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Function GetLineLength returns the length of a line segment defined by aPointA and aPointB...
Definition: trigo.h:191
void drawPolygon(GERBER_DRAW_ITEM *aParent, SHAPE_POLY_SET &aPolygon, bool aFilled)
Helper routine to draw a polygon.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:272
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
const Vec GetEnd() const
Definition: box2.h:193
int color
Definition: DXF_plotter.cpp:62
bool m_lineFill
Flag determining if lines should be drawn with fill.
void drawFlashedShape(GERBER_DRAW_ITEM *aItem, bool aFilled)
Helper to draw a flashed shape (aka spot)
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Function Iterate returns an object to iterate through the points of the polygons between aFirst and a...
bool m_spotFill
Flag determining if spots should be drawn with fill.
Definition: dcode.h:52
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:345
void SetFontBold(const bool aBold)
Set bold property of current font.
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:306
virtual void SetLineWidth(double aLineWidth)
Set the line width.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
Class SHAPE_POLY_SET.
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.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
bool m_polygonFill
Flag determining if polygons should be drawn with fill.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void SetNegativeDrawMode(bool aSetting)
Sets negative draw mode in the renderer.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void GERBVIEW_PAINTER::drawApertureMacro ( GERBER_DRAW_ITEM aParent,
bool  aFilled 
)
protected

Helper to draw an aperture macro shape.

Definition at line 542 of file gerbview_painter.cpp.

References SHAPE_POLY_SET::COutline(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawPolyline(), APERTURE_MACRO::GetApertureMacroShape(), GERBER_DRAW_ITEM::GetDcodeDescr(), D_CODE::GetMacro(), i, KIGFX::PAINTER::m_gal, m_gerbviewSettings, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::GERBVIEW_RENDER_SETTINGS::m_polygonFill, GERBER_DRAW_ITEM::m_Start, KIGFX::GERBVIEW_RENDER_SETTINGS::MAX_FONT_SIZE, SHAPE_POLY_SET::OutlineCount(), and KIGFX::GAL::SetLineWidth().

Referenced by drawFlashedShape().

543 {
544  D_CODE* code = aParent->GetDcodeDescr();
545  APERTURE_MACRO* macro = code->GetMacro();
546 
547  SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aParent, aParent->m_Start );
548 
551 
552  if( !aFilled )
553  {
554  for( int i = 0; i < macroShape->OutlineCount(); i++ )
555  m_gal->DrawPolyline( macroShape->COutline( i ) );
556  }
557  else
558  m_gal->DrawPolygon( *macroShape );
559 }
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:272
int OutlineCount() const
Returns the number of outlines in the set
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:345
D_CODE * GetDcodeDescr() const
Function GetDcodeDescr returns the GetDcodeDescr of this object, or NULL.
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
Function GetApertureMacroShape Calculate the primitive shape for flashed items.
virtual void SetLineWidth(double aLineWidth)
Set the line width.
Class SHAPE_POLY_SET.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
bool m_polygonFill
Flag determining if polygons should be drawn with fill.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
size_t i
Definition: json11.cpp:597
APERTURE_MACRO * GetMacro() const
Definition: dcode.h:157
Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.
Definition: am_primitive.h:163
void GERBVIEW_PAINTER::drawFlashedShape ( GERBER_DRAW_ITEM aItem,
bool  aFilled 
)
protected

Helper to draw a flashed shape (aka spot)

Definition at line 406 of file gerbview_painter.cpp.

References APT_DEF_NO_HOLE, D_CODE::ConvertShapeToPolygon(), delta, drawApertureMacro(), KIGFX::GAL::DrawCircle(), drawPolygon(), KIGFX::GAL::DrawRectangle(), KIGFX::GAL::DrawSegment(), GBR_SPOT_CIRCLE, GBR_SPOT_MACRO, GBR_SPOT_OVAL, GBR_SPOT_POLY, GBR_SPOT_RECT, GERBER_DRAW_ITEM::GetABPosition(), GERBER_DRAW_ITEM::GetDcodeDescr(), D_CODE::m_DrillShape, KIGFX::PAINTER::m_gal, m_gerbviewSettings, KIGFX::RENDER_SETTINGS::m_outlineWidth, D_CODE::m_Polygon, GERBER_DRAW_ITEM::m_Shape, D_CODE::m_Size, GERBER_DRAW_ITEM::m_Start, SHAPE_POLY_SET::Move(), SHAPE_POLY_SET::OutlineCount(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), wxPoint::x, and wxPoint::y.

Referenced by draw().

407 {
408  D_CODE* code = aItem->GetDcodeDescr();
409 
410  wxASSERT_MSG( code, wxT( "drawFlashedShape: Item has no D_CODE!" ) );
411 
412  if( !code )
413  return;
414 
415  m_gal->SetIsFill( aFilled );
416  m_gal->SetIsStroke( !aFilled );
418 
419  switch( aItem->m_Shape )
420  {
421  case GBR_SPOT_CIRCLE:
422  {
423  int radius = code->m_Size.x >> 1;
424  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
425 
426  if( !aFilled )
427  {
428  m_gal->DrawCircle( start, radius );
429  }
430  else
431  {
432  if( code->m_DrillShape == APT_DEF_NO_HOLE )
433  {
434  m_gal->DrawCircle( start, radius );
435  }
436  else // rectangular hole
437  {
438  if( code->m_Polygon.OutlineCount() == 0 )
439  code->ConvertShapeToPolygon();
440 
441  SHAPE_POLY_SET poly = code->m_Polygon;
442  poly.Move( aItem->m_Start );
443 
444  drawPolygon( aItem, poly, aFilled );
445  }
446  }
447  break;
448  }
449 
450  case GBR_SPOT_RECT:
451  {
452  wxPoint codeStart;
453  wxPoint aShapePos = aItem->m_Start;
454  codeStart.x = aShapePos.x - code->m_Size.x / 2;
455  codeStart.y = aShapePos.y - code->m_Size.y / 2;
456  wxPoint codeEnd = codeStart + code->m_Size;
457  codeStart = aItem->GetABPosition( codeStart );
458  codeEnd = aItem->GetABPosition( codeEnd );
459 
460  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
461  {
462  m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
463  }
464  else
465  {
466  if( code->m_Polygon.OutlineCount() == 0 )
467  code->ConvertShapeToPolygon();
468 
469  SHAPE_POLY_SET poly = code->m_Polygon;
470  poly.Move( aItem->m_Start );
471 
472  drawPolygon( aItem, poly, aFilled );
473  }
474  break;
475  }
476 
477  case GBR_SPOT_OVAL:
478  {
479  int radius = 0;
480 
481  wxPoint codeStart = aItem->m_Start;
482  wxPoint codeEnd = aItem->m_Start;
483 
484  if( code->m_Size.x > code->m_Size.y ) // horizontal oval
485  {
486  int delta = (code->m_Size.x - code->m_Size.y) / 2;
487  codeStart.x -= delta;
488  codeEnd.x += delta;
489  radius = code->m_Size.y;
490  }
491  else // horizontal oval
492  {
493  int delta = (code->m_Size.y - code->m_Size.x) / 2;
494  codeStart.y -= delta;
495  codeEnd.y += delta;
496  radius = code->m_Size.x;
497  }
498 
499  codeStart = aItem->GetABPosition( codeStart );
500  codeEnd = aItem->GetABPosition( codeEnd );
501 
502  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
503  {
504  m_gal->DrawSegment( codeStart, codeEnd, radius );
505  }
506  else
507  {
508  if( code->m_Polygon.OutlineCount() == 0 )
509  code->ConvertShapeToPolygon();
510 
511  SHAPE_POLY_SET poly = code->m_Polygon;
512  poly.Move( aItem->m_Start );
513 
514  drawPolygon( aItem, poly, aFilled );
515  }
516  break;
517  }
518 
519  case GBR_SPOT_POLY:
520  {
521  if( code->m_Polygon.OutlineCount() == 0 )
522  code->ConvertShapeToPolygon();
523 
524  SHAPE_POLY_SET poly = code->m_Polygon;
525  poly.Move( aItem->m_Start );
526 
527  drawPolygon( aItem, poly, aFilled );
528  break;
529  }
530 
531  case GBR_SPOT_MACRO:
532  drawApertureMacro( aItem, aFilled );
533  break;
534 
535  default:
536  wxASSERT_MSG( false, wxT( "Unknown Gerber flashed shape!" ) );
537  break;
538  }
539 }
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void drawPolygon(GERBER_DRAW_ITEM *aParent, SHAPE_POLY_SET &aPolygon, bool aFilled)
Helper routine to draw a polygon.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:272
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
int OutlineCount() const
Returns the number of outlines in the set
static const int delta[8][2]
Definition: solve.cpp:112
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:345
D_CODE * GetDcodeDescr() const
Function GetDcodeDescr returns the GetDcodeDescr of this object, or NULL.
void drawApertureMacro(GERBER_DRAW_ITEM *aParent, bool aFilled)
Helper to draw an aperture macro shape.
virtual void SetLineWidth(double aLineWidth)
Set the line width.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void Move(const VECTOR2I &aVector) override
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
Class SHAPE_POLY_SET.
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:107
void ConvertShapeToPolygon()
Function ConvertShapeToPolygon convert a shape to an equivalent polygon.
Definition: dcode.cpp:303
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Function GetABPosition returns the image position of aPosition for this object.
void GERBVIEW_PAINTER::drawPolygon ( GERBER_DRAW_ITEM aParent,
SHAPE_POLY_SET aPolygon,
bool  aFilled 
)
protected

Helper routine to draw a polygon.

Definition at line 386 of file gerbview_painter.cpp.

References SHAPE_POLY_SET::COutline(), KIGFX::GAL::DrawPolygon(), KIGFX::GAL::DrawPolyline(), GERBER_DRAW_ITEM::GetABPosition(), i, SHAPE_POLY_SET::Iterate(), KIGFX::PAINTER::m_gal, m_gerbviewSettings, KIGFX::RENDER_SETTINGS::m_outlineWidth, KIGFX::GERBVIEW_RENDER_SETTINGS::m_polygonFill, SHAPE_POLY_SET::OutlineCount(), and KIGFX::GAL::SetLineWidth().

Referenced by draw(), and drawFlashedShape().

389 {
390  for( auto it = aPolygon.Iterate( 0 ); it; ++it )
391  *it = aParent->GetABPosition( *it );
392 
395 
396  if( !aFilled )
397  {
398  for( int i = 0; i < aPolygon.OutlineCount(); i++ )
399  m_gal->DrawPolyline( aPolygon.COutline( i ) );
400  }
401  else
402  m_gal->DrawPolygon( aPolygon );
403 }
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:272
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Function Iterate returns an object to iterate through the points of the polygons between aFirst and a...
int OutlineCount() const
Returns the number of outlines in the set
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:345
virtual void SetLineWidth(double aLineWidth)
Set the line width.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
bool m_polygonFill
Flag determining if polygons should be drawn with fill.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
size_t i
Definition: json11.cpp:597
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Function GetABPosition returns the image position of aPosition for this object.
int GERBVIEW_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 155 of file gerbview_painter.cpp.

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

156 {
157  // if items have 0 thickness, draw them with the outline
158  // width, otherwise respect the set value (which, no matter
159  // how small will produce something)
160  if( aActualThickness == 0 )
162 
163  return aActualThickness;
164 }
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:272
virtual GERBVIEW_RENDER_SETTINGS* KIGFX::GERBVIEW_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 gerbview_painter.h.

Referenced by draw(), and PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow().

176  {
177  return &m_gerbviewSettings;
178  }
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
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 313 of file painter.h.

314  {
315  m_gal = aGal;
316  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg...
Definition: painter.h:345

Member Data Documentation

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

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

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

GERBVIEW_RENDER_SETTINGS KIGFX::GERBVIEW_PAINTER::m_gerbviewSettings
protected

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