KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
22 */
23
24#include <advanced_config.h>
25#include <board.h>
26#include <netinfo.h>
28#include <pcb_drill_chart.h>
29#include <pcb_drill_map.h>
30#include <pcb_track.h>
31#include <pcb_group.h>
32#include <footprint.h>
33#include <pad.h>
34#include <pcb_shape.h>
35#include <string_utils.h>
36#include <zone.h>
37#include <pcb_reference_image.h>
38#include <pcb_text.h>
39#include <pcb_textbox.h>
44#include <pcb_table.h>
45#include <pcb_tablecell.h>
46#include <pcb_marker.h>
47#include <pcb_dimension.h>
48#include <pcb_point.h>
49#include <pcb_barcode.h>
50#include <pcb_target.h>
51#include <pcb_board_outline.h>
52#include <pcb_grid_item.h>
53
54#include <layer_ids.h>
55#include <lset.h>
56#include <pcb_painter.h>
57#include <pcb_display_options.h>
63#include <pcbnew_settings.h>
65
68#include <callback_gal.h>
71#include <geometry/shape_rect.h>
73#include <geometry/roundrect.h>
77#include <geometry/shape_arc.h>
78#include <stroke_params.h>
79#include <bezier_curves.h>
80#include <kiface_base.h>
81#include <gr_text.h>
82#include <pgm_base.h>
83
84using namespace KIGFX;
85
86
88{
89 return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
90}
91
92// Helpers for display options existing in Cvpcb and Pcbnew
93// Note, when running Cvpcb, pcbconfig() returns nullptr and viewer_settings()
94// returns the viewer options existing to Cvpcb and Pcbnew
116
117
119{
120 m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
124
125 m_trackOpacity = 1.0;
126 m_viaOpacity = 1.0;
127 m_padOpacity = 1.0;
128 m_zoneOpacity = 1.0;
129 m_imageOpacity = 1.0;
131
132 m_groupEditModeActive = false;
134
136
137 m_PadEditModePad = nullptr;
138
139 SetDashLengthRatio( 12 ); // From ISO 128-2
140 SetGapLengthRatio( 3 ); // From ISO 128-2
141
143
144 update();
145}
146
147
149{
151
152 // Init board layers colors:
153 for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
154 {
155 m_layerColors[i] = aSettings->GetColor( i );
156
157 // Guard: if the alpha channel is too small, the layer is not visible.
158 if( m_layerColors[i].a < 0.2 )
159 m_layerColors[i].a = 0.2;
160 }
161
162 // Init specific graphic layers colors:
163 for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
164 m_layerColors[i] = aSettings->GetColor( i );
165
166 // A per-board-layer GAL layer is unknown to every theme and resolves to UNSPECIFIED,
167 // which is transparent, so take the colour of the documentation layer hosting the map
168 for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
170
171 // Colors for layers that aren't theme-able
174
175 // Netnames for copper layers
176 const COLOR4D lightLabel = aSettings->GetColor( NETNAMES_LAYER_ID_START );
177 const COLOR4D darkLabel = lightLabel.Inverted();
178
179 for( PCB_LAYER_ID layer : LSET::AllCuMask().CuStack() )
180 {
181 if( m_layerColors[layer].GetBrightness() > 0.5 )
182 m_layerColors[GetNetnameLayer( layer )] = darkLabel;
183 else
184 m_layerColors[GetNetnameLayer( layer )] = lightLabel;
185 }
186
187 if( PgmOrNull() ) // can be null if used without project (i.e. from python script)
189 else
190 m_hiContrastFactor = 1.0f - 0.8f; // default value
191
192 update();
193}
194
195
211
212
213COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
214{
215 return GetColor( dynamic_cast<const BOARD_ITEM*>( aItem ), aLayer );
216}
217
218
220{
221 if( aLayer < 0 || aLayer >= MAX_LAYERS_FOR_VIEW || !m_canvasFadedLayers.test( aLayer ) )
222 return false;
223
224 // These through-hole pads follow the via layer's colour and activity, not their own
225 if( IsPadCopperLayer( aLayer ) && pcbconfig() && pcbconfig()->m_Display.m_UseViaColorForNormalTHPadstacks )
226 return false;
227
228 return true;
229}
230
231
232bool PCB_RENDER_SETTINGS::GetLayerDim( int aLayer, COLOR4D& aToward, double& aKeep ) const
233{
234 if( !IsCanvasFadedLayer( aLayer ) )
235 return false;
236
237 auto it = m_layerColors.find( LAYER_PCB_BACKGROUND );
238 const COLOR4D background = it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
239
240 // Net highlight fades every item it does not highlight towards black
241 aToward = COLOR4D::BLACK;
243
244 // Mirrors GetColor in dimmed high contrast, where zones, pad and via copper and clearance
245 // outlines follow their copper layer
246 int base = aLayer;
247
248 if( IsZoneFillLayer( aLayer ) )
249 base = aLayer - LAYER_ZONE_START;
250 else if( IsPadCopperLayer( aLayer ) )
251 base = aLayer - LAYER_PAD_COPPER_START;
252 else if( IsViaCopperLayer( aLayer ) )
253 base = aLayer - LAYER_VIA_COPPER_START;
254 else if( IsClearanceLayer( aLayer ) )
255 base = aLayer - LAYER_CLEARANCE_START;
256
258 && !m_highContrastLayers.count( base ) )
260 const double contrast = base == Edge_Cuts ? std::max( m_hiContrastFactor, 0.3f ) : m_hiContrastFactor;
261
262 // GetColor mixes c * keep with the background, which equals one fade keeping keep * contrast
263 // of c towards a colour with the same background share
264 const double keep = aKeep * contrast;
265 const double share = keep < 1.0 ? ( 1.0 - contrast ) / ( 1.0 - keep ) : 0.0;
266
267 aToward = COLOR4D( background.r * share, background.g * share, background.b * share, 1.0 );
268 aKeep = keep;
269 }
270
271 return true;
272}
273
274
276{
277 const BOARD_ITEM* item = dynamic_cast<const BOARD_ITEM*>( aItem );
278
279 if( !item )
280 return false;
281
282 // Must match the items GetColor leaves out of high contrast dimming
283 if( item->IsBrightened() || item->IsSelected() )
284 return true;
285
286 if( m_highlightEnabled && item->IsConnected() && item->IsOnCopperLayer() )
287 return m_highlightNetcodes.count( static_cast<const BOARD_CONNECTED_ITEM*>( item )->GetNetCode() ) > 0;
288
289 return false;
290}
291
292
294{
295 if( aItem->IsEntered() )
296 return true;
297
298 EDA_GROUP* pg = aItem->GetParentGroup();
299
300 if( !pg && aItem->GetParent() )
301 pg = aItem->GetParent()->GetParentGroup();
302
303 while( pg )
304 {
305 if( pg->AsEdaItem()->IsEntered() )
306 return true;
307
308 pg = pg->AsEdaItem()->GetParentGroup();
309 }
310
311 return false;
312}
313
314
315COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) const
316{
317 int netCode = -1;
318 int originalLayer = aLayer;
319
320 if( aLayer == LAYER_MARKER_SHADOWS )
321 return m_backgroundColor.WithAlpha( 0.5 );
322
323 if( aLayer == LAYER_LOCKED_ITEM_SHADOW || aLayer == LAYER_CONSTRAINT_SHADOW )
324 {
325 COLOR4D color = m_layerColors.at( aLayer );
326
327 // Dim shadows of items outside the currently-entered group
328 if( m_groupEditModeActive && m_outsideGroupOpacity < 1.0 && aItem && !isInEnteredGroup( aItem ) )
329 color.a *= m_outsideGroupOpacity;
330
331 return color;
332 }
333
334 // SMD pads use the copper netname layer
335 if( aLayer == LAYER_PAD_FR_NETNAMES )
336 aLayer = GetNetnameLayer( F_Cu );
337 else if( aLayer == LAYER_PAD_BK_NETNAMES )
338 aLayer = GetNetnameLayer( B_Cu );
339
340 if( IsHoleLayer( aLayer ) && m_isPrinting )
341 {
342 // Careful that we don't end up with the same colour for the annular ring and the hole
343 // when printing in B&W.
344 const PAD* pad = dynamic_cast<const PAD*>( aItem );
345 const PCB_VIA* via = dynamic_cast<const PCB_VIA*>( aItem );
346 int holeLayer = aLayer;
347 int annularRingLayer = UNDEFINED_LAYER;
348
349 if( pad && pad->GetAttribute() == PAD_ATTRIB::PTH )
350 {
351 LSET copperLayers = pad->GetLayerSet() & LSET::AllCuMask();
352
353 if( !copperLayers.empty() )
354 annularRingLayer = copperLayers.Seq().front();
355 }
356 else if( via )
357 {
358 annularRingLayer = F_Cu;
359 }
360
361 if( annularRingLayer != UNDEFINED_LAYER )
362 {
363 auto it = m_layerColors.find( holeLayer );
364 auto it2 = m_layerColors.find( annularRingLayer );
365
366 if( it != m_layerColors.end() && it2 != m_layerColors.end() && it->second == it2->second )
367 aLayer = LAYER_PCB_BACKGROUND;
368 }
369 }
370
371 // Zones should pull from the copper layer
372 if( aItem && aItem->Type() == PCB_ZONE_T )
373 {
374 if( IsZoneFillLayer( aLayer ) )
375 aLayer = aLayer - LAYER_ZONE_START;
376 }
377
378 // Points use the LAYER_POINTS color for their virtual per-layer layers
379 if( IsPointsLayer( aLayer ) )
380 aLayer = LAYER_POINTS;
381
382 // Pad and via copper and clearance outlines take their color from the copper layer
383 if( IsPadCopperLayer( aLayer ) )
384 {
385 if( pcbconfig() && aItem && aItem->Type() == PCB_PAD_T )
386 {
387 const PAD* pad = static_cast<const PAD*>( aItem );
388
389 // Old-skool display for people who struggle with change
390 if( pcbconfig()->m_Display.m_UseViaColorForNormalTHPadstacks
391 && pad->GetAttribute() == PAD_ATTRIB::PTH
392 && pad->Padstack().Mode() == PADSTACK::MODE::NORMAL )
393 {
394 aLayer = LAYER_VIA_HOLES;
395 }
396 else
397 {
398 aLayer = aLayer - LAYER_PAD_COPPER_START;
399 }
400 }
401 else
402 {
403 aLayer = aLayer - LAYER_PAD_COPPER_START;
404 }
405 }
406 else if( IsViaCopperLayer( aLayer ) )
407 aLayer = aLayer - LAYER_VIA_COPPER_START;
408 else if( IsClearanceLayer( aLayer ) )
409 aLayer = aLayer - LAYER_CLEARANCE_START;
410
411 // Use via "golden copper" hole color for pad hole walls for contrast
412 else if( aLayer == LAYER_PAD_HOLEWALLS )
413 aLayer = LAYER_VIA_HOLES;
414
415 // Show via mask layers if appropriate
416 if( aLayer == LAYER_VIA_THROUGH && !m_isPrinting )
417 {
418 if( aItem && aItem->GetBoard() )
419 {
420 LSET visibleLayers = aItem->GetBoard()->GetVisibleLayers()
421 & aItem->GetBoard()->GetEnabledLayers()
422 & aItem->GetLayerSet();
423
424 if( GetActiveLayer() == F_Mask && visibleLayers.test( F_Mask ) )
425 {
426 aLayer = F_Mask;
427 }
428 else if( GetActiveLayer() == B_Mask && visibleLayers.test( B_Mask ) )
429 {
430 aLayer = B_Mask;
431 }
432 else if( ( visibleLayers & LSET::AllCuMask() ).none() )
433 {
434 if( visibleLayers.any() )
435 aLayer = visibleLayers.Seq().back();
436 }
437 }
438 }
439
440 // Normal path: get the layer base color
441 auto it = m_layerColors.find( aLayer );
442 COLOR4D color = it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
443
444 if( !aItem )
445 return color;
446
447 // Selection disambiguation
448 if( aItem->IsBrightened() || ( aItem->Type() == PCB_MARKER_T && aItem->IsSelected() ) )
449 {
450 if( aItem->Type() == PCB_MARKER_T )
451 {
452 auto itemLayerIter = m_layerColors.find( LAYER_DRC_HIGHLIGHTED );
453
454 if( itemLayerIter != m_layerColors.end() )
455 return itemLayerIter->second;
456 }
457
458 return color.Brightened( m_selectFactor ).WithAlpha( 0.8 );
459 }
460
461 // Normal selection
462 if( aItem->IsSelected() )
463 {
464 // Selection for tables is done with a background wash, so pass in nullptr to GetColor()
465 // so we just get the "normal" (un-selected/un-brightened) color for the borders.
466 if( BaseType( aItem->Type() ) != PCB_TABLE_T && aItem->Type() != PCB_TABLECELL_T )
467 {
468 auto it_selected = m_layerColorsSel.find( aLayer );
469 color = it_selected == m_layerColorsSel.end() ? color.Brightened( 0.8 ) : it_selected->second;
470 }
471 }
472
473 // Some graphic objects are BOARD_CONNECTED_ITEM, but they are seen here as
474 // actually board connected objects only if on a copper layer
475 const BOARD_CONNECTED_ITEM* conItem = nullptr;
476
477 if( aItem->IsConnected() && aItem->IsOnCopperLayer() )
478 conItem = static_cast<const BOARD_CONNECTED_ITEM*>( aItem );
479
480 // Try to obtain the netcode for the aItem
481 if( conItem )
482 netCode = conItem->GetNetCode();
483
484 bool highlighted = m_highlightEnabled && m_highlightNetcodes.count( netCode );
485 bool selected = aItem->IsSelected();
486
487 // Apply net color overrides
488 if( conItem && m_netColorMode == NET_COLOR_MODE::ALL && IsCopperLayer( aLayer ) )
489 {
490 COLOR4D netColor = COLOR4D::UNSPECIFIED;
491
492 auto ii = m_netColors.find( netCode );
493
494 if( ii != m_netColors.end() )
495 netColor = ii->second;
496
497 if( netColor == COLOR4D::UNSPECIFIED )
498 {
499 const NETCLASS* nc = conItem->GetEffectiveNetClass();
500
501 if( nc->HasPcbColor() )
502 netColor = nc->GetPcbColor();
503 }
504
505 if( netColor == COLOR4D::UNSPECIFIED )
506 netColor = color;
507
508 if( selected )
509 {
510 // Selection brightening overrides highlighting
511 netColor.Brighten( m_selectFactor );
512 }
513 else if( m_highlightEnabled )
514 {
515 // Highlight brightens objects on all layers and darkens everything else. The canvas
516 // darkens layers it fades itself, see GetLayerDim.
517 if( highlighted )
518 netColor.Brighten( m_highlightFactor );
519 else if( !IsCanvasFadedLayer( originalLayer ) )
520 netColor.Darken( 1.0 - m_highlightFactor );
521 }
522
523 color = netColor;
524 }
525 else if( !selected && m_highlightEnabled )
526 {
527 // Single net highlight mode
528 if( m_highlightNetcodes.contains( netCode ) )
529 {
530 auto it_hi = m_layerColorsHi.find( aLayer );
531 color = it_hi == m_layerColorsHi.end() ? color.Brightened( m_highlightFactor ) : it_hi->second;
532 }
533 else if( !IsCanvasFadedLayer( originalLayer ) )
534 {
535 auto it_dark = m_layerColorsDark.find( aLayer );
536 color = it_dark == m_layerColorsDark.end() ? color.Darkened( 1.0 - m_highlightFactor ) : it_dark->second;
537 }
538 }
539
540 // Apply high-contrast dimming
541 if( m_hiContrastEnabled && m_highContrastLayers.size() && !highlighted && !selected )
542 {
544 bool isActive = m_highContrastLayers.count( aLayer );
545 bool hide = false;
546
547 switch( originalLayer )
548 {
549 case LAYER_PADS:
550 {
551 const PAD* pad = static_cast<const PAD*>( aItem );
552
553 if( pad->IsOnLayer( primary ) && !pad->FlashLayer( primary ) )
554 {
555 isActive = false;
556
557 if( IsCopperLayer( primary ) )
558 hide = true;
559 }
560
562 isActive = false;
563
564 break;
565 }
566
567 case LAYER_VIA_BLIND:
568 case LAYER_VIA_BURIED:
570 {
571 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
572
573 // Target graphic is active if the via crosses the primary layer
574 if( via->GetLayerSet().test( primary ) == 0 )
575 {
576 isActive = false;
577 hide = true;
578 }
579
580 break;
581 }
582
584 {
585 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
586
587 if( !via->FlashLayer( primary ) )
588 {
589 isActive = false;
590
591 if( IsCopperLayer( primary ) )
592 hide = true;
593 }
594
595 break;
596 }
597
601 // Pad holes are active is any physical layer is active
602 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
603 isActive = false;
604
605 break;
606
607 case LAYER_VIA_HOLES:
609 {
610 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
611
612 if( via->GetViaType() == VIATYPE::THROUGH )
613 {
614 // A through via's hole is active if any physical layer is active
615 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
616 isActive = false;
617 }
618 else
619 {
620 // A blind/buried or micro via's hole is active if it crosses the primary layer
621 if( via->GetLayerSet().test( primary ) == 0 )
622 isActive = false;
623 }
624
625 break;
626 }
627
628 case LAYER_DRC_ERROR:
631 isActive = true;
632 break;
633
634 default:
635 break;
636 }
637
638 if( !isActive )
639 {
640 // Graphics on Edge_Cuts layer are not fully dimmed or hidden because they are
641 // useful when working on another layer
642 // We could use a dim factor = m_hiContrastFactor, but to have a sufficient
643 // contrast whenever m_hiContrastFactor value, we clamp the factor to 0.3f
644 // (arbitray choice after tests)
645 float dim_factor_Edge_Cuts = std::max( m_hiContrastFactor, 0.3f );
646
648 || IsNetnameLayer( aLayer )
649 || hide )
650 {
651 if( originalLayer == Edge_Cuts )
652 {
654
655 if( it != m_layerColors.end() )
656 color = color.Mix( it->second, dim_factor_Edge_Cuts );
657 else
658 color = color.Mix( COLOR4D::BLACK, dim_factor_Edge_Cuts );
659 }
660 else
661 color = COLOR4D::CLEAR;
662 }
663 else if( !IsCanvasFadedLayer( originalLayer ) )
664 {
665 // The canvas fades the other layers as a whole, see GetLayerDim
667 COLOR4D backgroundColor = it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
668
669 if( originalLayer == Edge_Cuts )
670 color = color.Mix( backgroundColor, dim_factor_Edge_Cuts );
671 else
672 color = color.Mix( backgroundColor, m_hiContrastFactor );
673
674 // Reference images can't have their color mixed so just reduce the opacity a bit
675 // so they show through less
676 if( aItem->Type() == PCB_REFERENCE_IMAGE_T )
677 color.a *= m_hiContrastFactor;
678 }
679 }
680 }
681 else if( originalLayer == LAYER_VIA_BLIND
682 || originalLayer == LAYER_VIA_BURIED
683 || originalLayer == LAYER_VIA_MICROVIA )
684 {
685 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
686 const BOARD* board = via->GetBoard();
687 LSET visibleLayers = LSET::AllLayersMask();
688
689 if( board )
690 visibleLayers = board->GetVisibleLayers() & board->GetEnabledLayers();
691
692 // Target graphic is visible if the via crosses a visible layer
693 if( ( via->GetLayerSet() & visibleLayers ).none() )
694 color = COLOR4D::CLEAR;
695 }
696
697 // Dim items outside the currently-entered group
699 {
700 if( !isInEnteredGroup( aItem ) )
701 color.a *= m_outsideGroupOpacity;
702 }
703
704 // Apply per-type opacity overrides
705 if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
706 color.a *= m_trackOpacity;
707 else if( aItem->Type() == PCB_VIA_T )
708 color.a *= m_viaOpacity;
709 else if( aItem->Type() == PCB_PAD_T )
710 color.a *= m_padOpacity;
711 else if( aItem->Type() == PCB_ZONE_T && static_cast<const ZONE*>( aItem )->IsTeardropArea() )
712 color.a *= m_trackOpacity;
713 else if( aItem->Type() == PCB_ZONE_T )
714 color.a *= m_zoneOpacity;
715 else if( aItem->Type() == PCB_REFERENCE_IMAGE_T )
716 color.a *= m_imageOpacity;
717 else if( aItem->Type() == PCB_SHAPE_T && static_cast<const PCB_SHAPE*>( aItem )->IsAnyFill() )
718 color.a *= m_filledShapeOpacity;
719 else if( aItem->Type() == PCB_SHAPE_T && aItem->IsOnCopperLayer() )
720 color.a *= m_trackOpacity;
721
722 if( aItem->GetForcedTransparency() > 0.0 )
723 color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForcedTransparency() ) );
724
725 // No special modifiers enabled
726 return color;
727}
728
729
734
735
737 PAINTER( aGal ),
738 m_frameType( aFrameType ),
742{
743}
744
745
746int PCB_PAINTER::getLineThickness( int aActualThickness ) const
747{
748 // if items have 0 thickness, draw them with the outline
749 // width, otherwise respect the set value (which, no matter
750 // how small will produce something)
751 if( aActualThickness == 0 )
752 return KiROUND( m_pcbSettings.m_outlineWidth );
753
754 return aActualThickness;
755}
756
757
759{
760 return aPad->GetDrillShape();
761}
762
763
765{
766 SHAPE_SEGMENT segm = *aPad->GetEffectiveHoleShape();
767 return segm;
768}
769
770
771int PCB_PAINTER::getViaDrillSize( const PCB_VIA* aVia ) const
772{
773 return aVia->GetDrillValue();
774}
775
776
777bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
778{
779 if( !aItem->IsBOARD_ITEM() )
780 return false;
781
782 const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( aItem );
783
784 if( const BOARD* board = item->GetBoard() )
785 {
786 const BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
790
791 if( item->GetParentFootprint() && !board->IsFootprintHolder() )
792 {
793 FOOTPRINT* parentFP = item->GetParentFootprint();
794
795 // Never draw footprint reference images on board
796 if( item->Type() == PCB_REFERENCE_IMAGE_T )
797 {
798 return false;
799 }
800 else if( item->GetLayerSet().count() > 1 )
801 {
802 // For multi-layer objects, exclude only those layers that are private
803 if( IsPcbLayer( aLayer ) && parentFP->GetPrivateLayers().test( aLayer ) )
804 return false;
805 }
806 else if( item->GetLayerSet().count() == 1 )
807 {
808 // For single-layer objects, exclude all layers including ancillary layers
809 // such as holes, netnames, etc.
810 PCB_LAYER_ID singleLayer = item->GetLayerSet().ExtractLayer();
811
812 if( parentFP->GetPrivateLayers().test( singleLayer ) )
813 return false;
814 }
815 }
816 }
817 else
818 {
821 }
822
823 // the "cast" applied in here clarifies which overloaded draw() is called
824 switch( item->Type() )
825 {
826 case PCB_TRACE_T:
827 draw( static_cast<const PCB_TRACK*>( item ), aLayer );
828 break;
829
830 case PCB_ARC_T:
831 draw( static_cast<const PCB_ARC*>( item ), aLayer );
832 break;
833
834 case PCB_VIA_T:
835 if( IsDrillSymbolLayer( aLayer ) )
836 drawDrillSymbol( item, aLayer );
837 else
838 draw( static_cast<const PCB_VIA*>( item ), aLayer );
839
840 break;
841
842 case PCB_PAD_T:
843 if( IsDrillSymbolLayer( aLayer ) )
844 drawDrillSymbol( item, aLayer );
845 else
846 draw( static_cast<const PAD*>( item ), aLayer );
847
848 break;
849
850 case PCB_SHAPE_T:
851 draw( static_cast<const PCB_SHAPE*>( item ), aLayer );
852 break;
853
855 draw( static_cast<const PCB_REFERENCE_IMAGE*>( item ), aLayer );
856 break;
857
858 case PCB_FIELD_T:
859 draw( static_cast<const PCB_FIELD*>( item ), aLayer );
860 break;
861
862 case PCB_TEXT_T:
863 draw( static_cast<const PCB_TEXT*>( item ), aLayer );
864 break;
865
866 case PCB_TEXTBOX_T:
867 draw( static_cast<const PCB_TEXTBOX*>( item ), aLayer );
868 break;
869
870 case PCB_TABLE_T:
872 draw( static_cast<const PCB_TABLE*>( item ), aLayer );
873 break;
874
876 {
877 const PCB_DRILL_CHART* chart = static_cast<const PCB_DRILL_CHART*>( item );
878
879 // Before the table, whose selection wash is drawn last and would otherwise bury the
880 // marks the way it does not bury the cell text
881 drawChartSymbols( chart, aLayer );
882 draw( static_cast<const PCB_TABLE*>( item ), aLayer );
883 break;
884 }
885
886 case PCB_DRILL_MAP_T:
887 draw( static_cast<const PCB_DRILL_MAP*>( item ), aLayer );
888 break;
889
890 case PCB_FOOTPRINT_T:
891 draw( static_cast<const FOOTPRINT*>( item ), aLayer );
892 break;
893
894 case PCB_GROUP_T:
895 draw( static_cast<const PCB_GROUP*>( item ), aLayer );
896 break;
897
898 case PCB_ZONE_T:
899 draw( static_cast<const ZONE*>( item ), aLayer );
900 break;
901
903 case PCB_DIM_CENTER_T:
904 case PCB_DIM_RADIAL_T:
906 case PCB_DIM_LEADER_T:
907 draw( static_cast<const PCB_DIMENSION_BASE*>( item ), aLayer );
908 break;
909
910 case PCB_BARCODE_T:
911 draw( static_cast<const PCB_BARCODE*>( item ), aLayer );
912 break;
913
914 case PCB_TARGET_T:
915 draw( static_cast<const PCB_TARGET*>( item ) );
916 break;
917
918 case PCB_POINT_T:
919 draw( static_cast<const PCB_POINT*>( item ), aLayer );
920 break;
921
922 case PCB_GRID_ITEM_T:
923 draw( static_cast<const PCB_GRID_ITEM*>( item ), aLayer );
924 break;
925
926 case PCB_MARKER_T:
927 draw( static_cast<const PCB_MARKER*>( item ), aLayer );
928 break;
929
931 draw( static_cast<const PCB_BOARD_OUTLINE*>( item ), aLayer );
932 break;
933
934 default:
935 // Painter does not know how to draw the object
936 return false;
937 }
938
939 // Draw bounding boxes after drawing objects so they can be seen.
940 if( m_pcbSettings.GetDrawBoundingBoxes() )
941 {
942 // Show bounding boxes of painted objects for debugging.
943 BOX2I box = item->GetBoundingBox();
944
945 m_gal->SetIsFill( false );
946 m_gal->SetIsStroke( true );
947
948 if( item->Type() == PCB_FOOTPRINT_T )
949 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) : COLOR4D( MAGENTA ) );
950 else
951 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) : COLOR4D( 0.4, 0.4, 0.4, 1 ) );
952
953 m_gal->SetLineWidth( 1 );
954 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
955
956 if( item->Type() == PCB_FOOTPRINT_T )
957 {
958 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) : COLOR4D( CYAN ) );
959
960 const FOOTPRINT* fp = static_cast<const FOOTPRINT*>( item );
961
962 if( fp )
963 {
964 const SHAPE_POLY_SET& convex = fp->GetBoundingHull();
965
966 m_gal->DrawPolyline( convex.COutline( 0 ) );
967 }
968 }
969 }
970
971 return true;
972}
973
974
975void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
976{
977 const VECTOR2I& start = aTrack->GetStart();
978 const VECTOR2I& end = aTrack->GetEnd();
979 int track_width = aTrack->GetWidth();
980 COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
981
982 // If a chain highlight is active and the track belongs to the highlighted chain, and the chain
983 // has a colour override configured on the board, prefer that colour. Only do this when we're
984 // drawing the actual copper (not netname labels, clearance outlines, etc.).
985 if( IsCopperLayer( aLayer ) && !m_pcbSettings.m_highlightedNetChain.IsEmpty() )
986 {
987 if( NETINFO_ITEM* netinfo = aTrack->GetNet() )
988 {
989 if( netinfo->GetNetChain() == m_pcbSettings.m_highlightedNetChain )
990 {
991 if( const BOARD* board = aTrack->GetBoard() )
992 {
993 COLOR4D chainColor = board->GetNetChainColor( m_pcbSettings.m_highlightedNetChain );
994
995 if( chainColor != COLOR4D::UNSPECIFIED )
996 color = chainColor.WithAlpha( color.a );
997 }
998 }
999 }
1000 }
1001
1002 if( IsNetnameLayer( aLayer ) )
1003 {
1004 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
1005 return;
1006
1007 if( aTrack->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
1008 return;
1009
1010 SHAPE_SEGMENT trackShape( { aTrack->GetStart(), aTrack->GetEnd() }, aTrack->GetWidth() );
1011 renderNetNameForSegment( trackShape, color, aTrack->GetDisplayNetname() );
1012 return;
1013 }
1014 else if( IsCopperLayer( aLayer ) || IsSolderMaskLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW )
1015 {
1016 bool outline_mode = pcbconfig()
1018 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
1019
1020 if( IsSolderMaskLayer( aLayer ) )
1021 track_width = track_width + aTrack->GetSolderMaskExpansion() * 2;
1022
1023 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1024 track_width = track_width + m_lockedShadowMargin;
1025
1026 if( !outline_mode )
1027 {
1028 // Tracks are the most common primitive, so they bypass the generic fill and stroke path
1029 m_gal->DrawTrack( VECTOR2D( start ), VECTOR2D( end ), track_width, color );
1030 }
1031 else
1032 {
1033 m_gal->SetStrokeColor( color );
1034 m_gal->SetIsStroke( true );
1035 m_gal->SetIsFill( false );
1036 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1037 m_gal->DrawSegment( start, end, track_width );
1038 }
1039 }
1040
1041 // Clearance lines
1042 if( IsClearanceLayer( aLayer )
1043 && pcbconfig()
1044 && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
1045 && !m_pcbSettings.m_isPrinting )
1046 {
1047 const PCB_LAYER_ID copperLayerForClearance = ToLAYER_ID( aLayer - LAYER_CLEARANCE_START );
1048
1049 int clearance = aTrack->GetOwnClearance( copperLayerForClearance );
1050
1051 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1052 m_gal->SetIsFill( false );
1053 m_gal->SetIsStroke( true );
1054 m_gal->SetStrokeColor( color );
1055 m_gal->DrawSegment( start, end, track_width + clearance * 2 );
1056 }
1057}
1058
1059
1061 const wxString& aNetName ) const
1062{
1063 // When drawing netnames, clip the track to the viewport
1064 BOX2D viewport;
1065 VECTOR2D screenSize = m_gal->GetScreenPixelSize();
1066 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
1067
1068 viewport.SetOrigin( VECTOR2D( matrix * VECTOR2D( 0, 0 ) ) );
1069 viewport.SetEnd( VECTOR2D( matrix * screenSize ) );
1070 viewport.Normalize();
1071
1072 // Calc the approximate size of the netname (assume square chars)
1073 int nameSize = (int) aNetName.size() * aSeg.GetWidth();
1074
1075 // Check if the track is long enough to have a netname displayed
1076 if( aSeg.GetSeg().SquaredLength() < SEG::Square( nameSize ) )
1077 return;
1078
1079 double textSize = aSeg.GetWidth();
1080 double penWidth = textSize / 12.0;
1081 EDA_ANGLE textOrientation;
1082 int num_names = 1;
1083
1084 VECTOR2I start = aSeg.GetSeg().A;
1085 VECTOR2I end = aSeg.GetSeg().B;
1086 VECTOR2D segV = end - start;
1087
1088 if( end.y == start.y ) // horizontal
1089 {
1090 textOrientation = ANGLE_HORIZONTAL;
1091 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / viewport.GetWidth() ) );
1092 }
1093 else if( end.x == start.x ) // vertical
1094 {
1095 textOrientation = ANGLE_VERTICAL;
1096 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / viewport.GetHeight() ) );
1097 }
1098 else
1099 {
1100 textOrientation = -EDA_ANGLE( segV );
1101 textOrientation.Normalize90();
1102
1103 double min_size = std::min( viewport.GetWidth(), viewport.GetHeight() );
1104 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / ( M_SQRT2 * min_size ) ) );
1105 }
1106
1107 m_gal->SetIsStroke( true );
1108 m_gal->SetIsFill( false );
1109 m_gal->SetStrokeColor( aColor );
1110 m_gal->SetLineWidth( penWidth );
1111 m_gal->SetFontBold( false );
1112 m_gal->SetFontItalic( false );
1113 m_gal->SetFontUnderlined( false );
1114 m_gal->SetTextMirrored( false );
1115 m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
1116 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
1117 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
1118
1119 int divisions = num_names + 1;
1120
1121 for( int ii = 1; ii < divisions; ++ii )
1122 {
1123 VECTOR2I textPosition = start + segV * ( (double) ii / divisions );
1124
1125 if( viewport.Contains( textPosition ) )
1126 m_gal->BitmapText( aNetName, textPosition, textOrientation );
1127 }
1128}
1129
1130
1131void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
1132{
1133 COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
1134
1135 // If a chain highlight is active and the track belongs to the highlighted chain, and the chain
1136 // has a colour override configured on the board, prefer that colour. Only do this when we're
1137 // drawing the actual copper (not netname labels, clearance outlines, etc.).
1138 if( IsCopperLayer( aLayer ) && !m_pcbSettings.m_highlightedNetChain.IsEmpty() )
1139 {
1140 if( NETINFO_ITEM* netinfo = aArc->GetNet() )
1141 {
1142 if( netinfo->GetNetChain() == m_pcbSettings.m_highlightedNetChain )
1143 {
1144 if( const BOARD* board = aArc->GetBoard() )
1145 {
1146 COLOR4D chainColor = board->GetNetChainColor( m_pcbSettings.m_highlightedNetChain );
1147
1148 if( chainColor != COLOR4D::UNSPECIFIED )
1149 color = chainColor.WithAlpha( color.a );
1150 }
1151 }
1152 }
1153 }
1154
1155 VECTOR2D center( aArc->GetCenter() );
1156 int width = aArc->GetWidth();
1157 double radius = aArc->GetRadius();
1158 EDA_ANGLE start_angle = aArc->GetArcAngleStart();
1159 EDA_ANGLE angle = aArc->GetAngle();
1160
1161 // GetRadius() clamps a runaway centre but GetCenter() does not, thus the two disagree and
1162 // the copper draws far from the track. The plotter substitutes the chord for this reason.
1163 bool degenerate = aArc->IsDegenerated( 10 /* in IU */ );
1164
1165 if( IsNetnameLayer( aLayer ) )
1166 {
1167 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
1168 return;
1169
1170 if( aArc->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
1171 return;
1172
1173 const wxString& netname = aArc->GetDisplayNetname();
1174
1175 if( netname.IsEmpty() )
1176 return;
1177
1178 // Radius and centre disagree here, thus the arc length and the tangent are meaningless
1179 if( degenerate )
1180 {
1181 const SHAPE_SEGMENT chord( { aArc->GetStart(), aArc->GetEnd() }, width );
1182 renderNetNameForSegment( chord, color, netname );
1183 return;
1184 }
1185
1186 // Calc the approximate size of the netname (assume square chars)
1187 int nameSize = (int) netname.size() * width;
1188
1189 // Arc length must accommodate the label length.
1190 if( aArc->GetLength() < nameSize )
1191 return;
1192
1193 // Tangent at the arc midpoint is perpendicular to the radius there.
1194 VECTOR2I midPt = aArc->GetMid();
1195 VECTOR2D radial = VECTOR2D( midPt ) - center;
1196 EDA_ANGLE textOrientation( VECTOR2D( -radial.y, radial.x ) );
1197 textOrientation = -textOrientation;
1198 textOrientation.Normalize90();
1199
1200 double textSize = width;
1201 double penWidth = textSize / 12.0;
1202
1203 m_gal->SetIsStroke( true );
1204 m_gal->SetIsFill( false );
1205 m_gal->SetStrokeColor( color );
1206 m_gal->SetLineWidth( penWidth );
1207 m_gal->SetFontBold( false );
1208 m_gal->SetFontItalic( false );
1209 m_gal->SetFontUnderlined( false );
1210 m_gal->SetTextMirrored( false );
1211 m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
1212 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
1213 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
1214
1215 m_gal->BitmapText( netname, midPt, textOrientation );
1216 return;
1217 }
1218 else if( IsCopperLayer( aLayer ) || IsSolderMaskLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW )
1219 {
1220 // Draw a regular track
1221 bool outline_mode = pcbconfig()
1223 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
1224 m_gal->SetStrokeColor( color );
1225 m_gal->SetFillColor( color );
1226 m_gal->SetIsStroke( outline_mode );
1227 m_gal->SetIsFill( not outline_mode );
1228 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1229
1230 if( IsSolderMaskLayer( aLayer ) )
1231 width = width + aArc->GetSolderMaskExpansion() * 2;
1232
1233 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1234 width = width + m_lockedShadowMargin;
1235
1236 if( degenerate )
1237 m_gal->DrawSegment( aArc->GetStart(), aArc->GetEnd(), width );
1238 else
1239 m_gal->DrawArcSegment( center, radius, start_angle, angle, width, m_maxError );
1240 }
1241
1242 // Clearance lines
1243 if( IsClearanceLayer( aLayer )
1244 && pcbconfig()
1245 && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
1246 && !m_pcbSettings.m_isPrinting )
1247 {
1248 const PCB_LAYER_ID copperLayerForClearance = ToLAYER_ID( aLayer - LAYER_CLEARANCE_START );
1249
1250 int clearance = aArc->GetOwnClearance( copperLayerForClearance );
1251
1252 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1253 m_gal->SetIsFill( false );
1254 m_gal->SetIsStroke( true );
1255 m_gal->SetStrokeColor( color );
1256
1257 if( degenerate )
1258 m_gal->DrawSegment( aArc->GetStart(), aArc->GetEnd(), width + clearance * 2 );
1259 else
1260 m_gal->DrawArcSegment( center, radius, start_angle, angle, width + clearance * 2, m_maxError );
1261 }
1262
1263#if 0
1264 // Debug only: enable this code only to test the TransformArcToPolygon function and display the polygon
1265 // outline created by it.
1266 // arcs on F_Cu are approximated with ERROR_INSIDE, others with ERROR_OUTSIDE
1267 SHAPE_POLY_SET cornerBuffer;
1269 TransformArcToPolygon( cornerBuffer, aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), width,
1270 m_maxError, errorloc );
1271 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1272 m_gal->SetIsFill( false );
1273 m_gal->SetIsStroke( true );
1274 m_gal->SetStrokeColor( COLOR4D( 0, 0, 1.0, 1.0 ) );
1275 m_gal->DrawPolygon( cornerBuffer );
1276#endif
1277
1278#if 0
1279 // Debug only: enable this code only to test the arc geometry.
1280 // Draw 3 lines from arc center to arc start, arc middle, arc end to show how the arc is defined
1281 SHAPE_ARC arc( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), m_pcbSettings.m_outlineWidth );
1282 m_gal->SetIsFill( false );
1283 m_gal->SetIsStroke( true );
1284 m_gal->SetStrokeColor( COLOR4D( 0, 0, 1.0, 1.0 ) );
1285 m_gal->DrawSegment( arc.GetStart(), arc.GetCenter(), m_pcbSettings.m_outlineWidth );
1286 m_gal->DrawSegment( aArc->GetFocusPosition(), arc.GetCenter(), m_pcbSettings.m_outlineWidth );
1287 m_gal->DrawSegment( arc.GetEnd(), arc.GetCenter(), m_pcbSettings.m_outlineWidth );
1288#endif
1289
1290#if 0
1291 // Debug only: enable this code only to test the SHAPE_ARC::ConvertToPolyline function and display the
1292 // polyline created by it.
1293 SHAPE_ARC arc( aArc->GetCenter(), aArc->GetStart(), aArc->GetAngle(), aArc->GetWidth() );
1295 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1296 m_gal->SetIsFill( false );
1297 m_gal->SetIsStroke( true );
1298 m_gal->SetStrokeColor( COLOR4D( 0.3, 0.2, 0.5, 1.0 ) );
1299
1300 for( int idx = 1; idx < arcSpine.PointCount(); idx++ )
1301 m_gal->DrawSegment( arcSpine.CPoint( idx-1 ), arcSpine.CPoint( idx ), aArc->GetWidth() );
1302#endif
1303}
1304
1305
1306static bool viaHoleShowsLayerPair( const PCB_VIA* aVia )
1307{
1308 PCB_LAYER_ID layerTop, layerBottom;
1309 aVia->LayerPair( &layerTop, &layerBottom );
1310
1311 return aVia->GetViaType() == VIATYPE::BLIND || aVia->GetViaType() == VIATYPE::BURIED
1312 || ( aVia->GetViaType() == VIATYPE::MICROVIA && ( layerTop != F_Cu || layerBottom != B_Cu ) );
1313}
1314
1315
1316bool PCB_PAINTER::HasUniformColor( const VIEW_ITEM* aItem, int aLayer ) const
1317{
1318 if( !aItem->IsBOARD_ITEM() )
1319 return true;
1320
1321 const bool holeLayer = aLayer == LAYER_VIA_HOLES || aLayer == LAYER_VIA_HOLEWALLS;
1322
1323 switch( static_cast<const BOARD_ITEM*>( aItem )->Type() )
1324 {
1325 case PCB_PAD_T:
1326 {
1327 const PAD* pad = static_cast<const PAD*>( aItem );
1328 const NETINFO_ITEM* net = pad->GetNet();
1329
1330 // A net's terminal pads gain and lose their emphasis box with the net highlight
1331 if( net && ( net->GetTerminalPad( 0 ) == pad || net->GetTerminalPad( 1 ) == pad ) )
1332 return false;
1333
1334 if( aLayer != LAYER_PAD_HOLEWALLS )
1335 return true;
1336
1337 return pad->GetDrillSize().x <= 0 || ( pad->GetSecondaryDrillSizeX() <= 0 && pad->GetTertiaryDrillSizeX() <= 0 );
1338 }
1339
1340 case PCB_VIA_T:
1341 {
1342 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
1343
1344 if( !holeLayer )
1345 return true;
1346
1347 if( aLayer == LAYER_VIA_HOLES )
1348 return !viaHoleShowsLayerPair( via );
1349
1350 return via->GetSecondaryDrillSize().value_or( 0 ) <= 0 && via->GetTertiaryDrillSize().value_or( 0 ) <= 0;
1351 }
1352
1353 // A cached image takes its opacity from the settings, which only a repaint can apply
1355 return false;
1356
1357 // A zone's outline and hatch are drawn opaque whatever the zone opacity, so its outline does not
1358 // take the zone's colour
1359 case PCB_ZONE_T:
1360 return !ZoneOutlineDrawnOnLayer( zoneOutlineOnly( static_cast<const ZONE*>( aItem ) ), aLayer );
1361
1362 default:
1363 return true;
1364 }
1365}
1366
1367
1368bool PCB_PAINTER::zoneOutlineOnly( const ZONE* aZone ) const
1369{
1370 return aZone->GetIsRuleArea()
1371 || ( !aZone->IsTeardropArea() && m_pcbSettings.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE );
1372}
1373
1374
1375void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
1376{
1377 const BOARD* board = aVia->GetBoard();
1378 COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
1379 VECTOR2D center( aVia->GetStart() );
1380
1381 // draw hidden vias transparent not skipped so a recolour restores them without re-tessellating
1382
1383 // Chain highlight colour override for copper/hole layers.
1384 if( board && !m_pcbSettings.m_highlightedNetChain.IsEmpty()
1385 && ( IsCopperLayer( aLayer ) || IsViaCopperLayer( aLayer )
1386 || aLayer == LAYER_VIA_HOLES ) )
1387 {
1388 if( NETINFO_ITEM* netinfo = aVia->GetNet() )
1389 {
1390 if( netinfo->GetNetChain() == m_pcbSettings.m_highlightedNetChain )
1391 {
1392 COLOR4D chainColor = board->GetNetChainColor( m_pcbSettings.m_highlightedNetChain );
1393
1394 if( chainColor != COLOR4D::UNSPECIFIED )
1395 color = chainColor.WithAlpha( color.a );
1396 }
1397 }
1398 }
1399
1400 const int copperLayer = IsViaCopperLayer( aLayer ) ? aLayer - LAYER_VIA_COPPER_START : aLayer;
1401
1402 PCB_LAYER_ID currentLayer = ToLAYER_ID( copperLayer );
1403 PCB_LAYER_ID layerTop, layerBottom;
1404 aVia->LayerPair( &layerTop, &layerBottom );
1405
1406 // Blind/buried vias (and microvias) will use different hole and label rendering
1407 bool isBlindBuried = viaHoleShowsLayerPair( aVia );
1408
1409 // Draw description layer
1410 if( IsNetnameLayer( aLayer ) )
1411 {
1412 VECTOR2D position( center );
1413
1414 // Is anything that we can display enabled (netname and/or layers ids)?
1415 bool showNets = pcbconfig() && pcbconfig()->m_Display.m_NetNames != 0
1416 && !aVia->GetNetname().empty();
1417 bool showLayers = aVia->GetViaType() != VIATYPE::THROUGH;
1418
1419 if( !showNets && !showLayers )
1420 return;
1421
1422 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
1423 double size = aVia->GetWidth( currentLayer );
1424
1425 // Font size limits
1426 if( size > maxSize )
1427 size = maxSize;
1428
1429 m_gal->Save();
1430 m_gal->Translate( position );
1431
1432 // Default font settings
1433 m_gal->ResetTextAttributes();
1434 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
1435 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
1436 m_gal->SetFontBold( false );
1437 m_gal->SetFontItalic( false );
1438 m_gal->SetFontUnderlined( false );
1439 m_gal->SetTextMirrored( false );
1440 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, aLayer ) );
1441 m_gal->SetIsStroke( true );
1442 m_gal->SetIsFill( false );
1443
1444 // Set the text position via position. if only one text, it is on the via position
1445 // For 2 lines, the netname is slightly below the center, and the layer IDs above
1446 // the netname
1447 VECTOR2D textpos( 0.0, 0.0 );
1448
1449 const wxString& netname = aVia->GetDisplayNetname();
1450
1451 PCB_LAYER_ID topLayerId = aVia->TopLayer();
1452 PCB_LAYER_ID bottomLayerId = aVia->BottomLayer();
1453 int topLayer; // The via top layer number (from 1 to copper layer count)
1454 int bottomLayer; // The via bottom layer number (from 1 to copper layer count)
1455
1456 switch( topLayerId )
1457 {
1458 case F_Cu: topLayer = 1; break;
1459 case B_Cu: topLayer = aVia->BoardCopperLayerCount(); break;
1460 default: topLayer = (topLayerId - B_Cu)/2 + 1; break;
1461 }
1462
1463 switch( bottomLayerId )
1464 {
1465 case F_Cu: bottomLayer = 1; break;
1466 case B_Cu: bottomLayer = aVia->BoardCopperLayerCount(); break;
1467 default: bottomLayer = (bottomLayerId - B_Cu)/2 + 1; break;
1468 }
1469
1470 wxString layerIds;
1471#if wxUSE_UNICODE_WCHAR
1472 layerIds << std::to_wstring( topLayer ) << L'-' << std::to_wstring( bottomLayer );
1473#else
1474 layerIds << std::to_string( topLayer ) << '-' << std::to_string( bottomLayer );
1475#endif
1476
1477 // a good size is set room for at least 6 chars, to be able to print 2 lines of text,
1478 // or at least 3 chars for only the netname
1479 // (The layerIds string has 5 chars max)
1480 int minCharCnt = showLayers ? 6 : 3;
1481
1482 // approximate the size of netname and layerIds text:
1483 double tsize = 1.5 * size / std::max( PrintableCharCount( netname ), minCharCnt );
1484 tsize = std::min( tsize, size );
1485
1486 // Use a smaller text size to handle interline, pen size..
1487 tsize *= 0.75;
1488 VECTOR2D namesize( tsize, tsize );
1489
1490 // For 2 lines, adjust the text pos (move it a small amount to the bottom)
1491 if( showLayers && showNets )
1492 textpos.y += ( tsize * 1.3 )/ 2;
1493
1494 m_gal->SetGlyphSize( namesize );
1495 m_gal->SetLineWidth( namesize.x / 10.0 );
1496
1497 if( showNets )
1498 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
1499
1500 if( showLayers )
1501 {
1502 if( showNets )
1503 textpos.y -= tsize * 1.3;
1504
1505 m_gal->BitmapText( layerIds, textpos, ANGLE_HORIZONTAL );
1506 }
1507
1508 m_gal->Restore();
1509
1510 return;
1511 }
1512
1513 bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayViaFill;
1514
1515 m_gal->SetStrokeColor( color );
1516 m_gal->SetFillColor( color );
1517 m_gal->SetIsStroke( true );
1518 m_gal->SetIsFill( false );
1519
1520 if( outline_mode )
1521 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1522
1523 if( aLayer == LAYER_VIA_HOLEWALLS )
1524 {
1526 double drillRadius = getViaDrillSize( aVia ) / 2.0;
1527 double maxRadius = aVia->GetWidth( layerTop ) / 2.0;
1528 double radius = drillRadius + thickness;
1529
1530 // Clamp the hole wall so it doesn't extend beyond the via's copper
1531 if( radius > maxRadius )
1532 {
1533 radius = maxRadius;
1534 thickness = radius - drillRadius;
1535 }
1536
1537 if( thickness <= 0 )
1538 return;
1539
1540 if( !outline_mode )
1541 {
1542 m_gal->SetLineWidth( thickness );
1543 radius -= thickness / 2.0;
1544 }
1545
1546 // Underpaint the hole so that there aren't artifacts at its edge
1547 m_gal->SetIsFill( true );
1548
1549 m_gal->DrawCircle( center, radius );
1550
1551 // Draw backdrill indicators (semi-circles extending into the hole) on top of the
1552 // hole wall so they remain visible regardless of layer rendering order
1553 if( !m_pcbSettings.IsPrinting() )
1554 {
1555 std::optional<int> secDrill = aVia->GetSecondaryDrillSize();
1556 std::optional<int> terDrill = aVia->GetTertiaryDrillSize();
1557
1558 if( secDrill.value_or( 0 ) > 0 )
1559 drawBackdrillIndicator( aVia, center, *secDrill, aVia->GetSecondaryDrillEndLayer(), 0 );
1560
1561 if( terDrill.value_or( 0 ) > 0 )
1562 drawBackdrillIndicator( aVia, center, *terDrill, aVia->GetTertiaryDrillEndLayer(), 1 );
1563 }
1564 }
1565 else if( aLayer == LAYER_VIA_HOLES )
1566 {
1567 double radius = getViaDrillSize( aVia ) / 2.0;
1568
1569 m_gal->SetIsStroke( false );
1570 m_gal->SetIsFill( true );
1571
1572 if( isBlindBuried && !m_pcbSettings.IsPrinting() )
1573 {
1574 m_gal->SetIsStroke( false );
1575 m_gal->SetIsFill( true );
1576
1577 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
1578 m_gal->DrawArc( center, radius, EDA_ANGLE( 180, DEGREES_T ), EDA_ANGLE( 180, DEGREES_T ) );
1579
1580 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
1581 m_gal->DrawArc( center, radius, EDA_ANGLE( 0, DEGREES_T ), EDA_ANGLE( 180, DEGREES_T ) );
1582 }
1583 else
1584 {
1585 m_gal->DrawCircle( center, radius );
1586 }
1587
1588 }
1589 else if( ( aLayer == F_Mask && aVia->IsOnLayer( F_Mask ) )
1590 || ( aLayer == B_Mask && aVia->IsOnLayer( B_Mask ) ) )
1591 {
1592 int margin = board ? board->GetDesignSettings().m_SolderMaskExpansion : 0;
1593
1594 m_gal->SetIsFill( true );
1595 m_gal->SetIsStroke( false );
1596
1597 m_gal->SetLineWidth( margin );
1598 m_gal->DrawCircle( center, aVia->GetWidth( currentLayer ) / 2.0 + margin );
1599 }
1600 else if( m_pcbSettings.IsPrinting() || IsCopperLayer( currentLayer ) )
1601 {
1602 int annular_width = KiROUND( ( aVia->GetWidth( currentLayer ) - getViaDrillSize( aVia ) ) / 2.0 );
1603 double radius = aVia->GetWidth( currentLayer ) / 2.0;
1604 bool draw = false;
1605
1606 if( m_pcbSettings.IsPrinting() )
1607 {
1608 draw = aVia->FlashLayer( m_pcbSettings.GetPrintLayers() );
1609 }
1610 else if( aVia->IsSelected() )
1611 {
1612 draw = true;
1613 }
1614 else if( !board || aVia->FlashLayer( board->GetVisibleLayers() & board->GetEnabledLayers() ) )
1615 {
1616 draw = true;
1617 }
1618
1619 if( !aVia->FlashLayer( currentLayer ) )
1620 draw = false;
1621
1622 if( !outline_mode )
1623 {
1624 m_gal->SetLineWidth( annular_width );
1625 radius -= annular_width / 2.0;
1626 }
1627
1628 if( draw )
1629 m_gal->DrawCircle( center, radius );
1630
1631 // Draw post-machining indicator if this layer is post-machined
1632 if( !m_pcbSettings.IsPrinting() && draw )
1633 {
1634 drawPostMachiningIndicator( aVia, center, currentLayer );
1635 }
1636 }
1637 else if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // draw a ring around the via
1638 {
1639 m_gal->SetLineWidth( m_lockedShadowMargin );
1640
1641 m_gal->DrawCircle( center, ( aVia->GetWidth( currentLayer ) + m_lockedShadowMargin ) / 2.0 );
1642 }
1643
1644 // Clearance lines
1645 if( IsClearanceLayer( aLayer )
1646 && pcbconfig()
1647 && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
1648 && !m_pcbSettings.m_isPrinting )
1649 {
1650 const PCB_LAYER_ID copperLayerForClearance = ToLAYER_ID( aLayer - LAYER_CLEARANCE_START );
1651
1652 double radius;
1653
1654 if( aVia->FlashLayer( copperLayerForClearance ) )
1655 radius = aVia->GetWidth( copperLayerForClearance ) / 2.0;
1656 else
1658
1659 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1660 m_gal->SetIsFill( false );
1661 m_gal->SetIsStroke( true );
1662 m_gal->SetStrokeColor( color );
1663 m_gal->DrawCircle( center, radius + aVia->GetOwnClearance( copperLayerForClearance ) );
1664 }
1665}
1666
1667
1668// A shape mark has no text, so the cells are empty and the symbol column would otherwise
1669// print blank on every chart using the default policy
1670void PCB_PAINTER::drawChartSymbols( const PCB_DRILL_CHART* aChart, int aLayer )
1671{
1672 if( aChart->GetSymbolColumn() < 0 || aChart->RowShapes().empty() )
1673 return;
1674
1675 const BOARD* board = aChart->GetBoard();
1676
1677 if( !board )
1678 return;
1679
1681
1682 m_gal->SetIsFill( false );
1683 m_gal->SetIsStroke( true );
1684 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aChart, aLayer ) );
1685 m_gal->SetLineWidth( profile.GetSymbolWidth() );
1686
1687 for( const auto& [row, shapeIndex] : aChart->RowShapes() )
1688 {
1689 const PCB_TABLECELL* cell = aChart->GetCell( row, aChart->GetSymbolColumn() );
1690
1691 if( !cell )
1692 continue;
1693
1694 const BOX2I box = cell->GetBoundingBox();
1695 const VECTOR2I centre = box.GetCenter();
1696
1697 // Fitted to the cell so a tall symbol size cannot spill into the neighbouring row
1698 const int radius = std::min<int>( profile.GetSymbolSize() / 2,
1699 std::min( box.GetWidth(), box.GetHeight() ) / 3 );
1700
1701 if( radius <= 0 )
1702 continue;
1703
1704 const unsigned shape = DRILL_MARKERS::CuratedShape( shapeIndex );
1705
1706 for( const DRILL_MARKERS::MARKER_PART& part :
1707 DRILL_MARKERS::BuildMarker( centre, radius, shape ) )
1708 {
1709 switch( part.m_Type )
1710 {
1712 m_gal->DrawLine( part.m_Points.front(), part.m_Points.back() );
1713 break;
1714
1716 for( size_t ii = 0; ii + 1 < part.m_Points.size(); ++ii )
1717 m_gal->DrawLine( part.m_Points[ii], part.m_Points[ii + 1] );
1718
1719 break;
1720
1722 m_gal->DrawCircle( centre, part.m_Radius );
1723 break;
1724 }
1725 }
1726 }
1727}
1728
1729
1730// The holes draw the marks, so without the outline and anchor drawn here there would be
1731// nothing on screen to click and a placed map could not be selected or deleted
1732void PCB_PAINTER::draw( const PCB_DRILL_MAP* aMap, int aLayer )
1733{
1734 const BOARD* board = aMap->GetBoard();
1735
1736 // The plotted width, not the sketch width, because the outline is artwork the map really
1737 // does emit rather than an editing decoration
1738 const int outlineWidth =
1739 board ? std::max<int>( board->GetDesignSettings().GetDrillSymbolProfile().GetSymbolWidth(), 1 ) : 1;
1740
1741 m_gal->SetIsFill( false );
1742 m_gal->SetIsStroke( true );
1743 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aMap, aLayer ) );
1744 m_gal->SetLineWidth( outlineWidth );
1745
1746 const std::shared_ptr<const SHAPE_POLY_SET> outlines = aMap->GetBoardOutlines();
1747
1748 for( int ii = 0; ii < outlines->OutlineCount(); ++ii )
1749 {
1750 m_gal->DrawSegmentChain( outlines->COutline( ii ), outlineWidth );
1751
1752 for( int jj = 0; jj < outlines->HoleCount( ii ); ++jj )
1753 m_gal->DrawSegmentChain( outlines->CHole( ii, jj ), outlineWidth );
1754 }
1755
1756 // Every hole's view bounds were computed for the offset the map had when the drag began,
1757 // so the holes cannot draw the marks where they are now without being culled
1758 if( aMap->IsMoving() && board )
1759 {
1760 const std::shared_ptr<const DRILL_SYMBOL_CACHE> cache = board->DrillSymbolCache();
1761 const COLOR4D markColor = m_pcbSettings.GetColor( aMap, aLayer );
1762
1763 for( const auto& [itemId, entries] : cache->m_ByItem )
1764 drawDrillMarks( aMap, entries, markColor, aMap->GetFontMetrics() );
1765 }
1766
1767 if( !aMap->IsSelected() && !aMap->IsBrightened() )
1768 return;
1769
1770 const int thickness = std::max<int>( m_pcbSettings.m_outlineWidth, 1 );
1771
1772 m_gal->SetLineWidth( thickness );
1773
1774 const BOX2I box = aMap->GetBoundingBox();
1775
1776 if( box.GetWidth() <= 0 || box.GetHeight() <= 0 )
1777 return;
1778
1779 SHAPE_RECT rect( box );
1780
1782 [&]( const VECTOR2I& a, const VECTOR2I& b )
1783 {
1784 m_gal->DrawSegment( a, b, thickness );
1785 } );
1786}
1787
1788
1789// The mark comes from the board's shared symbol profile, so a symbol on screen means the
1790// same hole as that symbol in a plotted chart
1791void PCB_PAINTER::drawDrillSymbol( const BOARD_ITEM* aItem, int aLayer )
1792{
1793 const BOARD* board = aItem->GetBoard();
1794
1795 if( !board )
1796 return;
1797
1798 const std::vector<const PCB_DRILL_MAP*> maps =
1800
1801 if( maps.empty() )
1802 return;
1803
1804 // Held for the duration, because another thread may publish a new snapshot mid-draw
1805 const std::shared_ptr<const DRILL_SYMBOL_CACHE> cache = board->DrillSymbolCache();
1806
1807 const auto it = cache->m_ByItem.find( aItem->m_Uuid );
1808
1809 if( it == cache->m_ByItem.end() )
1810 {
1811 return;
1812 }
1813
1814 const COLOR4D color = m_pcbSettings.GetColor( aItem, aLayer );
1815
1816 // Several maps can share a layer. The UI prevents it but a parsed, pasted or
1817 // API-created board need not
1818 for( const PCB_DRILL_MAP* map : maps )
1819 {
1820 // A map being dragged draws its own marks. The hole's view bounds still describe
1821 // where they were, so drawing them from here would have them culled mid-drag.
1822 if( map->IsMoving() )
1823 continue;
1824
1825 drawDrillMarks( map, it->second, color, aItem->GetFontMetrics() );
1826 }
1827}
1828
1829
1830void PCB_PAINTER::drawDrillMarks( const PCB_DRILL_MAP* aMap, const std::vector<DRILL_SYMBOL_ENTRY>& aEntries,
1831 const COLOR4D& aColor, const KIFONT::METRICS& aFontMetrics )
1832{
1833 const BOARD* board = aMap->GetBoard();
1834
1835 if( !board )
1836 return;
1837
1839
1840 const int symbolSize = aMap->GetSymbolSize();
1841 const int radius = symbolSize / 2;
1842
1843 for( const DRILL_SYMBOL_ENTRY& entry : aEntries )
1844 {
1845 if( !aMap->GetAllSpans() && !( entry.m_Span == aMap->GetSpan() ) )
1846 continue;
1847
1848 // The mark is displaced from the hole it reports. The hole itself never moves
1849 const VECTOR2I pos = entry.m_Position + aMap->GetOffset();
1850
1851 m_gal->SetIsFill( false );
1852 m_gal->SetIsStroke( true );
1853 m_gal->SetStrokeColor( aColor );
1854 m_gal->SetLineWidth( profile.GetSymbolWidth() );
1855
1856 if( entry.m_Symbol.m_MarkMode == DRILL_MARK_MODE::SHAPE )
1857 {
1858 const unsigned shape = DRILL_MARKERS::CuratedShape( entry.m_Symbol.m_ShapeIndex );
1859
1860 for( const DRILL_MARKERS::MARKER_PART& part :
1861 DRILL_MARKERS::BuildMarker( pos, radius, shape ) )
1862 {
1863 switch( part.m_Type )
1864 {
1866 m_gal->DrawLine( part.m_Points.front(), part.m_Points.back() );
1867 break;
1868
1870 for( size_t ii = 0; ii + 1 < part.m_Points.size(); ++ii )
1871 m_gal->DrawLine( part.m_Points[ii], part.m_Points[ii + 1] );
1872
1873 break;
1874
1876 m_gal->DrawCircle( pos, part.m_Radius );
1877 break;
1878 }
1879 }
1880 }
1881 else
1882 {
1883 // The hole's own diameter, not the glyph size, or every hole would be labelled
1884 // with the same number and the screen would disagree with the plot
1885 const wxString text =
1886 entry.m_Symbol.m_MarkMode == DRILL_MARK_MODE::LETTER
1887 ? entry.m_Symbol.m_Letter
1888 : wxString::Format( wxT( "%.2f" ),
1889 pcbIUScale.IUTomm( entry.m_Diameter ) );
1890
1891 TEXT_ATTRIBUTES attrs;
1892 attrs.m_Size = VECTOR2I( symbolSize, symbolSize );
1893 attrs.m_StrokeWidth = profile.GetSymbolWidth();
1896
1897 m_gal->SetIsFill( true );
1898 m_gal->SetFillColor( aColor );
1899 strokeText( text, pos, attrs, aFontMetrics );
1900 }
1901
1902 if( aMap->GetGuideCross() )
1903 {
1904 // Reach matches the plotter exactly rather than 2 * radius, which loses an IU
1905 // for an odd symbol size and makes screen and plot disagree
1906 const int reach = symbolSize;
1907
1908 m_gal->SetIsFill( false );
1909 m_gal->SetIsStroke( true );
1910 m_gal->SetStrokeColor( aColor );
1911 m_gal->SetLineWidth( profile.GetSymbolWidth() );
1912 m_gal->DrawLine( pos - VECTOR2I( reach, 0 ), pos + VECTOR2I( reach, 0 ) );
1913 m_gal->DrawLine( pos - VECTOR2I( 0, reach ), pos + VECTOR2I( 0, reach ) );
1914 }
1915
1916 // A slot's true extent is the cost driver, so it is outlined as well as marked
1917 if( aMap->GetOutlineSlots() && entry.m_IsSlot )
1918 {
1919 // Built the same way the plotter builds its oval, so a rotated or tall slot is
1920 // not drawn as a horizontal one on screen
1921 VECTOR2I size = entry.m_SizeXY;
1922 EDA_ANGLE orientation = entry.m_Orientation;
1923
1924 if( size.x > size.y )
1925 {
1926 std::swap( size.x, size.y );
1928 }
1929
1930 const int half = ( size.y - size.x ) / 2;
1931 const VECTOR2I offset = VECTOR2I( 0, half );
1932 VECTOR2I start = offset;
1933 VECTOR2I end = VECTOR2I( 0, -half );
1934
1935 RotatePoint( start, orientation );
1937
1938 m_gal->SetIsFill( false );
1939 m_gal->SetIsStroke( true );
1940 m_gal->SetStrokeColor( aColor );
1941 m_gal->SetLineWidth( profile.GetSymbolWidth() );
1942 m_gal->DrawSegment( pos + start, pos + end, size.x );
1943 }
1944 }
1945}
1946
1947
1948void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
1949{
1950 COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
1951 const int copperLayer = IsPadCopperLayer( aLayer ) ? aLayer - LAYER_PAD_COPPER_START : aLayer;
1952 PCB_LAYER_ID pcbLayer = static_cast<PCB_LAYER_ID>( copperLayer );
1953
1954 if( IsNetnameLayer( aLayer ) )
1955 {
1956 PCBNEW_SETTINGS::DISPLAY_OPTIONS* displayOpts = pcbconfig() ? &pcbconfig()->m_Display : nullptr;
1957 wxString netname;
1958 wxString padNumber;
1959
1960 if( viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers )
1961 {
1962 padNumber = UnescapeString( aPad->GetNumber() );
1963
1964 if( dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
1965 netname = aPad->GetPinFunction();
1966 }
1967
1968 if( displayOpts && !dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
1969 {
1970 if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
1971 netname = aPad->GetDisplayNetname();
1972
1973 if( aPad->IsNoConnectPad() )
1974 netname = wxT( "x" );
1975 else if( aPad->IsFreePad() )
1976 netname = wxT( "*" );
1977 }
1978
1979 if( netname.IsEmpty() && padNumber.IsEmpty() )
1980 return;
1981
1982 BOX2I padBBox = aPad->GetBoundingBox();
1983 VECTOR2D position = padBBox.Centre();
1984 VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
1985
1986 if( aPad->IsEntered() )
1987 {
1988 FOOTPRINT* fp = aPad->GetParentFootprint();
1989
1990 // Find the number box
1991 for( const BOARD_ITEM* aItem : fp->GraphicalItems() )
1992 {
1993 if( aItem->Type() == PCB_SHAPE_T )
1994 {
1995 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
1996
1997 if( shape->IsProxyItem() && shape->GetShape() == SHAPE_T::RECTANGLE )
1998 {
1999 position = shape->GetCenter();
2000 padsize = shape->GetBotRight() - shape->GetTopLeft();
2001
2002 // We normally draw a bit outside the pad, but this will be somewhat
2003 // unexpected when the user has drawn a box.
2004 padsize *= 0.9;
2005
2006 break;
2007 }
2008 }
2009 }
2010 }
2011 else if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CUSTOM )
2012 {
2013 // See if we have a number box
2014 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives( pcbLayer ) )
2015 {
2016 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
2017 {
2018 position = primitive->GetCenter();
2019 RotatePoint( position, aPad->GetOrientation() );
2020 position += aPad->ShapePos( pcbLayer );
2021
2022 padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
2023 padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
2024
2025 // We normally draw a bit outside the pad, but this will be somewhat
2026 // unexpected when the user has drawn a box.
2027 padsize *= 0.9;
2028
2029 break;
2030 }
2031 }
2032 }
2033
2034 if( aPad->GetShape( pcbLayer ) != PAD_SHAPE::CUSTOM )
2035 {
2036 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
2037 double limit = std::min( aPad->GetSize( pcbLayer ).x, aPad->GetSize( pcbLayer ).y ) * 1.1;
2038
2039 if( padsize.x > limit && padsize.y > limit )
2040 {
2041 padsize.x = limit;
2042 padsize.y = limit;
2043 }
2044 }
2045
2046 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
2047 double size = padsize.y;
2048
2049 m_gal->Save();
2050 m_gal->Translate( position );
2051
2052 // Keep the size ratio for the font, but make it smaller
2053 if( padsize.x < ( padsize.y * 0.95 ) )
2054 {
2055 m_gal->Rotate( -ANGLE_90.AsRadians() );
2056 size = padsize.x;
2057 std::swap( padsize.x, padsize.y );
2058 }
2059
2060 // Font size limits
2061 if( size > maxSize )
2062 size = maxSize;
2063
2064 // Default font settings
2065 m_gal->ResetTextAttributes();
2066 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
2067 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
2068 m_gal->SetFontBold( false );
2069 m_gal->SetFontItalic( false );
2070 m_gal->SetFontUnderlined( false );
2071 m_gal->SetTextMirrored( false );
2072 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) );
2073 m_gal->SetIsStroke( true );
2074 m_gal->SetIsFill( false );
2075
2076 // We have already translated the GAL to be centered at the center of the pad's
2077 // bounding box
2078 VECTOR2I textpos( 0, 0 );
2079
2080 // Divide the space, to display both pad numbers and netnames and set the Y text
2081 // offset position to display 2 lines
2082 int Y_offset_numpad = 0;
2083 int Y_offset_netname = 0;
2084
2085 if( !netname.IsEmpty() && !padNumber.IsEmpty() )
2086 {
2087 // The magic numbers are defined experimentally for a better look.
2088 size = size / 2.5;
2089 Y_offset_netname = size / 1.4; // netname size is usually smaller than num pad
2090 // so the offset can be smaller
2091 Y_offset_numpad = size / 1.7;
2092 }
2093
2094 // We are using different fonts to display names, depending on the graphic
2095 // engine (OpenGL or Cairo).
2096 // Xscale_for_stroked_font adjust the text X size for cairo (stroke fonts) engine
2097 const double Xscale_for_stroked_font = 0.9;
2098
2099 if( !netname.IsEmpty() )
2100 {
2101 // approximate the size of net name text:
2102 // We use a size for at least 5 chars, to give a good look even for short names
2103 // (like VCC, GND...)
2104 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname )+1, 5 );
2105 tsize = std::min( tsize, size );
2106
2107 // Use a smaller text size to handle interline, pen size...
2108 tsize *= 0.85;
2109
2110 // Round and oval pads have less room to display the net name than other
2111 // (i.e RECT) shapes, so reduce the text size for these shapes
2112 if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CIRCLE
2113 || aPad->GetShape( pcbLayer ) == PAD_SHAPE::OVAL )
2114 {
2115 tsize *= 0.9;
2116 }
2117
2118 VECTOR2D namesize( tsize*Xscale_for_stroked_font, tsize );
2119 textpos.y = KiROUND( std::min( tsize * 1.4, double( Y_offset_netname ) ) );
2120
2121 m_gal->SetGlyphSize( namesize );
2122 m_gal->SetLineWidth( namesize.x / 6.0 );
2123 m_gal->SetFontBold( true );
2124 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
2125 }
2126
2127 if( !padNumber.IsEmpty() )
2128 {
2129 // approximate the size of the pad number text:
2130 // We use a size for at least 3 chars, to give a good look even for short numbers
2131 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( padNumber ), 3 );
2132 tsize = std::min( tsize, size );
2133
2134 // Use a smaller text size to handle interline, pen size...
2135 tsize *= 0.85;
2136 tsize = std::min( tsize, size );
2137 VECTOR2D numsize( tsize*Xscale_for_stroked_font, tsize );
2138 textpos.y = -Y_offset_numpad;
2139
2140 m_gal->SetGlyphSize( numsize );
2141 m_gal->SetLineWidth( numsize.x / 6.0 );
2142 m_gal->SetFontBold( true );
2143 m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL );
2144 }
2145
2146 m_gal->Restore();
2147
2148 return;
2149 }
2150 else if( aLayer == LAYER_PAD_HOLEWALLS )
2151 {
2152 m_gal->SetIsFill( true );
2153 m_gal->SetIsStroke( false );
2155 double lineWidth = widthFactor * m_holePlatingThickness;
2156 lineWidth = std::min( lineWidth, aPad->GetSize( PADSTACK::ALL_LAYERS ).x / 2.0 );
2157 lineWidth = std::min( lineWidth, aPad->GetSize( PADSTACK::ALL_LAYERS ).y / 2.0 );
2158
2159 m_gal->SetFillColor( color );
2160 m_gal->SetMinLineWidth( lineWidth );
2161
2162 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
2163
2164 if( slot->GetSeg().A == slot->GetSeg().B ) // Circular hole
2165 {
2166 double holeRadius = slot->GetWidth() / 2.0;
2167 m_gal->DrawHoleWall( slot->GetSeg().A, holeRadius, lineWidth );
2168 }
2169 else
2170 {
2171 int holeSize = KiROUND( slot->GetWidth() + ( 2 * lineWidth ) );
2172 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, holeSize );
2173 }
2174
2175 m_gal->SetMinLineWidth( 1.0 );
2176
2177 // Draw backdrill indicators on top of the hole wall so they remain visible
2178 // regardless of layer rendering order
2179 if( !m_pcbSettings.IsPrinting() && aPad->GetDrillSize().x > 0 )
2180 {
2181 const VECTOR2I& holePos = slot->GetSeg().A;
2182 const VECTOR2I& secondaryDrill = aPad->GetSecondaryDrillSize();
2183 const VECTOR2I& tertiaryDrill = aPad->GetTertiaryDrillSize();
2184
2185 if( secondaryDrill.x > 0 )
2186 drawBackdrillIndicator( aPad, holePos, secondaryDrill.x, aPad->GetSecondaryDrillEndLayer(), 0 );
2187
2188 if( tertiaryDrill.x > 0 )
2189 drawBackdrillIndicator( aPad, holePos, tertiaryDrill.x, aPad->GetTertiaryDrillEndLayer(), 1 );
2190 }
2191
2192 return;
2193 }
2194
2195 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
2196
2197 if( m_pcbSettings.m_ForcePadSketchModeOn )
2198 outline_mode = true;
2199
2200 bool drawShape = false;
2201
2202 if( m_pcbSettings.IsPrinting() )
2203 {
2204 drawShape = aPad->FlashLayer( m_pcbSettings.GetPrintLayers() );
2205 }
2206 else if( ( aLayer < PCB_LAYER_ID_COUNT || IsPadCopperLayer( aLayer ) )
2207 && aPad->FlashLayer( pcbLayer ) )
2208 {
2209 drawShape = true;
2210 }
2211 else if( aPad->IsSelected() )
2212 {
2213 drawShape = true;
2214 outline_mode = true;
2215 }
2216 else if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
2217 {
2218 drawShape = true;
2219 outline_mode = false;
2220 }
2221
2222 // Plated holes are always filled as they use a solid BG fill to
2223 // draw the "hole" over the hole-wall segment/circle.
2224 if( outline_mode && aLayer != LAYER_PAD_PLATEDHOLES )
2225 {
2226 // Outline mode
2227 m_gal->SetIsFill( false );
2228 m_gal->SetIsStroke( true );
2229 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2230 m_gal->SetStrokeColor( color );
2231 }
2232 else
2233 {
2234 // Filled mode
2235 m_gal->SetIsFill( true );
2236 m_gal->SetIsStroke( false );
2237 m_gal->SetFillColor( color );
2238 }
2239
2240 if( aLayer == LAYER_PAD_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
2241 {
2242 SHAPE_SEGMENT slot = getPadHoleShape( aPad );
2243 VECTOR2I center = slot.GetSeg().A;
2244
2245 if( slot.GetSeg().A == slot.GetSeg().B ) // Circular hole
2246 m_gal->DrawCircle( center, slot.GetWidth() / 2.0 );
2247 else
2248 m_gal->DrawSegment( slot.GetSeg().A, slot.GetSeg().B, slot.GetWidth() );
2249 }
2250 else if( drawShape )
2251 {
2252 // Simple pad shapes skip GetEffectiveShape() and tessellation. Chamfered and trapezoid pads
2253 // stay generic since the typed encoding has only one corner parameter.
2254 PAD_SHAPE padShape = aPad->GetShape( pcbLayer );
2255
2256 if( m_gal->SupportsTypedPads()
2257 && !outline_mode
2258 && aLayer != LAYER_LOCKED_ITEM_SHADOW
2259 && aLayer != F_Mask && aLayer != B_Mask
2260 && aLayer != F_Paste && aLayer != B_Paste
2261 && padShape != PAD_SHAPE::CUSTOM
2262 && padShape != PAD_SHAPE::CHAMFERED_RECT
2263 && padShape != PAD_SHAPE::TRAPEZOID
2264 && ( !IsCopperLayer( pcbLayer )
2265 || aPad->GetPostMachiningKnockout( pcbLayer ) == 0 ) )
2266 {
2267 VECTOR2I padSize = aPad->GetSize( pcbLayer );
2268 double halfWidth = padSize.x / 2.0;
2269 double halfHeight = padSize.y / 2.0;
2270 VECTOR2D center( aPad->ShapePos( pcbLayer ) );
2271 double rotation = aPad->GetOrientation().AsRadians();
2272 float shapeType;
2273
2274 switch( padShape )
2275 {
2276 case PAD_SHAPE::CIRCLE: shapeType = 0.0f; break;
2277 case PAD_SHAPE::RECTANGLE: shapeType = 1.0f; break;
2278 case PAD_SHAPE::ROUNDRECT: shapeType = 2.0f; break;
2279 case PAD_SHAPE::OVAL: shapeType = 4.0f; break;
2280 default: shapeType = 0.0f; break;
2281 }
2282
2283 double cornerRadius = 0.0;
2284
2285 if( padShape == PAD_SHAPE::ROUNDRECT )
2286 cornerRadius = aPad->GetRoundRectCornerRadius( pcbLayer );
2287
2288 m_gal->DrawPad( center, halfWidth, halfHeight, cornerRadius, shapeType,
2289 rotation, color );
2290 }
2291 else
2292 {
2293 VECTOR2I pad_size = aPad->GetSize( pcbLayer );
2294 VECTOR2I margin;
2295
2296 auto getExpansion =
2297 [&]( PCB_LAYER_ID layer )
2298 {
2299 VECTOR2I expansion;
2300
2301 switch( aLayer )
2302 {
2303 case F_Mask:
2304 case B_Mask:
2305 expansion.x = expansion.y = aPad->GetSolderMaskExpansion( layer );
2306 break;
2307
2308 case F_Paste:
2309 case B_Paste:
2310 expansion = aPad->GetSolderPasteMargin( layer );
2311 break;
2312
2313 default:
2314 expansion.x = expansion.y = 0;
2315 break;
2316 }
2317
2318 return expansion;
2319 };
2320
2321 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
2322 {
2323 LSET visibleLayers = aPad->GetLayerSet();
2324
2325 if( aPad->GetBoard() )
2326 {
2327 visibleLayers &= aPad->GetBoard()->GetVisibleLayers();
2328 visibleLayers &= aPad->GetBoard()->GetEnabledLayers();
2329 }
2330
2331 for( PCB_LAYER_ID layer : visibleLayers )
2332 {
2333 VECTOR2I expansion = getExpansion( layer );
2334
2335 if( expansion.SquaredEuclideanNorm() > margin.SquaredEuclideanNorm() )
2336 margin = expansion;
2337 }
2338
2339 margin.x += m_lockedShadowMargin / 2;
2340 margin.y += m_lockedShadowMargin / 2;
2341 }
2342 else
2343 {
2344 margin = getExpansion( pcbLayer );
2345 }
2346
2347 std::unique_ptr<PAD> dummyPad;
2348 std::shared_ptr<SHAPE_COMPOUND> shapes;
2349
2350 // Drawing components of compound shapes in outline mode produces a mess.
2351 bool simpleShapes = !outline_mode;
2352
2353 if( simpleShapes )
2354 {
2355 if( ( margin.x != margin.y && aPad->GetShape( pcbLayer ) != PAD_SHAPE::CUSTOM )
2356 || ( aPad->GetShape( pcbLayer ) == PAD_SHAPE::ROUNDRECT
2357 && ( margin.x < 0 || margin.y < 0 ) ) )
2358 {
2359 // Our algorithms below (polygon inflation in particular) can't handle differential
2360 // inflation along separate axes. So for those cases we build a dummy pad instead,
2361 // and inflate it.
2362
2363 // Margin is added to both sides. If the total margin is larger than the pad
2364 // then don't display this layer
2365 if( pad_size.x + 2 * margin.x <= 0 || pad_size.y + 2 * margin.y <= 0 )
2366 return;
2367
2368 dummyPad.reset( static_cast<PAD*>( aPad->Duplicate( IGNORE_PARENT_GROUP ) ) );
2369
2370 int initial_radius = dummyPad->GetRoundRectCornerRadius( pcbLayer );
2371
2372 dummyPad->SetSize( pcbLayer, pad_size + margin + margin );
2373
2374 if( dummyPad->GetShape( pcbLayer ) == PAD_SHAPE::ROUNDRECT )
2375 {
2376 // To keep the right margin around the corners, we need to modify the corner radius.
2377 // We must have only one radius correction, so use the smallest absolute margin.
2378 int radius_margin = std::max( margin.x, margin.y ); // radius_margin is < 0
2379 dummyPad->SetRoundRectCornerRadius( pcbLayer, std::max( initial_radius + radius_margin, 0 ) );
2380 }
2381
2382 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( dummyPad->GetEffectiveShape( pcbLayer ) );
2383 margin.x = margin.y = 0;
2384 }
2385 else
2386 {
2387 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( pcbLayer ) );
2388 }
2389
2390 // The dynamic cast above will fail if the pad returned the hole shape or a null shape
2391 // instead of a SHAPE_COMPOUND, which happens if we're on a copper layer and the pad has
2392 // no shape on that layer.
2393 if( !shapes )
2394 return;
2395
2396 if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CUSTOM && ( margin.x || margin.y ) )
2397 {
2398 // We can't draw as shapes because we don't know which edges are internal and which
2399 // are external (so we don't know when to apply the margin and when not to).
2400 simpleShapes = false;
2401 }
2402
2403 for( const SHAPE* shape : shapes->Shapes() )
2404 {
2405 if( !simpleShapes )
2406 break;
2407
2408 switch( shape->Type() )
2409 {
2410 case SH_SEGMENT:
2411 case SH_CIRCLE:
2412 case SH_RECT:
2413 case SH_SIMPLE:
2414 // OK so far
2415 break;
2416
2417 default:
2418 // Not OK
2419 simpleShapes = false;
2420 break;
2421 }
2422 }
2423 }
2424
2425 const auto drawOneSimpleShape =
2426 [&]( const SHAPE& aShape )
2427 {
2428 switch( aShape.Type() )
2429 {
2430 case SH_SEGMENT:
2431 {
2432 const SHAPE_SEGMENT& seg = (const SHAPE_SEGMENT&) aShape;
2433 int effectiveWidth = seg.GetWidth() + 2 * margin.x;
2434
2435 if( effectiveWidth > 0 )
2436 m_gal->DrawSegment( seg.GetSeg().A, seg.GetSeg().B, effectiveWidth );
2437
2438 break;
2439 }
2440
2441 case SH_CIRCLE:
2442 {
2443 const SHAPE_CIRCLE& circle = (const SHAPE_CIRCLE&) aShape;
2444 int effectiveRadius = circle.GetRadius() + margin.x;
2445
2446 if( effectiveRadius > 0 )
2447 m_gal->DrawCircle( circle.GetCenter(), effectiveRadius );
2448
2449 break;
2450 }
2451
2452 case SH_RECT:
2453 {
2454 const SHAPE_RECT& r = (const SHAPE_RECT&) aShape;
2455 VECTOR2I pos = r.GetPosition();
2456 VECTOR2I effectiveMargin = margin;
2457
2458 if( effectiveMargin.x < 0 )
2459 {
2460 // A negative margin just produces a smaller rect.
2461 VECTOR2I effectiveSize = r.GetSize() + effectiveMargin;
2462
2463 if( effectiveSize.x > 0 && effectiveSize.y > 0 )
2464 m_gal->DrawRectangle( pos - effectiveMargin, pos + effectiveSize );
2465 }
2466 else if( effectiveMargin.x > 0 )
2467 {
2468 // A positive margin produces a larger rect, but with rounded corners
2469 m_gal->DrawRectangle( r.GetPosition(), r.GetPosition() + r.GetSize() );
2470
2471 // Use segments to produce the margin with rounded corners
2472 m_gal->DrawSegment( pos,
2473 pos + VECTOR2I( r.GetWidth(), 0 ),
2474 effectiveMargin.x * 2 );
2475 m_gal->DrawSegment( pos + VECTOR2I( r.GetWidth(), 0 ),
2476 pos + r.GetSize(),
2477 effectiveMargin.x * 2 );
2478 m_gal->DrawSegment( pos + r.GetSize(),
2479 pos + VECTOR2I( 0, r.GetHeight() ),
2480 effectiveMargin.x * 2 );
2481 m_gal->DrawSegment( pos + VECTOR2I( 0, r.GetHeight() ),
2482 pos,
2483 effectiveMargin.x * 2 );
2484 }
2485 else
2486 {
2487 m_gal->DrawRectangle( r.GetPosition(), r.GetPosition() + r.GetSize() );
2488 }
2489
2490 break;
2491 }
2492
2493 case SH_SIMPLE:
2494 {
2495 const SHAPE_SIMPLE& poly = static_cast<const SHAPE_SIMPLE&>( aShape );
2496
2497 if( poly.PointCount() < 2 ) // Careful of empty pads
2498 break;
2499
2500 if( margin.x < 0 ) // The poly shape must be deflated
2501 {
2502 SHAPE_POLY_SET outline;
2503 outline.NewOutline();
2504
2505 for( int ii = 0; ii < poly.PointCount(); ++ii )
2506 outline.Append( poly.CPoint( ii ) );
2507
2509
2510 m_gal->DrawPolygon( outline );
2511 }
2512 else
2513 {
2514 m_gal->DrawPolygon( poly.Vertices() );
2515 }
2516
2517 // Now add on a rounded margin (using segments) if the margin > 0
2518 if( margin.x > 0 )
2519 {
2520 for( int ii = 0; ii < (int) poly.GetSegmentCount(); ++ii )
2521 {
2522 SEG seg = poly.GetSegment( ii );
2523 m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
2524 }
2525 }
2526
2527 break;
2528 }
2529
2530 default:
2531 // Better not get here; we already pre-flighted the shapes...
2532 break;
2533 }
2534 };
2535
2536 if( simpleShapes )
2537 {
2538 for( const SHAPE* shape : shapes->Shapes() )
2539 drawOneSimpleShape( *shape );
2540 }
2541 else
2542 {
2543 // This is expensive. Avoid if possible.
2544 SHAPE_POLY_SET polySet;
2545 aPad->TransformShapeToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x, m_maxError, ERROR_INSIDE );
2546 m_gal->DrawPolygon( polySet );
2547 }
2548 }
2549 }
2550
2551 if( !m_pcbSettings.IsPrinting() && IsCopperLayer( pcbLayer ) && aPad->GetDrillSize().x > 0 )
2552 {
2553 VECTOR2D holePos = aPad->GetPosition() + aPad->GetOffset( pcbLayer );
2554 drawPostMachiningIndicator( aPad, holePos, pcbLayer );
2555 }
2556
2557 if( IsClearanceLayer( aLayer )
2558 && ( ( pcbconfig() && pcbconfig()->m_Display.m_PadClearance ) || !pcbconfig() )
2559 && !m_pcbSettings.m_isPrinting )
2560 {
2561 const PCB_LAYER_ID copperLayerForClearance = ToLAYER_ID( aLayer - LAYER_CLEARANCE_START );
2562
2563 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
2564 color = m_pcbSettings.GetLayerColor( LAYER_NON_PLATEDHOLES );
2565
2566 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2567 m_gal->SetIsStroke( true );
2568 m_gal->SetIsFill( false );
2569 m_gal->SetStrokeColor( color );
2570
2571 const int clearance = aPad->GetOwnClearance( copperLayerForClearance );
2572
2573 if( aPad->FlashLayer( copperLayerForClearance ) && clearance > 0 )
2574 {
2575 auto shape = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( pcbLayer ) );
2576
2577 if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_SEGMENT )
2578 {
2579 const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape->Shapes()[0];
2580 m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() + 2 * clearance );
2581 }
2582 else if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_CIRCLE )
2583 {
2584 const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape->Shapes()[0];
2585 m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
2586 }
2587 else
2588 {
2589 SHAPE_POLY_SET polySet;
2590
2591 // Use ERROR_INSIDE because it avoids Clipper and is therefore much faster.
2592 aPad->TransformShapeToPolygon( polySet, copperLayerForClearance, clearance, m_maxError, ERROR_INSIDE );
2593
2594 if( polySet.Outline( 0 ).PointCount() > 2 ) // Careful of empty pads
2595 m_gal->DrawPolygon( polySet );
2596 }
2597 }
2598 else if( aPad->GetEffectiveHoleShape() && clearance > 0 )
2599 {
2600 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
2601 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, slot->GetWidth() + 2 * clearance );
2602 }
2603 }
2604
2605 if( m_pcbSettings.IsHighlightEnabled()
2606 && m_pcbSettings.GetHighlightNetCodes().contains( aPad->GetNetCode() ) )
2607 {
2608 NETINFO_ITEM* net = aPad->GetNet();
2609 if( net && ( net->GetTerminalPad( 0 ) == aPad || net->GetTerminalPad( 1 ) == aPad ) )
2610 {
2611 BOX2I box = aPad->GetBoundingBox();
2612 m_gal->SetIsFill( false );
2613 m_gal->SetIsStroke( true );
2614
2615 // Base emphasis (net highlight)
2616 COLOR4D termColor = color.Brightened( 0.2 );
2617 int baseWidth = m_pcbSettings.m_outlineWidth * 2;
2618
2619 // If a grouped chain highlight is active and this pad belongs to that chain,
2620 // make the emphasis stronger (brighter + thicker + inset second rectangle).
2621 if( !m_pcbSettings.m_highlightedNetChain.IsEmpty()
2622 && net && net->GetNetChain() == m_pcbSettings.m_highlightedNetChain )
2623 {
2624 // Prefer the chain's own colour override if the board has one.
2625 if( const BOARD* board = aPad->GetBoard() )
2626 {
2627 COLOR4D chainColor =
2628 board->GetNetChainColor( m_pcbSettings.m_highlightedNetChain );
2629
2630 if( chainColor != COLOR4D::UNSPECIFIED )
2631 termColor = chainColor;
2632 else
2633 termColor = termColor.Brightened( 0.25 );
2634 }
2635 else
2636 {
2637 termColor = termColor.Brightened( 0.25 );
2638 }
2639
2640 baseWidth = m_pcbSettings.m_outlineWidth * 3;
2641 }
2642
2643 m_gal->SetStrokeColor( termColor );
2644 m_gal->SetLineWidth( baseWidth );
2645 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
2646
2647 if( !m_pcbSettings.m_highlightedNetChain.IsEmpty()
2648 && net && net->GetNetChain() == m_pcbSettings.m_highlightedNetChain )
2649 {
2650 // Draw an inner rectangle for additional visual distinction.
2651 // Shrink by one outline width equivalent to avoid excessive size.
2652 int inset = baseWidth * 2; // screen-space approx; acceptable heuristic
2653 BOX2I inner = box;
2654 inner.Inflate( -inset, -inset );
2655 if( inner.GetWidth() > 0 && inner.GetHeight() > 0 )
2656 {
2657 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2658 m_gal->DrawRectangle( inner.GetOrigin(), inner.GetEnd() );
2659 }
2660 }
2661 }
2662 }
2663}
2664
2665
2666void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
2667{
2668 COLOR4D color = m_pcbSettings.GetColor( aShape, aLayer );
2670 int thickness = getLineThickness( aShape->GetWidth() );
2671 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
2672 bool isSolidFill = aShape->IsSolidFill();
2673 bool isHatchedFill = aShape->IsHatchedFill();
2674
2675 if( lineStyle == LINE_STYLE::DEFAULT )
2676 lineStyle = LINE_STYLE::SOLID;
2677
2678 if( IsSolderMaskLayer( aLayer )
2679 && aShape->HasSolderMask()
2680 && IsExternalCopperLayer( aShape->GetLayer() ) )
2681 {
2682 lineStyle = LINE_STYLE::SOLID;
2683 thickness += aShape->GetSolderMaskExpansion() * 2;
2684
2685 if( isHatchedFill )
2686 {
2687 isSolidFill = true;
2688 isHatchedFill = false;
2689 }
2690 }
2691
2692 if( IsNetnameLayer( aLayer ) )
2693 {
2694 // Net names are shown only in board editor:
2696 return;
2697
2698 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
2699 return;
2700
2701 if( aShape->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
2702 return;
2703
2704 const wxString& netname = aShape->GetDisplayNetname();
2705
2706 if( netname.IsEmpty() )
2707 return;
2708
2709 if( aShape->GetShape() == SHAPE_T::SEGMENT )
2710 {
2711 SHAPE_SEGMENT seg( { aShape->GetStart(), aShape->GetEnd() }, aShape->GetWidth() );
2712 renderNetNameForSegment( seg, color, netname );
2713 return;
2714 }
2715
2716 // TODO: Maybe use some of the pad code?
2717
2718 return;
2719 }
2720
2721 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
2722 {
2723 color = m_pcbSettings.GetColor( aShape, aLayer );
2724 thickness = thickness + m_lockedShadowMargin;
2725
2726 // Note: on LAYER_LOCKED_ITEM_SHADOW always draw shadow shapes as continuous lines
2727 // otherwise the look is very strange and ugly
2728 lineStyle = LINE_STYLE::SOLID;
2729 }
2730
2731 if( aLayer == LAYER_CONSTRAINT_SHADOW )
2732 {
2733 color = m_pcbSettings.GetColor( aShape, aLayer );
2734 int margin = m_lockedShadowMargin;
2735
2736 // Selected constraint members drawn brighter and thicker
2737 if( m_pcbSettings.GetHighlightedConstraintMembers().count( aShape->m_Uuid ) )
2738 {
2739 color = color.Brightened( 0.5 );
2740 margin *= 2;
2741 }
2742
2743 thickness = thickness + margin;
2744 lineStyle = LINE_STYLE::SOLID;
2745 }
2746
2747 if( outline_mode )
2748 {
2749 m_gal->SetIsFill( false );
2750 m_gal->SetIsStroke( true );
2751 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2752 }
2753
2754 m_gal->SetFillColor( color );
2755 m_gal->SetStrokeColor( color );
2756
2757 if( lineStyle == LINE_STYLE::SOLID || aShape->IsSolidFill() )
2758 {
2759 switch( aShape->GetShape() )
2760 {
2761 case SHAPE_T::SEGMENT:
2762 {
2763 VECTOR2I segStart = aShape->GetStart();
2764 VECTOR2I segEnd = aShape->GetEnd();
2765
2766 if( EDA_SHAPE::ShortenSegmentForEndings( segStart, segEnd, aShape->GetStartEnding(),
2767 aShape->GetEndEnding(), thickness ) )
2768 {
2769 if( aShape->IsProxyItem() )
2770 {
2771 std::vector<VECTOR2I> pts;
2772 VECTOR2I offset = ( segEnd - segStart ).Perpendicular();
2773 offset = offset.Resize( thickness / 2 );
2774
2775 pts.push_back( segStart + offset );
2776 pts.push_back( segStart - offset );
2777 pts.push_back( segEnd - offset );
2778 pts.push_back( segEnd + offset );
2779
2780 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2781 m_gal->DrawLine( pts[0], pts[1] );
2782 m_gal->DrawLine( pts[1], pts[2] );
2783 m_gal->DrawLine( pts[2], pts[3] );
2784 m_gal->DrawLine( pts[3], pts[0] );
2785 m_gal->DrawLine( ( pts[0] + pts[1] ) / 2, ( pts[1] + pts[2] ) / 2 );
2786 m_gal->DrawLine( ( pts[1] + pts[2] ) / 2, ( pts[2] + pts[3] ) / 2 );
2787 m_gal->DrawLine( ( pts[2] + pts[3] ) / 2, ( pts[3] + pts[0] ) / 2 );
2788 m_gal->DrawLine( ( pts[3] + pts[0] ) / 2, ( pts[0] + pts[1] ) / 2 );
2789 }
2790 else if( outline_mode )
2791 {
2792 m_gal->DrawSegment( segStart, segEnd, thickness );
2793 }
2794 else if( lineStyle == LINE_STYLE::SOLID )
2795 {
2796 m_gal->SetIsFill( true );
2797 m_gal->SetIsStroke( false );
2798
2799 m_gal->DrawSegment( segStart, segEnd, thickness );
2800 }
2801 }
2802
2803 break;
2804 }
2805
2806 case SHAPE_T::RECTANGLE:
2807 {
2808 if( aShape->GetCornerRadius() > 0 )
2809 {
2810 // Creates a normalized ROUNDRECT item
2811 // (GetRectangleWidth() and GetRectangleHeight() can be < 0 with transforms
2812 ROUNDRECT rr( SHAPE_RECT( aShape->GetStart(), aShape->GetRectangleWidth(),
2813 aShape->GetRectangleHeight() ),
2814 aShape->GetCornerRadius(), true /* normalize */ );
2815 SHAPE_POLY_SET poly;
2816 rr.TransformToPolygon( poly, aShape->GetMaxError() );
2817 SHAPE_LINE_CHAIN outline = poly.Outline( 0 );
2818
2819 if( aShape->IsProxyItem() )
2820 {
2821 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2822 m_gal->DrawPolygon( outline );
2823 }
2824 else if( outline_mode )
2825 {
2826 m_gal->DrawSegmentChain( outline, thickness );
2827 }
2828 else
2829 {
2830 m_gal->SetIsFill( true );
2831 m_gal->SetIsStroke( false );
2832
2833 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
2834 {
2835 m_gal->DrawSegmentChain( outline, thickness );
2836 }
2837
2838 if( isSolidFill )
2839 {
2840 if( thickness < 0 )
2841 {
2842 SHAPE_POLY_SET deflated_shape = outline;
2843 deflated_shape.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS, m_maxError );
2844 m_gal->DrawPolygon( deflated_shape );
2845 }
2846 else
2847 {
2848 m_gal->DrawPolygon( outline );
2849 }
2850 }
2851 }
2852 }
2853 else
2854 {
2855 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
2856
2857 if( aShape->IsProxyItem() )
2858 {
2859 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2860 m_gal->DrawLine( pts[0], pts[1] );
2861 m_gal->DrawLine( pts[1], pts[2] );
2862 m_gal->DrawLine( pts[2], pts[3] );
2863 m_gal->DrawLine( pts[3], pts[0] );
2864 m_gal->DrawLine( pts[0], pts[2] );
2865 m_gal->DrawLine( pts[1], pts[3] );
2866 }
2867 else if( outline_mode )
2868 {
2869 m_gal->DrawSegment( pts[0], pts[1], thickness );
2870 m_gal->DrawSegment( pts[1], pts[2], thickness );
2871 m_gal->DrawSegment( pts[2], pts[3], thickness );
2872 m_gal->DrawSegment( pts[3], pts[0], thickness );
2873 }
2874 else
2875 {
2876 m_gal->SetIsFill( true );
2877 m_gal->SetIsStroke( false );
2878
2879 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
2880 {
2881 m_gal->DrawSegment( pts[0], pts[1], thickness );
2882 m_gal->DrawSegment( pts[1], pts[2], thickness );
2883 m_gal->DrawSegment( pts[2], pts[3], thickness );
2884 m_gal->DrawSegment( pts[3], pts[0], thickness );
2885 }
2886
2887 if( isSolidFill )
2888 {
2889 SHAPE_POLY_SET poly;
2890 poly.NewOutline();
2891
2892 for( const VECTOR2I& pt : pts )
2893 poly.Append( pt );
2894
2895 if( thickness < 0 )
2897
2898 m_gal->DrawPolygon( poly );
2899 }
2900 }
2901 }
2902
2903 break;
2904 }
2905
2906 case SHAPE_T::ARC:
2907 {
2908 EDA_ANGLE startAngle;
2909 EDA_ANGLE endAngle;
2910 aShape->CalcArcAngles( startAngle, endAngle );
2911
2912 EDA_ANGLE arcAngle = endAngle - startAngle;
2913
2914 if( aShape->ShortenArcForEndings( startAngle, arcAngle, aShape->GetRadius(), thickness ) )
2915 {
2916 if( outline_mode )
2917 {
2918 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle, arcAngle, thickness,
2919 m_maxError );
2920 }
2921 else if( lineStyle == LINE_STYLE::SOLID )
2922 {
2923 m_gal->SetIsFill( true );
2924 m_gal->SetIsStroke( false );
2925
2926 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle, arcAngle, thickness,
2927 m_maxError );
2928 }
2929 }
2930
2931 break;
2932 }
2933
2934 case SHAPE_T::CIRCLE:
2935 if( outline_mode )
2936 {
2937 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() - thickness / 2 );
2938 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() + thickness / 2 );
2939 }
2940 else
2941 {
2942 m_gal->SetIsFill( aShape->IsSolidFill() );
2943 m_gal->SetIsStroke( lineStyle == LINE_STYLE::SOLID && thickness > 0 );
2944 m_gal->SetLineWidth( thickness );
2945
2946 int radius = aShape->GetRadius();
2947
2948 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
2949 {
2950 m_gal->DrawCircle( aShape->GetStart(), radius );
2951 }
2952 else if( isSolidFill )
2953 {
2954 if( thickness < 0 )
2955 {
2956 radius += thickness / 2;
2957 radius = std::max( radius, 0 );
2958 }
2959
2960 m_gal->DrawCircle( aShape->GetStart(), radius );
2961 }
2962 }
2963 break;
2964
2965 case SHAPE_T::POLY:
2966 {
2967 SHAPE_POLY_SET& shape = const_cast<PCB_SHAPE*>( aShape )->GetPolyShape();
2968
2969 auto drawOutlineBody =
2970 [&]( const SHAPE_LINE_CHAIN& aOutline, int aOutlineIdx )
2971 {
2972 if( aOutline.PointCount() < 2 )
2973 return;
2974
2975 if( aShape->GetStartEnding().GetShortenDepth( thickness ) > 0
2976 || aShape->GetEndEnding().GetShortenDepth( thickness ) > 0 )
2977 {
2978 std::vector<VECTOR2I> pts;
2979
2980 if( !aShape->GetShortenedBodyPolyPoints( aOutline, aOutlineIdx, pts, thickness ) )
2981 return;
2982
2983 SHAPE_LINE_CHAIN shortened;
2984
2985 for( const VECTOR2I& pt : pts )
2986 shortened.Append( pt );
2987
2988 shortened.SetClosed( aOutline.IsClosed() );
2989 m_gal->DrawSegmentChain( shortened, thickness );
2990 }
2991 else
2992 {
2993 m_gal->DrawSegmentChain( aOutline, thickness );
2994 }
2995 };
2996
2997 if( shape.OutlineCount() == 0 )
2998 break;
2999
3000 if( outline_mode )
3001 {
3002 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
3003 drawOutlineBody( shape.COutline( ii ), ii );
3004 }
3005 else
3006 {
3007 m_gal->SetIsFill( true );
3008 m_gal->SetIsStroke( false );
3009
3010 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
3011 {
3012 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
3013 drawOutlineBody( shape.COutline( ii ), ii );
3014 }
3015
3016 if( isSolidFill )
3017 {
3018 if( thickness < 0 )
3019 {
3020 SHAPE_POLY_SET deflated_shape = shape;
3021 deflated_shape.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS, m_maxError );
3022 m_gal->DrawPolygon( deflated_shape );
3023 }
3024 else
3025 {
3026 // On Opengl, a not convex filled polygon is usually drawn by using
3027 // triangles as primitives. CacheTriangulation() can create basic triangle
3028 // primitives to draw the polygon solid shape on Opengl. GLU tessellation
3029 // is much slower, so currently we are using our tessellation.
3030 if( m_gal->UsesPolygonTriangulationCache()
3031 && !shape.IsTriangulationUpToDate() )
3032 shape.CacheTriangulation( true );
3033
3034 m_gal->DrawPolygon( shape );
3035 }
3036 }
3037 }
3038
3039 break;
3040 }
3041
3042 case SHAPE_T::BEZIER:
3043 if( std::optional<BEZIER<double>> curve = aShape->ShortenedBezierCurve( thickness ) )
3044 {
3045 if( outline_mode )
3046 {
3047 std::vector<VECTOR2D> output;
3048 BEZIER_POLY converter( std::vector<VECTOR2D>{ curve->Start, curve->C1, curve->C2, curve->End } );
3049
3050 converter.GetPoly( output, m_maxError );
3051 m_gal->DrawSegmentChain( output, thickness );
3052 }
3053 else
3054 {
3055 m_gal->SetIsFill( aShape->IsSolidFill() );
3056 m_gal->SetIsStroke( lineStyle == LINE_STYLE::SOLID && thickness > 0 );
3057 m_gal->SetLineWidth( thickness );
3058 m_gal->DrawCurve( curve->Start, curve->C1, curve->C2, curve->End, m_maxError );
3059 }
3060 }
3061
3062 break;
3063
3064 case SHAPE_T::ELLIPSE:
3065 {
3066 const VECTOR2D center( aShape->GetEllipseCenter() );
3067 const int majorR = aShape->GetEllipseMajorRadius();
3068 const int minorR = aShape->GetEllipseMinorRadius();
3069 const EDA_ANGLE& rot = aShape->GetEllipseRotation();
3070
3071 if( outline_mode )
3072 {
3073 m_gal->DrawEllipse( center, majorR - thickness / 2, minorR - thickness / 2, rot );
3074 m_gal->DrawEllipse( center, majorR + thickness / 2, minorR + thickness / 2, rot );
3075 }
3076 else
3077 {
3078 m_gal->SetIsFill( aShape->IsSolidFill() );
3079 m_gal->SetIsStroke( lineStyle == LINE_STYLE::SOLID && thickness > 0 );
3080 m_gal->SetLineWidth( thickness );
3081
3082 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
3083 m_gal->DrawEllipse( center, majorR, minorR, rot );
3084 else if( isSolidFill )
3085 m_gal->DrawEllipse( center, majorR, minorR, rot );
3086 }
3087
3088 break;
3089 }
3090
3092 {
3093 const VECTOR2D center( aShape->GetEllipseCenter() );
3094 const int majorR = aShape->GetEllipseMajorRadius();
3095 const int minorR = aShape->GetEllipseMinorRadius();
3096 const EDA_ANGLE& rot = aShape->GetEllipseRotation();
3097 const EDA_ANGLE& start = aShape->GetEllipseStartAngle();
3098 const EDA_ANGLE& end = aShape->GetEllipseEndAngle();
3099 SHAPE_ELLIPSE ellipse( center, majorR, minorR, rot, start, end );
3100 SHAPE_LINE_CHAIN chain = ellipse.ConvertToPolyline( aShape->GetMaxError() );
3101 std::vector<VECTOR2I> pts;
3102
3103 if( aShape->GetShortenedBodyPolyPoints( chain, 0, pts, thickness ) )
3104 {
3105 chain.Clear();
3106
3107 for( const VECTOR2I& pt : pts )
3108 chain.Append( pt );
3109
3110 chain.SetClosed( false );
3111
3112 if( outline_mode )
3113 m_gal->DrawSegmentChain( chain, thickness );
3114 else if( lineStyle == LINE_STYLE::SOLID )
3115 m_gal->DrawSegmentChain( chain, thickness );
3116 }
3117
3118 break;
3119 }
3120
3121 case SHAPE_T::UNDEFINED:
3122 break;
3123 }
3124 }
3125
3126 if( lineStyle != LINE_STYLE::SOLID )
3127 {
3128 if( !outline_mode )
3129 {
3130 m_gal->SetIsFill( true );
3131 m_gal->SetIsStroke( false );
3132 }
3133
3134 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapesForStroking( thickness );
3135
3136 for( SHAPE* shape : shapes )
3137 {
3138 STROKE_PARAMS::Stroke( shape, lineStyle, getLineThickness( aShape->GetWidth() ),
3140 [&]( const VECTOR2I& a, const VECTOR2I& b )
3141 {
3142 m_gal->DrawSegment( a, b, thickness );
3143 } );
3144 }
3145
3146 for( SHAPE* shape : shapes )
3147 delete shape;
3148 }
3149
3150 if( isHatchedFill )
3151 {
3152 aShape->UpdateHatching();
3153 m_gal->SetIsFill( false );
3154 m_gal->SetIsStroke( true );
3155 m_gal->SetLineWidth( aShape->GetHatchLineWidth() );
3156
3157 for( const SEG& seg : aShape->GetHatchLines() )
3158 m_gal->DrawLine( seg.A, seg.B );
3159 }
3160
3161 // Line endings
3164 {
3165 EDA_ANGLE startTangent, endTangent;
3166 aShape->GetEndingTangents( startTangent, endTangent, thickness );
3167
3168 VECTOR2I startPt, endPt;
3169
3170 if( aShape->GetLineEndingEndpoints( startPt, endPt ) )
3171 {
3172 aShape->GetStartEnding().Draw( *m_gal, startPt, startTangent, thickness, color );
3173 aShape->GetEndEnding().Draw( *m_gal, endPt, endTangent, thickness, color );
3174 }
3175 }
3176}
3177
3178
3179void PCB_PAINTER::strokeText( const wxString& aText, const VECTOR2I& aPosition,
3180 const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
3181{
3182 KIFONT::FONT* font = aAttrs.m_Font;
3183
3184 if( !font )
3185 font = KIFONT::FONT::GetFont( wxEmptyString, aAttrs.m_Bold, aAttrs.m_Italic );
3186
3187 m_gal->SetIsFill( font->IsOutline() );
3188 m_gal->SetIsStroke( font->IsStroke() );
3189
3190 VECTOR2I pos( aPosition );
3191 VECTOR2I fudge( KiROUND( 0.16 * aAttrs.m_StrokeWidth ), 0 );
3192
3193 RotatePoint( fudge, aAttrs.m_Angle.GetAngle() );
3194
3195 if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && !aAttrs.m_Mirrored )
3196 || ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && aAttrs.m_Mirrored ) )
3197 {
3198 pos -= fudge;
3199 }
3200 else if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && !aAttrs.m_Mirrored )
3201 || ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && aAttrs.m_Mirrored ) )
3202 {
3203 pos += fudge;
3204 }
3205
3206 font->Draw( m_gal, aText, pos, aAttrs, aFontMetrics );
3207}
3208
3209
3210void PCB_PAINTER::draw( const PCB_REFERENCE_IMAGE* aBitmap, int aLayer )
3211{
3212 m_gal->Save();
3213
3214 const REFERENCE_IMAGE& refImg = aBitmap->GetReferenceImage();
3215 m_gal->Translate( refImg.GetPosition() );
3216
3217 m_gal->Rotate( -refImg.GetOrientation().AsRadians() );
3218
3219 // When the image scale factor is not 1.0, we need to modify the actual as the image scale
3220 // factor is similar to a local zoom
3221 const double img_scale = refImg.GetImageScale();
3222
3223 if( img_scale != 1.0 )
3224 m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
3225
3226 double imgAlpha = refImg.GetOpacity();
3227
3228 if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
3229 {
3230 COLOR4D color = m_pcbSettings.GetColor( aBitmap, LAYER_ANCHOR );
3231 m_gal->SetIsStroke( true );
3232 m_gal->SetStrokeColor( color );
3233 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth * 2.0f );
3234 m_gal->SetIsFill( false );
3235
3236 // Draws a bounding box.
3237 VECTOR2D bm_size( refImg.GetSize() );
3238 // bm_size is the actual image size in UI.
3239 // but m_canvas scale was previously set to img_scale
3240 // so recalculate size relative to this image size.
3241 bm_size.x /= img_scale;
3242 bm_size.y /= img_scale;
3243 VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
3244 VECTOR2D end = origin + bm_size;
3245
3246 m_gal->DrawRectangle( origin, end );
3247
3248 // Give it a floor when selected so you can't lose it too easily
3249 imgAlpha = std::max( imgAlpha, 0.1 );
3250 }
3251 else
3252 {
3253 imgAlpha *= m_pcbSettings.GetColor( aBitmap, aBitmap->GetLayer() ).a;
3254 }
3255
3256 m_gal->DrawBitmap( refImg.GetImage(), imgAlpha );
3257
3258 m_gal->Restore();
3259}
3260
3261
3262void PCB_PAINTER::draw( const PCB_FIELD* aField, int aLayer )
3263{
3264 if( aField->IsVisible() )
3265 draw( static_cast<const PCB_TEXT*>( aField ), aLayer );
3266}
3267
3268
3269void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
3270{
3271 wxString resolvedText( aText->GetShownText( FOR_CANVAS ) );
3272
3273 if( resolvedText.Length() == 0 )
3274 return;
3275
3276 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
3277 {
3278 const COLOR4D color = m_pcbSettings.GetColor( aText, aLayer );
3279
3280 m_gal->SetIsFill( true );
3281 m_gal->SetIsStroke( true );
3282 m_gal->SetFillColor( color );
3283 m_gal->SetStrokeColor( color );
3284 m_gal->SetLineWidth( m_lockedShadowMargin );
3285
3286 SHAPE_POLY_SET poly;
3287 aText->TransformShapeToPolygon( poly, aText->GetLayer(), 0, m_maxError, ERROR_OUTSIDE );
3288 m_gal->DrawPolygon( poly );
3289
3290 return;
3291 }
3292
3293 const KIFONT::METRICS& metrics = aText->GetFontMetrics();
3294 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
3295 // Raw attrs are lib frame for FP children, pull scaled values for render.
3296 attrs.m_Size = aText->GetTextSize();
3297 attrs.m_StrokeWidth = aText->GetTextThickness();
3298 const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
3299 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
3300
3301 KIFONT::FONT* font = aText->GetDrawFont( &m_pcbSettings );
3302
3303 m_gal->SetStrokeColor( color );
3304 m_gal->SetFillColor( color );
3305 attrs.m_Angle = aText->GetDrawRotation();
3306
3307 if( aText->IsKnockout() )
3308 {
3309 const SHAPE_POLY_SET& finalPoly = aText->GetKnockoutCache( font, resolvedText, m_maxError );
3310
3311 m_gal->SetIsStroke( false );
3312 m_gal->SetIsFill( true );
3313 m_gal->DrawPolygon( finalPoly );
3314 }
3315 else
3316 {
3317 if( outline_mode )
3318 attrs.m_StrokeWidth = m_pcbSettings.m_outlineWidth;
3319 else
3321
3322 if( m_gal->IsFlippedX() && !aText->IsSideSpecific() )
3323 {
3324 // We do not want to change the mirroring for this kind of text
3325 // on the mirrored canvas
3326 // (not mirrored is draw not mirrored and mirrored is draw mirrored)
3327 // So we need to recalculate the text position to keep it at the same position
3328 // on the canvas
3329 VECTOR2I textPos = aText->GetTextPos();
3330 VECTOR2I textWidth = VECTOR2I( aText->GetTextBox( &m_pcbSettings ).GetWidth(), 0 );
3331
3332 if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
3333 textWidth.x = -textWidth.x;
3334 else if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER )
3335 textWidth.x = 0;
3336
3337 RotatePoint( textWidth, VECTOR2I( 0, 0 ), aText->GetDrawRotation() );
3338
3339 if( attrs.m_Mirrored )
3340 textPos -= textWidth;
3341 else
3342 textPos += textWidth;
3343
3344 attrs.m_Mirrored = !attrs.m_Mirrored;
3345 strokeText( resolvedText, textPos, attrs, metrics );
3346 return;
3347 }
3348
3349 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
3350
3351 if( font->IsOutline() )
3352 cache = aText->GetRenderCache( font, resolvedText );
3353
3354 if( cache )
3355 {
3356 m_gal->SetLineWidth( attrs.m_StrokeWidth );
3357 m_gal->DrawGlyphs( *cache );
3358 }
3359 else
3360 {
3361 strokeText( resolvedText, aText->GetTextPos(), attrs, metrics );
3362 }
3363 }
3364
3365 // Draw the umbilical line for texts in footprints
3366 FOOTPRINT* fp_parent = aText->GetParentFootprint();
3367
3368 if( fp_parent && aText->IsSelected() )
3369 {
3370 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
3371 m_gal->SetStrokeColor( m_pcbSettings.GetColor( nullptr, LAYER_ANCHOR ) );
3372 m_gal->DrawLine( aText->GetTextPos(), fp_parent->GetPosition() );
3373 }
3374}
3375
3376
3377void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
3378{
3379 if( aTextBox->Type() == PCB_TABLECELL_T )
3380 {
3381 const PCB_TABLECELL* cell = static_cast<const PCB_TABLECELL*>( aTextBox );
3382
3383 if( cell->GetColSpan() == 0 || cell->GetRowSpan() == 0 )
3384 return;
3385 }
3386
3387 COLOR4D color = m_pcbSettings.GetColor( aTextBox, aLayer );
3388 int thickness = getLineThickness( aTextBox->GetWidth() );
3389 LINE_STYLE lineStyle = aTextBox->GetStroke().GetLineStyle();
3390 wxString resolvedText( aTextBox->GetShownText( FOR_CANVAS ) );
3391 KIFONT::FONT* font = aTextBox->GetDrawFont( &m_pcbSettings );
3392
3393 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
3394 {
3395 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
3396
3397 m_gal->SetIsFill( true );
3398 m_gal->SetIsStroke( false );
3399 m_gal->SetFillColor( sh_color );
3400 m_gal->SetStrokeColor( sh_color );
3401
3402 // Draw the box with a larger thickness than box thickness to show
3403 // the shadow mask
3404 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
3405 int line_thickness = std::max( thickness*3, pcbIUScale.mmToIU( 0.2 ) );
3406
3407 std::deque<VECTOR2D> dpts;
3408
3409 for( const VECTOR2I& pt : pts )
3410 dpts.push_back( VECTOR2D( pt ) );
3411
3412 dpts.push_back( VECTOR2D( pts[0] ) );
3413
3414 m_gal->SetIsStroke( true );
3415 m_gal->SetLineWidth( line_thickness );
3416 m_gal->DrawPolygon( dpts );
3417 }
3418
3419 m_gal->SetFillColor( color );
3420 m_gal->SetStrokeColor( color );
3421 m_gal->SetIsFill( true );
3422 m_gal->SetIsStroke( false );
3423
3424 if( aTextBox->Type() != PCB_TABLECELL_T && aTextBox->IsBorderEnabled() )
3425 {
3426 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
3427 {
3428 // Simple case: faster than not solid hape lines
3429 if( thickness > 0 )
3430 {
3431 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
3432
3433 for( size_t ii = 0; ii < pts.size(); ++ii )
3434 m_gal->DrawSegment( pts[ii], pts[( ii + 1 ) % pts.size()], thickness );
3435 }
3436 }
3437 else
3438 {
3439 std::vector<SHAPE*> shapes = aTextBox->GetPolygonalBoxShape().MakeEffectiveShapes( true );
3440
3441 for( SHAPE* shape : shapes )
3442 {
3443 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
3444 [&]( const VECTOR2I& a, const VECTOR2I& b )
3445 {
3446 m_gal->DrawSegment( a, b, thickness );
3447 } );
3448 }
3449
3450 for( SHAPE* shape : shapes )
3451 delete shape;
3452 }
3453 }
3454
3455 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
3456 {
3457 // For now, the textbox is a filled shape.
3458 // so the text drawn on LAYER_LOCKED_ITEM_SHADOW with a thick width is disabled
3459 // If enabled, the thick text position must be offsetted to be exactly on the
3460 // initial text, which is not easy, depending on its rotation and justification.
3461#if 0
3462 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
3463 m_canvas->SetFillColor( sh_color );
3464 m_canvas->SetStrokeColor( sh_color );
3465 attrs.m_StrokeWidth += m_lockedShadowMargin;
3466#else
3467 return;
3468#endif
3469 }
3470
3471 if( aTextBox->IsKnockout() )
3472 {
3473 SHAPE_POLY_SET finalPoly;
3474 aTextBox->TransformTextToPolySet( finalPoly, 0, m_maxError, ERROR_INSIDE );
3475 finalPoly.Fracture();
3476
3477 m_gal->SetIsStroke( false );
3478 m_gal->SetIsFill( true );
3479 m_gal->DrawPolygon( finalPoly );
3480 }
3481 else
3482 {
3483 if( resolvedText.Length() == 0 )
3484 return;
3485
3486 const KIFONT::METRICS& metrics = aTextBox->GetFontMetrics();
3487 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
3488 // Raw attrs are lib frame for FP children, pull scaled size for render.
3489 attrs.m_Size = aTextBox->GetTextSize();
3491
3492 if( m_gal->IsFlippedX() && !aTextBox->IsSideSpecific() )
3493 {
3494 attrs.m_Mirrored = !attrs.m_Mirrored;
3495 strokeText( resolvedText, aTextBox->GetDrawPos( true ), attrs, metrics );
3496 return;
3497 }
3498
3499 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
3500
3501 if( font->IsOutline() )
3502 cache = aTextBox->GetRenderCache( font, resolvedText );
3503
3504 if( cache )
3505 {
3506 m_gal->SetLineWidth( attrs.m_StrokeWidth );
3507 m_gal->DrawGlyphs( *cache );
3508 }
3509 else
3510 {
3511 strokeText( resolvedText, aTextBox->GetDrawPos(), attrs, metrics );
3512 }
3513 }
3514}
3515
3516void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
3517{
3518 if( aTable->GetCells().empty() )
3519 return;
3520
3521 for( PCB_TABLECELL* cell : aTable->GetCells() )
3522 {
3523 if( cell->GetColSpan() > 0 || cell->GetRowSpan() > 0 )
3524 draw( static_cast<PCB_TEXTBOX*>( cell ), aLayer );
3525 }
3526
3527 COLOR4D color = m_pcbSettings.GetColor( aTable, aLayer );
3528
3529 aTable->DrawBorders(
3530 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
3531 {
3532 int lineWidth = getLineThickness( stroke.GetWidth() );
3533 LINE_STYLE lineStyle = stroke.GetLineStyle();
3534
3535 m_gal->SetIsFill( false );
3536 m_gal->SetIsStroke( true );
3537 m_gal->SetStrokeColor( color );
3538 m_gal->SetLineWidth( lineWidth );
3539
3540 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
3541 {
3542 m_gal->DrawLine( ptA, ptB );
3543 }
3544 else
3545 {
3546 SHAPE_SEGMENT seg( ptA, ptB );
3547
3548 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, &m_pcbSettings,
3549 [&]( const VECTOR2I& a, const VECTOR2I& b )
3550 {
3551 // DrawLine has problem with 0 length lines so enforce minimum
3552 if( a == b )
3553 m_gal->DrawLine( a+1, b );
3554 else
3555 m_gal->DrawLine( a, b );
3556 } );
3557 }
3558 } );
3559
3560 // Highlight selected tablecells with a background wash.
3561 for( PCB_TABLECELL* cell : aTable->GetCells() )
3562 {
3563 if( aTable->IsSelected() || cell->IsSelected() )
3564 {
3565 std::vector<VECTOR2I> corners = cell->GetCorners();
3566 std::deque<VECTOR2D> pts;
3567
3568 pts.insert( pts.end(), corners.begin(), corners.end() );
3569
3570 m_gal->SetFillColor( color.WithAlpha( 0.5 ) );
3571 m_gal->SetIsFill( true );
3572 m_gal->SetIsStroke( false );
3573 m_gal->DrawPolygon( pts );
3574 }
3575 }
3576}
3577
3578
3579void PCB_PAINTER::draw( const FOOTPRINT* aFootprint, int aLayer )
3580{
3581 if( aLayer == LAYER_ANCHOR )
3582 {
3583 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
3584
3585 // A fixed pixel size at any zoom, which the shader rebuilds from the live projection
3586 double worldScale = m_gal->GetWorldScaleForScreenSpace();
3587 double anchorSize = 5.0 / worldScale;
3588 double anchorThickness = 1.0 / worldScale;
3589
3590 m_gal->SetIsFill( false );
3591 m_gal->SetIsStroke( true );
3592 m_gal->SetStrokeColor( color );
3593 m_gal->SetLineWidth( anchorThickness );
3594 m_gal->SetScreenSpaceMode( true );
3595
3596 VECTOR2D center = aFootprint->GetPosition();
3597 m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
3598 m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
3599
3600 m_gal->SetScreenSpaceMode( false );
3601 }
3602
3603 if( aLayer == LAYER_LOCKED_ITEM_SHADOW && m_frameType == FRAME_PCB_EDITOR ) // happens only if locked
3604 {
3605 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
3606
3607 m_gal->SetIsFill( true );
3608 m_gal->SetIsStroke( false );
3609 m_gal->SetFillColor( color );
3610
3611#if 0 // GetBoundingHull() can be very slow, especially for logos imported from graphics
3612 const SHAPE_POLY_SET& poly = aFootprint->GetBoundingHull();
3613 m_canvas->DrawPolygon( poly );
3614#else
3615 BOX2I bbox = aFootprint->GetBoundingBox( false );
3616 VECTOR2I topLeft = bbox.GetPosition();
3617 VECTOR2I botRight = bbox.GetPosition() + bbox.GetSize();
3618
3619 m_gal->DrawRectangle( topLeft, botRight );
3620
3621 // Use segments to produce a margin with rounded corners
3622 m_gal->DrawSegment( topLeft, VECTOR2I( botRight.x, topLeft.y ), m_lockedShadowMargin );
3623 m_gal->DrawSegment( VECTOR2I( botRight.x, topLeft.y ), botRight, m_lockedShadowMargin );
3624 m_gal->DrawSegment( botRight, VECTOR2I( topLeft.x, botRight.y ), m_lockedShadowMargin );
3625 m_gal->DrawSegment( VECTOR2I( topLeft.x, botRight.y ), topLeft, m_lockedShadowMargin );
3626#endif
3627 }
3628
3629 if( aLayer == LAYER_CONFLICTS_SHADOW && aFootprint->IsConflicting() )
3630 {
3631 const SHAPE_POLY_SET& frontpoly = aFootprint->GetCourtyard( F_CrtYd );
3632 const SHAPE_POLY_SET& backpoly = aFootprint->GetCourtyard( B_CrtYd );
3633
3634 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
3635
3636 m_gal->SetIsFill( true );
3637 m_gal->SetIsStroke( false );
3638 m_gal->SetFillColor( color );
3639
3640 if( frontpoly.OutlineCount() > 0 )
3641 m_gal->DrawPolygon( frontpoly );
3642
3643 if( backpoly.OutlineCount() > 0 )
3644 m_gal->DrawPolygon( backpoly );
3645 }
3646}
3647
3648
3649void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
3650{
3651 if( aLayer == LAYER_ANCHOR )
3652 {
3653 if( aGroup->IsSelected() && !( aGroup->GetParent() && aGroup->GetParent()->IsSelected() ) )
3654 {
3655 // Selected on our own; draw enclosing box
3656 }
3657 else if( aGroup->IsEntered() )
3658 {
3659 // Entered group; draw enclosing box
3660 }
3661 else
3662 {
3663 // Neither selected nor entered; draw nothing at the group level (ie: only draw
3664 // its members)
3665 return;
3666 }
3667
3668 const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
3669
3670 m_gal->SetStrokeColor( color );
3671 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth * 2.0f );
3672
3673 BOX2I bbox = aGroup->GetBoundingBox();
3674 VECTOR2I topLeft = bbox.GetPosition();
3675 VECTOR2I width = VECTOR2I( bbox.GetWidth(), 0 );
3676 VECTOR2I height = VECTOR2I( 0, bbox.GetHeight() );
3677
3678 m_gal->DrawLine( topLeft, topLeft + width );
3679 m_gal->DrawLine( topLeft + width, topLeft + width + height );
3680 m_gal->DrawLine( topLeft + width + height, topLeft + height );
3681 m_gal->DrawLine( topLeft + height, topLeft );
3682
3683 wxString name = aGroup->GetName();
3684
3685 if( name.IsEmpty() )
3686 return;
3687
3688 int ptSize = 12;
3689 int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
3690 int unscaledSize = pcbIUScale.MilsToIU( ptSize );
3691
3692 // Scale by zoom a bit, but not too much
3693 int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
3694 VECTOR2I textOffset = KiROUND( width.x / 2.0, -textSize * 0.5 );
3695 VECTOR2I titleHeight = KiROUND( 0.0, textSize * 2.0 );
3696
3697 if( PrintableCharCount( name ) * textSize < bbox.GetWidth() )
3698 {
3699 m_gal->DrawLine( topLeft, topLeft - titleHeight );
3700 m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
3701 m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
3702
3703 TEXT_ATTRIBUTES attrs;
3704 attrs.m_Italic = true;
3707 attrs.m_Size = VECTOR2I( textSize, textSize );
3708 attrs.m_StrokeWidth = GetPenSizeForNormal( textSize );
3709
3710 KIFONT::FONT::GetFont()->Draw( m_gal, aGroup->GetName(), topLeft + textOffset, attrs,
3711 aGroup->GetFontMetrics() );
3712 }
3713 }
3714}
3715
3716
3717bool KIGFX::ZoneOutlineDrawnOnLayer( bool aOutlineOnly, int aLayer )
3718{
3719 if( aOutlineOnly )
3720 return IsZoneFillLayer( aLayer );
3721
3722 return !IsZoneFillLayer( aLayer );
3723}
3724
3725
3726void PCB_PAINTER::draw( const ZONE* aZone, int aLayer )
3727{
3728 SHAPE_POLY_SET zoneOutlineStorage;
3729 const SHAPE_POLY_SET* zoneOutline = &zoneOutlineStorage;
3730
3731 if( aZone->GetParentFootprint() )
3732 zoneOutlineStorage = aZone->GetBoardOutline();
3733 else
3734 zoneOutline = aZone->Outline();
3735
3736 if( aLayer == LAYER_CONFLICTS_SHADOW )
3737 {
3738 if( aZone->IsConflicting() && aZone->GetIsRuleArea() )
3739 {
3740 COLOR4D color = m_pcbSettings.GetColor( aZone, aLayer );
3741
3742 m_gal->SetIsFill( true );
3743 m_gal->SetIsStroke( false );
3744 m_gal->SetFillColor( color );
3745
3746 m_gal->DrawPolygon( zoneOutline->Outline( 0 ) );
3747 }
3748
3749 return;
3750 }
3751
3752 /*
3753 * aLayer will be the virtual zone layer (LAYER_ZONE_START, ... in GAL_LAYER_ID)
3754 * This is used for draw ordering in the GAL.
3755 * The color for the zone comes from the associated copper layer ( aLayer - LAYER_ZONE_START )
3756 * and the visibility comes from the combination of that copper layer and LAYER_ZONES
3757 */
3758 PCB_LAYER_ID layer;
3759
3760 if( IsZoneFillLayer( aLayer ) )
3761 layer = ToLAYER_ID( aLayer - LAYER_ZONE_START );
3762 else
3763 layer = ToLAYER_ID( aLayer );
3764
3765 if( !aZone->IsOnLayer( layer ) )
3766 return;
3767
3768 COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
3769 std::deque<VECTOR2D> corners;
3770 ZONE_DISPLAY_MODE displayMode = m_pcbSettings.m_ZoneDisplayMode;
3771
3772 if( aZone->IsTeardropArea() )
3773 displayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
3774
3775 // An outline-only zone draws on the zone layer, above copper, so tracks and pads can't hide it
3776 if( ZoneOutlineDrawnOnLayer( zoneOutlineOnly( aZone ), aLayer ) )
3777 {
3778 bool allowDrawOutline = aZone->GetHatchStyle() != ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER;
3779
3780 if( allowDrawOutline && !m_pcbSettings.m_isPrinting && zoneOutline && zoneOutline->OutlineCount() > 0 )
3781 {
3782 COLOR4D outlineColor = color.a > 0.0 ? color.WithAlpha( 1.0 ) : color;
3783
3784 if( m_pcbSettings.m_groupEditModeActive && !aZone->IsSelected() && !m_pcbSettings.isInEnteredGroup( aZone ) )
3785 outlineColor.a *= m_pcbSettings.m_outsideGroupOpacity;
3786
3787 m_gal->SetStrokeColor( outlineColor );
3788 m_gal->SetIsFill( false );
3789 m_gal->SetIsStroke( true );
3790 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
3791
3792 // Draw each contour (main contour and holes)
3793
3794 /*
3795 * m_canvas->DrawPolygon( *outline );
3796 * should be enough, but currently does not work to draw holes contours in a complex
3797 * polygon so each contour is draw as a simple polygon
3798 */
3799
3800 // Draw the main contour(s?)
3801 for( int ii = 0; ii < zoneOutline->OutlineCount(); ++ii )
3802 {
3803 m_gal->DrawPolyline( zoneOutline->COutline( ii ) );
3804
3805 // Draw holes
3806 int holes_count = zoneOutline->HoleCount( ii );
3807
3808 for( int jj = 0; jj < holes_count; ++jj )
3809 m_gal->DrawPolyline( zoneOutline->CHole( ii, jj ) );
3810 }
3811
3812 // Draw hatch lines
3813 for( const SEG& hatchLine : aZone->GetHatchLines() )
3814 m_gal->DrawLine( hatchLine.A, hatchLine.B );
3815 }
3816 }
3817
3818 // Draw the filling
3819 if( IsZoneFillLayer( aLayer )
3820 && ( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED
3822 || displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) )
3823 {
3824 const std::shared_ptr<SHAPE_POLY_SET>& polySet = aZone->GetFilledPolysList( layer );
3825
3826 if( polySet->OutlineCount() == 0 ) // Nothing to draw
3827 return;
3828
3829 m_gal->SetStrokeColor( color );
3830 m_gal->SetFillColor( color );
3831 m_gal->SetLineWidth( 0 );
3832
3833 if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
3834 {
3835 m_gal->SetIsFill( true );
3836 m_gal->SetIsStroke( false );
3837 }
3838 else
3839 {
3840 m_gal->SetIsFill( false );
3841 m_gal->SetIsStroke( true );
3842 }
3843
3844 // On Opengl, a not convex filled polygon is usually drawn by using triangles
3845 // as primitives. CacheTriangulation() can create basic triangle primitives to
3846 // draw the polygon solid shape on Opengl. GLU tessellation is much slower,
3847 // so currently we are using our tessellation.
3848 if( m_gal->UsesPolygonTriangulationCache() && !polySet->IsTriangulationUpToDate() )
3849 polySet->CacheTriangulation( true );
3850
3851 m_gal->DrawPolygon( *polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION );
3852 }
3853}
3854
3855
3856void PCB_PAINTER::draw( const PCB_BARCODE* aBarcode, int aLayer )
3857{
3858 const COLOR4D& color = m_pcbSettings.GetColor( aBarcode, aLayer );
3859
3860 m_gal->SetIsFill( true );
3861 m_gal->SetIsStroke( false );
3862 m_gal->SetFillColor( color );
3863
3864 // Draw the barcode
3865 SHAPE_POLY_SET shape;
3866
3867 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
3868 aBarcode->GetBoundingHull( shape, aBarcode->GetLayer(), m_lockedShadowMargin, m_maxError, ERROR_INSIDE );
3869 else
3870 aBarcode->TransformShapeToPolySet( shape, aBarcode->GetLayer(), 0, m_maxError, ERROR_INSIDE );
3871
3872 if( shape.OutlineCount() != 0 )
3873 m_gal->DrawPolygon( shape );
3874}
3875
3876
3877void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
3878{
3879 COLOR4D color = m_pcbSettings.GetColor( aDimension, aLayer );
3880
3881 if( aLayer == LAYER_LOCKED_ITEM_SHADOW || aLayer == LAYER_CONSTRAINT_SHADOW )
3882 {
3883 int margin = m_lockedShadowMargin;
3884
3885 if( aLayer == LAYER_CONSTRAINT_SHADOW
3886 && m_pcbSettings.GetHighlightedConstraintMembers().count( aDimension->m_Uuid ) )
3887 {
3888 color = color.Brightened( 0.5 );
3889 margin *= 2;
3890 }
3891
3892 m_gal->SetIsFill( true );
3893 m_gal->SetIsStroke( true );
3894 m_gal->SetFillColor( color );
3895 m_gal->SetStrokeColor( color );
3896 m_gal->SetLineWidth( margin );
3897
3898 for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
3899 {
3900 switch( shape->Type() )
3901 {
3902 case SH_SEGMENT:
3903 {
3904 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
3905 m_gal->DrawSegment( seg.A, seg.B, margin );
3906 break;
3907 }
3908
3909 case SH_CIRCLE:
3910 {
3911 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
3912 m_gal->DrawCircle( shape->Centre(), radius );
3913 break;
3914 }
3915
3916 default: break;
3917 }
3918 }
3919
3920 SHAPE_POLY_SET poly;
3921 aDimension->PCB_TEXT::TransformShapeToPolygon( poly, aDimension->GetLayer(), 0, m_maxError, ERROR_OUTSIDE );
3922 m_gal->DrawPolygon( poly );
3923
3924 return;
3925 }
3926
3927 m_gal->SetStrokeColor( color );
3928 m_gal->SetFillColor( color );
3929 m_gal->SetIsFill( false );
3930 m_gal->SetIsStroke( true );
3931
3933
3934 if( outline_mode )
3935 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
3936 else
3937 m_gal->SetLineWidth( getLineThickness( aDimension->GetLineThickness() ) );
3938
3939 // Draw dimension shapes
3940 // TODO(JE) lift this out
3941 for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
3942 {
3943 switch( shape->Type() )
3944 {
3945 case SH_SEGMENT:
3946 {
3947 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
3948 m_gal->DrawLine( seg.A, seg.B );
3949 break;
3950 }
3951
3952 case SH_CIRCLE:
3953 {
3954 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
3955 m_gal->DrawCircle( shape->Centre(), radius );
3956 break;
3957 }
3958
3959 default:
3960 break;
3961 }
3962 }
3963
3964 // Draw text
3965 wxString resolvedText = aDimension->GetShownText( FOR_CANVAS );
3966 TEXT_ATTRIBUTES attrs = aDimension->GetAttributes();
3967
3968 if( m_gal->IsFlippedX() && !aDimension->IsSideSpecific() )
3969 attrs.m_Mirrored = !attrs.m_Mirrored;
3970
3971 if( outline_mode )
3972 attrs.m_StrokeWidth = m_pcbSettings.m_outlineWidth;
3973 else
3975
3976 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
3977
3978 if( aDimension->GetFont() && aDimension->GetFont()->IsOutline() )
3979 cache = aDimension->GetRenderCache( aDimension->GetFont(), resolvedText );
3980
3981 if( cache )
3982 {
3983 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
3984 m_gal->DrawGlyph( *glyph );
3985 }
3986 else
3987 {
3988 strokeText( resolvedText, aDimension->GetTextPos(), attrs, aDimension->GetFontMetrics() );
3989 }
3990}
3991
3992
3993void PCB_PAINTER::draw( const PCB_GRID_ITEM* aGridItem, int aLayer )
3994{
3995 // Grid content (lines/dots/crosses) is rendered by the GAL backend through GRID_SOURCE (see
3996 // PCB_DRAW_PANEL_GAL::prepareGridSources). Only selection decorations - outline and centre
3997 // marker - live here, on LAYER_GRID_ITEMS. The item is also registered on m_layer for VIEW::Query
3998 // (selection); skip those passes.
3999 const bool shadow = aLayer == LAYER_LOCKED_ITEM_SHADOW; // happens only if locked
4000
4001 if( aLayer != LAYER_SUBGRIDS && !shadow )
4002 return;
4003
4004 if( !shadow && !aGridItem->IsSelected() )
4005 return;
4006
4007 m_gal->SetLineWidth( shadow ? (float) m_lockedShadowMargin : m_pcbSettings.m_outlineWidth );
4008 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aGridItem, aLayer ) );
4009 m_gal->SetIsFill( false );
4010 m_gal->SetIsStroke( true );
4011
4012 m_gal->Save();
4013 m_gal->Translate( VECTOR2D( aGridItem->GetPosition() ) );
4014 // GAL::Rotate is math-convention; grid orientation is screen-convention - negate.
4015 m_gal->Rotate( -aGridItem->GetOrientation().AsRadians() );
4016
4017 switch( aGridItem->GetGridItemType() )
4018 {
4020 {
4021 // hairline outline at the maximum radius, only over the active phi range
4022 const int radius = aGridItem->GetRadiusExtent();
4023 const double phiMax = aGridItem->GetPhiExtent().AsRadians();
4024 m_gal->DrawArc( VECTOR2D( 0, 0 ), radius, EDA_ANGLE( 0, RADIANS_T ), EDA_ANGLE( phiMax, RADIANS_T ) );
4025
4026 // bounding "pie" radials when phi is less than full circle
4027 if( phiMax + 1e-9 < 2 * M_PI )
4028 {
4029 m_gal->DrawLine( VECTOR2D( 0, 0 ), VECTOR2D( radius, 0 ) );
4030 m_gal->DrawLine( VECTOR2D( 0, 0 ), VECTOR2D( radius * std::cos( phiMax ), radius * std::sin( phiMax ) ) );
4031 }
4032 break;
4033 }
4034
4036 {
4037 // hairline outline rectangle centred on the grid origin
4038 const VECTOR2I extent = aGridItem->GetExtent();
4039 m_gal->DrawLine( VECTOR2D( -extent.x, -extent.y ), VECTOR2D( extent.x, -extent.y ) );
4040 m_gal->DrawLine( VECTOR2D( extent.x, -extent.y ), VECTOR2D( extent.x, extent.y ) );
4041 m_gal->DrawLine( VECTOR2D( extent.x, extent.y ), VECTOR2D( -extent.x, extent.y ) );
4042 m_gal->DrawLine( VECTOR2D( -extent.x, extent.y ), VECTOR2D( -extent.x, -extent.y ) );
4043 break;
4044 }
4045
4046 default:
4047 wxFAIL_MSG( wxT( "draw(PCB_GRID_ITEM*): unhandled PCB_GRID_TYPE" ) );
4048 break;
4049 }
4050
4051 if( shadow )
4052 {
4053 m_gal->Restore();
4054 return;
4055 }
4056
4057 // Centre marker: screen-pixel-sized '+' cross in the LAYER_ANCHOR color, same
4058 // convention FOOTPRINT uses for its anchor (see draw(FOOTPRINT*)).
4059 const double anchorSize = 5.0 / m_gal->GetWorldScale();
4060 const double anchorThickness = 1.0 / m_gal->GetWorldScale();
4061 const COLOR4D anchorColor = m_pcbSettings.GetColor( aGridItem, LAYER_ANCHOR );
4062
4063 m_gal->SetStrokeColor( anchorColor );
4064 m_gal->SetLineWidth( anchorThickness );
4065 m_gal->DrawLine( VECTOR2D( -anchorSize, 0 ), VECTOR2D( anchorSize, 0 ) );
4066 m_gal->DrawLine( VECTOR2D( 0, -anchorSize ), VECTOR2D( 0, anchorSize ) );
4067
4068 m_gal->Restore();
4069}
4070
4071
4072void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
4073{
4074 const COLOR4D strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
4075 VECTOR2D position( aTarget->GetPosition() );
4076 double size, radius;
4077
4078 m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
4079 m_gal->SetStrokeColor( strokeColor );
4080 m_gal->SetIsFill( false );
4081 m_gal->SetIsStroke( true );
4082
4083 m_gal->Save();
4084 m_gal->Translate( position );
4085
4086 if( aTarget->GetShape() )
4087 {
4088 // shape x
4089 m_gal->Rotate( M_PI / 4.0 );
4090 size = 2.0 * aTarget->GetSize() / 3.0;
4091 radius = aTarget->GetSize() / 2.0;
4092 }
4093 else
4094 {
4095 // shape +
4096 size = aTarget->GetSize() / 2.0;
4097 radius = aTarget->GetSize() / 3.0;
4098 }
4099
4100 m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
4101 m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
4102 m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
4103
4104 m_gal->Restore();
4105}
4106
4107
4108void PCB_PAINTER::draw( const PCB_POINT* aPoint, int aLayer )
4109{
4110 // aLayer will be the virtual point layer (LAYER_POINT_START, ... in GAL_LAYER_ID).
4111 // This is used for draw ordering in the GAL.
4112 // The cross color comes from LAYER_POINTS and the ring color follows the point's board layer.
4113 // Visibility comes from the combination of that board layer and LAYER_POINTS.
4114
4115 double size = (double)aPoint->GetSize() / 2;
4116
4117 // Keep the width constant, not related to the scale because the anchor
4118 // is just a marker on screen, just draw in pixels
4119 double thickness = m_pcbSettings.m_outlineWidth;
4120
4121 // The general "points" colour
4122 COLOR4D crossColor = m_pcbSettings.GetColor( aPoint, LAYER_POINTS );
4123 // The colour for the ring around the point follows the "real" layer of the point
4124 COLOR4D ringColor = m_pcbSettings.GetColor( aPoint, aPoint->GetLayer() );
4125
4126 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
4127 {
4128 thickness += m_lockedShadowMargin;
4129 crossColor = m_pcbSettings.GetColor( aPoint, aLayer );
4130 ringColor = m_pcbSettings.GetColor( aPoint, aLayer );
4131 }
4132
4133 VECTOR2D position( aPoint->GetPosition() );
4134
4135 m_gal->SetLineWidth( (float) thickness );
4136 m_gal->SetStrokeColor( crossColor );
4137 m_gal->SetIsFill( false );
4138 m_gal->SetIsStroke( true );
4139
4140 m_gal->Save();
4141 m_gal->Translate( position );
4142
4143 // Draw as X to make it clearer when overlaid on cursor or axes
4144 m_gal->DrawLine( VECTOR2D( -size, -size ), VECTOR2D( size, size ) );
4145 m_gal->DrawLine( VECTOR2D( size, -size ), VECTOR2D( -size, size ) );
4146
4147 // Draw the circle in the layer colour
4148 m_gal->SetStrokeColor( ringColor );
4149 m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size / 2 );
4150
4151 m_gal->Restore();
4152}
4153
4154
4155void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer )
4156{
4157 // Don't paint invisible markers.
4158 // It would be nice to do this through layer dependencies but we can't do an "or" there today
4159 if( aMarker->GetBoard() && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
4160 return;
4161
4162 // The active marker is redrawn on LAYER_DRC_HIGHLIGHTED so it lands on top of any
4163 // neighbouring inactive markers
4164 if( aLayer == LAYER_DRC_HIGHLIGHTED && !aMarker->IsBrightened() && !aMarker->IsSelected() )
4165 return;
4166
4167 bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
4168 COLOR4D color = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
4169 COLOR4D shadowColor = m_pcbSettings.GetColor( aMarker, LAYER_MARKER_SHADOWS );
4171
4172 aMarker->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) );
4173 aMarker->ShapeToPolygon( polygon );
4174
4175 m_gal->Save();
4176 m_gal->Translate( aMarker->GetPosition() );
4177
4178 m_gal->SetStrokeColor( shadowColor );
4179 m_gal->SetFillColor( color );
4180
4181 if( isShadow )
4182 {
4183 m_gal->SetIsFill( false );
4184 m_gal->SetIsStroke( true );
4185 m_gal->SetLineWidth( (float) aMarker->MarkerScale() );
4186 }
4187 else
4188 {
4189 m_gal->SetIsFill( true );
4190 m_gal->SetIsStroke( false );
4191 }
4192
4193 m_gal->DrawPolygon( polygon );
4194 m_gal->Restore();
4195
4196 // Draw the error legend shapes.
4197 if( aLayer == LAYER_DRC_HIGHLIGHTED )
4198 {
4199 COLOR4D legendColor = m_pcbSettings.m_backgroundColor;
4200 double bg_h, bg_s, bg_l;
4201 COLOR4D haloColor;
4202
4203 legendColor.ToHSL( bg_h, bg_s, bg_l );
4204 haloColor.FromHSL( bg_h, bg_s, bg_l < 0.5 ? 1.0 : 0.0 );
4205
4206 m_gal->SetLineWidth( (float) aMarker->MarkerScale() / 3.0f );
4207 m_gal->SetStrokeColor( legendColor.WithAlpha( 1.0 ) );
4208 m_gal->SetFillColor( haloColor.WithAlpha( 0.5 ) );
4209
4210 for( const PCB_SHAPE& shape : aMarker->GetErrorLegendShapes() )
4211 {
4212 if( shape.GetStroke().GetWidth() == 1.0 ) // Item is a legend graphic
4213 {
4214 m_gal->SetIsFill( false );
4215 m_gal->SetIsStroke( true );
4216
4217 if( shape.GetShape() == SHAPE_T::SEGMENT )
4218 {
4219 m_gal->DrawLine( shape.GetStart(), shape.GetEnd() );
4220 }
4221 else if( shape.GetShape() == SHAPE_T::ARC )
4222 {
4223 EDA_ANGLE startAngle, endAngle;
4224 shape.CalcArcAngles( startAngle, endAngle );
4225
4226 m_gal->DrawArc( shape.GetCenter(), shape.GetRadius(), startAngle, shape.GetArcAngle() );
4227 }
4228 }
4229 else // Item is a highlight halo
4230 {
4231 m_gal->SetIsFill( true );
4232 m_gal->SetIsStroke( false );
4233
4234 if( shape.GetShape() == SHAPE_T::SEGMENT )
4235 {
4236 m_gal->DrawSegment( shape.GetStart(), shape.GetEnd(), shape.GetWidth() );
4237 }
4238 else if( shape.GetShape() == SHAPE_T::ARC )
4239 {
4240 EDA_ANGLE startAngle, endAngle;
4241 shape.CalcArcAngles( startAngle, endAngle );
4242
4243 m_gal->DrawArcSegment( shape.GetCenter(), shape.GetRadius(), startAngle, shape.GetArcAngle(),
4244 shape.GetWidth(), ARC_HIGH_DEF );
4245 }
4246 }
4247 }
4248 }
4249}
4250
4251
4252void PCB_PAINTER::draw( const PCB_BOARD_OUTLINE* aBoardOutline, int aLayer )
4253{
4254 if( !aBoardOutline->HasOutline() )
4255 return;
4256
4257 // aBoardOutline makes sense only for the board editor. for fp holder boards
4258 // there are no board outlines area.
4259 const BOARD* brd = aBoardOutline->GetBoard();
4260
4261 if( !brd || brd->GetBoardUse() == BOARD_USE::FPHOLDER )
4262 return;
4263
4265 m_gal->Save();
4266
4267 const COLOR4D& outlineColor = m_pcbSettings.GetColor( aBoardOutline, aLayer );
4268 m_gal->SetFillColor( outlineColor );
4269 m_gal->AdvanceDepth();
4270 m_gal->SetLineWidth( 0 );
4271 m_gal->SetIsFill( true );
4272 m_gal->SetIsStroke( false );
4273 m_gal->DrawPolygon( aBoardOutline->GetOutline() );
4274
4275 m_gal->Restore();
4276}
4277
4278
4280 int aBackdrillSize, PCB_LAYER_ID aMustCutLayer, int aOffset )
4281{
4282 double backdrillRadius = aBackdrillSize / 2.0;
4283 double lineWidth = std::max( backdrillRadius / 16.0, m_pcbSettings.m_outlineWidth * 2.0 );
4284
4285 // Inset so entire graphic is within backdrill extent
4286 backdrillRadius -= lineWidth / 2;
4287
4289 m_gal->AdvanceDepth();
4290 m_gal->SetIsFill( false );
4291 m_gal->SetIsStroke( true );
4292 m_gal->SetLineWidth( (float) lineWidth );
4293
4294 // Draw dashed circle manually with fixed number of segments for consistent appearance
4295 constexpr int NUM_DASHES = 12; // Number of dashes around the circle
4296 EDA_ANGLE dashAngle = ANGLE_360 / ( NUM_DASHES * 2 ); // Dash and gap are equal size
4297
4298 for( int i = aOffset; i < NUM_DASHES; i += 2 )
4299 {
4300 EDA_ANGLE startAngle = dashAngle * ( i * 2 );
4301 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aItem, aMustCutLayer ) );
4302 m_gal->DrawArc( aCenter, backdrillRadius, startAngle, dashAngle );
4303 }
4304}
4305
4306
4308{
4309 int size = 0;
4310
4311 // Check to see if the pad or via has a post-machining operation on this layer
4312 if( const PAD* pad = dynamic_cast<const PAD*>( aItem ) )
4313 size = pad->GetPostMachiningKnockout( aLayer );
4314 else if( const PCB_VIA* via = dynamic_cast<const PCB_VIA*>( aItem ) )
4315 size = via->GetPostMachiningKnockout( aLayer );
4316
4317 if( size <= 0 )
4318 return;
4319
4321 m_gal->AdvanceDepth();
4322
4323 double pmRadius = size / 2.0;
4324 // Use a line width proportional to the radius for visibility
4325 double lineWidth = std::max( pmRadius / 16.0, m_pcbSettings.m_outlineWidth * 2.0 );
4326
4327 // Inset so entire graphic is within post machining extent
4328 pmRadius -= lineWidth / 2;
4329
4330 COLOR4D layerColor = m_pcbSettings.GetColor( aItem, aLayer );
4331
4332 m_gal->SetIsFill( false );
4333 m_gal->SetIsStroke( true );
4334 m_gal->SetStrokeColor( layerColor );
4335 m_gal->SetLineWidth( (float) lineWidth );
4336
4337 // Draw dashed circle manually with fixed number of segments for consistent appearance
4338 constexpr int NUM_DASHES = 12; // Number of dashes around the circle
4339 EDA_ANGLE dashAngle = ANGLE_360 / ( NUM_DASHES * 2 ); // Dash and gap are equal size
4340
4341 for( int i = 0; i < NUM_DASHES; ++i )
4342 {
4343 EDA_ANGLE startAngle = dashAngle * ( i * 2 );
4344 m_gal->DrawArc( aCenter, pmRadius, startAngle, dashAngle );
4345 }
4346}
4347
4348
4349const double PCB_RENDER_SETTINGS::MAX_FONT_SIZE = pcbIUScale.mmToIU( 10.0 );
const char * name
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
constexpr int ARC_HIGH_DEF
Definition base_units.h:144
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
@ FPHOLDER
Definition board.h:403
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
@ ALL
Net/netclass colors are shown on all net copper.
ZONE_DISPLAY_MODE
Determine how zones should be displayed.
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
BOX2< VECTOR2D > BOX2D
Definition box2.h:918
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMaxError=10)
Convert a Bezier curve to a polygon.
Generic cubic Bezier representation.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
NETINFO_ITEM * GetNet() const
Return NETINFO_ITEM object for a given item.
const wxString & GetDisplayNetname() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
Container for design settings for a BOARD object.
int GetHolePlatingThickness() const
Pad & via drills are finish size.
DRILL_SYMBOL_PROFILE & GetDrillSymbolProfile()
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:99
virtual BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const
Create a copy of this BOARD_ITEM.
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition board_item.h:187
virtual bool IsKnockout() const
Definition board_item.h:437
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition board_item.h:369
virtual void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const
Convert the item shape to a polyset.
Definition board_item.h:582
const KIFONT::METRICS & GetFontMetrics() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:281
bool IsSideSpecific() const
virtual int BoardCopperLayerCount() const
Return the total number of copper layers for the board that this item resides on.
virtual bool IsOnCopperLayer() const
Definition board_item.h:204
int GetMaxError() const
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
std::vector< const PCB_DRILL_MAP * > DrillMapsOnLayer(PCB_LAYER_ID aLayer) const
Every map on this layer.
Definition board.cpp:207
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition board.h:430
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:1269
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:1216
std::shared_ptr< const DRILL_SYMBOL_CACHE > DrillSymbolCache() const
Resolved drill symbols, by group and by owning item.
Definition board.cpp:265
KIGFX::COLOR4D GetNetChainColor(const wxString &aChain) const
Definition board.h:1368
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:1202
BOARD_DESIGN_SETTINGS & GetDesignSettings()
Definition board.cpp:1318
constexpr const Vec & GetPosition() const
Definition box2.h:214
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr const Vec GetEnd() const
Definition box2.h:215
constexpr void SetOrigin(const Vec &pos)
Definition box2.h:240
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:149
constexpr size_type GetWidth() const
Definition box2.h:217
constexpr Vec Centre() const
Definition box2.h:100
constexpr const Vec GetCenter() const
Definition box2.h:233
constexpr size_type GetHeight() const
Definition box2.h:218
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:171
constexpr const Vec & GetOrigin() const
Definition box2.h:213
constexpr const SizeVec & GetSize() const
Definition box2.h:209
constexpr void SetEnd(coord_type x, coord_type y)
Definition box2.h:300
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
APPEARANCE m_Appearance
Grouping rules and symbol assignments, shared by reference so a chart and its map can never disagree ...
EDA_ANGLE Normalize90()
Definition eda_angle.h:260
double AsRadians() const
Definition eda_angle.h:119
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
wxString GetName() const
Definition eda_group.h:75
virtual EDA_ITEM * AsEdaItem()=0
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition eda_item.cpp:280
const KIID m_Uuid
Definition eda_item.h:599
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
bool IsEntered() const
Definition eda_item.h:135
bool IsSelected() const
Definition eda_item.h:134
bool IsBrightened() const
Definition eda_item.h:136
bool IsMoving() const
Definition eda_item.h:132
EDA_ANGLE GetAngle() const
Definition eda_angle.h:557
static bool ShortenSegmentForEndings(VECTOR2I &aStart, VECTOR2I &aEnd, const LINE_ENDING &aStartEnding, const LINE_ENDING &aEndEnding, int aLineWidth)
Shorten a segment body for line endings.
int GetEllipseMinorRadius() const
Definition eda_shape.h:404
const VECTOR2I & GetEllipseCenter() const
Definition eda_shape.h:386
virtual VECTOR2I GetTopLeft() const
Definition eda_shape.h:365
EDA_ANGLE GetEllipseEndAngle() const
Definition eda_shape.h:432
int GetEllipseMajorRadius() const
Definition eda_shape.h:395
int GetRectangleWidth() const
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:566
void GetEndingTangents(EDA_ANGLE &aStartTangent, EDA_ANGLE &aEndTangent, int aLineWidth=0) const
Compute outward-facing tangent angles at the start and end of the shape.
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
EDA_ANGLE GetEllipseRotation() const
Definition eda_shape.h:413
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:178
std::vector< SHAPE * > MakeEffectiveShapesForStroking(int aLineWidth=-1) const
Make a set of SHAPE objects to hand to STROKE_PARAMS::Stroke().
virtual VECTOR2I GetBotRight() const
Definition eda_shape.h:366
bool GetShortenedBodyPolyPoints(const SHAPE_LINE_CHAIN &aOutline, int aOutlineIdx, std::vector< VECTOR2I > &aPoints, int aLineWidth) const
Copy an outline and apply line-ending body shortening when applicable.
const std::vector< SEG > & GetHatchLines() const
bool IsHatchedFill() const
Definition eda_shape.h:133
bool GetLineEndingEndpoints(VECTOR2I &aStartPoint, VECTOR2I &aEndPoint) const
Return the source endpoints used to place line endings.
virtual int GetHatchLineWidth() const
Definition eda_shape.h:168
bool IsSolidFill() const
Definition eda_shape.h:126
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:334
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:284
std::vector< VECTOR2I > GetRectCorners() const
bool IsAnyFill() const
Definition eda_shape.h:121
EDA_ANGLE GetEllipseStartAngle() const
Definition eda_shape.h:423
const LINE_ENDING & GetStartEnding() const
Definition eda_shape.h:180
std::optional< BEZIER< double > > ShortenedBezierCurve(int aLineWidth) const
Return the cubic Bezier curve shortened for line endings.
int GetRectangleHeight() const
bool ShortenArcForEndings(EDA_ANGLE &aStartAngle, EDA_ANGLE &aArcAngle, double aRadius, int aLineWidth) const
Shorten an arc body for line endings.
const LINE_ENDING & GetEndEnding() const
Definition eda_shape.h:186
int GetCornerRadius() const
virtual bool IsVisible() const
Definition eda_text.h:226
KIFONT::FONT * GetFont() const
Definition eda_text.h:286
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:684
BOX2I GetTextBox(const RENDER_SETTINGS *aSettings, int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition eda_text.cpp:755
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:239
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition eda_text.cpp:648
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:270
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:428
LSET GetPrivateLayers() const
Definition footprint.h:295
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
bool IsConflicting() const
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
VECTOR2I GetPosition() const override
Definition footprint.h:379
DRAWINGS & GraphicalItems()
Definition footprint.h:358
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
APP_SETTINGS_BASE * KifaceSettings() const
Definition kiface_base.h:92
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition font.cpp:144
virtual bool IsStroke() const
Definition font.h:101
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr) const
Draw a string.
Definition font.cpp:243
virtual bool IsOutline() const
Definition font.h:102
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
double r
Red component.
Definition color4d.h:391
double g
Green component.
Definition color4d.h:392
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition color4d.h:309
static const COLOR4D CLEAR
Definition color4d.h:405
void ToHSL(double &aOutHue, double &aOutSaturation, double &aOutLightness) const
Converts current color (stored in RGB) to HSL format.
Definition color4d.cpp:309
COLOR4D & Darken(double aFactor)
Makes the color darker by a given factor.
Definition color4d.h:223
COLOR4D Darkened(double aFactor) const
Return a color that is darker by a given factor, without modifying object.
Definition color4d.h:279
COLOR4D Inverted() const
Returns an inverted color, alpha remains the same.
Definition color4d.h:321
COLOR4D & Brighten(double aFactor)
Makes the color brighter by a given factor.
Definition color4d.h:206
static const COLOR4D WHITE
Definition color4d.h:403
double a
Alpha component.
Definition color4d.h:394
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition color4d.h:265
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
void FromHSL(double aInHue, double aInSaturation, double aInLightness)
Change currently used color to the one given by hue, saturation and lightness parameters.
Definition color4d.cpp:342
static const COLOR4D BLACK
Definition color4d.h:404
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:293
double b
Blue component.
Definition color4d.h:393
Attribute save/restore for GAL attributes.
Abstract interface for drawing on a 2D-surface.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition painter.h:104
PAINTER(GAL *aGal)
Initialize this object for painting on any of the polymorphic GRAPHICS_ABSTRACTION_LAYER* derivatives...
Definition painter.cpp:29
void drawPostMachiningIndicator(const BOARD_ITEM *aItem, const VECTOR2D &aCenter, PCB_LAYER_ID aLayer)
Draw post-machining indicator (dashed circle) at the given center point.
virtual SHAPE_SEGMENT getPadHoleShape(const PAD *aPad) const
Return hole shape for a pad (internal units).
void drawChartSymbols(const PCB_DRILL_CHART *aChart, int aLayer)
PCB_PAINTER(GAL *aGal, FRAME_T aFrameType)
int getLineThickness(int aActualThickness) const
Get the thickness to draw for a line (e.g.
void drawDrillSymbol(const BOARD_ITEM *aItem, int aLayer)
virtual bool HasUniformColor(const VIEW_ITEM *aItem, int aLayer) const override
Return false when drawing the item on the given layer emits more than one colour, so a cached group o...
void renderNetNameForSegment(const SHAPE_SEGMENT &aSeg, const COLOR4D &aColor, const wxString &aNetName) const
bool zoneOutlineOnly(const ZONE *aZone) const
True when a zone's only visual is its outline, as for a rule area or outline-only display.
PCB_VIEWERS_SETTINGS_BASE * viewer_settings()
void draw(const PCB_TRACK *aTrack, int aLayer)
void drawDrillMarks(const PCB_DRILL_MAP *aMap, const std::vector< DRILL_SYMBOL_ENTRY > &aEntries, const COLOR4D &aColor, const KIFONT::METRICS &aFontMetrics)
One hole's marks for one map.
virtual PAD_DRILL_SHAPE getDrillShape(const PAD *aPad) const
Return drill shape of a pad.
void drawBackdrillIndicator(const BOARD_ITEM *aItem, const VECTOR2D &aCenter, int aBackdrillSize, PCB_LAYER_ID aMustCutLayer, int aOffset)
Draw backdrill indicator (two semi-circles) at the given center point.
PCB_RENDER_SETTINGS m_pcbSettings
virtual int getViaDrillSize(const PCB_VIA *aVia) const
Return drill diameter for a via (internal units).
void strokeText(const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs, const KIFONT::METRICS &aFontMetrics)
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.
double m_trackOpacity
Opacity override for all tracks.
double m_imageOpacity
Opacity override for user images.
double m_viaOpacity
Opacity override for all types of via.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
void LoadColors(const COLOR_SETTINGS *aSettings) override
double m_padOpacity
Opacity override for SMD pads and PTHs.
double m_outsideGroupOpacity
Opacity override for items outside the entered group.
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
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
std::map< int, KIGFX::COLOR4D > m_netColors
Overrides for specific net colors, stored as netcodes for the ratsnest to access easily.
bool isInEnteredGroup(const BOARD_ITEM *aItem) const
NET_COLOR_MODE m_netColorMode
How to display nets and netclasses with color overrides.
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
double m_filledShapeOpacity
Opacity override for graphic shapes.
bool IsDimExempt(const VIEW_ITEM *aItem) const override
Return true for an item that keeps its colour on a layer the canvas fades, such as a selected item in...
bool GetShowPageLimits() const override
std::bitset< MAX_LAYERS_FOR_VIEW > m_canvasFadedLayers
Layers the canvas fades for high contrast, see SetCanvasFadedLayers()
bool m_groupEditModeActive
True when inside an entered group.
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Load settings related to display options (high-contrast mode, full or outline modes for vias/pads/tra...
bool GetLayerDim(int aLayer, COLOR4D &aToward, double &aKeep) const override
Get how the canvas fades a whole layer, see GAL::SetSceneLayerDim().
bool IsCanvasFadedLayer(int aLayer) const
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
void SetGapLengthRatio(double aRatio)
PCB_LAYER_ID GetActiveLayer() const
std::map< int, COLOR4D > m_layerColorsHi
virtual void update()
Precalculates extra colors for layers (e.g.
void SetDashLengthRatio(double aRatio)
std::set< int > m_highlightNetcodes
std::map< int, COLOR4D > m_layerColorsDark
std::map< int, COLOR4D > m_layerColorsSel
std::set< int > m_highContrastLayers
std::map< int, COLOR4D > m_layerColors
bool m_hiContrastEnabled
Parameters for display modes.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:82
bool IsBOARD_ITEM() const
Definition view_item.h:98
double GetForcedTransparency() const
Definition view_item.h:167
int GetShortenDepth(int aLineWidth) const
Return how far the line should be shortened at this ending.
void Draw(KIGFX::GAL &aGal, const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, double aLineWidth, const KIGFX::COLOR4D &aColor) const
LINE_ENDING_STYLE GetStyle() const
Definition line_ending.h:81
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
Definition lset.cpp:538
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:309
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
static const LSET & AllLayersMask()
Definition lset.cpp:637
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition lset.cpp:693
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition marker_base.h:63
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...
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:44
COLOR4D GetPcbColor(bool aIsForSave=false) const
Definition netclass.h:214
bool HasPcbColor() const
Definition netclass.h:213
Handle the data for a net.
Definition netinfo.h:50
const wxString & GetNetChain() const
Definition netinfo.h:122
PAD * GetTerminalPad(int aIndex) const
Definition netinfo.h:125
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition netinfo.h:281
@ NORMAL
Shape is the same on all layers.
Definition padstack.h:175
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
Definition padstack.h:184
Definition pad.h:61
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1953
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition pad.h:579
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
Definition pad.h:375
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1053
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:697
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition pad.cpp:1233
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1545
PAD_ATTRIB GetAttribute() const
Definition pad.h:582
const wxString & GetPinFunction() const
Definition pad.h:154
const wxString & GetNumber() const
Definition pad.h:143
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool aIgnoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:3036
VECTOR2I GetPosition() const override
Definition pad.cpp:255
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pad.h:564
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.cpp:848
VECTOR2I GetDrillSize() const
Definition pad.h:320
bool IsNoConnectPad() const
Definition pad.cpp:608
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:205
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1960
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:297
bool IsFreePad() const
Definition pad.cpp:614
const VECTOR2I & GetSecondaryDrillSize() const
Definition pad.h:533
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1672
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:438
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition pad.cpp:1124
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
Definition pad.cpp:908
VECTOR2I GetSolderPasteMargin(PCB_LAYER_ID aLayer) const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition pad.cpp:2022
const VECTOR2I & GetTertiaryDrillSize() const
Definition pad.h:550
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1825
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pad.h:547
DISPLAY_OPTIONS m_Display
bool IsDegenerated(int aThreshold=5) const
virtual double GetLength() const override
Return the length of the arc track.
Definition pcb_track.h:338
EDA_ANGLE GetArcAngleStart() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_track.h:311
const VECTOR2I GetFocusPosition() const override
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition pcb_track.h:309
double GetRadius() const
EDA_ANGLE GetAngle() const
const VECTOR2I & GetMid() const
Definition pcb_track.h:304
void GetBoundingHull(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Add two rectangular polygons separately bounding the barcode's symbol and the barcode's text.
bool HasOutline() const
const SHAPE_POLY_SET & GetOutline() const
Abstract dimension API.
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
double m_TrackOpacity
Opacity override for all tracks.
double m_FilledShapeOpacity
Opacity override for graphic shapes.
double m_ZoneOpacity
Opacity override for filled zone areas.
double m_OutsideGroupOpacity
Opacity override for items outside the entered group.
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 drill chart placed on the board, kept in step with the holes.
const std::map< int, int > & RowShapes() const
Curated shape index for each generated row, by table row.
int GetSymbolColumn() const
Table column the symbol is drawn in, or -1 when the chart has no symbol column.
Turns on drill symbols at the holes, for one layer.
bool GetAllSpans() const
int GetSymbolSize() const
bool GetGuideCross() const
bool GetOutlineSlots() const
const DRILL_SPAN & GetSpan() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
std::shared_ptr< const SHAPE_POLY_SET > GetBoardOutlines() const
The board outline displaced by this map's offset.
const VECTOR2I & GetOffset() const
EDA_ANGLE GetPhiExtent() const
VECTOR2I GetExtent() const
VECTOR2I GetPosition() const override
EDA_ANGLE GetOrientation() const
int GetRadiusExtent() const
PCB_GRID_TYPE GetGridItemType() const
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.
void SetZoom(double aZoomFactor) const
std::vector< PCB_SHAPE > GetErrorLegendShapes() const
GAL_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
Definition pcb_marker.h:70
PCB_VIEWERS_SETTINGS_BASE * viewer_settings()
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:39
int GetSize() const
Definition pcb_point.h:69
VECTOR2I GetPosition() const override
Definition pcb_point.h:60
Object to handle a bitmap image that can be inserted in a PCB.
REFERENCE_IMAGE & GetReferenceImage()
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_shape.h:80
int GetWidth() const override
bool HasSolderMask() const
Definition pcb_shape.h:349
int GetSolderMaskExpansion() const
bool IsProxyItem() const override
Definition pcb_shape.h:155
STROKE_PARAMS GetStroke() const override
void UpdateHatching() const override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pcb_shape.h:70
int GetRowSpan() const
int GetColSpan() const
PCB_TABLECELL * GetCell(int aRow, int aCol) const
Definition pcb_table.h:155
std::vector< PCB_TABLECELL * > GetCells() const
Definition pcb_table.h:165
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
int GetShape() const
Definition pcb_target.h:54
int GetWidth() const
Definition pcb_target.h:60
int GetSize() const
Definition pcb_target.h:57
VECTOR2I GetPosition() const override
Definition pcb_target.h:51
bool IsBorderEnabled() const
Tests whether the border is disabled, as configured by the stroke.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Convert the text to a polygonSet describing the actual character strokes (one per segment).
VECTOR2I GetTextSize() const override
VECTOR2I GetDrawPos() const override
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
PCB_SHAPE GetPolygonalBoxShape() const
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
std::vector< VECTOR2I > GetCorners() const override
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition pcb_text.cpp:857
const SHAPE_POLY_SET & GetKnockoutCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, int aMaxError) const
Definition pcb_text.cpp:721
VECTOR2I GetTextPos() const override
Definition pcb_text.cpp:463
int GetTextThickness() const override
Definition pcb_text.cpp:499
EDA_ANGLE GetDrawRotation() const override
Definition pcb_text.cpp:222
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition pcb_text.cpp:180
VECTOR2I GetTextSize() const override
Definition pcb_text.cpp:472
int GetSolderMaskExpansion() const
const VECTOR2I & GetStart() const
Definition pcb_track.h:100
const VECTOR2I & GetEnd() const
Definition pcb_track.h:97
virtual int GetWidth() const
Definition pcb_track.h:94
PCB_LAYER_ID BottomLayer() const
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pcb_track.h:878
std::optional< int > GetTertiaryDrillSize() const
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
std::optional< int > GetSecondaryDrillSize() const
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pcb_track.h:864
int GetWidth() const override
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
PCB_LAYER_ID TopLayer() const
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
VIATYPE GetViaType() const
Definition pcb_track.h:426
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Return the 2 layers used by the via (the via actually uses all layers between these 2 layers)
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:600
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:124
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
EDA_ANGLE GetOrientation() const
VECTOR2I GetPosition() const
double GetOpacity() const
VECTOR2I GetSize() const
const BITMAP_BASE & GetImage() const
Get the underlying image.
double GetImageScale() const
A round rectangle shape, based on a rectangle and a radius.
Definition roundrect.h:32
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aMaxError) const
Get the polygonal representation of the roundrect.
Definition roundrect.cpp:79
Definition seg.h:38
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
int Length() const
Return the length (this).
Definition seg.h:361
static SEG::ecoord Square(int a)
Definition seg.h:119
ecoord SquaredLength() const
Definition seg.h:366
T * GetAppSettings(const char *aFilename)
Return a handle to the a given settings by type.
VECTOR2I GetEnd() const override
Definition shape_arc.h:208
const SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError=DefaultAccuracyForPCB(), int *aActualError=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
VECTOR2I GetStart() const override
Definition shape_arc.h:207
const VECTOR2I & GetCenter() const
int GetRadius() const
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the 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.
bool IsTriangulationUpToDate() const
virtual void CacheTriangulation(bool aSimplify=false, const TASK_SUBMITTER &aSubmitter={}, bool aBuildIndexes=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Return the number of outlines in the set.
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
int GetWidth() const override
Definition shape_rect.h:180
const VECTOR2I & GetPosition() const
Definition shape_rect.h:164
const VECTOR2I GetSize() const
Definition shape_rect.h:172
int GetHeight() const
Definition shape_rect.h:188
const SEG & GetSeg() const
int GetWidth() const override
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
const SHAPE_LINE_CHAIN & Vertices() const
Return the list of vertices defining this simple polygon.
virtual const SEG GetSegment(int aIndex) const override
const VECTOR2I & CPoint(int aIndex) const
Return a const reference to a given point in the polygon.
int PointCount() const
Return the number of points (vertices) in this polygon.
virtual size_t GetSegmentCount() const override
An abstract shape on 2D plane.
Definition shape.h:124
Simple container to manage line stroke parameters.
int GetWidth() const
LINE_STYLE GetLineStyle() const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
EDA_ORIENTATION m_Angle
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
Definition vector2d.h:312
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition vector2d.h:406
Handle a list of polygons defining a copper zone.
Definition zone.h:70
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:834
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition zone.h:701
SHAPE_POLY_SET * Outline()
Definition zone.h:421
SHAPE_POLY_SET GetBoardOutline() const
Definition zone.cpp:953
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition zone.cpp:808
bool IsTeardropArea() const
Definition zone.h:809
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition zone.h:689
bool IsConflicting() const
For rule areas which exclude footprints (and therefore participate in courtyard conflicts during move...
Definition zone.cpp:595
std::vector< SEG > GetHatchLines() const
Definition zone.cpp:1677
@ MAGENTA
Definition color4d.h:56
@ CYAN
Definition color4d.h:54
@ FOR_CANVAS
Definition common.h:92
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.
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
@ ROUND_ALL_CORNERS
All angles are rounded.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition cvpcb.cpp:178
#define MAX_LAYERS_FOR_VIEW
Definition definitions.h:41
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:474
@ RADIANS_T
Definition eda_angle.h:31
@ DEGREES_T
Definition eda_angle.h:30
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:469
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:468
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:478
#define IGNORE_PARENT_GROUP
Definition eda_item.h:55
@ UNDEFINED
Definition eda_shape.h:56
@ ELLIPSE
Definition eda_shape.h:63
@ SEGMENT
Definition eda_shape.h:57
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:58
@ ELLIPSE_ARC
Definition eda_shape.h:64
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:29
@ FRAME_PCB_EDITOR
Definition frame_type.h:38
@ FRAME_CVPCB_DISPLAY
Definition frame_type.h:49
@ FRAME_FOOTPRINT_VIEWER
Definition frame_type.h:41
@ FRAME_FOOTPRINT_WIZARD
Definition frame_type.h:42
@ FRAME_FOOTPRINT_PREVIEW
Definition frame_type.h:44
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:40
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:39
@ FRAME_PCB_DISPLAY3D
Definition frame_type.h:43
@ FRAME_CVPCB
Definition frame_type.h:48
a few functions useful in geometry calculations.
int GetPenSizeForNormal(int aTextSize)
Definition gr_text.cpp:58
double m_HoleWallPaintingMultiplier
What factor to use when painting via and PTH pad hole walls, so that the painted hole wall can be ove...
bool IsSolderMaskLayer(int aLayer)
Definition layer_ids.h:815
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer).
Definition layer_ids.h:196
@ LAYER_PAD_BK_NETNAMES
Definition layer_ids.h:197
@ LAYER_PAD_NETNAMES
Definition layer_ids.h:198
@ NETNAMES_LAYER_ID_START
Definition layer_ids.h:190
bool IsDrillSymbolLayer(int aLayer)
Definition layer_ids.h:966
bool IsPcbLayer(int aLayer)
Test whether a layer is a valid layer for Pcbnew.
Definition layer_ids.h:733
bool IsPadCopperLayer(int aLayer)
Definition layer_ids.h:948
#define BOARD_LAYER_FOR_DRILL_SYMBOL(galLayer)
Definition layer_ids.h:401
bool IsPointsLayer(int aLayer)
Definition layer_ids.h:972
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition layer_ids.h:921
bool IsClearanceLayer(int aLayer)
Definition layer_ids.h:960
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:744
@ LAYER_POINTS
PCB reference/manual snap points visibility.
Definition layer_ids.h:317
@ GAL_LAYER_ID_START
Definition layer_ids.h:225
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:303
@ LAYER_PAD_COPPER_START
Virtual layers for pad copper on a given copper layer.
Definition layer_ids.h:358
@ LAYER_VIA_HOLEWALLS
Definition layer_ids.h:294
@ LAYER_CONFLICTS_SHADOW
Shadow layer for items flagged conflicting.
Definition layer_ids.h:306
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
Definition layer_ids.h:235
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
Definition layer_ids.h:300
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:277
@ LAYER_DRC_HIGHLIGHTED
Color for highlighted DRC markers.
Definition layer_ids.h:337
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
Definition layer_ids.h:288
@ LAYER_DRC_WARNING
Layer for DRC markers with RPT_SEVERITY_WARNING.
Definition layer_ids.h:297
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition layer_ids.h:267
@ GAL_LAYER_ID_END
Definition layer_ids.h:388
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
Definition layer_ids.h:362
@ LAYER_CONSTRAINT_SHADOW
Shadow layer for items bound to a constraint.
Definition layer_ids.h:320
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
Definition layer_ids.h:366
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
Definition layer_ids.h:354
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition layer_ids.h:244
@ LAYER_VIA_BURIED
Draw blind vias.
Definition layer_ids.h:231
@ LAYER_MARKER_SHADOWS
Shadows for DRC markers.
Definition layer_ids.h:301
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
Definition layer_ids.h:270
@ LAYER_VIA_BLIND
Draw micro vias.
Definition layer_ids.h:230
@ LAYER_VIA_MICROVIA
Definition layer_ids.h:229
@ LAYER_VIA_THROUGH
Draw buried vias.
Definition layer_ids.h:232
@ LAYER_SUBGRIDS
Routing/placement subgrids (PCB_GRID_ITEM) visibility and color.
Definition layer_ids.h:323
@ LAYER_DRC_ERROR
Layer for DRC markers with RPT_SEVERITY_ERROR.
Definition layer_ids.h:273
@ LAYER_PAD_HOLEWALLS
Definition layer_ids.h:293
bool IsViaCopperLayer(int aLayer)
Definition layer_ids.h:954
#define DRILL_SYMBOL_LAYER_FOR(boardLayer)
Definition layer_ids.h:400
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition layer_ids.h:936
bool IsHoleLayer(int aLayer)
Definition layer_ids.h:806
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition layer_ids.h:755
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_CrtYd
Definition layer_ids.h:112
@ Edge_Cuts
Definition layer_ids.h:108
@ F_Paste
Definition layer_ids.h:100
@ B_Mask
Definition layer_ids.h:94
@ B_Cu
Definition layer_ids.h:61
@ F_Mask
Definition layer_ids.h:93
@ B_Paste
Definition layer_ids.h:101
@ F_SilkS
Definition layer_ids.h:96
@ B_CrtYd
Definition layer_ids.h:111
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
@ F_Cu
Definition layer_ids.h:60
bool IsZoneFillLayer(int aLayer)
Definition layer_ids.h:942
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition lset.cpp:750
MATRIX3x3< double > MATRIX3x3D
Definition matrix3x3.h:469
unsigned CuratedShape(int aIndex)
Pattern index for the nth curated mark.
std::vector< MARKER_PART > BuildMarker(const VECTOR2I &aPosition, int aRadius, unsigned aShapeId)
Decompose one mark, in the order the parts must be drawn.
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
bool ZoneOutlineDrawnOnLayer(bool aOutlineOnly, int aLayer)
Decide which GAL draw pass paints a zone's outline.
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:70
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:104
@ PTH
Plated through hole pad.
Definition padstack.h:99
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:53
@ CHAMFERED_RECT
Definition padstack.h:61
@ ROUNDRECT
Definition padstack.h:58
@ TRAPEZOID
Definition padstack.h:57
@ RECTANGLE
Definition padstack.h:55
BARCODE class definition.
Class to handle a set of BOARD_ITEMs.
static bool viaHoleShowsLayerPair(const PCB_VIA *aVia)
PCBNEW_SETTINGS * pcbconfig()
@ SHOW_WITH_VIA_ALWAYS
PGM_BASE & Pgm()
The global program "get" accessor.
PGM_BASE * PgmOrNull()
Return a reference that can be nullptr when running a shared lib from a script, not from a kicad app.
see class PGM_BASE
@ SH_RECT
axis-aligned rectangle
Definition shape.h:43
@ SH_CIRCLE
circle
Definition shape.h:46
@ SH_SIMPLE
simple polygon
Definition shape.h:47
@ SH_SEGMENT
line segment
Definition shape.h:44
wxString UnescapeString(const wxString &aSource)
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
LINE_STYLE
Dashed line types.
One stroke of a mark.
One drawable mark, with the geometry the renderer needs to place it.
static EDA_ORIENTATION orientation(double d)
VECTOR2I center
const SHAPE_LINE_CHAIN chain
int radius
VECTOR2I end
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
int clearance
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
#define M_PI
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition trigo.cpp:227
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition typeinfo.h:261
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:98
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:95
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
Definition typeinfo.h:240
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:96
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:103
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:100
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:81
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:82
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:91
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:93
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:99
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:87
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
@ PCB_GRID_ITEM_T
a subgrid placed on a board
Definition typeinfo.h:238
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:94
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_BOARD_OUTLINE_T
class PCB_BOARD_OUTLINE_T, a pcb board outline item
Definition typeinfo.h:104
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:86
@ PCB_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
Definition typeinfo.h:242
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:97
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)
static PIECE polygon(std::vector< VIA_CROSS_SECTION_GEOMETRY::POINT > aPoints, bool aMixed=false)