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