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