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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <sch_draw_panel.h>
26#include <macros.h>
27#include <plotters/plotter.h>
28#include <base_units.h>
29#include <widgets/msgpanel.h>
30#include <bitmaps.h>
31#include <eda_draw_frame.h>
32#include <gr_basic.h>
36#include <schematic.h>
37#include <api/api_utils.h>
38#include <api/schematic/schematic_types.pb.h>
39#include <sch_shape.h>
40#include <properties/property.h>
42
43
44SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
45 KICAD_T aType ) :
46 SCH_ITEM( nullptr, aType ),
47 EDA_SHAPE( aShape, aLineWidth, aFillType )
48{
49 SetLayer( aLayer );
50}
51
52
54{
55 return new SCH_SHAPE( *this );
56}
57
58
59void SCH_SHAPE::Serialize( google::protobuf::Any& aContainer ) const
60{
61 using namespace kiapi::common;
62
63 kiapi::schematic::types::SchematicGraphicShape msg;
64 google::protobuf::Any any;
65
66 msg.mutable_id()->set_value( m_Uuid.AsStdString() );
67 msg.set_locked( IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
68
70 any.UnpackTo( msg.mutable_shape() );
71
72 aContainer.PackFrom( msg );
73}
74
75
76bool SCH_SHAPE::Deserialize( const google::protobuf::Any& aContainer )
77{
78 using namespace kiapi::common;
79
80 kiapi::schematic::types::SchematicGraphicShape msg;
81
82 if( !aContainer.UnpackTo( &msg ) )
83 return false;
84
85 const_cast<KIID&>( m_Uuid ) = KIID( msg.id().value() );
86 SetLocked( msg.locked() == types::LockedState::LS_LOCKED );
87
88 google::protobuf::Any any;
89 any.PackFrom( msg.shape() );
91}
92
93
95{
96 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
97
98 EDA_SHAPE::SwapShape( shape );
99}
100
101
103{
104 m_stroke = aStroke;
105}
106
107
108void SCH_SHAPE::SetFilled( bool aFilled )
109{
110 if( !aFilled )
112 else if( GetParentSymbol() )
114 else
116}
117
118
119void SCH_SHAPE::Move( const VECTOR2I& aOffset )
120{
121 move( aOffset );
122}
123
124
126{
128 {
129 VECTOR2I size = GetEnd() - GetPosition();
130
131 if( size.y < 0 )
132 {
133 SetStartY( GetStartY() + size.y );
134 SetEndY( GetStartY() - size.y );
135 }
136
137 if( size.x < 0 )
138 {
139 SetStartX( GetStartX() + size.x );
140 SetEndX( GetStartX() - size.x );
141 }
142 }
143}
144
145
147{
148 flip( VECTOR2I( aCenter, 0 ), FLIP_DIRECTION::LEFT_RIGHT );
149}
150
151
153{
154 flip( VECTOR2I( 0, aCenter ), FLIP_DIRECTION::TOP_BOTTOM );
155}
156
157
158void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
159{
160 rotate( aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
161}
162
163
164bool SCH_SHAPE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
165{
166 return hitTest( aPosition, aAccuracy );
167}
168
169
170bool SCH_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
171{
173 return false;
174
175 return hitTest( aRect, aContained, aAccuracy );
176}
177
178
179bool SCH_SHAPE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
180{
182 return false;
183
184 std::vector<SHAPE*> shapes = MakeEffectiveShapes( false );
185
186 for( SHAPE* shape : shapes )
187 {
188 bool hit = KIGEOM::ShapeHitTest( aPoly, *shape, aContained );
189
190 if( hit )
191 {
192 for( SHAPE* s : shapes )
193 delete s;
194 return true;
195 }
196 }
197
198 for( SHAPE* shape : shapes )
199 delete shape;
200
201 return false;
202}
203
204
205bool SCH_SHAPE::IsEndPoint( const VECTOR2I& aPt ) const
206{
207 SHAPE_T shape = GetShape();
208
209 if( shape == SHAPE_T::ARC || shape == SHAPE_T::BEZIER || shape == SHAPE_T::SEGMENT )
210 return ( aPt == GetStart() ) || ( aPt == GetEnd() );
211
212 if( shape == SHAPE_T::RECTANGLE )
213 {
214 for( const VECTOR2I& corner : GetRectCorners() )
215 {
216 if( corner == aPt )
217 return true;
218 }
219
220 return false;
221 }
222
223 if( shape == SHAPE_T::POLY )
224 {
225 for( const VECTOR2I& pt : GetPolyPoints() )
226 {
227 if( pt == aPt )
228 return true;
229 }
230
231 return false;
232 }
233
234 return false;
235}
236
237
238void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
239 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
240{
241 if( IsPrivate() )
242 return;
243
244 // note: if aBodyStyle == -1 the outline shape is not plotted. Only the filled area
245 // is plotted (used to plot cells for SCH_TABLE items
246
247 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
248 int pen_size = GetEffectivePenWidth( renderSettings );
249
250 static std::vector<VECTOR2I> ptList;
251
252 if( GetShape() == SHAPE_T::POLY )
253 {
254 ptList.clear();
255
256 for( const VECTOR2I& pt : GetPolyShape().Outline( 0 ).CPoints() )
257 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
258 }
259 else if( GetShape() == SHAPE_T::BEZIER )
260 {
261 ptList.clear();
262
263 for( const VECTOR2I& pt : m_bezierPoints )
264 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
265 }
267 {
268 ptList.clear();
269
271
273
274 for( int ii = 0; ii < chain.PointCount(); ++ii )
275 ptList.push_back( renderSettings->TransformCoordinate( chain.CPoint( ii ) ) + aOffset );
276 }
277
278 COLOR4D color = GetStroke().GetColor();
279 COLOR4D bg = renderSettings->GetBackgroundColor();
280 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
281 FILL_T fill = m_fill;
282
283 if( aBackground )
284 {
285 switch( m_fill )
286 {
288 // Fill in the foreground layer
289 return;
290
291 case FILL_T::HATCH:
294 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
295 color = renderSettings->GetLayerColor( m_layer );
296
297 color.a = color.a * 0.4;
298 break;
299
301 // drop separate fills in B&W mode
302 if( !aPlotter->GetColorMode() && pen_size > 0 )
303 return;
304
305 color = GetFillColor();
306
307 if( color == COLOR4D::UNSPECIFIED )
308 color = renderSettings->GetLayerColor( m_layer );
309
310 break;
311
313 // drop fill in B&W mode
314 if( !aPlotter->GetColorMode() )
315 return;
316
317 color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
318 break;
319
320 default:
321 return;
322 }
323
324 pen_size = 0;
325 lineStyle = LINE_STYLE::SOLID;
326 }
327 else /* if( aForeground ) */
328 {
329 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
330 color = renderSettings->GetLayerColor( m_layer );
331
332 if( lineStyle == LINE_STYLE::DEFAULT )
333 lineStyle = LINE_STYLE::SOLID;
334
336 fill = m_fill;
337 else
338 fill = FILL_T::NO_FILL;
339
340 pen_size = aBodyStyle == -1 ? 0 : GetEffectivePenWidth( renderSettings );
341 }
342
343 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
344 bg = COLOR4D::WHITE;
345
346 if( color.m_text && Schematic() )
347 color = COLOR4D( ResolveText( *color.m_text, &Schematic()->CurrentSheet() ) );
348
349 if( aDimmed )
350 {
351 color.Desaturate( );
352 color = color.Mix( bg, 0.5f );
353 }
354
355 aPlotter->SetColor( color );
356
357 if( aBackground && IsHatchedFill() )
358 {
359 for( int ii = 0; ii < GetHatching().OutlineCount(); ++ii )
360 aPlotter->PlotPoly( GetHatching().COutline( ii ), FILL_T::FILLED_SHAPE, 0, nullptr );
361
362 return;
363 }
364
365 aPlotter->SetCurrentLineWidth( pen_size );
366 aPlotter->SetDash( pen_size, lineStyle );
367
368 VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
369 VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
370 VECTOR2I mid, center;
371
372 switch( GetShape() )
373 {
374 case SHAPE_T::ARC:
375 mid = renderSettings->TransformCoordinate( GetArcMid() ) + aOffset;
376 aPlotter->Arc( start, mid, end, fill, pen_size );
377 break;
378
379 case SHAPE_T::CIRCLE:
380 center = renderSettings->TransformCoordinate( getCenter() ) + aOffset;
381 aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
382 break;
383
385 aPlotter->Rect( start, end, fill, pen_size, GetCornerRadius() );
386 break;
387
388 case SHAPE_T::POLY:
389 case SHAPE_T::BEZIER:
390 aPlotter->PlotPoly( ptList, fill, pen_size, nullptr );
391 break;
392
393 case SHAPE_T::ELLIPSE:
394 if( !ptList.empty() )
395 ptList.push_back( ptList.front() );
396
397 aPlotter->PlotPoly( ptList, fill, pen_size, nullptr );
398 break;
399
400 case SHAPE_T::ELLIPSE_ARC: aPlotter->PlotPoly( ptList, FILL_T::NO_FILL, pen_size, nullptr ); break;
401
402 default:
404 }
405
406 aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
407}
408
409
411{
412 if( GetPenWidth() > 0 )
413 return GetPenWidth();
414
415 // Historically 0 meant "default width" and negative numbers meant "don't stroke".
416 if( GetPenWidth() < 0 )
417 return 0;
418
419 SCHEMATIC* schematic = Schematic();
420
421 if( schematic )
422 return schematic->Settings().m_DefaultLineWidth;
423
424 return schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS );
425}
426
427
429{
430 return getBoundingBox();
431}
432
433
434void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
435{
436 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
437
438 ShapeGetMsgPanelInfo( aFrame, aList );
439}
440
441
442wxString SCH_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
443{
444 switch( GetShape() )
445 {
446 case SHAPE_T::ARC:
447 return wxString::Format( _( "Arc, radius %s" ),
448 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
449
450 case SHAPE_T::CIRCLE:
451 return wxString::Format( _( "Circle, radius %s" ),
452 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
453
455 return wxString::Format( _( "Rectangle, width %s height %s" ),
456 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
457 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
458
459 case SHAPE_T::POLY:
460 return wxString::Format( _( "Polyline, %d points" ),
461 int( GetPolyShape().Outline( 0 ).GetPointCount() ) );
462
463 case SHAPE_T::BEZIER:
464 return wxString::Format( _( "Bezier Curve, %d points" ),
465 int( m_bezierPoints.size() ) );
466
467 case SHAPE_T::ELLIPSE:
468 return wxString::Format( _( "Ellipse, %s x %s" ),
469 aUnitsProvider->MessageTextFromValue( GetEllipseMajorRadius() ),
470 aUnitsProvider->MessageTextFromValue( GetEllipseMinorRadius() ) );
471
473 return wxString::Format( _( "Elliptical Arc, %s x %s" ),
474 aUnitsProvider->MessageTextFromValue( GetEllipseMajorRadius() ),
475 aUnitsProvider->MessageTextFromValue( GetEllipseMinorRadius() ) );
476
477 default:
479 return wxEmptyString;
480 }
481}
482
483
502
503
504std::vector<int> SCH_SHAPE::ViewGetLayers() const
505{
506 std::vector<int> layers( 3 );
507
508 layers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer;
509
510 if( m_layer == LAYER_DEVICE )
511 {
513 layers[1] = LAYER_DEVICE_BACKGROUND;
514 else
515 layers[1] = LAYER_SHAPES_BACKGROUND;
516 }
517 else
518 {
519 layers[1] = LAYER_SHAPES_BACKGROUND;
520 }
521
522 layers[2] = LAYER_SELECTION_SHADOWS;
523
524 return layers;
525}
526
527
528void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
529{
530 if( GetShape() == SHAPE_T::POLY )
531 {
532 if( GetPolyShape().IsEmpty() )
533 {
535 GetPolyShape().Outline( 0 ).SetClosed( false );
536 }
537
538 GetPolyShape().Outline( 0 ).Append( aPosition, true );
539 }
540 else
541 {
543 }
544}
545
546
547bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
548{
549 if( aOther.Type() != Type() )
550 return false;
551
552 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
553
554 return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
555}
556
557
558double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
559{
560 if( m_Uuid == aOther.m_Uuid )
561 return 1.0;
562
563 if( aOther.Type() != Type() )
564 return 0.0;
565
566 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
567
568 double similarity = SimilarityBase( other );
569
570 similarity *= EDA_SHAPE::Similarity( other );
571
572 return similarity;
573}
574
575
576int SCH_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
577{
578 int cmpFlags = aCompareFlags;
579
580 // The object UUIDs must be compared after the shape coordinates because shapes do not
581 // have immutable UUIDs.
584
585 int retv = SCH_ITEM::compare( aOther, cmpFlags );
586
587 if( retv )
588 return retv;
589
590 retv = EDA_SHAPE::Compare( &static_cast<const SCH_SHAPE&>( aOther ) );
591
592 if( retv )
593 return retv;
594
595 if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
596 || ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
597 {
598 return 0;
599 }
600
601 if( m_Uuid < aOther.m_Uuid )
602 return -1;
603
604 if( m_Uuid > aOther.m_Uuid )
605 return 1;
606
607 return 0;
608}
609
610
611static struct SCH_SHAPE_DESC
612{
614 {
616
617 if( fillEnum.Choices().GetCount() == 0 )
618 {
619 fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) )
620 .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) )
621 .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) )
622 .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) );
623 }
624
631
632 // Polygons and ellipses have meaningful Position properties (first vertex / center).
633 // On other shapes, Position duplicates the Start properties.
634 auto isPolygonOrEllipse = []( INSPECTABLE* aItem ) -> bool
635 {
636 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
637 {
638 const SHAPE_T t = shape->GetShape();
639 return t == SHAPE_T::POLY || t == SHAPE_T::ELLIPSE || t == SHAPE_T::ELLIPSE_ARC;
640 }
641 return false;
642 };
643
644 // Hide Start/End for shapes that don't use them directly
645 // (polygon uses first vertex via Position; circle uses Center; ellipse uses Center + radii).
646 auto isNotPolygonOrCircleOrEllipse = []( INSPECTABLE* aItem ) -> bool
647 {
648 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
649 {
650 const SHAPE_T t = shape->GetShape();
651 return t != SHAPE_T::POLY && t != SHAPE_T::CIRCLE && t != SHAPE_T::ELLIPSE && t != SHAPE_T::ELLIPSE_ARC;
652 }
653 return true;
654 };
655
656 auto isSymbolItem =
657 []( INSPECTABLE* aItem ) -> bool
658 {
659 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
660 return shape->GetLayer() == LAYER_DEVICE;
661
662 return false;
663 };
664
665 auto isSchematicItem =
666 []( INSPECTABLE* aItem ) -> bool
667 {
668 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
669 return shape->GetLayer() != LAYER_DEVICE;
670
671 return false;
672 };
673
674 auto isFillColorEditable =
675 []( INSPECTABLE* aItem ) -> bool
676 {
677 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
678 {
679 if( shape->GetParentSymbol() )
680 return shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR;
681 else
682 return shape->IsSolidFill();
683 }
684
685 return true;
686 };
687
688 const wxString shapeProps = _HKI( "Shape Properties" );
689
693 shapeProps )
694 .SetAvailableFunc( isPolygonOrEllipse );
695
699 shapeProps )
700 .SetAvailableFunc( isPolygonOrEllipse );
701
702 propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ),
703 isNotPolygonOrCircleOrEllipse );
704 propMgr.OverrideAvailability( TYPE_HASH( SCH_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ),
705 isNotPolygonOrCircleOrEllipse );
707 isNotPolygonOrCircleOrEllipse );
709 isNotPolygonOrCircleOrEllipse );
710
712 _HKI( "Filled" ), isSchematicItem );
713
715 _HKI( "Fill Color" ), isFillColorEditable );
716
717 void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode;
718 FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode;
719
720 propMgr.AddProperty( new PROPERTY_ENUM<SCH_SHAPE, FILL_T>( _HKI( "Fill Mode" ),
721 fillModeSetter, fillModeGetter ),
722 _HKI( "Shape Properties" ) )
723 .SetAvailableFunc( isSymbolItem );
724 }
726
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:127
BITMAPS
A list of all bitmap identifiers.
@ add_rectangle
@ add_ellipse_arc
@ add_graphical_segments
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
static const COLOR4D WHITE
Definition color4d.h:405
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:402
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:528
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
EDA_ITEM_FLAGS m_flags
Definition eda_item.h:539
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
void SetStartX(int x)
Definition eda_shape.h:212
int GetEllipseMinorRadius() const
Definition eda_shape.h:306
VECTOR2I getCenter() const
int GetStartY() const
Definition eda_shape.h:195
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
const SHAPE_POLY_SET & GetHatching() const
FILL_T GetFillMode() const
Definition eda_shape.h:162
int GetEllipseMajorRadius() const
Definition eda_shape.h:297
void SetEndY(int aY)
Definition eda_shape.h:247
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:205
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:189
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool IsHatchedFill() const
Definition eda_shape.h:144
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
void SetEndX(int aX)
Definition eda_shape.h:254
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill)
Definition eda_shape.cpp:57
VECTOR2I m_start
Definition eda_shape.h:599
int GetPointCount() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:236
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:194
COLOR4D GetFillColor() const
Definition eda_shape.h:173
void SwapShape(EDA_SHAPE *aImage)
std::vector< VECTOR2I > GetRectCorners() const
std::vector< VECTOR2I > m_bezierPoints
Definition eda_shape.h:608
wxString SHAPE_T_asString() const
int GetStartX() const
Definition eda_shape.h:196
double Similarity(const EDA_SHAPE &aOther) const
VECTOR2I m_end
Definition eda_shape.h:600
const BOX2I getBoundingBox() const
STROKE_PARAMS m_stroke
Definition eda_shape.h:588
FILL_T m_fill
Definition eda_shape.h:589
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:770
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:105
std::shared_ptr< wxString > m_text
Definition color4d.h:399
double a
Alpha component.
Definition color4d.h:396
COLOR4D & Desaturate()
Removes color (in HSL model)
Definition color4d.cpp:532
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:296
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Definition kiid.h:48
Base plotter engine class.
Definition plotter.h:137
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:165
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:152
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:89
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
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:827
void SetLocked(bool aLocked) override
Definition sch_item.h:257
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.h:730
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:278
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:272
bool IsLocked() const override
Definition sch_item.cpp:152
virtual bool operator==(const SCH_ITEM &aOther) const
Definition sch_item.cpp:698
bool IsPrivate() const
Definition sch_item.h:254
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:345
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:722
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:381
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:792
SCH_LAYER_ID m_layer
Definition sch_item.h:781
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:383
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:93
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:76
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition sch_shape.h:120
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:53
void SetStroke(const STROKE_PARAMS &aStroke) override
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition sch_shape.cpp:94
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:44
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:94
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:58
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:59
STROKE_PARAMS GetStroke() const override
Definition sch_shape.h:61
int GetPositionX() const
Definition sch_shape.h:91
VECTOR2I GetPosition() const override
Definition sch_shape.h:88
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:92
int getMaxError() const override
Definition sch_shape.h:156
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:128
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:93
#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:48
@ ELLIPSE
Definition eda_shape.h:56
@ SEGMENT
Definition eda_shape.h:50
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:51
@ ELLIPSE_ARC
Definition eda_shape.h:57
FILL_T
Definition eda_shape.h:63
@ FILLED_WITH_COLOR
Definition eda_shape.h:67
@ NO_FILL
Definition eda_shape.h:64
@ REVERSE_HATCH
Definition eda_shape.h:69
@ HATCH
Definition eda_shape.h:68
@ FILLED_WITH_BG_BODYCOLOR
Definition eda_shape.h:66
@ FILLED_SHAPE
Fill with object color.
Definition eda_shape.h:65
@ CROSS_HATCH
Definition eda_shape.h:70
a few functions useful in geometry calculations.
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:451
@ LAYER_SHAPES_BACKGROUND
Definition layer_ids.h:485
@ LAYER_DEVICE
Definition layer_ids.h:468
@ LAYER_PRIVATE_NOTES
Definition layer_ids.h:470
@ LAYER_DEVICE_BACKGROUND
Definition layer_ids.h:486
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:497
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition macros.h:96
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:28
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:29
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:44
#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:823
@ 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:75
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687