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  *
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 
29 #include <fctsys.h>
30 #include <gr_basic.h>
31 #include <macros.h>
32 #include <sch_draw_panel.h>
33 #include <plotter.h>
34 #include <trigo.h>
35 #include <base_units.h>
36 #include <msgpanel.h>
37 #include <bitmaps.h>
38 
39 #include <general.h>
40 #include <lib_arc.h>
41 #include <transform.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  m_lastEditState = 0;
62  m_editDirection = 0;
63 }
64 
65 
66 bool LIB_ARC::HitTest( const wxPoint& aRefPoint, int aAccuracy ) const
67 {
68  int mindist = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE );
69  wxPoint relativePosition = aRefPoint;
70 
71  relativePosition.y = -relativePosition.y; // reverse Y axis
72 
73  int distance = KiROUND( GetLineLength( m_Pos, relativePosition ) );
74 
75  if( abs( distance - m_Radius ) > mindist )
76  return false;
77 
78  // We are on the circle, ensure we are only on the arc, i.e. between
79  // m_ArcStart and m_ArcEnd
80 
81  wxPoint startEndVector = twoPointVector( m_ArcStart, m_ArcEnd);
82  wxPoint startRelativePositionVector = twoPointVector( m_ArcStart, relativePosition );
83 
84  wxPoint centerStartVector = twoPointVector( m_Pos, m_ArcStart );
85  wxPoint centerEndVector = twoPointVector( m_Pos, m_ArcEnd );
86  wxPoint centerRelativePositionVector = twoPointVector( m_Pos, relativePosition );
87 
88  // Compute the cross product to check if the point is in the sector
89  double crossProductStart = CrossProduct( centerStartVector, centerRelativePositionVector );
90  double crossProductEnd = CrossProduct( centerEndVector, centerRelativePositionVector );
91 
92  // The cross products need to be exchanged, depending on which side the center point
93  // relative to the start point to end point vector lies
94  if( CrossProduct( startEndVector, startRelativePositionVector ) < 0 )
95  {
96  std::swap( crossProductStart, crossProductEnd );
97  }
98 
99  // When the cross products have a different sign, the point lies in sector
100  // also check, if the reference is near start or end point
101  return HitTestPoints( m_ArcStart, relativePosition, MINIMUM_SELECTION_DISTANCE ) ||
102  HitTestPoints( m_ArcEnd, relativePosition, MINIMUM_SELECTION_DISTANCE ) ||
103  ( crossProductStart <= 0 && crossProductEnd >= 0 );
104 }
105 
106 
107 bool LIB_ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
108 {
109  if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
110  return false;
111 
112  wxPoint center = DefaultTransform.TransformCoordinate( GetPosition() );
113  int radius = GetRadius();
114  int lineWidth = GetWidth();
115  EDA_RECT sel = aRect ;
116 
117  if ( aAccuracy )
118  sel.Inflate( aAccuracy );
119 
120  if( aContained )
121  return sel.Contains( GetBoundingBox() );
122 
123  EDA_RECT arcRect = GetBoundingBox().Common( sel );
124 
125  /* All following tests must pass:
126  * 1. Rectangle must intersect arc BoundingBox
127  * 2. Rectangle must cross the outside of the arc
128  */
129  return arcRect.Intersects( sel ) && arcRect.IntersectsCircleEdge( center, radius, lineWidth );
130 }
131 
132 
134 {
135  return new LIB_ARC( *this );
136 }
137 
138 
139 int LIB_ARC::compare( const LIB_ITEM& aOther ) const
140 {
141  wxASSERT( aOther.Type() == LIB_ARC_T );
142 
143  const LIB_ARC* tmp = ( LIB_ARC* ) &aOther;
144 
145  if( m_Pos.x != tmp->m_Pos.x )
146  return m_Pos.x - tmp->m_Pos.x;
147 
148  if( m_Pos.y != tmp->m_Pos.y )
149  return m_Pos.y - tmp->m_Pos.y;
150 
151  if( m_t1 != tmp->m_t1 )
152  return m_t1 - tmp->m_t1;
153 
154  if( m_t2 != tmp->m_t2 )
155  return m_t2 - tmp->m_t2;
156 
157  return 0;
158 }
159 
160 
161 void LIB_ARC::Offset( const wxPoint& aOffset )
162 {
163  m_Pos += aOffset;
164  m_ArcStart += aOffset;
165  m_ArcEnd += aOffset;
166 }
167 
168 
169 bool LIB_ARC::Inside( EDA_RECT& aRect ) const
170 {
171  return aRect.Contains( m_ArcStart.x, -m_ArcStart.y )
172  || aRect.Contains( m_ArcEnd.x, -m_ArcEnd.y );
173 }
174 
175 
176 void LIB_ARC::MoveTo( const wxPoint& aPosition )
177 {
178  wxPoint offset = aPosition - m_Pos;
179  m_Pos = aPosition;
180  m_ArcStart += offset;
181  m_ArcEnd += offset;
182 }
183 
184 
185 void LIB_ARC::MirrorHorizontal( const wxPoint& aCenter )
186 {
187  m_Pos.x -= aCenter.x;
188  m_Pos.x *= -1;
189  m_Pos.x += aCenter.x;
190  m_ArcStart.x -= aCenter.x;
191  m_ArcStart.x *= -1;
192  m_ArcStart.x += aCenter.x;
193  m_ArcEnd.x -= aCenter.x;
194  m_ArcEnd.x *= -1;
195  m_ArcEnd.x += aCenter.x;
196  std::swap( m_ArcStart, m_ArcEnd );
197  std::swap( m_t1, m_t2 );
198  m_t1 = 1800 - m_t1;
199  m_t2 = 1800 - m_t2;
200  if( m_t1 > 3600 || m_t2 > 3600 )
201  {
202  m_t1 -= 3600;
203  m_t2 -= 3600;
204  }
205  else if( m_t1 < -3600 || m_t2 < -3600 )
206  {
207  m_t1 += 3600;
208  m_t2 += 3600;
209  }
210 }
211 
212 void LIB_ARC::MirrorVertical( const wxPoint& aCenter )
213 {
214  m_Pos.y -= aCenter.y;
215  m_Pos.y *= -1;
216  m_Pos.y += aCenter.y;
217  m_ArcStart.y -= aCenter.y;
218  m_ArcStart.y *= -1;
219  m_ArcStart.y += aCenter.y;
220  m_ArcEnd.y -= aCenter.y;
221  m_ArcEnd.y *= -1;
222  m_ArcEnd.y += aCenter.y;
223  std::swap( m_ArcStart, m_ArcEnd );
224  std::swap( m_t1, m_t2 );
225  m_t1 = - m_t1;
226  m_t2 = - m_t2;
227  if( m_t1 > 3600 || m_t2 > 3600 )
228  {
229  m_t1 -= 3600;
230  m_t2 -= 3600;
231  }
232  else if( m_t1 < -3600 || m_t2 < -3600 )
233  {
234  m_t1 += 3600;
235  m_t2 += 3600;
236  }
237 }
238 
239 void LIB_ARC::Rotate( const wxPoint& aCenter, bool aRotateCCW )
240 {
241  int rot_angle = aRotateCCW ? -900 : 900;
242  RotatePoint( &m_Pos, aCenter, rot_angle );
243  RotatePoint( &m_ArcStart, aCenter, rot_angle );
244  RotatePoint( &m_ArcEnd, aCenter, rot_angle );
245  m_t1 -= rot_angle;
246  m_t2 -= rot_angle;
247  if( m_t1 > 3600 || m_t2 > 3600 )
248  {
249  m_t1 -= 3600;
250  m_t2 -= 3600;
251  }
252  else if( m_t1 < -3600 || m_t2 < -3600 )
253  {
254  m_t1 += 3600;
255  m_t2 += 3600;
256  }
257 }
258 
259 
260 
261 void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
262  const TRANSFORM& aTransform )
263 {
264  wxASSERT( aPlotter != NULL );
265 
266  int t1 = m_t1;
267  int t2 = m_t2;
268  wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + aOffset;
269 
270  aTransform.MapAngles( &t1, &t2 );
271 
272  if( aFill && m_Fill == FILLED_WITH_BG_BODYCOLOR )
273  {
275  aPlotter->Arc( pos, -t2, -t1, m_Radius, FILLED_WITH_BG_BODYCOLOR, 0 );
276  }
277 
278  bool already_filled = m_Fill == FILLED_WITH_BG_BODYCOLOR;
279  auto pen_size = GetPenSize();
280 
281  if( !already_filled || pen_size > 0 )
282  {
283  pen_size = std::max( 0, pen_size );
284  aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
285  aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, pen_size );
286  }
287 }
288 
289 
291 {
292  if( m_Width > 0 )
293  return m_Width;
294 
295  if( m_Width == 0 )
296  return GetDefaultLineThickness();
297 
298  return -1; // a value to use a minimal pen size
299 }
300 
301 
302 void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
303  const TRANSFORM& aTransform )
304 {
305  // Don't draw the arc until the end point is selected. Only the edit indicators
306  // get drawn at this time.
307  if( IsNew() && m_lastEditState == 1 )
308  return;
309 
310  wxPoint pos1, pos2, posc;
313 
314  pos1 = aTransform.TransformCoordinate( m_ArcEnd ) + aOffset;
315  pos2 = aTransform.TransformCoordinate( m_ArcStart ) + aOffset;
316  posc = aTransform.TransformCoordinate( m_Pos ) + aOffset;
317  int pt1 = m_t1;
318  int pt2 = m_t2;
319  bool swap = aTransform.MapAngles( &pt1, &pt2 );
320 
321  if( swap )
322  {
323  std::swap( pos1.x, pos2.x );
324  std::swap( pos1.y, pos2.y );
325  }
326 
327  FILL_T fill = aData ? NO_FILL : m_Fill;
328 
329  EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;
330  int penSize = GetPenSize();
331 
332  if( fill == FILLED_WITH_BG_BODYCOLOR )
333  GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius, penSize, bgColor, bgColor );
334  else if( fill == FILLED_SHAPE && !aData )
335  GRFilledArc( clipbox, aDC, posc.x, posc.y, pt1, pt2, m_Radius, color, color );
336  else
337  GRArc1( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, posc.x, posc.y, penSize, color );
338 }
339 
340 
342 {
343  int minX, minY, maxX, maxY, angleStart, angleEnd;
344  EDA_RECT rect;
345  wxPoint nullPoint, startPos, endPos, centerPos;
346  wxPoint normStart = m_ArcStart - m_Pos;
347  wxPoint normEnd = m_ArcEnd - m_Pos;
348 
349  if( ( normStart == nullPoint ) || ( normEnd == nullPoint ) || ( m_Radius == 0 ) )
350  {
351  wxLogDebug( wxT("Invalid arc drawing definition, center(%d, %d) \
352 start(%d, %d), end(%d, %d), radius %d" ),
353  m_Pos.x, m_Pos.y, m_ArcStart.x, m_ArcStart.y, m_ArcEnd.x,
354  m_ArcEnd.y, m_Radius );
355  return rect;
356  }
357 
361  angleStart = m_t1;
362  angleEnd = m_t2;
363 
364  if( DefaultTransform.MapAngles( &angleStart, &angleEnd ) )
365  {
366  std::swap( endPos.x, startPos.x );
367  std::swap( endPos.y, startPos.y );
368  }
369 
370  /* Start with the start and end point of the arc. */
371  minX = std::min( startPos.x, endPos.x );
372  minY = std::min( startPos.y, endPos.y );
373  maxX = std::max( startPos.x, endPos.x );
374  maxY = std::max( startPos.y, endPos.y );
375 
376  /* Zero degrees is a special case. */
377  if( angleStart == 0 )
378  maxX = centerPos.x + m_Radius;
379 
380  /* Arc end angle wrapped passed 360. */
381  if( angleStart > angleEnd )
382  angleEnd += 3600;
383 
384  if( angleStart <= 900 && angleEnd >= 900 ) /* 90 deg */
385  maxY = centerPos.y + m_Radius;
386 
387  if( angleStart <= 1800 && angleEnd >= 1800 ) /* 180 deg */
388  minX = centerPos.x - m_Radius;
389 
390  if( angleStart <= 2700 && angleEnd >= 2700 ) /* 270 deg */
391  minY = centerPos.y - m_Radius;
392 
393  if( angleStart <= 3600 && angleEnd >= 3600 ) /* 0 deg */
394  maxX = centerPos.x + m_Radius;
395 
396  rect.SetOrigin( minX, minY );
397  rect.SetEnd( maxX, maxY );
398  rect.Inflate( ( GetPenSize()+1 ) / 2 );
399 
400  return rect;
401 }
402 
403 
404 void LIB_ARC::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
405 {
406  wxString msg;
407  EDA_RECT bBox = GetBoundingBox();
408 
409  LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
410 
411  msg = MessageTextFromValue( aUnits, m_Width, true );
412 
413  aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
414 
415  msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
416  bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
417 
418  aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
419 }
420 
421 
422 wxString LIB_ARC::GetSelectMenuText( EDA_UNITS_T aUnits ) const
423 {
424  return wxString::Format( _( "Arc center (%s, %s), radius %s" ),
425  MessageTextFromValue( aUnits, m_Pos.x ),
426  MessageTextFromValue( aUnits, m_Pos.y ),
427  MessageTextFromValue( aUnits, m_Radius ) );
428 }
429 
430 
431 BITMAP_DEF LIB_ARC::GetMenuImage() const
432 {
433  return add_arc_xpm;
434 }
435 
436 
437 void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
438 {
439  LIB_ITEM::BeginEdit( aEditMode, aPosition );
440 
441  if( aEditMode == IS_NEW )
442  {
443  m_ArcStart = m_ArcEnd = aPosition;
445  }
446  else if( aEditMode == IS_MOVED )
447  {
449  m_initialCursorPos = aPosition;
450  }
451  else
452  {
453  // The arc center point has to be rotated with while adjusting the
454  // start or end point, determine the side of this point and the distance
455  // from the start / end point
456  wxPoint middlePoint = wxPoint( (m_ArcStart.x + m_ArcEnd.x) / 2,
457  (m_ArcStart.y + m_ArcEnd.y) / 2 );
458  wxPoint centerVector = m_Pos - middlePoint;
459  wxPoint startEndVector = twoPointVector( m_ArcStart, m_ArcEnd );
460  m_editCenterDistance = EuclideanNorm( centerVector );
461 
462  // Determine on which side is the center point
463  m_editDirection = CrossProduct( startEndVector, centerVector ) ? 1 : -1;
464 
465  // Drag either the start, end point or the outline
467  {
469  }
470  else if( HitTestPoints( m_ArcEnd, aPosition, MINIMUM_SELECTION_DISTANCE ) )
471  {
473  }
474  else
475  {
477  }
478 
479  m_editState = 0;
480  }
481 }
482 
483 
484 bool LIB_ARC::ContinueEdit( const wxPoint aPosition )
485 {
486  if( IsNew() )
487  {
488  if( m_editState == 1 ) // Second position yields the arc segment length.
489  {
490  m_ArcEnd = aPosition;
491  m_editState = 2;
492  return true; // Need third position to calculate center point.
493  }
494  }
495 
496  return false;
497 }
498 
499 
500 void LIB_ARC::EndEdit( const wxPoint& aPosition )
501 {
502  LIB_ITEM::EndEdit( aPosition );
503 
504  m_lastEditState = 0;
505  m_editState = 0;
506 }
507 
508 
509 void LIB_ARC::CalcEdit( const wxPoint& aPosition )
510 {
511  if( IsNew() )
512  {
513  if( m_editState == 1 )
514  {
515  m_ArcEnd = aPosition;
516  }
517 
520 
521  // Keep the arc center point up to date. Otherwise, there will be edit graphic
522  // artifacts left behind from the initial draw.
523  int dx, dy;
524  int cX, cY;
525  double angle;
526 
527  cX = aPosition.x;
528  cY = aPosition.y;
529 
530  dx = m_ArcEnd.x - m_ArcStart.x;
531  dy = m_ArcEnd.y - m_ArcStart.y;
532  cX -= m_ArcStart.x;
533  cY -= m_ArcStart.y;
534  angle = ArcTangente( dy, dx );
535  RotatePoint( &dx, &dy, angle ); /* The segment dx, dy is horizontal
536  * -> Length = dx, dy = 0 */
537  RotatePoint( &cX, &cY, angle );
538  cX = dx / 2; /* cX, cY is on the median segment 0.0 a dx, 0 */
539 
540  RotatePoint( &cX, &cY, -angle );
541  cX += m_ArcStart.x;
542  cY += m_ArcStart.y;
543  m_Pos.x = cX;
544  m_Pos.y = cY;
546 
547  }
548  else if( IsMoving() )
549  {
550  MoveTo( m_initialPos + aPosition - m_initialCursorPos );
551  }
552 }
553 
554 
556 {
557  wxPoint centerStartVector = twoPointVector( m_Pos, m_ArcStart );
558  wxPoint centerEndVector = twoPointVector( m_Pos, m_ArcEnd );
559 
560  m_Radius = KiROUND( EuclideanNorm( centerStartVector ) );
561 
562  // Angles in eeschema are still integers
563  m_t1 = KiROUND( ArcTangente( centerStartVector.y, centerStartVector.x ) );
564  m_t2 = KiROUND( ArcTangente( centerEndVector.y, centerEndVector.x ) );
565 
567  NORMALIZE_ANGLE_POS( m_t2 ); // angles = 0 .. 3600
568 
569  // Restrict angle to less than 180 to avoid PBS display mirror Trace because it is
570  // assumed that the arc is less than 180 deg to find orientation after rotate or mirror.
571  if( (m_t2 - m_t1) > 1800 )
572  m_t2 -= 3600;
573  else if( (m_t2 - m_t1) <= -1800 )
574  m_t2 += 3600;
575 
576  while( (m_t2 - m_t1) >= 1800 )
577  {
578  m_t2--;
579  m_t1++;
580  }
581 
582  while( (m_t1 - m_t2) >= 1800 )
583  {
584  m_t2++;
585  m_t1--;
586  }
587 
589 
590  if( !IsMoving() )
592 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:121
Definition: colors.h:57
int m_Radius
Definition: lib_arc.h:47
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.
static wxPoint twoPointVector(const wxPoint &startPoint, const wxPoint &endPoint)
Definition: lib_arc.cpp:44
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:404
int m_t1
Definition: lib_arc.h:48
virtual void EndEdit(const wxPoint &aPosition)
End an object editing action.
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:261
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:200
double m_editCenterDistance
Definition: lib_arc.h:54
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
Implementation of conversion functions that require both schematic and board internal units.
virtual void SetColor(COLOR4D color)=0
#define MINIMUM_SELECTION_DISTANCE
Definition: lib_draw_item.h:53
int m_t2
Definition: lib_arc.h:49
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:125
bool IsMoving() const
Definition: base_struct.h:224
int m_lastEditState
Definition: lib_arc.h:58
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:341
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Draws the arc.
Definition: lib_arc.cpp:302
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
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:555
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:431
virtual EDA_RECT * GetClipBox()
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
wxPoint m_ArcEnd
Definition: lib_arc.h:51
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:250
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
#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_draw_item.h:67
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_arc.cpp:212
This file contains miscellaneous commonly used macros and functions.
bool IsNew() const
Definition: base_struct.h:222
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
const wxPoint GetEnd() const
Definition: eda_rect.h:114
void EndEdit(const wxPoint &aPosition) override
End an object editing action.
Definition: lib_arc.cpp:500
Class for tranforming 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:169
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:170
wxPoint m_Pos
Definition: lib_arc.h:52
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
void SetEnd(int x, int y)
Definition: eda_rect.h:134
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_arc.cpp:133
bool m_isFillable
Flag to indicate if draw item is fillable.
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:66
Define a library symbol object.
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:176
unsigned STATUS_FLAGS
Definition: base_struct.h:150
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:123
int m_editState
Definition: lib_arc.h:56
double CrossProduct(const wxPoint &vectorA, const wxPoint &vectorB)
Determine the cross product.
Definition: trigo.h:175
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_arc.cpp:139
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_arc.cpp:484
int GetPenSize() const override
Definition: lib_arc.cpp:290
virtual void Rotate()
Rotate the draw item.
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_arc.cpp:509
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:848
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:185
int GetRadius() const
Definition: lib_arc.h:117
virtual void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aPosition)
Begin an editing a component library draw item in aEditMode at aPosition.
Base plotter engine class.
Definition: plotter.h:97
int GetWidth() const override
Return the width of the draw item.
Definition: lib_arc.h:113
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:422
TRANSFORM DefaultTransform
Definition: eeschema.cpp:59
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
wxPoint m_initialPos
Temporary position when moving an existing item.
FILL_T m_Fill
The body fill type.
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:50
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
Definition: trigo.h:159
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:181
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:161
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:157
int m_editDirection
Definition: lib_arc.h:57
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:154
FILL_T
Enum FILL_T is the set of fill types used in plotting or drawing enclosed areas.
Definition: base_struct.h:54
void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aStartPoint) override
Begin an editing a component library draw item in aEditMode at aPosition.
Definition: lib_arc.cpp:437
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:80
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
SELECT_T m_editSelectPoint
Definition: lib_arc.h:55
wxPoint m_ArcStart
Definition: lib_arc.h:50
Message panel definition file.
EDA_UNITS_T
Definition: common.h:157
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
wxPoint m_initialCursorPos
Initial cursor position at the beginning of a move.
int m_Width
Definition: lib_arc.h:53
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
#define min(a, b)
Definition: auxiliary.h:85
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_arc.h:103
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:799
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
Definition: colors.h:62