KiCad PCB EDA Suite
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 (C) 1992-2023 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <algorithm> // for min
25#include <bitset> // for bitset, operator&, __bi...
26#include <math.h> // for abs
27#include <stddef.h> // for NULL, size_t
28
29#include <geometry/seg.h> // for SEG
31#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN
32#include <geometry/shape_poly_set.h> // for SHAPE_POLY_SET, SHAPE_P...
34#include <string_utils.h>
35#include <macros.h>
36#include <math/util.h> // for KiROUND, Clamp
37#include <math/vector2d.h> // for VECTOR2I
39#include <trigo.h>
40#include <callback_gal.h>
41
42#include <board_design_settings.h> // for BOARD_DESIGN_SETTINGS
43#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
44#include <gbr_metadata.h>
45#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
46#include <layer_ids.h> // for LSET, IsCopperLayer
47#include <pad_shapes.h> // for PAD_ATTRIB::NPTH
48#include <pcbplot.h>
49#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
50#include <advanced_config.h>
51
52#include <board.h>
53#include <board_item.h> // for BOARD_ITEM, S_CIRCLE
54#include <pcb_dimension.h>
55#include <pcb_shape.h>
56#include <fp_shape.h>
57#include <footprint.h>
58#include <fp_text.h>
59#include <fp_textbox.h>
60#include <pcb_track.h>
61#include <pad.h>
62#include <pcb_target.h>
63#include <pcb_text.h>
64#include <pcb_textbox.h>
65#include <zone.h>
66
67#include <wx/debug.h> // for wxASSERT_MSG
68
69
71{
72 COLOR4D color = ColorSettings()->GetColor( aLayer );
73
74 // A hack to avoid plotting a white item in white color, expecting the paper
75 // is also white: use a non white color:
76 if( color == COLOR4D::WHITE )
78
79 return color;
80}
81
82
83void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode )
84{
85 VECTOR2I shape_pos = aPad->ShapePos();
86 GBR_METADATA gbr_metadata;
87
88 bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
89 bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
90
91 // Pad not on the solder mask layer cannot be soldered.
92 // therefore it can have a specific aperture attribute.
93 // Not yet in use.
94 // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
95
96 gbr_metadata.SetCmpReference( aPad->GetParent()->GetReference() );
97
98 if( plotOnCopperLayer )
99 {
100 gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
101 gbr_metadata.SetCopper( true );
102
103 // Gives a default attribute, for instance for pads used as tracks in net ties:
104 // Connector pads and SMD pads are on external layers
105 // if on internal layers, they are certainly used as net tie
106 // and are similar to tracks: just conductor items
108
109 const bool useUTF8 = false;
110 const bool useQuoting = false;
111 gbr_metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
112
113 if( !aPad->GetNumber().IsEmpty() )
114 gbr_metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
115
116 gbr_metadata.SetNetName( aPad->GetNetname() );
117
118 // Some pads are mechanical pads ( through hole or smd )
119 // when this is the case, they have no pad name and/or are not plated.
120 // In this case gerber files have slightly different attributes.
121 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
122 gbr_metadata.m_NetlistMetadata.m_NotInNet = true;
123
124 if( !plotOnExternalCopperLayer )
125 {
126 // the .P object attribute (GBR_NETLIST_METADATA::GBR_NETINFO_PAD)
127 // is used on outer layers, unless the component is embedded
128 // or a "etched" component (fp only drawn, not a physical component)
129 // Currently, Pcbnew does not handle embedded component, so we disable the .P
130 // attribute on internal layers
131 // Note the Gerber doc is not really clear about through holes pads about the .P
134
135 }
136
137 // Some attributes are reserved to the external copper layers:
138 // GBR_APERTURE_ATTRIB_CONNECTORPAD and GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
139 // for instance.
140 // Pad with type PAD_ATTRIB::CONN or PAD_ATTRIB::SMD that is not on outer layer
141 // has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
142 switch( aPad->GetAttribute() )
143 {
144 case PAD_ATTRIB::NPTH: // Mechanical pad through hole
146 break;
147
148 case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
149 gbr_metadata.SetApertureAttrib(
151 break;
152
153 case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
154 if( plotOnExternalCopperLayer )
155 gbr_metadata.SetApertureAttrib(
157 break;
158
159 case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
160 // with solder paste and mask
161 if( plotOnExternalCopperLayer )
162 gbr_metadata.SetApertureAttrib(
164 break;
165 }
166
167 // Fabrication properties can have specific GBR_APERTURE_METADATA options
168 // that replace previous aperture attribute:
169 switch( aPad->GetProperty() )
170 {
171 case PAD_PROP::BGA: // Only applicable to outer layers
172 if( plotOnExternalCopperLayer )
173 gbr_metadata.SetApertureAttrib(
175 break;
176
178 gbr_metadata.SetApertureAttrib(
180 break;
181
183 gbr_metadata.SetApertureAttrib(
185 break;
186
187 case PAD_PROP::TESTPOINT: // Only applicable to outer layers
188 if( plotOnExternalCopperLayer )
189 gbr_metadata.SetApertureAttrib(
191 break;
192
194 gbr_metadata.SetApertureAttrib(
196 break;
197
199 gbr_metadata.SetApertureAttrib(
201 break;
202
203 case PAD_PROP::NONE:
204 break;
205 }
206
207 // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
208 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
210 }
211 else
212 {
214 }
215
216 // Set plot color (change WHITE to LIGHTGRAY because
217 // the white items are not seen on a white paper or screen
218 m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
219
220 if( aPlotMode == SKETCH )
222
223 switch( aPad->GetShape() )
224 {
226 m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &gbr_metadata );
227 break;
228
229 case PAD_SHAPE::OVAL:
230 m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
231 &gbr_metadata );
232 break;
233
234 case PAD_SHAPE::RECT:
235 m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
236 &gbr_metadata );
237 break;
238
240 m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
241 aPad->GetOrientation(), aPlotMode, &gbr_metadata );
242 break;
243
245 {
246 // Build the pad polygon in coordinates relative to the pad
247 // (i.e. for a pad at pos 0,0, rot 0.0). Needed to use aperture macros,
248 // to be able to create a pattern common to all trapezoid pads having the same shape
249 VECTOR2I coord[4];
250
251 // Order is lower left, lower right, upper right, upper left.
252 VECTOR2I half_size = aPad->GetSize() / 2;
253 VECTOR2I trap_delta = aPad->GetDelta() / 2;
254
255 coord[0] = VECTOR2I( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
256 coord[1] = VECTOR2I( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
257 coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
258 coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
259
260 m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode,
261 &gbr_metadata );
262 }
263 break;
264
267 {
268 GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
269
270 gerberPlotter->FlashPadChamferRoundRect( shape_pos, aPad->GetSize(),
272 aPad->GetChamferRectRatio(),
273 aPad->GetChamferPositions(),
274 aPad->GetOrientation(), aPlotMode,
275 &gbr_metadata );
276 break;
277 }
278
280
281 default:
283 {
284 const std::shared_ptr<SHAPE_POLY_SET>& polygons = aPad->GetEffectivePolygon();
285
286 if( polygons->OutlineCount() )
287 {
288 m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(),
289 polygons.get(), aPlotMode, &gbr_metadata );
290 }
291 }
292 break;
293 }
294}
295
296
298{
299 const FP_TEXT* textItem = &aFootprint->Reference();
300 int textLayer = textItem->GetLayer();
301
302 // Reference and value are specific items, not in graphic items list
303 if( GetPlotReference() && m_layerMask[textLayer]
304 && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
305 {
306 PlotFootprintTextItem( textItem, getColor( textLayer ) );
307 }
308
309 textItem = &aFootprint->Value();
310 textLayer = textItem->GetLayer();
311
312 if( GetPlotValue() && m_layerMask[textLayer]
313 && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
314 {
315 PlotFootprintTextItem( textItem, getColor( textLayer ) );
316 }
317
318 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
319 {
320 textItem = dyn_cast<const FP_TEXT*>( item );
321
322 if( !textItem )
323 continue;
324
325 if( !textItem->IsVisible() )
326 continue;
327
328 textLayer = textItem->GetLayer();
329
330 if( textLayer == Edge_Cuts || textLayer >= PCB_LAYER_ID_COUNT )
331 continue;
332
333 if( !m_layerMask[textLayer] || aFootprint->GetPrivateLayers().test( textLayer ) )
334 continue;
335
336 if( textItem->GetText() == wxT( "${REFERENCE}" ) && !GetPlotReference() )
337 continue;
338
339 if( textItem->GetText() == wxT( "${VALUE}" ) && !GetPlotValue() )
340 continue;
341
342 PlotFootprintTextItem( textItem, getColor( textLayer ) );
343 }
344}
345
346
348{
349 switch( item->Type() )
350 {
351 case PCB_SHAPE_T:
352 PlotPcbShape( static_cast<const PCB_SHAPE*>( item ) );
353 break;
354
355 case PCB_TEXT_T:
356 {
357 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
358 PlotPcbText( text, text->GetLayer(), text->IsKnockout() );
359 break;
360 }
361
362 case PCB_TEXTBOX_T:
363 {
364 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
365 PlotPcbText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
366 PlotPcbShape( textbox );
367 break;
368 }
369
371 case PCB_DIM_CENTER_T:
372 case PCB_DIM_RADIAL_T:
374 case PCB_DIM_LEADER_T:
375 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
376 break;
377
378 case PCB_TARGET_T:
379 PlotPcbTarget( static_cast<const PCB_TARGET*>( item ) );
380 break;
381
382 default:
383 break;
384 }
385}
386
387
389{
390 for( const BOARD_ITEM* item : m_board->Drawings() )
391 PlotPcbGraphicItem( item );
392}
393
394
395void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aText, const COLOR4D& aColor )
396{
397 COLOR4D color = aColor;
398
399 if( aColor == COLOR4D::WHITE )
401
403
404 // calculate some text parameters :
405 //VECTOR2I size = aText->GetTextSize();
406 VECTOR2I pos = aText->GetTextPos();
407 int thickness = aText->GetEffectiveTextPenWidth();
408 KIFONT::FONT* font = aText->GetFont();
409
410 if( !font )
411 {
414 : wxString( wxEmptyString ),
415 aText->IsBold(), aText->IsItalic() );
416 }
417
418 // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
419 // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
420 // (like bold text) and we manage the thickness.
421 // So we set bold flag to true
422 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
423 attrs.m_StrokeWidth = thickness;
424 attrs.m_Angle = aText->GetDrawRotation();
425 attrs.m_Bold = true;
426 attrs.m_Multiline = false;
427
428 GBR_METADATA gbr_metadata;
429
430 if( IsCopperLayer( aText->GetLayer() ) )
432
434 const FOOTPRINT* parent = static_cast<const FOOTPRINT*> ( aText->GetParent() );
435 gbr_metadata.SetCmpReference( parent->GetReference() );
436
437 m_plotter->SetCurrentLineWidth( thickness );
438
439 if( aText->IsKnockout() )
440 {
442 SHAPE_POLY_SET knockouts;
443
444 CALLBACK_GAL callback_gal( empty_opts,
445 // Polygon callback
446 [&]( const SHAPE_LINE_CHAIN& aPoly )
447 {
448 knockouts.AddOutline( aPoly );
449 } );
450
451 callback_gal.SetIsFill( font->IsOutline() );
452 callback_gal.SetIsStroke( font->IsStroke() );
453 font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs );
454
455 SHAPE_POLY_SET finalPoly;
456 int margin = attrs.m_StrokeWidth * 1.5
458
459 aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
460 finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
462
463 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
464 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
465 }
466 else
467 m_plotter->PlotText( pos, aColor, aText->GetShownText(), attrs, font, &gbr_metadata );
468}
469
470
472{
473 if( !m_layerMask[aDim->GetLayer()] )
474 return;
475
476 PCB_SHAPE draw;
477
479 draw.SetLayer( aDim->GetLayer() );
480
482
483 // Set plot color (change WHITE to LIGHTGRAY because
484 // the white items are not seen on a white paper or screen
486
487 PlotPcbText( aDim, aDim->GetLayer(), false );
488
489 for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
490 {
491 switch( shape->Type() )
492 {
493 case SH_SEGMENT:
494 {
495 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
496
498 draw.SetStart( seg.A );
499 draw.SetEnd( seg.B );
500
501 PlotPcbShape( &draw );
502 break;
503 }
504
505 case SH_CIRCLE:
506 {
507 VECTOR2I start( shape->Centre() );
508 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
509
511 draw.SetFilled( false );
512 draw.SetStart( start );
513 draw.SetEnd( VECTOR2I( start.x + radius, start.y ) );
514
515 PlotPcbShape( &draw );
516 break;
517 }
518
519 default:
520 break;
521 }
522 }
523}
524
525
527{
528 int dx1, dx2, dy1, dy2, radius;
529
530 if( !m_layerMask[aMire->GetLayer()] )
531 return;
532
533 m_plotter->SetColor( getColor( aMire->GetLayer() ) );
534
535 PCB_SHAPE draw;
536
538 draw.SetFilled( false );
540 draw.SetLayer( aMire->GetLayer() );
541 draw.SetStart( aMire->GetPosition() );
542 radius = aMire->GetSize() / 3;
543
544 if( aMire->GetShape() ) // shape X
545 radius = aMire->GetSize() / 2;
546
547 // Draw the circle
548 draw.SetEnd( VECTOR2I( draw.GetStart().x + radius, draw.GetStart().y ) );
549
550 PlotPcbShape( &draw );
551
553
554 radius = aMire->GetSize() / 2;
555 dx1 = radius;
556 dy1 = 0;
557 dx2 = 0;
558 dy2 = radius;
559
560 if( aMire->GetShape() ) // Shape X
561 {
562 dx1 = dy1 = radius;
563 dx2 = dx1;
564 dy2 = -dy1;
565 }
566
567 VECTOR2I mirePos( aMire->GetPosition() );
568
569 // Draw the X or + shape:
570 draw.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
571 draw.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
572 PlotPcbShape( &draw );
573
574 draw.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
575 draw.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
576 PlotPcbShape( &draw );
577}
578
579
581{
582 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
583 {
584 if( aFootprint->GetPrivateLayers().test( item->GetLayer() ) )
585 continue;
586
587 switch( item->Type() )
588 {
589 case PCB_FP_SHAPE_T:
590 {
591 const FP_SHAPE* shape = static_cast<const FP_SHAPE*>( item );
592
593 if( m_layerMask[ shape->GetLayer() ] )
594 PlotFootprintShape( shape );
595
596 break;
597 }
598
599 case PCB_FP_TEXTBOX_T:
600 {
601 const FP_TEXTBOX* textbox = static_cast<const FP_TEXTBOX*>( item );
602
603 if( m_layerMask[ textbox->GetLayer() ] )
604 {
605 PlotPcbText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
606 PlotFootprintShape( textbox );
607 }
608
609 break;
610 }
611
617 {
618 const PCB_DIMENSION_BASE* dimension = static_cast<const PCB_DIMENSION_BASE*>( item );
619
620 if( m_layerMask[ dimension->GetLayer() ] )
621 PlotDimension( dimension );
622
623 break;
624 }
625
626 case PCB_FP_TEXT_T:
627 // Plotted in PlotFootprintTextItem()
628 break;
629
630 default:
631 UNIMPLEMENTED_FOR( item->GetClass() );
632 }
633 }
634}
635
636
638{
639 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
640
641 bool sketch = GetPlotMode() == SKETCH;
642 int thickness = aShape->GetWidth();
643
644 GBR_METADATA gbr_metadata;
646 const FOOTPRINT* parent = static_cast<const FOOTPRINT*> ( aShape->GetParent() );
647 gbr_metadata.SetCmpReference( parent->GetReference() );
648
649 bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
650
651 if( aShape->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers
652 {
654 }
655 else if( isOnCopperLayer ) // only for items not on Edge_Cuts.
656 {
658 gbr_metadata.SetCopper( true );
659 }
660
661 int radius; // Circle/arc radius.
662 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
663
664 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
665 {
666 switch( aShape->GetShape() )
667 {
668 case SHAPE_T::SEGMENT:
669 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, GetPlotMode(),
670 &gbr_metadata );
671 break;
672
673 case SHAPE_T::RECT:
674 {
675 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
676
677 if( sketch || thickness > 0 )
678 {
679 m_plotter->ThickSegment( pts[0], pts[1], thickness, GetPlotMode(), &gbr_metadata );
680 m_plotter->ThickSegment( pts[1], pts[2], thickness, GetPlotMode(), &gbr_metadata );
681 m_plotter->ThickSegment( pts[2], pts[3], thickness, GetPlotMode(), &gbr_metadata );
682 m_plotter->ThickSegment( pts[3], pts[0], thickness, GetPlotMode(), &gbr_metadata );
683 }
684
685 if( !sketch && aShape->IsFilled() )
686 {
687 SHAPE_LINE_CHAIN poly;
688
689 for( const VECTOR2I& pt : pts )
690 poly.Append( pt );
691
692 m_plotter->PlotPoly( poly, FILL_T::FILLED_SHAPE, -1, &gbr_metadata );
693 }
694 }
695 break;
696
697 case SHAPE_T::CIRCLE:
698 radius = KiROUND( GetLineLength( aShape->GetStart(), aShape->GetEnd() ) );
699
700 if( aShape->IsFilled() )
701 {
702 m_plotter->FilledCircle( aShape->GetStart(), radius * 2 + thickness, GetPlotMode(),
703 &gbr_metadata );
704 }
705 else
706 {
707 m_plotter->ThickCircle( aShape->GetStart(), radius * 2, thickness, GetPlotMode(),
708 &gbr_metadata );
709 }
710
711 break;
712
713 case SHAPE_T::ARC:
714 {
715 radius = KiROUND( GetLineLength( aShape->GetCenter(), aShape->GetStart() ) );
716
717 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
718 // but it is a circle
719 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
720 {
721 m_plotter->ThickCircle( aShape->GetCenter(), radius * 2, thickness, GetPlotMode(),
722 &gbr_metadata );
723 }
724 else
725 {
726 m_plotter->ThickArc( *aShape, GetPlotMode(), &gbr_metadata );
727 }
728 }
729 break;
730
731 case SHAPE_T::POLY:
732 if( aShape->IsPolyShapeValid() )
733 {
734 std::vector<VECTOR2I> cornerList;
735 aShape->DupPolyPointsList( cornerList );
736
737 // We must compute board coordinates from m_PolyList which are relative to the parent
738 // position at orientation 0
739 const FOOTPRINT *parentFootprint = aShape->GetParentFootprint();
740
741 if( parentFootprint )
742 {
743 for( unsigned ii = 0; ii < cornerList.size(); ++ii )
744 {
745 RotatePoint( cornerList[ii], parentFootprint->GetOrientation() );
746 cornerList[ii] += parentFootprint->GetPosition();
747 }
748 }
749
750 if( sketch )
751 {
752 for( size_t i = 1; i < cornerList.size(); i++ )
753 {
754 m_plotter->ThickSegment( cornerList[i - 1], cornerList[i], thickness,
755 GetPlotMode(), &gbr_metadata );
756 }
757
758 m_plotter->ThickSegment( cornerList.back(), cornerList.front(), thickness,
759 GetPlotMode(), &gbr_metadata );
760
761 }
762 else
763 {
764 // This must be simplified and fractured to prevent overlapping polygons
765 // from generating invalid Gerber files
766
767 SHAPE_LINE_CHAIN line( cornerList );
768 SHAPE_POLY_SET tmpPoly;
769
770 line.SetClosed( true );
771 tmpPoly.AddOutline( line );
773
774 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
775 {
776 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
777 FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE
779 // Plot the current filled area
780 // (as region for Gerber plotter to manage attributes)
782 {
783 static_cast<GERBER_PLOTTER*>( m_plotter )->
784 PlotPolyAsRegion( poly, fill_mode,
785 thickness, &gbr_metadata );
786 }
787 else
788 m_plotter->PlotPoly( poly, fill_mode,
789 thickness, &gbr_metadata );
790 }
791 }
792 }
793
794 break;
795
796 case SHAPE_T::BEZIER:
797 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
798 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
799 break;
800
801 default:
802 wxASSERT_MSG( false, wxT( "Unhandled FP_SHAPE shape" ) );
803 break;
804 }
805 }
806 else
807 {
808 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
809
810 for( SHAPE* shape : shapes )
811 {
812 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, m_plotter->RenderSettings(),
813 [&]( const VECTOR2I& a, const VECTOR2I& b )
814 {
815 m_plotter->ThickSegment( a, b, thickness, GetPlotMode(),
816 &gbr_metadata );
817 } );
818 }
819
820 for( SHAPE* shape : shapes )
821 delete shape;
822 }
823}
824
825
826#include <font/stroke_font.h>
827void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout )
828{
829 KIFONT::FONT* font = aText->GetFont();
830
831 if( !font )
832 {
835 : wxString( wxEmptyString ),
836 aText->IsBold(), aText->IsItalic() );
837 }
838
839 wxString shownText( aText->GetShownText() );
840
841 if( shownText.IsEmpty() )
842 return;
843
844 if( !m_layerMask[aLayer] )
845 return;
846
847 GBR_METADATA gbr_metadata;
848
849 if( IsCopperLayer( aLayer ) )
851
852 COLOR4D color = getColor( aLayer );
854
855 //VECTOR2I size = aText->GetTextSize();
856 VECTOR2I pos = aText->GetTextPos();
857
858 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
860 attrs.m_Angle = aText->GetDrawRotation();
861 attrs.m_Multiline = false;
862
863 //if( aText->IsMirrored() )
864 // size.x = -size.x;
865
867
868 if( aIsKnockout )
869 {
871 SHAPE_POLY_SET knockouts;
872
873 CALLBACK_GAL callback_gal( empty_opts,
874 // Polygon callback
875 [&]( const SHAPE_LINE_CHAIN& aPoly )
876 {
877 knockouts.AddOutline( aPoly );
878 } );
879
880 callback_gal.SetIsFill( font->IsOutline() );
881 callback_gal.SetIsStroke( font->IsStroke() );
882 font->Draw( &callback_gal, shownText, aText->GetDrawPos(), attrs );
883
884 SHAPE_POLY_SET finalPoly;
885 int margin = attrs.m_StrokeWidth * 1.5
887
888 aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
889 finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
891
892 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
893 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
894 }
895 else if( aText->IsMultilineAllowed() )
896 {
897 std::vector<VECTOR2I> positions;
898 wxArrayString strings_list;
899 wxStringSplit( shownText, strings_list, '\n' );
900 positions.reserve( strings_list.Count() );
901
902 aText->GetLinePositions( positions, strings_list.Count() );
903
904 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
905 {
906 wxString& txt = strings_list.Item( ii );
907 m_plotter->PlotText( positions[ii], color, txt, attrs, font, &gbr_metadata );
908 }
909 }
910 else
911 {
912 m_plotter->PlotText( pos, color, shownText, attrs, font, &gbr_metadata );
913 }
914}
915
916
918 const SHAPE_POLY_SET& polysList )
919{
920 if( polysList.IsEmpty() )
921 return;
922
923 GBR_METADATA gbr_metadata;
924
925 bool isOnCopperLayer = aZone->IsOnCopperLayer();
926
927 if( isOnCopperLayer )
928 {
929 gbr_metadata.SetNetName( aZone->GetNetname() );
930 gbr_metadata.SetCopper( true );
931
932 // Zones with no net name can exist.
933 // they are not used to connect items, so the aperture attribute cannot
934 // be set as conductor
935 if( aZone->GetNetname().IsEmpty() )
936 {
937 gbr_metadata.SetApertureAttrib(
939 }
940 else
941 {
944 }
945 }
946
947 m_plotter->SetColor( getColor( aLayer ) );
948
949 m_plotter->StartBlock( nullptr ); // Clean current object attributes
950
951 /*
952 * In non filled mode the outline is plotted, but not the filling items
953 */
954
955 for( int idx = 0; idx < polysList.OutlineCount(); ++idx )
956 {
957 const SHAPE_LINE_CHAIN& outline = polysList.Outline( idx );
958
959 // Plot the current filled area (as region for Gerber plotter to manage attributes)
960 if( GetPlotMode() == FILLED )
961 {
963 {
964 static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline,
965 &gbr_metadata );
966 }
967 else
968 {
969 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
970 }
971 }
972 else
973 {
975 }
976 }
977
978 m_plotter->EndBlock( nullptr ); // Clear object attributes
979}
980
981
983{
984 if( !m_layerMask[aShape->GetLayer()] )
985 return;
986
987 bool sketch = GetPlotMode() == SKETCH;
988 int thickness = aShape->GetWidth();
989 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
990
991 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
992
993 GBR_METADATA gbr_metadata;
994
995 if( aShape->GetLayer() == Edge_Cuts )
997
998 if( IsCopperLayer( aShape->GetLayer() ) )
999 // Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
1000 // Graphic items having a net have the Conductor attribute, but are not (yet?)
1001 // supported in Pcbnew
1003
1004 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
1005 {
1006 switch( aShape->GetShape() )
1007 {
1008 case SHAPE_T::SEGMENT:
1009 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, GetPlotMode(),
1010 &gbr_metadata );
1011 break;
1012
1013 case SHAPE_T::CIRCLE:
1014 if( aShape->IsFilled() )
1015 {
1016 m_plotter->FilledCircle( aShape->GetStart(), aShape->GetRadius() * 2 + thickness,
1017 GetPlotMode(), &gbr_metadata );
1018 }
1019 else
1020 {
1021 m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness,
1022 GetPlotMode(), &gbr_metadata );
1023 }
1024
1025 break;
1026
1027 case SHAPE_T::ARC:
1028 {
1029 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
1030 // but it is a circle
1031 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
1032 {
1033 m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness,
1034 GetPlotMode(), &gbr_metadata );
1035 }
1036 else
1037 {
1038 m_plotter->ThickArc( *aShape, GetPlotMode(), &gbr_metadata );
1039 }
1040
1041 break;
1042 }
1043
1044 case SHAPE_T::BEZIER:
1045 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
1046 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
1047 break;
1048
1049 case SHAPE_T::POLY:
1050 if( aShape->IsPolyShapeValid() )
1051 {
1052 if( sketch )
1053 {
1054 for( auto it = aShape->GetPolyShape().CIterateSegments( 0 ); it; it++ )
1055 {
1056 auto seg = it.Get();
1057 m_plotter->ThickSegment( seg.A, seg.B, thickness, GetPlotMode(),
1058 &gbr_metadata );
1059 }
1060 }
1061 else
1062 {
1063 m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
1064
1065 // Draw the polygon: only one polygon is expected
1066 // However we provide a multi polygon shape drawing
1067 // ( for the future or to show a non expected shape )
1068 // This must be simplified and fractured to prevent overlapping polygons
1069 // from generating invalid Gerber files
1073
1074 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
1075 {
1076 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
1077
1078 // Ensure the polygon is closed:
1079 poly.SetClosed( true );
1080
1081 // Plot the current filled area
1082 // (as region for Gerber plotter to manage attributes)
1084 {
1085 static_cast<GERBER_PLOTTER*>( m_plotter )->
1086 PlotPolyAsRegion( poly, fill, thickness, &gbr_metadata );
1087 }
1088 else
1089 m_plotter->PlotPoly( poly, fill, thickness, &gbr_metadata );
1090 }
1091 }
1092 }
1093
1094 break;
1095
1096 case SHAPE_T::RECT:
1097 {
1098 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1099
1100 if( sketch )
1101 {
1102 m_plotter->ThickSegment( pts[0], pts[1], thickness, GetPlotMode(), &gbr_metadata );
1103 m_plotter->ThickSegment( pts[1], pts[2], thickness, GetPlotMode(), &gbr_metadata );
1104 m_plotter->ThickSegment( pts[2], pts[3], thickness, GetPlotMode(), &gbr_metadata );
1105 m_plotter->ThickSegment( pts[3], pts[0], thickness, GetPlotMode(), &gbr_metadata );
1106 }
1107 else
1108 {
1109 SHAPE_LINE_CHAIN poly;
1110
1111 for( const VECTOR2I& pt : pts )
1112 poly.Append( pt );
1113
1114 poly.Append( pts[0] ); // Close polygon.
1115
1116 FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE
1118
1120 {
1121 static_cast<GERBER_PLOTTER*>( m_plotter )->
1122 PlotPolyAsRegion( poly, fill_mode, thickness, &gbr_metadata );
1123 }
1124 else
1125 m_plotter->PlotPoly( poly, fill_mode, thickness, &gbr_metadata );
1126 }
1127
1128 break;
1129 }
1130
1131 default:
1133 }
1134 }
1135 else
1136 {
1137 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1138
1139 for( SHAPE* shape : shapes )
1140 {
1141 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, m_plotter->RenderSettings(),
1142 [&]( const VECTOR2I& a, const VECTOR2I& b )
1143 {
1144 m_plotter->ThickSegment( a, b, thickness, GetPlotMode(),
1145 &gbr_metadata );
1146 } );
1147 }
1148
1149 for( SHAPE* shape : shapes )
1150 delete shape;
1151 }
1152}
1153
1154
1156 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
1157 const EDA_ANGLE& aOrientation, int aSmallDrill )
1158{
1159 VECTOR2I drillSize = aDrillSize;
1160
1161 // Small drill marks have no significance when applied to slots
1162 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
1163 drillSize.x = std::min( aSmallDrill, drillSize.x );
1164
1165 // Round holes only have x diameter, slots have both
1166 drillSize.x -= getFineWidthAdj();
1167 drillSize.x = Clamp( 1, drillSize.x, aPadSize.x - 1 );
1168
1169 if( aDrillShape == PAD_DRILL_SHAPE_OBLONG )
1170 {
1171 drillSize.y -= getFineWidthAdj();
1172 drillSize.y = Clamp( 1, drillSize.y, aPadSize.y - 1 );
1173
1174 m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, GetPlotMode(), nullptr );
1175 }
1176 else
1177 {
1178 m_plotter->FlashPadCircle( aDrillPos, drillSize.x, GetPlotMode(), nullptr );
1179 }
1180}
1181
1182
1184{
1185 /* If small drills marks were requested prepare a clamp value to pass
1186 to the helper function */
1188 ? pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize ) : 0;
1189
1190 /* In the filled trace mode drill marks are drawn white-on-black to scrape
1191 the underlying pad. This works only for drivers supporting color change,
1192 obviously... it means that:
1193 - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
1194 - In HPGL you can't see them
1195 - In gerbers you can't see them, too. This is arguably the right thing to
1196 do since having drill marks and high speed drill stations is a sure
1197 recipe for broken tools and angry manufacturers. If you *really* want them
1198 you could start a layer with negative polarity to scrape the film.
1199 - In DXF they go into the 'WHITE' layer. This could be useful.
1200 */
1201 if( GetPlotMode() == FILLED )
1203
1204 for( PCB_TRACK* tracks : m_board->Tracks() )
1205 {
1206 const PCB_VIA* via = dyn_cast<const PCB_VIA*>( tracks );
1207
1208 if( via )
1209 {
1211 VECTOR2I( via->GetDrillValue(), 0 ), VECTOR2I( via->GetWidth(), 0 ),
1212 ANGLE_0, smallDrill );
1213 }
1214 }
1215
1216 for( FOOTPRINT* footprint : m_board->Footprints() )
1217 {
1218 for( PAD* pad : footprint->Pads() )
1219 {
1220 if( pad->GetDrillSize().x == 0 )
1221 continue;
1222
1223 plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
1224 pad->GetSize(), pad->GetOrientation(), smallDrill );
1225 }
1226 }
1227
1228 if( GetPlotMode() == FILLED )
1230}
int color
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
virtual bool IsKnockout() const
Definition: board_item.h:262
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:226
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:175
FOOTPRINTS & Footprints()
Definition: board.h:311
TRACKS & Tracks()
Definition: board.h:308
DRAWINGS & Drawings()
Definition: board.h:314
void PlotDrillMarks()
Draw a drill mark for pads and vias.
LSET m_layerMask
Definition: pcbplot.h:142
void plotOneDrillMark(PAD_DRILL_SHAPE_T aDrillShape, const VECTOR2I &aDrillPos, const VECTOR2I &aDrillSize, const VECTOR2I &aPadSize, const EDA_ANGLE &aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
void PlotPcbShape(const PCB_SHAPE *aShape)
void PlotPcbGraphicItem(const BOARD_ITEM *item)
void PlotFilledAreas(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
void PlotDimension(const PCB_DIMENSION_BASE *aDim)
void PlotPad(const PAD *aPad, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
void PlotFootprintShape(const FP_SHAPE *aShape)
BOARD * m_board
Definition: pcbplot.h:141
PLOTTER * m_plotter
Definition: pcbplot.h:140
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotBoardGraphicItems()
Plot items like text and graphics but not tracks and footprints.
void PlotPcbTarget(const PCB_TARGET *aMire)
void PlotFootprintTextItems(const FOOTPRINT *aFootprint)
int getFineWidthAdj() const
Definition: pcbplot.h:71
void PlotPcbText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout)
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
void PlotFootprintTextItem(const FP_TEXT *aText, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) const
double AsDegrees() const
Definition: eda_angle.h:149
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EDA_ANGLE GetArcAngle() const
Definition: eda_shape.cpp:585
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:179
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:289
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:247
bool IsFilled() const
Definition: eda_shape.h:90
void SetFilled(bool aFlag)
Definition: eda_shape.h:95
int GetRadius() const
Definition: eda_shape.cpp:523
SHAPE_T GetShape() const
Definition: eda_shape.h:113
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:124
void DupPolyPointsList(std::vector< VECTOR2I > &aBuffer) const
Duplicate the list of corners in a std::vector<VECTOR2I>
Definition: eda_shape.cpp:1225
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:112
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1035
int GetWidth() const
Definition: eda_shape.h:109
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:149
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:75
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:176
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1242
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
void TransformBoundingBoxToPolygon(SHAPE_POLY_SET *aBuffer, int aClearance) const
Convert the text bounding box to a rectangular polygon depending on the text orientation,...
Definition: eda_text.cpp:947
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
bool IsItalic() const
Definition: eda_text.h:130
bool IsMultilineAllowed() const
Definition: eda_text.h:146
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
virtual bool IsVisible() const
Definition: eda_text.h:136
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:317
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:318
void GetLinePositions(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:673
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
bool IsBold() const
Definition: eda_text.h:133
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
LSET GetPrivateLayers() const
Definition: footprint.h:120
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
const wxString & GetReference() const
Definition: footprint.h:519
VECTOR2I GetPosition() const override
Definition: footprint.h:188
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
FP_TEXT & Reference()
Definition: footprint.h:568
virtual EDA_ANGLE GetDrawRotation() const override
Definition: fp_text.cpp:247
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:415
@ GBR_APERTURE_ATTRIB_ETCHEDCMP
aperture used for etched components.
Definition: gbr_metadata.h:94
@ GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
aperture used for edge connector pad (outer layers).
Definition: gbr_metadata.h:117
@ GBR_APERTURE_ATTRIB_HEATSINKPAD
aperture used for castellated pads in copper layer files.
Definition: gbr_metadata.h:131
@ GBR_APERTURE_ATTRIB_TESTPOINT
aperture used for test point pad (outer layers).
Definition: gbr_metadata.h:122
@ GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
aperture used for BGA pads with a solder mask defined by the copper shape.
Definition: gbr_metadata.h:111
@ GBR_APERTURE_ATTRIB_WASHERPAD
aperture used for mechanical pads (NPTH).
Definition: gbr_metadata.h:121
@ GBR_APERTURE_ATTRIB_COMPONENTPAD
aperture used for SMD pad. Excluded BGA pads which have their own type.
Definition: gbr_metadata.h:105
@ GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
aperture used for fiducial pad (outer layers), at footprint level.
Definition: gbr_metadata.h:125
@ GBR_APERTURE_ATTRIB_CASTELLATEDPAD
aperture used for castellated pads in drill files.
Definition: gbr_metadata.h:134
@ GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
aperture used for heat sink pad (typically for SMDs).
Definition: gbr_metadata.h:128
@ GBR_APERTURE_ATTRIB_EDGECUT
aperture used for board cutout,
Definition: gbr_metadata.h:98
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:205
void SetCopper(bool aValue)
Definition: gbr_metadata.h:252
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:241
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:229
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
Definition: gbr_metadata.h:236
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:209
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:219
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
Definition: gbr_metadata.h:231
@ 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, OUTLINE_MODE aPlotMode, void *aData)
Flash a chamfered round rect pad.
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:138
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:232
virtual bool IsStroke() const
Definition: font.h:112
virtual bool IsOutline() const
Definition: font.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxString & GetDefaultFont() const
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:801
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
Definition: pad.h:60
PAD_PROP GetProperty() const
Definition: pad.h:404
PAD_ATTRIB GetAttribute() const
Definition: pad.h:401
const wxString & GetPinFunction() const
Definition: pad.h:147
const wxString & GetNumber() const
Definition: pad.h:136
int GetRoundRectCornerRadius() const
Definition: pad.cpp:330
VECTOR2I ShapePos() const
Definition: pad.cpp:770
FOOTPRINT * GetParent() const
Definition: pad.cpp:1471
const VECTOR2I & GetDelta() const
Definition: pad.h:265
PAD_SHAPE GetShape() const
Definition: pad.h:195
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:371
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:361
int GetChamferPositions() const
Definition: pad.h:595
const VECTOR2I & GetSize() const
Definition: pad.h:258
double GetChamferRectRatio() const
Definition: pad.h:585
Abstract dimension API.
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
bool GetPlotInvisibleText() const
bool GetPlotReference() const
int GetSketchPadLineWidth() const
DRILL_MARKS GetDrillMarksType() const
bool GetPlotValue() const
OUTLINE_MODE GetPlotMode() 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:67
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:252
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:71
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:72
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
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:549
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:652
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FilledCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:668
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness=USE_DEFAULT_LINE_WIDTH)
Generic fallback: Cubic Bezier curve rendered as a polyline In KiCad the bezier curves have 4 control...
Definition: plotter.cpp:224
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual PLOT_FORMAT GetPlotterType() const =0
Returns the effective plot engine in use.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
Definition: plotter.cpp:758
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:538
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
Flash a trapezoidal pad.
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void ThickArc(const VECTOR2I &aCentre, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, OUTLINE_MODE aTraceMode, void *aData)
Definition: plotter.cpp:592
virtual void FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void SetColor(const COLOR4D &color)=0
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
Definition: plotter.h:547
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
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 BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
bool IsEmpty() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
CONST_SEGMENT_ITERATOR CIterateSegments(int aFirst, int aLast, bool aIterateHoles=false) const
Return an iterator object, for iterating aPolygonIdx-th polygon edges.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
SHAPE_POLY_SET CloneDropTriangulation() const
Creates a new empty polygon in the set and returns its index.
An abstract shape on 2D plane.
Definition: shape.h:124
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
static void Stroke(const SHAPE *aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
PLOT_DASH_TYPE GetPlotStyle() const
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
bool IsOnCopperLayer() const override
Definition: zone.cpp:260
@ WHITE
Definition: color4d.h:46
@ LIGHTGRAY
Definition: color4d.h:45
@ BLACK
Definition: color4d.h:42
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:429
FILL_T
Definition: eda_shape.h:54
@ FILLED_SHAPE
Handle special data (items attributes) during plot.
#define GBR_NETINFO_ALL
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Returns the margin for knocking out text.
Definition: gr_text.h:104
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:827
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ Edge_Cuts
Definition: layer_ids.h:113
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137
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:83
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418
OUTLINE_MODE
Definition: outline_mode.h:25
@ SKETCH
Definition: outline_mode.h:26
@ FILLED
Definition: outline_mode.h:27
@ NPTH
like PAD_PTH, but not plated
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ CONN
Like smd, does not appear on the solder paste layer (default)
PAD_DRILL_SHAPE_T
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: pad_shapes.h:69
@ PAD_DRILL_SHAPE_CIRCLE
Definition: pad_shapes.h:70
@ PAD_DRILL_SHAPE_OBLONG
Definition: pad_shapes.h:71
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
@ NONE
no special fabrication property
@ TESTPOINT
a test point pad
@ CASTELLATED
a pad with a castellated through hole
@ BGA
Smd pad, used in BGA footprints.
Plotting engine (Gerber)
@ SH_CIRCLE
circle
Definition: shape.h:48
@ SH_SEGMENT
line segment
Definition: shape.h:46
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:188
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ 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:110
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109
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
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
Definition: util.h:64
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590