KiCad PCB EDA Suite
Loading...
Searching...
No Matches
odb_feature.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 * Author: SYSUEric <[email protected]>.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include "odb_feature.h"
22
23#include <sstream>
24#include <map>
25
26#include <wx/log.h>
27
28#include "footprint.h"
29#include "pad.h"
30#include "pcb_shape.h"
31#include "odb_defines.h"
32#include "pcb_track.h"
33#include "pcb_textbox.h"
34#include "pcb_table.h"
35#include "pcb_barcode.h"
36#include "pcb_dimension.h"
37#include "zone.h"
38#include "board.h"
40#include "geometry/eda_angle.h"
46#include "odb_eda_data.h"
47#include "pcb_io_odbpp.h"
48#include <callback_gal.h>
49#include <string_utils.h>
50#include <trace_helpers.h>
51
52
53void FEATURES_MANAGER::AddFeatureLine( const VECTOR2I& aStart, const VECTOR2I& aEnd,
54 uint64_t aWidth )
55{
56 AddFeature<ODB_LINE>( ODB::AddXY( aStart ), ODB::AddXY( aEnd ),
58}
59
60
61void FEATURES_MANAGER::AddFeatureArc( const VECTOR2I& aStart, const VECTOR2I& aEnd,
62 const VECTOR2I& aCenter, uint64_t aWidth,
63 ODB_DIRECTION aDirection )
64{
65 AddFeature<ODB_ARC>( ODB::AddXY( aStart ), ODB::AddXY( aEnd ), ODB::AddXY( aCenter ),
66 AddCircleSymbol( ODB::SymDouble2String( aWidth ) ), aDirection );
67}
68
69
70void FEATURES_MANAGER::AddPadCircle( const VECTOR2I& aCenter, uint64_t aDiameter,
71 const EDA_ANGLE& aAngle, bool aMirror,
72 double aResize /*= 1.0 */ )
73{
75 AddCircleSymbol( ODB::SymDouble2String( aDiameter ) ), aAngle, aMirror,
76 aResize );
77}
78
79
80bool FEATURES_MANAGER::AddContour( const SHAPE_POLY_SET& aPolySet, int aOutline /*= 0*/,
81 FILL_T aFillType /*= FILL_T::FILLED_SHAPE*/ )
82{
83 // todo: args modify aPolySet.Polygon( aOutline ) instead of aPolySet
84
85 if( aPolySet.OutlineCount() < ( aOutline + 1 ) )
86 return false;
87
88 AddFeatureSurface( aPolySet.Polygon( aOutline ), aFillType );
89
90 return true;
91}
92
93
95{
96 int stroke_width = aShape.GetWidth();
97
98 switch( aShape.GetShape() )
99 {
100 case SHAPE_T::CIRCLE:
101 {
102 // GetRadius() can reach INT_MAX / 2 rounded up, which overflows a signed int when doubled
103 int64_t diameter = static_cast<int64_t>( aShape.GetRadius() ) * 2;
105
106 // The stroke straddles the radius, so in diameter terms the whole width comes off the
107 // inner edge and goes onto the outer
108 int64_t innerDiameter = diameter - stroke_width;
109 wxString outerDim = ODB::SymDouble2String( diameter + stroke_width );
110
111 // donut_r has no spelling for a hole closed by its own stroke
112 if( aShape.IsSolidFill() || innerDiameter <= 0 )
113 {
115 }
116 else
117 {
119 AddRoundDonutSymbol( outerDim,
120 ODB::SymDouble2String( innerDiameter ) ) );
121 }
122
123 break;
124 }
125
127 {
128 // ODB++ donut_rc symbols degenerate when the corner radius is smaller than half the
129 // line width, and some viewers drop the feature entirely. Emit the rectangle as a
130 // filled pad for the fill (if any) plus four line segments for the stroke, matching
131 // how a rectangle drawn with the line tool is exported.
132 if( aShape.IsSolidFill() )
133 {
134 int width = std::abs( aShape.GetRectangleWidth() );
135 int height = std::abs( aShape.GetRectangleHeight() );
137
140 ODB::SymDouble2String( height ) ) );
141 }
142
143 if( stroke_width > 0 )
144 {
145 std::vector<VECTOR2I> corners = aShape.GetRectCorners();
146
147 for( size_t ii = 0; ii < corners.size(); ++ii )
148 AddFeatureLine( corners[ii], corners[( ii + 1 ) % corners.size()], stroke_width );
149 }
150
151 break;
152 }
153
154 case SHAPE_T::POLY:
155 {
156 int soldermask_min_thickness = 0;
157
158 // TODO: check if soldermask_min_thickness should be Stroke width
159
160 if( aLayer != UNDEFINED_LAYER && LSET( { F_Mask, B_Mask } ).Contains( aLayer ) )
161 soldermask_min_thickness = stroke_width;
162
163 int maxError = m_board->GetDesignSettings().m_MaxError;
164 SHAPE_POLY_SET poly_set;
165
166 if( soldermask_min_thickness == 0 )
167 {
168 poly_set = aShape.GetPolyShape().CloneDropTriangulation();
169 poly_set.Fracture();
170 }
171 else
172 {
173 SHAPE_POLY_SET initialPolys;
174
175 // add shapes inflated by aMinThickness/2 in areas
176 aShape.TransformShapeToPolygon( initialPolys, aLayer, 0, maxError, ERROR_OUTSIDE );
177 aShape.TransformShapeToPolygon( poly_set, aLayer, soldermask_min_thickness / 2 - 1,
178 maxError, ERROR_OUTSIDE );
179
180 poly_set.Simplify();
181 poly_set.Deflate( soldermask_min_thickness / 2 - 1,
183 poly_set.BooleanAdd( initialPolys );
184 poly_set.Fracture();
185 }
186
187 // ODB++ surface features can only represent closed polygons. We add a surface for
188 // the fill of the shape, if present, and add line segments for the outline, if present.
189 if( aShape.IsSolidFill() )
190 {
191 for( int ii = 0; ii < poly_set.OutlineCount(); ++ii )
192 {
193 AddContour( poly_set, ii, FILL_T::FILLED_SHAPE );
194
195 if( stroke_width != 0 )
196 {
197 for( int jj = 0; jj < poly_set.COutline( ii ).SegmentCount(); ++jj )
198 {
199 const SEG& seg = poly_set.COutline( ii ).CSegment( jj );
200 AddFeatureLine( seg.A, seg.B, stroke_width );
201 }
202 }
203 }
204 }
205 else
206 {
207 for( int ii = 0; ii < poly_set.OutlineCount(); ++ii )
208 {
209 for( int jj = 0; jj < poly_set.COutline( ii ).SegmentCount(); ++jj )
210 {
211 const SEG& seg = poly_set.COutline( ii ).CSegment( jj );
212 AddFeatureLine( seg.A, seg.B, stroke_width );
213 }
214 }
215 }
216
217 break;
218 }
219
220 case SHAPE_T::ARC:
221 {
223
224 AddFeatureArc( aShape.GetStart(), aShape.GetEnd(), aShape.GetCenter(), stroke_width, dir );
225 break;
226 }
227
228 case SHAPE_T::BEZIER:
229 {
230 const std::vector<VECTOR2I>& points = aShape.GetBezierPoints();
231
232 for( size_t i = 0; i < points.size() - 1; i++ )
233 AddFeatureLine( points[i], points[i + 1], stroke_width );
234
235 break;
236 }
237
238 case SHAPE_T::SEGMENT:
239 AddFeatureLine( aShape.GetStart(), aShape.GetEnd(), stroke_width );
240 break;
241
242 case SHAPE_T::ELLIPSE:
243 {
244 int maxError = m_board->GetDesignSettings().m_MaxError;
245
247 aShape.GetEllipseRotation() );
248
250 chain.SetClosed( true );
251
252 if( aShape.IsSolidFill() )
253 {
254 SHAPE_POLY_SET poly_set;
255 poly_set.AddOutline( chain );
256 poly_set.Fracture();
257
258 for( int ii = 0; ii < poly_set.OutlineCount(); ++ii )
259 AddContour( poly_set, ii, FILL_T::FILLED_SHAPE );
260 }
261
262 if( stroke_width > 0 )
263 {
264 for( int ii = 0; ii < chain.SegmentCount(); ++ii )
265 {
266 const SEG& seg = chain.CSegment( ii );
267 AddFeatureLine( seg.A, seg.B, stroke_width );
268 }
269 }
270
271 break;
272 }
273
275 {
276 int maxError = m_board->GetDesignSettings().m_MaxError;
277
279 aShape.GetEllipseRotation(), aShape.GetEllipseStartAngle(), aShape.GetEllipseEndAngle() );
280
282
283 for( int ii = 0; ii < chain.SegmentCount(); ++ii )
284 {
285 const SEG& seg = chain.CSegment( ii );
286 AddFeatureLine( seg.A, seg.B, stroke_width );
287 }
288
289 break;
290 }
291
292 default:
293 wxLogTrace( traceOdbppIo, wxT( "Unknown shape when adding ODB++ layer feature" ) );
294 break;
295 }
296
297 if( aShape.IsHatchedFill() )
298 {
299 for( int ii = 0; ii < aShape.GetHatching().OutlineCount(); ++ii )
301 }
302}
303
304
306 FILL_T aFillType /*= FILL_T::FILLED_SHAPE */ )
307{
308 AddFeature<ODB_SURFACE>( aPolygon, aFillType );
309}
310
311
313{
314 FOOTPRINT* fp = aPad.GetParentFootprint();
315 bool mirror = false;
316
317 if( aPad.GetOrientation() != ANGLE_0 )
318 {
319 if( fp && fp->IsFlipped() )
320 mirror = true;
321 }
322
323 int maxError = m_board->GetDesignSettings().m_MaxError;
324
325 VECTOR2I expansion{ 0, 0 };
326
327 if( aLayer != UNDEFINED_LAYER && LSET( { F_Mask, B_Mask } ).Contains( aLayer ) )
328 expansion.x = expansion.y = aPad.GetSolderMaskExpansion( aLayer );
329
330 if( aLayer != UNDEFINED_LAYER && LSET( { F_Paste, B_Paste } ).Contains( aLayer ) )
331 expansion = aPad.GetSolderPasteMargin( aLayer );
332
333 int mask_clearance = expansion.x;
334
335 VECTOR2I plotSize = aPad.GetSize( aLayer ) + 2 * expansion;
336
337 VECTOR2I center = aPad.ShapePos( aLayer );
338
339 wxString width = ODB::SymDouble2String( std::abs( plotSize.x ) );
340 wxString height = ODB::SymDouble2String( std::abs( plotSize.y ) );
341
342 switch( aPad.GetShape( aLayer ) )
343 {
345 {
346 wxString diam = ODB::SymDouble2String( plotSize.x );
347
349 mirror );
350
351 break;
352 }
354 {
355 if( mask_clearance > 0 )
356 {
357 wxString rad = ODB::SymDouble2String( mask_clearance );
358
359 AddFeature<ODB_PAD>( ODB::AddXY( center ), AddRoundRectSymbol( width, height, rad ),
360 aPad.GetOrientation(), mirror );
361 }
362 else
363 {
365 aPad.GetOrientation(), mirror );
366 }
367
368 break;
369 }
370 case PAD_SHAPE::OVAL:
371 {
373 aPad.GetOrientation(), mirror );
374 break;
375 }
377 {
378 wxString rad = ODB::SymDouble2String( aPad.GetRoundRectCornerRadius( aLayer ) );
379
380 AddFeature<ODB_PAD>( ODB::AddXY( center ), AddRoundRectSymbol( width, height, rad ),
381 aPad.GetOrientation(), mirror );
382
383 break;
384 }
386 {
387 int shorterSide = std::min( plotSize.x, plotSize.y );
388 int chamfer = std::max(
389 0, KiROUND( aPad.GetChamferRectRatio( aLayer ) * shorterSide ) );
390 wxString rad = ODB::SymDouble2String( chamfer );
391 int positions = aPad.GetChamferPositions( aLayer );
392
394 AddChamferRectSymbol( width, height, rad, positions ),
395 aPad.GetOrientation(), mirror );
396
397 break;
398 }
400 {
401 SHAPE_POLY_SET outline;
402
403 aPad.TransformShapeToPolygon( outline, aLayer, 0, maxError, ERROR_INSIDE );
404
405 // Shape polygon can have holes so use InflateWithLinkedHoles(), not Inflate()
406 // which can create bad shapes if margin.x is < 0
407
408 if( mask_clearance )
409 {
411 maxError );
412 }
413
414 for( int ii = 0; ii < outline.OutlineCount(); ++ii )
415 AddContour( outline, ii );
416
417 break;
418 }
420 {
421 SHAPE_POLY_SET shape;
422 aPad.MergePrimitivesAsPolygon( aLayer, &shape );
423
424 // as for custome shape, odb++ don't rotate the polygon,
425 // so we rotate the polygon in kicad anticlockwise
426
427 shape.Rotate( aPad.GetOrientation() );
428 shape.Move( center );
429
430 if( expansion != VECTOR2I( 0, 0 ) )
431 {
432 shape.InflateWithLinkedHoles( std::max( expansion.x, expansion.y ),
434 }
435
436 for( int ii = 0; ii < shape.OutlineCount(); ++ii )
437 AddContour( shape, ii );
438
439 break;
440 }
441 default: wxLogTrace( traceOdbppIo, wxT( "Unknown pad type" ) ); break;
442 }
443}
444
445
446void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_ITEM*>& aItems )
447{
448 auto add_track = [&]( PCB_TRACK* track )
449 {
450 auto iter = GetODBPlugin()->GetViaTraceSubnetMap().find( track );
451
452 if( iter == GetODBPlugin()->GetViaTraceSubnetMap().end() )
453 {
454 wxLogTrace( traceOdbppIo, wxT( "Failed to get subnet track data" ) );
455 return;
456 }
457
458 auto subnet = iter->second;
459
460 if( track->Type() == PCB_TRACE_T )
461 {
462 PCB_SHAPE shape( nullptr, SHAPE_T::SEGMENT );
463 shape.SetStart( track->GetStart() );
464 shape.SetEnd( track->GetEnd() );
465 shape.SetWidth( track->GetWidth() );
466
467 AddShape( shape );
468 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER, m_layerName,
469 m_featuresList.size() - 1 );
470 }
471 else if( track->Type() == PCB_ARC_T )
472 {
473 PCB_ARC* arc = static_cast<PCB_ARC*>( track );
474 PCB_SHAPE shape( nullptr, SHAPE_T::ARC );
475 shape.SetArcGeometry( arc->GetStart(), arc->GetMid(), arc->GetEnd() );
476 shape.SetWidth( arc->GetWidth() );
477
478 AddShape( shape );
479
480 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER, m_layerName,
481 m_featuresList.size() - 1 );
482 }
483 else
484 {
485 // add via
486 PCB_VIA* via = static_cast<PCB_VIA*>( track );
487
488 bool hole = false;
489
490 if( aLayer != PCB_LAYER_ID::UNDEFINED_LAYER )
491 {
492 hole = m_layerName.Contains( "plugging" );
493 }
494 else
495 {
496 hole = m_layerName.Contains( "drill" ) || m_layerName.Contains( "filling" )
497 || m_layerName.Contains( "capping" );
498 }
499
500 if( hole )
501 {
502 AddViaDrillHole( via, aLayer );
503 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::HOLE, m_layerName,
504 m_featuresList.size() - 1 );
505
506 // TODO: confirm TOOLING_HOLE
507 // AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::PAD_USAGE::TOOLING_HOLE );
508
509 if( !m_featuresList.empty() )
510 {
513 *m_featuresList.back(),
514 ODB_ATTR::GEOMETRY{ "VIA_RoundD" + std::to_string( via->GetWidth( aLayer ) ) } );
515 }
516 }
517 else
518 {
519 // to draw via copper shape on copper layer
520 AddVia( via, aLayer );
521 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER, m_layerName,
522 m_featuresList.size() - 1 );
523
524 if( !m_featuresList.empty() )
525 {
528 *m_featuresList.back(),
529 ODB_ATTR::GEOMETRY{ "VIA_RoundD" + std::to_string( via->GetWidth( aLayer ) ) } );
530 }
531 }
532 }
533 };
534
535 auto add_zone = [&]( ZONE* zone )
536 {
537 SHAPE_POLY_SET zone_shape = zone->GetFilledPolysList( aLayer )->CloneDropTriangulation();
538
539 for( int ii = 0; ii < zone_shape.OutlineCount(); ++ii )
540 {
541 AddContour( zone_shape, ii );
542
543 auto iter = GetODBPlugin()->GetPlaneSubnetMap().find( std::make_pair( aLayer, zone ) );
544
545 if( iter == GetODBPlugin()->GetPlaneSubnetMap().end() )
546 {
547 wxLogTrace( traceOdbppIo, wxT( "Failed to get subnet plane data" ) );
548 return;
549 }
550
551 iter->second->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER, m_layerName,
552 m_featuresList.size() - 1 );
553
554 if( zone->IsTeardropArea() && !m_featuresList.empty() )
555 AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::TEAR_DROP{ true } );
556 }
557 };
558
559 auto add_text = [&]( BOARD_ITEM* item )
560 {
561 EDA_TEXT* text_item = nullptr;
562
563 if( PCB_TEXT* tmp_text = dynamic_cast<PCB_TEXT*>( item ) )
564 text_item = static_cast<EDA_TEXT*>( tmp_text );
565 else if( PCB_TEXTBOX* tmp_textbox = dynamic_cast<PCB_TEXTBOX*>( item ) )
566 text_item = static_cast<EDA_TEXT*>( tmp_textbox );
567
568 if( !text_item || !text_item->IsVisible() || text_item->GetShownText( false ).empty() )
569 return;
570
571 auto plot_text = [&]( const VECTOR2I& aPos, const wxString& aTextString,
572 const TEXT_ATTRIBUTES& aAttributes, KIFONT::FONT* aFont,
573 const KIFONT::METRICS& aFontMetrics )
574 {
576
577 TEXT_ATTRIBUTES attributes = aAttributes;
578 int penWidth = attributes.m_StrokeWidth;
579
580 if( penWidth == 0 && attributes.m_Bold ) // Use default values if aPenWidth == 0
581 penWidth =
582 GetPenSizeForBold( std::min( attributes.m_Size.x, attributes.m_Size.y ) );
583
584 if( penWidth < 0 )
585 penWidth = -penWidth;
586
587 attributes.m_StrokeWidth = penWidth;
588
589 std::list<VECTOR2I> pts;
590
591 auto push_pts = [&]()
592 {
593 if( pts.size() < 2 )
594 return;
595
596 // Polylines are only allowed for more than 3 points.
597 // Otherwise, we have to use a line
598
599 if( pts.size() < 3 )
600 {
601 PCB_SHAPE shape( nullptr, SHAPE_T::SEGMENT );
602 shape.SetStart( pts.front() );
603 shape.SetEnd( pts.back() );
604 shape.SetWidth( attributes.m_StrokeWidth );
605
606 AddShape( shape );
608 ODB_ATTR::STRING{ aTextString.ToStdString() } );
609 }
610 else
611 {
612 for( auto it = pts.begin(); std::next( it ) != pts.end(); ++it )
613 {
614 auto it2 = std::next( it );
615 PCB_SHAPE shape( nullptr, SHAPE_T::SEGMENT );
616 shape.SetStart( *it );
617 shape.SetEnd( *it2 );
618 shape.SetWidth( attributes.m_StrokeWidth );
619 AddShape( shape );
620
621 if( !m_featuresList.empty() )
622 {
624 ODB_ATTR::STRING{ aTextString.ToStdString() } );
625 }
626 }
627 }
628
629 pts.clear();
630 };
631
632 CALLBACK_GAL callback_gal(
633 empty_opts,
634 // Stroke callback
635 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
636 {
637 if( !pts.empty() )
638 {
639 if( aPt1 == pts.back() )
640 pts.push_back( aPt2 );
641 else if( aPt2 == pts.front() )
642 pts.push_front( aPt1 );
643 else if( aPt1 == pts.front() )
644 pts.push_front( aPt2 );
645 else if( aPt2 == pts.back() )
646 pts.push_back( aPt1 );
647 else
648 {
649 push_pts();
650 pts.push_back( aPt1 );
651 pts.push_back( aPt2 );
652 }
653 }
654 else
655 {
656 pts.push_back( aPt1 );
657 pts.push_back( aPt2 );
658 }
659 },
660 // Polygon callback
661 [&]( const SHAPE_LINE_CHAIN& aPoly )
662 {
663 if( aPoly.PointCount() < 3 )
664 return;
665
666 SHAPE_POLY_SET poly_set;
667 poly_set.AddOutline( aPoly );
668
669 for( int ii = 0; ii < poly_set.OutlineCount(); ++ii )
670 {
671 AddContour( poly_set, ii, FILL_T::FILLED_SHAPE );
672
673 if( !m_featuresList.empty() )
674 {
676 ODB_ATTR::STRING{ aTextString.ToStdString() } );
677 }
678 }
679 } );
680
681 aFont->Draw( &callback_gal, aTextString, aPos, aAttributes, aFontMetrics );
682
683 if( !pts.empty() )
684 push_pts();
685 };
686
687 PCB_TEXT* text = nullptr;
688 PCB_TEXTBOX* textbox = nullptr;
689 bool isKnockout = false;
690
691 if( item->Type() == PCB_TEXT_T || item->Type() == PCB_FIELD_T )
692 {
693 text = static_cast<PCB_TEXT*>( item );
694 isKnockout = text->IsKnockout();
695 }
696 else if( item->Type() == PCB_TEXTBOX_T )
697 {
698 textbox = static_cast<PCB_TEXTBOX*>( item );
699 isKnockout = textbox->IsKnockout();
700 }
701
702 const KIFONT::METRICS& fontMetrics = item->GetFontMetrics();
703 KIFONT::FONT* font = text_item->GetDrawFont( nullptr );
704 wxString shownText( text_item->GetShownText( true ) );
705
706 if( shownText.IsEmpty() )
707 return;
708
709 VECTOR2I pos = text_item->GetTextPos();
710
711 TEXT_ATTRIBUTES attrs = text_item->GetAttributes();
712 attrs.m_StrokeWidth = text_item->GetEffectiveTextPenWidth();
713 attrs.m_Angle = text_item->GetDrawRotation();
714 attrs.m_Multiline = false;
715
716 if( isKnockout )
717 {
718 SHAPE_POLY_SET finalpolyset;
719 int maxError = m_board->GetDesignSettings().m_MaxError;
720
721 if( text )
722 text->TransformTextToPolySet( finalpolyset, 0, maxError, ERROR_INSIDE );
723 else if( textbox )
724 textbox->TransformTextToPolySet( finalpolyset, 0, maxError, ERROR_INSIDE );
725
726 finalpolyset.Fracture();
727
728 for( int ii = 0; ii < finalpolyset.OutlineCount(); ++ii )
729 {
730 AddContour( finalpolyset, ii, FILL_T::FILLED_SHAPE );
731
732 if( !m_featuresList.empty() )
733 {
735 ODB_ATTR::STRING{ shownText.ToStdString() } );
736 }
737 }
738 }
739 else if( text_item->IsMultilineAllowed() )
740 {
741 std::vector<VECTOR2I> positions;
742 wxArrayString strings_list;
743 wxStringSplit( shownText, strings_list, '\n' );
744 positions.reserve( strings_list.Count() );
745
746 text_item->GetLinePositions( nullptr, positions, strings_list.Count() );
747
748 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
749 {
750 wxString& txt = strings_list.Item( ii );
751 plot_text( positions[ii], txt, attrs, font, fontMetrics );
752 }
753 }
754 else
755 {
756 plot_text( pos, shownText, attrs, font, fontMetrics );
757 }
758 };
759
760
761 auto add_shape = [&]( PCB_SHAPE* shape )
762 {
763 // FOOTPRINT* fp = shape->GetParentFootprint();
764 AddShape( *shape, aLayer );
765 };
766
767 auto add_dimension = [&]( PCB_DIMENSION_BASE* dimension )
768 {
769 // A dimension is a PCB_TEXT subclass, so the value text is plotted via add_text.
770
771 add_text( dimension );
772
773 PCB_SHAPE temp_shape;
774 temp_shape.SetStroke( STROKE_PARAMS( dimension->GetLineThickness(), LINE_STYLE::SOLID ) );
775 temp_shape.SetLayer( dimension->GetLayer() );
776
777 for( const std::shared_ptr<SHAPE>& shape : dimension->GetShapes() )
778 {
779 switch( shape->Type() )
780 {
781 case SH_SEGMENT:
782 {
783 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
784
785 temp_shape.SetShape( SHAPE_T::SEGMENT );
786 temp_shape.SetStart( seg.A );
787 temp_shape.SetEnd( seg.B );
788
789 add_shape( &temp_shape );
790 break;
791 }
792
793 case SH_CIRCLE:
794 {
795 VECTOR2I center( shape->Centre() );
796 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
797
798 temp_shape.SetShape( SHAPE_T::CIRCLE );
799 temp_shape.SetFilled( false );
800 temp_shape.SetStart( center );
801 temp_shape.SetEnd( VECTOR2I( center.x + radius, center.y ) );
802
803 add_shape( &temp_shape );
804 break;
805 }
806
807 default:
808 break;
809 }
810 }
811 };
812
813 auto add_pad = [&]( PAD* pad )
814 {
815 auto iter = GetODBPlugin()->GetPadSubnetMap().find( pad );
816
817 if( iter == GetODBPlugin()->GetPadSubnetMap().end() )
818 {
819 wxLogTrace( traceOdbppIo, wxT( "Failed to get subnet top data" ) );
820 return;
821 }
822
823 if( aLayer != PCB_LAYER_ID::UNDEFINED_LAYER )
824 {
825 // FOOTPRINT* fp = pad->GetParentFootprint();
826
827 AddPadShape( *pad, aLayer );
828
829 iter->second->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER, m_layerName,
830 m_featuresList.size() - 1 );
831 if( !m_featuresList.empty() )
833
834 if( !pad->HasHole() && !m_featuresList.empty() )
835 AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::SMD{ true } );
836 }
837 else
838 {
839 // drill layer round hole or slot hole
840 if( m_layerName.Contains( "drill" ) )
841 {
842 // here we exchange round hole or slot hole into pad to draw in drill layer
843 PAD dummy( *pad );
844 dummy.Padstack().SetMode( PADSTACK::MODE::NORMAL );
845
846 if( pad->GetDrillSizeX() == pad->GetDrillSizeY() )
847 dummy.SetShape( PADSTACK::ALL_LAYERS, PAD_SHAPE::CIRCLE ); // round hole shape
848 else
849 dummy.SetShape( PADSTACK::ALL_LAYERS, PAD_SHAPE::OVAL ); // slot hole shape
850
851 dummy.SetOffset( PADSTACK::ALL_LAYERS,
852 VECTOR2I( 0, 0 ) ); // use hole position not pad position
853 dummy.SetSize( PADSTACK::ALL_LAYERS, pad->GetDrillSize() );
854
855 AddPadShape( dummy, aLayer );
856
857 if( pad->GetAttribute() == PAD_ATTRIB::PTH )
858 {
859 // only plated holes link to subnet
860 iter->second->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::HOLE, m_layerName,
861 m_featuresList.size() - 1 );
862
863 if( !m_featuresList.empty() )
865 }
866 else
867 {
868 if( !m_featuresList.empty() )
870 }
871 }
872 }
873 // AddSystemAttribute( *m_featuresList.back(),
874 // ODB_ATTR::GEOMETRY{ "PAD_xxxx" } );
875 };
876
877 for( BOARD_ITEM* item : aItems )
878 {
879 switch( item->Type() )
880 {
881 case PCB_TRACE_T:
882 case PCB_ARC_T:
883 case PCB_VIA_T:
884 add_track( static_cast<PCB_TRACK*>( item ) );
885 break;
886
887 case PCB_ZONE_T:
888 add_zone( static_cast<ZONE*>( item ) );
889 break;
890
891 case PCB_PAD_T:
892 add_pad( static_cast<PAD*>( item ) );
893 break;
894
895 case PCB_SHAPE_T:
896 add_shape( static_cast<PCB_SHAPE*>( item ) );
897 break;
898
899 case PCB_TEXT_T:
900 case PCB_FIELD_T:
901 add_text( item );
902 break;
903
904 case PCB_TEXTBOX_T:
905 add_text( item );
906
907 if( static_cast<PCB_TEXTBOX*>( item )->IsBorderEnabled() )
908 add_shape( static_cast<PCB_TEXTBOX*>( item ) );
909
910 break;
911
912 case PCB_TABLE_T:
913 {
914 PCB_TABLE* table = static_cast<PCB_TABLE*>( item );
915
916 for( PCB_TABLECELL* cell : table->GetCells() )
917 add_text( cell );
918
919 table->DrawBorders(
920 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const STROKE_PARAMS& aStroke )
921 {
922 int lineWidth = aStroke.GetWidth();
923
924 if( lineWidth > 0 )
925 AddFeatureLine( aPt1, aPt2, lineWidth );
926 } );
927
928 break;
929 }
930
932 case PCB_DIM_LEADER_T:
933 case PCB_DIM_CENTER_T:
934 case PCB_DIM_RADIAL_T:
936 add_dimension( static_cast<PCB_DIMENSION_BASE*>( item ) );
937 break;
938
939 case PCB_TARGET_T:
940 //TODO: Add support for targets
941 break;
942
943 case PCB_BARCODE_T:
944 {
945 const PCB_BARCODE* barcode = static_cast<const PCB_BARCODE*>( item );
946 SHAPE_POLY_SET poly_set;
947
948 barcode->TransformShapeToPolygon( poly_set, aLayer, 0, m_board->GetDesignSettings().m_MaxError,
949 ERROR_INSIDE );
950 poly_set.Fracture();
951
952 for( int ii = 0; ii < poly_set.OutlineCount(); ++ii )
953 AddContour( poly_set, ii, FILL_T::FILLED_SHAPE );
954
955 break;
956 }
957
958 default:
959 break;
960 }
961 }
962}
963
964
966{
967 if( !aVia->FlashLayer( aLayer ) )
968 return;
969
970 PAD dummy( nullptr ); // default pad shape is circle
971 dummy.SetPadstack( aVia->Padstack() );
972 dummy.SetPosition( aVia->GetStart() );
973
974 AddPadShape( dummy, aLayer );
975}
976
977
979{
980 PAD dummy( nullptr ); // default pad shape is circle
981 int hole = aVia->GetDrillValue();
982 dummy.SetPosition( aVia->GetStart() );
983 dummy.SetSize( PADSTACK::ALL_LAYERS, VECTOR2I( hole, hole ) );
984
985 AddPadShape( dummy, aLayer );
986}
987
988
989void FEATURES_MANAGER::GenerateProfileFeatures( std::ostream& ost ) const
990{
991 ost << "UNITS=" << PCB_IO_ODBPP::m_unitsStr << std::endl;
992 ost << "#\n#Num Features\n#" << std::endl;
993 ost << "F " << m_featuresList.size() << std::endl;
994
995 if( m_featuresList.empty() )
996 return;
997
998 ost << "#\n#Layer features\n#" << std::endl;
999
1000 for( const auto& feat : m_featuresList )
1001 {
1002 feat->WriteFeatures( ost );
1003 }
1004}
1005
1006
1007void FEATURES_MANAGER::GenerateFeatureFile( std::ostream& ost ) const
1008{
1009 ost << "UNITS=" << PCB_IO_ODBPP::m_unitsStr << std::endl;
1010 ost << "#\n#Num Features\n#" << std::endl;
1011 ost << "F " << m_featuresList.size() << std::endl << std::endl;
1012
1013 if( m_featuresList.empty() )
1014 return;
1015
1016 ost << "#\n#Feature symbol names\n#" << std::endl;
1017
1018 for( const auto& [n, name] : m_allSymMap )
1019 {
1020 ost << "$" << n << " " << name << std::endl;
1021 }
1022
1023 WriteAttributes( ost );
1024
1025 ost << "#\n#Layer features\n#" << std::endl;
1026
1027 for( const auto& feat : m_featuresList )
1028 {
1029 feat->WriteFeatures( ost );
1030 }
1031}
1032
1033
1034void ODB_FEATURE::WriteFeatures( std::ostream& ost )
1035{
1036 switch( GetFeatureType() )
1037 {
1038 case FEATURE_TYPE::LINE: ost << "L "; break;
1039
1040 case FEATURE_TYPE::ARC: ost << "A "; break;
1041
1042 case FEATURE_TYPE::PAD: ost << "P "; break;
1043
1044 case FEATURE_TYPE::SURFACE: ost << "S "; break;
1045 default: return;
1046 }
1047
1048 WriteRecordContent( ost );
1049 ost << std::endl;
1050}
1051
1052
1053void ODB_LINE::WriteRecordContent( std::ostream& ost )
1054{
1055 ost << m_start.first << " " << m_start.second << " " << m_end.first << " " << m_end.second
1056 << " " << m_symIndex << " P 0";
1057
1058 WriteAttributes( ost );
1059}
1060
1061
1062void ODB_ARC::WriteRecordContent( std::ostream& ost )
1063{
1064 ost << m_start.first << " " << m_start.second << " " << m_end.first << " " << m_end.second
1065 << " " << m_center.first << " " << m_center.second << " " << m_symIndex << " P 0 "
1066 << ( m_direction == ODB_DIRECTION::CW ? "Y" : "N" );
1067
1068 WriteAttributes( ost );
1069}
1070
1071
1072void ODB_PAD::WriteRecordContent( std::ostream& ost )
1073{
1074 ost << m_center.first << " " << m_center.second << " ";
1075
1076 // TODO: support resize symbol
1077 // ost << "-1" << " " << m_symIndex << " "
1078 // << m_resize << " P 0 ";
1079
1080 ost << m_symIndex << " P 0 ";
1081
1082 if( m_mirror )
1083 ost << "9 " << ODB::Double2String( m_angle.Normalize().AsDegrees() );
1084 else
1085 ost << "8 " << ODB::Double2String( ( ANGLE_360 - m_angle ).Normalize().AsDegrees() );
1086
1087 WriteAttributes( ost );
1088}
1089
1090
1091ODB_SURFACE::ODB_SURFACE( uint32_t aIndex, const SHAPE_POLY_SET::POLYGON& aPolygon,
1092 FILL_T aFillType /*= FILL_T::FILLED_SHAPE*/ ) : ODB_FEATURE( aIndex )
1093{
1094 if( !aPolygon.empty() && aPolygon[0].PointCount() >= 3 )
1095 {
1096 m_surfaces = std::make_unique<ODB_SURFACE_DATA>( aPolygon );
1097 if( aFillType != FILL_T::NO_FILL )
1098 {
1099 m_surfaces->AddPolygonHoles( aPolygon );
1100 }
1101 }
1102 else
1103 {
1104 delete this;
1105 }
1106}
1107
1108
1109void ODB_SURFACE::WriteRecordContent( std::ostream& ost )
1110{
1111 ost << "P 0";
1112 WriteAttributes( ost );
1113 ost << std::endl;
1114 m_surfaces->WriteData( ost );
1115 ost << "SE";
1116}
1117
1118
1120{
1121 const std::vector<VECTOR2I>& pts = aPolygon[0].CPoints();
1122 if( !pts.empty() )
1123 {
1124 if( m_polygons.empty() )
1125 {
1126 m_polygons.resize( 1 );
1127 }
1128
1129 m_polygons.at( 0 ).reserve( pts.size() );
1130 m_polygons.at( 0 ).emplace_back( pts.back() );
1131
1132 for( size_t jj = 0; jj < pts.size(); ++jj )
1133 {
1134 m_polygons.at( 0 ).emplace_back( pts.at( jj ) );
1135 }
1136 }
1137}
1138
1139
1141{
1142 for( size_t ii = 1; ii < aPolygon.size(); ++ii )
1143 {
1144 wxCHECK2( aPolygon[ii].PointCount() >= 3, continue );
1145
1146 const std::vector<VECTOR2I>& hole = aPolygon[ii].CPoints();
1147
1148 if( hole.empty() )
1149 continue;
1150
1151 if( m_polygons.size() <= ii )
1152 {
1153 m_polygons.resize( ii + 1 );
1154
1155 m_polygons[ii].reserve( hole.size() );
1156 }
1157
1158 m_polygons.at( ii ).emplace_back( hole.back() );
1159
1160 for( size_t jj = 0; jj < hole.size(); ++jj )
1161 {
1162 m_polygons.at( ii ).emplace_back( hole[jj] );
1163 }
1164 }
1165}
1166
1167
1168void ODB_SURFACE_DATA::WriteData( std::ostream& ost ) const
1169{
1170 ODB::CHECK_ONCE is_island;
1171
1172 for( const auto& contour : m_polygons )
1173 {
1174 if( contour.empty() )
1175 continue;
1176
1177 ost << "OB " << ODB::AddXY( contour.back().m_end ).first << " "
1178 << ODB::AddXY( contour.back().m_end ).second << " ";
1179
1180 if( is_island() )
1181 ost << "I";
1182 else
1183 ost << "H";
1184 ost << std::endl;
1185
1186 for( const auto& line : contour )
1187 {
1188 if( SURFACE_LINE::LINE_TYPE::SEGMENT == line.m_type )
1189 ost << "OS " << ODB::AddXY( line.m_end ).first << " "
1190 << ODB::AddXY( line.m_end ).second << std::endl;
1191 else
1192 ost << "OC " << ODB::AddXY( line.m_end ).first << " "
1193 << ODB::AddXY( line.m_end ).second << " " << ODB::AddXY( line.m_center ).first
1194 << " " << ODB::AddXY( line.m_center ).second << " "
1195 << ( line.m_direction == ODB_DIRECTION::CW ? "Y" : "N" ) << std::endl;
1196 }
1197 ost << "OE" << std::endl;
1198 }
1199}
const char * name
@ ERROR_OUTSIDE
@ ERROR_INSIDE
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
void WriteAttributes(std::ostream &ost, const std::string &prefix="") const
void AddSystemAttribute(Tr &r, Ta v)
void WriteAttributes(std::ostream &ost) const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:83
virtual bool IsKnockout() const
Definition board_item.h:382
FOOTPRINT * GetParentFootprint() const
int GetEllipseMinorRadius() const
Definition eda_shape.h:310
const VECTOR2I & GetEllipseCenter() const
Definition eda_shape.h:292
const SHAPE_POLY_SET & GetHatching() const
EDA_ANGLE GetEllipseEndAngle() const
Definition eda_shape.h:338
int GetEllipseMajorRadius() const
Definition eda_shape.h:301
int GetRectangleWidth() const
SHAPE_POLY_SET & GetPolyShape()
EDA_ANGLE GetEllipseRotation() const
Definition eda_shape.h:319
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:185
bool IsHatchedFill() const
Definition eda_shape.h:140
virtual void SetFilled(bool aFlag)
Definition eda_shape.h:152
bool IsSolidFill() const
Definition eda_shape.h:133
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:240
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:190
std::vector< VECTOR2I > GetRectCorners() const
EDA_ANGLE GetEllipseStartAngle() const
Definition eda_shape.h:329
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition eda_shape.h:404
int GetRectangleHeight() const
bool IsClockwiseArc() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:89
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:294
bool IsMultilineAllowed() const
Definition eda_text.h:218
virtual bool IsVisible() const
Definition eda_text.h:208
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:400
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition eda_text.cpp:667
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:252
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:461
void GetLinePositions(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition eda_text.cpp:943
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition eda_text.h:121
void AddPadShape(const PAD &aPad, PCB_LAYER_ID aLayer)
void AddShape(const PCB_SHAPE &aShape, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
uint32_t AddRectSymbol(const wxString &aWidth, const wxString &aHeight)
void AddVia(const PCB_VIA *aVia, PCB_LAYER_ID aLayer)
PCB_IO_ODBPP * GetODBPlugin()
void InitFeatureList(PCB_LAYER_ID aLayer, std::vector< BOARD_ITEM * > &aItems)
void AddFeatureLine(const VECTOR2I &aStart, const VECTOR2I &aEnd, uint64_t aWidth)
void AddFeatureArc(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, uint64_t aWidth, ODB_DIRECTION aDirection)
std::map< uint32_t, wxString > m_allSymMap
void GenerateFeatureFile(std::ostream &ost) const
void AddViaDrillHole(const PCB_VIA *aVia, PCB_LAYER_ID aLayer)
void AddPadCircle(const VECTOR2I &aCenter, uint64_t aDiameter, const EDA_ANGLE &aAngle, bool aMirror, double aResize=1.0)
void AddFeatureSurface(const SHAPE_POLY_SET::POLYGON &aPolygon, FILL_T aFillType=FILL_T::FILLED_SHAPE)
uint32_t AddRoundRectSymbol(const wxString &aWidth, const wxString &aHeight, const wxString &aRadius)
wxString m_layerName
uint32_t AddOvalSymbol(const wxString &aWidth, const wxString &aHeight)
void GenerateProfileFeatures(std::ostream &ost) const
std::list< std::unique_ptr< ODB_FEATURE > > m_featuresList
void AddFeature(Args &&... args)
uint32_t AddCircleSymbol(const wxString &aDiameter)
Definition odb_feature.h:96
uint32_t AddChamferRectSymbol(const wxString &aWidth, const wxString &aHeight, const wxString &aRadius, int aPositions)
uint32_t AddRoundDonutSymbol(const wxString &aOuterDim, const wxString &aInnerDim)
bool AddContour(const SHAPE_POLY_SET &aPolySet, int aOutline=0, FILL_T aFillType=FILL_T::FILLED_SHAPE)
bool IsFlipped() const
Definition footprint.h:617
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition lset.h:63
std::pair< wxString, wxString > m_end
std::pair< wxString, wxString > m_start
uint32_t m_symIndex
virtual void WriteRecordContent(std::ostream &ost) override
ODB_DIRECTION m_direction
std::pair< wxString, wxString > m_center
virtual void WriteRecordContent(std::ostream &ost)=0
virtual void WriteFeatures(std::ostream &ost)
virtual FEATURE_TYPE GetFeatureType()=0
ODB_FEATURE(uint32_t aIndex)
virtual void WriteRecordContent(std::ostream &ost) override
std::pair< wxString, wxString > m_start
std::pair< wxString, wxString > m_end
uint32_t m_symIndex
uint32_t m_symIndex
virtual void WriteRecordContent(std::ostream &ost) override
bool m_mirror
EDA_ANGLE m_angle
std::pair< wxString, wxString > m_center
void WriteData(std::ostream &ost) const
std::vector< std::vector< SURFACE_LINE > > m_polygons
ODB_SURFACE_DATA(const SHAPE_POLY_SET::POLYGON &aPolygon)
void AddPolygonHoles(const SHAPE_POLY_SET::POLYGON &aPolygon)
std::unique_ptr< ODB_SURFACE_DATA > m_surfaces
virtual void WriteRecordContent(std::ostream &ost) override
ODB_SURFACE(uint32_t aIndex, const SHAPE_POLY_SET::POLYGON &aPolygon, FILL_T aFillType=FILL_T::FILLED_SHAPE)
@ NORMAL
Shape is the same on all layers.
Definition padstack.h:171
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
Definition pad.h:61
void MergePrimitivesAsPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
Definition pad.cpp:3625
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1136
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:202
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:2945
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1951
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:287
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1723
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:840
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:823
VECTOR2I GetSolderPasteMargin(PCB_LAYER_ID aLayer) const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition pad.cpp:2014
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1831
const VECTOR2I & GetMid() const
Definition pcb_track.h:286
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the barcode (text + symbol shapes) to polygonal geometry suitable for filling/collision tests...
Abstract dimension API.
std::map< std::pair< PCB_LAYER_ID, ZONE * >, EDA_DATA::SUB_NET_PLANE * > & GetPlaneSubnetMap()
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > & GetViaTraceSubnetMap()
std::map< const PAD *, EDA_DATA::SUB_NET_TOEPRINT * > & GetPadSubnetMap()
static std::string m_unitsStr
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_shape.h:78
void SetWidth(int aWidth) override
int GetWidth() const override
void SetShape(SHAPE_T aShape) override
Definition pcb_shape.h:200
void SetEnd(const VECTOR2I &aEnd) override
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
void SetStart(const VECTOR2I &aStart) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
const VECTOR2I & GetStart() const
Definition pcb_track.h:93
const VECTOR2I & GetEnd() const
Definition pcb_track.h:90
virtual int GetWidth() const
Definition pcb_track.h:87
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
const PADSTACK & Padstack() const
Definition pcb_track.h:410
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
Definition seg.h:38
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
int GetRadius() const
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
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.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
int OutlineCount() const
Return the number of outlines in the set.
void InflateWithLinkedHoles(int aFactor, CORNER_STRATEGY aCornerStrategy, int aMaxError)
Perform outline inflation/deflation, using round corners.
void Move(const VECTOR2I &aVector) override
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
SHAPE_POLY_SET CloneDropTriangulation() const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const SEG & GetSeg() const
Simple container to manage line stroke parameters.
int GetWidth() const
Handle a list of polygons defining a copper zone.
Definition zone.h:70
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
@ ROUND_ALL_CORNERS
All angles are rounded.
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:417
@ ELLIPSE
Definition eda_shape.h:52
@ SEGMENT
Definition eda_shape.h:46
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:47
@ ELLIPSE_ARC
Definition eda_shape.h:53
FILL_T
Definition eda_shape.h:59
@ FILLED_SHAPE
Fill with object color.
Definition eda_shape.h:61
int GetPenSizeForBold(int aTextSize)
Definition gr_text.cpp:33
const wxChar *const traceOdbppIo
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_Paste
Definition layer_ids.h:100
@ B_Mask
Definition layer_ids.h:94
@ F_Mask
Definition layer_ids.h:93
@ B_Paste
Definition layer_ids.h:101
@ UNDEFINED_LAYER
Definition layer_ids.h:57
std::pair< wxString, wxString > AddXY(const VECTOR2I &aVec)
Definition odb_util.cpp:191
wxString Double2String(double aVal)
Definition odb_util.cpp:151
wxString SymDouble2String(double aVal)
Definition odb_util.cpp:179
VECTOR2I GetShapePosition(const PCB_SHAPE &aShape)
Definition odb_util.cpp:202
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
ODB_DIRECTION
Definition odb_feature.h:34
@ PTH
Plated through hole pad.
Definition padstack.h:98
@ CHAMFERED_RECT
Definition padstack.h:60
@ ROUNDRECT
Definition padstack.h:57
@ TRAPEZOID
Definition padstack.h:56
@ RECTANGLE
Definition padstack.h:54
BARCODE class definition.
@ SH_CIRCLE
circle
Definition shape.h:46
@ SH_SEGMENT
line segment
Definition shape.h:44
std::vector< FAB_LAYER_COLOR > dummy
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
VECTOR2I center
const SHAPE_LINE_CHAIN chain
int radius
VECTOR2I end
wxLogTrace helper definitions.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:81
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:99
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:96
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:90
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:97
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:86
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:101
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:85
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:83
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:94
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:100
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:95
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:80
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:91
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:87
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:98
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683