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>
33#include <schematic.h>
34#include <sch_shape.h>
35
36
37SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
38 KICAD_T aType ) :
39 SCH_ITEM( nullptr, aType ),
40 EDA_SHAPE( aShape, aLineWidth, aFillType )
41{
42 SetLayer( aLayer );
43}
44
45
47{
48 return new SCH_SHAPE( *this );
49}
50
51
53{
54 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
55
56 EDA_SHAPE::SwapShape( shape );
57 std::swap( m_layer, shape->m_layer );
58}
59
60
61void SCH_SHAPE::SetStroke( const STROKE_PARAMS& aStroke )
62{
63 m_stroke = aStroke;
64}
65
66
67void SCH_SHAPE::SetFilled( bool aFilled )
68{
69 if( !aFilled )
70 m_fill = FILL_T::NO_FILL;
71 else if( GetParentSymbol() )
72 m_fill = FILL_T::FILLED_SHAPE;
73 else
74 m_fill = FILL_T::FILLED_WITH_COLOR;
75}
76
77
78void SCH_SHAPE::Move( const VECTOR2I& aOffset )
79{
80 move( aOffset );
81}
82
83
85{
86 if( GetShape() == SHAPE_T::RECTANGLE )
87 {
88 VECTOR2I size = GetEnd() - GetPosition();
89
90 if( size.y < 0 )
91 {
92 SetStartY( GetStartY() + size.y );
93 SetEndY( GetStartY() - size.y );
94 }
95
96 if( size.x < 0 )
97 {
98 SetStartX( GetStartX() + size.x );
99 SetEndX( GetStartX() - size.x );
100 }
101 }
102}
103
104
106{
107 flip( VECTOR2I( aCenter, 0 ), FLIP_DIRECTION::LEFT_RIGHT );
108}
109
110
112{
113 flip( VECTOR2I( 0, aCenter ), FLIP_DIRECTION::TOP_BOTTOM );
114}
115
116
117void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
118{
119 rotate( aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
120}
121
122
123bool SCH_SHAPE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
124{
125 return hitTest( aPosition, aAccuracy );
126}
127
128
129bool SCH_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
130{
132 return false;
133
134 return hitTest( aRect, aContained, aAccuracy );
135}
136
137
138bool SCH_SHAPE::IsEndPoint( const VECTOR2I& aPt ) const
139{
140 SHAPE_T shape = GetShape();
141
142 if( ( shape == SHAPE_T::ARC ) || ( shape == SHAPE_T::BEZIER ) )
143 return ( aPt == GetStart() ) || ( aPt == GetEnd() );
144
145 return false;
146}
147
148
149void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
150 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
151{
152 if( IsPrivate() )
153 return;
154
155 // note: if aBodyStyle == -1 the outline shape is not plotted. Only the filled area
156 // is plotted (used to plot cells for SCH_TABLE items
157
158 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
159 int pen_size = GetEffectivePenWidth( renderSettings );
160
161 static std::vector<VECTOR2I> ptList;
162
163 if( GetShape() == SHAPE_T::POLY )
164 {
165 ptList.clear();
166
167 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
168 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
169 }
170 else if( GetShape() == SHAPE_T::BEZIER )
171 {
172 ptList.clear();
173
174 for( const VECTOR2I& pt : m_bezierPoints )
175 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
176 }
177
179 COLOR4D bg = renderSettings->GetBackgroundColor();
180 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
181 FILL_T fill = m_fill;
182
183 if( aBackground )
184 {
185 switch( m_fill )
186 {
187 case FILL_T::FILLED_SHAPE:
188 // Fill in the foreground layer
189 return;
190
191 case FILL_T::HATCH:
192 case FILL_T::REVERSE_HATCH:
193 case FILL_T::CROSS_HATCH:
194 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
195 color = renderSettings->GetLayerColor( m_layer );
196
197 color.a = color.a * 0.4;
198 break;
199
200 case FILL_T::FILLED_WITH_COLOR:
201 // drop fill in B&W mode
202 if( !aPlotter->GetColorMode() )
203 return;
204
206 break;
207
208 case FILL_T::FILLED_WITH_BG_BODYCOLOR:
209 // drop fill in B&W mode
210 if( !aPlotter->GetColorMode() )
211 return;
212
213 color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
214 break;
215
216 default:
217 return;
218 }
219
220 pen_size = 0;
221 lineStyle = LINE_STYLE::SOLID;
222 }
223 else /* if( aForeground ) */
224 {
225 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
226 color = renderSettings->GetLayerColor( m_layer );
227
228 if( lineStyle == LINE_STYLE::DEFAULT )
229 lineStyle = LINE_STYLE::SOLID;
230
231 if( m_fill == FILL_T::FILLED_SHAPE )
232 fill = m_fill;
233 else
234 fill = FILL_T::NO_FILL;
235
236 pen_size = aBodyStyle == -1 ? 0 : GetEffectivePenWidth( renderSettings );
237 }
238
239 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
240 bg = COLOR4D::WHITE;
241
242 if( aDimmed )
243 {
244 color.Desaturate( );
245 color = color.Mix( bg, 0.5f );
246 }
247
248 aPlotter->SetColor( color );
249
250 if( aBackground && IsHatchedFill() )
251 {
252 for( int ii = 0; ii < GetHatching().OutlineCount(); ++ii )
253 aPlotter->PlotPoly( GetHatching().COutline( ii ), FILL_T::FILLED_SHAPE, 0, nullptr );
254
255 return;
256 }
257
258 aPlotter->SetCurrentLineWidth( pen_size );
259 aPlotter->SetDash( pen_size, lineStyle );
260
261 VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
262 VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
263 VECTOR2I mid, center;
264
265 switch( GetShape() )
266 {
267 case SHAPE_T::ARC:
268 mid = renderSettings->TransformCoordinate( GetArcMid() ) + aOffset;
269 aPlotter->Arc( start, mid, end, fill, pen_size );
270 break;
271
272 case SHAPE_T::CIRCLE:
273 center = renderSettings->TransformCoordinate( getCenter() ) + aOffset;
274 aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
275 break;
276
277 case SHAPE_T::RECTANGLE:
278 aPlotter->Rect( start, end, fill, pen_size );
279 break;
280
281 case SHAPE_T::POLY:
282 case SHAPE_T::BEZIER:
283 aPlotter->PlotPoly( ptList, fill, pen_size, nullptr );
284 break;
285
286 default:
288 }
289
290 aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
291}
292
293
295{
296 if( GetPenWidth() > 0 )
297 return GetPenWidth();
298
299 // Historically 0 meant "default width" and negative numbers meant "don't stroke".
300 if( GetPenWidth() < 0 )
301 return 0;
302
303 SCHEMATIC* schematic = Schematic();
304
305 if( schematic )
306 return schematic->Settings().m_DefaultLineWidth;
307
309}
310
311
313{
314 return getBoundingBox();
315}
316
317
318void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
319{
320 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
321
322 ShapeGetMsgPanelInfo( aFrame, aList );
323}
324
325
326wxString SCH_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
327{
328 switch( GetShape() )
329 {
330 case SHAPE_T::ARC:
331 return wxString::Format( _( "Arc, radius %s" ),
332 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
333
334 case SHAPE_T::CIRCLE:
335 return wxString::Format( _( "Circle, radius %s" ),
336 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
337
338 case SHAPE_T::RECTANGLE:
339 return wxString::Format( _( "Rectangle, width %s height %s" ),
340 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
341 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
342
343 case SHAPE_T::POLY:
344 return wxString::Format( _( "Polyline, %d points" ),
345 int( m_poly.Outline( 0 ).GetPointCount() ) );
346
347 case SHAPE_T::BEZIER:
348 return wxString::Format( _( "Bezier Curve, %d points" ),
349 int( m_bezierPoints.size() ) );
350
351 default:
353 return wxEmptyString;
354 }
355}
356
357
359{
360 switch( GetShape() )
361 {
362 case SHAPE_T::SEGMENT: return BITMAPS::add_line;
363 case SHAPE_T::ARC: return BITMAPS::add_arc;
364 case SHAPE_T::CIRCLE: return BITMAPS::add_circle;
365 case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle;
366 case SHAPE_T::POLY: return BITMAPS::add_graphical_segments;
367 case SHAPE_T::BEZIER: return BITMAPS::add_bezier;
368
369 default:
371 return BITMAPS::question_mark;
372 }
373}
374
375
376std::vector<int> SCH_SHAPE::ViewGetLayers() const
377{
378 std::vector<int> layers( 3 );
379
380 layers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer;
381
382 if( m_layer == LAYER_DEVICE )
383 {
384 if( m_fill == FILL_T::FILLED_WITH_BG_BODYCOLOR )
385 layers[1] = LAYER_DEVICE_BACKGROUND;
386 else
387 layers[1] = LAYER_SHAPES_BACKGROUND;
388 }
389 else
390 {
391 layers[1] = LAYER_SHAPES_BACKGROUND;
392 }
393
394 layers[2] = LAYER_SELECTION_SHADOWS;
395
396 return layers;
397}
398
399
400void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
401{
402 if( GetShape() == SHAPE_T::POLY )
403 {
404 if( m_poly.IsEmpty() )
405 {
407 m_poly.Outline( 0 ).SetClosed( false );
408 }
409
410 m_poly.Outline( 0 ).Append( aPosition, true );
411 }
412 else
413 {
415 }
416}
417
418
419bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
420{
421 if( aOther.Type() != Type() )
422 return false;
423
424 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
425
426 return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
427}
428
429
430double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
431{
432 if( m_Uuid == aOther.m_Uuid )
433 return 1.0;
434
435 if( aOther.Type() != Type() )
436 return 0.0;
437
438 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
439
440 double similarity = SimilarityBase( other );
441
442 similarity *= EDA_SHAPE::Similarity( other );
443
444 return similarity;
445}
446
447
448int SCH_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
449{
450 int cmpFlags = aCompareFlags;
451
452 // The object UUIDs must be compared after the shape coordinates because shapes do not
453 // have immutable UUIDs.
456
457 int retv = SCH_ITEM::compare( aOther, cmpFlags );
458
459 if( retv )
460 return retv;
461
462 retv = EDA_SHAPE::Compare( &static_cast<const SCH_SHAPE&>( aOther ) );
463
464 if( retv )
465 return retv;
466
467 if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
468 || ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
469 {
470 return 0;
471 }
472
473 if( m_Uuid < aOther.m_Uuid )
474 return -1;
475
476 if( m_Uuid > aOther.m_Uuid )
477 return 1;
478
479 return 0;
480}
481
482
483static struct SCH_SHAPE_DESC
484{
486 {
488
489 if( fillEnum.Choices().GetCount() == 0 )
490 {
491 fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) )
492 .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) )
493 .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) )
494 .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) );
495 }
496
503
504 // Only polygons have meaningful Position properties.
505 // On other shapes, these are duplicates of the Start properties.
506 auto isPolygon =
507 []( INSPECTABLE* aItem ) -> bool
508 {
509 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
510 return shape->GetShape() == SHAPE_T::POLY;
511
512 return false;
513 };
514
515 auto isSymbolItem =
516 []( INSPECTABLE* aItem ) -> bool
517 {
518 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
519 return shape->GetLayer() == LAYER_DEVICE;
520
521 return false;
522 };
523
524 auto isSchematicItem =
525 []( INSPECTABLE* aItem ) -> bool
526 {
527 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
528 return shape->GetLayer() != LAYER_DEVICE;
529
530 return false;
531 };
532
533 auto isFillColorEditable =
534 []( INSPECTABLE* aItem ) -> bool
535 {
536 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
537 {
538 if( shape->GetParentSymbol() )
539 return shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR;
540 else
541 return shape->IsSolidFill();
542 }
543
544 return true;
545 };
546
548 _HKI( "Position X" ), isPolygon );
550 _HKI( "Position Y" ), isPolygon );
551
553 _HKI( "Filled" ), isSchematicItem );
554
556 _HKI( "Fill Color" ), isFillColorEditable );
557
558 void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode;
559 FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode;
560
561 propMgr.AddProperty( new PROPERTY_ENUM<SCH_SHAPE, FILL_T>( _HKI( "Fill Mode" ),
562 fillModeSetter, fillModeGetter ),
563 _HKI( "Shape Properties" ) )
564 .SetAvailableFunc( isSymbolItem );
565 }
567
int color
Definition: DXF_plotter.cpp:63
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:98
const KIID m_Uuid
Definition: eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:110
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:527
void SetStartX(int x)
Definition: eda_shape.h:191
VECTOR2I getCenter() const
Definition: eda_shape.cpp:930
int GetStartY() const
Definition: eda_shape.h:174
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Definition: eda_shape.cpp:795
const SHAPE_POLY_SET & GetHatching() const
Definition: eda_shape.h:148
FILL_T GetFillMode() const
Definition: eda_shape.h:142
void SetEndY(int aY)
Definition: eda_shape.h:226
void SetStartY(int y)
Definition: eda_shape.h:184
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:1150
bool operator==(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:2397
int GetRadius() const
Definition: eda_shape.cpp:1005
SHAPE_T GetShape() const
Definition: eda_shape.h:168
bool IsHatchedFill() const
Definition: eda_shape.h:124
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:1263
void SetEndX(int aX)
Definition: eda_shape.h:233
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition: eda_shape.cpp:858
VECTOR2I m_start
Definition: eda_shape.h:503
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:215
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:173
COLOR4D GetFillColor() const
Definition: eda_shape.h:152
void SwapShape(EDA_SHAPE *aImage)
Definition: eda_shape.cpp:2182
std::vector< VECTOR2I > m_bezierPoints
Definition: eda_shape.h:512
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:343
int GetStartX() const
Definition: eda_shape.h:175
double Similarity(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:2442
VECTOR2I m_end
Definition: eda_shape.h:504
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:1209
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:513
STROKE_PARAMS m_stroke
Definition: eda_shape.h:490
FILL_T m_fill
Definition: eda_shape.h:491
void SetFillMode(FILL_T aFill)
Definition: eda_shape.cpp:540
int Compare(const EDA_SHAPE *aOther) const
Definition: eda_shape.cpp:2207
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:975
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:703
static ENUM_MAP< T > & Instance()
Definition: property.h:697
wxPGChoices & Choices()
Definition: property.h:746
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:37
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Base plotter engine class.
Definition: plotter.h:121
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)=0
bool GetColorMode() const
Definition: plotter.h:149
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:150
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.
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.
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:88
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:356
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:661
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:693
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:252
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:246
@ EQUALITY
Definition: sch_item.h:674
virtual bool operator==(const SCH_ITEM &aOther) const
Definition: sch_item.cpp:541
bool IsPrivate() const
Definition: sch_item.h:254
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:314
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:565
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:626
SCH_LAYER_ID m_layer
Definition: sch_item.h:744
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:350
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.
Definition: sch_shape.cpp:105
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:326
void SetFilled(bool aFilled) override
Definition: sch_shape.cpp:67
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:78
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_shape.cpp:46
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:61
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_shape.cpp:52
void Normalize()
Definition: sch_shape.cpp:84
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_shape.cpp:430
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.
Definition: sch_shape.cpp:149
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:37
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.cpp:312
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_shape.cpp:111
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_shape.cpp:318
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:400
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:358
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_shape.cpp:123
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:117
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:419
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_shape.cpp:376
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.
Definition: sch_shape.cpp:138
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:57
VECTOR2I GetPosition() const override
Definition: sch_shape.h:84
int GetEffectiveWidth() const override
Definition: sch_shape.cpp:294
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_shape.cpp:448
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
virtual size_t GetPointCount() const override
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const std::vector< VECTOR2I > & CPoints() const
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
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.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Simple container to manage line stroke parameters.
Definition: stroke_params.h:94
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().
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _HKI(x)
#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:43
FILL_T
Definition: eda_shape.h:56
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:439
@ LAYER_SHAPES_BACKGROUND
Definition: layer_ids.h:473
@ LAYER_DEVICE
Definition: layer_ids.h:456
@ LAYER_PRIVATE_NOTES
Definition: layer_ids.h:458
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:474
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:484
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
Message panel definition file.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:400
#define TYPE_HASH(x)
Definition: property.h:72
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
Definition: property.h:799
#define REGISTER_TYPE(x)
Definition: property_mgr.h:351
static struct SCH_SHAPE_DESC _SCH_SHAPE_DESC
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
constexpr int MilsToIU(int mils) const
Definition: base_units.h:97
VECTOR2I center
VECTOR2I end
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695