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, 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 "pcb_shape.h"
28
29#include <google/protobuf/any.pb.h>
30#include <magic_enum.hpp>
31
32#include <bitmaps.h>
33#include <macros.h>
34#include <pcb_edit_frame.h>
36#include <board.h>
37#include <footprint.h>
38#include <lset.h>
39#include <pad.h>
40#include <base_units.h>
45#include <pcb_painter.h>
46#include <api/board/board_types.pb.h>
47#include <api/api_enums.h>
48#include <api/api_utils.h>
49
50
51PCB_SHAPE::PCB_SHAPE( BOARD_ITEM* aParent, KICAD_T aItemType, SHAPE_T aShapeType ) :
52 BOARD_CONNECTED_ITEM( aParent, aItemType ),
53 EDA_SHAPE( aShapeType, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL )
54{
55 m_hasSolderMask = false;
56}
57
58
59PCB_SHAPE::PCB_SHAPE( BOARD_ITEM* aParent, SHAPE_T shapetype ) :
61 EDA_SHAPE( shapetype, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL )
62{
63 m_hasSolderMask = false;
64}
65
66
68{
69}
70
71
72void PCB_SHAPE::CopyFrom( const BOARD_ITEM* aOther )
73{
74 wxCHECK( aOther && aOther->Type() == PCB_SHAPE_T, /* void */ );
75 *this = *static_cast<const PCB_SHAPE*>( aOther );
76}
77
78
79void PCB_SHAPE::Serialize( google::protobuf::Any &aContainer ) const
80{
81 using namespace kiapi::common;
82 using namespace kiapi::board::types;
83 BoardGraphicShape msg;
84
85 msg.set_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( GetLayer() ) );
86 msg.mutable_net()->mutable_code()->set_value( GetNetCode() );
87 msg.mutable_net()->set_name( GetNetname() );
88 msg.mutable_id()->set_value( m_Uuid.AsStdString() );
89 msg.set_locked( IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
90
91 google::protobuf::Any any;
93 any.UnpackTo( msg.mutable_shape() );
94
95 // TODO m_hasSolderMask and m_solderMaskMargin
96
97 aContainer.PackFrom( msg );
98}
99
100
101bool PCB_SHAPE::Deserialize( const google::protobuf::Any &aContainer )
102{
103 using namespace kiapi::common;
104 using namespace kiapi::board::types;
105
106 BoardGraphicShape msg;
107
108 if( !aContainer.UnpackTo( &msg ) )
109 return false;
110
111 // Initialize everything to a known state that doesn't get touched by every
112 // codepath below, to make sure the equality operator is consistent
113 m_start = {};
114 m_end = {};
115 m_arcCenter = {};
116 m_arcMidData = {};
117 m_bezierC1 = {};
118 m_bezierC2 = {};
119 m_editState = 0;
120 m_proxyItem = false;
121 m_endsSwapped = false;
122
123 const_cast<KIID&>( m_Uuid ) = KIID( msg.id().value() );
124 SetLocked( msg.locked() == types::LS_LOCKED );
125 SetLayer( FromProtoEnum<PCB_LAYER_ID, BoardLayer>( msg.layer() ) );
126 SetNetCode( msg.net().code().value() );
127
128 google::protobuf::Any any;
129 any.PackFrom( msg.shape() );
131
132 // TODO m_hasSolderMask and m_solderMaskMargin
133
134 return true;
135}
136
137
138bool PCB_SHAPE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
139{
140 if( BOARD_ITEM::IsType( aScanTypes ) )
141 return true;
142
143 bool sametype = false;
144
145 for( KICAD_T scanType : aScanTypes )
146 {
147 if( scanType == PCB_LOCATE_BOARD_EDGE_T )
148 sametype = m_layer == Edge_Cuts;
149 else if( scanType == PCB_SHAPE_LOCATE_ARC_T )
150 sametype = m_shape == SHAPE_T::ARC;
151 else if( scanType == PCB_SHAPE_LOCATE_CIRCLE_T )
152 sametype = m_shape == SHAPE_T::CIRCLE;
153 else if( scanType == PCB_SHAPE_LOCATE_RECT_T )
154 sametype = m_shape == SHAPE_T::RECTANGLE;
155 else if( scanType == PCB_SHAPE_LOCATE_SEGMENT_T )
156 sametype = m_shape == SHAPE_T::SEGMENT;
157 else if( scanType == PCB_SHAPE_LOCATE_POLY_T )
158 sametype = m_shape == SHAPE_T::POLY;
159 else if( scanType == PCB_SHAPE_LOCATE_BEZIER_T )
160 sametype = m_shape == SHAPE_T::BEZIER;
161
162 if( sametype )
163 return true;
164 }
165
166 return false;
167}
168
169
171{
172 // Only board-level copper shapes are connectable
173 return IsOnCopperLayer() && !GetParentFootprint();
174}
175
176
178{
179 BOARD_ITEM::SetLayer( aLayer );
180
181 if( !IsOnCopperLayer() )
182 SetNetCode( -1 );
183}
184
185
187{
188 int margin = m_solderMaskMargin.value_or( 0 );
189
190 // If no local margin is set, get the board's solder mask expansion value
191 if( !m_solderMaskMargin.has_value() )
192 {
193 const BOARD* board = GetBoard();
194
195 if( board )
197 }
198
199 // Ensure the resulting mask opening has a non-negative size
200 if( margin < 0 && !IsSolidFill() )
201 margin = std::max( margin, -GetWidth() / 2 );
202
203 return margin;
204}
205
206
208{
209 if( aLayer == m_layer )
210 {
211 return true;
212 }
213
215 && ( ( aLayer == F_Mask && m_layer == F_Cu )
216 || ( aLayer == B_Mask && m_layer == B_Cu ) ) )
217 {
218 return true;
219 }
220
221 return false;
222}
223
224
226{
227 LSET layermask( { m_layer } );
228
229 if( m_hasSolderMask )
230 {
231 if( layermask.test( F_Cu ) )
232 layermask.set( F_Mask );
233
234 if( layermask.test( B_Cu ) )
235 layermask.set( B_Mask );
236 }
237
238 return layermask;
239}
240
241
242void PCB_SHAPE::SetLayerSet( const LSET& aLayerSet )
243{
244 aLayerSet.RunOnLayers(
245 [&]( PCB_LAYER_ID layer )
246 {
247 if( IsCopperLayer( layer ) )
248 SetLayer( layer );
249 else if( IsSolderMaskLayer( layer ) )
250 SetHasSolderMask( true );
251 } );
252}
253
254
255std::vector<VECTOR2I> PCB_SHAPE::GetConnectionPoints() const
256{
257 std::vector<VECTOR2I> ret;
258
259 // For filled shapes, we may as well use a centroid
260 if( IsSolidFill() )
261 {
262 ret.emplace_back( GetCenter() );
263 return ret;
264 }
265
266 switch( m_shape )
267 {
268 case SHAPE_T::CIRCLE:
269 {
270 const CIRCLE circle( GetCenter(), GetRadius() );
271
272 for( const TYPED_POINT2I& pt : KIGEOM::GetCircleKeyPoints( circle, false ) )
273 ret.emplace_back( pt.m_point );
274
275 break;
276 }
277
278 case SHAPE_T::ARC:
279 ret.emplace_back( GetArcMid() );
281 case SHAPE_T::SEGMENT:
282 case SHAPE_T::BEZIER:
283 ret.emplace_back( GetStart() );
284 ret.emplace_back( GetEnd() );
285 break;
286
287 case SHAPE_T::POLY:
288 for( auto iter = GetPolyShape().CIterate(); iter; ++iter )
289 ret.emplace_back( *iter );
290
291 break;
292
293 case SHAPE_T::RECTANGLE:
294 for( const VECTOR2I& pt : GetRectCorners() )
295 ret.emplace_back( pt );
296
297 break;
298
299 case SHAPE_T::UNDEFINED:
301 break;
302 }
303
304 return ret;
305}
306
307
309{
310 // Force update; we don't bother to propagate damage from all the things that might
311 // knock-out parts of our hatching.
312 m_hatchingDirty = true;
313
315
316 if( !m_hatching.IsEmpty() )
317 {
318 PCB_LAYER_ID layer = GetLayer();
319 BOX2I bbox = GetBoundingBox();
320 SHAPE_POLY_SET holes;
321 int maxError = ARC_LOW_DEF;
322
323 auto knockoutItem =
324 [&]( BOARD_ITEM* item )
325 {
326 int margin = GetHatchLineSpacing() / 2;
327
328 if( item->Type() == PCB_TEXTBOX_T )
329 margin = 0;
330
331 item->TransformShapeToPolygon( holes, layer, margin, maxError, ERROR_OUTSIDE );
332 };
333
334 for( BOARD_ITEM* item : GetBoard()->Drawings() )
335 {
336 if( item == this )
337 continue;
338
339 if( item->Type() == PCB_FIELD_T
340 || item->Type() == PCB_TEXT_T
341 || item->Type() == PCB_TEXTBOX_T
342 || item->Type() == PCB_SHAPE_T )
343 {
344 if( item->GetLayer() == layer && item->GetBoundingBox().Intersects( bbox ) )
345 knockoutItem( item );
346 }
347 }
348
349 for( FOOTPRINT* footprint : GetBoard()->Footprints() )
350 {
351 if( footprint == GetParentFootprint() )
352 continue;
353
354 // Knockout footprint courtyard
355 holes.Append( footprint->GetCourtyard( layer ) );
356
357 // Knockout footprint fields
358 footprint->RunOnChildren(
359 [&]( BOARD_ITEM* item )
360 {
361 if( ( item->Type() == PCB_FIELD_T || item->Type() == PCB_SHAPE_T )
362 && item->GetLayer() == layer
363 && item->GetBoundingBox().Intersects( bbox ) )
364 {
365 knockoutItem( item );
366 }
367 },
368 RECURSE_MODE::RECURSE );
369 }
370
371 if( !holes.IsEmpty() )
372 {
375 }
376 }
377}
378
379
381{
382 // A stroke width of 0 in PCBNew means no-border, but negative stroke-widths are only used
383 // in EEschema (see SCH_SHAPE::GetPenWidth()).
384 // Since negative stroke widths can trip up down-stream code (such as the Gerber plotter), we
385 // weed them out here.
386 return std::max( EDA_SHAPE::GetWidth(), 0 );
387}
388
389
391{
393}
394
395
397{
398 // For some shapes return the visual center, but for not filled polygonal shapes,
399 // the center is usually far from the shape: a point on the outline is better
400
401 switch( m_shape )
402 {
403 case SHAPE_T::CIRCLE:
404 if( !IsAnyFill() )
405 return VECTOR2I( GetCenter().x + GetRadius(), GetCenter().y );
406 else
407 return GetCenter();
408
409 case SHAPE_T::RECTANGLE:
410 if( !IsAnyFill() )
411 return GetStart();
412 else
413 return GetCenter();
414
415 case SHAPE_T::POLY:
416 if( !IsAnyFill() )
417 {
418 VECTOR2I pos = GetPolyShape().Outline(0).CPoint(0);
419 return VECTOR2I( pos.x, pos.y );
420 }
421 else
422 {
423 return GetCenter();
424 }
425
426 case SHAPE_T::ARC:
427 return GetArcMid();
428
429 case SHAPE_T::BEZIER:
430 return GetStart();
431
432 default:
433 return GetCenter();
434 }
435}
436
437
438std::vector<VECTOR2I> PCB_SHAPE::GetCorners() const
439{
440 std::vector<VECTOR2I> pts;
441
442 if( GetShape() == SHAPE_T::RECTANGLE )
443 {
444 pts = GetRectCorners();
445 }
446 else if( GetShape() == SHAPE_T::POLY )
447 {
448 for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii )
449 {
450 for( const VECTOR2I& pt : GetPolyShape().Outline( ii ).CPoints() )
451 pts.emplace_back( pt );
452 }
453 }
454 else
455 {
457 }
458
459 while( pts.size() < 4 )
460 pts.emplace_back( pts.back() + VECTOR2I( 10, 10 ) );
461
462 return pts;
463}
464
465
466void PCB_SHAPE::Move( const VECTOR2I& aMoveVector )
467{
468 move( aMoveVector );
469}
470
471
472void PCB_SHAPE::Scale( double aScale )
473{
474 scale( aScale );
475}
476
477
479{
480 if( m_shape == SHAPE_T::RECTANGLE )
481 {
482 VECTOR2I start = GetStart();
483 VECTOR2I end = GetEnd();
484
485 BOX2I rect( start, end - start );
486 rect.Normalize();
487
488 SetStart( rect.GetPosition() );
489 SetEnd( rect.GetEnd() );
490 }
491 else if( m_shape == SHAPE_T::POLY )
492 {
493 auto horizontal =
494 []( const SEG& seg )
495 {
496 return seg.A.y == seg.B.y;
497 };
498
499 auto vertical =
500 []( const SEG& seg )
501 {
502 return seg.A.x == seg.B.x;
503 };
504
505 // Convert a poly back to a rectangle if appropriate
506 if( m_poly.OutlineCount() == 1 && m_poly.Outline( 0 ).SegmentCount() == 4 )
507 {
508 SHAPE_LINE_CHAIN& outline = m_poly.Outline( 0 );
509
510 if( horizontal( outline.Segment( 0 ) )
511 && vertical( outline.Segment( 1 ) )
512 && horizontal( outline.Segment( 2 ) )
513 && vertical( outline.Segment( 3 ) ) )
514 {
515 m_shape = SHAPE_T::RECTANGLE;
516 m_start.x = std::min( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x );
517 m_start.y = std::min( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y );
518 m_end.x = std::max( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x );
519 m_end.y = std::max( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y );
520 }
521 else if( vertical( outline.Segment( 0 ) )
522 && horizontal( outline.Segment( 1 ) )
523 && vertical( outline.Segment( 2 ) )
524 && horizontal( outline.Segment( 3 ) ) )
525 {
526 m_shape = SHAPE_T::RECTANGLE;
527 m_start.x = std::min( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x );
528 m_start.y = std::min( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y );
529 m_end.x = std::max( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x );
530 m_end.y = std::max( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y );
531 }
532 }
533 }
534}
535
536
538{
539 if( m_shape == SHAPE_T::SEGMENT )
540 {
541 // we want start point the top left point and end point the bottom right
542 // (more easy to compare 2 segments: we are seeing them as equivalent if
543 // they have the same end points, not necessary the same order)
544 VECTOR2I start = GetStart();
545 VECTOR2I end = GetEnd();
546
547 if( ( start.x > end.x )
548 || ( start.x == end.x && start.y < end.y ) )
549 {
550 SetStart( end );
551 SetEnd( start );
552 }
553 }
554 else
555 Normalize();
556}
557
558
559void PCB_SHAPE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
560{
561 rotate( aRotCentre, aAngle );
562}
563
564
565void PCB_SHAPE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
566{
567 flip( aCentre, aFlipDirection );
568
570}
571
572
573void PCB_SHAPE::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
574{
575 // Mirror an edge of the footprint. the layer is not modified
576 // This is a footprint shape modification.
577
578 switch( GetShape() )
579 {
580 case SHAPE_T::ARC:
581 case SHAPE_T::SEGMENT:
582 case SHAPE_T::RECTANGLE:
583 case SHAPE_T::CIRCLE:
584 case SHAPE_T::BEZIER:
585 MIRROR( m_start, aCentre, aFlipDirection );
586 MIRROR( m_end, aCentre, aFlipDirection );
587 MIRROR( m_arcCenter, aCentre, aFlipDirection );
588 MIRROR( m_bezierC1, aCentre, aFlipDirection );
589 MIRROR( m_bezierC2, aCentre, aFlipDirection );
590
591 if( GetShape() == SHAPE_T::ARC )
592 std::swap( m_start, m_end );
593
594 if( GetShape() == SHAPE_T::BEZIER )
596
597 break;
598
599 case SHAPE_T::POLY:
600 m_poly.Mirror( aCentre, aFlipDirection );
601 break;
602
603 default:
605 }
606}
607
608
609void PCB_SHAPE::SetIsProxyItem( bool aIsProxy )
610{
611 PAD* parentPad = nullptr;
612
613 if( GetBoard() && GetBoard()->IsFootprintHolder() )
614 {
615 for( FOOTPRINT* fp : GetBoard()->Footprints() )
616 {
617 for( PAD* pad : fp->Pads() )
618 {
619 if( pad->IsEntered() )
620 {
621 parentPad = pad;
622 break;
623 }
624 }
625 }
626 }
627
628 if( aIsProxy && !m_proxyItem )
629 {
630 if( GetShape() == SHAPE_T::SEGMENT )
631 {
632 if( parentPad && parentPad->GetLocalThermalSpokeWidthOverride().has_value() )
633 SetWidth( parentPad->GetLocalThermalSpokeWidthOverride().value() );
634 else
636 }
637 else
638 {
639 SetWidth( 1 );
640 }
641 }
642 else if( m_proxyItem && !aIsProxy )
643 {
645 }
646
647 m_proxyItem = aIsProxy;
648}
649
650
651double PCB_SHAPE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
652{
653 KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
654 KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
655
656 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
657 {
658 // Hide shadow if the main layer is not shown
659 if( !aView->IsLayerVisible( m_layer ) )
660 return LOD_HIDE;
661
662 // Hide shadow on dimmed tracks
663 if( renderSettings.GetHighContrast() )
664 {
665 if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
666 return LOD_HIDE;
667 }
668 }
669
670 if( FOOTPRINT* parent = GetParentFootprint() )
671 {
672 if( parent->GetLayer() == F_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
673 return LOD_HIDE;
674
675 if( parent->GetLayer() == B_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
676 return LOD_HIDE;
677 }
678
679 return LOD_SHOW;
680}
681
682
683std::vector<int> PCB_SHAPE::ViewGetLayers() const
684{
685 std::vector<int> layers;
686 layers.reserve( 4 );
687
688 layers.push_back( GetLayer() );
689
690 if( IsOnCopperLayer() )
691 {
692 layers.push_back( GetNetnameLayer( GetLayer() ) );
693
694 if( m_hasSolderMask )
695 {
696 if( m_layer == F_Cu )
697 layers.push_back( F_Mask );
698 else if( m_layer == B_Cu )
699 layers.push_back( B_Mask );
700 }
701 }
702
704 layers.push_back( LAYER_LOCKED_ITEM_SHADOW );
705
706 return layers;
707}
708
709
710void PCB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
711{
712 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
713 {
714 if( FOOTPRINT* parent = GetParentFootprint() )
715 aList.emplace_back( _( "Footprint" ), parent->GetReference() );
716 }
717
718 aList.emplace_back( _( "Type" ), _( "Drawing" ) );
719
720 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
721 aList.emplace_back( _( "Status" ), _( "Locked" ) );
722
723 ShapeGetMsgPanelInfo( aFrame, aList );
724
725 aList.emplace_back( _( "Layer" ), GetLayerName() );
726}
727
728
729wxString PCB_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
730{
731 FOOTPRINT* parentFP = GetParentFootprint();
732
733 // Don't report parent footprint info from footprint editor, viewer, etc.
734 if( GetBoard() && GetBoard()->GetBoardUse() == BOARD_USE::FPHOLDER )
735 parentFP = nullptr;
736
737 if( IsOnCopperLayer() )
738 {
739 if( parentFP )
740 {
741 return wxString::Format( _( "%s %s of %s on %s" ),
744 parentFP->GetReference(),
745 GetLayerName() );
746 }
747 else
748 {
749 return wxString::Format( _( "%s %s on %s" ),
752 GetLayerName() );
753 }
754 }
755 else
756 {
757 if( parentFP )
758 {
759 return wxString::Format( _( "%s of %s on %s" ),
761 parentFP->GetReference(),
762 GetLayerName() );
763 }
764 else
765 {
766 return wxString::Format( _( "%s on %s" ),
768 GetLayerName() );
769 }
770 }
771}
772
773
775{
776 if( GetParentFootprint() )
777 return BITMAPS::show_mod_edge;
778 else
779 return BITMAPS::add_dashed_line;
780}
781
782
784{
785 return new PCB_SHAPE( *this );
786}
787
788
790{
791 BOX2I return_box = EDA_ITEM::ViewBBox();
792
793 // Inflate the bounding box by just a bit more for safety.
794 return_box.Inflate( GetWidth() );
795
796 return return_box;
797}
798
799
800std::shared_ptr<SHAPE> PCB_SHAPE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
801{
802 return std::make_shared<SHAPE_COMPOUND>( MakeEffectiveShapes() );
803}
804
805
807{
808 PCB_SHAPE* image = dynamic_cast<PCB_SHAPE*>( aImage );
809 wxCHECK( image, /* void */ );
810
811 SwapShape( image );
812
813 // Swap params not handled by SwapShape( image )
814 std::swap( m_layer, image->m_layer );
815 std::swap( m_isKnockout, image->m_isKnockout );
816 std::swap( m_isLocked, image->m_isLocked );
817 std::swap( m_flags, image->m_flags );
818 std::swap( m_parent, image->m_parent );
819 std::swap( m_forceVisible, image->m_forceVisible );
820 std::swap( m_netinfo, image->m_netinfo );
821 std::swap( m_hasSolderMask, image->m_hasSolderMask );
822 std::swap( m_solderMaskMargin, image->m_solderMaskMargin );
823}
824
825
827 const BOARD_ITEM* aSecond ) const
828{
829 if( aFirst->Type() != aSecond->Type() )
830 return aFirst->Type() < aSecond->Type();
831
832 if( aFirst->GetLayer() != aSecond->GetLayer() )
833 return aFirst->GetLayer() < aSecond->GetLayer();
834
835 if( aFirst->Type() == PCB_SHAPE_T )
836 {
837 const PCB_SHAPE* dwgA = static_cast<const PCB_SHAPE*>( aFirst );
838 const PCB_SHAPE* dwgB = static_cast<const PCB_SHAPE*>( aSecond );
839
840 if( dwgA->GetShape() != dwgB->GetShape() )
841 return dwgA->GetShape() < dwgB->GetShape();
842 }
843
844 return aFirst->m_Uuid < aSecond->m_Uuid;
845}
846
847
849 int aClearance, int aError, ERROR_LOC aErrorLoc,
850 bool ignoreLineWidth ) const
851{
852 EDA_SHAPE::TransformShapeToPolygon( aBuffer, aClearance, aError, aErrorLoc, ignoreLineWidth,
853 false );
854}
855
856
858 int aClearance, int aError, ERROR_LOC aErrorLoc ) const
859{
860 EDA_SHAPE::TransformShapeToPolygon( aBuffer, aClearance, aError, aErrorLoc, false, true );
861}
862
863
864bool PCB_SHAPE::operator==( const BOARD_ITEM& aOther ) const
865{
866 if( aOther.Type() != Type() )
867 return false;
868
869 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
870
871 return *this == other;
872}
873
874
875bool PCB_SHAPE::operator==( const PCB_SHAPE& aOther ) const
876{
877 if( aOther.Type() != Type() )
878 return false;
879
880 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
881
882 if( m_layer != other.m_layer )
883 return false;
884
885 if( m_isKnockout != other.m_isKnockout )
886 return false;
887
888 if( m_isLocked != other.m_isLocked )
889 return false;
890
891 if( m_flags != other.m_flags )
892 return false;
893
894 if( m_forceVisible != other.m_forceVisible )
895 return false;
896
897 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
898 return false;
899
900 if( m_hasSolderMask != other.m_hasSolderMask )
901 return false;
902
904 return false;
905
906 return EDA_SHAPE::operator==( other );
907}
908
909
910double PCB_SHAPE::Similarity( const BOARD_ITEM& aOther ) const
911{
912 if( aOther.Type() != Type() )
913 return 0.0;
914
915 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
916
917 double similarity = 1.0;
918
919 if( GetLayer() != other.GetLayer() )
920 similarity *= 0.9;
921
922 if( m_isKnockout != other.m_isKnockout )
923 similarity *= 0.9;
924
925 if( m_isLocked != other.m_isLocked )
926 similarity *= 0.9;
927
928 if( m_flags != other.m_flags )
929 similarity *= 0.9;
930
931 if( m_forceVisible != other.m_forceVisible )
932 similarity *= 0.9;
933
934 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
935 similarity *= 0.9;
936
937 if( m_hasSolderMask != other.m_hasSolderMask )
938 similarity *= 0.9;
939
941 similarity *= 0.9;
942
943 similarity *= EDA_SHAPE::Similarity( other );
944
945 return similarity;
946}
947
948
949static struct PCB_SHAPE_DESC
950{
952 {
959
960 // Need to initialise enum_map before we can use a Property enum for it
962
963 if( layerEnum.Choices().GetCount() == 0 )
964 {
965 layerEnum.Undefined( UNDEFINED_LAYER );
966
967 for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
968 layerEnum.Map( layer, LSET::Name( layer ) );
969 }
970
971 void ( PCB_SHAPE::*shapeLayerSetter )( PCB_LAYER_ID ) = &PCB_SHAPE::SetLayer;
972 PCB_LAYER_ID ( PCB_SHAPE::*shapeLayerGetter )() const = &PCB_SHAPE::GetLayer;
973
974 auto layerProperty = new PROPERTY_ENUM<PCB_SHAPE, PCB_LAYER_ID>(
975 _HKI( "Layer" ), shapeLayerSetter, shapeLayerGetter );
976
977 propMgr.ReplaceProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ), layerProperty );
978
979 // Only polygons have meaningful Position properties.
980 // On other shapes, these are duplicates of the Start properties.
981 auto isPolygon =
982 []( INSPECTABLE* aItem ) -> bool
983 {
984 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
985 return shape->GetShape() == SHAPE_T::POLY;
986
987 return false;
988 };
989
991 _HKI( "Position X" ), isPolygon );
993 _HKI( "Position Y" ), isPolygon );
994
995 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Color" ) );
996 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Fill Color" ) );
997
998 auto isCopper =
999 []( INSPECTABLE* aItem ) -> bool
1000 {
1001 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
1002 return shape->IsOnCopperLayer();
1003
1004 return false;
1005 };
1006
1008 _HKI( "Net" ), isCopper );
1009
1010 auto isPadEditMode =
1011 []( BOARD* aBoard ) -> bool
1012 {
1013 if( aBoard && aBoard->IsFootprintHolder() )
1014 {
1015 for( FOOTPRINT* fp : aBoard->Footprints() )
1016 {
1017 for( PAD* pad : fp->Pads() )
1018 {
1019 if( pad->IsEntered() )
1020 return true;
1021 }
1022 }
1023 }
1024
1025 return false;
1026 };
1027
1028 auto showNumberBoxProperty =
1029 [&]( INSPECTABLE* aItem ) -> bool
1030 {
1031 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
1032 {
1033 if( shape->GetShape() == SHAPE_T::RECTANGLE )
1034 return isPadEditMode( shape->GetBoard() );
1035 }
1036
1037 return false;
1038 };
1039
1040 auto showSpokeTemplateProperty =
1041 [&]( INSPECTABLE* aItem ) -> bool
1042 {
1043 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
1044 {
1045 if( shape->GetShape() == SHAPE_T::SEGMENT )
1046 return isPadEditMode( shape->GetBoard() );
1047 }
1048
1049 return false;
1050 };
1051
1052 const wxString groupPadPrimitives = _HKI( "Pad Primitives" );
1053
1054 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Number Box" ),
1057 groupPadPrimitives )
1058 .SetAvailableFunc( showNumberBoxProperty )
1060
1061 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Thermal Spoke Template" ),
1064 groupPadPrimitives )
1065 .SetAvailableFunc( showSpokeTemplateProperty )
1067
1068 const wxString groupTechLayers = _HKI( "Technical Layers" );
1069
1070 auto isExternalCuLayer =
1071 []( INSPECTABLE* aItem )
1072 {
1073 if( auto shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
1074 return IsExternalCopperLayer( shape->GetLayer() );
1075
1076 return false;
1077 };
1078
1079 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Soldermask" ),
1082 groupTechLayers )
1083 .SetAvailableFunc( isExternalCuLayer );
1084
1085 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, std::optional<int>>(
1086 _HKI( "Soldermask Margin Override" ),
1089 PROPERTY_DISPLAY::PT_SIZE ),
1090 groupTechLayers )
1091 .SetAvailableFunc( isExternalCuLayer );
1092 }
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
@ ERROR_OUTSIDE
Definition: approximation.h:33
constexpr int ARC_HIGH_DEF
Definition: base_units.h:127
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:110
constexpr int ARC_LOW_DEF
Definition: base_units.h:126
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
#define DEFAULT_LINE_WIDTH
BASE_SET & set(size_t pos)
Definition: base_set.h:116
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:78
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:229
void SetLocked(bool aLocked) override
Definition: board_item.h:320
bool m_isKnockout
Definition: board_item.h:446
PCB_LAYER_ID m_layer
Definition: board_item.h:445
bool m_isLocked
Definition: board_item.h:448
bool IsLocked() const override
Definition: board_item.cpp:76
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:280
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:48
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:299
virtual bool IsOnCopperLayer() const
Definition: board_item.h:148
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:140
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:297
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:955
constexpr const Vec & GetPosition() const
Definition: box2.h:211
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr const Vec GetEnd() const
Definition: box2.h:212
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:33
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:96
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:84
const KIID m_Uuid
Definition: eda_item.h:502
bool m_forceVisible
Definition: eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:108
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:513
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:188
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: eda_item.cpp:318
EDA_ITEM * m_parent
Linked list: Link (parent struct).
Definition: eda_item.h:514
virtual int GetHatchLineSpacing() const
Definition: eda_shape.h:159
SHAPE_T m_shape
Definition: eda_shape.h:494
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.
Definition: eda_shape.cpp:2245
bool m_proxyItem
Definition: eda_shape.h:521
bool m_hatchingDirty
Definition: eda_shape.h:500
bool m_endsSwapped
Definition: eda_shape.h:493
int m_editState
Definition: eda_shape.h:520
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Definition: eda_shape.cpp:803
SHAPE_POLY_SET m_hatching
Definition: eda_shape.h:499
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:379
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:337
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:1155
bool operator==(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:2394
int GetRadius() const
Definition: eda_shape.cpp:1013
SHAPE_T GetShape() const
Definition: eda_shape.h:168
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: eda_shape.cpp:236
VECTOR2I m_arcCenter
Definition: eda_shape.h:511
ARC_MID m_arcMidData
Definition: eda_shape.h:512
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
Definition: eda_shape.cpp:911
bool IsSolidFill() const
Definition: eda_shape.h:117
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition: eda_shape.cpp:866
VECTOR2I m_start
Definition: eda_shape.h:508
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:215
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:177
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:173
void SwapShape(EDA_SHAPE *aImage)
Definition: eda_shape.cpp:2179
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1596
bool IsAnyFill() const
Definition: eda_shape.h:112
virtual void UpdateHatching() const
Definition: eda_shape.cpp:580
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:219
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:342
double Similarity(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:2439
VECTOR2I m_end
Definition: eda_shape.h:509
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:518
virtual int GetWidth() const
Definition: eda_shape.h:156
STROKE_PARAMS m_stroke
Definition: eda_shape.h:495
VECTOR2I m_bezierC1
Definition: eda_shape.h:514
void SetWidth(int aWidth)
Definition: eda_shape.cpp:2372
VECTOR2I m_bezierC2
Definition: eda_shape.h:515
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: eda_shape.cpp:148
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:983
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:687
static ENUM_MAP< T > & Instance()
Definition: property.h:681
ENUM_MAP & Undefined(T aValue)
Definition: property.h:694
wxPGChoices & Choices()
Definition: property.h:730
const wxString & GetReference() const
Definition: footprint.h:621
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:37
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:181
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:186
PCB specific render settings.
Definition: pcb_painter.h:79
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition: view_item.h:174
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition: view_item.h:179
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
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:216
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:252
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:255
static const LSET & AllLayersMask()
Definition: lset.cpp:627
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:188
int GetNetCode() const
Definition: netinfo.h:108
Definition: pad.h:54
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition: pad.h:609
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:121
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
Definition: pcb_shape.cpp:573
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:710
void swapData(BOARD_ITEM *aImage) override
Definition: pcb_shape.cpp:806
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: pcb_shape.cpp:170
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_shape.cpp:651
std::optional< int > GetLocalSolderMaskMargin() const
Definition: pcb_shape.h:193
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:81
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:559
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_shape.cpp:774
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T aItemType, SHAPE_T aShapeType)
Definition: pcb_shape.cpp:51
int GetWidth() const override
Definition: pcb_shape.cpp:380
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_shape.cpp:789
bool HasSolderMask() const
Definition: pcb_shape.h:190
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:800
void SetHasSolderMask(bool aVal)
Definition: pcb_shape.h:189
std::optional< int > m_solderMaskMargin
Definition: pcb_shape.h:213
int GetSolderMaskExpansion() const
Definition: pcb_shape.cpp:186
void NormalizeForCompare() override
Normalize coordinates to compare 2 similar PCB_SHAPES similat to Normalize(), but also normalize SEGM...
Definition: pcb_shape.cpp:537
const VECTOR2I GetFocusPosition() const override
Allows items to return their visual center rather than their anchor.
Definition: pcb_shape.cpp:396
virtual void SetLayerSet(const LSET &aLayers) override
Definition: pcb_shape.cpp:242
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_shape.cpp:565
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:438
bool IsProxyItem() const override
Definition: pcb_shape.h:116
bool m_hasSolderMask
Definition: pcb_shape.h:212
~PCB_SHAPE() override
Definition: pcb_shape.cpp:67
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_shape.cpp:225
bool operator==(const PCB_SHAPE &aShape) const
Definition: pcb_shape.cpp:875
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:177
wxString GetFriendlyName() const override
Definition: pcb_shape.h:66
void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const override
Convert the item shape to a polyset.
Definition: pcb_shape.cpp:857
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:848
void SetIsProxyItem(bool aIsProxy=true) override
Definition: pcb_shape.cpp:609
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_shape.cpp:390
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pcb_shape.h:192
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:466
std::vector< VECTOR2I > GetConnectionPoints() const
Definition: pcb_shape.cpp:255
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_shape.cpp:101
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_shape.cpp:783
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_shape.cpp:207
void UpdateHatching() const override
Definition: pcb_shape.cpp:308
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: pcb_shape.cpp:729
void Scale(double aScale)
Definition: pcb_shape.cpp:472
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_shape.cpp:79
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
Definition: pcb_shape.cpp:478
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pcb_shape.cpp:138
void CopyFrom(const BOARD_ITEM *aOther) override
Definition: pcb_shape.cpp:72
std::vector< int > ViewGetLayers() const override
Definition: pcb_shape.cpp:683
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:910
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:71
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition: property.h:258
PROPERTY_BASE & SetIsHiddenFromRulesEditor(bool aHide=true)
Definition: property.h:308
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.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Fracture()
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
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.
void Mirror(const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
Mirror the line points about y or x (or both)
int OutlineCount() const
Return the number of outlines in the set.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
void SetWidth(int aWidth)
#define _HKI(x)
#define _(s)
#define PCB_EDIT_FRAME_NAME
SHAPE_T
Definition: eda_shape.h:43
FILL_T
Definition: eda_shape.h:56
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: layer_id.cpp:169
bool IsSolderMaskLayer(int aLayer)
Definition: layer_ids.h:733
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:184
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition: layer_ids.h:839
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition: layer_ids.h:663
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition: layer_ids.h:306
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition: layer_ids.h:258
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition: layer_ids.h:259
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition: layer_ids.h:674
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:112
@ B_Mask
Definition: layer_ids.h:98
@ B_Cu
Definition: layer_ids.h:65
@ F_Mask
Definition: layer_ids.h:97
@ 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
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:45
FLIP_DIRECTION
Definition: mirror.h:27
std::vector< TYPED_POINT2I > GetCircleKeyPoints(const CIRCLE &aCircle, bool aIncludeCenter)
Get key points of an CIRCLE.
static struct PCB_SHAPE_DESC _PCB_SHAPE_DESC
static bool isCopper(const PNS::ITEM *aItem)
#define TYPE_HASH(x)
Definition: property.h:72
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
Utility functions for working with shapes.
const int scale
constexpr int mmToIU(double mm) const
Definition: base_units.h:90
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition: pcb_shape.cpp:826
VECTOR2I end
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
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_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ 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:695
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MM
Definition: zones.h:34