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-2019 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 
36 #include <general.h>
37 #include <lib_arc.h>
38 #include <transform.h>
39 #include <status_popup.h>
40 
41 // Helper function
42 static inline wxPoint twoPointVector( const wxPoint &startPoint, const wxPoint &endPoint )
43 {
44  return endPoint - startPoint;
45 }
46 
47 
48 LIB_ARC::LIB_ARC( LIB_PART* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
49 {
50  m_Radius = 0;
51  m_t1 = 0;
52  m_t2 = 0;
53  m_Width = 0;
54  m_Fill = NO_FILL;
55  m_isFillable = true;
56  m_editState = 0;
57 }
58 
59 
60 bool LIB_ARC::HitTest( const wxPoint& aRefPoint, int aAccuracy ) const
61 {
62  int mindist = std::max( aAccuracy + GetPenSize() / 2, 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 ) const
134 {
135  wxASSERT( aOther.Type() == LIB_ARC_T );
136 
137  const LIB_ARC* tmp = ( LIB_ARC* ) &aOther;
138 
139  if( m_Pos.x != tmp->m_Pos.x )
140  return m_Pos.x - tmp->m_Pos.x;
141 
142  if( m_Pos.y != tmp->m_Pos.y )
143  return m_Pos.y - tmp->m_Pos.y;
144 
145  if( m_t1 != tmp->m_t1 )
146  return m_t1 - tmp->m_t1;
147 
148  if( m_t2 != tmp->m_t2 )
149  return m_t2 - tmp->m_t2;
150 
151  return 0;
152 }
153 
154 
155 void LIB_ARC::Offset( const wxPoint& aOffset )
156 {
157  m_Pos += aOffset;
158  m_ArcStart += aOffset;
159  m_ArcEnd += aOffset;
160 }
161 
162 
163 bool LIB_ARC::Inside( EDA_RECT& aRect ) const
164 {
165  return aRect.Contains( m_ArcStart.x, -m_ArcStart.y )
166  || aRect.Contains( m_ArcEnd.x, -m_ArcEnd.y );
167 }
168 
169 
170 void LIB_ARC::MoveTo( const wxPoint& aPosition )
171 {
172  wxPoint offset = aPosition - m_Pos;
173  m_Pos = aPosition;
174  m_ArcStart += offset;
175  m_ArcEnd += offset;
176 }
177 
178 
179 void LIB_ARC::MirrorHorizontal( const wxPoint& aCenter )
180 {
181  m_Pos.x -= aCenter.x;
182  m_Pos.x *= -1;
183  m_Pos.x += aCenter.x;
184  m_ArcStart.x -= aCenter.x;
185  m_ArcStart.x *= -1;
186  m_ArcStart.x += aCenter.x;
187  m_ArcEnd.x -= aCenter.x;
188  m_ArcEnd.x *= -1;
189  m_ArcEnd.x += aCenter.x;
190  std::swap( m_ArcStart, m_ArcEnd );
191  std::swap( m_t1, m_t2 );
192  m_t1 = 1800 - m_t1;
193  m_t2 = 1800 - m_t2;
194  if( m_t1 > 3600 || m_t2 > 3600 )
195  {
196  m_t1 -= 3600;
197  m_t2 -= 3600;
198  }
199  else if( m_t1 < -3600 || m_t2 < -3600 )
200  {
201  m_t1 += 3600;
202  m_t2 += 3600;
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  if( m_t1 > 3600 || m_t2 > 3600 )
222  {
223  m_t1 -= 3600;
224  m_t2 -= 3600;
225  }
226  else if( m_t1 < -3600 || m_t2 < -3600 )
227  {
228  m_t1 += 3600;
229  m_t2 += 3600;
230  }
231 }
232 
233 void LIB_ARC::Rotate( const wxPoint& aCenter, bool aRotateCCW )
234 {
235  int rot_angle = aRotateCCW ? -900 : 900;
236  RotatePoint( &m_Pos, aCenter, rot_angle );
237  RotatePoint( &m_ArcStart, aCenter, rot_angle );
238  RotatePoint( &m_ArcEnd, aCenter, rot_angle );
239  m_t1 -= rot_angle;
240  m_t2 -= rot_angle;
241  if( m_t1 > 3600 || m_t2 > 3600 )
242  {
243  m_t1 -= 3600;
244  m_t2 -= 3600;
245  }
246  else if( m_t1 < -3600 || m_t2 < -3600 )
247  {
248  m_t1 += 3600;
249  m_t2 += 3600;
250  }
251 }
252 
253 
254 
255 void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
256  const TRANSFORM& aTransform )
257 {
258  wxASSERT( aPlotter != NULL );
259 
260  int t1 = m_t1;
261  int t2 = m_t2;
262  wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + aOffset;
263 
264  aTransform.MapAngles( &t1, &t2 );
265 
266  if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
267  {
269  aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_WITH_BG_BODYCOLOR, 0 );
270  }
271 
272  bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
273  auto pen_size = GetPenSize();
274 
275  if( !already_filled || pen_size > 0 )
276  {
277  pen_size = std::max( 0, pen_size );
278  aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
279  aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, pen_size );
280  }
281 }
282 
283 
285 {
286  if( m_Width > 0 )
287  return m_Width;
288 
289  if( m_Width == 0 )
290  return GetDefaultLineThickness();
291 
292  return -1; // a value to use a minimal pen size
293 }
294 
295 
296 void LIB_ARC::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform )
297 {
298  wxPoint pos1, pos2, posc;
301 
302  pos1 = aTransform.TransformCoordinate( m_ArcEnd ) + aOffset;
303  pos2 = aTransform.TransformCoordinate( m_ArcStart ) + aOffset;
304  posc = aTransform.TransformCoordinate( m_Pos ) + aOffset;
305  int pt1 = m_t1;
306  int pt2 = m_t2;
307  bool swap = aTransform.MapAngles( &pt1, &pt2 );
308 
309  if( swap )
310  {
311  std::swap( pos1.x, pos2.x );
312  std::swap( pos1.y, pos2.y );
313  }
314 
315  FILL_T fill = aData ? NO_FILL : m_Fill;
316 
317  int penSize = GetPenSize();
318 
319  if( fill == FILLED_WITH_BG_BODYCOLOR )
320  GRFilledArc( nullptr, aDC, posc.x, posc.y, pt1, pt2, m_Radius, penSize, bgColor, bgColor );
321  else if( fill == FILLED_SHAPE && !aData )
322  GRFilledArc( nullptr, aDC, posc.x, posc.y, pt1, pt2, m_Radius, color, color );
323  else
324  GRArc1( nullptr, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, penSize, color );
325 }
326 
327 
329 {
330  int minX, minY, maxX, maxY, angleStart, angleEnd;
331  EDA_RECT rect;
332  wxPoint nullPoint, startPos, endPos, centerPos;
333  wxPoint normStart = m_ArcStart - m_Pos;
334  wxPoint normEnd = m_ArcEnd - m_Pos;
335 
336  if( ( normStart == nullPoint ) || ( normEnd == nullPoint ) || ( m_Radius == 0 ) )
337  {
338  wxLogDebug( wxT("Invalid arc drawing definition, center(%d, %d), start(%d, %d), "
339  "end(%d, %d), radius %d" ),
340  m_Pos.x, m_Pos.y, m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x,
341  m_ArcEnd.y, m_Radius );
342  return rect;
343  }
344 
348  angleStart = m_t1;
349  angleEnd = m_t2;
350 
351  if( DefaultTransform.MapAngles( &angleStart, &angleEnd ) )
352  {
353  std::swap( endPos.x, startPos.x );
354  std::swap( endPos.y, startPos.y );
355  }
356 
357  /* Start with the start and end point of the arc. */
358  minX = std::min( startPos.x, endPos.x );
359  minY = std::min( startPos.y, endPos.y );
360  maxX = std::max( startPos.x, endPos.x );
361  maxY = std::max( startPos.y, endPos.y );
362 
363  /* Zero degrees is a special case. */
364  if( angleStart == 0 )
365  maxX = centerPos.x + m_Radius;
366 
367  /* Arc end angle wrapped passed 360. */
368  if( angleStart > angleEnd )
369  angleEnd += 3600;
370 
371  if( angleStart <= 900 && angleEnd >= 900 ) /* 90 deg */
372  maxY = centerPos.y + m_Radius;
373 
374  if( angleStart <= 1800 && angleEnd >= 1800 ) /* 180 deg */
375  minX = centerPos.x - m_Radius;
376 
377  if( angleStart <= 2700 && angleEnd >= 2700 ) /* 270 deg */
378  minY = centerPos.y - m_Radius;
379 
380  if( angleStart <= 3600 && angleEnd >= 3600 ) /* 0 deg */
381  maxX = centerPos.x + m_Radius;
382 
383  rect.SetOrigin( minX, minY );
384  rect.SetEnd( maxX, maxY );
385  rect.Inflate( ( GetPenSize()+1 ) / 2 );
386 
387  return rect;
388 }
389 
390 
391 void LIB_ARC::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
392 {
393  wxString msg;
394  EDA_RECT bBox = GetBoundingBox();
395 
396  LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
397 
398  msg = MessageTextFromValue( aUnits, m_Width, true );
399 
400  aList.emplace_back( _( "Line Width" ), msg, BLUE );
401 
402  msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
403  bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
404 
405  aList.emplace_back( _( "Bounding Box" ), msg, BROWN );
406 }
407 
408 
409 wxString LIB_ARC::GetSelectMenuText( EDA_UNITS_T aUnits ) const
410 {
411  return wxString::Format( _( "Arc center (%s, %s), radius %s" ),
412  MessageTextFromValue( aUnits, m_Pos.x ),
413  MessageTextFromValue( aUnits, m_Pos.y ),
414  MessageTextFromValue( aUnits, m_Radius ) );
415 }
416 
417 
418 BITMAP_DEF LIB_ARC::GetMenuImage() const
419 {
420  return add_arc_xpm;
421 }
422 
423 
424 void LIB_ARC::BeginEdit( const wxPoint aPosition )
425 {
426  m_ArcStart = m_ArcEnd = aPosition;
427  m_editState = 1;
428 }
429 
430 
431 void LIB_ARC::CalcEdit( const wxPoint& aPosition )
432 {
433 #define sq( x ) pow( x, 2 )
434 
435  // Edit state 0: drawing: place ArcStart
436  // Edit state 1: drawing: place ArcEnd (center calculated for 90-degree subtended angle)
437  // Edit state 2: point editing: move ArcStart (center calculated for invariant subtended angle)
438  // Edit state 3: point editing: move ArcEnd (center calculated for invariant subtended angle)
439  // Edit state 4: point editing: move center
440 
441  switch( m_editState )
442  {
443  case 0:
444  m_ArcStart = aPosition;
445  m_ArcEnd = aPosition;
446  m_Pos = aPosition;
447  m_Radius = 0;
448  m_t1 = 0;
449  m_t2 = 0;
450  return;
451 
452  case 1:
453  m_ArcEnd = aPosition;
454  m_Radius = KiROUND( sqrt( pow( GetLineLength( m_ArcStart, m_ArcEnd ), 2 ) / 2.0 ) );
455  break;
456 
457  case 2:
458  case 3:
459  {
460  wxPoint v = m_ArcStart - m_ArcEnd;
461  double chordBefore = sq( v.x ) + sq( v.y );
462 
463  if( m_editState == 2 )
464  m_ArcStart = aPosition;
465  else
466  m_ArcEnd = aPosition;
467 
468  v = m_ArcStart - m_ArcEnd;
469  double chordAfter = sq( v.x ) + sq( v.y );
470  double ratio = chordAfter / chordBefore;
471 
472  if( ratio > 0 )
473  {
474  m_Radius = int( sqrt( m_Radius * m_Radius * ratio ) ) + 1;
475  m_Radius = std::max( m_Radius, int( sqrt( chordAfter ) / 2 ) + 1 );
476  }
477 
478  break;
479  }
480 
481  case 4:
482  {
483  double chordA = GetLineLength( m_ArcStart, aPosition );
484  double chordB = GetLineLength( m_ArcEnd, aPosition );
485  m_Radius = int( ( chordA + chordB ) / 2.0 ) + 1;
486  break;
487  }
488  }
489 
490  // Calculate center based on start, end, and radius
491  //
492  // Let 'l' be the length of the chord and 'm' the middle point of the chord
493  double l = GetLineLength( m_ArcStart, m_ArcEnd );
494  wxPoint m = ( m_ArcStart + m_ArcEnd ) / 2;
495 
496  // Calculate 'd', the vector from the chord midpoint to the center
497  wxPoint d;
498  d.x = KiROUND( sqrt( sq( m_Radius ) - sq( l/2 ) ) * ( m_ArcStart.y - m_ArcEnd.y ) / l );
499  d.y = KiROUND( sqrt( sq( m_Radius ) - sq( l/2 ) ) * ( m_ArcEnd.x - m_ArcStart.x ) / l );
500 
501  wxPoint c1 = m + d;
502  wxPoint c2 = m - d;
503 
504  // Solution gives us 2 centers; we need to pick one:
505  switch( m_editState )
506  {
507  case 1:
508  {
509  // Keep center clockwise from chord while drawing
510  wxPoint chordVector = twoPointVector( m_ArcStart, m_ArcEnd );
511  double chordAngle = ArcTangente( chordVector.y, chordVector.x );
512  NORMALIZE_ANGLE_POS( chordAngle );
513 
514  wxPoint c1Test = c1;
515  RotatePoint( &c1Test, m_ArcStart, -chordAngle );
516 
517  m_Pos = c1Test.x > 0 ? c2 : c1;
518  }
519  break;
520 
521  case 2:
522  case 3:
523  // Pick the one closer to the old center
524  m_Pos = ( GetLineLength( c1, m_Pos ) < GetLineLength( c2, m_Pos ) ) ? c1 : c2;
525  break;
526 
527  case 4:
528  // Pick the one closer to the mouse position
529  m_Pos = ( GetLineLength( c1, aPosition ) < GetLineLength( c2, aPosition ) ) ? c1 : c2;
530  break;
531  }
532 
534 }
535 
536 
538 {
539  wxPoint centerStartVector = twoPointVector( m_Pos, m_ArcStart );
540  wxPoint centerEndVector = twoPointVector( m_Pos, m_ArcEnd );
541 
542  m_Radius = KiROUND( EuclideanNorm( centerStartVector ) );
543 
544  // Angles in eeschema are still integers
545  m_t1 = KiROUND( ArcTangente( centerStartVector.y, centerStartVector.x ) );
546  m_t2 = KiROUND( ArcTangente( centerEndVector.y, centerEndVector.x ) );
547 
549  NORMALIZE_ANGLE_POS( m_t2 ); // angles = 0 .. 3600
550 
551  // Restrict angle to less than 180 to avoid PBS display mirror Trace because it is
552  // assumed that the arc is less than 180 deg to find orientation after rotate or mirror.
553  if( (m_t2 - m_t1) > 1800 )
554  m_t2 -= 3600;
555  else if( (m_t2 - m_t1) <= -1800 )
556  m_t2 += 3600;
557 
558  while( (m_t2 - m_t1) >= 1800 )
559  {
560  m_t2--;
561  m_t1++;
562  }
563 
564  while( (m_t1 - m_t2) >= 1800 )
565  {
566  m_t2++;
567  m_t1--;
568  }
569 
571 
572  if( !IsMoving() )
574 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:123
Definition: colors.h:57
int m_Radius
Definition: lib_arc.h:44
void GetMsgPanelInfo(EDA_UNITS_T 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
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_arc.cpp:233
static wxPoint twoPointVector(const wxPoint &startPoint, const wxPoint &endPoint)
Definition: lib_arc.cpp:42
void GetMsgPanelInfo(EDA_UNITS_T 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:391
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:255
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Function GetLineLength returns the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:202
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:230
int color
Definition: DXF_plotter.cpp:62
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_arc.cpp:328
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
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:537
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:418
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206
wxPoint m_ArcEnd
Definition: lib_arc.h:48
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:252
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
#define abs(a)
Definition: auxiliary.h:84
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:41
The base class for drawable items used by schematic library components.
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
This file contains miscellaneous commonly used macros and functions.
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
const wxPoint GetEnd() const
Definition: eda_rect.h:116
Class for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
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:163
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:160
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:127
#define MINIMUM_SELECTION_DISTANCE
Definition: lib_item.h:47
bool m_isFillable
Definition: lib_item.h:95
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:60
Define a library symbol object.
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:170
#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:177
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_arc.cpp:133
int GetPenSize() const override
Definition: lib_arc.cpp:284
#define _(s)
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_arc.cpp:431
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:688
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:179
int GetRadius() const
Definition: lib_arc.h:105
Base plotter engine class.
Definition: plotter.h:97
int GetWidth() const override
Definition: lib_arc.h:101
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_arc.cpp:409
TRANSFORM DefaultTransform
Definition: eeschema.cpp:50
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
#define max(a, b)
Definition: auxiliary.h:86
FILL_T m_Fill
The body fill type.
Definition: lib_item.h:94
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:48
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
Definition: trigo.h:161
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:187
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:155
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
void print(wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_arc.cpp:296
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:156
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:42
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:80
#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:424
EDA_UNITS_T
Definition: common.h:133
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:210
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
#define min(a, b)
Definition: auxiliary.h:85
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:639
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62