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 (C) 2004-2022 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 <general.h>
33#include <schematic.h>
34#include <sch_shape.h>
35#include "plotters/plotter.h"
36
37
38SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, int aLineWidth, FILL_T aFillType, KICAD_T aType ) :
39 SCH_ITEM( nullptr, aType ),
40 EDA_SHAPE( aShape, aLineWidth, aFillType )
41{
43}
44
45
47{
48 return new SCH_SHAPE( *this );
49}
50
51
53{
54 SCH_ITEM::SwapFlags( aItem );
55
56 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( aItem );
57
58 EDA_SHAPE::SwapShape( shape );
59 std::swap( m_layer, shape->m_layer );
60}
61
62
63void SCH_SHAPE::SetStroke( const STROKE_PARAMS& aStroke )
64{
65 m_stroke = aStroke;
66}
67
68
69void SCH_SHAPE::Move( const VECTOR2I& aOffset )
70{
71 move( aOffset );
72}
73
74
76{
77 if( GetShape() == SHAPE_T::RECTANGLE )
78 {
79 VECTOR2I size = GetEnd() - GetPosition();
80
81 if( size.y < 0 )
82 {
83 SetStartY( GetStartY() + size.y );
84 SetEndY( GetStartY() - size.y );
85 }
86
87 if( size.x < 0 )
88 {
89 SetStartX( GetStartX() + size.x );
90 SetEndX( GetStartX() - size.x );
91 }
92 }
93}
94
95
97{
98 flip( VECTOR2I( aCenter, 0 ), true );
99}
100
101
103{
104 flip( VECTOR2I( 0, aCenter ), false );
105}
106
107
108void SCH_SHAPE::Rotate( const VECTOR2I& aCenter )
109{
110 rotate( aCenter, ANGLE_90 );
111}
112
113
114void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground,
115 const SCH_PLOT_SETTINGS& aPlotSettings ) const
116{
117 int pen_size = GetPenWidth();
118
119 if( pen_size > 0 )
120 pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() );
121
122 static std::vector<VECTOR2I> cornerList;
123
124 if( GetShape() == SHAPE_T::POLY )
125 {
126 cornerList.clear();
127
128 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
129 cornerList.push_back( pt );
130 }
131
132 if( aBackground )
133 {
134 if( !aPlotter->GetColorMode() )
135 return;
136
137 if( IsFilled() )
138 {
139 if( GetFillColor() != COLOR4D::UNSPECIFIED )
140 aPlotter->SetColor( GetFillColor() );
141 else
142 aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOTES ) );
143
144 switch( GetShape() )
145 {
146 case SHAPE_T::ARC:
147 aPlotter->Arc( GetStart(), GetArcMid(), GetEnd(), m_fill, 0 );
148 break;
149
150 case SHAPE_T::CIRCLE:
151 aPlotter->Circle( getCenter(), GetRadius() * 2, m_fill, 0 );
152 break;
153
154 case SHAPE_T::RECTANGLE:
155 aPlotter->Rect( GetStart(), GetEnd(), m_fill, 0 );
156 break;
157
158 case SHAPE_T::POLY:
159 aPlotter->PlotPoly( cornerList, m_fill, 0 );
160 break;
161
162 case SHAPE_T::BEZIER:
163 aPlotter->PlotPoly( m_bezierPoints, m_fill, 0 );
164 break;
165
166 default:
168 }
169 }
170 }
171 else /* if( aForeground ) */
172 {
173 if( aPlotter->GetColorMode() && GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
174 aPlotter->SetColor( GetStroke().GetColor() );
175 else
176 aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOTES ) );
177
178 aPlotter->SetCurrentLineWidth( pen_size );
179 aPlotter->SetDash( pen_size, GetEffectiveLineStyle() );
180
181 switch( GetShape() )
182 {
183 case SHAPE_T::ARC:
184 aPlotter->Arc( GetStart(), GetArcMid(), GetEnd(), FILL_T::NO_FILL, pen_size );
185 break;
186
187 case SHAPE_T::CIRCLE:
188 aPlotter->Circle( getCenter(), GetRadius() * 2, FILL_T::NO_FILL, pen_size );
189 break;
190
191 case SHAPE_T::RECTANGLE:
192 aPlotter->Rect( GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size );
193 break;
194
195 case SHAPE_T::POLY:
196 aPlotter->PlotPoly( cornerList, FILL_T::NO_FILL, pen_size );
197 break;
198
199 case SHAPE_T::BEZIER:
200 aPlotter->PlotPoly( m_bezierPoints, FILL_T::NO_FILL, pen_size );
201 break;
202
203 default:
205 }
206
207 aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
208 }
209}
210
211
213{
214 if( m_stroke.GetWidth() > 0 )
215 return m_stroke.GetWidth();
216
217 // Historically 0 meant "default width" and negative numbers meant "don't stroke".
218 if( GetWidth() < 0 )
219 return 0;
220
221 SCHEMATIC* schematic = Schematic();
222
223 if( schematic )
224 return schematic->Settings().m_DefaultLineWidth;
225
227}
228
229
230void SCH_SHAPE::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
231{
232 wxDC* DC = aSettings->GetPrintDC();
234
235 unsigned ptCount = 0;
236 VECTOR2I* buffer = nullptr;
237
238 if( GetShape() == SHAPE_T::POLY )
239 {
240 SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 );
241
242 ptCount = poly.GetPointCount();
243 buffer = new VECTOR2I[ptCount];
244
245 for( unsigned ii = 0; ii < ptCount; ++ii )
246 buffer[ii] = poly.CPoint( ii );
247 }
248 else if( GetShape() == SHAPE_T::BEZIER )
249 {
250 ptCount = m_bezierPoints.size();
251 buffer = new VECTOR2I[ptCount];
252
253 for( size_t ii = 0; ii < ptCount; ++ii )
254 buffer[ii] = m_bezierPoints[ii];
255 }
256
257 if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
258 {
259 if( GetFillColor() == COLOR4D::UNSPECIFIED )
260 color = aSettings->GetLayerColor( LAYER_NOTES );
261 else
263
264 switch( GetShape() )
265 {
266 case SHAPE_T::ARC:
267 GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, color, color );
268 break;
269
270 case SHAPE_T::CIRCLE:
272 break;
273
274 case SHAPE_T::RECTANGLE:
275 GRFilledRect( DC, GetStart(), GetEnd(), 0, color, color );
276 break;
277
278 case SHAPE_T::POLY:
279 GRPoly( DC, ptCount, buffer, true, 0, color, color );
280 break;
281
282 case SHAPE_T::BEZIER:
283 GRPoly( DC, ptCount, buffer, true, 0, color, color );
284 break;
285
286 default:
288 }
289 }
290
291 delete[] buffer;
292
293}
294
295
296void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
297{
298 int penWidth = GetPenWidth();
299 wxDC* DC = aSettings->GetPrintDC();
301
302 if( color == COLOR4D::UNSPECIFIED )
303 color = aSettings->GetLayerColor( LAYER_NOTES );
304
305 COLOR4D bg = aSettings->GetBackgroundColor();
306
307 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
308 bg = COLOR4D::WHITE;
309
310 unsigned ptCount = 0;
311 VECTOR2I* buffer = nullptr;
312
313 if( GetShape() == SHAPE_T::POLY )
314 {
315 SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 );
316
317 ptCount = poly.GetPointCount();
318 buffer = new VECTOR2I[ptCount];
319
320 for( unsigned ii = 0; ii < ptCount; ++ii )
321 buffer[ii] = poly.CPoint( ii );
322 }
323 else if( GetShape() == SHAPE_T::BEZIER )
324 {
325 ptCount = m_bezierPoints.size();
326 buffer = new VECTOR2I[ptCount];
327
328 for( size_t ii = 0; ii < ptCount; ++ii )
329 buffer[ii] = m_bezierPoints[ii];
330 }
331
332 COLOR4D fillColor = COLOR4D::UNSPECIFIED;
333
334 if( GetFillMode() == FILL_T::FILLED_SHAPE )
335 fillColor = color;
336 else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
337 fillColor = GetFillColor();
338
339 if( fillColor != COLOR4D::UNSPECIFIED )
340 {
341 switch( GetShape() )
342 {
343 case SHAPE_T::ARC:
344 GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, fillColor, fillColor );
345 break;
346
347 case SHAPE_T::CIRCLE:
348 GRFilledCircle( DC, GetStart(), GetRadius(), 0, fillColor, fillColor );
349 break;
350
351 case SHAPE_T::RECTANGLE:
352 GRFilledRect( DC, GetStart(), GetEnd(), 0, fillColor, fillColor );
353 break;
354
355 case SHAPE_T::POLY:
356 GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
357 break;
358
359 case SHAPE_T::BEZIER:
360 GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
361 break;
362
363 default:
365 }
366 }
367 else
368 {
369 penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
370 }
371
372 if( penWidth > 0 )
373 {
374 if( GetEffectiveLineStyle() == LINE_STYLE::SOLID )
375 {
376 switch( GetShape() )
377 {
378 case SHAPE_T::ARC:
379 GRArc( DC, GetEnd(), GetStart(), getCenter(), penWidth, color );
380 break;
381
382 case SHAPE_T::CIRCLE:
383 GRCircle( DC, GetStart(), GetRadius(), penWidth, color );
384 break;
385
386 case SHAPE_T::RECTANGLE:
387 GRRect( DC, GetStart(), GetEnd(), penWidth, color );
388 break;
389
390 case SHAPE_T::POLY:
391 GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
392 break;
393
394 case SHAPE_T::BEZIER:
395 GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
396 break;
397
398 default:
400 }
401 }
402 else
403 {
404 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
405
406 for( SHAPE* shape : shapes )
407 {
408 STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
409 [&]( const VECTOR2I& a, const VECTOR2I& b )
410 {
411 GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
412 } );
413 }
414
415 for( SHAPE* shape : shapes )
416 delete shape;
417 }
418 }
419
420 delete[] buffer;
421}
422
423
424void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
425{
426 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
427
428 ShapeGetMsgPanelInfo( aFrame, aList );
429}
430
431
432wxString SCH_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
433{
434 switch( GetShape() )
435 {
436 case SHAPE_T::ARC:
437 return wxString::Format( _( "Arc, radius %s" ),
438 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
439
440 case SHAPE_T::CIRCLE:
441 return wxString::Format( _( "Circle, radius %s" ),
442 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
443
444 case SHAPE_T::RECTANGLE:
445 return wxString::Format( _( "Rectangle, width %s height %s" ),
446 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
447 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
448
449 case SHAPE_T::POLY:
450 return wxString::Format( _( "Polyline, %d points" ),
451 int( m_poly.Outline( 0 ).GetPointCount() ) );
452
453 case SHAPE_T::BEZIER:
454 return wxString::Format( _( "Bezier Curve, %d points" ),
455 int( m_bezierPoints.size() ) );
456
457 default:
459 return wxEmptyString;
460 }
461}
462
463
465{
466 switch( GetShape() )
467 {
468 case SHAPE_T::SEGMENT: return BITMAPS::add_line;
469 case SHAPE_T::ARC: return BITMAPS::add_arc;
470 case SHAPE_T::CIRCLE: return BITMAPS::add_circle;
471 case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle;
472 case SHAPE_T::POLY: return BITMAPS::add_graphical_segments;
473 case SHAPE_T::BEZIER: return BITMAPS::add_bezier;
474
475 default:
477 return BITMAPS::question_mark;
478 }
479}
480
481
482void SCH_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const
483{
484 aCount = 3;
485 aLayers[0] = LAYER_NOTES;
486 aLayers[1] = LAYER_NOTES_BACKGROUND;
487 aLayers[2] = LAYER_SELECTION_SHADOWS;
488}
489
490
491void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
492{
493 if( GetShape() == SHAPE_T::POLY )
494 {
495 if( m_poly.IsEmpty() )
497
498 m_poly.Outline( 0 ).Append( aPosition, true );
499 }
500 else
501 {
503 }
504}
505
506
507bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
508{
509 if( aOther.Type() != Type() )
510 return false;
511
512 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
513
514 return EDA_SHAPE::operator==( other );
515}
516
517
518double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
519{
520 if( aOther.Type() != Type() )
521 return 0.0;
522
523 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
524
525 double similarity = EDA_SHAPE::Similarity( other );
526
527 return similarity;
528}
529
530
531static struct SCH_SHAPE_DESC
532{
534 {
541
542 // Only polygons have meaningful Position properties.
543 // On other shapes, these are duplicates of the Start properties.
544 auto isPolygon =
545 []( INSPECTABLE* aItem ) -> bool
546 {
547 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
548 return shape->GetShape() == SHAPE_T::POLY;
549
550 return false;
551 };
552
554 _HKI( "Position X" ), isPolygon );
556 _HKI( "Position Y" ), isPolygon );
557 }
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: eda_item.h:199
void SetStartX(int x)
Definition: eda_shape.h:142
VECTOR2I getCenter() const
Definition: eda_shape.cpp:512
int GetStartY() const
Definition: eda_shape.h:127
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
FILL_T GetFillMode() const
Definition: eda_shape.h:101
void SetEndY(int aY)
Definition: eda_shape.h:161
void SetStartY(int y)
Definition: eda_shape.h:136
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:305
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:1804
int GetRadius() const
Definition: eda_shape.cpp:586
SHAPE_T GetShape() const
Definition: eda_shape.h:119
void SetEndX(int aX)
Definition: eda_shape.h:167
VECTOR2I m_start
Definition: eda_shape.h:405
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:151
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:126
COLOR4D GetFillColor() const
Definition: eda_shape.h:105
void SwapShape(EDA_SHAPE *aImage)
Definition: eda_shape.cpp:1606
std::vector< VECTOR2I > m_bezierPoints
Definition: eda_shape.h:414
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:87
int GetStartX() const
Definition: eda_shape.h:128
double Similarity(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:1849
VECTOR2I m_end
Definition: eda_shape.h:406
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:415
virtual int GetWidth() const
Definition: eda_shape.h:109
STROKE_PARAMS m_stroke
Definition: eda_shape.h:395
FILL_T m_fill
Definition: eda_shape.h:396
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:556
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:36
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
wxDC * GetPrintDC() const
Base plotter engine class.
Definition: plotter.h:104
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void Arc(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH)
Definition: plotter.cpp:149
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:135
bool GetColorMode() const
Definition: plotter.h:132
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=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColor(const COLOR4D &color)=0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
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 AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Definition: schematic.h:75
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:279
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:267
SCH_LAYER_ID m_layer
Definition: sch_item.h:538
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:432
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_shape.cpp:482
SCH_SHAPE(SHAPE_T aShape, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
Definition: sch_shape.cpp:38
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_shape.cpp:96
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:69
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_SETTINGS &aPlotSettings) const override
Plot the schematic item to aPlotter.
Definition: sch_shape.cpp:114
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:63
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_shape.h:67
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:75
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:518
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_shape.cpp:102
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:424
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:108
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:491
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:464
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:507
void PrintBackground(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print the (optional) backaground elements if they exist.
Definition: sch_shape.cpp:230
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_shape.cpp:296
int GetPenWidth() const override
Definition: sch_shape.cpp:212
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:64
VECTOR2I GetPosition() const override
Definition: sch_shape.h:77
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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 VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in 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.
An abstract shape on 2D plane.
Definition: shape.h:126
Simple container to manage line stroke parameters.
Definition: stroke_params.h:81
int GetWidth() const
Definition: stroke_params.h:91
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:97
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:437
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:54
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:396
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:357
void GRFilledArc(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:387
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:171
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:403
void GRArc(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:378
void GRPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
Definition: gr_basic.cpp:341
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
void GRFilledCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aStrokeColor, const COLOR4D &aFillColor)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
Definition: gr_basic.cpp:369
@ LAYER_NOTES
Definition: layer_ids.h:369
@ LAYER_NOTES_BACKGROUND
Definition: layer_ids.h:371
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:393
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:424
#define TYPE_HASH(x)
Definition: property.h:67
#define REGISTER_TYPE(x)
Definition: property_mgr.h:366
static struct SCH_SHAPE_DESC _SCH_SHAPE_DESC
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588