KiCad PCB EDA Suite
gerbview_painter.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
5  * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <gerbview_painter.h>
25 #include <convert_to_biu.h>
26 #include <gerbview.h>
27 
28 #include <dcode.h>
29 #include <gerber_draw_item.h>
30 #include <gerber_file_image.h>
31 
32 using namespace KIGFX;
33 
35 {
37 
38  m_spotFill = true;
39  m_lineFill = true;
40  m_polygonFill = true;
41  m_showNegativeItems = false;
42  m_showCodes = false;
43  m_diffMode = true;
44 
48 
49  update();
50 }
51 
52 
54 {
55  size_t palette_size = aSettings->m_Palette.size();
56  size_t palette_idx = 0;
57 
58  // Layers to draw gerber data read from gerber files:
59  for( int i = GERBVIEW_LAYER_ID_START;
61  {
62  COLOR4D baseColor = aSettings->GetColor( i );
63 
64  if( baseColor == COLOR4D::UNSPECIFIED )
65  baseColor = aSettings->m_Palette[ ( palette_idx++ ) % palette_size ];
66 
67  if( m_diffMode )
68  baseColor.a = 0.75;
69 
70  m_layerColors[i] = baseColor;
71  m_layerColorsHi[i] = baseColor.Brightened( 0.5 );
72  m_layerColorsSel[i] = baseColor.Brightened( 0.8 );
73  m_layerColorsDark[i] = baseColor.Darkened( 0.25 );
74  }
75 
76  // Draw layers specific to Gerbview:
77  // LAYER_DCODES, LAYER_NEGATIVE_OBJECTS, LAYER_GERBVIEW_GRID,
78  // LAYER_GERBVIEW_AXES, LAYER_GERBVIEW_BACKGROUND, LAYER_GERBVIEW_WORKSHEET,
79  for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ )
80  m_layerColors[i] = aSettings->GetColor( i );
81 
82  for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
83  m_layerColors[i] = aSettings->GetColor( i );
84 
85  update();
86 }
87 
88 
90 {
92  m_lineFill = aOptions.m_DisplayLinesFill;
95  m_showCodes = aOptions.m_DisplayDCodes;
96  m_diffMode = aOptions.m_DiffMode;
100 
101  update();
102 }
103 
104 
105 const COLOR4D& GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
106 {
107  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
108  static const COLOR4D transparent = COLOR4D( 0, 0, 0, 0 );
109  const GERBER_DRAW_ITEM* gbrItem = nullptr;
110 
111  if( item && item->Type() == GERBER_DRAW_ITEM_T )
112  gbrItem = static_cast<const GERBER_DRAW_ITEM*>( item );
113 
114  // All DCODE layers stored under a single color setting
115  if( IsDCodeLayer( aLayer ) )
116  return m_layerColors[ LAYER_DCODES ];
117 
118  if( item && item->IsSelected() )
119  return m_layerColorsSel[aLayer];
120 
121  if( gbrItem && gbrItem->GetLayerPolarity() )
122  {
123  if( m_showNegativeItems )
125  else
126  return transparent;
127  }
128 
129  if( !m_netHighlightString.IsEmpty() && gbrItem &&
131  return m_layerColorsHi[aLayer];
132 
133  if( !m_componentHighlightString.IsEmpty() && gbrItem &&
135  return m_layerColorsHi[aLayer];
136 
137  if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() &&
139  return m_layerColorsHi[aLayer];
140 
141  // Return grayish color for non-highlighted layers in the high contrast mode
142  if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0)
143  return m_hiContrastColor[aLayer];
144 
145  // Catch the case when highlight and high-contraste modes are enabled
146  // and we are drawing a not highlighted track
147  if( m_highlightEnabled )
148  return m_layerColorsDark[aLayer];
149 
150  // No special modificators enabled
151  return m_layerColors[aLayer];
152 }
153 
154 
156  PAINTER( aGal )
157 {
158 }
159 
160 
161 // TODO(JE): Pull up to PAINTER?
162 int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
163 {
164  // if items have 0 thickness, draw them with the outline
165  // width, otherwise respect the set value (which, no matter
166  // how small will produce something)
167  if( aActualThickness == 0 )
169 
170  return aActualThickness;
171 }
172 
173 
174 bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
175 {
176  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
177 
178  // the "cast" applied in here clarifies which overloaded draw() is called
179  switch( item->Type() )
180  {
181  case GERBER_DRAW_ITEM_T:
182  draw( static_cast<GERBER_DRAW_ITEM*>( const_cast<EDA_ITEM*>( item ) ), aLayer );
183  break;
184 
185  default:
186  // Painter does not know how to draw the object
187  return false;
188  }
189 
190  return true;
191 }
192 
193 
194 // TODO(JE) aItem can't be const because of GetDcodeDescr()
195 // Probably that can be refactored in GERBER_DRAW_ITEM to allow const here.
196 void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
197 {
198  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) ); // TODO(JE) Getter
199  VECTOR2D end( aItem->GetABPosition( aItem->m_End ) ); // TODO(JE) Getter
200  int width = aItem->m_Size.x; // TODO(JE) Getter
201  bool isFilled = true;
202  COLOR4D color;
203  // TODO(JE) This doesn't actually work properly for ImageNegative
204  bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative );
205 
206  // Draw DCODE overlay text
207  if( IsDCodeLayer( aLayer ) )
208  {
209  wxString codeText;
210  VECTOR2D textPosition;
211  double textSize;
212  double orient;
213 
214  if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
215  return;
216 
217  color = m_gerbviewSettings.GetColor( aItem, aLayer );
218  codeText.Printf( "D%d", aItem->m_DCode );
219 
220  m_gal->SetIsStroke( true );
221  m_gal->SetIsFill( false );
223  m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) );
224  m_gal->SetLineWidth( textSize/10 );
225  m_gal->SetFontBold( false );
226  m_gal->SetFontItalic( false );
227  m_gal->SetTextMirrored( false );
228  m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
231  m_gal->BitmapText( codeText, textPosition, orient );
232 
233  return;
234  }
235 
236  color = m_gerbviewSettings.GetColor( aItem, aLayer );
237 
238  // TODO: Should brightened color be a preference?
239  if( aItem->IsBrightened() )
240  color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
241 
242  m_gal->SetNegativeDrawMode( isNegative );
245  m_gal->SetIsFill( isFilled );
246  m_gal->SetIsStroke( !isFilled );
247 
248  switch( aItem->m_Shape )
249  {
250  case GBR_POLYGON:
251  {
253  m_gal->SetIsFill( isFilled );
254  m_gal->SetIsStroke( !isFilled );
255 
256  if( isNegative && !isFilled )
257  {
258  m_gal->SetNegativeDrawMode( false );
259  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
260  }
261 
262  if( !isFilled )
264 
265  std::vector<VECTOR2I> pts = aItem->m_Polygon.COutline( 0 ).CPoints();
266 
267  for( auto& pt : pts )
268  pt = aItem->GetABPosition( pt );
269 
270 
271  SHAPE_POLY_SET absolutePolygon;
272  SHAPE_LINE_CHAIN chain( pts );
273  chain.SetClosed( true );
274  absolutePolygon.AddOutline( chain );
275 
276  // Degenerated polygons (having < 3 points) are drawn as lines
277  // to avoid issues in draw polygon functions
278  if( !isFilled || absolutePolygon.COutline( 0 ).PointCount() < 3 )
279  m_gal->DrawPolyline( absolutePolygon.COutline( 0 ) );
280  else
281  {
282  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
283  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
284  // on Opengl
285  if( m_gal->IsOpenGlEngine() )
286  absolutePolygon.CacheTriangulation();
287 
288  m_gal->DrawPolygon( absolutePolygon );
289  }
290 
291  break;
292  }
293 
294  case GBR_CIRCLE:
295  {
296  isFilled = m_gerbviewSettings.m_lineFill;
297  double radius = GetLineLength( aItem->m_Start, aItem->m_End );
298  m_gal->DrawCircle( start, radius );
299  break;
300  }
301 
302  case GBR_ARC:
303  {
304  isFilled = m_gerbviewSettings.m_lineFill;
305 
306  // These are swapped because wxDC fills arcs counterclockwise and GAL
307  // fills them clockwise.
308  wxPoint arcStart = aItem->m_End;
309  wxPoint arcEnd = aItem->m_Start;
310 
311  // Gerber arcs are 3-point (start, center, end)
312  // GAL needs center, radius, start angle, end angle
313  double radius = GetLineLength( arcStart, aItem->m_ArcCentre );
314  VECTOR2D center = aItem->GetABPosition( aItem->m_ArcCentre );
315  VECTOR2D startVec = VECTOR2D( aItem->GetABPosition( arcStart ) ) - center;
316  VECTOR2D endVec = VECTOR2D( aItem->GetABPosition( arcEnd ) ) - center;
317 
318  m_gal->SetIsFill( isFilled );
319  m_gal->SetIsStroke( !isFilled );
320  m_gal->SetLineWidth( isFilled ? width : m_gerbviewSettings.m_outlineWidth );
321 
322  double startAngle = startVec.Angle();
323  double endAngle = endVec.Angle();
324 
325  // GAL fills in direction of increasing angle, so we have to convert
326  // the angle from the -PI to PI domain of atan2() to ensure that
327  // the arc goes in the right direction
328  if( startAngle > endAngle )
329  endAngle += (2 * M_PI);
330 
331  // In Gerber, 360-degree arcs are stored in the file with start equal to end
332  if( arcStart == arcEnd )
333  {
334  endAngle = startAngle + 2*M_PI;
335  }
336 
337  m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width );
338 
339 #if 0 // Arc Debugging only
340  m_gal->SetIsFill( false );
341  m_gal->SetIsStroke( true );
342  m_gal->SetLineWidth( 5 );
343  m_gal->SetStrokeColor( COLOR4D( 0.1, 0.5, 0.0, 0.5 ) );
344  m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) );
345  m_gal->SetStrokeColor( COLOR4D( 0.6, 0.1, 0.0, 0.5 ) );
346  m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) );
347 #endif
348 
349 #if 0 // Bbox arc Debugging only
350  m_gal->SetIsFill( false );
351  m_gal->SetIsStroke( true );
352  EDA_RECT box = aItem->GetBoundingBox();
353  m_gal->SetLineWidth( 5 );
354  m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
355  // box coordinates are already in AB position.
356  m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
357 #endif
358  break;
359  }
360 
361  case GBR_SPOT_CIRCLE:
362  case GBR_SPOT_RECT:
363  case GBR_SPOT_OVAL:
364  case GBR_SPOT_POLY:
365  case GBR_SPOT_MACRO:
366  {
367  isFilled = m_gerbviewSettings.m_spotFill;
368  drawFlashedShape( aItem, isFilled );
369  break;
370  }
371 
372  case GBR_SEGMENT:
373  {
374  /* Plot a line from m_Start to m_End.
375  * Usually, a round pen is used, but some gerber files use a rectangular pen
376  * In fact, any aperture can be used to plot a line.
377  * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
378  */
379  isFilled = m_gerbviewSettings.m_lineFill;
380  m_gal->SetIsFill( isFilled );
381  m_gal->SetIsStroke( !isFilled );
382 
383  if( isNegative && !isFilled )
384  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
385 
386  // TODO(JE) Refactor this to allow const aItem
387  D_CODE* code = aItem->GetDcodeDescr();
388  if( code && code->m_Shape == APT_RECT )
389  {
390  if( aItem->m_Polygon.OutlineCount() == 0 )
391  aItem->ConvertSegmentToPolygon();
392 
393  drawPolygon( aItem, aItem->m_Polygon, isFilled );
394  }
395  else
396  {
397  if( !isFilled )
399 
400  m_gal->DrawSegment( start, end, width );
401  }
402  break;
403  }
404 
405  default:
406  wxASSERT_MSG( false, "GERBER_DRAW_ITEM shape is unknown!" );
407  break;
408  }
409 
410  // Enable for bounding box debugging
411  #if 0
412  const BOX2I& bb = aItem->ViewBBox();
413  m_gal->SetIsStroke( true );
414  m_gal->SetIsFill( true );
415  m_gal->SetLineWidth( 3 );
416  m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
417  m_gal->SetFillColor( COLOR4D(0.9, 0.9, 0, 0.1) );
418  m_gal->DrawRectangle( bb.GetOrigin(), bb.GetEnd() );
419  #endif
420 }
421 
422 
424  GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon, bool aFilled, bool aShift )
425 {
426  wxASSERT( aPolygon.OutlineCount() == 1 );
427 
428  if( aPolygon.OutlineCount() == 0 )
429  return;
430 
431  SHAPE_POLY_SET poly;
432  poly.NewOutline();
433  const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
434  VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
435 
436  for( auto& pt : pts )
437  poly.Append( aParent->GetABPosition( pt + offset ) );
438 
441 
442  if( !aFilled )
443  {
444  m_gal->DrawPolyline( poly.COutline( 0 ) );
445  }
446  else
447  m_gal->DrawPolygon( poly );
448 }
449 
450 
452 {
453  D_CODE* code = aItem->GetDcodeDescr();
454 
455  wxASSERT_MSG( code, "drawFlashedShape: Item has no D_CODE!" );
456 
457  if( !code )
458  return;
459 
460  m_gal->SetIsFill( aFilled );
461  m_gal->SetIsStroke( !aFilled );
463 
464  switch( aItem->m_Shape )
465  {
466  case GBR_SPOT_CIRCLE:
467  {
468  int radius = code->m_Size.x >> 1;
469  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
470 
471  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
472  {
473  m_gal->DrawCircle( start, radius );
474  }
475  else // rectangular hole
476  {
477  if( code->m_Polygon.OutlineCount() == 0 )
478  code->ConvertShapeToPolygon();
479 
480  drawPolygon( aItem, code->m_Polygon, aFilled, true );
481  }
482 
483  break;
484  }
485 
486  case GBR_SPOT_RECT:
487  {
488  wxPoint codeStart;
489  wxPoint aShapePos = aItem->m_Start;
490  codeStart.x = aShapePos.x - code->m_Size.x / 2;
491  codeStart.y = aShapePos.y - code->m_Size.y / 2;
492  wxPoint codeEnd = codeStart + code->m_Size;
493  codeStart = aItem->GetABPosition( codeStart );
494  codeEnd = aItem->GetABPosition( codeEnd );
495 
496  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
497  {
498  m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
499  }
500  else
501  {
502  if( code->m_Polygon.OutlineCount() == 0 )
503  code->ConvertShapeToPolygon();
504 
505  drawPolygon( aItem, code->m_Polygon, aFilled, true );
506  }
507  break;
508  }
509 
510  case GBR_SPOT_OVAL:
511  {
512  int radius = 0;
513 
514  wxPoint codeStart = aItem->m_Start;
515  wxPoint codeEnd = aItem->m_Start;
516 
517  if( code->m_Size.x > code->m_Size.y ) // horizontal oval
518  {
519  int delta = (code->m_Size.x - code->m_Size.y) / 2;
520  codeStart.x -= delta;
521  codeEnd.x += delta;
522  radius = code->m_Size.y;
523  }
524  else // horizontal oval
525  {
526  int delta = (code->m_Size.y - code->m_Size.x) / 2;
527  codeStart.y -= delta;
528  codeEnd.y += delta;
529  radius = code->m_Size.x;
530  }
531 
532  codeStart = aItem->GetABPosition( codeStart );
533  codeEnd = aItem->GetABPosition( codeEnd );
534 
535  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
536  {
537  m_gal->DrawSegment( codeStart, codeEnd, radius );
538  }
539  else
540  {
541  if( code->m_Polygon.OutlineCount() == 0 )
542  code->ConvertShapeToPolygon();
543 
544  drawPolygon( aItem, code->m_Polygon, aFilled, true );
545  }
546  break;
547  }
548 
549  case GBR_SPOT_POLY:
550  {
551  if( code->m_Polygon.OutlineCount() == 0 )
552  code->ConvertShapeToPolygon();
553 
554  drawPolygon( aItem, code->m_Polygon, aFilled, true );
555  break;
556  }
557 
558  case GBR_SPOT_MACRO:
559  drawApertureMacro( aItem, aFilled );
560  break;
561 
562  default:
563  wxASSERT_MSG( false, wxT( "Unknown Gerber flashed shape!" ) );
564  break;
565  }
566 }
567 
568 
570 {
571  D_CODE* code = aParent->GetDcodeDescr();
572  APERTURE_MACRO* macro = code->GetMacro();
573 
574  SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aParent, aParent->m_Start );
575 
578 
579  if( !aFilled )
580  {
581  for( int i = 0; i < macroShape->OutlineCount(); i++ )
582  m_gal->DrawPolyline( macroShape->COutline( i ) );
583  }
584  else
585  m_gal->DrawPolygon( *macroShape );
586 }
587 
588 
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
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...
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
D_CODE * GetDcodeDescr() const
Function GetDcodeDescr returns the GetDcodeDescr of this object, or NULL.
bool m_showNegativeItems
Flag determining if negative items should be drawn with a "ghost" color.
bool IsDCodeLayer(int aLayer)
int OutlineCount() const
Returns the number of outlines in the set
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:206
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
bool IsSelected() const
Definition: base_struct.h:203
const Vec GetEnd() const
Definition: box2.h:195
static const double MAX_FONT_SIZE
Maximum font size for D-Codes and other strings.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
COLOR4D m_layerColors[LAYER_ID_COUNT]
void draw(GERBER_DRAW_ITEM *aVia, int aLayer)
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
COLOR4D m_BgDrawColor
The background color.
int color
Definition: DXF_plotter.cpp:61
bool m_lineFill
Flag determining if lines should be drawn with fill.
virtual const BOX2I ViewBBox() const override
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 it...
void drawFlashedShape(GERBER_DRAW_ITEM *aItem, bool aFilled)
Helper to draw a flashed shape (aka spot)
wxString m_Cmpref
the component reference parent of the data
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
bool IsBrightened() const
Definition: base_struct.h:205
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
Add new GAL layers here.
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
COLOR4D Darkened(double aFactor) const
Function Darkened Returns a color that is darker by a given factor, without modifying object.
Definition: color4d.h:275
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
int PointCount() const
Function PointCount()
SHAPE_POLY_SET m_Polygon
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:372
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
COLOR4D Brightened(double aFactor) const
Function Brightened Returns a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:259
bool m_showCodes
Flag determining if D-Codes should be drawn.
static const COLOR4D BLACK
Definition: color4d.h:376
std::set< unsigned int > m_activeLayers
Stores active layers number.
const wxPoint GetEnd() const
Definition: eda_rect.h:116
void SetFontBold(const bool aBold)
Set bold property of current font.
void SetClosed(bool aClosed)
Function SetClosed()
void drawApertureMacro(GERBER_DRAW_ITEM *aParent, bool aFilled)
Helper to draw an aperture macro shape.
PAINTER contains all the knowledge about how to draw graphical object onto any particular output devi...
Definition: painter.h:58
bool m_DiffMode
Display layers in diff mode.
double a
Alpha component.
Definition: color4d.h:369
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Function GetABPosition returns the image position of aPosition for this object.
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
Function GetApertureMacroShape Calculate the primitive shape for flashed items.
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
#define GERBER_DRAWLAYERS_COUNT
wxString m_netHighlightString
If set to anything but an empty string, will highlight items with matching net.
wxString m_attributeHighlightString
If set to anything but an empty string, will highlight items with matching attribute.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const std::vector< VECTOR2I > & CPoints() const
bool m_hiContrastEnabled
Parameters for display modes.
virtual void update()
Function update Precalculates extra colors for layers (e.g.
SHAPE_POLY_SET.
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
bool GetTextD_CodePrms(int &aSize, wxPoint &aPos, double &aOrientation)
Returns the best size and orientation to display the D_Code on screen.
wxString m_Netname
for items associated to a net: the netname
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
wxString m_componentHighlightString
If set to anything but an empty string, will highlight items with matching component.
const GBR_NETLIST_METADATA & GetNetAttributes() const
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
double Angle() const
Function Angle computes the angle of the vector.
Definition: vector2d.h:313
int NewOutline()
Creates a new empty polygon in the set and returns its index
void ConvertSegmentToPolygon()
Function ConvertSegmentToPolygon convert a line to an equivalent polygon.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
Definition: dcode.h:105
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
Definition: dcode.h:98
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
std::vector< COLOR4D > m_Palette
m_Pallete stores a list of colors that are used, in order, when a list of colors needs to be generate...
COLOR4D GetColor(int aLayer) const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
bool m_polygonFill
Flag determining if polygons should be drawn with fill.
void LoadColors(const COLOR_SETTINGS *aSettings) override
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
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_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:107
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void drawPolygon(GERBER_DRAW_ITEM *aParent, const SHAPE_POLY_SET &aPolygon, bool aFilled, bool aShift=false)
Helper routine to draw a polygon.
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
APERTURE_MACRO * GetMacro() const
Definition: dcode.h:157
Color settings are a bit different than most of the settings objects in that there can be more than o...
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 ConvertShapeToPolygon()
Function ConvertShapeToPolygon convert a shape to an equivalent polygon.
Definition: dcode.cpp:301
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.
Definition: am_primitive.h:163
const Vec & GetOrigin() const
Definition: box2.h:193
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
static constexpr int Millimeter2iu(double mm)
bool GetLayerPolarity() const
virtual void SetNegativeDrawMode(bool aSetting)
Sets negative draw mode in the renderer.
GERBER_FILE_IMAGE * m_GerberImageFile
bool m_diffMode
Flag determining if layers should be rendered in "diff" mode.
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
Class GAL is the abstract interface for drawing on a 2D-surface.
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)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99