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