KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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{
41}
42
43
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_ForceOpacityMode )
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_ShapeType )
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_ShapeAsPolygon.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 = aItem->m_Start.Distance( 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 = arcStart.Distance( 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 // Adjust the allowed approx error to convert arcs to segments:
339 int arc_to_seg_error = gerbIUScale.mmToIU( 0.005 ); // Allow 5 microns
340 m_gal->DrawArcSegment( center, radius, startAngle, endAngle - startAngle, width,
341 arc_to_seg_error );
342
343#if 0 // Arc Debugging only
344 m_gal->SetIsFill( false );
345 m_gal->SetIsStroke( true );
346 m_gal->SetLineWidth( 5 );
347 m_gal->SetStrokeColor( COLOR4D( 0.1, 0.5, 0.0, 0.5 ) );
348 m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) );
349 m_gal->SetStrokeColor( COLOR4D( 0.6, 0.1, 0.0, 0.5 ) );
350 m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) );
351#endif
352
353#if 0 // Bbox arc Debugging only
354 m_gal->SetIsFill( false );
355 m_gal->SetIsStroke( true );
356 BOX2I box = aItem->GetBoundingBox();
357 m_gal->SetLineWidth( 5 );
358 m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
359 // box coordinates are already in AB position.
360 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
361#endif
362 break;
363 }
364
365 case GBR_SPOT_CIRCLE:
366 case GBR_SPOT_RECT:
367 case GBR_SPOT_OVAL:
368 case GBR_SPOT_POLY:
369 case GBR_SPOT_MACRO:
371 drawFlashedShape( aItem, isFilled );
372 break;
373
374 case GBR_SEGMENT:
375 {
376 /* Plot a line from m_Start to m_End.
377 * Usually, a round pen is used, but some gerber files use a rectangular pen
378 * In fact, any aperture can be used to plot a line.
379 * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
380 */
382 m_gal->SetIsFill( isFilled );
383 m_gal->SetIsStroke( !isFilled );
384
385 if( isNegative && !isFilled )
386 m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
387
388 // TODO(JE) Refactor this to allow const aItem
389 D_CODE* code = aItem->GetDcodeDescr();
390 if( code && code->m_ApertType == APT_RECT )
391 {
392 if( aItem->m_ShapeAsPolygon.OutlineCount() == 0 )
394
395 drawPolygon( aItem, aItem->m_ShapeAsPolygon, isFilled );
396 }
397 else
398 {
399 if( !isFilled )
401
402 m_gal->DrawSegment( start, end, width );
403 }
404 break;
405 }
406
407 default:
408 wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
409 break;
410 }
411 m_gal->SetNegativeDrawMode( false );
412
413 // Enable for bounding box debugging
414 #if 0
415 const BOX2I& bb = aItem->ViewBBox();
416 m_gal->SetIsStroke( true );
417 m_gal->SetIsFill( true );
418 m_gal->SetLineWidth( 3 );
419 m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
420 m_gal->SetFillColor( COLOR4D(0.9, 0.9, 0, 0.1) );
421 m_gal->DrawRectangle( bb.GetOrigin(), bb.GetEnd() );
422 #endif
423}
424
425
427 bool aFilled, bool aShift )
428{
429 wxASSERT( aPolygon.OutlineCount() == 1 );
430
431 if( aPolygon.OutlineCount() == 0 )
432 return;
433
434 SHAPE_POLY_SET poly;
435 poly.NewOutline();
436 const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
437 VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
438
439 for( const VECTOR2I& pt : pts )
440 poly.Append( aParent->GetABPosition( pt + offset ) );
441
442 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
444
445 if( !aFilled )
446 m_gal->DrawPolyline( poly.COutline( 0 ) );
447 else
448 m_gal->DrawPolygon( poly );
449}
450
451
453{
454 D_CODE* code = aItem->GetDcodeDescr();
455
456 wxASSERT_MSG( code, wxT( "drawFlashedShape: Item has no D_CODE!" ) );
457
458 if( !code )
459 return;
460
461 m_gal->SetIsFill( aFilled );
462 m_gal->SetIsStroke( !aFilled );
464
465 switch( aItem->m_ShapeType )
466 {
467 case GBR_SPOT_CIRCLE:
468 {
469 int radius = code->m_Size.x >> 1;
470 VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
471
472 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
473 {
474 m_gal->DrawCircle( start, radius );
475 }
476 else // rectangular hole
477 {
478 if( code->m_Polygon.OutlineCount() == 0 )
479 code->ConvertShapeToPolygon( aItem );
480
481 drawPolygon( aItem, code->m_Polygon, aFilled, true );
482 }
483
484 break;
485 }
486
487 case GBR_SPOT_RECT:
488 {
489 VECTOR2I codeStart;
490 VECTOR2I aShapePos = aItem->m_Start;
491 codeStart.x = aShapePos.x - code->m_Size.x / 2;
492 codeStart.y = aShapePos.y - code->m_Size.y / 2;
493 VECTOR2I codeEnd = codeStart + code->m_Size;
494 codeStart = aItem->GetABPosition( codeStart );
495 codeEnd = aItem->GetABPosition( codeEnd );
496
497 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
498 {
499 m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
500 }
501 else
502 {
503 if( code->m_Polygon.OutlineCount() == 0 )
504 code->ConvertShapeToPolygon( aItem );
505
506 drawPolygon( aItem, code->m_Polygon, aFilled, true );
507 }
508 break;
509 }
510
511 case GBR_SPOT_OVAL:
512 {
513 int radius = 0;
514
515 VECTOR2I codeStart = aItem->m_Start;
516 VECTOR2I codeEnd = aItem->m_Start;
517
518 if( code->m_Size.x > code->m_Size.y ) // horizontal oval
519 {
520 int delta = (code->m_Size.x - code->m_Size.y) / 2;
521 codeStart.x -= delta;
522 codeEnd.x += delta;
523 radius = code->m_Size.y;
524 }
525 else // horizontal oval
526 {
527 int delta = (code->m_Size.y - code->m_Size.x) / 2;
528 codeStart.y -= delta;
529 codeEnd.y += delta;
530 radius = code->m_Size.x;
531 }
532
533 codeStart = aItem->GetABPosition( codeStart );
534 codeEnd = aItem->GetABPosition( codeEnd );
535
536 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
537 {
538 m_gal->DrawSegment( codeStart, codeEnd, radius );
539 }
540 else
541 {
542 if( code->m_Polygon.OutlineCount() == 0 )
543 code->ConvertShapeToPolygon( aItem );
544
545 drawPolygon( aItem, code->m_Polygon, aFilled, true );
546 }
547 break;
548 }
549
550 case GBR_SPOT_POLY:
551 if( code->m_Polygon.OutlineCount() == 0 )
552 code->ConvertShapeToPolygon( aItem );
553
554 drawPolygon( aItem, code->m_Polygon, aFilled, true );
555 break;
556
557 case GBR_SPOT_MACRO:
558 drawApertureMacro( aItem, aFilled );
559 break;
560
561 default:
562 wxASSERT_MSG( false, wxT( "Unknown Gerber flashed shape!" ) );
563 break;
564 }
565}
566
567
569{
570 if( aParent->m_AbsolutePolygon.OutlineCount() == 0 )
571 {
572 D_CODE* code = aParent->GetDcodeDescr();
573 APERTURE_MACRO* macro = code->GetMacro();
574 aParent->m_AbsolutePolygon = *macro->GetApertureMacroShape( aParent, aParent->m_Start );
575 }
576
577 SHAPE_POLY_SET& polyset = aParent->m_AbsolutePolygon;
578
579 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
581
582 if( !aFilled )
583 {
584 for( int i = 0; i < polyset.OutlineCount(); i++ )
585 m_gal->DrawPolyline( polyset.COutline( i ) );
586 }
587 else
588 {
589 m_gal->DrawPolygon( polyset );
590 }
591}
592
593
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE gerbIUScale
Definition: base_units.h:107
Support the "aperture macro" defined within standard RS274X.
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, const VECTOR2I &aShapePos)
Calculate the primitive shape for flashed items.
constexpr const Vec GetEnd() const
Definition: box2.h:212
constexpr const Vec & GetOrigin() const
Definition: box2.h:210
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:125
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
Definition: dcode.h:203
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:193
VECTOR2I m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:190
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
Definition: dcode.h:191
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition: dcode.h:195
SHAPE_POLY_SET m_Polygon
Definition: dcode.h:206
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition: dcode.cpp:297
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
bool IsSelected() const
Definition: eda_item.h:110
bool IsBrightened() const
Definition: eda_item.h:112
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
double m_OpacityModeAlphaValue
the alpha channel (opacity) value in opacity forced mode
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.
VECTOR2I GetABPosition(const VECTOR2I &aXYPosition) const
Return the image position of aPosition for this object.
SHAPE_POLY_SET m_ShapeAsPolygon
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.
GBR_BASIC_SHAPE_TYPE m_ShapeType
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:282
double a
Alpha component.
Definition: color4d.h:395
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:268
static const COLOR4D BLACK
Definition: color4d.h:402
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 DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aWidth, double aMaxError)
Draw an arc segment.
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 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:59
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:102
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
virtual void update()
Precalculates extra colors for layers (e.g.
COLOR4D m_layerColors[LAYER_ID_COUNT]
std::set< int > m_highContrastLayers
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:84
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
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 outline to the set and returns its index.
virtual 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)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition: vector2d.h:557
@ APT_DEF_NO_HOLE
Definition: dcode.h:61
@ APT_RECT
Definition: dcode.h:50
static constexpr EDA_ANGLE ANGLE_360
Definition: eda_angle.h:407
@ 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:436
@ GERBVIEW_LAYER_ID_START
Definition: layer_ids.h:426
@ LAYER_DCODES
Definition: layer_ids.h:431
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:432
@ GERBVIEW_LAYER_ID_END
Definition: layer_ids.h:439
bool IsDCodeLayer(int aLayer)
Definition: layer_ids.h:731
@ GAL_LAYER_ID_START
Definition: layer_ids.h:193
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:219
@ GAL_LAYER_ID_END
Definition: layer_ids.h:269
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:421
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
constexpr int delta
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER
@ GERBER_DRAW_ITEM_T
Definition: typeinfo.h:209
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
VECTOR2< double > VECTOR2D
Definition: vector2d.h:690