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-2020 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 <fctsys.h>
27 #include <gr_basic.h>
28 #include <macros.h>
29 #include <sch_draw_panel.h>
30 #include <plotter.h>
31 #include <trigo.h>
32 #include <base_units.h>
33 #include <msgpanel.h>
34 #include <bitmaps.h>
35 #include <math/util.h> // for KiROUND
36 
37 #include <general.h>
38 #include <lib_arc.h>
39 #include <transform.h>
41 #include <status_popup.h>
42 
43 // Helper function
44 static inline wxPoint twoPointVector( const wxPoint &startPoint, const wxPoint &endPoint )
45 {
46  return endPoint - startPoint;
47 }
48 
49 
50 LIB_ARC::LIB_ARC( LIB_PART* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
51 {
52  m_Radius = 0;
53  m_t1 = 0;
54  m_t2 = 0;
55  m_Width = 0;
56  m_Fill = NO_FILL;
57  m_isFillable = true;
58  m_editState = 0;
59 }
60 
61 
62 bool LIB_ARC::HitTest( const wxPoint& aRefPoint, int aAccuracy ) const
63 {
64  int mindist = std::max( aAccuracy + GetPenSize() / 2,
65  Mils2iu( MINIMUM_SELECTION_DISTANCE ) );
66  wxPoint relativePosition = aRefPoint;
67 
68  relativePosition.y = -relativePosition.y; // reverse Y axis
69 
70  int distance = KiROUND( GetLineLength( m_Pos, relativePosition ) );
71 
72  if( abs( distance - m_Radius ) > mindist )
73  return false;
74 
75  // We are on the circle, ensure we are only on the arc, i.e. between
76  // m_ArcStart and m_ArcEnd
77 
78  wxPoint startEndVector = twoPointVector( m_ArcStart, m_ArcEnd );
79  wxPoint startRelativePositionVector = twoPointVector( m_ArcStart, relativePosition );
80 
81  wxPoint centerStartVector = twoPointVector( m_Pos, m_ArcStart );
82  wxPoint centerEndVector = twoPointVector( m_Pos, m_ArcEnd );
83  wxPoint centerRelativePositionVector = twoPointVector( m_Pos, relativePosition );
84 
85  // Compute the cross product to check if the point is in the sector
86  double crossProductStart = CrossProduct( centerStartVector, centerRelativePositionVector );
87  double crossProductEnd = CrossProduct( centerEndVector, centerRelativePositionVector );
88 
89  // The cross products need to be exchanged, depending on which side the center point
90  // relative to the start point to end point vector lies
91  if( CrossProduct( startEndVector, startRelativePositionVector ) < 0 )
92  {
93  std::swap( crossProductStart, crossProductEnd );
94  }
95 
96  // When the cross products have a different sign, the point lies in sector
97  // also check, if the reference is near start or end point
98  return HitTestPoints( m_ArcStart, relativePosition, MINIMUM_SELECTION_DISTANCE ) ||
99  HitTestPoints( m_ArcEnd, relativePosition, MINIMUM_SELECTION_DISTANCE ) ||
100  ( crossProductStart <= 0 && crossProductEnd >= 0 );
101 }
102 
103 
104 bool LIB_ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
105 {
106  if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
107  return false;
108 
110  int radius = GetRadius();
111  int lineWidth = GetWidth();
112  EDA_RECT sel = aRect ;
113 
114  if ( aAccuracy )
115  sel.Inflate( aAccuracy );
116 
117  if( aContained )
118  return sel.Contains( GetBoundingBox() );
119 
120  EDA_RECT arcRect = GetBoundingBox().Common( sel );
121 
122  /* All following tests must pass:
123  * 1. Rectangle must intersect arc BoundingBox
124  * 2. Rectangle must cross the outside of the arc
125  */
126  return arcRect.Intersects( sel ) && arcRect.IntersectsCircleEdge( center, radius, lineWidth );
127 }
128 
129 
131 {
132  return new LIB_ARC( *this );
133 }
134 
135 
136 int LIB_ARC::compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags ) const
137 {
138  wxASSERT( aOther.Type() == LIB_ARC_T );
139 
140  int retv = LIB_ITEM::compare( aOther );
141 
142  if( retv )
143  return retv;
144 
145  const LIB_ARC* tmp = ( LIB_ARC* ) &aOther;
146 
147  if( m_Pos.x != tmp->m_Pos.x )
148  return m_Pos.x - tmp->m_Pos.x;
149 
150  if( m_Pos.y != tmp->m_Pos.y )
151  return m_Pos.y - tmp->m_Pos.y;
152 
153  if( m_t1 != tmp->m_t1 )
154  return m_t1 - tmp->m_t1;
155 
156  if( m_t2 != tmp->m_t2 )
157  return m_t2 - tmp->m_t2;
158 
159  return 0;
160 }
161 
162 
163 void LIB_ARC::Offset( const wxPoint& aOffset )
164 {
165  m_Pos += aOffset;
166  m_ArcStart += aOffset;
167  m_ArcEnd += aOffset;
168 }
169 
170 
171 bool LIB_ARC::Inside( EDA_RECT& aRect ) const
172 {
173  return aRect.Contains( m_ArcStart.x, -m_ArcStart.y )
174  || aRect.Contains( m_ArcEnd.x, -m_ArcEnd.y );
175 }
176 
177 
178 void LIB_ARC::MoveTo( const wxPoint& aPosition )
179 {
180  wxPoint offset = aPosition - m_Pos;
181  m_Pos = aPosition;
182  m_ArcStart += offset;
183  m_ArcEnd += offset;
184 }
185 
186 
187 void LIB_ARC::MirrorHorizontal( const wxPoint& aCenter )
188 {
189  m_Pos.x -= aCenter.x;
190  m_Pos.x *= -1;
191  m_Pos.x += aCenter.x;
192  m_ArcStart.x -= aCenter.x;
193  m_ArcStart.x *= -1;
194  m_ArcStart.x += aCenter.x;
195  m_ArcEnd.x -= aCenter.x;
196  m_ArcEnd.x *= -1;
197  m_ArcEnd.x += aCenter.x;
198  std::swap( m_ArcStart, m_ArcEnd );
199  std::swap( m_t1, m_t2 );
200  m_t1 = 1800 - m_t1;
201  m_t2 = 1800 - m_t2;
202  if( m_t1 > 3600 || m_t2 > 3600 )
203  {
204  m_t1 -= 3600;
205  m_t2 -= 3600;
206  }
207  else if( m_t1 < -3600 || m_t2 < -3600 )
208  {
209  m_t1 += 3600;
210  m_t2 += 3600;
211  }
212 }
213 
214 void LIB_ARC::MirrorVertical( const wxPoint& aCenter )
215 {
216  m_Pos.y -= aCenter.y;
217  m_Pos.y *= -1;
218  m_Pos.y += aCenter.y;
219  m_ArcStart.y -= aCenter.y;
220  m_ArcStart.y *= -1;
221  m_ArcStart.y += aCenter.y;
222  m_ArcEnd.y -= aCenter.y;
223  m_ArcEnd.y *= -1;
224  m_ArcEnd.y += aCenter.y;
225  std::swap( m_ArcStart, m_ArcEnd );
226  std::swap( m_t1, m_t2 );
227  m_t1 = - m_t1;
228  m_t2 = - m_t2;
229  if( m_t1 > 3600 || m_t2 > 3600 )
230  {
231  m_t1 -= 3600;
232  m_t2 -= 3600;
233  }
234  else if( m_t1 < -3600 || m_t2 < -3600 )
235  {
236  m_t1 += 3600;
237  m_t2 += 3600;
238  }
239 }
240 
241 void LIB_ARC::Rotate( const wxPoint& aCenter, bool aRotateCCW )
242 {
243  int rot_angle = aRotateCCW ? -900 : 900;
244  RotatePoint( &m_Pos, aCenter, rot_angle );
245  RotatePoint( &m_ArcStart, aCenter, rot_angle );
246  RotatePoint( &m_ArcEnd, aCenter, rot_angle );
247  m_t1 -= rot_angle;
248  m_t2 -= rot_angle;
249  if( m_t1 > 3600 || m_t2 > 3600 )
250  {
251  m_t1 -= 3600;
252  m_t2 -= 3600;
253  }
254  else if( m_t1 < -3600 || m_t2 < -3600 )
255  {
256  m_t1 += 3600;
257  m_t2 += 3600;
258  }
259 }
260 
261 
262 
263 void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
264  const TRANSFORM& aTransform )
265 {
266  wxASSERT( aPlotter != NULL );
267 
268  int t1 = m_t1;
269  int t2 = m_t2;
270  wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + aOffset;
271 
272  aTransform.MapAngles( &t1, &t2 );
273 
274  if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
275  {
276  aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE_BACKGROUND ) );
277  aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_WITH_BG_BODYCOLOR, 0 );
278  }
279 
280  bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
281  auto pen_size = GetPenSize();
282 
283  if( !already_filled || pen_size > 0 )
284  {
285  pen_size = std::max( 0, pen_size );
286  aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE ) );
287  aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, pen_size );
288  }
289 }
290 
291 
293 {
294  if( m_Width > 0 )
295  return m_Width;
296 
297  if( m_Width == 0 )
298  return GetDefaultLineThickness();
299 
300  return -1; // a value to use a minimal pen size
301 }
302 
303 
304 void LIB_ARC::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform )
305 {
306  wxPoint pos1, pos2, posc;
309 
310  pos1 = aTransform.TransformCoordinate( m_ArcEnd ) + aOffset;
311  pos2 = aTransform.TransformCoordinate( m_ArcStart ) + aOffset;
312  posc = aTransform.TransformCoordinate( m_Pos ) + aOffset;
313  int pt1 = m_t1;
314  int pt2 = m_t2;
315  bool swap = aTransform.MapAngles( &pt1, &pt2 );
316 
317  if( swap )
318  {
319  std::swap( pos1.x, pos2.x );
320  std::swap( pos1.y, pos2.y );
321  }
322 
323  FILL_T fill = aData ? NO_FILL : m_Fill;
324 
325  int penSize = GetPenSize();
326 
327  if( fill == FILLED_WITH_BG_BODYCOLOR )
328  GRFilledArc( nullptr, aDC, posc.x, posc.y, pt1, pt2, m_Radius, penSize, bgColor, bgColor );
329  else if( fill == FILLED_SHAPE && !aData )
330  GRFilledArc( nullptr, aDC, posc.x, posc.y, pt1, pt2, m_Radius, color, color );
331  else
332  GRArc1( nullptr, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, penSize, color );
333 }
334 
335 
337 {
338  int minX, minY, maxX, maxY, angleStart, angleEnd;
339  EDA_RECT rect;
340  wxPoint nullPoint, startPos, endPos, centerPos;
341  wxPoint normStart = m_ArcStart - m_Pos;
342  wxPoint normEnd = m_ArcEnd - m_Pos;
343 
344  if( ( normStart == nullPoint ) || ( normEnd == nullPoint ) || ( m_Radius == 0 ) )
345  {
346  wxLogDebug( wxT("Invalid arc drawing definition, center(%d, %d), start(%d, %d), "
347  "end(%d, %d), radius %d" ),
349  m_ArcEnd.y, m_Radius );
350  return rect;
351  }
352 
356  angleStart = m_t1;
357  angleEnd = m_t2;
358 
359  if( DefaultTransform.MapAngles( &angleStart, &angleEnd ) )
360  {
361  std::swap( endPos.x, startPos.x );
362  std::swap( endPos.y, startPos.y );
363  }
364 
365  /* Start with the start and end point of the arc. */
366  minX = std::min( startPos.x, endPos.x );
367  minY = std::min( startPos.y, endPos.y );
368  maxX = std::max( startPos.x, endPos.x );
369  maxY = std::max( startPos.y, endPos.y );
370 
371  /* Zero degrees is a special case. */
372  if( angleStart == 0 )
373  maxX = centerPos.x + m_Radius;
374 
375  /* Arc end angle wrapped passed 360. */
376  if( angleStart > angleEnd )
377  angleEnd += 3600;
378 
379  if( angleStart <= 900 && angleEnd >= 900 ) /* 90 deg */
380  maxY = centerPos.y + m_Radius;
381 
382  if( angleStart <= 1800 && angleEnd >= 1800 ) /* 180 deg */
383  minX = centerPos.x - m_Radius;
384 
385  if( angleStart <= 2700 && angleEnd >= 2700 ) /* 270 deg */
386  minY = centerPos.y - m_Radius;
387 
388  if( angleStart <= 3600 && angleEnd >= 3600 ) /* 0 deg */
389  maxX = centerPos.x + m_Radius;
390 
391  rect.SetOrigin( minX, minY );
392  rect.SetEnd( maxX, maxY );
393  rect.Inflate( ( GetPenSize()+1 ) / 2 );
394 
395  return rect;
396 }
397 
398 
399 void LIB_ARC::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
400 {
401  wxString msg;
402  EDA_RECT bBox = GetBoundingBox();
403 
404  LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
405 
406  msg = MessageTextFromValue( aUnits, m_Width, true );
407 
408  aList.emplace_back( _( "Line Width" ), msg, BLUE );
409 
410  msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
411  bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
412 
413  aList.emplace_back( _( "Bounding Box" ), msg, BROWN );
414 }
415 
416 
417 wxString LIB_ARC::GetSelectMenuText( EDA_UNITS aUnits ) const
418 {
419  return wxString::Format( _( "Arc center (%s, %s), radius %s" ),
420  MessageTextFromValue( aUnits, m_Pos.x ),
421  MessageTextFromValue( aUnits, m_Pos.y ),
422  MessageTextFromValue( aUnits, m_Radius ) );
423 }
424 
425 
427 {
428  return add_arc_xpm;
429 }
430 
431 
432 void LIB_ARC::BeginEdit( const wxPoint aPosition )
433 {
434  m_ArcStart = m_ArcEnd = aPosition;
435  m_editState = 1;
436 }
437 
438 
439 void LIB_ARC::CalcEdit( const wxPoint& aPosition )
440 {
441 #define sq( x ) pow( x, 2 )
442 
443  // Edit state 0: drawing: place ArcStart
444  // Edit state 1: drawing: place ArcEnd (center calculated for 90-degree subtended angle)
445  // Edit state 2: point editing: move ArcStart (center calculated for invariant subtended angle)
446  // Edit state 3: point editing: move ArcEnd (center calculated for invariant subtended angle)
447  // Edit state 4: point editing: move center
448 
449  switch( m_editState )
450  {
451  case 0:
452  m_ArcStart = aPosition;
453  m_ArcEnd = aPosition;
454  m_Pos = aPosition;
455  m_Radius = 0;
456  m_t1 = 0;
457  m_t2 = 0;
458  return;
459 
460  case 1:
461  m_ArcEnd = aPosition;
462  m_Radius = KiROUND( sqrt( pow( GetLineLength( m_ArcStart, m_ArcEnd ), 2 ) / 2.0 ) );
463  break;
464 
465  case 2:
466  case 3:
467  {
469  double chordBefore = sq( v.x ) + sq( v.y );
470 
471  if( m_editState == 2 )
472  m_ArcStart = aPosition;
473  else
474  m_ArcEnd = aPosition;
475 
476  v = m_ArcStart - m_ArcEnd;
477  double chordAfter = sq( v.x ) + sq( v.y );
478  double ratio = chordAfter / chordBefore;
479 
480  if( ratio > 0 )
481  {
482  m_Radius = int( sqrt( m_Radius * m_Radius * ratio ) ) + 1;
483  m_Radius = std::max( m_Radius, int( sqrt( chordAfter ) / 2 ) + 1 );
484  }
485 
486  break;
487  }
488 
489  case 4:
490  {
491  double chordA = GetLineLength( m_ArcStart, aPosition );
492  double chordB = GetLineLength( m_ArcEnd, aPosition );
493  m_Radius = int( ( chordA + chordB ) / 2.0 ) + 1;
494  break;
495  }
496  }
497 
498  // Calculate center based on start, end, and radius
499  //
500  // Let 'l' be the length of the chord and 'm' the middle point of the chord
501  double l = GetLineLength( m_ArcStart, m_ArcEnd );
502  wxPoint m = ( m_ArcStart + m_ArcEnd ) / 2;
503 
504  // Calculate 'd', the vector from the chord midpoint to the center
505  wxPoint d;
506  d.x = KiROUND( sqrt( sq( m_Radius ) - sq( l/2 ) ) * ( m_ArcStart.y - m_ArcEnd.y ) / l );
507  d.y = KiROUND( sqrt( sq( m_Radius ) - sq( l/2 ) ) * ( m_ArcEnd.x - m_ArcStart.x ) / l );
508 
509  wxPoint c1 = m + d;
510  wxPoint c2 = m - d;
511 
512  // Solution gives us 2 centers; we need to pick one:
513  switch( m_editState )
514  {
515  case 1:
516  {
517  // Keep center clockwise from chord while drawing
518  wxPoint chordVector = twoPointVector( m_ArcStart, m_ArcEnd );
519  double chordAngle = ArcTangente( chordVector.y, chordVector.x );
520  NORMALIZE_ANGLE_POS( chordAngle );
521 
522  wxPoint c1Test = c1;
523  RotatePoint( &c1Test, m_ArcStart, -chordAngle );
524 
525  m_Pos = c1Test.x > 0 ? c2 : c1;
526  }
527  break;
528 
529  case 2:
530  case 3:
531  // Pick the one closer to the old center
532  m_Pos = ( GetLineLength( c1, m_Pos ) < GetLineLength( c2, m_Pos ) ) ? c1 : c2;
533  break;
534 
535  case 4:
536  // Pick the one closer to the mouse position
537  m_Pos = ( GetLineLength( c1, aPosition ) < GetLineLength( c2, aPosition ) ) ? c1 : c2;
538  break;
539  }
540 
542 }
543 
544 
546 {
547  wxPoint centerStartVector = twoPointVector( m_Pos, m_ArcStart );
548  wxPoint centerEndVector = twoPointVector( m_Pos, m_ArcEnd );
549 
550  m_Radius = KiROUND( EuclideanNorm( centerStartVector ) );
551 
552  // Angles in eeschema are still integers
553  m_t1 = KiROUND( ArcTangente( centerStartVector.y, centerStartVector.x ) );
554  m_t2 = KiROUND( ArcTangente( centerEndVector.y, centerEndVector.x ) );
555 
557  NORMALIZE_ANGLE_POS( m_t2 ); // angles = 0 .. 3600
558 
559  // Restrict angle to less than 180 to avoid PBS display mirror Trace because it is
560  // assumed that the arc is less than 180 deg to find orientation after rotate or mirror.
561  if( (m_t2 - m_t1) > 1800 )
562  m_t2 -= 3600;
563  else if( (m_t2 - m_t1) <= -1800 )
564  m_t2 += 3600;
565 
566  while( (m_t2 - m_t1) >= 1800 )
567  {
568  m_t2--;
569  m_t1++;
570  }
571 
572  while( (m_t1 - m_t2) >= 1800 )
573  {
574  m_t2++;
575  m_t1--;
576  }
577 
579 
580  if( !IsMoving() )
582 }
583 
584 
586 {
587  VECTOR2D midPoint;
588  double startAngle = static_cast<double>( m_t1 ) / 10.0;
589  double endAngle = static_cast<double>( m_t2 ) / 10.0;
590 
591  if( endAngle < startAngle )
592  endAngle -= 360.0;
593 
594  double midPointAngle = ( ( endAngle - startAngle ) / 2.0 ) + startAngle;
595  double x = cos( DEG2RAD( midPointAngle ) ) * m_Radius;
596  double y = sin( DEG2RAD( midPointAngle ) ) * m_Radius;
597 
598  midPoint.x = KiROUND( x ) + m_Pos.x;
599  midPoint.y = KiROUND( y ) + m_Pos.y;
600 
601  return midPoint;
602 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
Definition: colors.h:57
int m_Radius
Definition: lib_arc.h:44
EDA_UNITS
Definition: common.h:184
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_arc.cpp:241
static wxPoint twoPointVector(const wxPoint &startPoint, const wxPoint &endPoint)
Definition: lib_arc.cpp:44
int m_t1
Definition: lib_arc.h:45
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_arc.cpp:263
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:206
PNG memory record (file in memory).
Definition: bitmap_def.h:29
void GetMsgPanelInfo(EDA_UNITS aUnits, 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:52
Implementation of conversion functions that require both schematic and board internal units.
virtual void SetColor(COLOR4D color)=0
int m_t2
Definition: lib_arc.h:46
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:131
bool IsMoving() const
Definition: base_struct.h:222
int color
Definition: DXF_plotter.cpp:61
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_arc.cpp:336
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
TRANSFORM DefaultTransform
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
bool IntersectsCircleEdge(const wxPoint &aCenter, const int aRadius, const int aWidth) const
IntersectsCircleEdge Tests for intersection between this rect and the edge (radius) of a circle.
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:545
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: lib_arc.cpp:399
EDA_RECT Common(const EDA_RECT &aRect) const
Function Common returns the area that is common with another rectangle.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_arc.cpp:426
VECTOR2I CalcMidPoint() const
Calculate the arc mid point using the arc start and end angles and radius length.
Definition: lib_arc.cpp:585
wxPoint m_ArcEnd
Definition: lib_arc.h:48
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
bool Contains(const wxPoint &aPoint) const
Function Contains.
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 components.
Definition: lib_item.h:60
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_arc.cpp:214
This file contains miscellaneous commonly used macros and functions.
const wxPoint GetEnd() const
Definition: eda_rect.h:116
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
#define NULL
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
Definition: lib_arc.cpp:171
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:116
COLOR_SETTINGS * ColorSettings()
Definition: plotter.h:145
wxPoint m_Pos
Definition: lib_arc.h:49
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
void SetEnd(int x, int y)
Definition: eda_rect.h:192
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_arc.cpp:130
#define MINIMUM_SELECTION_DISTANCE
Definition: lib_item.h:46
bool m_isFillable
Definition: lib_item.h:94
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: lib_arc.cpp:62
Define a library symbol object.
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:178
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper for all the old plotting/printing code while it still exists.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:129
int m_editState
Definition: lib_arc.h:51
double CrossProduct(const wxPoint &vectorA, const wxPoint &vectorB)
Determine the cross product.
Definition: trigo.h:182
int GetPenSize() const override
Definition: lib_arc.cpp:292
const BITMAP_OPAQUE add_arc_xpm[1]
Definition: add_arc.cpp:37
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_arc.cpp:439
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:689
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:187
int GetRadius() const
Definition: lib_arc.h:105
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aUseMils, EDA_DATA_TYPE aType)
Definition: base_units.cpp:127
Base plotter engine class.
Definition: plotter.h:104
COLOR4D GetColor(int aLayer) const
int GetWidth() const override
Definition: lib_arc.h:101
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
double DEG2RAD(double deg)
Definition: trigo.h:214
#define _(s)
Definition: 3d_actions.cpp:33
FILL_T m_Fill
The body fill type.
Definition: lib_item.h:93
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:50
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
Definition: trigo.h:166
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:163
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
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:61
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
void print(wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_arc.cpp:304
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:157
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:42
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:136
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_arc.cpp:417
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:81
#define sq(x)
wxPoint m_ArcStart
Definition: lib_arc.h:47
Message panel definition file.
void BeginEdit(const wxPoint aStartPoint) override
Begin drawing a component library draw item at aPosition.
Definition: lib_arc.cpp:432
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:76
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
int m_Width
Definition: lib_arc.h:50
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
wxPoint GetPosition() const override
Definition: lib_arc.h:92
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:640
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
Definition: colors.h:62