KiCad PCB EDA Suite
Loading...
Searching...
No Matches
plot_brditems_plotter.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <algorithm> // for min
21#include <cmath> // for abs
22
23#include <geometry/seg.h> // for SEG
26#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN
27#include <geometry/shape_poly_set.h> // for SHAPE_POLY_SET, SHAPE_P...
28#include <geometry/shape_rect.h>
30#include <string_utils.h>
31#include <macros.h>
32#include <math/util.h> // for KiROUND
33#include <math/vector2d.h> // for VECTOR2I
35#include <trigo.h>
36#include <font/stroke_font.h>
38#include <callback_gal.h>
39#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
40#include <gbr_metadata.h>
41#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
42#include <layer_ids.h> // for LSET, IsCopperLayer
43#include <lset.h>
49#include <pcb_drill_chart.h>
50#include <pcb_drill_map.h>
51#include <pcbplot.h>
52#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
53#include <advanced_config.h>
54
55#include <line_ending.h>
56#include <pcb_dimension.h>
57#include <pcb_shape.h>
58#include <footprint.h>
59#include <pcb_track.h>
60#include <pad.h>
61#include <pcb_target.h>
62#include <pcb_text.h>
63#include <pcb_textbox.h>
64#include <pcb_tablecell.h>
65#include <pcb_table.h>
66#include <zone.h>
67#include <pcb_barcode.h>
68
69#include <wx/debug.h> // for wxASSERT_MSG
70
71
73{
74 COLOR4D color = ColorSettings()->GetColor( aLayer );
75
76 // A hack to avoid plotting a white item in white color on white paper
77 if( color == COLOR4D::WHITE )
78 color = COLOR4D( LIGHTGRAY );
79
80 return color;
81}
82
83
84void BRDITEMS_PLOTTER::PlotPadNumber( const PAD* aPad, const COLOR4D& aColor ) const
85{
86 wxString padNumber = UnescapeString( aPad->GetNumber() );
87
88 if( padNumber.IsEmpty() )
89 return;
90
91 BOX2I padBBox = aPad->GetBoundingBox();
92 VECTOR2I position = padBBox.Centre();
93 VECTOR2I padsize = padBBox.GetSize();
94
95 // TODO(JE) padstacks
97 {
98 // See if we have a number box
99 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives( PADSTACK::TEMP_ALL_LAYERS ) )
100 {
101 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
102 {
103 position = primitive->GetCenter();
104 RotatePoint( position, aPad->GetOrientation() );
105 position += aPad->ShapePos( PADSTACK::TEMP_ALL_LAYERS );
106
107 padsize.x = std::abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
108 padsize.y = std::abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
109
110 break;
111 }
112 }
113 }
114
116 {
117 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
118 int limit = KiROUND( std::min( aPad->GetSize( PADSTACK::TEMP_ALL_LAYERS ).x,
119 aPad->GetSize( PADSTACK::TEMP_ALL_LAYERS ).y ) * 1.1 );
120
121 if( padsize.x > limit && padsize.y > limit )
122 {
123 padsize.x = limit;
124 padsize.y = limit;
125 }
126 }
127
128 TEXT_ATTRIBUTES textAttrs;
129
130 textAttrs.m_Mirrored = m_plotter->GetPlotMirrored();
131
132 if( padsize.x < ( padsize.y * 0.95 ) )
133 {
134 textAttrs.m_Angle = ANGLE_90;
135 std::swap( padsize.x, padsize.y );
136 }
137
138 // approximate the size of the pad number text:
139 // We use a size for at least 3 chars, to give a good look even for short numbers
140 int tsize = KiROUND( padsize.x / std::max( PrintableCharCount( padNumber ), 3 ) );
141 tsize = std::min( tsize, padsize.y );
142
143 // enforce a max size
144 tsize = std::min( tsize, pcbIUScale.mmToIU( 5.0 ) );
145
146 textAttrs.m_Size = VECTOR2I( tsize, tsize );
147
148 // use a somewhat spindly font to go with the outlined pads
149 textAttrs.m_StrokeWidth = KiROUND( tsize / 12.0 );
150
151 m_plotter->PlotText( position, aColor, padNumber, textAttrs );
152}
153
154
155void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, PCB_LAYER_ID aLayer, const COLOR4D& aColor, bool aSketchMode ) const
156{
157 VECTOR2I shape_pos = aPad->ShapePos( aLayer );
158 GBR_METADATA metadata;
159
160 m_plotter->MarkFootprintPlotted( aPad->GetParentFootprint() );
161
162 bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
163 bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
164
165 // Pad not on the solder mask layer cannot be soldered.
166 // therefore it can have a specific aperture attribute.
167 // Not yet in use.
168 // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
169
170 metadata.SetCmpReference( aPad->GetParentFootprint()->GetReference() );
171
172 if( plotOnCopperLayer )
173 {
175 metadata.SetCopper( true );
176
177 // Gives a default attribute, for instance for pads used as tracks in net ties:
178 // Connector pads and SMD pads are on external layers
179 // if on internal layers, they are certainly used as net tie
180 // and are similar to tracks: just conductor items
182
183 const bool useUTF8 = false;
184 const bool useQuoting = false;
185 metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
186
187 if( !aPad->GetNumber().IsEmpty() )
188 metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
189
190 metadata.SetNetName( aPad->GetNetname() );
191
192 // Some pads are mechanical pads ( through hole or smd )
193 // when this is the case, they have no pad name and/or are not plated.
194 // In this case gerber files have slightly different attributes.
195 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
196 metadata.m_NetlistMetadata.m_NotInNet = true;
197
198 if( !plotOnExternalCopperLayer )
199 {
200 // the .P object attribute (GBR_NETLIST_METADATA::GBR_NETINFO_PAD)
201 // is used on outer layers, unless the component is embedded
202 // or a "etched" component (fp only drawn, not a physical component)
203 // Currently, Pcbnew does not handle embedded component, so we disable the .P
204 // attribute on internal layers
205 // Note the Gerber doc is not really clear about through holes pads about the .P
208
209 }
210
211 // Some attributes are reserved to the external copper layers:
212 // GBR_APERTURE_ATTRIB_CONNECTORPAD and GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
213 // for instance.
214 // Pad with type PAD_ATTRIB::CONN or PAD_ATTRIB::SMD that is not on outer layer
215 // has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
216 switch( aPad->GetAttribute() )
217 {
218 case PAD_ATTRIB::NPTH: // Mechanical pad through hole
220 break;
221
222 case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
224 break;
225
226 case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
227 if( plotOnExternalCopperLayer )
229 break;
230
231 case PAD_ATTRIB::NON_COMPONENT: // Non-component only pads on any layer
232 // For now, keep the existing "Conductor" logic above, but this can be changed later if needed.
233 // For example:
234 // metadata.SetApertureAttrib( "internal" );
235 break;
236
237 case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
238 // with solder paste and mask
239 if( plotOnExternalCopperLayer )
241 break;
242 }
243
244 // Fabrication properties can have specific GBR_APERTURE_METADATA options
245 // that replace previous aperture attribute:
246 switch( aPad->GetProperty() )
247 {
248 case PAD_PROP::BGA: // Only applicable to outer layers
249 if( plotOnExternalCopperLayer )
251 break;
252
255 break;
256
259 break;
260
261 case PAD_PROP::TESTPOINT: // Only applicable to outer layers
262 if( plotOnExternalCopperLayer )
264 break;
265
268 break;
269
272 break;
273
274 case PAD_PROP::PRESSFIT: // used only in drill files
275 case PAD_PROP::NONE:
277 break;
278 }
279
280 // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
281 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
283 }
284 else
285 {
287 }
288
289 // Set plot color (change WHITE to LIGHTGRAY because
290 // the white items are not seen on a white paper or screen
291 m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY );
292
293 if( aSketchMode )
294 {
295 switch( aPad->GetShape( aLayer ) )
296 {
298 m_plotter->ThickCircle( shape_pos, aPad->GetSize( aLayer ).x, GetSketchPadLineWidth(),
299 nullptr );
300 break;
301
302 case PAD_SHAPE::OVAL:
303 {
304 m_plotter->ThickOval( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(),
305 GetSketchPadLineWidth(), nullptr );
306 break;
307 }
308
314 {
315 SHAPE_POLY_SET outline;
316 aPad->TransformShapeToPolygon( outline, aLayer, 0, m_plotter->GetPlotterArcHighDef(),
317 ERROR_INSIDE, false );
318
319 m_plotter->ThickPoly( outline, GetSketchPadLineWidth(), nullptr );
320 break;
321 }
322
323 default:
325 }
326
327 return;
328 }
329
330 switch( aPad->GetShape( aLayer ) )
331 {
333 m_plotter->FlashPadCircle( shape_pos, aPad->GetSize( aLayer ).x, &metadata );
334 break;
335
336 case PAD_SHAPE::OVAL:
337 m_plotter->FlashPadOval( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(), &metadata );
338 break;
339
341 m_plotter->FlashPadRect( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(), &metadata );
342 break;
343
345 m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize( aLayer ),
346 aPad->GetRoundRectCornerRadius( aLayer ),
347 aPad->GetOrientation(), &metadata );
348 break;
349
351 {
352 // Build the pad polygon in coordinates relative to the pad
353 // (i.e. for a pad at pos 0,0, rot 0.0). Needed to use aperture macros,
354 // to be able to create a pattern common to all trapezoid pads having the same shape
355 VECTOR2I coord[4];
356
357 // Order is lower left, lower right, upper right, upper left.
358 VECTOR2I half_size = aPad->GetSize( aLayer ) / 2;
359 VECTOR2I trap_delta = aPad->GetDelta( aLayer ) / 2;
360
361 coord[0] = VECTOR2I( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
362 coord[1] = VECTOR2I( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
363 coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
364 coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
365
366 m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), &metadata );
367 break;
368 }
369
371 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
372 {
373 GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
374
375 gerberPlotter->FlashPadChamferRoundRect( shape_pos, aPad->GetSize( aLayer ),
376 aPad->GetRoundRectCornerRadius( aLayer ),
377 aPad->GetChamferRectRatio( aLayer ),
378 aPad->GetChamferPositions( aLayer ),
379 aPad->GetOrientation(), &metadata );
380 break;
381 }
382
384
385 default:
387 {
388 const std::shared_ptr<SHAPE_POLY_SET>& polygons = aPad->GetEffectivePolygon( aLayer, ERROR_INSIDE );
389
390 if( polygons->OutlineCount() )
391 {
392 m_plotter->FlashPadCustom( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(),
393 polygons.get(), &metadata );
394 }
395 }
396 break;
397 }
398}
399
400
402{
403 if( !GetPlotFPText() )
404 return;
405
406 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
407 const bool dnp = aFootprint->GetDNPForVariant( variantName );
408
409 const PCB_TEXT* reference = &aFootprint->Reference();
410 PCB_LAYER_ID refLayer = reference->GetLayer();
411
412 // Reference and value have special controls for forcing their plotting
413 if( GetPlotReference()
414 && m_layerMask[refLayer]
415 && reference->IsVisible()
416 && !( dnp && hideDNPItems( refLayer ) ) )
417 {
418 m_plotter->MarkFootprintPlotted( aFootprint );
419 PlotText( reference, refLayer, reference->IsKnockout(), reference->GetFontMetrics(),
420 dnp && crossoutDNPItems( refLayer ) );
421 }
422
423 const PCB_TEXT* value = &aFootprint->Value();
424 PCB_LAYER_ID valueLayer = value->GetLayer();
425
426 if( GetPlotValue()
427 && m_layerMask[valueLayer]
428 && value->IsVisible()
429 && !( dnp && hideDNPItems( valueLayer ) ) )
430 {
431 m_plotter->MarkFootprintPlotted( aFootprint );
432 PlotText( value, valueLayer, value->IsKnockout(), value->GetFontMetrics(), false );
433 }
434
435 std::vector<PCB_TEXT*> texts;
436
437 // Skip the reference and value texts that are handled specially
438 for( PCB_FIELD* field : aFootprint->GetFields() )
439 {
440 wxCHECK2( field, continue );
441
442 if( field->IsReference() || field->IsValue() )
443 continue;
444
445 if( field->IsVisible() )
446 texts.push_back( field );
447 }
448
449 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
450 {
451 if( PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item ) )
452 texts.push_back( textItem );
453 }
454
455 for( const PCB_TEXT* text : texts )
456 {
457 PCB_LAYER_ID textLayer = text->GetLayer();
458 bool strikeout = false;
459
460 if( textLayer == Edge_Cuts || textLayer >= PCB_LAYER_ID_COUNT )
461 continue;
462
463 if( dnp && hideDNPItems( textLayer ) )
464 continue;
465
466 if( !m_layerMask[textLayer] || aFootprint->GetPrivateLayers().test( textLayer ) )
467 continue;
468
469 if( text->GetText() == wxT( "${REFERENCE}" ) )
470 {
471 if( !GetPlotReference() )
472 continue;
473
474 strikeout = dnp && crossoutDNPItems( textLayer );
475 }
476
477 if( text->GetText() == wxT( "${VALUE}" ) )
478 {
479 if( !GetPlotValue() )
480 continue;
481 }
482
483 m_plotter->MarkFootprintPlotted( aFootprint );
484 PlotText( text, textLayer, text->IsKnockout(), text->GetFontMetrics(), strikeout );
485 }
486}
487
488
490{
491 switch( item->Type() )
492 {
493 case PCB_SHAPE_T:
494 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
495 break;
496
497 case PCB_TEXT_T:
498 {
499 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
500 PlotText( text, text->GetLayer(), text->IsKnockout(), text->GetFontMetrics() );
501 break;
502 }
503
504 case PCB_TEXTBOX_T:
505 {
506 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
507
508 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
509 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() );
510
511 if( textbox->IsBorderEnabled() )
512 {
513 // PlotShape works only for textbox rotated by 0 or 180 degrees.
514 // This is not always the case so use the polygonal shape of the box of the text box.
516 PlotShape( &dummy );
517 }
518
519 m_plotter->SetTextMode( GetTextMode() );
520 break;
521 }
522
523 case PCB_BARCODE_T:
524 PlotBarCode( static_cast<const PCB_BARCODE*>( item ) );
525 break;
526
527 case PCB_TABLE_T:
530 {
531 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
532
533 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
534
535 for( const PCB_TABLECELL* cell : table->GetCells() )
536 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
537
539
540 if( item->Type() == PCB_DRILL_CHART_T )
541 PlotChartSymbols( static_cast<const PCB_DRILL_CHART*>( item ) );
542
543 m_plotter->SetTextMode( GetTextMode() );
544 break;
545 }
546
548 case PCB_DIM_CENTER_T:
549 case PCB_DIM_RADIAL_T:
551 case PCB_DIM_LEADER_T:
552 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
553
554 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
555
556 m_plotter->SetTextMode( GetTextMode() );
557 break;
558
559 case PCB_TARGET_T:
560 PlotPcbTarget( static_cast<const PCB_TARGET*>( item ) );
561 break;
562
563 default:
564 break;
565 }
566}
567
568
570{
571 if( !m_layerMask[aDim->GetLayer()] )
572 return;
573
574 COLOR4D color = ColorSettings()->GetColor( aDim->GetLayer() );
575
576 // Set plot color (change WHITE to LIGHTGRAY because
577 // the white items are not seen on a white paper or screen
578 m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
579
580 PlotText( aDim, aDim->GetLayer(), false, aDim->GetFontMetrics() );
581
582 PCB_SHAPE temp_item;
583
585 temp_item.SetLayer( aDim->GetLayer() );
586
587 for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
588 {
589 switch( shape->Type() )
590 {
591 case SH_SEGMENT:
592 {
593 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
594
595 temp_item.SetShape( SHAPE_T::SEGMENT );
596 temp_item.SetStart( seg.A );
597 temp_item.SetEnd( seg.B );
598
599 PlotShape( &temp_item );
600 break;
601 }
602
603 case SH_CIRCLE:
604 {
605 VECTOR2I start( shape->Centre() );
606 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
607
608 temp_item.SetShape( SHAPE_T::CIRCLE );
609 temp_item.SetFilled( false );
610 temp_item.SetStart( start );
611 temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
612
613 PlotShape( &temp_item );
614 break;
615 }
616
617 default:
618 break;
619 }
620 }
621}
622
623
625{
626 int dx1, dx2, dy1, dy2, radius;
627
628 if( !m_layerMask[aMire->GetLayer()] )
629 return;
630
631 m_plotter->SetColor( getColor( aMire->GetLayer() ) );
632
633 PCB_SHAPE temp_item;
634
635 temp_item.SetShape( SHAPE_T::CIRCLE );
636 temp_item.SetFilled( false );
637 temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), LINE_STYLE::SOLID ) );
638 temp_item.SetLayer( aMire->GetLayer() );
639 temp_item.SetStart( aMire->GetPosition() );
640 radius = aMire->GetSize() / 3;
641
642 if( aMire->GetShape() ) // temp_item X
643 radius = aMire->GetSize() / 2;
644
645 // Draw the circle
646 temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
647
648 PlotShape( &temp_item );
649
650 temp_item.SetShape( SHAPE_T::SEGMENT );
651
652 radius = aMire->GetSize() / 2;
653 dx1 = radius;
654 dy1 = 0;
655 dx2 = 0;
656 dy2 = radius;
657
658 if( aMire->GetShape() ) // Shape X
659 {
660 dx1 = dy1 = radius;
661 dx2 = dx1;
662 dy2 = -dy1;
663 }
664
665 VECTOR2I mirePos( aMire->GetPosition() );
666
667 // Draw the X or + temp_item:
668 temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
669 temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
670 PlotShape( &temp_item );
671
672 temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
673 temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
674 PlotShape( &temp_item );
675}
676
677
679{
680 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
681 const bool dnp = aFootprint->GetDNPForVariant( variantName );
682
683 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
684 {
685 PCB_LAYER_ID itemLayer = item->GetLayer();
686
687 if( aFootprint->GetPrivateLayers().test( itemLayer ) )
688 continue;
689
690 if( dnp && hideDNPItems( itemLayer ) )
691 continue;
692
693 if( !( m_layerMask & item->GetLayerSet() ).any() )
694 continue;
695
696 m_plotter->MarkFootprintPlotted( aFootprint );
697
698 switch( item->Type() )
699 {
700 case PCB_SHAPE_T:
701 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
702 break;
703
704 case PCB_TEXTBOX_T:
705 {
706 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
707
708 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
709
710 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(),
711 textbox->GetFontMetrics() );
712
713 if( textbox->IsBorderEnabled() )
714 {
715 // PlotShape works only for textbox rotated by 0 or 180 degrees.
716 // This is not always the case so use the polygonal shape
718 PlotShape( &dummy );
719 }
720
721 m_plotter->SetTextMode( GetTextMode() );
722 break;
723 }
724
725 case PCB_BARCODE_T:
726 PlotBarCode( static_cast<const PCB_BARCODE*>( item ) );
727 break;
728
729 case PCB_TABLE_T:
732 {
733 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
734
735 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
736
737 for( const PCB_TABLECELL* cell : table->GetCells() )
738 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
739
741
742 m_plotter->SetTextMode( GetTextMode() );
743 break;
744 }
745
747 case PCB_DIM_CENTER_T:
748 case PCB_DIM_RADIAL_T:
750 case PCB_DIM_LEADER_T:
751 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
752 break;
753
754 case PCB_TEXT_T:
755 // Plotted in PlotFootprintTextItems()
756 break;
757
759 // Not plotted at all
760 break;
761
762 default:
763 UNIMPLEMENTED_FOR( item->GetClass() );
764 }
765 }
766}
767
768
769static void* plotMetadata( PLOTTER* aPlotter, GBR_METADATA& aMetadata, const PLOT_PARAMS* aPlotOptions )
770{
771 // Gerber writes its metadata through the plotters' opaque data parameter, so that parameter
772 // stays void*. DXF instead reads the sketch/filled mode back out of the plot options and
773 // never writes to them, which is what lets a const plot hand them over at all.
774 switch( aPlotter->GetPlotterType() )
775 {
776 case PLOT_FORMAT::GERBER: return &aMetadata;
777 case PLOT_FORMAT::DXF: return const_cast<PLOT_PARAMS*>( aPlotOptions );
778 default: return nullptr;
779 }
780}
781
782
783#define getMetadata() plotMetadata( m_plotter, gbr_metadata, this )
784
785
786void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
787 const KIFONT::METRICS& aFontMetrics, bool aStrikeout ) const
788{
789 int maxError = m_board->GetDesignSettings().m_MaxError;
790 KIFONT::FONT* font = aText->GetDrawFont( m_plotter->RenderSettings() );
791 wxString shownText( aText->GetShownText( FOR_CANVAS ) );
792
793 const PCB_TEXTBOX* knockoutBox = aIsKnockout ? dynamic_cast<const PCB_TEXTBOX*>( aText ) : nullptr;
794
795 if( shownText.IsEmpty() && !knockoutBox )
796 return;
797
798 if( !m_layerMask[aLayer] )
799 return;
800
801 GBR_METADATA gbr_metadata;
802
803 if( IsCopperLayer( aLayer ) )
805
806 COLOR4D color = getColor( aLayer );
807 m_plotter->SetColor( color );
808
809 const VECTOR2I& pos = aText->GetTextPos();
810
811 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
812 attrs.m_Size = aText->GetTextSize();
814 attrs.m_Angle = aText->GetDrawRotation();
815 attrs.m_Multiline = false;
816
817 m_plotter->SetCurrentLineWidth( attrs.m_StrokeWidth );
818
819 const auto strikeoutText =
820 [&]( const PCB_TEXT* text )
821 {
822 SHAPE_POLY_SET textPoly;
823
824 text->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
825 textPoly.Rotate( -text->GetDrawRotation(), text->GetDrawPos() );
826
827 BOX2I rect = textPoly.BBox();
828 VECTOR2I start( rect.GetLeft() - attrs.m_StrokeWidth,
829 ( rect.GetTop() + rect.GetBottom() ) / 2 );
830 VECTOR2I end( rect.GetRight() + attrs.m_StrokeWidth,
831 ( rect.GetTop() + rect.GetBottom() ) / 2 );
832
833 RotatePoint( start, text->GetDrawPos(), text->GetDrawRotation() );
834 RotatePoint( end, text->GetDrawPos(), text->GetDrawRotation() );
835
836 m_plotter->ThickSegment( start, end, attrs.m_StrokeWidth, getMetadata() );
837 };
838
839 if( aIsKnockout )
840 {
841 SHAPE_POLY_SET finalPoly;
842
843 if( knockoutBox )
844 knockoutBox->TransformTextToPolySet( finalPoly, 0, maxError, ERROR_INSIDE );
845 else if( const PCB_TEXT* text = dynamic_cast<const PCB_TEXT*>( aText ) )
846 text->TransformTextToPolySet( finalPoly, 0, maxError, ERROR_INSIDE );
847
848 finalPoly.Fracture();
849
850 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
851 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, getMetadata() );
852 }
853 else
854 {
855 if( font->IsOutline() && !m_board->GetEmbeddedFiles()->GetAreFontsEmbedded() )
856 {
858
859 CALLBACK_GAL callback_gal( empty_opts,
860 // Stroke callback
861 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
862 {
863 m_plotter->ThickSegment( aPt1, aPt2, attrs.m_StrokeWidth, getMetadata() );
864 },
865 // Polygon callback
866 [&]( const SHAPE_LINE_CHAIN& aPoly )
867 {
868 m_plotter->PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, getMetadata() );
869 } );
870
871 callback_gal.DrawGlyphs( *aText->GetRenderCache( font, shownText ) );
872 }
873 else if( aText->IsMultilineAllowed() )
874 {
875 std::vector<VECTOR2I> positions;
876 wxArrayString strings_list;
877 wxStringSplit( shownText, strings_list, '\n' );
878 positions.reserve( strings_list.Count() );
879
880 aText->GetLinePositions( m_plotter->RenderSettings(), positions, (int) strings_list.Count() );
881
882 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
883 {
884 wxString& txt = strings_list.Item( ii );
885 m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics, getMetadata() );
886 }
887
888 if( aStrikeout && strings_list.Count() == 1 )
889 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
890 }
891 else
892 {
893 m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, getMetadata() );
894
895 if( aStrikeout )
896 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
897 }
898 }
899}
900
901
902void BRDITEMS_PLOTTER::PlotZone( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList ) const
903{
904 if( aPolysList.IsEmpty() )
905 return;
906
907 GBR_METADATA gbr_metadata;
908
909 if( aZone->IsOnCopperLayer() )
910 {
911 gbr_metadata.SetNetName( aZone->GetNetname() );
912 gbr_metadata.SetCopper( true );
913
914 // Zones with no net name can exist.
915 // they are not used to connect items, so the aperture attribute cannot
916 // be set as conductor
917 if( aZone->GetNetname().IsEmpty() )
918 {
920 }
921 else
922 {
925 }
926 }
927
928 m_plotter->SetColor( getColor( aLayer ) );
929
930 m_plotter->StartBlock( nullptr ); // Clean current object attributes
931
932 /*
933 * In non filled mode the outline is plotted, but not the filling items
934 */
935
936 for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
937 {
938 const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
939
940 // Plot the current filled area (as region for Gerber plotter to manage attributes)
941 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
942 {
943 static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline, &gbr_metadata );
944 }
945 else if( m_plotter->GetPlotterType() == PLOT_FORMAT::DXF )
946 {
947 if( GetDXFPlotMode() == FILLED )
948 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, getMetadata() );
949 }
950 else
951 {
952 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, getMetadata() );
953 }
954 }
955
956 m_plotter->EndBlock( nullptr ); // Clear object attributes
957}
958
959
960void BRDITEMS_PLOTTER::PlotShape( const PCB_SHAPE* aShape ) const
961{
962 if( !( m_layerMask & aShape->GetLayerSet() ).any() )
963 return;
964
965 int thickness = aShape->GetWidth();
966 int margin = thickness; // unclamped thickness (can be negative)
967 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
968 bool onCopperLayer = ( LSET::AllCuMask() & m_layerMask ).any();
969 bool onSolderMaskLayer = ( LSET( { F_Mask, B_Mask } ) & m_layerMask ).any();
970 bool isSolidFill = aShape->IsSolidFill();
971 bool isHatchedFill = aShape->IsHatchedFill();
972
973 if( onSolderMaskLayer
974 && aShape->HasSolderMask()
975 && IsExternalCopperLayer( aShape->GetLayer() ) )
976 {
977 margin += 2 * aShape->GetSolderMaskExpansion();
978 thickness = std::max( margin, 0 );
979
980 if( isHatchedFill )
981 {
982 isSolidFill = true;
983 isHatchedFill = false;
984 }
985 }
986
987 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
988
989 const FOOTPRINT* parentFP = aShape->GetParentFootprint();
990 GBR_METADATA gbr_metadata;
991 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
992 const bool parentDnp = parentFP ? parentFP->GetDNPForVariant( variantName ) : false;
993
994 if( parentFP )
995 {
996 gbr_metadata.SetCmpReference( parentFP->GetReference() );
998 }
999
1000 if( parentFP && parentDnp && GetSketchDNPFPsOnFabLayers() )
1001 {
1002 if( aShape->GetLayer() == F_Fab || aShape->GetLayer() == B_Fab )
1003 {
1004 thickness = GetSketchPadLineWidth();
1005 isSolidFill = false;
1006 isHatchedFill = false;
1007 }
1008 }
1009
1010 if( aShape->GetLayer() == Edge_Cuts )
1011 {
1013 }
1014 else if( onCopperLayer )
1015 {
1016 if( parentFP )
1017 {
1019 gbr_metadata.SetCopper( true );
1020 }
1021 else if( aShape->GetNetCode() > 0 )
1022 {
1023 gbr_metadata.SetCopper( true );
1026 gbr_metadata.SetNetName( aShape->GetNetname() );
1027 }
1028 else
1029 {
1030 // Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
1031 // Graphic items having a net have the Conductor attribute, but are not (yet?)
1032 // supported in Pcbnew
1034 }
1035 }
1036
1037 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
1038 {
1039 switch( aShape->GetShape() )
1040 {
1041 case SHAPE_T::SEGMENT:
1042 {
1043 VECTOR2I segStart = aShape->GetStart();
1044 VECTOR2I segEnd = aShape->GetEnd();
1045
1046 if( EDA_SHAPE::ShortenSegmentForEndings( segStart, segEnd, aShape->GetStartEnding(), aShape->GetEndEnding(),
1047 thickness ) )
1048 {
1049 m_plotter->ThickSegment( segStart, segEnd, thickness, getMetadata() );
1050 }
1051
1052 break;
1053 }
1054
1055 case SHAPE_T::CIRCLE:
1056 if( isSolidFill )
1057 {
1058 int diameter = aShape->GetRadius() * 2 + thickness;
1059
1060 if( margin < 0 )
1061 {
1062 diameter += margin;
1063 diameter = std::max( diameter, 0 );
1064 }
1065
1066 m_plotter->FilledCircle( aShape->GetStart(), diameter, getMetadata() );
1067 }
1068 else
1069 {
1070 m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness, getMetadata() );
1071 }
1072
1073 break;
1074
1075 case SHAPE_T::ARC:
1076 {
1077 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
1078 // but it is a circle
1079 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
1080 {
1081 m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness, getMetadata() );
1082 }
1083 else
1084 {
1085 EDA_ANGLE startAngle;
1086 EDA_ANGLE endAngle;
1087 aShape->CalcArcAngles( startAngle, endAngle );
1088
1089 EDA_ANGLE arcAngle = endAngle - startAngle;
1090
1091 if( aShape->ShortenArcForEndings( startAngle, arcAngle, aShape->GetRadius(), thickness ) )
1092 {
1093 m_plotter->ThickArc( VECTOR2D( aShape->GetCenter() ), startAngle, arcAngle, aShape->GetRadius(),
1094 thickness, getMetadata() );
1095 }
1096 }
1097
1098 break;
1099 }
1100
1101 case SHAPE_T::BEZIER:
1102 if( std::optional<BEZIER<double>> curve = aShape->ShortenedBezierCurve( thickness ) )
1103 {
1104 if( m_plotter->GetPlotterType() == PLOT_FORMAT::SVG )
1105 {
1106 m_plotter->BezierCurve( VECTOR2I( curve->Start ), VECTOR2I( curve->C1 ), VECTOR2I( curve->C2 ),
1107 VECTOR2I( curve->End ), aShape->GetMaxError(), thickness );
1108 }
1109 else
1110 {
1111 std::vector<VECTOR2D> pts = aShape->ShortenedBezierPolyline( thickness );
1112
1113 for( size_t i = 0; i + 1 < pts.size(); i++ )
1114 m_plotter->ThickSegment( VECTOR2I( pts[i] ), VECTOR2I( pts[i + 1] ), thickness, getMetadata() );
1115 }
1116 }
1117
1118 break;
1119
1120 case SHAPE_T::POLY:
1121 if( aShape->IsPolyShapeValid() )
1122 {
1123 auto plotStrokeOutline =
1124 [&]( const SHAPE_LINE_CHAIN& aOutline, int aOutlineIdx )
1125 {
1126 if( aOutline.PointCount() < 2 )
1127 return;
1128
1129 if( aShape->GetStartEnding().GetShortenDepth( thickness ) > 0
1130 || aShape->GetEndEnding().GetShortenDepth( thickness ) > 0 )
1131 {
1132 std::vector<VECTOR2I> pts;
1133
1134 if( !aShape->GetShortenedBodyPolyPoints( aOutline, aOutlineIdx, pts, thickness ) )
1135 return;
1136
1137 SHAPE_LINE_CHAIN shortened;
1138
1139 for( const VECTOR2I& pt : pts )
1140 shortened.Append( pt );
1141
1142 shortened.SetClosed( aOutline.IsClosed() );
1143 m_plotter->PlotPoly( shortened, FILL_T::NO_FILL, thickness, getMetadata() );
1144 }
1145 else
1146 {
1147 m_plotter->PlotPoly( aOutline, FILL_T::NO_FILL, thickness, getMetadata() );
1148 }
1149 };
1150
1151 if( m_plotter->GetPlotterType() == PLOT_FORMAT::DXF && GetDXFPlotMode() == SKETCH )
1152 {
1153 m_plotter->ThickPoly( aShape->GetPolyShape(), thickness, getMetadata() );
1154 }
1155 else
1156 {
1157 m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
1158
1159 const SHAPE_POLY_SET& origPoly = aShape->GetPolyShape();
1160
1161 // Stroke the unfractured outline so degenerate near-zero-width spikes (which Fracture()
1162 // collapses but the editor still draws as thick lines) are preserved in the plot output
1163 // (issue #24143).
1164 if( thickness > 0 )
1165 {
1166 if( m_plotter->GetPlotterType() == PLOT_FORMAT::DXF && isSolidFill )
1167 {
1168 // We can't split outline and fill into separate instructions for DXF as it
1169 // doesn't do fills, so we need the outline to be drawn only once (and include
1170 // any thick edge).
1171 }
1172 else
1173 {
1174 for( int jj = 0; jj < origPoly.OutlineCount(); ++jj )
1175 plotStrokeOutline( origPoly.COutline( jj ), jj );
1176
1177 thickness = 0;
1178 }
1179 }
1180
1181 if( !isSolidFill )
1182 break;
1183
1184 // Fracture before plotting the fill to avoid invalid gerber regions generated from
1185 // self-intersecting or overlapping outlines.
1186 // Note that we can't do this in the DXF case because we weren't able to separately
1187 // stroke the outline to preserve degenerate near-zero-width spikes. See above
1188 // comments.
1189 SHAPE_POLY_SET tmpPoly = origPoly.CloneDropTriangulation();
1190
1191 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF )
1192 tmpPoly.Fracture();
1193
1194 if( margin < 0 )
1195 tmpPoly.Inflate( margin / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS, aShape->GetMaxError() );
1196
1197 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
1198 {
1199 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
1200 poly.SetClosed( true );
1201
1202 // Width 0; the stroke was already plotted from the unfractured outline.
1203 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1204 {
1205 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1206 gbr_plotter->PlotPolyAsRegion( poly, FILL_T::FILLED_SHAPE, thickness, &gbr_metadata );
1207 }
1208 else
1209 {
1210 m_plotter->PlotPoly( poly, FILL_T::FILLED_SHAPE, thickness, getMetadata() );
1211 }
1212 }
1213 }
1214 }
1215
1216 break;
1217
1218 case SHAPE_T::RECTANGLE:
1219 {
1220 int radius = aShape->GetCornerRadius();
1221
1222 if( radius == 0 && m_plotter->GetPlotterType() == PLOT_FORMAT::DXF && GetDXFPlotMode() == SKETCH )
1223 {
1224 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1225 m_plotter->ThickRect( pts[0], pts[2], thickness, getMetadata() );
1226 }
1227 else
1228 {
1229 BOX2I box( aShape->GetStart(), VECTOR2I( aShape->GetEnd().x - aShape->GetStart().x,
1230 aShape->GetEnd().y - aShape->GetStart().y ) );
1231 box.Normalize();
1232
1233 if( margin < 0 )
1234 {
1235 box.Inflate( margin );
1236 radius += margin;
1237 }
1238
1239 SHAPE_RECT rect( box );
1240 rect.SetRadius( radius );
1241
1242 SHAPE_LINE_CHAIN outline = rect.Outline();
1243 SHAPE_POLY_SET poly( outline );
1244
1245 FILL_T fill_mode = isSolidFill ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1246
1247 if( poly.OutlineCount() > 0 )
1248 {
1249 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1250 {
1251 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1252 gbr_plotter->PlotPolyAsRegion( poly.COutline( 0 ), fill_mode, thickness, &gbr_metadata );
1253 }
1254 else
1255 {
1256 // TODO: PlotPoly needs to handle arcs...
1257 m_plotter->PlotPoly( poly.COutline( 0 ), fill_mode, thickness, getMetadata() );
1258 }
1259 }
1260 }
1261
1262 break;
1263 }
1264
1265 case SHAPE_T::ELLIPSE:
1267 {
1268 const bool isClosed = ( aShape->GetShape() == SHAPE_T::ELLIPSE );
1269
1270 SHAPE_ELLIPSE e = isClosed ? SHAPE_ELLIPSE( aShape->GetEllipseCenter(), aShape->GetEllipseMajorRadius(),
1271 aShape->GetEllipseMinorRadius(), aShape->GetEllipseRotation() )
1273 aShape->GetEllipseMinorRadius(), aShape->GetEllipseRotation(),
1274 aShape->GetEllipseStartAngle(), aShape->GetEllipseEndAngle() );
1275
1277
1278 if( isClosed )
1279 chain.SetClosed( true );
1280
1281 FILL_T fill = ( isClosed && isSolidFill ) ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1282
1283 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER && isClosed )
1284 {
1285 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1286 gbr_plotter->PlotPolyAsRegion( chain, fill, thickness, &gbr_metadata );
1287 }
1288 else
1289 {
1290 m_plotter->PlotPoly( chain, fill, thickness, getMetadata() );
1291 }
1292
1293 break;
1294 }
1295
1296 default:
1298 }
1299 }
1300 else
1301 {
1302 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapesForStroking( thickness );
1303
1304 for( SHAPE* shape : shapes )
1305 {
1306 STROKE_PARAMS::Stroke( shape, lineStyle, aShape->GetWidth(),
1307 m_plotter->RenderSettings(),
1308 [&]( const VECTOR2I& a, const VECTOR2I& b )
1309 {
1310 m_plotter->ThickSegment( a, b, thickness, getMetadata() );
1311 } );
1312 }
1313
1314 for( SHAPE* shape : shapes )
1315 delete shape;
1316 }
1317
1318 // Plot line endings for open shapes.
1321 {
1322 EDA_ANGLE startTangent, endTangent;
1323 aShape->GetEndingTangents( startTangent, endTangent, thickness );
1324
1325 VECTOR2I startPt, endPt;
1326
1327 if( aShape->GetLineEndingEndpoints( startPt, endPt ) )
1328 {
1329 aShape->GetStartEnding().Plot( m_plotter, startPt, startTangent, thickness, getMetadata() );
1330 aShape->GetEndEnding().Plot( m_plotter, endPt, endTangent, thickness, getMetadata() );
1331 }
1332 }
1333
1334 if( isHatchedFill )
1335 {
1336 for( int ii = 0; ii < aShape->GetHatching().OutlineCount(); ++ii )
1337 {
1338 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1339 {
1340 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1341 gbr_plotter->PlotPolyAsRegion( aShape->GetHatching().Outline( ii ), FILL_T::FILLED_SHAPE, 0,
1342 &gbr_metadata );
1343 }
1344 else
1345 {
1346 m_plotter->PlotPoly( aShape->GetHatching().Outline( ii ), FILL_T::FILLED_SHAPE, 0, getMetadata() );
1347 }
1348 }
1349 }
1350}
1351
1352
1353void BRDITEMS_PLOTTER::PlotBarCode( const PCB_BARCODE* aBarCode ) const
1354{
1355 if( !m_layerMask[aBarCode->GetLayer()] )
1356 return;
1357
1358 // To avoid duplicate code, build a PCB_SHAPE to plot the polygon shape
1359 PCB_SHAPE dummy( aBarCode->GetParent(), SHAPE_T::POLY );
1360 dummy.SetLayer( aBarCode->GetLayer() );
1361 dummy.SetFillMode( FILL_T::FILLED_SHAPE );
1362 dummy.SetWidth( 0 );
1363
1364 SHAPE_POLY_SET shape;
1365 aBarCode->TransformShapeToPolySet( shape, aBarCode->GetLayer(), 0, 0, ERROR_INSIDE );
1366 dummy.SetPolyShape( shape );
1367
1368 PlotShape( &dummy );
1369}
1370
1371
1373{
1374 if( !m_layerMask[aTable->GetLayer()] )
1375 return;
1376
1377 GBR_METADATA gbr_metadata;
1378
1379 if( const FOOTPRINT* parentFP = aTable->GetParentFootprint() )
1380 {
1381 gbr_metadata.SetCmpReference( parentFP->GetReference() );
1383 }
1384
1385 aTable->DrawBorders(
1386 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
1387 {
1388 int lineWidth = stroke.GetWidth();
1389 LINE_STYLE lineStyle = stroke.GetLineStyle();
1390
1391 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
1392 {
1393 m_plotter->ThickSegment( ptA, ptB, lineWidth, getMetadata() );
1394 }
1395 else
1396 {
1397 SHAPE_SEGMENT seg( ptA, ptB );
1398
1399 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, m_plotter->RenderSettings(),
1400 [&]( const VECTOR2I& a, const VECTOR2I& b )
1401 {
1402 m_plotter->ThickSegment( a, b, lineWidth, getMetadata() );
1403 } );
1404 }
1405 } );
1406}
1407
1408
1410 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
1411 const EDA_ANGLE& aOrientation, int aSmallDrill ) const
1412{
1413 VECTOR2I drillSize = aDrillSize;
1414
1415 // Small drill marks have no significance when applied to slots
1416 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
1417 drillSize.x = std::min( aSmallDrill, drillSize.x );
1418
1419 // Round holes only have x diameter, slots have both
1420 drillSize.x -= getFineWidthAdj();
1421 drillSize.x = std::clamp( drillSize.x, 1, aPadSize.x - 1 );
1422
1423 if( aDrillShape == PAD_DRILL_SHAPE::OBLONG )
1424 {
1425 drillSize.y -= getFineWidthAdj();
1426 drillSize.y = std::clamp( drillSize.y, 1, aPadSize.y - 1 );
1427
1428 m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, nullptr );
1429 }
1430 else
1431 {
1432 m_plotter->FlashPadCircle( aDrillPos, drillSize.x, nullptr );
1433 }
1434}
1435
1436
1438{
1439 int smallDrill = 0;
1440
1442 smallDrill = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize );
1443
1444 /* Drill marks are drawn white-on-black to knock-out the underlying pad. This works only
1445 * for drivers supporting color change, obviously... it means that:
1446 - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
1447 - In gerbers you can't see them. This is arguably the right thing to do since having
1448 drill marks and high speed drill stations is a sure recipe for broken tools and angry
1449 manufacturers. If you *really* want them you could start a layer with negative
1450 polarity to knock-out the film.
1451 - In DXF they go into the 'WHITE' layer. This could be useful.
1452 */
1453 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1454 m_plotter->SetColor( WHITE );
1455
1456 for( PCB_TRACK* track : m_board->Tracks() )
1457 {
1458 if( track->Type() == PCB_VIA_T )
1459 {
1460 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
1461
1462 // Via are not always on all layers
1463 if( ( via->GetLayerSet() & m_layerMask ).none() )
1464 continue;
1465
1467 VECTOR2I( via->GetDrillValue(), 0 ),
1468 VECTOR2I( via->GetWidth( PADSTACK::TEMP_ALL_LAYERS ), 0 ),
1469 ANGLE_0, smallDrill );
1470 }
1471 }
1472
1473 for( FOOTPRINT* footprint : m_board->Footprints() )
1474 {
1475 for( PAD* pad : footprint->Pads() )
1476 {
1477 if( pad->GetDrillSize().x == 0 )
1478 continue;
1479
1480 // Skip marks on layers the pad isn't on for Gerber only (24416). Other
1481 // formats keep them as a drill map, e.g. Edge.Cuts (24867).
1482 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER && ( pad->GetLayerSet() & m_layerMask ).none() )
1483 continue;
1484
1485 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1486 {
1487 // Drill mark is in black unless we can find something to knock it out of
1488 m_plotter->SetColor( BLACK );
1489
1490 for( PCB_LAYER_ID layer : m_layerMask )
1491 {
1492 if( !pad->IsOnLayer( layer ) )
1493 continue;
1494
1495 VECTOR2I padSize = pad->GetSize( layer );
1496
1497 if( padSize.x > pad->GetDrillSize().x || padSize.y > pad->GetDrillSize().y )
1498 {
1499 m_plotter->SetColor( WHITE );
1500 break;
1501 }
1502 }
1503 }
1504
1505 plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
1506 pad->GetSize( PADSTACK::TEMP_ALL_LAYERS ), pad->GetOrientation(), smallDrill );
1507 }
1508 }
1509
1510 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1511 m_plotter->SetColor( BLACK );
1512}
1513
1514
1516{
1517 const std::vector<const PCB_DRILL_MAP*> maps = m_board->DrillMapsOnLayer( aLayer );
1518
1519 if( maps.empty() )
1520 return;
1521
1522 const DRILL_SYMBOL_PROFILE& profile = m_board->GetDesignSettings().GetDrillSymbolProfile();
1523
1524 // Resolved rather than read straight from the profile, so a map drawn without any chart
1525 // ever having been placed still shows marks
1526 const std::shared_ptr<const DRILL_SYMBOL_CACHE> cache = m_board->DrillSymbolCache();
1527
1528 // DXF reads its sketch/filled mode back out of this. Without it every stroked mark is
1529 // emitted filled no matter what the user asked for
1530 GBR_METADATA gbr_metadata;
1531
1532 m_plotter->SetColor( getColor( aLayer ) );
1533 m_plotter->SetCurrentLineWidth( profile.GetSymbolWidth() );
1534
1535 DRILL_QUERY query;
1536 query.m_MergePTHNPTH = true;
1537
1538 // Several maps can share a layer. The UI prevents it but a parsed, pasted or
1539 // API-created board need not
1540 for( const PCB_DRILL_MAP* map : maps )
1541 {
1542
1543 const std::shared_ptr<const SHAPE_POLY_SET> outlines = map->GetBoardOutlines();
1544
1545 for( int ii = 0; ii < outlines->OutlineCount(); ++ii )
1546 {
1547 m_plotter->PlotPoly( outlines->COutline( ii ), FILL_T::NO_FILL, profile.GetSymbolWidth(),
1548 getMetadata() );
1549
1550 for( int jj = 0; jj < outlines->HoleCount( ii ); ++jj )
1551 {
1552 m_plotter->PlotPoly( outlines->CHole( ii, jj ), FILL_T::NO_FILL, profile.GetSymbolWidth(),
1553 getMetadata() );
1554 }
1555 }
1556
1557 for( const DRILL_SPAN& span : EnumerateDrillSpans( *m_board ) )
1558 {
1559 // The map's own span filter, so a backdrill map does not print every other hole too
1560 if( !map->GetAllSpans() && !( span == map->GetSpan() ) )
1561 continue;
1562
1563 query.m_Span = span;
1564
1565 for( const DRILL_OPERATION& op : EnumerateDrillOperations( *m_board, query ) )
1566 {
1567 // The map is a set of marks on the holes, displaced as a whole. The holes
1568 // themselves never move
1569 const VECTOR2I pos = op.m_Position + map->GetOffset();
1570
1571 const auto it = cache->m_ByGroup.find( profile.GroupKeyString( op ) );
1572
1573 if( it == cache->m_ByGroup.end() )
1574 continue;
1575
1576 const DRILL_SYMBOL_ASSIGNMENT& assignment = it->second;
1577
1578 if( assignment.m_MarkMode == DRILL_MARK_MODE::SHAPE )
1579 {
1580 m_plotter->Marker( pos, map->GetSymbolSize(),
1582 }
1583 else
1584 {
1585 const wxString text =
1587 ? assignment.m_Letter
1588 : wxString::Format( wxT( "%.2f" ),
1589 pcbIUScale.IUTomm( op.m_Diameter ) );
1590
1591 TEXT_ATTRIBUTES attrs;
1592 attrs.m_Size = VECTOR2I( map->GetSymbolSize(), map->GetSymbolSize() );
1593 attrs.m_StrokeWidth = profile.GetSymbolWidth();
1596
1597 m_plotter->PlotText( pos, getColor( aLayer ), text, attrs, nullptr,
1599 }
1600
1601 if( map->GetGuideCross() )
1602 {
1603 const int reach = map->GetSymbolSize();
1604
1605 m_plotter->ThickSegment( pos - VECTOR2I( reach, 0 ),
1606 pos + VECTOR2I( reach, 0 ),
1607 profile.GetSymbolWidth(), getMetadata() );
1608 m_plotter->ThickSegment( pos - VECTOR2I( 0, reach ),
1609 pos + VECTOR2I( 0, reach ),
1610 profile.GetSymbolWidth(), getMetadata() );
1611 }
1612
1613 // A slot's true extent is the cost driver, so it is drawn as well as marked
1614 if( map->GetOutlineSlots() && op.m_IsSlot )
1615 {
1616 m_plotter->ThickOval( pos, op.m_SizeXY, op.m_Orientation,
1617 profile.GetSymbolWidth(), getMetadata() );
1618 }
1619 }
1620 }
1621 }
1622
1623 m_plotter->SetCurrentLineWidth( PLOTTER::USE_DEFAULT_LINE_WIDTH );
1624}
1625
1626
1628{
1629
1630 if( aChart->GetSymbolColumn() < 0 || aChart->RowShapes().empty() )
1631 return;
1632
1633 const DRILL_SYMBOL_PROFILE& profile = m_board->GetDesignSettings().GetDrillSymbolProfile();
1634
1635 m_plotter->SetColor( getColor( aChart->GetLayer() ) );
1636 m_plotter->SetCurrentLineWidth( profile.GetSymbolWidth() );
1637
1638 for( const auto& [row, shapeIndex] : aChart->RowShapes() )
1639 {
1640 const PCB_TABLECELL* cell = aChart->GetCell( row, aChart->GetSymbolColumn() );
1641
1642 if( !cell )
1643 continue;
1644
1645 const BOX2I box = cell->GetBoundingBox();
1646
1647 // Same fit as the painter, so the plotted chart matches what was on screen
1648 const int size = std::min<int>( profile.GetSymbolSize(),
1649 std::min( box.GetWidth(), box.GetHeight() ) * 2 / 3 );
1650
1651 if( size > 0 )
1652 m_plotter->Marker( box.GetCenter(), size, DRILL_MARKERS::CuratedShape( shapeIndex ) );
1653 }
1654
1655 m_plotter->SetCurrentLineWidth( PLOTTER::USE_DEFAULT_LINE_WIDTH );
1656}
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr int ARC_LOW_DEF
Definition base_units.h:143
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Generic cubic Bezier representation.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
virtual bool IsKnockout() const
Definition board_item.h:437
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
FOOTPRINT * GetParentFootprint() const
virtual void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const
Convert the item shape to a polyset.
Definition board_item.h:582
const KIFONT::METRICS & GetFontMetrics() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:281
int GetMaxError() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:149
constexpr size_type GetWidth() const
Definition box2.h:217
constexpr Vec Centre() const
Definition box2.h:100
constexpr const Vec GetCenter() const
Definition box2.h:233
constexpr size_type GetHeight() const
Definition box2.h:218
constexpr const SizeVec & GetSize() const
Definition box2.h:209
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint) const
void PlotBoardGraphicItem(const BOARD_ITEM *item) const
Plot items like text and graphics but not tracks and footprints.
void PlotText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS &aFontMetrics, bool aStrikeout=false) const
void PlotPadNumber(const PAD *aPad, const COLOR4D &aColor) const
void PlotDimension(const PCB_DIMENSION_BASE *aDim) const
void PlotDrillSymbols(PCB_LAYER_ID aLayer) const
Draw each hole's chart symbol on aLayer, from the board's shared symbol profile.
void PlotZone(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList) const
void plotOneDrillMark(PAD_DRILL_SHAPE aDrillShape, const VECTOR2I &aDrillPos, const VECTOR2I &aDrillSize, const VECTOR2I &aPadSize, const EDA_ANGLE &aOrientation, int aSmallDrill) const
Helper function to plot a single drill mark.
bool crossoutDNPItems(PCB_LAYER_ID aLayer) const
Definition pcbplot.h:146
void PlotTableBorders(const PCB_TABLE *aTable) const
bool hideDNPItems(PCB_LAYER_ID aLayer) const
Definition pcbplot.h:141
void PlotFootprintTextItems(const FOOTPRINT *aFootprint) const
PLOTTER * m_plotter
Definition pcbplot.h:159
void PlotPcbTarget(const PCB_TARGET *aMire) const
const BOARD * m_board
Definition pcbplot.h:160
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotDrillMarks() const
Draw a drill mark for pads and vias.
void PlotShape(const PCB_SHAPE *aShape) const
int getFineWidthAdj() const
Definition pcbplot.h:75
void PlotBarCode(const PCB_BARCODE *aBarCode) const
void PlotChartSymbols(const PCB_DRILL_CHART *aChart) const
Shape marks in a chart's symbol column, which carry no cell text of their own.
void PlotPad(const PAD *aPad, PCB_LAYER_ID aLayer, const COLOR4D &aColor, bool aSketchMode) const
Plot a pad.
static const COLOR4D WHITE
Definition color4d.h:403
COLOR4D GetColor(int aLayer) const
Grouping rules and symbol assignments, shared by reference so a chart and its map can never disagree ...
std::string GroupKeyString(const DRILL_OPERATION &aOperation) const
Stable identity for a group under the currently enabled keys.
double AsDegrees() const
Definition eda_angle.h:115
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
static bool ShortenSegmentForEndings(VECTOR2I &aStart, VECTOR2I &aEnd, const LINE_ENDING &aStartEnding, const LINE_ENDING &aEndEnding, int aLineWidth)
Shorten a segment body for line endings.
EDA_ANGLE GetArcAngle() const
int GetEllipseMinorRadius() const
Definition eda_shape.h:404
const VECTOR2I & GetEllipseCenter() const
Definition eda_shape.h:386
const SHAPE_POLY_SET & GetHatching() const
EDA_ANGLE GetEllipseEndAngle() const
Definition eda_shape.h:432
int GetEllipseMajorRadius() const
Definition eda_shape.h:395
SHAPE_POLY_SET & GetPolyShape()
void GetEndingTangents(EDA_ANGLE &aStartTangent, EDA_ANGLE &aEndTangent, int aLineWidth=0) const
Compute outward-facing tangent angles at the start and end of the shape.
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
EDA_ANGLE GetEllipseRotation() const
Definition eda_shape.h:413
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:178
std::vector< SHAPE * > MakeEffectiveShapesForStroking(int aLineWidth=-1) const
Make a set of SHAPE objects to hand to STROKE_PARAMS::Stroke().
bool GetShortenedBodyPolyPoints(const SHAPE_LINE_CHAIN &aOutline, int aOutlineIdx, std::vector< VECTOR2I > &aPoints, int aLineWidth) const
Copy an outline and apply line-ending body shortening when applicable.
bool IsHatchedFill() const
Definition eda_shape.h:133
bool GetLineEndingEndpoints(VECTOR2I &aStartPoint, VECTOR2I &aEndPoint) const
Return the source endpoints used to place line endings.
virtual void SetFilled(bool aFlag)
Definition eda_shape.h:145
bool IsSolidFill() const
Definition eda_shape.h:126
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:334
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:284
std::vector< VECTOR2I > GetRectCorners() const
EDA_ANGLE GetEllipseStartAngle() const
Definition eda_shape.h:423
const LINE_ENDING & GetStartEnding() const
Definition eda_shape.h:180
wxString SHAPE_T_asString() const
std::optional< BEZIER< double > > ShortenedBezierCurve(int aLineWidth) const
Return the cubic Bezier curve shortened for line endings.
bool ShortenArcForEndings(EDA_ANGLE &aStartAngle, EDA_ANGLE &aArcAngle, double aRadius, int aLineWidth) const
Shorten an arc body for line endings.
std::vector< VECTOR2D > ShortenedBezierPolyline(int aLineWidth) const
Return the flattened Bezier polyline after line-ending shortening.
const LINE_ENDING & GetEndEnding() const
Definition eda_shape.h:186
int GetCornerRadius() const
bool IsPolyShapeValid() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
virtual VECTOR2I GetTextSize() const
Definition eda_text.h:301
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:313
bool IsMultilineAllowed() const
Definition eda_text.h:236
virtual bool IsVisible() const
Definition eda_text.h:226
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
Definition eda_text.cpp:684
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:425
virtual wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition eda_text.h:128
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition eda_text.cpp:648
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:270
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:428
void GetLinePositions(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition eda_text.cpp:932
PCB_FIELD & Value()
read/write accessors:
Definition footprint.h:831
LSET GetPrivateLayers() const
Definition footprint.h:295
PCB_FIELD & Reference()
Definition footprint.h:832
bool GetDNPForVariant(const wxString &aVariantName) const
Get the DNP status for a specific variant.
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
const wxString & GetReference() const
Definition footprint.h:793
DRAWINGS & GraphicalItems()
Definition footprint.h:358
@ GBR_APERTURE_ATTRIB_CONDUCTOR
Aperture used for connected items like tracks (not vias).
@ GBR_APERTURE_ATTRIB_ETCHEDCMP
Aperture used for etched components.
@ GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
Aperture used for BGA pad with a solder mask defined by the solder mask.
@ GBR_APERTURE_ATTRIB_HEATSINKPAD
Aperture used for heat sink pad (typically for SMDs).
@ GBR_APERTURE_ATTRIB_TESTPOINT
Aperture used for test point pad (outer layers).
@ GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
Aperture used for SMD pad with a solder mask defined by the solder mask.
@ GBR_APERTURE_ATTRIB_CONNECTORPAD
Aperture used for edge connector pad (outer layers).
@ GBR_APERTURE_ATTRIB_NONCONDUCTOR
Aperture used for not connected items (texts, outlines on copper).
@ GBR_APERTURE_ATTRIB_WASHERPAD
Aperture used for mechanical pads (NPTH).
@ GBR_APERTURE_ATTRIB_COMPONENTPAD
Aperture used for through hole component on outer layer.
@ GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
Aperture used for fiducial pad (outer layers), at board level.
@ GBR_APERTURE_ATTRIB_CASTELLATEDPAD
Aperture used for castellated pads in copper layer files.
@ GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
Aperture used for fiducial pad (outer layers), at footprint level.
@ GBR_APERTURE_ATTRIB_EDGECUT
Aperture used for board cutout,.
Metadata which can be added in a gerber file as attribute in X2 format.
void SetCopper(bool aValue)
void SetCmpReference(const wxString &aComponentRef)
void SetNetName(const wxString &aNetname)
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
void SetNetAttribType(int aNetAttribType)
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
@ GBR_NETINFO_NET
print info associated to a net (TO.N attribute)
@ GBR_NETINFO_CMP
print info associated to a component (TO.C attribute)
bool m_NotInNet
true if a pad of a footprint cannot be connected (for instance a mechanical NPTH, ot a not named pad)...
void FlashPadChamferRoundRect(const VECTOR2I &aShapePos, const VECTOR2I &aPadSize, int aCornerRadius, double aChamferRatio, int aChamferPositions, const EDA_ANGLE &aPadOrient, void *aData)
Flash a chamfered round rect pad.
void PlotPolyAsRegion(const SHAPE_LINE_CHAIN &aPoly, FILL_T aFill, int aWidth, GBR_METADATA *aGbrMetadata)
Similar to PlotPoly(), plot a filled polygon using Gerber region, therefore adding X2 attributes to t...
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
virtual bool IsOutline() const
Definition font.h:102
static const METRICS & Default()
Definition font.cpp:49
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
int GetShortenDepth(int aLineWidth) const
Return how far the line should be shortened at this ending.
LINE_ENDING_STYLE GetStyle() const
Definition line_ending.h:81
void Plot(PLOTTER *aPlotter, const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, int aLineWidth, void *aData=nullptr) const
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
static const LSET & ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition lset.cpp:630
static constexpr PCB_LAYER_ID TEMP_ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:181
Definition pad.h:61
PAD_PROP GetProperty() const
Definition pad.h:585
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2524
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
Definition pad.h:375
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1053
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1545
PAD_ATTRIB GetAttribute() const
Definition pad.h:582
const wxString & GetPinFunction() const
Definition pad.h:154
const wxString & GetNumber() const
Definition pad.h:143
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition pad.h:307
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool aIgnoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:3036
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:205
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:297
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1672
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:878
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1111
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:860
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1825
Abstract dimension API.
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
A drill chart placed on the board, kept in step with the holes.
const std::map< int, int > & RowShapes() const
Curated shape index for each generated row, by table row.
int GetSymbolColumn() const
Table column the symbol is drawn in, or -1 when the chart has no symbol column.
Turns on drill symbols at the holes, for one layer.
bool GetSketchDNPFPsOnFabLayers() const
PLOT_TEXT_MODE GetTextMode() const override
bool GetPlotReference() const
DXF_OUTLINE_MODE GetDXFPlotMode() const override
int GetSketchPadLineWidth() const
DRILL_MARKS GetDrillMarksType() const
bool GetPlotValue() const
bool GetPlotFPText() const
COLOR_SETTINGS * ColorSettings() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_shape.h:80
int GetWidth() const override
bool HasSolderMask() const
Definition pcb_shape.h:349
int GetSolderMaskExpansion() const
void SetShape(SHAPE_T aShape) override
Definition pcb_shape.h:214
void SetEnd(const VECTOR2I &aEnd) override
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
STROKE_PARAMS GetStroke() const override
void SetStart(const VECTOR2I &aStart) override
void SetStroke(const STROKE_PARAMS &aStroke) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pcb_shape.h:70
PCB_TABLECELL * GetCell(int aRow, int aCol) const
Definition pcb_table.h:155
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
int GetShape() const
Definition pcb_target.h:54
int GetWidth() const
Definition pcb_target.h:60
int GetSize() const
Definition pcb_target.h:57
VECTOR2I GetPosition() const override
Definition pcb_target.h:51
bool IsBorderEnabled() const
Tests whether the border is disabled, as configured by the stroke.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Convert the text to a polygonSet describing the actual character strokes (one per segment).
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
PCB_SHAPE GetPolygonalBoxShape() const
Base plotter engine class.
Definition plotter.h:138
static const int USE_DEFAULT_LINE_WIDTH
Definition plotter.h:142
virtual PLOT_FORMAT GetPlotterType() const =0
Return the effective plot engine in use.
Definition seg.h:38
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
int GetRadius() const
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
SHAPE_POLY_SET CloneDropTriangulation() const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
const SEG & GetSeg() const
An abstract shape on 2D plane.
Definition shape.h:124
Simple container to manage line stroke parameters.
int GetWidth() const
LINE_STYLE GetLineStyle() const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
EDA_ORIENTATION m_Angle
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
Handle a list of polygons defining a copper zone.
Definition zone.h:70
bool IsOnCopperLayer() const override
Definition zone.cpp:652
A type-safe container of any type.
Definition ki_any.h:92
constexpr any() noexcept
Default constructor, creates an empty object.
Definition ki_any.h:155
@ WHITE
Definition color4d.h:44
@ LIGHTGRAY
Definition color4d.h:43
@ BLACK
Definition color4d.h:40
@ FOR_CANVAS
Definition common.h:92
@ ROUND_ALL_CORNERS
All angles are rounded.
std::vector< DRILL_SPAN > EnumerateDrillSpans(const BOARD &aBoard, bool aPadBackdrills)
Every drill span present on the board, through-holes first.
std::vector< DRILL_OPERATION > EnumerateDrillOperations(const BOARD &aBoard, const DRILL_QUERY &aQuery)
The one place that decides what the board's holes are.
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:472
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:474
FILL_T
Definition eda_fill.h:29
@ NO_FILL
Definition eda_fill.h:30
@ FILLED_SHAPE
Fill with object color.
Definition eda_fill.h:31
@ ELLIPSE
Definition eda_shape.h:63
@ SEGMENT
Definition eda_shape.h:57
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:58
@ ELLIPSE_ARC
Definition eda_shape.h:64
Handle special data (items attributes) during plot.
#define GBR_NETINFO_ALL
static const bool FILLED
Definition gr_basic.cpp:30
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:744
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition layer_ids.h:755
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ Edge_Cuts
Definition layer_ids.h:108
@ B_Mask
Definition layer_ids.h:94
@ F_Mask
Definition layer_ids.h:93
@ F_Fab
Definition layer_ids.h:115
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
@ B_Fab
Definition layer_ids.h:114
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition macros.h:79
#define UNIMPLEMENTED_FOR(type)
Definition macros.h:92
unsigned CuratedShape(int aIndex)
Pattern index for the nth curated mark.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:461
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:70
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:104
@ NON_COMPONENT
Pad with no hole that does not connect to a physical component, but rather provides a connection poin...
Definition padstack.h:106
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition padstack.h:100
@ PTH
Plated through hole pad.
Definition padstack.h:99
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
Definition padstack.h:101
@ CHAMFERED_RECT
Definition padstack.h:61
@ ROUNDRECT
Definition padstack.h:58
@ TRAPEZOID
Definition padstack.h:57
@ RECTANGLE
Definition padstack.h:55
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
Definition padstack.h:122
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
Definition padstack.h:121
@ MECHANICAL
a pad used for mechanical support
Definition padstack.h:126
@ PRESSFIT
a PTH with a hole diameter with tight tolerances for press fit pin
Definition padstack.h:127
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
Definition padstack.h:124
@ NONE
no special fabrication property
Definition padstack.h:119
@ TESTPOINT
a test point pad
Definition padstack.h:123
@ CASTELLATED
a pad with a castellated through hole
Definition padstack.h:125
@ BGA
Smd pad, used in BGA footprints.
Definition padstack.h:120
BARCODE class definition.
static void * plotMetadata(PLOTTER *aPlotter, GBR_METADATA &aMetadata, const PLOT_PARAMS *aPlotOptions)
#define getMetadata()
@ SKETCH
Definition plotter.h:83
@ SH_CIRCLE
circle
Definition shape.h:46
@ SH_SEGMENT
line segment
Definition shape.h:44
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
LINE_STYLE
Dashed line types.
One machining action, which is also one NC hit and one tool assignment.
Selects which operations EnumerateDrillOperations() returns.
bool m_MergePTHNPTH
Emit plated and non-plated together, as the merged drill file does.
DRILL_SPAN m_Span
const std::string table
const SHAPE_LINE_CHAIN chain
int radius
VECTOR2I end
@ GR_TEXT_H_ALIGN_CENTER
@ 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:227
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:98
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:95
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:96
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:81
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:93
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:99
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:94
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:86
@ PCB_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
Definition typeinfo.h:242
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:97
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)