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 <bitmaps.h>
28#include <core/mirror.h>
29#include <macros.h>
30#include <pcb_edit_frame.h>
32#include <footprint.h>
33#include <pad.h>
34#include <base_units.h>
36#include <pcb_shape.h>
37#include <pcb_painter.h>
38
39PCB_SHAPE::PCB_SHAPE( BOARD_ITEM* aParent, KICAD_T aItemType, SHAPE_T aShapeType ) :
40 BOARD_CONNECTED_ITEM( aParent, aItemType ),
41 EDA_SHAPE( aShapeType, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL )
42{
43}
44
45
46PCB_SHAPE::PCB_SHAPE( BOARD_ITEM* aParent, SHAPE_T shapetype ) :
48 EDA_SHAPE( shapetype, pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ), FILL_T::NO_FILL )
49{
50}
51
52
54{
55}
56
57
58bool PCB_SHAPE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
59{
60 if( BOARD_ITEM::IsType( aScanTypes ) )
61 return true;
62
63 bool sametype = false;
64
65 for( KICAD_T scanType : aScanTypes )
66 {
67 if( scanType == PCB_LOCATE_BOARD_EDGE_T )
68 sametype = m_layer == Edge_Cuts;
69 else if( scanType == PCB_SHAPE_LOCATE_ARC_T )
70 sametype = m_shape == SHAPE_T::ARC;
71 else if( scanType == PCB_SHAPE_LOCATE_CIRCLE_T )
72 sametype = m_shape == SHAPE_T::CIRCLE;
73 else if( scanType == PCB_SHAPE_LOCATE_RECT_T )
74 sametype = m_shape == SHAPE_T::RECTANGLE;
75 else if( scanType == PCB_SHAPE_LOCATE_SEGMENT_T )
76 sametype = m_shape == SHAPE_T::SEGMENT;
77 else if( scanType == PCB_SHAPE_LOCATE_POLY_T )
78 sametype = m_shape == SHAPE_T::POLY;
79 else if( scanType == PCB_SHAPE_LOCATE_BEZIER_T )
80 sametype = m_shape == SHAPE_T::BEZIER;
81
82 if( sametype )
83 return true;
84 }
85
86 return false;
87}
88
89
91{
92 // Only board-level copper shapes are connectable
94}
95
96
98{
99 BOARD_ITEM::SetLayer( aLayer );
100
101 if( !IsOnCopperLayer() )
102 SetNetCode( -1 );
103}
104
105
106std::vector<VECTOR2I> PCB_SHAPE::GetConnectionPoints() const
107{
108 std::vector<VECTOR2I> ret;
109
110 // For filled shapes, we may as well use a centroid
111 if( IsFilled() )
112 {
113 ret.emplace_back( GetCenter() );
114 return ret;
115 }
116
117 switch( m_shape )
118 {
119 case SHAPE_T::ARC:
120 ret.emplace_back( GetArcMid() );
122
123 case SHAPE_T::SEGMENT:
124 case SHAPE_T::BEZIER:
125 ret.emplace_back( GetStart() );
126 ret.emplace_back( GetEnd() );
127 break;
128
129 case SHAPE_T::POLY:
130 for( auto iter = GetPolyShape().CIterate(); iter; ++iter )
131 ret.emplace_back( *iter );
132
133 break;
134
135 case SHAPE_T::RECTANGLE:
136 for( const VECTOR2I& pt : GetRectCorners() )
137 ret.emplace_back( pt );
138
139 break;
140
141 default:
142 break;
143 }
144
145 return ret;
146}
147
148
150{
151 // A stroke width of 0 in PCBNew means no-border, but negative stroke-widths are only used
152 // in EEschema (see SCH_SHAPE::GetPenWidth()).
153 // Since negative stroke widths can trip up down-stream code (such as the Gerber plotter), we
154 // weed them out here.
155 return std::max( EDA_SHAPE::GetWidth(), 0 );
156}
157
158
160{
162}
163
164
166{
167 // For some shapes return the visual center, but for not filled polygonal shapes,
168 // the center is usually far from the shape: a point on the outline is better
169
170 switch( m_shape )
171 {
172 case SHAPE_T::CIRCLE:
173 if( !IsFilled() )
174 return VECTOR2I( GetCenter().x + GetRadius(), GetCenter().y );
175 else
176 return GetCenter();
177
178 case SHAPE_T::RECTANGLE:
179 if( !IsFilled() )
180 return GetStart();
181 else
182 return GetCenter();
183
184 case SHAPE_T::POLY:
185 if( !IsFilled() )
186 {
187 VECTOR2I pos = GetPolyShape().Outline(0).CPoint(0);
188 return VECTOR2I( pos.x, pos.y );
189 }
190 else
191 {
192 return GetCenter();
193 }
194
195 case SHAPE_T::ARC:
196 return GetArcMid();
197
198 case SHAPE_T::BEZIER:
199 return GetStart();
200
201 default:
202 return GetCenter();
203 }
204}
205
206
207std::vector<VECTOR2I> PCB_SHAPE::GetCorners() const
208{
209 std::vector<VECTOR2I> pts;
210
211 if( GetShape() == SHAPE_T::RECTANGLE )
212 {
213 pts = GetRectCorners();
214 }
215 else if( GetShape() == SHAPE_T::POLY )
216 {
217 for( int ii = 0; ii < GetPolyShape().OutlineCount(); ++ii )
218 {
219 for( const VECTOR2I& pt : GetPolyShape().Outline( ii ).CPoints() )
220 pts.emplace_back( pt );
221 }
222 }
223 else
224 {
226 }
227
228 while( pts.size() < 4 )
229 pts.emplace_back( pts.back() + VECTOR2I( 10, 10 ) );
230
231 return pts;
232}
233
234
235void PCB_SHAPE::Move( const VECTOR2I& aMoveVector )
236{
237 move( aMoveVector );
238}
239
240
241void PCB_SHAPE::Scale( double aScale )
242{
243 scale( aScale );
244}
245
246
248{
249 if( m_shape == SHAPE_T::RECTANGLE )
250 {
251 VECTOR2I start = GetStart();
252 VECTOR2I end = GetEnd();
253
254 BOX2I rect( start, end - start );
255 rect.Normalize();
256
257 SetStart( rect.GetPosition() );
258 SetEnd( rect.GetEnd() );
259 }
260 else if( m_shape == SHAPE_T::POLY )
261 {
262 auto horizontal =
263 []( const SEG& seg )
264 {
265 return seg.A.y == seg.B.y;
266 };
267
268 auto vertical =
269 []( const SEG& seg )
270 {
271 return seg.A.x == seg.B.x;
272 };
273
274 // Convert a poly back to a rectangle if appropriate
275 if( m_poly.OutlineCount() == 1 && m_poly.Outline( 0 ).SegmentCount() == 4 )
276 {
277 SHAPE_LINE_CHAIN& outline = m_poly.Outline( 0 );
278
279 if( horizontal( outline.Segment( 0 ) )
280 && vertical( outline.Segment( 1 ) )
281 && horizontal( outline.Segment( 2 ) )
282 && vertical( outline.Segment( 3 ) ) )
283 {
284 m_shape = SHAPE_T::RECTANGLE;
285 m_start.x = std::min( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x );
286 m_start.y = std::min( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y );
287 m_end.x = std::max( outline.Segment( 0 ).A.x, outline.Segment( 0 ).B.x );
288 m_end.y = std::max( outline.Segment( 1 ).A.y, outline.Segment( 1 ).B.y );
289 }
290 else if( vertical( outline.Segment( 0 ) )
291 && horizontal( outline.Segment( 1 ) )
292 && vertical( outline.Segment( 2 ) )
293 && horizontal( outline.Segment( 3 ) ) )
294 {
295 m_shape = SHAPE_T::RECTANGLE;
296 m_start.x = std::min( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x );
297 m_start.y = std::min( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y );
298 m_end.x = std::max( outline.Segment( 1 ).A.x, outline.Segment( 1 ).B.x );
299 m_end.y = std::max( outline.Segment( 0 ).A.y, outline.Segment( 0 ).B.y );
300 }
301 }
302 }
303}
304
305
306void PCB_SHAPE::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
307{
308 rotate( aRotCentre, aAngle );
309}
310
311
312void PCB_SHAPE::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
313{
314 flip( aCentre, aFlipLeftRight );
315
316 SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
317}
318
319
320void PCB_SHAPE::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
321{
322 // Mirror an edge of the footprint. the layer is not modified
323 // This is a footprint shape modification.
324
325 switch( GetShape() )
326 {
327 case SHAPE_T::ARC:
328 case SHAPE_T::SEGMENT:
329 case SHAPE_T::RECTANGLE:
330 case SHAPE_T::CIRCLE:
331 case SHAPE_T::BEZIER:
332 if( aMirrorAroundXAxis )
333 {
334 MIRROR( m_start.y, aCentre.y );
335 MIRROR( m_end.y, aCentre.y );
336 MIRROR( m_arcCenter.y, aCentre.y );
337 MIRROR( m_bezierC1.y, aCentre.y );
338 MIRROR( m_bezierC2.y, aCentre.y );
339 }
340 else
341 {
342 MIRROR( m_start.x, aCentre.x );
343 MIRROR( m_end.x, aCentre.x );
344 MIRROR( m_arcCenter.x, aCentre.x );
345 MIRROR( m_bezierC1.x, aCentre.x );
346 MIRROR( m_bezierC2.x, aCentre.x );
347 }
348
349 if( GetShape() == SHAPE_T::ARC )
350 std::swap( m_start, m_end );
351
352 if( GetShape() == SHAPE_T::BEZIER )
354
355 break;
356
357 case SHAPE_T::POLY:
358 m_poly.Mirror( !aMirrorAroundXAxis, aMirrorAroundXAxis, aCentre );
359 break;
360
361 default:
363 }
364}
365
366
367void PCB_SHAPE::SetIsProxyItem( bool aIsProxy )
368{
369 PAD* parentPad = nullptr;
370
371 if( GetBoard() && GetBoard()->IsFootprintHolder() )
372 {
373 for( FOOTPRINT* fp : GetBoard()->Footprints() )
374 {
375 for( PAD* pad : fp->Pads() )
376 {
377 if( pad->IsEntered() )
378 {
379 parentPad = pad;
380 break;
381 }
382 }
383 }
384 }
385
386 if( aIsProxy && !m_proxyItem )
387 {
388 if( GetShape() == SHAPE_T::SEGMENT )
389 {
390 if( parentPad && parentPad->GetThermalSpokeWidth() )
391 SetWidth( parentPad->GetThermalSpokeWidth() );
392 else
394 }
395 else
396 {
397 SetWidth( 1 );
398 }
399 }
400 else if( m_proxyItem && !aIsProxy )
401 {
403 }
404
405 m_proxyItem = aIsProxy;
406}
407
408
409double PCB_SHAPE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
410{
411 constexpr double HIDE = std::numeric_limits<double>::max();
412 constexpr double SHOW = 0.0;
413
414 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() );
415 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
416
417 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
418 {
419 // Hide shadow if the main layer is not shown
420 if( !aView->IsLayerVisible( m_layer ) )
421 return HIDE;
422
423 // Hide shadow on dimmed tracks
424 if( renderSettings->GetHighContrast() )
425 {
426 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
427 return HIDE;
428 }
429 }
430
431 if( FOOTPRINT* parent = GetParentFootprint() )
432 {
433 if( parent->GetLayer() == F_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
434 return HIDE;
435
436 if( parent->GetLayer() == B_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
437 return HIDE;
438 }
439
440 return SHOW;
441}
442
443
444void PCB_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const
445{
446 aLayers[0] = GetLayer();
447
448 if( IsOnCopperLayer() )
449 {
450 aLayers[1] = GetNetnameLayer( aLayers[0] );
451 aCount = 2;
452 }
453 else
454 {
455 aCount = 1;
456 }
457
458 if( IsLocked() )
459 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
460}
461
462
463void PCB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
464{
465 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
466 {
467 if( FOOTPRINT* parent = GetParentFootprint() )
468 aList.emplace_back( _( "Footprint" ), parent->GetReference() );
469 }
470
471 aList.emplace_back( _( "Type" ), _( "Drawing" ) );
472
473 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
474 aList.emplace_back( _( "Status" ), _( "Locked" ) );
475
476 ShapeGetMsgPanelInfo( aFrame, aList );
477
478 aList.emplace_back( _( "Layer" ), GetLayerName() );
479}
480
481
482wxString PCB_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
483{
484 if( GetNetCode() > 0 )
485 {
486 return wxString::Format( _( "%s %s on %s" ), GetFriendlyName(), GetNetnameMsg(),
487 GetLayerName() );
488 }
489 else
490 {
491 return wxString::Format( _( "%s on %s" ), GetFriendlyName(), GetLayerName() );
492 }
493}
494
495
497{
498 if( GetParentFootprint() )
499 return BITMAPS::show_mod_edge;
500 else
501 return BITMAPS::add_dashed_line;
502}
503
504
506{
507 return new PCB_SHAPE( *this );
508}
509
510
512{
513 BOX2I return_box = EDA_ITEM::ViewBBox();
514
515 // Inflate the bounding box by just a bit more for safety.
516 return_box.Inflate( GetWidth() );
517
518 return return_box;
519}
520
521
522std::shared_ptr<SHAPE> PCB_SHAPE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
523{
524 return std::make_shared<SHAPE_COMPOUND>( MakeEffectiveShapes() );
525}
526
527
529{
530 PCB_SHAPE* image = dynamic_cast<PCB_SHAPE*>( aImage );
531 wxCHECK( image, /* void */ );
532
533 SwapShape( image );
534
535 // Swap params not handled by SwapShape( image )
536 std::swap( m_layer, image->m_layer );
537 std::swap( m_isKnockout, image->m_isKnockout );
538 std::swap( m_isLocked, image->m_isLocked );
539 std::swap( m_flags, image->m_flags );
540 std::swap( m_parent, image->m_parent );
541 std::swap( m_forceVisible, image->m_forceVisible );
542 std::swap( m_netinfo, image->m_netinfo );
543}
544
545
547 const BOARD_ITEM* aSecond ) const
548{
549 if( aFirst->Type() != aSecond->Type() )
550 return aFirst->Type() < aSecond->Type();
551
552 if( aFirst->GetLayer() != aSecond->GetLayer() )
553 return aFirst->GetLayer() < aSecond->GetLayer();
554
555 if( aFirst->Type() == PCB_SHAPE_T )
556 {
557 const PCB_SHAPE* dwgA = static_cast<const PCB_SHAPE*>( aFirst );
558 const PCB_SHAPE* dwgB = static_cast<const PCB_SHAPE*>( aSecond );
559
560 if( dwgA->GetShape() != dwgB->GetShape() )
561 return dwgA->GetShape() < dwgB->GetShape();
562 }
563
564 return aFirst->m_Uuid < aSecond->m_Uuid;
565}
566
567
569 int aClearance, int aError, ERROR_LOC aErrorLoc,
570 bool ignoreLineWidth ) const
571{
572 EDA_SHAPE::TransformShapeToPolygon( aBuffer, aClearance, aError, aErrorLoc, ignoreLineWidth );
573}
574
575
576bool PCB_SHAPE::operator==( const BOARD_ITEM& aOther ) const
577{
578 if( aOther.Type() != Type() )
579 return false;
580
581 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
582
583 if( m_layer != other.m_layer )
584 return false;
585
586 if( m_isKnockout != other.m_isKnockout )
587 return false;
588
589 if( m_isLocked != other.m_isLocked )
590 return false;
591
592 if( m_flags != other.m_flags )
593 return false;
594
595 if( m_forceVisible != other.m_forceVisible )
596 return false;
597
598 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
599 return false;
600
601 return EDA_SHAPE::operator==( other );
602}
603
604
605double PCB_SHAPE::Similarity( const BOARD_ITEM& aOther ) const
606{
607 if( aOther.Type() != Type() )
608 return 0.0;
609
610 const PCB_SHAPE& other = static_cast<const PCB_SHAPE&>( aOther );
611
612 double similarity = 1.0;
613
614 if( GetLayer() != other.GetLayer() )
615 similarity *= 0.9;
616
617 if( m_isKnockout != other.m_isKnockout )
618 similarity *= 0.9;
619
620 if( m_isLocked != other.m_isLocked )
621 similarity *= 0.9;
622
623 if( m_flags != other.m_flags )
624 similarity *= 0.9;
625
626 if( m_forceVisible != other.m_forceVisible )
627 similarity *= 0.9;
628
629 if( m_netinfo->GetNetCode() != other.m_netinfo->GetNetCode() )
630 similarity *= 0.9;
631
632 similarity *= EDA_SHAPE::Similarity( other );
633
634 return similarity;
635}
636
637
638static struct PCB_SHAPE_DESC
639{
641 {
648
649 // Need to initialise enum_map before we can use a Property enum for it
651
652 if( layerEnum.Choices().GetCount() == 0 )
653 {
654 layerEnum.Undefined( UNDEFINED_LAYER );
655
656 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
657 layerEnum.Map( *seq, LSET::Name( *seq ) );
658 }
659
660 void ( PCB_SHAPE::*shapeLayerSetter )( PCB_LAYER_ID ) = &PCB_SHAPE::SetLayer;
661 PCB_LAYER_ID ( PCB_SHAPE::*shapeLayerGetter )() const = &PCB_SHAPE::GetLayer;
662
663 auto layerProperty = new PROPERTY_ENUM<PCB_SHAPE, PCB_LAYER_ID>(
664 _HKI( "Layer" ), shapeLayerSetter, shapeLayerGetter );
665
666 propMgr.ReplaceProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ), layerProperty );
667
668 // Only polygons have meaningful Position properties.
669 // On other shapes, these are duplicates of the Start properties.
670 auto isPolygon =
671 []( INSPECTABLE* aItem ) -> bool
672 {
673 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
674 return shape->GetShape() == SHAPE_T::POLY;
675
676 return false;
677 };
678
680 _HKI( "Position X" ), isPolygon );
682 _HKI( "Position Y" ), isPolygon );
683
684 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Color" ) );
685 propMgr.Mask( TYPE_HASH( PCB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Fill Color" ) );
686
687 auto isCopper =
688 []( INSPECTABLE* aItem ) -> bool
689 {
690 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
691 return shape->IsOnCopperLayer();
692
693 return false;
694 };
695
697 _HKI( "Net" ), isCopper );
698
699 auto isPadEditMode =
700 []( BOARD* aBoard ) -> bool
701 {
702 if( aBoard && aBoard->IsFootprintHolder() )
703 {
704 for( FOOTPRINT* fp : aBoard->Footprints() )
705 {
706 for( PAD* pad : fp->Pads() )
707 {
708 if( pad->IsEntered() )
709 return true;
710 }
711 }
712 }
713
714 return false;
715 };
716
717 auto showNumberBoxProperty =
718 [&]( INSPECTABLE* aItem ) -> bool
719 {
720 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
721 {
722 if( shape->GetShape() == SHAPE_T::RECTANGLE )
723 return isPadEditMode( shape->GetBoard() );
724 }
725
726 return false;
727 };
728
729 auto showSpokeTemplateProperty =
730 [&]( INSPECTABLE* aItem ) -> bool
731 {
732 if( PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem ) )
733 {
734 if( shape->GetShape() == SHAPE_T::SEGMENT )
735 return isPadEditMode( shape->GetBoard() );
736 }
737
738 return false;
739 };
740
741 const wxString groupPadPrimitives = _HKI( "Pad Primitives" );
742
743 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Number Box" ),
746 groupPadPrimitives )
747 .SetAvailableFunc( showNumberBoxProperty )
749
750 propMgr.AddProperty( new PROPERTY<PCB_SHAPE, bool>( _HKI( "Thermal Spoke Template" ),
753 groupPadPrimitives )
754 .SetAvailableFunc( showSpokeTemplateProperty )
756 }
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
#define DEFAULT_LINE_WIDTH
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetnameMsg() const
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
NETINFO_ITEM * m_netinfo
Store all information about the net that item belongs to.
Container for design settings for a BOARD object.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:225
bool m_isKnockout
Definition: board_item.h:388
PCB_LAYER_ID m_layer
Definition: board_item.h:387
bool m_isLocked
Definition: board_item.h:390
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:259
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:45
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:247
virtual bool IsLocked() const
Definition: board_item.cpp:73
virtual bool IsOnCopperLayer() const
Definition: board_item.h:151
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:102
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:276
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:120
const Vec & GetPosition() const
Definition: box2.h:185
const Vec GetEnd() const
Definition: box2.h:186
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
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:85
const KIID m_Uuid
Definition: eda_item.h:482
bool m_forceVisible
Definition: eda_item.h:486
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:487
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:172
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:485
SHAPE_T m_shape
Definition: eda_shape.h:389
bool m_proxyItem
Definition: eda_shape.h:413
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Definition: eda_shape.cpp:331
void flip(const VECTOR2I &aCentre, bool aFlipLeftRight)
Definition: eda_shape.cpp:388
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
Definition: eda_shape.cpp:473
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:300
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:258
bool IsFilled() const
Definition: eda_shape.h:90
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:726
bool operator==(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:1751
int GetRadius() const
Definition: eda_shape.cpp:586
SHAPE_T GetShape() const
Definition: eda_shape.h:119
VECTOR2I m_arcCenter
Definition: eda_shape.h:403
VECTOR2I m_start
Definition: eda_shape.h:400
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:151
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:130
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:126
void SwapShape(EDA_SHAPE *aImage)
Definition: eda_shape.cpp:1560
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1132
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:155
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:87
double Similarity(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:1796
VECTOR2I m_end
Definition: eda_shape.h:401
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:410
virtual int GetWidth() const
Definition: eda_shape.h:109
STROKE_PARAMS m_stroke
Definition: eda_shape.h:390
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:1624
VECTOR2I m_bezierC1
Definition: eda_shape.h:406
void SetWidth(int aWidth)
Definition: eda_shape.h:108
VECTOR2I m_bezierC2
Definition: eda_shape.h:407
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:556
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:646
static ENUM_MAP< T > & Instance()
Definition: property.h:640
ENUM_MAP & Undefined(T aValue)
Definition: property.h:653
wxPGChoices & Choices()
Definition: property.h:689
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:163
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:168
PCB specific render settings.
Definition: pcb_painter.h:76
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:412
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:513
static LSET AllLayersMask()
Definition: lset.cpp:817
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:89
int GetNetCode() const
Definition: netinfo.h:108
Definition: pad.h:58
int GetThermalSpokeWidth() const
Definition: pad.h:504
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition: pcb_shape.cpp:576
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:463
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_shape.cpp:528
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: pcb_shape.cpp:90
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_shape.cpp:312
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:72
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:306
virtual BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_shape.cpp:496
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T aItemType, SHAPE_T aShapeType)
Definition: pcb_shape.cpp:39
int GetWidth() const override
Definition: pcb_shape.cpp:149
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_shape.cpp:511
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:522
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: pcb_shape.cpp:444
const VECTOR2I GetFocusPosition() const override
Allows items to return their visual center rather than their anchor.
Definition: pcb_shape.cpp:165
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pcb_shape.cpp:482
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:207
bool IsProxyItem() const override
Definition: pcb_shape.h:107
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:97
wxString GetFriendlyName() const override
Definition: pcb_shape.h:62
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:568
void SetIsProxyItem(bool aIsProxy=true) override
Definition: pcb_shape.cpp:367
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_shape.cpp:159
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:235
std::vector< VECTOR2I > GetConnectionPoints() const
Definition: pcb_shape.cpp:106
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_shape.cpp:505
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_shape.cpp:409
virtual void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_shape.cpp:320
void Scale(double aScale)
Definition: pcb_shape.cpp:241
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
Definition: pcb_shape.cpp:247
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pcb_shape.cpp:58
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:605
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:67
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition: property.h:249
PROPERTY_BASE & SetIsHiddenFromRulesEditor(bool aHide=true)
Definition: property.h:299
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
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:76
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...
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
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
Represent a set of closed polygons.
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:54
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:148
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:994
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:240
@ LAYER_FOOTPRINTS_FR
show footprints on front
Definition: layer_ids.h:209
@ LAYER_FOOTPRINTS_BK
show footprints on back
Definition: layer_ids.h:210
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:114
@ B_Cu
Definition: layer_ids.h:96
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:65
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:553
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
static struct PCB_SHAPE_DESC _PCB_SHAPE_DESC
static bool isCopper(const PNS::ITEM *aItem)
#define TYPE_HASH(x)
Definition: property.h:64
#define REGISTER_TYPE(x)
Definition: property_mgr.h:331
const int scale
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition: pcb_shape.cpp:546
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:128
@ PCB_SHAPE_LOCATE_CIRCLE_T
Definition: typeinfo.h:133
@ PCB_SHAPE_LOCATE_SEGMENT_T
Definition: typeinfo.h:131
@ PCB_SHAPE_LOCATE_RECT_T
Definition: typeinfo.h:132
@ PCB_SHAPE_LOCATE_BEZIER_T
Definition: typeinfo.h:136
@ PCB_SHAPE_LOCATE_POLY_T
Definition: typeinfo.h:135
@ PCB_SHAPE_LOCATE_ARC_T
Definition: typeinfo.h:134
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MM
Definition: zones.h:34