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