KiCad PCB EDA Suite
class_drawsegment.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) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <macros.h>
34 #include <wxstruct.h>
35 #include <gr_basic.h>
36 #include <bezier_curves.h>
37 #include <class_drawpanel.h>
38 #include <class_pcb_screen.h>
39 #include <colors_selection.h>
40 #include <trigo.h>
41 #include <msgpanel.h>
42 #include <bitmaps.h>
43 
44 #include <pcbnew.h>
45 
46 #include <class_board.h>
47 #include <class_module.h>
48 #include <class_drawsegment.h>
49 #include <base_units.h>
50 
51 
53  BOARD_ITEM( aParent, idtype )
54 {
55  m_Type = 0;
56  m_Angle = 0;
57  m_Flags = 0;
59  m_Width = Millimeter2iu( 0.15 ); // Gives a decent width
60 }
61 
62 
64 {
65 }
66 
67 
68 void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle )
69 {
70  switch( m_Shape )
71  {
72  case S_ARC:
73  case S_SEGMENT:
74  case S_CIRCLE:
75  // these can all be done by just rotating the start and end points
76  RotatePoint( &m_Start, aRotCentre, aAngle);
77  RotatePoint( &m_End, aRotCentre, aAngle);
78  break;
79 
80  case S_POLYGON:
81  for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
82  {
83  RotatePoint( &m_PolyPoints[ii], aRotCentre, aAngle);
84  }
85  break;
86 
87  case S_CURVE:
88  RotatePoint( &m_Start, aRotCentre, aAngle);
89  RotatePoint( &m_End, aRotCentre, aAngle);
90 
91  for( unsigned int ii = 0; ii < m_BezierPoints.size(); ii++ )
92  {
93  RotatePoint( &m_BezierPoints[ii], aRotCentre, aAngle);
94  }
95  break;
96 
97  case S_RECT:
98  default:
99  // un-handled edge transform
100  wxASSERT_MSG( false, wxT( "DRAWSEGMENT::Rotate not implemented for "
101  + ShowShape( m_Shape ) ) );
102  break;
103  }
104 };
105 
106 void DRAWSEGMENT::Flip( const wxPoint& aCentre )
107 {
108  m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
109  m_End.y = aCentre.y - (m_End.y - aCentre.y);
110 
111  if( m_Shape == S_ARC )
112  m_Angle = -m_Angle;
113 
114  // DRAWSEGMENT items are not allowed on copper layers, so
115  // copper layers count is not taken in accoun in Flip transform
116  SetLayer( FlipLayer( GetLayer() ) );
117 }
118 
120 {
121  wxPoint c;
122 
123  switch( m_Shape )
124  {
125  case S_ARC:
126  case S_CIRCLE:
127  c = m_Start;
128  break;
129 
130  case S_SEGMENT:
131  // Midpoint of the line
132  c = ( GetStart() + GetEnd() ) / 2;
133  break;
134 
135  case S_POLYGON:
136  case S_RECT:
137  case S_CURVE:
138  c = GetBoundingBox().Centre();
139  break;
140 
141  default:
142  wxASSERT_MSG( false, "DRAWSEGMENT::GetCentre not implemented for shape"
143  + ShowShape( GetShape() ) );
144  break;
145  }
146 
147  return c;
148 }
149 
151 {
152  wxPoint endPoint; // start of arc
153 
154  switch( m_Shape )
155  {
156  case S_ARC:
157  // rotate the starting point of the arc, given by m_End, through the
158  // angle m_Angle to get the ending point of the arc.
159  // m_Start is the arc centre
160  endPoint = m_End; // m_End = start point of arc
161  RotatePoint( &endPoint, m_Start, -m_Angle );
162  break;
163 
164  default:
165  ;
166  }
167 
168  return endPoint; // after rotation, the end of the arc.
169 }
170 
172 {
173  // due to the Y axis orient atan2 needs - y value
174  double angleStart = ArcTangente( GetArcStart().y - GetCenter().y,
175  GetArcStart().x - GetCenter().x );
176 
177  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
178  // because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg.
179  // and this is not easy to handle in calculations
180  NORMALIZE_ANGLE_POS( angleStart );
181 
182  return angleStart;
183 }
184 
185 
186 void DRAWSEGMENT::SetAngle( double aAngle )
187 {
188  m_Angle = NormalizeAngle360( aAngle );
189 }
190 
191 
193 {
194  if( m_Parent->Type() != PCB_MODULE_T )
195  return NULL;
196 
197  return (MODULE*) m_Parent;
198 }
199 
200 
201 void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
202  const wxPoint& aOffset )
203 {
204  int ux0, uy0, dx, dy;
205  int l_trace;
206  int radius;
207 
208  LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
209  COLOR4D color;
210 
211  BOARD * brd = GetBoard( );
212 
213  if( brd->IsLayerVisible( GetLayer() ) == false )
214  return;
215 
216  color = brd->GetLayerColor( GetLayer() );
217 
218  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
219 
220  if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
221  {
222  if( !IsOnLayer( curr_layer ) && !IsOnLayer( Edge_Cuts ) )
223  color = COLOR4D( DARKDARKGRAY );
224  }
225 
226  GRSetDrawMode( DC, draw_mode );
227  l_trace = m_Width >> 1; // half trace width
228 
229  // Line start point or Circle and Arc center
230  ux0 = m_Start.x + aOffset.x;
231  uy0 = m_Start.y + aOffset.y;
232 
233  // Line end point or circle and arc start point
234  dx = m_End.x + aOffset.x;
235  dy = m_End.y + aOffset.y;
236 
237  bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED;
238 
239  if( m_Flags & FORCE_SKETCH )
240  filled = SKETCH;
241 
242  switch( m_Shape )
243  {
244  case S_CIRCLE:
245  radius = KiROUND( Distance( ux0, uy0, dx, dy ) );
246 
247  if( filled )
248  {
249  GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius, m_Width, color );
250  }
251  else
252  {
253  GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius - l_trace, color );
254  GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius + l_trace, color );
255  }
256 
257  break;
258 
259  case S_ARC:
260  double StAngle, EndAngle;
261  radius = KiROUND( Distance( ux0, uy0, dx, dy ) );
262  StAngle = ArcTangente( dy - uy0, dx - ux0 );
263  EndAngle = StAngle + m_Angle;
264 
265  if( !panel->GetPrintMirrored() )
266  {
267  if( StAngle > EndAngle )
268  std::swap( StAngle, EndAngle );
269  }
270  else // Mirrored mode: arc orientation is reversed
271  {
272  if( StAngle < EndAngle )
273  std::swap( StAngle, EndAngle );
274  }
275 
276  if( filled )
277  {
278  GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
279  radius, m_Width, color );
280  }
281  else
282  {
283  GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
284  radius - l_trace, color );
285  GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
286  radius + l_trace, color );
287  }
288 
289  break;
290 
291  case S_CURVE:
293 
294  for( unsigned int i=1; i < m_BezierPoints.size(); i++ )
295  {
296  if( filled )
297  {
298  GRFillCSegm( panel->GetClipBox(), DC,
299  m_BezierPoints[i].x, m_BezierPoints[i].y,
300  m_BezierPoints[i-1].x, m_BezierPoints[i-1].y,
301  m_Width, color );
302  }
303  else
304  {
305  GRCSegm( panel->GetClipBox(), DC,
306  m_BezierPoints[i].x, m_BezierPoints[i].y,
307  m_BezierPoints[i-1].x, m_BezierPoints[i-1].y,
308  m_Width, color );
309  }
310  }
311 
312  break;
313 
314  default:
315  if( filled )
316  {
317  GRFillCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
318  }
319  else
320  {
321  GRCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
322  }
323 
324  break;
325  }
326 }
327 
328 
329 // see pcbstruct.h
330 void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
331 {
332  wxString msg;
333  wxASSERT( m_Parent );
334 
335  msg = _( "Drawing" );
336 
337  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
338 
339  wxString shape = _( "Shape" );
340 
341  switch( m_Shape )
342  {
343  case S_CIRCLE:
344  aList.push_back( MSG_PANEL_ITEM( shape, _( "Circle" ), RED ) );
345  break;
346 
347  case S_ARC:
348  aList.push_back( MSG_PANEL_ITEM( shape, _( "Arc" ), RED ) );
349  msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 );
350  aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, RED ) );
351  break;
352 
353  case S_CURVE:
354  aList.push_back( MSG_PANEL_ITEM( shape, _( "Curve" ), RED ) );
355  break;
356 
357  default:
358  {
359  aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) );
360 
362  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKGREEN ) );
363 
364  // angle counter-clockwise from 3'o-clock
365  const double deg = RAD2DEG( atan2( (double)( m_Start.y - m_End.y ),
366  (double)( m_End.x - m_Start.x ) ) );
367  msg.Printf( wxT( "%.1f" ), deg );
368  aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
369  }
370  }
371 
372  wxString start;
373  start << GetStart();
374 
375  wxString end;
376  end << GetEnd();
377 
378  aList.push_back( MSG_PANEL_ITEM( start, end, DARKGREEN ) );
379  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKBROWN ) );
380  msg = ::CoordinateToString( m_Width );
381  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
382 }
383 
384 
386 {
387  EDA_RECT bbox;
388 
389  bbox.SetOrigin( m_Start );
390 
391  switch( m_Shape )
392  {
393  case S_SEGMENT:
394  bbox.SetEnd( m_End );
395  break;
396 
397  case S_CIRCLE:
398  bbox.Inflate( GetRadius() );
399  break;
400 
401  case S_ARC:
402  computeArcBBox( bbox );
403  break;
404 
405  case S_POLYGON:
406  {
407  wxPoint p_end;
408  MODULE* module = GetParentModule();
409 
410  for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
411  {
412  wxPoint pt = m_PolyPoints[ii];
413 
414  if( module ) // Transform, if we belong to a module
415  {
416  RotatePoint( &pt, module->GetOrientation() );
417  pt += module->GetPosition();
418  }
419 
420  if( ii == 0 )
421  p_end = pt;
422 
423  bbox.SetX( std::min( bbox.GetX(), pt.x ) );
424  bbox.SetY( std::min( bbox.GetY(), pt.y ) );
425  p_end.x = std::max( p_end.x, pt.x );
426  p_end.y = std::max( p_end.y, pt.y );
427  }
428 
429  bbox.SetEnd( p_end );
430  }
431  break;
432 
433  default:
434  ;
435  }
436 
437  bbox.Inflate( ((m_Width+1) / 2) + 1 );
438  bbox.Normalize();
439 
440  return bbox;
441 }
442 
443 
444 bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
445 {
446  switch( m_Shape )
447  {
448  case S_CIRCLE:
449  case S_ARC:
450  {
451  wxPoint relPos = aPosition - GetCenter();
452  int radius = GetRadius();
453  int dist = KiROUND( EuclideanNorm( relPos ) );
454 
455  if( abs( radius - dist ) <= ( m_Width / 2 ) )
456  {
457  if( m_Shape == S_CIRCLE )
458  return true;
459 
460  // For arcs, the test point angle must be >= arc angle start
461  // and <= arc angle end
462  // However angle values > 360 deg are not easy to handle
463  // so we calculate the relative angle between arc start point and teast point
464  // this relative arc should be < arc angle if arc angle > 0 (CW arc)
465  // and > arc angle if arc angle < 0 (CCW arc)
466  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
467 
468  double arc_hittest = ArcTangente( relPos.y, relPos.x );
469 
470  // Calculate relative angle between the starting point of the arc, and the test point
471  arc_hittest -= arc_angle_start;
472 
473  // Normalise arc_hittest between 0 ... 360 deg
474  NORMALIZE_ANGLE_POS( arc_hittest );
475 
476  // Check angle: inside the arc angle when it is > 0
477  // and outside the not drawn arc when it is < 0
478  if( GetAngle() >= 0.0 )
479  {
480  if( arc_hittest <= GetAngle() )
481  return true;
482  }
483  else
484  {
485  if( arc_hittest >= (3600.0 + GetAngle()) )
486  return true;
487  }
488  }
489  }
490  break;
491 
492  case S_CURVE:
493  for( unsigned int i= 1; i < m_BezierPoints.size(); i++)
494  {
495  if( TestSegmentHit( aPosition, m_BezierPoints[i-1], m_BezierPoints[i-1], m_Width / 2 ) )
496  return true;
497  }
498  break;
499 
500  case S_SEGMENT:
501  if( TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 ) )
502  return true;
503  break;
504 
505  case S_POLYGON: // not yet handled
506  break;
507 
508  default:
509  wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
510  break;
511  }
512 
513  return false;
514 }
515 
516 
517 bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
518 {
519  wxPoint p1, p2;
520  int radius;
521  float theta;
522  EDA_RECT arect = aRect;
523  arect.Inflate( aAccuracy );
524 
525  switch( m_Shape )
526  {
527  case S_CIRCLE:
528  // Test if area intersects or contains the circle:
529  if( aContained )
530  return arect.Contains( GetBoundingBox() );
531  else
532  return arect.Intersects( GetBoundingBox() );
533  break;
534 
535  case S_ARC:
536  radius = hypot( (double)( GetEnd().x - GetStart().x ),
537  (double)( GetEnd().y - GetStart().y ) );
538  theta = std::atan2( (double)( GetEnd().y - GetStart().y ),
539  (double)( GetEnd().x - GetStart().x ) );
540 
541  //Approximate the arc with two lines. This should be accurate enough for selection.
542  p1.x = radius * std::cos( theta + M_PI/4 ) + GetStart().x;
543  p1.y = radius * std::sin( theta + M_PI/4 ) + GetStart().y;
544  p2.x = radius * std::cos( theta + M_PI/2 ) + GetStart().x;
545  p2.y = radius * std::sin( theta + M_PI/2 ) + GetStart().y;
546 
547  if( aContained )
548  return arect.Contains( GetEnd() ) && aRect.Contains( p1 ) && aRect.Contains( p2 );
549  else
550  return arect.Intersects( GetEnd(), p1 ) || aRect.Intersects( p1, p2 );
551 
552  break;
553 
554  case S_SEGMENT:
555  if( aContained )
556  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
557  else
558  return arect.Intersects( GetStart(), GetEnd() );
559 
560  break;
561 
562  case S_CURVE:
563  case S_POLYGON: // not yet handled
564  break;
565 
566  default:
567  wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
568  break;
569  }
570 
571  return false;
572 }
573 
574 
576 {
577  wxString text;
578  wxString temp = ::LengthDoubleToString( GetLength() );
579 
580  text.Printf( _( "Pcb Graphic: %s, length %s on %s" ),
581  GetChars( ShowShape( m_Shape ) ),
582  GetChars( temp ), GetChars( GetLayerName() ) );
583 
584  return text;
585 }
586 
587 
589 {
590  return add_dashed_line_xpm;
591 }
592 
593 
595 {
596  return new DRAWSEGMENT( *this );
597 }
598 
599 
601 {
602  // For arcs - do not include the center point in the bounding box,
603  // it is redundant for displaying an arc
604  if( m_Shape == S_ARC )
605  {
606  EDA_RECT bbox;
607  bbox.SetOrigin( m_End );
608  computeArcBBox( bbox );
609  return BOX2I( bbox.GetOrigin(), bbox.GetSize() );
610  }
611 
612  return EDA_ITEM::ViewBBox();
613 }
614 
615 
617 {
618  // Do not include the center, which is not necessarily
619  // inside the BB of a arc with a small angle
620  aBBox.SetOrigin( m_End );
621 
622  wxPoint end = m_End;
623  RotatePoint( &end, m_Start, -m_Angle );
624  aBBox.Merge( end );
625 
626  // Determine the starting quarter
627  // 0 right-bottom
628  // 1 left-bottom
629  // 2 left-top
630  // 3 right-top
631  unsigned int quarter = 0; // assume right-bottom
632 
633  if( m_End.x < m_Start.x )
634  {
635  if( m_End.y <= m_Start.y )
636  quarter = 2;
637  else // ( m_End.y > m_Start.y )
638  quarter = 1;
639  }
640  else if( m_End.x >= m_Start.x )
641  {
642  if( m_End.y < m_Start.y )
643  quarter = 3;
644  else if( m_End.x == m_Start.x )
645  quarter = 1;
646  }
647 
648  int radius = GetRadius();
649  int angle = (int) GetArcAngleStart() % 900 + m_Angle;
650  bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise?
651 
652  // Make the angle positive, so we go clockwise and merge points belonging to the arc
653  if( !directionCW )
654  {
655  angle = 900 - angle;
656  quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
657  }
658 
659  while( angle > 900 )
660  {
661  switch( quarter )
662  {
663  case 0:
664  aBBox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); // down
665  break;
666 
667  case 1:
668  aBBox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); // left
669  break;
670 
671  case 2:
672  aBBox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); // up
673  break;
674 
675  case 3:
676  aBBox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); // right
677  break;
678  }
679 
680  if( directionCW )
681  ++quarter;
682  else
683  quarter += 3; // -1 modulo arithmetic
684 
685  quarter %= 4;
686  angle -= 900;
687  }
688 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:104
wxString CoordinateToString(int aValue, bool aConvertToMils)
Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inche...
Definition: base_units.cpp:117
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
static wxString ShowShape(STROKE_T aShape)
Function ShowShape converts the enum STROKE_T integer value to a wxString.
virtual void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
BOX2< VECTOR2I > BOX2I
Definition: box2.h:468
virtual const BOX2I ViewBBox() const override
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:168
double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
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:183
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect...
virtual void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
PNG memory record (file in memory).
Definition: bitmap_types.h:38
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
Implementation of conversion functions that require both schematic and board internal units...
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
const wxPoint GetCenter() const override
Function GetCenter()
bool Contains(const wxPoint &aPoint) const
Function Contains.
Class BOARD to handle a board.
const wxPoint & GetPosition() const override
Definition: class_module.h:143
polygon (not yet used for tracks, but could be in microwave apps)
COLOR4D GetLayerColor(LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
virtual BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
double RAD2DEG(double rad)
Definition: trigo.h:192
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
double GetArcAngleStart() const
function GetArcAngleStart()
static const int dist[10][10]
Definition: dist.cpp:57
void SetOrigin(const wxPoint &pos)
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:481
usual segment : line with rounded ends
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:222
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
#define abs(a)
Definition: auxiliary.h:84
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
This file contains miscellaneous commonly used macros and functions.
wxPoint m_BezierC1
Bezier Control Point 1.
const wxPoint & GetArcStart() const
virtual bool IsOnLayer(LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
const wxPoint & GetOrigin() const
segment with non rounded ends
class MODULE, a footprint
Definition: typeinfo.h:101
std::vector< wxPoint > Bezier2Poly(wxPoint c1, wxPoint c2, wxPoint c3, wxPoint c4)
Function Bezier2Poly convert a Bezier curve to a polyline.
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
STROKE_T GetShape() const
wxPoint m_Start
Line start point or Circle and Arc center.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:271
wxPoint m_End
Line end point or circle and arc start point.
double GetOrientation() const
Definition: class_module.h:147
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
Base window classes and related definitions.
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:584
void SetEnd(int x, int y)
Arcs (with rounded ends)
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, double StAngle, double EndAngle, int r, COLOR4D Color)
Definition: gr_basic.cpp:982
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
bool m_DisplayDrawItemsFill
Definition: pcbstruct.h:84
EDA_RECT * GetClipBox()
void SetX(int val)
wxString LengthDoubleToString(double aValue, bool aConvertToMils)
Function LengthDoubleToString is a helper to convert the double length aValue to a string in inches...
Definition: base_units.cpp:122
STROKE_T m_Shape
Shape: line, Circle, Arc.
Definition: colors.h:60
Bezier Curve.
wxPoint Centre() const
void computeArcBBox(EDA_RECT &aBBox) const
void SetY(int val)
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
bool IsLayerVisible(LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:440
void Normalize()
Function Normalize ensures that the height ant width are positive.
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
double GetAngle() const
int m_Type
Used in complex associations ( Dimensions.. )
Class to handle a graphic segment.
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
bool GetPrintMirrored() const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
LAYER_ID FlipLayer(LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:444
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:791
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
const wxPoint GetArcEnd() const
Class EDA_RECT handles the component boundary box.
int GetX() const
wxPoint m_BezierC2
Bezier Control Point 2.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
int GetY() const
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees...
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
int m_Width
thickness of lines ...
Module description (excepted pads)
void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_panel.cpp:182
DRAWSEGMENT(BOARD_ITEM *aParent=NULL, KICAD_T idtype=PCB_LINE_T)
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
std::vector< wxPoint > m_PolyPoints
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:142
double Distance(double x1, double y1, double x2, double y2)
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
virtual const BOX2I ViewBBox() const override
Message panel definition file.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
#define FORCE_SKETCH
Definition: pcbnew.h:69
const wxSize & GetSize() const
virtual wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
T NormalizeAngle360(T Angle)
Normalize angle to be in the -360.0 .. 360.0:
Definition: trigo.h:202
#define min(a, b)
Definition: auxiliary.h:85
std::vector< wxPoint > m_BezierPoints
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
virtual const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...