KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_shape.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#include "pcb_shape.h"
24
25#include <google/protobuf/any.pb.h>
26#include <magic_enum.hpp>
27
28#include <bitmaps.h>
29#include <macros.h>
30#include <pcb_edit_frame.h>
33#include <board.h>
34#include <footprint.h>
35#include <lset.h>
36#include <pad.h>
37#include <base_units.h>
38#include <trigo.h>
39#include <drc/drc_engine.h>
45#include <pcb_painter.h>
47#include <api/board/board_types.pb.h>
48#include <api/api_enums.h>
49#include <api/api_utils.h>
50#include <properties/property.h>
52
53
54// Move every vertex of the polygon through the transform. SetVertex turns the arc a vertex
55// belongs to into segments, so a uniform transform maps each arc as an arc and only a skewing
56// one is left to flatten them.
57static void transformPolyVertices( SHAPE_POLY_SET& aPoly, const TRANSFORM_TRS& aXform, bool aInverse )
58{
59 auto map = [&]( const VECTOR2I& aPt )
60 {
61 return aInverse ? aXform.InverseApply( aPt ) : aXform.Apply( aPt );
62 };
63
64 if( !aXform.IsUniformScale() )
65 {
66 for( auto it = aPoly.IterateWithHoles(); it; it++ )
67 aPoly.SetVertex( it.GetIndex(), map( *it ) );
68
69 return;
70 }
71
72 // a mirroring transform reverses the sweep of an arc
73 const bool mirrored = aXform.GetScaleX() * aXform.GetScaleY() < 0;
74
75 auto transformChain = [&]( SHAPE_LINE_CHAIN& aChain )
76 {
77 SHAPE_LINE_CHAIN mapped;
78
79 for( int i = 0; i < aChain.PointCount(); i++ )
80 {
81 int arcIndex = aChain.ArcIndex( i );
82
83 if( arcIndex < 0 )
84 {
85 mapped.Append( map( aChain.CPoint( i ) ) );
86 continue;
87 }
88
89 const SHAPE_ARC& arc = aChain.Arc( arcIndex );
91
92 // three points fix an arc exactly, except a full circle whose ends coincide
93 if( arc.GetP0() != arc.GetP1() )
94 mapped.Append( SHAPE_ARC( map( arc.GetP0() ), map( arc.GetArcMid() ), map( arc.GetP1() ), 0 ) );
95 else
96 mapped.Append( SHAPE_ARC( map( arc.GetCenter() ), map( arc.GetP0() ), mirrored ? -sweep : sweep ) );
97
98 while( i + 1 < aChain.PointCount() && aChain.ArcIndex( i + 1 ) == arcIndex )
99 i++;
100 }
101
102 mapped.SetClosed( aChain.IsClosed() );
103 aChain = mapped;
104 };
105
106 for( int i = 0; i < aPoly.OutlineCount(); i++ )
107 {
108 transformChain( aPoly.Outline( i ) );
109
110 for( int j = 0; j < aPoly.HoleCount( i ); j++ )
111 transformChain( aPoly.Hole( i, j ) );
112 }
113}
114
115
116namespace
117{
118struct BOARD_ELLIPSE
119{
120 double major;
121 double minor;
122 EDA_ANGLE rotation;
123 EDA_ANGLE startShift;
124};
125
126
127// SVD of a 2x2 matrix into ellipse major / minor / rotation and the arc angle shift.
128static BOARD_ELLIPSE decompose2x2( double m00, double m01, double m10, double m11 )
129{
130 const double A = m00 * m00 + m10 * m10;
131 const double B = m00 * m01 + m10 * m11;
132 const double C = m01 * m01 + m11 * m11;
133
134 const double diff = A - C;
135 const double rad = std::hypot( diff, 2.0 * B );
136 const double lambda1 = ( A + C + rad ) * 0.5;
137 const double lambda2 = ( A + C - rad ) * 0.5;
138
139 const double sigma1 = std::sqrt( std::max( 0.0, lambda1 ) );
140 const double sigma2 = std::sqrt( std::max( 0.0, lambda2 ) );
141
142 double v0x;
143 double v0y;
144
145 if( std::abs( B ) > 1e-12 )
146 {
147 v0x = lambda1 - C;
148 v0y = B;
149 }
150 else if( A >= C )
151 {
152 v0x = 1.0;
153 v0y = 0.0;
154 }
155 else
156 {
157 v0x = 0.0;
158 v0y = 1.0;
159 }
160
161 const double vn = std::hypot( v0x, v0y );
162 v0x /= vn;
163 v0y /= vn;
164
165 double u0x = 1.0;
166 double u0y = 0.0;
167
168 if( sigma1 > 1e-12 )
169 {
170 u0x = ( m00 * v0x + m01 * v0y ) / sigma1;
171 u0y = ( m10 * v0x + m11 * v0y ) / sigma1;
172 }
173
174 BOARD_ELLIPSE out;
175 out.major = sigma1;
176 out.minor = sigma2;
177 out.rotation = EDA_ANGLE( std::atan2( u0y, u0x ), RADIANS_T );
178 out.startShift = EDA_ANGLE( -std::atan2( v0y, v0x ), RADIANS_T );
179 return out;
180}
181
182
183// Board ellipse from a lib ellipse: M = R(theta) * diag(sx, sy) * R(phi) * diag(a, b).
184static BOARD_ELLIPSE decomposeBoardEllipse( const TRANSFORM_TRS& aXform, int aLibMajor, int aLibMinor,
185 const EDA_ANGLE& aLibRotation )
186{
187 const double sx = aXform.GetScaleX();
188 const double sy = aXform.GetScaleY();
189 // Lib rotation and xform rotation use opposite signs, negate to match.
190 const double theta = -aXform.GetRotate().AsRadians();
191 const double phi = aLibRotation.AsRadians();
192 const double cTheta = std::cos( theta );
193 const double sTheta = std::sin( theta );
194 const double cPhi = std::cos( phi );
195 const double sPhi = std::sin( phi );
196 const double a = aLibMajor;
197 const double b = aLibMinor;
198
199 const double m00 = a * ( sx * cTheta * cPhi - sy * sTheta * sPhi );
200 const double m01 = -b * ( sx * cTheta * sPhi + sy * sTheta * cPhi );
201 const double m10 = a * ( sx * sTheta * cPhi + sy * cTheta * sPhi );
202 const double m11 = b * ( -sx * sTheta * sPhi + sy * cTheta * cPhi );
203
204 return decompose2x2( m00, m01, m10, m11 );
205}
206
207
208// Inverse of decomposeBoardEllipse: lib ellipse from a board ellipse.
209static BOARD_ELLIPSE composeLibEllipse( const TRANSFORM_TRS& aXform, double aBoardMajor, double aBoardMinor,
210 const EDA_ANGLE& aBoardRotation )
211{
212 const double sx = aXform.GetScaleX();
213 const double sy = aXform.GetScaleY();
214 const double theta = -aXform.GetRotate().AsRadians();
215 const double beta = aBoardRotation.AsRadians();
216
217 const double li00 = std::cos( theta ) / sx;
218 const double li01 = std::sin( theta ) / sx;
219 const double li10 = -std::sin( theta ) / sy;
220 const double li11 = std::cos( theta ) / sy;
221
222 const double e00 = aBoardMajor * std::cos( beta );
223 const double e01 = -aBoardMinor * std::sin( beta );
224 const double e10 = aBoardMajor * std::sin( beta );
225 const double e11 = aBoardMinor * std::cos( beta );
226
227 return decompose2x2( li00 * e00 + li01 * e10, li00 * e01 + li01 * e11, li10 * e00 + li11 * e10,
228 li10 * e01 + li11 * e11 );
229}
230} // namespace
231
232
233PCB_SHAPE::PCB_SHAPE( BOARD_ITEM* aParent, KICAD_T aItemType, SHAPE_T aShapeType ) :
234 BOARD_CONNECTED_ITEM( aParent, aItemType ),
235 EDA_SHAPE( aShapeType, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL ),
236 m_libStart( 0, 0 ),
237 m_libEnd( 0, 0 ),
239 m_libArcMid( 0, 0 ),
240 m_libBezierC1( 0, 0 ),
241 m_libBezierC2( 0, 0 ),
242 m_libEllipseCenter( 0, 0 ),
248 m_libShape( aShapeType )
249{
250 m_hasSolderMask = false;
251}
252
253
256 EDA_SHAPE( shapetype, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL ),
257 m_libStart( 0, 0 ),
258 m_libEnd( 0, 0 ),
260 m_libArcMid( 0, 0 ),
261 m_libBezierC1( 0, 0 ),
262 m_libBezierC2( 0, 0 ),
263 m_libEllipseCenter( 0, 0 ),
269 m_libShape( shapetype )
270{
271 m_hasSolderMask = false;
272}
273
274
278
279
280void PCB_SHAPE::CopyFrom( const BOARD_ITEM* aOther )
281{
282 wxCHECK( aOther && aOther->Type() == PCB_SHAPE_T, /* void */ );
283 *this = *static_cast<const PCB_SHAPE*>( aOther );
284}
285
286
287void PCB_SHAPE::Serialize( google::protobuf::Any &aContainer ) const
288{
289 using namespace kiapi::common;
290 using namespace kiapi::board::types;
291 BoardGraphicShape msg;
292
294 PackNet( msg.mutable_net() );
295 msg.mutable_id()->set_value( m_Uuid.AsStdString() );
296 msg.set_locked( IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
297
298 EDA_SHAPE::Serialize( *msg.mutable_shape(), pcbIUScale );
299
300 if( IsProxyItem() )
301 {
302 PadCustomShapeOptions* options = msg.mutable_pad_custom_shape_options();
303
304 switch( GetShape() )
305 {
306 case SHAPE_T::RECTANGLE: options->set_is_number_box( true ); break;
307 case SHAPE_T::SEGMENT: options->set_is_thermal_spoke_template( true ); break;
308 default: wxFAIL_MSG( wxT( "Unexpected proxy shape type" ) ); break;
309 }
310 }
311
312 if( FOOTPRINT* parent = GetParentFootprint() )
313 msg.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
314 else if( const BOARD* board = GetBoard() )
315 msg.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
316
317 if( HasSolderMask() )
318 {
319 SolderMaskOverrides* sm = msg.mutable_solder_mask();
320 sm->set_expose_copper( true );
321
322 if( GetLocalSolderMaskMargin().has_value() )
323 sm->mutable_solder_mask_margin()->set_value_nm( GetLocalSolderMaskMargin().value() );
324 }
325
326 kiapi::common::PackCustomProperties( msg.mutable_custom_properties(), *this );
327
328 if( !aContainer.PackFrom( msg ) )
329 wxFAIL_MSG( wxT( "Failed to pack PCB_SHAPE" ) );
330}
331
332
333bool PCB_SHAPE::Deserialize( const google::protobuf::Any &aContainer )
334{
335 using namespace kiapi::common;
336 using namespace kiapi::board::types;
337
338 BoardGraphicShape msg;
339
340 if( !aContainer.UnpackTo( &msg ) )
341 return false;
342
343 // Initialize everything to a known state that doesn't get touched by every
344 // codepath below, to make sure the equality operator is consistent
345 m_start = {};
346 m_end = {};
347 m_arcCenter = {};
348 m_arcMidData = {};
349 m_bezierC1 = {};
350 m_bezierC2 = {};
351 m_editState = 0;
352 m_proxyItem = false;
353 m_endsSwapped = false;
354
355 SetUuidDirect( KIID( msg.id().value() ) );
356 SetLocked( msg.locked() == types::LS_LOCKED );
358 UnpackNet( msg.net() );
359 kiapi::common::UnpackCustomProperties( msg.custom_properties(), *this );
360
361 EDA_SHAPE::Deserialize( msg.shape(), pcbIUScale );
362
363 if( msg.has_pad_custom_shape_options() )
364 {
365 switch( msg.pad_custom_shape_options().role_case() )
366 {
367 case PadCustomShapeOptions::kIsNumberBox:
369 m_proxyItem = true;
370
371 break;
372
373 case PadCustomShapeOptions::kIsThermalSpokeTemplate:
374 if( GetShape() == SHAPE_T::SEGMENT )
375 m_proxyItem = true;
376
377 break;
378
379 case PadCustomShapeOptions::ROLE_NOT_SET:
380 break;
381 }
382 }
383
384 if( msg.has_solder_mask() )
385 {
386 SetHasSolderMask( msg.solder_mask().expose_copper() );
387
388 if( msg.solder_mask().has_solder_mask_margin() )
389 SetLocalSolderMaskMargin( msg.solder_mask().solder_mask_margin().value_nm() );
390 else
392 }
393 else
394 {
395 SetHasSolderMask( false );
397 }
398
399 return true;
400}
401
402
403bool PCB_SHAPE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
404{
405 if( BOARD_ITEM::IsType( aScanTypes ) )
406 return true;
407
408 bool sametype = false;
409
410 for( KICAD_T scanType : aScanTypes )
411 {
412 if( scanType == PCB_LOCATE_BOARD_EDGE_T )
413 sametype = m_layer == Edge_Cuts;
414 else if( scanType == PCB_SHAPE_LOCATE_ARC_T )
415 sametype = m_shape == SHAPE_T::ARC;
416 else if( scanType == PCB_SHAPE_LOCATE_CIRCLE_T )
417 sametype = m_shape == SHAPE_T::CIRCLE;
418 else if( scanType == PCB_SHAPE_LOCATE_RECT_T )
419 sametype = m_shape == SHAPE_T::RECTANGLE;
420 else if( scanType == PCB_SHAPE_LOCATE_SEGMENT_T )
421 sametype = m_shape == SHAPE_T::SEGMENT;
422 else if( scanType == PCB_SHAPE_LOCATE_POLY_T )
423 sametype = m_shape == SHAPE_T::POLY;
424 else if( scanType == PCB_SHAPE_LOCATE_BEZIER_T )
425 sametype = m_shape == SHAPE_T::BEZIER;
426 else if( scanType == PCB_SHAPE_LOCATE_ELLIPSE_T )
427 sametype = m_shape == SHAPE_T::ELLIPSE;
428 else if( scanType == PCB_SHAPE_LOCATE_ELLIPSE_ARC_T )
429 sametype = m_shape == SHAPE_T::ELLIPSE_ARC;
430
431 if( sametype )
432 return true;
433 }
434
435 return false;
436}
437
438
440{
441 // Only board-level copper shapes are connectable
442 return IsOnCopperLayer() && !GetParentFootprint();
443}
444
445
447{
448 BOARD_ITEM::SetLayer( aLayer );
449
450 if( !IsOnCopperLayer() )
451 SetNetCode( -1 );
452}
453
454
456{
457 int margin = 0;
458
459 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine
460 && GetBoard()->GetDesignSettings().m_DRCEngine->HasRulesForConstraintType( SOLDER_MASK_EXPANSION_CONSTRAINT ) )
461 {
462 DRC_CONSTRAINT constraint;
463 std::shared_ptr<DRC_ENGINE> drcEngine = GetBoard()->GetDesignSettings().m_DRCEngine;
464
465 constraint = drcEngine->EvalRules( SOLDER_MASK_EXPANSION_CONSTRAINT, this, nullptr, m_layer );
466
467 if( constraint.m_Value.HasOpt() )
468 margin = constraint.m_Value.Opt();
469 }
470 else if( m_solderMaskMargin.has_value() )
471 {
472 margin = m_solderMaskMargin.value();
473 }
474 else if( const BOARD* board = GetBoard() )
475 {
476 margin = board->GetDesignSettings().m_SolderMaskExpansion;
477 }
478
479 // Ensure the resulting mask opening has a non-negative size
480 if( margin < 0 && !IsSolidFill() )
481 margin = std::max( margin, -GetWidth() / 2 );
482
483 return margin;
484}
485
486
488{
489 if( aLayer == m_layer )
490 {
491 return true;
492 }
493
495 && ( ( aLayer == F_Mask && m_layer == F_Cu )
496 || ( aLayer == B_Mask && m_layer == B_Cu ) ) )
497 {
498 return true;
499 }
500
501 return false;
502}
503
504
506{
507 LSET layermask( { m_layer } );
508
509 if( m_hasSolderMask )
510 {
511 if( layermask.test( F_Cu ) )
512 layermask.set( F_Mask );
513
514 if( layermask.test( B_Cu ) )
515 layermask.set( B_Mask );
516 }
517
518 return layermask;
519}
520
521
522void PCB_SHAPE::SetLayerSet( const LSET& aLayerSet )
523{
524 aLayerSet.RunOnLayers(
525 [&]( PCB_LAYER_ID layer )
526 {
527 if( IsCopperLayer( layer ) )
528 SetLayer( layer );
529 else if( IsSolderMaskLayer( layer ) )
530 SetHasSolderMask( true );
531 } );
532}
533
534
535std::vector<VECTOR2I> PCB_SHAPE::GetConnectionPoints() const
536{
537 std::vector<VECTOR2I> ret;
538
539 // For filled shapes, we may as well use a centroid
540 if( IsSolidFill() )
541 {
542 ret.emplace_back( GetCenter() );
543 return ret;
544 }
545
546 switch( m_shape )
547 {
548 case SHAPE_T::CIRCLE:
549 {
550 const CIRCLE circle( GetCenter(), GetRadius() );
551
552 for( const TYPED_POINT2I& pt : KIGEOM::GetCircleKeyPoints( circle, false ) )
553 ret.emplace_back( pt.m_point );
554
555 break;
556 }
557
558 case SHAPE_T::ARC:
559 ret.emplace_back( GetArcMid() );
561 case SHAPE_T::SEGMENT:
562 case SHAPE_T::BEZIER:
563 ret.emplace_back( GetStart() );
564 ret.emplace_back( GetEnd() );
565 break;
566
567 case SHAPE_T::POLY:
568 for( auto iter = GetPolyShape().CIterate(); iter; ++iter )
569 ret.emplace_back( *iter );
570
571 break;
572
574 for( const VECTOR2I& pt : GetRectCorners() )
575 ret.emplace_back( pt );
576
577 break;
578
579 case SHAPE_T::ELLIPSE:
580 {
581 const double phi = GetEllipseRotation().AsRadians();
582 const double cosPhi = std::cos( phi );
583 const double sinPhi = std::sin( phi );
584 const int a = GetEllipseMajorRadius();
585 const int b = GetEllipseMinorRadius();
586 const VECTOR2I c = GetEllipseCenter();
587
588 ret.emplace_back( c + VECTOR2I( KiROUND( a * cosPhi ), KiROUND( a * sinPhi ) ) );
589 ret.emplace_back( c + VECTOR2I( KiROUND( -a * cosPhi ), KiROUND( -a * sinPhi ) ) );
590 ret.emplace_back( c + VECTOR2I( KiROUND( -b * sinPhi ), KiROUND( b * cosPhi ) ) );
591 ret.emplace_back( c + VECTOR2I( KiROUND( b * sinPhi ), KiROUND( -b * cosPhi ) ) );
592 break;
593 }
594
596 {
597 const double a = GetEllipseMajorRadius();
598 const double b = GetEllipseMinorRadius();
599 const double phi = GetEllipseRotation().AsRadians();
600 const double cosPhi = std::cos( phi );
601 const double sinPhi = std::sin( phi );
602 const VECTOR2I c = GetEllipseCenter();
603
604 auto eval = [&]( double theta ) -> VECTOR2I
605 {
606 const double lx = a * std::cos( theta );
607 const double ly = b * std::sin( theta );
608 return c + VECTOR2I( KiROUND( lx * cosPhi - ly * sinPhi ), KiROUND( lx * sinPhi + ly * cosPhi ) );
609 };
610
611 double thetaStart = GetEllipseStartAngle().AsRadians();
612 double thetaEnd = GetEllipseEndAngle().AsRadians();
613
614 if( thetaEnd < thetaStart )
615 thetaEnd += 2.0 * M_PI;
616
617 ret.emplace_back( eval( thetaStart ) );
618 ret.emplace_back( eval( thetaEnd ) );
619 ret.emplace_back( eval( 0.5 * ( thetaStart + thetaEnd ) ) );
620 break;
621 }
622
625 break;
626 }
627
628 return ret;
629}
630
631
633{
634 // Force update; we don't bother to propagate damage from all the things that might
635 // knock-out parts of our hatching.
636 m_hatchingDirty = true;
637
639}
640
641
643{
644 SHAPE_POLY_SET knockouts;
645
646 if( !GetBoard() )
647 return knockouts;
648
649 PCB_LAYER_ID layer = GetLayer();
650 BOX2I bbox = GetBoundingBox();
651 int maxError = ARC_LOW_DEF;
652
653 auto knockoutItem =
654 [&]( BOARD_ITEM* item )
655 {
656 int margin = GetHatchLineSpacing() / 2;
657
658 if( item->Type() == PCB_TEXTBOX_T )
659 margin = 0;
660
661 item->TransformShapeToPolygon( knockouts, layer, margin, maxError, ERROR_OUTSIDE );
662 };
663
664 for( BOARD_ITEM* item : GetBoard()->Drawings() )
665 {
666 if( item == this )
667 continue;
668
669 if( item->Type() == PCB_FIELD_T
670 || item->Type() == PCB_TEXT_T
671 || item->Type() == PCB_TEXTBOX_T
672 || item->Type() == PCB_SHAPE_T )
673 {
674 if( item->GetLayer() == layer && item->GetBoundingBox().Intersects( bbox ) )
675 knockoutItem( item );
676 }
677 }
678
679 for( FOOTPRINT* footprint : GetBoard()->Footprints() )
680 {
681 if( footprint == GetParentFootprint() )
682 continue;
683
684 // GetCourtyard() returns the front courtyard for any non-back layer, so only knock it
685 // out when the hatched shape actually lives on a courtyard layer.
686 if( layer == F_CrtYd || layer == B_CrtYd )
687 knockouts.Append( footprint->GetCourtyard( layer ) );
688
689 // Knockout footprint fields
690 footprint->RunOnChildren(
691 [&]( BOARD_ITEM* item )
692 {
693 if( ( item->Type() == PCB_FIELD_T || item->Type() == PCB_SHAPE_T )
694 && item->GetLayer() == layer
695 && !( item->Type() == PCB_FIELD_T && !static_cast<PCB_FIELD*>(item)->IsVisible() )
696 && item->GetBoundingBox().Intersects( bbox ) )
697 {
698 knockoutItem( item );
699 }
700 },
702 }
703
704 return knockouts;
705}
706
707
708static double fpScaleLinear( const FOOTPRINT* aFp )
709{
710 if( !aFp )
711 return 1.0;
712
713 const TRANSFORM_TRS& xform = aFp->GetTransform();
714 return ( xform.GetScaleX() + xform.GetScaleY() ) * 0.5;
715}
716
717
719{
720 if( GetParent() && GetParent()->Type() == PCB_PAD_T )
721 return nullptr;
722
723 return GetParentFootprint();
724}
725
726
728{
729 // Clamp negative widths to zero. They mean something in eeschema but break
730 // plotters and exporters here.
731 const int lib = std::max( EDA_SHAPE::GetWidth(), 0 );
732 const double s = fpScaleLinear( transformFp() );
733 return s == 1.0 ? lib : KiROUND( lib * s );
734}
735
736
737void PCB_SHAPE::StyleFromSettings( const BOARD_DESIGN_SETTINGS& aSettings, bool aCheckSide )
738{
739 m_stroke.SetWidth( aSettings.GetLineThickness( GetLayer() ) );
740}
741
742
744{
745 // For some shapes return the visual center, but for not filled polygonal shapes,
746 // the center is usually far from the shape: a point on the outline is better
747
748 switch( m_shape )
749 {
750 case SHAPE_T::CIRCLE:
751 if( !IsAnyFill() )
752 return VECTOR2I( GetCenter().x + GetRadius(), GetCenter().y );
753 else
754 return GetCenter();
755
757 if( !IsAnyFill() )
758 return GetStart();
759 else
760 return GetCenter();
761
762 case SHAPE_T::POLY:
763 if( !IsAnyFill() )
764 {
765 VECTOR2I pos = GetPolyShape().Outline(0).CPoint(0);
766 return VECTOR2I( pos.x, pos.y );
767 }
768 else
769 {
770 return GetCenter();
771 }
772
773 case SHAPE_T::ARC:
774 return GetArcMid();
775
776 case SHAPE_T::BEZIER:
777 return GetStart();
778
779 default:
780 return GetCenter();
781 }
782}
783
784
785std::vector<VECTOR2I> PCB_SHAPE::GetCorners() const
786{
787 std::vector<VECTOR2I> pts;
788
790 {
791 pts = GetRectCorners();
792 }
793 else if( GetShape() == SHAPE_T::POLY )
794 {
795 for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii )
796 {
797 for( const VECTOR2I& pt : GetPolyShape().Outline( ii ).CPoints() )
798 pts.emplace_back( pt );
799 }
800 }
801 else
802 {
804 }
805
806 while( pts.size() < 4 )
807 pts.emplace_back( pts.back() + VECTOR2I( 10, 10 ) );
808
809 return pts;
810}
811
812
813void PCB_SHAPE::Move( const VECTOR2I& aMoveVector )
814{
815 move( aMoveVector );
817}
818
819
820void PCB_SHAPE::Scale( double aScale )
821{
822 scale( aScale );
823}
824
825
827{
829 {
830 VECTOR2I start = GetStart();
831 VECTOR2I end = GetEnd();
832
833 BOX2I rect( start, end - start );
834 rect.Normalize();
835
836 SetStart( rect.GetPosition() );
837 SetEnd( rect.GetEnd() );
838 }
839 else if( m_shape == SHAPE_T::POLY )
840 {
841 auto horizontal =
842 []( const SEG& seg )
843 {
844 return seg.A.y == seg.B.y;
845 };
846
847 auto vertical =
848 []( const SEG& seg )
849 {
850 return seg.A.x == seg.B.x;
851 };
852
853 // Convert a poly back to a rectangle if appropriate
854 if( GetPolyShape().OutlineCount() == 1 && GetPolyShape().Outline( 0 ).SegmentCount() == 4 )
855 {
856 SHAPE_LINE_CHAIN& outline = GetPolyShape().Outline( 0 );
857
858 if( horizontal( outline.Segment( 0 ) )
859 && vertical( outline.Segment( 1 ) )
860 && horizontal( outline.Segment( 2 ) )
861 && vertical( outline.Segment( 3 ) ) )
862 {
864 SetStart( VECTOR2I( std::min( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x ),
865 std::min( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y ) ) );
866 SetEnd( VECTOR2I( std::max( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x ),
867 std::max( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y ) ) );
868 }
869 else if( vertical( outline.Segment( 0 ) )
870 && horizontal( outline.Segment( 1 ) )
871 && vertical( outline.Segment( 2 ) )
872 && horizontal( outline.Segment( 3 ) ) )
873 {
875 SetStart( VECTOR2I( std::min( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x ),
876 std::min( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y ) ) );
877 SetEnd( VECTOR2I( std::max( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x ),
878 std::max( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y ) ) );
879 }
880 }
881 }
882}
883
884
886{
888 {
889 VECTOR2I libStart = GetLibraryStart();
890 VECTOR2I libEnd = GetLibraryEnd();
891
892 if( ( libStart.x > libEnd.x ) || ( libStart.x == libEnd.x && libStart.y < libEnd.y ) )
893 {
894 VECTOR2I s = GetStart();
895 VECTOR2I e = GetEnd();
896 SetStart( e );
897 SetEnd( s );
898 }
899 }
900 else
901 Normalize();
902}
903
904
905void PCB_SHAPE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
906{
907 rotate( aRotCentre, aAngle );
909}
910
911
912void PCB_SHAPE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
913{
914 const FOOTPRINT* fp = transformFp();
915
916 TRANSFORM_TRS xform;
917 bool mirrorLib = false;
918
919 if( fp )
920 {
921 xform = fp->GetTransform();
922 mirrorLib = true;
923 }
924 else if( GetParent() && GetParent()->Type() == PCB_PAD_T && m_shape != m_libShape )
925 {
926 double sx = 1.0, sy = 1.0;
927 static_cast<const PAD*>( static_cast<const BOARD_ITEM*>( GetParent() ) )->GetPrimitiveLibScale( sx, sy );
928 xform.SetScale( sx, sy );
929 mirrorLib = true;
930 }
931
932 if( mirrorLib
935 {
936 const VECTOR2I libCenter = xform.InverseApply( aCentre );
937
938 auto mirrorPt =
939 [&]( VECTOR2I& p )
940 {
941 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
942 p.x = 2 * libCenter.x - p.x;
943 else
944 p.y = 2 * libCenter.y - p.y;
945 };
946
947 if( m_libShape == SHAPE_T::ARC )
948 {
949 mirrorPt( m_libStart );
950 mirrorPt( m_libEnd );
951 mirrorPt( m_libArcMid );
952 std::swap( m_libStart, m_libEnd );
953 }
954 else
955 {
956 mirrorPt( m_libStart );
957 mirrorPt( m_libEnd );
958 }
959
961 {
962 mirrorPt( m_libBezierC1 );
963 mirrorPt( m_libBezierC2 );
964 }
965
966 // Mirror() moves the arcs of the polygon as arcs, which a vertex at a time would turn into segments
968 m_libPoly.Mirror( libCenter, aFlipDirection );
969
971 rebakeFromTransform( xform );
972 return;
973 }
974
975 if( mirrorLib && ( m_libShape == SHAPE_T::ELLIPSE || m_libShape == SHAPE_T::ELLIPSE_ARC ) )
976 {
977 const VECTOR2I libCenter = xform.InverseApply( aCentre );
978
979 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
980 m_libEllipseCenter.x = 2 * libCenter.x - m_libEllipseCenter.x;
981 else
982 m_libEllipseCenter.y = 2 * libCenter.y - m_libEllipseCenter.y;
983
985
986 const EDA_ANGLE oldStart = m_libEllipseStartAngle;
987 const EDA_ANGLE oldEnd = m_libEllipseEndAngle;
988
989 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
990 {
992 m_libEllipseEndAngle = ANGLE_180 - oldStart;
993 }
994 else
995 {
996 m_libEllipseStartAngle = -oldEnd;
997 m_libEllipseEndAngle = -oldStart;
998 }
999
1001 rebakeFromTransform( xform );
1002 return;
1003 }
1004
1005 flip( aCentre, aFlipDirection );
1006
1008 syncLibCoords();
1009}
1010
1011
1012void PCB_SHAPE::SetStart( const VECTOR2I& aStart )
1013{
1014 EDA_SHAPE::SetStart( aStart );
1015 syncLibCoords();
1016}
1017
1018
1019void PCB_SHAPE::SetEnd( const VECTOR2I& aEnd )
1020{
1021 EDA_SHAPE::SetEnd( aEnd );
1022 syncLibCoords();
1023}
1024
1025
1026void PCB_SHAPE::SetCenter( const VECTOR2I& aCenter )
1027{
1028 EDA_SHAPE::SetCenter( aCenter );
1029 syncLibCoords();
1030}
1031
1032
1033void PCB_SHAPE::SetCornerRadius( int aCornerRadius )
1034{
1035 EDA_SHAPE::SetCornerRadius( aCornerRadius );
1036 syncLibCoords();
1037}
1038
1039
1040void PCB_SHAPE::OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
1041 const EDA_ANGLE& aParentRotate )
1042{
1043 RebakeFromLib();
1044}
1045
1046
1047void PCB_SHAPE::SetWidth( int aWidth )
1048{
1049 const double s = fpScaleLinear( transformFp() );
1050
1051 if( s == 1.0 )
1052 m_stroke.SetWidth( aWidth );
1053 else
1054 m_stroke.SetWidth( KiROUND( aWidth / s ) );
1055
1056 m_hatchingDirty = true;
1057}
1058
1059
1061{
1062 m_stroke.SetWidth( aWidth );
1063 m_hatchingDirty = true;
1064}
1065
1066
1068{
1070 s.SetWidth( GetWidth() );
1071 return s;
1072}
1073
1074
1076{
1077 m_stroke = aStroke;
1078 SetWidth( aStroke.GetWidth() );
1079}
1080
1081
1082void PCB_SHAPE::RebakeWithScale( double aScaleX, double aScaleY )
1083{
1084 TRANSFORM_TRS xform;
1085 xform.SetScale( aScaleX, aScaleY );
1086 rebakeFromTransform( xform );
1087}
1088
1089
1091{
1092 const FOOTPRINT* fp = transformFp();
1093
1094 if( !fp )
1095 return;
1096
1098}
1099
1100
1102{
1103 const bool nonUniform = !xform.IsUniformScale();
1104
1106 {
1107 VECTOR2I libCenter = m_libStart;
1108 int libRadius = ( m_libEnd - m_libStart ).EuclideanNorm();
1109 VECTOR2I newCenter = xform.Apply( libCenter );
1110
1111 if( nonUniform )
1112 {
1113 int majorRadius = std::abs( KiROUND( libRadius * xform.GetScaleX() ) );
1114 int minorRadius = std::abs( KiROUND( libRadius * xform.GetScaleY() ) );
1115
1116 EDA_ANGLE rotation = -xform.GetRotate();
1117
1118 if( minorRadius > majorRadius )
1119 {
1120 std::swap( majorRadius, minorRadius );
1121 rotation += EDA_ANGLE( 90.0, DEGREES_T );
1122 }
1123
1125 SetEllipseCenter( newCenter );
1126 SetEllipseMajorRadius( majorRadius );
1127 SetEllipseMinorRadius( minorRadius );
1128 SetEllipseRotation( rotation );
1129 }
1130 else
1131 {
1133 EDA_SHAPE::SetStart( newCenter );
1134 EDA_SHAPE::SetEnd( xform.Apply( m_libEnd ) );
1135 }
1136
1137 return;
1138 }
1139
1140 if( m_libShape == SHAPE_T::ARC )
1141 {
1143 int libRadius = ( m_libStart - libCenter ).EuclideanNorm();
1144 VECTOR2I newCenter = xform.Apply( libCenter );
1145
1146 if( nonUniform )
1147 {
1148 int majorRadius = std::abs( KiROUND( libRadius * xform.GetScaleX() ) );
1149 int minorRadius = std::abs( KiROUND( libRadius * xform.GetScaleY() ) );
1150
1151 EDA_ANGLE rotation = -xform.GetRotate();
1152 EDA_ANGLE startAngle( VECTOR2D( m_libStart - libCenter ) );
1153 EDA_ANGLE midAngle( VECTOR2D( m_libArcMid - libCenter ) );
1154 EDA_ANGLE endAngle( VECTOR2D( m_libEnd - libCenter ) );
1155
1156 auto wrap = []( EDA_ANGLE a, EDA_ANGLE base )
1157 {
1158 while( a < base )
1159 a += ANGLE_360;
1160 return a;
1161 };
1162
1163 if( wrap( midAngle, startAngle ) > wrap( endAngle, startAngle ) )
1164 std::swap( startAngle, endAngle );
1165
1166 while( endAngle < startAngle )
1167 endAngle += ANGLE_360;
1168
1169 if( minorRadius > majorRadius )
1170 {
1171 std::swap( majorRadius, minorRadius );
1172 rotation += EDA_ANGLE( 90.0, DEGREES_T );
1173 startAngle -= EDA_ANGLE( 90.0, DEGREES_T );
1174 endAngle -= EDA_ANGLE( 90.0, DEGREES_T );
1175 }
1176
1178 SetEllipseCenter( newCenter );
1179 SetEllipseMajorRadius( majorRadius );
1180 SetEllipseMinorRadius( minorRadius );
1181 SetEllipseRotation( rotation );
1182 SetEllipseStartAngle( startAngle );
1183 SetEllipseEndAngle( endAngle );
1184 }
1185 else
1186 {
1189 }
1190
1191 return;
1192 }
1193
1195 {
1196 // The linear transform preserves ellipse-ness only when scale is uniform
1197 // or the lib ellipse's axes are aligned with the scale axes (cardinal lib
1198 // rotation). Otherwise the result is a sheared shape that no standard
1199 // ellipse can represent; tessellate to POLY in that case.
1200 const bool keepNative = xform.IsUniformScale() || m_libEllipseRotation.IsCardinal();
1201
1202 if( keepNative )
1203 {
1206
1207 if( xform.IsUniformScale() )
1208 {
1209 double absScale = std::abs( xform.GetScaleX() );
1213
1215 {
1218 }
1219 }
1220 else
1221 {
1222 BOARD_ELLIPSE be = decomposeBoardEllipse( xform, m_libEllipseMajorRadius,
1225
1228 EDA_SHAPE::SetEllipseRotation( be.rotation );
1229
1231 {
1234 }
1235 }
1236 }
1237 else
1238 {
1239 const bool isArc = ( m_libShape == SHAPE_T::ELLIPSE_ARC );
1240
1241 std::unique_ptr<SHAPE_ELLIPSE> libEllipse;
1242
1243 if( isArc )
1244 {
1245 libEllipse = std::make_unique<SHAPE_ELLIPSE>( m_libEllipseCenter, m_libEllipseMajorRadius,
1248 }
1249 else
1250 {
1251 libEllipse = std::make_unique<SHAPE_ELLIPSE>( m_libEllipseCenter, m_libEllipseMajorRadius,
1253 }
1254
1255 SHAPE_LINE_CHAIN chain = libEllipse->ConvertToPolyline( getMaxError() );
1256
1258 SHAPE_POLY_SET& poly = GetPolyShape();
1259 poly.RemoveAllContours();
1260 poly.NewOutline();
1261
1262 for( int ii = 0; ii < chain.PointCount(); ++ii )
1263 poly.Append( xform.Apply( chain.CPoint( ii ) ) );
1264
1265 poly.Outline( 0 ).SetClosed( !isArc );
1266 }
1267
1268 return;
1269 }
1270
1272 {
1273 const VECTOR2I c1 = xform.Apply( m_libStart );
1274 const VECTOR2I c2 = xform.Apply( VECTOR2I( m_libEnd.x, m_libStart.y ) );
1275 const VECTOR2I c3 = xform.Apply( m_libEnd );
1276 const VECTOR2I c4 = xform.Apply( VECTOR2I( m_libStart.x, m_libEnd.y ) );
1277
1278 if( xform.GetRotate().IsCardinal()
1279 && ( m_libCornerRadius == 0 || xform.IsUniformScale() ) )
1280 {
1282 BOX2I bbox( c1, VECTOR2I( 0, 0 ) );
1283 bbox.Merge( c2 );
1284 bbox.Merge( c3 );
1285 bbox.Merge( c4 );
1287 EDA_SHAPE::SetEnd( bbox.GetEnd() );
1288
1290 }
1291 else
1292 {
1294 SHAPE_POLY_SET& poly = GetPolyShape();
1295 poly.RemoveAllContours();
1296
1297 if( m_libCornerRadius > 0 )
1298 {
1299 SHAPE_POLY_SET rounded;
1300 VECTOR2I libCenter = ( m_libStart + m_libEnd ) / 2;
1301 VECTOR2I libSize( std::abs( m_libEnd.x - m_libStart.x ), std::abs( m_libEnd.y - m_libStart.y ) );
1302
1303 TransformRoundChamferedRectToPolygon( rounded, libCenter, libSize, ANGLE_0, m_libCornerRadius, 0.0,
1304 0, 0, getMaxError(), ERROR_INSIDE );
1305
1306 poly.NewOutline();
1307
1308 for( int ii = 0; ii < rounded.Outline( 0 ).PointCount(); ++ii )
1309 poly.Append( xform.Apply( rounded.Outline( 0 ).CPoint( ii ) ) );
1310 }
1311 else
1312 {
1313 poly.NewOutline();
1314 poly.Append( c1 );
1315 poly.Append( c2 );
1316 poly.Append( c3 );
1317 poly.Append( c4 );
1318 }
1319
1320 EDA_SHAPE::SetStart( c1 );
1321 EDA_SHAPE::SetEnd( c3 );
1322 }
1323
1324 return;
1325 }
1326
1327 if( m_libShape == SHAPE_T::POLY )
1328 {
1329 SHAPE_POLY_SET& poly = GetPolyShape();
1330 poly = m_libPoly;
1331
1332 transformPolyVertices( poly, xform, false );
1333
1334 // m_libStart/m_libEnd are not seeded for POLY, skip the start/end fall-through below.
1335 return;
1336 }
1337
1339 EDA_SHAPE::SetEnd( xform.Apply( m_libEnd ) );
1340
1342 {
1346 }
1347}
1348
1349
1351{
1352 if( m_libShape == SHAPE_T::ARC )
1353 return m_libArcMid;
1354
1355 if( const FOOTPRINT* fp = transformFp() )
1356 return fp->GetTransform().InverseApply( GetArcMid() );
1357
1358 return GetArcMid();
1359}
1360
1361
1363{
1364 if( GetParent() && GetParent()->Type() == PCB_PAD_T )
1365 return m_libBezierC1;
1366
1367 if( const FOOTPRINT* fp = transformFp() )
1368 return fp->GetTransform().InverseApply( GetBezierC1() );
1369
1370 return GetBezierC1();
1371}
1372
1373
1375{
1376 if( GetParent() && GetParent()->Type() == PCB_PAD_T )
1377 return m_libBezierC2;
1378
1379 if( const FOOTPRINT* fp = transformFp() )
1380 return fp->GetTransform().InverseApply( GetBezierC2() );
1381
1382 return GetBezierC2();
1383}
1384
1385
1387{
1388 if( GetParent() && GetParent()->Type() == PCB_PAD_T )
1389 return m_libPoly;
1390
1392
1393 if( const FOOTPRINT* fp = transformFp() )
1394 {
1395 const TRANSFORM_TRS& xform = fp->GetTransform();
1396
1397 transformPolyVertices( poly, xform, true );
1398 }
1399
1400 return poly;
1401}
1402
1403
1404void PCB_SHAPE::SetArcGeometry( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd )
1405{
1406 EDA_SHAPE::SetArcGeometry( aStart, aMid, aEnd );
1407 syncLibCoords();
1408}
1409
1410
1412{
1414 syncLibCoords();
1415}
1416
1417
1419{
1421 syncLibCoords();
1422}
1423
1424
1426{
1427 EDA_SHAPE::SetPolyShape( aShape );
1428 syncLibCoords();
1429}
1430
1431
1433{
1435 syncLibCoords();
1436}
1437
1438
1444
1445
1451
1452
1458
1459
1465
1466
1472
1473
1475{
1476 TRANSFORM_TRS xform;
1477 bool hasXform = false;
1478
1479 if( GetParent() && GetParent()->Type() == PCB_PAD_T )
1480 {
1481 double sx = 1.0, sy = 1.0;
1482 static_cast<const PAD*>( static_cast<const BOARD_ITEM*>( GetParent() ) )->GetPrimitiveLibScale( sx, sy );
1483 xform.SetScale( sx, sy );
1484 hasXform = ( sx != 1.0 || sy != 1.0 );
1485 }
1486 else if( const FOOTPRINT* fp = transformFp() )
1487 {
1488 xform = fp->GetTransform();
1489 hasXform = true;
1490 }
1491
1493 {
1494 if( hasXform )
1495 {
1497
1498 if( xform.IsUniformScale() )
1499 {
1500 double invScale = 1.0 / std::abs( xform.GetScaleX() );
1506 }
1507 else
1508 {
1509 // Non-uniform scale shears the ellipse, so invert the whole board ellipse to lib.
1510 BOARD_ELLIPSE le = composeLibEllipse( xform, GetEllipseMajorRadius(), GetEllipseMinorRadius(),
1512 m_libEllipseMajorRadius = KiROUND( le.major );
1513 m_libEllipseMinorRadius = KiROUND( le.minor );
1514 m_libEllipseRotation = le.rotation;
1515 m_libEllipseStartAngle = GetEllipseStartAngle() + le.startShift;
1516 m_libEllipseEndAngle = GetEllipseEndAngle() + le.startShift;
1517 }
1518 }
1519 else
1520 {
1527 }
1528
1529 return;
1530 }
1531
1532 if( m_shape == SHAPE_T::POLY )
1533 {
1535
1536 if( hasXform )
1537 transformPolyVertices( m_libPoly, xform, true );
1538
1539 return;
1540 }
1541
1542 if( hasXform )
1543 {
1544 m_libStart = xform.InverseApply( GetStart() );
1545 m_libEnd = xform.InverseApply( GetEnd() );
1546
1548 {
1549 // We assume xform is uniform scale. If not, we should have been turned into a
1550 // polygon.
1552 }
1553
1554 if( m_shape == SHAPE_T::ARC )
1555 m_libArcMid = xform.InverseApply( GetArcMid() );
1556
1557 if( m_shape == SHAPE_T::BEZIER )
1558 {
1561 }
1562 }
1563 else
1564 {
1565 m_libStart = GetStart();
1566 m_libEnd = GetEnd();
1567
1570
1571 if( m_shape == SHAPE_T::ARC )
1573
1574 if( m_shape == SHAPE_T::BEZIER )
1575 {
1578 }
1579 }
1580}
1581
1582
1583void PCB_SHAPE::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
1584{
1585 Mirror( MIRROR_AXIS( aCentre, aFlipDirection ) );
1586}
1587
1588
1589void PCB_SHAPE::Mirror( const SEG& aAxis )
1590{
1591 EDA_SHAPE::mirror( aAxis );
1592 syncLibCoords();
1593}
1594
1595
1596void PCB_SHAPE::SetIsProxyItem( bool aIsProxy )
1597{
1598 PAD* parentPad = nullptr;
1599
1600 if( GetBoard() && GetBoard()->IsFootprintHolder() )
1601 {
1602 for( FOOTPRINT* fp : GetBoard()->Footprints() )
1603 {
1604 for( PAD* pad : fp->Pads() )
1605 {
1606 if( pad->IsEntered() )
1607 {
1608 parentPad = pad;
1609 break;
1610 }
1611 }
1612 }
1613 }
1614
1615 if( aIsProxy && !m_proxyItem )
1616 {
1617 if( GetShape() == SHAPE_T::SEGMENT )
1618 {
1619 if( parentPad && parentPad->GetLocalThermalSpokeWidthOverride().has_value() )
1620 SetWidth( parentPad->GetLocalThermalSpokeWidthOverride().value() );
1621 else
1623 }
1624 else
1625 {
1626 SetWidth( 1 );
1627 }
1628 }
1629 else if( m_proxyItem && !aIsProxy )
1630 {
1632 }
1633
1634 m_proxyItem = aIsProxy;
1635}
1636
1637
1638double PCB_SHAPE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
1639{
1640 KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
1641 KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
1642
1643 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1644 {
1645 // Hide shadow if the main layer is not shown
1646 if( !aView->IsLayerVisibleCached( m_layer ) )
1647 return LOD_HIDE;
1648
1649 // Hide shadow on dimmed tracks
1650 if( renderSettings.GetHighContrast() )
1651 {
1652 if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
1653 return LOD_HIDE;
1654 }
1655 }
1656
1657 if( aLayer == LAYER_CONSTRAINT_SHADOW )
1658 {
1659 // Shadow always appended gate draw here on live constrained-item set not in
1660 // ViewGetLayers which caches
1661 if( !renderSettings.GetConstrainedItems().count( m_Uuid ) )
1662 return LOD_HIDE;
1663
1664 if( !aView->IsLayerVisibleCached( m_layer ) )
1665 return LOD_HIDE;
1666
1667 if( renderSettings.GetHighContrast() && m_layer != renderSettings.GetPrimaryHighContrastLayer() )
1668 return LOD_HIDE;
1669 }
1670
1671 if( FOOTPRINT* parent = GetParentFootprint() )
1672 {
1673 PCB_LAYER_ID checkLayer = m_layer;
1674
1675 if( !IsFrontLayer( checkLayer ) && !IsBackLayer( checkLayer ) )
1676 checkLayer = parent->GetLayer();
1677
1678 if( IsFrontLayer( checkLayer ) && !aView->IsLayerVisibleCached( LAYER_FOOTPRINTS_FR ) )
1679 return LOD_HIDE;
1680
1681 if( IsBackLayer( checkLayer ) && !aView->IsLayerVisibleCached( LAYER_FOOTPRINTS_BK ) )
1682 return LOD_HIDE;
1683 }
1684
1685 return LOD_SHOW;
1686}
1687
1688
1689std::vector<int> PCB_SHAPE::ViewGetLayers() const
1690{
1691 std::vector<int> layers;
1692 layers.reserve( 5 );
1693
1694 layers.push_back( GetLayer() );
1695
1696 if( IsOnCopperLayer() )
1697 {
1698 layers.push_back( GetNetnameLayer( GetLayer() ) );
1699
1700 if( m_hasSolderMask )
1701 {
1702 if( m_layer == F_Cu )
1703 layers.push_back( F_Mask );
1704 else if( m_layer == B_Cu )
1705 layers.push_back( B_Mask );
1706 }
1707 }
1708
1710 layers.push_back( LAYER_LOCKED_ITEM_SHADOW );
1711
1712 // Always advertise constraint-shadow layer ViewGetLOD gates draw by constrained state
1713 layers.push_back( LAYER_CONSTRAINT_SHADOW );
1714
1715 return layers;
1716}
1717
1718
1719void PCB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1720{
1721 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
1722 {
1723 if( FOOTPRINT* parent = GetParentFootprint() )
1724 aList.emplace_back( _( "Footprint" ), parent->GetReference() );
1725 }
1726
1727 aList.emplace_back( _( "Type" ), _( "Drawing" ) );
1728
1729 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
1730 aList.emplace_back( _( "Status" ), _( "Locked" ) );
1731
1732 ShapeGetMsgPanelInfo( aFrame, aList );
1733
1734 aList.emplace_back( _( "Layer" ), GetLayerName() );
1735
1736 if( IsOnCopperLayer() )
1737 {
1738 if( GetNetCode() > 0 ) // Only graphics connected to a net have a netcode > 0
1739 aList.emplace_back( _( "Net" ), GetNetname() );
1740 }
1741}
1742
1743
1744wxString PCB_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1745{
1746 FOOTPRINT* parentFP = GetParentFootprint();
1747
1748 // Don't report parent footprint info from footprint editor, viewer, etc.
1749 if( GetBoard() && GetBoard()->GetBoardUse() == BOARD_USE::FPHOLDER )
1750 parentFP = nullptr;
1751
1752 if( IsOnCopperLayer() )
1753 {
1754 if( parentFP )
1755 {
1756 return wxString::Format( _( "%s %s of %s on %s" ),
1758 GetNetnameMsg(),
1759 parentFP->GetReference(),
1760 GetLayerName() );
1761 }
1762 else
1763 {
1764 return wxString::Format( _( "%s %s on %s" ),
1766 GetNetnameMsg(),
1767 GetLayerName() );
1768 }
1769 }
1770 else
1771 {
1772 if( parentFP )
1773 {
1774 return wxString::Format( _( "%s of %s on %s" ),
1776 parentFP->GetReference(),
1777 GetLayerName() );
1778 }
1779 else
1780 {
1781 return wxString::Format( _( "%s on %s" ),
1783 GetLayerName() );
1784 }
1785 }
1786}
1787
1788
1790{
1791 if( GetParentFootprint() )
1793 else
1795}
1796
1797
1799{
1800 return new PCB_SHAPE( *this );
1801}
1802
1803
1805{
1806 BOX2I return_box = EDA_ITEM::ViewBBox();
1807
1808 // Inflate the bounding box by just a bit more for safety.
1809 return_box.Inflate( GetWidth() );
1810
1811 return return_box;
1812}
1813
1814
1816{
1817 BOX2I bbox = getBoundingBox();
1818 BOX2I endingsBBox;
1819
1820 if( GetLineEndingsBoundingBox( endingsBBox, GetEffectiveWidth() ) )
1821 bbox.Merge( endingsBBox );
1822
1823 bbox.Normalize();
1824
1825 return bbox;
1826}
1827
1828
1830{
1831 int width = GetEffectiveWidth();
1832
1833 if( IsSolderMaskLayer( aLayer ) && HasSolderMask() && IsCopperLayer( GetLayer() ) )
1834 width += 2 * GetSolderMaskExpansion();
1835
1836 return std::make_shared<SHAPE_COMPOUND>( MakeEffectiveShapesWithLineEndings( width ) );
1837}
1838
1839
1841{
1842 return GetMaxError();
1843}
1844
1845
1847{
1848 PCB_SHAPE* image = dynamic_cast<PCB_SHAPE*>( aImage );
1849 wxCHECK( image, /* void */ );
1850
1851 SwapShape( image );
1852
1853 // Swap params not handled by SwapShape( image )
1854 std::swap( m_layer, image->m_layer );
1855 std::swap( m_isKnockout, image->m_isKnockout );
1856 std::swap( m_isLocked, image->m_isLocked );
1857 std::swap( m_flags, image->m_flags );
1858 std::swap( m_parent, image->m_parent );
1859 std::swap( m_forceVisible, image->m_forceVisible );
1860 std::swap( m_netinfo, image->m_netinfo );
1861 std::swap( m_hasSolderMask, image->m_hasSolderMask );
1862 std::swap( m_solderMaskMargin, image->m_solderMaskMargin );
1863 std::swap( m_customProperties, image->m_customProperties );
1864
1865 std::swap( m_libStart, image->m_libStart );
1866 std::swap( m_libEnd, image->m_libEnd );
1867 std::swap( m_libCornerRadius, image->m_libCornerRadius );
1868 std::swap( m_libArcMid, image->m_libArcMid );
1869 std::swap( m_libBezierC1, image->m_libBezierC1 );
1870 std::swap( m_libBezierC2, image->m_libBezierC2 );
1871 std::swap( m_libPoly, image->m_libPoly );
1872 std::swap( m_libEllipseCenter, image->m_libEllipseCenter );
1873 std::swap( m_libEllipseMajorRadius, image->m_libEllipseMajorRadius );
1874 std::swap( m_libEllipseMinorRadius, image->m_libEllipseMinorRadius );
1875 std::swap( m_libEllipseRotation, image->m_libEllipseRotation );
1876 std::swap( m_libEllipseStartAngle, image->m_libEllipseStartAngle );
1877 std::swap( m_libEllipseEndAngle, image->m_libEllipseEndAngle );
1878 std::swap( m_libShape, image->m_libShape );
1879}
1880
1881
1882bool PCB_SHAPE::cmp_drawings::operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const
1883{
1884 if( aFirst->Type() != aSecond->Type() )
1885 return aFirst->Type() < aSecond->Type();
1886
1887 if( aFirst->GetLayer() != aSecond->GetLayer() )
1888 return aFirst->GetLayer() < aSecond->GetLayer();
1889
1890 if( aFirst->Type() == PCB_SHAPE_T )
1891 {
1892 const PCB_SHAPE* dwgA = static_cast<const PCB_SHAPE*>( aFirst );
1893 const PCB_SHAPE* dwgB = static_cast<const PCB_SHAPE*>( aSecond );
1894
1895 if( dwgA->GetShape() != dwgB->GetShape() )
1896 return dwgA->GetShape() < dwgB->GetShape();
1897 }
1898
1899 return aFirst->m_Uuid < aSecond->m_Uuid;
1900}
1901
1902
1903double PCB_SHAPE::GetCoverageArea( int aTextMargin ) const
1904{
1905 // Approximate "linear" shapes with just their width squared, as we don't want to consider
1906 // a linear shape as being much bigger than another for purposes of selection filtering
1907 // just because it happens to be really long.
1908 const double width = GetWidth();
1909
1910 switch( GetShape() )
1911 {
1912 case SHAPE_T::SEGMENT:
1913 case SHAPE_T::ARC:
1914 case SHAPE_T::BEZIER:
1915 return width * width;
1916
1917 case SHAPE_T::RECTANGLE:
1918 case SHAPE_T::CIRCLE:
1919 case SHAPE_T::POLY:
1920 if( !IsAnyFill() )
1921 return width * width;
1922
1924
1925 default:
1926 return BOARD_ITEM::GetCoverageArea( aTextMargin );
1927 }
1928}
1929
1930
1932 int aClearance, int aError, ERROR_LOC aErrorLoc,
1933 bool ignoreLineWidth ) const
1934{
1935 EDA_SHAPE::TransformShapeToPolygon( aBuffer, aClearance, aError, aErrorLoc, ignoreLineWidth,
1936 false );
1937}
1938
1939
1941 int aClearance, int aError, ERROR_LOC aErrorLoc,
1942 KIGFX::RENDER_SETTINGS* aRenderSettings ) const
1943{
1944 EDA_SHAPE::TransformShapeToPolygon( aBuffer, aClearance, aError, aErrorLoc, false, true );
1945}
1946
1947
1948bool PCB_SHAPE::operator==( const BOARD_ITEM& aOther ) const
1949{
1950 if( aOther.Type() != Type() )
1951 return false;
1952
1953 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
1954
1955 return *this == other;
1956}
1957
1958
1959bool PCB_SHAPE::operator==( const PCB_SHAPE& aOther ) const
1960{
1961 if( aOther.Type() != Type() )
1962 return false;
1963
1964 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
1965
1966 if( m_layer != other.m_layer )
1967 return false;
1968
1969 if( m_isKnockout != other.m_isKnockout )
1970 return false;
1971
1972 if( m_isLocked != other.m_isLocked )
1973 return false;
1974
1975 if( m_flags != other.m_flags )
1976 return false;
1977
1978 if( m_forceVisible != other.m_forceVisible )
1979 return false;
1980
1981 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
1982 return false;
1983
1984 if( m_hasSolderMask != other.m_hasSolderMask )
1985 return false;
1986
1988 return false;
1989
1990 return EDA_SHAPE::operator==( other );
1991}
1992
1993
1994double PCB_SHAPE::Similarity( const BOARD_ITEM& aOther ) const
1995{
1996 if( aOther.Type() != Type() )
1997 return 0.0;
1998
1999 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
2000
2001 double similarity = 1.0;
2002
2003 if( GetLayer() != other.GetLayer() )
2004 similarity *= 0.9;
2005
2006 if( m_isKnockout != other.m_isKnockout )
2007 similarity *= 0.9;
2008
2009 if( m_isLocked != other.m_isLocked )
2010 similarity *= 0.9;
2011
2012 if( m_flags != other.m_flags )
2013 similarity *= 0.9;
2014
2015 if( m_forceVisible != other.m_forceVisible )
2016 similarity *= 0.9;
2017
2018 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
2019 similarity *= 0.9;
2020
2021 if( m_hasSolderMask != other.m_hasSolderMask )
2022 similarity *= 0.9;
2023
2025 similarity *= 0.9;
2026
2027 similarity *= EDA_SHAPE::Similarity( other );
2028
2029 return similarity;
2030}
2031
2032
2033static struct PCB_SHAPE_DESC
2034{
2036 {
2043
2044 // Need to initialise enum_map before we can use a Property enum for it
2046
2047 if( layerEnum.Choices().GetCount() == 0 )
2048 {
2049 layerEnum.Undefined( UNDEFINED_LAYER );
2050
2051 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
2052 layerEnum.Map( layer, LSET::Name( layer ) );
2053 }
2054
2055 void ( PCB_SHAPE::*shapeLayerSetter )( PCB_LAYER_ID ) = &PCB_SHAPE::SetLayer;
2056 PCB_LAYER_ID ( PCB_SHAPE::*shapeLayerGetter )() const = &PCB_SHAPE::GetLayer;
2057
2058 propMgr.ReplaceProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ),
2060 shapeLayerSetter, shapeLayerGetter ) )
2061 .SetIsCopyable();
2062
2063 auto isPolygonOrEllipse =
2064 []( INSPECTABLE* aItem ) -> bool
2065 {
2066 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2067 {
2068 const SHAPE_T t = shape->GetShape();
2069 return t == SHAPE_T::POLY || t == SHAPE_T::ELLIPSE || t == SHAPE_T::ELLIPSE_ARC;
2070 }
2071
2072 return false;
2073 };
2074
2075 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
2076 isPolygonOrEllipse );
2077 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
2078 isPolygonOrEllipse );
2079
2080 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Color" ) );
2081 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Fill Color" ) );
2082
2083 auto isNotBezierOrEllipseArc =
2084 []( INSPECTABLE* aItem ) -> bool
2085 {
2086 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2087 {
2088 const SHAPE_T t = shape->GetShape();
2089 return t != SHAPE_T::BEZIER && t != SHAPE_T::ELLIPSE_ARC;
2090 }
2091
2092 return true;
2093 };
2094
2096 isNotBezierOrEllipseArc );
2097
2098 auto isCircle =
2099 []( INSPECTABLE* aItem ) -> bool
2100 {
2101 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2102 return shape->GetShape() == SHAPE_T::CIRCLE;
2103
2104 return false;
2105 };
2106
2107 auto isNotCircleOrEllipse =
2108 []( INSPECTABLE* aItem ) -> bool
2109 {
2110 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2111 {
2112 const SHAPE_T t = shape->GetShape();
2113 return t != SHAPE_T::CIRCLE && t != SHAPE_T::ELLIPSE && t != SHAPE_T::ELLIPSE_ARC;
2114 }
2115
2116 return true;
2117 };
2118
2119 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ),
2120 isNotCircleOrEllipse );
2121 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ),
2122 isNotCircleOrEllipse );
2123 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ),
2124 isNotCircleOrEllipse );
2125 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ),
2126 isNotCircleOrEllipse );
2127 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Center X" ),
2128 isCircle );
2129 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Center Y" ),
2130 isCircle );
2131 propMgr.OverrideAvailability( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Radius" ),
2132 isCircle );
2133
2134 auto isCopper =
2135 []( INSPECTABLE* aItem ) -> bool
2136 {
2137 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2138 return shape->IsOnCopperLayer();
2139
2140 return false;
2141 };
2142
2144 isCopper );
2145
2146 auto isPadEditMode =
2147 []( BOARD* aBoard ) -> bool
2148 {
2149 if( aBoard && aBoard->IsFootprintHolder() )
2150 {
2151 for( FOOTPRINT* fp : aBoard->Footprints() )
2152 {
2153 for( PAD* pad : fp->Pads() )
2154 {
2155 if( pad->IsEntered() )
2156 return true;
2157 }
2158 }
2159 }
2160
2161 return false;
2162 };
2163
2164 auto showNumberBoxProperty =
2165 [&]( INSPECTABLE* aItem ) -> bool
2166 {
2167 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2168 {
2169 if( shape->GetShape() == SHAPE_T::RECTANGLE )
2170 return isPadEditMode( shape->GetBoard() );
2171 }
2172
2173 return false;
2174 };
2175
2176 auto showSpokeTemplateProperty =
2177 [&]( INSPECTABLE* aItem ) -> bool
2178 {
2179 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2180 {
2181 if( shape->GetShape() == SHAPE_T::SEGMENT )
2182 return isPadEditMode( shape->GetBoard() );
2183 }
2184
2185 return false;
2186 };
2187
2188 const wxString groupPadPrimitives = _HKI( "Pad Primitives" );
2189
2190 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Number Box" ),
2192 groupPadPrimitives )
2193 .SetAvailableFunc( showNumberBoxProperty )
2195
2196 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Thermal Spoke Template" ),
2198 groupPadPrimitives )
2199 .SetAvailableFunc( showSpokeTemplateProperty )
2201
2202 const wxString groupTechLayers = _HKI( "Technical Layers" );
2203
2204 auto isExternalCuLayer =
2205 []( INSPECTABLE* aItem )
2206 {
2207 if( auto shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
2208 return IsExternalCopperLayer( shape->GetLayer() );
2209
2210 return false;
2211 };
2212
2213 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Soldermask" ),
2215 groupTechLayers )
2216 .SetAvailableFunc( isExternalCuLayer )
2217 .SetIsCopyable();
2218
2219 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, std::optional<int>>( _HKI( "Soldermask Margin Override" ),
2222 groupTechLayers )
2223 .SetAvailableFunc( isExternalCuLayer )
2224 .SetIsCopyable();
2225 }
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:56
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_OUTSIDE
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr int ARC_LOW_DEF
Definition base_units.h:143
BITMAPS
A list of all bitmap identifiers.
@ add_dashed_line
@ FPHOLDER
Definition board.h:403
#define DEFAULT_LINE_WIDTH
SEG MIRROR_AXIS(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition board_item.h:85
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
void PackNet(kiapi::board::types::Net *aProto) const
NETINFO_ITEM * m_netinfo
Store all information about the net that item belongs to.
void UnpackNet(const kiapi::board::types::Net &aProto)
Assigns a net to this item from an API message.
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:101
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
Definition board_item.h:441
bool m_isKnockout
Definition board_item.h:626
PCB_LAYER_ID GetFlippedLayer(PCB_LAYER_ID aLayer) const
Return the layer paired with aLayer on the opposite side of the board.
PCB_LAYER_ID m_layer
Definition board_item.h:625
bool m_isLocked
Definition board_item.h:627
bool IsLocked() const override
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual double GetCoverageArea(int aTextMargin) const
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:397
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:281
virtual bool IsOnCopperLayer() const
Definition board_item.h:204
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
int GetMaxError() const
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
BOARD_DESIGN_SETTINGS & GetDesignSettings()
Definition board.cpp:1318
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr const Vec GetEnd() const
Definition box2.h:215
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:149
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:597
constexpr const Vec & GetOrigin() const
Definition box2.h:213
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:314
Represent basic circle geometry with utility geometry functions.
Definition circle.h:33
MINOPTMAX< int > m_Value
Definition drc_rule.h:206
bool IsCardinal() const
Definition eda_angle.cpp:40
double AsRadians() const
Definition eda_angle.h:119
The base class for create windows for drawing purpose.
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition eda_item.cpp:280
const KIID m_Uuid
Definition eda_item.h:599
bool m_forceVisible
Definition eda_item.h:614
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM_FLAGS m_flags
Definition eda_item.h:608
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:214
std::map< wxString, wxString > m_customProperties
Definition eda_item.h:617
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition eda_item.cpp:519
EDA_ITEM * m_parent
Owner.
Definition eda_item.h:609
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
virtual int GetHatchLineSpacing() const
Definition eda_shape.h:169
SHAPE_T m_shape
Definition eda_shape.h:754
virtual void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:338
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false, bool includeFill=false) const
Convert the shape to a closed polygon.
int GetEllipseMinorRadius() const
Definition eda_shape.h:404
bool m_proxyItem
Definition eda_shape.h:783
bool m_hatchingDirty
Definition eda_shape.h:763
bool m_endsSwapped
Definition eda_shape.h:753
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:377
const VECTOR2I & GetEllipseCenter() const
Definition eda_shape.h:386
bool GetLineEndingsBoundingBox(BOX2I &aBBox, int aLineWidth) const
virtual void SetCenter(const VECTOR2I &aCenter)
void mirror(const SEG &aAxis)
int m_editState
Definition eda_shape.h:782
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
std::vector< SHAPE * > MakeEffectiveShapesWithLineEndings(int aLineWidth) const
Make effective geometry for the shape body shortened for line endings plus the line-ending geometry i...
EDA_ANGLE GetEllipseEndAngle() const
Definition eda_shape.h:432
virtual void SetCornerRadius(int aRadius)
int GetEllipseMajorRadius() const
Definition eda_shape.h:395
virtual int GetEffectiveWidth() const
Definition eda_shape.h:167
SHAPE_POLY_SET & GetPolyShape()
EDA_ANGLE GetEllipseRotation() const
Definition eda_shape.h:413
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
virtual void SetEllipseEndAngle(const EDA_ANGLE &aA)
Definition eda_shape.h:425
bool operator==(const EDA_SHAPE &aOther) const
int GetRadius() const
SHAPE_T GetShape() const
Definition eda_shape.h:178
virtual void SetBezierC2(const VECTOR2I &aPt)
Definition eda_shape.h:376
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
VECTOR2I m_arcCenter
Definition eda_shape.h:772
virtual void SetBezierC1(const VECTOR2I &aPt)
Definition eda_shape.h:373
virtual void SetEllipseRotation(const EDA_ANGLE &aA)
Definition eda_shape.h:406
ARC_MID m_arcMidData
Definition eda_shape.h:773
bool IsSolidFill() const
Definition eda_shape.h:126
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill)
Definition eda_shape.cpp:56
VECTOR2I m_start
Definition eda_shape.h:769
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:334
virtual void SetEllipseCenter(const VECTOR2I &aPt)
Definition eda_shape.h:379
virtual void SetEllipseMinorRadius(int aR)
Definition eda_shape.h:397
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:284
virtual void SetEllipseMajorRadius(int aR)
Definition eda_shape.h:388
void SwapShape(EDA_SHAPE *aImage)
std::vector< VECTOR2I > GetRectCorners() const
bool IsAnyFill() const
Definition eda_shape.h:121
EDA_ANGLE GetEllipseStartAngle() const
Definition eda_shape.h:423
virtual void UpdateHatching() const
virtual void SetEllipseStartAngle(const EDA_ANGLE &aA)
Definition eda_shape.h:416
virtual void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
wxString SHAPE_T_asString() const
double Similarity(const EDA_SHAPE &aOther) const
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:374
VECTOR2I m_end
Definition eda_shape.h:770
const BOX2I getBoundingBox() const
virtual int GetWidth() const
Definition eda_shape.h:166
STROKE_PARAMS m_stroke
Definition eda_shape.h:755
void RebuildBezierToSegmentsPointsList()
Definition eda_shape.h:556
VECTOR2I m_bezierC1
Definition eda_shape.h:775
int GetCornerRadius() const
virtual void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition eda_shape.h:529
virtual void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:288
VECTOR2I m_bezierC2
Definition eda_shape.h:776
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
VECTOR2I GetArcMid() const
virtual bool IsVisible() const
Definition eda_text.h:226
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:817
static ENUM_MAP< T > & Instance()
Definition property.h:811
ENUM_MAP & Undefined(T aValue)
Definition property.h:824
wxPGChoices & Choices()
Definition property.h:862
const TRANSFORM_TRS & GetTransform() const
Definition footprint.h:395
const wxString & GetReference() const
Definition footprint.h:793
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:39
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
Definition pcb_painter.h:94
const std::unordered_set< KIID > & GetConstrainedItems() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition view_item.h:176
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition view_item.h:181
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:472
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
Definition view.h:242
Definition kiid.h:46
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
Definition lset.h:275
static const LSET & AllLayersMask()
Definition lset.cpp:637
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition lset.cpp:184
T Opt() const
Definition minoptmax.h:31
bool HasOpt() const
Definition minoptmax.h:39
int GetNetCode() const
Definition netinfo.h:104
Definition pad.h:61
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition pad.h:763
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &aSettings, bool aCheckSide) override
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
VECTOR2I m_libEllipseCenter
Definition pcb_shape.h:399
void swapData(BOARD_ITEM *aImage) override
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
void SetEllipseCenter(const VECTOR2I &aPt) override
void SetCenter(const VECTOR2I &aCenter) override
EDA_ANGLE m_libEllipseStartAngle
Definition pcb_shape.h:403
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
VECTOR2I m_libEnd
Definition pcb_shape.h:388
VECTOR2I m_libBezierC1
Definition pcb_shape.h:394
virtual void syncLibCoords()
SHAPE_POLY_SET getHatchingKnockouts() const override
void SetBezierC1(const VECTOR2I &aPt) override
void SetCornerRadius(int aCornerRadius) override
std::optional< int > GetLocalSolderMaskMargin() const
Definition pcb_shape.h:352
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_shape.h:80
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
VECTOR2I GetLibraryBezierC1() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T aItemType, SHAPE_T aShapeType)
void SetWidth(int aWidth) override
EDA_ANGLE m_libEllipseEndAngle
Definition pcb_shape.h:404
void SetLibStrokeWidth(int aWidth)
SHAPE_T m_libShape
Definition pcb_shape.h:406
void rebakeFromTransform(const TRANSFORM_TRS &aXform)
int GetWidth() const override
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
bool HasSolderMask() const
Definition pcb_shape.h:349
void SetEllipseStartAngle(const EDA_ANGLE &aA) override
void SetHasSolderMask(bool aVal)
Definition pcb_shape.h:348
std::optional< int > m_solderMaskMargin
Definition pcb_shape.h:385
int GetSolderMaskExpansion() const
void NormalizeForCompare() override
Normalize coordinates to compare 2 similar PCB_SHAPES similat to Normalize(), but also normalize SEGM...
void SetShape(SHAPE_T aShape) override
Definition pcb_shape.h:214
void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const override
Convert the item shape to a polyset.
VECTOR2I m_libArcMid
Definition pcb_shape.h:392
void SetEllipseEndAngle(const EDA_ANGLE &aA) override
int m_libEllipseMinorRadius
Definition pcb_shape.h:401
const VECTOR2I GetFocusPosition() const override
Allows items to return their visual center rather than their anchor.
virtual void SetLayerSet(const LSET &aLayers) override
void SetEnd(const VECTOR2I &aEnd) override
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetLibraryEnd() const
Definition pcb_shape.h:235
void SetPolyShape(const SHAPE_POLY_SET &aShape) override
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
bool IsProxyItem() const override
Definition pcb_shape.h:155
void SetEllipseRotation(const EDA_ANGLE &aA) override
bool m_hasSolderMask
Definition pcb_shape.h:384
const FOOTPRINT * transformFp() const
VECTOR2I GetLibraryStart() const
Definition pcb_shape.h:234
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
~PCB_SHAPE() override
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool operator==(const PCB_SHAPE &aShape) const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
int m_libCornerRadius
Definition pcb_shape.h:390
void SetEllipseMinorRadius(int aR) override
wxString GetFriendlyName() const override
Definition pcb_shape.h:65
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.
STROKE_PARAMS GetStroke() const override
void SetIsProxyItem(bool aIsProxy=true) override
void RebakeWithScale(double aScaleX, double aScaleY)
SHAPE_POLY_SET m_libPoly
Definition pcb_shape.h:397
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition pcb_shape.h:351
void Move(const VECTOR2I &aMoveVector) override
Move this object.
std::vector< VECTOR2I > GetConnectionPoints() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
int getMaxError() const override
void SetStart(const VECTOR2I &aStart) override
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
void SetBezierC2(const VECTOR2I &aPt) override
void UpdateHatching() const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void Scale(double aScale)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
SHAPE_POLY_SET GetLibraryPolyShape() const
void SetStroke(const STROKE_PARAMS &aStroke) override
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
void CopyFrom(const BOARD_ITEM *aOther) override
VECTOR2I GetLibraryBezierC2() const
VECTOR2I m_libBezierC2
Definition pcb_shape.h:395
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void RebakeFromLib()
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) override
Set the three controlling points for an arc.
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
VECTOR2I m_libStart
Definition pcb_shape.h:387
EDA_ANGLE m_libEllipseRotation
Definition pcb_shape.h:402
int m_libEllipseMajorRadius
Definition pcb_shape.h:400
VECTOR2I GetLibraryArcMid() const
void SetEllipseMajorRadius(int aR) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pcb_shape.h:70
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition property.h:275
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
Definition property.h:388
PROPERTY_BASE & SetIsHiddenFromRulesEditor(bool aHide=true)
Definition property.h:361
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Definition seg.h:38
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
EDA_ANGLE GetCentralAngle() const
Get the "central angle" of the arc - this is the angle at the point of the "pie slice".
const VECTOR2I & GetArcMid() const
Definition shape_arc.h:116
const VECTOR2I & GetP1() const
Definition shape_arc.h:115
const VECTOR2I & GetP0() const
Definition shape_arc.h:114
const VECTOR2I & GetCenter() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
SEG Segment(int aIndex) const
Return a copy of the aIndex-th segment in the line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
ITERATOR IterateWithHoles(int aOutline)
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
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.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the reference to aHole-th hole in the aIndex-th outline.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
Simple container to manage line stroke parameters.
int GetWidth() const
void SetWidth(int aWidth)
VECTOR2I InverseApply(const VECTOR2I &aPoint) const
bool IsUniformScale() const
Scales that differ only by rounding count as equal, so a pure rotation stays uniform.
const EDA_ANGLE & GetRotate() const
double GetScaleX() const
VECTOR2I Apply(const VECTOR2I &aPoint) const
double GetScaleY() const
double ApplyLinearScale(double aLength) const
void SetScale(double aSx, double aSy)
double InverseApplyLinearScale(double aLength) const
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
@ SOLDER_MASK_EXPANSION_CONSTRAINT
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:472
@ RADIANS_T
Definition eda_angle.h:31
@ DEGREES_T
Definition eda_angle.h:30
static constexpr EDA_ANGLE ANGLE_360
Definition eda_angle.h:478
static constexpr EDA_ANGLE ANGLE_180
Definition eda_angle.h:476
#define PCB_EDIT_FRAME_NAME
FILL_T
Definition eda_fill.h:29
@ NO_FILL
Definition eda_fill.h:30
@ RECURSE
Definition eda_item.h:51
SHAPE_T
Definition eda_shape.h:55
@ UNDEFINED
Definition eda_shape.h:56
@ ELLIPSE
Definition eda_shape.h:63
@ SEGMENT
Definition eda_shape.h:57
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:58
@ ELLIPSE_ARC
Definition eda_shape.h:64
bool IsSolderMaskLayer(int aLayer)
Definition layer_ids.h:815
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:847
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition layer_ids.h:870
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition layer_ids.h:921
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:744
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:303
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition layer_ids.h:255
@ LAYER_CONSTRAINT_SHADOW
Shadow layer for items bound to a constraint.
Definition layer_ids.h:320
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition layer_ids.h:256
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition layer_ids.h:755
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_CrtYd
Definition layer_ids.h:112
@ Edge_Cuts
Definition layer_ids.h:108
@ B_Mask
Definition layer_ids.h:94
@ B_Cu
Definition layer_ids.h:61
@ F_Mask
Definition layer_ids.h:93
@ B_CrtYd
Definition layer_ids.h:111
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
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:79
#define UNIMPLEMENTED_FOR(type)
Definition macros.h:92
FLIP_DIRECTION
Definition mirror.h:26
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:27
std::vector< TYPED_POINT2I > GetCircleKeyPoints(const CIRCLE &aCircle, bool aIncludeCenter)
Get key points of an CIRCLE.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:461
#define _HKI(x)
Definition page_info.cpp:40
static void transformPolyVertices(SHAPE_POLY_SET &aPoly, const TRANSFORM_TRS &aXform, bool aInverse)
Definition pcb_shape.cpp:57
static double fpScaleLinear(const FOOTPRINT *aFp)
static struct PCB_SHAPE_DESC _PCB_SHAPE_DESC
static bool isCopper(const PNS::ITEM *aItem)
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:63
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
Utility functions for working with shapes.
const int scale
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
const SHAPE_LINE_CHAIN chain
VECTOR2I end
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
static double sweep(float aStart, float aEnd)
#define M_PI
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition trigo.cpp:540
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ PCB_SHAPE_LOCATE_ELLIPSE_ARC_T
Definition typeinfo.h:236
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ PCB_LOCATE_BOARD_EDGE_T
Definition typeinfo.h:126
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:82
@ PCB_SHAPE_LOCATE_CIRCLE_T
Definition typeinfo.h:131
@ PCB_SHAPE_LOCATE_SEGMENT_T
Definition typeinfo.h:129
@ PCB_SHAPE_LOCATE_RECT_T
Definition typeinfo.h:130
@ PCB_SHAPE_LOCATE_ELLIPSE_T
Definition typeinfo.h:235
@ PCB_SHAPE_LOCATE_BEZIER_T
Definition typeinfo.h:134
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_SHAPE_LOCATE_POLY_T
Definition typeinfo.h:133
@ PCB_SHAPE_LOCATE_ARC_T
Definition typeinfo.h:132
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MM
Definition zones.h:29