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 The 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
18 * along with this program. If not, see <https://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
42
43
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
110 && !GetLayerIsHighContrast( aLayer ) )
111 {
112 return transparent;
113 }
114
115 // All DCODE layers stored under a single color setting
116 if( IsDCodeLayer( aLayer ) )
117 {
118 auto it = m_layerColors.find( LAYER_DCODES );
119 return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
120 }
121
122 if( item && item->IsSelected() )
123 {
124 auto it = m_layerColorsSel.find( aLayer );
125 return it == m_layerColorsSel.end() ? COLOR4D::WHITE : it->second;
126 }
127
128 if( gbrItem && gbrItem->GetLayerPolarity() )
129 {
130 if( gvconfig()->m_Appearance.show_negative_objects )
131 {
132 auto it = m_layerColors.find( LAYER_NEGATIVE_OBJECTS );
133 return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
134 }
135 else
136 {
137 return transparent;
138 }
139 }
140
141 if( !m_netHighlightString.IsEmpty() && gbrItem &&
143 {
144 auto it = m_layerColorsHi.find( aLayer );
145 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
146 }
147
148 if( !m_componentHighlightString.IsEmpty() && gbrItem &&
150 {
151 auto it = m_layerColorsHi.find( aLayer );
152 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
153 }
154
155 if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() &&
157 {
158 auto it = m_layerColorsHi.find( aLayer );
159 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
160 }
161
162 if( m_dcodeHighlightValue> 0 && gbrItem && gbrItem->GetDcodeDescr() &&
164 {
165 auto it = m_layerColorsHi.find( aLayer );
166 return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
167 }
168
169 // Return grayish color for non-highlighted layers in the high contrast mode
170 if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
171 {
172 auto it = m_hiContrastColor.find( aLayer );
173 return it == m_hiContrastColor.end() ? COLOR4D::WHITE.Darkened( 0.25 ) : it->second;
174 }
175
176 // Catch the case when highlight and high-contraste modes are enabled
177 // and we are drawing a not highlighted track
179 {
180 auto it = m_layerColorsDark.find( aLayer );
181 return it == m_layerColorsDark.end() ? COLOR4D::WHITE.Darkened( 0.5 ) : it->second;
182 }
183
184 // No special modificators enabled
185 auto it = m_layerColors.find( aLayer );
186 return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
187}
188
189
194
195
197 PAINTER( aGal )
198{
199}
200
201
202// TODO(JE): Pull up to PAINTER?
203int GERBVIEW_PAINTER::getLineThickness( int aActualThickness ) const
204{
205 // if items have 0 thickness, draw them with the outline width, otherwise respect the set
206 // value (which, no matter how small will produce something)
207 if( aActualThickness == 0 )
208 return m_gerbviewSettings.m_outlineWidth;
209
210 return aActualThickness;
211}
212
213
214bool GERBVIEW_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
215{
216 GERBER_DRAW_ITEM* gbrItem = dynamic_cast<GERBER_DRAW_ITEM*>( const_cast<VIEW_ITEM*>( aItem ) );
217
218 if( gbrItem )
219 {
220 draw( gbrItem, aLayer );
221 return true;
222 }
223
224 return false;
225}
226
227
228// TODO(JE) aItem can't be const because of GetDcodeDescr()
229// Probably that can be refactored in GERBER_DRAW_ITEM to allow const here.
230void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
231{
233 && !m_gerbviewSettings.GetLayerIsHighContrast( aLayer ) )
234 {
235 return;
236 }
237
238 VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) ); // TODO(JE) Getter
239 VECTOR2D end( aItem->GetABPosition( aItem->m_End ) ); // TODO(JE) Getter
240 int width = aItem->m_Size.x; // TODO(JE) Getter
241 bool isFilled = true;
242 COLOR4D color;
243 // TODO(JE) This doesn't actually work properly for ImageNegative
244 bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative );
245
246 // Draw DCODE overlay text
247 if( IsDCodeLayer( aLayer ) )
248 {
249 wxString codeText;
250 VECTOR2I textPosition;
251 int textSize;
252 EDA_ANGLE orient;
253
254 if( !aItem->GetTextD_CodePrms( textSize, textPosition, orient ) )
255 return;
256
257 color = m_gerbviewSettings.GetColor( aItem, aLayer );
258 codeText.Printf( wxT( "D%d" ), aItem->m_DCode );
259
260 m_gal->SetIsStroke( true );
261 m_gal->SetIsFill( false );
262 m_gal->SetStrokeColor( color );
263 m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) );
264 m_gal->SetLineWidth( textSize/10 );
265 m_gal->SetFontBold( false );
266 m_gal->SetFontItalic( false );
267 m_gal->SetFontUnderlined( false );
268 m_gal->SetTextMirrored( false );
269 m_gal->SetGlyphSize( VECTOR2D( textSize, textSize) );
270 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
271 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
272 m_gal->BitmapText( codeText, textPosition, orient );
273
274 return;
275 }
276
277 color = m_gerbviewSettings.GetColor( aItem, aLayer );
278
279 // TODO: Should brightened color be a preference?
280 if( aItem->IsBrightened() )
281 color = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
282
283 m_gal->SetNegativeDrawMode( isNegative && !gvconfig()->m_Appearance.show_negative_objects );
284 m_gal->SetStrokeColor( color );
285 m_gal->SetFillColor( color );
286 m_gal->SetIsFill( isFilled );
287 m_gal->SetIsStroke( !isFilled );
288
289 switch( aItem->m_ShapeType )
290 {
291 case GBR_POLYGON:
292 {
294 m_gal->SetIsFill( isFilled );
295 m_gal->SetIsStroke( !isFilled );
296
297 if( isNegative && !isFilled )
298 {
299 m_gal->SetNegativeDrawMode( false );
300 m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
301 }
302
303 if( !isFilled )
304 m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
305
306 if( aItem->m_AbsolutePolygon.OutlineCount() == 0 )
307 {
308 std::vector<VECTOR2I> pts = aItem->m_ShapeAsPolygon.COutline( 0 ).CPoints();
309
310 for( auto& pt : pts )
311 pt = aItem->GetABPosition( pt );
312
313 SHAPE_LINE_CHAIN chain( pts );
314 chain.SetClosed( true );
316 }
317
318 // Degenerated polygons (having < 3 points) are drawn as lines
319 // to avoid issues in draw polygon functions
320 if( !isFilled || aItem->m_AbsolutePolygon.COutline( 0 ).PointCount() < 3 )
321 m_gal->DrawPolyline( aItem->m_AbsolutePolygon.COutline( 0 ) );
322 else
323 {
324 // On Opengl, a not convex filled polygon is usually drawn by using triangles as
325 // primitives. CacheTriangulation() can create basic triangle primitives to draw the
326 // polygon solid shape on Opengl
327 // We use the fastest CacheTriangulation calculation mode: no partition created because
328 // the partition is useless in Gerbview, and very time consumming (optimized only
329 // for pcbnew that has different internal unit)
330 if( m_gal->IsOpenGlEngine() && !aItem->m_AbsolutePolygon.IsTriangulationUpToDate() )
331 aItem->m_AbsolutePolygon.CacheTriangulation( false /* fastest triangulation calculation mode */ );
332
333 m_gal->DrawPolygon( aItem->m_AbsolutePolygon );
334 }
335
336 break;
337 }
338
339 case GBR_CIRCLE:
340 {
342 double radius = aItem->m_Start.Distance( aItem->m_End );
343 m_gal->DrawCircle( start, radius );
344 break;
345 }
346
347 case GBR_ARC:
348 {
350
351 // These are swapped because wxDC fills arcs counterclockwise and GAL
352 // fills them clockwise.
353 VECTOR2I arcStart = aItem->m_End;
354 VECTOR2I arcEnd = aItem->m_Start;
355
356 // Gerber arcs are 3-point (start, center, end)
357 // GAL needs center, radius, start angle, end angle
358 double radius = arcStart.Distance( aItem->m_ArcCentre );
359 VECTOR2D center = aItem->GetABPosition( aItem->m_ArcCentre );
360 VECTOR2D startVec = VECTOR2D( aItem->GetABPosition( arcStart ) ) - center;
361 VECTOR2D endVec = VECTOR2D( aItem->GetABPosition( arcEnd ) ) - center;
362
363 m_gal->SetIsFill( isFilled );
364 m_gal->SetIsStroke( !isFilled );
365 m_gal->SetLineWidth( isFilled ? width : m_gerbviewSettings.m_outlineWidth );
366
367 EDA_ANGLE startAngle( startVec );
368 EDA_ANGLE endAngle( endVec );
369
370 // GAL fills in direction of increasing angle, so we have to convert
371 // the angle from the -PI to PI domain of atan2() to ensure that
372 // the arc goes in the right direction
373 if( startAngle > endAngle )
374 endAngle += ANGLE_360;
375
376 // In Gerber, 360-degree arcs are stored in the file with start equal to end
377 if( arcStart == arcEnd )
378 endAngle = startAngle + ANGLE_360;
379
380 // Adjust the allowed approx error to convert arcs to segments:
381 int arc_to_seg_error = gerbIUScale.mmToIU( 0.005 ); // Allow 5 microns
382 m_gal->DrawArcSegment( center, radius, startAngle, endAngle - startAngle, width,
383 arc_to_seg_error );
384
385#if 0 // Arc Debugging only
386 m_canvas->SetIsFill( false );
387 m_canvas->SetIsStroke( true );
388 m_canvas->SetLineWidth( 5 );
389 m_canvas->SetStrokeColor( COLOR4D( 0.1, 0.5, 0.0, 0.5 ) );
390 m_canvas->DrawLine( center, aItem->GetABPosition( arcStart ) );
391 m_canvas->SetStrokeColor( COLOR4D( 0.6, 0.1, 0.0, 0.5 ) );
392 m_canvas->DrawLine( center, aItem->GetABPosition( arcEnd ) );
393#endif
394
395#if 0 // Bbox arc Debugging only
396 m_canvas->SetIsFill( false );
397 m_canvas->SetIsStroke( true );
398 BOX2I box = aItem->GetBoundingBox();
399 m_canvas->SetLineWidth( 5 );
400 m_canvas->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
401 // box coordinates are already in AB position.
402 m_canvas->DrawRectangle( box.GetOrigin(), box.GetEnd() );
403#endif
404 break;
405 }
406
407 case GBR_SPOT_CIRCLE:
408 case GBR_SPOT_RECT:
409 case GBR_SPOT_OVAL:
410 case GBR_SPOT_POLY:
411 case GBR_SPOT_MACRO:
413 drawFlashedShape( aItem, isFilled );
414 break;
415
416 case GBR_SEGMENT:
417 {
418 /* Plot a line from m_Start to m_End.
419 * Usually, a round pen is used, but some gerber files use a rectangular pen
420 * In fact, any aperture can be used to plot a line.
421 * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
422 */
424 m_gal->SetIsFill( isFilled );
425 m_gal->SetIsStroke( !isFilled );
426
427 if( isNegative && !isFilled )
428 m_gal->SetStrokeColor( GetSettings()->GetColor( aItem, aLayer ) );
429
430 // TODO(JE) Refactor this to allow const aItem
431 D_CODE* code = aItem->GetDcodeDescr();
432 if( code && code->m_ApertType == APT_RECT )
433 {
434 if( aItem->m_ShapeAsPolygon.OutlineCount() == 0 )
436
437 drawPolygon( aItem, aItem->m_ShapeAsPolygon, isFilled );
438 }
439 else
440 {
441 if( !isFilled )
442 m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
443
444 m_gal->DrawSegment( start, end, width );
445 }
446 break;
447 }
448
449 default:
450 wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
451 break;
452 }
453 m_gal->SetNegativeDrawMode( false );
454
455 // Enable for bounding box debugging
456 #if 0
457 const BOX2I& bb = aItem->ViewBBox();
458 m_canvas->SetIsStroke( true );
459 m_canvas->SetIsFill( true );
460 m_canvas->SetLineWidth( 3 );
461 m_canvas->SetStrokeColor( COLOR4D(0.9, 0.9, 0, 0.4) );
462 m_canvas->SetFillColor( COLOR4D(0.9, 0.9, 0, 0.1) );
463 m_canvas->DrawRectangle( bb.GetOrigin(), bb.GetEnd() );
464 #endif
465}
466
467
469 bool aFilled, bool aShift )
470{
471 wxASSERT( aPolygon.OutlineCount() == 1 );
472
473 if( aPolygon.OutlineCount() == 0 )
474 return;
475
476 SHAPE_POLY_SET poly;
477 poly.NewOutline();
478 const std::vector<VECTOR2I> pts = aPolygon.COutline( 0 ).CPoints();
479 VECTOR2I offset = aShift ? VECTOR2I( aParent->m_Start ) : VECTOR2I( 0, 0 );
480
481 for( const VECTOR2I& pt : pts )
482 poly.Append( aParent->GetABPosition( pt + offset ) );
483
484 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
485 m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
486
487 if( !aFilled )
488 m_gal->DrawPolyline( poly.COutline( 0 ) );
489 else
490 m_gal->DrawPolygon( poly );
491}
492
493
495{
496 D_CODE* code = aItem->GetDcodeDescr();
497
498 if( !code )
499 {
500 wxLogDebug( wxT( "drawFlashedShape: Item has no D_CODE" ) );
501 return;
502 }
503
504 m_gal->SetIsFill( aFilled );
505 m_gal->SetIsStroke( !aFilled );
506 m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
507
508 switch( aItem->m_ShapeType )
509 {
510 case GBR_SPOT_CIRCLE:
511 {
512 int radius = code->m_Size.x >> 1;
513 VECTOR2D start( aItem->GetABPosition( aItem->m_Start ) );
514
515 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
516 {
517 m_gal->DrawCircle( start, radius );
518 }
519 else // rectangular hole
520 {
521 if( code->m_Polygon.OutlineCount() == 0 )
522 code->ConvertShapeToPolygon( aItem );
523
524 drawPolygon( aItem, code->m_Polygon, aFilled, true );
525 }
526
527 break;
528 }
529
530 case GBR_SPOT_RECT:
531 {
532 VECTOR2I codeStart;
533 VECTOR2I aShapePos = aItem->m_Start;
534 codeStart.x = aShapePos.x - code->m_Size.x / 2;
535 codeStart.y = aShapePos.y - code->m_Size.y / 2;
536 VECTOR2I codeEnd = codeStart + code->m_Size;
537 codeStart = aItem->GetABPosition( codeStart );
538 codeEnd = aItem->GetABPosition( codeEnd );
539
540 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
541 {
542 m_gal->DrawRectangle( VECTOR2D( codeStart ), VECTOR2D( codeEnd ) );
543 }
544 else
545 {
546 if( code->m_Polygon.OutlineCount() == 0 )
547 code->ConvertShapeToPolygon( aItem );
548
549 drawPolygon( aItem, code->m_Polygon, aFilled, true );
550 }
551 break;
552 }
553
554 case GBR_SPOT_OVAL:
555 {
556 int radius = 0;
557
558 VECTOR2I codeStart = aItem->m_Start;
559 VECTOR2I codeEnd = aItem->m_Start;
560
561 if( code->m_Size.x > code->m_Size.y ) // horizontal oval
562 {
563 int delta = (code->m_Size.x - code->m_Size.y) / 2;
564 codeStart.x -= delta;
565 codeEnd.x += delta;
566 radius = code->m_Size.y;
567 }
568 else // horizontal oval
569 {
570 int delta = (code->m_Size.y - code->m_Size.x) / 2;
571 codeStart.y -= delta;
572 codeEnd.y += delta;
573 radius = code->m_Size.x;
574 }
575
576 codeStart = aItem->GetABPosition( codeStart );
577 codeEnd = aItem->GetABPosition( codeEnd );
578
579 if( !aFilled || code->m_DrillShape == APT_DEF_NO_HOLE )
580 {
581 m_gal->DrawSegment( codeStart, codeEnd, radius );
582 }
583 else
584 {
585 if( code->m_Polygon.OutlineCount() == 0 )
586 code->ConvertShapeToPolygon( aItem );
587
588 drawPolygon( aItem, code->m_Polygon, aFilled, true );
589 }
590 break;
591 }
592
593 case GBR_SPOT_POLY:
594 if( code->m_Polygon.OutlineCount() == 0 )
595 code->ConvertShapeToPolygon( aItem );
596
597 drawPolygon( aItem, code->m_Polygon, aFilled, true );
598 break;
599
600 case GBR_SPOT_MACRO:
601 drawApertureMacro( aItem, aFilled );
602 break;
603
604 default:
605 wxASSERT_MSG( false, wxT( "Unknown Gerber flashed shape!" ) );
606 break;
607 }
608}
609
610
612{
613 if( aParent->m_AbsolutePolygon.OutlineCount() == 0 )
614 {
615 D_CODE* code = aParent->GetDcodeDescr();
616 APERTURE_MACRO* macro = code->GetMacro();
617 aParent->m_AbsolutePolygon = *macro->GetApertureMacroShape( aParent, aParent->m_Start );
618 }
619
620 SHAPE_POLY_SET& polyset = aParent->m_AbsolutePolygon;
621
622 if( !gvconfig()->m_Display.m_DisplayPolygonsFill )
623 m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
624
625 if( !aFilled )
626 {
627 for( int i = 0; i < polyset.OutlineCount(); i++ )
628 m_gal->DrawPolyline( polyset.COutline( i ) );
629 }
630 else
631 {
632 m_gal->DrawPolygon( polyset );
633 }
634}
635
636
637const double GERBVIEW_RENDER_SETTINGS::MAX_FONT_SIZE = gerbIUScale.mmToIU( 10.0 );
constexpr EDA_IU_SCALE gerbIUScale
Definition base_units.h:127
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
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:209
constexpr const Vec & GetOrigin() const
Definition box2.h:207
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:76
APERTURE_MACRO * GetMacro() const
Definition dcode.h:132
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
Definition dcode.h:210
int m_Num_Dcode
D code value ( >= 10 )
Definition dcode.h:200
VECTOR2I m_Size
Horizontal and vertical dimensions.
Definition dcode.h:197
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
Definition dcode.h:198
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2).
Definition dcode.h:202
SHAPE_POLY_SET m_Polygon
Definition dcode.h:213
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
Definition dcode.cpp:288
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
bool IsSelected() const
Definition eda_item.h:134
bool IsBrightened() const
Definition eda_item.h:136
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 lines in m_ShapeAsPolygon 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
Return the bounding box of the item covering all its layers.
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:101
COLOR4D Darkened(double aFactor) const
Return a color that is darker by a given factor, without modifying object.
Definition color4d.h:279
static const COLOR4D WHITE
Definition color4d.h:403
double a
Alpha component.
Definition color4d.h:394
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition color4d.h:265
static const COLOR4D BLACK
Definition color4d.h:404
Abstract interface for drawing on a 2D-surface.
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)
GBR_INACTIVE_LAYER_MODE m_contrastMode
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
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition painter.h:104
PAINTER(GAL *aGal)
Initialize this object for painting on any of the polymorphic GRAPHICS_ABSTRACTION_LAYER* derivatives...
Definition painter.cpp:29
std::map< int, COLOR4D > m_layerColorsHi
virtual void update()
Precalculates extra colors for layers (e.g.
std::map< int, COLOR4D > m_hiContrastColor
bool GetLayerIsHighContrast(int aLayerId) const
Return information whether the queried layer is marked as high-contrast.
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:82
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
T * GetAppSettings(const char *aFilename)
Return a handle to the a given settings by type.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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.
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)
virtual void CacheTriangulation(bool aSimplify=false, const TASK_SUBMITTER &aSubmitter={})
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
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:574
@ APT_DEF_NO_HOLE
Definition dcode.h:57
@ APT_RECT
Definition dcode.h:46
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:454
@ 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:556
@ GERBVIEW_LAYER_ID_START
Definition layer_ids.h:546
@ LAYER_DCODES
Definition layer_ids.h:551
@ LAYER_NEGATIVE_OBJECTS
Definition layer_ids.h:552
@ GERBVIEW_LAYER_ID_END
Definition layer_ids.h:559
bool IsDCodeLayer(int aLayer)
Definition layer_ids.h:937
@ GAL_LAYER_ID_START
Definition layer_ids.h:225
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition layer_ids.h:274
@ GAL_LAYER_ID_END
Definition layer_ids.h:379
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
Definition layer_ids.h:541
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
VECTOR2I center
const SHAPE_LINE_CHAIN chain
int radius
VECTOR2I end
int delta
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER
@ GERBER_DRAW_ITEM_T
Definition typeinfo.h:206
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707