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, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
28#include <advanced_config.h>
29#include <board.h>
31#include <pcb_track.h>
32#include <pcb_group.h>
33#include <footprint.h>
34#include <pad.h>
35#include <pcb_shape.h>
36#include <string_utils.h>
37#include <zone.h>
38#include <pcb_reference_image.h>
39#include <pcb_text.h>
40#include <pcb_textbox.h>
41#include <pcb_table.h>
42#include <pcb_tablecell.h>
43#include <pcb_marker.h>
44#include <pcb_dimension.h>
45#include <pcb_point.h>
46#include <pcb_barcode.h>
47#include <pcb_target.h>
48#include <pcb_board_outline.h>
49
50#include <layer_ids.h>
51#include <lset.h>
52#include <pcb_painter.h>
53#include <pcb_display_options.h>
59#include <pcbnew_settings.h>
61
64#include <callback_gal.h>
67#include <geometry/shape_rect.h>
69#include <geometry/roundrect.h>
73#include <geometry/shape_arc.h>
74#include <stroke_params.h>
75#include <bezier_curves.h>
76#include <kiface_base.h>
77#include <gr_text.h>
78#include <pgm_base.h>
79
80using namespace KIGFX;
81
82
84{
85 return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
86}
87
88// Helpers for display options existing in Cvpcb and Pcbnew
89// Note, when running Cvpcb, pcbconfig() returns nullptr and viewer_settings()
90// returns the viewer options existing to Cvpcb and Pcbnew
112
113
115{
116 m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
120
121 m_trackOpacity = 1.0;
122 m_viaOpacity = 1.0;
123 m_padOpacity = 1.0;
124 m_zoneOpacity = 1.0;
125 m_imageOpacity = 1.0;
127
129
130 m_PadEditModePad = nullptr;
131
132 SetDashLengthRatio( 12 ); // From ISO 128-2
133 SetGapLengthRatio( 3 ); // From ISO 128-2
134
136
137 update();
138}
139
140
142{
144
145 // Init board layers colors:
146 for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
147 {
148 m_layerColors[i] = aSettings->GetColor( i );
149
150 // Guard: if the alpha channel is too small, the layer is not visible.
151 if( m_layerColors[i].a < 0.2 )
152 m_layerColors[i].a = 0.2;
153 }
154
155 // Init specific graphic layers colors:
156 for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
157 m_layerColors[i] = aSettings->GetColor( i );
158
159 // Colors for layers that aren't theme-able
162
163 // Netnames for copper layers
164 const COLOR4D lightLabel = aSettings->GetColor( NETNAMES_LAYER_ID_START );
165 const COLOR4D darkLabel = lightLabel.Inverted();
166
167 for( PCB_LAYER_ID layer : LSET::AllCuMask().CuStack() )
168 {
169 if( m_layerColors[layer].GetBrightness() > 0.5 )
170 m_layerColors[GetNetnameLayer( layer )] = darkLabel;
171 else
172 m_layerColors[GetNetnameLayer( layer )] = lightLabel;
173 }
174
175 if( PgmOrNull() ) // can be null if used without project (i.e. from python script)
177 else
178 m_hiContrastFactor = 1.0f - 0.8f; // default value
179
180 update();
181}
182
183
185{
190
192 m_viaOpacity = aOptions.m_ViaOpacity;
193 m_padOpacity = aOptions.m_PadOpacity;
194 m_zoneOpacity = aOptions.m_ZoneOpacity;
197}
198
199
200COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
201{
202 return GetColor( dynamic_cast<const BOARD_ITEM*>( aItem ), aLayer );
203}
204
205
206COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) const
207{
208 int netCode = -1;
209 int originalLayer = aLayer;
210
211 if( aLayer == LAYER_MARKER_SHADOWS )
212 return m_backgroundColor.WithAlpha( 0.6 );
213
214 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
215 return m_layerColors.at( aLayer );
216
217 // SMD pads use the copper netname layer
218 if( aLayer == LAYER_PAD_FR_NETNAMES )
219 aLayer = GetNetnameLayer( F_Cu );
220 else if( aLayer == LAYER_PAD_BK_NETNAMES )
221 aLayer = GetNetnameLayer( B_Cu );
222
223 if( IsHoleLayer( aLayer ) && m_isPrinting )
224 {
225 // Careful that we don't end up with the same colour for the annular ring and the hole
226 // when printing in B&W.
227 const PAD* pad = dynamic_cast<const PAD*>( aItem );
228 const PCB_VIA* via = dynamic_cast<const PCB_VIA*>( aItem );
229 int holeLayer = aLayer;
230 int annularRingLayer = UNDEFINED_LAYER;
231
232 if( pad && pad->GetAttribute() == PAD_ATTRIB::PTH )
233 {
234 LSET copperLayers = pad->GetLayerSet() & LSET::AllCuMask();
235
236 if( !copperLayers.empty() )
237 annularRingLayer = copperLayers.Seq().front();
238 }
239 else if( via )
240 {
241 annularRingLayer = F_Cu;
242 }
243
244 if( annularRingLayer != UNDEFINED_LAYER )
245 {
246 auto it = m_layerColors.find( holeLayer );
247 auto it2 = m_layerColors.find( annularRingLayer );
248
249 if( it != m_layerColors.end() && it2 != m_layerColors.end() && it->second == it2->second )
250 aLayer = LAYER_PCB_BACKGROUND;
251 }
252 }
253
254 // Zones should pull from the copper layer
255 if( aItem && aItem->Type() == PCB_ZONE_T )
256 {
257 if( IsZoneFillLayer( aLayer ) )
258 aLayer = aLayer - LAYER_ZONE_START;
259 }
260
261 // Points use the LAYER_POINTS color for their virtual per-layer layers
262 if( IsPointsLayer( aLayer ) )
263 aLayer = LAYER_POINTS;
264
265 // Pad and via copper and clearance outlines take their color from the copper layer
266 if( IsPadCopperLayer( aLayer ) )
267 {
268 if( pcbconfig() && aItem && aItem->Type() == PCB_PAD_T )
269 {
270 const PAD* pad = static_cast<const PAD*>( aItem );
271
272 // Old-skool display for people who struggle with change
273 if( pcbconfig()->m_Display.m_UseViaColorForNormalTHPadstacks
274 && pad->GetAttribute() == PAD_ATTRIB::PTH
275 && pad->Padstack().Mode() == PADSTACK::MODE::NORMAL )
276 {
277 aLayer = LAYER_VIA_HOLES;
278 }
279 else
280 {
281 aLayer = aLayer - LAYER_PAD_COPPER_START;
282 }
283 }
284 else
285 {
286 aLayer = aLayer - LAYER_PAD_COPPER_START;
287 }
288 }
289 else if( IsViaCopperLayer( aLayer ) )
290 aLayer = aLayer - LAYER_VIA_COPPER_START;
291 else if( IsClearanceLayer( aLayer ) )
292 aLayer = aLayer - LAYER_CLEARANCE_START;
293
294 // Use via "golden copper" hole color for pad hole walls for contrast
295 else if( aLayer == LAYER_PAD_HOLEWALLS )
296 aLayer = LAYER_VIA_HOLES;
297
298 // Show via mask layers if appropriate
299 if( aLayer == LAYER_VIA_THROUGH && !m_isPrinting )
300 {
301 if( aItem && aItem->GetBoard() )
302 {
303 LSET visibleLayers = aItem->GetBoard()->GetVisibleLayers()
304 & aItem->GetBoard()->GetEnabledLayers()
305 & aItem->GetLayerSet();
306
307 if( GetActiveLayer() == F_Mask && visibleLayers.test( F_Mask ) )
308 {
309 aLayer = F_Mask;
310 }
311 else if( GetActiveLayer() == B_Mask && visibleLayers.test( B_Mask ) )
312 {
313 aLayer = B_Mask;
314 }
315 else if( ( visibleLayers & LSET::AllCuMask() ).none() )
316 {
317 if( visibleLayers.any() )
318 aLayer = visibleLayers.Seq().back();
319 }
320 }
321 }
322
323 // Normal path: get the layer base color
324 auto it = m_layerColors.find( aLayer );
325 COLOR4D color = it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
326
327 if( !aItem )
328 return color;
329
330 // Selection disambiguation
331 if( aItem->IsBrightened() )
332 {
333 if( aItem->Type() == PCB_MARKER_T )
334 {
335 auto itemLayerIter = m_layerColors.find( LAYER_DRC_HIGHLIGHTED );
336
337 if( itemLayerIter != m_layerColors.end() )
338 return itemLayerIter->second;
339 }
340
341 return color.Brightened( m_selectFactor ).WithAlpha( 0.8 );
342 }
343
344 // Normal selection
345 if( aItem->IsSelected() )
346 {
347 // Selection for tables is done with a background wash, so pass in nullptr to GetColor()
348 // so we just get the "normal" (un-selected/un-brightened) color for the borders.
349 if( aItem->Type() != PCB_TABLE_T && aItem->Type() != PCB_TABLECELL_T )
350 {
351 auto it_selected = m_layerColorsSel.find( aLayer );
352 color = it_selected == m_layerColorsSel.end() ? color.Brightened( 0.8 ) : it_selected->second;
353 }
354 }
355
356 // Some graphic objects are BOARD_CONNECTED_ITEM, but they are seen here as
357 // actually board connected objects only if on a copper layer
358 const BOARD_CONNECTED_ITEM* conItem = nullptr;
359
360 if( aItem->IsConnected() && aItem->IsOnCopperLayer() )
361 conItem = static_cast<const BOARD_CONNECTED_ITEM*>( aItem );
362
363 // Try to obtain the netcode for the aItem
364 if( conItem )
365 netCode = conItem->GetNetCode();
366
367 bool highlighted = m_highlightEnabled && m_highlightNetcodes.count( netCode );
368 bool selected = aItem->IsSelected();
369
370 // Apply net color overrides
371 if( conItem && m_netColorMode == NET_COLOR_MODE::ALL && IsCopperLayer( aLayer ) )
372 {
373 COLOR4D netColor = COLOR4D::UNSPECIFIED;
374
375 auto ii = m_netColors.find( netCode );
376
377 if( ii != m_netColors.end() )
378 netColor = ii->second;
379
380 if( netColor == COLOR4D::UNSPECIFIED )
381 {
382 const NETCLASS* nc = conItem->GetEffectiveNetClass();
383
384 if( nc->HasPcbColor() )
385 netColor = nc->GetPcbColor();
386 }
387
388 if( netColor == COLOR4D::UNSPECIFIED )
389 netColor = color;
390
391 if( selected )
392 {
393 // Selection brightening overrides highlighting
394 netColor.Brighten( m_selectFactor );
395 }
396 else if( m_highlightEnabled )
397 {
398 // Highlight brightens objects on all layers and darkens everything else for contrast
399 if( highlighted )
400 netColor.Brighten( m_highlightFactor );
401 else
402 netColor.Darken( 1.0 - m_highlightFactor );
403 }
404
405 color = netColor;
406 }
407 else if( !selected && m_highlightEnabled )
408 {
409 // Single net highlight mode
410 if( m_highlightNetcodes.contains( netCode ) )
411 {
412 auto it_hi = m_layerColorsHi.find( aLayer );
413 color = it_hi == m_layerColorsHi.end() ? color.Brightened( m_highlightFactor ) : it_hi->second;
414 }
415 else
416 {
417 auto it_dark = m_layerColorsDark.find( aLayer );
418 color = it_dark == m_layerColorsDark.end() ? color.Darkened( 1.0 - m_highlightFactor ) : it_dark->second;
419 }
420 }
421
422 // Apply high-contrast dimming
423 if( m_hiContrastEnabled && m_highContrastLayers.size() && !highlighted && !selected )
424 {
426 bool isActive = m_highContrastLayers.count( aLayer );
427 bool hide = false;
428
429 switch( originalLayer )
430 {
431 case LAYER_PADS:
432 {
433 const PAD* pad = static_cast<const PAD*>( aItem );
434
435 if( pad->IsOnLayer( primary ) && !pad->FlashLayer( primary ) )
436 {
437 isActive = false;
438
439 if( IsCopperLayer( primary ) )
440 hide = true;
441 }
442
444 isActive = false;
445
446 break;
447 }
448
449 case LAYER_VIA_BLIND:
450 case LAYER_VIA_BURIED:
452 {
453 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
454
455 // Target graphic is active if the via crosses the primary layer
456 if( via->GetLayerSet().test( primary ) == 0 )
457 {
458 isActive = false;
459 hide = true;
460 }
461
462 break;
463 }
464
466 {
467 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
468
469 if( !via->FlashLayer( primary ) )
470 {
471 isActive = false;
472
473 if( IsCopperLayer( primary ) )
474 hide = true;
475 }
476
477 break;
478 }
479
483 // Pad holes are active is any physical layer is active
484 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
485 isActive = false;
486
487 break;
488
489 case LAYER_VIA_HOLES:
491 {
492 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
493
494 if( via->GetViaType() == VIATYPE::THROUGH )
495 {
496 // A through via's hole is active if any physical layer is active
497 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
498 isActive = false;
499 }
500 else
501 {
502 // A blind/buried or micro via's hole is active if it crosses the primary layer
503 if( via->GetLayerSet().test( primary ) == 0 )
504 isActive = false;
505 }
506
507 break;
508 }
509
510 case LAYER_DRC_ERROR:
513 case LAYER_DRC_SHAPES:
514 isActive = true;
515 break;
516
517 default:
518 break;
519 }
520
521 if( !isActive )
522 {
523 // Graphics on Edge_Cuts layer are not fully dimmed or hidden because they are
524 // useful when working on another layer
525 // We could use a dim factor = m_hiContrastFactor, but to have a sufficient
526 // contrast whenever m_hiContrastFactor value, we clamp the factor to 0.3f
527 // (arbitray choice after tests)
528 float dim_factor_Edge_Cuts = std::max( m_hiContrastFactor, 0.3f );
529
531 || IsNetnameLayer( aLayer )
532 || hide )
533 {
534 if( originalLayer == Edge_Cuts )
535 {
537
538 if( it != m_layerColors.end() )
539 color = color.Mix( it->second, dim_factor_Edge_Cuts );
540 else
541 color = color.Mix( COLOR4D::BLACK, dim_factor_Edge_Cuts );
542 }
543 else
544 color = COLOR4D::CLEAR;
545 }
546 else
547 {
549 COLOR4D backgroundColor = it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
550
551 if( originalLayer == Edge_Cuts )
552 color = color.Mix( backgroundColor, dim_factor_Edge_Cuts );
553 else
554 color = color.Mix( backgroundColor, m_hiContrastFactor );
555
556 // Reference images can't have their color mixed so just reduce the opacity a bit
557 // so they show through less
558 if( aItem->Type() == PCB_REFERENCE_IMAGE_T )
559 color.a *= m_hiContrastFactor;
560 }
561 }
562 }
563 else if( originalLayer == LAYER_VIA_BLIND
564 || originalLayer == LAYER_VIA_BURIED
565 || originalLayer == LAYER_VIA_MICROVIA )
566 {
567 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
568 const BOARD* board = via->GetBoard();
569 LSET visibleLayers = board->GetVisibleLayers() & board->GetEnabledLayers();
570
571 // Target graphic is visible if the via crosses a visible layer
572 if( ( via->GetLayerSet() & visibleLayers ).none() )
573 color = COLOR4D::CLEAR;
574 }
575
576 // Apply per-type opacity overrides
577 if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
578 color.a *= m_trackOpacity;
579 else if( aItem->Type() == PCB_VIA_T )
580 color.a *= m_viaOpacity;
581 else if( aItem->Type() == PCB_PAD_T )
582 color.a *= m_padOpacity;
583 else if( aItem->Type() == PCB_ZONE_T && static_cast<const ZONE*>( aItem )->IsTeardropArea() )
584 color.a *= m_trackOpacity;
585 else if( aItem->Type() == PCB_ZONE_T )
586 color.a *= m_zoneOpacity;
587 else if( aItem->Type() == PCB_REFERENCE_IMAGE_T )
588 color.a *= m_imageOpacity;
589 else if( aItem->Type() == PCB_SHAPE_T && static_cast<const PCB_SHAPE*>( aItem )->IsAnyFill() )
590 color.a *= m_filledShapeOpacity;
591 else if( aItem->Type() == PCB_SHAPE_T && aItem->IsOnCopperLayer() )
592 color.a *= m_trackOpacity;
593
594 if( aItem->GetForcedTransparency() > 0.0 )
595 color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForcedTransparency() ) );
596
597 // No special modifiers enabled
598 return color;
599}
600
601
606
607
609 PAINTER( aGal ),
610 m_frameType( aFrameType ),
614{
615}
616
617
618int PCB_PAINTER::getLineThickness( int aActualThickness ) const
619{
620 // if items have 0 thickness, draw them with the outline
621 // width, otherwise respect the set value (which, no matter
622 // how small will produce something)
623 if( aActualThickness == 0 )
624 return m_pcbSettings.m_outlineWidth;
625
626 return aActualThickness;
627}
628
629
631{
632 return aPad->GetDrillShape();
633}
634
635
637{
638 SHAPE_SEGMENT segm = *aPad->GetEffectiveHoleShape().get();
639 return segm;
640}
641
642
643int PCB_PAINTER::getViaDrillSize( const PCB_VIA* aVia ) const
644{
645 return aVia->GetDrillValue();
646}
647
648
649bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
650{
651 if( !aItem->IsBOARD_ITEM() )
652 return false;
653
654 const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( aItem );
655
656 if( const BOARD* board = item->GetBoard() )
657 {
658 BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
662
663 if( item->GetParentFootprint() && !board->IsFootprintHolder() )
664 {
665 FOOTPRINT* parentFP = item->GetParentFootprint();
666
667 // Never draw footprint reference images on board
668 if( item->Type() == PCB_REFERENCE_IMAGE_T )
669 {
670 return false;
671 }
672 else if( item->GetLayerSet().count() > 1 )
673 {
674 // For multi-layer objects, exclude only those layers that are private
675 if( IsPcbLayer( aLayer ) && parentFP->GetPrivateLayers().test( aLayer ) )
676 return false;
677 }
678 else if( item->GetLayerSet().count() == 1 )
679 {
680 // For single-layer objects, exclude all layers including ancillary layers
681 // such as holes, netnames, etc.
682 PCB_LAYER_ID singleLayer = item->GetLayerSet().ExtractLayer();
683
684 if( parentFP->GetPrivateLayers().test( singleLayer ) )
685 return false;
686 }
687 }
688 }
689 else
690 {
693 }
694
695 // the "cast" applied in here clarifies which overloaded draw() is called
696 switch( item->Type() )
697 {
698 case PCB_TRACE_T:
699 draw( static_cast<const PCB_TRACK*>( item ), aLayer );
700 break;
701
702 case PCB_ARC_T:
703 draw( static_cast<const PCB_ARC*>( item ), aLayer );
704 break;
705
706 case PCB_VIA_T:
707 draw( static_cast<const PCB_VIA*>( item ), aLayer );
708 break;
709
710 case PCB_PAD_T:
711 draw( static_cast<const PAD*>( item ), aLayer );
712 break;
713
714 case PCB_SHAPE_T:
715 draw( static_cast<const PCB_SHAPE*>( item ), aLayer );
716 break;
717
719 draw( static_cast<const PCB_REFERENCE_IMAGE*>( item ), aLayer );
720 break;
721
722 case PCB_FIELD_T:
723 draw( static_cast<const PCB_FIELD*>( item ), aLayer );
724 break;
725
726 case PCB_TEXT_T:
727 draw( static_cast<const PCB_TEXT*>( item ), aLayer );
728 break;
729
730 case PCB_TEXTBOX_T:
731 draw( static_cast<const PCB_TEXTBOX*>( item ), aLayer );
732 break;
733
734 case PCB_TABLE_T:
735 draw( static_cast<const PCB_TABLE*>( item ), aLayer );
736 break;
737
738 case PCB_FOOTPRINT_T:
739 draw( static_cast<const FOOTPRINT*>( item ), aLayer );
740 break;
741
742 case PCB_GROUP_T:
743 draw( static_cast<const PCB_GROUP*>( item ), aLayer );
744 break;
745
746 case PCB_ZONE_T:
747 draw( static_cast<const ZONE*>( item ), aLayer );
748 break;
749
751 case PCB_DIM_CENTER_T:
752 case PCB_DIM_RADIAL_T:
754 case PCB_DIM_LEADER_T:
755 draw( static_cast<const PCB_DIMENSION_BASE*>( item ), aLayer );
756 break;
757
758 case PCB_BARCODE_T:
759 draw( static_cast<const PCB_BARCODE*>( item ), aLayer );
760 break;
761
762 case PCB_TARGET_T:
763 draw( static_cast<const PCB_TARGET*>( item ) );
764 break;
765
766 case PCB_POINT_T:
767 draw( static_cast<const PCB_POINT*>( item ), aLayer );
768 break;
769
770 case PCB_MARKER_T:
771 draw( static_cast<const PCB_MARKER*>( item ), aLayer );
772 break;
773
775 draw( static_cast<const PCB_BOARD_OUTLINE*>( item ), aLayer );
776 break;
777
778 default:
779 // Painter does not know how to draw the object
780 return false;
781 }
782
783 // Draw bounding boxes after drawing objects so they can be seen.
784 if( m_pcbSettings.GetDrawBoundingBoxes() )
785 {
786 // Show bounding boxes of painted objects for debugging.
787 BOX2I box = item->GetBoundingBox();
788
789 m_gal->SetIsFill( false );
790 m_gal->SetIsStroke( true );
791
792 if( item->Type() == PCB_FOOTPRINT_T )
793 {
794 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
795 COLOR4D( MAGENTA ) );
796 }
797 else
798 {
799 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
800 COLOR4D( 0.4, 0.4, 0.4, 1 ) );
801 }
802
803 m_gal->SetLineWidth( 1 );
804 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
805
806 if( item->Type() == PCB_FOOTPRINT_T )
807 {
808 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
809 COLOR4D( CYAN ) );
810
811 const FOOTPRINT* fp = static_cast<const FOOTPRINT*>( item );
812
813 if( fp )
814 {
815 const SHAPE_POLY_SET& convex = fp->GetBoundingHull();
816
817 m_gal->DrawPolyline( convex.COutline( 0 ) );
818 }
819 }
820 }
821
822 return true;
823}
824
825
826void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
827{
828 VECTOR2I start( aTrack->GetStart() );
829 VECTOR2I end( aTrack->GetEnd() );
830 int track_width = aTrack->GetWidth();
831 COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
832
833 if( IsNetnameLayer( aLayer ) )
834 {
835 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
836 return;
837
838 if( aTrack->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
839 return;
840
841 SHAPE_SEGMENT trackShape( { aTrack->GetStart(), aTrack->GetEnd() }, aTrack->GetWidth() );
842 renderNetNameForSegment( trackShape, color, aTrack->GetDisplayNetname() );
843 return;
844 }
845 else if( IsCopperLayer( aLayer ) || IsSolderMaskLayer( aLayer )
846 || aLayer == LAYER_LOCKED_ITEM_SHADOW )
847 {
848 // Draw a regular track
849 bool outline_mode = pcbconfig()
851 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
852 m_gal->SetStrokeColor( color );
853 m_gal->SetFillColor( color );
854 m_gal->SetIsStroke( outline_mode );
855 m_gal->SetIsFill( not outline_mode );
856 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
857
858 if( IsSolderMaskLayer( aLayer ) )
859 track_width = track_width + aTrack->GetSolderMaskExpansion() * 2;
860
861 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
862 track_width = track_width + m_lockedShadowMargin;
863
864 m_gal->DrawSegment( start, end, track_width );
865 }
866
867 // Clearance lines
868 if( IsClearanceLayer( aLayer ) && pcbconfig()
869 && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
870 && !m_pcbSettings.m_isPrinting )
871 {
872 const PCB_LAYER_ID copperLayerForClearance = ToLAYER_ID( aLayer - LAYER_CLEARANCE_START );
873
874 int clearance = aTrack->GetOwnClearance( copperLayerForClearance );
875
876 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
877 m_gal->SetIsFill( false );
878 m_gal->SetIsStroke( true );
879 m_gal->SetStrokeColor( color );
880 m_gal->DrawSegment( start, end, track_width + clearance * 2 );
881 }
882}
883
884
886 const wxString& aNetName ) const
887{
888 // When drawing netnames, clip the track to the viewport
889 BOX2D viewport;
890 VECTOR2D screenSize = m_gal->GetScreenPixelSize();
891 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
892
893 viewport.SetOrigin( VECTOR2D( matrix * VECTOR2D( 0, 0 ) ) );
894 viewport.SetEnd( VECTOR2D( matrix * screenSize ) );
895 viewport.Normalize();
896
897 int num_char = aNetName.size();
898
899 // Check if the track is long enough to have a netname displayed
900 int seg_minlength = aSeg.GetWidth() * num_char;
901 SEG::ecoord seg_minlength_sq = (SEG::ecoord)seg_minlength * seg_minlength;
902
903 if( aSeg.GetSeg().SquaredLength() < seg_minlength_sq )
904 return;
905
906 double textSize = aSeg.GetWidth();
907 double penWidth = textSize / 12.0;
908 EDA_ANGLE textOrientation;
909 int num_names = 1;
910
911 VECTOR2I start = aSeg.GetSeg().A;
912 VECTOR2I end = aSeg.GetSeg().B;
913 VECTOR2D segV = end - start;
914
915 if( end.y == start.y ) // horizontal
916 {
917 textOrientation = ANGLE_HORIZONTAL;
918 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / viewport.GetWidth() ) );
919 }
920 else if( end.x == start.x ) // vertical
921 {
922 textOrientation = ANGLE_VERTICAL;
923 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / viewport.GetHeight() ) );
924 }
925 else
926 {
927 textOrientation = -EDA_ANGLE( segV );
928 textOrientation.Normalize90();
929
930 double min_size = std::min( viewport.GetWidth(), viewport.GetHeight() );
931 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / ( M_SQRT2 * min_size ) ) );
932 }
933
934 m_gal->SetIsStroke( true );
935 m_gal->SetIsFill( false );
936 m_gal->SetStrokeColor( aColor );
937 m_gal->SetLineWidth( penWidth );
938 m_gal->SetFontBold( false );
939 m_gal->SetFontItalic( false );
940 m_gal->SetFontUnderlined( false );
941 m_gal->SetTextMirrored( false );
942 m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
943 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
944 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
945
946 int divisions = num_names + 1;
947
948 for( int ii = 1; ii < divisions; ++ii )
949 {
950 VECTOR2I textPosition = start + segV * ( (double) ii / divisions );
951
952 if( viewport.Contains( textPosition ) )
953 m_gal->BitmapText( aNetName, textPosition, textOrientation );
954 }
955}
956
957
958void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
959{
960 VECTOR2D center( aArc->GetCenter() );
961 int width = aArc->GetWidth();
962 COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
963 double radius = aArc->GetRadius();
964 EDA_ANGLE start_angle = aArc->GetArcAngleStart();
965 EDA_ANGLE angle = aArc->GetAngle();
966
967 if( IsNetnameLayer( aLayer ) )
968 {
969 // Ummm, yeah. Anyone fancy implementing text on a path?
970 return;
971 }
972 else if( IsCopperLayer( aLayer ) || IsSolderMaskLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW )
973 {
974 // Draw a regular track
975 bool outline_mode = pcbconfig()
977 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
978 m_gal->SetStrokeColor( color );
979 m_gal->SetFillColor( color );
980 m_gal->SetIsStroke( outline_mode );
981 m_gal->SetIsFill( not outline_mode );
982 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
983
984 if( IsSolderMaskLayer( aLayer ) )
985 width = width + aArc->GetSolderMaskExpansion() * 2;
986
987 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
988 width = width + m_lockedShadowMargin;
989
990 m_gal->DrawArcSegment( center, radius, start_angle, angle, width, m_maxError );
991 }
992
993 // Clearance lines
994 if( IsClearanceLayer( aLayer )
995 && pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
996 && !m_pcbSettings.m_isPrinting )
997 {
998 /*
999 * Showing the clearance area is not obvious for optionally-flashed pads and vias, so we
1000 * choose to not display clearance lines at all on non-copper active layers. We follow
1001 * the same rule for tracks to be consistent (even though they don't have the same issue).
1002 */
1003 const PCB_LAYER_ID activeLayer = m_pcbSettings.GetActiveLayer();
1004 const BOARD& board = *aArc->GetBoard();
1005
1006 if( IsCopperLayer( activeLayer ) && board.GetVisibleLayers().test( activeLayer ) )
1007 {
1008 int clearance = aArc->GetOwnClearance( activeLayer );
1009
1010 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1011 m_gal->SetIsFill( false );
1012 m_gal->SetIsStroke( true );
1013 m_gal->SetStrokeColor( color );
1014
1015 m_gal->DrawArcSegment( center, radius, start_angle, angle, width + clearance * 2, m_maxError );
1016 }
1017 }
1018
1019#if 0
1020 // Debug only: enable this code only to test the TransformArcToPolygon function and display the polygon
1021 // outline created by it.
1022 // arcs on F_Cu are approximated with ERROR_INSIDE, others with ERROR_OUTSIDE
1023 SHAPE_POLY_SET cornerBuffer;
1025 TransformArcToPolygon( cornerBuffer, aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), width,
1026 m_maxError, errorloc );
1027 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1028 m_gal->SetIsFill( false );
1029 m_gal->SetIsStroke( true );
1030 m_gal->SetStrokeColor( COLOR4D( 0, 0, 1.0, 1.0 ) );
1031 m_gal->DrawPolygon( cornerBuffer );
1032#endif
1033
1034#if 0
1035 // Debug only: enable this code only to test the arc geometry.
1036 // Draw 3 lines from arc center to arc start, arc middle, arc end to show how the arc is defined
1037 SHAPE_ARC arc( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), m_pcbSettings.m_outlineWidth );
1038 m_gal->SetIsFill( false );
1039 m_gal->SetIsStroke( true );
1040 m_gal->SetStrokeColor( COLOR4D( 0, 0, 1.0, 1.0 ) );
1041 m_gal->DrawSegment( arc.GetStart(), arc.GetCenter(), m_pcbSettings.m_outlineWidth );
1042 m_gal->DrawSegment( aArc->GetFocusPosition(), arc.GetCenter(), m_pcbSettings.m_outlineWidth );
1043 m_gal->DrawSegment( arc.GetEnd(), arc.GetCenter(), m_pcbSettings.m_outlineWidth );
1044#endif
1045
1046#if 0
1047 // Debug only: enable this code only to test the SHAPE_ARC::ConvertToPolyline function and display the
1048 // polyline created by it.
1049 SHAPE_ARC arc( aArc->GetCenter(), aArc->GetStart(), aArc->GetAngle(), aArc->GetWidth() );
1051 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1052 m_gal->SetIsFill( false );
1053 m_gal->SetIsStroke( true );
1054 m_gal->SetStrokeColor( COLOR4D( 0.3, 0.2, 0.5, 1.0 ) );
1055
1056 for( int idx = 1; idx < arcSpine.PointCount(); idx++ )
1057 m_gal->DrawSegment( arcSpine.CPoint( idx-1 ), arcSpine.CPoint( idx ), aArc->GetWidth() );
1058#endif
1059}
1060
1061
1062void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
1063{
1064 const BOARD* board = aVia->GetBoard();
1065 COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
1066 VECTOR2D center( aVia->GetStart() );
1067
1068 if( color == COLOR4D::CLEAR )
1069 return;
1070
1071 const int copperLayer = IsViaCopperLayer( aLayer ) ? aLayer - LAYER_VIA_COPPER_START : aLayer;
1072
1073 PCB_LAYER_ID currentLayer = ToLAYER_ID( copperLayer );
1074 PCB_LAYER_ID layerTop, layerBottom;
1075 aVia->LayerPair( &layerTop, &layerBottom );
1076
1077 // Blind/buried vias (and microvias) will use different hole and label rendering
1078 bool isBlindBuried = aVia->GetViaType() == VIATYPE::BLIND
1079 || aVia->GetViaType() == VIATYPE::BURIED
1080 || ( aVia->GetViaType() == VIATYPE::MICROVIA
1081 && ( layerTop != F_Cu || layerBottom != B_Cu ) );
1082
1083 // Draw description layer
1084 if( IsNetnameLayer( aLayer ) )
1085 {
1086 VECTOR2D position( center );
1087
1088 // Is anything that we can display enabled (netname and/or layers ids)?
1089 bool showNets = pcbconfig() && pcbconfig()->m_Display.m_NetNames != 0
1090 && !aVia->GetNetname().empty();
1091 bool showLayers = aVia->GetViaType() != VIATYPE::THROUGH;
1092
1093 if( !showNets && !showLayers )
1094 return;
1095
1096 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
1097 double size = aVia->GetWidth( currentLayer );
1098
1099 // Font size limits
1100 if( size > maxSize )
1101 size = maxSize;
1102
1103 m_gal->Save();
1104 m_gal->Translate( position );
1105
1106 // Default font settings
1107 m_gal->ResetTextAttributes();
1108 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
1109 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
1110 m_gal->SetFontBold( false );
1111 m_gal->SetFontItalic( false );
1112 m_gal->SetFontUnderlined( false );
1113 m_gal->SetTextMirrored( false );
1114 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, aLayer ) );
1115 m_gal->SetIsStroke( true );
1116 m_gal->SetIsFill( false );
1117
1118 // Set the text position via position. if only one text, it is on the via position
1119 // For 2 lines, the netname is slightly below the center, and the layer IDs above
1120 // the netname
1121 VECTOR2D textpos( 0.0, 0.0 );
1122
1123 wxString netname = aVia->GetDisplayNetname();
1124
1125 PCB_LAYER_ID topLayerId = aVia->TopLayer();
1126 PCB_LAYER_ID bottomLayerId = aVia->BottomLayer();
1127 int topLayer; // The via top layer number (from 1 to copper layer count)
1128 int bottomLayer; // The via bottom layer number (from 1 to copper layer count)
1129
1130 switch( topLayerId )
1131 {
1132 case F_Cu: topLayer = 1; break;
1133 case B_Cu: topLayer = board->GetCopperLayerCount(); break;
1134 default: topLayer = (topLayerId - B_Cu)/2 + 1; break;
1135 }
1136
1137 switch( bottomLayerId )
1138 {
1139 case F_Cu: bottomLayer = 1; break;
1140 case B_Cu: bottomLayer = board->GetCopperLayerCount(); break;
1141 default: bottomLayer = (bottomLayerId - B_Cu)/2 + 1; break;
1142 }
1143
1144 wxString layerIds;
1145#if wxUSE_UNICODE_WCHAR
1146 layerIds << std::to_wstring( topLayer ) << L'-' << std::to_wstring( bottomLayer );
1147#else
1148 layerIds << std::to_string( topLayer ) << '-' << std::to_string( bottomLayer );
1149#endif
1150
1151 // a good size is set room for at least 6 chars, to be able to print 2 lines of text,
1152 // or at least 3 chars for only the netname
1153 // (The layerIds string has 5 chars max)
1154 int minCharCnt = showLayers ? 6 : 3;
1155
1156 // approximate the size of netname and layerIds text:
1157 double tsize = 1.5 * size / std::max( PrintableCharCount( netname ), minCharCnt );
1158 tsize = std::min( tsize, size );
1159
1160 // Use a smaller text size to handle interline, pen size..
1161 tsize *= 0.75;
1162 VECTOR2D namesize( tsize, tsize );
1163
1164 // For 2 lines, adjust the text pos (move it a small amount to the bottom)
1165 if( showLayers && showNets )
1166 textpos.y += ( tsize * 1.3 )/ 2;
1167
1168 m_gal->SetGlyphSize( namesize );
1169 m_gal->SetLineWidth( namesize.x / 10.0 );
1170
1171 if( showNets )
1172 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
1173
1174 if( showLayers )
1175 {
1176 if( showNets )
1177 textpos.y -= tsize * 1.3;
1178
1179 m_gal->BitmapText( layerIds, textpos, ANGLE_HORIZONTAL );
1180 }
1181
1182 m_gal->Restore();
1183
1184 return;
1185 }
1186
1187 bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayViaFill;
1188
1189 m_gal->SetStrokeColor( color );
1190 m_gal->SetFillColor( color );
1191 m_gal->SetIsStroke( true );
1192 m_gal->SetIsFill( false );
1193
1194 if( outline_mode )
1195 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1196
1197 if( aLayer == LAYER_VIA_HOLEWALLS )
1198 {
1199 double thickness =
1201 double drillRadius = getViaDrillSize( aVia ) / 2.0;
1202 double maxRadius = aVia->GetWidth( layerTop ) / 2.0;
1203 double radius = drillRadius + thickness;
1204
1205 // Clamp the hole wall so it doesn't extend beyond the via's copper
1206 if( radius > maxRadius )
1207 {
1208 radius = maxRadius;
1209 thickness = radius - drillRadius;
1210 }
1211
1212 if( thickness <= 0 )
1213 return;
1214
1215 if( !outline_mode )
1216 {
1217 m_gal->SetLineWidth( thickness );
1218 radius -= thickness / 2.0;
1219 }
1220
1221 // Underpaint the hole so that there aren't artifacts at its edge
1222 m_gal->SetIsFill( true );
1223
1224 m_gal->DrawCircle( center, radius );
1225 }
1226 else if( aLayer == LAYER_VIA_HOLES )
1227 {
1228 double radius = getViaDrillSize( aVia ) / 2.0;
1229
1230 m_gal->SetIsStroke( false );
1231 m_gal->SetIsFill( true );
1232
1233 if( isBlindBuried && !m_pcbSettings.IsPrinting() )
1234 {
1235 m_gal->SetIsStroke( false );
1236 m_gal->SetIsFill( true );
1237
1238 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
1239 m_gal->DrawArc( center, radius, EDA_ANGLE( 180, DEGREES_T ),
1240 EDA_ANGLE( 180, DEGREES_T ) );
1241
1242 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
1243 m_gal->DrawArc( center, radius, EDA_ANGLE( 0, DEGREES_T ),
1244 EDA_ANGLE( 180, DEGREES_T ) );
1245 }
1246 else
1247 {
1248 m_gal->DrawCircle( center, radius );
1249 }
1250
1251 }
1252 else if( ( aLayer == F_Mask && aVia->IsOnLayer( F_Mask ) )
1253 || ( aLayer == B_Mask && aVia->IsOnLayer( B_Mask ) ) )
1254 {
1255 int margin = board->GetDesignSettings().m_SolderMaskExpansion;
1256
1257 m_gal->SetIsFill( true );
1258 m_gal->SetIsStroke( false );
1259
1260 m_gal->SetLineWidth( margin );
1261 m_gal->DrawCircle( center, aVia->GetWidth( currentLayer ) / 2.0 + margin );
1262 }
1263 else if( m_pcbSettings.IsPrinting() || IsCopperLayer( currentLayer ) )
1264 {
1265 int annular_width = ( aVia->GetWidth( currentLayer ) - getViaDrillSize( aVia ) ) / 2.0;
1266 double radius = aVia->GetWidth( currentLayer ) / 2.0;
1267 bool draw = false;
1268
1269 if( m_pcbSettings.IsPrinting() )
1270 {
1271 draw = aVia->FlashLayer( m_pcbSettings.GetPrintLayers() );
1272 }
1273 else if( aVia->IsSelected() )
1274 {
1275 draw = true;
1276 }
1277 else if( aVia->FlashLayer( board->GetVisibleLayers() & board->GetEnabledLayers() ) )
1278 {
1279 draw = true;
1280 }
1281
1282 if( !aVia->FlashLayer( currentLayer ) )
1283 draw = false;
1284
1285 if( !outline_mode )
1286 {
1287 m_gal->SetLineWidth( annular_width );
1288 radius -= annular_width / 2.0;
1289 }
1290
1291 if( draw )
1292 m_gal->DrawCircle( center, radius );
1293
1294 // Draw backdrill indicators (semi-circles extending into the hole)
1295 // Drawn on copper layer so they appear above the annular ring
1296 if( !m_pcbSettings.IsPrinting() && draw )
1297 {
1298 std::optional<int> secDrill = aVia->GetSecondaryDrillSize();
1299 std::optional<int> terDrill = aVia->GetTertiaryDrillSize();
1300
1301 if( secDrill.value_or( 0 ) > 0 )
1302 {
1303 drawBackdrillIndicator( aVia, center, *secDrill,
1305 aVia->GetSecondaryDrillEndLayer() );
1306 }
1307
1308 if( terDrill.value_or( 0 ) > 0 )
1309 {
1310 drawBackdrillIndicator( aVia, center, *terDrill,
1312 aVia->GetTertiaryDrillEndLayer() );
1313 }
1314 }
1315
1316 // Draw post-machining indicator if this layer is post-machined
1317 if( !m_pcbSettings.IsPrinting() && draw )
1318 {
1319 drawPostMachiningIndicator( aVia, center, currentLayer );
1320 }
1321 }
1322 else if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // draw a ring around the via
1323 {
1324 m_gal->SetLineWidth( m_lockedShadowMargin );
1325
1326 m_gal->DrawCircle( center, ( aVia->GetWidth( currentLayer ) + m_lockedShadowMargin ) / 2.0 );
1327 }
1328
1329 // Clearance lines
1330 if( IsClearanceLayer( aLayer ) && pcbconfig()
1331 && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
1332 && !m_pcbSettings.m_isPrinting )
1333 {
1334 const PCB_LAYER_ID copperLayerForClearance = ToLAYER_ID( aLayer - LAYER_CLEARANCE_START );
1335
1336 double radius;
1337
1338 if( aVia->FlashLayer( copperLayerForClearance ) )
1339 radius = aVia->GetWidth( copperLayerForClearance ) / 2.0;
1340 else
1342
1343 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1344 m_gal->SetIsFill( false );
1345 m_gal->SetIsStroke( true );
1346 m_gal->SetStrokeColor( color );
1347 m_gal->DrawCircle( center, radius + aVia->GetOwnClearance( copperLayerForClearance ) );
1348 }
1349}
1350
1351
1352void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
1353{
1354 COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
1355 const int copperLayer = IsPadCopperLayer( aLayer ) ? aLayer - LAYER_PAD_COPPER_START : aLayer;
1356 PCB_LAYER_ID pcbLayer = static_cast<PCB_LAYER_ID>( copperLayer );
1357
1358 if( IsNetnameLayer( aLayer ) )
1359 {
1360 PCBNEW_SETTINGS::DISPLAY_OPTIONS* displayOpts = pcbconfig() ? &pcbconfig()->m_Display : nullptr;
1361 wxString netname;
1362 wxString padNumber;
1363
1364 if( viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers )
1365 {
1366 padNumber = UnescapeString( aPad->GetNumber() );
1367
1368 if( dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
1369 netname = aPad->GetPinFunction();
1370 }
1371
1372 if( displayOpts && !dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
1373 {
1374 if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
1375 netname = aPad->GetDisplayNetname();
1376
1377 if( aPad->IsNoConnectPad() )
1378 netname = wxT( "x" );
1379 else if( aPad->IsFreePad() )
1380 netname = wxT( "*" );
1381 }
1382
1383 if( netname.IsEmpty() && padNumber.IsEmpty() )
1384 return;
1385
1386 BOX2I padBBox = aPad->GetBoundingBox();
1387 VECTOR2D position = padBBox.Centre();
1388 VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
1389
1390 if( aPad->IsEntered() )
1391 {
1392 FOOTPRINT* fp = aPad->GetParentFootprint();
1393
1394 // Find the number box
1395 for( const BOARD_ITEM* aItem : fp->GraphicalItems() )
1396 {
1397 if( aItem->Type() == PCB_SHAPE_T )
1398 {
1399 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
1400
1401 if( shape->IsProxyItem() && shape->GetShape() == SHAPE_T::RECTANGLE )
1402 {
1403 position = shape->GetCenter();
1404 padsize = shape->GetBotRight() - shape->GetTopLeft();
1405
1406 // We normally draw a bit outside the pad, but this will be somewhat
1407 // unexpected when the user has drawn a box.
1408 padsize *= 0.9;
1409
1410 break;
1411 }
1412 }
1413 }
1414 }
1415 else if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CUSTOM )
1416 {
1417 // See if we have a number box
1418 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives( pcbLayer ) )
1419 {
1420 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
1421 {
1422 position = primitive->GetCenter();
1423 RotatePoint( position, aPad->GetOrientation() );
1424 position += aPad->ShapePos( pcbLayer );
1425
1426 padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
1427 padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
1428
1429 // We normally draw a bit outside the pad, but this will be somewhat
1430 // unexpected when the user has drawn a box.
1431 padsize *= 0.9;
1432
1433 break;
1434 }
1435 }
1436 }
1437
1438 if( aPad->GetShape( pcbLayer ) != PAD_SHAPE::CUSTOM )
1439 {
1440 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
1441 double limit = std::min( aPad->GetSize( pcbLayer ).x,
1442 aPad->GetSize( pcbLayer ).y ) * 1.1;
1443
1444 if( padsize.x > limit && padsize.y > limit )
1445 {
1446 padsize.x = limit;
1447 padsize.y = limit;
1448 }
1449 }
1450
1451 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
1452 double size = padsize.y;
1453
1454 m_gal->Save();
1455 m_gal->Translate( position );
1456
1457 // Keep the size ratio for the font, but make it smaller
1458 if( padsize.x < ( padsize.y * 0.95 ) )
1459 {
1460 m_gal->Rotate( -ANGLE_90.AsRadians() );
1461 size = padsize.x;
1462 std::swap( padsize.x, padsize.y );
1463 }
1464
1465 // Font size limits
1466 if( size > maxSize )
1467 size = maxSize;
1468
1469 // Default font settings
1470 m_gal->ResetTextAttributes();
1471 m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
1472 m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
1473 m_gal->SetFontBold( false );
1474 m_gal->SetFontItalic( false );
1475 m_gal->SetFontUnderlined( false );
1476 m_gal->SetTextMirrored( false );
1477 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) );
1478 m_gal->SetIsStroke( true );
1479 m_gal->SetIsFill( false );
1480
1481 // We have already translated the GAL to be centered at the center of the pad's
1482 // bounding box
1483 VECTOR2I textpos( 0, 0 );
1484
1485 // Divide the space, to display both pad numbers and netnames and set the Y text
1486 // offset position to display 2 lines
1487 int Y_offset_numpad = 0;
1488 int Y_offset_netname = 0;
1489
1490 if( !netname.IsEmpty() && !padNumber.IsEmpty() )
1491 {
1492 // The magic numbers are defined experimentally for a better look.
1493 size = size / 2.5;
1494 Y_offset_netname = size / 1.4; // netname size is usually smaller than num pad
1495 // so the offset can be smaller
1496 Y_offset_numpad = size / 1.7;
1497 }
1498
1499 // We are using different fonts to display names, depending on the graphic
1500 // engine (OpenGL or Cairo).
1501 // Xscale_for_stroked_font adjust the text X size for cairo (stroke fonts) engine
1502 const double Xscale_for_stroked_font = 0.9;
1503
1504 if( !netname.IsEmpty() )
1505 {
1506 // approximate the size of net name text:
1507 // We use a size for at least 5 chars, to give a good look even for short names
1508 // (like VCC, GND...)
1509 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname )+1, 5 );
1510 tsize = std::min( tsize, size );
1511
1512 // Use a smaller text size to handle interline, pen size...
1513 tsize *= 0.85;
1514
1515 // Round and oval pads have less room to display the net name than other
1516 // (i.e RECT) shapes, so reduce the text size for these shapes
1517 if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CIRCLE
1518 || aPad->GetShape( pcbLayer ) == PAD_SHAPE::OVAL )
1519 {
1520 tsize *= 0.9;
1521 }
1522
1523 VECTOR2D namesize( tsize*Xscale_for_stroked_font, tsize );
1524 textpos.y = std::min( tsize * 1.4, double( Y_offset_netname ) );
1525
1526 m_gal->SetGlyphSize( namesize );
1527 m_gal->SetLineWidth( namesize.x / 6.0 );
1528 m_gal->SetFontBold( true );
1529 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
1530 }
1531
1532 if( !padNumber.IsEmpty() )
1533 {
1534 // approximate the size of the pad number text:
1535 // We use a size for at least 3 chars, to give a good look even for short numbers
1536 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( padNumber ), 3 );
1537 tsize = std::min( tsize, size );
1538
1539 // Use a smaller text size to handle interline, pen size...
1540 tsize *= 0.85;
1541 tsize = std::min( tsize, size );
1542 VECTOR2D numsize( tsize*Xscale_for_stroked_font, tsize );
1543 textpos.y = -Y_offset_numpad;
1544
1545 m_gal->SetGlyphSize( numsize );
1546 m_gal->SetLineWidth( numsize.x / 6.0 );
1547 m_gal->SetFontBold( true );
1548 m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL );
1549 }
1550
1551 m_gal->Restore();
1552
1553 return;
1554 }
1555 else if( aLayer == LAYER_PAD_HOLEWALLS )
1556 {
1557 m_gal->SetIsFill( true );
1558 m_gal->SetIsStroke( false );
1560 double lineWidth = widthFactor * m_holePlatingThickness;
1561 lineWidth = std::min( lineWidth, aPad->GetSizeX() / 2.0 );
1562 lineWidth = std::min( lineWidth, aPad->GetSizeY() / 2.0 );
1563
1564 m_gal->SetFillColor( color );
1565 m_gal->SetMinLineWidth( lineWidth );
1566
1567 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
1568
1569 if( slot->GetSeg().A == slot->GetSeg().B ) // Circular hole
1570 {
1571 double holeRadius = slot->GetWidth() / 2.0;
1572 m_gal->DrawHoleWall( slot->GetSeg().A, holeRadius, lineWidth );
1573 }
1574 else
1575 {
1576 int holeSize = slot->GetWidth() + ( 2 * lineWidth );
1577 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, holeSize );
1578 }
1579
1580 m_gal->SetMinLineWidth( 1.0 );
1581
1582 return;
1583 }
1584
1585 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
1586
1587 if( m_pcbSettings.m_ForcePadSketchModeOn )
1588 outline_mode = true;
1589
1590 bool drawShape = false;
1591
1592 if( m_pcbSettings.IsPrinting() )
1593 {
1594 drawShape = aPad->FlashLayer( m_pcbSettings.GetPrintLayers() );
1595 }
1596 else if( ( aLayer < PCB_LAYER_ID_COUNT || IsPadCopperLayer( aLayer ) )
1597 && aPad->FlashLayer( pcbLayer ) )
1598 {
1599 drawShape = true;
1600 }
1601 else if( aPad->IsSelected() )
1602 {
1603 drawShape = true;
1604 outline_mode = true;
1605 }
1606 else if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1607 {
1608 drawShape = true;
1609 outline_mode = false;
1610 }
1611
1612 // Plated holes are always filled as they use a solid BG fill to
1613 // draw the "hole" over the hole-wall segment/circle.
1614 if( outline_mode && aLayer != LAYER_PAD_PLATEDHOLES )
1615 {
1616 // Outline mode
1617 m_gal->SetIsFill( false );
1618 m_gal->SetIsStroke( true );
1619 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1620 m_gal->SetStrokeColor( color );
1621 }
1622 else
1623 {
1624 // Filled mode
1625 m_gal->SetIsFill( true );
1626 m_gal->SetIsStroke( false );
1627 m_gal->SetFillColor( color );
1628 }
1629
1630 if( aLayer == LAYER_PAD_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
1631 {
1632 SHAPE_SEGMENT slot = getPadHoleShape( aPad );
1633 VECTOR2I center = slot.GetSeg().A;
1634
1635 if( slot.GetSeg().A == slot.GetSeg().B ) // Circular hole
1636 m_gal->DrawCircle( center, slot.GetWidth() / 2.0 );
1637 else
1638 m_gal->DrawSegment( slot.GetSeg().A, slot.GetSeg().B, slot.GetWidth() );
1639 }
1640 else if( drawShape )
1641 {
1642 VECTOR2I pad_size = aPad->GetSize( pcbLayer );
1643 VECTOR2I margin;
1644
1645 auto getExpansion =
1646 [&]( PCB_LAYER_ID layer )
1647 {
1648 VECTOR2I expansion;
1649
1650 switch( aLayer )
1651 {
1652 case F_Mask:
1653 case B_Mask:
1654 expansion.x = expansion.y = aPad->GetSolderMaskExpansion( layer );
1655 break;
1656
1657 case F_Paste:
1658 case B_Paste:
1659 expansion = aPad->GetSolderPasteMargin( layer );
1660 break;
1661
1662 default:
1663 expansion.x = expansion.y = 0;
1664 break;
1665 }
1666
1667 return expansion;
1668 };
1669
1670 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1671 {
1672 LSET visibleLayers = aPad->GetBoard()->GetVisibleLayers()
1673 & aPad->GetBoard()->GetEnabledLayers()
1674 & aPad->GetLayerSet();
1675
1676 for( PCB_LAYER_ID layer : visibleLayers )
1677 margin = std::max( margin, getExpansion( layer ) );
1678
1679 margin.x += m_lockedShadowMargin / 2;
1680 margin.y += m_lockedShadowMargin / 2;
1681 }
1682 else
1683 {
1684 margin = getExpansion( pcbLayer );
1685 }
1686
1687 std::unique_ptr<PAD> dummyPad;
1688 std::shared_ptr<SHAPE_COMPOUND> shapes;
1689
1690 // Drawing components of compound shapes in outline mode produces a mess.
1691 bool simpleShapes = !outline_mode;
1692
1693 // When this layer has post-machining (counterbore/countersink), GetEffectiveShape returns
1694 // the counterbore hole circle (for DRC purposes), not the actual copper shape. Force the
1695 // slower TransformShapeToPolygon path which always returns the correct copper shape.
1696 if( IsCopperLayer( pcbLayer ) && aPad->GetPostMachiningKnockout( pcbLayer ) > 0 )
1697 simpleShapes = false;
1698
1699 if( simpleShapes )
1700 {
1701 if( ( margin.x != margin.y && aPad->GetShape( pcbLayer ) != PAD_SHAPE::CUSTOM )
1702 || ( aPad->GetShape( pcbLayer ) == PAD_SHAPE::ROUNDRECT
1703 && ( margin.x < 0 || margin.y < 0 ) ) )
1704 {
1705 // Our algorithms below (polygon inflation in particular) can't handle differential
1706 // inflation along separate axes. So for those cases we build a dummy pad instead,
1707 // and inflate it.
1708
1709 // Margin is added to both sides. If the total margin is larger than the pad
1710 // then don't display this layer
1711 if( pad_size.x + 2 * margin.x <= 0 || pad_size.y + 2 * margin.y <= 0 )
1712 return;
1713
1714 dummyPad.reset( static_cast<PAD*>( aPad->Duplicate( IGNORE_PARENT_GROUP ) ) );
1715
1716 int initial_radius = dummyPad->GetRoundRectCornerRadius( pcbLayer );
1717
1718 dummyPad->SetSize( pcbLayer, pad_size + margin + margin );
1719
1720 if( dummyPad->GetShape( pcbLayer ) == PAD_SHAPE::ROUNDRECT )
1721 {
1722 // To keep the right margin around the corners, we need to modify the corner radius.
1723 // We must have only one radius correction, so use the smallest absolute margin.
1724 int radius_margin = std::max( margin.x, margin.y ); // radius_margin is < 0
1725 dummyPad->SetRoundRectCornerRadius(
1726 pcbLayer, std::max( initial_radius + radius_margin, 0 ) );
1727 }
1728
1729 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>(
1730 dummyPad->GetEffectiveShape( pcbLayer ) );
1731 margin.x = margin.y = 0;
1732 }
1733 else
1734 {
1735 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>(
1736 aPad->GetEffectiveShape( pcbLayer ) );
1737 }
1738
1739 // The dynamic cast above will fail if the pad returned the hole shape or a null shape
1740 // instead of a SHAPE_COMPOUND, which happens if we're on a copper layer and the pad has
1741 // no shape on that layer.
1742 if( !shapes )
1743 return;
1744
1745 if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CUSTOM && ( margin.x || margin.y ) )
1746 {
1747 // We can't draw as shapes because we don't know which edges are internal and which
1748 // are external (so we don't know when to apply the margin and when not to).
1749 simpleShapes = false;
1750 }
1751
1752 for( const SHAPE* shape : shapes->Shapes() )
1753 {
1754 if( !simpleShapes )
1755 break;
1756
1757 switch( shape->Type() )
1758 {
1759 case SH_SEGMENT:
1760 case SH_CIRCLE:
1761 case SH_RECT:
1762 case SH_SIMPLE:
1763 // OK so far
1764 break;
1765
1766 default:
1767 // Not OK
1768 simpleShapes = false;
1769 break;
1770 }
1771 }
1772 }
1773
1774 const auto drawOneSimpleShape =
1775 [&]( const SHAPE& aShape )
1776 {
1777 switch( aShape.Type() )
1778 {
1779 case SH_SEGMENT:
1780 {
1781 const SHAPE_SEGMENT& seg = (const SHAPE_SEGMENT&) aShape;
1782 int effectiveWidth = seg.GetWidth() + 2 * margin.x;
1783
1784 if( effectiveWidth > 0 )
1785 m_gal->DrawSegment( seg.GetSeg().A, seg.GetSeg().B, effectiveWidth );
1786
1787 break;
1788 }
1789
1790 case SH_CIRCLE:
1791 {
1792 const SHAPE_CIRCLE& circle = (const SHAPE_CIRCLE&) aShape;
1793 int effectiveRadius = circle.GetRadius() + margin.x;
1794
1795 if( effectiveRadius > 0 )
1796 m_gal->DrawCircle( circle.GetCenter(), effectiveRadius );
1797
1798 break;
1799 }
1800
1801 case SH_RECT:
1802 {
1803 const SHAPE_RECT& r = (const SHAPE_RECT&) aShape;
1804 VECTOR2I pos = r.GetPosition();
1805 VECTOR2I effectiveMargin = margin;
1806
1807 if( effectiveMargin.x < 0 )
1808 {
1809 // A negative margin just produces a smaller rect.
1810 VECTOR2I effectiveSize = r.GetSize() + effectiveMargin;
1811
1812 if( effectiveSize.x > 0 && effectiveSize.y > 0 )
1813 m_gal->DrawRectangle( pos - effectiveMargin, pos + effectiveSize );
1814 }
1815 else if( effectiveMargin.x > 0 )
1816 {
1817 // A positive margin produces a larger rect, but with rounded corners
1818 m_gal->DrawRectangle( r.GetPosition(), r.GetPosition() + r.GetSize() );
1819
1820 // Use segments to produce the margin with rounded corners
1821 m_gal->DrawSegment( pos,
1822 pos + VECTOR2I( r.GetWidth(), 0 ),
1823 effectiveMargin.x * 2 );
1824 m_gal->DrawSegment( pos + VECTOR2I( r.GetWidth(), 0 ),
1825 pos + r.GetSize(),
1826 effectiveMargin.x * 2 );
1827 m_gal->DrawSegment( pos + r.GetSize(),
1828 pos + VECTOR2I( 0, r.GetHeight() ),
1829 effectiveMargin.x * 2 );
1830 m_gal->DrawSegment( pos + VECTOR2I( 0, r.GetHeight() ),
1831 pos,
1832 effectiveMargin.x * 2 );
1833 }
1834 else
1835 {
1836 m_gal->DrawRectangle( r.GetPosition(), r.GetPosition() + r.GetSize() );
1837 }
1838
1839 break;
1840 }
1841
1842 case SH_SIMPLE:
1843 {
1844 const SHAPE_SIMPLE& poly = static_cast<const SHAPE_SIMPLE&>( aShape );
1845
1846 if( poly.PointCount() < 2 ) // Careful of empty pads
1847 break;
1848
1849 if( margin.x < 0 ) // The poly shape must be deflated
1850 {
1851 SHAPE_POLY_SET outline;
1852 outline.NewOutline();
1853
1854 for( int ii = 0; ii < poly.PointCount(); ++ii )
1855 outline.Append( poly.CPoint( ii ) );
1856
1858
1859 m_gal->DrawPolygon( outline );
1860 }
1861 else
1862 {
1863 m_gal->DrawPolygon( poly.Vertices() );
1864 }
1865
1866 // Now add on a rounded margin (using segments) if the margin > 0
1867 if( margin.x > 0 )
1868 {
1869 for( size_t ii = 0; ii < poly.GetSegmentCount(); ++ii )
1870 {
1871 SEG seg = poly.GetSegment( ii );
1872 m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
1873 }
1874 }
1875
1876 break;
1877 }
1878
1879 default:
1880 // Better not get here; we already pre-flighted the shapes...
1881 break;
1882 }
1883 };
1884
1885 if( simpleShapes )
1886 {
1887 for( const SHAPE* shape : shapes->Shapes() )
1888 drawOneSimpleShape( *shape );
1889 }
1890 else
1891 {
1892 // This is expensive. Avoid if possible.
1893 SHAPE_POLY_SET polySet;
1894 aPad->TransformShapeToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x, m_maxError, ERROR_INSIDE );
1895 m_gal->DrawPolygon( polySet );
1896 }
1897
1898 // Draw backdrill indicators (semi-circles extending into the hole)
1899 // Drawn on copper layer so they appear above the annular ring
1900 if( !m_pcbSettings.IsPrinting() && aPad->GetDrillSizeX() > 0 )
1901 {
1902 VECTOR2D holePos = aPad->GetPosition() + aPad->GetOffset( pcbLayer );
1903 VECTOR2I secDrill = aPad->GetSecondaryDrillSize();
1904 VECTOR2I terDrill = aPad->GetTertiaryDrillSize();
1905
1906 if( secDrill.x > 0 )
1907 {
1908 drawBackdrillIndicator( aPad, holePos, secDrill.x,
1910 aPad->GetSecondaryDrillEndLayer() );
1911 }
1912
1913 if( terDrill.x > 0 )
1914 {
1915 drawBackdrillIndicator( aPad, holePos, terDrill.x,
1917 aPad->GetTertiaryDrillEndLayer() );
1918 }
1919 }
1920 }
1921
1922 if( !m_pcbSettings.IsPrinting() && IsCopperLayer( pcbLayer ) && aPad->GetDrillSizeX() > 0 )
1923 {
1924 VECTOR2D holePos = aPad->GetPosition() + aPad->GetOffset( pcbLayer );
1925 drawPostMachiningIndicator( aPad, holePos, pcbLayer );
1926 }
1927
1928 if( IsClearanceLayer( aLayer )
1929 && ( ( pcbconfig() && pcbconfig()->m_Display.m_PadClearance ) || !pcbconfig() )
1930 && !m_pcbSettings.m_isPrinting )
1931 {
1932 const PCB_LAYER_ID copperLayerForClearance = ToLAYER_ID( aLayer - LAYER_CLEARANCE_START );
1933
1934 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
1935 color = m_pcbSettings.GetLayerColor( LAYER_NON_PLATEDHOLES );
1936
1937 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
1938 m_gal->SetIsStroke( true );
1939 m_gal->SetIsFill( false );
1940 m_gal->SetStrokeColor( color );
1941
1942 const int clearance = aPad->GetOwnClearance( copperLayerForClearance );
1943
1944 if( aPad->FlashLayer( copperLayerForClearance ) && clearance > 0 )
1945 {
1946 auto shape = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( pcbLayer ) );
1947
1948 if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_SEGMENT )
1949 {
1950 const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape->Shapes()[0];
1951 m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
1952 seg->GetWidth() + 2 * clearance );
1953 }
1954 else if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_CIRCLE )
1955 {
1956 const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape->Shapes()[0];
1957 m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
1958 }
1959 else
1960 {
1961 SHAPE_POLY_SET polySet;
1962
1963 // Use ERROR_INSIDE because it avoids Clipper and is therefore much faster.
1964 aPad->TransformShapeToPolygon( polySet, copperLayerForClearance, clearance,
1966
1967 if( polySet.Outline( 0 ).PointCount() > 2 ) // Careful of empty pads
1968 m_gal->DrawPolygon( polySet );
1969 }
1970 }
1971 else if( aPad->GetEffectiveHoleShape() && clearance > 0 )
1972 {
1973 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
1974 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B,
1975 slot->GetWidth() + 2 * clearance );
1976 }
1977 }
1978}
1979
1980
1981void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
1982{
1983 COLOR4D color = m_pcbSettings.GetColor( aShape, aLayer );
1985 int thickness = getLineThickness( aShape->GetWidth() );
1986 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
1987 bool isSolidFill = aShape->IsSolidFill();
1988 bool isHatchedFill = aShape->IsHatchedFill();
1989
1990 if( lineStyle == LINE_STYLE::DEFAULT )
1991 lineStyle = LINE_STYLE::SOLID;
1992
1993 if( IsSolderMaskLayer( aLayer )
1994 && aShape->HasSolderMask()
1995 && IsExternalCopperLayer( aShape->GetLayer() ) )
1996 {
1997 lineStyle = LINE_STYLE::SOLID;
1998 thickness += aShape->GetSolderMaskExpansion() * 2;
1999
2000 if( isHatchedFill )
2001 {
2002 isSolidFill = true;
2003 isHatchedFill = false;
2004 }
2005 }
2006
2007 if( IsNetnameLayer( aLayer ) )
2008 {
2009 // Net names are shown only in board editor:
2011 return;
2012
2013 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
2014 return;
2015
2016 if( aShape->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
2017 return;
2018
2019 const wxString& netname = aShape->GetDisplayNetname();
2020
2021 if( netname.IsEmpty() )
2022 return;
2023
2024 if( aShape->GetShape() == SHAPE_T::SEGMENT )
2025 {
2026 SHAPE_SEGMENT seg( { aShape->GetStart(), aShape->GetEnd() }, aShape->GetWidth() );
2027 renderNetNameForSegment( seg, color, netname );
2028 return;
2029 }
2030
2031 // TODO: Maybe use some of the pad code?
2032
2033 return;
2034 }
2035
2036 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
2037 {
2038 color = m_pcbSettings.GetColor( aShape, aLayer );
2039 thickness = thickness + m_lockedShadowMargin;
2040
2041 // Note: on LAYER_LOCKED_ITEM_SHADOW always draw shadow shapes as continuous lines
2042 // otherwise the look is very strange and ugly
2043 lineStyle = LINE_STYLE::SOLID;
2044 }
2045
2046 if( outline_mode )
2047 {
2048 m_gal->SetIsFill( false );
2049 m_gal->SetIsStroke( true );
2050 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2051 }
2052
2053 m_gal->SetFillColor( color );
2054 m_gal->SetStrokeColor( color );
2055
2056 if( lineStyle == LINE_STYLE::SOLID || aShape->IsSolidFill() )
2057 {
2058 switch( aShape->GetShape() )
2059 {
2060 case SHAPE_T::SEGMENT:
2061 if( aShape->IsProxyItem() )
2062 {
2063 std::vector<VECTOR2I> pts;
2064 VECTOR2I offset = ( aShape->GetEnd() - aShape->GetStart() ).Perpendicular();
2065 offset = offset.Resize( thickness / 2 );
2066
2067 pts.push_back( aShape->GetStart() + offset );
2068 pts.push_back( aShape->GetStart() - offset );
2069 pts.push_back( aShape->GetEnd() - offset );
2070 pts.push_back( aShape->GetEnd() + offset );
2071
2072 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2073 m_gal->DrawLine( pts[0], pts[1] );
2074 m_gal->DrawLine( pts[1], pts[2] );
2075 m_gal->DrawLine( pts[2], pts[3] );
2076 m_gal->DrawLine( pts[3], pts[0] );
2077 m_gal->DrawLine( ( pts[0] + pts[1] ) / 2, ( pts[1] + pts[2] ) / 2 );
2078 m_gal->DrawLine( ( pts[1] + pts[2] ) / 2, ( pts[2] + pts[3] ) / 2 );
2079 m_gal->DrawLine( ( pts[2] + pts[3] ) / 2, ( pts[3] + pts[0] ) / 2 );
2080 m_gal->DrawLine( ( pts[3] + pts[0] ) / 2, ( pts[0] + pts[1] ) / 2 );
2081 }
2082 else if( outline_mode )
2083 {
2084 m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
2085 }
2086 else if( lineStyle == LINE_STYLE::SOLID )
2087 {
2088 m_gal->SetIsFill( true );
2089 m_gal->SetIsStroke( false );
2090
2091 m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
2092 }
2093
2094 break;
2095
2096 case SHAPE_T::RECTANGLE:
2097 {
2098 if( aShape->GetCornerRadius() > 0 )
2099 {
2100 // Creates a normalized ROUNDRECT item
2101 // (GetRectangleWidth() and GetRectangleHeight() can be < 0 with transforms
2102 ROUNDRECT rr( SHAPE_RECT( aShape->GetStart(), aShape->GetRectangleWidth(),
2103 aShape->GetRectangleHeight() ),
2104 aShape->GetCornerRadius(), true /* normalize */ );
2105 SHAPE_POLY_SET poly;
2106 rr.TransformToPolygon( poly, aShape->GetMaxError() );
2107 SHAPE_LINE_CHAIN outline = poly.Outline( 0 );
2108
2109 if( aShape->IsProxyItem() )
2110 {
2111 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2112 m_gal->DrawPolygon( outline );
2113 }
2114 else if( outline_mode )
2115 {
2116 m_gal->DrawSegmentChain( outline, thickness );
2117 }
2118 else
2119 {
2120 m_gal->SetIsFill( true );
2121 m_gal->SetIsStroke( false );
2122
2123 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
2124 {
2125 m_gal->DrawSegmentChain( outline, thickness );
2126 }
2127
2128 if( isSolidFill )
2129 {
2130 if( thickness < 0 )
2131 {
2132 SHAPE_POLY_SET deflated_shape = outline;
2133 deflated_shape.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS, m_maxError );
2134 m_gal->DrawPolygon( deflated_shape );
2135 }
2136 else
2137 {
2138 m_gal->DrawPolygon( outline );
2139 }
2140 }
2141 }
2142 }
2143 else
2144 {
2145 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
2146
2147 if( aShape->IsProxyItem() )
2148 {
2149 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2150 m_gal->DrawLine( pts[0], pts[1] );
2151 m_gal->DrawLine( pts[1], pts[2] );
2152 m_gal->DrawLine( pts[2], pts[3] );
2153 m_gal->DrawLine( pts[3], pts[0] );
2154 m_gal->DrawLine( pts[0], pts[2] );
2155 m_gal->DrawLine( pts[1], pts[3] );
2156 }
2157 else if( outline_mode )
2158 {
2159 m_gal->DrawSegment( pts[0], pts[1], thickness );
2160 m_gal->DrawSegment( pts[1], pts[2], thickness );
2161 m_gal->DrawSegment( pts[2], pts[3], thickness );
2162 m_gal->DrawSegment( pts[3], pts[0], thickness );
2163 }
2164 else
2165 {
2166 m_gal->SetIsFill( true );
2167 m_gal->SetIsStroke( false );
2168
2169 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
2170 {
2171 m_gal->DrawSegment( pts[0], pts[1], thickness );
2172 m_gal->DrawSegment( pts[1], pts[2], thickness );
2173 m_gal->DrawSegment( pts[2], pts[3], thickness );
2174 m_gal->DrawSegment( pts[3], pts[0], thickness );
2175 }
2176
2177 if( isSolidFill )
2178 {
2179 SHAPE_POLY_SET poly;
2180 poly.NewOutline();
2181
2182 for( const VECTOR2I& pt : pts )
2183 poly.Append( pt );
2184
2185 if( thickness < 0 )
2186 poly.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
2187 m_maxError );
2188
2189 m_gal->DrawPolygon( poly );
2190 }
2191 }
2192 }
2193
2194 break;
2195 }
2196
2197 case SHAPE_T::ARC:
2198 {
2199 EDA_ANGLE startAngle;
2200 EDA_ANGLE endAngle;
2201 aShape->CalcArcAngles( startAngle, endAngle );
2202
2203 if( outline_mode )
2204 {
2205 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
2206 endAngle - startAngle, thickness, m_maxError );
2207 }
2208 else if( lineStyle == LINE_STYLE::SOLID )
2209 {
2210 m_gal->SetIsFill( true );
2211 m_gal->SetIsStroke( false );
2212
2213 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
2214 endAngle - startAngle, thickness, m_maxError );
2215 }
2216 break;
2217 }
2218
2219 case SHAPE_T::CIRCLE:
2220 if( outline_mode )
2221 {
2222 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() - thickness / 2 );
2223 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() + thickness / 2 );
2224 }
2225 else
2226 {
2227 m_gal->SetIsFill( aShape->IsSolidFill() );
2228 m_gal->SetIsStroke( lineStyle == LINE_STYLE::SOLID && thickness > 0 );
2229 m_gal->SetLineWidth( thickness );
2230
2231 int radius = aShape->GetRadius();
2232
2233 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
2234 {
2235 m_gal->DrawCircle( aShape->GetStart(), radius );
2236 }
2237 else if( isSolidFill )
2238 {
2239 if( thickness < 0 )
2240 {
2241 radius += thickness / 2;
2242 radius = std::max( radius, 0 );
2243 }
2244
2245 m_gal->DrawCircle( aShape->GetStart(), radius );
2246 }
2247 }
2248 break;
2249
2250 case SHAPE_T::POLY:
2251 {
2252 SHAPE_POLY_SET& shape = const_cast<PCB_SHAPE*>( aShape )->GetPolyShape();
2253
2254 if( shape.OutlineCount() == 0 )
2255 break;
2256
2257 if( outline_mode )
2258 {
2259 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
2260 m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
2261 }
2262 else
2263 {
2264 m_gal->SetIsFill( true );
2265 m_gal->SetIsStroke( false );
2266
2267 if( lineStyle == LINE_STYLE::SOLID && thickness > 0 )
2268 {
2269 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
2270 m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
2271 }
2272
2273 if( isSolidFill )
2274 {
2275 if( thickness < 0 )
2276 {
2277 SHAPE_POLY_SET deflated_shape = shape;
2278 deflated_shape.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
2279 m_maxError );
2280 m_gal->DrawPolygon( deflated_shape );
2281 }
2282 else
2283 {
2284 // On Opengl, a not convex filled polygon is usually drawn by using
2285 // triangles as primitives. CacheTriangulation() can create basic triangle
2286 // primitives to draw the polygon solid shape on Opengl. GLU tessellation
2287 // is much slower, so currently we are using our tessellation.
2288 if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
2289 shape.CacheTriangulation( true );
2290
2291 m_gal->DrawPolygon( shape );
2292 }
2293 }
2294 }
2295
2296 break;
2297 }
2298
2299 case SHAPE_T::BEZIER:
2300 if( outline_mode )
2301 {
2302 std::vector<VECTOR2D> output;
2303 std::vector<VECTOR2D> pointCtrl;
2304
2305 pointCtrl.push_back( aShape->GetStart() );
2306 pointCtrl.push_back( aShape->GetBezierC1() );
2307 pointCtrl.push_back( aShape->GetBezierC2() );
2308 pointCtrl.push_back( aShape->GetEnd() );
2309
2310 BEZIER_POLY converter( pointCtrl );
2311 converter.GetPoly( output, m_maxError );
2312
2313 m_gal->DrawSegmentChain( aShape->GetBezierPoints(), thickness );
2314 }
2315 else
2316 {
2317 m_gal->SetIsFill( aShape->IsSolidFill() );
2318 m_gal->SetIsStroke( lineStyle == LINE_STYLE::SOLID && thickness > 0 );
2319 m_gal->SetLineWidth( thickness );
2320
2321 if( aShape->GetBezierPoints().size() > 2 )
2322 {
2323 m_gal->DrawPolygon( aShape->GetBezierPoints() );
2324 }
2325 else
2326 {
2327 m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
2328 VECTOR2D( aShape->GetBezierC1() ),
2329 VECTOR2D( aShape->GetBezierC2() ),
2330 VECTOR2D( aShape->GetEnd() ), m_maxError );
2331 }
2332 }
2333
2334 break;
2335
2336 case SHAPE_T::UNDEFINED:
2337 break;
2338 }
2339 }
2340
2341 if( lineStyle != LINE_STYLE::SOLID )
2342 {
2343 if( !outline_mode )
2344 {
2345 m_gal->SetIsFill( true );
2346 m_gal->SetIsStroke( false );
2347 }
2348
2349 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
2350
2351 for( SHAPE* shape : shapes )
2352 {
2353 STROKE_PARAMS::Stroke( shape, lineStyle, getLineThickness( aShape->GetWidth() ),
2355 [&]( const VECTOR2I& a, const VECTOR2I& b )
2356 {
2357 m_gal->DrawSegment( a, b, thickness );
2358 } );
2359 }
2360
2361 for( SHAPE* shape : shapes )
2362 delete shape;
2363 }
2364
2365 if( isHatchedFill )
2366 {
2367 aShape->UpdateHatching();
2368 m_gal->SetIsFill( false );
2369 m_gal->SetIsStroke( true );
2370 m_gal->SetLineWidth( aShape->GetHatchLineWidth() );
2371
2372 for( const SEG& seg : aShape->GetHatchLines() )
2373 m_gal->DrawLine( seg.A, seg.B );
2374 }
2375}
2376
2377
2378void PCB_PAINTER::strokeText( const wxString& aText, const VECTOR2I& aPosition,
2379 const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
2380{
2381 KIFONT::FONT* font = aAttrs.m_Font;
2382
2383 if( !font )
2384 font = KIFONT::FONT::GetFont( wxEmptyString, aAttrs.m_Bold, aAttrs.m_Italic );
2385
2386 m_gal->SetIsFill( font->IsOutline() );
2387 m_gal->SetIsStroke( font->IsStroke() );
2388
2389 VECTOR2I pos( aPosition );
2390 VECTOR2I fudge( KiROUND( 0.16 * aAttrs.m_StrokeWidth ), 0 );
2391
2392 RotatePoint( fudge, aAttrs.m_Angle );
2393
2394 if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && !aAttrs.m_Mirrored )
2395 || ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && aAttrs.m_Mirrored ) )
2396 {
2397 pos -= fudge;
2398 }
2399 else if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && !aAttrs.m_Mirrored )
2400 || ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && aAttrs.m_Mirrored ) )
2401 {
2402 pos += fudge;
2403 }
2404
2405 font->Draw( m_gal, aText, pos, aAttrs, aFontMetrics );
2406}
2407
2408
2409void PCB_PAINTER::draw( const PCB_REFERENCE_IMAGE* aBitmap, int aLayer )
2410{
2411 m_gal->Save();
2412
2413 const REFERENCE_IMAGE& refImg = aBitmap->GetReferenceImage();
2414 m_gal->Translate( refImg.GetPosition() );
2415
2416 // When the image scale factor is not 1.0, we need to modify the actual as the image scale
2417 // factor is similar to a local zoom
2418 const double img_scale = refImg.GetImageScale();
2419
2420 if( img_scale != 1.0 )
2421 m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
2422
2423 const double imgAlpha = m_pcbSettings.GetColor( aBitmap, aBitmap->GetLayer() ).a;
2424
2425 if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
2426 {
2427 COLOR4D color = m_pcbSettings.GetColor( aBitmap, LAYER_ANCHOR );
2428 m_gal->SetIsStroke( true );
2429 m_gal->SetStrokeColor( color );
2430 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth * 2.0f );
2431 m_gal->SetIsFill( false );
2432
2433 // Draws a bounding box.
2434 VECTOR2D bm_size( refImg.GetSize() );
2435 // bm_size is the actual image size in UI.
2436 // but m_canvas scale was previously set to img_scale
2437 // so recalculate size relative to this image size.
2438 bm_size.x /= img_scale;
2439 bm_size.y /= img_scale;
2440 VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
2441 VECTOR2D end = origin + bm_size;
2442
2443 m_gal->DrawRectangle( origin, end );
2444
2445 // Keep reference images opaque when selected (and not moving). Otherwise cached layers
2446 // will not be rendered under the selected image because cached layers are rendered
2447 // after non-cached layers (e.g. bitmaps), which will have a closer Z order.
2448 m_gal->DrawBitmap( refImg.GetImage(), aBitmap->IsMoving() ? imgAlpha : 1.0 );
2449 }
2450 else
2451 m_gal->DrawBitmap( refImg.GetImage(), imgAlpha );
2452
2453 m_gal->Restore();
2454}
2455
2456
2457void PCB_PAINTER::draw( const PCB_FIELD* aField, int aLayer )
2458{
2459 if( aField->IsVisible() )
2460 draw( static_cast<const PCB_TEXT*>( aField ), aLayer );
2461}
2462
2463
2464void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
2465{
2466 wxString resolvedText( aText->GetShownText( true ) );
2467
2468 if( resolvedText.Length() == 0 )
2469 return;
2470
2471 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
2472 {
2473 const COLOR4D color = m_pcbSettings.GetColor( aText, aLayer );
2474
2475 m_gal->SetIsFill( true );
2476 m_gal->SetIsStroke( true );
2477 m_gal->SetFillColor( color );
2478 m_gal->SetStrokeColor( color );
2479 m_gal->SetLineWidth( m_lockedShadowMargin );
2480
2481 SHAPE_POLY_SET poly;
2482 aText->TransformShapeToPolygon( poly, aText->GetLayer(), 0, m_maxError, ERROR_OUTSIDE );
2483 m_gal->DrawPolygon( poly );
2484
2485 return;
2486 }
2487
2488 const KIFONT::METRICS& metrics = aText->GetFontMetrics();
2489 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
2490 const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
2491 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
2492
2493 KIFONT::FONT* font = aText->GetDrawFont( &m_pcbSettings );
2494
2495 m_gal->SetStrokeColor( color );
2496 m_gal->SetFillColor( color );
2497 attrs.m_Angle = aText->GetDrawRotation();
2498
2499 if( aText->IsKnockout() )
2500 {
2501 const SHAPE_POLY_SET& finalPoly = aText->GetKnockoutCache( font, resolvedText, m_maxError );
2502
2503 m_gal->SetIsStroke( false );
2504 m_gal->SetIsFill( true );
2505 m_gal->DrawPolygon( finalPoly );
2506 }
2507 else
2508 {
2509 if( outline_mode )
2510 attrs.m_StrokeWidth = m_pcbSettings.m_outlineWidth;
2511 else
2513
2514 if( m_gal->IsFlippedX() && !aText->IsSideSpecific() )
2515 {
2516 // We do not want to change the mirroring for this kind of text
2517 // on the mirrored canvas
2518 // (not mirrored is draw not mirrored and mirrored is draw mirrored)
2519 // So we need to recalculate the text position to keep it at the same position
2520 // on the canvas
2521 VECTOR2I textPos = aText->GetTextPos();
2522 VECTOR2I textWidth = VECTOR2I( aText->GetTextBox( &m_pcbSettings ).GetWidth(), 0 );
2523
2524 if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
2525 textWidth.x = -textWidth.x;
2526 else if( aText->GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER )
2527 textWidth.x = 0;
2528
2529 RotatePoint( textWidth, VECTOR2I( 0, 0 ), aText->GetDrawRotation() );
2530
2531 if( attrs.m_Mirrored )
2532 textPos -= textWidth;
2533 else
2534 textPos += textWidth;
2535
2536 attrs.m_Mirrored = !attrs.m_Mirrored;
2537 strokeText( resolvedText, textPos, attrs, metrics );
2538 return;
2539 }
2540
2541 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2542
2543 if( font->IsOutline() )
2544 cache = aText->GetRenderCache( font, resolvedText );
2545
2546 if( cache )
2547 {
2548 m_gal->SetLineWidth( attrs.m_StrokeWidth );
2549 m_gal->DrawGlyphs( *cache );
2550 }
2551 else
2552 {
2553 strokeText( resolvedText, aText->GetTextPos(), attrs, metrics );
2554 }
2555 }
2556
2557 // Draw the umbilical line for texts in footprints
2558 FOOTPRINT* fp_parent = aText->GetParentFootprint();
2559
2560 if( fp_parent && aText->IsSelected() )
2561 {
2562 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2563 m_gal->SetStrokeColor( m_pcbSettings.GetColor( nullptr, LAYER_ANCHOR ) );
2564 m_gal->DrawLine( aText->GetTextPos(), fp_parent->GetPosition() );
2565 }
2566}
2567
2568
2569void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
2570{
2571 if( aTextBox->Type() == PCB_TABLECELL_T )
2572 {
2573 const PCB_TABLECELL* cell = static_cast<const PCB_TABLECELL*>( aTextBox );
2574
2575 if( cell->GetColSpan() == 0 || cell->GetRowSpan() == 0 )
2576 return;
2577 }
2578
2579 COLOR4D color = m_pcbSettings.GetColor( aTextBox, aLayer );
2580 int thickness = getLineThickness( aTextBox->GetWidth() );
2581 LINE_STYLE lineStyle = aTextBox->GetStroke().GetLineStyle();
2582 wxString resolvedText( aTextBox->GetShownText( true ) );
2583 KIFONT::FONT* font = aTextBox->GetDrawFont( &m_pcbSettings );
2584
2585 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
2586 {
2587 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
2588
2589 m_gal->SetIsFill( true );
2590 m_gal->SetIsStroke( false );
2591 m_gal->SetFillColor( sh_color );
2592 m_gal->SetStrokeColor( sh_color );
2593
2594 // Draw the box with a larger thickness than box thickness to show
2595 // the shadow mask
2596 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
2597 int line_thickness = std::max( thickness*3, pcbIUScale.mmToIU( 0.2 ) );
2598
2599 std::deque<VECTOR2D> dpts;
2600
2601 for( const VECTOR2I& pt : pts )
2602 dpts.push_back( VECTOR2D( pt ) );
2603
2604 dpts.push_back( VECTOR2D( pts[0] ) );
2605
2606 m_gal->SetIsStroke( true );
2607 m_gal->SetLineWidth( line_thickness );
2608 m_gal->DrawPolygon( dpts );
2609 }
2610
2611 m_gal->SetFillColor( color );
2612 m_gal->SetStrokeColor( color );
2613 m_gal->SetIsFill( true );
2614 m_gal->SetIsStroke( false );
2615
2616 if( aTextBox->Type() != PCB_TABLECELL_T && aTextBox->IsBorderEnabled() )
2617 {
2618 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
2619 {
2620 if( thickness > 0 )
2621 {
2622 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
2623
2624 for( size_t ii = 0; ii < pts.size(); ++ii )
2625 m_gal->DrawSegment( pts[ii], pts[( ii + 1 ) % pts.size()], thickness );
2626 }
2627 }
2628 else
2629 {
2630 std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
2631
2632 for( SHAPE* shape : shapes )
2633 {
2634 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
2635 [&]( const VECTOR2I& a, const VECTOR2I& b )
2636 {
2637 m_gal->DrawSegment( a, b, thickness );
2638 } );
2639 }
2640
2641 for( SHAPE* shape : shapes )
2642 delete shape;
2643 }
2644 }
2645
2646 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
2647 {
2648 // For now, the textbox is a filled shape.
2649 // so the text drawn on LAYER_LOCKED_ITEM_SHADOW with a thick width is disabled
2650 // If enabled, the thick text position must be offsetted to be exactly on the
2651 // initial text, which is not easy, depending on its rotation and justification.
2652#if 0
2653 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
2654 m_canvas->SetFillColor( sh_color );
2655 m_canvas->SetStrokeColor( sh_color );
2656 attrs.m_StrokeWidth += m_lockedShadowMargin;
2657#else
2658 return;
2659#endif
2660 }
2661
2662 if( aTextBox->IsKnockout() )
2663 {
2664 SHAPE_POLY_SET finalPoly;
2665 aTextBox->TransformTextToPolySet( finalPoly, 0, m_maxError, ERROR_INSIDE );
2666 finalPoly.Fracture();
2667
2668 m_gal->SetIsStroke( false );
2669 m_gal->SetIsFill( true );
2670 m_gal->DrawPolygon( finalPoly );
2671 }
2672 else
2673 {
2674 if( resolvedText.Length() == 0 )
2675 return;
2676
2677 const KIFONT::METRICS& metrics = aTextBox->GetFontMetrics();
2678 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
2680
2681 if( m_gal->IsFlippedX() && !aTextBox->IsSideSpecific() )
2682 {
2683 attrs.m_Mirrored = !attrs.m_Mirrored;
2684 strokeText( resolvedText, aTextBox->GetDrawPos( true ), attrs, metrics );
2685 return;
2686 }
2687
2688 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2689
2690 if( font->IsOutline() )
2691 cache = aTextBox->GetRenderCache( font, resolvedText );
2692
2693 if( cache )
2694 {
2695 m_gal->SetLineWidth( attrs.m_StrokeWidth );
2696 m_gal->DrawGlyphs( *cache );
2697 }
2698 else
2699 {
2700 strokeText( resolvedText, aTextBox->GetDrawPos(), attrs, metrics );
2701 }
2702 }
2703}
2704
2705void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
2706{
2707 if( aTable->GetCells().empty() )
2708 return;
2709
2710 for( PCB_TABLECELL* cell : aTable->GetCells() )
2711 {
2712 if( cell->GetColSpan() > 0 || cell->GetRowSpan() > 0 )
2713 draw( static_cast<PCB_TEXTBOX*>( cell ), aLayer );
2714 }
2715
2716 COLOR4D color = m_pcbSettings.GetColor( aTable, aLayer );
2717
2718 aTable->DrawBorders(
2719 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
2720 {
2721 int lineWidth = getLineThickness( stroke.GetWidth() );
2722 LINE_STYLE lineStyle = stroke.GetLineStyle();
2723
2724 m_gal->SetIsFill( false );
2725 m_gal->SetIsStroke( true );
2726 m_gal->SetStrokeColor( color );
2727 m_gal->SetLineWidth( lineWidth );
2728
2729 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
2730 {
2731 m_gal->DrawLine( ptA, ptB );
2732 }
2733 else
2734 {
2735 SHAPE_SEGMENT seg( ptA, ptB );
2736
2737 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, &m_pcbSettings,
2738 [&]( VECTOR2I a, VECTOR2I b )
2739 {
2740 // DrawLine has problem with 0 length lines so enforce minimum
2741 if( a == b )
2742 m_gal->DrawLine( a+1, b );
2743 else
2744 m_gal->DrawLine( a, b );
2745 } );
2746 }
2747 } );
2748
2749 // Highlight selected tablecells with a background wash.
2750 for( PCB_TABLECELL* cell : aTable->GetCells() )
2751 {
2752 if( aTable->IsSelected() || cell->IsSelected() )
2753 {
2754 std::vector<VECTOR2I> corners = cell->GetCorners();
2755 std::deque<VECTOR2D> pts;
2756
2757 pts.insert( pts.end(), corners.begin(), corners.end() );
2758
2759 m_gal->SetFillColor( color.WithAlpha( 0.5 ) );
2760 m_gal->SetIsFill( true );
2761 m_gal->SetIsStroke( false );
2762 m_gal->DrawPolygon( pts );
2763 }
2764 }
2765}
2766
2767
2768void PCB_PAINTER::draw( const FOOTPRINT* aFootprint, int aLayer )
2769{
2770 if( aLayer == LAYER_ANCHOR )
2771 {
2772 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2773
2774 // Keep the size and width constant, not related to the scale because the anchor
2775 // is just a marker on screen
2776 double anchorSize = 5.0 / m_gal->GetWorldScale(); // 5 pixels size
2777 double anchorThickness = 1.0 / m_gal->GetWorldScale(); // 1 pixels width
2778
2779 // Draw anchor
2780 m_gal->SetIsFill( false );
2781 m_gal->SetIsStroke( true );
2782 m_gal->SetStrokeColor( color );
2783 m_gal->SetLineWidth( anchorThickness );
2784
2785 VECTOR2D center = aFootprint->GetPosition();
2786 m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
2787 m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
2788 }
2789
2790 if( aLayer == LAYER_LOCKED_ITEM_SHADOW && m_frameType == FRAME_PCB_EDITOR ) // happens only if locked
2791 {
2792 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2793
2794 m_gal->SetIsFill( true );
2795 m_gal->SetIsStroke( false );
2796 m_gal->SetFillColor( color );
2797
2798#if 0 // GetBoundingHull() can be very slow, especially for logos imported from graphics
2799 const SHAPE_POLY_SET& poly = aFootprint->GetBoundingHull();
2800 m_canvas->DrawPolygon( poly );
2801#else
2802 BOX2I bbox = aFootprint->GetBoundingBox( false );
2803 VECTOR2I topLeft = bbox.GetPosition();
2804 VECTOR2I botRight = bbox.GetPosition() + bbox.GetSize();
2805
2806 m_gal->DrawRectangle( topLeft, botRight );
2807
2808 // Use segments to produce a margin with rounded corners
2809 m_gal->DrawSegment( topLeft, VECTOR2I( botRight.x, topLeft.y ), m_lockedShadowMargin );
2810 m_gal->DrawSegment( VECTOR2I( botRight.x, topLeft.y ), botRight, m_lockedShadowMargin );
2811 m_gal->DrawSegment( botRight, VECTOR2I( topLeft.x, botRight.y ), m_lockedShadowMargin );
2812 m_gal->DrawSegment( VECTOR2I( topLeft.x, botRight.y ), topLeft, m_lockedShadowMargin );
2813#endif
2814 }
2815
2816 if( aLayer == LAYER_CONFLICTS_SHADOW )
2817 {
2818 const SHAPE_POLY_SET& frontpoly = aFootprint->GetCourtyard( F_CrtYd );
2819 const SHAPE_POLY_SET& backpoly = aFootprint->GetCourtyard( B_CrtYd );
2820
2821 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2822
2823 m_gal->SetIsFill( true );
2824 m_gal->SetIsStroke( false );
2825 m_gal->SetFillColor( color );
2826
2827 if( frontpoly.OutlineCount() > 0 )
2828 m_gal->DrawPolygon( frontpoly );
2829
2830 if( backpoly.OutlineCount() > 0 )
2831 m_gal->DrawPolygon( backpoly );
2832 }
2833}
2834
2835
2836void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
2837{
2838 if( aLayer == LAYER_ANCHOR )
2839 {
2840 if( aGroup->IsSelected() && !( aGroup->GetParent() && aGroup->GetParent()->IsSelected() ) )
2841 {
2842 // Selected on our own; draw enclosing box
2843 }
2844 else if( aGroup->IsEntered() )
2845 {
2846 // Entered group; draw enclosing box
2847 }
2848 else
2849 {
2850 // Neither selected nor entered; draw nothing at the group level (ie: only draw
2851 // its members)
2852 return;
2853 }
2854
2855 const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
2856
2857 m_gal->SetStrokeColor( color );
2858 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth * 2.0f );
2859
2860 BOX2I bbox = aGroup->GetBoundingBox();
2861 VECTOR2I topLeft = bbox.GetPosition();
2862 VECTOR2I width = VECTOR2I( bbox.GetWidth(), 0 );
2863 VECTOR2I height = VECTOR2I( 0, bbox.GetHeight() );
2864
2865 m_gal->DrawLine( topLeft, topLeft + width );
2866 m_gal->DrawLine( topLeft + width, topLeft + width + height );
2867 m_gal->DrawLine( topLeft + width + height, topLeft + height );
2868 m_gal->DrawLine( topLeft + height, topLeft );
2869
2870 wxString name = aGroup->GetName();
2871
2872 if( name.IsEmpty() )
2873 return;
2874
2875 int ptSize = 12;
2876 int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
2877 int unscaledSize = pcbIUScale.MilsToIU( ptSize );
2878
2879 // Scale by zoom a bit, but not too much
2880 int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
2881 VECTOR2I textOffset = KiROUND( width.x / 2.0, -textSize * 0.5 );
2882 VECTOR2I titleHeight = KiROUND( 0.0, textSize * 2.0 );
2883
2884 if( PrintableCharCount( name ) * textSize < bbox.GetWidth() )
2885 {
2886 m_gal->DrawLine( topLeft, topLeft - titleHeight );
2887 m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
2888 m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
2889
2890 TEXT_ATTRIBUTES attrs;
2891 attrs.m_Italic = true;
2894 attrs.m_Size = VECTOR2I( textSize, textSize );
2895 attrs.m_StrokeWidth = GetPenSizeForNormal( textSize );
2896
2897 KIFONT::FONT::GetFont()->Draw( m_gal, aGroup->GetName(), topLeft + textOffset, attrs,
2898 aGroup->GetFontMetrics() );
2899 }
2900 }
2901}
2902
2903
2904void PCB_PAINTER::draw( const ZONE* aZone, int aLayer )
2905{
2906 if( aLayer == LAYER_CONFLICTS_SHADOW )
2907 {
2908 COLOR4D color = m_pcbSettings.GetColor( aZone, aLayer );
2909
2910 m_gal->SetIsFill( true );
2911 m_gal->SetIsStroke( false );
2912 m_gal->SetFillColor( color );
2913
2914 m_gal->DrawPolygon( aZone->Outline()->Outline( 0 ) );
2915 return;
2916 }
2917
2918 /*
2919 * aLayer will be the virtual zone layer (LAYER_ZONE_START, ... in GAL_LAYER_ID)
2920 * This is used for draw ordering in the GAL.
2921 * The color for the zone comes from the associated copper layer ( aLayer - LAYER_ZONE_START )
2922 * and the visibility comes from the combination of that copper layer and LAYER_ZONES
2923 */
2924 PCB_LAYER_ID layer;
2925
2926 if( IsZoneFillLayer( aLayer ) )
2927 layer = ToLAYER_ID( aLayer - LAYER_ZONE_START );
2928 else
2929 layer = ToLAYER_ID( aLayer );
2930
2931 if( !aZone->IsOnLayer( layer ) )
2932 return;
2933
2934 COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
2935 std::deque<VECTOR2D> corners;
2936 ZONE_DISPLAY_MODE displayMode = m_pcbSettings.m_ZoneDisplayMode;
2937
2938 if( aZone->IsTeardropArea() )
2939 displayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
2940
2941 // Draw the outline
2942 if( !IsZoneFillLayer( aLayer ) )
2943 {
2944 const SHAPE_POLY_SET* outline = aZone->Outline();
2945 bool allowDrawOutline = aZone->GetHatchStyle() != ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER;
2946
2947 if( allowDrawOutline && !m_pcbSettings.m_isPrinting && outline && outline->OutlineCount() > 0 )
2948 {
2949 m_gal->SetStrokeColor( color.a > 0.0 ? color.WithAlpha( 1.0 ) : color );
2950 m_gal->SetIsFill( false );
2951 m_gal->SetIsStroke( true );
2952 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
2953
2954 // Draw each contour (main contour and holes)
2955
2956 /*
2957 * m_canvas->DrawPolygon( *outline );
2958 * should be enough, but currently does not work to draw holes contours in a complex
2959 * polygon so each contour is draw as a simple polygon
2960 */
2961
2962 // Draw the main contour(s?)
2963 for( int ii = 0; ii < outline->OutlineCount(); ++ii )
2964 {
2965 m_gal->DrawPolyline( outline->COutline( ii ) );
2966
2967 // Draw holes
2968 int holes_count = outline->HoleCount( ii );
2969
2970 for( int jj = 0; jj < holes_count; ++jj )
2971 m_gal->DrawPolyline( outline->CHole( ii, jj ) );
2972 }
2973
2974 // Draw hatch lines
2975 for( const SEG& hatchLine : aZone->GetHatchLines() )
2976 m_gal->DrawLine( hatchLine.A, hatchLine.B );
2977 }
2978 }
2979
2980 // Draw the filling
2981 if( IsZoneFillLayer( aLayer )
2982 && ( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED
2984 || displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) )
2985 {
2986 const std::shared_ptr<SHAPE_POLY_SET>& polySet = aZone->GetFilledPolysList( layer );
2987
2988 if( polySet->OutlineCount() == 0 ) // Nothing to draw
2989 return;
2990
2991 m_gal->SetStrokeColor( color );
2992 m_gal->SetFillColor( color );
2993 m_gal->SetLineWidth( 0 );
2994
2995 if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
2996 {
2997 m_gal->SetIsFill( true );
2998 m_gal->SetIsStroke( false );
2999 }
3000 else
3001 {
3002 m_gal->SetIsFill( false );
3003 m_gal->SetIsStroke( true );
3004 }
3005
3006 // On Opengl, a not convex filled polygon is usually drawn by using triangles
3007 // as primitives. CacheTriangulation() can create basic triangle primitives to
3008 // draw the polygon solid shape on Opengl. GLU tessellation is much slower,
3009 // so currently we are using our tessellation.
3010 if( m_gal->IsOpenGlEngine() && !polySet->IsTriangulationUpToDate() )
3011 polySet->CacheTriangulation( true );
3012
3013 m_gal->DrawPolygon( *polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION );
3014 }
3015}
3016
3017
3018void PCB_PAINTER::draw( const PCB_BARCODE* aBarcode, int aLayer )
3019{
3020 const COLOR4D& color = m_pcbSettings.GetColor( aBarcode, aLayer );
3021
3022 m_gal->SetIsFill( true );
3023 m_gal->SetIsStroke( false );
3024 m_gal->SetFillColor( color );
3025
3026 // Draw the barcode
3027 SHAPE_POLY_SET shape;
3028
3029 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
3030 aBarcode->GetBoundingHull( shape, aBarcode->GetLayer(), m_lockedShadowMargin, m_maxError, ERROR_INSIDE );
3031 else
3032 aBarcode->TransformShapeToPolySet( shape, aBarcode->GetLayer(), 0, m_maxError, ERROR_INSIDE );
3033
3034 if( shape.OutlineCount() != 0 )
3035 m_gal->DrawPolygon( shape );
3036}
3037
3038
3039void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
3040{
3041 const COLOR4D& color = m_pcbSettings.GetColor( aDimension, aLayer );
3042
3043 m_gal->SetStrokeColor( color );
3044 m_gal->SetFillColor( color );
3045 m_gal->SetIsFill( false );
3046 m_gal->SetIsStroke( true );
3047
3049
3050 if( outline_mode )
3051 m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
3052 else
3053 m_gal->SetLineWidth( getLineThickness( aDimension->GetLineThickness() ) );
3054
3055 // Draw dimension shapes
3056 // TODO(JE) lift this out
3057 for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
3058 {
3059 switch( shape->Type() )
3060 {
3061 case SH_SEGMENT:
3062 {
3063 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
3064 m_gal->DrawLine( seg.A, seg.B );
3065 break;
3066 }
3067
3068 case SH_CIRCLE:
3069 {
3070 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
3071 m_gal->DrawCircle( shape->Centre(), radius );
3072 break;
3073 }
3074
3075 default:
3076 break;
3077 }
3078 }
3079
3080 // Draw text
3081 wxString resolvedText = aDimension->GetShownText( true );
3082 TEXT_ATTRIBUTES attrs = aDimension->GetAttributes();
3083
3084 if( m_gal->IsFlippedX() && !aDimension->IsSideSpecific() )
3085 attrs.m_Mirrored = !attrs.m_Mirrored;
3086
3087 if( outline_mode )
3088 attrs.m_StrokeWidth = m_pcbSettings.m_outlineWidth;
3089 else
3091
3092 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
3093
3094 if( aDimension->GetFont() && aDimension->GetFont()->IsOutline() )
3095 cache = aDimension->GetRenderCache( aDimension->GetFont(), resolvedText );
3096
3097 if( cache )
3098 {
3099 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
3100 m_gal->DrawGlyph( *glyph.get() );
3101 }
3102 else
3103 {
3104 strokeText( resolvedText, aDimension->GetTextPos(), attrs, aDimension->GetFontMetrics() );
3105 }
3106}
3107
3108
3109void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
3110{
3111 const COLOR4D strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
3112 VECTOR2D position( aTarget->GetPosition() );
3113 double size, radius;
3114
3115 m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
3116 m_gal->SetStrokeColor( strokeColor );
3117 m_gal->SetIsFill( false );
3118 m_gal->SetIsStroke( true );
3119
3120 m_gal->Save();
3121 m_gal->Translate( position );
3122
3123 if( aTarget->GetShape() )
3124 {
3125 // shape x
3126 m_gal->Rotate( M_PI / 4.0 );
3127 size = 2.0 * aTarget->GetSize() / 3.0;
3128 radius = aTarget->GetSize() / 2.0;
3129 }
3130 else
3131 {
3132 // shape +
3133 size = aTarget->GetSize() / 2.0;
3134 radius = aTarget->GetSize() / 3.0;
3135 }
3136
3137 m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
3138 m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
3139 m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
3140
3141 m_gal->Restore();
3142}
3143
3144
3145void PCB_PAINTER::draw( const PCB_POINT* aPoint, int aLayer )
3146{
3147 // aLayer will be the virtual point layer (LAYER_POINT_START, ... in GAL_LAYER_ID).
3148 // This is used for draw ordering in the GAL.
3149 // The cross color comes from LAYER_POINTS and the ring color follows the point's board layer.
3150 // Visibility comes from the combination of that board layer and LAYER_POINTS.
3151
3152 double size = (double)aPoint->GetSize() / 2;
3153
3154 // Keep the width constant, not related to the scale because the anchor
3155 // is just a marker on screen, just draw in pixels
3156 double thickness = m_pcbSettings.m_outlineWidth;
3157
3158 // The general "points" colour
3159 COLOR4D crossColor = m_pcbSettings.GetColor( aPoint, LAYER_POINTS );
3160 // The colour for the ring around the point follows the "real" layer of the point
3161 COLOR4D ringColor = m_pcbSettings.GetColor( aPoint, aPoint->GetLayer() );
3162
3163 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
3164 {
3165 thickness += m_lockedShadowMargin;
3166 crossColor = m_pcbSettings.GetColor( aPoint, aLayer );
3167 ringColor = m_pcbSettings.GetColor( aPoint, aLayer );
3168 }
3169
3170 VECTOR2D position( aPoint->GetPosition() );
3171
3172 m_gal->SetLineWidth( thickness );
3173 m_gal->SetStrokeColor( crossColor );
3174 m_gal->SetIsFill( false );
3175 m_gal->SetIsStroke( true );
3176
3177 m_gal->Save();
3178 m_gal->Translate( position );
3179
3180 // Draw as X to make it clearer when overlaid on cursor or axes
3181 m_gal->DrawLine( VECTOR2D( -size, -size ), VECTOR2D( size, size ) );
3182 m_gal->DrawLine( VECTOR2D( size, -size ), VECTOR2D( -size, size ) );
3183
3184 // Draw the circle in the layer colour
3185 m_gal->SetStrokeColor( ringColor );
3186 m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size / 2 );
3187
3188 m_gal->Restore();
3189}
3190
3191
3192void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer )
3193{
3194 // Don't paint invisible markers.
3195 // It would be nice to do this through layer dependencies but we can't do an "or" there today
3196 if( aMarker->GetBoard() && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
3197 return;
3198
3199 COLOR4D color = m_pcbSettings.GetColor( aMarker, aMarker->GetColorLayer() );
3200
3201 aMarker->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) );
3202
3203 switch( aLayer )
3204 {
3206 case LAYER_DRC_ERROR:
3207 case LAYER_DRC_WARNING:
3209 {
3210 bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
3211
3212 SHAPE_LINE_CHAIN polygon;
3213 aMarker->ShapeToPolygon( polygon );
3214
3215 m_gal->Save();
3216 m_gal->Translate( aMarker->GetPosition() );
3217
3218 if( isShadow )
3219 {
3220 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aMarker, LAYER_MARKER_SHADOWS ) );
3221 m_gal->SetIsStroke( true );
3222 m_gal->SetLineWidth( (float) aMarker->MarkerScale() );
3223 }
3224 else
3225 {
3226 m_gal->SetFillColor( color );
3227 m_gal->SetIsFill( true );
3228 }
3229
3230 m_gal->DrawPolygon( polygon );
3231 m_gal->Restore();
3232 break;
3233 }
3234
3235 case LAYER_DRC_SHAPES:
3236 if( !aMarker->IsBrightened() )
3237 return;
3238
3239 for( const PCB_SHAPE& shape : aMarker->GetShapes() )
3240 {
3241 if( shape.GetStroke().GetWidth() == 1.0 )
3242 {
3243 m_gal->SetIsFill( false );
3244 m_gal->SetIsStroke( true );
3245 m_gal->SetStrokeColor( color );
3246 m_gal->SetLineWidth( KiROUND( aMarker->MarkerScale() / 2.0 ) );
3247
3248 if( shape.GetShape() == SHAPE_T::SEGMENT )
3249 {
3250 m_gal->DrawLine( shape.GetStart(), shape.GetEnd() );
3251 }
3252 else if( shape.GetShape() == SHAPE_T::ARC )
3253 {
3254 EDA_ANGLE startAngle, endAngle;
3255 shape.CalcArcAngles( startAngle, endAngle );
3256
3257 m_gal->DrawArc( shape.GetCenter(), shape.GetRadius(), startAngle, shape.GetArcAngle() );
3258 }
3259 }
3260 else
3261 {
3262 m_gal->SetIsFill( true );
3263 m_gal->SetIsStroke( false );
3264 m_gal->SetFillColor( color.WithAlpha( 0.5 ) );
3265
3266 if( shape.GetShape() == SHAPE_T::SEGMENT )
3267 {
3268 m_gal->DrawSegment( shape.GetStart(), shape.GetEnd(), shape.GetWidth() );
3269 }
3270 else if( shape.GetShape() == SHAPE_T::ARC )
3271 {
3272 EDA_ANGLE startAngle, endAngle;
3273 shape.CalcArcAngles( startAngle, endAngle );
3274
3275 m_gal->DrawArcSegment( shape.GetCenter(), shape.GetRadius(), startAngle, shape.GetArcAngle(),
3276 shape.GetWidth(), ARC_HIGH_DEF );
3277 }
3278 }
3279 }
3280
3281 break;
3282 }
3283}
3284
3285
3286void PCB_PAINTER::draw( const PCB_BOARD_OUTLINE* aBoardOutline, int aLayer )
3287{
3288 if( !aBoardOutline->HasOutline() )
3289 return;
3290
3291 // aBoardOutline makes sense only for the board editor. for fp holder boards
3292 // there are no board outlines area.
3293 const BOARD* brd = aBoardOutline->GetBoard();
3294
3295 if( !brd || brd->GetBoardUse() == BOARD_USE::FPHOLDER )
3296 return;
3297
3299 m_gal->Save();
3300
3301 const COLOR4D& outlineColor = m_pcbSettings.GetColor( aBoardOutline, aLayer );
3302 m_gal->SetFillColor( outlineColor );
3303 m_gal->AdvanceDepth();
3304 m_gal->SetLineWidth( 0 );
3305 m_gal->SetIsFill( true );
3306 m_gal->SetIsStroke( false );
3307 m_gal->DrawPolygon( aBoardOutline->GetOutline() );
3308
3309 m_gal->Restore();
3310}
3311
3312
3314 int aDrillSize, PCB_LAYER_ID aStartLayer,
3315 PCB_LAYER_ID aEndLayer )
3316{
3317 double backdrillRadius = aDrillSize / 2.0;
3318 double lineWidth = std::max( backdrillRadius / 4.0, m_pcbSettings.m_outlineWidth * 2.0 );
3319
3321 m_gal->AdvanceDepth();
3322 m_gal->SetIsFill( false );
3323 m_gal->SetIsStroke( true );
3324 m_gal->SetLineWidth( lineWidth );
3325
3326 // Draw semi-circle in start layer color (top half, from 90° to 270°)
3327 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aItem, aStartLayer ) );
3328 m_gal->DrawArc( aCenter, backdrillRadius, EDA_ANGLE( 90, DEGREES_T ),
3329 EDA_ANGLE( 180, DEGREES_T ) );
3330
3331 // Draw semi-circle in end layer color (bottom half, from 270° to 90°)
3332 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aItem, aEndLayer ) );
3333 m_gal->DrawArc( aCenter, backdrillRadius, EDA_ANGLE( 270, DEGREES_T ),
3334 EDA_ANGLE( 180, DEGREES_T ) );
3335}
3336
3337
3339{
3340 int size = 0;
3341
3342 // Check to see if the pad or via has a post-machining operation on this layer
3343 if( const PAD* pad = dynamic_cast<const PAD*>( aItem ) )
3344 {
3345 size = pad->GetPostMachiningKnockout( aLayer );
3346 }
3347 else if( const PCB_VIA* via = dynamic_cast<const PCB_VIA*>( aItem ) )
3348 {
3349 size = via->GetPostMachiningKnockout( aLayer );
3350 }
3351
3352 if( size <= 0 )
3353 return;
3354
3356 m_gal->AdvanceDepth();
3357
3358 double pmRadius = size / 2.0;
3359 // Use a line width proportional to the radius for visibility
3360 double lineWidth = std::max( pmRadius / 8.0, m_pcbSettings.m_outlineWidth * 2.0 );
3361
3362 COLOR4D layerColor = m_pcbSettings.GetColor( aItem, aLayer );
3363
3364 m_gal->SetIsFill( false );
3365 m_gal->SetIsStroke( true );
3366 m_gal->SetStrokeColor( layerColor );
3367 m_gal->SetLineWidth( lineWidth );
3368
3369 // Draw dashed circle manually with fixed number of segments for consistent appearance
3370 constexpr int NUM_DASHES = 12; // Number of dashes around the circle
3371 EDA_ANGLE dashAngle = ANGLE_360 / ( NUM_DASHES * 2 ); // Dash and gap are equal size
3372
3373 for( int i = 0; i < NUM_DASHES; ++i )
3374 {
3375 EDA_ANGLE startAngle = dashAngle * ( i * 2 );
3376 m_gal->DrawArc( aCenter, pmRadius, startAngle, dashAngle );
3377 }
3378}
3379
3380
3381const 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:128
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ FPHOLDER
Definition board.h:315
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
@ ALL
Net/netclass colors are shown on all net copper.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
BOX2< VECTOR2D > BOX2D
Definition box2.h:923
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.
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.
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.
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:84
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:268
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:158
virtual bool IsKnockout() const
Definition board_item.h:355
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:288
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:461
const KIFONT::METRICS & GetFontMetrics() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:234
bool IsSideSpecific() const
virtual bool IsOnCopperLayer() const
Definition board_item.h:175
int GetMaxError() const
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition board.h:342
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:1042
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:990
int GetCopperLayerCount() const
Definition board.cpp:928
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1091
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:976
constexpr const Vec & GetPosition() const
Definition box2.h:211
constexpr const Vec GetEnd() const
Definition box2.h:212
constexpr void SetOrigin(const Vec &pos)
Definition box2.h:237
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:146
constexpr size_type GetWidth() const
Definition box2.h:214
constexpr Vec Centre() const
Definition box2.h:97
constexpr size_type GetHeight() const
Definition box2.h:215
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:168
constexpr const Vec & GetOrigin() const
Definition box2.h:210
constexpr const SizeVec & GetSize() const
Definition box2.h:206
constexpr void SetEnd(coord_type x, coord_type y)
Definition box2.h:297
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
EDA_ANGLE Normalize90()
Definition eda_angle.h:257
wxString GetName() const
Definition eda_group.h:51
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition eda_item.cpp:120
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
bool IsEntered() const
Definition eda_item.h:130
bool IsSelected() const
Definition eda_item.h:129
bool IsBrightened() const
Definition eda_item.h:131
bool IsMoving() const
Definition eda_item.h:127
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:271
virtual VECTOR2I GetTopLeft() const
Definition eda_shape.h:259
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:390
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:181
virtual VECTOR2I GetBotRight() const
Definition eda_shape.h:260
const std::vector< SEG > & GetHatchLines() const
bool IsHatchedFill() const
Definition eda_shape.h:136
virtual int GetHatchLineWidth() const
Definition eda_shape.h:171
bool IsSolidFill() const
Definition eda_shape.h:129
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:228
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:186
std::vector< VECTOR2I > GetRectCorners() const
bool IsAnyFill() const
Definition eda_shape.h:124
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition eda_shape.h:333
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:268
int GetRectangleHeight() const
int GetCornerRadius() const
const VECTOR2I & GetTextPos() const
Definition eda_text.h:284
virtual bool IsVisible() const
Definition eda_text.h:198
KIFONT::FONT * GetFont() const
Definition eda_text.h:258
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:670
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:739
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:211
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition eda_text.cpp:634
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:242
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:449
LSET GetPrivateLayers() const
Definition footprint.h:266
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
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:347
DRAWINGS & GraphicalItems()
Definition footprint.h:329
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:95
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:98
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:147
virtual bool IsStroke() const
Definition font.h:105
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:250
virtual bool IsOutline() const
Definition font.h:106
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition color4d.h:312
static const COLOR4D CLEAR
Definition color4d.h:407
COLOR4D & Darken(double aFactor)
Makes the color darker by a given factor.
Definition color4d.h:227
COLOR4D Darkened(double aFactor) const
Return a color that is darker by a given factor, without modifying object.
Definition color4d.h:283
COLOR4D Inverted() const
Returns an inverted color, alpha remains the same.
Definition color4d.h:324
COLOR4D & Brighten(double aFactor)
Makes the color brighter by a given factor.
Definition color4d.h:210
static const COLOR4D WHITE
Definition color4d.h:405
double a
Alpha component.
Definition color4d.h:396
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition color4d.h:269
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:402
static const COLOR4D BLACK
Definition color4d.h:406
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:296
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:102
PAINTER(GAL *aGal)
Initialize this object for painting on any of the polymorphic GRAPHICS_ABSTRACTION_LAYER* derivatives...
Definition painter.cpp:33
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).
PCB_PAINTER(GAL *aGal, FRAME_T aFrameType)
int getLineThickness(int aActualThickness) const
Get the thickness to draw for a line (e.g.
void renderNetNameForSegment(const SHAPE_SEGMENT &aSeg, const COLOR4D &aColor, const wxString &aNetName) const
PCB_VIEWERS_SETTINGS_BASE * viewer_settings()
void draw(const PCB_TRACK *aTrack, int aLayer)
virtual PAD_DRILL_SHAPE getDrillShape(const PAD *aPad) const
Return drill shape of a pad.
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)
void drawBackdrillIndicator(const BOARD_ITEM *aItem, const VECTOR2D &aCenter, int aDrillSize, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer)
Draw backdrill indicator (two semi-circles) at the given center point.
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.
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
Set of net codes that should not have their ratsnest displayed.
NET_COLOR_MODE m_netColorMode
Overrides for specific netclass colors.
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 GetShowPageLimits() const override
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Load settings related to display options (high-contrast mode, full or outline modes for vias/pads/tra...
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
void SetGapLengthRatio(double aRatio)
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:86
bool IsBOARD_ITEM() const
Definition view_item.h:102
double GetForcedTransparency() const
Definition view_item.h:171
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:608
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
Definition lset.cpp:542
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:313
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:599
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition lset.cpp:697
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition marker_base.h:69
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:42
COLOR4D GetPcbColor(bool aIsForSave=false) const
Definition netclass.h:186
bool HasPcbColor() const
Definition netclass.h:185
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition netinfo.h:228
@ NORMAL
Shape is the same on all layers.
Definition padstack.h:171
Definition pad.h:55
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1654
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition pad.h:560
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:377
int GetSizeX() const
Definition pad.h:285
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:439
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition pad.cpp:962
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1354
PAD_ATTRIB GetAttribute() const
Definition pad.h:563
const wxString & GetPinFunction() const
Definition pad.h:148
const wxString & GetNumber() const
Definition pad.h:137
VECTOR2I GetPosition() const override
Definition pad.h:209
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pad.h:545
PCB_LAYER_ID GetTertiaryDrillStartLayer() const
Definition pad.h:543
bool IsNoConnectPad() const
Definition pad.cpp:356
int GetDrillSizeX() const
Definition pad.h:319
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:196
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:2572
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1661
const VECTOR2I & GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.h:329
bool IsFreePad() const
Definition pad.cpp:362
const VECTOR2I & GetSecondaryDrillSize() const
Definition pad.h:514
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.h:420
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:437
int GetSizeY() const
Definition pad.h:296
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
Definition pad.cpp:662
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:1724
PCB_LAYER_ID GetSecondaryDrillStartLayer() const
Definition pad.h:526
const VECTOR2I & GetTertiaryDrillSize() const
Definition pad.h:531
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1558
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition pad.cpp:1066
PCB_LAYER_ID GetSecondaryDrillEndLayer() const
Definition pad.h:528
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
Definition pad.h:264
DISPLAY_OPTIONS m_Display
EDA_ANGLE GetArcAngleStart() const
const VECTOR2I GetFocusPosition() const override
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition pcb_track.h:295
double GetRadius() const
EDA_ANGLE GetAngle() const
const VECTOR2I & GetMid() const
Definition pcb_track.h:290
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_track.h:297
void GetBoundingHull(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
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_ImageOpacity
Opacity override for user images.
double m_PadOpacity
Opacity override for SMD pads and PTHs.
double m_ViaOpacity
Opacity override for all types of via.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
NET_COLOR_MODE m_NetColorMode
How to use color overrides on specific nets and netclasses.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:53
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 > GetShapes() const
GAL_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
Definition pcb_marker.h:64
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:43
int GetSize() const
Definition pcb_point.h:67
VECTOR2I GetPosition() const override
Definition pcb_point.h:64
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:81
int GetWidth() const override
bool HasSolderMask() const
Definition pcb_shape.h:207
int GetSolderMaskExpansion() const
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
bool IsProxyItem() const override
Definition pcb_shape.h:116
STROKE_PARAMS GetStroke() const override
Definition pcb_shape.h:91
void UpdateHatching() const override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pcb_shape.h:71
int GetRowSpan() const
int GetColSpan() const
std::vector< PCB_TABLECELL * > GetCells() const
Definition pcb_table.h:159
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:58
int GetWidth() const
Definition pcb_target.h:64
int GetSize() const
Definition pcb_target.h:61
VECTOR2I GetPosition() const override
Definition pcb_target.h:55
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
VECTOR2I GetDrawPos() const override
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition pcb_text.cpp:674
const SHAPE_POLY_SET & GetKnockoutCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, int aMaxError) const
Definition pcb_text.cpp:548
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition pcb_text.cpp:162
EDA_ANGLE GetDrawRotation() const override
Definition pcb_text.cpp:204
int GetSolderMaskExpansion() const
const VECTOR2I & GetStart() const
Definition pcb_track.h:97
const VECTOR2I & GetEnd() const
Definition pcb_track.h:94
virtual int GetWidth() const
Definition pcb_track.h:91
PCB_LAYER_ID BottomLayer() const
PCB_LAYER_ID GetTertiaryDrillEndLayer() const
Definition pcb_track.h:798
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:784
int GetWidth() const override
PCB_LAYER_ID GetTertiaryDrillStartLayer() const
Definition pcb_track.h:795
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:398
PCB_LAYER_ID GetSecondaryDrillStartLayer() const
Definition pcb_track.h:781
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:541
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:130
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
VECTOR2I GetPosition() 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:36
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aMaxError) const
Get the polygonal representation of the roundrect.
Definition roundrect.cpp:83
Definition seg.h:42
VECTOR2I A
Definition seg.h:49
VECTOR2I::extended_type ecoord
Definition seg.h:44
VECTOR2I B
Definition seg.h:50
int Length() const
Return the length (this).
Definition seg.h:343
ecoord SquaredLength() const
Definition seg.h:348
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
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
bool IsTriangulationUpToDate() const
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)
virtual void CacheTriangulation(bool aSimplify=false, const TASK_SUBMITTER &aSubmitter={})
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
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:185
const VECTOR2I & GetPosition() const
Definition shape_rect.h:169
const VECTOR2I GetSize() const
Definition shape_rect.h:177
int GetHeight() const
Definition shape_rect.h:193
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:126
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)
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
Definition vector2d.h:385
Handle a list of polygons defining a copper zone.
Definition zone.h:74
const std::vector< SEG > & GetHatchLines() const
Definition zone.h:782
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition zone.h:602
SHAPE_POLY_SET * Outline()
Definition zone.h:336
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition zone.cpp:644
bool IsTeardropArea() const
Definition zone.h:691
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition zone.h:590
@ MAGENTA
Definition color4d.h:60
@ CYAN
Definition color4d.h:58
void TransformArcToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
@ ROUND_ALL_CORNERS
All angles are rounded.
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
@ DEGREES_T
Definition eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:408
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:407
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:417
#define IGNORE_PARENT_GROUP
Definition eda_item.h:57
@ UNDEFINED
Definition eda_shape.h:46
@ SEGMENT
Definition eda_shape.h:47
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:48
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
@ FRAME_PCB_EDITOR
Definition frame_type.h:42
@ FRAME_CVPCB_DISPLAY
Definition frame_type.h:53
@ FRAME_FOOTPRINT_VIEWER
Definition frame_type.h:45
@ FRAME_FOOTPRINT_WIZARD
Definition frame_type.h:46
@ FRAME_FOOTPRINT_PREVIEW
Definition frame_type.h:48
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:44
@ FRAME_FOOTPRINT_EDITOR
Definition frame_type.h:43
@ FRAME_PCB_DISPLAY3D
Definition frame_type.h:47
@ FRAME_CVPCB
Definition frame_type.h:52
a few functions useful in geometry calculations.
int GetPenSizeForNormal(int aTextSize)
Definition gr_text.cpp:61
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:750
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer).
Definition layer_ids.h:200
@ LAYER_PAD_BK_NETNAMES
Definition layer_ids.h:201
@ LAYER_PAD_NETNAMES
Definition layer_ids.h:202
@ NETNAMES_LAYER_ID_START
Definition layer_ids.h:194
bool IsPcbLayer(int aLayer)
Test whether a layer is a valid layer for Pcbnew.
Definition layer_ids.h:668
bool IsPadCopperLayer(int aLayer)
Definition layer_ids.h:883
bool IsPointsLayer(int aLayer)
Definition layer_ids.h:901
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition layer_ids.h:856
bool IsClearanceLayer(int aLayer)
Definition layer_ids.h:895
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:679
@ LAYER_POINTS
PCB reference/manual snap points visibility.
Definition layer_ids.h:321
@ GAL_LAYER_ID_START
Definition layer_ids.h:229
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:307
@ LAYER_PAD_COPPER_START
Virtual layers for pad copper on a given copper layer.
Definition layer_ids.h:339
@ LAYER_VIA_HOLEWALLS
Definition layer_ids.h:298
@ LAYER_CONFLICTS_SHADOW
Shadow layer for items flagged conflicting.
Definition layer_ids.h:310
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
Definition layer_ids.h:239
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
Definition layer_ids.h:304
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:281
@ LAYER_DRC_HIGHLIGHTED
Color for highlighted DRC markers.
Definition layer_ids.h:332
@ LAYER_DRC_SHAPES
Custom shapes for DRC markers.
Definition layer_ids.h:315
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
Definition layer_ids.h:292
@ LAYER_DRC_WARNING
Layer for DRC markers with #SEVERITY_WARNING.
Definition layer_ids.h:301
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition layer_ids.h:271
@ GAL_LAYER_ID_END
Definition layer_ids.h:362
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
Definition layer_ids.h:343
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
Definition layer_ids.h:347
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
Definition layer_ids.h:335
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition layer_ids.h:248
@ LAYER_VIA_BURIED
Draw blind vias.
Definition layer_ids.h:235
@ LAYER_MARKER_SHADOWS
Shadows for DRC markers.
Definition layer_ids.h:305
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
Definition layer_ids.h:274
@ LAYER_VIA_BLIND
Draw micro vias.
Definition layer_ids.h:234
@ LAYER_VIA_MICROVIA
Definition layer_ids.h:233
@ LAYER_VIA_THROUGH
Draw buried vias.
Definition layer_ids.h:236
@ LAYER_DRC_ERROR
Layer for DRC markers with #SEVERITY_ERROR.
Definition layer_ids.h:277
@ LAYER_PAD_HOLEWALLS
Definition layer_ids.h:297
bool IsViaCopperLayer(int aLayer)
Definition layer_ids.h:889
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition layer_ids.h:871
bool IsHoleLayer(int aLayer)
Definition layer_ids.h:741
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition layer_ids.h:690
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ F_CrtYd
Definition layer_ids.h:116
@ Edge_Cuts
Definition layer_ids.h:112
@ F_Paste
Definition layer_ids.h:104
@ B_Mask
Definition layer_ids.h:98
@ B_Cu
Definition layer_ids.h:65
@ F_Mask
Definition layer_ids.h:97
@ B_Paste
Definition layer_ids.h:105
@ F_SilkS
Definition layer_ids.h:100
@ B_CrtYd
Definition layer_ids.h:115
@ UNDEFINED_LAYER
Definition layer_ids.h:61
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:171
@ F_Cu
Definition layer_ids.h:64
bool IsZoneFillLayer(int aLayer)
Definition layer_ids.h:877
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition lset.cpp:754
MATRIX3x3< double > MATRIX3x3D
Definition matrix3x3.h:473
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:69
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:103
@ PTH
Plated through hole pad.
Definition padstack.h:98
@ ROUNDRECT
Definition padstack.h:57
BARCODE class definition.
Class to handle a set of BOARD_ITEMs.
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:47
@ SH_CIRCLE
circle
Definition shape.h:50
@ SH_SIMPLE
simple polygon
Definition shape.h:51
@ SH_SEGMENT
line segment
Definition shape.h:48
wxString UnescapeString(const wxString &aSource)
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
LINE_STYLE
Dashed line types.
nlohmann::json output
VECTOR2I center
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:229
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:85
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:103
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:100
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:101
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:90
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:105
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:89
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:86
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:87
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:96
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:98
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:104
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:92
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:83
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:99
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:84
@ PCB_BOARD_OUTLINE_T
class PCB_BOARD_OUTLINE_T, a pcb board outline item
Definition typeinfo.h:109
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:95
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:91
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:110
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:93
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:102
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
VECTOR2< double > VECTOR2D
Definition vector2d.h:686