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
30#include <geometry/shape_line_chain.h> // for SHAPE_LINE_CHAIN
31#include <geometry/shape_poly_set.h> // for SHAPE_POLY_SET, SHAPE_P...
32#include <geometry/shape_rect.h>
34#include <string_utils.h>
35#include <macros.h>
36#include <math/util.h> // for KiROUND
37#include <math/vector2d.h> // for VECTOR2I
39#include <trigo.h>
40#include <font/stroke_font.h>
42#include <callback_gal.h>
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 <lset.h>
48#include <pcbplot.h>
49#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
50#include <advanced_config.h>
51
52#include <pcb_dimension.h>
53#include <pcb_shape.h>
54#include <footprint.h>
55#include <pcb_track.h>
56#include <pad.h>
57#include <pcb_target.h>
58#include <pcb_text.h>
59#include <pcb_textbox.h>
60#include <pcb_tablecell.h>
61#include <pcb_table.h>
62#include <zone.h>
63#include <pcb_barcode.h>
64
65#include <wx/debug.h> // for wxASSERT_MSG
66
67
69{
70 COLOR4D color = ColorSettings()->GetColor( aLayer );
71
72 // A hack to avoid plotting a white item in white color on white paper
73 if( color == COLOR4D::WHITE )
74 color = COLOR4D( LIGHTGRAY );
75
76 return color;
77}
78
79
80void BRDITEMS_PLOTTER::PlotPadNumber( const PAD* aPad, const COLOR4D& aColor )
81{
82 wxString padNumber = UnescapeString( aPad->GetNumber() );
83
84 if( padNumber.IsEmpty() )
85 return;
86
87 BOX2I padBBox = aPad->GetBoundingBox();
88 VECTOR2I position = padBBox.Centre();
89 VECTOR2I padsize = padBBox.GetSize();
90
91 // TODO(JE) padstacks
93 {
94 // See if we have a number box
95 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives( PADSTACK::ALL_LAYERS ) )
96 {
97 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
98 {
99 position = primitive->GetCenter();
100 RotatePoint( position, aPad->GetOrientation() );
101 position += aPad->ShapePos( PADSTACK::ALL_LAYERS );
102
103 padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
104 padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
105
106 break;
107 }
108 }
109 }
110
112 {
113 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
114 int limit = KiROUND( std::min( aPad->GetSize( PADSTACK::ALL_LAYERS ).x,
115 aPad->GetSize( PADSTACK::ALL_LAYERS ).y ) * 1.1 );
116
117 if( padsize.x > limit && padsize.y > limit )
118 {
119 padsize.x = limit;
120 padsize.y = limit;
121 }
122 }
123
124 TEXT_ATTRIBUTES textAttrs;
125
126 textAttrs.m_Mirrored = m_plotter->GetPlotMirrored();
127
128 if( padsize.x < ( padsize.y * 0.95 ) )
129 {
130 textAttrs.m_Angle = ANGLE_90;
131 std::swap( padsize.x, padsize.y );
132 }
133
134 // approximate the size of the pad number text:
135 // We use a size for at least 3 chars, to give a good look even for short numbers
136 int tsize = KiROUND( padsize.x / std::max( PrintableCharCount( padNumber ), 3 ) );
137 tsize = std::min( tsize, padsize.y );
138
139 // enforce a max size
140 tsize = std::min( tsize, pcbIUScale.mmToIU( 5.0 ) );
141
142 textAttrs.m_Size = VECTOR2I( tsize, tsize );
143
144 // use a somewhat spindly font to go with the outlined pads
145 textAttrs.m_StrokeWidth = KiROUND( tsize / 12.0 );
146
147 m_plotter->PlotText( position, aColor, padNumber, textAttrs );
148}
149
150
151void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, PCB_LAYER_ID aLayer, const COLOR4D& aColor,
152 bool aSketchMode )
153{
154 VECTOR2I shape_pos = aPad->ShapePos( aLayer );
155 GBR_METADATA metadata;
156
157 bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
158 bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
159
160 // Pad not on the solder mask layer cannot be soldered.
161 // therefore it can have a specific aperture attribute.
162 // Not yet in use.
163 // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
164
165 metadata.SetCmpReference( aPad->GetParentFootprint()->GetReference() );
166
167 if( plotOnCopperLayer )
168 {
170 metadata.SetCopper( true );
171
172 // Gives a default attribute, for instance for pads used as tracks in net ties:
173 // Connector pads and SMD pads are on external layers
174 // if on internal layers, they are certainly used as net tie
175 // and are similar to tracks: just conductor items
177
178 const bool useUTF8 = false;
179 const bool useQuoting = false;
180 metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
181
182 if( !aPad->GetNumber().IsEmpty() )
183 metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
184
185 metadata.SetNetName( aPad->GetNetname() );
186
187 // Some pads are mechanical pads ( through hole or smd )
188 // when this is the case, they have no pad name and/or are not plated.
189 // In this case gerber files have slightly different attributes.
190 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
191 metadata.m_NetlistMetadata.m_NotInNet = true;
192
193 if( !plotOnExternalCopperLayer )
194 {
195 // the .P object attribute (GBR_NETLIST_METADATA::GBR_NETINFO_PAD)
196 // is used on outer layers, unless the component is embedded
197 // or a "etched" component (fp only drawn, not a physical component)
198 // Currently, Pcbnew does not handle embedded component, so we disable the .P
199 // attribute on internal layers
200 // Note the Gerber doc is not really clear about through holes pads about the .P
203
204 }
205
206 // Some attributes are reserved to the external copper layers:
207 // GBR_APERTURE_ATTRIB_CONNECTORPAD and GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
208 // for instance.
209 // Pad with type PAD_ATTRIB::CONN or PAD_ATTRIB::SMD that is not on outer layer
210 // has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
211 switch( aPad->GetAttribute() )
212 {
213 case PAD_ATTRIB::NPTH: // Mechanical pad through hole
215 break;
216
217 case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
219 break;
220
221 case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
222 if( plotOnExternalCopperLayer )
224 break;
225
226 case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
227 // with solder paste and mask
228 if( plotOnExternalCopperLayer )
230 break;
231 }
232
233 // Fabrication properties can have specific GBR_APERTURE_METADATA options
234 // that replace previous aperture attribute:
235 switch( aPad->GetProperty() )
236 {
237 case PAD_PROP::BGA: // Only applicable to outer layers
238 if( plotOnExternalCopperLayer )
240 break;
241
244 break;
245
248 break;
249
250 case PAD_PROP::TESTPOINT: // Only applicable to outer layers
251 if( plotOnExternalCopperLayer )
253 break;
254
257 break;
258
261 break;
262
263 case PAD_PROP::PRESSFIT: // used only in drill files
264 case PAD_PROP::NONE:
266 break;
267 }
268
269 // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
270 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
272 }
273 else
274 {
276 }
277
278 // Set plot color (change WHITE to LIGHTGRAY because
279 // the white items are not seen on a white paper or screen
280 m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY );
281
282 if( aSketchMode )
283 {
284 switch( aPad->GetShape( aLayer ) )
285 {
287 m_plotter->ThickCircle( shape_pos, aPad->GetSize( aLayer ).x, GetSketchPadLineWidth(),
288 nullptr );
289 break;
290
291 case PAD_SHAPE::OVAL:
292 {
293 m_plotter->ThickOval( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(),
294 GetSketchPadLineWidth(), nullptr );
295 break;
296 }
297
299 {
300 const VECTOR2I& size = aPad->GetSize( aLayer );
301
302 m_plotter->ThickRect( VECTOR2I( shape_pos.x - ( size.x / 2 ), shape_pos.y - (size.y / 2 ) ),
303 VECTOR2I( shape_pos.x + ( size.x / 2 ), shape_pos.y + (size.y / 2 ) ),
304 GetSketchPadLineWidth(), nullptr );
305 break;
306 }
307
312 {
313 SHAPE_POLY_SET outline;
314 aPad->TransformShapeToPolygon( outline, aLayer, 0, m_plotter->GetPlotterArcHighDef(),
315 ERROR_INSIDE, true );
316
317 m_plotter->ThickPoly( outline, GetSketchPadLineWidth(), nullptr );
318 break;
319 }
320
321 default:
323 }
324
325 return;
326 }
327
328 switch( aPad->GetShape( aLayer ) )
329 {
331 m_plotter->FlashPadCircle( shape_pos, aPad->GetSize( aLayer ).x, &metadata );
332 break;
333
334 case PAD_SHAPE::OVAL:
335 m_plotter->FlashPadOval( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(), &metadata );
336 break;
337
339 m_plotter->FlashPadRect( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(), &metadata );
340 break;
341
343 m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize( aLayer ),
344 aPad->GetRoundRectCornerRadius( aLayer ),
345 aPad->GetOrientation(), &metadata );
346 break;
347
349 {
350 // Build the pad polygon in coordinates relative to the pad
351 // (i.e. for a pad at pos 0,0, rot 0.0). Needed to use aperture macros,
352 // to be able to create a pattern common to all trapezoid pads having the same shape
353 VECTOR2I coord[4];
354
355 // Order is lower left, lower right, upper right, upper left.
356 VECTOR2I half_size = aPad->GetSize( aLayer ) / 2;
357 VECTOR2I trap_delta = aPad->GetDelta( aLayer ) / 2;
358
359 coord[0] = VECTOR2I( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
360 coord[1] = VECTOR2I( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
361 coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
362 coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
363
364 m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), &metadata );
365 break;
366 }
367
369 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
370 {
371 GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
372
373 gerberPlotter->FlashPadChamferRoundRect( shape_pos, aPad->GetSize( aLayer ),
374 aPad->GetRoundRectCornerRadius( aLayer ),
375 aPad->GetChamferRectRatio( aLayer ),
376 aPad->GetChamferPositions( aLayer ),
377 aPad->GetOrientation(), &metadata );
378 break;
379 }
380
382
383 default:
385 {
386 const std::shared_ptr<SHAPE_POLY_SET>& polygons = aPad->GetEffectivePolygon( aLayer, ERROR_INSIDE );
387
388 if( polygons->OutlineCount() )
389 {
390 m_plotter->FlashPadCustom( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(),
391 polygons.get(), &metadata );
392 }
393 }
394 break;
395 }
396}
397
398
400{
401 if( !GetPlotFPText() )
402 return;
403
404 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
405 const bool dnp = aFootprint->GetDNPForVariant( variantName );
406
407 const PCB_TEXT* reference = &aFootprint->Reference();
408 PCB_LAYER_ID refLayer = reference->GetLayer();
409
410 // Reference and value have special controls for forcing their plotting
411 if( GetPlotReference()
412 && m_layerMask[refLayer]
413 && reference->IsVisible()
414 && !( dnp && hideDNPItems( refLayer ) ) )
415 {
416 PlotText( reference, refLayer, reference->IsKnockout(), reference->GetFontMetrics(),
417 dnp && crossoutDNPItems( refLayer ) );
418 }
419
420 const PCB_TEXT* value = &aFootprint->Value();
421 PCB_LAYER_ID valueLayer = value->GetLayer();
422
423 if( GetPlotValue()
424 && m_layerMask[valueLayer]
425 && value->IsVisible()
426 && !( dnp && hideDNPItems( valueLayer ) ) )
427 {
428 PlotText( value, valueLayer, value->IsKnockout(), value->GetFontMetrics(), false );
429 }
430
431 std::vector<PCB_TEXT*> texts;
432
433 // Skip the reference and value texts that are handled specially
434 for( PCB_FIELD* field : aFootprint->GetFields() )
435 {
436 if( field->IsReference() || field->IsValue() )
437 continue;
438
439 if( field->IsVisible() )
440 texts.push_back( field );
441 }
442
443 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
444 {
445 if( PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item ) )
446 texts.push_back( textItem );
447 }
448
449 for( const PCB_TEXT* text : texts )
450 {
451 PCB_LAYER_ID textLayer = text->GetLayer();
452 bool strikeout = false;
453
454 if( textLayer == Edge_Cuts || textLayer >= PCB_LAYER_ID_COUNT )
455 continue;
456
457 if( dnp && hideDNPItems( textLayer ) )
458 continue;
459
460 if( !m_layerMask[textLayer] || aFootprint->GetPrivateLayers().test( textLayer ) )
461 continue;
462
463 if( text->GetText() == wxT( "${REFERENCE}" ) )
464 {
465 if( !GetPlotReference() )
466 continue;
467
468 strikeout = dnp && crossoutDNPItems( textLayer );
469 }
470
471 if( text->GetText() == wxT( "${VALUE}" ) )
472 {
473 if( !GetPlotValue() )
474 continue;
475 }
476
477 PlotText( text, textLayer, text->IsKnockout(), text->GetFontMetrics(), strikeout );
478 }
479}
480
481
483{
484 switch( item->Type() )
485 {
486 case PCB_SHAPE_T:
487 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
488 break;
489
490 case PCB_TEXT_T:
491 {
492 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
493 PlotText( text, text->GetLayer(), text->IsKnockout(), text->GetFontMetrics() );
494 break;
495 }
496
497 case PCB_TEXTBOX_T:
498 {
499 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
500
501 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
502 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() );
503
504 if( textbox->IsBorderEnabled() )
505 PlotShape( textbox );
506
507 m_plotter->SetTextMode( GetTextMode() );
508 break;
509 }
510
511 case PCB_BARCODE_T:
512 PlotBarCode( static_cast<const PCB_BARCODE*>( item ) );
513 break;
514
515 case PCB_TABLE_T:
516 {
517 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
518
519 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
520
521 for( const PCB_TABLECELL* cell : table->GetCells() )
522 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
523
525
526 m_plotter->SetTextMode( GetTextMode() );
527 break;
528 }
529
531 case PCB_DIM_CENTER_T:
532 case PCB_DIM_RADIAL_T:
534 case PCB_DIM_LEADER_T:
535 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
536
537 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
538
539 m_plotter->SetTextMode( GetTextMode() );
540 break;
541
542 case PCB_TARGET_T:
543 PlotPcbTarget( static_cast<const PCB_TARGET*>( item ) );
544 break;
545
546 default:
547 break;
548 }
549}
550
551
553{
554 if( !m_layerMask[aDim->GetLayer()] )
555 return;
556
557 COLOR4D color = ColorSettings()->GetColor( aDim->GetLayer() );
558
559 // Set plot color (change WHITE to LIGHTGRAY because
560 // the white items are not seen on a white paper or screen
561 m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
562
563 PlotText( aDim, aDim->GetLayer(), false, aDim->GetFontMetrics() );
564
565 PCB_SHAPE temp_item;
566
568 temp_item.SetLayer( aDim->GetLayer() );
569
570 for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
571 {
572 switch( shape->Type() )
573 {
574 case SH_SEGMENT:
575 {
576 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
577
578 temp_item.SetShape( SHAPE_T::SEGMENT );
579 temp_item.SetStart( seg.A );
580 temp_item.SetEnd( seg.B );
581
582 PlotShape( &temp_item );
583 break;
584 }
585
586 case SH_CIRCLE:
587 {
588 VECTOR2I start( shape->Centre() );
589 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
590
591 temp_item.SetShape( SHAPE_T::CIRCLE );
592 temp_item.SetFilled( false );
593 temp_item.SetStart( start );
594 temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
595
596 PlotShape( &temp_item );
597 break;
598 }
599
600 default:
601 break;
602 }
603 }
604}
605
606
608{
609 int dx1, dx2, dy1, dy2, radius;
610
611 if( !m_layerMask[aMire->GetLayer()] )
612 return;
613
614 m_plotter->SetColor( getColor( aMire->GetLayer() ) );
615
616 PCB_SHAPE temp_item;
617
618 temp_item.SetShape( SHAPE_T::CIRCLE );
619 temp_item.SetFilled( false );
620 temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), LINE_STYLE::SOLID ) );
621 temp_item.SetLayer( aMire->GetLayer() );
622 temp_item.SetStart( aMire->GetPosition() );
623 radius = aMire->GetSize() / 3;
624
625 if( aMire->GetShape() ) // temp_item X
626 radius = aMire->GetSize() / 2;
627
628 // Draw the circle
629 temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
630
631 PlotShape( &temp_item );
632
633 temp_item.SetShape( SHAPE_T::SEGMENT );
634
635 radius = aMire->GetSize() / 2;
636 dx1 = radius;
637 dy1 = 0;
638 dx2 = 0;
639 dy2 = radius;
640
641 if( aMire->GetShape() ) // Shape X
642 {
643 dx1 = dy1 = radius;
644 dx2 = dx1;
645 dy2 = -dy1;
646 }
647
648 VECTOR2I mirePos( aMire->GetPosition() );
649
650 // Draw the X or + temp_item:
651 temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
652 temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
653 PlotShape( &temp_item );
654
655 temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
656 temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
657 PlotShape( &temp_item );
658}
659
660
662{
663 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
664 const bool dnp = aFootprint->GetDNPForVariant( variantName );
665
666 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
667 {
668 PCB_LAYER_ID itemLayer = item->GetLayer();
669
670 if( aFootprint->GetPrivateLayers().test( itemLayer ) )
671 continue;
672
673 if( dnp && hideDNPItems( itemLayer ) )
674 continue;
675
676 if( !( m_layerMask & item->GetLayerSet() ).any() )
677 continue;
678
679 switch( item->Type() )
680 {
681 case PCB_SHAPE_T:
682 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
683 break;
684
685 case PCB_TEXTBOX_T:
686 {
687 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
688
689 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
690
691 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(),
692 textbox->GetFontMetrics() );
693
694 if( textbox->IsBorderEnabled() )
695 PlotShape( textbox );
696
697 m_plotter->SetTextMode( GetTextMode() );
698 break;
699 }
700
701 case PCB_BARCODE_T:
702 PlotBarCode( static_cast<const PCB_BARCODE*>( item ) );
703 break;
704
705 case PCB_TABLE_T:
706 {
707 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
708
709 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
710
711 for( const PCB_TABLECELL* cell : table->GetCells() )
712 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
713
715
716 m_plotter->SetTextMode( GetTextMode() );
717 break;
718 }
719
721 case PCB_DIM_CENTER_T:
722 case PCB_DIM_RADIAL_T:
724 case PCB_DIM_LEADER_T:
725 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
726 break;
727
728 case PCB_TEXT_T:
729 // Plotted in PlotFootprintTextItems()
730 break;
731
733 // Not plotted at all
734 break;
735
736 default:
737 UNIMPLEMENTED_FOR( item->GetClass() );
738 }
739 }
740}
741
742
743#define getMetadata() ( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER ? (void*) &gbr_metadata \
744 : m_plotter->GetPlotterType() == PLOT_FORMAT::DXF ? (void*) this \
745 : (void*) nullptr )
746
747
748void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
749 const KIFONT::METRICS& aFontMetrics, bool aStrikeout )
750{
751 int maxError = m_board->GetDesignSettings().m_MaxError;
752 KIFONT::FONT* font = aText->GetDrawFont( m_plotter->RenderSettings() );
753 wxString shownText( aText->GetShownText( true ) );
754
755 if( shownText.IsEmpty() )
756 return;
757
758 if( !m_layerMask[aLayer] )
759 return;
760
761 GBR_METADATA gbr_metadata;
762
763 if( IsCopperLayer( aLayer ) )
765
766 COLOR4D color = getColor( aLayer );
767 m_plotter->SetColor( color );
768
769 const VECTOR2I& pos = aText->GetTextPos();
770
771 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
773 attrs.m_Angle = aText->GetDrawRotation();
774 attrs.m_Multiline = false;
775
776 m_plotter->SetCurrentLineWidth( attrs.m_StrokeWidth );
777
778 auto strikeoutText =
779 [&]( const PCB_TEXT* text )
780 {
781 SHAPE_POLY_SET textPoly;
782
783 text->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
784 textPoly.Rotate( -text->GetDrawRotation(), text->GetDrawPos() );
785
786 BOX2I rect = textPoly.BBox();
787 VECTOR2I start( rect.GetLeft() - attrs.m_StrokeWidth,
788 ( rect.GetTop() + rect.GetBottom() ) / 2 );
789 VECTOR2I end( rect.GetRight() + attrs.m_StrokeWidth,
790 ( rect.GetTop() + rect.GetBottom() ) / 2 );
791
792 RotatePoint( start, text->GetDrawPos(), text->GetDrawRotation() );
793 RotatePoint( end, text->GetDrawPos(), text->GetDrawRotation() );
794
795 m_plotter->ThickSegment( start, end, attrs.m_StrokeWidth, getMetadata() );
796 };
797
798 if( aIsKnockout )
799 {
800 SHAPE_POLY_SET finalPoly;
801
802 if( const PCB_TEXT* text = dynamic_cast<const PCB_TEXT*>( aText) )
803 text->TransformTextToPolySet( finalPoly, 0, maxError, ERROR_INSIDE );
804 else if( const PCB_TEXTBOX* textbox = dynamic_cast<const PCB_TEXTBOX*>( aText ) )
805 textbox->TransformTextToPolySet( finalPoly, 0, maxError, ERROR_INSIDE );
806
807 finalPoly.Fracture();
808
809 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
810 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, getMetadata() );
811 }
812 else
813 {
814 if( font->IsOutline() && !m_board->GetEmbeddedFiles()->GetAreFontsEmbedded() )
815 {
817
818 CALLBACK_GAL callback_gal( empty_opts,
819 // Stroke callback
820 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
821 {
822 m_plotter->ThickSegment( aPt1, aPt2, attrs.m_StrokeWidth, getMetadata() );
823 },
824 // Polygon callback
825 [&]( const SHAPE_LINE_CHAIN& aPoly )
826 {
827 m_plotter->PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, getMetadata() );
828 } );
829
830 callback_gal.DrawGlyphs( *aText->GetRenderCache( font, shownText ) );
831 }
832 else if( aText->IsMultilineAllowed() )
833 {
834 std::vector<VECTOR2I> positions;
835 wxArrayString strings_list;
836 wxStringSplit( shownText, strings_list, '\n' );
837 positions.reserve( strings_list.Count() );
838
839 aText->GetLinePositions( m_plotter->RenderSettings(), positions, (int) strings_list.Count() );
840
841 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
842 {
843 wxString& txt = strings_list.Item( ii );
844 m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics, getMetadata() );
845 }
846
847 if( aStrikeout && strings_list.Count() == 1 )
848 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
849 }
850 else
851 {
852 m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, getMetadata() );
853
854 if( aStrikeout )
855 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
856 }
857 }
858}
859
860
861void BRDITEMS_PLOTTER::PlotZone( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList )
862{
863 if( aPolysList.IsEmpty() )
864 return;
865
866 GBR_METADATA gbr_metadata;
867
868 if( aZone->IsOnCopperLayer() )
869 {
870 gbr_metadata.SetNetName( aZone->GetNetname() );
871 gbr_metadata.SetCopper( true );
872
873 // Zones with no net name can exist.
874 // they are not used to connect items, so the aperture attribute cannot
875 // be set as conductor
876 if( aZone->GetNetname().IsEmpty() )
877 {
879 }
880 else
881 {
884 }
885 }
886
887 m_plotter->SetColor( getColor( aLayer ) );
888
889 m_plotter->StartBlock( nullptr ); // Clean current object attributes
890
891 /*
892 * In non filled mode the outline is plotted, but not the filling items
893 */
894
895 for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
896 {
897 const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
898
899 // Plot the current filled area (as region for Gerber plotter to manage attributes)
900 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
901 {
902 static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline, &gbr_metadata );
903 }
904 else if( m_plotter->GetPlotterType() == PLOT_FORMAT::DXF )
905 {
906 if( GetDXFPlotMode() == FILLED )
907 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, getMetadata() );
908 }
909 else
910 {
911 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, getMetadata() );
912 }
913 }
914
915 m_plotter->EndBlock( nullptr ); // Clear object attributes
916}
917
918
920{
921 if( !( m_layerMask & aShape->GetLayerSet() ).any() )
922 return;
923
924 int thickness = aShape->GetWidth();
925 int margin = thickness; // unclamped thickness (can be negative)
926 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
927 bool onCopperLayer = ( LSET::AllCuMask() & m_layerMask ).any();
928 bool onSolderMaskLayer = ( LSET( { F_Mask, B_Mask } ) & m_layerMask ).any();
929 bool isSolidFill = aShape->IsSolidFill();
930 bool isHatchedFill = aShape->IsHatchedFill();
931
932 if( onSolderMaskLayer
933 && aShape->HasSolderMask()
934 && IsExternalCopperLayer( aShape->GetLayer() ) )
935 {
936 margin += 2 * aShape->GetSolderMaskExpansion();
937 thickness = std::max( margin, 0 );
938
939 if( isHatchedFill )
940 {
941 isSolidFill = true;
942 isHatchedFill = false;
943 }
944 }
945
946 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
947
948 const FOOTPRINT* parentFP = aShape->GetParentFootprint();
949 GBR_METADATA gbr_metadata;
950 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
951 const bool parentDnp = parentFP ? parentFP->GetDNPForVariant( variantName ) : false;
952
953 if( parentFP )
954 {
955 gbr_metadata.SetCmpReference( parentFP->GetReference() );
957 }
958
959 if( parentFP && parentDnp && GetSketchDNPFPsOnFabLayers() )
960 {
961 if( aShape->GetLayer() == F_Fab || aShape->GetLayer() == B_Fab )
962 {
963 thickness = GetSketchPadLineWidth();
964 isSolidFill = false;
965 isHatchedFill = false;
966 }
967 }
968
969 if( aShape->GetLayer() == Edge_Cuts )
970 {
972 }
973 else if( onCopperLayer )
974 {
975 if( parentFP )
976 {
978 gbr_metadata.SetCopper( true );
979 }
980 else if( aShape->GetNetCode() > 0 )
981 {
982 gbr_metadata.SetCopper( true );
985 gbr_metadata.SetNetName( aShape->GetNetname() );
986 }
987 else
988 {
989 // Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
990 // Graphic items having a net have the Conductor attribute, but are not (yet?)
991 // supported in Pcbnew
993 }
994 }
995
996 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
997 {
998 switch( aShape->GetShape() )
999 {
1000 case SHAPE_T::SEGMENT:
1001 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, getMetadata() );
1002 break;
1003
1004 case SHAPE_T::CIRCLE:
1005 if( isSolidFill )
1006 {
1007 int diameter = aShape->GetRadius() * 2 + thickness;
1008
1009 if( margin < 0 )
1010 {
1011 diameter += margin;
1012 diameter = std::max( diameter, 0 );
1013 }
1014
1015 m_plotter->FilledCircle( aShape->GetStart(), diameter, getMetadata() );
1016 }
1017 else
1018 {
1019 m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness,
1020 getMetadata() );
1021 }
1022
1023 break;
1024
1025 case SHAPE_T::ARC:
1026 {
1027 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
1028 // but it is a circle
1029 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
1030 {
1031 m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness,
1032 getMetadata() );
1033 }
1034 else
1035 {
1036 m_plotter->ThickArc( *aShape, getMetadata(), thickness );
1037 }
1038
1039 break;
1040 }
1041
1042 case SHAPE_T::BEZIER:
1043 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
1044 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
1045 break;
1046
1047 case SHAPE_T::POLY:
1048 if( aShape->IsPolyShapeValid() )
1049 {
1050 if( m_plotter->GetPlotterType() == PLOT_FORMAT::DXF && GetDXFPlotMode() == SKETCH )
1051 {
1052 m_plotter->ThickPoly( aShape->GetPolyShape(), thickness, getMetadata() );
1053 }
1054 else
1055 {
1056 m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
1057
1058 // Draw the polygon: only one polygon is expected
1059 // However we provide a multi polygon shape drawing
1060 // ( for the future or to show a non expected shape )
1061 // This must be simplified and fractured to prevent overlapping polygons
1062 // from generating invalid Gerber files
1064 tmpPoly.Fracture();
1065
1066 if( margin < 0 )
1067 tmpPoly.Inflate( margin / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS, aShape->GetMaxError() );
1068
1069 FILL_T fill = isSolidFill ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1070
1071 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
1072 {
1073 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
1074
1075 // Ensure the polygon is closed:
1076 poly.SetClosed( true );
1077
1078 // Plot the current filled area
1079 // (as region for Gerber plotter to manage attributes)
1080 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1081 {
1082 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1083 gbr_plotter->PlotPolyAsRegion( poly, fill, thickness, &gbr_metadata );
1084 }
1085 else
1086 {
1087 m_plotter->PlotPoly( poly, fill, thickness, getMetadata() );
1088 }
1089 }
1090 }
1091 }
1092
1093 break;
1094
1095 case SHAPE_T::RECTANGLE:
1096 {
1097 int radius = aShape->GetCornerRadius();
1098
1099 if( radius == 0 && m_plotter->GetPlotterType() == PLOT_FORMAT::DXF &&
1100 GetDXFPlotMode() == SKETCH )
1101 {
1102 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1103 m_plotter->ThickRect( pts[0], pts[2], thickness, getMetadata() );
1104 }
1105 else
1106 {
1107 BOX2I box( aShape->GetStart(), VECTOR2I( aShape->GetEnd().x - aShape->GetStart().x,
1108 aShape->GetEnd().y - aShape->GetStart().y ) );
1109 box.Normalize();
1110
1111 if( margin < 0 )
1112 {
1113 box.Inflate( margin );
1114 radius += margin;
1115 }
1116
1117 SHAPE_RECT rect( box );
1118 rect.SetRadius( radius );
1119
1120 SHAPE_LINE_CHAIN outline = rect.Outline();
1121 SHAPE_POLY_SET poly( outline );
1122
1123 FILL_T fill_mode = isSolidFill ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1124
1125 if( poly.OutlineCount() > 0 )
1126 {
1127 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1128 {
1129 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1130 gbr_plotter->PlotPolyAsRegion( poly.COutline( 0 ), fill_mode, thickness, &gbr_metadata );
1131 }
1132 else
1133 {
1134 // TODO: PlotPoly needs to handle arcs...
1135 m_plotter->PlotPoly( poly.COutline( 0 ), fill_mode, thickness, getMetadata() );
1136 }
1137 }
1138 }
1139
1140 break;
1141 }
1142
1143 default:
1145 }
1146 }
1147 else
1148 {
1149 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1150
1151 for( SHAPE* shape : shapes )
1152 {
1153 STROKE_PARAMS::Stroke( shape, lineStyle, aShape->GetWidth(),
1154 m_plotter->RenderSettings(),
1155 [&]( const VECTOR2I& a, const VECTOR2I& b )
1156 {
1157 m_plotter->ThickSegment( a, b, thickness, getMetadata() );
1158 } );
1159 }
1160
1161 for( SHAPE* shape : shapes )
1162 delete shape;
1163 }
1164
1165 if( isHatchedFill )
1166 {
1167 for( int ii = 0; ii < aShape->GetHatching().OutlineCount(); ++ii )
1168 {
1169 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1170 {
1171 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1172 gbr_plotter->PlotPolyAsRegion( aShape->GetHatching().Outline( ii ),
1173 FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
1174 }
1175 else
1176 {
1177 m_plotter->PlotPoly( aShape->GetHatching().Outline( ii ), FILL_T::FILLED_SHAPE,
1178 0, getMetadata() );
1179 }
1180 }
1181 }
1182}
1183
1184
1186{
1187 if( !m_layerMask[aBarCode->GetLayer()] )
1188 return;
1189
1190 // To avoid duplicate code, build a PCB_SHAPE to plot the polygon shape
1191 PCB_SHAPE dummy( aBarCode->GetParent(), SHAPE_T::POLY );
1192 dummy.SetLayer( aBarCode->GetLayer() );
1193 dummy.SetFillMode( FILL_T::FILLED_SHAPE );
1194 dummy.SetWidth( 0 );
1195
1196 SHAPE_POLY_SET shape;
1197 aBarCode->TransformShapeToPolySet( shape, aBarCode->GetLayer(), 0, 0, ERROR_INSIDE );
1198 dummy.SetPolyShape( shape );
1199
1200 PlotShape( &dummy );
1201}
1202
1203
1205{
1206 if( !m_layerMask[aTable->GetLayer()] )
1207 return;
1208
1209 GBR_METADATA gbr_metadata;
1210
1211 if( const FOOTPRINT* parentFP = aTable->GetParentFootprint() )
1212 {
1213 gbr_metadata.SetCmpReference( parentFP->GetReference() );
1215 }
1216
1217 aTable->DrawBorders(
1218 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
1219 {
1220 int lineWidth = stroke.GetWidth();
1221 LINE_STYLE lineStyle = stroke.GetLineStyle();
1222
1223 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
1224 {
1225 m_plotter->ThickSegment( ptA, ptB, lineWidth, getMetadata() );
1226 }
1227 else
1228 {
1229 SHAPE_SEGMENT seg( ptA, ptB );
1230
1231 STROKE_PARAMS::Stroke( &seg, lineStyle, lineWidth, m_plotter->RenderSettings(),
1232 [&]( const VECTOR2I& a, const VECTOR2I& b )
1233 {
1234 m_plotter->ThickSegment( a, b, lineWidth, getMetadata() );
1235 } );
1236 }
1237 } );
1238}
1239
1240
1242 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
1243 const EDA_ANGLE& aOrientation, int aSmallDrill )
1244{
1245 VECTOR2I drillSize = aDrillSize;
1246
1247 // Small drill marks have no significance when applied to slots
1248 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
1249 drillSize.x = std::min( aSmallDrill, drillSize.x );
1250
1251 // Round holes only have x diameter, slots have both
1252 drillSize.x -= getFineWidthAdj();
1253 drillSize.x = std::clamp( drillSize.x, 1, aPadSize.x - 1 );
1254
1255 if( aDrillShape == PAD_DRILL_SHAPE::OBLONG )
1256 {
1257 drillSize.y -= getFineWidthAdj();
1258 drillSize.y = std::clamp( drillSize.y, 1, aPadSize.y - 1 );
1259
1260 m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, nullptr );
1261 }
1262 else
1263 {
1264 m_plotter->FlashPadCircle( aDrillPos, drillSize.x, nullptr );
1265 }
1266}
1267
1268
1270{
1271 int smallDrill = 0;
1272
1274 smallDrill = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_SmallDrillMarkSize );
1275
1276 /* Drill marks are drawn white-on-black to knock-out the underlying pad. This works only
1277 * for drivers supporting color change, obviously... it means that:
1278 - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
1279 - In gerbers you can't see them. This is arguably the right thing to do since having
1280 drill marks and high speed drill stations is a sure recipe for broken tools and angry
1281 manufacturers. If you *really* want them you could start a layer with negative
1282 polarity to knock-out the film.
1283 - In DXF they go into the 'WHITE' layer. This could be useful.
1284 */
1285 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1286 m_plotter->SetColor( WHITE );
1287
1288 for( PCB_TRACK* track : m_board->Tracks() )
1289 {
1290 if( track->Type() == PCB_VIA_T )
1291 {
1292 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
1293
1294 // Via are not always on all layers
1295 if( ( via->GetLayerSet() & m_layerMask ).none() )
1296 continue;
1297
1299 VECTOR2I( via->GetDrillValue(), 0 ),
1300 VECTOR2I( via->GetWidth( PADSTACK::ALL_LAYERS ), 0 ),
1301 ANGLE_0, smallDrill );
1302 }
1303 }
1304
1305 for( FOOTPRINT* footprint : m_board->Footprints() )
1306 {
1307 for( PAD* pad : footprint->Pads() )
1308 {
1309 if( pad->GetDrillSize().x == 0 )
1310 continue;
1311
1312 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1313 {
1314 // Drill mark is in black unless we can find something to knock it out of
1315 m_plotter->SetColor( BLACK );
1316
1317 for( PCB_LAYER_ID layer : m_layerMask )
1318 {
1319 if( !pad->IsOnLayer( layer ) )
1320 continue;
1321
1322 VECTOR2I padSize = pad->GetSize( layer );
1323
1324 if( padSize.x > pad->GetDrillSizeX() || padSize.y > pad->GetDrillSizeY() )
1325 {
1326 m_plotter->SetColor( WHITE );
1327 break;
1328 }
1329 }
1330 }
1331
1332 plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
1333 pad->GetSize( PADSTACK::ALL_LAYERS ), pad->GetOrientation(), smallDrill );
1334 }
1335 }
1336
1337 if( m_plotter->GetPlotterType() != PLOT_FORMAT::DXF || GetDXFPlotMode() == FILLED )
1338 m_plotter->SetColor( BLACK );
1339}
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
constexpr int ARC_LOW_DEF
Definition base_units.h:128
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:83
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:236
virtual bool IsKnockout() const
Definition board_item.h:323
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:429
const KIFONT::METRICS & GetFontMetrics() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:214
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:110
EDA_ANGLE GetArcAngle() const
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:259
const SHAPE_POLY_SET & GetHatching() const
Definition eda_shape.h:148
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:379
SHAPE_POLY_SET & GetPolyShape()
Definition eda_shape.h:337
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:169
bool IsHatchedFill() const
Definition eda_shape.h:124
virtual void SetFilled(bool aFlag)
Definition eda_shape.h:136
bool IsSolidFill() const
Definition eda_shape.h:117
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:216
void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:178
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:174
void SetShape(SHAPE_T aShape)
Definition eda_shape.h:168
std::vector< VECTOR2I > GetRectCorners() const
void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:220
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:256
int GetCornerRadius() const
bool IsPolyShapeValid() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
const VECTOR2I & GetTextPos() const
Definition eda_text.h:273
bool IsMultilineAllowed() const
Definition eda_text.h:197
virtual bool IsVisible() const
Definition eda_text.h:187
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:692
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:377
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition eda_text.cpp:656
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:231
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:474
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:916
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition eda_text.h:109
PCB_FIELD & Value()
read/write accessors:
Definition footprint.h:777
LSET GetPrivateLayers() const
Definition footprint.h:244
PCB_FIELD & Reference()
Definition footprint.h:778
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:741
DRAWINGS & GraphicalItems()
Definition footprint.h:307
@ 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:131
virtual bool IsOutline() const
Definition font.h:139
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 & ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition lset.cpp:617
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:591
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:2049
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:859
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1300
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:2475
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:834
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:917
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:817
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1505
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:207
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:91
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition pcb_shape.h:92
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
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 Fracture()
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
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.
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:126
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:511
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
@ SEGMENT
Definition eda_shape.h:45
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:46
FILL_T
Definition eda_shape.h:56
@ NO_FILL
Definition eda_shape.h:57
@ FILLED_SHAPE
Fill with object color.
Definition eda_shape.h:58
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:677
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition layer_ids.h:688
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:81
@ 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.
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:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:106
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:103
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:97
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:104
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:93
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:92
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:89
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:101
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:107
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:102
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:94
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:105
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695