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 <[email protected]>
5  * Copyright (C) 2022 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 
50 
51  update();
52 }
53 
54 
56 {
57  size_t palette_size = aSettings->m_Palette.size();
58  size_t palette_idx = 0;
59 
60  // Layers to draw gerber data read from gerber files:
61  for( int i = GERBVIEW_LAYER_ID_START;
63  {
64  COLOR4D baseColor = aSettings->GetColor( i );
65 
66  if( baseColor == COLOR4D::UNSPECIFIED )
67  baseColor = aSettings->m_Palette[ ( palette_idx++ ) % palette_size ];
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  // Draw layers specific to Gerbview:
76  // LAYER_DCODES, LAYER_NEGATIVE_OBJECTS, LAYER_GERBVIEW_GRID,
77  // LAYER_GERBVIEW_AXES, LAYER_GERBVIEW_BACKGROUND, LAYER_GERBVIEW_DRAWINGSHEET,
78  for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ )
79  m_layerColors[i] = aSettings->GetColor( i );
80 
81  for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
82  m_layerColors[i] = aSettings->GetColor( i );
83 
84  update();
85 }
86 
87 
89 {
91  m_lineFill = aOptions.m_DisplayLinesFill;
94  m_showCodes = aOptions.m_DisplayDCodes;
95  m_diffMode = aOptions.m_DiffMode;
99 
100  update();
101 }
102 
103 
105 {
106  // Clear all highlight selections (dcode, net, component, attribute selection)
108  m_netHighlightString.Empty();
111 }
112 
113 COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
114 {
115  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
116  static const COLOR4D transparent = COLOR4D( 0, 0, 0, 0 );
117  const GERBER_DRAW_ITEM* gbrItem = nullptr;
118 
119  if( item && item->Type() == GERBER_DRAW_ITEM_T )
120  gbrItem = static_cast<const GERBER_DRAW_ITEM*>( item );
121 
122  // All DCODE layers stored under a single color setting
123  if( IsDCodeLayer( aLayer ) )
124  return m_layerColors[ LAYER_DCODES ];
125 
126  if( item && item->IsSelected() )
127  return m_layerColorsSel[aLayer];
128 
129  if( gbrItem && gbrItem->GetLayerPolarity() )
130  {
131  if( m_showNegativeItems )
133  else
134  return transparent;
135  }
136 
137  if( !m_netHighlightString.IsEmpty() && gbrItem &&
139  return m_layerColorsHi[aLayer];
140 
141  if( !m_componentHighlightString.IsEmpty() && gbrItem &&
143  return m_layerColorsHi[aLayer];
144 
145  if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() &&
147  return m_layerColorsHi[aLayer];
148 
149  if( m_dcodeHighlightValue> 0 && gbrItem && gbrItem->GetDcodeDescr() &&
151  return m_layerColorsHi[aLayer];
152 
153  // Return grayish color for non-highlighted layers in the high contrast mode
154  if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
155  return m_hiContrastColor[aLayer];
156 
157  // Catch the case when highlight and high-contraste modes are enabled
158  // and we are drawing a not highlighted track
159  if( m_highlightEnabled )
160  return m_layerColorsDark[aLayer];
161 
162  // No special modificators enabled
163  return m_layerColors[aLayer];
164 }
165 
166 
168  PAINTER( aGal )
169 {
170 }
171 
172 
173 // TODO(JE): Pull up to PAINTER?
174 int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
175 {
176  // if items have 0 thickness, draw them with the outline
177  // width, otherwise respect the set value (which, no matter
178  // how small will produce something)
179  if( aActualThickness == 0 )
181 
182  return aActualThickness;
183 }
184 
185 
186 bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
187 {
188  const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
189 
190  if( !item )
191  return false;
192 
193  // the "cast" applied in here clarifies which overloaded draw() is called
194  switch( item->Type() )
195  {
196  case GERBER_DRAW_ITEM_T:
197  draw( static_cast<GERBER_DRAW_ITEM*>( const_cast<EDA_ITEM*>( item ) ), aLayer );
198  break;
199 
200  default:
201  // Painter does not know how to draw the object
202  return false;
203  }
204 
205  return true;
206 }
207 
208 
209 // TODO(JE) aItem can't be const because of GetDcodeDescr()
210 // Probably that can be refactored in GERBER_DRAW_ITEM to allow const here.
211 void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
212 {
213  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) ); // TODO(JE) Getter
214  VECTOR2D end( aItem->GetABPosition( aItem->m_End ) ); // TODO(JE) Getter
215  int width = aItem->m_Size.x; // TODO(JE) Getter
216  bool isFilled = true;
217  COLOR4D color;
218  // TODO(JE) This doesn't actually work properly for ImageNegative
219  bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative );
220 
221  // Draw DCODE overlay text
222  if( IsDCodeLayer( aLayer ) )
223  {
224  wxString codeText;
225  VECTOR2D textPosition;
226  double textSize;
227  double orient;
228 
229  if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
230  return;
231 
232  color = m_gerbviewSettings.GetColor( aItem, aLayer );
233  codeText.Printf( wxT( "D%d" ), aItem->m_DCode );
234 
235  m_gal->SetIsStroke( true );
236  m_gal->SetIsFill( false );
238  m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) );
239  m_gal->SetLineWidth( textSize/10 );
240  m_gal->SetFontBold( false );
241  m_gal->SetFontItalic( false );
242  m_gal->SetFontUnderlined( false );
243  m_gal->SetTextMirrored( false );
244  m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
247  m_gal->BitmapText( codeText, textPosition, orient );
248 
249  return;
250  }
251 
252  color = m_gerbviewSettings.GetColor( aItem, aLayer );
253 
254  // TODO: Should brightened color be a preference?
255  if( aItem->IsBrightened() )
256  color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
257 
261  m_gal->SetIsFill( isFilled );
262  m_gal->SetIsStroke( !isFilled );
263 
264  switch( aItem->m_Shape )
265  {
266  case GBR_POLYGON:
267  {
269  m_gal->SetIsFill( isFilled );
270  m_gal->SetIsStroke( !isFilled );
271 
272  if( isNegative && !isFilled )
273  {
274  m_gal->SetNegativeDrawMode( false );
275  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
276  }
277 
278  if( !isFilled )
280 
281  if( aItem->m_AbsolutePolygon.OutlineCount() == 0 )
282  {
283  std::vector<VECTOR2I> pts = aItem->m_Polygon.COutline( 0 ).CPoints();
284 
285  for( auto& pt : pts )
286  pt = aItem->GetABPosition( pt );
287 
288  SHAPE_LINE_CHAIN chain( pts );
289  chain.SetClosed( true );
290  aItem->m_AbsolutePolygon.AddOutline( chain );
291  }
292 
293  // Degenerated polygons (having < 3 points) are drawn as lines
294  // to avoid issues in draw polygon functions
295  if( !isFilled || aItem->m_AbsolutePolygon.COutline( 0 ).PointCount() < 3 )
297  else
298  {
299  // On Opengl, a not convex filled polygon is usually drawn by using triangles as primitives.
300  // CacheTriangulation() can create basic triangle primitives to draw the polygon solid shape
301  // on Opengl
302  // We use the fastest CacheTriangulation calculation mode: no partition created because
303  // the partition is useless in Gerbview, and very time consumming (optimized only
304  // for pcbnew that has different internal unit)
306  aItem->m_AbsolutePolygon.CacheTriangulation( false /* fastest triangulation calculation mode */ );
307 
309  }
310 
311  break;
312  }
313 
314  case GBR_CIRCLE:
315  {
316  isFilled = m_gerbviewSettings.m_lineFill;
317  double radius = GetLineLength( aItem->m_Start, aItem->m_End );
318  m_gal->DrawCircle( start, radius );
319  break;
320  }
321 
322  case GBR_ARC:
323  {
324  isFilled = m_gerbviewSettings.m_lineFill;
325 
326  // These are swapped because wxDC fills arcs counterclockwise and GAL
327  // fills them clockwise.
328  wxPoint arcStart = aItem->m_End;
329  wxPoint arcEnd = aItem->m_Start;
330 
331  // Gerber arcs are 3-point (start, center, end)
332  // GAL needs center, radius, start angle, end angle
333  double radius = GetLineLength( arcStart, aItem->m_ArcCentre );
334  VECTOR2D center = aItem->GetABPosition( aItem->m_ArcCentre );
335  VECTOR2D startVec = VECTOR2D( aItem->GetABPosition( arcStart ) ) - center;
336  VECTOR2D endVec = VECTOR2D( aItem->GetABPosition( arcEnd ) ) - center;
337 
338  m_gal->SetIsFill( isFilled );
339  m_gal->SetIsStroke( !isFilled );
340  m_gal->SetLineWidth( isFilled ? width : m_gerbviewSettings.m_outlineWidth );
341 
342  double startAngle = startVec.Angle();
343  double endAngle = endVec.Angle();
344 
345  // GAL fills in direction of increasing angle, so we have to convert
346  // the angle from the -PI to PI domain of atan2() to ensure that
347  // the arc goes in the right direction
348  if( startAngle > endAngle )
349  endAngle += (2 * M_PI);
350 
351  // In Gerber, 360-degree arcs are stored in the file with start equal to end
352  if( arcStart == arcEnd )
353  {
354  endAngle = startAngle + 2*M_PI;
355  }
356 
357  m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width, ARC_HIGH_DEF );
358 
359 #if 0 // Arc Debugging only
360  m_gal->SetIsFill( false );
361  m_gal->SetIsStroke( true );
362  m_gal->SetLineWidth( 5 );
363  m_gal->SetStrokeColor( COLOR4D( 0.1, 0.5, 0.0, 0.5 ) );
364  m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) );
365  m_gal->SetStrokeColor( COLOR4D( 0.6, 0.1, 0.0, 0.5 ) );
366  m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) );
367 #endif
368 
369 #if 0 // Bbox arc Debugging only
370  m_gal->SetIsFill( false );
371  m_gal->SetIsStroke( true );
372  EDA_RECT box = aItem->GetBoundingBox();
373  m_gal->SetLineWidth( 5 );
374  m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
375  // box coordinates are already in AB position.
376  m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
377 #endif
378  break;
379  }
380 
381  case GBR_SPOT_CIRCLE:
382  case GBR_SPOT_RECT:
383  case GBR_SPOT_OVAL:
384  case GBR_SPOT_POLY:
385  case GBR_SPOT_MACRO:
386  {
387  isFilled = m_gerbviewSettings.m_spotFill;
388  drawFlashedShape( aItem, isFilled );
389  break;
390  }
391 
392  case GBR_SEGMENT:
393  {
394  /* Plot a line from m_Start to m_End.
395  * Usually, a round pen is used, but some gerber files use a rectangular pen
396  * In fact, any aperture can be used to plot a line.
397  * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
398  */
399  isFilled = m_gerbviewSettings.m_lineFill;
400  m_gal->SetIsFill( isFilled );
401  m_gal->SetIsStroke( !isFilled );
402 
403  if( isNegative && !isFilled )
404  m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
405 
406  // TODO(JE) Refactor this to allow const aItem
407  D_CODE* code = aItem->GetDcodeDescr();
408  if( code && code->m_Shape == APT_RECT )
409  {
410  if( aItem->m_Polygon.OutlineCount() == 0 )
411  aItem->ConvertSegmentToPolygon();
412 
413  drawPolygon( aItem, aItem->m_Polygon, isFilled );
414  }
415  else
416  {
417  if( !isFilled )
419 
420  m_gal->DrawSegment( start, end, width );
421  }
422  break;
423  }
424 
425  default:
426  wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
427  break;
428  }
429  m_gal->SetNegativeDrawMode( false );
430 
431  // Enable for bounding box debugging
432  #if 0
433  const BOX2I& bb = aItem->ViewBBox();
434  m_gal->SetIsStroke( true );
435  m_gal->SetIsFill( true );
436  m_gal->SetLineWidth( 3 );
437  m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
438  m_gal->SetFillColor( COLOR4D(0.9, 0.9, 0, 0.1) );
439  m_gal->DrawRectangle( bb.GetOrigin(), bb.GetEnd() );
440  #endif
441 }
442 
443 
445  GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon, bool aFilled, bool aShift )
446 {
447  wxASSERT( aPolygon.OutlineCount() == 1 );
448 
449  if( aPolygon.OutlineCount() == 0 )
450  return;
451 
452  SHAPE_POLY_SET poly;
453  poly.NewOutline();
454  const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
455  VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
456 
457  for( auto& pt : pts )
458  poly.Append( aParent->GetABPosition( pt + offset ) );
459 
462 
463  if( !aFilled )
464  {
465  m_gal->DrawPolyline( poly.COutline( 0 ) );
466  }
467  else
468  m_gal->DrawPolygon( poly );
469 }
470 
471 
473 {
474  D_CODE* code = aItem->GetDcodeDescr();
475 
476  wxASSERT_MSG( code, wxT( "drawFlashedShape: Item has no D_CODE!" ) );
477 
478  if( !code )
479  return;
480 
481  m_gal->SetIsFill( aFilled );
482  m_gal->SetIsStroke( !aFilled );
484 
485  switch( aItem->m_Shape )
486  {
487  case GBR_SPOT_CIRCLE:
488  {
489  int radius = code->m_Size.x >> 1;
490  VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
491 
492  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
493  {
494  m_gal->DrawCircle( start, radius );
495  }
496  else // rectangular hole
497  {
498  if( code->m_Polygon.OutlineCount() == 0 )
499  code->ConvertShapeToPolygon();
500 
501  drawPolygon( aItem, code->m_Polygon, aFilled, true );
502  }
503 
504  break;
505  }
506 
507  case GBR_SPOT_RECT:
508  {
509  wxPoint codeStart;
510  wxPoint aShapePos = aItem->m_Start;
511  codeStart.x = aShapePos.x - code->m_Size.x / 2;
512  codeStart.y = aShapePos.y - code->m_Size.y / 2;
513  wxPoint codeEnd = codeStart + code->m_Size;
514  codeStart = aItem->GetABPosition( codeStart );
515  codeEnd = aItem->GetABPosition( codeEnd );
516 
517  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
518  {
519  m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
520  }
521  else
522  {
523  if( code->m_Polygon.OutlineCount() == 0 )
524  code->ConvertShapeToPolygon();
525 
526  drawPolygon( aItem, code->m_Polygon, aFilled, true );
527  }
528  break;
529  }
530 
531  case GBR_SPOT_OVAL:
532  {
533  int radius = 0;
534 
535  wxPoint codeStart = aItem->m_Start;
536  wxPoint codeEnd = aItem->m_Start;
537 
538  if( code->m_Size.x > code->m_Size.y ) // horizontal oval
539  {
540  int delta = (code->m_Size.x - code->m_Size.y) / 2;
541  codeStart.x -= delta;
542  codeEnd.x += delta;
543  radius = code->m_Size.y;
544  }
545  else // horizontal oval
546  {
547  int delta = (code->m_Size.y - code->m_Size.x) / 2;
548  codeStart.y -= delta;
549  codeEnd.y += delta;
550  radius = code->m_Size.x;
551  }
552 
553  codeStart = aItem->GetABPosition( codeStart );
554  codeEnd = aItem->GetABPosition( codeEnd );
555 
556  if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
557  {
558  m_gal->DrawSegment( codeStart, codeEnd, radius );
559  }
560  else
561  {
562  if( code->m_Polygon.OutlineCount() == 0 )
563  code->ConvertShapeToPolygon();
564 
565  drawPolygon( aItem, code->m_Polygon, aFilled, true );
566  }
567  break;
568  }
569 
570  case GBR_SPOT_POLY:
571  {
572  if( code->m_Polygon.OutlineCount() == 0 )
573  code->ConvertShapeToPolygon();
574 
575  drawPolygon( aItem, code->m_Polygon, aFilled, true );
576  break;
577  }
578 
579  case GBR_SPOT_MACRO:
580  drawApertureMacro( aItem, aFilled );
581  break;
582 
583  default:
584  wxASSERT_MSG( false, wxT( "Unknown Gerber flashed shape!" ) );
585  break;
586  }
587 }
588 
589 
591 {
592  D_CODE* code = aParent->GetDcodeDescr();
593  APERTURE_MACRO* macro = code->GetMacro();
594 
595  SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aParent, aParent->m_Start );
596 
599 
600  if( !aFilled )
601  {
602  for( int i = 0; i < macroShape->OutlineCount(); i++ )
603  m_gal->DrawPolyline( macroShape->COutline( i ) );
604  }
605  else
606  m_gal->DrawPolygon( *macroShape );
607 }
608 
609 
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
Return 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)
Definition: layer_ids.h:989
int OutlineCount() const
Return the number of vertices in a given outline/hole.
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:243
bool IsSelected() const
Definition: eda_item.h:122
const Vec GetEnd() const
Definition: box2.h:178
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)
Draw a text using a bitmap font.
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:188
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:189
COLOR4D m_BgDrawColor
The background color.
int color
Definition: DXF_plotter.cpp:57
bool m_lineFill
Flag determining if lines should be drawn with fill.
virtual const BOX2I ViewBBox() const override
void SetFontBold(bool aBold)
Set bold property of current font.
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
SHAPE_POLY_SET m_AbsolutePolygon
void drawFlashedShape(GERBER_DRAW_ITEM *aItem, bool aFilled)
Helper to draw a flashed shape (aka spot)
static const COLOR4D BLACK
Definition: color4d.h:394
wxString m_Cmpref
the component reference parent of the data
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool IsBrightened() const
Definition: eda_item.h:125
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:76
COLOR4D Darkened(double aFactor) const
Return a color that is darker by a given factor, without modifying object.
Definition: color4d.h:292
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int getLineThickness(int aActualThickness) const
Get the thickness to draw for a line (e.g.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
int PointCount() const
Return the number of points (vertices) in this line chain.
SHAPE_POLY_SET m_Polygon
bool IsTriangulationUpToDate() const
bool m_spotFill
Flag determining if spots should be drawn with fill.
Definition: dcode.h:51
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:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:278
bool m_showCodes
Flag determining if D-Codes should be drawn.
const wxPoint GetEnd() const
Definition: eda_rect.h:112
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void drawApertureMacro(GERBER_DRAW_ITEM *aParent, bool aFilled)
Helper to draw an aperture macro shape.
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:57
bool m_DiffMode
Display layers in diff mode.
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Return 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...
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:621
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()
Precalculates extra colors for layers (e.g.
Represent a set of closed polygons.
const wxPoint GetOrigin() const
Definition: eda_rect.h:110
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:190
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:390
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
bool GetTextD_CodePrms(int &aSize, wxPoint &aPos, double &aOrientation)
Return 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()
Return true if the GAL engine is a OpenGL based type.
void ClearHighlightSelections()
Clear all highlight selections (dcode, net, component, attribute selection)
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
Compute the angle of the vector.
Definition: vector2d.h:307
void SetFontItalic(bool aItalic)
Set italic property of current font.
int NewOutline()
Creates a new hole in a given outline.
void ConvertSegmentToPolygon()
Convert a line to an equivalent polygon.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
Definition: dcode.h:200
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition: dcode.h:192
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
void SetTextMirrored(bool aMirrored)
Set a mirrored property of text.
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
Return a 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.
void LoadColors(const COLOR_SETTINGS *aSettings) override
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
void SetFontUnderlined(bool aUnderlined)
A gerber DCODE (also called Aperture) definition.
Definition: dcode.h:80
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int m_dcodeHighlightValue
If set to anything but >0 (in fact 10 the min dcode value), will highlight items with matching dcode.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Handle the component boundary box.
Definition: eda_rect.h:42
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:390
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:203
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
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)
Load settings related to display options.
APERTURE_MACRO * GetMacro() const
Definition: dcode.h:125
Color settings are a bit different than most of the settings objects in that there can be more than o...
constexpr int delta
void CacheTriangulation(bool aPartition=true)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
void ConvertShapeToPolygon()
Convert a shape to an equivalent polygon.
Definition: dcode.cpp:298
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
Support the "aperture macro" defined within standard RS274X.
Definition: am_primitive.h:167
const Vec & GetOrigin() const
Definition: box2.h:176
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)
Set negative draw mode in the renderer.
GERBER_FILE_IMAGE * m_GerberImageFile
bool m_diffMode
Flag determining if layers should be rendered in "diff" mode.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth, double aMaxError)
Draw an arc segment.
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
Abstract interface for drawing on a 2D-surface.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const wxPoint &aShapePos)
Calculate the primitive shape for flashed items.