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 if( padsize.x < ( padsize.y * 0.95 ) )
125 {
126 textAttrs.m_Angle = ANGLE_90;
127 std::swap( padsize.x, padsize.y );
128 }
129
130 // approximate the size of the pad number text:
131 // We use a size for at least 3 chars, to give a good look even for short numbers
132 int tsize = KiROUND( padsize.x / std::max( PrintableCharCount( padNumber ), 3 ) );
133 tsize = std::min( tsize, padsize.y );
134
135 // enforce a max size
136 tsize = std::min( tsize, pcbIUScale.mmToIU( 5.0 ) );
137
138 textAttrs.m_Size = VECTOR2I( tsize, tsize );
139
140 // use a somewhat spindly font to go with the outlined pads
141 textAttrs.m_StrokeWidth = KiROUND( tsize / 12.0 );
142
143 m_plotter->PlotText( position, aColor, padNumber, textAttrs );
144}
145
146
147void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, PCB_LAYER_ID aLayer, const COLOR4D& aColor,
148 OUTLINE_MODE aPlotMode )
149{
150 VECTOR2I shape_pos = aPad->ShapePos( aLayer );
151 GBR_METADATA metadata;
152
153 bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
154 bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
155
156 // Pad not on the solder mask layer cannot be soldered.
157 // therefore it can have a specific aperture attribute.
158 // Not yet in use.
159 // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
160
161 metadata.SetCmpReference( aPad->GetParentFootprint()->GetReference() );
162
163 if( plotOnCopperLayer )
164 {
166 metadata.SetCopper( true );
167
168 // Gives a default attribute, for instance for pads used as tracks in net ties:
169 // Connector pads and SMD pads are on external layers
170 // if on internal layers, they are certainly used as net tie
171 // and are similar to tracks: just conductor items
173
174 const bool useUTF8 = false;
175 const bool useQuoting = false;
176 metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
177
178 if( !aPad->GetNumber().IsEmpty() )
179 metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
180
181 metadata.SetNetName( aPad->GetNetname() );
182
183 // Some pads are mechanical pads ( through hole or smd )
184 // when this is the case, they have no pad name and/or are not plated.
185 // In this case gerber files have slightly different attributes.
186 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
187 metadata.m_NetlistMetadata.m_NotInNet = true;
188
189 if( !plotOnExternalCopperLayer )
190 {
191 // the .P object attribute (GBR_NETLIST_METADATA::GBR_NETINFO_PAD)
192 // is used on outer layers, unless the component is embedded
193 // or a "etched" component (fp only drawn, not a physical component)
194 // Currently, Pcbnew does not handle embedded component, so we disable the .P
195 // attribute on internal layers
196 // Note the Gerber doc is not really clear about through holes pads about the .P
199
200 }
201
202 // Some attributes are reserved to the external copper layers:
203 // GBR_APERTURE_ATTRIB_CONNECTORPAD and GBR_APERTURE_ATTRIB_SMDPAD_CUDEF
204 // for instance.
205 // Pad with type PAD_ATTRIB::CONN or PAD_ATTRIB::SMD that is not on outer layer
206 // has its aperture attribute set to GBR_APERTURE_ATTRIB_CONDUCTOR
207 switch( aPad->GetAttribute() )
208 {
209 case PAD_ATTRIB::NPTH: // Mechanical pad through hole
211 break;
212
213 case PAD_ATTRIB::PTH : // Pad through hole, a hole is also expected
215 break;
216
217 case PAD_ATTRIB::CONN: // Connector pads, no solder paste but with solder mask.
218 if( plotOnExternalCopperLayer )
220 break;
221
222 case PAD_ATTRIB::SMD: // SMD pads (on external copper layer only)
223 // with solder paste and mask
224 if( plotOnExternalCopperLayer )
226 break;
227 }
228
229 // Fabrication properties can have specific GBR_APERTURE_METADATA options
230 // that replace previous aperture attribute:
231 switch( aPad->GetProperty() )
232 {
233 case PAD_PROP::BGA: // Only applicable to outer layers
234 if( plotOnExternalCopperLayer )
236 break;
237
238 case PAD_PROP::FIDUCIAL_GLBL:
240 break;
241
242 case PAD_PROP::FIDUCIAL_LOCAL:
244 break;
245
246 case PAD_PROP::TESTPOINT: // Only applicable to outer layers
247 if( plotOnExternalCopperLayer )
249 break;
250
251 case PAD_PROP::HEATSINK:
253 break;
254
255 case PAD_PROP::CASTELLATED:
257 break;
258
259 case PAD_PROP::NONE:
260 case PAD_PROP::MECHANICAL:
261 break;
262 }
263
264 // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
265 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
267 }
268 else
269 {
271 }
272
273 // Set plot color (change WHITE to LIGHTGRAY because
274 // the white items are not seen on a white paper or screen
275 m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY );
276
277 if( aPlotMode == SKETCH )
279
280 switch( aPad->GetShape( aLayer ) )
281 {
282 case PAD_SHAPE::CIRCLE:
283 m_plotter->FlashPadCircle( shape_pos, aPad->GetSize( aLayer ).x,
284 aPlotMode, &metadata );
285 break;
286
287 case PAD_SHAPE::OVAL:
288 m_plotter->FlashPadOval( shape_pos, aPad->GetSize( aLayer ),
289 aPad->GetOrientation(), aPlotMode, &metadata );
290 break;
291
292 case PAD_SHAPE::RECTANGLE:
293 m_plotter->FlashPadRect( shape_pos, aPad->GetSize( aLayer ),
294 aPad->GetOrientation(), aPlotMode, &metadata );
295 break;
296
297 case PAD_SHAPE::ROUNDRECT:
298 m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize( aLayer ),
299 aPad->GetRoundRectCornerRadius( aLayer ),
300 aPad->GetOrientation(), aPlotMode, &metadata );
301 break;
302
303 case PAD_SHAPE::TRAPEZOID:
304 {
305 // Build the pad polygon in coordinates relative to the pad
306 // (i.e. for a pad at pos 0,0, rot 0.0). Needed to use aperture macros,
307 // to be able to create a pattern common to all trapezoid pads having the same shape
308 VECTOR2I coord[4];
309
310 // Order is lower left, lower right, upper right, upper left.
311 VECTOR2I half_size = aPad->GetSize( aLayer ) / 2;
312 VECTOR2I trap_delta = aPad->GetDelta( aLayer ) / 2;
313
314 coord[0] = VECTOR2I( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
315 coord[1] = VECTOR2I( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
316 coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
317 coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
318
319 m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode, &metadata );
320 }
321 break;
322
323 case PAD_SHAPE::CHAMFERED_RECT:
324 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
325 {
326 GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
327
328 gerberPlotter->FlashPadChamferRoundRect( shape_pos,
329 aPad->GetSize( aLayer ),
330 aPad->GetRoundRectCornerRadius( aLayer ),
331 aPad->GetChamferRectRatio( aLayer ),
332 aPad->GetChamferPositions( aLayer ), aPad->GetOrientation(),
333 aPlotMode, &metadata );
334 break;
335 }
336
338
339 default:
340 case PAD_SHAPE::CUSTOM:
341 {
342 const std::shared_ptr<SHAPE_POLY_SET>& polygons =
343 aPad->GetEffectivePolygon( aLayer, ERROR_INSIDE );
344
345 if( polygons->OutlineCount() )
346 {
347 m_plotter->FlashPadCustom( shape_pos, aPad->GetSize( aLayer ), aPad->GetOrientation(),
348 polygons.get(), aPlotMode, &metadata );
349 }
350 }
351 break;
352 }
353}
354
355
357{
358 if( !GetPlotFPText() )
359 return;
360
361 const PCB_TEXT* textItem = &aFootprint->Reference();
362 PCB_LAYER_ID textLayer = textItem->GetLayer();
363
364 // Reference and value have special controls for forcing their plotting
365 if( GetPlotReference() && m_layerMask[textLayer]
366 && ( textItem->IsVisible() || GetPlotInvisibleText() )
367 && !( aFootprint->IsDNP() && hideDNPItems( textLayer ) ) )
368 {
369 PlotText( textItem, textLayer, textItem->IsKnockout(), textItem->GetFontMetrics(),
370 aFootprint->IsDNP() && crossoutDNPItems( textLayer ) );
371 }
372
373 textItem = &aFootprint->Value();
374 textLayer = textItem->GetLayer();
375
376 if( GetPlotValue() && m_layerMask[textLayer]
377 && ( textItem->IsVisible() || GetPlotInvisibleText() )
378 && !( aFootprint->IsDNP() && hideDNPItems( textLayer ) ) )
379 {
380 PlotText( textItem, textLayer, textItem->IsKnockout(), textItem->GetFontMetrics(),
381 false );
382 }
383
384 std::vector<PCB_TEXT*> texts;
385
386 // Skip the reference and value texts that are handled specially
387 for( PCB_FIELD* field : aFootprint->GetFields() )
388 {
389 if( field->IsReference() || field->IsValue() )
390 continue;
391
392 texts.push_back( field );
393 }
394
395 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
396 {
397 textItem = dynamic_cast<const PCB_TEXT*>( item );
398
399 if( textItem )
400 texts.push_back( static_cast<PCB_TEXT*>( item ) );
401 }
402
403 for( const PCB_TEXT* text : texts )
404 {
405 if( !text->IsVisible() )
406 continue;
407
408 textLayer = text->GetLayer();
409 bool strikeout = false;
410
411 if( textLayer == Edge_Cuts || textLayer >= PCB_LAYER_ID_COUNT )
412 continue;
413
414 if( aFootprint->IsDNP() && hideDNPItems( textLayer ) )
415 continue;
416
417 if( !m_layerMask[textLayer] || aFootprint->GetPrivateLayers().test( textLayer ) )
418 continue;
419
420 if( text->GetText() == wxT( "${REFERENCE}" ) )
421 {
422 if( !GetPlotReference() )
423 continue;
424
425 strikeout = aFootprint->IsDNP() && crossoutDNPItems( textLayer );
426 }
427
428 if( text->GetText() == wxT( "${VALUE}" ) )
429 {
430 if( !GetPlotValue() )
431 continue;
432 }
433
434 PlotText( text, textLayer, text->IsKnockout(), text->GetFontMetrics(), strikeout );
435 }
436}
437
438
440{
441 switch( item->Type() )
442 {
443 case PCB_SHAPE_T:
444 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
445 break;
446
447 case PCB_TEXT_T:
448 {
449 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
450 PlotText( text, text->GetLayer(), text->IsKnockout(), text->GetFontMetrics() );
451 break;
452 }
453
454 case PCB_TEXTBOX_T:
455 {
456 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
457
458 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
459 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(), textbox->GetFontMetrics() );
460
461 if( textbox->IsBorderEnabled() )
462 PlotShape( textbox );
463
465 break;
466 }
467
468 case PCB_TABLE_T:
469 {
470 const PCB_TABLE* table = static_cast<const PCB_TABLE*>( item );
471
472 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
473
474 for( const PCB_TABLECELL* cell : table->GetCells() )
475 PlotText( cell, cell->GetLayer(), cell->IsKnockout(), cell->GetFontMetrics() );
476
477 PlotTableBorders( table );
478
480 break;
481 }
482
484 case PCB_DIM_CENTER_T:
485 case PCB_DIM_RADIAL_T:
487 case PCB_DIM_LEADER_T:
488 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
489
490 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
491
493 break;
494
495 case PCB_TARGET_T:
496 PlotPcbTarget( static_cast<const PCB_TARGET*>( item ) );
497 break;
498
499 default:
500 break;
501 }
502}
503
504
506{
507 if( !m_layerMask[aDim->GetLayer()] )
508 return;
509
511
512 // Set plot color (change WHITE to LIGHTGRAY because
513 // the white items are not seen on a white paper or screen
515
516 PlotText( aDim, aDim->GetLayer(), false, aDim->GetFontMetrics() );
517
518 PCB_SHAPE temp_item;
519
520 temp_item.SetStroke( STROKE_PARAMS( aDim->GetLineThickness(), LINE_STYLE::SOLID ) );
521 temp_item.SetLayer( aDim->GetLayer() );
522
523 for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
524 {
525 switch( shape->Type() )
526 {
527 case SH_SEGMENT:
528 {
529 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
530
531 temp_item.SetShape( SHAPE_T::SEGMENT );
532 temp_item.SetStart( seg.A );
533 temp_item.SetEnd( seg.B );
534
535 PlotShape( &temp_item );
536 break;
537 }
538
539 case SH_CIRCLE:
540 {
541 VECTOR2I start( shape->Centre() );
542 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
543
544 temp_item.SetShape( SHAPE_T::CIRCLE );
545 temp_item.SetFilled( false );
546 temp_item.SetStart( start );
547 temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
548
549 PlotShape( &temp_item );
550 break;
551 }
552
553 default:
554 break;
555 }
556 }
557}
558
559
561{
562 int dx1, dx2, dy1, dy2, radius;
563
564 if( !m_layerMask[aMire->GetLayer()] )
565 return;
566
567 m_plotter->SetColor( getColor( aMire->GetLayer() ) );
568
569 PCB_SHAPE temp_item;
570
571 temp_item.SetShape( SHAPE_T::CIRCLE );
572 temp_item.SetFilled( false );
573 temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), LINE_STYLE::SOLID ) );
574 temp_item.SetLayer( aMire->GetLayer() );
575 temp_item.SetStart( aMire->GetPosition() );
576 radius = aMire->GetSize() / 3;
577
578 if( aMire->GetShape() ) // temp_item X
579 radius = aMire->GetSize() / 2;
580
581 // Draw the circle
582 temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
583
584 PlotShape( &temp_item );
585
586 temp_item.SetShape( SHAPE_T::SEGMENT );
587
588 radius = aMire->GetSize() / 2;
589 dx1 = radius;
590 dy1 = 0;
591 dx2 = 0;
592 dy2 = radius;
593
594 if( aMire->GetShape() ) // Shape X
595 {
596 dx1 = dy1 = radius;
597 dx2 = dx1;
598 dy2 = -dy1;
599 }
600
601 VECTOR2I mirePos( aMire->GetPosition() );
602
603 // Draw the X or + temp_item:
604 temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
605 temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
606 PlotShape( &temp_item );
607
608 temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
609 temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
610 PlotShape( &temp_item );
611}
612
613
615{
616 for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
617 {
618 PCB_LAYER_ID itemLayer = item->GetLayer();
619
620 if( aFootprint->GetPrivateLayers().test( itemLayer ) )
621 continue;
622
623 if( aFootprint->IsDNP() && hideDNPItems( itemLayer ) )
624 continue;
625
626 if( !( m_layerMask & item->GetLayerSet() ).any() )
627 continue;
628
629 switch( item->Type() )
630 {
631 case PCB_SHAPE_T:
632 PlotShape( static_cast<const PCB_SHAPE*>( item ) );
633 break;
634
635 case PCB_TEXTBOX_T:
636 {
637 const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
638
639 m_plotter->SetTextMode( PLOT_TEXT_MODE::STROKE );
640
641 PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout(),
642 textbox->GetFontMetrics() );
643
644 if( textbox->IsBorderEnabled() )
645 PlotShape( textbox );
646
648 break;
649 }
650
652 case PCB_DIM_CENTER_T:
653 case PCB_DIM_RADIAL_T:
655 case PCB_DIM_LEADER_T:
656 PlotDimension( static_cast<const PCB_DIMENSION_BASE*>( item ) );
657 break;
658
659 case PCB_TEXT_T:
660 // Plotted in PlotFootprintTextItems()
661 break;
662
663 default:
664 UNIMPLEMENTED_FOR( item->GetClass() );
665 }
666 }
667}
668
669
670void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout,
671 const KIFONT::METRICS& aFontMetrics, bool aStrikeout )
672{
673 KIFONT::FONT* font = aText->GetFont();
674
675 if( !font )
676 {
677 wxString defaultFontName; // empty string is the KiCad stroke font
678
680 defaultFontName = m_plotter->RenderSettings()->GetDefaultFont();
681
682 font = KIFONT::FONT::GetFont( defaultFontName, aText->IsBold(), aText->IsItalic() );
683 }
684
685 wxString shownText( aText->GetShownText( true ) );
686
687 if( shownText.IsEmpty() )
688 return;
689
690 if( !m_layerMask[aLayer] )
691 return;
692
693 GBR_METADATA gbr_metadata;
694
695 if( IsCopperLayer( aLayer ) )
697
698 COLOR4D color = getColor( aLayer );
700
701 VECTOR2I pos = aText->GetTextPos();
702
703 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
705 attrs.m_Angle = aText->GetDrawRotation();
706 attrs.m_Multiline = false;
707
709
710 auto strikeoutText =
711 [&]( const PCB_TEXT* text )
712 {
713 SHAPE_POLY_SET textPoly;
714
715 text->TransformTextToPolySet( textPoly, 0, ARC_LOW_DEF, ERROR_INSIDE );
716 textPoly.Rotate( -text->GetDrawRotation(), text->GetDrawPos() );
717
718 BOX2I rect = textPoly.BBox();
719 VECTOR2I start( rect.GetLeft() - attrs.m_StrokeWidth,
720 ( rect.GetTop() + rect.GetBottom() ) / 2 );
721 VECTOR2I end( rect.GetRight() + attrs.m_StrokeWidth,
722 ( rect.GetTop() + rect.GetBottom() ) / 2 );
723
724 RotatePoint( start, text->GetDrawPos(), text->GetDrawRotation() );
725 RotatePoint( end, text->GetDrawPos(), text->GetDrawRotation() );
726
727 m_plotter->ThickSegment( start, end, attrs.m_StrokeWidth, FILLED, nullptr );
728 };
729
730 if( aIsKnockout )
731 {
732 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aText );
733 SHAPE_POLY_SET finalPoly;
734
735 text->TransformTextToPolySet( finalPoly, 0, m_board->GetDesignSettings().m_MaxError,
736 ERROR_INSIDE );
737 finalPoly.Fracture();
738
739 for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
740 m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
741 }
742 else
743 {
745 {
747
748 CALLBACK_GAL callback_gal( empty_opts,
749 // Stroke callback
750 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
751 {
752 m_plotter->ThickSegment( aPt1, aPt2, attrs.m_StrokeWidth, FILLED, nullptr );
753 },
754 // Polygon callback
755 [&]( const SHAPE_LINE_CHAIN& aPoly )
756 {
757 m_plotter->PlotPoly( aPoly, FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
758 } );
759
760 callback_gal.DrawGlyphs( *aText->GetRenderCache( font, shownText ) );
761 }
762 else if( aText->IsMultilineAllowed() )
763 {
764 std::vector<VECTOR2I> positions;
765 wxArrayString strings_list;
766 wxStringSplit( shownText, strings_list, '\n' );
767 positions.reserve( strings_list.Count() );
768
769 aText->GetLinePositions( positions, (int) strings_list.Count() );
770
771 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
772 {
773 wxString& txt = strings_list.Item( ii );
774 m_plotter->PlotText( positions[ii], color, txt, attrs, font, aFontMetrics,
775 &gbr_metadata );
776 }
777
778 if( aStrikeout && strings_list.Count() == 1 )
779 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
780 }
781 else
782 {
783 m_plotter->PlotText( pos, color, shownText, attrs, font, aFontMetrics, &gbr_metadata );
784
785 if( aStrikeout )
786 strikeoutText( static_cast<const PCB_TEXT*>( aText ) );
787 }
788 }
789}
790
791
793 const SHAPE_POLY_SET& aPolysList )
794{
795 if( aPolysList.IsEmpty() )
796 return;
797
798 GBR_METADATA gbr_metadata;
799
800 if( aZone->IsOnCopperLayer() )
801 {
802 gbr_metadata.SetNetName( aZone->GetNetname() );
803 gbr_metadata.SetCopper( true );
804
805 // Zones with no net name can exist.
806 // they are not used to connect items, so the aperture attribute cannot
807 // be set as conductor
808 if( aZone->GetNetname().IsEmpty() )
809 {
811 }
812 else
813 {
816 }
817 }
818
819 m_plotter->SetColor( getColor( aLayer ) );
820
821 m_plotter->StartBlock( nullptr ); // Clean current object attributes
822
823 /*
824 * In non filled mode the outline is plotted, but not the filling items
825 */
826
827 for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
828 {
829 const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
830
831 // Plot the current filled area (as region for Gerber plotter to manage attributes)
832 if( GetPlotMode() == FILLED )
833 {
834 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
835 {
836 static_cast<GERBER_PLOTTER*>( m_plotter )->PlotGerberRegion( outline,
837 &gbr_metadata );
838 }
839 else
840 {
841 m_plotter->PlotPoly( outline, FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
842 }
843 }
844 else
845 {
847 }
848 }
849
850 m_plotter->EndBlock( nullptr ); // Clear object attributes
851}
852
853
855{
856 if( !( m_layerMask & aShape->GetLayerSet() ).any() )
857 return;
858
859 OUTLINE_MODE plotMode = GetPlotMode();
860 int thickness = aShape->GetWidth();
861 int margin = thickness; // unclamped thickness (can be negative)
862 LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
863 bool onCopperLayer = ( LSET::AllCuMask() & m_layerMask ).any();
864 bool onSolderMaskLayer = ( LSET( { F_Mask, B_Mask } ) & m_layerMask ).any();
865
866 if( onSolderMaskLayer
867 && aShape->HasSolderMask()
868 && IsExternalCopperLayer( aShape->GetLayer() ) )
869 {
870 margin += 2 * aShape->GetSolderMaskExpansion();
871 thickness = std::max( margin, 0 );
872 }
873
874 m_plotter->SetColor( getColor( aShape->GetLayer() ) );
875
876 const FOOTPRINT* parentFP = aShape->GetParentFootprint();
877 GBR_METADATA gbr_metadata;
878
879 if( parentFP )
880 {
881 gbr_metadata.SetCmpReference( parentFP->GetReference() );
883 }
884
885 if( parentFP && parentFP->IsDNP() && GetSketchDNPFPsOnFabLayers() )
886 {
887 if( aShape->GetLayer() == F_Fab || aShape->GetLayer() == B_Fab )
888 plotMode = SKETCH;
889 }
890
891 if( aShape->GetLayer() == Edge_Cuts )
892 {
894 }
895 else if( onCopperLayer )
896 {
897 if( parentFP )
898 {
900 gbr_metadata.SetCopper( true );
901 }
902 else if( aShape->GetNetCode() > 0 )
903 {
904 gbr_metadata.SetCopper( true );
907 gbr_metadata.SetNetName( aShape->GetNetname() );
908 }
909 else
910 {
911 // Graphic items (PCB_SHAPE, TEXT) having no net have the NonConductor attribute
912 // Graphic items having a net have the Conductor attribute, but are not (yet?)
913 // supported in Pcbnew
915 }
916 }
917
918 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
919 {
920 switch( aShape->GetShape() )
921 {
922 case SHAPE_T::SEGMENT:
923 m_plotter->ThickSegment( aShape->GetStart(), aShape->GetEnd(), thickness, plotMode,
924 &gbr_metadata );
925 break;
926
927 case SHAPE_T::CIRCLE:
928 if( aShape->IsFilled() )
929 {
930 int diameter = aShape->GetRadius() * 2 + thickness;
931
932 if( margin < 0 )
933 {
934 diameter += margin;
935 diameter = std::max( diameter, 0 );
936 }
937
938 m_plotter->FilledCircle( aShape->GetStart(), diameter, plotMode, &gbr_metadata );
939 }
940 else
941 {
942 m_plotter->ThickCircle( aShape->GetStart(), aShape->GetRadius() * 2, thickness,
943 plotMode, &gbr_metadata );
944 }
945
946 break;
947
948 case SHAPE_T::ARC:
949 {
950 // when startAngle == endAngle ThickArc() doesn't know whether it's 0 deg and 360 deg
951 // but it is a circle
952 if( std::abs( aShape->GetArcAngle().AsDegrees() ) == 360.0 )
953 {
954 m_plotter->ThickCircle( aShape->GetCenter(), aShape->GetRadius() * 2, thickness,
955 plotMode, &gbr_metadata );
956 }
957 else
958 {
959 m_plotter->ThickArc( *aShape, plotMode, &gbr_metadata, thickness );
960 }
961
962 break;
963 }
964
965 case SHAPE_T::BEZIER:
966 m_plotter->BezierCurve( aShape->GetStart(), aShape->GetBezierC1(),
967 aShape->GetBezierC2(), aShape->GetEnd(), 0, thickness );
968 break;
969
970 case SHAPE_T::POLY:
971 if( aShape->IsPolyShapeValid() )
972 {
973 if( plotMode == SKETCH )
974 {
975 for( auto it = aShape->GetPolyShape().CIterateSegments( 0 ); it; it++ )
976 {
977 const SEG& seg = it.Get();
978 m_plotter->ThickSegment( seg.A, seg.B, thickness, SKETCH, &gbr_metadata );
979 }
980 }
981 else
982 {
983 m_plotter->SetCurrentLineWidth( thickness, &gbr_metadata );
984
985 // Draw the polygon: only one polygon is expected
986 // However we provide a multi polygon shape drawing
987 // ( for the future or to show a non expected shape )
988 // This must be simplified and fractured to prevent overlapping polygons
989 // from generating invalid Gerber files
991 tmpPoly.Fracture();
992
993 if( margin < 0 )
994 {
995 tmpPoly.Inflate( margin / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
997 }
998
999 FILL_T fill = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1000
1001 for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj )
1002 {
1003 SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj );
1004
1005 // Ensure the polygon is closed:
1006 poly.SetClosed( true );
1007
1008 // Plot the current filled area
1009 // (as region for Gerber plotter to manage attributes)
1010 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1011 {
1012 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1013 gbr_plotter->PlotPolyAsRegion( poly, fill, thickness, &gbr_metadata );
1014 }
1015 else
1016 {
1017 m_plotter->PlotPoly( poly, fill, thickness, &gbr_metadata );
1018 }
1019 }
1020 }
1021 }
1022
1023 break;
1024
1025 case SHAPE_T::RECTANGLE:
1026 {
1027 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
1028
1029 if( plotMode == SKETCH )
1030 {
1031 m_plotter->ThickSegment( pts[0], pts[1], thickness, SKETCH, &gbr_metadata );
1032 m_plotter->ThickSegment( pts[1], pts[2], thickness, SKETCH, &gbr_metadata );
1033 m_plotter->ThickSegment( pts[2], pts[3], thickness, SKETCH, &gbr_metadata );
1034 m_plotter->ThickSegment( pts[3], pts[0], thickness, SKETCH, &gbr_metadata );
1035 }
1036 else
1037 {
1038 SHAPE_POLY_SET poly;
1039 poly.NewOutline();
1040
1041 for( const VECTOR2I& pt : pts )
1042 poly.Append( pt );
1043
1044 if( margin < 0 )
1045 {
1046 poly.Inflate( margin / 2, CORNER_STRATEGY::ROUND_ALL_CORNERS,
1048 }
1049
1050 FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
1051
1052 if( poly.OutlineCount() > 0 )
1053 {
1054 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
1055 {
1056 GERBER_PLOTTER* gbr_plotter = static_cast<GERBER_PLOTTER*>( m_plotter );
1057 gbr_plotter->PlotPolyAsRegion( poly.COutline( 0 ), fill_mode, thickness,
1058 &gbr_metadata );
1059 }
1060 else
1061 {
1062 m_plotter->PlotPoly( poly.COutline( 0 ), fill_mode, thickness,
1063 &gbr_metadata );
1064 }
1065 }
1066 }
1067
1068 break;
1069 }
1070
1071 default:
1073 }
1074 }
1075 else
1076 {
1077 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1078
1079 for( SHAPE* shape : shapes )
1080 {
1081 STROKE_PARAMS::Stroke( shape, lineStyle, aShape->GetWidth(),
1083 [&]( const VECTOR2I& a, const VECTOR2I& b )
1084 {
1085 m_plotter->ThickSegment( a, b, thickness, plotMode,
1086 &gbr_metadata );
1087 } );
1088 }
1089
1090 for( SHAPE* shape : shapes )
1091 delete shape;
1092 }
1093}
1094
1095
1097{
1098 if( !m_layerMask[aTable->GetLayer()] )
1099 return;
1100
1101 VECTOR2I pos = aTable->GetPosition();
1102 VECTOR2I end = aTable->GetEnd();
1103 int lineWidth;
1104 LINE_STYLE lineStyle;
1105 GBR_METADATA gbr_metadata;
1106
1107 if( const FOOTPRINT* parentFP = aTable->GetParentFootprint() )
1108 {
1109 gbr_metadata.SetCmpReference( parentFP->GetReference() );
1111 }
1112
1113 auto setupStroke =
1114 [&]( const STROKE_PARAMS& stroke )
1115 {
1116 lineWidth = stroke.GetWidth();
1117 lineStyle = stroke.GetLineStyle();
1118 };
1119
1120 auto strokeShape =
1121 [&]( const SHAPE& shape )
1122 {
1123 STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, m_plotter->RenderSettings(),
1124 [&]( const VECTOR2I& a, const VECTOR2I& b )
1125 {
1126 m_plotter->ThickSegment( a, b, lineWidth, GetPlotMode(),
1127 &gbr_metadata );
1128 } );
1129 };
1130
1131 auto strokeLine =
1132 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
1133 {
1134 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
1135 {
1136 m_plotter->ThickSegment( ptA, ptB, lineWidth, GetPlotMode(), &gbr_metadata );
1137 }
1138 else
1139 {
1140 SHAPE_SEGMENT seg( ptA, ptB );
1141 strokeShape( seg );
1142 }
1143 };
1144
1145 auto strokeRect =
1146 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
1147 {
1148 strokeLine( VECTOR2I( ptA.x, ptA.y ), VECTOR2I( ptB.x, ptA.y ) );
1149 strokeLine( VECTOR2I( ptB.x, ptA.y ), VECTOR2I( ptB.x, ptB.y ) );
1150 strokeLine( VECTOR2I( ptB.x, ptB.y ), VECTOR2I( ptA.x, ptB.y ) );
1151 strokeLine( VECTOR2I( ptA.x, ptB.y ), VECTOR2I( ptA.x, ptA.y ) );
1152 };
1153
1154 if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
1155 {
1156 setupStroke( aTable->GetSeparatorsStroke() );
1157
1158 if( aTable->StrokeColumns() )
1159 {
1160 for( int col = 0; col < aTable->GetColCount() - 1; ++col )
1161 {
1162 for( int row = 0; row < aTable->GetRowCount(); ++row )
1163 {
1164 PCB_TABLECELL* cell = aTable->GetCell( row, col );
1165 VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
1166
1167 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
1168 strokeLine( topRight, cell->GetEnd() );
1169 }
1170 }
1171 }
1172
1173 if( aTable->StrokeRows() )
1174 {
1175 for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
1176 {
1177 for( int col = 0; col < aTable->GetColCount(); ++col )
1178 {
1179 PCB_TABLECELL* cell = aTable->GetCell( row, col );
1180 VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
1181
1182 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
1183 strokeLine( botLeft, cell->GetEnd() );
1184 }
1185 }
1186 }
1187 }
1188
1189 if( aTable->GetBorderStroke().GetWidth() >= 0 )
1190 {
1191 setupStroke( aTable->GetBorderStroke() );
1192
1193 if( aTable->StrokeHeader() )
1194 {
1195 PCB_TABLECELL* cell = aTable->GetCell( 0, 0 );
1196 strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
1197 }
1198
1199 if( aTable->StrokeExternal() )
1200 strokeRect( pos, end );
1201 }
1202}
1203
1204
1206 const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
1207 const EDA_ANGLE& aOrientation, int aSmallDrill )
1208{
1209 VECTOR2I drillSize = aDrillSize;
1210
1211 // Small drill marks have no significance when applied to slots
1212 if( aSmallDrill && aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
1213 drillSize.x = std::min( aSmallDrill, drillSize.x );
1214
1215 // Round holes only have x diameter, slots have both
1216 drillSize.x -= getFineWidthAdj();
1217 drillSize.x = std::clamp( drillSize.x, 1, aPadSize.x - 1 );
1218
1219 if( aDrillShape == PAD_DRILL_SHAPE::OBLONG )
1220 {
1221 drillSize.y -= getFineWidthAdj();
1222 drillSize.y = std::clamp( drillSize.y, 1, aPadSize.y - 1 );
1223
1224 m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, GetPlotMode(), nullptr );
1225 }
1226 else
1227 {
1228 m_plotter->FlashPadCircle( aDrillPos, drillSize.x, GetPlotMode(), nullptr );
1229 }
1230}
1231
1232
1234{
1235 bool onCopperLayer = ( LSET::AllCuMask() & m_layerMask ).any();
1236 int smallDrill = 0;
1237
1238 if( GetDrillMarksType() == DRILL_MARKS::SMALL_DRILL_SHAPE )
1240
1241 /* In the filled trace mode drill marks are drawn white-on-black to knock-out the underlying
1242 pad. This works only for drivers supporting color change, obviously... it means that:
1243 - PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
1244 - In HPGL you can't see them
1245 - In gerbers you can't see them, too. This is arguably the right thing to do since having
1246 drill marks and high speed drill stations is a sure recipe for broken tools and angry
1247 manufacturers. If you *really* want them you could start a layer with negative polarity
1248 to knock-out the film.
1249 - In DXF they go into the 'WHITE' layer. This could be useful.
1250 */
1251 if( GetPlotMode() == FILLED && onCopperLayer )
1253
1254 for( PCB_TRACK* track : m_board->Tracks() )
1255 {
1256 if( track->Type() == PCB_VIA_T )
1257 {
1258 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
1259
1260 // Via are not always on all layers
1261 if( ( via->GetLayerSet() & m_layerMask ).none() )
1262 continue;
1263
1264 plotOneDrillMark( PAD_DRILL_SHAPE::CIRCLE, via->GetStart(),
1265 VECTOR2I( via->GetDrillValue(), 0 ),
1266 VECTOR2I( via->GetWidth( PADSTACK::ALL_LAYERS ), 0 ),
1267 ANGLE_0, smallDrill );
1268 }
1269 }
1270
1271 for( FOOTPRINT* footprint : m_board->Footprints() )
1272 {
1273 for( PAD* pad : footprint->Pads() )
1274 {
1275 if( pad->GetDrillSize().x == 0 )
1276 continue;
1277
1278 plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
1279 pad->GetSize( PADSTACK::ALL_LAYERS ), pad->GetOrientation(), smallDrill );
1280 }
1281 }
1282
1283 if( GetPlotMode() == FILLED && onCopperLayer )
1285}
int color
Definition: DXF_plotter.cpp:60
@ ERROR_INSIDE
Definition: approximation.h:34
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr int ARC_LOW_DEF
Definition: base_units.h:119
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:239
virtual bool IsKnockout() const
Definition: board_item.h:326
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:298
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:100
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: board.cpp:2589
const FOOTPRINTS & Footprints() const
Definition: board.h:336
const TRACKS & Tracks() const
Definition: board.h:334
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:934
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 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)
void PlotPad(const PAD *aPad, PCB_LAYER_ID aLayer, const COLOR4D &aColor, OUTLINE_MODE aPlotMode)
Plot a pad.
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:113
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ANGLE GetArcAngle() const
Definition: eda_shape.cpp:912
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:213
int GetStartY() const
Definition: eda_shape.h:138
int GetEndX() const
Definition: eda_shape.h:176
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:333
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:291
bool IsFilled() const
Definition: eda_shape.h:98
int GetRadius() const
Definition: eda_shape.cpp:840
SHAPE_T GetShape() const
Definition: eda_shape.h:132
virtual void SetFilled(bool aFlag)
Definition: eda_shape.h:108
int GetEndY() const
Definition: eda_shape.h:175
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:174
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:141
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:137
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:131
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1404
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:178
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:340
int GetStartX() const
Definition: eda_shape.h:139
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:210
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1590
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:260
bool IsItalic() const
Definition: eda_text.h:156
bool IsMultilineAllowed() const
Definition: eda_text.h:184
virtual bool IsVisible() const
Definition: eda_text.h:174
KIFONT::FONT * GetFont() const
Definition: eda_text.h:234
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:662
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:365
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:894
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:218
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:456
bool IsBold() const
Definition: eda_text.h:171
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:109
bool GetAreFontsEmbedded() const
bool IsDNP() const
Definition: footprint.h:790
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:656
LSET GetPrivateLayers() const
Definition: footprint.h:145
PCB_FIELD & Reference()
Definition: footprint.h:657
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:667
const wxString & GetReference() const
Definition: footprint.h:620
DRAWINGS & GraphicalItems()
Definition: footprint.h:207
@ 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:206
void SetCopper(bool aValue)
Definition: gbr_metadata.h:253
void SetCmpReference(const wxString &aComponentRef)
Definition: gbr_metadata.h:242
void SetNetName(const wxString &aNetname)
Definition: gbr_metadata.h:230
void SetPadPinFunction(const wxString &aPadPinFunction, bool aUseUTF8, bool aEscapeString)
Definition: gbr_metadata.h:237
void SetApertureAttrib(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute)
Definition: gbr_metadata.h:210
GBR_NETLIST_METADATA m_NetlistMetadata
An item to handle object attribute.
Definition: gbr_metadata.h:263
void SetNetAttribType(int aNetAttribType)
Definition: gbr_metadata.h:220
void SetPadName(const wxString &aPadname, bool aUseUTF8=false, bool aEscapeString=false)
Definition: gbr_metadata.h:232
@ 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 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...
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, bool aForDrawingSheet=false)
Definition: font.cpp:146
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.
const wxString & GetDefaultFont() const
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:580
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:562
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition: padstack.h:144
Definition: pad.h:54
PAD_PROP GetProperty() const
Definition: pad.h:441
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:363
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition: pad.cpp:442
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:826
PAD_ATTRIB GetAttribute() const
Definition: pad.h:438
const wxString & GetPinFunction() const
Definition: pad.h:145
const wxString & GetNumber() const
Definition: pad.h:134
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
Definition: pad.h:297
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition: pad.h:193
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:406
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition: pad.h:703
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition: pad.cpp:500
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition: pad.h:686
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition: pad.cpp:1016
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
Definition: pad.h:262
Abstract dimension API.
int GetLineThickness() const
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
bool GetPlotInvisibleText() const
PLOT_TEXT_MODE GetTextMode() const
bool GetSketchDNPFPsOnFabLayers() 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:79
int GetWidth() const override
Definition: pcb_shape.cpp:301
bool HasSolderMask() const
Definition: pcb_shape.h:183
int GetSolderMaskExpansion() const
Definition: pcb_shape.cpp:179
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_shape.cpp:218
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:170
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:89
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:90
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:69
int GetRowSpan() const
Definition: pcb_tablecell.h:65
int GetColSpan() const
Definition: pcb_tablecell.h:62
VECTOR2I GetEnd() const
Definition: pcb_table.cpp:116
bool StrokeRows() const
Definition: pcb_table.h:86
int GetRowCount() const
Definition: pcb_table.h:103
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:128
std::vector< PCB_TABLECELL * > GetCells() const
Definition: pcb_table.h:138
int GetColCount() const
Definition: pcb_table.h:101
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:110
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 ThickArc(const EDA_SHAPE &aArcShape, OUTLINE_MODE aTraceMode, void *aData, int aWidth)
Definition: plotter.cpp:596
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:646
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:662
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.
Definition: plotter.cpp:230
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:136
virtual PLOT_FORMAT GetPlotterType() const =0
Return the effective plot engine in use.
virtual void SetTextMode(PLOT_TEXT_MODE mode)
Change the current text mode.
Definition: plotter.h:517
virtual void FlashPadCircle(const VECTOR2I &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData)=0
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:540
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:754
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:549
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.
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
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:93
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:73
bool IsOnCopperLayer() const override
Definition: zone.cpp:480
@ 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:56
Handle special data (items attributes) during plot.
#define GBR_NETINFO_ALL
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)
Test whether a layer is a copper layer.
Definition: layer_ids.h:581
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition: layer_ids.h:592
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:135
@ 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: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:69
@ 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: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: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_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