KiCad PCB EDA Suite
lib_arc.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-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  * Copyright (C) 2019 CERN
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <sch_draw_panel.h>
27 #include <plotter.h>
28 #include <trigo.h>
29 #include <base_units.h>
30 #include <widgets/msgpanel.h>
31 #include <bitmaps.h>
32 #include <math/util.h> // for KiROUND
33 #include <eda_draw_frame.h>
34 #include <general.h>
35 #include <lib_arc.h>
36 #include <transform.h>
38 #include <status_popup.h>
39 
40 // Helper function
41 static inline wxPoint twoPointVector( const wxPoint &startPoint, const wxPoint &endPoint )
42 {
43  return endPoint - startPoint;
44 }
45 
46 
47 LIB_ARC::LIB_ARC( LIB_SYMBOL* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
48 {
49  m_Radius = 0;
50  m_t1 = 0;
51  m_t2 = 0;
52  m_Width = 0;
54  m_isFillable = true;
55  m_editState = 0;
56 }
57 
58 
59 bool LIB_ARC::HitTest( const wxPoint& aRefPoint, int aAccuracy ) const
60 {
61  int mindist = std::max( aAccuracy + GetPenWidth() / 2,
62  Mils2iu( MINIMUM_SELECTION_DISTANCE ) );
63  wxPoint relativePosition = aRefPoint;
64 
65  relativePosition.y = -relativePosition.y; // reverse Y axis
66 
67  int distance = KiROUND( GetLineLength( m_Pos, relativePosition ) );
68 
69  if( abs( distance - m_Radius ) > mindist )
70  return false;
71 
72  // We are on the circle, ensure we are only on the arc, i.e. between
73  // m_ArcStart and m_ArcEnd
74 
75  wxPoint startEndVector = twoPointVector( m_ArcStart, m_ArcEnd );
76  wxPoint startRelativePositionVector = twoPointVector( m_ArcStart, relativePosition );
77 
78  wxPoint centerStartVector = twoPointVector( m_Pos, m_ArcStart );
79  wxPoint centerEndVector = twoPointVector( m_Pos, m_ArcEnd );
80  wxPoint centerRelativePositionVector = twoPointVector( m_Pos, relativePosition );
81 
82  // Compute the cross product to check if the point is in the sector
83  double crossProductStart = CrossProduct( centerStartVector, centerRelativePositionVector );
84  double crossProductEnd = CrossProduct( centerEndVector, centerRelativePositionVector );
85 
86  // The cross products need to be exchanged, depending on which side the center point
87  // relative to the start point to end point vector lies
88  if( CrossProduct( startEndVector, startRelativePositionVector ) < 0 )
89  {
90  std::swap( crossProductStart, crossProductEnd );
91  }
92 
93  // When the cross products have a different sign, the point lies in sector
94  // also check, if the reference is near start or end point
95  return HitTestPoints( m_ArcStart, relativePosition, MINIMUM_SELECTION_DISTANCE ) ||
96  HitTestPoints( m_ArcEnd, relativePosition, MINIMUM_SELECTION_DISTANCE ) ||
97  ( crossProductStart <= 0 && crossProductEnd >= 0 );
98 }
99 
100 
101 bool LIB_ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
102 {
103  if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) )
104  return false;
105 
106  wxPoint center = DefaultTransform.TransformCoordinate( GetPosition() );
107  int radius = GetRadius();
108  int lineWidth = GetWidth();
109  EDA_RECT sel = aRect ;
110 
111  if ( aAccuracy )
112  sel.Inflate( aAccuracy );
113 
114  if( aContained )
115  return sel.Contains( GetBoundingBox() );
116 
117  EDA_RECT arcRect = GetBoundingBox().Common( sel );
118 
119  /* All following tests must pass:
120  * 1. Rectangle must intersect arc BoundingBox
121  * 2. Rectangle must cross the outside of the arc
122  */
123  return arcRect.Intersects( sel ) && arcRect.IntersectsCircleEdge( center, radius, lineWidth );
124 }
125 
126 
128 {
129  return new LIB_ARC( *this );
130 }
131 
132 
133 int LIB_ARC::compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags ) const
134 {
135  wxASSERT( aOther.Type() == LIB_ARC_T );
136 
137  int retv = LIB_ITEM::compare( aOther );
138 
139  if( retv )
140  return retv;
141 
142  const LIB_ARC* tmp = ( LIB_ARC* ) &aOther;
143 
144  if( m_Pos.x != tmp->m_Pos.x )
145  return m_Pos.x - tmp->m_Pos.x;
146 
147  if( m_Pos.y != tmp->m_Pos.y )
148  return m_Pos.y - tmp->m_Pos.y;
149 
150  if( m_t1 != tmp->m_t1 )
151  return m_t1 - tmp->m_t1;
152 
153  if( m_t2 != tmp->m_t2 )
154  return m_t2 - tmp->m_t2;
155 
156  return 0;
157 }
158 
159 
160 void LIB_ARC::Offset( const wxPoint& aOffset )
161 {
162  m_Pos += aOffset;
163  m_ArcStart += aOffset;
164  m_ArcEnd += aOffset;
165 }
166 
167 
168 void LIB_ARC::MoveTo( const wxPoint& aPosition )
169 {
170  wxPoint offset = aPosition - m_Pos;
171  m_Pos = aPosition;
172  m_ArcStart += offset;
173  m_ArcEnd += offset;
174 }
175 
176 
177 void LIB_ARC::MirrorHorizontal( const wxPoint& aCenter )
178 {
179  m_Pos.x -= aCenter.x;
180  m_Pos.x *= -1;
181  m_Pos.x += aCenter.x;
182  m_ArcStart.x -= aCenter.x;
183  m_ArcStart.x *= -1;
184  m_ArcStart.x += aCenter.x;
185  m_ArcEnd.x -= aCenter.x;
186  m_ArcEnd.x *= -1;
187  m_ArcEnd.x += aCenter.x;
188  std::swap( m_ArcStart, m_ArcEnd );
189  std::swap( m_t1, m_t2 );
190  m_t1 = 1800 - m_t1;
191  m_t2 = 1800 - m_t2;
192 
193  if( m_t1 > 3600 || m_t2 > 3600 )
194  {
195  m_t1 -= 3600;
196  m_t2 -= 3600;
197  }
198  else if( m_t1 < -3600 || m_t2 < -3600 )
199  {
200  m_t1 += 3600;
201  m_t2 += 3600;
202  }
203 }
204 
205 
206 void LIB_ARC::MirrorVertical( const wxPoint& aCenter )
207 {
208  m_Pos.y -= aCenter.y;
209  m_Pos.y *= -1;
210  m_Pos.y += aCenter.y;
211  m_ArcStart.y -= aCenter.y;
212  m_ArcStart.y *= -1;
213  m_ArcStart.y += aCenter.y;
214  m_ArcEnd.y -= aCenter.y;
215  m_ArcEnd.y *= -1;
216  m_ArcEnd.y += aCenter.y;
217  std::swap( m_ArcStart, m_ArcEnd );
218  std::swap( m_t1, m_t2 );
219  m_t1 = - m_t1;
220  m_t2 = - m_t2;
221 
222  if( m_t1 > 3600 || m_t2 > 3600 )
223  {
224  m_t1 -= 3600;
225  m_t2 -= 3600;
226  }
227  else if( m_t1 < -3600 || m_t2 < -3600 )
228  {
229  m_t1 += 3600;
230  m_t2 += 3600;
231  }
232 }
233 
234 
235 void LIB_ARC::Rotate( const wxPoint& aCenter, bool aRotateCCW )
236 {
237  int rot_angle = aRotateCCW ? -900 : 900;
238  RotatePoint( &m_Pos, aCenter, rot_angle );
239  RotatePoint( &m_ArcStart, aCenter, rot_angle );
240  RotatePoint( &m_ArcEnd, aCenter, rot_angle );
241  m_t1 -= rot_angle;
242  m_t2 -= rot_angle;
243 
244  if( m_t1 > 3600 || m_t2 > 3600 )
245  {
246  m_t1 -= 3600;
247  m_t2 -= 3600;
248  }
249  else if( m_t1 < -3600 || m_t2 < -3600 )
250  {
251  m_t1 += 3600;
252  m_t2 += 3600;
253  }
254 }
255 
256 
257 void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
258  const TRANSFORM& aTransform ) const
259 {
260  wxASSERT( aPlotter != nullptr );
261 
262  int t1 = m_t1;
263  int t2 = m_t2;
264  wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + aOffset;
265 
266  aTransform.MapAngles( &t1, &t2 );
267 
269  {
270  aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
271  aPlotter->Arc( pos, -t2, -t1, m_Radius, FILL_TYPE::FILLED_WITH_BG_BODYCOLOR, 0 );
272  }
273 
274  bool already_filled = m_fill == FILL_TYPE::FILLED_WITH_BG_BODYCOLOR;
275  int pen_size = GetPenWidth();
276 
277  if( !already_filled || pen_size > 0 )
278  {
279  pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() );
280 
281  aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) );
282  aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? FILL_TYPE::NO_FILL : m_fill,
283  pen_size );
284  }
285 }
286 
287 
289 {
290  // Historically 0 meant "default width" and negative numbers meant "don't stroke".
291  if( m_Width < 0 && GetFillMode() != FILL_TYPE::NO_FILL )
292  return 0;
293  else
294  return std::max( m_Width, 1 );
295 }
296 
297 
298 void LIB_ARC::print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
299  const TRANSFORM& aTransform )
300 {
301  bool forceNoFill = static_cast<bool>( aData );
302  int penWidth = GetPenWidth();
303 
304  if( forceNoFill && m_fill != FILL_TYPE::NO_FILL && penWidth == 0 )
305  return;
306 
307  wxDC* DC = aSettings->GetPrintDC();
308  wxPoint pos1, pos2, posc;
309  COLOR4D color = aSettings->GetLayerColor( LAYER_DEVICE );
310 
311  pos1 = aTransform.TransformCoordinate( m_ArcEnd ) + aOffset;
312  pos2 = aTransform.TransformCoordinate( m_ArcStart ) + aOffset;
313  posc = aTransform.TransformCoordinate( m_Pos ) + aOffset;
314  int pt1 = m_t1;
315  int pt2 = m_t2;
316  bool swap = aTransform.MapAngles( &pt1, &pt2 );
317 
318  if( swap )
319  {
320  std::swap( pos1.x, pos2.x );
321  std::swap( pos1.y, pos2.y );
322  }
323 
324  if( forceNoFill || m_fill == FILL_TYPE::NO_FILL )
325  {
326  penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
327 
328  GRArc1( nullptr, DC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, penWidth, color );
329  }
330  else
331  {
334 
335  GRFilledArc( nullptr, DC, posc.x, posc.y, pt1, pt2, m_Radius, penWidth, color, color );
336  }
337 }
338 
339 
341 {
342  int minX, minY, maxX, maxY, angleStart, angleEnd;
343  EDA_RECT rect;
344  wxPoint nullPoint, startPos, endPos, centerPos;
345  wxPoint normStart = m_ArcStart - m_Pos;
346  wxPoint normEnd = m_ArcEnd - m_Pos;
347 
348  if( ( normStart == nullPoint ) || ( normEnd == nullPoint ) || ( m_Radius == 0 ) )
349  return rect;
350 
354  angleStart = m_t1;
355  angleEnd = m_t2;
356 
357  if( DefaultTransform.MapAngles( &angleStart, &angleEnd ) )
358  {
359  std::swap( endPos.x, startPos.x );
360  std::swap( endPos.y, startPos.y );
361  }
362 
363  /* Start with the start and end point of the arc. */
364  minX = std::min( startPos.x, endPos.x );
365  minY = std::min( startPos.y, endPos.y );
366  maxX = std::max( startPos.x, endPos.x );
367  maxY = std::max( startPos.y, endPos.y );
368 
369  /* Zero degrees is a special case. */
370  if( angleStart == 0 )
371  maxX = centerPos.x + m_Radius;
372 
373  /* Arc end angle wrapped passed 360. */
374  if( angleStart > angleEnd )
375  angleEnd += 3600;
376 
377  if( angleStart <= 900 && angleEnd >= 900 ) /* 90 deg */
378  maxY = centerPos.y + m_Radius;
379 
380  if( angleStart <= 1800 && angleEnd >= 1800 ) /* 180 deg */
381  minX = centerPos.x - m_Radius;
382 
383  if( angleStart <= 2700 && angleEnd >= 2700 ) /* 270 deg */
384  minY = centerPos.y - m_Radius;
385 
386  if( angleStart <= 3600 && angleEnd >= 3600 ) /* 0 deg */
387  maxX = centerPos.x + m_Radius;
388 
389  rect.SetOrigin( minX, minY );
390  rect.SetEnd( maxX, maxY );
391  rect.Inflate( ( GetPenWidth() / 2 ) + 1 );
392 
393  return rect;
394 }
395 
396 
397 void LIB_ARC::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
398 {
399  wxString msg;
400  EDA_RECT bBox = GetBoundingBox();
401 
402  LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
403 
404  msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width );
405 
406  aList.emplace_back( _( "Line Width" ), msg );
407 
408  msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
409  bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
410 
411  aList.emplace_back( _( "Bounding Box" ), msg );
412 }
413 
414 
415 wxString LIB_ARC::GetSelectMenuText( EDA_UNITS aUnits ) const
416 {
417  return wxString::Format( _( "Arc, radius %s" ),
418  MessageTextFromValue( aUnits, m_Radius ) );
419 }
420 
421 
423 {
424  return BITMAPS::add_arc;
425 }
426 
427 
428 void LIB_ARC::BeginEdit( const wxPoint& aPosition )
429 {
430  m_ArcStart = m_ArcEnd = aPosition;
431  m_editState = 1;
432 }
433 
434 
435 void LIB_ARC::CalcEdit( const wxPoint& aPosition )
436 {
437 #define sq( x ) pow( x, 2 )
438 
439  // Edit state 0: drawing: place ArcStart
440  // Edit state 1: drawing: place ArcEnd (center calculated for 90-degree subtended angle)
441  // Edit state 2: point editing: move ArcStart (center calculated for invariant subtended angle)
442  // Edit state 3: point editing: move ArcEnd (center calculated for invariant subtended angle)
443  // Edit state 4: point editing: move center
444 
445  switch( m_editState )
446  {
447  case 0:
448  m_ArcStart = aPosition;
449  m_ArcEnd = aPosition;
450  m_Pos = aPosition;
451  m_Radius = 0;
452  m_t1 = 0;
453  m_t2 = 0;
454  return;
455 
456  case 1:
457  m_ArcEnd = aPosition;
458  m_Radius = KiROUND( sqrt( pow( GetLineLength( m_ArcStart, m_ArcEnd ), 2 ) / 2.0 ) );
459  break;
460 
461  case 2:
462  case 3:
463  {
464  wxPoint v = m_ArcStart - m_ArcEnd;
465  double chordBefore = sq( v.x ) + sq( v.y );
466 
467  if( m_editState == 2 )
468  m_ArcStart = aPosition;
469  else
470  m_ArcEnd = aPosition;
471 
472  v = m_ArcStart - m_ArcEnd;
473  double chordAfter = sq( v.x ) + sq( v.y );
474  double ratio = chordAfter / chordBefore;
475 
476  if( ratio > 0 )
477  {
478  m_Radius = int( sqrt( m_Radius * m_Radius * ratio ) ) + 1;
479  m_Radius = std::max( m_Radius, int( sqrt( chordAfter ) / 2 ) + 1 );
480  }
481 
482  break;
483  }
484 
485  case 4:
486  {
487  double chordA = GetLineLength( m_ArcStart, aPosition );
488  double chordB = GetLineLength( m_ArcEnd, aPosition );
489  m_Radius = int( ( chordA + chordB ) / 2.0 ) + 1;
490  break;
491  }
492  }
493 
494  // Calculate center based on start, end, and radius
495  //
496  // Let 'l' be the length of the chord and 'm' the middle point of the chord
497  double l = GetLineLength( m_ArcStart, m_ArcEnd );
498  wxPoint m = ( m_ArcStart + m_ArcEnd ) / 2;
499 
500  // Calculate 'd', the vector from the chord midpoint to the center
501  wxPoint d;
502  d.x = KiROUND( sqrt( sq( m_Radius ) - sq( l/2 ) ) * ( m_ArcStart.y - m_ArcEnd.y ) / l );
503  d.y = KiROUND( sqrt( sq( m_Radius ) - sq( l/2 ) ) * ( m_ArcEnd.x - m_ArcStart.x ) / l );
504 
505  wxPoint c1 = m + d;
506  wxPoint c2 = m - d;
507 
508  // Solution gives us 2 centers; we need to pick one:
509  switch( m_editState )
510  {
511  case 1:
512  {
513  // Keep center clockwise from chord while drawing
514  wxPoint chordVector = twoPointVector( m_ArcStart, m_ArcEnd );
515  double chordAngle = ArcTangente( chordVector.y, chordVector.x );
516  NORMALIZE_ANGLE_POS( chordAngle );
517 
518  wxPoint c1Test = c1;
519  RotatePoint( &c1Test, m_ArcStart, -chordAngle );
520 
521  m_Pos = c1Test.x > 0 ? c2 : c1;
522  }
523  break;
524 
525  case 2:
526  case 3:
527  // Pick the one closer to the old center
528  m_Pos = ( GetLineLength( c1, m_Pos ) < GetLineLength( c2, m_Pos ) ) ? c1 : c2;
529  break;
530 
531  case 4:
532  // Pick the one closer to the mouse position
533  m_Pos = ( GetLineLength( c1, aPosition ) < GetLineLength( c2, aPosition ) ) ? c1 : c2;
534  break;
535  }
536 
538 }
539 
540 
542 {
543  wxPoint centerStartVector = twoPointVector( m_Pos, m_ArcStart );
544  wxPoint centerEndVector = twoPointVector( m_Pos, m_ArcEnd );
545 
546  m_Radius = KiROUND( EuclideanNorm( centerStartVector ) );
547 
548  // Angles in Eeschema are still integers
549  m_t1 = KiROUND( ArcTangente( centerStartVector.y, centerStartVector.x ) );
550  m_t2 = KiROUND( ArcTangente( centerEndVector.y, centerEndVector.x ) );
551 
553  NORMALIZE_ANGLE_POS( m_t2 ); // angles = 0 .. 3600
554 
555  // Restrict angle to less than 180 to avoid PBS display mirror Trace because it is
556  // assumed that the arc is less than 180 deg to find orientation after rotate or mirror.
557  if( ( m_t2 - m_t1 ) > 1800 )
558  m_t2 -= 3600;
559  else if( ( m_t2 - m_t1 ) <= -1800 )
560  m_t2 += 3600;
561 
562  while( ( m_t2 - m_t1 ) >= 1800 )
563  {
564  m_t2--;
565  m_t1++;
566  }
567 
568  while( ( m_t1 - m_t2 ) >= 1800 )
569  {
570  m_t2++;
571  m_t1--;
572  }
573 
575 
576  if( !IsMoving() )
578 }
579 
580 
582 {
583  VECTOR2D midPoint;
584  double startAngle = static_cast<double>( m_t1 ) / 10.0;
585  double endAngle = static_cast<double>( m_t2 ) / 10.0;
586 
587  if( endAngle < startAngle )
588  endAngle -= 360.0;
589 
590  double midPointAngle = ( ( endAngle - startAngle ) / 2.0 ) + startAngle;
591  double x = cos( DEG2RAD( midPointAngle ) ) * m_Radius;
592  double y = sin( DEG2RAD( midPointAngle ) ) * m_Radius;
593 
594  midPoint.x = KiROUND( x ) + m_Pos.x;
595  midPoint.y = KiROUND( y ) + m_Pos.y;
596 
597  return midPoint;
598 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
int m_Radius
Definition: lib_arc.h:143
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_arc.cpp:235
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
static wxPoint twoPointVector(const wxPoint &startPoint, const wxPoint &endPoint)
Definition: lib_arc.cpp:41
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
int m_t1
Definition: lib_arc.h:144
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:223
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_arc.cpp:298
Implementation of conversion functions that require both schematic and board internal units.
int m_t2
Definition: lib_arc.h:145
bool IsMoving() const
Definition: eda_item.h:120
int color
Definition: DXF_plotter.cpp:60
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_arc.cpp:340
void BeginEdit(const wxPoint &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_arc.cpp:428
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) const override
Plot the draw item using the plot object.
Definition: lib_arc.cpp:257
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
bool IntersectsCircleEdge(const wxPoint &aCenter, const int aRadius, const int aWidth) const
Test for intersection between this rect and the edge (radius) of a circle.
Definition: eda_rect.cpp:331
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:541
EDA_RECT Common(const EDA_RECT &aRect) const
Return the area that is common with another rectangle.
Definition: eda_rect.cpp:489
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:165
LIB_ARC(LIB_SYMBOL *aParent)
Definition: lib_arc.cpp:47
VECTOR2I CalcMidPoint() const
Calculate the arc mid point using the arc start and end angles and radius length.
Definition: lib_arc.cpp:581
wxPoint m_ArcEnd
Definition: lib_arc.h:147
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:288
The base class for create windows for drawing purpose.
Define a library symbol object.
Definition: lib_symbol.h:96
FILL_TYPE m_fill
The body fill type.
Definition: lib_item.h:326
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_arc.cpp:206
const wxPoint GetEnd() const
Definition: eda_rect.h:103
FILL_TYPE GetFillMode() const
Definition: lib_item.h:265
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:81
wxPoint m_Pos
Definition: lib_arc.h:148
const wxPoint GetOrigin() const
Definition: eda_rect.h:101
void SetEnd(int x, int y)
Definition: eda_rect.h:182
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_arc.cpp:127
#define MINIMUM_SELECTION_DISTANCE
Definition: lib_item.h:47
bool m_isFillable
Definition: lib_item.h:327
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: lib_arc.cpp:59
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:168
int m_editState
Definition: lib_arc.h:150
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: lib_arc.cpp:397
#define STRUCT_DELETED
flag indication structures to be erased
#define _(s)
double CrossProduct(const wxPoint &vectorA, const wxPoint &vectorB)
Determine the cross product.
Definition: trigo.h:200
wxDC * GetPrintDC() const
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
void CalcEdit(const wxPoint &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_arc.cpp:435
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_item.cpp:50
void GRFilledArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:691
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:177
virtual void SetColor(const COLOR4D &color)=0
int GetRadius() const
Definition: lib_arc.h:84
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
EDA_UNITS
Definition: eda_units.h:38
Base plotter engine class.
Definition: plotter.h:121
int GetWidth() const override
Definition: lib_arc.h:80
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:156
TRANSFORM DefaultTransform
Definition: eeschema.cpp:56
#define SKIP_STRUCT
flag indicating that the structure should be ignored
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
double DEG2RAD(double deg)
Definition: trigo.h:231
int GetPenWidth() const override
Definition: lib_arc.cpp:288
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
Definition: trigo.h:186
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:160
Handle the component boundary box.
Definition: eda_rect.h:42
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_arc.cpp:422
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
int GetDefaultPenWidth() const
int compare(const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_arc.cpp:133
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: lib_arc.cpp:415
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:182
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:79
#define sq(x)
wxPoint m_ArcStart
Definition: lib_arc.h:146
Message panel definition file.
virtual int compare(const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_item.cpp:74
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
int m_Width
Definition: lib_arc.h:149
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
wxPoint GetPosition() const override
Definition: lib_arc.h:71
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
Definition: gr_basic.cpp:642
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103