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 <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 ), true );
99}
100
101
103{
104 flip( VECTOR2I( 0, aCenter ), false );
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 {
146 if( m_layer == LAYER_DEVICE )
147 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
148 else
149 ptList.push_back( pt );
150 }
151 }
152 else if( GetShape() == SHAPE_T::BEZIER )
153 {
154 ptList.clear();
155
156 for( const VECTOR2I& pt : m_bezierPoints )
157 {
158 if( m_layer == LAYER_DEVICE )
159 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
160 else
161 ptList.push_back( pt );
162 }
163 }
164
166 COLOR4D bg = renderSettings->GetBackgroundColor();
167 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
168 FILL_T fill = m_fill;
169
170 if( aBackground )
171 {
172 if( !aPlotter->GetColorMode() )
173 return;
174
175 switch( m_fill )
176 {
177 case FILL_T::FILLED_SHAPE:
178 return;
179
180 case FILL_T::FILLED_WITH_COLOR:
182 break;
183
184 case FILL_T::FILLED_WITH_BG_BODYCOLOR:
185 color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
186 break;
187
188 default:
189 return;
190 }
191
192 pen_size = 0;
193 lineStyle = LINE_STYLE::SOLID;
194 }
195 else /* if( aForeground ) */
196 {
197 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
198 color = renderSettings->GetLayerColor( m_layer );
199
200 if( lineStyle == LINE_STYLE::DEFAULT )
201 lineStyle = LINE_STYLE::SOLID;
202
203 if( m_fill == FILL_T::FILLED_SHAPE )
204 fill = m_fill;
205 else
206 fill = FILL_T::NO_FILL;
207
208 pen_size = GetEffectivePenWidth( renderSettings );
209 }
210
211 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
212 bg = COLOR4D::WHITE;
213
214 if( aDimmed )
215 {
216 color.Desaturate( );
217 color = color.Mix( bg, 0.5f );
218 }
219
220 aPlotter->SetColor( color );
221 aPlotter->SetCurrentLineWidth( pen_size );
222 aPlotter->SetDash( pen_size, lineStyle );
223
224 VECTOR2I start = m_start;
225 VECTOR2I end = m_end;
226 VECTOR2I mid, center;
227
228 if( m_layer == LAYER_DEVICE )
229 {
230 start = renderSettings->TransformCoordinate( start ) + aOffset;
231 end = renderSettings->TransformCoordinate( end ) + aOffset;
232 }
233
234 switch( GetShape() )
235 {
236 case SHAPE_T::ARC:
237 mid = GetArcMid();
238
239 if( m_layer == LAYER_DEVICE )
240 mid = renderSettings->TransformCoordinate( mid ) + aOffset;
241
242 aPlotter->Arc( start, mid, end, fill, pen_size );
243 break;
244
245 case SHAPE_T::CIRCLE:
246 center = getCenter();
247
248 if( m_layer == LAYER_DEVICE )
249 center = renderSettings->TransformCoordinate( center ) + aOffset;
250
251 aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
252 break;
253
254 case SHAPE_T::RECTANGLE:
255 aPlotter->Rect( start, end, fill, pen_size );
256 break;
257
258 case SHAPE_T::POLY:
259 case SHAPE_T::BEZIER:
260 aPlotter->PlotPoly( ptList, fill, pen_size );
261 break;
262
263 default:
265 }
266
267 aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
268}
269
270
272{
273 if( GetPenWidth() > 0 )
274 return GetPenWidth();
275
276 // Historically 0 meant "default width" and negative numbers meant "don't stroke".
277 if( GetPenWidth() < 0 )
278 return 0;
279
280 SCHEMATIC* schematic = Schematic();
281
282 if( schematic )
283 return schematic->Settings().m_DefaultLineWidth;
284
286}
287
288
290{
291 return getBoundingBox();
292}
293
294
295void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
296 const VECTOR2I& aOffset, bool aDimmed )
297{
298 if( IsPrivate() )
299 return;
300
301 wxDC* DC = aSettings->GetPrintDC();
303
304 static std::vector<VECTOR2I> ptList;
305
306 if( GetShape() == SHAPE_T::POLY )
307 {
308 ptList.clear();
309
310 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
311 {
312 if( m_layer == LAYER_DEVICE )
313 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
314 else
315 ptList.push_back( pt );
316 }
317 }
318 else if( GetShape() == SHAPE_T::BEZIER )
319 {
320 ptList.clear();
321
322 for( const VECTOR2I& pt : m_bezierPoints )
323 {
324 if( m_layer == LAYER_DEVICE )
325 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
326 else
327 ptList.push_back( pt );
328 }
329 }
330
331 if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
332 {
333 if( GetFillColor() == COLOR4D::UNSPECIFIED )
334 color = aSettings->GetLayerColor( LAYER_NOTES );
335 else
337
338 switch( GetShape() )
339 {
340 case SHAPE_T::ARC:
341 GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, color, color );
342 break;
343
344 case SHAPE_T::CIRCLE:
346 break;
347
348 case SHAPE_T::RECTANGLE:
349 GRFilledRect( DC, GetStart(), GetEnd(), 0, color, color );
350 break;
351
352 case SHAPE_T::POLY:
353 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
354 break;
355
356 case SHAPE_T::BEZIER:
357 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
358 break;
359
360 default:
362 }
363 }
364}
365
366
367void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
368 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
369{
370 if( IsPrivate() )
371 return;
372
373 int penWidth = GetEffectivePenWidth( aSettings );
374 wxDC* DC = aSettings->GetPrintDC();
376 COLOR4D bg = aSettings->GetBackgroundColor();
377
378 if( color == COLOR4D::UNSPECIFIED )
379 color = aSettings->GetLayerColor( LAYER_NOTES );
380
381 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
382 bg = COLOR4D::WHITE;
383
384 if( aDimmed )
385 {
386 color.Desaturate( );
387 color = color.Mix( bg, 0.5f );
388 }
389
390 static std::vector<VECTOR2I> ptList;
391
392 if( GetShape() == SHAPE_T::POLY )
393 {
394 ptList.clear();
395
396 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
397 {
398 if( m_layer == LAYER_DEVICE )
399 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
400 else
401 ptList.push_back( pt );
402 }
403 }
404 else if( GetShape() == SHAPE_T::BEZIER )
405 {
406 ptList.clear();
407
408 for( const VECTOR2I& pt : m_bezierPoints )
409 {
410 if( m_layer == LAYER_DEVICE )
411 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
412 else
413 ptList.push_back( pt );
414 }
415 }
416
417 VECTOR2I start = GetStart();
418 VECTOR2I end = GetEnd();
419 VECTOR2I center = ( GetShape() == SHAPE_T::ARC ) ? getCenter() : VECTOR2I( 0, 0 );
420
421 if( m_layer == LAYER_DEVICE )
422 {
423 start = aSettings->TransformCoordinate( start ) + aOffset;
424 end = aSettings->TransformCoordinate( end ) + aOffset;
425
426 if( GetShape() == SHAPE_T::ARC )
427 {
428 center = aSettings->TransformCoordinate( center ) + aOffset;
429
430 EDA_ANGLE t1, t2;
431
432 CalcArcAngles( t1, t2 );
433
434 // N.B. The order of evaluation is critical here as MapAngles will modify t1, t2
435 // and the Normalize routine depends on these modifications for the correct output
436 bool transformed = aSettings->m_Transform.MapAngles( &t1, &t2 );
437 EDA_ANGLE arc_angle = ( t1 - t2 ).Normalize180();
438 bool transformed2 = ( arc_angle > ANGLE_0 ) && ( arc_angle < ANGLE_180 );
439
440 if( transformed == transformed2 )
441 std::swap( start, end );
442 }
443 }
444
445 COLOR4D fillColor = COLOR4D::UNSPECIFIED;
446
447 if( GetFillMode() == FILL_T::FILLED_SHAPE )
448 fillColor = color;
449 else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
450 fillColor = GetFillColor();
451 else if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
452 fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
453
454 if( fillColor != COLOR4D::UNSPECIFIED && !aForceNoFill )
455 {
456 if( aDimmed )
457 {
458 fillColor.Desaturate( );
459 fillColor = fillColor.Mix( bg, 0.5f );
460 }
461
462 switch( GetShape() )
463 {
464 case SHAPE_T::ARC:
465 GRFilledArc( DC, end, start, center, 0, fillColor, fillColor );
466 break;
467
468 case SHAPE_T::CIRCLE:
469 GRFilledCircle( DC, start, GetRadius(), 0, fillColor, fillColor );
470 break;
471
472 case SHAPE_T::RECTANGLE:
473 GRFilledRect( DC, start, end, 0, fillColor, fillColor );
474 break;
475
476 case SHAPE_T::POLY:
477 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
478 break;
479
480 case SHAPE_T::BEZIER:
481 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
482 break;
483
484 default:
486 }
487 }
488
489 penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
490
491 if( penWidth > 0 )
492 {
493 if( GetEffectiveLineStyle() == LINE_STYLE::SOLID )
494 {
495 switch( GetShape() )
496 {
497 case SHAPE_T::ARC:
498 GRArc( DC, end, start, center, penWidth, color );
499 break;
500
501 case SHAPE_T::CIRCLE:
502 GRCircle( DC, start, GetRadius(), penWidth, color );
503 break;
504
505 case SHAPE_T::RECTANGLE:
506 GRRect( DC, start, end, penWidth, color );
507 break;
508
509 case SHAPE_T::POLY:
510 GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
511 break;
512
513 case SHAPE_T::BEZIER:
514 GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
515 break;
516
517 default:
519 }
520 }
521 else
522 {
523 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
524
525 for( SHAPE* shape : shapes )
526 {
527 STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
528 [&]( const VECTOR2I& a, const VECTOR2I& b )
529 {
530 if( m_layer == LAYER_DEVICE )
531 {
532 VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
533 VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
534 GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
535 }
536 else
537 {
538 GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
539 }
540 } );
541 }
542
543 for( SHAPE* shape : shapes )
544 delete shape;
545 }
546 }
547}
548
549
550void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
551{
552 if( m_layer == LAYER_DEVICE )
553 getSymbolEditorMsgPanelInfo( aFrame, aList );
554 else
555 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
556
557 ShapeGetMsgPanelInfo( aFrame, aList );
558}
559
560
561wxString SCH_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
562{
563 switch( GetShape() )
564 {
565 case SHAPE_T::ARC:
566 return wxString::Format( _( "Arc, radius %s" ),
567 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
568
569 case SHAPE_T::CIRCLE:
570 return wxString::Format( _( "Circle, radius %s" ),
571 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
572
573 case SHAPE_T::RECTANGLE:
574 return wxString::Format( _( "Rectangle, width %s height %s" ),
575 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
576 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
577
578 case SHAPE_T::POLY:
579 return wxString::Format( _( "Polyline, %d points" ),
580 int( m_poly.Outline( 0 ).GetPointCount() ) );
581
582 case SHAPE_T::BEZIER:
583 return wxString::Format( _( "Bezier Curve, %d points" ),
584 int( m_bezierPoints.size() ) );
585
586 default:
588 return wxEmptyString;
589 }
590}
591
592
594{
595 switch( GetShape() )
596 {
597 case SHAPE_T::SEGMENT: return BITMAPS::add_line;
598 case SHAPE_T::ARC: return BITMAPS::add_arc;
599 case SHAPE_T::CIRCLE: return BITMAPS::add_circle;
600 case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle;
601 case SHAPE_T::POLY: return BITMAPS::add_graphical_segments;
602 case SHAPE_T::BEZIER: return BITMAPS::add_bezier;
603
604 default:
606 return BITMAPS::question_mark;
607 }
608}
609
610
611void SCH_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const
612{
613 aCount = 3;
614 aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer;
615
617 aLayers[1] = LAYER_NOTES_BACKGROUND;
618 else if( m_layer == LAYER_DEVICE )
619 aLayers[1] = LAYER_DEVICE_BACKGROUND;
620 else
621 aLayers[1] = LAYER_NOTES_BACKGROUND;
622
623 aLayers[2] = LAYER_SELECTION_SHADOWS;
624}
625
626
627void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
628{
629 if( GetShape() == SHAPE_T::POLY )
630 {
631 if( m_poly.IsEmpty() )
633
634 m_poly.Outline( 0 ).Append( aPosition, true );
635 }
636 else
637 {
639 }
640}
641
642
643bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
644{
645 if( aOther.Type() != Type() )
646 return false;
647
648 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
649
650 return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
651}
652
653
654double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
655{
656 if( m_Uuid == aOther.m_Uuid )
657 return 1.0;
658
659 if( aOther.Type() != Type() )
660 return 0.0;
661
662 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
663
664 double similarity = SimilarityBase( other );
665
666 similarity *= EDA_SHAPE::Similarity( other );
667
668 return similarity;
669}
670
671
672int SCH_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
673{
674 int retv = SCH_ITEM::compare( aOther, aCompareFlags );
675
676 if( retv )
677 return retv;
678
679 return EDA_SHAPE::Compare( &static_cast<const SCH_SHAPE&>( aOther ) );
680}
681
682
683static struct SCH_SHAPE_DESC
684{
686 {
688
689 if( fillEnum.Choices().GetCount() == 0 )
690 {
691 fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) )
692 .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) )
693 .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) )
694 .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) );
695 }
696
703
704 // Only polygons have meaningful Position properties.
705 // On other shapes, these are duplicates of the Start properties.
706 auto isPolygon =
707 []( INSPECTABLE* aItem ) -> bool
708 {
709 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
710 return shape->GetShape() == SHAPE_T::POLY;
711
712 return false;
713 };
714
715 auto isSymbolItem =
716 []( INSPECTABLE* aItem ) -> bool
717 {
718 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
719 return shape->GetLayer() == LAYER_DEVICE;
720
721 return false;
722 };
723
724 auto isSchematicItem =
725 []( INSPECTABLE* aItem ) -> bool
726 {
727 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
728 return shape->GetLayer() != LAYER_DEVICE;
729
730 return false;
731 };
732
734 _HKI( "Position X" ), isPolygon );
736 _HKI( "Position Y" ), isPolygon );
737
739 _HKI( "Filled" ), isSchematicItem );
740
741 void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode;
742 FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode;
743
744 propMgr.AddProperty( new PROPERTY_ENUM<SCH_SHAPE, FILL_T>( _HKI( "Fill" ),
745 fillModeSetter, fillModeGetter ),
746 _HKI( "Shape Properties" ) )
747 .SetAvailableFunc( isSymbolItem );
748 }
750
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:88
const KIID m_Uuid
Definition: eda_item.h:485
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:490
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:202
void SetStartX(int x)
Definition: eda_shape.h:141
VECTOR2I getCenter() const
Definition: eda_shape.cpp:519
int GetStartY() const
Definition: eda_shape.h:126
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Definition: eda_shape.cpp:338
void flip(const VECTOR2I &aCentre, bool aFlipLeftRight)
Definition: eda_shape.cpp:395
FILL_T GetFillMode() const
Definition: eda_shape.h:102
void SetEndY(int aY)
Definition: eda_shape.h:160
void SetStartY(int y)
Definition: eda_shape.h:135
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:577
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:733
bool operator==(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:1803
int GetRadius() const
Definition: eda_shape.cpp:593
SHAPE_T GetShape() const
Definition: eda_shape.h:120
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:844
void SetEndX(int aX)
Definition: eda_shape.h:166
VECTOR2I m_start
Definition: eda_shape.h:406
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:150
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:125
COLOR4D GetFillColor() const
Definition: eda_shape.h:106
void SwapShape(EDA_SHAPE *aImage)
Definition: eda_shape.cpp:1605
std::vector< VECTOR2I > m_bezierPoints
Definition: eda_shape.h:415
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:89
int GetStartX() const
Definition: eda_shape.h:127
double Similarity(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:1848
VECTOR2I m_end
Definition: eda_shape.h:407
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:790
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:416
STROKE_PARAMS m_stroke
Definition: eda_shape.h:396
FILL_T m_fill
Definition: eda_shape.h:397
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:101
int Compare(const EDA_SHAPE *aOther) const
Definition: eda_shape.cpp:1628
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:563
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: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
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
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: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:174
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:678
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:139
virtual bool operator==(const SCH_ITEM &aOther) const
Definition: sch_item.cpp:384
bool IsPrivate() const
Definition: sch_item.h:243
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:290
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:408
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:343
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:464
SCH_LAYER_ID m_layer
Definition: sch_item.h:731
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:324
void getSymbolEditorMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: sch_item.cpp:490
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:561
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:611
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_shape.cpp:96
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:367
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:654
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:295
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:289
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:550
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:627
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:593
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:643
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:271
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:672
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:81
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:94
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:97
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)
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:435
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:437
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:440
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:55
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:386
@ LAYER_NOTES_BACKGROUND
Definition: layer_ids.h:373
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:395
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: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:366
static struct SCH_SHAPE_DESC _SCH_SHAPE_DESC
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
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< int > VECTOR2I
Definition: vector2d.h:588