KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <sch_draw_panel.h>
22#include <macros.h>
23#include <plotters/plotter.h>
24#include <base_units.h>
25#include <widgets/msgpanel.h>
26#include <bitmaps.h>
27#include <eda_draw_frame.h>
28#include <gr_basic.h>
32#include <schematic.h>
33#include <api/api_utils.h>
34#include <api/schematic/schematic_types.pb.h>
35#include <sch_shape.h>
36#include <properties/property.h>
38
39
40SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
41 KICAD_T aType ) :
42 SCH_ITEM( nullptr, aType ),
43 EDA_SHAPE( aShape, aLineWidth, aFillType )
44{
45 SetLayer( aLayer );
46}
47
48
50{
51 return new SCH_SHAPE( *this );
52}
53
54
55void SCH_SHAPE::Serialize( google::protobuf::Any& aContainer ) const
56{
57 using namespace kiapi::common;
58
59 kiapi::schematic::types::SchematicGraphicShape msg;
60 google::protobuf::Any any;
61
62 msg.mutable_id()->set_value( m_Uuid.AsStdString() );
63 msg.set_locked( IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
64
66 any.UnpackTo( msg.mutable_shape() );
67
68 aContainer.PackFrom( msg );
69}
70
71
72bool SCH_SHAPE::Deserialize( const google::protobuf::Any& aContainer )
73{
74 using namespace kiapi::common;
75
76 kiapi::schematic::types::SchematicGraphicShape msg;
77
78 if( !aContainer.UnpackTo( &msg ) )
79 return false;
80
81 const_cast<KIID&>( m_Uuid ) = KIID( msg.id().value() );
82 SetLocked( msg.locked() == types::LockedState::LS_LOCKED );
83
84 google::protobuf::Any any;
85 any.PackFrom( msg.shape() );
87}
88
89
91{
92 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
93
94 EDA_SHAPE::SwapShape( shape );
95}
96
97
98void SCH_SHAPE::SetStroke( const STROKE_PARAMS& aStroke )
99{
100 m_stroke = aStroke;
101}
102
103
104void SCH_SHAPE::SetFilled( bool aFilled )
105{
106 if( !aFilled )
108 else if( GetParentSymbol() )
110 else
112}
113
114
115void SCH_SHAPE::Move( const VECTOR2I& aOffset )
116{
117 move( aOffset );
118}
119
120
122{
124 {
125 VECTOR2I size = GetEnd() - GetPosition();
126
127 if( size.y < 0 )
128 {
129 SetStartY( GetStartY() + size.y );
130 SetEndY( GetStartY() - size.y );
131 }
132
133 if( size.x < 0 )
134 {
135 SetStartX( GetStartX() + size.x );
136 SetEndX( GetStartX() - size.x );
137 }
138 }
139}
140
141
143{
144 flip( VECTOR2I( aCenter, 0 ), FLIP_DIRECTION::LEFT_RIGHT );
145}
146
147
149{
150 flip( VECTOR2I( 0, aCenter ), FLIP_DIRECTION::TOP_BOTTOM );
151}
152
153
154void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
155{
156 rotate( aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
157}
158
159
160bool SCH_SHAPE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
161{
162 return hitTest( aPosition, aAccuracy );
163}
164
165
166bool SCH_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
167{
169 return false;
170
171 return hitTest( aRect, aContained, aAccuracy );
172}
173
174
175bool SCH_SHAPE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
176{
178 return false;
179
180 std::vector<SHAPE*> shapes = MakeEffectiveShapes( false );
181
182 for( SHAPE* shape : shapes )
183 {
184 bool hit = KIGEOM::ShapeHitTest( aPoly, *shape, aContained );
185
186 if( hit )
187 {
188 for( SHAPE* s : shapes )
189 delete s;
190 return true;
191 }
192 }
193
194 for( SHAPE* shape : shapes )
195 delete shape;
196
197 return false;
198}
199
200
201bool SCH_SHAPE::IsEndPoint( const VECTOR2I& aPt ) const
202{
203 SHAPE_T shape = GetShape();
204
205 if( shape == SHAPE_T::ARC || shape == SHAPE_T::BEZIER || shape == SHAPE_T::SEGMENT )
206 return ( aPt == GetStart() ) || ( aPt == GetEnd() );
207
208 if( shape == SHAPE_T::RECTANGLE )
209 {
210 for( const VECTOR2I& corner : GetRectCorners() )
211 {
212 if( corner == aPt )
213 return true;
214 }
215
216 return false;
217 }
218
219 if( shape == SHAPE_T::POLY )
220 {
221 for( const VECTOR2I& pt : GetPolyPoints() )
222 {
223 if( pt == aPt )
224 return true;
225 }
226
227 return false;
228 }
229
230 return false;
231}
232
233
234void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
235 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
236{
237 if( IsPrivate() )
238 return;
239
240 // note: if aBodyStyle == -1 the outline shape is not plotted. Only the filled area
241 // is plotted (used to plot cells for SCH_TABLE items
242
243 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
244 int pen_size = GetEffectivePenWidth( renderSettings );
245
246 static std::vector<VECTOR2I> ptList;
247
248 if( GetShape() == SHAPE_T::POLY )
249 {
250 ptList.clear();
251
252 for( const VECTOR2I& pt : GetPolyShape().Outline( 0 ).CPoints() )
253 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
254 }
255 else if( GetShape() == SHAPE_T::BEZIER )
256 {
257 ptList.clear();
258
259 for( const VECTOR2I& pt : m_bezierPoints )
260 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
261 }
263 {
264 ptList.clear();
265
267
269
270 for( int ii = 0; ii < chain.PointCount(); ++ii )
271 ptList.push_back( renderSettings->TransformCoordinate( chain.CPoint( ii ) ) + aOffset );
272 }
273
274 COLOR4D color = GetStroke().GetColor();
275 COLOR4D bg = renderSettings->GetBackgroundColor();
276 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
277 FILL_T fill = m_fill;
278
279 if( aBackground )
280 {
281 switch( m_fill )
282 {
284 // Fill in the foreground layer
285 return;
286
287 case FILL_T::HATCH:
290 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
291 color = renderSettings->GetLayerColor( m_layer );
292
293 color.a = color.a * 0.4;
294 break;
295
297 // drop separate fills in B&W mode
298 if( !aPlotter->GetColorMode() && pen_size > 0 )
299 return;
300
301 color = GetFillColor();
302
303 if( color == COLOR4D::UNSPECIFIED )
304 color = renderSettings->GetLayerColor( m_layer );
305
306 break;
307
309 // drop fill in B&W mode
310 if( !aPlotter->GetColorMode() )
311 return;
312
313 color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
314 break;
315
316 default:
317 return;
318 }
319
320 pen_size = 0;
321 lineStyle = LINE_STYLE::SOLID;
322 }
323 else /* if( aForeground ) */
324 {
325 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
326 color = renderSettings->GetLayerColor( m_layer );
327
328 if( lineStyle == LINE_STYLE::DEFAULT )
329 lineStyle = LINE_STYLE::SOLID;
330
332 fill = m_fill;
333 else
334 fill = FILL_T::NO_FILL;
335
336 pen_size = aBodyStyle == -1 ? 0 : GetEffectivePenWidth( renderSettings );
337 }
338
339 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
340 bg = COLOR4D::WHITE;
341
342 if( color.m_text && Schematic() )
343 color = COLOR4D( ResolveText( *color.m_text, &Schematic()->CurrentSheet() ) );
344
345 if( aDimmed )
346 {
347 color.Desaturate( );
348 color = color.Mix( bg, 0.5f );
349 }
350
351 aPlotter->SetColor( color );
352
353 if( aBackground && IsHatchedFill() )
354 {
355 for( int ii = 0; ii < GetHatching().OutlineCount(); ++ii )
356 aPlotter->PlotPoly( GetHatching().COutline( ii ), FILL_T::FILLED_SHAPE, 0, nullptr );
357
358 return;
359 }
360
361 aPlotter->SetCurrentLineWidth( pen_size );
362 aPlotter->SetDash( pen_size, lineStyle );
363
364 VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
365 VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
366 VECTOR2I mid, center;
367
368 switch( GetShape() )
369 {
370 case SHAPE_T::ARC:
371 mid = renderSettings->TransformCoordinate( GetArcMid() ) + aOffset;
372 aPlotter->Arc( start, mid, end, fill, pen_size );
373 break;
374
375 case SHAPE_T::CIRCLE:
376 center = renderSettings->TransformCoordinate( getCenter() ) + aOffset;
377 aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
378 break;
379
381 aPlotter->Rect( start, end, fill, pen_size, GetCornerRadius() );
382 break;
383
384 case SHAPE_T::POLY:
385 case SHAPE_T::BEZIER:
386 aPlotter->PlotPoly( ptList, fill, pen_size, nullptr );
387 break;
388
389 case SHAPE_T::ELLIPSE:
390 if( !ptList.empty() )
391 ptList.push_back( ptList.front() );
392
393 aPlotter->PlotPoly( ptList, fill, pen_size, nullptr );
394 break;
395
396 case SHAPE_T::ELLIPSE_ARC: aPlotter->PlotPoly( ptList, FILL_T::NO_FILL, pen_size, nullptr ); break;
397
398 default:
400 }
401
402 aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
403}
404
405
407{
408 if( GetPenWidth() > 0 )
409 return GetPenWidth();
410
411 // Historically 0 meant "default width" and negative numbers meant "don't stroke".
412 if( GetPenWidth() < 0 )
413 return 0;
414
415 SCHEMATIC* schematic = Schematic();
416
417 if( schematic )
418 return schematic->Settings().m_DefaultLineWidth;
419
420 return schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS );
421}
422
423
425{
426 return getBoundingBox();
427}
428
429
430void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
431{
432 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
433
434 ShapeGetMsgPanelInfo( aFrame, aList );
435}
436
437
438wxString SCH_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
439{
440 switch( GetShape() )
441 {
442 case SHAPE_T::ARC:
443 return wxString::Format( _( "Arc, radius %s" ),
444 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
445
446 case SHAPE_T::CIRCLE:
447 return wxString::Format( _( "Circle, radius %s" ),
448 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
449
451 return wxString::Format( _( "Rectangle, width %s height %s" ),
452 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
453 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
454
455 case SHAPE_T::POLY:
456 return wxString::Format( _( "Polyline, %d points" ),
457 int( GetPolyShape().Outline( 0 ).GetPointCount() ) );
458
459 case SHAPE_T::BEZIER:
460 return wxString::Format( _( "Bezier Curve, %d points" ),
461 int( m_bezierPoints.size() ) );
462
463 case SHAPE_T::ELLIPSE:
464 return wxString::Format( _( "Ellipse, %s x %s" ),
465 aUnitsProvider->MessageTextFromValue( GetEllipseMajorRadius() ),
466 aUnitsProvider->MessageTextFromValue( GetEllipseMinorRadius() ) );
467
469 return wxString::Format( _( "Elliptical Arc, %s x %s" ),
470 aUnitsProvider->MessageTextFromValue( GetEllipseMajorRadius() ),
471 aUnitsProvider->MessageTextFromValue( GetEllipseMinorRadius() ) );
472
473 default:
475 return wxEmptyString;
476 }
477}
478
479
498
499
500std::vector<int> SCH_SHAPE::ViewGetLayers() const
501{
502 std::vector<int> layers( 3 );
503
504 layers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer;
505
506 if( m_layer == LAYER_DEVICE )
507 {
509 layers[1] = LAYER_DEVICE_BACKGROUND;
510 else
511 layers[1] = LAYER_SHAPES_BACKGROUND;
512 }
513 else
514 {
515 layers[1] = LAYER_SHAPES_BACKGROUND;
516 }
517
518 layers[2] = LAYER_SELECTION_SHADOWS;
519
520 return layers;
521}
522
523
524void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
525{
526 if( GetShape() == SHAPE_T::POLY )
527 {
528 if( GetPolyShape().IsEmpty() )
529 {
531 GetPolyShape().Outline( 0 ).SetClosed( false );
532 }
533
534 GetPolyShape().Outline( 0 ).Append( aPosition, true );
535 }
536 else
537 {
539 }
540}
541
542
543bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
544{
545 if( aOther.Type() != Type() )
546 return false;
547
548 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
549
550 return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
551}
552
553
554double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
555{
556 if( m_Uuid == aOther.m_Uuid )
557 return 1.0;
558
559 if( aOther.Type() != Type() )
560 return 0.0;
561
562 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
563
564 double similarity = SimilarityBase( other );
565
566 similarity *= EDA_SHAPE::Similarity( other );
567
568 return similarity;
569}
570
571
572int SCH_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
573{
574 int cmpFlags = aCompareFlags;
575
576 // The object UUIDs must be compared after the shape coordinates because shapes do not
577 // have immutable UUIDs.
580
581 int retv = SCH_ITEM::compare( aOther, cmpFlags );
582
583 if( retv )
584 return retv;
585
586 retv = EDA_SHAPE::Compare( &static_cast<const SCH_SHAPE&>( aOther ) );
587
588 if( retv )
589 return retv;
590
591 if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
592 || ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
593 {
594 return 0;
595 }
596
597 if( m_Uuid < aOther.m_Uuid )
598 return -1;
599
600 if( m_Uuid > aOther.m_Uuid )
601 return 1;
602
603 return 0;
604}
605
606
607static struct SCH_SHAPE_DESC
608{
610 {
612
613 if( fillEnum.Choices().GetCount() == 0 )
614 {
615 fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) )
616 .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) )
617 .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) )
618 .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) );
619 }
620
627
628 // Polygons and ellipses have meaningful Position properties (first vertex / center).
629 // On other shapes, Position duplicates the Start properties.
630 auto isPolygonOrEllipse = []( INSPECTABLE* aItem ) -> bool
631 {
632 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
633 {
634 const SHAPE_T t = shape->GetShape();
635 return t == SHAPE_T::POLY || t == SHAPE_T::ELLIPSE || t == SHAPE_T::ELLIPSE_ARC;
636 }
637 return false;
638 };
639
640 // Hide Start/End for shapes that don't use them directly
641 // (polygon uses first vertex via Position; circle uses Center; ellipse uses Center + radii).
642 auto isNotPolygonOrCircleOrEllipse = []( INSPECTABLE* aItem ) -> bool
643 {
644 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
645 {
646 const SHAPE_T t = shape->GetShape();
647 return t != SHAPE_T::POLY && t != SHAPE_T::CIRCLE && t != SHAPE_T::ELLIPSE && t != SHAPE_T::ELLIPSE_ARC;
648 }
649 return true;
650 };
651
652 auto isSymbolItem =
653 []( INSPECTABLE* aItem ) -> bool
654 {
655 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
656 return shape->GetLayer() == LAYER_DEVICE;
657
658 return false;
659 };
660
661 auto isSchematicItem =
662 []( INSPECTABLE* aItem ) -> bool
663 {
664 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
665 return shape->GetLayer() != LAYER_DEVICE;
666
667 return false;
668 };
669
670 auto isFillColorEditable =
671 []( INSPECTABLE* aItem ) -> bool
672 {
673 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
674 {
675 if( shape->GetParentSymbol() )
676 return shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR;
677 else
678 return shape->IsSolidFill();
679 }
680
681 return true;
682 };
683
684 const wxString shapeProps = _HKI( "Shape Properties" );
685
689 shapeProps )
690 .SetAvailableFunc( isPolygonOrEllipse );
691
695 shapeProps )
696 .SetAvailableFunc( isPolygonOrEllipse );
697
698 propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ),
699 isNotPolygonOrCircleOrEllipse );
700 propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ),
701 isNotPolygonOrCircleOrEllipse );
703 isNotPolygonOrCircleOrEllipse );
705 isNotPolygonOrCircleOrEllipse );
706
708 _HKI( "Filled" ), isSchematicItem );
709
711 _HKI( "Fill Color" ), isFillColorEditable );
712
713 void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode;
714 FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode;
715
716 propMgr.AddProperty( new PROPERTY_ENUM<SCH_SHAPE, FILL_T>( _HKI( "Fill Mode" ),
717 fillModeSetter, fillModeGetter ),
718 _HKI( "Shape Properties" ) )
719 .SetAvailableFunc( isSymbolItem );
720 }
722
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
BITMAPS
A list of all bitmap identifiers.
@ add_rectangle
@ add_ellipse_arc
@ add_graphical_segments
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
static const COLOR4D WHITE
Definition color4d.h:401
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:531
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM_FLAGS m_flags
Definition eda_item.h:542
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
void SetStartX(int x)
Definition eda_shape.h:208
int GetEllipseMinorRadius() const
Definition eda_shape.h:310
VECTOR2I getCenter() const
int GetStartY() const
Definition eda_shape.h:191
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
const SHAPE_POLY_SET & GetHatching() const
FILL_T GetFillMode() const
Definition eda_shape.h:158
int GetEllipseMajorRadius() const
Definition eda_shape.h:301
void SetEndY(int aY)
Definition eda_shape.h:251
std::vector< VECTOR2I > GetPolyPoints() const
Duplicate the polygon outlines into a flat list of VECTOR2I points.
SHAPE_ELLIPSE buildShapeEllipse() const
void SetStartY(int y)
Definition eda_shape.h:201
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:185
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool IsHatchedFill() const
Definition eda_shape.h:140
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
void SetEndX(int aX)
Definition eda_shape.h:258
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill)
Definition eda_shape.cpp:53
VECTOR2I m_start
Definition eda_shape.h:604
int GetPointCount() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:240
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:190
COLOR4D GetFillColor() const
Definition eda_shape.h:169
void SwapShape(EDA_SHAPE *aImage)
std::vector< VECTOR2I > GetRectCorners() const
std::vector< VECTOR2I > m_bezierPoints
Definition eda_shape.h:613
wxString SHAPE_T_asString() const
int GetStartX() const
Definition eda_shape.h:192
double Similarity(const EDA_SHAPE &aOther) const
VECTOR2I m_end
Definition eda_shape.h:605
const BOX2I getBoundingBox() const
STROKE_PARAMS m_stroke
Definition eda_shape.h:593
FILL_T m_fill
Definition eda_shape.h:594
int GetCornerRadius() const
void SetFillMode(FILL_T aFill)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int Compare(const EDA_SHAPE *aOther) const
VECTOR2I GetArcMid() const
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:727
static ENUM_MAP< T > & Instance()
Definition property.h:721
wxPGChoices & Choices()
Definition property.h:772
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:38
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
std::shared_ptr< wxString > m_text
Definition color4d.h:395
double a
Alpha component.
Definition color4d.h:392
COLOR4D & Desaturate()
Removes color (in HSL model)
Definition color4d.cpp:528
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:292
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Definition kiid.h:44
Base plotter engine class.
Definition plotter.h:133
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width)=0
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0)=0
bool GetColorMode() const
Definition plotter.h:161
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth, void *aData)=0
Draw a polygon ( filled or not ).
virtual void SetColor(const COLOR4D &color)=0
virtual void Arc(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd, FILL_T aFill, int aWidth)
Definition plotter.cpp:148
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition property.h:262
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.
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.
void OverrideWriteability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override writeability functor for a base class property of a given derived class.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Definition schematic.h:90
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
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 sch_item.cpp:825
void SetLocked(bool aLocked) override
Definition sch_item.h:251
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.h:724
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:274
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:268
bool IsLocked() const override
Definition sch_item.cpp:148
virtual bool operator==(const SCH_ITEM &aOther) const
Definition sch_item.cpp:696
bool IsPrivate() const
Definition sch_item.h:248
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:339
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
Definition sch_item.cpp:720
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:377
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:790
SCH_LAYER_ID m_layer
Definition sch_item.h:775
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
Definition sch_item.h:377
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void SetPositionX(int aX)
Definition sch_shape.h:89
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition sch_shape.cpp:72
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition sch_shape.h:116
void SetFilled(bool aFilled) override
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_shape.cpp:49
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition sch_shape.cpp:98
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition sch_shape.cpp:90
void Normalize()
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
SCH_SHAPE(SHAPE_T aShape=SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
Definition sch_shape.cpp:40
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
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 AddPoint(const VECTOR2I &aPosition)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool operator==(const SCH_ITEM &aOther) const override
void SetPositionY(int aY)
Definition sch_shape.h:90
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
int GetPenWidth() const override
Definition sch_shape.h:54
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition sch_shape.cpp:55
STROKE_PARAMS GetStroke() const override
Definition sch_shape.h:57
int GetPositionX() const
Definition sch_shape.h:87
VECTOR2I GetPosition() const override
Definition sch_shape.h:84
int GetEffectiveWidth() const override
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
int GetPositionY() const
Definition sch_shape.h:88
int getMaxError() const override
Definition sch_shape.h:152
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
An abstract shape on 2D plane.
Definition shape.h:124
Simple container to manage line stroke parameters.
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
A type-safe container of any type.
Definition ki_any.h:92
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
static constexpr EDA_ANGLE ANGLE_270
Definition eda_angle.h:416
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
SHAPE_T
Definition eda_shape.h:44
@ ELLIPSE
Definition eda_shape.h:52
@ SEGMENT
Definition eda_shape.h:46
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:47
@ ELLIPSE_ARC
Definition eda_shape.h:53
FILL_T
Definition eda_shape.h:59
@ FILLED_WITH_COLOR
Definition eda_shape.h:63
@ NO_FILL
Definition eda_shape.h:60
@ REVERSE_HATCH
Definition eda_shape.h:65
@ HATCH
Definition eda_shape.h:64
@ FILLED_WITH_BG_BODYCOLOR
Definition eda_shape.h:62
@ FILLED_SHAPE
Fill with object color.
Definition eda_shape.h:61
@ CROSS_HATCH
Definition eda_shape.h:66
a few functions useful in geometry calculations.
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:447
@ LAYER_SHAPES_BACKGROUND
Definition layer_ids.h:481
@ LAYER_DEVICE
Definition layer_ids.h:464
@ LAYER_PRIVATE_NOTES
Definition layer_ids.h:466
@ LAYER_DEVICE_BACKGROUND
Definition layer_ids.h:482
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:493
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition macros.h:92
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:24
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:25
Message panel definition file.
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
#define _HKI(x)
Definition page_info.cpp:40
#define TYPE_HASH(x)
Definition property.h:74
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
Definition property.h:828
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Definition property.h:65
#define REGISTER_TYPE(x)
static struct SCH_SHAPE_DESC _SCH_SHAPE_DESC
LINE_STYLE
Dashed line types.
VECTOR2I center
const SHAPE_LINE_CHAIN chain
VECTOR2I end
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683