KiCad PCB EDA Suite
Loading...
Searching...
No Matches
plot_brditems_plotter.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, 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
28#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...
33#include <geometry/shape_rect.h>
35#include <string_utils.h>
36#include <macros.h>
37#include <math/util.h> // for KiROUND
38#include <math/vector2d.h> // for VECTOR2I
40#include <trigo.h>
41#include <font/stroke_font.h>
43#include <callback_gal.h>
44#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
45#include <gbr_metadata.h>
46#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
47#include <layer_ids.h> // for LSET, IsCopperLayer
48#include <lset.h>
49#include <pcbplot.h>
50#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
51#include <advanced_config.h>
52
53#include <pcb_dimension.h>
54#include <pcb_shape.h>
55#include <footprint.h>
56#include <pcb_track.h>
57#include <pad.h>
58#include <pcb_target.h>
59#include <pcb_text.h>
60#include <pcb_textbox.h>
61#include <pcb_tablecell.h>
62#include <pcb_table.h>
63#include <zone.h>
64#include <pcb_barcode.h>
65
66#include <wx/debug.h> // for wxASSERT_MSG
67
68
70{
71 COLOR4D color = ColorSettings()->GetColor( aLayer );
72
73 // A hack to avoid plotting a white item in white color on white paper
74 if( color == COLOR4D::WHITE )
75 color = COLOR4D( LIGHTGRAY );
76
77 return color;
78}
79
80
81void BRDITEMS_PLOTTER::PlotPadNumber( const PAD* aPad, const COLOR4D& aColor )
82{
83 wxString padNumber = UnescapeString( aPad->GetNumber() );
84
85 if( padNumber.IsEmpty() )
86 return;
87
88 BOX2I padBBox = aPad->GetBoundingBox();
89 VECTOR2I position = padBBox.Centre();
90 VECTOR2I padsize = padBBox.GetSize();
91
92 // TODO(JE) padstacks
94 {
95 // See if we have a number box
96 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives( PADSTACK::ALL_LAYERS ) )
97 {
98 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
99 {
100 position = primitive->GetCenter();
101 RotatePoint( position, aPad->GetOrientation() );
102 position += aPad->ShapePos( PADSTACK::ALL_LAYERS );
103
104 padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
105 padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
106
107 break;
108 }
109 }
110 }
111
113 {
114 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
115 int limit = KiROUND( std::min( aPad->GetSize( PADSTACK::ALL_LAYERS ).x,
116 aPad->GetSize( PADSTACK::ALL_LAYERS ).y ) * 1.1 );
117
118 if( padsize.x > limit && padsize.y > limit )
119 {
120 padsize.x = limit;
121 padsize.y = limit;
122 }
123 }
124
125 TEXT_ATTRIBUTES textAttrs;
126
127 textAttrs.m_Mirrored = m_plotter->GetPlotMirrored();
128
129 if( padsize.x < ( padsize.y * 0.95 ) )
130 {
131 textAttrs.m_Angle = ANGLE_90;
132 std::swap( padsize.x, padsize.y );
133 }
134
135 // approximate the size of the pad number text:
136 // We use a size for at least 3 chars, to give a good look even for short numbers
137 int tsize = KiROUND( padsize.x / std::max( PrintableCharCount( padNumber ), 3 ) );
138 tsize = std::min( tsize, padsize.y );
139
140 // enforce a max size
141 tsize = std::min( tsize, pcbIUScale.mmToIU( 5.0 ) );
142
143 textAttrs.m_Size = VECTOR2I( tsize, tsize );
144
145 // use a somewhat spindly font to go with the outlined pads
146 textAttrs.m_StrokeWidth = KiROUND( tsize / 12.0 );
147
148 m_plotter->PlotText( position, aColor, padNumber, textAttrs );
149}
150
151
152void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, PCB_LAYER_ID aLayer, const COLOR4D& aColor,
153 bool aSketchMode )
154{
155 VECTOR2I shape_pos = aPad->ShapePos( aLayer );
156 GBR_METADATA metadata;
157
158 bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
159 bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
160
161 // Pad not on the solder mask layer cannot be soldered.
162 // therefore it can have a specific aperture attribute.
163 // Not yet in use.
164 // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
165
166 metadata.SetCmpReference( aPad->GetParentFootprint()->GetReference() );
167
168 if( plotOnCopperLayer )
169 {
171 metadata.SetCopper( true );
172
173 // Gives a default attribute, for instance for pads used as tracks in net ties:
174 // Connector pads and SMD pads are on external layers
175 // if on internal layers, they are certainly used as net tie
176 // and are similar to tracks: just conductor items
178
179 const bool useUTF8 = false;
180 const bool useQuoting = false;
181 metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
182
183 if( !aPad->GetNumber().IsEmpty() )
184 metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
185
186 metadata.SetNetName( aPad->GetNetname() );
187
188 // Some pads are mechanical pads ( through hole or smd )
189 // when this is the case, they have no pad name and/or are not plated.
190 // In this case gerber files have slightly different attributes.
191 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
192 metadata.m_NetlistMetadata.m_NotInNet = true;
193
194 if( !plotOnExternalCopperLayer )
195 {
196 // the .P object attribute (GBR_NETLIST_METADATA::GBR_NETINFO_PAD)
197 // is used on outer layers, unless the component is embedded
198 // or a "etched" component (fp only drawn, not a physical component)
199 // Currently, Pcbnew does not handle embedded component, so we disable the .P
200 // attribute on internal layers
201 // Note the Gerber doc is not really clear about through holes pads about the .P
204
205 }
206
207 // Some attributes are reserved to the external copper layers:
208 // GBR_APERTURE_ATTRIB_CONNECTORPAD and GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
209 // for instance.
210 // Pad with type PAD_ATTRIB::CONN or PAD_ATTRIB::SMD that is not on outer layer
211 // has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
212 switch( aPad->GetAttribute() )
213 {
214 case PAD_ATTRIB::NPTH: // Mechanical pad through hole
216 break;
217
218 case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
220 break;
221
222 case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
223 if( plotOnExternalCopperLayer )
225 break;
226
227 case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
228 // with solder paste and mask
229 if( plotOnExternalCopperLayer )
231 break;
232 }
233
234 // Fabrication properties can have specific GBR_APERTURE_METADATA options
235 // that replace previous aperture attribute:
236 switch( aPad->GetProperty() )
237 {
238 case PAD_PROP::BGA: // Only applicable to outer layers
239 if( plotOnExternalCopperLayer )
241 break;
242
245 break;
246
249 break;
250
251 case PAD_PROP::TESTPOINT: // Only applicable to outer layers
252 if( plotOnExternalCopperLayer )
254 break;
255
258 break;
259
262 break;
263
264 case PAD_PROP::PRESSFIT: // used only in drill files
265 case PAD_PROP::NONE:
267 break;
268 }
269
270 // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
271 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
273 }
274 else
275 {
277 }
278
279 // Set plot color (change WHITE to LIGHTGRAY because
280 // the white items are not seen on a white paper or screen
281 m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY );
282
283 if( aSketchMode )
284 {
285 switch( aPad->GetShape( aLayer ) )
286 {
288 m_plotter->ThickCircle( shape_pos, aPad->GetSize( aLayer ).x, GetSketchPadLineWidth(),
289 nullptr );
290 break;
291
292 case PAD_SHAPE::OVAL:
293 {
294 m_plotter->ThickOval( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(),
295 GetSketchPadLineWidth(), nullptr );
296 break;
297 }
298
304 {
305 SHAPE_POLY_SET outline;
306 aPad->TransformShapeToPolygon( outline, aLayer, 0, m_plotter->GetPlotterArcHighDef(),
307 ERROR_INSIDE, false );
308
309 m_plotter->ThickPoly( outline, GetSketchPadLineWidth(), nullptr );
310 break;
311 }
312
313 default:
315 }
316
317 return;
318 }
319
320 switch( aPad->GetShape( aLayer ) )
321 {
323 m_plotter->FlashPadCircle( shape_pos, aPad->GetSize( aLayer ).x, &metadata );
324 break;
325
326 case PAD_SHAPE::OVAL:
327 m_plotter->FlashPadOval( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(), &metadata );
328 break;
329
331 m_plotter->FlashPadRect( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(), &metadata );
332 break;
333
335 m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize( aLayer ),
336 aPad->GetRoundRectCornerRadius( aLayer ),
337 aPad->GetOrientation(), &metadata );
338 break;
339
341 {
342 // Build the pad polygon in coordinates relative to the pad
343 // (i.e. for a pad at pos 0,0, rot 0.0). Needed to use aperture macros,
344 // to be able to create a pattern common to all trapezoid pads having the same shape
345 VECTOR2I coord[4];
346
347 // Order is lower left, lower right, upper right, upper left.
348 VECTOR2I half_size = aPad->GetSize( aLayer ) / 2;
349 VECTOR2I trap_delta = aPad->GetDelta( aLayer ) / 2;
350
351 coord[0] = VECTOR2I( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
352 coord[1] = VECTOR2I( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
353 coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
354 coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
355
356 m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), &metadata );
357 break;
358 }
359
361 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
362 {
363 GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
364
365 gerberPlotter->FlashPadChamferRoundRect( shape_pos, aPad->GetSize( aLayer ),
366 aPad->GetRoundRectCornerRadius( aLayer ),
367 aPad->GetChamferRectRatio( aLayer ),
368 aPad->GetChamferPositions( aLayer ),
369 aPad->GetOrientation(), &metadata );
370 break;
371 }
372
374
375 default:
377 {
378 const std::shared_ptr<SHAPE_POLY_SET>& polygons = aPad->GetEffectivePolygon( aLayer, ERROR_INSIDE );
379
380 if( polygons->OutlineCount() )
381 {
382 m_plotter->FlashPadCustom( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(),
383 polygons.get(), &metadata );
384 }
385 }
386 break;
387 }
388}
389
390
392{
393 if( !GetPlotFPText() )
394 return;
395
396 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
397 const bool dnp = aFootprint->GetDNPForVariant( variantName );
398
399 const PCB_TEXT* reference = &aFootprint->Reference();
400 PCB_LAYER_ID refLayer = reference->GetLayer();
401
402 // Reference and value have special controls for forcing their plotting
403 if( GetPlotReference()
404 && m_layerMask[refLayer]
405 && reference->IsVisible()
406 && !( dnp && hideDNPItems( refLayer ) ) )
407 {
408 PlotText( reference, refLayer, reference->IsKnockout(), reference->GetFontMetrics(),
409 dnp && crossoutDNPItems( refLayer ) );
410 }
411
412 const PCB_TEXT* value = &aFootprint->Value();
413 PCB_LAYER_ID valueLayer = value->GetLayer();
414
415 if( GetPlotValue()
416 && m_layerMask[valueLayer]
417 && value->IsVisible()
418 && !( dnp && hideDNPItems( valueLayer ) ) )
419 {
420 PlotText( value, valueLayer, value->IsKnockout(), value->GetFontMetrics(), false );
421 }
422
423 std::vector<PCB_TEXT*> texts;
424
425 // Skip the reference and value texts that are handled specially
426 for( PCB_FIELD* field : aFootprint->GetFields() )
427 {
428 wxCHECK2( field, continue );
429
430 if( field->IsReference() || field->IsValue() )
431 continue;
432
433 if( field->IsVisible() )
434 texts.push_back( field );
435 }
436
437 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
438 {
439 if( PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item ) )
440 texts.push_back( textItem );
441 }
442
443 for( const PCB_TEXT* text : texts )
444 {
445 PCB_LAYER_ID textLayer = text->GetLayer();
446 bool strikeout = false;
447
448 if( textLayer == Edge_Cuts || textLayer >= PCB_LAYER_ID_COUNT )
449 continue;
450
451 if( dnp && hideDNPItems( textLayer ) )
452 continue;
453
454 if( !m_layerMask[textLayer] || aFootprint->GetPrivateLayers().test( textLayer ) )
455 continue;
456
457 if( text->GetText() == wxT( "${REFERENCE}" ) )
458 {
459 if( !GetPlotReference() )
460 continue;
461
462 strikeout = dnp && crossoutDNPItems( textLayer );
463 }
464
465 if( text->GetText() == wxT( "${VALUE}" ) )
466 {
467 if( !GetPlotValue() )
468 continue;
469 }
470
471 PlotText( text, textLayer, text->IsKnockout(), text->GetFontMetrics(), strikeout );
472 }
473}
474
475
477{
478 switch( item->Type() )
479 {
480 case PCB_SHAPE_T:
481 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
482 break;
483
484 case PCB_TEXT_T:
485 {
486 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
487 PlotText( text, text->GetLayer(), text->IsKnockout(), text->GetFontMetrics() );
488 break;
489 }
490
491 case PCB_TEXTBOX_T:
492 {
493 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
494
495 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
496 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() );
497
498 if( textbox->IsBorderEnabled() )
499 PlotShape( textbox );
500
501 m_plotter->SetTextMode( GetTextMode() );
502 break;
503 }
504
505 case PCB_BARCODE_T:
506 PlotBarCode( static_cast<const PCB_BARCODE*>( item ) );
507 break;
508
509 case PCB_TABLE_T:
510 {
511 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
512
513 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
514
515 for( const PCB_TABLECELL* cell : table->GetCells() )
516 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
517
519
520 m_plotter->SetTextMode( GetTextMode() );
521 break;
522 }
523
525 case PCB_DIM_CENTER_T:
526 case PCB_DIM_RADIAL_T:
528 case PCB_DIM_LEADER_T:
529 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
530
531 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
532
533 m_plotter->SetTextMode( GetTextMode() );
534 break;
535
536 case PCB_TARGET_T:
537 PlotPcbTarget( static_cast<const PCB_TARGET*>( item ) );
538 break;
539
540 default:
541 break;
542 }
543}
544
545
547{
548 if( !m_layerMask[aDim->GetLayer()] )
549 return;
550
551 COLOR4D color = ColorSettings()->GetColor( aDim->GetLayer() );
552
553 // Set plot color (change WHITE to LIGHTGRAY because
554 // the white items are not seen on a white paper or screen
555 m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
556
557 PlotText( aDim, aDim->GetLayer(), false, aDim->GetFontMetrics() );
558
559 PCB_SHAPE temp_item;
560
562 temp_item.SetLayer( aDim->GetLayer() );
563
564 for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
565 {
566 switch( shape->Type() )
567 {
568 case SH_SEGMENT:
569 {
570 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
571
572 temp_item.SetShape( SHAPE_T::SEGMENT );
573 temp_item.SetStart( seg.A );
574 temp_item.SetEnd( seg.B );
575
576 PlotShape( &temp_item );
577 break;
578 }
579
580 case SH_CIRCLE:
581 {
582 VECTOR2I start( shape->Centre() );
583 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
584
585 temp_item.SetShape( SHAPE_T::CIRCLE );
586 temp_item.SetFilled( false );
587 temp_item.SetStart( start );
588 temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
589
590 PlotShape( &temp_item );
591 break;
592 }
593
594 default:
595 break;
596 }
597 }
598}
599
600
602{
603 int dx1, dx2, dy1, dy2, radius;
604
605 if( !m_layerMask[aMire->GetLayer()] )
606 return;
607
608 m_plotter->SetColor( getColor( aMire->GetLayer() ) );
609
610 PCB_SHAPE temp_item;
611
612 temp_item.SetShape( SHAPE_T::CIRCLE );
613 temp_item.SetFilled( false );
614 temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), LINE_STYLE::SOLID ) );
615 temp_item.SetLayer( aMire->GetLayer() );
616 temp_item.SetStart( aMire->GetPosition() );
617 radius = aMire->GetSize() / 3;
618
619 if( aMire->GetShape() ) // temp_item X
620 radius = aMire->GetSize() / 2;
621
622 // Draw the circle
623 temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
624
625 PlotShape( &temp_item );
626
627 temp_item.SetShape( SHAPE_T::SEGMENT );
628
629 radius = aMire->GetSize() / 2;
630 dx1 = radius;
631 dy1 = 0;
632 dx2 = 0;
633 dy2 = radius;
634
635 if( aMire->GetShape() ) // Shape X
636 {
637 dx1 = dy1 = radius;
638 dx2 = dx1;
639 dy2 = -dy1;
640 }
641
642 VECTOR2I mirePos( aMire->GetPosition() );
643
644 // Draw the X or + temp_item:
645 temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
646 temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
647 PlotShape( &temp_item );
648
649 temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
650 temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
651 PlotShape( &temp_item );
652}
653
654
656{
657 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
658 const bool dnp = aFootprint->GetDNPForVariant( variantName );
659
660 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
661 {
662 PCB_LAYER_ID itemLayer = item->GetLayer();
663
664 if( aFootprint->GetPrivateLayers().test( itemLayer ) )
665 continue;
666
667 if( dnp && hideDNPItems( itemLayer ) )
668 continue;
669
670 if( !( m_layerMask & item->GetLayerSet() ).any() )
671 continue;
672
673 switch( item->Type() )
674 {
675 case PCB_SHAPE_T:
676 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
677 break;
678
679 case PCB_TEXTBOX_T:
680 {
681 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
682
683 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
684
685 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(),
686 textbox->GetFontMetrics() );
687
688 if( textbox->IsBorderEnabled() )
689 PlotShape( textbox );
690
691 m_plotter->SetTextMode( GetTextMode() );
692 break;
693 }
694
695 case PCB_BARCODE_T:
696 PlotBarCode( static_cast<const PCB_BARCODE*>( item ) );
697 break;
698
699 case PCB_TABLE_T:
700 {
701 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
702
703 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
704
705 for( const PCB_TABLECELL* cell : table->GetCells() )
706 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
707
709
710 m_plotter->SetTextMode( GetTextMode() );
711 break;
712 }
713
715 case PCB_DIM_CENTER_T:
716 case PCB_DIM_RADIAL_T:
718 case PCB_DIM_LEADER_T:
719 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
720 break;
721
722 case PCB_TEXT_T:
723 // Plotted in PlotFootprintTextItems()
724 break;
725
727 // Not plotted at all
728 break;
729
730 default:
731 UNIMPLEMENTED_FOR( item->GetClass() );
732 }
733 }
734}
735
736
737#define getMetadata() ( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER ? (void*) &gbr_metadata \
738 : m_plotter->GetPlotterType() == PLOT_FORMAT::DXF ? (void*) this \
739 : (void*) nullptr )
740
741
742void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
743 const KIFONT::METRICS& aFontMetrics, bool aStrikeout )
744{
745 int maxError = m_board->GetDesignSettings().m_MaxError;
746 KIFONT::FONT* font = aText->GetDrawFont( m_plotter->RenderSettings() );
747 wxString shownText( aText->GetShownText( true ) );
748
749 if( shownText.IsEmpty() )
750 return;
751
752 if( !m_layerMask[aLayer] )
753 return;
754
755 GBR_METADATA gbr_metadata;
756
757 if( IsCopperLayer( aLayer ) )
759
760 COLOR4D color = getColor( aLayer );
761 m_plotter->SetColor( color );
762
763 const VECTOR2I& pos = aText->GetTextPos();
764
765 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
767 attrs.m_Angle = aText->GetDrawRotation();
768 attrs.m_Multiline = false;
769
770 m_plotter->SetCurrentLineWidth( attrs.m_StrokeWidth );
771
772 auto strikeoutText =
773 [&]( const PCB_TEXT* text )
774 {
775 SHAPE_POLY_SET textPoly;
776
777 text->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
778 textPoly.Rotate( -text->GetDrawRotation(), text->GetDrawPos() );
779
780 BOX2I rect = textPoly.BBox();
781 VECTOR2I start( rect.GetLeft() - attrs.m_StrokeWidth,
782 ( rect.GetTop() + rect.GetBottom() ) / 2 );
783 VECTOR2I end( rect.GetRight() + attrs.m_StrokeWidth,
784 ( rect.GetTop() + rect.GetBottom() ) / 2 );
785
786 RotatePoint( start, text->GetDrawPos(), text->GetDrawRotation() );
787 RotatePoint( end, text->GetDrawPos(), text->GetDrawRotation() );
788
789 m_plotter->ThickSegment( start, end, attrs.m_StrokeWidth, getMetadata() );
790 };
791
792 if( aIsKnockout )
793 {
794 SHAPE_POLY_SET finalPoly;
795
796 if( const PCB_TEXT* text = dynamic_cast<const PCB_TEXT*>( aText) )
797 text->TransformTextToPolySet( finalPoly, 0, maxError, ERROR_INSIDE );
798 else if( const PCB_TEXTBOX* textbox = dynamic_cast<const PCB_TEXTBOX*>( aText ) )
799 textbox->TransformTextToPolySet( finalPoly, 0, maxError, ERROR_INSIDE );
800
801 finalPoly.Fracture();
802
803 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
804 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, getMetadata() );
805 }
806 else
807 {
808 if( font->IsOutline() && !m_board->GetEmbeddedFiles()->GetAreFontsEmbedded() )
809 {
811
812 CALLBACK_GAL callback_gal( empty_opts,
813 // Stroke callback
814 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
815 {
816 m_plotter->ThickSegment( aPt1, aPt2, attrs.m_StrokeWidth, getMetadata() );
817 },
818 // Polygon callback
819 [&]( const SHAPE_LINE_CHAIN& aPoly )
820 {
821 m_plotter->PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, getMetadata() );
822 } );
823
824 callback_gal.DrawGlyphs( *aText->GetRenderCache( font, shownText ) );
825 }
826 else if( aText->IsMultilineAllowed() )
827 {
828 std::vector<VECTOR2I> positions;
829 wxArrayString strings_list;
830 wxStringSplit( shownText, strings_list, '\n' );
831 positions.reserve( strings_list.Count() );
832
833 aText->GetLinePositions( m_plotter->RenderSettings(), positions, (int) strings_list.Count() );
834
835 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
836 {
837 wxString& txt = strings_list.Item( ii );
838 m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics, getMetadata() );
839 }
840
841 if( aStrikeout && strings_list.Count() == 1 )
842 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
843 }
844 else
845 {
846 m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, getMetadata() );
847
848 if( aStrikeout )
849 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
850 }
851 }
852}
853
854
855void BRDITEMS_PLOTTER::PlotZone( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
856{
857 if( aPolysList.IsEmpty() )
858 return;
859
860 GBR_METADATA gbr_metadata;
861
862 if( aZone->IsOnCopperLayer() )
863 {
864 gbr_metadata.SetNetName( aZone->GetNetname() );
865 gbr_metadata.SetCopper( true );
866
867 // Zones with no net name can exist.
868 // they are not used to connect items, so the aperture attribute cannot
869 // be set as conductor
870 if( aZone->GetNetname().IsEmpty() )
871 {
873 }
874 else
875 {
878 }
879 }
880
881 m_plotter->SetColor( getColor( aLayer ) );
882
883 m_plotter->StartBlock( nullptr ); // Clean current object attributes
884
885 /*
886 * In non filled mode the outline is plotted, but not the filling items
887 */
888
889 for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
890 {
891 const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
892
893 // Plot the current filled area (as region for Gerber plotter to manage attributes)
894 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
895 {
896 static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline, &gbr_metadata );
897 }
898 else if( m_plotter->GetPlotterType() == PLOT_FORMAT::DXF )
899 {
900 if( GetDXFPlotMode() == FILLED )
901 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, getMetadata() );
902 }
903 else
904 {
905 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, getMetadata() );
906 }
907 }
908
909 m_plotter->EndBlock( nullptr ); // Clear object attributes
910}
911
912
914{
915 if( !( m_layerMask & aShape->GetLayerSet() ).any() )
916 return;
917
918 int thickness = aShape->GetWidth();
919 int margin = thickness; // unclamped thickness (can be negative)
920 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
921 bool onCopperLayer = ( LSET::AllCuMask() & m_layerMask ).any();
922 bool onSolderMaskLayer = ( LSET( { F_Mask, B_Mask } ) & m_layerMask ).any();
923 bool isSolidFill = aShape->IsSolidFill();
924 bool isHatchedFill = aShape->IsHatchedFill();
925
926 if( onSolderMaskLayer
927 && aShape->HasSolderMask()
928 && IsExternalCopperLayer( aShape->GetLayer() ) )
929 {
930 margin += 2 * aShape->GetSolderMaskExpansion();
931 thickness = std::max( margin, 0 );
932
933 if( isHatchedFill )
934 {
935 isSolidFill = true;
936 isHatchedFill = false;
937 }
938 }
939
940 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
941
942 const FOOTPRINT* parentFP = aShape->GetParentFootprint();
943 GBR_METADATA gbr_metadata;
944 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
945 const bool parentDnp = parentFP ? parentFP->GetDNPForVariant( variantName ) : false;
946
947 if( parentFP )
948 {
949 gbr_metadata.SetCmpReference( parentFP->GetReference() );
951 }
952
953 if( parentFP && parentDnp && GetSketchDNPFPsOnFabLayers() )
954 {
955 if( aShape->GetLayer() == F_Fab || aShape->GetLayer() == B_Fab )
956 {
957 thickness = GetSketchPadLineWidth();
958 isSolidFill = false;
959 isHatchedFill = false;
960 }
961 }
962
963 if( aShape->GetLayer() == Edge_Cuts )
964 {
966 }
967 else if( onCopperLayer )
968 {
969 if( parentFP )
970 {
972 gbr_metadata.SetCopper( true );
973 }
974 else if( aShape->GetNetCode() > 0 )
975 {
976 gbr_metadata.SetCopper( true );
979 gbr_metadata.SetNetName( aShape->GetNetname() );
980 }
981 else
982 {
983 // Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
984 // Graphic items having a net have the Conductor attribute, but are not (yet?)
985 // supported in Pcbnew
987 }
988 }
989
990 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
991 {
992 switch( aShape->GetShape() )
993 {
994 case SHAPE_T::SEGMENT:
995 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, getMetadata() );
996 break;
997
998 case SHAPE_T::CIRCLE:
999 if( isSolidFill )
1000 {
1001 int diameter = aShape->GetRadius() * 2 + thickness;
1002
1003 if( margin < 0 )
1004 {
1005 diameter += margin;
1006 diameter = std::max( diameter, 0 );
1007 }
1008
1009 m_plotter->FilledCircle( aShape->GetStart(), diameter, getMetadata() );
1010 }
1011 else
1012 {
1013 m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness,
1014 getMetadata() );
1015 }
1016
1017 break;
1018
1019 case SHAPE_T::ARC:
1020 {
1021 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
1022 // but it is a circle
1023 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
1024 {
1025 m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness,
1026 getMetadata() );
1027 }
1028 else
1029 {
1030 m_plotter->ThickArc( *aShape, getMetadata(), thickness );
1031 }
1032
1033 break;
1034 }
1035
1036 case SHAPE_T::BEZIER:
1037 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
1038 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
1039 break;
1040
1041 case SHAPE_T::POLY:
1042 if( aShape->IsPolyShapeValid() )
1043 {
1044 if( m_plotter->GetPlotterType() == PLOT_FORMAT::DXF && GetDXFPlotMode() == SKETCH )
1045 {
1046 m_plotter->ThickPoly( aShape->GetPolyShape(), thickness, getMetadata() );
1047 }
1048 else
1049 {
1050 m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
1051
1052 const SHAPE_POLY_SET& origPoly = aShape->GetPolyShape();
1053
1054 // Stroke the unfractured outline so degenerate near-zero-width
1055 // spikes (which Fracture() collapses but the editor still draws as
1056 // thick lines) are preserved in the plot output (issue #24143).
1057 if( thickness > 0 )
1058 {
1059 for( int jj = 0; jj < origPoly.OutlineCount(); ++jj )
1060 {
1061 m_plotter->PlotPoly( origPoly.COutline( jj ), FILL_T::NO_FILL,
1062 thickness, getMetadata() );
1063 }
1064 }
1065
1066 if( !isSolidFill )
1067 break;
1068
1069 // Fracture before plotting the fill to avoid invalid gerber regions
1070 // from self-intersecting or overlapping outlines.
1071 SHAPE_POLY_SET tmpPoly = origPoly.CloneDropTriangulation();
1072 tmpPoly.Fracture();
1073
1074 if( margin < 0 )
1075 tmpPoly.Inflate( margin / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS, aShape->GetMaxError() );
1076
1077 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
1078 {
1079 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
1080 poly.SetClosed( true );
1081
1082 // Width 0; the stroke was already plotted from the unfractured outline.
1083 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1084 {
1085 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1086 gbr_plotter->PlotPolyAsRegion( poly, FILL_T::FILLED_SHAPE, 0,
1087 &gbr_metadata );
1088 }
1089 else
1090 {
1091 m_plotter->PlotPoly( poly, FILL_T::FILLED_SHAPE, 0, getMetadata() );
1092 }
1093 }
1094 }
1095 }
1096
1097 break;
1098
1099 case SHAPE_T::RECTANGLE:
1100 {
1101 int radius = aShape->GetCornerRadius();
1102
1103 if( radius == 0 && m_plotter->GetPlotterType() == PLOT_FORMAT::DXF &&
1104 GetDXFPlotMode() == SKETCH )
1105 {
1106 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1107 m_plotter->ThickRect( pts[0], pts[2], thickness, getMetadata() );
1108 }
1109 else
1110 {
1111 BOX2I box( aShape->GetStart(), VECTOR2I( aShape->GetEnd().x - aShape->GetStart().x,
1112 aShape->GetEnd().y - aShape->GetStart().y ) );
1113 box.Normalize();
1114
1115 if( margin < 0 )
1116 {
1117 box.Inflate( margin );
1118 radius += margin;
1119 }
1120
1121 SHAPE_RECT rect( box );
1122 rect.SetRadius( radius );
1123
1124 SHAPE_LINE_CHAIN outline = rect.Outline();
1125 SHAPE_POLY_SET poly( outline );
1126
1127 FILL_T fill_mode = isSolidFill ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1128
1129 if( poly.OutlineCount() > 0 )
1130 {
1131 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1132 {
1133 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1134 gbr_plotter->PlotPolyAsRegion( poly.COutline( 0 ), fill_mode, thickness, &gbr_metadata );
1135 }
1136 else
1137 {
1138 // TODO: PlotPoly needs to handle arcs...
1139 m_plotter->PlotPoly( poly.COutline( 0 ), fill_mode, thickness, getMetadata() );
1140 }
1141 }
1142 }
1143
1144 break;
1145 }
1146
1147 case SHAPE_T::ELLIPSE:
1149 {
1150 const bool isClosed = ( aShape->GetShape() == SHAPE_T::ELLIPSE );
1151
1152 SHAPE_ELLIPSE e = isClosed ? SHAPE_ELLIPSE( aShape->GetEllipseCenter(), aShape->GetEllipseMajorRadius(),
1153 aShape->GetEllipseMinorRadius(), aShape->GetEllipseRotation() )
1155 aShape->GetEllipseMinorRadius(), aShape->GetEllipseRotation(),
1156 aShape->GetEllipseStartAngle(), aShape->GetEllipseEndAngle() );
1157
1159
1160 if( isClosed )
1161 chain.SetClosed( true );
1162
1163 FILL_T fill = ( isClosed && isSolidFill ) ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1164
1165 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER && isClosed )
1166 {
1167 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1168 gbr_plotter->PlotPolyAsRegion( chain, fill, thickness, &gbr_metadata );
1169 }
1170 else
1171 {
1172 m_plotter->PlotPoly( chain, fill, thickness, getMetadata() );
1173 }
1174
1175 break;
1176 }
1177
1178 default:
1180 }
1181 }
1182 else
1183 {
1184 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1185
1186 for( SHAPE* shape : shapes )
1187 {
1188 STROKE_PARAMS::Stroke( shape, lineStyle, aShape->GetWidth(),
1189 m_plotter->RenderSettings(),
1190 [&]( const VECTOR2I& a, const VECTOR2I& b )
1191 {
1192 m_plotter->ThickSegment( a, b, thickness, getMetadata() );
1193 } );
1194 }
1195
1196 for( SHAPE* shape : shapes )
1197 delete shape;
1198 }
1199
1200 if( isHatchedFill )
1201 {
1202 for( int ii = 0; ii < aShape->GetHatching().OutlineCount(); ++ii )
1203 {
1204 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1205 {
1206 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1207 gbr_plotter->PlotPolyAsRegion( aShape->GetHatching().Outline( ii ),
1208 FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
1209 }
1210 else
1211 {
1212 m_plotter->PlotPoly( aShape->GetHatching().Outline( ii ), FILL_T::FILLED_SHAPE,
1213 0, getMetadata() );
1214 }
1215 }
1216 }
1217}
1218
1219
1221{
1222 if( !m_layerMask[aBarCode->GetLayer()] )
1223 return;
1224
1225 // To avoid duplicate code, build a PCB_SHAPE to plot the polygon shape
1226 PCB_SHAPE dummy( aBarCode->GetParent(), SHAPE_T::POLY );
1227 dummy.SetLayer( aBarCode->GetLayer() );
1228 dummy.SetFillMode( FILL_T::FILLED_SHAPE );
1229 dummy.SetWidth( 0 );
1230
1231 SHAPE_POLY_SET shape;
1232 aBarCode->TransformShapeToPolySet( shape, aBarCode->GetLayer(), 0, 0, ERROR_INSIDE );
1233 dummy.SetPolyShape( shape );
1234
1235 PlotShape( &dummy );
1236}
1237
1238
1240{
1241 if( !m_layerMask[aTable->GetLayer()] )
1242 return;
1243
1244 GBR_METADATA gbr_metadata;
1245
1246 if( const FOOTPRINT* parentFP = aTable->GetParentFootprint() )
1247 {
1248 gbr_metadata.SetCmpReference( parentFP->GetReference() );
1250 }
1251
1252 aTable->DrawBorders(
1253 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
1254 {
1255 int lineWidth = stroke.GetWidth();
1256 LINE_STYLE lineStyle = stroke.GetLineStyle();
1257
1258 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
1259 {
1260 m_plotter->ThickSegment( ptA, ptB, lineWidth, getMetadata() );
1261 }
1262 else
1263 {
1264 SHAPE_SEGMENT seg( ptA, ptB );
1265
1266 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, m_plotter->RenderSettings(),
1267 [&]( const VECTOR2I& a, const VECTOR2I& b )
1268 {
1269 m_plotter->ThickSegment( a, b, lineWidth, getMetadata() );
1270 } );
1271 }
1272 } );
1273}
1274
1275
1277 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
1278 const EDA_ANGLE& aOrientation, int aSmallDrill )
1279{
1280 VECTOR2I drillSize = aDrillSize;
1281
1282 // Small drill marks have no significance when applied to slots
1283 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
1284 drillSize.x = std::min( aSmallDrill, drillSize.x );
1285
1286 // Round holes only have x diameter, slots have both
1287 drillSize.x -= getFineWidthAdj();
1288 drillSize.x = std::clamp( drillSize.x, 1, aPadSize.x - 1 );
1289
1290 if( aDrillShape == PAD_DRILL_SHAPE::OBLONG )
1291 {
1292 drillSize.y -= getFineWidthAdj();
1293 drillSize.y = std::clamp( drillSize.y, 1, aPadSize.y - 1 );
1294
1295 m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, nullptr );
1296 }
1297 else
1298 {
1299 m_plotter->FlashPadCircle( aDrillPos, drillSize.x, nullptr );
1300 }
1301}
1302
1303
1305{
1306 int smallDrill = 0;
1307
1309 smallDrill = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize );
1310
1311 /* Drill marks are drawn white-on-black to knock-out the underlying pad. This works only
1312 * for drivers supporting color change, obviously... it means that:
1313 - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
1314 - In gerbers you can't see them. This is arguably the right thing to do since having
1315 drill marks and high speed drill stations is a sure recipe for broken tools and angry
1316 manufacturers. If you *really* want them you could start a layer with negative
1317 polarity to knock-out the film.
1318 - In DXF they go into the 'WHITE' layer. This could be useful.
1319 */
1320 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1321 m_plotter->SetColor( WHITE );
1322
1323 for( PCB_TRACK* track : m_board->Tracks() )
1324 {
1325 if( track->Type() == PCB_VIA_T )
1326 {
1327 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
1328
1329 // Via are not always on all layers
1330 if( ( via->GetLayerSet() & m_layerMask ).none() )
1331 continue;
1332
1334 VECTOR2I( via->GetDrillValue(), 0 ),
1335 VECTOR2I( via->GetWidth( PADSTACK::ALL_LAYERS ), 0 ),
1336 ANGLE_0, smallDrill );
1337 }
1338 }
1339
1340 for( FOOTPRINT* footprint : m_board->Footprints() )
1341 {
1342 for( PAD* pad : footprint->Pads() )
1343 {
1344 if( pad->GetDrillSize().x == 0 )
1345 continue;
1346
1347 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1348 {
1349 // Drill mark is in black unless we can find something to knock it out of
1350 m_plotter->SetColor( BLACK );
1351
1352 for( PCB_LAYER_ID layer : m_layerMask )
1353 {
1354 if( !pad->IsOnLayer( layer ) )
1355 continue;
1356
1357 VECTOR2I padSize = pad->GetSize( layer );
1358
1359 if( padSize.x > pad->GetDrillSizeX() || padSize.y > pad->GetDrillSizeY() )
1360 {
1361 m_plotter->SetColor( WHITE );
1362 break;
1363 }
1364 }
1365 }
1366
1367 plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
1368 pad->GetSize( PADSTACK::ALL_LAYERS ), pad->GetOrientation(), smallDrill );
1369 }
1370 }
1371
1372 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1373 m_plotter->SetColor( BLACK );
1374}
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:125
constexpr int ARC_LOW_DEF
Definition base_units.h:140
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
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:84
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:268
virtual bool IsKnockout() const
Definition board_item.h:355
FOOTPRINT * GetParentFootprint() const
virtual void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const
Convert the item shape to a polyset.
Definition board_item.h:461
const KIFONT::METRICS & GetFontMetrics() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:234
int GetMaxError() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:558
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:146
constexpr Vec Centre() const
Definition box2.h:97
constexpr coord_type GetLeft() const
Definition box2.h:228
constexpr coord_type GetRight() const
Definition box2.h:217
constexpr const SizeVec & GetSize() const
Definition box2.h:206
constexpr coord_type GetTop() const
Definition box2.h:229
constexpr coord_type GetBottom() const
Definition box2.h:222
void PlotDrillMarks()
Draw a drill mark for pads and vias.
void PlotZone(const ZONE *aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
void PlotPadNumber(const PAD *aPad, const COLOR4D &aColor)
void PlotBoardGraphicItem(const BOARD_ITEM *item)
Plot items like text and graphics but not tracks and footprints.
void PlotPad(const PAD *aPad, PCB_LAYER_ID aLayer, const COLOR4D &aColor, bool aSketchMode)
Plot a pad.
void PlotDimension(const PCB_DIMENSION_BASE *aDim)
void PlotText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS &aFontMetrics, bool aStrikeout=false)
BOARD * m_board
Definition pcbplot.h:155
void PlotShape(const PCB_SHAPE *aShape)
PLOTTER * m_plotter
Definition pcbplot.h:154
bool crossoutDNPItems(PCB_LAYER_ID aLayer)
Definition pcbplot.h:140
void PlotBarCode(const PCB_BARCODE *aBarCode)
COLOR4D getColor(int aLayer) const
White color is special because it cannot be seen on a white paper in B&W mode.
void PlotPcbTarget(const PCB_TARGET *aMire)
void PlotTableBorders(const PCB_TABLE *aTable)
void PlotFootprintTextItems(const FOOTPRINT *aFootprint)
int getFineWidthAdj() const
Definition pcbplot.h:78
void plotOneDrillMark(PAD_DRILL_SHAPE aDrillShape, const VECTOR2I &aDrillPos, const VECTOR2I &aDrillSize, const VECTOR2I &aPadSize, const EDA_ANGLE &aOrientation, int aSmallDrill)
Helper function to plot a single drill mark.
bool hideDNPItems(PCB_LAYER_ID aLayer)
Definition pcbplot.h:135
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
static const COLOR4D WHITE
Definition color4d.h:405
COLOR4D GetColor(int aLayer) const
double AsDegrees() const
Definition eda_angle.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
EDA_ANGLE GetArcAngle() const
int GetEllipseMinorRadius() const
Definition eda_shape.h:306
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:279
const VECTOR2I & GetEllipseCenter() const
Definition eda_shape.h:288
const SHAPE_POLY_SET & GetHatching() const
EDA_ANGLE GetEllipseEndAngle() const
Definition eda_shape.h:334
int GetEllipseMajorRadius() const
Definition eda_shape.h:297
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:457
SHAPE_POLY_SET & GetPolyShape()
EDA_ANGLE GetEllipseRotation() const
Definition eda_shape.h:315
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:189
bool IsHatchedFill() const
Definition eda_shape.h:144
virtual void SetFilled(bool aFlag)
Definition eda_shape.h:156
bool IsSolidFill() const
Definition eda_shape.h:137
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:236
void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:198
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:194
void SetShape(SHAPE_T aShape)
Definition eda_shape.h:188
std::vector< VECTOR2I > GetRectCorners() const
EDA_ANGLE GetEllipseStartAngle() const
Definition eda_shape.h:325
void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:240
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:276
int GetCornerRadius() const
bool IsPolyShapeValid() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:93
const VECTOR2I & GetTextPos() const
Definition eda_text.h:298
bool IsMultilineAllowed() const
Definition eda_text.h:222
virtual bool IsVisible() const
Definition eda_text.h:212
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
Definition eda_text.cpp:702
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:404
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition eda_text.cpp:666
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:256
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:465
void GetLinePositions(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition eda_text.cpp:941
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition eda_text.h:125
PCB_FIELD & Value()
read/write accessors:
Definition footprint.h:865
LSET GetPrivateLayers() const
Definition footprint.h:317
PCB_FIELD & Reference()
Definition footprint.h:866
bool GetDNPForVariant(const wxString &aVariantName) const
Get the DNP status for a specific variant.
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
const wxString & GetReference() const
Definition footprint.h:829
DRAWINGS & GraphicalItems()
Definition footprint.h:380
@ GBR_APERTURE_ATTRIB_CONDUCTOR
Aperture used for connected items like tracks (not vias).
@ GBR_APERTURE_ATTRIB_ETCHEDCMP
Aperture used for etched components.
@ GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
Aperture used for BGA pad with a solder mask defined by the solder mask.
@ GBR_APERTURE_ATTRIB_HEATSINKPAD
Aperture used for heat sink pad (typically for SMDs).
@ GBR_APERTURE_ATTRIB_TESTPOINT
Aperture used for test point pad (outer layers).
@ GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
Aperture used for SMD pad with a solder mask defined by the solder mask.
@ GBR_APERTURE_ATTRIB_CONNECTORPAD
Aperture used for edge connector pad (outer layers).
@ GBR_APERTURE_ATTRIB_NONCONDUCTOR
Aperture used for not connected items (texts, outlines on copper).
@ GBR_APERTURE_ATTRIB_WASHERPAD
Aperture used for mechanical pads (NPTH).
@ GBR_APERTURE_ATTRIB_COMPONENTPAD
Aperture used for through hole component on outer layer.
@ GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
Aperture used for fiducial pad (outer layers), at board level.
@ GBR_APERTURE_ATTRIB_CASTELLATEDPAD
Aperture used for castellated pads in copper layer files.
@ GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
Aperture used for fiducial pad (outer layers), at footprint level.
@ GBR_APERTURE_ATTRIB_EDGECUT
Aperture used for board cutout,.
Metadata which can be added in a gerber file as attribute in X2 format.
void SetCopper(bool aValue)
void SetCmpReference(const wxString &aComponentRef)
void SetNetName(const wxString &aNetname)
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
void SetNetAttribType(int aNetAttribType)
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
@ GBR_NETINFO_NET
print info associated to a net (TO.N attribute)
@ GBR_NETINFO_CMP
print info associated to a component (TO.C attribute)
bool m_NotInNet
true if a pad of a footprint cannot be connected (for instance a mechanical NPTH, ot a not named pad)...
void FlashPadChamferRoundRect(const VECTOR2I &aShapePos, const VECTOR2I &aPadSize, int aCornerRadius, double aChamferRatio, int aChamferPositions, const EDA_ANGLE &aPadOrient, void *aData)
Flash a chamfered round rect pad.
void PlotPolyAsRegion(const SHAPE_LINE_CHAIN &aPoly, FILL_T aFill, int aWidth, GBR_METADATA *aGbrMetadata)
Similar to PlotPoly(), plot a filled polygon using Gerber region, therefore adding X2 attributes to t...
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:98
virtual bool IsOutline() const
Definition font.h:106
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:608
static const LSET & ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition lset.cpp:634
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
Definition pad.h:55
PAD_PROP GetProperty() const
Definition pad.h:566
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2172
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
Definition pad.h:377
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:890
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1354
PAD_ATTRIB GetAttribute() const
Definition pad.h:563
const wxString & GetPinFunction() const
Definition pad.h:148
const wxString & GetNumber() const
Definition pad.h:137
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition pad.h:304
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:196
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:2609
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.h:420
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:845
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:948
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:828
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1558
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
Definition pad.h:264
Abstract dimension API.
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
bool GetSketchDNPFPsOnFabLayers() const
PLOT_TEXT_MODE GetTextMode() const override
bool GetPlotReference() const
DXF_OUTLINE_MODE GetDXFPlotMode() const override
int GetSketchPadLineWidth() const
DRILL_MARKS GetDrillMarksType() const
bool GetPlotValue() const
bool GetPlotFPText() const
COLOR_SETTINGS * ColorSettings() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_shape.h:81
int GetWidth() const override
bool HasSolderMask() const
Definition pcb_shape.h:213
int GetSolderMaskExpansion() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
STROKE_PARAMS GetStroke() const override
Definition pcb_shape.h:97
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition pcb_shape.h:98
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pcb_shape.h:71
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
int GetShape() const
Definition pcb_target.h:58
int GetWidth() const
Definition pcb_target.h:64
int GetSize() const
Definition pcb_target.h:61
VECTOR2I GetPosition() const override
Definition pcb_target.h:55
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
Definition seg.h:42
VECTOR2I A
Definition seg.h:49
VECTOR2I B
Definition seg.h:50
int GetRadius() const
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
SHAPE_POLY_SET CloneDropTriangulation() const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
const SHAPE_LINE_CHAIN Outline() const
void SetRadius(int aRadius)
Definition shape_rect.h:206
const SEG & GetSeg() const
An abstract shape on 2D plane.
Definition shape.h:128
Simple container to manage line stroke parameters.
int GetWidth() const
LINE_STYLE GetLineStyle() const
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
Handle a list of polygons defining a copper zone.
Definition zone.h:74
bool IsOnCopperLayer() const override
Definition zone.cpp:578
A type-safe container of any type.
Definition ki_any.h:93
constexpr any() noexcept
Default constructor, creates an empty object.
Definition ki_any.h:156
@ WHITE
Definition color4d.h:48
@ LIGHTGRAY
Definition color4d.h:47
@ BLACK
Definition color4d.h:44
@ ROUND_ALL_CORNERS
All angles are rounded.
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
@ ELLIPSE
Definition eda_shape.h:56
@ SEGMENT
Definition eda_shape.h:50
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:51
@ ELLIPSE_ARC
Definition eda_shape.h:57
FILL_T
Definition eda_shape.h:63
@ NO_FILL
Definition eda_shape.h:64
@ FILLED_SHAPE
Fill with object color.
Definition eda_shape.h:65
Handle special data (items attributes) during plot.
#define GBR_NETINFO_ALL
static const bool FILLED
Definition gr_basic.cpp:30
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:679
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition layer_ids.h:690
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ Edge_Cuts
Definition layer_ids.h:112
@ B_Mask
Definition layer_ids.h:98
@ F_Mask
Definition layer_ids.h:97
@ F_Fab
Definition layer_ids.h:119
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:171
@ B_Fab
Definition layer_ids.h:118
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:96
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:69
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:103
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition padstack.h:99
@ PTH
Plated through hole pad.
Definition padstack.h:98
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
Definition padstack.h:100
@ CHAMFERED_RECT
Definition padstack.h:60
@ ROUNDRECT
Definition padstack.h:57
@ TRAPEZOID
Definition padstack.h:56
@ RECTANGLE
Definition padstack.h:54
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
Definition padstack.h:118
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
Definition padstack.h:117
@ MECHANICAL
a pad used for mechanical support
Definition padstack.h:122
@ PRESSFIT
a PTH with a hole diameter with tight tolerances for press fit pin
Definition padstack.h:123
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
Definition padstack.h:120
@ NONE
no special fabrication property
Definition padstack.h:115
@ TESTPOINT
a test point pad
Definition padstack.h:119
@ CASTELLATED
a pad with a castellated through hole
Definition padstack.h:121
@ BGA
Smd pad, used in BGA footprints.
Definition padstack.h:116
BARCODE class definition.
#define getMetadata()
@ SKETCH
Definition plotter.h:82
@ SH_CIRCLE
circle
Definition shape.h:50
@ SH_SEGMENT
line segment
Definition shape.h:48
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
LINE_STYLE
Dashed line types.
std::vector< std::vector< std::string > > table
const SHAPE_LINE_CHAIN chain
int radius
VECTOR2I end
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition trigo.cpp:229
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:85
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:103
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:100
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:101
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:90
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:89
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:86
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:98
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:104
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:99
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:91
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:102
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687