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