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 <trigo.h>
40 #include <msgpanel.h>
41 #include <bitmaps.h>
42 
43 #include <wxPcbStruct.h>
44 
45 #include <pcbnew.h>
46 
47 #include <class_board.h>
48 #include <class_module.h>
49 #include <class_drawsegment.h>
50 #include <base_units.h>
51 
52 
54  BOARD_ITEM( aParent, idtype )
55 {
56  m_Type = 0;
57  m_Angle = 0;
58  m_Flags = 0;
60  m_Width = Millimeter2iu( 0.15 ); // Gives a decent width
61 }
62 
63 
65 {
66 }
67 
68 
69 void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle )
70 {
71  switch( m_Shape )
72  {
73  case S_ARC:
74  case S_SEGMENT:
75  case S_CIRCLE:
76  // these can all be done by just rotating the start and end points
77  RotatePoint( &m_Start, aRotCentre, aAngle);
78  RotatePoint( &m_End, aRotCentre, aAngle);
79  break;
80 
81  case S_POLYGON:
82  for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
83  {
84  RotatePoint( &m_PolyPoints[ii], aRotCentre, aAngle);
85  }
86  break;
87 
88  case S_CURVE:
89  RotatePoint( &m_Start, aRotCentre, aAngle);
90  RotatePoint( &m_End, aRotCentre, aAngle);
91 
92  for( unsigned int ii = 0; ii < m_BezierPoints.size(); ii++ )
93  {
94  RotatePoint( &m_BezierPoints[ii], aRotCentre, aAngle);
95  }
96  break;
97 
98  case S_RECT:
99  default:
100  // un-handled edge transform
101  wxASSERT_MSG( false, wxT( "DRAWSEGMENT::Rotate not implemented for "
102  + ShowShape( m_Shape ) ) );
103  break;
104  }
105 };
106 
107 void DRAWSEGMENT::Flip( const wxPoint& aCentre )
108 {
109  m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
110  m_End.y = aCentre.y - (m_End.y - aCentre.y);
111 
112  if( m_Shape == S_ARC )
113  m_Angle = -m_Angle;
114 
115  // DRAWSEGMENT items are not allowed on copper layers, so
116  // copper layers count is not taken in accoun in Flip transform
117  SetLayer( FlipLayer( GetLayer() ) );
118 }
119 
121 {
122  wxPoint c;
123 
124  switch( m_Shape )
125  {
126  case S_ARC:
127  case S_CIRCLE:
128  c = m_Start;
129  break;
130 
131  case S_SEGMENT:
132  // Midpoint of the line
133  c = ( GetStart() + GetEnd() ) / 2;
134  break;
135 
136  case S_POLYGON:
137  case S_RECT:
138  case S_CURVE:
139  c = GetBoundingBox().Centre();
140  break;
141 
142  default:
143  wxASSERT_MSG( false, "DRAWSEGMENT::GetCentre not implemented for shape"
144  + ShowShape( GetShape() ) );
145  break;
146  }
147 
148  return c;
149 }
150 
152 {
153  wxPoint endPoint; // start of arc
154 
155  switch( m_Shape )
156  {
157  case S_ARC:
158  // rotate the starting point of the arc, given by m_End, through the
159  // angle m_Angle to get the ending point of the arc.
160  // m_Start is the arc centre
161  endPoint = m_End; // m_End = start point of arc
162  RotatePoint( &endPoint, m_Start, -m_Angle );
163  break;
164 
165  default:
166  ;
167  }
168 
169  return endPoint; // after rotation, the end of the arc.
170 }
171 
173 {
174  // due to the Y axis orient atan2 needs - y value
175  double angleStart = ArcTangente( GetArcStart().y - GetCenter().y,
176  GetArcStart().x - GetCenter().x );
177 
178  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
179  // because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg.
180  // and this is not easy to handle in calculations
181  NORMALIZE_ANGLE_POS( angleStart );
182 
183  return angleStart;
184 }
185 
186 
187 void DRAWSEGMENT::SetAngle( double aAngle )
188 {
189  m_Angle = NormalizeAngle360( aAngle );
190 }
191 
192 
194 {
195  if( !m_Parent || m_Parent->Type() != PCB_MODULE_T )
196  return NULL;
197 
198  return (MODULE*) m_Parent;
199 }
200 
201 
202 void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
203  const wxPoint& aOffset )
204 {
205  int ux0, uy0, dx, dy;
206  int l_trace;
207  int radius;
208 
209  PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
210 
211  BOARD * brd = GetBoard( );
212 
213  if( brd->IsLayerVisible( GetLayer() ) == false )
214  return;
215 
216  auto frame = static_cast<PCB_EDIT_FRAME*> ( panel->GetParent() );
217  auto color = frame->Settings().Colors().GetLayerColor( GetLayer() );
218 
219  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
220 
221  if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
222  {
223  if( !IsOnLayer( curr_layer ) && !IsOnLayer( Edge_Cuts ) )
225  }
226 
227  GRSetDrawMode( DC, draw_mode );
228  l_trace = m_Width >> 1; // half trace width
229 
230  // Line start point or Circle and Arc center
231  ux0 = m_Start.x + aOffset.x;
232  uy0 = m_Start.y + aOffset.y;
233 
234  // Line end point or circle and arc start point
235  dx = m_End.x + aOffset.x;
236  dy = m_End.y + aOffset.y;
237 
238  bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED;
239 
240  if( m_Flags & FORCE_SKETCH )
241  filled = SKETCH;
242 
243  switch( m_Shape )
244  {
245  case S_CIRCLE:
246  radius = KiROUND( Distance( ux0, uy0, dx, dy ) );
247 
248  if( filled )
249  {
250  GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius, m_Width, color );
251  }
252  else
253  {
254  GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius - l_trace, color );
255  GRCircle( panel->GetClipBox(), DC, ux0, uy0, radius + l_trace, color );
256  }
257 
258  break;
259 
260  case S_ARC:
261  double StAngle, EndAngle;
262  radius = KiROUND( Distance( ux0, uy0, dx, dy ) );
263  StAngle = ArcTangente( dy - uy0, dx - ux0 );
264  EndAngle = StAngle + m_Angle;
265 
266  if( !panel->GetPrintMirrored() )
267  {
268  if( StAngle > EndAngle )
269  std::swap( StAngle, EndAngle );
270  }
271  else // Mirrored mode: arc orientation is reversed
272  {
273  if( StAngle < EndAngle )
274  std::swap( StAngle, EndAngle );
275  }
276 
277  if( filled )
278  {
279  GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
280  radius, m_Width, color );
281  }
282  else
283  {
284  GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
285  radius - l_trace, color );
286  GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
287  radius + l_trace, color );
288  }
289 
290  break;
291 
292  case S_CURVE:
293  {
294  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
295  BEZIER_POLY converter( ctrlPoints );
296  converter.GetPoly( m_BezierPoints );
297  }
298 
299  for( unsigned int i=1; i < m_BezierPoints.size(); i++ )
300  {
301  if( filled )
302  {
303  GRFillCSegm( panel->GetClipBox(), DC,
304  m_BezierPoints[i].x, m_BezierPoints[i].y,
305  m_BezierPoints[i-1].x, m_BezierPoints[i-1].y,
306  m_Width, color );
307  }
308  else
309  {
310  GRCSegm( panel->GetClipBox(), DC,
311  m_BezierPoints[i].x, m_BezierPoints[i].y,
312  m_BezierPoints[i-1].x, m_BezierPoints[i-1].y,
313  m_Width, color );
314  }
315  }
316 
317  break;
318 
319  default:
320  if( filled )
321  {
322  GRFillCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
323  }
324  else
325  {
326  GRCSegm( panel->GetClipBox(), DC, ux0, uy0, dx, dy, m_Width, color );
327  }
328 
329  break;
330  }
331 }
332 
333 
334 // see pcbstruct.h
335 void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
336 {
337  wxString msg;
338  wxASSERT( m_Parent );
339 
340  msg = _( "Drawing" );
341 
342  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
343 
344  wxString shape = _( "Shape" );
345 
346  switch( m_Shape )
347  {
348  case S_CIRCLE:
349  aList.push_back( MSG_PANEL_ITEM( shape, _( "Circle" ), RED ) );
350  break;
351 
352  case S_ARC:
353  aList.push_back( MSG_PANEL_ITEM( shape, _( "Arc" ), RED ) );
354  msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 );
355  aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, RED ) );
356  break;
357 
358  case S_CURVE:
359  aList.push_back( MSG_PANEL_ITEM( shape, _( "Curve" ), RED ) );
360  break;
361 
362  default:
363  {
364  aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) );
365 
367  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKGREEN ) );
368 
369  // angle counter-clockwise from 3'o-clock
370  const double deg = RAD2DEG( atan2( (double)( m_Start.y - m_End.y ),
371  (double)( m_End.x - m_Start.x ) ) );
372  msg.Printf( wxT( "%.1f" ), deg );
373  aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
374  }
375  }
376 
377  wxString start;
378  start << GetStart();
379 
380  wxString end;
381  end << GetEnd();
382 
383  aList.push_back( MSG_PANEL_ITEM( start, end, DARKGREEN ) );
384  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKBROWN ) );
385  msg = ::CoordinateToString( m_Width );
386  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
387 }
388 
389 
391 {
392  EDA_RECT bbox;
393 
394  bbox.SetOrigin( m_Start );
395 
396  switch( m_Shape )
397  {
398  case S_SEGMENT:
399  bbox.SetEnd( m_End );
400  break;
401 
402  case S_CIRCLE:
403  bbox.Inflate( GetRadius() );
404  break;
405 
406  case S_ARC:
407  computeArcBBox( bbox );
408  break;
409 
410  case S_POLYGON:
411  {
412  wxPoint p_end;
413  MODULE* module = GetParentModule();
414 
415  for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
416  {
417  wxPoint pt = m_PolyPoints[ii];
418 
419  if( module ) // Transform, if we belong to a module
420  {
421  RotatePoint( &pt, module->GetOrientation() );
422  pt += module->GetPosition();
423  }
424 
425  if( ii == 0 )
426  p_end = pt;
427 
428  bbox.SetX( std::min( bbox.GetX(), pt.x ) );
429  bbox.SetY( std::min( bbox.GetY(), pt.y ) );
430  p_end.x = std::max( p_end.x, pt.x );
431  p_end.y = std::max( p_end.y, pt.y );
432  }
433 
434  bbox.SetEnd( p_end );
435  }
436  break;
437 
438  default:
439  break;
440  }
441 
442  bbox.Inflate( ((m_Width+1) / 2) + 1 );
443  bbox.Normalize();
444 
445  return bbox;
446 }
447 
448 
449 bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
450 {
451  switch( m_Shape )
452  {
453  case S_CIRCLE:
454  case S_ARC:
455  {
456  wxPoint relPos = aPosition - GetCenter();
457  int radius = GetRadius();
458  int dist = KiROUND( EuclideanNorm( relPos ) );
459 
460  if( abs( radius - dist ) <= ( m_Width / 2 ) )
461  {
462  if( m_Shape == S_CIRCLE )
463  return true;
464 
465  // For arcs, the test point angle must be >= arc angle start
466  // and <= arc angle end
467  // However angle values > 360 deg are not easy to handle
468  // so we calculate the relative angle between arc start point and teast point
469  // this relative arc should be < arc angle if arc angle > 0 (CW arc)
470  // and > arc angle if arc angle < 0 (CCW arc)
471  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
472 
473  double arc_hittest = ArcTangente( relPos.y, relPos.x );
474 
475  // Calculate relative angle between the starting point of the arc, and the test point
476  arc_hittest -= arc_angle_start;
477 
478  // Normalise arc_hittest between 0 ... 360 deg
479  NORMALIZE_ANGLE_POS( arc_hittest );
480 
481  // Check angle: inside the arc angle when it is > 0
482  // and outside the not drawn arc when it is < 0
483  if( GetAngle() >= 0.0 )
484  {
485  if( arc_hittest <= GetAngle() )
486  return true;
487  }
488  else
489  {
490  if( arc_hittest >= (3600.0 + GetAngle()) )
491  return true;
492  }
493  }
494  }
495  break;
496 
497  case S_CURVE:
498  for( unsigned int i= 1; i < m_BezierPoints.size(); i++)
499  {
500  if( TestSegmentHit( aPosition, m_BezierPoints[i-1], m_BezierPoints[i-1], m_Width / 2 ) )
501  return true;
502  }
503  break;
504 
505  case S_SEGMENT:
506  if( TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 ) )
507  return true;
508  break;
509 
510  case S_POLYGON: // not yet handled
511  break;
512 
513  default:
514  wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
515  break;
516  }
517 
518  return false;
519 }
520 
521 
522 bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
523 {
524  EDA_RECT arect = aRect;
525  arect.Normalize();
526  arect.Inflate( aAccuracy );
527 
528  EDA_RECT arcRect;
529  EDA_RECT bb = GetBoundingBox();
530 
531  switch( m_Shape )
532  {
533  case S_CIRCLE:
534  // Test if area intersects or contains the circle:
535  if( aContained )
536  return arect.Contains( bb );
537  else
538  {
539  // If the rectangle does not intersect the bounding box, this is a much quicker test
540  if( !aRect.Intersects( bb ) )
541  {
542  return false;
543  }
544  else
545  {
546  return arect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() );
547  }
548 
549  }
550  break;
551 
552  case S_ARC:
553 
554  // Test for full containment of this arc in the rect
555  if( aContained )
556  {
557  return arect.Contains( bb );
558  }
559  // Test if the rect crosses the arc
560  else
561  {
562  arcRect = bb.Common( arect );
563 
564  /* All following tests must pass:
565  * 1. Rectangle must intersect arc BoundingBox
566  * 2. Rectangle must cross the outside of the arc
567  */
568  return arcRect.Intersects( arect ) &&
570  }
571  break;
572  case S_SEGMENT:
573  if( aContained )
574  {
575  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
576  }
577  else
578  {
579  // Account for the width of the line
580  arect.Inflate( GetWidth() / 2 );
581  return arect.Intersects( GetStart(), GetEnd() );
582  }
583 
584  break;
585 
586  case S_CURVE:
587  case S_POLYGON: // not yet handled
588  break;
589 
590  default:
591  wxASSERT_MSG( 0, wxString::Format( "unknown DRAWSEGMENT shape: %d", m_Shape ) );
592  break;
593  }
594 
595  return false;
596 }
597 
598 
600 {
601  wxString text;
602  wxString temp = ::LengthDoubleToString( GetLength() );
603 
604  text.Printf( _( "Pcb Graphic: %s, length %s on %s" ),
605  GetChars( ShowShape( m_Shape ) ),
606  GetChars( temp ), GetChars( GetLayerName() ) );
607 
608  return text;
609 }
610 
611 
613 {
614  return add_dashed_line_xpm;
615 }
616 
617 
619 {
620  return new DRAWSEGMENT( *this );
621 }
622 
623 
625 {
626  // For arcs - do not include the center point in the bounding box,
627  // it is redundant for displaying an arc
628  if( m_Shape == S_ARC )
629  {
630  EDA_RECT bbox;
631  bbox.SetOrigin( m_End );
632  computeArcBBox( bbox );
633  return BOX2I( bbox.GetOrigin(), bbox.GetSize() );
634  }
635 
636  return EDA_ITEM::ViewBBox();
637 }
638 
639 
641 {
642  // Do not include the center, which is not necessarily
643  // inside the BB of a arc with a small angle
644  aBBox.SetOrigin( m_End );
645 
646  wxPoint end = m_End;
647  RotatePoint( &end, m_Start, -m_Angle );
648  aBBox.Merge( end );
649 
650  // Determine the starting quarter
651  // 0 right-bottom
652  // 1 left-bottom
653  // 2 left-top
654  // 3 right-top
655  unsigned int quarter = 0; // assume right-bottom
656 
657  if( m_End.x < m_Start.x )
658  {
659  if( m_End.y <= m_Start.y )
660  quarter = 2;
661  else // ( m_End.y > m_Start.y )
662  quarter = 1;
663  }
664  else if( m_End.x >= m_Start.x )
665  {
666  if( m_End.y < m_Start.y )
667  quarter = 3;
668  else if( m_End.x == m_Start.x )
669  quarter = 1;
670  }
671 
672  int radius = GetRadius();
673  int angle = (int) GetArcAngleStart() % 900 + m_Angle;
674  bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise?
675 
676  // Make the angle positive, so we go clockwise and merge points belonging to the arc
677  if( !directionCW )
678  {
679  angle = 900 - angle;
680  quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
681  }
682 
683  while( angle > 900 )
684  {
685  switch( quarter )
686  {
687  case 0:
688  aBBox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); // down
689  break;
690 
691  case 1:
692  aBBox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); // left
693  break;
694 
695  case 2:
696  aBBox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); // up
697  break;
698 
699  case 3:
700  aBBox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); // right
701  break;
702  }
703 
704  if( directionCW )
705  ++quarter;
706  else
707  quarter += 3; // -1 modulo arithmetic
708 
709  quarter %= 4;
710  angle -= 900;
711  }
712 }
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:212
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:182
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:155
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:160
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
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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:169
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:189
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:187
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
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:181
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:451
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...