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 (C) 2021-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
8 * @author Maciej Suminski <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
28#include <board.h>
30#include <pcb_track.h>
31#include <pcb_group.h>
32#include <footprint.h>
33#include <pad.h>
34#include <pcb_shape.h>
35#include <string_utils.h>
36#include <zone.h>
37#include <pcb_reference_image.h>
38#include <pcb_text.h>
39#include <pcb_textbox.h>
40#include <pcb_table.h>
41#include <pcb_tablecell.h>
42#include <pcb_marker.h>
43#include <pcb_dimension.h>
44#include <pcb_target.h>
45
46#include <layer_ids.h>
47#include <lset.h>
48#include <pcb_painter.h>
49#include <pcb_display_options.h>
55#include <pcbnew_settings.h>
57
60#include <callback_gal.h>
63#include <geometry/shape_rect.h>
67#include <bezier_curves.h>
68#include <kiface_base.h>
69#include <gr_text.h>
70#include <pgm_base.h>
71
72using namespace KIGFX;
73
74
76{
77 return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
78}
79
80// Helpers for display options existing in Cvpcb and Pcbnew
81// Note, when running Cvpcb, pcbconfig() returns nullptr and viewer_settings()
82// returns the viewer options existing to Cvpcb and Pcbnew
84{
85 switch( m_frameType )
86 {
89 default:
91
95
99 case FRAME_CVPCB:
102 }
103}
104
105
107{
108 m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
109 m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
110 m_netColorMode = NET_COLOR_MODE::RATSNEST;
111 m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
112
113 m_trackOpacity = 1.0;
114 m_viaOpacity = 1.0;
115 m_padOpacity = 1.0;
116 m_zoneOpacity = 1.0;
117 m_imageOpacity = 1.0;
119
121
122 m_PadEditModePad = nullptr;
123
124 SetDashLengthRatio( 12 ); // From ISO 128-2
125 SetGapLengthRatio( 3 ); // From ISO 128-2
126
128
129 update();
130}
131
132
134{
136
137 // Init board layers colors:
138 for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
139 {
140 m_layerColors[i] = aSettings->GetColor( i );
141
142 // Guard: if the alpha channel is too small, the layer is not visible.
143 if( m_layerColors[i].a < 0.2 )
144 m_layerColors[i].a = 0.2;
145 }
146
147 // Init specific graphic layers colors:
148 for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
149 m_layerColors[i] = aSettings->GetColor( i );
150
151 // Colors for layers that aren't theme-able
154
155 // Netnames for copper layers
156 const COLOR4D lightLabel = aSettings->GetColor( NETNAMES_LAYER_ID_START );
157 const COLOR4D darkLabel = lightLabel.Inverted();
158
159 for( PCB_LAYER_ID layer : LSET::AllCuMask().CuStack() )
160 {
161 if( m_layerColors[layer].GetBrightness() > 0.5 )
162 m_layerColors[GetNetnameLayer( layer )] = darkLabel;
163 else
164 m_layerColors[GetNetnameLayer( layer )] = lightLabel;
165 }
166
167 if( PgmOrNull() ) // can be null if used without project (i.e. from python script)
169 else
170 m_hiContrastFactor = 1.0f - 0.8f; // default value
171
172 update();
173}
174
175
177{
178 m_hiContrastEnabled = aOptions.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
182
184 m_viaOpacity = aOptions.m_ViaOpacity;
185 m_padOpacity = aOptions.m_PadOpacity;
186 m_zoneOpacity = aOptions.m_ZoneOpacity;
189}
190
191
192COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
193{
194 return GetColor( dynamic_cast<const BOARD_ITEM*>( aItem ), aLayer );
195}
196
197
198COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) const
199{
200 int netCode = -1;
201 int originalLayer = aLayer;
202
203 // Marker shadows
204 if( aLayer == LAYER_MARKER_SHADOWS )
205 return m_backgroundColor.WithAlpha( 0.6 );
206
207 // SMD pads use the copper netname layer
208 if( aLayer == LAYER_PAD_FR_NETNAMES )
209 aLayer = GetNetnameLayer( F_Cu );
210 else if( aLayer == LAYER_PAD_BK_NETNAMES )
211 aLayer = GetNetnameLayer( B_Cu );
212
213 if( IsHoleLayer( aLayer ) && m_isPrinting )
214 {
215 // Careful that we don't end up with the same colour for the annular ring and the hole
216 // when printing in B&W.
217 const PAD* pad = dynamic_cast<const PAD*>( aItem );
218 const PCB_VIA* via = dynamic_cast<const PCB_VIA*>( aItem );
219 int holeLayer = aLayer;
220 int annularRingLayer = UNDEFINED_LAYER;
221
222 // TODO(JE) padstacks -- this won't work, we don't know what the annular ring layer is
223 // Inserting F_Cu here for now.
224 if( pad && pad->GetAttribute() == PAD_ATTRIB::PTH )
225 annularRingLayer = F_Cu;
226 else if( via )
227 annularRingLayer = F_Cu;
228
229 if( annularRingLayer != UNDEFINED_LAYER )
230 {
231 auto it = m_layerColors.find( holeLayer );
232 auto it2 = m_layerColors.find( annularRingLayer );
233
234 if( it != m_layerColors.end() && it2 != m_layerColors.end() && it->second == it2->second )
235 aLayer = LAYER_PCB_BACKGROUND;
236 }
237 }
238
239 // Zones should pull from the copper layer
240 if( aItem && aItem->Type() == PCB_ZONE_T )
241 {
242 if( IsZoneFillLayer( aLayer ) )
243 aLayer = aLayer - LAYER_ZONE_START;
244 }
245
246 // Hole walls should pull from the via hole layer since it does not vary with active copper
247 // layer. For simplicity of configuration, pad hole walls can use the via color.
248 else if( aLayer == LAYER_VIA_HOLEWALLS || aLayer == LAYER_PAD_HOLEWALLS )
249 aLayer = LAYER_VIA_HOLES;
250
251 // Show via mask layers if appropriate
252 if( aLayer == LAYER_VIA_THROUGH && !m_isPrinting )
253 {
254 if( aItem && aItem->GetBoard() )
255 {
256 LSET visibleLayers = aItem->GetBoard()->GetVisibleLayers()
257 & aItem->GetBoard()->GetEnabledLayers()
258 & aItem->GetLayerSet();
259
260 if( GetActiveLayer() == F_Mask && visibleLayers.test( F_Mask ) )
261 aLayer = F_Mask;
262 else if( GetActiveLayer() == B_Mask && visibleLayers.test( B_Mask ) )
263 aLayer = B_Mask;
264 else if( ( visibleLayers & LSET::AllCuMask() ).none() )
265 {
266 if( visibleLayers.any() )
267 aLayer = visibleLayers.Seq().back();
268 }
269 }
270 }
271
272 // Normal path: get the layer base color
273 auto it = m_layerColors.find( aLayer );
274 COLOR4D color = it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
275
276 if( !aItem )
277 return color;
278
279 // Selection disambiguation
280 if( aItem->IsBrightened() )
281 return color.Brightened( m_selectFactor ).WithAlpha( 0.8 );
282
283 // Normal selection
284 if( aItem->IsSelected() )
285 {
286 auto it_selected = m_layerColorsSel.find( aLayer );
287 color = it_selected == m_layerColorsSel.end() ? color.Brightened( 0.8 ) : it_selected->second;
288 }
289
290 // Some graphic objects are BOARD_CONNECTED_ITEM, but they are seen here as
291 // actually board connected objects only if on a copper layer
292 const BOARD_CONNECTED_ITEM* conItem =
293 aItem->IsConnected() && aItem->IsOnCopperLayer()
294 ? static_cast<const BOARD_CONNECTED_ITEM*>( aItem )
295 : nullptr;
296
297 // Try to obtain the netcode for the aItem
298 if( conItem )
299 netCode = conItem->GetNetCode();
300
301 bool highlighted = m_highlightEnabled && m_highlightNetcodes.count( netCode );
302 bool selected = aItem->IsSelected();
303
304 // Apply net color overrides
305 if( conItem && m_netColorMode == NET_COLOR_MODE::ALL && IsCopperLayer( aLayer ) )
306 {
307 COLOR4D netColor = COLOR4D::UNSPECIFIED;
308
309 auto ii = m_netColors.find( netCode );
310
311 if( ii != m_netColors.end() )
312 netColor = ii->second;
313
314 if( netColor == COLOR4D::UNSPECIFIED )
315 {
316 const NETCLASS* nc = conItem->GetEffectiveNetClass();
317
318 if( nc->HasPcbColor() )
319 netColor = nc->GetPcbColor();
320 }
321
322 if( netColor == COLOR4D::UNSPECIFIED )
323 netColor = color;
324
325 if( selected )
326 {
327 // Selection brightening overrides highlighting
328 netColor.Brighten( m_selectFactor );
329 }
330 else if( m_highlightEnabled )
331 {
332 // Highlight brightens objects on all layers and darkens everything else for contrast
333 if( highlighted )
334 netColor.Brighten( m_highlightFactor );
335 else
336 netColor.Darken( 1.0 - m_highlightFactor );
337 }
338
339 color = netColor;
340 }
341 else if( !selected && m_highlightEnabled )
342 {
343 // Single net highlight mode
344 if( m_highlightNetcodes.contains( netCode ) )
345 {
346 auto it_hi = m_layerColorsHi.find( aLayer );
347 color = it_hi == m_layerColorsHi.end() ? color.Brightened( m_highlightFactor ) : it_hi->second;
348 }
349 else
350 {
351 auto it_dark = m_layerColorsDark.find( aLayer );
352 color = it_dark == m_layerColorsDark.end() ? color.Darkened( 1.0 - m_highlightFactor ) : it_dark->second;
353 }
354 }
355
356 // Apply high-contrast dimming
357 if( m_hiContrastEnabled && m_highContrastLayers.size() && !highlighted && !selected )
358 {
360 bool isActive = m_highContrastLayers.count( aLayer );
361 bool hide = false;
362
363 switch( originalLayer )
364 {
365 // TODO(JE) not sure if this is needed
366 case LAYER_PADS:
367 {
368 const PAD* pad = static_cast<const PAD*>( aItem );
369
370 if( pad->IsOnLayer( primary ) && !pad->FlashLayer( primary ) )
371 {
372 isActive = false;
373
374 if( IsCopperLayer( primary ) )
375 hide = true;
376 }
377
379 isActive = false;
380
381 break;
382 }
383
384 case LAYER_VIA_BBLIND:
386 {
387 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
388
389 // Target graphic is active if the via crosses the primary layer
390 if( via->GetLayerSet().test( primary ) == 0 )
391 {
392 isActive = false;
393 hide = true;
394 }
395
396 break;
397 }
398
400 {
401 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
402
403 if( !via->FlashLayer( primary ) )
404 {
405 isActive = false;
406
407 if( IsCopperLayer( primary ) )
408 hide = true;
409 }
410
411 break;
412 }
413
417 // Pad holes are active is any physical layer is active
418 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
419 isActive = false;
420
421 break;
422
423 case LAYER_VIA_HOLES:
425 {
426 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
427
428 if( via->GetViaType() == VIATYPE::THROUGH )
429 {
430 // A through via's hole is active if any physical layer is active
431 if( LSET::PhysicalLayersMask().test( primary ) == 0 )
432 isActive = false;
433 }
434 else
435 {
436 // A blind/buried or micro via's hole is active if it crosses the primary layer
437 if( via->GetLayerSet().test( primary ) == 0 )
438 isActive = false;
439 }
440
441 break;
442 }
443
444 case LAYER_DRC_ERROR:
447 isActive = true;
448 break;
449
450 default:
451 break;
452 }
453
454 if( !isActive )
455 {
456 // Graphics on Edge_Cuts layer are not fully dimmed or hidden because they are
457 // useful when working on another layer
458 // We could use a dim factor = m_hiContrastFactor, but to have a sufficient
459 // contrast whenever m_hiContrastFactor value, we clamp the factor to 0.3f
460 // (arbitray choice after tests)
461 float dim_factor_Edge_Cuts = std::max( m_hiContrastFactor, 0.3f );
462
463 if( m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN
464 || IsNetnameLayer( aLayer )
465 || hide )
466 {
467 if( originalLayer == Edge_Cuts )
468 {
470
471 if( it != m_layerColors.end() )
472 color = color.Mix( it->second, dim_factor_Edge_Cuts );
473 else
474 color = color.Mix( COLOR4D::BLACK, dim_factor_Edge_Cuts );
475 }
476 else
478 }
479 else
480 {
482 COLOR4D backgroundColor = it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
483
484 if( originalLayer == Edge_Cuts )
485 color = color.Mix( backgroundColor, dim_factor_Edge_Cuts );
486 else
487 color = color.Mix( backgroundColor, m_hiContrastFactor );
488
489 // Reference images can't have their color mixed so just reduce the opacity a bit
490 // so they show through less
491 if( aItem->Type() == PCB_REFERENCE_IMAGE_T )
493 }
494 }
495 }
496 else if( originalLayer == LAYER_VIA_BBLIND || originalLayer == LAYER_VIA_MICROVIA )
497 {
498 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
499 const BOARD* board = via->GetBoard();
500 LSET visibleLayers = board->GetVisibleLayers() & board->GetEnabledLayers();
501
502 // Target graphic is visible if the via crosses a visible layer
503 if( ( via->GetLayerSet() & visibleLayers ).none() )
505 }
506
507 // Apply per-type opacity overrides
508 if( aItem->Type() == PCB_TRACE_T || aItem->Type() == PCB_ARC_T )
510 else if( aItem->Type() == PCB_VIA_T )
511 color.a *= m_viaOpacity;
512 else if( aItem->Type() == PCB_PAD_T )
513 color.a *= m_padOpacity;
514 else if( aItem->Type() == PCB_ZONE_T && static_cast<const ZONE*>( aItem )->IsTeardropArea() )
516 else if( aItem->Type() == PCB_ZONE_T )
517 color.a *= m_zoneOpacity;
518 else if( aItem->Type() == PCB_REFERENCE_IMAGE_T )
520 else if( aItem->Type() == PCB_SHAPE_T && static_cast<const PCB_SHAPE*>( aItem )->IsFilled() )
522 else if( aItem->Type() == PCB_SHAPE_T && aItem->IsOnCopperLayer() )
524
525 if( aItem->GetForcedTransparency() > 0.0 )
526 color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForcedTransparency() ) );
527
528 // No special modifiers enabled
529 return color;
530}
531
532
534{
535 return pcbconfig() && pcbconfig()->m_ShowPageLimits;
536}
537
538
540 PAINTER( aGal ),
541 m_frameType( aFrameType ),
542 m_maxError( ARC_HIGH_DEF ),
543 m_holePlatingThickness( 0 ),
544 m_lockedShadowMargin( 0 )
545{
546}
547
548
549int PCB_PAINTER::getLineThickness( int aActualThickness ) const
550{
551 // if items have 0 thickness, draw them with the outline
552 // width, otherwise respect the set value (which, no matter
553 // how small will produce something)
554 if( aActualThickness == 0 )
556
557 return aActualThickness;
558}
559
560
562{
563 return aPad->GetDrillShape();
564}
565
566
568{
569 SHAPE_SEGMENT segm = *aPad->GetEffectiveHoleShape().get();
570 return segm;
571}
572
573
574int PCB_PAINTER::getViaDrillSize( const PCB_VIA* aVia ) const
575{
576 return aVia->GetDrillValue();
577}
578
579
580bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
581{
582 if( !aItem->IsBOARD_ITEM() )
583 return false;
584
585 const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( aItem );
586
587 if( const BOARD* board = item->GetBoard() )
588 {
589 BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
593
594 if( item->GetParentFootprint() && !board->IsFootprintHolder() )
595 {
596 FOOTPRINT* parentFP = item->GetParentFootprint();
597
598 // Never draw footprint reference images on board
599 if( item->Type() == PCB_REFERENCE_IMAGE_T )
600 {
601 return false;
602 }
603 else if( item->GetLayerSet().count() > 1 )
604 {
605 // For multi-layer objects, exclude only those layers that are private
606 if( IsPcbLayer( aLayer ) && parentFP->GetPrivateLayers().test( aLayer ) )
607 return false;
608 }
609 else if( item->GetLayerSet().count() == 1 )
610 {
611 // For single-layer objects, exclude all layers including ancillary layers
612 // such as holes, netnames, etc.
613 PCB_LAYER_ID singleLayer = item->GetLayerSet().ExtractLayer();
614
615 if( parentFP->GetPrivateLayers().test( singleLayer ) )
616 return false;
617 }
618 }
619 }
620 else
621 {
624 }
625
626 // the "cast" applied in here clarifies which overloaded draw() is called
627 switch( item->Type() )
628 {
629 case PCB_TRACE_T:
630 draw( static_cast<const PCB_TRACK*>( item ), aLayer );
631 break;
632
633 case PCB_ARC_T:
634 draw( static_cast<const PCB_ARC*>( item ), aLayer );
635 break;
636
637 case PCB_VIA_T:
638 draw( static_cast<const PCB_VIA*>( item ), aLayer );
639 break;
640
641 case PCB_PAD_T:
642 draw( static_cast<const PAD*>( item ), aLayer );
643 break;
644
645 case PCB_SHAPE_T:
646 draw( static_cast<const PCB_SHAPE*>( item ), aLayer );
647 break;
648
650 draw( static_cast<const PCB_REFERENCE_IMAGE*>( item ), aLayer );
651 break;
652
653 case PCB_FIELD_T:
654 case PCB_TEXT_T:
655 draw( static_cast<const PCB_TEXT*>( item ), aLayer );
656 break;
657
658 case PCB_TEXTBOX_T:
659 draw( static_cast<const PCB_TEXTBOX*>( item ), aLayer );
660 break;
661
662 case PCB_TABLE_T:
663 draw( static_cast<const PCB_TABLE*>( item ), aLayer );
664 break;
665
666 case PCB_FOOTPRINT_T:
667 draw( static_cast<const FOOTPRINT*>( item ), aLayer );
668 break;
669
670 case PCB_GROUP_T:
671 draw( static_cast<const PCB_GROUP*>( item ), aLayer );
672 break;
673
674 case PCB_ZONE_T:
675 draw( static_cast<const ZONE*>( item ), aLayer );
676 break;
677
679 case PCB_DIM_CENTER_T:
680 case PCB_DIM_RADIAL_T:
682 case PCB_DIM_LEADER_T:
683 draw( static_cast<const PCB_DIMENSION_BASE*>( item ), aLayer );
684 break;
685
686 case PCB_TARGET_T:
687 draw( static_cast<const PCB_TARGET*>( item ) );
688 break;
689
690 case PCB_MARKER_T:
691 draw( static_cast<const PCB_MARKER*>( item ), aLayer );
692 break;
693
694 default:
695 // Painter does not know how to draw the object
696 return false;
697 }
698
699 // Draw bounding boxes after drawing objects so they can be seen.
701 {
702 // Show bounding boxes of painted objects for debugging.
703 BOX2I box = item->GetBoundingBox();
704
705 m_gal->SetIsFill( false );
706 m_gal->SetIsStroke( true );
707
708 if( item->Type() == PCB_FOOTPRINT_T )
709 {
710 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
711 COLOR4D( MAGENTA ) );
712 }
713 else
714 {
715 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
716 COLOR4D( 0.4, 0.4, 0.4, 1 ) );
717 }
718
719 m_gal->SetLineWidth( 1 );
720 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
721
722 if( item->Type() == PCB_FOOTPRINT_T )
723 {
724 m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
725 COLOR4D( CYAN ) );
726
727 const FOOTPRINT* fp = static_cast<const FOOTPRINT*>( item );
728
729 if( fp )
730 {
731 const SHAPE_POLY_SET& convex = fp->GetBoundingHull();
732
733 m_gal->DrawPolyline( convex.COutline( 0 ) );
734 }
735 }
736 }
737
738 return true;
739}
740
741
742void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
743{
744 VECTOR2I start( aTrack->GetStart() );
745 VECTOR2I end( aTrack->GetEnd() );
746 int track_width = aTrack->GetWidth();
747 COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
748
749 if( IsNetnameLayer( aLayer ) )
750 {
751 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
752 return;
753
754 if( aTrack->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
755 return;
756
757 SHAPE_SEGMENT trackShape( { aTrack->GetStart(), aTrack->GetEnd() }, aTrack->GetWidth() );
758 renderNetNameForSegment( trackShape, color, aTrack->GetDisplayNetname() );
759 return;
760 }
761 else if( IsCopperLayer( aLayer ) || IsSolderMaskLayer( aLayer )
762 || aLayer == LAYER_LOCKED_ITEM_SHADOW )
763 {
764 // Draw a regular track
765 bool outline_mode = pcbconfig()
767 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
770 m_gal->SetIsStroke( outline_mode );
771 m_gal->SetIsFill( not outline_mode );
773
774 if( IsSolderMaskLayer( aLayer ) )
775 track_width = track_width + aTrack->GetSolderMaskExpansion() * 2;
776
777 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
778 track_width = track_width + m_lockedShadowMargin;
779
780 m_gal->DrawSegment( start, end, track_width );
781 }
782
783 // Clearance lines
784 if( pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
786 && aLayer != LAYER_LOCKED_ITEM_SHADOW )
787 {
788 /*
789 * Showing the clearance area is not obvious for optionally-flashed pads and vias, so we
790 * choose to not display clearance lines at all on non-copper active layers. We follow
791 * the same rule for tracks to be consistent (even though they don't have the same issue).
792 */
794 const BOARD* board = aTrack->GetBoard();
795
796 if( IsCopperLayer( activeLayer ) && board->GetVisibleLayers().test( activeLayer ) )
797 {
798 int clearance = aTrack->GetOwnClearance( activeLayer );
799
801 m_gal->SetIsFill( false );
802 m_gal->SetIsStroke( true );
804 m_gal->DrawSegment( start, end, track_width + clearance * 2 );
805 }
806 }
807}
808
809
811 const wxString& aNetName ) const
812{
813 // When drawing netnames, clip the track to the viewport
814 BOX2D viewport;
815 VECTOR2D screenSize = m_gal->GetScreenPixelSize();
816 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
817
818 viewport.SetOrigin( VECTOR2D( matrix * VECTOR2D( 0, 0 ) ) );
819 viewport.SetEnd( VECTOR2D( matrix * screenSize ) );
820 viewport.Normalize();
821
822 int num_char = aNetName.size();
823
824 // Check if the track is long enough to have a netname displayed
825 int seg_minlength = aSeg.GetWidth() * num_char;
826 SEG::ecoord seg_minlength_sq = (SEG::ecoord)seg_minlength * seg_minlength;
827
828 if( aSeg.GetSeg().SquaredLength() < seg_minlength_sq )
829 return;
830
831 double textSize = aSeg.GetWidth();
832 double penWidth = textSize / 12.0;
833 EDA_ANGLE textOrientation;
834 int num_names = 1;
835
836 VECTOR2I start = aSeg.GetSeg().A;
837 VECTOR2I end = aSeg.GetSeg().B;
838 VECTOR2D segV = end - start;
839
840 if( end.y == start.y ) // horizontal
841 {
842 textOrientation = ANGLE_HORIZONTAL;
843 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / viewport.GetWidth() ) );
844 }
845 else if( end.x == start.x ) // vertical
846 {
847 textOrientation = ANGLE_VERTICAL;
848 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / viewport.GetHeight() ) );
849 }
850 else
851 {
852 textOrientation = -EDA_ANGLE( segV );
853 textOrientation.Normalize90();
854
855 double min_size = std::min( viewport.GetWidth(), viewport.GetHeight() );
856 num_names = std::max( num_names, KiROUND( aSeg.GetSeg().Length() / ( M_SQRT2 * min_size ) ) );
857 }
858
859 m_gal->SetIsStroke( true );
860 m_gal->SetIsFill( false );
861 m_gal->SetStrokeColor( aColor );
862 m_gal->SetLineWidth( penWidth );
863 m_gal->SetFontBold( false );
864 m_gal->SetFontItalic( false );
865 m_gal->SetFontUnderlined( false );
866 m_gal->SetTextMirrored( false );
867 m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
870
871 int divisions = num_names + 1;
872
873 for( int ii = 1; ii < divisions; ++ii )
874 {
875 VECTOR2I textPosition = start + segV * ( (double) ii / divisions );
876
877 if( viewport.Contains( textPosition ) )
878 m_gal->BitmapText( aNetName, textPosition, textOrientation );
879 }
880}
881
882
883void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
884{
885 VECTOR2D center( aArc->GetCenter() );
886 int width = aArc->GetWidth();
887 COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
888 double radius = aArc->GetRadius();
889 EDA_ANGLE start_angle = aArc->GetArcAngleStart();
890 EDA_ANGLE angle = aArc->GetAngle();
891
892 if( IsNetnameLayer( aLayer ) )
893 {
894 // Ummm, yeah. Anyone fancy implementing text on a path?
895 return;
896 }
897 else if( IsCopperLayer( aLayer ) || IsSolderMaskLayer( aLayer )
898 || aLayer == LAYER_LOCKED_ITEM_SHADOW )
899 {
900 // Draw a regular track
901 bool outline_mode = pcbconfig()
903 && aLayer != LAYER_LOCKED_ITEM_SHADOW;
906 m_gal->SetIsStroke( outline_mode );
907 m_gal->SetIsFill( not outline_mode );
909
910 if( IsSolderMaskLayer( aLayer ) )
911 width = width + aArc->GetSolderMaskExpansion() * 2;
912
913 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
914 width = width + m_lockedShadowMargin;
915
916 m_gal->DrawArcSegment( center, radius, start_angle, angle, width, m_maxError );
917 }
918
919 // Clearance lines
920 if( pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
922 && aLayer != LAYER_LOCKED_ITEM_SHADOW )
923 {
924 /*
925 * Showing the clearance area is not obvious for optionally-flashed pads and vias, so we
926 * choose to not display clearance lines at all on non-copper active layers. We follow
927 * the same rule for tracks to be consistent (even though they don't have the same issue).
928 */
930 const BOARD* board = aArc->GetBoard();
931
932 if( IsCopperLayer( activeLayer ) && board->GetVisibleLayers().test( activeLayer ) )
933 {
934 int clearance = aArc->GetOwnClearance( activeLayer );
935
937 m_gal->SetIsFill( false );
938 m_gal->SetIsStroke( true );
940
941 m_gal->DrawArcSegment( center, radius, start_angle, angle, width + clearance * 2,
942 m_maxError );
943 }
944 }
945
946// Debug only: enable this code only to test the TransformArcToPolygon function
947// and display the polygon outline created by it.
948// arcs on F_Cu are approximated with ERROR_INSIDE, others with ERROR_OUTSIDE
949#if 0
950 SHAPE_POLY_SET cornerBuffer;
951 ERROR_LOC errorloc = aLayer == F_Cu ? ERROR_LOC::ERROR_INSIDE : ERROR_LOC::ERROR_OUTSIDE;
952 TransformArcToPolygon( cornerBuffer, aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), width,
953 m_maxError, errorloc );
955 m_gal->SetIsFill( false );
956 m_gal->SetIsStroke( true );
957 m_gal->SetStrokeColor( COLOR4D( 0, 0, 1.0, 1.0 ) );
958 m_gal->DrawPolygon( cornerBuffer );
959#endif
960
961// Debug only: enable this code only to test the SHAPE_ARC::ConvertToPolyline function
962// and display the polyline created by it.
963#if 0
964 SHAPE_ARC arc( aArc->GetCenter(), aArc->GetStart(), aArc->GetAngle(), aArc->GetWidth() );
967 m_gal->SetIsFill( false );
968 m_gal->SetIsStroke( true );
969 m_gal->SetStrokeColor( COLOR4D( 0.3, 0.2, 0.5, 1.0 ) );
970
971 for( int idx = 1; idx < arcSpine.PointCount(); idx++ )
972 m_gal->DrawSegment( arcSpine.CPoint( idx-1 ), arcSpine.CPoint( idx ), aArc->GetWidth() );
973#endif
974}
975
976
977void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
978{
979 const BOARD* board = aVia->GetBoard();
980 COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
981 VECTOR2D center( aVia->GetStart() );
982
983 if( color == COLOR4D::CLEAR )
984 return;
985
986 PCB_LAYER_ID currentLayer = ToLAYER_ID( aLayer );
987 PCB_LAYER_ID layerTop, layerBottom;
988 aVia->LayerPair( &layerTop, &layerBottom );
989
990 // Blind/buried vias (and microvias) will use different hole and label rendering
991 bool isBlindBuried = aVia->GetViaType() == VIATYPE::BLIND_BURIED
992 || ( aVia->GetViaType() == VIATYPE::MICROVIA
993 && ( layerTop != F_Cu || layerBottom != B_Cu ) );
994
995 // Draw description layer
996 if( IsNetnameLayer( aLayer ) )
997 {
998 VECTOR2D position( center );
999
1000 // Is anything that we can display enabled (netname and/or layers ids)?
1001 bool showNets = pcbconfig() && pcbconfig()->m_Display.m_NetNames != 0
1002 && !aVia->GetNetname().empty();
1003 bool showLayers = aVia->GetViaType() != VIATYPE::THROUGH;
1004
1005 if( !showNets && !showLayers )
1006 return;
1007
1008 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
1009 double size = aVia->GetWidth( currentLayer );
1010
1011 // Font size limits
1012 if( size > maxSize )
1013 size = maxSize;
1014
1015 m_gal->Save();
1016 m_gal->Translate( position );
1017
1018 // Default font settings
1022 m_gal->SetFontBold( false );
1023 m_gal->SetFontItalic( false );
1024 m_gal->SetFontUnderlined( false );
1025 m_gal->SetTextMirrored( false );
1026 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, aLayer ) );
1027 m_gal->SetIsStroke( true );
1028 m_gal->SetIsFill( false );
1029
1030 // Set the text position via position. if only one text, it is on the via position
1031 // For 2 lines, the netname is slightly below the center, and the layer IDs above
1032 // the netname
1033 VECTOR2D textpos( 0.0, 0.0 );
1034
1035 wxString netname = aVia->GetDisplayNetname();
1036
1037 PCB_LAYER_ID topLayerId = aVia->TopLayer();
1038 PCB_LAYER_ID bottomLayerId = aVia->BottomLayer();
1039 int topLayer; // The via top layer number (from 1 to copper layer count)
1040 int bottomLayer; // The via bottom layer number (from 1 to copper layer count)
1041
1042 switch( topLayerId )
1043 {
1044 case F_Cu: topLayer = 1; break;
1045 case B_Cu: topLayer = board->GetCopperLayerCount(); break;
1046 default: topLayer = (topLayerId - B_Cu)/2 + 1; break;
1047 }
1048
1049 switch( bottomLayerId )
1050 {
1051 case F_Cu: bottomLayer = 1; break;
1052 case B_Cu: bottomLayer = board->GetCopperLayerCount(); break;
1053 default: bottomLayer = (bottomLayerId - B_Cu)/2 + 1; break;
1054 }
1055
1056 wxString layerIds;
1057#if wxUSE_UNICODE_WCHAR
1058 layerIds << std::to_wstring( topLayer ) << L'-' << std::to_wstring( bottomLayer );
1059#else
1060 layerIds << std::to_string( topLayer ) << '-' << std::to_string( bottomLayer );
1061#endif
1062
1063 // a good size is set room for at least 6 chars, to be able to print 2 lines of text,
1064 // or at least 3 chars for only the netname
1065 // (The layerIds string has 5 chars max)
1066 int minCharCnt = showLayers ? 6 : 3;
1067
1068 // approximate the size of netname and layerIds text:
1069 double tsize = 1.5 * size / std::max( PrintableCharCount( netname ), minCharCnt );
1070 tsize = std::min( tsize, size );
1071
1072 // Use a smaller text size to handle interline, pen size..
1073 tsize *= 0.75;
1074 VECTOR2D namesize( tsize, tsize );
1075
1076 // For 2 lines, adjust the text pos (move it a small amount to the bottom)
1077 if( showLayers && showNets )
1078 textpos.y += ( tsize * 1.3 )/ 2;
1079
1080 m_gal->SetGlyphSize( namesize );
1081 m_gal->SetLineWidth( namesize.x / 10.0 );
1082
1083 if( showNets )
1084 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
1085
1086 if( showLayers )
1087 {
1088 if( showNets )
1089 textpos.y -= tsize * 1.3;
1090
1091 m_gal->BitmapText( layerIds, textpos, ANGLE_HORIZONTAL );
1092 }
1093
1094 m_gal->Restore();
1095
1096 return;
1097 }
1098
1099 bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayViaFill;
1100
1103 m_gal->SetIsStroke( true );
1104 m_gal->SetIsFill( false );
1105
1106 if( outline_mode )
1108
1109 if( aLayer == LAYER_VIA_HOLEWALLS )
1110 {
1111 double radius = ( getViaDrillSize( aVia ) / 2.0 ) + m_holePlatingThickness;
1112
1113 if( !outline_mode )
1114 {
1116 radius -= m_holePlatingThickness / 2.0;
1117 }
1118
1119 // Underpaint the hole so that there aren't artifacts at its edge
1120 m_gal->SetIsFill( true );
1121
1122 m_gal->DrawCircle( center, radius );
1123 }
1124 else if( aLayer == LAYER_VIA_HOLES )
1125 {
1126 double radius = getViaDrillSize( aVia ) / 2.0;
1127
1128 m_gal->SetIsStroke( false );
1129 m_gal->SetIsFill( true );
1130
1131 if( isBlindBuried && !m_pcbSettings.IsPrinting() )
1132 {
1133 m_gal->SetIsStroke( false );
1134 m_gal->SetIsFill( true );
1135
1136 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
1137 m_gal->DrawArc( center, radius, EDA_ANGLE( 180, DEGREES_T ),
1138 EDA_ANGLE( 180, DEGREES_T ) );
1139
1140 m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
1141 m_gal->DrawArc( center, radius, EDA_ANGLE( 0, DEGREES_T ),
1142 EDA_ANGLE( 180, DEGREES_T ) );
1143 }
1144 else
1145 {
1146 m_gal->DrawCircle( center, radius );
1147 }
1148 }
1149 else if( ( aLayer == F_Mask && aVia->IsOnLayer( F_Mask ) )
1150 || ( aLayer == B_Mask && aVia->IsOnLayer( B_Mask ) ) )
1151 {
1152 int margin = board->GetDesignSettings().m_SolderMaskExpansion;
1153
1154 m_gal->SetIsFill( true );
1155 m_gal->SetIsStroke( false );
1156
1157 m_gal->SetLineWidth( margin );
1158 m_gal->DrawCircle( center, aVia->GetWidth( currentLayer ) / 2.0 + margin );
1159 }
1160 else if( m_pcbSettings.IsPrinting() || IsCopperLayer( aLayer ) )
1161 {
1162 int annular_width = ( aVia->GetWidth( currentLayer ) - getViaDrillSize( aVia ) ) / 2.0;
1163 double radius = aVia->GetWidth( currentLayer ) / 2.0;
1164 bool draw = false;
1165
1167 {
1169 }
1170 else if( aVia->IsSelected() )
1171 {
1172 draw = true;
1173 }
1174 else if( aVia->FlashLayer( board->GetVisibleLayers() & board->GetEnabledLayers() ) )
1175 {
1176 draw = true;
1177 }
1178
1179 if( !aVia->FlashLayer( aLayer ) )
1180 draw = false;
1181
1182 if( !outline_mode )
1183 {
1184 m_gal->SetLineWidth( annular_width );
1185 radius -= annular_width / 2.0;
1186 }
1187
1188 if( draw )
1189 m_gal->DrawCircle( center, radius );
1190 }
1191 else if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // draw a ring around the via
1192 {
1194
1195 m_gal->DrawCircle( center,
1196 ( aVia->GetWidth( currentLayer ) + m_lockedShadowMargin ) / 2.0 );
1197 }
1198
1199 // Clearance lines
1201 && aLayer != LAYER_VIA_HOLES
1203 && aLayer != LAYER_LOCKED_ITEM_SHADOW )
1204 {
1205 /*
1206 * Showing the clearance area is not obvious as the clearance extends from the via's pad
1207 * on flashed copper layers and from the via's hole on non-flashed copper layers. Because
1208 * of this, we choose to not display clearance lines at all on non-copper active layers as
1209 * it's not clear which we'd be displaying.
1210 */
1212
1213 if( IsCopperLayer( activeLayer ) && board->GetVisibleLayers().test( activeLayer ) )
1214 {
1215 double radius;
1216
1217 if( aVia->FlashLayer( activeLayer ) )
1218 radius = aVia->GetWidth( activeLayer ) / 2.0;
1219 else
1220 radius = getViaDrillSize( aVia ) / 2.0 + m_holePlatingThickness;
1221
1223 m_gal->SetIsFill( false );
1224 m_gal->SetIsStroke( true );
1226 m_gal->DrawCircle( center, radius + aVia->GetOwnClearance( activeLayer ) );
1227 }
1228 }
1229}
1230
1231
1232void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
1233{
1234 const BOARD* board = aPad->GetBoard();
1235 COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
1236 const PCB_LAYER_ID& pcbLayer = static_cast<PCB_LAYER_ID>( aLayer );
1237
1238 if( IsNetnameLayer( aLayer ) )
1239 {
1240 PCBNEW_SETTINGS::DISPLAY_OPTIONS* displayOpts = pcbconfig() ? &pcbconfig()->m_Display : nullptr;
1241 wxString netname;
1242 wxString padNumber;
1243
1244 if( viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers )
1245 {
1246 padNumber = UnescapeString( aPad->GetNumber() );
1247
1248 if( dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
1249 netname = aPad->GetPinFunction();
1250 }
1251
1252 if( displayOpts && !dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
1253 {
1254 if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
1255 netname = aPad->GetDisplayNetname();
1256
1257 if( aPad->IsNoConnectPad() )
1258 netname = wxT( "x" );
1259 else if( aPad->IsFreePad() )
1260 netname = wxT( "*" );
1261 }
1262
1263 if( netname.IsEmpty() && padNumber.IsEmpty() )
1264 return;
1265
1266 BOX2I padBBox = aPad->GetBoundingBox();
1267 VECTOR2D position = padBBox.Centre();
1268 VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
1269
1270 if( aPad->IsEntered() )
1271 {
1272 FOOTPRINT* fp = aPad->GetParentFootprint();
1273
1274 // Find the number box
1275 for( const BOARD_ITEM* aItem : fp->GraphicalItems() )
1276 {
1277 if( aItem->Type() == PCB_SHAPE_T )
1278 {
1279 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
1280
1281 if( shape->IsProxyItem() && shape->GetShape() == SHAPE_T::RECTANGLE )
1282 {
1283 position = shape->GetCenter();
1284 padsize = shape->GetBotRight() - shape->GetTopLeft();
1285
1286 // We normally draw a bit outside the pad, but this will be somewhat
1287 // unexpected when the user has drawn a box.
1288 padsize *= 0.9;
1289
1290 break;
1291 }
1292 }
1293 }
1294 }
1295 else if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CUSTOM )
1296 {
1297 // See if we have a number box
1298 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives( pcbLayer ) )
1299 {
1300 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
1301 {
1302 position = primitive->GetCenter();
1303 RotatePoint( position, aPad->GetOrientation() );
1304 position += aPad->ShapePos( pcbLayer );
1305
1306 padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
1307 padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
1308
1309 // We normally draw a bit outside the pad, but this will be somewhat
1310 // unexpected when the user has drawn a box.
1311 padsize *= 0.9;
1312
1313 break;
1314 }
1315 }
1316 }
1317
1318 if( aPad->GetShape( pcbLayer ) != PAD_SHAPE::CUSTOM )
1319 {
1320 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
1321 double limit = std::min( aPad->GetSize( pcbLayer ).x,
1322 aPad->GetSize( pcbLayer ).y ) * 1.1;
1323
1324 if( padsize.x > limit && padsize.y > limit )
1325 {
1326 padsize.x = limit;
1327 padsize.y = limit;
1328 }
1329 }
1330
1331 double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
1332 double size = padsize.y;
1333
1334 m_gal->Save();
1335 m_gal->Translate( position );
1336
1337 // Keep the size ratio for the font, but make it smaller
1338 if( padsize.x < ( padsize.y * 0.95 ) )
1339 {
1341 size = padsize.x;
1342 std::swap( padsize.x, padsize.y );
1343 }
1344
1345 // Font size limits
1346 if( size > maxSize )
1347 size = maxSize;
1348
1349 // Default font settings
1353 m_gal->SetFontBold( false );
1354 m_gal->SetFontItalic( false );
1355 m_gal->SetFontUnderlined( false );
1356 m_gal->SetTextMirrored( false );
1357 m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) );
1358 m_gal->SetIsStroke( true );
1359 m_gal->SetIsFill( false );
1360
1361 // We have already translated the GAL to be centered at the center of the pad's
1362 // bounding box
1363 VECTOR2I textpos( 0, 0 );
1364
1365 // Divide the space, to display both pad numbers and netnames and set the Y text
1366 // offset position to display 2 lines
1367 int Y_offset_numpad = 0;
1368 int Y_offset_netname = 0;
1369
1370 if( !netname.IsEmpty() && !padNumber.IsEmpty() )
1371 {
1372 // The magic numbers are defined experimentally for a better look.
1373 size = size / 2.5;
1374 Y_offset_netname = size / 1.4; // netname size is usually smaller than num pad
1375 // so the offset can be smaller
1376 Y_offset_numpad = size / 1.7;
1377 }
1378
1379 // We are using different fonts to display names, depending on the graphic
1380 // engine (OpenGL or Cairo).
1381 // Xscale_for_stroked_font adjust the text X size for cairo (stroke fonts) engine
1382 const double Xscale_for_stroked_font = 0.9;
1383
1384 if( !netname.IsEmpty() )
1385 {
1386 // approximate the size of net name text:
1387 // We use a size for at least 5 chars, to give a good look even for short names
1388 // (like VCC, GND...)
1389 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname )+1, 5 );
1390 tsize = std::min( tsize, size );
1391
1392 // Use a smaller text size to handle interline, pen size...
1393 tsize *= 0.85;
1394
1395 // Round and oval pads have less room to display the net name than other
1396 // (i.e RECT) shapes, so reduce the text size for these shapes
1397 if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CIRCLE
1398 || aPad->GetShape( pcbLayer ) == PAD_SHAPE::OVAL )
1399 {
1400 tsize *= 0.9;
1401 }
1402
1403 VECTOR2D namesize( tsize*Xscale_for_stroked_font, tsize );
1404 textpos.y = std::min( tsize * 1.4, double( Y_offset_netname ) );
1405
1406 m_gal->SetGlyphSize( namesize );
1407 m_gal->SetLineWidth( namesize.x / 6.0 );
1408 m_gal->SetFontBold( true );
1409 m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
1410 }
1411
1412 if( !padNumber.IsEmpty() )
1413 {
1414 // approximate the size of the pad number text:
1415 // We use a size for at least 3 chars, to give a good look even for short numbers
1416 double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( padNumber ), 3 );
1417 tsize = std::min( tsize, size );
1418
1419 // Use a smaller text size to handle interline, pen size...
1420 tsize *= 0.85;
1421 tsize = std::min( tsize, size );
1422 VECTOR2D numsize( tsize*Xscale_for_stroked_font, tsize );
1423 textpos.y = -Y_offset_numpad;
1424
1425 m_gal->SetGlyphSize( numsize );
1426 m_gal->SetLineWidth( numsize.x / 6.0 );
1427 m_gal->SetFontBold( true );
1428 m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL );
1429 }
1430
1431 m_gal->Restore();
1432
1433 return;
1434 }
1435 else if( aLayer == LAYER_PAD_HOLEWALLS )
1436 {
1437 m_gal->SetIsFill( false );
1438 m_gal->SetIsStroke( true );
1441
1442 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
1443 int holeSize = slot->GetWidth() + m_holePlatingThickness;
1444
1445 if( slot->GetSeg().A == slot->GetSeg().B ) // Circular hole
1446 m_gal->DrawCircle( slot->GetSeg().A, KiROUND( holeSize / 2.0 ) );
1447 else
1448 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, holeSize );
1449
1450 return;
1451 }
1452
1453 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
1454
1456 outline_mode = true;
1457
1458 if( outline_mode )
1459 {
1460 // Outline mode
1461 m_gal->SetIsFill( false );
1462 m_gal->SetIsStroke( true );
1465 }
1466 else
1467 {
1468 // Filled mode
1469 m_gal->SetIsFill( true );
1470 m_gal->SetIsStroke( false );
1472 }
1473
1474 bool drawShape = false;
1475
1476 if( aLayer == LAYER_PAD_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
1477 {
1478 SHAPE_SEGMENT slot = getPadHoleShape( aPad );
1479
1480 if( slot.GetSeg().A == slot.GetSeg().B ) // Circular hole
1481 m_gal->DrawCircle( slot.GetSeg().A, slot.GetWidth() / 2.0 );
1482 else
1483 m_gal->DrawSegment( slot.GetSeg().A, slot.GetSeg().B, slot.GetWidth() );
1484 }
1485 else if( m_pcbSettings.IsPrinting() )
1486 {
1487 drawShape = aPad->FlashLayer( m_pcbSettings.GetPrintLayers() );
1488 }
1489 else if( aPad->FlashLayer( board->GetVisibleLayers() & board->GetEnabledLayers() ) )
1490 {
1491 drawShape = true;
1492 }
1493 else if( aPad->IsSelected() )
1494 {
1495 drawShape = true;
1496 outline_mode = true;
1497 }
1498
1499 if( outline_mode )
1500 {
1501 // Outline mode
1502 m_gal->SetIsFill( false );
1503 m_gal->SetIsStroke( true );
1506 }
1507
1508 if( drawShape )
1509 {
1510 VECTOR2I pad_size = aPad->GetSize( pcbLayer );
1511 VECTOR2I margin;
1512
1513 switch( aLayer )
1514 {
1515 case F_Mask:
1516 case B_Mask:
1517 margin.x = margin.y = aPad->GetSolderMaskExpansion( pcbLayer );
1518 break;
1519
1520 case F_Paste:
1521 case B_Paste:
1522 margin = aPad->GetSolderPasteMargin( pcbLayer );
1523 break;
1524
1525 default:
1526 margin.x = margin.y = 0;
1527 break;
1528 }
1529
1530 std::unique_ptr<PAD> dummyPad;
1531 std::shared_ptr<SHAPE_COMPOUND> shapes;
1532
1533 // Drawing components of compound shapes in outline mode produces a mess.
1534 bool simpleShapes = !outline_mode;
1535
1536 if( simpleShapes )
1537 {
1538 if( ( margin.x != margin.y && aPad->GetShape( pcbLayer ) != PAD_SHAPE::CUSTOM )
1539 || ( aPad->GetShape( pcbLayer ) == PAD_SHAPE::ROUNDRECT
1540 && ( margin.x < 0 || margin.y < 0 ) ) )
1541 {
1542 // Our algorithms below (polygon inflation in particular) can't handle differential
1543 // inflation along separate axes. So for those cases we build a dummy pad instead,
1544 // and inflate it.
1545
1546 // Margin is added to both sides. If the total margin is larger than the pad
1547 // then don't display this layer
1548 if( pad_size.x + 2 * margin.x <= 0 || pad_size.y + 2 * margin.y <= 0 )
1549 return;
1550
1551 dummyPad.reset( static_cast<PAD*>( aPad->Duplicate() ) );
1552
1553 if( dummyPad->GetParentGroup() )
1554 dummyPad->GetParentGroup()->RemoveItem( dummyPad.get() );
1555
1556 int initial_radius = dummyPad->GetRoundRectCornerRadius( pcbLayer );
1557
1558 dummyPad->SetSize( pcbLayer, pad_size + margin + margin );
1559
1560 if( dummyPad->GetShape( pcbLayer ) == PAD_SHAPE::ROUNDRECT )
1561 {
1562 // To keep the right margin around the corners, we need to modify the corner radius.
1563 // We must have only one radius correction, so use the smallest absolute margin.
1564 int radius_margin = std::max( margin.x, margin.y ); // radius_margin is < 0
1565 dummyPad->SetRoundRectCornerRadius(
1566 pcbLayer, std::max( initial_radius + radius_margin, 0 ) );
1567 }
1568
1569 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>(
1570 dummyPad->GetEffectiveShape( pcbLayer ) );
1571 margin.x = margin.y = 0;
1572 }
1573 else
1574 {
1575 shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>(
1576 aPad->GetEffectiveShape( pcbLayer ) );
1577 }
1578
1579 // The dynamic cast above will fail if the pad returned the hole shape or a null shape
1580 // instead of a SHAPE_COMPOUND, which happens if we're on a copper layer and the pad has
1581 // no shape on that layer.
1582 if( !shapes )
1583 return;
1584
1585 if( aPad->GetShape( pcbLayer ) == PAD_SHAPE::CUSTOM && ( margin.x || margin.y ) )
1586 {
1587 // We can't draw as shapes because we don't know which edges are internal and which
1588 // are external (so we don't know when to apply the margin and when not to).
1589 simpleShapes = false;
1590 }
1591
1592 for( const SHAPE* shape : shapes->Shapes() )
1593 {
1594 if( !simpleShapes )
1595 break;
1596
1597 switch( shape->Type() )
1598 {
1599 case SH_SEGMENT:
1600 case SH_CIRCLE:
1601 case SH_RECT:
1602 case SH_SIMPLE:
1603 // OK so far
1604 break;
1605
1606 default:
1607 // Not OK
1608 simpleShapes = false;
1609 break;
1610 }
1611 }
1612 }
1613
1614 if( simpleShapes )
1615 {
1616 for( const SHAPE* shape : shapes->Shapes() )
1617 {
1618 switch( shape->Type() )
1619 {
1620 case SH_SEGMENT:
1621 {
1622 const SHAPE_SEGMENT* seg = (const SHAPE_SEGMENT*) shape;
1623 int effectiveWidth = seg->GetWidth() + 2 * margin.x;
1624
1625 if( effectiveWidth > 0 )
1626 m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, effectiveWidth );
1627
1628 break;
1629 }
1630
1631 case SH_CIRCLE:
1632 {
1633 const SHAPE_CIRCLE* circle = (const SHAPE_CIRCLE*) shape;
1634 int effectiveRadius = circle->GetRadius() + margin.x;
1635
1636 if( effectiveRadius > 0 )
1637 m_gal->DrawCircle( circle->GetCenter(), effectiveRadius );
1638
1639 break;
1640 }
1641
1642 case SH_RECT:
1643 {
1644 const SHAPE_RECT* r = (const SHAPE_RECT*) shape;
1645 VECTOR2I pos = r->GetPosition();
1646 VECTOR2I effectiveMargin = margin;
1647
1648 if( effectiveMargin.x < 0 )
1649 {
1650 // A negative margin just produces a smaller rect.
1651 VECTOR2I effectiveSize = r->GetSize() + effectiveMargin;
1652
1653 if( effectiveSize.x > 0 && effectiveSize.y > 0 )
1654 m_gal->DrawRectangle( pos - effectiveMargin, pos + effectiveSize );
1655 }
1656 else if( effectiveMargin.x > 0 )
1657 {
1658 // A positive margin produces a larger rect, but with rounded corners
1659 m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
1660
1661 // Use segments to produce the margin with rounded corners
1662 m_gal->DrawSegment( pos,
1663 pos + VECTOR2I( r->GetWidth(), 0 ),
1664 effectiveMargin.x * 2 );
1665 m_gal->DrawSegment( pos + VECTOR2I( r->GetWidth(), 0 ),
1666 pos + r->GetSize(),
1667 effectiveMargin.x * 2 );
1668 m_gal->DrawSegment( pos + r->GetSize(),
1669 pos + VECTOR2I( 0, r->GetHeight() ),
1670 effectiveMargin.x * 2 );
1671 m_gal->DrawSegment( pos + VECTOR2I( 0, r->GetHeight() ),
1672 pos,
1673 effectiveMargin.x * 2 );
1674 }
1675 else
1676 {
1677 m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
1678 }
1679
1680 break;
1681 }
1682
1683 case SH_SIMPLE:
1684 {
1685 const SHAPE_SIMPLE* poly = static_cast<const SHAPE_SIMPLE*>( shape );
1686
1687 if( poly->PointCount() < 2 ) // Careful of empty pads
1688 break;
1689
1690 if( margin.x < 0 ) // The poly shape must be deflated
1691 {
1692 SHAPE_POLY_SET outline;
1693 outline.NewOutline();
1694
1695 for( int ii = 0; ii < poly->PointCount(); ++ii )
1696 outline.Append( poly->CPoint( ii ) );
1697
1698 outline.Deflate( -margin.x, CORNER_STRATEGY::CHAMFER_ALL_CORNERS,
1699 m_maxError );
1700
1701 m_gal->DrawPolygon( outline );
1702 }
1703 else
1704 {
1705 m_gal->DrawPolygon( poly->Vertices() );
1706 }
1707
1708 // Now add on a rounded margin (using segments) if the margin > 0
1709 if( margin.x > 0 )
1710 {
1711 for( size_t ii = 0; ii < poly->GetSegmentCount(); ++ii )
1712 {
1713 SEG seg = poly->GetSegment( ii );
1714 m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
1715 }
1716 }
1717
1718 break;
1719 }
1720
1721 default:
1722 // Better not get here; we already pre-flighted the shapes...
1723 break;
1724 }
1725 }
1726 }
1727 else
1728 {
1729 // This is expensive. Avoid if possible.
1730 SHAPE_POLY_SET polySet;
1731 aPad->TransformShapeToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x, m_maxError,
1732 ERROR_INSIDE );
1733 m_gal->DrawPolygon( polySet );
1734 }
1735 }
1736
1737 if( ( ( pcbconfig() && pcbconfig()->m_Display.m_PadClearance ) || !pcbconfig() )
1739 {
1740 /*
1741 * Showing the clearance area is not obvious as the clearance extends from the pad on
1742 * flashed copper layers and from the hole on non-flashed copper layers. Because of this,
1743 * we choose to not display clearance lines at all on non-copper active layers as it's
1744 * not clear which we'd be displaying.
1745 */
1747
1748 if( activeLayer == aLayer && IsCopperLayer( activeLayer )
1749 && board->GetVisibleLayers().test( activeLayer ) )
1750 {
1751 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
1753
1755 m_gal->SetIsStroke( true );
1756 m_gal->SetIsFill( false );
1758
1759 int clearance = aPad->GetOwnClearance( activeLayer );
1760
1761 if( aPad->FlashLayer( activeLayer ) && clearance > 0 )
1762 {
1763 auto shape = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape( pcbLayer ) );
1764
1765 if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_SEGMENT )
1766 {
1767 const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape->Shapes()[0];
1768 m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
1769 seg->GetWidth() + 2 * clearance );
1770 }
1771 else if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_CIRCLE )
1772 {
1773 const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape->Shapes()[0];
1774 m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
1775 }
1776 else
1777 {
1778 SHAPE_POLY_SET polySet;
1779
1780 // Use ERROR_INSIDE because it avoids Clipper and is therefore much faster.
1781 aPad->TransformShapeToPolygon( polySet, activeLayer, clearance, m_maxError,
1782 ERROR_INSIDE );
1783
1784 if( polySet.Outline( 0 ).PointCount() > 2 ) // Careful of empty pads
1785 m_gal->DrawPolygon( polySet );
1786 }
1787 }
1788 else if( aPad->GetEffectiveHoleShape() && clearance > 0 )
1789 {
1790 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
1791 m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B,
1792 slot->GetWidth() + 2 * clearance );
1793 }
1794 }
1795 }
1796}
1797
1798
1799void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
1800{
1801 COLOR4D color = m_pcbSettings.GetColor( aShape, aLayer );
1803 int thickness = getLineThickness( aShape->GetWidth() );
1804 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
1805
1806 if( IsSolderMaskLayer( aLayer )
1807 && aShape->HasSolderMask()
1808 && IsExternalCopperLayer( aShape->GetLayer() ) )
1809 {
1810 thickness += aShape->GetSolderMaskExpansion() * 2;
1811 }
1812
1813 if( IsNetnameLayer( aLayer ) )
1814 {
1815 // Net names are shown only in board editor:
1816 if( m_frameType != FRAME_T::FRAME_PCB_EDITOR )
1817 return;
1818
1819 if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
1820 return;
1821
1822 if( aShape->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
1823 return;
1824
1825 wxString netname = aShape->GetDisplayNetname();
1826
1827 if( netname.IsEmpty() )
1828 return;
1829
1830 if( aShape->GetShape() == SHAPE_T::SEGMENT )
1831 {
1832 SHAPE_SEGMENT seg( { aShape->GetStart(), aShape->GetEnd() }, aShape->GetWidth() );
1833 renderNetNameForSegment( seg, color, netname );
1834 return;
1835 }
1836
1837 // TODO: Maybe use some of the pad code?
1838
1839 return;
1840 }
1841
1842 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1843 {
1844 color = m_pcbSettings.GetColor( aShape, aLayer );
1845 thickness = thickness + m_lockedShadowMargin;
1846 }
1847
1848 if( outline_mode )
1849 {
1850 m_gal->SetIsFill( false );
1851 m_gal->SetIsStroke( true );
1853 }
1854
1857
1858 // Note: on LAYER_LOCKED_ITEM_SHADOW always draw shadow shapes as continuous lines
1859 // otherwise the look is very strange and ugly
1860 if( lineStyle <= LINE_STYLE::FIRST_TYPE || aLayer == LAYER_LOCKED_ITEM_SHADOW )
1861 {
1862 switch( aShape->GetShape() )
1863 {
1864 case SHAPE_T::SEGMENT:
1865 if( aShape->IsProxyItem() )
1866 {
1867 std::vector<VECTOR2I> pts;
1868 VECTOR2I offset = ( aShape->GetEnd() - aShape->GetStart() ).Perpendicular();
1869 offset = offset.Resize( thickness / 2 );
1870
1871 pts.push_back( aShape->GetStart() + offset );
1872 pts.push_back( aShape->GetStart() - offset );
1873 pts.push_back( aShape->GetEnd() - offset );
1874 pts.push_back( aShape->GetEnd() + offset );
1875
1877 m_gal->DrawLine( pts[0], pts[1] );
1878 m_gal->DrawLine( pts[1], pts[2] );
1879 m_gal->DrawLine( pts[2], pts[3] );
1880 m_gal->DrawLine( pts[3], pts[0] );
1881 m_gal->DrawLine( ( pts[0] + pts[1] ) / 2, ( pts[1] + pts[2] ) / 2 );
1882 m_gal->DrawLine( ( pts[1] + pts[2] ) / 2, ( pts[2] + pts[3] ) / 2 );
1883 m_gal->DrawLine( ( pts[2] + pts[3] ) / 2, ( pts[3] + pts[0] ) / 2 );
1884 m_gal->DrawLine( ( pts[3] + pts[0] ) / 2, ( pts[0] + pts[1] ) / 2 );
1885 }
1886 else if( outline_mode )
1887 {
1888 m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
1889 }
1890 else
1891 {
1892 m_gal->SetIsFill( true );
1893 m_gal->SetIsStroke( false );
1894
1895 m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
1896 }
1897
1898 break;
1899
1900 case SHAPE_T::RECTANGLE:
1901 {
1902 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1903
1904 if( aShape->IsProxyItem() )
1905 {
1907 m_gal->DrawLine( pts[0], pts[1] );
1908 m_gal->DrawLine( pts[1], pts[2] );
1909 m_gal->DrawLine( pts[2], pts[3] );
1910 m_gal->DrawLine( pts[3], pts[0] );
1911 m_gal->DrawLine( pts[0], pts[2] );
1912 m_gal->DrawLine( pts[1], pts[3] );
1913 }
1914 else if( outline_mode )
1915 {
1916 m_gal->DrawSegment( pts[0], pts[1], thickness );
1917 m_gal->DrawSegment( pts[1], pts[2], thickness );
1918 m_gal->DrawSegment( pts[2], pts[3], thickness );
1919 m_gal->DrawSegment( pts[3], pts[0], thickness );
1920 }
1921 else
1922 {
1923 m_gal->SetIsFill( true );
1924 m_gal->SetIsStroke( false );
1925
1926 if( thickness > 0 )
1927 {
1928 m_gal->DrawSegment( pts[0], pts[1], thickness );
1929 m_gal->DrawSegment( pts[1], pts[2], thickness );
1930 m_gal->DrawSegment( pts[2], pts[3], thickness );
1931 m_gal->DrawSegment( pts[3], pts[0], thickness );
1932 }
1933
1934 if( aShape->IsFilled() )
1935 {
1936 SHAPE_POLY_SET poly;
1937 poly.NewOutline();
1938
1939 for( const VECTOR2I& pt : pts )
1940 poly.Append( pt );
1941
1942 if( thickness < 0 )
1943 {
1944 poly.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
1945 m_maxError );
1946 }
1947
1948 m_gal->DrawPolygon( poly );
1949 }
1950 }
1951
1952 break;
1953 }
1954
1955 case SHAPE_T::ARC:
1956 {
1957 EDA_ANGLE startAngle;
1958 EDA_ANGLE endAngle;
1959 aShape->CalcArcAngles( startAngle, endAngle );
1960
1961 if( outline_mode )
1962 {
1963 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
1964 endAngle - startAngle, thickness, m_maxError );
1965 }
1966 else
1967 {
1968 m_gal->SetIsFill( true );
1969 m_gal->SetIsStroke( false );
1970
1971 m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
1972 endAngle - startAngle, thickness, m_maxError );
1973 }
1974 break;
1975 }
1976
1977 case SHAPE_T::CIRCLE:
1978 if( outline_mode )
1979 {
1980 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() - thickness / 2 );
1981 m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() + thickness / 2 );
1982 }
1983 else
1984 {
1985 m_gal->SetIsFill( aShape->IsFilled() );
1986 m_gal->SetIsStroke( thickness > 0 );
1987 m_gal->SetLineWidth( thickness );
1988
1989 int radius = aShape->GetRadius();
1990
1991 if( thickness < 0 )
1992 {
1993 radius += thickness / 2;
1994 radius = std::max( radius, 0 );
1995 }
1996
1997 m_gal->DrawCircle( aShape->GetStart(), radius );
1998 }
1999 break;
2000
2001 case SHAPE_T::POLY:
2002 {
2003 SHAPE_POLY_SET& shape = const_cast<PCB_SHAPE*>( aShape )->GetPolyShape();
2004
2005 if( shape.OutlineCount() == 0 )
2006 break;
2007
2008 if( outline_mode )
2009 {
2010 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
2011 m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
2012 }
2013 else
2014 {
2015 m_gal->SetIsFill( true );
2016 m_gal->SetIsStroke( false );
2017
2018 if( thickness > 0 )
2019 {
2020 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
2021 m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
2022 }
2023
2024 if( aShape->IsFilled() )
2025 {
2026 // On Opengl, a not convex filled polygon is usually drawn by using triangles
2027 // as primitives. CacheTriangulation() can create basic triangle primitives to
2028 // draw the polygon solid shape on Opengl. GLU tessellation is much slower,
2029 // so currently we are using our tessellation.
2030 if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
2031 shape.CacheTriangulation( true, true );
2032
2033
2034 if( thickness >= 0 )
2035 {
2036 m_gal->DrawPolygon( shape );
2037 }
2038 else
2039 {
2040 SHAPE_POLY_SET deflated_shape = shape;
2041 deflated_shape.Inflate( thickness / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
2042 m_maxError );
2043 m_gal->DrawPolygon( deflated_shape );
2044 }
2045 }
2046 }
2047
2048 break;
2049 }
2050
2051 case SHAPE_T::BEZIER:
2052 if( outline_mode )
2053 {
2054 std::vector<VECTOR2D> output;
2055 std::vector<VECTOR2D> pointCtrl;
2056
2057 pointCtrl.push_back( aShape->GetStart() );
2058 pointCtrl.push_back( aShape->GetBezierC1() );
2059 pointCtrl.push_back( aShape->GetBezierC2() );
2060 pointCtrl.push_back( aShape->GetEnd() );
2061
2062 BEZIER_POLY converter( pointCtrl );
2063 converter.GetPoly( output, m_maxError );
2064
2065 m_gal->DrawSegmentChain( aShape->GetBezierPoints(), thickness );
2066 }
2067 else
2068 {
2069 m_gal->SetIsFill( aShape->IsFilled() );
2070 m_gal->SetIsStroke( thickness > 0 );
2071 m_gal->SetLineWidth( thickness );
2072
2073 if( aShape->GetBezierPoints().size() > 2 )
2074 {
2075 m_gal->DrawPolygon( aShape->GetBezierPoints() );
2076 }
2077 else
2078 {
2079 m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
2080 VECTOR2D( aShape->GetBezierC1() ),
2081 VECTOR2D( aShape->GetBezierC2() ),
2082 VECTOR2D( aShape->GetEnd() ), m_maxError );
2083 }
2084 }
2085
2086 break;
2087
2088 case SHAPE_T::UNDEFINED:
2089 break;
2090 }
2091 }
2092 else
2093 {
2094 if( !outline_mode )
2095 {
2096 m_gal->SetIsFill( true );
2097 m_gal->SetIsStroke( false );
2098 }
2099
2100 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
2101
2102 for( SHAPE* shape : shapes )
2103 {
2104 STROKE_PARAMS::Stroke( shape, lineStyle, getLineThickness( aShape->GetWidth() ),
2106 [&]( const VECTOR2I& a, const VECTOR2I& b )
2107 {
2108 m_gal->DrawSegment( a, b, thickness );
2109 } );
2110 }
2111
2112 for( SHAPE* shape : shapes )
2113 delete shape;
2114 }
2115}
2116
2117
2118void PCB_PAINTER::strokeText( const wxString& aText, const VECTOR2I& aPosition,
2119 const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
2120{
2121 KIFONT::FONT* font = aAttrs.m_Font;
2122
2123 if( !font )
2124 font = KIFONT::FONT::GetFont( wxEmptyString, aAttrs.m_Bold, aAttrs.m_Italic );
2125
2126 m_gal->SetIsFill( font->IsOutline() );
2127 m_gal->SetIsStroke( font->IsStroke() );
2128
2129 VECTOR2I pos( aPosition );
2130 VECTOR2I fudge( KiROUND( 0.16 * aAttrs.m_StrokeWidth ), 0 );
2131
2132 RotatePoint( fudge, aAttrs.m_Angle );
2133
2134 if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && !aAttrs.m_Mirrored )
2135 || ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && aAttrs.m_Mirrored ) )
2136 {
2137 pos -= fudge;
2138 }
2139 else if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && !aAttrs.m_Mirrored )
2140 || ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && aAttrs.m_Mirrored ) )
2141 {
2142 pos += fudge;
2143 }
2144
2145 font->Draw( m_gal, aText, pos, aAttrs, aFontMetrics );
2146}
2147
2148
2149void PCB_PAINTER::draw( const PCB_REFERENCE_IMAGE* aBitmap, int aLayer )
2150{
2151 m_gal->Save();
2152
2153 const REFERENCE_IMAGE& refImg = aBitmap->GetReferenceImage();
2154 m_gal->Translate( refImg.GetPosition() );
2155
2156 // When the image scale factor is not 1.0, we need to modify the actual as the image scale
2157 // factor is similar to a local zoom
2158 const double img_scale = refImg.GetImageScale();
2159
2160 if( img_scale != 1.0 )
2161 m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
2162
2163 if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
2164 {
2166 m_gal->SetIsStroke( true );
2169 m_gal->SetIsFill( false );
2170
2171 // Draws a bounding box.
2172 VECTOR2D bm_size( refImg.GetSize() );
2173 // bm_size is the actual image size in UI.
2174 // but m_gal scale was previously set to img_scale
2175 // so recalculate size relative to this image size.
2176 bm_size.x /= img_scale;
2177 bm_size.y /= img_scale;
2178 VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
2179 VECTOR2D end = origin + bm_size;
2180
2181 m_gal->DrawRectangle( origin, end );
2182
2183 // Hard code reference images as opaque when selected. Otherwise cached layers will
2184 // not be rendered under the selected image because cached layers are rendered after
2185 // non-cached layers (e.g. bitmaps), which will have a closer Z order.
2186 m_gal->DrawBitmap( refImg.GetImage(), 1.0 );
2187 }
2188 else
2189 m_gal->DrawBitmap( refImg.GetImage(),
2190 m_pcbSettings.GetColor( aBitmap, aBitmap->GetLayer() ).a );
2191
2192 m_gal->Restore();
2193}
2194
2195
2196void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
2197{
2198 wxString resolvedText( aText->GetShownText( true ) );
2199
2200 if( resolvedText.Length() == 0 || !aText->GetAttributes().m_Visible )
2201 return;
2202
2203 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
2204 {
2205 const COLOR4D color = m_pcbSettings.GetColor( aText, aLayer );
2206
2207 m_gal->SetIsFill( true );
2208 m_gal->SetIsStroke( true );
2212
2213 SHAPE_POLY_SET poly;
2214 aText->TransformShapeToPolygon( poly, aText->GetLayer(), 0, m_maxError, ERROR_OUTSIDE );
2215 m_gal->DrawPolygon( poly );
2216
2217 return;
2218 }
2219
2220 const KIFONT::METRICS& metrics = aText->GetFontMetrics();
2221 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
2222 const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
2223 bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
2224
2225 KIFONT::FONT* font = aText->GetFont();
2226
2227 if( !font )
2228 {
2230 aText->IsItalic() );
2231 }
2232
2235 attrs.m_Angle = aText->GetDrawRotation();
2236
2237 if( aText->IsKnockout() )
2238 {
2239 SHAPE_POLY_SET finalPoly;
2240 aText->TransformTextToPolySet( finalPoly, 0, m_maxError, ERROR_INSIDE );
2241 finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
2242
2243 m_gal->SetIsStroke( false );
2244 m_gal->SetIsFill( true );
2245 m_gal->DrawPolygon( finalPoly );
2246 }
2247 else
2248 {
2249 if( outline_mode )
2251 else
2253
2254 if( m_gal->IsFlippedX() && !aText->IsSideSpecific() )
2255 {
2256 VECTOR2I textPos = aText->GetTextPos();
2257 VECTOR2I textWidth = VECTOR2I( aText->GetTextBox().GetWidth(), 0 );
2258 RotatePoint( textWidth, VECTOR2I( 0, 0 ), aText->GetDrawRotation() );
2259
2260 if( attrs.m_Mirrored )
2261 textPos -= textWidth;
2262 else
2263 textPos += textWidth;
2264
2265 attrs.m_Mirrored = !attrs.m_Mirrored;
2266 strokeText( resolvedText, textPos, attrs, metrics );
2267 return;
2268 }
2269
2270 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2271
2272 if( font->IsOutline() )
2273 cache = aText->GetRenderCache( font, resolvedText );
2274
2275 if( cache )
2276 {
2278 m_gal->DrawGlyphs( *cache );
2279 }
2280 else
2281 {
2282 strokeText( resolvedText, aText->GetTextPos(), attrs, metrics );
2283 }
2284 }
2285
2286 // Draw the umbilical line for texts in footprints
2287 FOOTPRINT* fp_parent = aText->GetParentFootprint();
2288
2289 if( fp_parent && aText->IsSelected() )
2290 {
2293 m_gal->DrawLine( aText->GetTextPos(), fp_parent->GetPosition() );
2294 }
2295}
2296
2297
2298void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
2299{
2300 if( aTextBox->Type() == PCB_TABLECELL_T )
2301 {
2302 const PCB_TABLECELL* cell = static_cast<const PCB_TABLECELL*>( aTextBox );
2303
2304 if( cell->GetColSpan() == 0 || cell->GetRowSpan() == 0 )
2305 return;
2306 }
2307
2308 COLOR4D color = m_pcbSettings.GetColor( aTextBox, aLayer );
2309 int thickness = getLineThickness( aTextBox->GetWidth() );
2310 LINE_STYLE lineStyle = aTextBox->GetStroke().GetLineStyle();
2311 wxString resolvedText( aTextBox->GetShownText( true ) );
2312
2313 KIFONT::FONT* font = aTextBox->GetFont();
2314
2315 if( !font )
2316 {
2318 aTextBox->IsItalic() );
2319 }
2320
2321 if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
2322 {
2323 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
2324
2325 m_gal->SetIsFill( true );
2326 m_gal->SetIsStroke( false );
2327 m_gal->SetFillColor( sh_color );
2328 m_gal->SetStrokeColor( sh_color );
2329
2330 // Draw the box with a larger thickness than box thickness to show
2331 // the shadow mask
2332 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
2333 int line_thickness = std::max( thickness*3, pcbIUScale.mmToIU( 0.2 ) );
2334
2335 std::deque<VECTOR2D> dpts;
2336
2337 for( const VECTOR2I& pt : pts )
2338 dpts.push_back( VECTOR2D( pt ) );
2339
2340 dpts.push_back( VECTOR2D( pts[0] ) );
2341
2342 m_gal->SetIsStroke( true );
2343 m_gal->SetLineWidth( line_thickness );
2344 m_gal->DrawPolygon( dpts );
2345 }
2346
2347 if( aTextBox->Type() == PCB_TABLECELL_T )
2348 {
2349 // Selection for tables is done with a background wash, so pass in nullptr to GetColor()
2350 // so we just get the "normal" (un-selected/un-brightened) color for the borders.
2351 color = m_pcbSettings.GetColor( nullptr, aLayer );
2352 }
2353
2356 m_gal->SetIsFill( true );
2357 m_gal->SetIsStroke( false );
2358
2359 if( aTextBox->Type() != PCB_TABLECELL_T && aTextBox->IsBorderEnabled() )
2360 {
2361 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
2362 {
2363 if( thickness > 0 )
2364 {
2365 std::vector<VECTOR2I> pts = aTextBox->GetCorners();
2366
2367 for( size_t ii = 0; ii < pts.size(); ++ii )
2368 m_gal->DrawSegment( pts[ii], pts[( ii + 1 ) % pts.size()], thickness );
2369 }
2370 }
2371 else
2372 {
2373 std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
2374
2375 for( SHAPE* shape : shapes )
2376 {
2377 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
2378 [&]( const VECTOR2I& a, const VECTOR2I& b )
2379 {
2380 m_gal->DrawSegment( a, b, thickness );
2381 } );
2382 }
2383
2384 for( SHAPE* shape : shapes )
2385 delete shape;
2386 }
2387 }
2388
2389 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
2390 {
2391 // For now, the textbox is a filled shape.
2392 // so the text drawn on LAYER_LOCKED_ITEM_SHADOW with a thick width is disabled
2393 // If enabled, the thick text position must be offsetted to be exactly on the
2394 // initial text, which is not easy, depending on its rotation and justification.
2395#if 0
2396 const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
2397 m_gal->SetFillColor( sh_color );
2398 m_gal->SetStrokeColor( sh_color );
2399 attrs.m_StrokeWidth += m_lockedShadowMargin;
2400#else
2401 return;
2402#endif
2403 }
2404
2405 if( resolvedText.Length() == 0 )
2406 return;
2407
2408 const KIFONT::METRICS& metrics = aTextBox->GetFontMetrics();
2409 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
2411
2412 if( m_gal->IsFlippedX() && !aTextBox->IsSideSpecific() )
2413 {
2414 attrs.m_Mirrored = !attrs.m_Mirrored;
2415 strokeText( resolvedText, aTextBox->GetDrawPos( true ), attrs, metrics );
2416 return;
2417 }
2418
2419 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2420
2421 if( font->IsOutline() )
2422 cache = aTextBox->GetRenderCache( font, resolvedText );
2423
2424 if( cache )
2425 {
2427 m_gal->DrawGlyphs( *cache );
2428 }
2429 else
2430 {
2431 strokeText( resolvedText, aTextBox->GetDrawPos(), attrs, metrics );
2432 }
2433}
2434
2435
2436void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
2437{
2438 if( aTable->GetCells().empty() )
2439 return;
2440
2441 for( PCB_TABLECELL* cell : aTable->GetCells() )
2442 draw( static_cast<PCB_TEXTBOX*>( cell ), aLayer );
2443
2444 VECTOR2I pos = aTable->GetPosition();
2445 VECTOR2I end = aTable->GetEnd();
2446
2447 // Selection for tables is done with a background wash, so pass in nullptr to GetColor()
2448 // so we just get the "normal" (un-selected/un-brightened) color for the borders.
2449 COLOR4D color = m_pcbSettings.GetColor( nullptr, aLayer );
2450 int lineWidth;
2451 LINE_STYLE lineStyle;
2452
2453 auto setupStroke =
2454 [&]( const STROKE_PARAMS& stroke )
2455 {
2456 lineWidth = getLineThickness( stroke.GetWidth() );
2457 lineStyle = stroke.GetLineStyle();
2458
2459 m_gal->SetIsFill( false );
2460 m_gal->SetIsStroke( true );
2462 m_gal->SetLineWidth( lineWidth );
2463 };
2464
2465 auto strokeShape =
2466 [&]( const SHAPE& shape )
2467 {
2468 STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, &m_pcbSettings,
2469 [&]( VECTOR2I a, VECTOR2I b )
2470 {
2471 // DrawLine has problem with 0 length lines so enforce minimum
2472 if( a == b )
2473 m_gal->DrawLine( a+1, b );
2474 else
2475 m_gal->DrawLine( a, b );
2476 } );
2477 };
2478
2479 auto strokeLine =
2480 [&]( VECTOR2I ptA, VECTOR2I ptB )
2481 {
2482 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
2483 {
2484 m_gal->DrawLine( ptA, ptB );
2485 }
2486 else
2487 {
2488 SHAPE_SEGMENT seg( ptA, ptB );
2489 strokeShape( seg );
2490 }
2491 };
2492
2493 auto strokeRect =
2494 [&]( VECTOR2I ptA, VECTOR2I ptB )
2495 {
2496 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
2497 {
2498 m_gal->DrawRectangle( ptA, ptB );
2499 }
2500 else
2501 {
2502 SHAPE_RECT rect( BOX2I( ptA, ptB - ptA ) );
2503 strokeShape( rect );
2504 }
2505 };
2506
2507 if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
2508 {
2509 setupStroke( aTable->GetSeparatorsStroke() );
2510
2511 if( aTable->StrokeColumns() )
2512 {
2513 for( int col = 0; col < aTable->GetColCount() - 1; ++col )
2514 {
2515 for( int row = 0; row < aTable->GetRowCount(); ++row )
2516 {
2517 PCB_TABLECELL* cell = aTable->GetCell( row, col );
2518 VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
2519
2520 if( !cell->GetTextAngle().IsHorizontal() )
2521 topRight = VECTOR2I( cell->GetStartX(), cell->GetEndY() );
2522
2523 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
2524 strokeLine( topRight, cell->GetEnd() );
2525 }
2526 }
2527 }
2528
2529 if( aTable->StrokeRows() )
2530 {
2531 for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
2532 {
2533 for( int col = 0; col < aTable->GetColCount(); ++col )
2534 {
2535 PCB_TABLECELL* cell = aTable->GetCell( row, col );
2536 VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
2537
2538 if( !cell->GetTextAngle().IsHorizontal() )
2539 botLeft = VECTOR2I( cell->GetEndX(), cell->GetStartY() );
2540
2541 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
2542 strokeLine( botLeft, cell->GetEnd() );
2543 }
2544 }
2545 }
2546 }
2547
2548 if( aTable->GetBorderStroke().GetWidth() >= 0 )
2549 {
2550 PCB_TABLECELL* first = aTable->GetCell( 0, 0 );
2551
2552 setupStroke( aTable->GetBorderStroke() );
2553
2554 if( aTable->StrokeHeader() )
2555 {
2556 if( !first->GetTextAngle().IsHorizontal() )
2557 strokeLine( VECTOR2I( first->GetEndX(), pos.y ), VECTOR2I( first->GetEndX(), first->GetEndY() ) );
2558 else
2559 strokeLine( VECTOR2I( pos.x, first->GetEndY() ), VECTOR2I( end.x, first->GetEndY() ) );
2560 }
2561
2562 if( aTable->StrokeExternal() )
2563 {
2564 RotatePoint( pos, aTable->GetPosition(), first->GetTextAngle() );
2565 RotatePoint( end, aTable->GetPosition(), first->GetTextAngle() );
2566
2567 strokeRect( pos, end );
2568 }
2569 }
2570
2571 // Highlight selected tablecells with a background wash.
2572 for( PCB_TABLECELL* cell : aTable->GetCells() )
2573 {
2574 if( aTable->IsSelected() || cell->IsSelected() )
2575 {
2576 std::vector<VECTOR2I> corners = cell->GetCorners();
2577 std::deque<VECTOR2D> pts;
2578
2579 pts.insert( pts.end(), corners.begin(), corners.end() );
2580
2581 m_gal->SetFillColor( color.WithAlpha( 0.5 ) );
2582 m_gal->SetIsFill( true );
2583 m_gal->SetIsStroke( false );
2584 m_gal->DrawPolygon( pts );
2585 }
2586 }
2587}
2588
2589
2590void PCB_PAINTER::draw( const FOOTPRINT* aFootprint, int aLayer )
2591{
2592 if( aLayer == LAYER_ANCHOR )
2593 {
2594 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2595
2596 // Keep the size and width constant, not related to the scale because the anchor
2597 // is just a marker on screen
2598 double anchorSize = 5.0 / m_gal->GetWorldScale(); // 5 pixels size
2599 double anchorThickness = 1.0 / m_gal->GetWorldScale(); // 1 pixels width
2600
2601 // Draw anchor
2602 m_gal->SetIsFill( false );
2603 m_gal->SetIsStroke( true );
2605 m_gal->SetLineWidth( anchorThickness );
2606
2607 VECTOR2D center = aFootprint->GetPosition();
2608 m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
2609 m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
2610 }
2611
2612 if( aLayer == LAYER_LOCKED_ITEM_SHADOW && m_frameType == FRAME_PCB_EDITOR ) // happens only if locked
2613 {
2614 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2615
2616 m_gal->SetIsFill( true );
2617 m_gal->SetIsStroke( false );
2619
2620#if 0 // GetBoundingHull() can be very slow, especially for logos imported from graphics
2621 const SHAPE_POLY_SET& poly = aFootprint->GetBoundingHull();
2622 m_gal->DrawPolygon( poly );
2623#else
2624 BOX2I bbox = aFootprint->GetBoundingBox( false );
2625 VECTOR2I topLeft = bbox.GetPosition();
2626 VECTOR2I botRight = bbox.GetPosition() + bbox.GetSize();
2627
2628 m_gal->DrawRectangle( topLeft, botRight );
2629
2630 // Use segments to produce a margin with rounded corners
2631 m_gal->DrawSegment( topLeft, VECTOR2I( botRight.x, topLeft.y ), m_lockedShadowMargin );
2632 m_gal->DrawSegment( VECTOR2I( botRight.x, topLeft.y ), botRight, m_lockedShadowMargin );
2633 m_gal->DrawSegment( botRight, VECTOR2I( topLeft.x, botRight.y ), m_lockedShadowMargin );
2634 m_gal->DrawSegment( VECTOR2I( topLeft.x, botRight.y ), topLeft, m_lockedShadowMargin );
2635#endif
2636 }
2637
2638 if( aLayer == LAYER_CONFLICTS_SHADOW )
2639 {
2640 const SHAPE_POLY_SET& frontpoly = aFootprint->GetCourtyard( F_CrtYd );
2641 const SHAPE_POLY_SET& backpoly = aFootprint->GetCourtyard( B_CrtYd );
2642
2643 const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
2644
2645 m_gal->SetIsFill( true );
2646 m_gal->SetIsStroke( false );
2648
2649 if( frontpoly.OutlineCount() > 0 )
2650 m_gal->DrawPolygon( frontpoly );
2651
2652 if( backpoly.OutlineCount() > 0 )
2653 m_gal->DrawPolygon( backpoly );
2654 }
2655}
2656
2657
2658void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
2659{
2660 if( aLayer == LAYER_ANCHOR )
2661 {
2662 if( aGroup->IsSelected() && !( aGroup->GetParent() && aGroup->GetParent()->IsSelected() ) )
2663 {
2664 // Selected on our own; draw enclosing box
2665 }
2666 else if( aGroup->IsEntered() )
2667 {
2668 // Entered group; draw enclosing box
2669 }
2670 else
2671 {
2672 // Neither selected nor entered; draw nothing at the group level (ie: only draw
2673 // its members)
2674 return;
2675 }
2676
2677 const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
2678
2681
2682 BOX2I bbox = aGroup->GetBoundingBox();
2683 VECTOR2I topLeft = bbox.GetPosition();
2684 VECTOR2I width = VECTOR2I( bbox.GetWidth(), 0 );
2685 VECTOR2I height = VECTOR2I( 0, bbox.GetHeight() );
2686
2687 m_gal->DrawLine( topLeft, topLeft + width );
2688 m_gal->DrawLine( topLeft + width, topLeft + width + height );
2689 m_gal->DrawLine( topLeft + width + height, topLeft + height );
2690 m_gal->DrawLine( topLeft + height, topLeft );
2691
2692 wxString name = aGroup->GetName();
2693
2694 if( name.IsEmpty() )
2695 return;
2696
2697 int ptSize = 12;
2698 int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
2699 int unscaledSize = pcbIUScale.MilsToIU( ptSize );
2700
2701 // Scale by zoom a bit, but not too much
2702 int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
2703 VECTOR2I textOffset = VECTOR2I( width.x / 2, -KiROUND( textSize * 0.5 ) );
2704 VECTOR2I titleHeight = VECTOR2I( 0, KiROUND( textSize * 2.0 ) );
2705
2706 if( PrintableCharCount( name ) * textSize < bbox.GetWidth() )
2707 {
2708 m_gal->DrawLine( topLeft, topLeft - titleHeight );
2709 m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
2710 m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
2711
2712 TEXT_ATTRIBUTES attrs;
2713 attrs.m_Italic = true;
2716 attrs.m_Size = VECTOR2I( textSize, textSize );
2717 attrs.m_StrokeWidth = GetPenSizeForNormal( textSize );
2718
2719 KIFONT::FONT::GetFont()->Draw( m_gal, aGroup->GetName(), topLeft + textOffset, attrs,
2720 aGroup->GetFontMetrics() );
2721 }
2722 }
2723}
2724
2725
2726void PCB_PAINTER::draw( const ZONE* aZone, int aLayer )
2727{
2728 if( aLayer == LAYER_CONFLICTS_SHADOW )
2729 {
2730 COLOR4D color = m_pcbSettings.GetColor( aZone, aLayer );
2731
2732 m_gal->SetIsFill( true );
2733 m_gal->SetIsStroke( false );
2735
2736 m_gal->DrawPolygon( aZone->Outline()->Outline( 0 ) );
2737 return;
2738 }
2739
2740 /*
2741 * aLayer will be the virtual zone layer (LAYER_ZONE_START, ... in GAL_LAYER_ID)
2742 * This is used for draw ordering in the GAL.
2743 * The color for the zone comes from the associated copper layer ( aLayer - LAYER_ZONE_START )
2744 * and the visibility comes from the combination of that copper layer and LAYER_ZONES
2745 */
2746 PCB_LAYER_ID layer;
2747
2748 if( IsZoneFillLayer( aLayer ) )
2749 layer = ToLAYER_ID( aLayer - LAYER_ZONE_START );
2750 else
2751 layer = ToLAYER_ID( aLayer );
2752
2753 if( !aZone->IsOnLayer( layer ) )
2754 return;
2755
2756 COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
2757 std::deque<VECTOR2D> corners;
2759
2760 // Draw the outline
2761 if( !IsZoneFillLayer( aLayer ) )
2762 {
2763 const SHAPE_POLY_SET* outline = aZone->Outline();
2764 bool allowDrawOutline = aZone->GetHatchStyle() != ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER;
2765
2766 if( allowDrawOutline && !m_pcbSettings.m_isPrinting && outline && outline->OutlineCount() > 0 )
2767 {
2768 m_gal->SetStrokeColor( color.a > 0.0 ? color.WithAlpha( 1.0 ) : color );
2769 m_gal->SetIsFill( false );
2770 m_gal->SetIsStroke( true );
2772
2773 // Draw each contour (main contour and holes)
2774
2775 /*
2776 * m_gal->DrawPolygon( *outline );
2777 * should be enough, but currently does not work to draw holes contours in a complex
2778 * polygon so each contour is draw as a simple polygon
2779 */
2780
2781 // Draw the main contour(s?)
2782 for( int ii = 0; ii < outline->OutlineCount(); ++ii )
2783 {
2784 m_gal->DrawPolyline( outline->COutline( ii ) );
2785
2786 // Draw holes
2787 int holes_count = outline->HoleCount( ii );
2788
2789 for( int jj = 0; jj < holes_count; ++jj )
2790 m_gal->DrawPolyline( outline->CHole( ii, jj ) );
2791 }
2792
2793 // Draw hatch lines
2794 for( const SEG& hatchLine : aZone->GetHatchLines() )
2795 m_gal->DrawLine( hatchLine.A, hatchLine.B );
2796 }
2797 }
2798
2799 // Draw the filling
2800 if( IsZoneFillLayer( aLayer )
2801 && ( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED
2802 || displayMode == ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS
2803 || displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) )
2804 {
2805 const std::shared_ptr<SHAPE_POLY_SET>& polySet = aZone->GetFilledPolysList( layer );
2806
2807 if( polySet->OutlineCount() == 0 ) // Nothing to draw
2808 return;
2809
2812 m_gal->SetLineWidth( 0 );
2813
2814 if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
2815 {
2816 m_gal->SetIsFill( true );
2817 m_gal->SetIsStroke( false );
2818 }
2819 else
2820 {
2821 m_gal->SetIsFill( false );
2822 m_gal->SetIsStroke( true );
2823 }
2824
2825 // On Opengl, a not convex filled polygon is usually drawn by using triangles
2826 // as primitives. CacheTriangulation() can create basic triangle primitives to
2827 // draw the polygon solid shape on Opengl. GLU tessellation is much slower,
2828 // so currently we are using our tessellation.
2829 if( m_gal->IsOpenGlEngine() && !polySet->IsTriangulationUpToDate() )
2830 polySet->CacheTriangulation( true, true );
2831
2832 m_gal->DrawPolygon( *polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION );
2833 }
2834}
2835
2836
2837void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
2838{
2839 const COLOR4D& color = m_pcbSettings.GetColor( aDimension, aLayer );
2840
2843 m_gal->SetIsFill( false );
2844 m_gal->SetIsStroke( true );
2845
2847
2848 if( outline_mode )
2850 else
2852
2853 // Draw dimension shapes
2854 // TODO(JE) lift this out
2855 for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
2856 {
2857 switch( shape->Type() )
2858 {
2859 case SH_SEGMENT:
2860 {
2861 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
2862 m_gal->DrawLine( seg.A, seg.B );
2863 break;
2864 }
2865
2866 case SH_CIRCLE:
2867 {
2868 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
2869 m_gal->DrawCircle( shape->Centre(), radius );
2870 break;
2871 }
2872
2873 default:
2874 break;
2875 }
2876 }
2877
2878 // Draw text
2879 wxString resolvedText = aDimension->GetShownText( true );
2880 TEXT_ATTRIBUTES attrs = aDimension->GetAttributes();
2881
2882 if( m_gal->IsFlippedX() && !aDimension->IsSideSpecific() )
2883 attrs.m_Mirrored = !attrs.m_Mirrored;
2884
2885 if( outline_mode )
2887 else
2889
2890 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2891
2892 if( aDimension->GetFont() && aDimension->GetFont()->IsOutline() )
2893 cache = aDimension->GetRenderCache( aDimension->GetFont(), resolvedText );
2894
2895 if( cache )
2896 {
2897 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
2898 m_gal->DrawGlyph( *glyph.get() );
2899 }
2900 else
2901 {
2902 strokeText( resolvedText, aDimension->GetTextPos(), attrs, aDimension->GetFontMetrics() );
2903 }
2904}
2905
2906
2907void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
2908{
2909 const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
2910 VECTOR2D position( aTarget->GetPosition() );
2911 double size, radius;
2912
2913 m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
2914 m_gal->SetStrokeColor( strokeColor );
2915 m_gal->SetIsFill( false );
2916 m_gal->SetIsStroke( true );
2917
2918 m_gal->Save();
2919 m_gal->Translate( position );
2920
2921 if( aTarget->GetShape() )
2922 {
2923 // shape x
2924 m_gal->Rotate( M_PI / 4.0 );
2925 size = 2.0 * aTarget->GetSize() / 3.0;
2926 radius = aTarget->GetSize() / 2.0;
2927 }
2928 else
2929 {
2930 // shape +
2931 size = aTarget->GetSize() / 2.0;
2932 radius = aTarget->GetSize() / 3.0;
2933 }
2934
2935 m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
2936 m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
2937 m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
2938
2939 m_gal->Restore();
2940}
2941
2942
2943void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer )
2944{
2945 switch( aLayer )
2946 {
2948 case LAYER_DRC_ERROR:
2949 case LAYER_DRC_WARNING:
2950 {
2951 bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
2952
2953 // Don't paint invisible markers.
2954 // It would be nice to do this through layer dependencies but we can't do an "or" there today
2955 if( aMarker->GetBoard()
2956 && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
2957 return;
2958
2959 const_cast<PCB_MARKER*>( aMarker )->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) );
2960
2961 SHAPE_LINE_CHAIN polygon;
2962 aMarker->ShapeToPolygon( polygon );
2963
2965 : aMarker->GetColorLayer() );
2966
2967 m_gal->Save();
2968 m_gal->Translate( aMarker->GetPosition() );
2969
2970 if( isShadow )
2971 {
2973 m_gal->SetIsStroke( true );
2974 m_gal->SetLineWidth( aMarker->MarkerScale() );
2975 }
2976 else
2977 {
2979 m_gal->SetIsFill( true );
2980 }
2981
2982 m_gal->DrawPolygon( polygon );
2983 m_gal->Restore();
2984 return;
2985 }
2986 case LAYER_DRC_SHAPE1:
2987 case LAYER_DRC_SHAPE2:
2988 {
2989 if( !aMarker->IsBrightened() )
2990 return;
2991
2992 int arc_to_seg_error = gerbIUScale.mmToIU( 0.005 ); // Allow 5 microns
2993 m_gal->SetLineWidth( aMarker->MarkerScale() );
2994
2995 for( auto& shape :
2996 aLayer == LAYER_DRC_SHAPE1 ? aMarker->GetShapes1() : aMarker->GetShapes2() )
2997 {
2998 m_gal->SetIsFill( shape.IsFilled() );
2999 m_gal->SetIsStroke( aLayer == LAYER_DRC_SHAPE1 ? true : false );
3000 m_gal->SetStrokeColor( shape.GetLineColor() );
3001 m_gal->SetFillColor( shape.GetFillColor() );
3002
3003 switch( shape.GetShape() )
3004 {
3005 case SHAPE_T::SEGMENT:
3006 m_gal->DrawSegment( shape.GetStart(), shape.GetEnd(), shape.GetWidth() );
3007 break;
3008 case SHAPE_T::ARC:
3009 {
3010 EDA_ANGLE startAngle, endAngle;
3011 shape.CalcArcAngles( startAngle, endAngle );
3012 m_gal->DrawArcSegment( shape.GetCenter(), shape.GetRadius(), startAngle,
3013 shape.GetArcAngle(), shape.GetWidth(), arc_to_seg_error );
3014 break;
3015 }
3016 default: break;
3017 }
3018 }
3019 }
3020 }
3021}
3022
3023
int color
Definition: DXF_plotter.cpp:58
const char * name
Definition: DXF_plotter.cpp:57
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
@ ERROR_OUTSIDE
Definition: approximation.h:33
@ ERROR_INSIDE
Definition: approximation.h:34
constexpr int ARC_HIGH_DEF
Definition: base_units.h:120
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr EDA_IU_SCALE gerbIUScale
Definition: base_units.h:107
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
BOX2< VECTOR2I > BOX2I
Definition: box2.h:922
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
Bezier curves to polygon converter.
Definition: bezier_curves.h:38
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:79
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:237
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:133
virtual bool IsKnockout() const
Definition: board_item.h:324
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
Definition: board_item.cpp:243
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:47
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:298
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:257
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:100
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:215
bool IsSideSpecific() const
Definition: board_item.cpp:149
virtual bool IsOnCopperLayer() const
Definition: board_item.h:150
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:778
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:792
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:844
int GetCopperLayerCount() const
Definition: board.cpp:741
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:895
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:249
bool IsHorizontal() const
Definition: eda_angle.h:138
double AsRadians() const
Definition: eda_angle.h:117
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:77
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
bool IsEntered() const
Definition: eda_item.h:111
bool IsSelected() const
Definition: eda_item.h:110
bool IsBrightened() const
Definition: eda_item.h:112
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:213
int GetStartY() const
Definition: eda_shape.h:138
virtual VECTOR2I GetTopLeft() const
Definition: eda_shape.h:201
int GetEndX() const
Definition: eda_shape.h:176
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:326
bool IsFilled() const
Definition: eda_shape.h:98
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:810
int GetRadius() const
Definition: eda_shape.cpp:826
SHAPE_T GetShape() const
Definition: eda_shape.h:132
virtual VECTOR2I GetBotRight() const
Definition: eda_shape.h:202
int GetEndY() const
Definition: eda_shape.h:175
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:174
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:137
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1386
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition: eda_shape.h:269
int GetStartX() const
Definition: eda_shape.h:139
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:210
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:257
bool IsItalic() const
Definition: eda_text.h:156
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
KIFONT::FONT * GetFont() const
Definition: eda_text.h:234
BOX2I GetTextBox(int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:703
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:644
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:218
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:456
bool IsBold() const
Definition: eda_text.h:171
LSET GetPrivateLayers() const
Definition: footprint.h:141
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:1486
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.cpp:2892
VECTOR2I GetPosition() const override
Definition: footprint.h:224
DRAWINGS & GraphicalItems()
Definition: footprint.h:209
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:1295
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:131
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:146
virtual bool IsStroke() const
Definition: font.h:138
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const
Draw a string.
Definition: font.cpp:258
virtual bool IsOutline() const
Definition: font.h:139
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:311
static const COLOR4D CLEAR
Definition: color4d.h:403
COLOR4D & Darken(double aFactor)
Makes the color darker by a given factor.
Definition: color4d.h:226
COLOR4D Inverted() const
Returns an inverted color, alpha remains the same.
Definition: color4d.h:323
COLOR4D & Brighten(double aFactor)
Makes the color brighter by a given factor.
Definition: color4d.h:209
static const COLOR4D WHITE
Definition: color4d.h:401
double a
Alpha component.
Definition: color4d.h:395
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:398
static const COLOR4D BLACK
Definition: color4d.h:402
Abstract interface for drawing on a 2D-surface.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth=0, int aTotal=1)
Draw a polygon representing a font glyph.
virtual void Rotate(double aAngle)
Rotate the context.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetFontBold(const bool aBold)
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
double GetZoomFactor() const
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual void Restore()
Restore the context.
virtual bool IsOpenGlEngine()
Return true if the GAL engine is a OpenGL based type.
void ResetTextAttributes()
Reset text attributes to default styling.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetTextMirrored(const bool aMirrored)
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aWidth, double aMaxError)
Draw an arc segment.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void SetGlyphSize(const VECTOR2I aSize)
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
Draw a cubic bezier spline.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle)
Draw an arc.
void SetFontItalic(bool aItalic)
virtual void DrawBitmap(const BITMAP_BASE &aBitmap, double alphaBlend=1.0)
Draw a bitmap image.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
virtual void BitmapText(const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
Draw a text using a bitmap font.
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
virtual void Save()
Save the context.
virtual void DrawSegmentChain(const std::vector< VECTOR2D > &aPointList, double aWidth)
Draw a chain of rounded segments.
double GetWorldScale() const
Get the world scale.
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:59
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:102
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()
Definition: pcb_painter.cpp:83
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
Definition: pcb_painter.h:242
virtual int getViaDrillSize(const PCB_VIA *aVia) const
Return drill diameter for a via (internal units).
void strokeText(const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs, const KIFONT::METRICS &aFontMetrics)
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
double m_zoneOpacity
Opacity override for filled zones.
Definition: pcb_painter.h:170
double m_trackOpacity
Opacity override for all tracks.
Definition: pcb_painter.h:167
double m_imageOpacity
Opacity override for user images.
Definition: pcb_painter.h:171
double m_viaOpacity
Opacity override for all types of via.
Definition: pcb_painter.h:168
ZONE_DISPLAY_MODE m_ZoneDisplayMode
Definition: pcb_painter.h:145
void LoadColors(const COLOR_SETTINGS *aSettings) override
double m_padOpacity
Opacity override for SMD pads and PTHs.
Definition: pcb_painter.h:169
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
Definition: pcb_painter.h:124
COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
HIGH_CONTRAST_MODE m_ContrastModeDisplay
Definition: pcb_painter.h:146
std::map< int, KIGFX::COLOR4D > m_netColors
Set of net codes that should not have their ratsnest displayed.
Definition: pcb_painter.h:161
NET_COLOR_MODE m_netColorMode
Overrides for specific netclass colors.
Definition: pcb_painter.h:155
static const double MAX_FONT_SIZE
< Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:152
double m_filledShapeOpacity
Opacity override for graphic shapes.
Definition: pcb_painter.h:172
bool GetShowPageLimits() const override
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Load settings related to display options (high-contrast mode, full or outline modes for vias/pads/tra...
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
void SetGapLengthRatio(double aRatio)
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
PCB_LAYER_ID GetActiveLayer() const
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.
bool GetDrawBoundingBoxes() const
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
bool IsBOARD_ITEM() const
Definition: view_item.h:100
double GetForcedTransparency() const
Definition: view_item.h:158
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
PCB_LAYER_ID ExtractLayer() const
Find the first set PCB_LAYER_ID.
Definition: lset.cpp:640
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:686
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:766
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:420
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...
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:295
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:44
COLOR4D GetPcbColor(bool aIsForSave=false) const
Definition: netclass.h:176
bool HasPcbColor() const
Definition: netclass.h:175
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:381
Definition: pad.h:54
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition: pad.cpp:1056
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:367
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition: pad.cpp:340
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:488
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:802
PAD_ATTRIB GetAttribute() const
Definition: pad.h:442
const wxString & GetPinFunction() const
Definition: pad.h:145
const wxString & GetNumber() const
Definition: pad.h:134
bool IsNoConnectPad() const
Definition: pad.cpp:256
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition: pad.h:193
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:1876
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition: pad.cpp:1082
bool IsFreePad() const
Definition: pad.cpp:262
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:410
PAD_DRILL_SHAPE GetDrillShape() const
Definition: pad.h:424
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:1128
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition: pad.cpp:973
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:545
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
Definition: pad.h:266
DISPLAY_OPTIONS m_Display
EDA_ANGLE GetArcAngleStart() const
Definition: pcb_track.cpp:1872
double GetRadius() const
Definition: pcb_track.cpp:1855
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:1862
const VECTOR2I & GetMid() const
Definition: pcb_track.h:305
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_track.h:312
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:52
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_group.cpp:263
wxString GetName() const
Definition: pcb_group.h:66
std::vector< PCB_SHAPE > GetShapes1() const
Definition: pcb_marker.h:146
GAL_LAYER_ID GetColorLayer() const
Definition: pcb_marker.cpp:323
VECTOR2I GetPosition() const override
Definition: pcb_marker.h:69
std::vector< PCB_SHAPE > GetShapes2() const
Definition: pcb_marker.h:147
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:79
int GetWidth() const override
Definition: pcb_shape.cpp:301
bool HasSolderMask() const
Definition: pcb_shape.h:183
int GetSolderMaskExpansion() const
Definition: pcb_shape.cpp:179
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:359
bool IsProxyItem() const override
Definition: pcb_shape.h:114
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:89
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:69
int GetRowSpan() const
Definition: pcb_tablecell.h:65
int GetColSpan() const
Definition: pcb_tablecell.h:62
VECTOR2I GetEnd() const
Definition: pcb_table.cpp:116
bool StrokeRows() const
Definition: pcb_table.h:86
int GetRowCount() const
Definition: pcb_table.h:103
bool StrokeColumns() const
Definition: pcb_table.h:83
bool StrokeExternal() const
Definition: pcb_table.h:53
bool StrokeHeader() const
Definition: pcb_table.h:56
PCB_TABLECELL * GetCell(int aRow, int aCol) const
Definition: pcb_table.h:128
std::vector< PCB_TABLECELL * > GetCells() const
Definition: pcb_table.h:138
int GetColCount() const
Definition: pcb_table.h:101
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition: pcb_table.h:71
const STROKE_PARAMS & GetBorderStroke() const
Definition: pcb_table.h:59
VECTOR2I GetPosition() const override
Definition: pcb_table.cpp:110
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.
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:568
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:133
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...
Definition: pcb_text.cpp:510
EDA_ANGLE GetDrawRotation() const override
Definition: pcb_text.cpp:175
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:937
const VECTOR2I & GetStart() const
Definition: pcb_track.h:122
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:119
virtual int GetWidth() const
Definition: pcb_track.h:116
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:1189
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
Definition: pcb_track.cpp:1225
int GetWidth() const override
Definition: pcb_track.cpp:359
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:976
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:1183
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
Definition: pcb_track.cpp:613
VIATYPE GetViaType() const
Definition: pcb_track.h:409
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)
Definition: pcb_track.cpp:1161
VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:679
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
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
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:333
ecoord SquaredLength() const
Definition: seg.h:338
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:560
int GetRadius() const
Definition: shape_circle.h:118
const VECTOR2I GetCenter() const
Definition: shape_circle.h:123
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
void Fracture(POLYGON_MODE aFastMode)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
bool IsTriangulationUpToDate() const
virtual void CacheTriangulation(bool aPartition=true, bool aSimplify=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const VECTOR2I & GetPosition() const
Definition: shape_rect.h:160
const VECTOR2I GetSize() const
Definition: shape_rect.h:168
int GetWidth() const
Definition: shape_rect.h:176
int GetHeight() const
Definition: shape_rect.h:184
const SEG & GetSeg() const
int GetWidth() const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:42
const SHAPE_LINE_CHAIN & Vertices() const
Return the list of vertices defining this simple polygon.
Definition: shape_simple.h:124
virtual const SEG GetSegment(int aIndex) const override
Definition: shape_simple.h:174
const VECTOR2I & CPoint(int aIndex) const
Return a const reference to a given point in the polygon.
Definition: shape_simple.h:102
int PointCount() const
Return the number of points (vertices) in this polygon.
Definition: shape_simple.h:88
virtual size_t GetSegmentCount() const override
Definition: shape_simple.h:176
An abstract shape on 2D plane.
Definition: shape.h:126
Simple container to manage line stroke parameters.
Definition: stroke_params.h:79
int GetWidth() const
Definition: stroke_params.h:89
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:92
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:73
const std::vector< SEG > & GetHatchLines() const
Definition: zone.h:803
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:620
SHAPE_POLY_SET * Outline()
Definition: zone.h:340
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:561
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:609
@ 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.
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:398
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
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:64
bool IsSolderMaskLayer(int aLayer)
Definition: layer_ids.h:601
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer)
Definition: layer_ids.h:165
@ LAYER_PAD_BK_NETNAMES
Definition: layer_ids.h:166
@ LAYER_PAD_NETNAMES
Definition: layer_ids.h:167
@ NETNAMES_LAYER_ID_START
Definition: layer_ids.h:157
bool IsPcbLayer(int aLayer)
Test whether a layer is a valid layer for Pcbnew.
Definition: layer_ids.h:520
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:706
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:531
@ GAL_LAYER_ID_START
Definition: layer_ids.h:192
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:240
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:235
@ LAYER_CONFLICTS_SHADOW
shadow layer for items flagged conficting
Definition: layer_ids.h:242
@ LAYER_DRC_SHAPE1
Custom shape for DRC marker.
Definition: layer_ids.h:245
@ LAYER_NON_PLATEDHOLES
handle color for not plated holes (holes, not pads)
Definition: layer_ids.h:198
@ LAYER_DRC_EXCLUSION
layer for drc markers which have been individually excluded
Definition: layer_ids.h:237
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:221
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored)
Definition: layer_ids.h:231
@ LAYER_DRC_WARNING
layer for drc markers with SEVERITY_WARNING
Definition: layer_ids.h:236
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition: layer_ids.h:215
@ GAL_LAYER_ID_END
Definition: layer_ids.h:268
@ LAYER_DRC_SHAPE2
Custom shape for DRC marker.
Definition: layer_ids.h:246
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
Definition: layer_ids.h:257
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
Definition: layer_ids.h:202
@ LAYER_MARKER_SHADOWS
shadows for drc markers
Definition: layer_ids.h:238
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:216
@ LAYER_VIA_MICROVIA
to draw micro vias
Definition: layer_ids.h:195
@ LAYER_VIA_THROUGH
to draw usual through hole vias
Definition: layer_ids.h:197
@ LAYER_DRC_ERROR
layer for drc markers with SEVERITY_ERROR
Definition: layer_ids.h:217
@ LAYER_VIA_BBLIND
to draw blind/buried vias
Definition: layer_ids.h:196
@ LAYER_PAD_HOLEWALLS
Definition: layer_ids.h:234
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition: layer_ids.h:721
bool IsHoleLayer(int aLayer)
Definition: layer_ids.h:592
bool IsExternalCopperLayer(int aLayerId)
Tests whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition: layer_ids.h:542
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:135
@ F_Cu
Definition: layer_ids.h:64
bool IsZoneFillLayer(int aLayer)
Definition: layer_ids.h:727
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:820
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: padstack.h:69
Class to handle a set of BOARD_ITEMs.
PCBNEW_SETTINGS * pcbconfig()
Definition: pcb_painter.cpp:75
@ SHOW_WITH_VIA_ALWAYS
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
Definition: pgm_base.cpp:1067
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.
Definition: stroke_params.h:46
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
TRACK_CLEARANCE_MODE m_TrackClearance
@ 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
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:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:105
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:102
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:103
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:110
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:99
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:106
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition: typeinfo.h:95
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:101
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition: typeinfo.h:94
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:104
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
VECTOR2< double > VECTOR2D
Definition: vector2d.h:690