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 (C) 1992-2023 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, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <google/protobuf/any.pb.h>
28#include <magic_enum.hpp>
29
30#include <bitmaps.h>
31#include <core/mirror.h>
32#include <macros.h>
33#include <pcb_edit_frame.h>
35#include <board.h>
36#include <footprint.h>
37#include <pad.h>
38#include <base_units.h>
40#include <pcb_shape.h>
41#include <pcb_painter.h>
42#include <api/board/board_types.pb.h>
43#include <api/api_enums.h>
44#include <api/api_utils.h>
45
46
47PCB_SHAPE::PCB_SHAPE( BOARD_ITEM* aParent, KICAD_T aItemType, SHAPE_T aShapeType ) :
48 BOARD_CONNECTED_ITEM( aParent, aItemType ),
49 EDA_SHAPE( aShapeType, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL )
50{
51}
52
53
54PCB_SHAPE::PCB_SHAPE( BOARD_ITEM* aParent, SHAPE_T shapetype ) :
56 EDA_SHAPE( shapetype, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL )
57{
58}
59
60
62{
63}
64
65
66void PCB_SHAPE::Serialize( google::protobuf::Any &aContainer ) const
67{
68 kiapi::board::types::GraphicShape msg;
69
70 msg.mutable_id()->set_value( m_Uuid.AsStdString() );
71 msg.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( GetLayer() ) );
72 msg.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
73 : kiapi::common::types::LockedState::LS_UNLOCKED );
74 msg.mutable_net()->mutable_code()->set_value( GetNetCode() );
75 msg.mutable_net()->set_name( GetNetname() );
76
77 kiapi::common::types::StrokeAttributes* stroke
78 = msg.mutable_attributes()->mutable_stroke();
79 kiapi::common::types::GraphicFillAttributes* fill = msg.mutable_attributes()->mutable_fill();
80
81 stroke->mutable_width()->set_value_nm( GetWidth() );
82
83 switch( GetLineStyle() )
84 {
85 case LINE_STYLE::DEFAULT: stroke->set_style( kiapi::common::types::SLS_DEFAULT ); break;
86 case LINE_STYLE::SOLID: stroke->set_style( kiapi::common::types::SLS_SOLID ); break;
87 case LINE_STYLE::DASH: stroke->set_style( kiapi::common::types::SLS_DASH ); break;
88 case LINE_STYLE::DOT: stroke->set_style( kiapi::common::types::SLS_DOT ); break;
89 case LINE_STYLE::DASHDOT: stroke->set_style( kiapi::common::types::SLS_DASHDOT ); break;
90 case LINE_STYLE::DASHDOTDOT: stroke->set_style( kiapi::common::types::SLS_DASHDOTDOT ); break;
91 default: break;
92 }
93
94 switch( GetFillMode() )
95 {
96 case FILL_T::FILLED_SHAPE: fill->set_fill_type( kiapi::common::types::GFT_FILLED ); break;
97 default: fill->set_fill_type( kiapi::common::types::GFT_UNFILLED ); break;
98 }
99
100 switch( GetShape() )
101 {
102 case SHAPE_T::SEGMENT:
103 {
104 kiapi::board::types::GraphicSegmentAttributes* segment = msg.mutable_segment();
105 kiapi::common::PackVector2( *segment->mutable_start(), GetStart() );
106 kiapi::common::PackVector2( *segment->mutable_end(), GetEnd() );
107 break;
108 }
109
110 case SHAPE_T::RECTANGLE:
111 {
112 kiapi::board::types::GraphicRectangleAttributes* rectangle = msg.mutable_rectangle();
113 kiapi::common::PackVector2( *rectangle->mutable_top_left(), GetStart() );
114 kiapi::common::PackVector2( *rectangle->mutable_bottom_right(), GetEnd() );
115 break;
116 }
117
118 case SHAPE_T::ARC:
119 {
120 kiapi::board::types::GraphicArcAttributes* arc = msg.mutable_arc();
121 kiapi::common::PackVector2( *arc->mutable_start(), GetStart() );
122 kiapi::common::PackVector2( *arc->mutable_mid(), GetArcMid() );
123 kiapi::common::PackVector2( *arc->mutable_end(), GetEnd() );
124 break;
125 }
126
127 case SHAPE_T::CIRCLE:
128 {
129 kiapi::board::types::GraphicCircleAttributes* circle = msg.mutable_circle();
130 kiapi::common::PackVector2( *circle->mutable_center(), GetStart() );
131 kiapi::common::PackVector2( *circle->mutable_radius_point(), GetEnd() );
132 break;
133 }
134
135 case SHAPE_T::POLY:
136 {
137 kiapi::common::types::PolySet* polyset = msg.mutable_polygon();
138
139 for( int idx = 0; idx < GetPolyShape().OutlineCount(); ++idx )
140 {
141 const SHAPE_POLY_SET::POLYGON& poly = GetPolyShape().Polygon( idx );
142
143 if( poly.empty() )
144 continue;
145
146 kiapi::common::types::PolygonWithHoles* polyMsg = polyset->mutable_polygons()->Add();
147 kiapi::common::PackPolyLine( *polyMsg->mutable_outline(), poly.front() );
148
149 if( poly.size() > 1 )
150 {
151 for( size_t hole = 1; hole < poly.size(); ++hole )
152 {
153 kiapi::common::types::PolyLine* pl = polyMsg->mutable_holes()->Add();
154 kiapi::common::PackPolyLine( *pl, poly[hole] );
155 }
156 }
157 }
158 break;
159 }
160
161 case SHAPE_T::BEZIER:
162 {
163 kiapi::board::types::GraphicBezierAttributes* bezier = msg.mutable_bezier();
164 kiapi::common::PackVector2( *bezier->mutable_start(), GetStart() );
165 kiapi::common::PackVector2( *bezier->mutable_control1(), GetBezierC1() );
166 kiapi::common::PackVector2( *bezier->mutable_control2(), GetBezierC2() );
167 kiapi::common::PackVector2( *bezier->mutable_end(), GetEnd() );
168 break;
169 }
170
171 default:
172 wxASSERT_MSG( false, "Unhandled shape in PCB_SHAPE::Serialize" );
173 }
174
175 aContainer.PackFrom( msg );
176}
177
178
179bool PCB_SHAPE::Deserialize( const google::protobuf::Any &aContainer )
180{
181 kiapi::board::types::GraphicShape msg;
182
183 if( !aContainer.UnpackTo( &msg ) )
184 return false;
185
186 // Initialize everything to a known state that doesn't get touched by every
187 // codepath below, to make sure the equality operator is consistent
188 m_start = {};
189 m_end = {};
190 m_arcCenter = {};
191 m_arcMidData = {};
192 m_bezierC1 = {};
193 m_bezierC2 = {};
194 m_editState = 0;
195 m_proxyItem = false;
196 m_endsSwapped = false;
197
198 const_cast<KIID&>( m_Uuid ) = KIID( msg.id().value() );
199 SetLocked( msg.locked() == kiapi::common::types::LS_LOCKED );
200 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( msg.layer() ) );
201 SetNetCode( msg.net().code().value() );
202
203 SetFilled( msg.attributes().fill().fill_type() == kiapi::common::types::GFT_FILLED );
204 SetWidth( msg.attributes().stroke().width().value_nm() );
205
206 switch( msg.attributes().stroke().style() )
207 {
208 case kiapi::common::types::SLS_DEFAULT: SetLineStyle( LINE_STYLE::DEFAULT ); break;
209 case kiapi::common::types::SLS_SOLID: SetLineStyle( LINE_STYLE::SOLID ); break;
210 case kiapi::common::types::SLS_DASH: SetLineStyle( LINE_STYLE::DASH ); break;
211 case kiapi::common::types::SLS_DOT: SetLineStyle( LINE_STYLE::DOT ); break;
212 case kiapi::common::types::SLS_DASHDOT: SetLineStyle( LINE_STYLE::DASHDOT ); break;
213 case kiapi::common::types::SLS_DASHDOTDOT: SetLineStyle( LINE_STYLE::DASHDOTDOT ); break;
214 default: break;
215 }
216
217 if( msg.has_segment() )
218 {
219 SetShape( SHAPE_T::SEGMENT );
220 SetStart( kiapi::common::UnpackVector2( msg.segment().start() ) );
221 SetEnd( kiapi::common::UnpackVector2( msg.segment().end() ) );
222 }
223 else if( msg.has_rectangle() )
224 {
225 SetShape( SHAPE_T::RECTANGLE );
226 SetStart( kiapi::common::UnpackVector2( msg.rectangle().top_left() ) );
227 SetEnd( kiapi::common::UnpackVector2( msg.rectangle().bottom_right() ) );
228 }
229 else if( msg.has_arc() )
230 {
231 SetShape( SHAPE_T::ARC );
232 SetArcGeometry( kiapi::common::UnpackVector2( msg.arc().start() ),
233 kiapi::common::UnpackVector2( msg.arc().mid() ),
234 kiapi::common::UnpackVector2( msg.arc().end() ) );
235 }
236 else if( msg.has_circle() )
237 {
238 SetShape( SHAPE_T::CIRCLE );
239 SetStart( kiapi::common::UnpackVector2( msg.circle().center() ) );
240 SetEnd( kiapi::common::UnpackVector2( msg.circle().radius_point() ) );
241 }
242 else if( msg.has_polygon() )
243 {
244 SetShape( SHAPE_T::POLY );
245 const auto& polyMsg = msg.polygon().polygons();
246
247 SHAPE_POLY_SET sps;
248
249 for( const kiapi::common::types::PolygonWithHoles& polygonWithHoles : polyMsg )
250 {
252
253 polygon.emplace_back( kiapi::common::UnpackPolyLine( polygonWithHoles.outline() ) );
254
255 for( const kiapi::common::types::PolyLine& holeMsg : polygonWithHoles.holes() )
256 polygon.emplace_back( kiapi::common::UnpackPolyLine( holeMsg ) );
257
258 sps.AddPolygon( polygon );
259 }
260
261 SetPolyShape( sps );
262 }
263 else if( msg.has_bezier() )
264 {
265 SetShape( SHAPE_T::BEZIER );
266 SetStart( kiapi::common::UnpackVector2( msg.bezier().start() ) );
267 SetBezierC1( kiapi::common::UnpackVector2( msg.bezier().control1() ) );
268 SetBezierC2( kiapi::common::UnpackVector2( msg.bezier().control2() ) );
269 SetEnd( kiapi::common::UnpackVector2( msg.bezier().end() ) );
270 }
271
272 return true;
273}
274
275
276bool PCB_SHAPE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
277{
278 if( BOARD_ITEM::IsType( aScanTypes ) )
279 return true;
280
281 bool sametype = false;
282
283 for( KICAD_T scanType : aScanTypes )
284 {
285 if( scanType == PCB_LOCATE_BOARD_EDGE_T )
286 sametype = m_layer == Edge_Cuts;
287 else if( scanType == PCB_SHAPE_LOCATE_ARC_T )
288 sametype = m_shape == SHAPE_T::ARC;
289 else if( scanType == PCB_SHAPE_LOCATE_CIRCLE_T )
290 sametype = m_shape == SHAPE_T::CIRCLE;
291 else if( scanType == PCB_SHAPE_LOCATE_RECT_T )
292 sametype = m_shape == SHAPE_T::RECTANGLE;
293 else if( scanType == PCB_SHAPE_LOCATE_SEGMENT_T )
294 sametype = m_shape == SHAPE_T::SEGMENT;
295 else if( scanType == PCB_SHAPE_LOCATE_POLY_T )
296 sametype = m_shape == SHAPE_T::POLY;
297 else if( scanType == PCB_SHAPE_LOCATE_BEZIER_T )
298 sametype = m_shape == SHAPE_T::BEZIER;
299
300 if( sametype )
301 return true;
302 }
303
304 return false;
305}
306
307
309{
310 // Only board-level copper shapes are connectable
311 return IsOnCopperLayer() && !GetParentFootprint();
312}
313
314
316{
317 BOARD_ITEM::SetLayer( aLayer );
318
319 if( !IsOnCopperLayer() )
320 SetNetCode( -1 );
321}
322
323
324std::vector<VECTOR2I> PCB_SHAPE::GetConnectionPoints() const
325{
326 std::vector<VECTOR2I> ret;
327
328 // For filled shapes, we may as well use a centroid
329 if( IsFilled() )
330 {
331 ret.emplace_back( GetCenter() );
332 return ret;
333 }
334
335 switch( m_shape )
336 {
337 case SHAPE_T::ARC:
338 ret.emplace_back( GetArcMid() );
340
341 case SHAPE_T::SEGMENT:
342 case SHAPE_T::BEZIER:
343 ret.emplace_back( GetStart() );
344 ret.emplace_back( GetEnd() );
345 break;
346
347 case SHAPE_T::POLY:
348 for( auto iter = GetPolyShape().CIterate(); iter; ++iter )
349 ret.emplace_back( *iter );
350
351 break;
352
353 case SHAPE_T::RECTANGLE:
354 for( const VECTOR2I& pt : GetRectCorners() )
355 ret.emplace_back( pt );
356
357 break;
358
359 default:
360 break;
361 }
362
363 return ret;
364}
365
366
368{
369 // A stroke width of 0 in PCBNew means no-border, but negative stroke-widths are only used
370 // in EEschema (see SCH_SHAPE::GetPenWidth()).
371 // Since negative stroke widths can trip up down-stream code (such as the Gerber plotter), we
372 // weed them out here.
373 return std::max( EDA_SHAPE::GetWidth(), 0 );
374}
375
376
378{
380}
381
382
384{
385 // For some shapes return the visual center, but for not filled polygonal shapes,
386 // the center is usually far from the shape: a point on the outline is better
387
388 switch( m_shape )
389 {
390 case SHAPE_T::CIRCLE:
391 if( !IsFilled() )
392 return VECTOR2I( GetCenter().x + GetRadius(), GetCenter().y );
393 else
394 return GetCenter();
395
396 case SHAPE_T::RECTANGLE:
397 if( !IsFilled() )
398 return GetStart();
399 else
400 return GetCenter();
401
402 case SHAPE_T::POLY:
403 if( !IsFilled() )
404 {
405 VECTOR2I pos = GetPolyShape().Outline(0).CPoint(0);
406 return VECTOR2I( pos.x, pos.y );
407 }
408 else
409 {
410 return GetCenter();
411 }
412
413 case SHAPE_T::ARC:
414 return GetArcMid();
415
416 case SHAPE_T::BEZIER:
417 return GetStart();
418
419 default:
420 return GetCenter();
421 }
422}
423
424
425std::vector<VECTOR2I> PCB_SHAPE::GetCorners() const
426{
427 std::vector<VECTOR2I> pts;
428
429 if( GetShape() == SHAPE_T::RECTANGLE )
430 {
431 pts = GetRectCorners();
432 }
433 else if( GetShape() == SHAPE_T::POLY )
434 {
435 for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii )
436 {
437 for( const VECTOR2I& pt : GetPolyShape().Outline( ii ).CPoints() )
438 pts.emplace_back( pt );
439 }
440 }
441 else
442 {
444 }
445
446 while( pts.size() < 4 )
447 pts.emplace_back( pts.back() + VECTOR2I( 10, 10 ) );
448
449 return pts;
450}
451
452
453void PCB_SHAPE::Move( const VECTOR2I& aMoveVector )
454{
455 move( aMoveVector );
456}
457
458
459void PCB_SHAPE::Scale( double aScale )
460{
461 scale( aScale );
462}
463
464
466{
467 if( m_shape == SHAPE_T::RECTANGLE )
468 {
469 VECTOR2I start = GetStart();
470 VECTOR2I end = GetEnd();
471
472 BOX2I rect( start, end - start );
473 rect.Normalize();
474
475 SetStart( rect.GetPosition() );
476 SetEnd( rect.GetEnd() );
477 }
478 else if( m_shape == SHAPE_T::POLY )
479 {
480 auto horizontal =
481 []( const SEG& seg )
482 {
483 return seg.A.y == seg.B.y;
484 };
485
486 auto vertical =
487 []( const SEG& seg )
488 {
489 return seg.A.x == seg.B.x;
490 };
491
492 // Convert a poly back to a rectangle if appropriate
493 if( m_poly.OutlineCount() == 1 && m_poly.Outline( 0 ).SegmentCount() == 4 )
494 {
495 SHAPE_LINE_CHAIN& outline = m_poly.Outline( 0 );
496
497 if( horizontal( outline.Segment( 0 ) )
498 && vertical( outline.Segment( 1 ) )
499 && horizontal( outline.Segment( 2 ) )
500 && vertical( outline.Segment( 3 ) ) )
501 {
502 m_shape = SHAPE_T::RECTANGLE;
503 m_start.x = std::min( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x );
504 m_start.y = std::min( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y );
505 m_end.x = std::max( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x );
506 m_end.y = std::max( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y );
507 }
508 else if( vertical( outline.Segment( 0 ) )
509 && horizontal( outline.Segment( 1 ) )
510 && vertical( outline.Segment( 2 ) )
511 && horizontal( outline.Segment( 3 ) ) )
512 {
513 m_shape = SHAPE_T::RECTANGLE;
514 m_start.x = std::min( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x );
515 m_start.y = std::min( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y );
516 m_end.x = std::max( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x );
517 m_end.y = std::max( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y );
518 }
519 }
520 }
521}
522
523
524void PCB_SHAPE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
525{
526 rotate( aRotCentre, aAngle );
527}
528
529
530void PCB_SHAPE::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
531{
532 flip( aCentre, aFlipLeftRight );
533
534 SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
535}
536
537
538void PCB_SHAPE::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
539{
540 // Mirror an edge of the footprint. the layer is not modified
541 // This is a footprint shape modification.
542
543 switch( GetShape() )
544 {
545 case SHAPE_T::ARC:
546 case SHAPE_T::SEGMENT:
547 case SHAPE_T::RECTANGLE:
548 case SHAPE_T::CIRCLE:
549 case SHAPE_T::BEZIER:
550 if( aMirrorAroundXAxis )
551 {
552 MIRROR( m_start.y, aCentre.y );
553 MIRROR( m_end.y, aCentre.y );
554 MIRROR( m_arcCenter.y, aCentre.y );
555 MIRROR( m_bezierC1.y, aCentre.y );
556 MIRROR( m_bezierC2.y, aCentre.y );
557 }
558 else
559 {
560 MIRROR( m_start.x, aCentre.x );
561 MIRROR( m_end.x, aCentre.x );
562 MIRROR( m_arcCenter.x, aCentre.x );
563 MIRROR( m_bezierC1.x, aCentre.x );
564 MIRROR( m_bezierC2.x, aCentre.x );
565 }
566
567 if( GetShape() == SHAPE_T::ARC )
568 std::swap( m_start, m_end );
569
570 if( GetShape() == SHAPE_T::BEZIER )
572
573 break;
574
575 case SHAPE_T::POLY:
576 m_poly.Mirror( !aMirrorAroundXAxis, aMirrorAroundXAxis, aCentre );
577 break;
578
579 default:
581 }
582}
583
584
585void PCB_SHAPE::SetIsProxyItem( bool aIsProxy )
586{
587 PAD* parentPad = nullptr;
588
589 if( GetBoard() && GetBoard()->IsFootprintHolder() )
590 {
591 for( FOOTPRINT* fp : GetBoard()->Footprints() )
592 {
593 for( PAD* pad : fp->Pads() )
594 {
595 if( pad->IsEntered() )
596 {
597 parentPad = pad;
598 break;
599 }
600 }
601 }
602 }
603
604 if( aIsProxy && !m_proxyItem )
605 {
606 if( GetShape() == SHAPE_T::SEGMENT )
607 {
608 if( parentPad && parentPad->GetThermalSpokeWidth() )
609 SetWidth( parentPad->GetThermalSpokeWidth() );
610 else
612 }
613 else
614 {
615 SetWidth( 1 );
616 }
617 }
618 else if( m_proxyItem && !aIsProxy )
619 {
621 }
622
623 m_proxyItem = aIsProxy;
624}
625
626
627double PCB_SHAPE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
628{
629 constexpr double HIDE = std::numeric_limits<double>::max();
630 constexpr double SHOW = 0.0;
631
632 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() );
633 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
634
635 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
636 {
637 // Hide shadow if the main layer is not shown
638 if( !aView->IsLayerVisible( m_layer ) )
639 return HIDE;
640
641 // Hide shadow on dimmed tracks
642 if( renderSettings->GetHighContrast() )
643 {
644 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
645 return HIDE;
646 }
647 }
648
649 if( FOOTPRINT* parent = GetParentFootprint() )
650 {
651 if( parent->GetLayer() == F_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
652 return HIDE;
653
654 if( parent->GetLayer() == B_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
655 return HIDE;
656 }
657
658 return SHOW;
659}
660
661
662void PCB_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const
663{
664 aLayers[0] = GetLayer();
665
666 if( IsOnCopperLayer() )
667 {
668 aLayers[1] = GetNetnameLayer( aLayers[0] );
669 aCount = 2;
670 }
671 else
672 {
673 aCount = 1;
674 }
675
676 if( IsLocked() )
677 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
678}
679
680
681void PCB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
682{
683 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
684 {
685 if( FOOTPRINT* parent = GetParentFootprint() )
686 aList.emplace_back( _( "Footprint" ), parent->GetReference() );
687 }
688
689 aList.emplace_back( _( "Type" ), _( "Drawing" ) );
690
691 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
692 aList.emplace_back( _( "Status" ), _( "Locked" ) );
693
694 ShapeGetMsgPanelInfo( aFrame, aList );
695
696 aList.emplace_back( _( "Layer" ), GetLayerName() );
697}
698
699
700wxString PCB_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
701{
702 if( GetNetCode() > 0 )
703 {
704 return wxString::Format( _( "%s %s on %s" ), GetFriendlyName(), GetNetnameMsg(),
705 GetLayerName() );
706 }
707 else
708 {
709 return wxString::Format( _( "%s on %s" ), GetFriendlyName(), GetLayerName() );
710 }
711}
712
713
715{
716 if( GetParentFootprint() )
717 return BITMAPS::show_mod_edge;
718 else
719 return BITMAPS::add_dashed_line;
720}
721
722
724{
725 return new PCB_SHAPE( *this );
726}
727
728
730{
731 BOX2I return_box = EDA_ITEM::ViewBBox();
732
733 // Inflate the bounding box by just a bit more for safety.
734 return_box.Inflate( GetWidth() );
735
736 return return_box;
737}
738
739
740std::shared_ptr<SHAPE> PCB_SHAPE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
741{
742 return std::make_shared<SHAPE_COMPOUND>( MakeEffectiveShapes() );
743}
744
745
747{
748 PCB_SHAPE* image = dynamic_cast<PCB_SHAPE*>( aImage );
749 wxCHECK( image, /* void */ );
750
751 SwapShape( image );
752
753 // Swap params not handled by SwapShape( image )
754 std::swap( m_layer, image->m_layer );
755 std::swap( m_isKnockout, image->m_isKnockout );
756 std::swap( m_isLocked, image->m_isLocked );
757 std::swap( m_flags, image->m_flags );
758 std::swap( m_parent, image->m_parent );
759 std::swap( m_forceVisible, image->m_forceVisible );
760 std::swap( m_netinfo, image->m_netinfo );
761}
762
763
765 const BOARD_ITEM* aSecond ) const
766{
767 if( aFirst->Type() != aSecond->Type() )
768 return aFirst->Type() < aSecond->Type();
769
770 if( aFirst->GetLayer() != aSecond->GetLayer() )
771 return aFirst->GetLayer() < aSecond->GetLayer();
772
773 if( aFirst->Type() == PCB_SHAPE_T )
774 {
775 const PCB_SHAPE* dwgA = static_cast<const PCB_SHAPE*>( aFirst );
776 const PCB_SHAPE* dwgB = static_cast<const PCB_SHAPE*>( aSecond );
777
778 if( dwgA->GetShape() != dwgB->GetShape() )
779 return dwgA->GetShape() < dwgB->GetShape();
780 }
781
782 return aFirst->m_Uuid < aSecond->m_Uuid;
783}
784
785
787 int aClearance, int aError, ERROR_LOC aErrorLoc,
788 bool ignoreLineWidth ) const
789{
790 EDA_SHAPE::TransformShapeToPolygon( aBuffer, aClearance, aError, aErrorLoc, ignoreLineWidth );
791}
792
793
794bool PCB_SHAPE::operator==( const BOARD_ITEM& aOther ) const
795{
796 if( aOther.Type() != Type() )
797 return false;
798
799 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
800
801 if( m_layer != other.m_layer )
802 return false;
803
804 if( m_isKnockout != other.m_isKnockout )
805 return false;
806
807 if( m_isLocked != other.m_isLocked )
808 return false;
809
810 if( m_flags != other.m_flags )
811 return false;
812
813 if( m_forceVisible != other.m_forceVisible )
814 return false;
815
816 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
817 return false;
818
819 return EDA_SHAPE::operator==( other );
820}
821
822
823double PCB_SHAPE::Similarity( const BOARD_ITEM& aOther ) const
824{
825 if( aOther.Type() != Type() )
826 return 0.0;
827
828 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
829
830 double similarity = 1.0;
831
832 if( GetLayer() != other.GetLayer() )
833 similarity *= 0.9;
834
835 if( m_isKnockout != other.m_isKnockout )
836 similarity *= 0.9;
837
838 if( m_isLocked != other.m_isLocked )
839 similarity *= 0.9;
840
841 if( m_flags != other.m_flags )
842 similarity *= 0.9;
843
844 if( m_forceVisible != other.m_forceVisible )
845 similarity *= 0.9;
846
847 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
848 similarity *= 0.9;
849
850 similarity *= EDA_SHAPE::Similarity( other );
851
852 return similarity;
853}
854
855
856static struct PCB_SHAPE_DESC
857{
859 {
866
867 // Need to initialise enum_map before we can use a Property enum for it
869
870 if( layerEnum.Choices().GetCount() == 0 )
871 {
872 layerEnum.Undefined( UNDEFINED_LAYER );
873
874 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
875 layerEnum.Map( *seq, LSET::Name( *seq ) );
876 }
877
878 void ( PCB_SHAPE::*shapeLayerSetter )( PCB_LAYER_ID ) = &PCB_SHAPE::SetLayer;
879 PCB_LAYER_ID ( PCB_SHAPE::*shapeLayerGetter )() const = &PCB_SHAPE::GetLayer;
880
881 auto layerProperty = new PROPERTY_ENUM<PCB_SHAPE, PCB_LAYER_ID>(
882 _HKI( "Layer" ), shapeLayerSetter, shapeLayerGetter );
883
884 propMgr.ReplaceProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ), layerProperty );
885
886 // Only polygons have meaningful Position properties.
887 // On other shapes, these are duplicates of the Start properties.
888 auto isPolygon =
889 []( INSPECTABLE* aItem ) -> bool
890 {
891 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
892 return shape->GetShape() == SHAPE_T::POLY;
893
894 return false;
895 };
896
898 _HKI( "Position X" ), isPolygon );
900 _HKI( "Position Y" ), isPolygon );
901
902 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Color" ) );
903 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Fill Color" ) );
904
905 auto isCopper =
906 []( INSPECTABLE* aItem ) -> bool
907 {
908 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
909 return shape->IsOnCopperLayer();
910
911 return false;
912 };
913
915 _HKI( "Net" ), isCopper );
916
917 auto isPadEditMode =
918 []( BOARD* aBoard ) -> bool
919 {
920 if( aBoard && aBoard->IsFootprintHolder() )
921 {
922 for( FOOTPRINT* fp : aBoard->Footprints() )
923 {
924 for( PAD* pad : fp->Pads() )
925 {
926 if( pad->IsEntered() )
927 return true;
928 }
929 }
930 }
931
932 return false;
933 };
934
935 auto showNumberBoxProperty =
936 [&]( INSPECTABLE* aItem ) -> bool
937 {
938 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
939 {
940 if( shape->GetShape() == SHAPE_T::RECTANGLE )
941 return isPadEditMode( shape->GetBoard() );
942 }
943
944 return false;
945 };
946
947 auto showSpokeTemplateProperty =
948 [&]( INSPECTABLE* aItem ) -> bool
949 {
950 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
951 {
952 if( shape->GetShape() == SHAPE_T::SEGMENT )
953 return isPadEditMode( shape->GetBoard() );
954 }
955
956 return false;
957 };
958
959 const wxString groupPadPrimitives = _HKI( "Pad Primitives" );
960
961 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Number Box" ),
964 groupPadPrimitives )
965 .SetAvailableFunc( showNumberBoxProperty )
967
968 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Thermal Spoke Template" ),
971 groupPadPrimitives )
972 .SetAvailableFunc( showSpokeTemplateProperty )
974 }
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
#define DEFAULT_LINE_WIDTH
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetnameMsg() const
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
NETINFO_ITEM * m_netinfo
Store all information about the net that item belongs to.
Container for design settings for a BOARD object.
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:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:231
bool m_isKnockout
Definition: board_item.h:399
virtual void SetLocked(bool aLocked)
Definition: board_item.h:305
PCB_LAYER_ID m_layer
Definition: board_item.h:398
bool m_isLocked
Definition: board_item.h:401
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:265
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
virtual bool IsLocked() const
Definition: board_item.cpp:74
virtual bool IsOnCopperLayer() const
Definition: board_item.h:151
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:103
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:136
const Vec & GetPosition() const
Definition: box2.h:201
const Vec GetEnd() const
Definition: box2.h:202
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:541
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
const KIID m_Uuid
Definition: eda_item.h:485
bool m_forceVisible
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:490
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:175
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: eda_item.cpp:273
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:488
SHAPE_T m_shape
Definition: eda_shape.h:411
bool m_proxyItem
Definition: eda_shape.h:435
bool m_endsSwapped
Definition: eda_shape.h:410
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:201
void SetBezierC2(const VECTOR2I &aPt)
Definition: eda_shape.h:200
int m_editState
Definition: eda_shape.h:434
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Definition: eda_shape.cpp:364
void flip(const VECTOR2I &aCentre, bool aFlipLeftRight)
Definition: eda_shape.cpp:421
FILL_T GetFillMode() const
Definition: eda_shape.h:102
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
Definition: eda_shape.cpp:506
void SetLineStyle(const LINE_STYLE aStyle)
Definition: eda_shape.cpp:1814
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:316
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:274
bool IsFilled() const
Definition: eda_shape.h:91
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:759
void SetFilled(bool aFlag)
Definition: eda_shape.h:96
bool operator==(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:1829
int GetRadius() const
Definition: eda_shape.cpp:619
SHAPE_T GetShape() const
Definition: eda_shape.h:120
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:282
VECTOR2I m_arcCenter
Definition: eda_shape.h:425
ARC_MID m_arcMidData
Definition: eda_shape.h:426
VECTOR2I m_start
Definition: eda_shape.h:422
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:162
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:129
LINE_STYLE GetLineStyle() const
Definition: eda_shape.cpp:1820
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:125
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:119
void SwapShape(EDA_SHAPE *aImage)
Definition: eda_shape.cpp:1631
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1165
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:166
void SetBezierC1(const VECTOR2I &aPt)
Definition: eda_shape.h:197
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
Definition: eda_shape.cpp:651
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:89
double Similarity(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:1874
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:198
VECTOR2I m_end
Definition: eda_shape.h:423
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:432
virtual int GetWidth() const
Definition: eda_shape.h:110
STROKE_PARAMS m_stroke
Definition: eda_shape.h:412
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the shape to a closed polygon.
Definition: eda_shape.cpp:1695
VECTOR2I m_bezierC1
Definition: eda_shape.h:428
void SetWidth(int aWidth)
Definition: eda_shape.h:109
VECTOR2I m_bezierC2
Definition: eda_shape.h:429
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:589
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:669
static ENUM_MAP< T > & Instance()
Definition: property.h:663
ENUM_MAP & Undefined(T aValue)
Definition: property.h:676
wxPGChoices & Choices()
Definition: property.h:712
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:36
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:165
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:170
PCB specific render settings.
Definition: pcb_painter.h:78
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:412
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:263
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:521
static LSET AllLayersMask()
Definition: lset.cpp:898
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:89
int GetNetCode() const
Definition: netinfo.h:108
Definition: pad.h:53
int GetThermalSpokeWidth() const
Definition: pad.h:554
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition: pcb_shape.cpp:794
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.
Definition: pcb_shape.cpp:681
void swapData(BOARD_ITEM *aImage) override
Definition: pcb_shape.cpp:746
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: pcb_shape.cpp:308
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_shape.cpp:530
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:75
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:524
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_shape.cpp:714
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T aItemType, SHAPE_T aShapeType)
Definition: pcb_shape.cpp:47
int GetWidth() const override
Definition: pcb_shape.cpp:367
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_shape.cpp:729
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
Definition: pcb_shape.cpp:740
void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: pcb_shape.cpp:662
const VECTOR2I GetFocusPosition() const override
Allows items to return their visual center rather than their anchor.
Definition: pcb_shape.cpp:383
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pcb_shape.cpp:700
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:425
bool IsProxyItem() const override
Definition: pcb_shape.h:110
~PCB_SHAPE() override
Definition: pcb_shape.cpp:61
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:315
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.
Definition: pcb_shape.cpp:786
void SetIsProxyItem(bool aIsProxy=true) override
Definition: pcb_shape.cpp:585
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_shape.cpp:377
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:453
std::vector< VECTOR2I > GetConnectionPoints() const
Definition: pcb_shape.cpp:324
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_shape.cpp:179
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_shape.cpp:723
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_shape.cpp:627
virtual void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_shape.cpp:538
void Scale(double aScale)
Definition: pcb_shape.cpp:459
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_shape.cpp:66
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
Definition: pcb_shape.cpp:465
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pcb_shape.cpp:276
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_shape.cpp:823
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:257
PROPERTY_BASE & SetIsHiddenFromRulesEditor(bool aHide=true)
Definition: property.h:307
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
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()
Definition: property_mgr.h:87
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:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
SEG Segment(int aIndex) const
Return a copy of the aIndex-th segment in the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
int AddPolygon(const POLYGON &apolygon)
Adds a polygon to the set.
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
void SetWidth(int aWidth)
Definition: stroke_params.h:92
#define _HKI(x)
#define _(s)
#define PCB_EDIT_FRAME_NAME
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:55
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:149
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:1022
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:243
@ LAYER_FOOTPRINTS_FR
show footprints on front
Definition: layer_ids.h:212
@ LAYER_FOOTPRINTS_BK
show footprints on back
Definition: layer_ids.h:213
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:634
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
void PackVector2(kiapi::common::types::Vector2 &aOutput, const VECTOR2I aInput)
Definition: api_utils.cpp:69
VECTOR2I UnpackVector2(const types::Vector2 &aInput)
Definition: api_utils.cpp:75
void PackPolyLine(kiapi::common::types::PolyLine &aOutput, const SHAPE_LINE_CHAIN &aSlc)
Definition: api_utils.cpp:81
SHAPE_LINE_CHAIN UnpackPolyLine(const kiapi::common::types::PolyLine &aInput)
Definition: api_utils.cpp:111
static struct PCB_SHAPE_DESC _PCB_SHAPE_DESC
static bool isCopper(const PNS::ITEM *aItem)
#define TYPE_HASH(x)
Definition: property.h:71
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
const int scale
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition: pcb_shape.cpp:764
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_LOCATE_BOARD_EDGE_T
Definition: typeinfo.h:130
@ PCB_SHAPE_LOCATE_CIRCLE_T
Definition: typeinfo.h:135
@ PCB_SHAPE_LOCATE_SEGMENT_T
Definition: typeinfo.h:133
@ PCB_SHAPE_LOCATE_RECT_T
Definition: typeinfo.h:134
@ PCB_SHAPE_LOCATE_BEZIER_T
Definition: typeinfo.h:138
@ PCB_SHAPE_LOCATE_POLY_T
Definition: typeinfo.h:137
@ PCB_SHAPE_LOCATE_ARC_T
Definition: typeinfo.h:136
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MM
Definition: zones.h:34