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 (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <algorithm> // for min
25#include <bitset> // for bitset, operator&, __bi...
26#include <math.h> // for abs
27
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, Clamp
36#include <math/vector2d.h> // for VECTOR2I
38#include <trigo.h>
39
40#include <core/typeinfo.h> // for dyn_cast, PCB_DIMENSION_T
41#include <gbr_metadata.h>
42#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
43#include <layer_ids.h> // for LSET, IsCopperLayer
44#include <lset.h>
45#include <pcbplot.h>
46#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
47#include <advanced_config.h>
48
49#include <pcb_dimension.h>
50#include <pcb_shape.h>
51#include <footprint.h>
52#include <pcb_track.h>
53#include <pad.h>
54#include <pcb_target.h>
55#include <pcb_text.h>
56#include <pcb_textbox.h>
57#include <pcb_tablecell.h>
58#include <pcb_table.h>
59#include <zone.h>
60
61#include <wx/debug.h> // for wxASSERT_MSG
62
63
65{
66 COLOR4D color = ColorSettings()->GetColor( aLayer );
67
68 // A hack to avoid plotting a white item in white color on white paper
69 if( color == COLOR4D::WHITE )
71
72 return color;
73}
74
75
76void BRDITEMS_PLOTTER::PlotPadNumber( const PAD* aPad, const COLOR4D& aColor )
77{
78 wxString padNumber = UnescapeString( aPad->GetNumber() );
79
80 if( padNumber.IsEmpty() )
81 return;
82
83 BOX2I padBBox = aPad->GetBoundingBox();
84 VECTOR2I position = padBBox.Centre();
85 VECTOR2I padsize = padBBox.GetSize();
86
87 if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
88 {
89 // See if we have a number box
90 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
91 {
92 if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
93 {
94 position = primitive->GetCenter();
95 RotatePoint( position, aPad->GetOrientation() );
96 position += aPad->ShapePos();
97
98 padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
99 padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
100
101 break;
102 }
103 }
104 }
105
106 if( aPad->GetShape() != PAD_SHAPE::CUSTOM )
107 {
108 // Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
109 int limit = KiROUND( std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1 );
110
111 if( padsize.x > limit && padsize.y > limit )
112 {
113 padsize.x = limit;
114 padsize.y = limit;
115 }
116 }
117
118 TEXT_ATTRIBUTES textAttrs;
119
120 if( padsize.x < ( padsize.y * 0.95 ) )
121 {
122 textAttrs.m_Angle = ANGLE_90;
123 std::swap( padsize.x, padsize.y );
124 }
125
126 // approximate the size of the pad number text:
127 // We use a size for at least 3 chars, to give a good look even for short numbers
128 int tsize = KiROUND( padsize.x / std::max( PrintableCharCount( padNumber ), 3 ) );
129 tsize = std::min( tsize, padsize.y );
130
131 // enforce a max size
132 tsize = std::min( tsize, pcbIUScale.mmToIU( 5.0 ) );
133
134 textAttrs.m_Size = VECTOR2I( tsize, tsize );
135
136 // use a somewhat spindly font to go with the outlined pads
137 textAttrs.m_StrokeWidth = KiROUND( tsize / 12.0 );
138
139 m_plotter->PlotText( position, aColor, padNumber, textAttrs );
140}
141
142
143void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode )
144{
145 VECTOR2I shape_pos = aPad->ShapePos();
146 GBR_METADATA metadata;
147
148 bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
149 bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
150
151 // Pad not on the solder mask layer cannot be soldered.
152 // therefore it can have a specific aperture attribute.
153 // Not yet in use.
154 // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
155
156 metadata.SetCmpReference( aPad->GetParentFootprint()->GetReference() );
157
158 if( plotOnCopperLayer )
159 {
161 metadata.SetCopper( true );
162
163 // Gives a default attribute, for instance for pads used as tracks in net ties:
164 // Connector pads and SMD pads are on external layers
165 // if on internal layers, they are certainly used as net tie
166 // and are similar to tracks: just conductor items
168
169 const bool useUTF8 = false;
170 const bool useQuoting = false;
171 metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
172
173 if( !aPad->GetNumber().IsEmpty() )
174 metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
175
176 metadata.SetNetName( aPad->GetNetname() );
177
178 // Some pads are mechanical pads ( through hole or smd )
179 // when this is the case, they have no pad name and/or are not plated.
180 // In this case gerber files have slightly different attributes.
181 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
182 metadata.m_NetlistMetadata.m_NotInNet = true;
183
184 if( !plotOnExternalCopperLayer )
185 {
186 // the .P object attribute (GBR_NETLIST_METADATA::GBR_NETINFO_PAD)
187 // is used on outer layers, unless the component is embedded
188 // or a "etched" component (fp only drawn, not a physical component)
189 // Currently, Pcbnew does not handle embedded component, so we disable the .P
190 // attribute on internal layers
191 // Note the Gerber doc is not really clear about through holes pads about the .P
194
195 }
196
197 // Some attributes are reserved to the external copper layers:
198 // GBR_APERTURE_ATTRIB_CONNECTORPAD and GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
199 // for instance.
200 // Pad with type PAD_ATTRIB::CONN or PAD_ATTRIB::SMD that is not on outer layer
201 // has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
202 switch( aPad->GetAttribute() )
203 {
204 case PAD_ATTRIB::NPTH: // Mechanical pad through hole
206 break;
207
208 case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
210 break;
211
212 case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
213 if( plotOnExternalCopperLayer )
215 break;
216
217 case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
218 // with solder paste and mask
219 if( plotOnExternalCopperLayer )
221 break;
222 }
223
224 // Fabrication properties can have specific GBR_APERTURE_METADATA options
225 // that replace previous aperture attribute:
226 switch( aPad->GetProperty() )
227 {
228 case PAD_PROP::BGA: // Only applicable to outer layers
229 if( plotOnExternalCopperLayer )
231 break;
232
233 case PAD_PROP::FIDUCIAL_GLBL:
235 break;
236
237 case PAD_PROP::FIDUCIAL_LOCAL:
239 break;
240
241 case PAD_PROP::TESTPOINT: // Only applicable to outer layers
242 if( plotOnExternalCopperLayer )
244 break;
245
246 case PAD_PROP::HEATSINK:
248 break;
249
250 case PAD_PROP::CASTELLATED:
252 break;
253
254 case PAD_PROP::NONE:
255 case PAD_PROP::MECHANICAL:
256 break;
257 }
258
259 // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
260 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
262 }
263 else
264 {
266 }
267
268 // Set plot color (change WHITE to LIGHTGRAY because
269 // the white items are not seen on a white paper or screen
270 m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
271
272 if( aPlotMode == SKETCH )
274
275 switch( aPad->GetShape() )
276 {
277 case PAD_SHAPE::CIRCLE:
278 m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &metadata );
279 break;
280
281 case PAD_SHAPE::OVAL:
282 m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
283 &metadata );
284 break;
285
286 case PAD_SHAPE::RECTANGLE:
287 m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
288 &metadata );
289 break;
290
291 case PAD_SHAPE::ROUNDRECT:
292 m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
293 aPad->GetOrientation(), aPlotMode, &metadata );
294 break;
295
296 case PAD_SHAPE::TRAPEZOID:
297 {
298 // Build the pad polygon in coordinates relative to the pad
299 // (i.e. for a pad at pos 0,0, rot 0.0). Needed to use aperture macros,
300 // to be able to create a pattern common to all trapezoid pads having the same shape
301 VECTOR2I coord[4];
302
303 // Order is lower left, lower right, upper right, upper left.
304 VECTOR2I half_size = aPad->GetSize() / 2;
305 VECTOR2I trap_delta = aPad->GetDelta() / 2;
306
307 coord[0] = VECTOR2I( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
308 coord[1] = VECTOR2I( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
309 coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
310 coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
311
312 m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode, &metadata );
313 }
314 break;
315
316 case PAD_SHAPE::CHAMFERED_RECT:
317 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
318 {
319 GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
320
321 gerberPlotter->FlashPadChamferRoundRect( shape_pos, aPad->GetSize(),
323 aPad->GetChamferRectRatio(),
324 aPad->GetChamferPositions(),
325 aPad->GetOrientation(), aPlotMode, &metadata );
326 break;
327 }
328
330
331 default:
332 case PAD_SHAPE::CUSTOM:
333 {
334 const std::shared_ptr<SHAPE_POLY_SET>& polygons = aPad->GetEffectivePolygon( ERROR_INSIDE );
335
336 if( polygons->OutlineCount() )
337 {
338 m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(),
339 polygons.get(), aPlotMode, &metadata );
340 }
341 }
342 break;
343 }
344}
345
346
348{
349 if( !GetPlotFPText() )
350 return;
351
352 const PCB_TEXT* textItem = &aFootprint->Reference();
353 PCB_LAYER_ID textLayer = textItem->GetLayer();
354
355 // Reference and value have special controls for forcing their plotting
356 if( GetPlotReference() && m_layerMask[textLayer]
357 && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
358 {
359 PlotText( textItem, textLayer, textItem->IsKnockout(), textItem->GetFontMetrics() );
360 }
361
362 textItem = &aFootprint->Value();
363 textLayer = textItem->GetLayer();
364
365 if( GetPlotValue() && m_layerMask[textLayer]
366 && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
367 {
368 PlotText( textItem, textLayer, textItem->IsKnockout(), textItem->GetFontMetrics() );
369 }
370
371 std::vector<PCB_TEXT*> texts;
372
373 // Skip the reference and value texts that are handled specially
374 for( PCB_FIELD* field : aFootprint->Fields() )
375 {
376 if( field->IsReference() || field->IsValue() )
377 continue;
378
379 texts.push_back( field );
380 }
381
382 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
383 {
384 textItem = dynamic_cast<const PCB_TEXT*>( item );
385
386 if( textItem )
387 texts.push_back( static_cast<PCB_TEXT*>( item ) );
388 }
389
390 for( const PCB_TEXT* text : texts )
391 {
392 if( !text->IsVisible() )
393 continue;
394
395 textLayer = text->GetLayer();
396
397 if( textLayer == Edge_Cuts || textLayer >= PCB_LAYER_ID_COUNT )
398 continue;
399
400 if( !m_layerMask[textLayer] || aFootprint->GetPrivateLayers().test( textLayer ) )
401 continue;
402
403 if( text->GetText() == wxT( "${REFERENCE}" ) && !GetPlotReference() )
404 continue;
405
406 if( text->GetText() == wxT( "${VALUE}" ) && !GetPlotValue() )
407 continue;
408
409 PlotText( text, textLayer, text->IsKnockout(), text->GetFontMetrics() );
410 }
411}
412
413
415{
416 switch( item->Type() )
417 {
418 case PCB_SHAPE_T:
419 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
420 break;
421
422 case PCB_TEXT_T:
423 {
424 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
425 PlotText( text, text->GetLayer(), text->IsKnockout(), text->GetFontMetrics() );
426 break;
427 }
428
429 case PCB_TEXTBOX_T:
430 {
431 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
432
433 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
434 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() );
435
436 if( textbox->IsBorderEnabled() )
437 PlotShape( textbox );
438
440 break;
441 }
442
443 case PCB_TABLE_T:
444 {
445 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
446
447 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
448
449 for( const PCB_TABLECELL* cell : table->GetCells() )
450 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
451
452 PlotTableBorders( table );
453
455 break;
456 }
457
459 case PCB_DIM_CENTER_T:
460 case PCB_DIM_RADIAL_T:
462 case PCB_DIM_LEADER_T:
463 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
464
465 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
466
468 break;
469
470 case PCB_TARGET_T:
471 PlotPcbTarget( static_cast<const PCB_TARGET*>( item ) );
472 break;
473
474 default:
475 break;
476 }
477}
478
479
481{
482 if( !m_layerMask[aDim->GetLayer()] )
483 return;
484
486
487 // Set plot color (change WHITE to LIGHTGRAY because
488 // the white items are not seen on a white paper or screen
490
491 PlotText( aDim, aDim->GetLayer(), false, aDim->GetFontMetrics() );
492
493 PCB_SHAPE temp_item;
494
495 temp_item.SetStroke( STROKE_PARAMS( aDim->GetLineThickness(), LINE_STYLE::SOLID ) );
496 temp_item.SetLayer( aDim->GetLayer() );
497
498 for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
499 {
500 switch( shape->Type() )
501 {
502 case SH_SEGMENT:
503 {
504 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
505
506 temp_item.SetShape( SHAPE_T::SEGMENT );
507 temp_item.SetStart( seg.A );
508 temp_item.SetEnd( seg.B );
509
510 PlotShape( &temp_item );
511 break;
512 }
513
514 case SH_CIRCLE:
515 {
516 VECTOR2I start( shape->Centre() );
517 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
518
519 temp_item.SetShape( SHAPE_T::CIRCLE );
520 temp_item.SetFilled( false );
521 temp_item.SetStart( start );
522 temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
523
524 PlotShape( &temp_item );
525 break;
526 }
527
528 default:
529 break;
530 }
531 }
532}
533
534
536{
537 int dx1, dx2, dy1, dy2, radius;
538
539 if( !m_layerMask[aMire->GetLayer()] )
540 return;
541
542 m_plotter->SetColor( getColor( aMire->GetLayer() ) );
543
544 PCB_SHAPE temp_item;
545
546 temp_item.SetShape( SHAPE_T::CIRCLE );
547 temp_item.SetFilled( false );
548 temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), LINE_STYLE::SOLID ) );
549 temp_item.SetLayer( aMire->GetLayer() );
550 temp_item.SetStart( aMire->GetPosition() );
551 radius = aMire->GetSize() / 3;
552
553 if( aMire->GetShape() ) // temp_item X
554 radius = aMire->GetSize() / 2;
555
556 // Draw the circle
557 temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
558
559 PlotShape( &temp_item );
560
561 temp_item.SetShape( SHAPE_T::SEGMENT );
562
563 radius = aMire->GetSize() / 2;
564 dx1 = radius;
565 dy1 = 0;
566 dx2 = 0;
567 dy2 = radius;
568
569 if( aMire->GetShape() ) // Shape X
570 {
571 dx1 = dy1 = radius;
572 dx2 = dx1;
573 dy2 = -dy1;
574 }
575
576 VECTOR2I mirePos( aMire->GetPosition() );
577
578 // Draw the X or + temp_item:
579 temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
580 temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
581 PlotShape( &temp_item );
582
583 temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
584 temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
585 PlotShape( &temp_item );
586}
587
588
590{
591 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
592 {
593 if( aFootprint->GetPrivateLayers().test( item->GetLayer() ) )
594 continue;
595
596 if( !m_layerMask[ item->GetLayer() ] )
597 continue;
598
599 switch( item->Type() )
600 {
601 case PCB_SHAPE_T:
602 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
603 break;
604
605 case PCB_TEXTBOX_T:
606 {
607 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
608
609 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
610
611 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(),
612 textbox->GetFontMetrics() );
613
614 if( textbox->IsBorderEnabled() )
615 PlotShape( textbox );
616
618 break;
619 }
620
622 case PCB_DIM_CENTER_T:
623 case PCB_DIM_RADIAL_T:
625 case PCB_DIM_LEADER_T:
626 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
627 break;
628
629 case PCB_TEXT_T:
630 // Plotted in PlotFootprintTextItems()
631 break;
632
633 default:
634 UNIMPLEMENTED_FOR( item->GetClass() );
635 }
636 }
637}
638
639
640#include <font/stroke_font.h>
641void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
642 const KIFONT::METRICS& aFontMetrics )
643{
644 KIFONT::FONT* font = aText->GetFont();
645
646 if( !font )
647 {
648 wxString defaultFontName; // empty string is the KiCad stroke font
649
651 defaultFontName = m_plotter->RenderSettings()->GetDefaultFont();
652
653 font = KIFONT::FONT::GetFont( defaultFontName, aText->IsBold(), aText->IsItalic() );
654 }
655
656 wxString shownText( aText->GetShownText( true ) );
657
658 if( shownText.IsEmpty() )
659 return;
660
661 if( !m_layerMask[aLayer] )
662 return;
663
664 GBR_METADATA gbr_metadata;
665
666 if( IsCopperLayer( aLayer ) )
668
669 COLOR4D color = getColor( aLayer );
671
672 VECTOR2I pos = aText->GetTextPos();
673
674 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
676 attrs.m_Angle = aText->GetDrawRotation();
677 attrs.m_Multiline = false;
678
680
681 if( aIsKnockout )
682 {
683 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aText );
684 SHAPE_POLY_SET finalPoly;
685
686 text->TransformTextToPolySet( finalPoly, 0, m_board->GetDesignSettings().m_MaxError,
687 ERROR_INSIDE );
689
690 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
691 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
692 }
693 else if( aText->IsMultilineAllowed() )
694 {
695 std::vector<VECTOR2I> positions;
696 wxArrayString strings_list;
697 wxStringSplit( shownText, strings_list, '\n' );
698 positions.reserve( strings_list.Count() );
699
700 aText->GetLinePositions( positions, strings_list.Count() );
701
702 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
703 {
704 wxString& txt = strings_list.Item( ii );
705 m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics, &gbr_metadata );
706 }
707 }
708 else
709 {
710 m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, &gbr_metadata );
711 }
712}
713
714
716 const SHAPE_POLY_SET& aPolysList )
717{
718 if( aPolysList.IsEmpty() )
719 return;
720
721 GBR_METADATA gbr_metadata;
722
723 if( aZone->IsOnCopperLayer() )
724 {
725 gbr_metadata.SetNetName( aZone->GetNetname() );
726 gbr_metadata.SetCopper( true );
727
728 // Zones with no net name can exist.
729 // they are not used to connect items, so the aperture attribute cannot
730 // be set as conductor
731 if( aZone->GetNetname().IsEmpty() )
732 {
734 }
735 else
736 {
739 }
740 }
741
742 m_plotter->SetColor( getColor( aLayer ) );
743
744 m_plotter->StartBlock( nullptr ); // Clean current object attributes
745
746 /*
747 * In non filled mode the outline is plotted, but not the filling items
748 */
749
750 for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
751 {
752 const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
753
754 // Plot the current filled area (as region for Gerber plotter to manage attributes)
755 if( GetPlotMode() == FILLED )
756 {
757 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
758 {
759 static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline,
760 &gbr_metadata );
761 }
762 else
763 {
764 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
765 }
766 }
767 else
768 {
770 }
771 }
772
773 m_plotter->EndBlock( nullptr ); // Clear object attributes
774}
775
776
778{
779 if( !m_layerMask[aShape->GetLayer()] )
780 return;
781
782 bool sketch = GetPlotMode() == SKETCH;
783 int thickness = aShape->GetWidth();
784 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
785
786 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
787
788 const FOOTPRINT* parentFP = aShape->GetParentFootprint();
789 GBR_METADATA gbr_metadata;
790
791 if( parentFP )
792 {
793 gbr_metadata.SetCmpReference( parentFP->GetReference() );
795 }
796
797 if( aShape->GetLayer() == Edge_Cuts )
798 {
800 }
801 else if( IsCopperLayer( aShape->GetLayer() ) )
802 {
803 if( parentFP )
804 {
806 gbr_metadata.SetCopper( true );
807 }
808 else if( aShape->GetNetCode() > 0 )
809 {
810 gbr_metadata.SetCopper( true );
813 gbr_metadata.SetNetName( aShape->GetNetname() );
814 }
815 else
816 {
817 // Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
818 // Graphic items having a net have the Conductor attribute, but are not (yet?)
819 // supported in Pcbnew
821 }
822 }
823
824 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
825 {
826 switch( aShape->GetShape() )
827 {
828 case SHAPE_T::SEGMENT:
829 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, GetPlotMode(),
830 &gbr_metadata );
831 break;
832
833 case SHAPE_T::CIRCLE:
834 if( aShape->IsFilled() )
835 {
836 m_plotter->FilledCircle( aShape->GetStart(), aShape->GetRadius() * 2 + thickness,
837 GetPlotMode(), &gbr_metadata );
838 }
839 else
840 {
841 m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness,
842 GetPlotMode(), &gbr_metadata );
843 }
844
845 break;
846
847 case SHAPE_T::ARC:
848 {
849 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
850 // but it is a circle
851 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
852 {
853 m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness,
854 GetPlotMode(), &gbr_metadata );
855 }
856 else
857 {
858 m_plotter->ThickArc( *aShape, GetPlotMode(), &gbr_metadata );
859 }
860
861 break;
862 }
863
864 case SHAPE_T::BEZIER:
865 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
866 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
867 break;
868
869 case SHAPE_T::POLY:
870 if( aShape->IsPolyShapeValid() )
871 {
872 if( sketch )
873 {
874 for( auto it = aShape->GetPolyShape().CIterateSegments( 0 ); it; it++ )
875 {
876 auto seg = it.Get();
877 m_plotter->ThickSegment( seg.A, seg.B, thickness, GetPlotMode(),
878 &gbr_metadata );
879 }
880 }
881 else
882 {
883 m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
884
885 // Draw the polygon: only one polygon is expected
886 // However we provide a multi polygon shape drawing
887 // ( for the future or to show a non expected shape )
888 // This must be simplified and fractured to prevent overlapping polygons
889 // from generating invalid Gerber files
892 FILL_T fill = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
893
894 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
895 {
896 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
897
898 // Ensure the polygon is closed:
899 poly.SetClosed( true );
900
901 // Plot the current filled area
902 // (as region for Gerber plotter to manage attributes)
903 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
904 {
905 static_cast<GERBER_PLOTTER*>( m_plotter )->
906 PlotPolyAsRegion( poly, fill, thickness, &gbr_metadata );
907 }
908 else
909 {
910 m_plotter->PlotPoly( poly, fill, thickness, &gbr_metadata );
911 }
912 }
913 }
914 }
915
916 break;
917
918 case SHAPE_T::RECTANGLE:
919 {
920 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
921
922 if( sketch )
923 {
924 m_plotter->ThickSegment( pts[0], pts[1], thickness, GetPlotMode(), &gbr_metadata );
925 m_plotter->ThickSegment( pts[1], pts[2], thickness, GetPlotMode(), &gbr_metadata );
926 m_plotter->ThickSegment( pts[2], pts[3], thickness, GetPlotMode(), &gbr_metadata );
927 m_plotter->ThickSegment( pts[3], pts[0], thickness, GetPlotMode(), &gbr_metadata );
928 }
929
930 if( !sketch )
931 {
932 SHAPE_LINE_CHAIN poly;
933
934 for( const VECTOR2I& pt : pts )
935 poly.Append( pt );
936
937 poly.Append( pts[0] ); // Close polygon.
938
939 FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
940
941 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
942 {
943 static_cast<GERBER_PLOTTER*>( m_plotter )->
944 PlotPolyAsRegion( poly, fill_mode, thickness, &gbr_metadata );
945 }
946 else
947 {
948 m_plotter->PlotPoly( poly, fill_mode, thickness, &gbr_metadata );
949 }
950 }
951
952 break;
953 }
954
955 default:
957 }
958 }
959 else
960 {
961 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
962
963 for( SHAPE* shape : shapes )
964 {
965 STROKE_PARAMS::Stroke( shape, lineStyle, thickness, m_plotter->RenderSettings(),
966 [&]( const VECTOR2I& a, const VECTOR2I& b )
967 {
968 m_plotter->ThickSegment( a, b, thickness, GetPlotMode(),
969 &gbr_metadata );
970 } );
971 }
972
973 for( SHAPE* shape : shapes )
974 delete shape;
975 }
976}
977
978
980{
981 VECTOR2I pos = aTable->GetPosition();
982 VECTOR2I end = aTable->GetEnd();
983 int lineWidth;
984 LINE_STYLE lineStyle;
985 GBR_METADATA gbr_metadata;
986
987 if( const FOOTPRINT* parentFP = aTable->GetParentFootprint() )
988 {
989 gbr_metadata.SetCmpReference( parentFP->GetReference() );
991 }
992
993 auto setupStroke =
994 [&]( const STROKE_PARAMS& stroke )
995 {
996 lineWidth = stroke.GetWidth();
997 lineStyle = stroke.GetLineStyle();
998 };
999
1000 auto strokeShape =
1001 [&]( const SHAPE& shape )
1002 {
1003 STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, m_plotter->RenderSettings(),
1004 [&]( const VECTOR2I& a, const VECTOR2I& b )
1005 {
1006 m_plotter->ThickSegment( a, b, lineWidth, GetPlotMode(),
1007 &gbr_metadata );
1008 } );
1009 };
1010
1011 auto strokeLine =
1012 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
1013 {
1014 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
1015 {
1016 m_plotter->ThickSegment( ptA, ptB, lineWidth, GetPlotMode(), &gbr_metadata );
1017 }
1018 else
1019 {
1020 SHAPE_SEGMENT seg( ptA, ptB );
1021 strokeShape( seg );
1022 }
1023 };
1024
1025 auto strokeRect =
1026 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
1027 {
1028 strokeLine( VECTOR2I( ptA.x, ptA.y ), VECTOR2I( ptB.x, ptA.y ) );
1029 strokeLine( VECTOR2I( ptB.x, ptA.y ), VECTOR2I( ptB.x, ptB.y ) );
1030 strokeLine( VECTOR2I( ptB.x, ptB.y ), VECTOR2I( ptA.x, ptB.y ) );
1031 strokeLine( VECTOR2I( ptA.x, ptB.y ), VECTOR2I( ptA.x, ptA.y ) );
1032 };
1033
1034 if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
1035 {
1036 setupStroke( aTable->GetSeparatorsStroke() );
1037
1038 if( aTable->StrokeColumns() )
1039 {
1040 for( int col = 0; col < aTable->GetColCount() - 1; ++col )
1041 {
1042 for( int row = 0; row < aTable->GetRowCount(); ++row )
1043 {
1044 PCB_TABLECELL* cell = aTable->GetCell( row, col );
1045 VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
1046
1047 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
1048 strokeLine( topRight, cell->GetEnd() );
1049 }
1050 }
1051 }
1052
1053 if( aTable->StrokeRows() )
1054 {
1055 for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
1056 {
1057 for( int col = 0; col < aTable->GetColCount(); ++col )
1058 {
1059 PCB_TABLECELL* cell = aTable->GetCell( row, col );
1060 VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
1061
1062 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
1063 strokeLine( botLeft, cell->GetEnd() );
1064 }
1065 }
1066 }
1067 }
1068
1069 if( aTable->GetBorderStroke().GetWidth() >= 0 )
1070 {
1071 setupStroke( aTable->GetBorderStroke() );
1072
1073 if( aTable->StrokeHeader() )
1074 {
1075 PCB_TABLECELL* cell = aTable->GetCell( 0, 0 );
1076 strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
1077 }
1078
1079 if( aTable->StrokeExternal() )
1080 strokeRect( pos, end );
1081 }
1082}
1083
1084
1086 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
1087 const EDA_ANGLE& aOrientation, int aSmallDrill )
1088{
1089 VECTOR2I drillSize = aDrillSize;
1090
1091 // Small drill marks have no significance when applied to slots
1092 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
1093 drillSize.x = std::min( aSmallDrill, drillSize.x );
1094
1095 // Round holes only have x diameter, slots have both
1096 drillSize.x -= getFineWidthAdj();
1097 drillSize.x = Clamp( 1, drillSize.x, aPadSize.x - 1 );
1098
1099 if( aDrillShape == PAD_DRILL_SHAPE::OBLONG )
1100 {
1101 drillSize.y -= getFineWidthAdj();
1102 drillSize.y = Clamp( 1, drillSize.y, aPadSize.y - 1 );
1103
1104 m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, GetPlotMode(), nullptr );
1105 }
1106 else
1107 {
1108 m_plotter->FlashPadCircle( aDrillPos, drillSize.x, GetPlotMode(), nullptr );
1109 }
1110}
1111
1112
1114{
1115 bool onCopperLayer = ( LSET::AllCuMask() & m_layerMask ).any();
1116 int smallDrill = 0;
1117
1118 if( GetDrillMarksType() == DRILL_MARKS::SMALL_DRILL_SHAPE )
1120
1121 /* In the filled trace mode drill marks are drawn white-on-black to knock-out the underlying
1122 pad. This works only for drivers supporting color change, obviously... it means that:
1123 - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
1124 - In HPGL you can't see them
1125 - In gerbers you can't see them, too. This is arguably the right thing to do since having
1126 drill marks and high speed drill stations is a sure recipe for broken tools and angry
1127 manufacturers. If you *really* want them you could start a layer with negative polarity
1128 to knock-out the film.
1129 - In DXF they go into the 'WHITE' layer. This could be useful.
1130 */
1131 if( GetPlotMode() == FILLED && onCopperLayer )
1133
1134 for( PCB_TRACK* track : m_board->Tracks() )
1135 {
1136 if( track->Type() == PCB_VIA_T )
1137 {
1138 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
1139
1140 // Via are not always on all layers
1141 if( ( via->GetLayerSet() & m_layerMask ).none() )
1142 continue;
1143
1144 plotOneDrillMark( PAD_DRILL_SHAPE::CIRCLE, via->GetStart(),
1145 VECTOR2I( via->GetDrillValue(), 0 ), VECTOR2I( via->GetWidth(), 0 ),
1146 ANGLE_0, smallDrill );
1147 }
1148 }
1149
1150 for( FOOTPRINT* footprint : m_board->Footprints() )
1151 {
1152 for( PAD* pad : footprint->Pads() )
1153 {
1154 if( pad->GetDrillSize().x == 0 )
1155 continue;
1156
1157 plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
1158 pad->GetSize(), pad->GetOrientation(), smallDrill );
1159 }
1160 }
1161
1162 if( GetPlotMode() == FILLED && onCopperLayer )
1164}
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
bool test(size_t pos) const
Definition: base_set.h:47
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:240
virtual bool IsKnockout() const
Definition: board_item.h:312
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:264
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:98
const FOOTPRINTS & Footprints() const
Definition: board.h:330
const TRACKS & Tracks() const
Definition: board.h:328
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:874
const SizeVec & GetSize() const
Definition: box2.h:196
Vec Centre() const
Definition: box2.h:87
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:143
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 PlotDimension(const PCB_DIMENSION_BASE *aDim)
void PlotPad(const PAD *aPad, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
BOARD * m_board
Definition: pcbplot.h:142
void PlotShape(const PCB_SHAPE *aShape)
PLOTTER * m_plotter
Definition: pcbplot.h:141
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 PlotText(const EDA_TEXT *aText, PCB_LAYER_ID aLayer, bool aIsKnockout, const KIFONT::METRICS &aFontMetrics)
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.
void PlotFootprintGraphicItems(const FOOTPRINT *aFootprint)
COLOR4D GetColor(int aLayer) const
double AsDegrees() const
Definition: eda_angle.h:113
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ANGLE GetArcAngle() const
Definition: eda_shape.cpp:682
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:206
int GetStartY() const
Definition: eda_shape.h:131
int GetEndX() const
Definition: eda_shape.h:169
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:319
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:279
bool IsFilled() const
Definition: eda_shape.h:91
void SetFilled(bool aFlag)
Definition: eda_shape.h:101
int GetRadius() const
Definition: eda_shape.cpp:612
SHAPE_T GetShape() const
Definition: eda_shape.h:125
int GetEndY() const
Definition: eda_shape.h:168
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:167
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:134
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:130
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:124
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1171
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:171
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:89
int GetStartX() const
Definition: eda_shape.h:132
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:203
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1356
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:230
bool IsItalic() const
Definition: eda_text.h:140
bool IsMultilineAllowed() const
Definition: eda_text.h:157
virtual bool IsVisible() const
Definition: eda_text.h:147
KIFONT::FONT * GetFont() const
Definition: eda_text.h:207
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:336
void GetLinePositions(std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:753
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:191
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:323
bool IsBold() const
Definition: eda_text.h:144
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:105
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:627
LSET GetPrivateLayers() const
Definition: footprint.h:130
PCB_FIELD & Reference()
Definition: footprint.h:628
PCB_FIELDS & Fields()
Definition: footprint.h:192
const wxString & GetReference() const
Definition: footprint.h:591
DRAWINGS & GraphicalItems()
Definition: footprint.h:198
@ GBR_APERTURE_ATTRIB_ETCHEDCMP
aperture used for etched components.
Definition: gbr_metadata.h:94
@ GBR_APERTURE_ATTRIB_BGAPAD_CUDEF
aperture used for edge connector pad (outer layers).
Definition: gbr_metadata.h:117
@ GBR_APERTURE_ATTRIB_HEATSINKPAD
aperture used for castellated pads in copper layer files.
Definition: gbr_metadata.h:131
@ GBR_APERTURE_ATTRIB_TESTPOINT
aperture used for test point pad (outer layers).
Definition: gbr_metadata.h:122
@ GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
aperture used for BGA pads with a solder mask defined by the copper shape.
Definition: gbr_metadata.h:111
@ GBR_APERTURE_ATTRIB_WASHERPAD
aperture used for mechanical pads (NPTH).
Definition: gbr_metadata.h:121
@ GBR_APERTURE_ATTRIB_COMPONENTPAD
aperture used for SMD pad. Excluded BGA pads which have their own type.
Definition: gbr_metadata.h:105
@ GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL
aperture used for fiducial pad (outer layers), at footprint level.
Definition: gbr_metadata.h:125
@ GBR_APERTURE_ATTRIB_CASTELLATEDPAD
aperture used for castellated pads in drill files.
Definition: gbr_metadata.h:134
@ GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL
aperture used for heat sink pad (typically for SMDs).
Definition: gbr_metadata.h:128
@ GBR_APERTURE_ATTRIB_EDGECUT
aperture used for board cutout,
Definition: gbr_metadata.h:98
Metadata which can be added in a gerber file as attribute in X2 format.
Definition: gbr_metadata.h:205
void SetCopper(bool aValue)
Definition: gbr_metadata.h:252
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:241
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:229
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
Definition: gbr_metadata.h:236
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:209
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:262
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:219
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
Definition: gbr_metadata.h:231
@ GBR_NETINFO_NET
print info associated to a net (TO.N attribute)
@ GBR_NETINFO_CMP
print info associated to a component (TO.C attribute)
bool m_NotInNet
true if a pad of a footprint cannot be connected (for instance a mechanical NPTH, ot a not named pad)...
void FlashPadChamferRoundRect(const VECTOR2I &aShapePos, const VECTOR2I &aPadSize, int aCornerRadius, double aChamferRatio, int aChamferPositions, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aPlotMode, void *aData)
Flash a chamfered round rect pad.
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr)
Definition: font.cpp:146
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
const wxString & GetDefaultFont() const
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:760
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:732
Definition: pad.h:54
PAD_PROP GetProperty() const
Definition: pad.h:398
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:736
PAD_ATTRIB GetAttribute() const
Definition: pad.h:395
const wxString & GetPinFunction() const
Definition: pad.h:145
const wxString & GetNumber() const
Definition: pad.h:134
int GetRoundRectCornerRadius() const
Definition: pad.cpp:425
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:318
VECTOR2I ShapePos() const
Definition: pad.cpp:896
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:453
const VECTOR2I & GetDelta() const
Definition: pad.h:264
PAD_SHAPE GetShape() const
Definition: pad.h:193
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:359
int GetChamferPositions() const
Definition: pad.h:624
const VECTOR2I & GetSize() const
Definition: pad.h:256
double GetChamferRectRatio() const
Definition: pad.h:614
Abstract dimension API.
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
bool GetPlotInvisibleText() const
PLOT_TEXT_MODE GetTextMode() const
bool GetPlotReference() const
int GetSketchPadLineWidth() const
DRILL_MARKS GetDrillMarksType() const
bool GetPlotValue() const
bool GetPlotFPText() const
OUTLINE_MODE GetPlotMode() const
COLOR_SETTINGS * ColorSettings() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:75
int GetWidth() const override
Definition: pcb_shape.cpp:369
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:317
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:85
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:86
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:70
int GetRowSpan() const
Definition: pcb_tablecell.h:65
int GetColSpan() const
Definition: pcb_tablecell.h:62
VECTOR2I GetEnd() const
Definition: pcb_table.cpp:118
bool StrokeRows() const
Definition: pcb_table.h:86
int GetRowCount() const
Definition: pcb_table.h:106
bool StrokeColumns() const
Definition: pcb_table.h:83
bool StrokeExternal() const
Definition: pcb_table.h:53
bool StrokeHeader() const
Definition: pcb_table.h:56
PCB_TABLECELL * GetCell(int aRow, int aCol) const
Definition: pcb_table.h:131
std::vector< PCB_TABLECELL * > GetCells() const
Definition: pcb_table.h:141
int GetColCount() const
Definition: pcb_table.h:104
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition: pcb_table.h:71
const STROKE_PARAMS & GetBorderStroke() const
Definition: pcb_table.h:59
VECTOR2I GetPosition() const override
Definition: pcb_table.cpp:112
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 ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:553
virtual void ThickCircle(const VECTOR2I &pos, int diametre, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:645
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FilledCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:661
virtual void BezierCurve(const VECTOR2I &aStart, const VECTOR2I &aControl1, const VECTOR2I &aControl2, const VECTOR2I &aEnd, int aTolerance, int aLineThickness=USE_DEFAULT_LINE_WIDTH)
Generic fallback: Cubic Bezier curve rendered as a polyline In KiCad the bezier curves have 4 control...
Definition: plotter.cpp:229
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:136
virtual PLOT_FORMAT GetPlotterType() const =0
Returns the effective plot engine in use.
virtual void SetTextMode(PLOT_TEXT_MODE mode)
Change the current text mode.
Definition: plotter.h:514
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void ThickArc(const EDA_SHAPE &aArcShape, OUTLINE_MODE aTraceMode, void *aData)
Definition: plotter.cpp:596
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:537
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void 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:752
virtual void FlashPadOval(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
Flash a trapezoidal pad.
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void FlashPadRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void SetColor(const COLOR4D &color)=0
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
Definition: plotter.h:546
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Represent a set of closed polygons.
void Fracture(POLYGON_MODE aFastMode)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
CONST_SEGMENT_ITERATOR CIterateSegments(int aFirst, int aLast, bool aIterateHoles=false) const
Return an iterator object, for iterating between aFirst and aLast outline, with or without holes (def...
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
An abstract shape on 2D plane.
Definition: shape.h:126
Simple container to manage line stroke parameters.
Definition: stroke_params.h:81
int GetWidth() const
Definition: stroke_params.h:91
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:94
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:73
bool IsOnCopperLayer() const override
Definition: zone.cpp:257
@ 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:401
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
FILL_T
Definition: eda_shape.h:55
Handle special data (items attributes) during plot.
#define GBR_NETINFO_ALL
@ ERROR_INSIDE
static const bool FILLED
Definition: gr_basic.cpp:30
double m_SmallDrillMarkSize
The diameter of the drill marks on print and plot outputs (in mm) when the "Drill marks" option is se...
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:531
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:113
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
OUTLINE_MODE
Definition: outline_mode.h:25
@ SKETCH
Definition: outline_mode.h:26
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition: padstack.h:63
@ 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:48
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
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:228
@ 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_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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:121
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
Definition: util.h:65
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:673