KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_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-2023 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 <plotters/plotter.h>
27#include <macros.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 <lib_shape.h>
34#include "plotters/plotter.h"
35
36
37LIB_SHAPE::LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType,
38 KICAD_T aType ) :
39 LIB_ITEM( aType, aParent ),
40 EDA_SHAPE( aShape, aLineWidth, aFillType )
41{
42 m_editState = 0;
43}
44
45
46bool LIB_SHAPE::HitTest( const VECTOR2I& aPosRef, int aAccuracy ) const
47{
50
51 return hitTest( DefaultTransform.TransformCoordinate( aPosRef ), aAccuracy );
52}
53
54
55bool LIB_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
56{
58 return false;
59
60 return hitTest( DefaultTransform.TransformCoordinate( aRect ), aContained, aAccuracy );
61}
62
63
65{
66 return new LIB_SHAPE( *this );
67}
68
69
70int LIB_SHAPE::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
71{
72 int retv = LIB_ITEM::compare( aOther, aCompareFlags );
73
74 if( retv )
75 return retv;
76
77 return EDA_SHAPE::Compare( &static_cast<const LIB_SHAPE&>( aOther ) );
78}
79
80
81void LIB_SHAPE::Offset( const VECTOR2I& aOffset )
82{
83 move( aOffset );
84}
85
86
87void LIB_SHAPE::MoveTo( const VECTOR2I& aPosition )
88{
89 setPosition( aPosition );
90}
91
92
94{
95 if( GetShape() == SHAPE_T::RECTANGLE )
96 {
97 VECTOR2I size = GetEnd() - GetPosition();
98
99 if( size.y > 0 )
100 {
101 SetStartY( GetStartY() + size.y );
102 SetEndY( GetStartY() - size.y );
103 }
104
105 if( size.x < 0 )
106 {
107 SetStartX( GetStartX() + size.x );
108 SetEndX( GetStartX() - size.x );
109 }
110 }
111}
112
113
115{
116 flip( aCenter, true );
117}
118
119
121{
122 flip( aCenter, false );
123}
124
125
126void LIB_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
127{
128 EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90;
129
130 rotate( aCenter, rot_angle );
131}
132
133
134void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
135 const TRANSFORM& aTransform, bool aDimmed ) const
136{
137 if( IsPrivate() )
138 return;
139
140 VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset;
141 VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset;
142
143 static std::vector<VECTOR2I> cornerList;
144
145 if( GetShape() == SHAPE_T::POLY )
146 {
147 const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
148 cornerList.clear();
149
150 for( const VECTOR2I& pt : poly.CPoints() )
151 cornerList.push_back( aTransform.TransformCoordinate( pt ) + aOffset );
152 }
153 else if( GetShape() == SHAPE_T::BEZIER )
154 {
155 cornerList.clear();
156
157 for( const VECTOR2I& pt : m_bezierPoints )
158 cornerList.push_back( aTransform.TransformCoordinate( pt ) + aOffset );
159 }
160
161 int penWidth;
163 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
164 FILL_T fill = m_fill;
165
166 if( aBackground )
167 {
168 if( !aPlotter->GetColorMode() )
169 return;
170
171 switch( m_fill )
172 {
173 case FILL_T::FILLED_SHAPE:
174 return;
175
176 case FILL_T::FILLED_WITH_COLOR:
178 break;
179
180 case FILL_T::FILLED_WITH_BG_BODYCOLOR:
182 break;
183
184 default:
185 return;
186 }
187
188 penWidth = 0;
189 lineStyle = LINE_STYLE::SOLID;
190 }
191 else
192 {
193 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
195
196 if( lineStyle == LINE_STYLE::DEFAULT )
197 lineStyle = LINE_STYLE::SOLID;
198
199 if( m_fill == FILL_T::FILLED_SHAPE )
200 fill = m_fill;
201 else
202 fill = FILL_T::NO_FILL;
203
204 penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() );
205 }
206
207 COLOR4D bg = aPlotter->RenderSettings()->GetBackgroundColor();
208
209 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
210 bg = COLOR4D::WHITE;
211
212 if( aDimmed )
213 {
214 color.Desaturate( );
215 color = color.Mix( bg, 0.5f );
216 }
217
218 aPlotter->SetColor( color );
219 aPlotter->SetDash( penWidth, lineStyle );
220
221 switch( GetShape() )
222 {
223 case SHAPE_T::ARC:
224 {
225 VECTOR2I mid = aTransform.TransformCoordinate( GetArcMid() ) + aOffset;
226
227 aPlotter->Arc( start, mid, end, fill, penWidth );
228 break;
229 }
230
231 case SHAPE_T::CIRCLE:
232 {
233 VECTOR2I center = aTransform.TransformCoordinate( getCenter() ) + aOffset;
234
235 aPlotter->Circle( center, GetRadius() * 2, fill, penWidth );
236 break;
237 }
238
239 case SHAPE_T::RECTANGLE:
240 aPlotter->Rect( start, end, fill, penWidth );
241 break;
242
243 case SHAPE_T::POLY:
244 case SHAPE_T::BEZIER:
245 aPlotter->PlotPoly( cornerList, fill, penWidth );
246 break;
247
248 default:
250 }
251
252 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
253}
254
255
257{
258 return GetWidth();
259}
260
261
262void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
263 const TRANSFORM& aTransform, bool aDimmed )
264{
265 if( IsPrivate() )
266 return;
267
268 bool forceNoFill = static_cast<bool>( aData );
269 int penWidth = GetEffectivePenWidth( aSettings );
270
271 if( forceNoFill && IsFilled() && penWidth == 0 )
272 return;
273
274 wxDC* DC = aSettings->GetPrintDC();
275 VECTOR2I pt1 = aTransform.TransformCoordinate( m_start ) + aOffset;
276 VECTOR2I pt2 = aTransform.TransformCoordinate( m_end ) + aOffset;
277 VECTOR2I c;
279
280 if( color == COLOR4D::UNSPECIFIED )
281 color = aSettings->GetLayerColor( LAYER_DEVICE );
282
283 COLOR4D bg = aSettings->GetBackgroundColor();
284
285 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
286 bg = COLOR4D::WHITE;
287
288 if( aDimmed )
289 {
290 color.Desaturate( );
291 color = color.Mix( bg, 0.5f );
292 }
293
294 unsigned ptCount = 0;
295 VECTOR2I* buffer = nullptr;
296
297 if( GetShape() == SHAPE_T::POLY )
298 {
299 const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
300
301 ptCount = poly.GetPointCount();
302 buffer = new VECTOR2I[ptCount];
303
304 for( unsigned ii = 0; ii < ptCount; ++ii )
305 buffer[ii] = aTransform.TransformCoordinate( poly.CPoint( ii ) ) + aOffset;
306 }
307 else if( GetShape() == SHAPE_T::BEZIER )
308 {
309 ptCount = m_bezierPoints.size();
310 buffer = new VECTOR2I[ptCount];
311
312 for( size_t ii = 0; ii < ptCount; ++ii )
313 buffer[ii] = aTransform.TransformCoordinate( m_bezierPoints[ii] ) + aOffset;
314 }
315 else if( GetShape() == SHAPE_T::ARC )
316 {
317 c = aTransform.TransformCoordinate( getCenter() ) + aOffset;
318
319 EDA_ANGLE t1, t2;
320
321 CalcArcAngles( t1, t2 );
322
323 // N.B. The order of evaluation is critical here as MapAngles will modify t1, t2
324 // and the Normalize routine depends on these modifications for the correct output
325 bool transformed = aTransform.MapAngles( &t1, &t2 );
326 EDA_ANGLE arc_angle = ( t1 - t2 ).Normalize180();
327 bool transformed2 = ( arc_angle > ANGLE_0 ) && ( arc_angle < ANGLE_180 );
328
329 if( transformed == transformed2 )
330 std::swap( pt1, pt2 );
331 }
332
333 COLOR4D fillColor = COLOR4D::UNSPECIFIED;
334
335 if( !forceNoFill )
336 {
337 if( GetFillMode() == FILL_T::FILLED_SHAPE )
338 fillColor = color;
339 else if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
340 fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
341 else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
342 fillColor = GetFillColor();
343 }
344
345 if( fillColor != COLOR4D::UNSPECIFIED )
346 {
347 if( aDimmed )
348 {
349 fillColor.Desaturate( );
350 fillColor = fillColor.Mix( bg, 0.5f );
351 }
352
353 switch( GetShape() )
354 {
355 case SHAPE_T::ARC:
356 GRFilledArc( DC, pt1, pt2, c, 0, fillColor, fillColor );
357 break;
358
359 case SHAPE_T::CIRCLE:
360 GRFilledCircle( DC, pt1, GetRadius(), 0, fillColor, fillColor );
361 break;
362
363 case SHAPE_T::RECTANGLE:
364 GRFilledRect( DC, pt1, pt2, 0, fillColor, fillColor );
365 break;
366
367 case SHAPE_T::POLY:
368 GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
369 break;
370
371 case SHAPE_T::BEZIER:
372 GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
373 break;
374
375 default:
377 }
378 }
379 else
380 {
381 penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
382 }
383
384 if( penWidth > 0 )
385 {
386 if( GetEffectiveLineStyle() == LINE_STYLE::SOLID )
387 {
388 switch( GetShape() )
389 {
390 case SHAPE_T::ARC:
391 GRArc( DC, pt1, pt2, c, penWidth, color );
392 break;
393
394 case SHAPE_T::CIRCLE:
395 GRCircle( DC, pt1, GetRadius(), penWidth, color );
396 break;
397
398 case SHAPE_T::RECTANGLE:
399 GRRect( DC, pt1, pt2, penWidth, color );
400 break;
401
402 case SHAPE_T::POLY:
403 GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
404 break;
405
406 case SHAPE_T::BEZIER:
407 GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
408 break;
409
410 default:
412 }
413 }
414 else
415 {
416 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
417
418 for( SHAPE* shape : shapes )
419 {
420 STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
421 [&]( const VECTOR2I& a, const VECTOR2I& b )
422 {
423 VECTOR2I pts = aTransform.TransformCoordinate( a ) + aOffset;
424 VECTOR2I pte = aTransform.TransformCoordinate( b ) + aOffset;
425 GRLine( DC, pts.x, pts.y, pte.x, pte.y, penWidth, color );
426 } );
427 }
428
429 for( SHAPE* shape : shapes )
430 delete shape;
431 }
432 }
433
434 delete[] buffer;
435}
436
437
439{
440 BOX2I bbox = getBoundingBox();
441
442 bbox.RevertYAxis();
443
444 return bbox;
445}
446
447
448void LIB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
449{
450 LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
451
452 ShapeGetMsgPanelInfo( aFrame, aList );
453}
454
455
456wxString LIB_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
457{
458 switch( GetShape() )
459 {
460 case SHAPE_T::ARC:
461 return wxString::Format( _( "Arc with radius %s" ),
462 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
463
464 case SHAPE_T::CIRCLE:
465 return wxString::Format( _( "Circle with radius %s" ),
466 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
467
468 case SHAPE_T::RECTANGLE:
469 return wxString::Format( _( "Rectangle with width %s height %s" ),
470 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
471 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
472
473 case SHAPE_T::POLY:
474 return wxString::Format( _( "Polyline with %d points" ),
475 int( m_poly.Outline( 0 ).GetPointCount() ) );
476
477 case SHAPE_T::BEZIER:
478 return wxString::Format( _( "Bezier Curve with %d points" ),
479 int( m_bezierPoints.size() ) );
480
481 default:
483 return wxEmptyString;
484 }
485}
486
487
489{
490 switch( GetShape() )
491 {
492 case SHAPE_T::SEGMENT: return BITMAPS::add_line;
493 case SHAPE_T::ARC: return BITMAPS::add_arc;
494 case SHAPE_T::CIRCLE: return BITMAPS::add_circle;
495 case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle;
496 case SHAPE_T::POLY: return BITMAPS::add_graphical_segments;
497 case SHAPE_T::BEZIER: return BITMAPS::add_bezier;
498
499 default:
501 return BITMAPS::question_mark;
502 }
503}
504
505
506void LIB_SHAPE::AddPoint( const VECTOR2I& aPosition )
507{
508 if( GetShape() == SHAPE_T::POLY )
509 {
510 if( m_poly.IsEmpty() )
512
513 m_poly.Outline( 0 ).Append( aPosition, true );
514 }
515 else
516 {
518 }
519}
520
521
522bool LIB_SHAPE::operator==( const LIB_ITEM& aOther ) const
523{
524 if( aOther.Type() != Type() )
525 return false;
526
527 const LIB_SHAPE& other = static_cast<const LIB_SHAPE&>( aOther );
528
529 return LIB_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
530}
531
532
533double LIB_SHAPE::Similarity( const LIB_ITEM& aOther ) const
534{
535 if( m_Uuid == aOther.m_Uuid )
536 return 1.0;
537
538 if( aOther.Type() != Type() )
539 return 0.0;
540
541 const LIB_SHAPE& other = static_cast<const LIB_SHAPE&>( aOther );
542
543 double similarity = SimilarityBase( other );
544
545 similarity *= EDA_SHAPE::Similarity( other );
546
547 return similarity;
548}
549
550
551void LIB_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const
552{
553 aCount = 3;
554 aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : LAYER_DEVICE;
556 aLayers[2] = LAYER_SELECTION_SHADOWS;
557}
558
559
560static struct LIB_SHAPE_DESC
561{
563 {
570
571 // Only polygons have meaningful Position properties.
572 // On other shapes, these are duplicates of the Start properties.
573 auto isPolygon =
574 []( INSPECTABLE* aItem ) -> bool
575 {
576 if( LIB_SHAPE* shape = dynamic_cast<LIB_SHAPE*>( aItem ) )
577 return shape->GetShape() == SHAPE_T::POLY;
578
579 return false;
580 };
581
583 _HKI( "Position X" ), isPolygon );
585 _HKI( "Position Y" ), isPolygon );
586
587 propMgr.Mask( TYPE_HASH( LIB_SHAPE ), TYPE_HASH( EDA_SHAPE ), _HKI( "Filled" ) );
588
590
591 if( fillEnum.Choices().GetCount() == 0 )
592 {
593 fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) )
594 .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) )
595 .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) )
596 .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) );
597 }
598
599 void ( LIB_SHAPE::*fillModeSetter )( FILL_T ) = &LIB_SHAPE::SetFillMode;
600 FILL_T ( LIB_SHAPE::*fillModeGetter )() const = &LIB_SHAPE::GetFillMode;
601
602 propMgr.AddProperty( new PROPERTY_ENUM< LIB_SHAPE, FILL_T>( _HKI( "Fill" ),
603 fillModeSetter, fillModeGetter ) );
604 }
606
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
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: box2.h:690
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
const KIID m_Uuid
Definition: eda_item.h:482
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:487
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
int m_editState
Definition: eda_shape.h:417
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
bool IsFilled() const
Definition: eda_shape.h:90
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:570
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
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:837
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
COLOR4D GetFillColor() const
Definition: eda_shape.h:105
std::vector< VECTOR2I > m_bezierPoints
Definition: eda_shape.h:414
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:103
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
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:783
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:415
virtual int GetWidth() const
Definition: eda_shape.h:109
FILL_T m_fill
Definition: eda_shape.h:396
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:100
int Compare(const EDA_SHAPE *aOther) const
Definition: eda_shape.cpp:1629
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:556
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:659
static ENUM_MAP< T > & Instance()
Definition: property.h:653
wxPGChoices & Choices()
Definition: property.h:702
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
COLOR4D & Desaturate()
Removes color (in HSL model)
Definition: color4d.cpp:511
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:295
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
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
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
bool IsPrivate() const
Definition: lib_item.h:349
virtual bool operator==(const LIB_ITEM &aOther) const
Test LIB_ITEM objects for equivalence.
Definition: lib_item.cpp:113
virtual int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_item.cpp:88
virtual int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const
Definition: lib_item.h:196
double SimilarityBase(const LIB_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
Definition: lib_item.h:227
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_item.cpp:68
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: lib_shape.cpp:46
STROKE_PARAMS GetStroke() const
Definition: lib_shape.h:57
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the item to aDC.
Definition: lib_shape.cpp:262
bool operator==(const LIB_ITEM &aOther) const override
Test LIB_ITEM objects for equivalence.
Definition: lib_shape.cpp:522
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_shape.cpp:448
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_shape.cpp:114
LINE_STYLE GetEffectiveLineStyle() const
Definition: lib_shape.h:65
void AddPoint(const VECTOR2I &aPosition)
Definition: lib_shape.cpp:506
double Similarity(const LIB_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: lib_shape.cpp:533
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_shape.cpp:120
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_shape.cpp:81
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Definition: lib_shape.cpp:134
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_shape.cpp:64
int GetPenWidth() const override
Definition: lib_shape.cpp:256
const BOX2I GetBoundingBox() const override
Definition: lib_shape.cpp:438
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_shape.cpp:126
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_shape.cpp:70
LIB_SHAPE(LIB_SYMBOL *aParent, SHAPE_T aShape, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=LIB_SHAPE_T)
Definition: lib_shape.cpp:37
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: lib_shape.cpp:456
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_shape.cpp:87
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_shape.cpp:488
void Normalize()
Definition: lib_shape.cpp:93
VECTOR2I GetPosition() const override
Definition: lib_shape.h:90
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the LIB_SHAPE.
Definition: lib_shape.h:101
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: lib_shape.cpp:551
Define a library symbol object.
Definition: lib_symbol.h:99
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 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.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
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 AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
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
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)
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:94
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:97
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
bool MapAngles(EDA_ANGLE *aAngle1, EDA_ANGLE *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:81
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:44
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:435
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:437
static constexpr EDA_ANGLE ANGLE_180
Definition: eda_angle.h:439
#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:42
FILL_T
Definition: eda_shape.h:54
TRANSFORM DefaultTransform
Definition: transform.cpp:32
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_DEVICE
Definition: layer_ids.h:368
@ LAYER_PRIVATE_NOTES
Definition: layer_ids.h:370
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:384
@ LAYER_NOTES_BACKGROUND
Definition: layer_ids.h:371
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:393
#define MINIMUM_SELECTION_DISTANCE
Definition: lib_item.h:53
static struct LIB_SHAPE_DESC _LIB_SHAPE_DESC
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 ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
Definition: property.h:755
#define REGISTER_TYPE(x)
Definition: property_mgr.h:366
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
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