KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_shape.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <sch_draw_panel.h>
26#include <macros.h>
27#include <plotters/plotter.h>
28#include <base_units.h>
29#include <widgets/msgpanel.h>
30#include <bitmaps.h>
31#include <eda_draw_frame.h>
32#include <gr_basic.h>
33#include <schematic.h>
34#include <sch_shape.h>
35
36
37SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
38 KICAD_T aType ) :
39 SCH_ITEM( nullptr, aType ),
40 EDA_SHAPE( aShape, aLineWidth, aFillType )
41{
42 SetLayer( aLayer );
43}
44
45
47{
48 return new SCH_SHAPE( *this );
49}
50
51
53{
54 SCH_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::SetFilled( bool aFilled )
70{
71 if( !aFilled )
72 m_fill = FILL_T::NO_FILL;
73 else if( GetParentSymbol() )
74 m_fill = FILL_T::FILLED_SHAPE;
75 else
76 m_fill = FILL_T::FILLED_WITH_COLOR;
77}
78
79
80void SCH_SHAPE::Move( const VECTOR2I& aOffset )
81{
82 move( aOffset );
83}
84
85
87{
88 if( GetShape() == SHAPE_T::RECTANGLE )
89 {
90 VECTOR2I size = GetEnd() - GetPosition();
91
92 if( size.y < 0 )
93 {
94 SetStartY( GetStartY() + size.y );
95 SetEndY( GetStartY() - size.y );
96 }
97
98 if( size.x < 0 )
99 {
100 SetStartX( GetStartX() + size.x );
101 SetEndX( GetStartX() - size.x );
102 }
103 }
104}
105
106
108{
109 flip( VECTOR2I( aCenter, 0 ), FLIP_DIRECTION::LEFT_RIGHT );
110}
111
112
114{
115 flip( VECTOR2I( 0, aCenter ), FLIP_DIRECTION::TOP_BOTTOM );
116}
117
118
119void SCH_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
120{
121 rotate( aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
122}
123
124
125bool SCH_SHAPE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
126{
127 return hitTest( aPosition, aAccuracy );
128}
129
130
131bool SCH_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
132{
134 return false;
135
136 return hitTest( aRect, aContained, aAccuracy );
137}
138
139
140void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
141 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
142{
143 if( IsPrivate() )
144 return;
145
146 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
147 int pen_size = GetEffectivePenWidth( renderSettings );
148
149 static std::vector<VECTOR2I> ptList;
150
151 if( GetShape() == SHAPE_T::POLY )
152 {
153 ptList.clear();
154
155 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
156 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
157 }
158 else if( GetShape() == SHAPE_T::BEZIER )
159 {
160 ptList.clear();
161
162 for( const VECTOR2I& pt : m_bezierPoints )
163 ptList.push_back( renderSettings->TransformCoordinate( pt ) + aOffset );
164 }
165
167 COLOR4D bg = renderSettings->GetBackgroundColor();
168 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
169 FILL_T fill = m_fill;
170
171 if( aBackground )
172 {
173 if( !aPlotter->GetColorMode() )
174 return;
175
176 switch( m_fill )
177 {
178 case FILL_T::FILLED_SHAPE:
179 return;
180
181 case FILL_T::FILLED_WITH_COLOR:
183 break;
184
185 case FILL_T::FILLED_WITH_BG_BODYCOLOR:
186 color = renderSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
187 break;
188
189 default:
190 return;
191 }
192
193 pen_size = 0;
194 lineStyle = LINE_STYLE::SOLID;
195 }
196 else /* if( aForeground ) */
197 {
198 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
199 color = renderSettings->GetLayerColor( m_layer );
200
201 if( lineStyle == LINE_STYLE::DEFAULT )
202 lineStyle = LINE_STYLE::SOLID;
203
204 if( m_fill == FILL_T::FILLED_SHAPE )
205 fill = m_fill;
206 else
207 fill = FILL_T::NO_FILL;
208
209 pen_size = GetEffectivePenWidth( renderSettings );
210 }
211
212 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
213 bg = COLOR4D::WHITE;
214
215 if( aDimmed )
216 {
217 color.Desaturate( );
218 color = color.Mix( bg, 0.5f );
219 }
220
221 aPlotter->SetColor( color );
222 aPlotter->SetCurrentLineWidth( pen_size );
223 aPlotter->SetDash( pen_size, lineStyle );
224
225 VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
226 VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
227 VECTOR2I mid, center;
228
229 switch( GetShape() )
230 {
231 case SHAPE_T::ARC:
232 mid = renderSettings->TransformCoordinate( GetArcMid() ) + aOffset;
233 aPlotter->Arc( start, mid, end, fill, pen_size );
234 break;
235
236 case SHAPE_T::CIRCLE:
237 center = renderSettings->TransformCoordinate( getCenter() ) + aOffset;
238 aPlotter->Circle( center, GetRadius() * 2, fill, pen_size );
239 break;
240
241 case SHAPE_T::RECTANGLE:
242 aPlotter->Rect( start, end, fill, pen_size );
243 break;
244
245 case SHAPE_T::POLY:
246 case SHAPE_T::BEZIER:
247 aPlotter->PlotPoly( ptList, fill, pen_size );
248 break;
249
250 default:
252 }
253
254 aPlotter->SetDash( pen_size, LINE_STYLE::SOLID );
255}
256
257
259{
260 if( GetPenWidth() > 0 )
261 return GetPenWidth();
262
263 // Historically 0 meant "default width" and negative numbers meant "don't stroke".
264 if( GetPenWidth() < 0 )
265 return 0;
266
267 SCHEMATIC* schematic = Schematic();
268
269 if( schematic )
270 return schematic->Settings().m_DefaultLineWidth;
271
273}
274
275
277{
278 return getBoundingBox();
279}
280
281
282void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
283 const VECTOR2I& aOffset, bool aDimmed )
284{
285 if( IsPrivate() )
286 return;
287
288 wxDC* DC = aSettings->GetPrintDC();
290
291 static std::vector<VECTOR2I> ptList;
292
293 if( GetShape() == SHAPE_T::POLY )
294 {
295 ptList.clear();
296
297 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
298 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
299 }
300 else if( GetShape() == SHAPE_T::BEZIER )
301 {
302 ptList.clear();
303
304 for( const VECTOR2I& pt : m_bezierPoints )
305 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
306 }
307
308 if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
309 {
310 if( GetFillColor() == COLOR4D::UNSPECIFIED )
311 color = aSettings->GetLayerColor( LAYER_NOTES );
312 else
314
315 switch( GetShape() )
316 {
317 case SHAPE_T::ARC:
318 GRFilledArc( DC, GetEnd(), GetStart(), getCenter(), 0, color, color );
319 break;
320
321 case SHAPE_T::CIRCLE:
323 break;
324
325 case SHAPE_T::RECTANGLE:
326 GRFilledRect( DC, GetStart(), GetEnd(), 0, color, color );
327 break;
328
329 case SHAPE_T::POLY:
330 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
331 break;
332
333 case SHAPE_T::BEZIER:
334 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, color, color );
335 break;
336
337 default:
339 }
340 }
341}
342
343
344void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
345 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
346{
347 if( IsPrivate() )
348 return;
349
350 int penWidth = GetEffectivePenWidth( aSettings );
351 wxDC* DC = aSettings->GetPrintDC();
353 COLOR4D bg = aSettings->GetBackgroundColor();
354
355 if( color == COLOR4D::UNSPECIFIED )
356 color = aSettings->GetLayerColor( LAYER_NOTES );
357
358 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
359 bg = COLOR4D::WHITE;
360
361 if( aDimmed )
362 {
363 color.Desaturate( );
364 color = color.Mix( bg, 0.5f );
365 }
366
367 static std::vector<VECTOR2I> ptList;
368
369 if( GetShape() == SHAPE_T::POLY )
370 {
371 ptList.clear();
372
373 for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
374 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
375 }
376 else if( GetShape() == SHAPE_T::BEZIER )
377 {
378 ptList.clear();
379
380 for( const VECTOR2I& pt : m_bezierPoints )
381 ptList.push_back( aSettings->TransformCoordinate( pt ) + aOffset );
382 }
383
384 VECTOR2I start = GetStart();
385 VECTOR2I end = GetEnd();
386 VECTOR2I center = ( GetShape() == SHAPE_T::ARC ) ? getCenter() : VECTOR2I( 0, 0 );
387
388 if( aSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
389 {
390 start = aSettings->TransformCoordinate( start ) + aOffset;
391 end = aSettings->TransformCoordinate( end ) + aOffset;
392
393 if( GetShape() == SHAPE_T::ARC )
394 {
395 center = aSettings->TransformCoordinate( center ) + aOffset;
396
397 EDA_ANGLE t1, t2;
398
399 CalcArcAngles( t1, t2 );
400
401 // N.B. The order of evaluation is critical here as MapAngles will modify t1, t2
402 // and the Normalize routine depends on these modifications for the correct output
403 bool transformed = aSettings->m_Transform.MapAngles( &t1, &t2 );
404 EDA_ANGLE arc_angle = ( t1 - t2 ).Normalize180();
405 bool transformed2 = ( arc_angle > ANGLE_0 ) && ( arc_angle < ANGLE_180 );
406
407 if( transformed != transformed2 )
408 std::swap( start, end );
409 }
410 }
411
412 COLOR4D fillColor = COLOR4D::UNSPECIFIED;
413
414 if( GetFillMode() == FILL_T::FILLED_SHAPE )
415 fillColor = color;
416 else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
417 fillColor = GetFillColor();
418 else if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
419 fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
420
421 if( fillColor != COLOR4D::UNSPECIFIED && !aForceNoFill )
422 {
423 if( aDimmed )
424 {
425 fillColor.Desaturate( );
426 fillColor = fillColor.Mix( bg, 0.5f );
427 }
428
429 switch( GetShape() )
430 {
431 case SHAPE_T::ARC:
432 GRFilledArc( DC, end, start, center, 0, fillColor, fillColor );
433 break;
434
435 case SHAPE_T::CIRCLE:
436 GRFilledCircle( DC, start, GetRadius(), 0, fillColor, fillColor );
437 break;
438
439 case SHAPE_T::RECTANGLE:
440 GRFilledRect( DC, start, end, 0, fillColor, fillColor );
441 break;
442
443 case SHAPE_T::POLY:
444 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
445 break;
446
447 case SHAPE_T::BEZIER:
448 GRPoly( DC, (int) ptList.size(), ptList.data(), true, 0, fillColor, fillColor );
449 break;
450
451 default:
453 }
454 }
455
456 penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
457
458 if( penWidth > 0 )
459 {
460 if( GetEffectiveLineStyle() == LINE_STYLE::SOLID )
461 {
462 switch( GetShape() )
463 {
464 case SHAPE_T::ARC:
465 GRArc( DC, end, start, center, penWidth, color );
466 break;
467
468 case SHAPE_T::CIRCLE:
469 GRCircle( DC, start, GetRadius(), penWidth, color );
470 break;
471
472 case SHAPE_T::RECTANGLE:
473 GRRect( DC, start, end, penWidth, color );
474 break;
475
476 case SHAPE_T::POLY:
477 GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
478 break;
479
480 case SHAPE_T::BEZIER:
481 GRPoly( DC, (int) ptList.size(), ptList.data(), false, penWidth, color, color );
482 break;
483
484 default:
486 }
487 }
488 else
489 {
490 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
491
492 for( SHAPE* shape : shapes )
493 {
494 STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
495 [&]( const VECTOR2I& a, const VECTOR2I& b )
496 {
497 VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
498 VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
499 GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
500 } );
501 }
502
503 for( SHAPE* shape : shapes )
504 delete shape;
505 }
506 }
507}
508
509
510void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
511{
512 if( m_layer == LAYER_DEVICE )
513 getSymbolEditorMsgPanelInfo( aFrame, aList );
514 else
515 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
516
517 ShapeGetMsgPanelInfo( aFrame, aList );
518}
519
520
521wxString SCH_SHAPE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
522{
523 switch( GetShape() )
524 {
525 case SHAPE_T::ARC:
526 return wxString::Format( _( "Arc, radius %s" ),
527 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
528
529 case SHAPE_T::CIRCLE:
530 return wxString::Format( _( "Circle, radius %s" ),
531 aUnitsProvider->MessageTextFromValue( GetRadius() ) );
532
533 case SHAPE_T::RECTANGLE:
534 return wxString::Format( _( "Rectangle, width %s height %s" ),
535 aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ),
536 aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) );
537
538 case SHAPE_T::POLY:
539 return wxString::Format( _( "Polyline, %d points" ),
540 int( m_poly.Outline( 0 ).GetPointCount() ) );
541
542 case SHAPE_T::BEZIER:
543 return wxString::Format( _( "Bezier Curve, %d points" ),
544 int( m_bezierPoints.size() ) );
545
546 default:
548 return wxEmptyString;
549 }
550}
551
552
554{
555 switch( GetShape() )
556 {
557 case SHAPE_T::SEGMENT: return BITMAPS::add_line;
558 case SHAPE_T::ARC: return BITMAPS::add_arc;
559 case SHAPE_T::CIRCLE: return BITMAPS::add_circle;
560 case SHAPE_T::RECTANGLE: return BITMAPS::add_rectangle;
561 case SHAPE_T::POLY: return BITMAPS::add_graphical_segments;
562 case SHAPE_T::BEZIER: return BITMAPS::add_bezier;
563
564 default:
566 return BITMAPS::question_mark;
567 }
568}
569
570
571std::vector<int> SCH_SHAPE::ViewGetLayers() const
572{
573 std::vector<int> layers( 3 );
574
575 layers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : m_layer;
576
577 if( m_layer == LAYER_DEVICE )
578 {
579 if( m_fill == FILL_T::FILLED_WITH_BG_BODYCOLOR )
580 layers[1] = LAYER_DEVICE_BACKGROUND;
581 else
582 layers[1] = LAYER_SHAPES_BACKGROUND;
583 }
584 else
585 {
586 layers[1] = LAYER_SHAPES_BACKGROUND;
587 }
588
589 layers[2] = LAYER_SELECTION_SHADOWS;
590
591 return layers;
592}
593
594
595void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
596{
597 if( GetShape() == SHAPE_T::POLY )
598 {
599 if( m_poly.IsEmpty() )
600 {
602 m_poly.Outline( 0 ).SetClosed( false );
603 }
604
605 m_poly.Outline( 0 ).Append( aPosition, true );
606 }
607 else
608 {
610 }
611}
612
613
614bool SCH_SHAPE::operator==( const SCH_ITEM& aOther ) const
615{
616 if( aOther.Type() != Type() )
617 return false;
618
619 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
620
621 return SCH_ITEM::operator==( aOther ) && EDA_SHAPE::operator==( other );
622}
623
624
625double SCH_SHAPE::Similarity( const SCH_ITEM& aOther ) const
626{
627 if( m_Uuid == aOther.m_Uuid )
628 return 1.0;
629
630 if( aOther.Type() != Type() )
631 return 0.0;
632
633 const SCH_SHAPE& other = static_cast<const SCH_SHAPE&>( aOther );
634
635 double similarity = SimilarityBase( other );
636
637 similarity *= EDA_SHAPE::Similarity( other );
638
639 return similarity;
640}
641
642
643int SCH_SHAPE::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
644{
645 int retv = SCH_ITEM::compare( aOther, aCompareFlags );
646
647 if( retv )
648 return retv;
649
650 return EDA_SHAPE::Compare( &static_cast<const SCH_SHAPE&>( aOther ) );
651}
652
653
654static struct SCH_SHAPE_DESC
655{
657 {
659
660 if( fillEnum.Choices().GetCount() == 0 )
661 {
662 fillEnum.Map( FILL_T::NO_FILL, _HKI( "None" ) )
663 .Map( FILL_T::FILLED_SHAPE, _HKI( "Body outline color" ) )
664 .Map( FILL_T::FILLED_WITH_BG_BODYCOLOR, _HKI( "Body background color" ) )
665 .Map( FILL_T::FILLED_WITH_COLOR, _HKI( "Fill color" ) );
666 }
667
674
675 // Only polygons have meaningful Position properties.
676 // On other shapes, these are duplicates of the Start properties.
677 auto isPolygon =
678 []( INSPECTABLE* aItem ) -> bool
679 {
680 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
681 return shape->GetShape() == SHAPE_T::POLY;
682
683 return false;
684 };
685
686 auto isSymbolItem =
687 []( INSPECTABLE* aItem ) -> bool
688 {
689 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
690 return shape->GetLayer() == LAYER_DEVICE;
691
692 return false;
693 };
694
695 auto isSchematicItem =
696 []( INSPECTABLE* aItem ) -> bool
697 {
698 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
699 return shape->GetLayer() != LAYER_DEVICE;
700
701 return false;
702 };
703
704 auto isFillColorEditable =
705 []( INSPECTABLE* aItem ) -> bool
706 {
707 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
708 {
709 if( shape->GetParentSymbol() )
710 return shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR;
711 else
712 return shape->IsFilled();
713 }
714
715 return true;
716 };
717
719 _HKI( "Position X" ), isPolygon );
721 _HKI( "Position Y" ), isPolygon );
722
724 _HKI( "Filled" ), isSchematicItem );
725
727 _HKI( "Fill Color" ), isFillColorEditable );
728
729 void ( SCH_SHAPE::*fillModeSetter )( FILL_T ) = &SCH_SHAPE::SetFillMode;
730 FILL_T ( SCH_SHAPE::*fillModeGetter )() const = &SCH_SHAPE::GetFillMode;
731
732 propMgr.AddProperty( new PROPERTY_ENUM<SCH_SHAPE, FILL_T>( _HKI( "Fill" ),
733 fillModeSetter, fillModeGetter ),
734 _HKI( "Shape Properties" ) )
735 .SetAvailableFunc( isSymbolItem );
736 }
738
int color
Definition: DXF_plotter.cpp:60
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:490
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:501
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:204
void SetStartX(int x)
Definition: eda_shape.h:153
VECTOR2I getCenter() const
Definition: eda_shape.cpp:766
int GetStartY() const
Definition: eda_shape.h:138
void rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Definition: eda_shape.cpp:635
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:824
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:982
bool operator==(const EDA_SHAPE &aOther) const
Definition: eda_shape.cpp:2070
int GetRadius() const
Definition: eda_shape.cpp:840
SHAPE_T GetShape() const
Definition: eda_shape.h:132
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:1095
void SetEndX(int aX)
Definition: eda_shape.h:190
void flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition: eda_shape.cpp:696
VECTOR2I m_start
Definition: eda_shape.h:444
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:1871
std::vector< VECTOR2I > m_bezierPoints
Definition: eda_shape.h:453
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:2115
VECTOR2I m_end
Definition: eda_shape.h:445
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:1041
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:454
STROKE_PARAMS m_stroke
Definition: eda_shape.h:434
FILL_T m_fill
Definition: eda_shape.h:435
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:113
int Compare(const EDA_SHAPE *aOther) const
Definition: eda_shape.cpp:1894
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:810
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:686
static ENUM_MAP< T > & Instance()
Definition: property.h:680
wxPGChoices & Choices()
Definition: property.h:729
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:37
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
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 OverrideWriteability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override writeability functor for a base class property of a given derived class.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Definition: schematic.h:82
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:167
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:656
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:166
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:236
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:283
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:709
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:317
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:107
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:521
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition: sch_shape.h:99
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:344
void SetFilled(bool aFilled) override
Definition: sch_shape.cpp:69
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:80
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:86
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:625
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:140
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:282
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:276
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_shape.cpp:113
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:510
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:595
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:553
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:125
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:119
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:614
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:571
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:72
int GetEffectiveWidth() const override
Definition: sch_shape.cpp:258
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:643
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:93
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
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:397
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:358
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:388
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:404
void GRArc(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:379
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:342
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:370
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:401
@ LAYER_SHAPES_BACKGROUND
Definition: layer_ids.h:435
@ LAYER_DEVICE
Definition: layer_ids.h:418
@ LAYER_PRIVATE_NOTES
Definition: layer_ids.h:420
@ LAYER_NOTES
Definition: layer_ids.h:419
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:436
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:446
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:782
#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:695