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-2022 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 {
413 aText->IsBold(), aText->IsItalic() );
414 }
415
416 if( aText->IsMirrored() )
417 size.x = -size.x; // Text is mirrored
418
419 // Non bold texts thickness is clamped at 1/6 char size by the low level draw function.
420 // but in Pcbnew we do not manage bold texts and thickness up to 1/4 char size
421 // (like bold text) and we manage the thickness.
422 // So we set bold flag to true
423 bool allow_bold = true;
424
425 GBR_METADATA gbr_metadata;
426
427 if( IsCopperLayer( aText->GetLayer() ) )
429
431 const FOOTPRINT* parent = static_cast<const FOOTPRINT*> ( aText->GetParent() );
432 gbr_metadata.SetCmpReference( parent->GetReference() );
433
434 m_plotter->SetCurrentLineWidth( thickness );
435
436 m_plotter->Text( pos, aColor, aText->GetShownText(), aText->GetDrawRotation(), size,
437 aText->GetHorizJustify(), aText->GetVertJustify(), thickness,
438 aText->IsItalic(), allow_bold, false, font, &gbr_metadata );
439}
440
441
443{
444 if( !m_layerMask[aDim->GetLayer()] )
445 return;
446
447 PCB_SHAPE draw;
448
450 draw.SetLayer( aDim->GetLayer() );
451
453
454 // Set plot color (change WHITE to LIGHTGRAY because
455 // the white items are not seen on a white paper or screen
457
458 PlotPcbText( &aDim->Text(), aDim->GetLayer(), false );
459
460 for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
461 {
462 switch( shape->Type() )
463 {
464 case SH_SEGMENT:
465 {
466 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
467
469 draw.SetStart( seg.A );
470 draw.SetEnd( seg.B );
471
472 PlotPcbShape( &draw );
473 break;
474 }
475
476 case SH_CIRCLE:
477 {
478 VECTOR2I start( shape->Centre() );
479 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
480
482 draw.SetFilled( false );
483 draw.SetStart( start );
484 draw.SetEnd( VECTOR2I( start.x + radius, start.y ) );
485
486 PlotPcbShape( &draw );
487 break;
488 }
489
490 default:
491 break;
492 }
493 }
494}
495
496
498{
499 int dx1, dx2, dy1, dy2, radius;
500
501 if( !m_layerMask[aMire->GetLayer()] )
502 return;
503
504 m_plotter->SetColor( getColor( aMire->GetLayer() ) );
505
506 PCB_SHAPE draw;
507
509 draw.SetFilled( false );
511 draw.SetLayer( aMire->GetLayer() );
512 draw.SetStart( aMire->GetPosition() );
513 radius = aMire->GetSize() / 3;
514
515 if( aMire->GetShape() ) // shape X
516 radius = aMire->GetSize() / 2;
517
518 // Draw the circle
519 draw.SetEnd( VECTOR2I( draw.GetStart().x + radius, draw.GetStart().y ) );
520
521 PlotPcbShape( &draw );
522
524
525 radius = aMire->GetSize() / 2;
526 dx1 = radius;
527 dy1 = 0;
528 dx2 = 0;
529 dy2 = radius;
530
531 if( aMire->GetShape() ) // Shape X
532 {
533 dx1 = dy1 = radius;
534 dx2 = dx1;
535 dy2 = -dy1;
536 }
537
538 VECTOR2I mirePos( aMire->GetPosition() );
539
540 // Draw the X or + shape:
541 draw.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
542 draw.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
543 PlotPcbShape( &draw );
544
545 draw.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
546 draw.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
547 PlotPcbShape( &draw );
548}
549
550
552{
553 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
554 {
555 if( aFootprint->GetPrivateLayers().test( item->GetLayer() ) )
556 continue;
557
558 switch( item->Type() )
559 {
560 case PCB_FP_SHAPE_T:
561 {
562 const FP_SHAPE* shape = static_cast<const FP_SHAPE*>( item );
563
564 if( m_layerMask[ shape->GetLayer() ] )
565 PlotFootprintShape( shape );
566
567 break;
568 }
569
570 case PCB_FP_TEXTBOX_T:
571 {
572 const FP_TEXTBOX* textbox = static_cast<const FP_TEXTBOX*>( item );
573
574 if( m_layerMask[ textbox->GetLayer() ] )
575 {
576 PlotPcbText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
577 PlotFootprintShape( textbox );
578 }
579
580 break;
581 }
582
588 {
589 const PCB_DIMENSION_BASE* dimension = static_cast<const PCB_DIMENSION_BASE*>( item );
590
591 if( m_layerMask[ dimension->GetLayer() ] )
592 PlotDimension( dimension );
593
594 break;
595 }
596
597 case PCB_FP_TEXT_T:
598 // Plotted in PlotFootprintTextItem()
599 break;
600
601 default:
602 UNIMPLEMENTED_FOR( item->GetClass() );
603 }
604 }
605}
606
607
609{
610 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
611
612 bool sketch = GetPlotMode() == SKETCH;
613 int thickness = aShape->GetWidth();
614
615 GBR_METADATA gbr_metadata;
617 const FOOTPRINT* parent = static_cast<const FOOTPRINT*> ( aShape->GetParent() );
618 gbr_metadata.SetCmpReference( parent->GetReference() );
619
620 bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
621
622 if( aShape->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers
623 {
625 }
626 else if( isOnCopperLayer ) // only for items not on Edge_Cuts.
627 {
629 gbr_metadata.SetCopper( true );
630 }
631
632 int radius; // Circle/arc radius.
633 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
634
635 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
636 {
637 switch( aShape->GetShape() )
638 {
639 case SHAPE_T::SEGMENT:
640 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, GetPlotMode(),
641 &gbr_metadata );
642 break;
643
644 case SHAPE_T::RECT:
645 {
646 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
647
648 if( sketch || thickness > 0 )
649 {
650 m_plotter->ThickSegment( pts[0], pts[1], thickness, GetPlotMode(), &gbr_metadata );
651 m_plotter->ThickSegment( pts[1], pts[2], thickness, GetPlotMode(), &gbr_metadata );
652 m_plotter->ThickSegment( pts[2], pts[3], thickness, GetPlotMode(), &gbr_metadata );
653 m_plotter->ThickSegment( pts[3], pts[0], thickness, GetPlotMode(), &gbr_metadata );
654 }
655
656 if( !sketch && aShape->IsFilled() )
657 {
658 SHAPE_LINE_CHAIN poly;
659
660 for( const VECTOR2I& pt : pts )
661 poly.Append( pt );
662
663 m_plotter->PlotPoly( poly, FILL_T::FILLED_SHAPE, -1, &gbr_metadata );
664 }
665 }
666 break;
667
668 case SHAPE_T::CIRCLE:
669 radius = KiROUND( GetLineLength( aShape->GetStart(), aShape->GetEnd() ) );
670
671 if( aShape->IsFilled() )
672 {
673 m_plotter->FilledCircle( aShape->GetStart(), radius * 2 + thickness, GetPlotMode(),
674 &gbr_metadata );
675 }
676 else
677 {
678 m_plotter->ThickCircle( aShape->GetStart(), radius * 2, thickness, GetPlotMode(),
679 &gbr_metadata );
680 }
681
682 break;
683
684 case SHAPE_T::ARC:
685 {
686 radius = KiROUND( GetLineLength( aShape->GetCenter(), aShape->GetStart() ) );
687
688 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
689 // but it is a circle
690 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
691 {
692 m_plotter->ThickCircle( aShape->GetCenter(), radius * 2, thickness, GetPlotMode(),
693 &gbr_metadata );
694 }
695 else
696 {
697 m_plotter->ThickArc( *aShape, GetPlotMode(), &gbr_metadata );
698 }
699 }
700 break;
701
702 case SHAPE_T::POLY:
703 if( aShape->IsPolyShapeValid() )
704 {
705 std::vector<VECTOR2I> cornerList;
706 aShape->DupPolyPointsList( cornerList );
707
708 // We must compute board coordinates from m_PolyList which are relative to the parent
709 // position at orientation 0
710 const FOOTPRINT *parentFootprint = aShape->GetParentFootprint();
711
712 if( parentFootprint )
713 {
714 for( unsigned ii = 0; ii < cornerList.size(); ++ii )
715 {
716 RotatePoint( cornerList[ii], parentFootprint->GetOrientation() );
717 cornerList[ii] += parentFootprint->GetPosition();
718 }
719 }
720
721 if( sketch )
722 {
723 for( size_t i = 1; i < cornerList.size(); i++ )
724 {
725 m_plotter->ThickSegment( cornerList[i - 1], cornerList[i], thickness,
726 GetPlotMode(), &gbr_metadata );
727 }
728
729 m_plotter->ThickSegment( cornerList.back(), cornerList.front(), thickness,
730 GetPlotMode(), &gbr_metadata );
731
732 }
733 else
734 {
735 // This must be simplified and fractured to prevent overlapping polygons
736 // from generating invalid Gerber files
737
738 SHAPE_LINE_CHAIN line( cornerList );
739 SHAPE_POLY_SET tmpPoly;
740
741 line.SetClosed( true );
742 tmpPoly.AddOutline( line );
744
745 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
746 {
747 SHAPE_LINE_CHAIN &poly = tmpPoly.Outline( jj );
750 thickness, &gbr_metadata );
751 }
752 }
753 }
754
755 break;
756
757 case SHAPE_T::BEZIER:
758 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
759 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
760 break;
761
762 default:
763 wxASSERT_MSG( false, wxT( "Unhandled FP_SHAPE shape" ) );
764 break;
765 }
766 }
767 else
768 {
769 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
770
771 for( SHAPE* shape : shapes )
772 {
773 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, m_plotter->RenderSettings(),
774 [&]( const VECTOR2I& a, const VECTOR2I& b )
775 {
776 m_plotter->ThickSegment( a, b, thickness, GetPlotMode(),
777 &gbr_metadata );
778 } );
779 }
780
781 for( SHAPE* shape : shapes )
782 delete shape;
783 }
784}
785
786
787void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout )
788{
789 KIFONT::FONT* font = aText->GetFont();
790
791 if( !font )
792 {
794 aText->IsBold(), aText->IsItalic() );
795 }
796
797 wxString shownText( aText->GetShownText() );
798 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
799
800 if( shownText.IsEmpty() )
801 return;
802
803 if( !m_layerMask[aLayer] )
804 return;
805
806 GBR_METADATA gbr_metadata;
807
808 if( IsCopperLayer( aLayer ) )
810
811 COLOR4D color = getColor( aLayer );
813
814 VECTOR2I size = aText->GetTextSize();
815 VECTOR2I pos = aText->GetTextPos();
816
818
819 if( aText->IsMirrored() )
820 size.x = -size.x;
821
823
824 if( aIsKnockout )
825 {
827 SHAPE_POLY_SET knockouts;
828
829 CALLBACK_GAL callback_gal( empty_opts,
830 // Polygon callback
831 [&]( const SHAPE_LINE_CHAIN& aPoly )
832 {
833 knockouts.AddOutline( aPoly );
834 } );
835
836 callback_gal.SetIsFill( font->IsOutline() );
837 callback_gal.SetIsStroke( font->IsStroke() );
838 font->Draw( &callback_gal, shownText, aText->GetDrawPos(), attrs );
839
840 SHAPE_POLY_SET finalPoly;
841 int margin = attrs.m_StrokeWidth * 1.5
843
844 aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
845 finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
847
848 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
849 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
850 }
851 else if( aText->IsMultilineAllowed() )
852 {
853 std::vector<VECTOR2I> positions;
854 wxArrayString strings_list;
855 wxStringSplit( shownText, strings_list, '\n' );
856 positions.reserve( strings_list.Count() );
857
858 aText->GetLinePositions( positions, strings_list.Count() );
859
860 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
861 {
862 wxString& txt = strings_list.Item( ii );
863 m_plotter->Text( positions[ii], color, txt, aText->GetDrawRotation(), size,
864 attrs.m_Halign, attrs.m_Valign, attrs.m_StrokeWidth, attrs.m_Italic,
865 attrs.m_Bold, false, font, &gbr_metadata );
866 }
867 }
868 else
869 {
870 m_plotter->Text( pos, color, shownText, aText->GetDrawRotation(), size, attrs.m_Halign,
871 attrs.m_Valign, attrs.m_StrokeWidth, attrs.m_Italic, attrs.m_Bold, false,
872 font, &gbr_metadata );
873 }
874}
875
876
878 const SHAPE_POLY_SET& polysList )
879{
880 if( polysList.IsEmpty() )
881 return;
882
883 GBR_METADATA gbr_metadata;
884
885 bool isOnCopperLayer = aZone->IsOnCopperLayer();
886
887 if( isOnCopperLayer )
888 {
889 gbr_metadata.SetNetName( aZone->GetNetname() );
890 gbr_metadata.SetCopper( true );
891
892 // Zones with no net name can exist.
893 // they are not used to connect items, so the aperture attribute cannot
894 // be set as conductor
895 if( aZone->GetNetname().IsEmpty() )
896 {
897 gbr_metadata.SetApertureAttrib(
899 }
900 else
901 {
904 }
905 }
906
907 m_plotter->SetColor( getColor( aLayer ) );
908
909 m_plotter->StartBlock( nullptr ); // Clean current object attributes
910
911 /*
912 * In non filled mode the outline is plotted, but not the filling items
913 */
914
915 for( int idx = 0; idx < polysList.OutlineCount(); ++idx )
916 {
917 const SHAPE_LINE_CHAIN& outline = polysList.Outline( idx );
918
919 // Plot the current filled area (as region for Gerber plotter to manage attributes)
920 if( GetPlotMode() == FILLED )
921 {
923 {
924 static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline,
925 &gbr_metadata );
926 }
927 else
928 {
929 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
930 }
931 }
932 else
933 {
935 }
936 }
937
938 m_plotter->EndBlock( nullptr ); // Clear object attributes
939}
940
941
943{
944 if( !m_layerMask[aShape->GetLayer()] )
945 return;
946
947 bool sketch = GetPlotMode() == SKETCH;
948 int thickness = aShape->GetWidth();
949 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
950
951 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
952
953 GBR_METADATA gbr_metadata;
954
955 if( aShape->GetLayer() == Edge_Cuts )
957
958 if( IsCopperLayer( aShape->GetLayer() ) )
959 // Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
960 // Graphic items having a net have the Conductor attribute, but are not (yet?)
961 // supported in Pcbnew
963
964 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
965 {
966 switch( aShape->GetShape() )
967 {
968 case SHAPE_T::SEGMENT:
969 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, GetPlotMode(),
970 &gbr_metadata );
971 break;
972
973 case SHAPE_T::CIRCLE:
974 if( aShape->IsFilled() )
975 {
976 m_plotter->FilledCircle( aShape->GetStart(), aShape->GetRadius() * 2 + thickness,
977 GetPlotMode(), &gbr_metadata );
978 }
979 else
980 {
981 m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness,
982 GetPlotMode(), &gbr_metadata );
983 }
984
985 break;
986
987 case SHAPE_T::ARC:
988 {
989 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
990 // but it is a circle
991 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
992 {
993 m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness,
994 GetPlotMode(), &gbr_metadata );
995 }
996 else
997 {
998 m_plotter->ThickArc( *aShape, GetPlotMode(), &gbr_metadata );
999 }
1000
1001 break;
1002 }
1003
1004 case SHAPE_T::BEZIER:
1005 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
1006 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
1007 break;
1008
1009 case SHAPE_T::POLY:
1010 if( aShape->IsPolyShapeValid() )
1011 {
1012 if( sketch )
1013 {
1014 for( auto it = aShape->GetPolyShape().CIterateSegments( 0 ); it; it++ )
1015 {
1016 auto seg = it.Get();
1017 m_plotter->ThickSegment( seg.A, seg.B, thickness, GetPlotMode(),
1018 &gbr_metadata );
1019 }
1020 }
1021 else
1022 {
1023 m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
1024
1025 // Draw the polygon: only one polygon is expected
1026 // However we provide a multi polygon shape drawing
1027 // ( for the future or to show a non expected shape )
1028 // This must be simplified and fractured to prevent overlapping polygons
1029 // from generating invalid Gerber files
1033
1034 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
1035 {
1036 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
1037
1038 // Ensure the polygon is closed:
1039 poly.SetClosed( true );
1040
1041 m_plotter->PlotPoly( poly, fill, thickness, &gbr_metadata );
1042 }
1043 }
1044 }
1045
1046 break;
1047
1048 case SHAPE_T::RECT:
1049 {
1050 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1051
1052 if( sketch || thickness > 0 )
1053 {
1054 m_plotter->ThickSegment( pts[0], pts[1], thickness, GetPlotMode(), &gbr_metadata );
1055 m_plotter->ThickSegment( pts[1], pts[2], thickness, GetPlotMode(), &gbr_metadata );
1056 m_plotter->ThickSegment( pts[2], pts[3], thickness, GetPlotMode(), &gbr_metadata );
1057 m_plotter->ThickSegment( pts[3], pts[0], thickness, GetPlotMode(), &gbr_metadata );
1058 }
1059
1060 if( !sketch && aShape->IsFilled() )
1061 {
1062 SHAPE_LINE_CHAIN poly;
1063
1064 for( const VECTOR2I& pt : pts )
1065 poly.Append( pt );
1066
1067 m_plotter->PlotPoly( poly, FILL_T::FILLED_SHAPE, -1, &gbr_metadata );
1068 }
1069
1070 break;
1071 }
1072
1073 default:
1075 }
1076 }
1077 else
1078 {
1079 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1080
1081 for( SHAPE* shape : shapes )
1082 {
1083 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, m_plotter->RenderSettings(),
1084 [&]( const VECTOR2I& a, const VECTOR2I& b )
1085 {
1086 m_plotter->ThickSegment( a, b, thickness, GetPlotMode(),
1087 &gbr_metadata );
1088 } );
1089 }
1090
1091 for( SHAPE* shape : shapes )
1092 delete shape;
1093 }
1094}
1095
1096
1098 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
1099 const EDA_ANGLE& aOrientation, int aSmallDrill )
1100{
1101 VECTOR2I drillSize = aDrillSize;
1102
1103 // Small drill marks have no significance when applied to slots
1104 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE_CIRCLE )
1105 drillSize.x = std::min( aSmallDrill, drillSize.x );
1106
1107 // Round holes only have x diameter, slots have both
1108 drillSize.x -= getFineWidthAdj();
1109 drillSize.x = Clamp( 1, drillSize.x, aPadSize.x - 1 );
1110
1111 if( aDrillShape == PAD_DRILL_SHAPE_OBLONG )
1112 {
1113 drillSize.y -= getFineWidthAdj();
1114 drillSize.y = Clamp( 1, drillSize.y, aPadSize.y - 1 );
1115
1116 m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, GetPlotMode(), nullptr );
1117 }
1118 else
1119 {
1120 m_plotter->FlashPadCircle( aDrillPos, drillSize.x, GetPlotMode(), nullptr );
1121 }
1122}
1123
1124
1126{
1127 /* If small drills marks were requested prepare a clamp value to pass
1128 to the helper function */
1130 ? pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize ) : 0;
1131
1132 /* In the filled trace mode drill marks are drawn white-on-black to scrape
1133 the underlying pad. This works only for drivers supporting color change,
1134 obviously... it means that:
1135 - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
1136 - In HPGL you can't see them
1137 - In gerbers you can't see them, too. This is arguably the right thing to
1138 do since having drill marks and high speed drill stations is a sure
1139 recipe for broken tools and angry manufacturers. If you *really* want them
1140 you could start a layer with negative polarity to scrape the film.
1141 - In DXF they go into the 'WHITE' layer. This could be useful.
1142 */
1143 if( GetPlotMode() == FILLED )
1145
1146 for( PCB_TRACK* tracks : m_board->Tracks() )
1147 {
1148 const PCB_VIA* via = dyn_cast<const PCB_VIA*>( tracks );
1149
1150 if( via )
1151 {
1153 wxSize( via->GetDrillValue(), 0 ),
1154 wxSize( via->GetWidth(), 0 ), ANGLE_0, smallDrill );
1155 }
1156 }
1157
1158 for( FOOTPRINT* footprint : m_board->Footprints() )
1159 {
1160 for( PAD* pad : footprint->Pads() )
1161 {
1162 if( pad->GetDrillSize().x == 0 )
1163 continue;
1164
1165 plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
1166 pad->GetSize(), pad->GetOrientation(), smallDrill );
1167 }
1168 }
1169
1170 if( GetPlotMode() == FILLED )
1172}
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:58
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
virtual bool IsKnockout() const
Definition: board_item.h:250
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:214
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
DRAWINGS & Drawings()
Definition: board.h:310
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:541
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:175
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:285
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:243
bool IsFilled() const
Definition: eda_shape.h:90
void SetFilled(bool aFlag)
Definition: eda_shape.h:95
int GetRadius() const
Definition: eda_shape.cpp:479
SHAPE_T GetShape() const
Definition: eda_shape.h:111
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:141
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:120
void DupPolyPointsList(std::vector< VECTOR2I > &aBuffer) const
Duplicate the list of corners in a std::vector<VECTOR2I>
Definition: eda_shape.cpp:1179
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:116
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:110
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:989
int GetWidth() const
Definition: eda_shape.h:107
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:145
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:75
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:172
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1196
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:945
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:201
bool IsItalic() const
Definition: eda_text.h:123
bool IsMultilineAllowed() const
Definition: eda_text.h:139
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:129
KIFONT::FONT * GetFont() const
Definition: eda_text.h:181
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:310
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:311
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:142
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:671
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:165
bool IsMirrored() const
Definition: eda_text.h:132
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
bool IsBold() const
Definition: eda_text.h:126
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:145
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
VECTOR2I GetTextSize() const
Definition: eda_text.h:189
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
LSET GetPrivateLayers() const
Definition: footprint.h:120
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:558
const wxString & GetReference() const
Definition: footprint.h:510
VECTOR2I GetPosition() const override
Definition: footprint.h:188
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
FP_TEXT & Reference()
Definition: footprint.h:559
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:65
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:159
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:104
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:59
PAD_PROP GetProperty() const
Definition: pad.h:398
PAD_ATTRIB GetAttribute() const
Definition: pad.h:395
const wxString & GetPinFunction() const
Definition: pad.h:146
const wxString & GetNumber() const
Definition: pad.h:135
int GetRoundRectCornerRadius() const
Definition: pad.cpp:315
VECTOR2I ShapePos() const
Definition: pad.cpp:755
FOOTPRINT * GetParent() const
Definition: pad.cpp:1454
const VECTOR2I & GetDelta() const
Definition: pad.h:259
PAD_SHAPE GetShape() const
Definition: pad.h:189
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:365
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:346
int GetChamferPositions() const
Definition: pad.h:589
const VECTOR2I & GetSize() const
Definition: pad.h:252
double GetChamferRectRatio() const
Definition: pad.h:579
Abstract dimension API.
Definition: pcb_dimension.h:96
int GetLineThickness() const
PCB_TEXT & Text()
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:65
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:69
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:70
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 void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
Definition: plotter.cpp:714
virtual PLOT_FORMAT GetPlotterType() const =0
Returns the effective plot engine in use.
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:518
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:527
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:123
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
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:57
bool IsOnCopperLayer() const override
Definition: zone.cpp:251
@ WHITE
Definition: color4d.h:48
@ LIGHTGRAY
Definition: color4d.h:47
@ BLACK
Definition: color4d.h:44
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
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 knockout text.
Definition: gr_text.h:97
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825
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:401
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:47
@ SH_SEGMENT
line segment
Definition: shape.h:45
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:618