KiCad PCB EDA Suite
pcb_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) 2013-2019 CERN
5 * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
8 * @author Maciej Suminski <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
28#include <board.h>
30#include <pcb_track.h>
31#include <pcb_group.h>
32#include <footprint.h>
33#include <fp_textbox.h>
34#include <pad.h>
35#include <pcb_shape.h>
36#include <string_utils.h>
37#include <zone.h>
38#include <pcb_bitmap.h>
39#include <pcb_text.h>
40#include <pcb_textbox.h>
41#include <pcb_marker.h>
42#include <pcb_dimension.h>
43#include <pcb_target.h>
44
45#include <layer_ids.h>
46#include <pcb_painter.h>
47#include <pcb_display_options.h>
53#include <pcbnew_settings.h>
54
57#include <callback_gal.h>
60#include <geometry/shape_rect.h>
64#include <bezier_curves.h>
65#include <kiface_base.h>
66#include <gr_text.h>
67#include <pgm_base.h>
68
69using namespace KIGFX;
70
71
73{
74 return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
75}
76
77// Helpers for display options existing in Cvpcb and Pcbnew
78// Note, when running Cvpcb, pcbconfig() returns nullptr and viewer_settings()
79// returns the viewer options existing to Cvpcb and Pcbnew
80PCB_VIEWERS_SETTINGS_BASE* PCB_PAINTER::viewer_settings()
81{
82 switch( m_frameType )
83 {
88 default:
89 return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
90
94 case FRAME_CVPCB:
96 return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
97 }
98}
99
100
102{
103 m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
107
108 m_trackOpacity = 1.0;
109 m_viaOpacity = 1.0;
110 m_padOpacity = 1.0;
111 m_zoneOpacity = 1.0;
112 m_imageOpacity = 1.0;
113
116
117 SetDashLengthRatio( 12 ); // From ISO 128-2
118 SetGapLengthRatio( 3 ); // From ISO 128-2
119
120 update();
121}
122
123
125{
127
128 // Init board layers colors:
129 for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
130 {
131 m_layerColors[i] = aSettings->GetColor( i );
132
133 // Guard: if the alpha channel is too small, the layer is not visible.
134 if( m_layerColors[i].a < 0.2 )
135 m_layerColors[i].a = 0.2;
136 }
137
138 // Init specific graphic layers colors:
139 for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
140 m_layerColors[i] = aSettings->GetColor( i );
141
142 // Colors for layers that aren't theme-able
144 m_layerColors[LAYER_VIA_NETNAMES] = COLOR4D( 0.2, 0.2, 0.2, 0.9 );
145 m_layerColors[LAYER_PAD_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
146 m_layerColors[LAYER_PAD_FR] = aSettings->GetColor( F_Cu );
147 m_layerColors[LAYER_PAD_BK] = aSettings->GetColor( B_Cu );
148 m_layerColors[LAYER_PAD_FR_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
149 m_layerColors[LAYER_PAD_BK_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
150
151 // Netnames for copper layers
152 for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
153 {
154 const COLOR4D lightLabel( 1.0, 1.0, 1.0, 0.7 );
155 const COLOR4D darkLabel = lightLabel.Inverted();
156 PCB_LAYER_ID layer = *cu;
157
158 if( m_layerColors[layer].GetBrightness() > 0.5 )
159 m_layerColors[GetNetnameLayer( layer )] = darkLabel;
160 else
161 m_layerColors[GetNetnameLayer( layer )] = lightLabel;
162 }
163
164 if( PgmOrNull() ) // can be null if used without project (i.e. from python script)
165 m_hiContrastFactor = 1.0f - Pgm().GetCommonSettings()->m_Appearance.hicontrast_dimming_factor;
166 else
167 m_hiContrastFactor = 1.0f - 0.8f; // default value
168
169 update();
170}
171
172
174{
179
181 m_viaOpacity = aOptions.m_ViaOpacity;
182 m_padOpacity = aOptions.m_PadOpacity;
183 m_zoneOpacity = aOptions.m_ZoneOpacity;
185}
186
187
188COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
189{
190 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
191 const BOARD_CONNECTED_ITEM* conItem = dynamic_cast<const BOARD_CONNECTED_ITEM*> ( aItem );
192 int netCode = -1;
193 int originalLayer = aLayer;
194
195 // Marker shadows
196 if( aLayer == LAYER_MARKER_SHADOWS )
197 return m_backgroundColor.WithAlpha( 0.6 );
198
199 if( IsHoleLayer( aLayer ) && m_isPrinting )
200 {
201 // Careful that we don't end up with the same colour for the annular ring and the hole
202 // when printing in B&W.
203 const PAD* pad = dynamic_cast<const PAD*>( item );
204 const PCB_VIA* via = dynamic_cast<const PCB_VIA*>( item );
205 int holeLayer = aLayer;
206 int annularRingLayer = UNDEFINED_LAYER;
207
208 if( pad && pad->GetAttribute() == PAD_ATTRIB::PTH )
209 annularRingLayer = LAYER_PADS_TH;
210 else if( via && via->GetViaType() == VIATYPE::MICROVIA )
211 annularRingLayer = LAYER_VIA_MICROVIA;
212 else if( via && via->GetViaType() == VIATYPE::BLIND_BURIED )
213 annularRingLayer = LAYER_VIA_BBLIND;
214 else if( via && via->GetViaType() == VIATYPE::THROUGH )
215 annularRingLayer = LAYER_VIA_THROUGH;
216
217 if( annularRingLayer != UNDEFINED_LAYER
218 && m_layerColors[ holeLayer ] == m_layerColors[ annularRingLayer ] )
219 {
220 aLayer = LAYER_PCB_BACKGROUND;
221 }
222 }
223
224 // Zones should pull from the copper layer
225 if( item && ( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ) )
226 {
227 if( IsZoneFillLayer( aLayer ) )
228 aLayer = aLayer - LAYER_ZONE_START;
229 }
230
231 // Hole walls should pull from the copper layer
232 if( aLayer == LAYER_PAD_HOLEWALLS )
233 aLayer = LAYER_PADS_TH;
234 else if( aLayer == LAYER_VIA_HOLEWALLS )
235 aLayer = LAYER_VIA_THROUGH;
236
237 // Normal path: get the layer base color
238 COLOR4D color = m_layerColors[aLayer];
239
240 if( !item )
241 return m_layerColors[aLayer];
242
243 // Selection disambiguation
244 if( item->IsBrightened() )
245 return color.Brightened( m_selectFactor ).WithAlpha( 0.8 );
246
247 // Normal selection
248 if( item->IsSelected() )
249 color = m_layerColorsSel[aLayer];
250
251 // Try to obtain the netcode for the item
252 if( conItem )
253 netCode = conItem->GetNetCode();
254
255 bool highlighted = m_highlightEnabled && m_highlightNetcodes.count( netCode );
256 bool selected = item->IsSelected();
257
258 // Apply net color overrides
259 if( conItem && m_netColorMode == NET_COLOR_MODE::ALL && IsNetCopperLayer( aLayer ) )
260 {
261 COLOR4D netColor = COLOR4D::UNSPECIFIED;
262
263 auto ii = m_netColors.find( netCode );
264
265 if( ii != m_netColors.end() )
266 netColor = ii->second;
267
268 if( netColor == COLOR4D::UNSPECIFIED )
269 {
270 auto jj = m_netclassColors.find( conItem->GetNetClassName() );
271
272 if( jj != m_netclassColors.end() )
273 netColor = jj->second;
274 }
275
276 if( netColor == COLOR4D::UNSPECIFIED )
277 netColor = color;
278
279 if( selected )
280 {
281 // Selection brightening overrides highlighting
282 netColor.Brighten( m_selectFactor );
283 }
284 else if( m_highlightEnabled )
285 {
286 // Highlight brightens objects on all layers and darkens everything else for contrast
287 if( highlighted )
288 netColor.Brighten( m_highlightFactor );
289 else
290 netColor.Darken( 1.0 - m_highlightFactor );
291 }
292
293 color = netColor;
294 }
295 else if( !selected && m_highlightEnabled )
296 {
297 // Single net highlight mode
298 color = m_highlightNetcodes.count( netCode ) ? m_layerColorsHi[aLayer]
299 : m_layerColorsDark[aLayer];
300 }
301
302 // Apply high-contrast dimming
303 if( m_hiContrastEnabled && m_highContrastLayers.size() && !highlighted && !selected )
304 {
306 bool isActive = m_highContrastLayers.count( aLayer );
307
308 switch( originalLayer )
309 {
310 case LAYER_PADS_TH:
311 if( !static_cast<const PAD*>( item )->FlashLayer( primary ) )
312 isActive = false;
313
314 break;
315
316 case LAYER_VIA_BBLIND:
318 // Target graphic is active if the via crosses the primary layer
319 if( static_cast<const PCB_VIA*>( item )->GetLayerSet().test( primary ) == 0 )
320 isActive = false;
321
322 break;
323
325 if( !static_cast<const PCB_VIA*>( item )->FlashLayer( primary ) )
326 isActive = false;
327
328 break;
329
333 // Pad holes are active is any physical layer is active
334 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
335 isActive = false;
336
337 break;
338
339 case LAYER_VIA_HOLES:
341 if( static_cast<const PCB_VIA*>( item )->GetViaType() == VIATYPE::BLIND_BURIED
342 || static_cast<const PCB_VIA*>( item )->GetViaType() == VIATYPE::MICROVIA )
343 {
344 // A blind or micro via's hole is active if it crosses the primary layer
345 if( static_cast<const PCB_VIA*>( item )->GetLayerSet().test( primary ) == 0 )
346 isActive = false;
347 }
348 else
349 {
350 // A through via's hole is active if any physical layer is active
351 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
352 isActive = false;
353 }
354
355 break;
356
357 default:
358 break;
359 }
360
361 if( !isActive )
362 {
365 else
366 {
368
369 // Bitmaps can't have their color mixed so just reduce the opacity a bit so they
370 // show through less
371 if( item->Type() == PCB_BITMAP_T )
373 }
374 }
375 }
376
377 // Apply per-type opacity overrides
378 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
380 else if( item->Type() == PCB_VIA_T )
381 color.a *= m_viaOpacity;
382 else if( item->Type() == PCB_PAD_T )
383 color.a *= m_padOpacity;
384 else if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
385 color.a *= m_zoneOpacity;
386 else if( item->Type() == PCB_BITMAP_T )
388
389 // No special modifiers enabled
390 return color;
391}
392
393
395{
396 return pcbconfig() && pcbconfig()->m_ShowPageLimits;
397}
398
399
401 PAINTER( aGal ),
402 m_frameType( aFrameType ),
403 m_maxError( ARC_HIGH_DEF ),
404 m_holePlatingThickness( 0 ),
405 m_lockedShadowMargin( 0 )
406{
407}
408
409
410int PCB_PAINTER::getLineThickness( int aActualThickness ) const
411{
412 // if items have 0 thickness, draw them with the outline
413 // width, otherwise respect the set value (which, no matter
414 // how small will produce something)
415 if( aActualThickness == 0 )
417
418 return aActualThickness;
419}
420
421
422int PCB_PAINTER::getDrillShape( const PAD* aPad ) const
423{
424 return aPad->GetDrillShape();
425}
426
427
429{
430 SHAPE_SEGMENT segm = *aPad->GetEffectiveHoleShape().get();
431 return segm;
432}
433
434
435int PCB_PAINTER::getViaDrillSize( const PCB_VIA* aVia ) const
436{
437 return aVia->GetDrillValue();
438}
439
440
441bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
442{
443 const BOARD_ITEM* item = dynamic_cast<const BOARD_ITEM*>( aItem );
444
445 if( !item )
446 return false;
447
448 if( const BOARD* board = item->GetBoard() )
449 {
450 BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
454
455 if( item->GetParentFootprint() && !board->IsFootprintHolder() )
456 {
457 FOOTPRINT* parentFP = static_cast<FOOTPRINT*>( item->GetParentFootprint() );
458
459 // Never draw footprint bitmaps on board
460 if( item->Type() == PCB_BITMAP_T )
461 return false;
462 else if( item->GetLayerSet().count() > 1 )
463 {
464 // For multi-layer objects, exclude only those layers that are private
465 if( IsPcbLayer( aLayer ) && parentFP->GetPrivateLayers().test( aLayer ) )
466 return false;
467 }
468 else if( item->GetLayerSet().count() == 1 )
469 {
470 // For single-layer objects, exclude all layers including ancillary layers
471 // such as holes, netnames, etc.
472 PCB_LAYER_ID singleLayer = item->GetLayerSet().Seq()[0];
473
474 if( parentFP->GetPrivateLayers().test( singleLayer ) )
475 return false;
476 }
477 }
478 }
479 else
480 {
483 }
484
485 // the "cast" applied in here clarifies which overloaded draw() is called
486 switch( item->Type() )
487 {
488 case PCB_TRACE_T:
489 draw( static_cast<const PCB_TRACK*>( item ), aLayer );
490 break;
491
492 case PCB_ARC_T:
493 draw( static_cast<const PCB_ARC*>( item ), aLayer );
494 break;
495
496 case PCB_VIA_T:
497 draw( static_cast<const PCB_VIA*>( item ), aLayer );
498 break;
499
500 case PCB_PAD_T:
501 draw( static_cast<const PAD*>( item ), aLayer );
502 break;
503
504 case PCB_SHAPE_T:
505 case PCB_FP_SHAPE_T:
506 draw( static_cast<const PCB_SHAPE*>( item ), aLayer );
507 break;
508
509 case PCB_BITMAP_T:
510 draw( static_cast<const PCB_BITMAP*>( item ), aLayer );
511 break;
512
513 case PCB_TEXT_T:
514 draw( static_cast<const PCB_TEXT*>( item ), aLayer );
515 break;
516
517 case PCB_TEXTBOX_T:
518 draw( static_cast<const PCB_TEXTBOX*>( item ), aLayer );
519 break;
520
521 case PCB_FP_TEXT_T:
522 draw( static_cast<const FP_TEXT*>( item ), aLayer );
523 break;
524
525 case PCB_FP_TEXTBOX_T:
526 draw( static_cast<const FP_TEXTBOX*>( item ), aLayer );
527 break;
528
529 case PCB_FOOTPRINT_T:
530 draw( static_cast<const FOOTPRINT*>( item ), aLayer );
531 break;
532
533 case PCB_GROUP_T:
534 draw( static_cast<const PCB_GROUP*>( item ), aLayer );
535 break;
536
537 case PCB_ZONE_T:
538 case PCB_FP_ZONE_T:
539 draw( static_cast<const ZONE*>( item ), aLayer );
540 break;
541
543 case PCB_DIM_CENTER_T:
544 case PCB_DIM_RADIAL_T:
546 case PCB_DIM_LEADER_T:
552 draw( static_cast<const PCB_DIMENSION_BASE*>( item ), aLayer );
553 break;
554
555 case PCB_TARGET_T:
556 draw( static_cast<const PCB_TARGET*>( item ) );
557 break;
558
559 case PCB_MARKER_T:
560 draw( static_cast<const PCB_MARKER*>( item ), aLayer );
561 break;
562
563 default:
564 // Painter does not know how to draw the object
565 return false;
566 }
567
568 // Draw bounding boxes after drawing objects so they can be seen.
570 {
571 // Show bounding boxes of painted objects for debugging.
572 BOX2I box = item->GetBoundingBox();
573
574 m_gal->SetIsFill( false );
575 m_gal->SetIsStroke( true );
576
577 if( item->Type() == PCB_FOOTPRINT_T )
578 {
579 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
580 COLOR4D( MAGENTA ) );
581 }
582 else
583 {
584 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
585 COLOR4D( 0.4, 0.4, 0.4, 1 ) );
586 }
587
588 m_gal->SetLineWidth( 1 );
589 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
590
591 if( item->Type() == PCB_FOOTPRINT_T )
592 {
593 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
594 COLOR4D( CYAN ) );
595
596 const FOOTPRINT* fp = static_cast<const FOOTPRINT*>( item );
597
598 if( fp )
599 {
600 const SHAPE_POLY_SET& convex = fp->GetBoundingHull();
601
602 m_gal->DrawPolyline( convex.COutline( 0 ) );
603 }
604 }
605 }
606
607 return true;
608}
609
610
611void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
612{
613 VECTOR2I start( aTrack->GetStart() );
614 VECTOR2I end( aTrack->GetEnd() );
615 int track_width = aTrack->GetWidth();
616 COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
617
618 if( IsNetnameLayer( aLayer ) )
619 {
620 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
621 return;
622
623 if( aTrack->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
624 return;
625
626 // When drawing netnames, clip the track to the viewport
627 BOX2D viewport;
628 VECTOR2D screenSize = m_gal->GetScreenPixelSize();
629 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
630
631 viewport.SetOrigin( VECTOR2D( matrix * VECTOR2D( 0, 0 ) ) );
632 viewport.SetEnd( VECTOR2D( matrix * screenSize ) );
633 viewport.Normalize();
634
635 BOX2I clipBox( viewport.GetOrigin(), viewport.GetSize() );
636 SEG visibleSeg( start, end );
637
638 ClipLine( &clipBox, visibleSeg.A.x, visibleSeg.A.y, visibleSeg.B.x, visibleSeg.B.y );
639
640 wxString netName = UnescapeString( aTrack->GetShortNetname() );
641 size_t num_char = netName.size();
642
643 // Check if the track is long enough to have a netname displayed
644 int seg_minlength = track_width * num_char;
645
646 if( visibleSeg.Length() < seg_minlength )
647 return;
648
649 double textSize = track_width;
650 double penWidth = textSize / 12.0;
651 EDA_ANGLE textOrientation;
652 int num_names = 1;
653
654 if( end.y == start.y ) // horizontal
655 {
656 textOrientation = ANGLE_HORIZONTAL;
657 num_names = std::max( num_names,
658 static_cast<int>( aTrack->GetLength() / viewport.GetWidth() ) );
659 }
660 else if( end.x == start.x ) // vertical
661 {
662 textOrientation = ANGLE_VERTICAL;
663 num_names = std::max( num_names,
664 static_cast<int>( aTrack->GetLength() / viewport.GetHeight() ) );
665 }
666 else
667 {
668 textOrientation = -EDA_ANGLE( visibleSeg.B - visibleSeg.A );
669 textOrientation.Normalize90();
670
671 double min_size = std::min( viewport.GetWidth(), viewport.GetHeight() );
672 num_names = std::max( num_names,
673 static_cast<int>( aTrack->GetLength() / ( M_SQRT2 * min_size ) ) );
674 }
675
676 m_gal->SetIsStroke( true );
677 m_gal->SetIsFill( false );
679 m_gal->SetLineWidth( penWidth );
680 m_gal->SetFontBold( false );
681 m_gal->SetFontItalic( false );
682 m_gal->SetFontUnderlined( false );
683 m_gal->SetTextMirrored( false );
684 m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
687
688 for( int ii = 0; ii < num_names; ++ii )
689 {
690 VECTOR2I textPosition =
691 VECTOR2D( start ) * static_cast<double>( num_names - ii ) / ( num_names + 1 )
692 + VECTOR2D( end ) * static_cast<double>( ii + 1 ) / ( num_names + 1 );
693 m_gal->BitmapText( netName, textPosition, textOrientation );
694 }
695
696 return;
697 }
698 else if( IsCopperLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW )
699 {
700 // Draw a regular track
701 bool outline_mode = pcbconfig()
703 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
706 m_gal->SetIsStroke( outline_mode );
707 m_gal->SetIsFill( not outline_mode );
709
710 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
711 track_width = track_width + m_lockedShadowMargin;
712
713 m_gal->DrawSegment( start, end, track_width );
714 }
715
716 // Clearance lines
717 if( pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
719 {
720 int clearance = aTrack->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
721
723 m_gal->SetIsFill( false );
724 m_gal->SetIsStroke( true );
726 m_gal->DrawSegment( start, end, track_width + clearance * 2 );
727 }
728}
729
730
731void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
732{
733 VECTOR2D center( aArc->GetCenter() );
734 int width = aArc->GetWidth();
735 COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
736 double radius = aArc->GetRadius();
737 EDA_ANGLE start_angle = aArc->GetArcAngleStart();
738 EDA_ANGLE angle = aArc->GetAngle();
739
740 if( IsNetnameLayer( aLayer ) )
741 {
742 // Ummm, yeah. Anyone fancy implementing text on a path?
743 return;
744 }
745 else if( IsCopperLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW )
746 {
747 // Draw a regular track
748 bool outline_mode = pcbconfig()
750 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
753 m_gal->SetIsStroke( outline_mode );
754 m_gal->SetIsFill( not outline_mode );
756
757 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
758 width = width + m_lockedShadowMargin;
759
760 m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle, width,
761 m_maxError );
762 }
763
764 // Clearance lines
765 if( pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
767 {
768 int clearance = aArc->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
769
771 m_gal->SetIsFill( false );
772 m_gal->SetIsStroke( true );
774
775 m_gal->DrawArcSegment( center, radius, start_angle, start_angle + angle,
776 width + clearance * 2, m_maxError );
777 }
778
779// Debug only: enable this code only to test the TransformArcToPolygon function
780// and display the polygon outline created by it.
781// arcs on F_Cu are approximated with ERROR_INSIDE, others with ERROR_OUTSIDE
782#if 0
783 SHAPE_POLY_SET cornerBuffer;
785 TransformArcToPolygon( cornerBuffer, aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), width,
786 m_maxError, errorloc );
788 m_gal->SetIsFill( false );
789 m_gal->SetIsStroke( true );
790 m_gal->SetStrokeColor( COLOR4D( 0, 0, 1.0, 1.0 ) );
791 m_gal->DrawPolygon( cornerBuffer );
792#endif
793
794// Debug only: enable this code only to test the SHAPE_ARC::ConvertToPolyline function
795// and display the polyline created by it.
796#if 0
797 SHAPE_ARC arc( aArc->GetCenter(), aArc->GetStart(), aArc->GetAngle() / 10.0, aArc->GetWidth() );
800 m_gal->SetIsFill( false );
801 m_gal->SetIsStroke( true );
802 m_gal->SetStrokeColor( COLOR4D( 0.3, 0.2, 0.5, 1.0 ) );
803
804 for( int idx = 1; idx < arcSpine.PointCount(); idx++ )
805 m_gal->DrawSegment( arcSpine.CPoint( idx-1 ), arcSpine.CPoint( idx ), aArc->GetWidth() );
806#endif
807}
808
809
810void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
811{
812 const BOARD* board = aVia->GetBoard();
813 COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
814 VECTOR2D center( aVia->GetStart() );
815
816 if( color == COLOR4D::CLEAR )
817 return;
818
819 // Draw description layer
820 if( IsNetnameLayer( aLayer ) )
821 {
822 VECTOR2D position( center );
823
824 // Is anything that we can display enabled?
825 if( !pcbconfig() )
826 return;
827
828 if( pcbconfig()->m_Display.m_NetNames == 0
829 || pcbconfig()->m_Display.m_NetNames == 2
830 || aVia->GetNetname().empty() )
831 {
832 return;
833 }
834
835 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
836 double size = aVia->GetWidth();
837
838 // Font size limits
839 if( size > maxSize )
840 size = maxSize;
841
842 m_gal->Save();
843 m_gal->Translate( position );
844
845 // Default font settings
849 m_gal->SetFontBold( false );
850 m_gal->SetFontItalic( false );
851 m_gal->SetFontUnderlined( false );
852 m_gal->SetTextMirrored( false );
853 m_gal->SetStrokeColor( m_pcbSettings.GetColor( nullptr, aLayer ) );
854 m_gal->SetIsStroke( true );
855 m_gal->SetIsFill( false );
856
857 // Set the text position to the pad shape position (the pad position is not the best place)
858 VECTOR2D textpos( 0.0, 0.0 );
859
860 wxString netname = UnescapeString( aVia->GetShortNetname() );
861
862 // approximate the size of net name text:
863 double tsize = 1.5 * size / std::max( PrintableCharCount( netname ), 1 );
864 tsize = std::min( tsize, size );
865
866 // Use a smaller text size to handle interline, pen size..
867 tsize *= 0.75;
868 VECTOR2D namesize( tsize, tsize );
869
870 m_gal->SetGlyphSize( namesize );
871 m_gal->SetLineWidth( namesize.x / 12.0 );
872 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
873
874 m_gal->Restore();
875
876 return;
877 }
878
879 bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayViaFill;
880
883 m_gal->SetIsStroke( true );
884 m_gal->SetIsFill( false );
885
886 if( outline_mode )
888
889 if( aLayer == LAYER_VIA_HOLEWALLS )
890 {
891 double radius = ( getViaDrillSize( aVia ) / 2.0 ) + m_holePlatingThickness;
892
893 if( !outline_mode )
894 {
896 radius -= m_holePlatingThickness / 2.0;
897 }
898
899 m_gal->DrawCircle( center, radius );
900 }
901 else if( aLayer == LAYER_VIA_HOLES )
902 {
903 m_gal->SetIsStroke( false );
904 m_gal->SetIsFill( true );
905 m_gal->DrawCircle( center, getViaDrillSize( aVia ) / 2.0 );
906 }
907 else if( aLayer == LAYER_VIA_THROUGH || m_pcbSettings.IsPrinting() )
908 {
909 int annular_width = ( aVia->GetWidth() - getViaDrillSize( aVia ) ) / 2.0;
910 double radius = aVia->GetWidth() / 2.0;
911 bool draw = false;
912
914 {
916 }
917 else if( aVia->FlashLayer( board->GetVisibleLayers() & board->GetEnabledLayers() ) )
918 {
919 draw = true;
920 }
921 else if( aVia->IsSelected() )
922 {
923 draw = true;
924 outline_mode = true;
926 }
927
928 if( !outline_mode )
929 {
930 m_gal->SetLineWidth( annular_width );
931 radius -= annular_width / 2.0;
932 }
933
934 if( draw )
935 m_gal->DrawCircle( center, radius );
936 }
937 else if( aLayer == LAYER_VIA_BBLIND || aLayer == LAYER_VIA_MICROVIA )
938 {
939 int annular_width = ( aVia->GetWidth() - getViaDrillSize( aVia ) ) / 2.0;
940 double radius = aVia->GetWidth() / 2.0;
941
942 // Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
943 // top and bottom layers
944 PCB_LAYER_ID layerTop, layerBottom;
945 aVia->LayerPair( &layerTop, &layerBottom );
946
947 if( !outline_mode )
948 {
949 m_gal->SetIsStroke( false );
950 m_gal->SetIsFill( true );
951 }
952
953 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerTop ) );
954 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
955 m_gal->DrawArc( center, radius, EDA_ANGLE( 240, DEGREES_T ), EDA_ANGLE( 300, DEGREES_T ) );
956
957 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
958 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
959 m_gal->DrawArc( center, radius, EDA_ANGLE( 60, DEGREES_T ), EDA_ANGLE( 120, DEGREES_T ) );
960
963 m_gal->SetIsStroke( true );
964 m_gal->SetIsFill( false );
965
966 if( !outline_mode )
967 {
968 m_gal->SetLineWidth( annular_width );
969 radius -= annular_width / 2.0;
970 }
971
972 m_gal->DrawCircle( center, radius );
973 }
974 else if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // draw a ring around the via
975 {
977
978 m_gal->DrawCircle( center, ( aVia->GetWidth() + m_lockedShadowMargin ) / 2.0 );
979 }
980
981 // Clearance lines
983 && aLayer != LAYER_VIA_HOLES
985 {
987 double radius;
988
989 if( aVia->FlashLayer( activeLayer ) )
990 radius = aVia->GetWidth() / 2.0;
991 else
992 radius = getViaDrillSize( aVia ) / 2.0 + m_holePlatingThickness;
993
995 m_gal->SetIsFill( false );
996 m_gal->SetIsStroke( true );
998 m_gal->DrawCircle( center, radius + aVia->GetOwnClearance( activeLayer ) );
999 }
1000}
1001
1002
1003void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
1004{
1005 const BOARD* board = aPad->GetBoard();
1006 COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
1007
1008 if( IsNetnameLayer( aLayer ) )
1009 {
1010 PCBNEW_SETTINGS::DISPLAY_OPTIONS* displayOpts = pcbconfig() ? &pcbconfig()->m_Display : nullptr;
1011 wxString netname;
1012 wxString padNumber;
1013
1014 if( viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers )
1015 {
1016 padNumber = UnescapeString( aPad->GetNumber() );
1017
1018 if( dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
1019 netname = UnescapeString( aPad->GetShortNetname() );
1020 }
1021
1022 if( displayOpts )
1023 {
1024 if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
1025 netname = UnescapeString( aPad->GetShortNetname() );
1026
1027 if( aPad->IsNoConnectPad() )
1028 netname = wxT( "x" );
1029 else if( aPad->IsFreePad() )
1030 netname = wxT( "*" );
1031 }
1032
1033 if( netname.IsEmpty() && padNumber.IsEmpty() )
1034 return;
1035
1036 BOX2I padBBox = aPad->GetBoundingBox();
1037 VECTOR2D position = padBBox.Centre();
1038 VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
1039
1040 if( aPad->GetFlags() & ENTERED )
1041 {
1042 FOOTPRINT* fp = static_cast<FOOTPRINT*>( aPad->GetParentFootprint() );
1043
1044 // Find the number box
1045 for( const BOARD_ITEM* aItem : fp->GraphicalItems() )
1046 {
1047 if( aItem->Type() == PCB_FP_SHAPE_T )
1048 {
1049 const FP_SHAPE* shape = static_cast<const FP_SHAPE*>( aItem );
1050
1051 if( shape->IsAnnotationProxy() )
1052 {
1053 position = shape->GetCenter();
1054 padsize = shape->GetBotRight() - shape->GetTopLeft();
1055
1056 // We normally draw a bit outside the pad, but this will be somewhat
1057 // unexpected when the user has drawn a box.
1058 padsize *= 0.9;
1059
1060 break;
1061 }
1062 }
1063 }
1064 }
1065 else if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
1066 {
1067 // See if we have a number box
1068 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
1069 {
1070 if( primitive->IsAnnotationProxy() )
1071 {
1072 position = aPad->GetPosition() + primitive->GetCenter();
1073 padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
1074 padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
1075
1076 // We normally draw a bit outside the pad, but this will be somewhat
1077 // unexpected when the user has drawn a box.
1078 padsize *= 0.9;
1079
1080 break;
1081 }
1082 }
1083 }
1084
1085 if( aPad->GetShape() != PAD_SHAPE::CUSTOM )
1086 {
1087 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
1088 double limit = std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1;
1089
1090 if( padsize.x > limit && padsize.y > limit )
1091 {
1092 padsize.x = limit;
1093 padsize.y = limit;
1094 }
1095 }
1096
1097 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
1098 double size = padsize.y;
1099
1100 m_gal->Save();
1101 m_gal->Translate( position );
1102
1103 // Keep the size ratio for the font, but make it smaller
1104 if( padsize.x < ( padsize.y * 0.95 ) )
1105 {
1107 size = padsize.x;
1108 std::swap( padsize.x, padsize.y );
1109 }
1110
1111 // Font size limits
1112 if( size > maxSize )
1113 size = maxSize;
1114
1115 // Default font settings
1119 m_gal->SetFontBold( false );
1120 m_gal->SetFontItalic( false );
1121 m_gal->SetFontUnderlined( false );
1122 m_gal->SetTextMirrored( false );
1123 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) );
1124 m_gal->SetIsStroke( true );
1125 m_gal->SetIsFill( false );
1126
1127 // We have already translated the GAL to be centered at the center of the pad's
1128 // bounding box
1129 VECTOR2I textpos( 0, 0 );
1130
1131 // Divide the space, to display both pad numbers and netnames and set the Y text
1132 // position to display 2 lines
1133 if( !netname.IsEmpty() && !padNumber.IsEmpty() )
1134 {
1135 size = size / 2.2;
1136 textpos.y = size / 1.7;
1137 }
1138
1139 if( !netname.IsEmpty() )
1140 {
1141 // approximate the size of net name text:
1142 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname ), 1 );
1143 tsize = std::min( tsize, size );
1144
1145 // Use a smaller text size to handle interline, pen size...
1146 tsize *= 0.85;
1147 VECTOR2D namesize( tsize, tsize );
1148
1149 m_gal->SetGlyphSize( namesize );
1150 m_gal->SetLineWidth( namesize.x / 6.0 );
1151 m_gal->SetFontBold( true );
1152 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
1153 }
1154
1155 if( !padNumber.IsEmpty() )
1156 {
1157 textpos.y = -textpos.y;
1158
1159 // approximate the size of the pad number text:
1160 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( padNumber ), 1 );
1161 tsize = std::min( tsize, size );
1162
1163 // Use a smaller text size to handle interline, pen size...
1164 tsize *= 0.85;
1165 tsize = std::min( tsize, size );
1166 VECTOR2D numsize( tsize, tsize );
1167
1168 m_gal->SetGlyphSize( numsize );
1169 m_gal->SetLineWidth( numsize.x / 6.0 );
1170 m_gal->SetFontBold( true );
1171 m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL );
1172 }
1173
1174 m_gal->Restore();
1175
1176 return;
1177 }
1178 else if( aLayer == LAYER_PAD_HOLEWALLS )
1179 {
1180 m_gal->SetIsFill( false );
1181 m_gal->SetIsStroke( true );
1184
1185 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
1186 int holeSize = slot->GetWidth() + m_holePlatingThickness;
1187
1188 if( slot->GetSeg().A == slot->GetSeg().B ) // Circular hole
1189 m_gal->DrawCircle( slot->GetSeg().A, KiROUND( holeSize / 2.0 ) );
1190 else
1191 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, holeSize );
1192
1193 return;
1194 }
1195
1196 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
1197
1199 outline_mode = false;
1201 outline_mode = true;
1202
1203 if( outline_mode )
1204 {
1205 // Outline mode
1206 m_gal->SetIsFill( false );
1207 m_gal->SetIsStroke( true );
1210 }
1211 else
1212 {
1213 // Filled mode
1214 m_gal->SetIsFill( true );
1215 m_gal->SetIsStroke( false );
1217 }
1218
1219 bool drawShape = false;
1220
1221 if( aLayer == LAYER_PAD_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
1222 {
1223 SHAPE_SEGMENT slot = getPadHoleShape( aPad );
1224
1225 if( slot.GetSeg().A == slot.GetSeg().B ) // Circular hole
1226 m_gal->DrawCircle( slot.GetSeg().A, slot.GetWidth() / 2.0 );
1227 else
1228 m_gal->DrawSegment( slot.GetSeg().A, slot.GetSeg().B, slot.GetWidth() );
1229 }
1230 else if( m_pcbSettings.IsPrinting() )
1231 {
1232 drawShape = aPad->FlashLayer( m_pcbSettings.GetPrintLayers() );
1233 }
1234 else if( aPad->FlashLayer( board->GetEnabledLayers() ) )
1235 {
1236 drawShape = true;
1237 }
1238 else if( aPad->IsSelected() )
1239 {
1240 drawShape = true;
1241 outline_mode = true;
1242 }
1243
1244 if( outline_mode )
1245 {
1246 // Outline mode
1247 m_gal->SetIsFill( false );
1248 m_gal->SetIsStroke( true );
1251 }
1252
1253 if( drawShape )
1254 {
1255 VECTOR2I pad_size = aPad->GetSize();
1256 VECTOR2I margin;
1257
1258 switch( aLayer )
1259 {
1260 case F_Mask:
1261 case B_Mask:
1262 margin.x = margin.y = aPad->GetSolderMaskExpansion();
1263 break;
1264
1265 case F_Paste:
1266 case B_Paste:
1267 margin = aPad->GetSolderPasteMargin();
1268 break;
1269
1270 default:
1271 margin.x = margin.y = 0;
1272 break;
1273 }
1274
1275 std::unique_ptr<PAD> dummyPad;
1276 std::shared_ptr<SHAPE_COMPOUND> shapes;
1277
1278 // Drawing components of compound shapes in outline mode produces a mess.
1279 bool simpleShapes = !outline_mode;
1280
1281 if( simpleShapes )
1282 {
1283 if( ( margin.x != margin.y && aPad->GetShape() != PAD_SHAPE::CUSTOM )
1284 || ( aPad->GetShape() == PAD_SHAPE::ROUNDRECT && ( margin.x < 0 || margin.y < 0 ) ) )
1285 {
1286 // Our algorithms below (polygon inflation in particular) can't handle differential
1287 // inflation along separate axes. So for those cases we build a dummy pad instead,
1288 // and inflate it.
1289
1290 // Margin is added to both sides. If the total margin is larger than the pad
1291 // then don't display this layer
1292 if( pad_size.x + 2 * margin.x <= 0 || pad_size.y + 2 * margin.y <= 0 )
1293 return;
1294
1295 dummyPad.reset( static_cast<PAD*>( aPad->Duplicate() ) );
1296 int initial_radius = dummyPad->GetRoundRectCornerRadius();
1297
1298 dummyPad->SetSize( pad_size + margin + margin );
1299
1300 if( dummyPad->GetShape() == PAD_SHAPE::ROUNDRECT )
1301 {
1302 // To keep the right margin around the corners, we need to modify the corner radius.
1303 // We must have only one radius correction, so use the smallest absolute margin.
1304 int radius_margin = std::max( margin.x, margin.y ); // radius_margin is < 0
1305 dummyPad->SetRoundRectCornerRadius( std::max( initial_radius + radius_margin, 0 ) );
1306 }
1307
1308 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( dummyPad->GetEffectiveShape() );
1309 margin.x = margin.y = 0;
1310 }
1311 else
1312 {
1313 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
1314 }
1315
1316 if( aPad->GetShape() == PAD_SHAPE::CUSTOM && ( margin.x || margin.y ) )
1317 {
1318 // We can't draw as shapes because we don't know which edges are internal and which
1319 // are external (so we don't know when to apply the margin and when not to).
1320 simpleShapes = false;
1321 }
1322
1323 for( const SHAPE* shape : shapes->Shapes() )
1324 {
1325 if( !simpleShapes )
1326 break;
1327
1328 switch( shape->Type() )
1329 {
1330 case SH_SEGMENT:
1331 case SH_CIRCLE:
1332 case SH_RECT:
1333 case SH_SIMPLE:
1334 // OK so far
1335 break;
1336
1337 default:
1338 // Not OK
1339 simpleShapes = false;
1340 break;
1341 }
1342 }
1343 }
1344
1345 if( simpleShapes )
1346 {
1347 for( const SHAPE* shape : shapes->Shapes() )
1348 {
1349 switch( shape->Type() )
1350 {
1351 case SH_SEGMENT:
1352 {
1353 const SHAPE_SEGMENT* seg = (const SHAPE_SEGMENT*) shape;
1354 int effectiveWidth = seg->GetWidth() + 2 * margin.x;
1355
1356 if( effectiveWidth > 0 )
1357 m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, effectiveWidth );
1358
1359 break;
1360 }
1361
1362 case SH_CIRCLE:
1363 {
1364 const SHAPE_CIRCLE* circle = (const SHAPE_CIRCLE*) shape;
1365 int effectiveRadius = circle->GetRadius() + margin.x;
1366
1367 if( effectiveRadius > 0 )
1368 m_gal->DrawCircle( circle->GetCenter(), effectiveRadius );
1369
1370 break;
1371 }
1372
1373 case SH_RECT:
1374 {
1375 const SHAPE_RECT* r = (const SHAPE_RECT*) shape;
1376 VECTOR2I pos = r->GetPosition();
1377 VECTOR2I effectiveMargin = margin;
1378
1379 if( effectiveMargin.x < 0 )
1380 {
1381 // A negative margin just produces a smaller rect.
1382 VECTOR2I effectiveSize = r->GetSize() + effectiveMargin;
1383
1384 if( effectiveSize.x > 0 && effectiveSize.y > 0 )
1385 m_gal->DrawRectangle( pos - effectiveMargin, pos + effectiveSize );
1386 }
1387 else if( effectiveMargin.x > 0 )
1388 {
1389 // A positive margin produces a larger rect, but with rounded corners
1390 m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
1391
1392 // Use segments to produce the margin with rounded corners
1393 m_gal->DrawSegment( pos,
1394 pos + VECTOR2I( r->GetWidth(), 0 ),
1395 effectiveMargin.x * 2 );
1396 m_gal->DrawSegment( pos + VECTOR2I( r->GetWidth(), 0 ),
1397 pos + r->GetSize(),
1398 effectiveMargin.x * 2 );
1399 m_gal->DrawSegment( pos + r->GetSize(),
1400 pos + VECTOR2I( 0, r->GetHeight() ),
1401 effectiveMargin.x * 2 );
1402 m_gal->DrawSegment( pos + VECTOR2I( 0, r->GetHeight() ),
1403 pos,
1404 effectiveMargin.x * 2 );
1405 }
1406 else
1407 {
1408 m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
1409 }
1410
1411 break;
1412 }
1413
1414 case SH_SIMPLE:
1415 {
1416 const SHAPE_SIMPLE* poly = static_cast<const SHAPE_SIMPLE*>( shape );
1417
1418 if( poly->PointCount() < 2 ) // Careful of empty pads
1419 break;
1420
1421 if( margin.x < 0 ) // The poly shape must be deflated
1422 {
1423 int numSegs = GetArcToSegmentCount( -margin.x, m_maxError, FULL_CIRCLE );
1424 SHAPE_POLY_SET outline;
1425 outline.NewOutline();
1426
1427 for( int ii = 0; ii < poly->PointCount(); ++ii )
1428 outline.Append( poly->CPoint( ii ) );
1429
1430 outline.Deflate( -margin.x, numSegs );
1431
1432 m_gal->DrawPolygon( outline );
1433 }
1434 else
1435 {
1436 m_gal->DrawPolygon( poly->Vertices() );
1437 }
1438
1439 // Now add on a rounded margin (using segments) if the margin > 0
1440 if( margin.x > 0 )
1441 {
1442 for( size_t ii = 0; ii < poly->GetSegmentCount(); ++ii )
1443 {
1444 SEG seg = poly->GetSegment( ii );
1445 m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
1446 }
1447 }
1448
1449 break;
1450 }
1451
1452 default:
1453 // Better not get here; we already pre-flighted the shapes...
1454 break;
1455 }
1456 }
1457 }
1458 else
1459 {
1460 // This is expensive. Avoid if possible.
1461 SHAPE_POLY_SET polySet;
1462 aPad->TransformShapeToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x, m_maxError,
1463 ERROR_INSIDE );
1464 m_gal->DrawPolygon( polySet );
1465 }
1466 }
1467
1468 if( pcbconfig() && pcbconfig()->m_Display.m_PadClearance
1469 && ( aLayer == LAYER_PAD_FR || aLayer == LAYER_PAD_BK || aLayer == LAYER_PADS_TH )
1471 {
1472 /* Showing the clearance area is not obvious.
1473 * - A pad can be removed from some copper layers.
1474 * - For non copper layers, what is the clearance area?
1475 * So for copper layers, the clearance area is the shape if the pad is flashed on this
1476 * layer and the hole clearance area for other copper layers.
1477 * For other layers, use the pad shape, although one can use an other criteria,
1478 * depending on the non copper layer.
1479 */
1480 int activeLayer = m_pcbSettings.GetActiveLayer();
1481 bool flashActiveLayer = true;
1482
1483 if( IsCopperLayer( activeLayer ) )
1484 flashActiveLayer = aPad->FlashLayer( activeLayer );
1485
1486 if( flashActiveLayer || aPad->GetDrillSize().x )
1487 {
1488 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
1490
1492 m_gal->SetIsStroke( true );
1493 m_gal->SetIsFill( false );
1495
1496 int clearance = aPad->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
1497
1498 if( flashActiveLayer && clearance > 0 )
1499 {
1500 auto shape = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
1501
1502 if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_SEGMENT )
1503 {
1504 const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape->Shapes()[0];
1505 m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
1506 seg->GetWidth() + 2 * clearance );
1507 }
1508 else if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_CIRCLE )
1509 {
1510 const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape->Shapes()[0];
1511 m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
1512 }
1513 else
1514 {
1515 SHAPE_POLY_SET polySet;
1516
1517 // Use ERROR_INSIDE because it avoids Clipper and is therefore much faster.
1518 aPad->TransformShapeToPolygon( polySet, ToLAYER_ID( aLayer ), clearance,
1520
1521 if( polySet.Outline( 0 ).PointCount() > 2 ) // Careful of empty pads
1522 m_gal->DrawPolygon( polySet );
1523 }
1524 }
1525 else if( aPad->GetEffectiveHoleShape() && clearance > 0 )
1526 {
1527 clearance += m_holePlatingThickness;
1528
1529 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
1530 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B,
1531 slot->GetWidth() + 2 * clearance );
1532 }
1533 }
1534 }
1535}
1536
1537
1538void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
1539{
1540 COLOR4D color = m_pcbSettings.GetColor( aShape, aShape->GetLayer() );
1542 int thickness = getLineThickness( aShape->GetWidth() );
1543 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
1544
1545 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1546 {
1547 color = m_pcbSettings.GetColor( aShape, aLayer );
1548 thickness = thickness + m_lockedShadowMargin;
1549 }
1550
1551 if( outline_mode )
1552 {
1553 m_gal->SetIsFill( false );
1554 m_gal->SetIsStroke( true );
1556 }
1557
1560
1561 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
1562 {
1563 switch( aShape->GetShape() )
1564 {
1565 case SHAPE_T::SEGMENT:
1566 if( outline_mode )
1567 {
1568 m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
1569 }
1570 else
1571 {
1572 m_gal->SetIsFill( true );
1573 m_gal->SetIsStroke( false );
1574
1575 m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
1576 }
1577
1578 break;
1579
1580 case SHAPE_T::RECT:
1581 {
1582 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1583
1584 if( aShape->IsAnnotationProxy() )
1585 {
1586 m_gal->DrawSegment( pts[0], pts[1], thickness );
1587 m_gal->DrawSegment( pts[1], pts[2], thickness );
1588 m_gal->DrawSegment( pts[2], pts[3], thickness );
1589 m_gal->DrawSegment( pts[3], pts[0], thickness );
1590 m_gal->DrawSegment( pts[0], pts[2], thickness );
1591 m_gal->DrawSegment( pts[1], pts[3], thickness );
1592 }
1593 else if( outline_mode )
1594 {
1595 m_gal->DrawSegment( pts[0], pts[1], thickness );
1596 m_gal->DrawSegment( pts[1], pts[2], thickness );
1597 m_gal->DrawSegment( pts[2], pts[3], thickness );
1598 m_gal->DrawSegment( pts[3], pts[0], thickness );
1599 }
1600 else
1601 {
1602 m_gal->SetIsFill( true );
1603 m_gal->SetIsStroke( false );
1604
1605 if( thickness > 0 )
1606 {
1607 m_gal->DrawSegment( pts[0], pts[1], thickness );
1608 m_gal->DrawSegment( pts[1], pts[2], thickness );
1609 m_gal->DrawSegment( pts[2], pts[3], thickness );
1610 m_gal->DrawSegment( pts[3], pts[0], thickness );
1611 }
1612
1613 if( aShape->IsFilled() )
1614 {
1615 SHAPE_POLY_SET poly;
1616 poly.NewOutline();
1617
1618 for( const VECTOR2I& pt : pts )
1619 poly.Append( pt );
1620
1621 m_gal->DrawPolygon( poly );
1622 }
1623 }
1624
1625 break;
1626 }
1627
1628 case SHAPE_T::ARC:
1629 {
1630 EDA_ANGLE startAngle;
1631 EDA_ANGLE endAngle;
1632 aShape->CalcArcAngles( startAngle, endAngle );
1633
1634 if( outline_mode )
1635 {
1636 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
1637 endAngle, thickness, m_maxError );
1638 }
1639 else
1640 {
1641 m_gal->SetIsFill( true );
1642 m_gal->SetIsStroke( false );
1643
1644 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
1645 endAngle, thickness, m_maxError );
1646 }
1647 break;
1648 }
1649
1650 case SHAPE_T::CIRCLE:
1651 if( outline_mode )
1652 {
1653 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() - thickness / 2 );
1654 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() + thickness / 2 );
1655 }
1656 else
1657 {
1658 m_gal->SetIsFill( aShape->IsFilled() );
1659 m_gal->SetIsStroke( thickness > 0 );
1660 m_gal->SetLineWidth( thickness );
1661
1662 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() );
1663 }
1664 break;
1665
1666 case SHAPE_T::POLY:
1667 {
1668 SHAPE_POLY_SET& shape = const_cast<PCB_SHAPE*>( aShape )->GetPolyShape();
1669 const FOOTPRINT* parentFootprint = aShape->GetParentFootprint();
1670
1671 if( shape.OutlineCount() == 0 )
1672 break;
1673
1674 if( parentFootprint )
1675 {
1676 m_gal->Save();
1677 m_gal->Translate( parentFootprint->GetPosition() );
1678 m_gal->Rotate( -parentFootprint->GetOrientation().AsRadians() );
1679 }
1680
1681 if( outline_mode )
1682 {
1683 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
1684 m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
1685 }
1686 else
1687 {
1688 m_gal->SetIsFill( true );
1689 m_gal->SetIsStroke( false );
1690
1691 if( thickness > 0 )
1692 {
1693 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
1694 m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
1695 }
1696
1697 if( aShape->IsFilled() )
1698 {
1699 // On Opengl, a not convex filled polygon is usually drawn by using triangles
1700 // as primitives. CacheTriangulation() can create basic triangle primitives to
1701 // draw the polygon solid shape on Opengl. GLU tessellation is much slower,
1702 // so currently we are using our tessellation.
1703 if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
1704 shape.CacheTriangulation( true, true );
1705
1706 m_gal->DrawPolygon( shape );
1707 }
1708 }
1709
1710 if( parentFootprint )
1711 m_gal->Restore();
1712
1713 break;
1714 }
1715
1716 case SHAPE_T::BEZIER:
1717 if( outline_mode )
1718 {
1719 std::vector<VECTOR2D> output;
1720 std::vector<VECTOR2D> pointCtrl;
1721
1722 pointCtrl.push_back( aShape->GetStart() );
1723 pointCtrl.push_back( aShape->GetBezierC1() );
1724 pointCtrl.push_back( aShape->GetBezierC2() );
1725 pointCtrl.push_back( aShape->GetEnd() );
1726
1727 BEZIER_POLY converter( pointCtrl );
1728 converter.GetPoly( output, thickness );
1729
1730 m_gal->DrawSegmentChain( output, thickness );
1731 }
1732 else
1733 {
1734 m_gal->SetIsFill( aShape->IsFilled() );
1735 m_gal->SetIsStroke( thickness > 0 );
1736 m_gal->SetLineWidth( thickness );
1737
1738 // Use thickness as filter value to convert the curve to polyline when the curve
1739 // is not supported
1740 m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
1741 VECTOR2D( aShape->GetBezierC1() ),
1742 VECTOR2D( aShape->GetBezierC2() ),
1743 VECTOR2D( aShape->GetEnd() ), thickness );
1744 }
1745
1746 break;
1747
1748 case SHAPE_T::LAST:
1749 break;
1750 }
1751 }
1752 else
1753 {
1754 if( !outline_mode )
1755 {
1756 m_gal->SetIsFill( true );
1757 m_gal->SetIsStroke( false );
1758 }
1759
1760 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1761
1762 for( SHAPE* shape : shapes )
1763 {
1764 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
1765 [&]( const VECTOR2I& a, const VECTOR2I& b )
1766 {
1767 m_gal->DrawSegment( a, b, thickness );
1768 } );
1769 }
1770
1771 for( SHAPE* shape : shapes )
1772 delete shape;
1773 }
1774}
1775
1776
1777void PCB_PAINTER::strokeText( const wxString& aText, const VECTOR2I& aPosition,
1778 const TEXT_ATTRIBUTES& aAttrs )
1779{
1780 KIFONT::FONT* font = aAttrs.m_Font;
1781
1782 if( !font )
1783 font = KIFONT::FONT::GetFont( wxEmptyString, aAttrs.m_Bold, aAttrs.m_Italic );
1784
1785 m_gal->SetIsFill( font->IsOutline() );
1786 m_gal->SetIsStroke( font->IsStroke() );
1787
1788 font->Draw( m_gal, aText, aPosition, aAttrs );
1789}
1790
1791
1792void PCB_PAINTER::draw( const PCB_BITMAP* aBitmap, int aLayer )
1793{
1794 m_gal->Save();
1795 m_gal->Translate( aBitmap->GetPosition() );
1796
1797 // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1798 // factor is similar to a local zoom
1799 double img_scale = aBitmap->GetImageScale();
1800
1801 if( img_scale != 1.0 )
1802 m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1803
1804 if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
1805 {
1807 m_gal->SetIsStroke( true );
1810 m_gal->SetIsFill( false );
1811
1812 // Draws a bounding box.
1813 VECTOR2D bm_size( aBitmap->GetSize() );
1814 // bm_size is the actual image size in UI.
1815 // but m_gal scale was previously set to img_scale
1816 // so recalculate size relative to this image size.
1817 bm_size.x /= img_scale;
1818 bm_size.y /= img_scale;
1819 VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1820 VECTOR2D end = origin + bm_size;
1821
1822 m_gal->DrawRectangle( origin, end );
1823
1824 // Hard code bitmaps as opaque when selected. Otherwise cached layers
1825 // will not be rendered under the selected bitmap because cached layers
1826 // are rendered after non-cached layers (e.g. bitmaps), which will have
1827 // a closer Z order.
1828 m_gal->DrawBitmap( *aBitmap->GetImage(), 1.0 );
1829 }
1830 else
1831 m_gal->DrawBitmap( *aBitmap->GetImage(),
1832 m_pcbSettings.GetColor( aBitmap, aBitmap->GetLayer() ).a );
1833
1834
1835 m_gal->Restore();
1836}
1837
1838
1839void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
1840{
1841 wxString resolvedText( aText->GetShownText() );
1842
1843 if( resolvedText.Length() == 0 )
1844 return;
1845
1846 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
1847 {
1848 const COLOR4D color = m_pcbSettings.GetColor( aText, aLayer );
1849
1850 m_gal->SetIsFill( true );
1851 m_gal->SetIsStroke( true );
1854
1855 SHAPE_POLY_SET poly;
1856 aText->TransformShapeToPolygon( poly, aText->GetLayer(), 0, m_maxError, ERROR_OUTSIDE );
1857 m_gal->DrawPolygon( poly );
1858
1859 return;
1860 }
1861
1862 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
1863 const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
1864 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
1865
1866 KIFONT::FONT* font = aText->GetFont();
1867
1868 if( !font )
1869 {
1871 aText->IsItalic() );
1872 }
1873
1876
1877 if( aText->IsKnockout() )
1878 {
1879 KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
1880 SHAPE_POLY_SET knockouts;
1881
1882 CALLBACK_GAL callback_gal( empty_opts,
1883 // Polygon callback
1884 [&]( const SHAPE_LINE_CHAIN& aPoly )
1885 {
1886 knockouts.AddOutline( aPoly );
1887 } );
1888
1890
1891 callback_gal.SetIsFill( font->IsOutline() );
1892 callback_gal.SetIsStroke( font->IsStroke() );
1893 callback_gal.SetLineWidth( attrs.m_StrokeWidth );
1894 font->Draw( &callback_gal, resolvedText, aText->GetDrawPos(), attrs );
1895
1896 SHAPE_POLY_SET finalPoly;
1897 int margin = attrs.m_StrokeWidth * 1.5
1898 + GetKnockoutTextMargin( attrs.m_Size, attrs.m_StrokeWidth );
1899
1900 aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
1901 finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
1902 finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
1903
1904 m_gal->SetIsStroke( false );
1905 m_gal->SetIsFill( true );
1906 m_gal->DrawPolygon( finalPoly );
1907 }
1908 else
1909 {
1910 if( outline_mode )
1912 else
1914
1915 if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::SideSpecificMask() ).any() )
1916 {
1917 attrs.m_Mirrored = !attrs.m_Mirrored;
1918 attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
1919 }
1920
1921 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
1922
1923 if( font->IsOutline() )
1924 cache = aText->GetRenderCache( font, resolvedText );
1925
1926 if( cache )
1927 m_gal->DrawGlyphs( *cache );
1928 else
1929 strokeText( resolvedText, aText->GetTextPos(), attrs );
1930 }
1931}
1932
1933
1934void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
1935{
1936 const COLOR4D& color = m_pcbSettings.GetColor( aTextBox, aLayer );
1937 int thickness = getLineThickness( aTextBox->GetWidth() );
1938 PLOT_DASH_TYPE lineStyle = aTextBox->GetStroke().GetPlotStyle();
1939 wxString resolvedText( aTextBox->GetShownText() );
1940
1941 KIFONT::FONT* font = aTextBox->GetFont();
1942
1943 if( !font )
1944 {
1946 aTextBox->IsItalic() );
1947 }
1948
1949 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
1950 {
1951 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
1952
1953 m_gal->SetIsFill( true );
1954 m_gal->SetIsStroke( false );
1955 m_gal->SetFillColor( sh_color );
1956 m_gal->SetStrokeColor( sh_color );
1957
1958 // Draw the box with a larger thickness than box thickness to show
1959 // the shadow mask
1960 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
1961 int line_thickness = std::max( thickness*3, pcbIUScale.mmToIU( 0.2 ) );
1962
1963 for( size_t ii = 0; ii < pts.size(); ++ii )
1964 m_gal->DrawSegment( pts[ ii ], pts[ (ii + 1) % pts.size() ], line_thickness );
1965 }
1966
1969 m_gal->SetIsFill( true );
1970 m_gal->SetIsStroke( false );
1971
1972 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
1973 {
1974 if( thickness > 0 )
1975 {
1976 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
1977
1978 for( size_t ii = 0; ii < pts.size(); ++ii )
1979 m_gal->DrawSegment( pts[ ii ], pts[ (ii + 1) % pts.size() ], thickness );
1980 }
1981 }
1982 else
1983 {
1984 std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
1985
1986 for( SHAPE* shape : shapes )
1987 {
1988 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
1989 [&]( const VECTOR2I& a, const VECTOR2I& b )
1990 {
1991 m_gal->DrawSegment( a, b, thickness );
1992 } );
1993 }
1994
1995 for( SHAPE* shape : shapes )
1996 delete shape;
1997 }
1998
1999 if( resolvedText.Length() == 0 )
2000 return;
2001
2002 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
2004
2005 if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::SideSpecificMask() ).any() )
2006 {
2007 attrs.m_Mirrored = !attrs.m_Mirrored;
2008 attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
2009 }
2010
2011 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
2012 {
2013 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
2014 m_gal->SetFillColor( sh_color );
2015 m_gal->SetStrokeColor( sh_color );
2017 }
2018
2019 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2020
2021 if( font->IsOutline() )
2022 cache = aTextBox->GetRenderCache( font, resolvedText );
2023
2024 if( cache )
2025 m_gal->DrawGlyphs( *cache );
2026 else
2027 strokeText( resolvedText, aTextBox->GetDrawPos(), attrs );
2028}
2029
2030
2031void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer )
2032{
2033 wxString resolvedText( aText->GetShownText() );
2034
2035 if( resolvedText.Length() == 0 )
2036 return;
2037
2038 const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
2039 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
2040 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
2041
2042 KIFONT::FONT* font = aText->GetFont();
2043
2044 if( !font )
2045 {
2047 aText->IsItalic() );
2048 }
2049
2052 attrs.m_Angle = aText->GetDrawRotation();
2053
2054 if( aText->IsKnockout() )
2055 {
2056 KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
2057 SHAPE_POLY_SET knockouts;
2058
2059 CALLBACK_GAL callback_gal( empty_opts,
2060 // Polygon callback
2061 [&]( const SHAPE_LINE_CHAIN& aPoly )
2062 {
2063 knockouts.AddOutline( aPoly );
2064 } );
2065
2067
2068 callback_gal.SetIsFill( font->IsOutline() );
2069 callback_gal.SetIsStroke( font->IsStroke() );
2070 callback_gal.SetLineWidth( attrs.m_StrokeWidth );
2071 font->Draw( &callback_gal, resolvedText, aText->GetDrawPos(), attrs );
2072
2073 SHAPE_POLY_SET finalPoly;
2074 int margin = attrs.m_StrokeWidth * 1.5
2075 + GetKnockoutTextMargin( attrs.m_Size, attrs.m_StrokeWidth );
2076
2077 aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
2078 finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
2079 finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
2080
2081 m_gal->SetIsStroke( false );
2082 m_gal->SetIsFill( true );
2083 m_gal->DrawPolygon( finalPoly );
2084 }
2085 else
2086 {
2087 if( outline_mode )
2089 else
2091
2092 if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::SideSpecificMask() ).any() )
2093 {
2094 attrs.m_Mirrored = !attrs.m_Mirrored;
2095 attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
2096 }
2097
2098 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2099
2100 if( font->IsOutline() )
2101 cache = aText->GetRenderCache( font, resolvedText );
2102
2103 if( cache )
2104 m_gal->DrawGlyphs( *cache );
2105 else
2106 strokeText( resolvedText, aText->GetTextPos(), attrs );
2107 }
2108
2109 // Draw the umbilical line
2110 if( aText->IsSelected() )
2111 {
2114 m_gal->DrawLine( aText->GetTextPos(), aText->GetParent()->GetPosition() );
2115 }
2116}
2117
2118
2119void PCB_PAINTER::draw( const FP_TEXTBOX* aTextBox, int aLayer )
2120{
2121 const COLOR4D& color = m_pcbSettings.GetColor( aTextBox, aTextBox->GetLayer() );
2122 int thickness = getLineThickness( aTextBox->GetWidth() );
2123 PLOT_DASH_TYPE lineStyle = aTextBox->GetStroke().GetPlotStyle();
2124
2127 m_gal->SetIsFill( true );
2128 m_gal->SetIsStroke( false );
2129
2130 if( thickness > 0 )
2131 {
2132 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
2133 {
2134 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
2135
2136 for( size_t ii = 0; ii < pts.size(); ++ii )
2137 m_gal->DrawSegment( pts[ ii ], pts[ (ii + 1) % pts.size() ], thickness );
2138 }
2139 else
2140 {
2141 std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
2142
2143 for( SHAPE* shape : shapes )
2144 {
2145 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
2146 [&]( const VECTOR2I& a, const VECTOR2I& b )
2147 {
2148 m_gal->DrawSegment( a, b, thickness );
2149 } );
2150 }
2151
2152 for( SHAPE* shape : shapes )
2153 delete shape;
2154 }
2155 }
2156
2157 wxString resolvedText( aTextBox->GetShownText() );
2158
2159 if( resolvedText.Length() == 0 )
2160 return;
2161
2162 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
2163 attrs.m_Angle = aTextBox->GetDrawRotation();
2165
2166 if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::SideSpecificMask() ).any() )
2167 {
2168 attrs.m_Mirrored = !attrs.m_Mirrored;
2169 attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
2170 }
2171
2172 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2173
2174 if( aTextBox->GetFont() && aTextBox->GetFont()->IsOutline() )
2175 cache = aTextBox->GetRenderCache( aTextBox->GetFont(), resolvedText );
2176
2177 if( cache )
2178 m_gal->DrawGlyphs( *cache );
2179 else
2180 strokeText( resolvedText, aTextBox->GetDrawPos(), attrs );
2181}
2182
2183
2184void PCB_PAINTER::draw( const FOOTPRINT* aFootprint, int aLayer )
2185{
2186 if( aLayer == LAYER_ANCHOR )
2187 {
2188 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2189
2190 // Keep the size and width constant, not related to the scale because the anchor
2191 // is just a marker on screen
2192 double anchorSize = 5.0 / m_gal->GetWorldScale(); // 5 pixels size
2193 double anchorThickness = 1.0 / m_gal->GetWorldScale(); // 1 pixels width
2194
2195 // Draw anchor
2196 m_gal->SetIsFill( false );
2197 m_gal->SetIsStroke( true );
2199 m_gal->SetLineWidth( anchorThickness );
2200
2201 VECTOR2D center = aFootprint->GetPosition();
2202 m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
2203 m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
2204 }
2205
2206 if( aLayer == LAYER_LOCKED_ITEM_SHADOW && m_frameType == FRAME_PCB_EDITOR ) // happens only if locked
2207 {
2208 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2209
2210 m_gal->SetIsFill( true );
2211 m_gal->SetIsStroke( false );
2213
2214#if 0 // GetBoundingHull() can be very slow, especially for logos imported from graphics
2215 const SHAPE_POLY_SET& poly = aFootprint->GetBoundingHull();
2216 m_gal->DrawPolygon( poly );
2217#else
2218 BOX2I bbox = aFootprint->GetBoundingBox( false, false );
2219 VECTOR2I topLeft = bbox.GetPosition();
2220 VECTOR2I botRight = bbox.GetPosition() + bbox.GetSize();
2221
2222 m_gal->DrawRectangle( topLeft, botRight );
2223
2224 // Use segments to produce a margin with rounded corners
2225 m_gal->DrawSegment( topLeft, VECTOR2I( botRight.x, topLeft.y ), m_lockedShadowMargin );
2226 m_gal->DrawSegment( VECTOR2I( botRight.x, topLeft.y ), botRight, m_lockedShadowMargin );
2227 m_gal->DrawSegment( botRight, VECTOR2I( topLeft.x, botRight.y ), m_lockedShadowMargin );
2228 m_gal->DrawSegment( VECTOR2I( topLeft.x, botRight.y ), topLeft, m_lockedShadowMargin );
2229#endif
2230 }
2231
2232 if( aLayer == LAYER_CONFLICTS_SHADOW )
2233 {
2234 const SHAPE_POLY_SET& frontpoly = aFootprint->GetCourtyard( F_CrtYd );
2235 const SHAPE_POLY_SET& backpoly = aFootprint->GetCourtyard( B_CrtYd );
2236
2237 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2238
2239 m_gal->SetIsFill( true );
2240 m_gal->SetIsStroke( false );
2242
2243 if( frontpoly.OutlineCount() > 0 )
2244 m_gal->DrawPolygon( frontpoly );
2245
2246 if( backpoly.OutlineCount() > 0 )
2247 m_gal->DrawPolygon( backpoly );
2248 }
2249}
2250
2251
2252void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
2253{
2254 if( aLayer == LAYER_ANCHOR )
2255 {
2256 if( aGroup->IsSelected() && !( aGroup->GetParent() && aGroup->GetParent()->IsSelected() ) )
2257 {
2258 // Selected on our own; draw enclosing box
2259 }
2260 else if( aGroup->IsEntered() )
2261 {
2262 // Entered group; draw enclosing box
2263 }
2264 else
2265 {
2266 // Neither selected nor entered; draw nothing at the group level (ie: only draw
2267 // its members)
2268 return;
2269 }
2270
2271 const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
2272
2275
2276 BOX2I bbox = aGroup->GetBoundingBox();
2277 VECTOR2I topLeft = bbox.GetPosition();
2278 VECTOR2I width = VECTOR2I( bbox.GetWidth(), 0 );
2279 VECTOR2I height = VECTOR2I( 0, bbox.GetHeight() );
2280
2281 m_gal->DrawLine( topLeft, topLeft + width );
2282 m_gal->DrawLine( topLeft + width, topLeft + width + height );
2283 m_gal->DrawLine( topLeft + width + height, topLeft + height );
2284 m_gal->DrawLine( topLeft + height, topLeft );
2285
2286 wxString name = aGroup->GetName();
2287
2288 if( name.IsEmpty() )
2289 return;
2290
2291 int ptSize = 12;
2292 int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
2293 int unscaledSize = pcbIUScale.MilsToIU( ptSize );
2294
2295 // Scale by zoom a bit, but not too much
2296 int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
2297 VECTOR2I textOffset = VECTOR2I( width.x / 2, -KiROUND( textSize * 0.5 ) );
2298 VECTOR2I titleHeight = VECTOR2I( 0, KiROUND( textSize * 2.0 ) );
2299
2300 if( PrintableCharCount( name ) * textSize < bbox.GetWidth() )
2301 {
2302 m_gal->DrawLine( topLeft, topLeft - titleHeight );
2303 m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
2304 m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
2305
2306 TEXT_ATTRIBUTES attrs;
2307 attrs.m_Italic = true;
2310 attrs.m_Size = VECTOR2I( textSize, textSize );
2311 attrs.m_StrokeWidth = GetPenSizeForNormal( textSize );
2312
2313 KIFONT::FONT::GetFont()->Draw( m_gal, aGroup->GetName(), topLeft + textOffset, attrs );
2314 }
2315 }
2316}
2317
2318
2319void PCB_PAINTER::draw( const ZONE* aZone, int aLayer )
2320{
2321 if( aLayer == LAYER_CONFLICTS_SHADOW )
2322 {
2323 COLOR4D color = m_pcbSettings.GetColor( aZone, aLayer );
2324
2325 m_gal->SetIsFill( true );
2326 m_gal->SetIsStroke( false );
2328
2329 m_gal->DrawPolygon( aZone->Outline()->Outline( 0 ) );
2330 return;
2331 }
2332
2333 /*
2334 * aLayer will be the virtual zone layer (LAYER_ZONE_START, ... in GAL_LAYER_ID)
2335 * This is used for draw ordering in the GAL.
2336 * The color for the zone comes from the associated copper layer ( aLayer - LAYER_ZONE_START )
2337 * and the visibility comes from the combination of that copper layer and LAYER_ZONES
2338 */
2339 PCB_LAYER_ID layer;
2340
2341 if( IsZoneFillLayer( aLayer ) )
2342 layer = ToLAYER_ID( aLayer - LAYER_ZONE_START );
2343 else
2344 layer = ToLAYER_ID( aLayer );
2345
2346 if( !aZone->IsOnLayer( layer ) )
2347 return;
2348
2349 COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
2350 std::deque<VECTOR2D> corners;
2352
2353 // Draw the outline
2354 if( !IsZoneFillLayer( aLayer ) )
2355 {
2356 const SHAPE_POLY_SET* outline = aZone->Outline();
2357
2358 if( !m_pcbSettings.m_isPrinting && outline && outline->OutlineCount() > 0 )
2359 {
2360 m_gal->SetStrokeColor( color.a > 0.0 ? color.WithAlpha( 1.0 ) : color );
2361 m_gal->SetIsFill( false );
2362 m_gal->SetIsStroke( true );
2364
2365 // Draw each contour (main contour and holes)
2366
2367 /*
2368 * m_gal->DrawPolygon( *outline );
2369 * should be enough, but currently does not work to draw holes contours in a complex
2370 * polygon so each contour is draw as a simple polygon
2371 */
2372
2373 // Draw the main contour(s?)
2374 for( int ii = 0; ii < outline->OutlineCount(); ++ii )
2375 {
2376 m_gal->DrawPolyline( outline->COutline( ii ) );
2377
2378 // Draw holes
2379 int holes_count = outline->HoleCount( ii );
2380
2381 for( int jj = 0; jj < holes_count; ++jj )
2382 m_gal->DrawPolyline( outline->CHole( ii, jj ) );
2383 }
2384
2385 // Draw hatch lines
2386 for( const SEG& hatchLine : aZone->GetHatchLines() )
2387 m_gal->DrawLine( hatchLine.A, hatchLine.B );
2388 }
2389 }
2390
2391 // Draw the filling
2392 if( IsZoneFillLayer( aLayer )
2393 && ( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED
2395 || displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) )
2396 {
2397 const std::shared_ptr<SHAPE_POLY_SET>& polySet = aZone->GetFilledPolysList( layer );
2398
2399 if( polySet->OutlineCount() == 0 ) // Nothing to draw
2400 return;
2401
2404 m_gal->SetLineWidth( 0 );
2405
2406 if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
2407 {
2408 m_gal->SetIsFill( true );
2409 m_gal->SetIsStroke( false );
2410 }
2411 else
2412 {
2413 m_gal->SetIsFill( false );
2414 m_gal->SetIsStroke( true );
2415 }
2416
2417 m_gal->DrawPolygon( *polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION );
2418 }
2419}
2420
2421
2422void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
2423{
2424 const COLOR4D& color = m_pcbSettings.GetColor( aDimension, aLayer );
2425
2428 m_gal->SetIsFill( false );
2429 m_gal->SetIsStroke( true );
2430
2432
2433 if( outline_mode )
2435 else
2437
2438 // Draw dimension shapes
2439 // TODO(JE) lift this out
2440 for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
2441 {
2442 switch( shape->Type() )
2443 {
2444 case SH_SEGMENT:
2445 {
2446 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
2447 m_gal->DrawLine( seg.A, seg.B );
2448 break;
2449 }
2450
2451 case SH_CIRCLE:
2452 {
2453 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
2454 m_gal->DrawCircle( shape->Centre(), radius );
2455 break;
2456 }
2457
2458 default:
2459 break;
2460 }
2461 }
2462
2463 // Draw text
2464 const PCB_TEXT& text = aDimension->Text();
2465 wxString resolvedText = text.GetShownText();
2466 TEXT_ATTRIBUTES attrs = text.GetAttributes();
2467
2468 if( m_gal->IsFlippedX() && !( aDimension->GetLayerSet() & LSET::SideSpecificMask() ).any() )
2469 attrs.m_Mirrored = !attrs.m_Mirrored;
2470
2471 if( outline_mode )
2473 else
2474 attrs.m_StrokeWidth = getLineThickness( text.GetEffectiveTextPenWidth() );
2475
2476 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2477
2478 if( text.GetFont() && text.GetFont()->IsOutline() )
2479 cache = text.GetRenderCache( text.GetFont(), resolvedText );
2480
2481 if( cache )
2482 {
2483 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
2484 m_gal->DrawGlyph( *glyph.get() );
2485 }
2486 else
2487 {
2488 strokeText( resolvedText, text.GetTextPos(), attrs );
2489 }
2490}
2491
2492
2493void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
2494{
2495 const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
2496 VECTOR2D position( aTarget->GetPosition() );
2497 double size, radius;
2498
2499 m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
2500 m_gal->SetStrokeColor( strokeColor );
2501 m_gal->SetIsFill( false );
2502 m_gal->SetIsStroke( true );
2503
2504 m_gal->Save();
2505 m_gal->Translate( position );
2506
2507 if( aTarget->GetShape() )
2508 {
2509 // shape x
2510 m_gal->Rotate( M_PI / 4.0 );
2511 size = 2.0 * aTarget->GetSize() / 3.0;
2512 radius = aTarget->GetSize() / 2.0;
2513 }
2514 else
2515 {
2516 // shape +
2517 size = aTarget->GetSize() / 2.0;
2518 radius = aTarget->GetSize() / 3.0;
2519 }
2520
2521 m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
2522 m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
2523 m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
2524
2525 m_gal->Restore();
2526}
2527
2528
2529void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer )
2530{
2531 bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
2532
2533 // Don't paint shadows for invisible markers.
2534 // It would be nice to do this through layer dependencies but we can't do an "or" there today
2535 if( isShadow && aMarker->GetBoard()
2536 && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
2537 {
2538 return;
2539 }
2540
2541 const_cast<PCB_MARKER*>( aMarker )->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) );
2542
2543 SHAPE_LINE_CHAIN polygon;
2544 aMarker->ShapeToPolygon( polygon );
2545
2547 : aMarker->GetColorLayer() );
2548
2549 m_gal->Save();
2550 m_gal->Translate( aMarker->GetPosition() );
2551
2552 if( isShadow )
2553 {
2555 m_gal->SetIsStroke( true );
2556 m_gal->SetLineWidth( aMarker->MarkerScale() );
2557 }
2558 else
2559 {
2561 m_gal->SetIsFill( true );
2562 }
2563
2564 m_gal->DrawPolygon( polygon );
2565 m_gal->Restore();
2566}
2567
2568
int color
Definition: DXF_plotter.cpp:57
const char * name
Definition: DXF_plotter.cpp:56
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
@ ALL
Net/netclass colors are shown on all net copper.
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetClassName() const
Returns the name of the effective netclass.
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
wxString GetShortNetname() const
Container for design settings for a BOARD object.
int GetHolePlatingThickness() const
Pad & via drills are finish size.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
virtual bool IsKnockout() const
Definition: board_item.h:250
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.cpp:184
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:43
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:185
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Definition: board_item.cpp:239
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:526
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:540
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:592
void SetOrigin(const Vec &pos)
Definition: box2.h:202
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
const Vec & GetPosition() const
Definition: box2.h:184
const Vec & GetOrigin() const
Definition: box2.h:183
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
const Vec GetEnd() const
Definition: box2.h:185
Vec Centre() const
Definition: box2.h:70
const Vec & GetSize() const
Definition: box2.h:179
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
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
EDA_ANGLE Normalize90()
Definition: eda_angle.h:260
double AsRadians() const
Definition: eda_angle.h:153
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:251
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsEntered() const
Definition: eda_item.h:108
bool IsSelected() const
Definition: eda_item.h:107
bool IsBrightened() const
Definition: eda_item.h:110
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:144
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:179
virtual VECTOR2I GetTopLeft() const
Definition: eda_shape.h:167
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:289
bool IsFilled() const
Definition: eda_shape.h:90
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:490
int GetRadius() const
Definition: eda_shape.cpp:511
SHAPE_T GetShape() const
Definition: eda_shape.h:113
virtual VECTOR2I GetBotRight() const
Definition: eda_shape.h:168
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1023
int GetWidth() const
Definition: eda_shape.h:109
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:176
bool IsAnnotationProxy() const
Definition: eda_shape.h:87
void TransformBoundingBoxToPolygon(SHAPE_POLY_SET *aBuffer, int aClearance) const
Convert the text bounding box to a rectangular polygon depending on the text orientation,...
Definition: eda_text.cpp:945
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
bool IsItalic() const
Definition: eda_text.h:130
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
Definition: eda_text.cpp:451
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:318
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
bool IsBold() const
Definition: eda_text.h:133
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
LSET GetPrivateLayers() const
Definition: footprint.h:120
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:925
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.cpp:2203
VECTOR2I GetPosition() const override
Definition: footprint.h:188
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:794
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: fp_textbox.cpp:393
VECTOR2I GetDrawPos() const override
Definition: fp_textbox.cpp:191
virtual EDA_ANGLE GetDrawRotation() const override
Definition: fp_textbox.cpp:134
virtual EDA_ANGLE GetDrawRotation() const override
Definition: fp_text.cpp:247
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:415
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:93
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:159
virtual bool IsStroke() const
Definition: font.h:112
virtual bool IsOutline() const
Definition: font.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:321
static const COLOR4D CLEAR
Definition: color4d.h:395
COLOR4D & Darken(double aFactor)
Makes the color darker by a given factor.
Definition: color4d.h:242
COLOR4D Inverted() const
Returns an inverted color, alpha remains the same.
Definition: color4d.h:333
COLOR4D & Brighten(double aFactor)
Makes the color brighter by a given factor.
Definition: color4d.h:225
double a
Alpha component.
Definition: color4d.h:387
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:390
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 DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth=0, int aTotal=1)
Draw a polygon representing a font glyph.
virtual void Rotate(double aAngle)
Rotate the context.
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)
double GetZoomFactor() const
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual void Restore()
Restore the context.
virtual bool IsOpenGlEngine()
Return true if the GAL engine is a OpenGL based type.
void ResetTextAttributes()
Reset text attributes to default styling.
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 DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
Draw a cubic bezier spline.
void SetFontItalic(bool aItalic)
virtual void DrawBitmap(const BITMAP_BASE &aBitmap, double alphaBlend=1.0)
Draw a bitmap image.
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.
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
virtual void Save()
Save the context.
virtual void DrawSegmentChain(const std::vector< VECTOR2D > &aPointList, double aWidth)
Draw a chain of rounded segments.
double GetWorldScale() const
Get the world scale.
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 void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle)
Draw an arc.
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
virtual SHAPE_SEGMENT getPadHoleShape(const PAD *aPad) const
Return hole shape for a pad (internal units).
PCB_PAINTER(GAL *aGal, FRAME_T aFrameType)
int getLineThickness(int aActualThickness) const
Get the thickness to draw for a line (e.g.
PCB_VIEWERS_SETTINGS_BASE * viewer_settings()
Definition: pcb_painter.cpp:80
void draw(const PCB_TRACK *aTrack, int aLayer)
void strokeText(const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs)
virtual int getDrillShape(const PAD *aPad) const
Return drill shape of a pad.
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:218
virtual int getViaDrillSize(const PCB_VIA *aVia) const
Return drill diameter for a via (internal units).
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.
double m_zoneOpacity
Opacity override for filled zones.
Definition: pcb_painter.h:148
double m_trackOpacity
Opacity override for all tracks.
Definition: pcb_painter.h:145
double m_imageOpacity
Opacity override for user images.
Definition: pcb_painter.h:149
double m_viaOpacity
Opacity override for all types of via.
Definition: pcb_painter.h:146
ZONE_DISPLAY_MODE m_ZoneDisplayMode
Definition: pcb_painter.h:125
void LoadColors(const COLOR_SETTINGS *aSettings) override
double m_padOpacity
Opacity override for SMD pads and PTHs.
Definition: pcb_painter.h:147
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
Definition: pcb_painter.h:102
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...
HIGH_CONTRAST_MODE m_ContrastModeDisplay
Definition: pcb_painter.h:126
std::map< int, KIGFX::COLOR4D > m_netColors
Set of net codes that should not have their ratsnest displayed.
Definition: pcb_painter.h:139
NET_COLOR_MODE m_netColorMode
Overrides for specific netclass colors.
Definition: pcb_painter.h:133
static const double MAX_FONT_SIZE
< Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:130
std::map< wxString, KIGFX::COLOR4D > m_netclassColors
Overrides for specific net colors, stored as netcodes for the ratsnest to access easily.
Definition: pcb_painter.h:136
bool GetShowPageLimits() const override
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Load settings related to display options (high-contrast mode, full or outline modes for vias/pads/tra...
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
void SetGapLengthRatio(double aRatio)
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
PCB_LAYER_ID GetActiveLayer() const
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.
void SetDashLengthRatio(double aRatio)
COLOR4D m_layerColors[LAYER_ID_COUNT]
std::set< int > m_highlightNetcodes
bool m_hiContrastEnabled
Parameters for display modes.
bool GetDrawBoundingBoxes() const
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:491
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
static LSET SideSpecificMask()
Definition: lset.cpp:908
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:870
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:68
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:373
Definition: pad.h:59
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return an item's "own" clearance in internal units.
Definition: pad.cpp:795
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:378
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:622
int GetSolderMaskExpansion() const
Definition: pad.cpp:821
const VECTOR2I & GetDrillSize() const
Definition: pad.h:262
PAD_ATTRIB GetAttribute() const
Definition: pad.h:395
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition: pad.cpp:1573
const wxString & GetNumber() const
Definition: pad.h:135
VECTOR2I GetPosition() const override
Definition: pad.h:197
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:325
bool IsNoConnectPad() const
Definition: pad.cpp:165
bool IsFreePad() const
Definition: pad.cpp:172
PAD_SHAPE GetShape() const
Definition: pad.h:189
bool FlashLayer(int aLayer) const
Check to see whether the pad should be flashed on the specific layer.
Definition: pad.cpp:250
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:866
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:357
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:394
const VECTOR2I & GetSize() const
Definition: pad.h:252
DISPLAY_OPTIONS m_Display
EDA_ANGLE GetArcAngleStart() const
Definition: pcb_track.cpp:1120
double GetRadius() const
Definition: pcb_track.cpp:1105
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:1111
const VECTOR2I & GetMid() const
Definition: pcb_track.h:310
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_track.h:319
Object to handle a bitmap image that can be inserted in a PCB.
Definition: pcb_bitmap.h:42
VECTOR2I GetPosition() const override
Definition: pcb_bitmap.h:117
double GetImageScale() const
Definition: pcb_bitmap.h:65
const VECTOR2I GetSize() const
Definition: pcb_bitmap.cpp:140
BITMAP_BASE * GetImage() const
Definition: pcb_bitmap.h:53
Abstract dimension API.
Definition: pcb_dimension.h:96
int GetLineThickness() const
PCB_TEXT & Text()
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
double m_TrackOpacity
Opacity override for all tracks.
double m_ZoneOpacity
Opacity override for filled zone areas.
double m_ImageOpacity
Opacity override for user images.
double m_PadOpacity
Opacity override for SMD pads and PTHs.
double m_ViaOpacity
Opacity override for all types of via.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
NET_COLOR_MODE m_NetColorMode
How to use color overrides on specific nets and netclasses.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_group.cpp:276
wxString GetName() const
Definition: pcb_group.h:65
GAL_LAYER_ID GetColorLayer() const
Definition: pcb_marker.cpp:310
VECTOR2I GetPosition() const override
Definition: pcb_marker.h:68
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:67
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:252
std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:133
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:71
int GetShape() const
Definition: pcb_target.h:58
int GetWidth() const
Definition: pcb_target.h:64
int GetSize() const
Definition: pcb_target.h:61
VECTOR2I GetPosition() const override
Definition: pcb_target.h:55
VECTOR2I GetDrawPos() const override
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition: pcb_text.cpp:326
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:55
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: pcb_track.cpp:285
int GetWidth() const
Definition: pcb_track.h:106
const VECTOR2I & GetStart() const
Definition: pcb_track.h:112
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:109
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
Definition: pcb_track.cpp:601
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: pcb_track.cpp:192
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
Definition: pcb_track.cpp:542
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
int Length() const
Return the length (this).
Definition: seg.h:326
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:464
int GetRadius() const
Definition: shape_circle.h:108
const VECTOR2I GetCenter() const
Definition: shape_circle.h:113
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 VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
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 Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
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 HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
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...
SHAPE_LINE_CHAIN & Outline(int aIndex)
int NewOutline()
Creates a new hole in a given outline.
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const SEG & GetSeg() const
int GetWidth() const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:42
const SHAPE_LINE_CHAIN & Vertices() const
Return the list of vertices defining this simple polygon.
Definition: shape_simple.h:124
virtual const SEG GetSegment(int aIndex) const override
Definition: shape_simple.h:174
const VECTOR2I & CPoint(int aIndex) const
Return a const reference to a given point in the polygon.
Definition: shape_simple.h:102
int PointCount() const
Return the number of points (vertices) in this polygon.
Definition: shape_simple.h:88
virtual size_t GetSegmentCount() const override
Definition: shape_simple.h:176
An abstract shape on 2D plane.
Definition: shape.h:123
static void Stroke(const SHAPE *aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
PLOT_DASH_TYPE GetPlotStyle() const
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:761
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:602
SHAPE_POLY_SET * Outline()
Definition: zone.h:312
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:314
@ MAGENTA
Definition: color4d.h:60
@ CYAN
Definition: color4d.h:58
void TransformArcToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
Definition: cvpcb.cpp:125
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:409
static constexpr EDA_ANGLE & FULL_CIRCLE
Definition: eda_angle.h:410
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
#define ENTERED
indicates a group has been entered
@ LAST
marker for list end
E_SERIE r
Definition: eserie.cpp:41
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_CVPCB_DISPLAY
Definition: frame_type.h:49
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_WIZARD
Definition: frame_type.h:44
@ FRAME_FOOTPRINT_PREVIEW
Definition: frame_type.h:46
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
@ FRAME_PCB_DISPLAY3D
Definition: frame_type.h:45
@ FRAME_CVPCB
Definition: frame_type.h:48
a few functions useful in geometry calculations.
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_OUTSIDE
@ ERROR_INSIDE
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
int GetPenSizeForNormal(int aTextSize)
Definition: gr_text.cpp:52
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Returns the margin for knockout text.
Definition: gr_text.h:97
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer)
Definition: layer_ids.h:165
@ LAYER_PAD_BK_NETNAMES
Definition: layer_ids.h:166
@ LAYER_PAD_NETNAMES
Definition: layer_ids.h:167
@ LAYER_VIA_NETNAMES
Definition: layer_ids.h:168
bool IsPcbLayer(int aLayer)
Test whether a layer is a valid layer for Pcbnew.
Definition: layer_ids.h:814
bool IsNetCopperLayer(int aLayer)
Checks if the given layer is "net copper", meaning it is eligible for net coloring.
Definition: layer_ids.h:1014
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:966
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825
@ GAL_LAYER_ID_START
Definition: layer_ids.h:191
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:239
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:234
@ LAYER_CONFLICTS_SHADOW
shadow layer for items flagged conficting
Definition: layer_ids.h:241
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
Definition: layer_ids.h:197
@ LAYER_PAD_FR
smd pads, front layer
Definition: layer_ids.h:202
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:220
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition: layer_ids.h:214
@ GAL_LAYER_ID_END
Definition: layer_ids.h:260
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
Definition: layer_ids.h:253
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
Definition: layer_ids.h:201
@ LAYER_PAD_BK
smd pads, back layer
Definition: layer_ids.h:203
@ LAYER_PADS_TH
multilayer pads, usually with holes
Definition: layer_ids.h:213
@ LAYER_MARKER_SHADOWS
shadows for drc markers
Definition: layer_ids.h:237
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:215
@ LAYER_VIA_MICROVIA
to draw micro vias
Definition: layer_ids.h:194
@ LAYER_VIA_THROUGH
to draw usual through hole vias
Definition: layer_ids.h:196
@ LAYER_VIA_BBLIND
to draw blind/buried vias
Definition: layer_ids.h:195
@ LAYER_PAD_HOLEWALLS
Definition: layer_ids.h:233
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition: layer_ids.h:989
bool IsHoleLayer(int aLayer)
Definition: layer_ids.h:864
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ F_CrtYd
Definition: layer_ids.h:117
@ F_Paste
Definition: layer_ids.h:101
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ F_SilkS
Definition: layer_ids.h:104
@ B_CrtYd
Definition: layer_ids.h:116
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137
@ F_Cu
Definition: layer_ids.h:64
bool IsZoneFillLayer(int aLayer)
Definition: layer_ids.h:995
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:266
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
@ NPTH
like PAD_PTH, but not plated
@ PTH
Plated through hole pad.
PCBNEW_SETTINGS * pcbconfig()
Definition: pcb_painter.cpp:72
@ BLIND_BURIED
@ SHOW_WITH_VIA_ALWAYS
see class PGM_BASE
@ SH_RECT
axis-aligned rectangle
Definition: shape.h:44
@ SH_CIRCLE
circle
Definition: shape.h:47
@ SH_SIMPLE
simple polygon
Definition: shape.h:48
@ SH_SEGMENT
line segment
Definition: shape.h:45
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
wxString UnescapeString(const wxString &aSource)
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
TRACK_CLEARANCE_MODE m_TrackClearance
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618