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) 2017-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>
23#include <pgm_base.h>
26#include <gerbview_settings.h>
28#include <gerbview.h>
29#include <trigo.h>
30
31#include <dcode.h>
32#include <gerber_draw_item.h>
33#include <gerber_file_image.h>
34
35using namespace KIGFX;
36
37
39{
40 return Pgm().GetSettingsManager().GetAppSettings<GERBVIEW_SETTINGS>();
41}
42
43
44GERBVIEW_RENDER_SETTINGS::GERBVIEW_RENDER_SETTINGS()
45{
47
52
53 update();
54}
55
56
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( gvconfig()->m_Display.m_DiffMode )
66 baseColor.a = 0.75;
67
68 m_layerColors[i] = baseColor;
69 m_layerColorsHi[i] = baseColor.Brightened( 0.5 );
70 m_layerColorsSel[i] = baseColor.Brightened( 0.8 );
71 m_layerColorsDark[i] = baseColor.Darkened( 0.25 );
72 }
73
74 // Draw layers specific to Gerbview:
75 // LAYER_DCODES, LAYER_NEGATIVE_OBJECTS, LAYER_GERBVIEW_GRID, LAYER_GERBVIEW_AXES,
76 // LAYER_GERBVIEW_BACKGROUND, LAYER_GERBVIEW_DRAWINGSHEET, LAYER_GERBVIEW_PAGE_LIMITS
77 for( int i = LAYER_DCODES; i < GERBVIEW_LAYER_ID_END; i++ )
78 m_layerColors[i] = aSettings->GetColor( i );
79
80 for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
81 m_layerColors[i] = aSettings->GetColor( i );
82
83 // Ensure the generic LAYER_DRAWINGSHEET has the same color as the specialized
84 // LAYER_GERBVIEW_DRAWINGSHEET
86
87 update();
88}
89
90
92{
93 // Clear all highlight selections (dcode, net, component, attribute selection)
98}
99
100COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
101{
102 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
103 static const COLOR4D transparent = COLOR4D( 0, 0, 0, 0 );
104 const GERBER_DRAW_ITEM* gbrItem = nullptr;
105
106 if( item && item->Type() == GERBER_DRAW_ITEM_T )
107 gbrItem = static_cast<const GERBER_DRAW_ITEM*>( item );
108
109 // All DCODE layers stored under a single color setting
110 if( IsDCodeLayer( aLayer ) )
111 return m_layerColors[ LAYER_DCODES ];
112
113 if( item && item->IsSelected() )
114 return m_layerColorsSel[aLayer];
115
116 if( gbrItem && gbrItem->GetLayerPolarity() )
117 {
120 else
121 return transparent;
122 }
123
124 if( !m_netHighlightString.IsEmpty() && gbrItem &&
126 return m_layerColorsHi[aLayer];
127
128 if( !m_componentHighlightString.IsEmpty() && gbrItem &&
130 return m_layerColorsHi[aLayer];
131
132 if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() &&
134 return m_layerColorsHi[aLayer];
135
136 if( m_dcodeHighlightValue> 0 && gbrItem && gbrItem->GetDcodeDescr() &&
138 return m_layerColorsHi[aLayer];
139
140 // Return grayish color for non-highlighted layers in the high contrast mode
141 if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
142 return m_hiContrastColor[aLayer];
143
144 // Catch the case when highlight and high-contraste modes are enabled
145 // and we are drawing a not highlighted track
147 return m_layerColorsDark[aLayer];
148
149 // No special modificators enabled
150 return m_layerColors[aLayer];
151}
152
153
155{
157}
158
159
161 PAINTER( aGal )
162{
163}
164
165
166// TODO(JE): Pull up to PAINTER?
167int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
168{
169 // if items have 0 thickness, draw them with the outline width, otherwise respect the set
170 // value (which, no matter how small will produce something)
171 if( aActualThickness == 0 )
173
174 return aActualThickness;
175}
176
177
178bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
179{
180 GERBER_DRAW_ITEM* gbrItem = dynamic_cast<GERBER_DRAW_ITEM*>( const_cast<VIEW_ITEM*>( aItem ) );
181
182 if( gbrItem )
183 {
184 draw( gbrItem, aLayer );
185 return true;
186 }
187
188 return false;
189}
190
191
192// TODO(JE) aItem can't be const because of GetDcodeDescr()
193// Probably that can be refactored in GERBER_DRAW_ITEM to allow const here.
194void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
195{
196 VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) ); // TODO(JE) Getter
197 VECTOR2D end( aItem->GetABPosition( aItem->m_End ) ); // TODO(JE) Getter
198 int width = aItem->m_Size.x; // TODO(JE) Getter
199 bool isFilled = true;
201 // TODO(JE) This doesn't actually work properly for ImageNegative
202 bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative );
203
204 // Draw DCODE overlay text
205 if( IsDCodeLayer( aLayer ) )
206 {
207 wxString codeText;
208 VECTOR2I textPosition;
209 int textSize;
210 EDA_ANGLE orient;
211
212 if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
213 return;
214
215 color = m_gerbviewSettings.GetColor( aItem, aLayer );
216 codeText.Printf( wxT( "D%d" ), aItem->m_DCode );
217
218 m_gal->SetIsStroke( true );
219 m_gal->SetIsFill( false );
221 m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) );
222 m_gal->SetLineWidth( textSize/10 );
223 m_gal->SetFontBold( false );
224 m_gal->SetFontItalic( false );
225 m_gal->SetFontUnderlined( false );
226 m_gal->SetTextMirrored( false );
227 m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
230 m_gal->BitmapText( codeText, textPosition, orient );
231
232 return;
233 }
234
235 color = m_gerbviewSettings.GetColor( aItem, aLayer );
236
237 // TODO: Should brightened color be a preference?
238 if( aItem->IsBrightened() )
239 color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
240
244 m_gal->SetIsFill( isFilled );
245 m_gal->SetIsStroke( !isFilled );
246
247 switch( aItem->m_Shape )
248 {
249 case GBR_POLYGON:
250 {
252 m_gal->SetIsFill( isFilled );
253 m_gal->SetIsStroke( !isFilled );
254
255 if( isNegative && !isFilled )
256 {
257 m_gal->SetNegativeDrawMode( false );
258 m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
259 }
260
261 if( !isFilled )
263
264 if( aItem->m_AbsolutePolygon.OutlineCount() == 0 )
265 {
266 std::vector<VECTOR2I> pts = aItem->m_Polygon.COutline( 0 ).CPoints();
267
268 for( auto& pt : pts )
269 pt = aItem->GetABPosition( pt );
270
271 SHAPE_LINE_CHAIN chain( pts );
272 chain.SetClosed( true );
273 aItem->m_AbsolutePolygon.AddOutline( chain );
274 }
275
276 // Degenerated polygons (having < 3 points) are drawn as lines
277 // to avoid issues in draw polygon functions
278 if( !isFilled || aItem->m_AbsolutePolygon.COutline( 0 ).PointCount() < 3 )
280 else
281 {
282 // On Opengl, a not convex filled polygon is usually drawn by using triangles as
283 // primitives. CacheTriangulation() can create basic triangle primitives to draw the
284 // polygon solid shape on Opengl
285 // We use the fastest CacheTriangulation calculation mode: no partition created because
286 // the partition is useless in Gerbview, and very time consumming (optimized only
287 // for pcbnew that has different internal unit)
289 aItem->m_AbsolutePolygon.CacheTriangulation( false /* fastest triangulation calculation mode */ );
290
292 }
293
294 break;
295 }
296
297 case GBR_CIRCLE:
298 {
300 double radius = GetLineLength( aItem->m_Start, aItem->m_End );
301 m_gal->DrawCircle( start, radius );
302 break;
303 }
304
305 case GBR_ARC:
306 {
308
309 // These are swapped because wxDC fills arcs counterclockwise and GAL
310 // fills them clockwise.
311 VECTOR2I arcStart = aItem->m_End;
312 VECTOR2I arcEnd = aItem->m_Start;
313
314 // Gerber arcs are 3-point (start, center, end)
315 // GAL needs center, radius, start angle, end angle
316 double radius = GetLineLength( arcStart, aItem->m_ArcCentre );
317 VECTOR2D center = aItem->GetABPosition( aItem->m_ArcCentre );
318 VECTOR2D startVec = VECTOR2D( aItem->GetABPosition( arcStart ) ) - center;
319 VECTOR2D endVec = VECTOR2D( aItem->GetABPosition( arcEnd ) ) - center;
320
321 m_gal->SetIsFill( isFilled );
322 m_gal->SetIsStroke( !isFilled );
324
325 EDA_ANGLE startAngle( startVec );
326 EDA_ANGLE endAngle( endVec );
327
328 // GAL fills in direction of increasing angle, so we have to convert
329 // the angle from the -PI to PI domain of atan2() to ensure that
330 // the arc goes in the right direction
331 if( startAngle > endAngle )
332 endAngle += ANGLE_360;
333
334 // In Gerber, 360-degree arcs are stored in the file with start equal to end
335 if( arcStart == arcEnd )
336 endAngle = startAngle + ANGLE_360;
337
338 m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width, ARC_HIGH_DEF );
339
340#if 0 // Arc Debugging only
341 m_gal->SetIsFill( false );
342 m_gal->SetIsStroke( true );
343 m_gal->SetLineWidth( 5 );
344 m_gal->SetStrokeColor( COLOR4D( 0.1, 0.5, 0.0, 0.5 ) );
345 m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) );
346 m_gal->SetStrokeColor( COLOR4D( 0.6, 0.1, 0.0, 0.5 ) );
347 m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) );
348#endif
349
350#if 0 // Bbox arc Debugging only
351 m_gal->SetIsFill( false );
352 m_gal->SetIsStroke( true );
353 BOX2I box = aItem->GetBoundingBox();
354 m_gal->SetLineWidth( 5 );
355 m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
356 // box coordinates are already in AB position.
357 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
358#endif
359 break;
360 }
361
362 case GBR_SPOT_CIRCLE:
363 case GBR_SPOT_RECT:
364 case GBR_SPOT_OVAL:
365 case GBR_SPOT_POLY:
366 case GBR_SPOT_MACRO:
368 drawFlashedShape( aItem, isFilled );
369 break;
370
371 case GBR_SEGMENT:
372 {
373 /* Plot a line from m_Start to m_End.
374 * Usually, a round pen is used, but some gerber files use a rectangular pen
375 * In fact, any aperture can be used to plot a line.
376 * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
377 */
379 m_gal->SetIsFill( isFilled );
380 m_gal->SetIsStroke( !isFilled );
381
382 if( isNegative && !isFilled )
383 m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
384
385 // TODO(JE) Refactor this to allow const aItem
386 D_CODE* code = aItem->GetDcodeDescr();
387 if( code && code->m_Shape == APT_RECT )
388 {
389 if( aItem->m_Polygon.OutlineCount() == 0 )
391
392 drawPolygon( aItem, aItem->m_Polygon, isFilled );
393 }
394 else
395 {
396 if( !isFilled )
398
399 m_gal->DrawSegment( start, end, width );
400 }
401 break;
402 }
403
404 default:
405 wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
406 break;
407 }
408 m_gal->SetNegativeDrawMode( false );
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 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( const VECTOR2I& pt : pts )
437 poly.Append( aParent->GetABPosition( pt + offset ) );
438
439 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
441
442 if( !aFilled )
443 m_gal->DrawPolyline( poly.COutline( 0 ) );
444 else
445 m_gal->DrawPolygon( poly );
446}
447
448
450{
451 D_CODE* code = aItem->GetDcodeDescr();
452
453 wxASSERT_MSG( code, wxT( "drawFlashedShape: Item has no D_CODE!" ) );
454
455 if( !code )
456 return;
457
458 m_gal->SetIsFill( aFilled );
459 m_gal->SetIsStroke( !aFilled );
461
462 switch( aItem->m_Shape )
463 {
464 case GBR_SPOT_CIRCLE:
465 {
466 int radius = code->m_Size.x >> 1;
467 VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
468
469 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
470 {
471 m_gal->DrawCircle( start, radius );
472 }
473 else // rectangular hole
474 {
475 if( code->m_Polygon.OutlineCount() == 0 )
476 code->ConvertShapeToPolygon( aItem );
477
478 drawPolygon( aItem, code->m_Polygon, aFilled, true );
479 }
480
481 break;
482 }
483
484 case GBR_SPOT_RECT:
485 {
486 VECTOR2I codeStart;
487 VECTOR2I aShapePos = aItem->m_Start;
488 codeStart.x = aShapePos.x - code->m_Size.x / 2;
489 codeStart.y = aShapePos.y - code->m_Size.y / 2;
490 VECTOR2I codeEnd = codeStart + code->m_Size;
491 codeStart = aItem->GetABPosition( codeStart );
492 codeEnd = aItem->GetABPosition( codeEnd );
493
494 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
495 {
496 m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
497 }
498 else
499 {
500 if( code->m_Polygon.OutlineCount() == 0 )
501 code->ConvertShapeToPolygon( aItem );
502
503 drawPolygon( aItem, code->m_Polygon, aFilled, true );
504 }
505 break;
506 }
507
508 case GBR_SPOT_OVAL:
509 {
510 int radius = 0;
511
512 VECTOR2I codeStart = aItem->m_Start;
513 VECTOR2I codeEnd = aItem->m_Start;
514
515 if( code->m_Size.x > code->m_Size.y ) // horizontal oval
516 {
517 int delta = (code->m_Size.x - code->m_Size.y) / 2;
518 codeStart.x -= delta;
519 codeEnd.x += delta;
520 radius = code->m_Size.y;
521 }
522 else // horizontal oval
523 {
524 int delta = (code->m_Size.y - code->m_Size.x) / 2;
525 codeStart.y -= delta;
526 codeEnd.y += delta;
527 radius = code->m_Size.x;
528 }
529
530 codeStart = aItem->GetABPosition( codeStart );
531 codeEnd = aItem->GetABPosition( codeEnd );
532
533 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
534 {
535 m_gal->DrawSegment( codeStart, codeEnd, radius );
536 }
537 else
538 {
539 if( code->m_Polygon.OutlineCount() == 0 )
540 code->ConvertShapeToPolygon( aItem );
541
542 drawPolygon( aItem, code->m_Polygon, aFilled, true );
543 }
544 break;
545 }
546
547 case GBR_SPOT_POLY:
548 if( code->m_Polygon.OutlineCount() == 0 )
549 code->ConvertShapeToPolygon( aItem );
550
551 drawPolygon( aItem, code->m_Polygon, aFilled, true );
552 break;
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 SHAPE_POLY_SET* macroShape = macro->GetApertureMacroShape( aParent, aParent->m_Start );
570
571 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
573
574 if( !aFilled )
575 {
576 for( int i = 0; i < macroShape->OutlineCount(); i++ )
577 m_gal->DrawPolyline( macroShape->COutline( i ) );
578 }
579 else
580 {
581 m_gal->DrawPolygon( *macroShape );
582 }
583}
584
585
int color
Definition: DXF_plotter.cpp:57
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
constexpr EDA_IU_SCALE gerbIUScale
Definition: base_units.h:108
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
A gerber DCODE (also called Aperture) definition.
Definition: dcode.h:80
APERTURE_MACRO * GetMacro() const
Definition: dcode.h:124
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
Definition: dcode.h:201
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:191
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:190
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition: dcode.h:193
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:204
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:189
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition: dcode.cpp:294
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsSelected() const
Definition: eda_item.h:107
bool IsBrightened() const
Definition: eda_item.h:110
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
wxString m_Cmpref
the component reference parent of the data
wxString m_Netname
for items associated to a net: the netname
bool GetTextD_CodePrms(int &aSize, VECTOR2I &aPos, EDA_ANGLE &aOrientation)
Return the best size and orientation to display the D_Code on screen.
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
SHAPE_POLY_SET m_Polygon
VECTOR2I GetABPosition(const VECTOR2I &aXYPosition) const
Return the image position of aPosition for this object.
bool GetLayerPolarity() const
void ConvertSegmentToPolygon()
Convert a line to an equivalent polygon.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
GERBER_FILE_IMAGE * m_GerberImageFile
SHAPE_POLY_SET m_AbsolutePolygon
virtual const BOX2I ViewBBox() const override
const GBR_NETLIST_METADATA & GetNetAttributes() const
bool m_ImageNegative
true = Negative image
GBR_DISPLAY_OPTIONS m_Display
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
COLOR4D Darkened(double aFactor) const
Return a color that is darker by a given factor, without modifying object.
Definition: color4d.h:292
double a
Alpha component.
Definition: color4d.h:387
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:278
static const COLOR4D BLACK
Definition: color4d.h:394
Abstract interface for drawing on a 2D-surface.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetFontBold(const bool aBold)
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual bool IsOpenGlEngine()
Return true if the GAL engine is a OpenGL based type.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetTextMirrored(const bool aMirrored)
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void SetGlyphSize(const VECTOR2I aSize)
virtual void SetNegativeDrawMode(bool aSetting)
Set negative draw mode in the renderer.
void SetFontItalic(bool aItalic)
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
virtual void BitmapText(const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
Draw a text using a bitmap font.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, double aWidth, double aMaxError)
Draw an arc segment.
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.
void drawPolygon(GERBER_DRAW_ITEM *aParent, const SHAPE_POLY_SET &aPolygon, bool aFilled, bool aShift=false)
Helper routine to draw a polygon.
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
int getLineThickness(int aActualThickness) const
Get the thickness to draw for a line (e.g.
void draw(GERBER_DRAW_ITEM *aVia, int aLayer)
void drawApertureMacro(GERBER_DRAW_ITEM *aParent, bool aFilled)
Helper to draw an aperture macro shape.
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
void drawFlashedShape(GERBER_DRAW_ITEM *aItem, bool aFilled)
Helper to draw a flashed shape (aka spot)
wxString m_attributeHighlightString
If set to anything but an empty string, will highlight items with matching attribute.
void LoadColors(const COLOR_SETTINGS *aSettings) override
wxString m_componentHighlightString
If set to anything but an empty string, will highlight items with matching component.
void ClearHighlightSelections()
Clear all highlight selections (dcode, net, component, attribute selection)
int m_dcodeHighlightValue
If set to anything but >0 (in fact 10 the min dcode value), will highlight items with matching dcode.
static const double MAX_FONT_SIZE
Maximum font size for D-Codes and other strings.
wxString m_netHighlightString
If set to anything but an empty string, will highlight items with matching net.
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...
bool GetShowPageLimits() const override
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:58
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
std::set< unsigned int > m_highContrastLayers
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
virtual void update()
Precalculates extra colors for layers (e.g.
COLOR4D m_layerColors[LAYER_ID_COUNT]
bool m_hiContrastEnabled
Parameters for display modes.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
bool IsTriangulationUpToDate() const
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
void CacheTriangulation(bool aPartition=true, bool aSimplify=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
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...
int NewOutline()
Creates a new hole in a given outline.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
@ APT_DEF_NO_HOLE
Definition: dcode.h:61
@ APT_RECT
Definition: dcode.h:50
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:418
@ GBR_SPOT_OVAL
@ GBR_SEGMENT
@ GBR_SPOT_POLY
@ GBR_SPOT_RECT
@ GBR_CIRCLE
@ GBR_POLYGON
@ GBR_SPOT_CIRCLE
@ GBR_ARC
@ GBR_SPOT_MACRO
GERBVIEW_SETTINGS * gvconfig()
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition: layer_ids.h:417
@ GERBVIEW_LAYER_ID_START
Definition: layer_ids.h:407
@ LAYER_DCODES
Definition: layer_ids.h:412
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:413
@ GERBVIEW_LAYER_ID_END
Definition: layer_ids.h:420
bool IsDCodeLayer(int aLayer)
Definition: layer_ids.h:1001
@ GAL_LAYER_ID_START
Definition: layer_ids.h:191
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:217
@ GAL_LAYER_ID_END
Definition: layer_ids.h:260
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:402
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:266
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
Support the "aperture macro" defined within standard RS274X.
Definition: am_primitive.h:167
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const VECTOR2I &aShapePos)
Calculate the primitive shape for flashed items.
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
constexpr int delta
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:188
@ GERBER_DRAW_ITEM_T
Definition: typeinfo.h:214
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618