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  for( int i = GERBVIEW_LAYER_ID_START;
60  {
61  COLOR4D baseColor = aSettings->GetColor( i );
62 
63  if( baseColor == COLOR4D::UNSPECIFIED )
64  baseColor = aSettings->m_Palette[ ( palette_idx++ ) % palette_size ];
65 
66  if( m_diffMode )
67  baseColor.a = 0.75;
68 
69  m_layerColors[i] = baseColor;
70  m_layerColorsHi[i] = baseColor.Brightened( 0.5 );
71  m_layerColorsSel[i] = baseColor.Brightened( 0.8 );
72  m_layerColorsDark[i] = baseColor.Darkened( 0.25 );
73  }
74 
75  for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ )
76  m_layerColors[i] = aSettings->GetColor( i );
77 
78  for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
79  m_layerColors[i] = aSettings->GetColor( i );
80 
81  update();
82 }
83 
84 
86 {
88  m_lineFill = aOptions.m_DisplayLinesFill;
91  m_showCodes = aOptions.m_DisplayDCodes;
92  m_diffMode = aOptions.m_DiffMode;
96 
97  update();
98 }
99 
100 
101 const COLOR4D& GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
102 {
103  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
104  static const COLOR4D transparent = COLOR4D( 0, 0, 0, 0 );
105  const GERBER_DRAW_ITEM* gbrItem = nullptr;
106 
107  if( item && item->Type() == GERBER_DRAW_ITEM_T )
108  gbrItem = static_cast<const GERBER_DRAW_ITEM*>( item );
109 
110  // All DCODE layers stored under a single color setting
111  if( IsDCodeLayer( aLayer ) )
112  return m_layerColors[ LAYER_DCODES ];
113 
114  if( item && item->IsSelected() )
115  return m_layerColorsSel[aLayer];
116 
117  if( gbrItem && gbrItem->GetLayerPolarity() )
118  {
119  if( m_showNegativeItems )
121  else
122  return transparent;
123  }
124 
125  if( !m_netHighlightString.IsEmpty() && gbrItem &&
127  return m_layerColorsHi[aLayer];
128 
129  if( !m_componentHighlightString.IsEmpty() && gbrItem &&
131  return m_layerColorsHi[aLayer];
132 
133  if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() &&
135  return m_layerColorsHi[aLayer];
136 
137  // Return grayish color for non-highlighted layers in the high contrast mode
138  if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0)
139  return m_hiContrastColor[aLayer];
140 
141  // Catch the case when highlight and high-contraste modes are enabled
142  // and we are drawing a not highlighted track
143  if( m_highlightEnabled )
144  return m_layerColorsDark[aLayer];
145 
146  // No special modificators enabled
147  return m_layerColors[aLayer];
148 }
149 
150 
152  PAINTER( aGal )
153 {
154 }
155 
156 
157 // TODO(JE): Pull up to PAINTER?
158 int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
159 {
160  // if items have 0 thickness, draw them with the outline
161  // width, otherwise respect the set value (which, no matter
162  // how small will produce something)
163  if( aActualThickness == 0 )
165 
166  return aActualThickness;
167 }
168 
169 
170 bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
171 {
172  const EDA_ITEM* item = static_cast<const EDA_ITEM*>( aItem );
173 
174  // the "cast" applied in here clarifies which overloaded draw() is called
175  switch( item->Type() )
176  {
177  case GERBER_DRAW_ITEM_T:
178  draw( static_cast<GERBER_DRAW_ITEM*>( const_cast<EDA_ITEM*>( item ) ), aLayer );
179  break;
180 
181  default:
182  // Painter does not know how to draw the object
183  return false;
184  }
185 
186  return true;
187 }
188 
189 
190 // TODO(JE) aItem can't be const because of GetDcodeDescr()
191 // Probably that can be refactored in GERBER_DRAW_ITEM to allow const here.
192 void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
193 {
194  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) ); // TODO(JE) Getter
195  VECTOR2D end( aItem->GetABPosition( aItem->m_End ) ); // TODO(JE) Getter
196  int width = aItem->m_Size.x; // TODO(JE) Getter
197  bool isFilled = true;
198  COLOR4D color;
199  // TODO(JE) This doesn't actually work properly for ImageNegative
200  bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative );
201 
202  // Draw DCODE overlay text
203  if( IsDCodeLayer( aLayer ) )
204  {
205  wxString codeText;
206  VECTOR2D textPosition;
207  double textSize;
208  double orient;
209 
210  if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
211  return;
212 
213  color = m_gerbviewSettings.GetColor( aItem, aLayer );
214  codeText.Printf( "D%d", aItem->m_DCode );
215 
216  m_gal->SetIsStroke( true );
217  m_gal->SetIsFill( false );
219  m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) );
220  m_gal->SetLineWidth( textSize/10 );
221  m_gal->SetFontBold( false );
222  m_gal->SetFontItalic( false );
223  m_gal->SetTextMirrored( false );
224  m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
227  m_gal->BitmapText( codeText, textPosition, orient );
228 
229  return;
230  }
231 
232  color = m_gerbviewSettings.GetColor( aItem, aLayer );
233 
234  // TODO: Should brightened color be a preference?
235  if( aItem->IsBrightened() )
236  color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
237 
238  m_gal->SetNegativeDrawMode( isNegative );
241  m_gal->SetIsFill( isFilled );
242  m_gal->SetIsStroke( !isFilled );
243 
244  switch( aItem->m_Shape )
245  {
246  case GBR_POLYGON:
247  {
249  m_gal->SetIsFill( isFilled );
250  m_gal->SetIsStroke( !isFilled );
251 
252  if( isNegative && !isFilled )
253  {
254  m_gal->SetNegativeDrawMode( false );
255  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
256  }
257 
258  if( !isFilled )
260 
261  std::vector<VECTOR2I> pts = aItem->m_Polygon.COutline( 0 ).CPoints();
262 
263  for( auto& pt : pts )
264  pt = aItem->GetABPosition( pt );
265 
266 
267  SHAPE_POLY_SET absolutePolygon;
268  SHAPE_LINE_CHAIN chain( pts );
269  chain.SetClosed( true );
270  absolutePolygon.AddOutline( chain );
271 
272  // Degenerated polygons (having < 3 points) are drawn as lines
273  // to avoid issues in draw polygon functions
274  if( !isFilled || absolutePolygon.COutline( 0 ).PointCount() < 3 )
275  m_gal->DrawPolyline( absolutePolygon.COutline( 0 ) );
276  else
277  {
278  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
279  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
280  // on Opengl
281  if( m_gal->IsOpenGlEngine() )
282  absolutePolygon.CacheTriangulation();
283 
284  m_gal->DrawPolygon( absolutePolygon );
285  }
286 
287  break;
288  }
289 
290  case GBR_CIRCLE:
291  {
292  isFilled = m_gerbviewSettings.m_lineFill;
293  double radius = GetLineLength( aItem->m_Start, aItem->m_End );
294  m_gal->DrawCircle( start, radius );
295  break;
296  }
297 
298  case GBR_ARC:
299  {
300  isFilled = m_gerbviewSettings.m_lineFill;
301 
302  // These are swapped because wxDC fills arcs counterclockwise and GAL
303  // fills them clockwise.
304  wxPoint arcStart = aItem->m_End;
305  wxPoint arcEnd = aItem->m_Start;
306 
307  // Gerber arcs are 3-point (start, center, end)
308  // GAL needs center, radius, start angle, end angle
309  double radius = GetLineLength( arcStart, aItem->m_ArcCentre );
310  VECTOR2D center = aItem->GetABPosition( aItem->m_ArcCentre );
311  VECTOR2D startVec = VECTOR2D( aItem->GetABPosition( arcStart ) ) - center;
312  VECTOR2D endVec = VECTOR2D( aItem->GetABPosition( arcEnd ) ) - center;
313 
314  m_gal->SetIsFill( isFilled );
315  m_gal->SetIsStroke( !isFilled );
316  m_gal->SetLineWidth( isFilled ? width : m_gerbviewSettings.m_outlineWidth );
317 
318  double startAngle = startVec.Angle();
319  double endAngle = endVec.Angle();
320 
321  // GAL fills in direction of increasing angle, so we have to convert
322  // the angle from the -PI to PI domain of atan2() to ensure that
323  // the arc goes in the right direction
324  if( startAngle > endAngle )
325  endAngle += (2 * M_PI);
326 
327  // In Gerber, 360-degree arcs are stored in the file with start equal to end
328  if( arcStart == arcEnd )
329  {
330  endAngle = startAngle + 2*M_PI;
331  }
332 
333  m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width );
334 
335 #if 0 // Arc Debugging only
336  m_gal->SetIsFill( false );
337  m_gal->SetIsStroke( true );
338  m_gal->SetLineWidth( 5 );
339  m_gal->SetStrokeColor( COLOR4D( 0.1, 0.5, 0.0, 0.5 ) );
340  m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) );
341  m_gal->SetStrokeColor( COLOR4D( 0.6, 0.1, 0.0, 0.5 ) );
342  m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) );
343 #endif
344 
345 #if 0 // Bbox arc Debugging only
346  m_gal->SetIsFill( false );
347  m_gal->SetIsStroke( true );
348  EDA_RECT box = aItem->GetBoundingBox();
349  m_gal->SetLineWidth( 5 );
350  m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
351  // box coordinates are already in AB position.
352  m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
353 #endif
354  break;
355  }
356 
357  case GBR_SPOT_CIRCLE:
358  case GBR_SPOT_RECT:
359  case GBR_SPOT_OVAL:
360  case GBR_SPOT_POLY:
361  case GBR_SPOT_MACRO:
362  {
363  isFilled = m_gerbviewSettings.m_spotFill;
364  drawFlashedShape( aItem, isFilled );
365  break;
366  }
367 
368  case GBR_SEGMENT:
369  {
370  /* Plot a line from m_Start to m_End.
371  * Usually, a round pen is used, but some gerber files use a rectangular pen
372  * In fact, any aperture can be used to plot a line.
373  * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
374  */
375  isFilled = m_gerbviewSettings.m_lineFill;
376  m_gal->SetIsFill( isFilled );
377  m_gal->SetIsStroke( !isFilled );
378 
379  if( isNegative && !isFilled )
380  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
381 
382  // TODO(JE) Refactor this to allow const aItem
383  D_CODE* code = aItem->GetDcodeDescr();
384  if( code && code->m_Shape == APT_RECT )
385  {
386  if( aItem->m_Polygon.OutlineCount() == 0 )
387  aItem->ConvertSegmentToPolygon();
388 
389  drawPolygon( aItem, aItem->m_Polygon, isFilled );
390  }
391  else
392  {
393  if( !isFilled )
395 
396  m_gal->DrawSegment( start, end, width );
397  }
398  break;
399  }
400 
401  default:
402  wxASSERT_MSG( false, "GERBER_DRAW_ITEM shape is unknown!" );
403  break;
404  }
405 
406  // Enable for bounding box debugging
407  #if 0
408  const BOX2I& bb = aItem->ViewBBox();
409  m_gal->SetIsStroke( true );
410  m_gal->SetIsFill( true );
411  m_gal->SetLineWidth( 3 );
412  m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
413  m_gal->SetFillColor( COLOR4D(0.9, 0.9, 0, 0.1) );
414  m_gal->DrawRectangle( bb.GetOrigin(), bb.GetEnd() );
415  #endif
416 }
417 
418 
420  GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon, bool aFilled, bool aShift )
421 {
422  wxASSERT( aPolygon.OutlineCount() == 1 );
423 
424  if( aPolygon.OutlineCount() == 0 )
425  return;
426 
427  SHAPE_POLY_SET poly;
428  poly.NewOutline();
429  const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
430  VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
431 
432  for( auto& pt : pts )
433  poly.Append( aParent->GetABPosition( pt + offset ) );
434 
437 
438  if( !aFilled )
439  {
440  m_gal->DrawPolyline( poly.COutline( 0 ) );
441  }
442  else
443  m_gal->DrawPolygon( poly );
444 }
445 
446 
448 {
449  D_CODE* code = aItem->GetDcodeDescr();
450 
451  wxASSERT_MSG( code, "drawFlashedShape: Item has no D_CODE!" );
452 
453  if( !code )
454  return;
455 
456  m_gal->SetIsFill( aFilled );
457  m_gal->SetIsStroke( !aFilled );
459 
460  switch( aItem->m_Shape )
461  {
462  case GBR_SPOT_CIRCLE:
463  {
464  int radius = code->m_Size.x >> 1;
465  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
466 
467  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
468  {
469  m_gal->DrawCircle( start, radius );
470  }
471  else // rectangular hole
472  {
473  if( code->m_Polygon.OutlineCount() == 0 )
474  code->ConvertShapeToPolygon();
475 
476  drawPolygon( aItem, code->m_Polygon, aFilled, true );
477  }
478 
479  break;
480  }
481 
482  case GBR_SPOT_RECT:
483  {
484  wxPoint codeStart;
485  wxPoint aShapePos = aItem->m_Start;
486  codeStart.x = aShapePos.x - code->m_Size.x / 2;
487  codeStart.y = aShapePos.y - code->m_Size.y / 2;
488  wxPoint codeEnd = codeStart + code->m_Size;
489  codeStart = aItem->GetABPosition( codeStart );
490  codeEnd = aItem->GetABPosition( codeEnd );
491 
492  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
493  {
494  m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
495  }
496  else
497  {
498  if( code->m_Polygon.OutlineCount() == 0 )
499  code->ConvertShapeToPolygon();
500 
501  drawPolygon( aItem, code->m_Polygon, aFilled, true );
502  }
503  break;
504  }
505 
506  case GBR_SPOT_OVAL:
507  {
508  int radius = 0;
509 
510  wxPoint codeStart = aItem->m_Start;
511  wxPoint codeEnd = aItem->m_Start;
512 
513  if( code->m_Size.x > code->m_Size.y ) // horizontal oval
514  {
515  int delta = (code->m_Size.x - code->m_Size.y) / 2;
516  codeStart.x -= delta;
517  codeEnd.x += delta;
518  radius = code->m_Size.y;
519  }
520  else // horizontal oval
521  {
522  int delta = (code->m_Size.y - code->m_Size.x) / 2;
523  codeStart.y -= delta;
524  codeEnd.y += delta;
525  radius = code->m_Size.x;
526  }
527 
528  codeStart = aItem->GetABPosition( codeStart );
529  codeEnd = aItem->GetABPosition( codeEnd );
530 
531  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
532  {
533  m_gal->DrawSegment( codeStart, codeEnd, radius );
534  }
535  else
536  {
537  if( code->m_Polygon.OutlineCount() == 0 )
538  code->ConvertShapeToPolygon();
539 
540  drawPolygon( aItem, code->m_Polygon, aFilled, true );
541  }
542  break;
543  }
544 
545  case GBR_SPOT_POLY:
546  {
547  if( code->m_Polygon.OutlineCount() == 0 )
548  code->ConvertShapeToPolygon();
549 
550  drawPolygon( aItem, code->m_Polygon, aFilled, true );
551  break;
552  }
553 
554  case GBR_SPOT_MACRO:
555  drawApertureMacro( aItem, aFilled );
556  break;
557 
558  default:
559  wxASSERT_MSG( false, wxT( "Unknown Gerber flashed shape!" ) );
560  break;
561  }
562 }
563 
564 
566 {
567  D_CODE* code = aParent->GetDcodeDescr();
568  APERTURE_MACRO* macro = code->GetMacro();
569 
570  SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aParent, aParent->m_Start );
571 
574 
575  if( !aFilled )
576  {
577  for( int i = 0; i < macroShape->OutlineCount(); i++ )
578  m_gal->DrawPolyline( macroShape->COutline( i ) );
579  }
580  else
581  m_gal->DrawPolygon( *macroShape );
582 }
583 
584 
585 const double GERBVIEW_RENDER_SETTINGS::MAX_FONT_SIZE = Millimeter2iu( 10.0 );
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:131
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
bool IsSelected() const
Definition: base_struct.h:225
const Vec GetEnd() const
Definition: box2.h:194
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]
Colors for all layers (highlighted)
Definition: painter.h:263
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:260
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
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:278
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:228
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:84
COLOR4D Darkened(double aFactor) const
Function Darkened Returns a color that is darker by a given factor, without modifying object.
Definition: color4d.h:216
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:360
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:308
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
Definition: painter.h:272
COLOR4D Brightened(double aFactor) const
Function Brightened Returns a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:200
bool m_showCodes
Flag determining if D-Codes should be drawn.
static const COLOR4D BLACK
Definition: color4d.h:312
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:257
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:308
bool m_DiffMode
Display layers in diff mode.
double a
Alpha component.
Definition: color4d.h:305
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]
Colors for all layers (darkened)
Definition: painter.h:269
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.
Definition: painter.h:275
virtual void update()
Function update Precalculates extra colors for layers (e.g.
Definition: painter.cpp:54
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
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:292
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:166
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
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:192
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
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]
Colors for all layers (selected)
Definition: painter.h:266
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:40