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 {
112 auto it = m_layerColors.find( LAYER_DCODES );
113 return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
114 }
115
116 if( item && item->IsSelected() )
117 {
118 auto it = m_layerColorsSel.find( aLayer );
119 return it == m_layerColorsSel.end() ? COLOR4D::WHITE : it->second;
120 }
121
122 if( gbrItem && gbrItem->GetLayerPolarity() )
123 {
125 {
126 auto it = m_layerColors.find( LAYER_NEGATIVE_OBJECTS );
127 return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
128 }
129 else
130 {
131 return transparent;
132 }
133 }
134
135 if( !m_netHighlightString.IsEmpty() && gbrItem &&
137 {
138 auto it = m_layerColorsHi.find( aLayer );
139 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
140 }
141
142 if( !m_componentHighlightString.IsEmpty() && gbrItem &&
144 {
145 auto it = m_layerColorsHi.find( aLayer );
146 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
147 }
148
149 if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() &&
151 {
152 auto it = m_layerColorsHi.find( aLayer );
153 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
154 }
155
156 if( m_dcodeHighlightValue> 0 && gbrItem && gbrItem->GetDcodeDescr() &&
158 {
159 auto it = m_layerColorsHi.find( aLayer );
160 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
161 }
162
163 // Return grayish color for non-highlighted layers in the high contrast mode
164 if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
165 {
166 auto it = m_hiContrastColor.find( aLayer );
167 return it == m_hiContrastColor.end() ? COLOR4D::WHITE.Darkened( 0.25 ) : it->second;
168 }
169
170 // Catch the case when highlight and high-contraste modes are enabled
171 // and we are drawing a not highlighted track
173 {
174 auto it = m_layerColorsDark.find( aLayer );
175 return it == m_layerColorsDark.end() ? COLOR4D::WHITE.Darkened( 0.5 ) : it->second;
176 }
177
178 // No special modificators enabled
179 auto it = m_layerColors.find( aLayer );
180 return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
181}
182
183
185{
187}
188
189
191 PAINTER( aGal )
192{
193}
194
195
196// TODO(JE): Pull up to PAINTER?
197int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
198{
199 // if items have 0 thickness, draw them with the outline width, otherwise respect the set
200 // value (which, no matter how small will produce something)
201 if( aActualThickness == 0 )
203
204 return aActualThickness;
205}
206
207
208bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
209{
210 GERBER_DRAW_ITEM* gbrItem = dynamic_cast<GERBER_DRAW_ITEM*>( const_cast<VIEW_ITEM*>( aItem ) );
211
212 if( gbrItem )
213 {
214 draw( gbrItem, aLayer );
215 return true;
216 }
217
218 return false;
219}
220
221
222// TODO(JE) aItem can't be const because of GetDcodeDescr()
223// Probably that can be refactored in GERBER_DRAW_ITEM to allow const here.
224void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
225{
226 VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) ); // TODO(JE) Getter
227 VECTOR2D end( aItem->GetABPosition( aItem->m_End ) ); // TODO(JE) Getter
228 int width = aItem->m_Size.x; // TODO(JE) Getter
229 bool isFilled = true;
231 // TODO(JE) This doesn't actually work properly for ImageNegative
232 bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative );
233
234 // Draw DCODE overlay text
235 if( IsDCodeLayer( aLayer ) )
236 {
237 wxString codeText;
238 VECTOR2I textPosition;
239 int textSize;
240 EDA_ANGLE orient;
241
242 if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
243 return;
244
245 color = m_gerbviewSettings.GetColor( aItem, aLayer );
246 codeText.Printf( wxT( "D%d" ), aItem->m_DCode );
247
248 m_gal->SetIsStroke( true );
249 m_gal->SetIsFill( false );
251 m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) );
252 m_gal->SetLineWidth( textSize/10 );
253 m_gal->SetFontBold( false );
254 m_gal->SetFontItalic( false );
255 m_gal->SetFontUnderlined( false );
256 m_gal->SetTextMirrored( false );
257 m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
260 m_gal->BitmapText( codeText, textPosition, orient );
261
262 return;
263 }
264
265 color = m_gerbviewSettings.GetColor( aItem, aLayer );
266
267 // TODO: Should brightened color be a preference?
268 if( aItem->IsBrightened() )
269 color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
270
274 m_gal->SetIsFill( isFilled );
275 m_gal->SetIsStroke( !isFilled );
276
277 switch( aItem->m_ShapeType )
278 {
279 case GBR_POLYGON:
280 {
282 m_gal->SetIsFill( isFilled );
283 m_gal->SetIsStroke( !isFilled );
284
285 if( isNegative && !isFilled )
286 {
287 m_gal->SetNegativeDrawMode( false );
288 m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
289 }
290
291 if( !isFilled )
293
294 if( aItem->m_AbsolutePolygon.OutlineCount() == 0 )
295 {
296 std::vector<VECTOR2I> pts = aItem->m_ShapeAsPolygon.COutline( 0 ).CPoints();
297
298 for( auto& pt : pts )
299 pt = aItem->GetABPosition( pt );
300
301 SHAPE_LINE_CHAIN chain( pts );
302 chain.SetClosed( true );
303 aItem->m_AbsolutePolygon.AddOutline( chain );
304 }
305
306 // Degenerated polygons (having < 3 points) are drawn as lines
307 // to avoid issues in draw polygon functions
308 if( !isFilled || aItem->m_AbsolutePolygon.COutline( 0 ).PointCount() < 3 )
310 else
311 {
312 // On Opengl, a not convex filled polygon is usually drawn by using triangles as
313 // primitives. CacheTriangulation() can create basic triangle primitives to draw the
314 // polygon solid shape on Opengl
315 // We use the fastest CacheTriangulation calculation mode: no partition created because
316 // the partition is useless in Gerbview, and very time consumming (optimized only
317 // for pcbnew that has different internal unit)
319 aItem->m_AbsolutePolygon.CacheTriangulation( false /* fastest triangulation calculation mode */ );
320
322 }
323
324 break;
325 }
326
327 case GBR_CIRCLE:
328 {
330 double radius = aItem->m_Start.Distance( aItem->m_End );
331 m_gal->DrawCircle( start, radius );
332 break;
333 }
334
335 case GBR_ARC:
336 {
338
339 // These are swapped because wxDC fills arcs counterclockwise and GAL
340 // fills them clockwise.
341 VECTOR2I arcStart = aItem->m_End;
342 VECTOR2I arcEnd = aItem->m_Start;
343
344 // Gerber arcs are 3-point (start, center, end)
345 // GAL needs center, radius, start angle, end angle
346 double radius = arcStart.Distance( aItem->m_ArcCentre );
347 VECTOR2D center = aItem->GetABPosition( aItem->m_ArcCentre );
348 VECTOR2D startVec = VECTOR2D( aItem->GetABPosition( arcStart ) ) - center;
349 VECTOR2D endVec = VECTOR2D( aItem->GetABPosition( arcEnd ) ) - center;
350
351 m_gal->SetIsFill( isFilled );
352 m_gal->SetIsStroke( !isFilled );
354
355 EDA_ANGLE startAngle( startVec );
356 EDA_ANGLE endAngle( endVec );
357
358 // GAL fills in direction of increasing angle, so we have to convert
359 // the angle from the -PI to PI domain of atan2() to ensure that
360 // the arc goes in the right direction
361 if( startAngle > endAngle )
362 endAngle += ANGLE_360;
363
364 // In Gerber, 360-degree arcs are stored in the file with start equal to end
365 if( arcStart == arcEnd )
366 endAngle = startAngle + ANGLE_360;
367
368 // Adjust the allowed approx error to convert arcs to segments:
369 int arc_to_seg_error = gerbIUScale.mmToIU( 0.005 ); // Allow 5 microns
370 m_gal->DrawArcSegment( center, radius, startAngle, endAngle - startAngle, width,
371 arc_to_seg_error );
372
373#if 0 // Arc Debugging only
374 m_gal->SetIsFill( false );
375 m_gal->SetIsStroke( true );
376 m_gal->SetLineWidth( 5 );
377 m_gal->SetStrokeColor( COLOR4D( 0.1, 0.5, 0.0, 0.5 ) );
378 m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) );
379 m_gal->SetStrokeColor( COLOR4D( 0.6, 0.1, 0.0, 0.5 ) );
380 m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) );
381#endif
382
383#if 0 // Bbox arc Debugging only
384 m_gal->SetIsFill( false );
385 m_gal->SetIsStroke( true );
386 BOX2I box = aItem->GetBoundingBox();
387 m_gal->SetLineWidth( 5 );
388 m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
389 // box coordinates are already in AB position.
390 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
391#endif
392 break;
393 }
394
395 case GBR_SPOT_CIRCLE:
396 case GBR_SPOT_RECT:
397 case GBR_SPOT_OVAL:
398 case GBR_SPOT_POLY:
399 case GBR_SPOT_MACRO:
401 drawFlashedShape( aItem, isFilled );
402 break;
403
404 case GBR_SEGMENT:
405 {
406 /* Plot a line from m_Start to m_End.
407 * Usually, a round pen is used, but some gerber files use a rectangular pen
408 * In fact, any aperture can be used to plot a line.
409 * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
410 */
412 m_gal->SetIsFill( isFilled );
413 m_gal->SetIsStroke( !isFilled );
414
415 if( isNegative && !isFilled )
416 m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
417
418 // TODO(JE) Refactor this to allow const aItem
419 D_CODE* code = aItem->GetDcodeDescr();
420 if( code && code->m_ApertType == APT_RECT )
421 {
422 if( aItem->m_ShapeAsPolygon.OutlineCount() == 0 )
424
425 drawPolygon( aItem, aItem->m_ShapeAsPolygon, isFilled );
426 }
427 else
428 {
429 if( !isFilled )
431
432 m_gal->DrawSegment( start, end, width );
433 }
434 break;
435 }
436
437 default:
438 wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
439 break;
440 }
441 m_gal->SetNegativeDrawMode( false );
442
443 // Enable for bounding box debugging
444 #if 0
445 const BOX2I& bb = aItem->ViewBBox();
446 m_gal->SetIsStroke( true );
447 m_gal->SetIsFill( true );
448 m_gal->SetLineWidth( 3 );
449 m_gal->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
450 m_gal->SetFillColor( COLOR4D(0.9, 0.9, 0, 0.1) );
451 m_gal->DrawRectangle( bb.GetOrigin(), bb.GetEnd() );
452 #endif
453}
454
455
457 bool aFilled, bool aShift )
458{
459 wxASSERT( aPolygon.OutlineCount() == 1 );
460
461 if( aPolygon.OutlineCount() == 0 )
462 return;
463
464 SHAPE_POLY_SET poly;
465 poly.NewOutline();
466 const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
467 VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
468
469 for( const VECTOR2I& pt : pts )
470 poly.Append( aParent->GetABPosition( pt + offset ) );
471
472 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
474
475 if( !aFilled )
476 m_gal->DrawPolyline( poly.COutline( 0 ) );
477 else
478 m_gal->DrawPolygon( poly );
479}
480
481
483{
484 D_CODE* code = aItem->GetDcodeDescr();
485
486 wxASSERT_MSG( code, wxT( "drawFlashedShape: Item has no D_CODE!" ) );
487
488 if( !code )
489 return;
490
491 m_gal->SetIsFill( aFilled );
492 m_gal->SetIsStroke( !aFilled );
494
495 switch( aItem->m_ShapeType )
496 {
497 case GBR_SPOT_CIRCLE:
498 {
499 int radius = code->m_Size.x >> 1;
500 VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
501
502 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
503 {
504 m_gal->DrawCircle( start, radius );
505 }
506 else // rectangular hole
507 {
508 if( code->m_Polygon.OutlineCount() == 0 )
509 code->ConvertShapeToPolygon( aItem );
510
511 drawPolygon( aItem, code->m_Polygon, aFilled, true );
512 }
513
514 break;
515 }
516
517 case GBR_SPOT_RECT:
518 {
519 VECTOR2I codeStart;
520 VECTOR2I aShapePos = aItem->m_Start;
521 codeStart.x = aShapePos.x - code->m_Size.x / 2;
522 codeStart.y = aShapePos.y - code->m_Size.y / 2;
523 VECTOR2I codeEnd = codeStart + code->m_Size;
524 codeStart = aItem->GetABPosition( codeStart );
525 codeEnd = aItem->GetABPosition( codeEnd );
526
527 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
528 {
529 m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
530 }
531 else
532 {
533 if( code->m_Polygon.OutlineCount() == 0 )
534 code->ConvertShapeToPolygon( aItem );
535
536 drawPolygon( aItem, code->m_Polygon, aFilled, true );
537 }
538 break;
539 }
540
541 case GBR_SPOT_OVAL:
542 {
543 int radius = 0;
544
545 VECTOR2I codeStart = aItem->m_Start;
546 VECTOR2I codeEnd = aItem->m_Start;
547
548 if( code->m_Size.x > code->m_Size.y ) // horizontal oval
549 {
550 int delta = (code->m_Size.x - code->m_Size.y) / 2;
551 codeStart.x -= delta;
552 codeEnd.x += delta;
553 radius = code->m_Size.y;
554 }
555 else // horizontal oval
556 {
557 int delta = (code->m_Size.y - code->m_Size.x) / 2;
558 codeStart.y -= delta;
559 codeEnd.y += delta;
560 radius = code->m_Size.x;
561 }
562
563 codeStart = aItem->GetABPosition( codeStart );
564 codeEnd = aItem->GetABPosition( codeEnd );
565
566 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
567 {
568 m_gal->DrawSegment( codeStart, codeEnd, radius );
569 }
570 else
571 {
572 if( code->m_Polygon.OutlineCount() == 0 )
573 code->ConvertShapeToPolygon( aItem );
574
575 drawPolygon( aItem, code->m_Polygon, aFilled, true );
576 }
577 break;
578 }
579
580 case GBR_SPOT_POLY:
581 if( code->m_Polygon.OutlineCount() == 0 )
582 code->ConvertShapeToPolygon( aItem );
583
584 drawPolygon( aItem, code->m_Polygon, aFilled, true );
585 break;
586
587 case GBR_SPOT_MACRO:
588 drawApertureMacro( aItem, aFilled );
589 break;
590
591 default:
592 wxASSERT_MSG( false, wxT( "Unknown Gerber flashed shape!" ) );
593 break;
594 }
595}
596
597
599{
600 if( aParent->m_AbsolutePolygon.OutlineCount() == 0 )
601 {
602 D_CODE* code = aParent->GetDcodeDescr();
603 APERTURE_MACRO* macro = code->GetMacro();
604 aParent->m_AbsolutePolygon = *macro->GetApertureMacroShape( aParent, aParent->m_Start );
605 }
606
607 SHAPE_POLY_SET& polyset = aParent->m_AbsolutePolygon;
608
609 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
611
612 if( !aFilled )
613 {
614 for( int i = 0; i < polyset.OutlineCount(); i++ )
615 m_gal->DrawPolyline( polyset.COutline( i ) );
616 }
617 else
618 {
619 m_gal->DrawPolygon( polyset );
620 }
621}
622
623
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
static const COLOR4D WHITE
Definition: color4d.h:401
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
std::map< int, COLOR4D > m_layerColorsHi
virtual void update()
Precalculates extra colors for layers (e.g.
std::map< int, COLOR4D > m_hiContrastColor
std::map< int, COLOR4D > m_layerColorsDark
std::map< int, COLOR4D > m_layerColorsSel
std::set< int > m_highContrastLayers
std::map< int, COLOR4D > m_layerColors
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(const wxString &aFilename)
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:435
@ GERBVIEW_LAYER_ID_START
Definition: layer_ids.h:425
@ LAYER_DCODES
Definition: layer_ids.h:430
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:431
@ GERBVIEW_LAYER_ID_END
Definition: layer_ids.h:438
bool IsDCodeLayer(int aLayer)
Definition: layer_ids.h:733
@ GAL_LAYER_ID_START
Definition: layer_ids.h:192
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:218
@ GAL_LAYER_ID_END
Definition: layer_ids.h:268
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:420
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