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  PCB_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:
292  {
293  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
294  BEZIER_POLY converter( ctrlPoints );
295  converter.GetPoly( m_BezierPoints );
296  }
297 
298  for( unsigned int i=1; i < m_BezierPoints.size(); i++ )
299  {
300  if( filled )
301  {
302  GRFillCSegm( panel->GetClipBox(), DC,
303  m_BezierPoints[i].x, m_BezierPoints[i].y,
304  m_BezierPoints[i-1].x, m_BezierPoints[i-1].y,
305  m_Width, color );
306  }
307  else
308  {
309  GRCSegm( panel->GetClipBox(), DC,
310  m_BezierPoints[i].x, m_BezierPoints[i].y,
311  m_BezierPoints[i-1].x, m_BezierPoints[i-1].y,
312  m_Width, color );
313  }
314  }
315 
316  break;
317 
318  default:
319  if( filled )
320  {
321  GRFillCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
322  }
323  else
324  {
325  GRCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
326  }
327 
328  break;
329  }
330 }
331 
332 
333 // see pcbstruct.h
334 void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
335 {
336  wxString msg;
337  wxASSERT( m_Parent );
338 
339  msg = _( "Drawing" );
340 
341  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
342 
343  wxString shape = _( "Shape" );
344 
345  switch( m_Shape )
346  {
347  case S_CIRCLE:
348  aList.push_back( MSG_PANEL_ITEM( shape, _( "Circle" ), RED ) );
349  break;
350 
351  case S_ARC:
352  aList.push_back( MSG_PANEL_ITEM( shape, _( "Arc" ), RED ) );
353  msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 );
354  aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, RED ) );
355  break;
356 
357  case S_CURVE:
358  aList.push_back( MSG_PANEL_ITEM( shape, _( "Curve" ), RED ) );
359  break;
360 
361  default:
362  {
363  aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) );
364 
366  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKGREEN ) );
367 
368  // angle counter-clockwise from 3'o-clock
369  const double deg = RAD2DEG( atan2( (double)( m_Start.y - m_End.y ),
370  (double)( m_End.x - m_Start.x ) ) );
371  msg.Printf( wxT( "%.1f" ), deg );
372  aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
373  }
374  }
375 
376  wxString start;
377  start << GetStart();
378 
379  wxString end;
380  end << GetEnd();
381 
382  aList.push_back( MSG_PANEL_ITEM( start, end, DARKGREEN ) );
383  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKBROWN ) );
384  msg = ::CoordinateToString( m_Width );
385  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
386 }
387 
388 
390 {
391  EDA_RECT bbox;
392 
393  bbox.SetOrigin( m_Start );
394 
395  switch( m_Shape )
396  {
397  case S_SEGMENT:
398  bbox.SetEnd( m_End );
399  break;
400 
401  case S_CIRCLE:
402  bbox.Inflate( GetRadius() );
403  break;
404 
405  case S_ARC:
406  computeArcBBox( bbox );
407  break;
408 
409  case S_POLYGON:
410  {
411  wxPoint p_end;
412  MODULE* module = GetParentModule();
413 
414  for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
415  {
416  wxPoint pt = m_PolyPoints[ii];
417 
418  if( module ) // Transform, if we belong to a module
419  {
420  RotatePoint( &pt, module->GetOrientation() );
421  pt += module->GetPosition();
422  }
423 
424  if( ii == 0 )
425  p_end = pt;
426 
427  bbox.SetX( std::min( bbox.GetX(), pt.x ) );
428  bbox.SetY( std::min( bbox.GetY(), pt.y ) );
429  p_end.x = std::max( p_end.x, pt.x );
430  p_end.y = std::max( p_end.y, pt.y );
431  }
432 
433  bbox.SetEnd( p_end );
434  }
435  break;
436 
437  default:
438  break;
439  }
440 
441  bbox.Inflate( ((m_Width+1) / 2) + 1 );
442  bbox.Normalize();
443 
444  return bbox;
445 }
446 
447 
448 bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
449 {
450  switch( m_Shape )
451  {
452  case S_CIRCLE:
453  case S_ARC:
454  {
455  wxPoint relPos = aPosition - GetCenter();
456  int radius = GetRadius();
457  int dist = KiROUND( EuclideanNorm( relPos ) );
458 
459  if( abs( radius - dist ) <= ( m_Width / 2 ) )
460  {
461  if( m_Shape == S_CIRCLE )
462  return true;
463 
464  // For arcs, the test point angle must be >= arc angle start
465  // and <= arc angle end
466  // However angle values > 360 deg are not easy to handle
467  // so we calculate the relative angle between arc start point and teast point
468  // this relative arc should be < arc angle if arc angle > 0 (CW arc)
469  // and > arc angle if arc angle < 0 (CCW arc)
470  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
471 
472  double arc_hittest = ArcTangente( relPos.y, relPos.x );
473 
474  // Calculate relative angle between the starting point of the arc, and the test point
475  arc_hittest -= arc_angle_start;
476 
477  // Normalise arc_hittest between 0 ... 360 deg
478  NORMALIZE_ANGLE_POS( arc_hittest );
479 
480  // Check angle: inside the arc angle when it is > 0
481  // and outside the not drawn arc when it is < 0
482  if( GetAngle() >= 0.0 )
483  {
484  if( arc_hittest <= GetAngle() )
485  return true;
486  }
487  else
488  {
489  if( arc_hittest >= (3600.0 + GetAngle()) )
490  return true;
491  }
492  }
493  }
494  break;
495 
496  case S_CURVE:
497  for( unsigned int i= 1; i < m_BezierPoints.size(); i++)
498  {
499  if( TestSegmentHit( aPosition, m_BezierPoints[i-1], m_BezierPoints[i-1], m_Width / 2 ) )
500  return true;
501  }
502  break;
503 
504  case S_SEGMENT:
505  if( TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 ) )
506  return true;
507  break;
508 
509  case S_POLYGON: // not yet handled
510  break;
511 
512  default:
513  wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
514  break;
515  }
516 
517  return false;
518 }
519 
520 
521 bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
522 {
523  EDA_RECT arect = aRect;
524  arect.Normalize();
525  arect.Inflate( aAccuracy );
526 
527  EDA_RECT arcRect;
528  EDA_RECT bb = GetBoundingBox();
529 
530  switch( m_Shape )
531  {
532  case S_CIRCLE:
533  // Test if area intersects or contains the circle:
534  if( aContained )
535  return arect.Contains( bb );
536  else
537  {
538  // If the rectangle does not intersect the bounding box, this is a much quicker test
539  if( !aRect.Intersects( bb ) )
540  {
541  return false;
542  }
543  else
544  {
545  return arect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() );
546  }
547 
548  }
549  break;
550 
551  case S_ARC:
552 
553  // Test for full containment of this arc in the rect
554  if( aContained )
555  {
556  return arect.Contains( bb );
557  }
558  // Test if the rect crosses the arc
559  else
560  {
561  arcRect = bb.Common( arect );
562 
563  /* All following tests must pass:
564  * 1. Rectangle must intersect arc BoundingBox
565  * 2. Rectangle must cross the outside of the arc
566  */
567  return arcRect.Intersects( arect ) &&
569  }
570  break;
571  case S_SEGMENT:
572  if( aContained )
573  {
574  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
575  }
576  else
577  {
578  // Account for the width of the line
579  arect.Inflate( GetWidth() / 2 );
580  return arect.Intersects( GetStart(), GetEnd() );
581  }
582 
583  break;
584 
585  case S_CURVE:
586  case S_POLYGON: // not yet handled
587  break;
588 
589  default:
590  wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
591  break;
592  }
593 
594  return false;
595 }
596 
597 
599 {
600  wxString text;
601  wxString temp = ::LengthDoubleToString( GetLength() );
602 
603  text.Printf( _( "Pcb Graphic: %s, length %s on %s" ),
604  GetChars( ShowShape( m_Shape ) ),
605  GetChars( temp ), GetChars( GetLayerName() ) );
606 
607  return text;
608 }
609 
610 
612 {
613  return add_dashed_line_xpm;
614 }
615 
616 
618 {
619  return new DRAWSEGMENT( *this );
620 }
621 
622 
624 {
625  // For arcs - do not include the center point in the bounding box,
626  // it is redundant for displaying an arc
627  if( m_Shape == S_ARC )
628  {
629  EDA_RECT bbox;
630  bbox.SetOrigin( m_End );
631  computeArcBBox( bbox );
632  return BOX2I( bbox.GetOrigin(), bbox.GetSize() );
633  }
634 
635  return EDA_ITEM::ViewBBox();
636 }
637 
638 
640 {
641  // Do not include the center, which is not necessarily
642  // inside the BB of a arc with a small angle
643  aBBox.SetOrigin( m_End );
644 
645  wxPoint end = m_End;
646  RotatePoint( &end, m_Start, -m_Angle );
647  aBBox.Merge( end );
648 
649  // Determine the starting quarter
650  // 0 right-bottom
651  // 1 left-bottom
652  // 2 left-top
653  // 3 right-top
654  unsigned int quarter = 0; // assume right-bottom
655 
656  if( m_End.x < m_Start.x )
657  {
658  if( m_End.y <= m_Start.y )
659  quarter = 2;
660  else // ( m_End.y > m_Start.y )
661  quarter = 1;
662  }
663  else if( m_End.x >= m_Start.x )
664  {
665  if( m_End.y < m_Start.y )
666  quarter = 3;
667  else if( m_End.x == m_Start.x )
668  quarter = 1;
669  }
670 
671  int radius = GetRadius();
672  int angle = (int) GetArcAngleStart() % 900 + m_Angle;
673  bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise?
674 
675  // Make the angle positive, so we go clockwise and merge points belonging to the arc
676  if( !directionCW )
677  {
678  angle = 900 - angle;
679  quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
680  }
681 
682  while( angle > 900 )
683  {
684  switch( quarter )
685  {
686  case 0:
687  aBBox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); // down
688  break;
689 
690  case 1:
691  aBBox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); // left
692  break;
693 
694  case 2:
695  aBBox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); // up
696  break;
697 
698  case 3:
699  aBBox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); // right
700  break;
701  }
702 
703  if( directionCW )
704  ++quarter;
705  else
706  quarter += 3; // -1 modulo arithmetic
707 
708  quarter %= 4;
709  angle -= 900;
710  }
711 }
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
COLOR4D GetLayerColor(PCB_LAYER_ID aLayer) const
Function GetLayerColor gets a layer color for any valid layer, including non-copper ones...
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
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
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
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...
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
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
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)
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:445
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
void GetPoly(std::vector< wxPoint > &aOutput)
Converts Bezier curve to a polygon.
double GetArcAngleStart() const
function GetArcAngleStart()
EDA_RECT Common(const EDA_RECT &aRect) const
Function Common returns the area that is common with another rectangle.
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
#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
const wxPoint & GetOrigin() const
segment with non rounded ends
class MODULE, a footprint
Definition: typeinfo.h:101
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
PCB_LAYER_ID
A quick note on layer IDs:
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
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.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
Bezier curves to polygon converter.
Definition: bezier_curves.h:34
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
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 GetWidth() const
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
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
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:68
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
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:438
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...