KiCad PCB EDA Suite
class_dimension.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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2012 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 
27 #include <fctsys.h>
28 #include <macros.h>
29 #include <gr_basic.h>
30 #include <trigo.h>
31 #include <kicad_string.h>
32 #include <richio.h>
33 #include <bitmaps.h>
34 #include <pcb_edit_frame.h>
35 
36 #include <base_units.h>
37 #include <class_board.h>
38 #include <class_dimension.h>
39 #include <class_pcb_text.h>
40 #include <math/util.h> // for KiROUND
41 #include <pgm_base.h>
44 
45 
47  : BOARD_ITEM( aParent, PCB_DIMENSION_T ),
48  m_Width( Millimeter2iu( 0.2 ) ),
49  m_Unit( EDA_UNITS::INCHES ),
50  m_UseMils( false ),
51  m_Value( 0 ),
52  m_Height( 0 ),
53  m_Text( this )
54 {
56  m_Shape = 0;
57 }
58 
59 
61 {
62 }
63 
64 
65 void DIMENSION::SetPosition( const wxPoint& aPos )
66 {
67  m_Text.SetTextPos( aPos );
68 }
69 
70 
72 {
73  return m_Text.GetTextPos();
74 }
75 
76 
77 void DIMENSION::SetText( const wxString& aNewText )
78 {
79  m_Text.SetText( aNewText );
80 }
81 
82 
83 const wxString DIMENSION::GetText() const
84 {
85  return m_Text.GetText();
86 }
87 
88 
90 {
91  m_Layer = aLayer;
92  m_Text.SetLayer( aLayer );
93 }
94 
95 
96 void DIMENSION::Move( const wxPoint& offset )
97 {
98  m_Text.Offset( offset );
99 
100  m_crossBarO += offset;
101  m_crossBarF += offset;
102  m_featureLineGO += offset;
103  m_featureLineGF += offset;
104  m_featureLineDO += offset;
105  m_featureLineDF += offset;
106  m_arrowG1F += offset;
107  m_arrowG2F += offset;
108  m_arrowD1F += offset;
109  m_arrowD2F += offset;
110 }
111 
112 
113 void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle )
114 {
115  wxPoint tmp = m_Text.GetTextPos();
116  RotatePoint( &tmp, aRotCentre, aAngle );
117  m_Text.SetTextPos( tmp );
118 
119  double newAngle = m_Text.GetTextAngle() + aAngle;
120 
121  if( newAngle >= 3600 )
122  newAngle -= 3600;
123 
124  if( newAngle > 900 && newAngle < 2700 )
125  newAngle -= 1800;
126 
127  m_Text.SetTextAngle( newAngle );
128 
129  RotatePoint( &m_crossBarO, aRotCentre, aAngle );
130  RotatePoint( &m_crossBarF, aRotCentre, aAngle );
131  RotatePoint( &m_featureLineGO, aRotCentre, aAngle );
132  RotatePoint( &m_featureLineGF, aRotCentre, aAngle );
133  RotatePoint( &m_featureLineDO, aRotCentre, aAngle );
134  RotatePoint( &m_featureLineDF, aRotCentre, aAngle );
135  RotatePoint( &m_arrowG1F, aRotCentre, aAngle );
136  RotatePoint( &m_arrowG2F, aRotCentre, aAngle );
137  RotatePoint( &m_arrowD1F, aRotCentre, aAngle );
138  RotatePoint( &m_arrowD2F, aRotCentre, aAngle );
139 }
140 
141 
142 void DIMENSION::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
143 {
144  Mirror( aCentre );
145 
146  // DIMENSION items are not usually on copper layers, so
147  // copper layers count is not taken in accoun in Flip transform
148  SetLayer( FlipLayer( GetLayer() ) );
149 }
150 
151 
152 void DIMENSION::Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight )
153 {
154  int axis = aMirrorLeftRight ? axis_pos.x : axis_pos.y;
155  wxPoint newPos = m_Text.GetTextPos();
156 
157 #define INVERT( pos ) (pos) = axis - ( (pos) - axis )
158 
159  if( aMirrorLeftRight )
160  INVERT( newPos.x );
161  else
162  INVERT( newPos.y );
163 
164  m_Text.SetTextPos( newPos );
165 
166  // invert angle
168 
169  if( aMirrorLeftRight )
170  {
171  INVERT( m_crossBarO.y );
172  INVERT( m_crossBarF.y );
177  INVERT( m_arrowG1F.y );
178  INVERT( m_arrowG2F.y );
179  INVERT( m_arrowD1F.y );
180  INVERT( m_arrowD2F.y );
181  }
182  else
183  {
184  INVERT( m_crossBarO.y );
185  INVERT( m_crossBarF.y );
190  INVERT( m_arrowG1F.y );
191  INVERT( m_arrowG2F.y );
192  INVERT( m_arrowD1F.y );
193  INVERT( m_arrowD2F.y );
194  }
195 }
196 
197 
198 void DIMENSION::SetOrigin( const wxPoint& aOrigin, int aPrecision )
199 {
200  m_featureLineGO = aOrigin;
201 
202  AdjustDimensionDetails( aPrecision );
203 }
204 
205 
206 void DIMENSION::SetEnd( const wxPoint& aEnd, int aPrecision )
207 {
208  m_featureLineDO = aEnd;
209 
210  AdjustDimensionDetails( aPrecision );
211 }
212 
213 
214 void DIMENSION::SetHeight( int aHeight, int aPrecision )
215 {
216  m_Height = aHeight;
217 
218  AdjustDimensionDetails( aPrecision );
219 }
220 
221 
223 {
224  VECTOR2D featureLine( m_crossBarO - m_featureLineGO );
226 
227  if( featureLine.Cross( crossBar ) > 0 )
228  m_Height = -featureLine.EuclideanNorm();
229  else
230  m_Height = featureLine.EuclideanNorm();
231 }
232 
233 
234 void DIMENSION::AdjustDimensionDetails( int aPrecision )
235 {
236  const int arrowz = Mils2iu( 50 ); // size of arrows
237  int ii;
238  int measure, deltax, deltay; // value of the measure on X and Y axes
239  int arrow_up_X = 0, arrow_up_Y = 0; // coordinates of arrow line /
240  int arrow_dw_X = 0, arrow_dw_Y = 0; // coordinates of arrow line '\'
241  int hx, hy; // dimension line interval
242  double angle, angle_f;
243 
244  // Init layer :
245  m_Text.SetLayer( GetLayer() );
246 
247  // calculate the size of the dimension (text + line above the text)
249 
250  deltax = m_featureLineDO.x - m_featureLineGO.x;
251  deltay = m_featureLineDO.y - m_featureLineGO.y;
252 
253  // Calculate dimension value
254  measure = KiROUND( hypot( deltax, deltay ) );
255 
256  angle = atan2( (double)deltay, (double)deltax );
257 
258  // Calculation of parameters X and Y dimensions of the arrows and lines.
259  hx = hy = ii;
260 
261  // Taking into account the slope of the side lines.
262  if( measure )
263  {
264  hx = abs( KiROUND( ( (double) deltay * hx ) / measure ) );
265  hy = abs( KiROUND( ( (double) deltax * hy ) / measure ) );
266 
268  hx = -hx;
269 
270  if( m_featureLineGO.x == m_crossBarO.x )
271  hx = 0;
272 
274  hy = -hy;
275 
276  if( m_featureLineGO.y == m_crossBarO.y )
277  hy = 0;
278 
279  angle_f = angle + DEG2RAD( 27.5 );
280  arrow_up_X = wxRound( arrowz * cos( angle_f ) );
281  arrow_up_Y = wxRound( arrowz * sin( angle_f ) );
282  angle_f = angle - DEG2RAD( 27.5 );
283  arrow_dw_X = wxRound( arrowz * cos( angle_f ) );
284  arrow_dw_Y = wxRound( arrowz * sin( angle_f ) );
285  }
286 
287  int dx = KiROUND( m_Height * cos( angle + M_PI / 2 ) );
288  int dy = KiROUND( m_Height * sin( angle + M_PI / 2 ) );
293 
294  m_arrowG1F.x = m_crossBarO.x + arrow_up_X;
295  m_arrowG1F.y = m_crossBarO.y + arrow_up_Y;
296 
297  m_arrowG2F.x = m_crossBarO.x + arrow_dw_X;
298  m_arrowG2F.y = m_crossBarO.y + arrow_dw_Y;
299 
300  /* The right arrow is symmetrical to the left.
301  * / = -\ and \ = -/
302  */
303  m_arrowD1F.x = m_crossBarF.x - arrow_dw_X;
304  m_arrowD1F.y = m_crossBarF.y - arrow_dw_Y;
305 
306  m_arrowD2F.x = m_crossBarF.x - arrow_up_X;
307  m_arrowD2F.y = m_crossBarF.y - arrow_up_Y;
308 
309  // Length of feature lines
310  double radius = ( m_Height +
311  ( std::copysign( 1.0, m_Height ) *
312  arrowz * sin( DEG2RAD( 27.5 ) ) ) );
313 
314  m_featureLineGF.x = m_featureLineGO.x - wxRound( radius * sin( angle ) );
315  m_featureLineGF.y = m_featureLineGO.y + wxRound( radius * cos( angle ) );
316 
317  m_featureLineDF.x = m_featureLineDO.x - wxRound( radius * sin( angle ) );
318  m_featureLineDF.y = m_featureLineDO.y + wxRound( radius * cos( angle ) );
319 
320  // Calculate the better text position and orientation:
321  radius = ( std::copysign( 1.0, m_Height ) * ii );
322 
323  wxPoint textPos;
324  textPos.x = ( m_crossBarF.x + m_crossBarO.x ) / 2;
325  textPos.y = ( m_crossBarF.y + m_crossBarO.y ) / 2;
326 
327  textPos.x -= KiROUND( radius * sin( angle ) );
328  textPos.y += KiROUND( radius * cos( angle ) );
329 
330  m_Text.SetTextPos( textPos );
331 
332  double newAngle = -RAD2DECIDEG( angle );
333 
334  NORMALIZE_ANGLE_POS( newAngle );
335 
336  if( newAngle > 900 && newAngle < 2700 )
337  newAngle -= 1800;
338 
339  m_Text.SetTextAngle( newAngle );
340 
341  m_Value = measure;
342 
344  aPrecision += 2;
345  else if( !m_UseMils )
346  aPrecision += 3;
347 
348  wxString text;
349  wxString format = wxT( "%." ) + wxString::Format( "%i", aPrecision ) + wxT( "f" );
350 
351  text.Printf( format, To_User_Unit( m_Unit, m_Value, m_UseMils ) );
352  text += " ";
354 
355  SetText( text );
356 }
357 
358 
359 void DIMENSION::Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset )
360 {
361  BOARD* brd = GetBoard();
362 
363  if( brd->IsLayerVisible( m_Layer ) == false )
364  return;
365 
366  m_Text.Print( aFrame, DC, offset );
367 
368  COLOR4D gcolor = Pgm().GetSettingsManager().GetColorSettings()->GetColor( m_Layer );
369  auto displ_opts = aFrame->GetDisplayOptions();
370  bool filled = displ_opts.m_DisplayDrawItemsFill;
371  int width = m_Width;
372 
373  if( filled )
374  {
375  GRLine( nullptr, DC, m_crossBarO + offset, m_crossBarF + offset, width, gcolor );
376  GRLine( nullptr, DC, m_featureLineGO + offset, m_featureLineGF + offset, width, gcolor );
377  GRLine( nullptr, DC, m_featureLineDO + offset, m_featureLineDF + offset, width, gcolor );
378  GRLine( nullptr, DC, m_crossBarF + offset, m_arrowD1F + offset, width, gcolor );
379  GRLine( nullptr, DC, m_crossBarF + offset, m_arrowD2F + offset, width, gcolor );
380  GRLine( nullptr, DC, m_crossBarO + offset, m_arrowG1F + offset, width, gcolor );
381  GRLine( nullptr, DC, m_crossBarO + offset, m_arrowG2F + offset, width, gcolor );
382  }
383  else
384  {
385  GRCSegm( nullptr, DC, m_crossBarO + offset, m_crossBarF + offset, width, gcolor );
386  GRCSegm( nullptr, DC, m_featureLineGO + offset, m_featureLineGF + offset, width, gcolor );
387  GRCSegm( nullptr, DC, m_featureLineDO + offset, m_featureLineDF + offset, width, gcolor );
388  GRCSegm( nullptr, DC, m_crossBarF + offset, m_arrowD1F + offset, width, gcolor );
389  GRCSegm( nullptr, DC, m_crossBarF + offset, m_arrowD2F + offset, width, gcolor );
390  GRCSegm( nullptr, DC, m_crossBarO + offset, m_arrowG1F + offset, width, gcolor );
391  GRCSegm( nullptr, DC, m_crossBarO + offset, m_arrowG2F + offset, width, gcolor );
392  }
393 }
394 
395 
396 // see class_cotation.h
397 void DIMENSION::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
398 {
399  // for now, display only the text within the DIMENSION using class TEXTE_PCB.
400  m_Text.GetMsgPanelInfo( aUnits, aList );
401 }
402 
403 
404 bool DIMENSION::HitTest( const wxPoint& aPosition, int aAccuracy ) const
405 {
406  if( m_Text.TextHitTest( aPosition ) )
407  return true;
408 
409  int dist_max = aAccuracy + ( m_Width / 2 );
410 
411  // Locate SEGMENTS
412 
413  if( TestSegmentHit( aPosition, m_crossBarO, m_crossBarF, dist_max ) )
414  return true;
415 
416  if( TestSegmentHit( aPosition, m_featureLineGO, m_featureLineGF, dist_max ) )
417  return true;
418 
419  if( TestSegmentHit( aPosition, m_featureLineDO, m_featureLineDF, dist_max ) )
420  return true;
421 
422  if( TestSegmentHit( aPosition, m_crossBarF, m_arrowD1F, dist_max ) )
423  return true;
424 
425  if( TestSegmentHit( aPosition, m_crossBarF, m_arrowD2F, dist_max ) )
426  return true;
427 
428  if( TestSegmentHit( aPosition, m_crossBarO, m_arrowG1F, dist_max ) )
429  return true;
430 
431  if( TestSegmentHit( aPosition, m_crossBarO, m_arrowG2F, dist_max ) )
432  return true;
433 
434  return false;
435 }
436 
437 
438 bool DIMENSION::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
439 {
440  EDA_RECT arect = aRect;
441  arect.Inflate( aAccuracy );
442 
443  EDA_RECT rect = GetBoundingBox();
444  if( aAccuracy )
445  rect.Inflate( aAccuracy );
446 
447  if( aContained )
448  return arect.Contains( rect );
449 
450  return arect.Intersects( rect );
451 }
452 
453 
455 {
456  EDA_RECT bBox;
457  int xmin, xmax, ymin, ymax;
458 
459  bBox = m_Text.GetTextBox( -1 );
460  xmin = bBox.GetX();
461  xmax = bBox.GetRight();
462  ymin = bBox.GetY();
463  ymax = bBox.GetBottom();
464 
465  xmin = std::min( xmin, m_crossBarO.x );
466  xmin = std::min( xmin, m_crossBarF.x );
467  ymin = std::min( ymin, m_crossBarO.y );
468  ymin = std::min( ymin, m_crossBarF.y );
469  xmax = std::max( xmax, m_crossBarO.x );
470  xmax = std::max( xmax, m_crossBarF.x );
471  ymax = std::max( ymax, m_crossBarO.y );
472  ymax = std::max( ymax, m_crossBarF.y );
473 
474  xmin = std::min( xmin, m_featureLineGO.x );
475  xmin = std::min( xmin, m_featureLineGF.x );
476  ymin = std::min( ymin, m_featureLineGO.y );
477  ymin = std::min( ymin, m_featureLineGF.y );
478  xmax = std::max( xmax, m_featureLineGO.x );
479  xmax = std::max( xmax, m_featureLineGF.x );
480  ymax = std::max( ymax, m_featureLineGO.y );
481  ymax = std::max( ymax, m_featureLineGF.y );
482 
483  xmin = std::min( xmin, m_featureLineDO.x );
484  xmin = std::min( xmin, m_featureLineDF.x );
485  ymin = std::min( ymin, m_featureLineDO.y );
486  ymin = std::min( ymin, m_featureLineDF.y );
487  xmax = std::max( xmax, m_featureLineDO.x );
488  xmax = std::max( xmax, m_featureLineDF.x );
489  ymax = std::max( ymax, m_featureLineDO.y );
490  ymax = std::max( ymax, m_featureLineDF.y );
491 
492  bBox.SetX( xmin );
493  bBox.SetY( ymin );
494  bBox.SetWidth( xmax - xmin + 1 );
495  bBox.SetHeight( ymax - ymin + 1 );
496 
497  bBox.Normalize();
498 
499  return bBox;
500 }
501 
502 
503 wxString DIMENSION::GetSelectMenuText( EDA_UNITS aUnits ) const
504 {
505  return wxString::Format( _( "Dimension \"%s\" on %s" ), GetText(), GetLayerName() );
506 }
507 
508 
510 {
511  return add_dimension_xpm;
512 }
513 
514 
516 {
517  BOX2I dimBBox = BOX2I( VECTOR2I( GetBoundingBox().GetPosition() ),
518  VECTOR2I( GetBoundingBox().GetSize() ) );
519  dimBBox.Merge( m_Text.ViewBBox() );
520 
521  return dimBBox;
522 }
523 
524 
526 {
527  return new DIMENSION( *this );
528 }
529 
531 {
532  assert( aImage->Type() == PCB_DIMENSION_T );
533 
534  std::swap( *((DIMENSION*) this), *((DIMENSION*) aImage) );
535 }
double To_User_Unit(EDA_UNITS aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:95
EDA_UNITS
Definition: common.h:184
extended_type Cross(const VECTOR2< T > &aVector) const
Function Cross() computes cross product of self with aVector.
Definition: vector2d.h:484
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:237
BOX2< VECTOR2I > BOX2I
Definition: box2.h:521
void SetTextAngle(double aAngle)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
void SetPosition(const wxPoint &aPos) override
PNG memory record (file in memory).
Definition: bitmap_def.h:29
TEXTE_PCB class definition.
void SetText(const wxString &NewText)
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.
wxPoint m_crossBarF
int m_Height
length of feature lines
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
wxPoint m_arrowD1F
int GetX() const
Definition: eda_rect.h:111
DIMENSION(BOARD_ITEM *aParent)
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:485
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:231
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
double GetTextAngle() const
Definition: eda_text.h:158
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
double RAD2DECIDEG(double rad)
Definition: trigo.h:219
TEXTE_PCB m_Text
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:312
void SetHeight(int aHeight, int aPrecision)
Function SetHeight Sets the length of feature lines.
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
int m_Shape
Currently always 0.
wxPoint m_featureLineDF
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
void Mirror(const wxPoint &axis_pos, bool aMirrorLeftRight=false)
Function Mirror Mirror the Dimension , relative to a given horizontal axis the text is not mirrored.
wxString GetAbbreviatedUnitsLabel(EDA_UNITS aUnit, bool aUseMils, EDA_DATA_TYPE aType)
Get the units string for a given units type.
Definition: base_units.cpp:467
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions returns the display options current in use Display options are relative to...
bool Contains(const wxPoint &aPoint) const
Function Contains.
void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
This file contains miscellaneous commonly used macros and functions.
int GetBottom() const
Definition: eda_rect.h:124
int GetTextHeight() const
Definition: eda_text.h:229
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
wxPoint m_featureLineGO
PCB_LAYER_ID m_Layer
DIMENSION class definition.
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
PCB_LAYER_ID
A quick note on layer IDs:
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
bool m_UseMils
If inches, use mils.
void SetOrigin(const wxPoint &aOrigin, int aPrecision)
Function SetOrigin Sets a new origin of the crossbar line.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
void SetEnd(const wxPoint &aEnd, int aPrecision)
Function SetEnd Sets a new end of the crossbar line.
void SetHeight(int val)
Definition: eda_rect.h:186
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:184
wxPoint m_arrowG1F
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
int GetRight() const
Definition: eda_rect.h:121
wxPoint m_arrowD2F
wxPoint m_arrowG2F
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
void SetX(int val)
Definition: eda_rect.h:168
const BITMAP_OPAQUE add_dimension_xpm[1]
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: box2.h:385
void SetWidth(int val)
Definition: eda_rect.h:180
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:230
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &offset=ZeroOffset) override
Function Print BOARD_ITEMs have their own color information.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
void SetY(int val)
Definition: eda_rect.h:174
int m_Width
Line width.
void AdjustDimensionDetails(int aPrecision)
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension.
void Normalize()
Function Normalize ensures that the height ant width are positive.
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &offset=ZeroOffset) override
Function Print BOARD_ITEMs have their own color information.
#define INVERT(pos)
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:431
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
see class PGM_BASE
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
double DEG2RAD(double deg)
Definition: trigo.h:214
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
#define _(s)
Definition: 3d_actions.cpp:33
void Move(const wxPoint &offset) override
Function Move.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:336
int GetY() const
Definition: eda_rect.h:112
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
wxPoint m_crossBarO
const wxPoint GetPosition() const override
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:299
const wxString GetText() const
void UpdateHeight()
Function UpdateHeight Updates stored height basing on points coordinates.
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
wxPoint m_featureLineDO
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int m_Value
value of PCB dimensions.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
DIMENSION.
EDA_UNITS m_Unit
0 = inches, 1 = mm
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
wxPoint m_featureLineGF