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-2024 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_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 ), FLIP_DIRECTION::LEFT_RIGHT );
99}
100
101
103{
104 flip( VECTOR2I( 0, aCenter ), FLIP_DIRECTION::TOP_BOTTOM );
105}
106
107
108void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
109{
110 rotate( aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
111}
112
113
114bool SCH_SHAPE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
115{
116 return hitTest( aPosition, aAccuracy );
117}
118
119
120bool SCH_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
121{
123 return false;
124
125 return hitTest( aRect, aContained, aAccuracy );
126}
127
128
129void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
130 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
131{
132 if( IsPrivate() )
133 return;
134
135 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
136 int pen_size = GetEffectivePenWidth( renderSettings );
137
138 static std::vector<VECTOR2I> ptList;
139
140 if( GetShape() == SHAPE_T::POLY )
141 {
142 ptList.clear();
143
144 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
145 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
146 }
147 else if( GetShape() == SHAPE_T::BEZIER )
148 {
149 ptList.clear();
150
151 for( const VECTOR2I& pt : m_bezierPoints )
152 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
153 }
154
156 COLOR4D bg = renderSettings->GetBackgroundColor();
157 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
158 FILL_T fill = m_fill;
159
160 if( aBackground )
161 {
162 if( !aPlotter->GetColorMode() )
163 return;
164
165 switch( m_fill )
166 {
167 case FILL_T::FILLED_SHAPE:
168 return;
169
170 case FILL_T::FILLED_WITH_COLOR:
172 break;
173
174 case FILL_T::FILLED_WITH_BG_BODYCOLOR:
175 color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
176 break;
177
178 default:
179 return;
180 }
181
182 pen_size = 0;
183 lineStyle = LINE_STYLE::SOLID;
184 }
185 else /* if( aForeground ) */
186 {
187 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
188 color = renderSettings->GetLayerColor( m_layer );
189
190 if( lineStyle == LINE_STYLE::DEFAULT )
191 lineStyle = LINE_STYLE::SOLID;
192
193 if( m_fill == FILL_T::FILLED_SHAPE )
194 fill = m_fill;
195 else
196 fill = FILL_T::NO_FILL;
197
198 pen_size = GetEffectivePenWidth( renderSettings );
199 }
200
201 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
202 bg = COLOR4D::WHITE;
203
204 if( aDimmed )
205 {
206 color.Desaturate( );
207 color = color.Mix( bg, 0.5f );
208 }
209
210 aPlotter->SetColor( color );
211 aPlotter->SetCurrentLineWidth( pen_size );
212 aPlotter->SetDash( pen_size, lineStyle );
213
214 VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
215 VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
216 VECTOR2I mid, center;
217
218 switch( GetShape() )
219 {
220 case SHAPE_T::ARC:
221 mid = renderSettings->TransformCoordinate( GetArcMid() ) + aOffset;
222 aPlotter->Arc( start, mid, end, fill, pen_size );
223 break;
224
225 case SHAPE_T::CIRCLE:
226 center = renderSettings->TransformCoordinate( getCenter() ) + aOffset;
227 aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
228 break;
229
230 case SHAPE_T::RECTANGLE:
231 aPlotter->Rect( start, end, fill, pen_size );
232 break;
233
234 case SHAPE_T::POLY:
235 case SHAPE_T::BEZIER:
236 aPlotter->PlotPoly( ptList, fill, pen_size );
237 break;
238
239 default:
241 }
242
243 aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
244}
245
246
248{
249 if( GetPenWidth() > 0 )
250 return GetPenWidth();
251
252 // Historically 0 meant "default width" and negative numbers meant "don't stroke".
253 if( GetPenWidth() < 0 )
254 return 0;
255
256 SCHEMATIC* schematic = Schematic();
257
258 if( schematic )
259 return schematic->Settings().m_DefaultLineWidth;
260
262}
263
264
266{
267 return getBoundingBox();
268}
269
270
271void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
272 const VECTOR2I& aOffset, bool aDimmed )
273{
274 if( IsPrivate() )
275 return;
276
277 wxDC* DC = aSettings->GetPrintDC();
279
280 static std::vector<VECTOR2I> ptList;
281
282 if( GetShape() == SHAPE_T::POLY )
283 {
284 ptList.clear();
285
286 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
287 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
288 }
289 else if( GetShape() == SHAPE_T::BEZIER )
290 {
291 ptList.clear();
292
293 for( const VECTOR2I& pt : m_bezierPoints )
294 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
295 }
296
297 if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
298 {
299 if( GetFillColor() == COLOR4D::UNSPECIFIED )
300 color = aSettings->GetLayerColor( LAYER_NOTES );
301 else
303
304 switch( GetShape() )
305 {
306 case SHAPE_T::ARC:
307 GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, color, color );
308 break;
309
310 case SHAPE_T::CIRCLE:
312 break;
313
314 case SHAPE_T::RECTANGLE:
315 GRFilledRect( DC, GetStart(), GetEnd(), 0, color, color );
316 break;
317
318 case SHAPE_T::POLY:
319 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
320 break;
321
322 case SHAPE_T::BEZIER:
323 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
324 break;
325
326 default:
328 }
329 }
330}
331
332
333void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
334 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
335{
336 if( IsPrivate() )
337 return;
338
339 int penWidth = GetEffectivePenWidth( aSettings );
340 wxDC* DC = aSettings->GetPrintDC();
342 COLOR4D bg = aSettings->GetBackgroundColor();
343
344 if( color == COLOR4D::UNSPECIFIED )
345 color = aSettings->GetLayerColor( LAYER_NOTES );
346
347 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
348 bg = COLOR4D::WHITE;
349
350 if( aDimmed )
351 {
352 color.Desaturate( );
353 color = color.Mix( bg, 0.5f );
354 }
355
356 static std::vector<VECTOR2I> ptList;
357
358 if( GetShape() == SHAPE_T::POLY )
359 {
360 ptList.clear();
361
362 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
363 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
364 }
365 else if( GetShape() == SHAPE_T::BEZIER )
366 {
367 ptList.clear();
368
369 for( const VECTOR2I& pt : m_bezierPoints )
370 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
371 }
372
373 VECTOR2I start = GetStart();
374 VECTOR2I end = GetEnd();
375 VECTOR2I center = ( GetShape() == SHAPE_T::ARC ) ? getCenter() : VECTOR2I( 0, 0 );
376
377 if( aSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
378 {
379 start = aSettings->TransformCoordinate( start ) + aOffset;
380 end = aSettings->TransformCoordinate( end ) + aOffset;
381
382 if( GetShape() == SHAPE_T::ARC )
383 {
384 center = aSettings->TransformCoordinate( center ) + aOffset;
385
386 EDA_ANGLE t1, t2;
387
388 CalcArcAngles( t1, t2 );
389
390 // N.B. The order of evaluation is critical here as MapAngles will modify t1, t2
391 // and the Normalize routine depends on these modifications for the correct output
392 bool transformed = aSettings->m_Transform.MapAngles( &t1, &t2 );
393 EDA_ANGLE arc_angle = ( t1 - t2 ).Normalize180();
394 bool transformed2 = ( arc_angle > ANGLE_0 ) && ( arc_angle < ANGLE_180 );
395
396 if( transformed != transformed2 )
397 std::swap( start, end );
398 }
399 }
400
401 COLOR4D fillColor = COLOR4D::UNSPECIFIED;
402
403 if( GetFillMode() == FILL_T::FILLED_SHAPE )
404 fillColor = color;
405 else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
406 fillColor = GetFillColor();
407 else if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
408 fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
409
410 if( fillColor != COLOR4D::UNSPECIFIED && !aForceNoFill )
411 {
412 if( aDimmed )
413 {
414 fillColor.Desaturate( );
415 fillColor = fillColor.Mix( bg, 0.5f );
416 }
417
418 switch( GetShape() )
419 {
420 case SHAPE_T::ARC:
421 GRFilledArc( DC, end, start, center, 0, fillColor, fillColor );
422 break;
423
424 case SHAPE_T::CIRCLE:
425 GRFilledCircle( DC, start, GetRadius(), 0, fillColor, fillColor );
426 break;
427
428 case SHAPE_T::RECTANGLE:
429 GRFilledRect( DC, start, end, 0, fillColor, fillColor );
430 break;
431
432 case SHAPE_T::POLY:
433 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
434 break;
435
436 case SHAPE_T::BEZIER:
437 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
438 break;
439
440 default:
442 }
443 }
444
445 penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
446
447 if( penWidth > 0 )
448 {
449 if( GetEffectiveLineStyle() == LINE_STYLE::SOLID )
450 {
451 switch( GetShape() )
452 {
453 case SHAPE_T::ARC:
454 GRArc( DC, end, start, center, penWidth, color );
455 break;
456
457 case SHAPE_T::CIRCLE:
458 GRCircle( DC, start, GetRadius(), penWidth, color );
459 break;
460
461 case SHAPE_T::RECTANGLE:
462 GRRect( DC, start, end, penWidth, color );
463 break;
464
465 case SHAPE_T::POLY:
466 GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
467 break;
468
469 case SHAPE_T::BEZIER:
470 GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
471 break;
472
473 default:
475 }
476 }
477 else
478 {
479 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
480
481 for( SHAPE* shape : shapes )
482 {
483 STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
484 [&]( const VECTOR2I& a, const VECTOR2I& b )
485 {
486 VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
487 VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
488 GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
489 } );
490 }
491
492 for( SHAPE* shape : shapes )
493 delete shape;
494 }
495 }
496}
497
498
499void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
500{
501 if( m_layer == LAYER_DEVICE )
502 getSymbolEditorMsgPanelInfo( aFrame, aList );
503 else
504 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
505
506 ShapeGetMsgPanelInfo( aFrame, aList );
507}
508
509
510wxString SCH_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
511{
512 switch( GetShape() )
513 {
514 case SHAPE_T::ARC:
515 return wxString::Format( _( "Arc, radius %s" ),
516 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
517
518 case SHAPE_T::CIRCLE:
519 return wxString::Format( _( "Circle, radius %s" ),
520 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
521
522 case SHAPE_T::RECTANGLE:
523 return wxString::Format( _( "Rectangle, width %s height %s" ),
524 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
525 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
526
527 case SHAPE_T::POLY:
528 return wxString::Format( _( "Polyline, %d points" ),
529 int( m_poly.Outline( 0 ).GetPointCount() ) );
530
531 case SHAPE_T::BEZIER:
532 return wxString::Format( _( "Bezier Curve, %d points" ),
533 int( m_bezierPoints.size() ) );
534
535 default:
537 return wxEmptyString;
538 }
539}
540
541
543{
544 switch( GetShape() )
545 {
546 case SHAPE_T::SEGMENT: return BITMAPS::add_line;
547 case SHAPE_T::ARC: return BITMAPS::add_arc;
548 case SHAPE_T::CIRCLE: return BITMAPS::add_circle;
549 case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle;
550 case SHAPE_T::POLY: return BITMAPS::add_graphical_segments;
551 case SHAPE_T::BEZIER: return BITMAPS::add_bezier;
552
553 default:
555 return BITMAPS::question_mark;
556 }
557}
558
559
560std::vector<int> SCH_SHAPE::ViewGetLayers() const
561{
562 std::vector<int> layers( 3 );
563
564 layers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer;
565
567 layers[1] = LAYER_NOTES_BACKGROUND;
568 else if( m_layer == LAYER_DEVICE )
569 layers[1] = LAYER_DEVICE_BACKGROUND;
570 else
571 layers[1] = LAYER_NOTES_BACKGROUND;
572
573 layers[2] = LAYER_SELECTION_SHADOWS;
574
575 return layers;
576}
577
578
579void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
580{
581 if( GetShape() == SHAPE_T::POLY )
582 {
583 if( m_poly.IsEmpty() )
584 {
586 m_poly.Outline( 0 ).SetClosed( false );
587 }
588
589 m_poly.Outline( 0 ).Append( aPosition, true );
590 }
591 else
592 {
594 }
595}
596
597
598bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
599{
600 if( aOther.Type() != Type() )
601 return false;
602
603 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
604
605 return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
606}
607
608
609double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
610{
611 if( m_Uuid == aOther.m_Uuid )
612 return 1.0;
613
614 if( aOther.Type() != Type() )
615 return 0.0;
616
617 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
618
619 double similarity = SimilarityBase( other );
620
621 similarity *= EDA_SHAPE::Similarity( other );
622
623 return similarity;
624}
625
626
627int SCH_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
628{
629 int retv = SCH_ITEM::compare( aOther, aCompareFlags );
630
631 if( retv )
632 return retv;
633
634 return EDA_SHAPE::Compare( &static_cast<const SCH_SHAPE&>( aOther ) );
635}
636
637
638static struct SCH_SHAPE_DESC
639{
641 {
643
644 if( fillEnum.Choices().GetCount() == 0 )
645 {
646 fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) )
647 .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) )
648 .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) )
649 .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) );
650 }
651
658
659 // Only polygons have meaningful Position properties.
660 // On other shapes, these are duplicates of the Start properties.
661 auto isPolygon =
662 []( INSPECTABLE* aItem ) -> bool
663 {
664 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
665 return shape->GetShape() == SHAPE_T::POLY;
666
667 return false;
668 };
669
670 auto isSymbolItem =
671 []( INSPECTABLE* aItem ) -> bool
672 {
673 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
674 return shape->GetLayer() == LAYER_DEVICE;
675
676 return false;
677 };
678
679 auto isSchematicItem =
680 []( INSPECTABLE* aItem ) -> bool
681 {
682 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
683 return shape->GetLayer() != LAYER_DEVICE;
684
685 return false;
686 };
687
689 _HKI( "Position X" ), isPolygon );
691 _HKI( "Position Y" ), isPolygon );
692
694 _HKI( "Filled" ), isSchematicItem );
695
696 void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode;
697 FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode;
698
699 propMgr.AddProperty( new PROPERTY_ENUM<SCH_SHAPE, FILL_T>( _HKI( "Fill" ),
700 fillModeSetter, fillModeGetter ),
701 _HKI( "Shape Properties" ) )
702 .SetAvailableFunc( isSymbolItem );
703 }
705
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
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:89
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:499
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:203
void SetStartX(int x)
Definition: eda_shape.h:153
VECTOR2I getCenter() const
Definition: eda_shape.cpp:752
int GetStartY() const
Definition: eda_shape.h:138
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Definition: eda_shape.cpp:625
FILL_T GetFillMode() const
Definition: eda_shape.h:114
void SetEndY(int aY)
Definition: eda_shape.h:184
void SetStartY(int y)
Definition: eda_shape.h:147
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:810
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:966
bool operator==(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:2050
int GetRadius() const
Definition: eda_shape.cpp:826
SHAPE_T GetShape() const
Definition: eda_shape.h:132
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:1077
void SetEndX(int aX)
Definition: eda_shape.h:190
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition: eda_shape.cpp:682
VECTOR2I m_start
Definition: eda_shape.h:432
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:174
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:137
COLOR4D GetFillColor() const
Definition: eda_shape.h:118
void SwapShape(EDA_SHAPE *aImage)
Definition: eda_shape.cpp:1852
std::vector< VECTOR2I > m_bezierPoints
Definition: eda_shape.h:441
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:340
int GetStartX() const
Definition: eda_shape.h:139
double Similarity(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:2095
VECTOR2I m_end
Definition: eda_shape.h:433
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:1023
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:442
STROKE_PARAMS m_stroke
Definition: eda_shape.h:422
FILL_T m_fill
Definition: eda_shape.h:423
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:113
int Compare(const EDA_SHAPE *aOther) const
Definition: eda_shape.cpp:1875
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:796
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:669
static ENUM_MAP< T > & Instance()
Definition: property.h:663
wxPGChoices & Choices()
Definition: property.h:712
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
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Base plotter engine class.
Definition: plotter.h:105
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:150
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
bool GetColorMode() const
Definition: plotter.h:133
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
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.
Holds all the data relating to one schematic.
Definition: schematic.h:77
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:670
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
virtual bool operator==(const SCH_ITEM &aOther) const
Definition: sch_item.cpp:392
bool IsPrivate() const
Definition: sch_item.h:235
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:282
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:416
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:351
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:473
SCH_LAYER_ID m_layer
Definition: sch_item.h:723
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:316
void getSymbolEditorMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: sch_item.cpp:499
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:96
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:510
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition: sch_shape.h:97
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
Definition: sch_shape.cpp:333
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:69
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:60
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:609
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:129
void PrintBackground(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Print just the background fills.
Definition: sch_shape.cpp:271
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:265
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:499
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:579
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:542
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:114
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:108
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:598
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:560
int GetPenWidth() const override
Definition: sch_shape.h:52
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:55
VECTOR2I GetPosition() const override
Definition: sch_shape.h:70
int GetEffectiveWidth() const override
Definition: sch_shape.cpp:247
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:627
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.
An abstract shape on 2D plane.
Definition: shape.h:126
Simple container to manage line stroke parameters.
Definition: stroke_params.h:79
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:92
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:95
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
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
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_0
Definition: eda_angle.h:401
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:406
static constexpr EDA_ANGLE ANGLE_180
Definition: eda_angle.h:405
#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
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
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_DEVICE
Definition: layer_ids.h:370
@ LAYER_PRIVATE_NOTES
Definition: layer_ids.h:372
@ LAYER_NOTES
Definition: layer_ids.h:371
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:387
@ LAYER_NOTES_BACKGROUND
Definition: layer_ids.h:373
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:397
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:390
#define TYPE_HASH(x)
Definition: property.h:71
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
Definition: property.h:765
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
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:93
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:691