KiCad PCB EDA Suite
class_dimension.h
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, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef DIMENSION_H_
31 #define DIMENSION_H_
32 
33 
34 #include <class_board_item.h>
35 #include <class_pcb_text.h>
36 
37 
38 class LINE_READER;
39 class EDA_DRAW_PANEL;
40 class TEXTE_PCB;
41 class MSG_PANEL_ITEM;
42 
43 
62 class DIMENSION : public BOARD_ITEM
63 {
64  int m_Width;
65  int m_Shape;
67  bool m_UseMils;
68  int m_Value;
69  int m_Height;
71 
72 public:
73 // TODO private: These member should be private. they are public only due to legacy code
79 
80  DIMENSION( BOARD_ITEM* aParent );
81 
82  // Do not create a copy constructor & operator=.
83  // The ones generated by the compiler are adequate.
84 
85  ~DIMENSION();
86 
87  static inline bool ClassOf( const EDA_ITEM* aItem )
88  {
89  return aItem && PCB_DIMENSION_T == aItem->Type();
90  }
91 
92  void SetValue( int aValue ) { m_Value = aValue; }
93 
94  int GetValue() const { return m_Value; }
95 
96  const wxPoint GetPosition() const override;
97 
98  void SetPosition( const wxPoint& aPos ) override;
99 
100  void SetTextSize( const wxSize& aTextSize )
101  {
102  m_Text.SetTextSize( aTextSize );
103  }
104 
105  void SetLayer( PCB_LAYER_ID aLayer ) override;
106 
107  void SetShape( int aShape ) { m_Shape = aShape; }
108  int GetShape() const { return m_Shape; }
109 
110  int GetWidth() const { return m_Width; }
111  void SetWidth( int aWidth ) { m_Width = aWidth; }
112 
118  void SetOrigin( const wxPoint& aOrigin );
119 
124  const wxPoint& GetOrigin() const
125  {
126  return m_featureLineGO;
127  }
128 
134  void SetEnd( const wxPoint& aEnd );
135 
140  const wxPoint& GetEnd()
141  {
142  return m_featureLineDO;
143  }
144 
150  void SetHeight( int aHeight );
151 
156  int GetHeight() const
157  {
158  return m_Height;
159  }
160 
165  void UpdateHeight();
166 
172  double GetAngle() const
173  {
174  wxPoint delta( m_featureLineDO - m_featureLineGO );
175 
176  return atan2( (double)delta.y, (double)delta.x );
177  }
178 
183  void AdjustDimensionDetails();
184 
185  void GetUnits( EDA_UNITS_T& aUnits, bool& aUseMils ) const
186  {
187  aUnits = m_Unit;
188  aUseMils = m_UseMils;
189  }
190 
191  void SetUnits( EDA_UNITS_T aUnits, bool aUseMils )
192  {
193  m_Unit = aUnits;
194  m_UseMils = aUseMils;
195  }
196 
197  void SetText( const wxString& NewText );
198  const wxString GetText() const;
199 
200  TEXTE_PCB& Text() { return m_Text; }
201  TEXTE_PCB& Text() const { return *(const_cast<TEXTE_PCB*> (&m_Text)); }
202 
203  void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
204  GR_DRAWMODE aColorMode, const wxPoint& offset = ZeroOffset ) override;
205 
210  void Move( const wxPoint& offset ) override;
211 
212  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
213 
214  void Flip( const wxPoint& aCentre ) override;
215 
223  void Mirror( const wxPoint& axis_pos );
224 
225  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
226 
227  bool HitTest( const wxPoint& aPosition ) const override;
228 
229  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
230 
231  wxString GetClass() const override
232  {
233  return wxT( "DIMENSION" );
234  }
235 
236  // Virtual function
237  const EDA_RECT GetBoundingBox() const override;
238 
239  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
240 
241  BITMAP_DEF GetMenuImage() const override;
242 
243  EDA_ITEM* Clone() const override;
244 
245  virtual const BOX2I ViewBBox() const override;
246 
247  virtual void SwapData( BOARD_ITEM* aImage ) override;
248 
249 #if defined(DEBUG)
250  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
251 #endif
252 };
253 
254 #endif // DIMENSION_H_
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void Mirror(const wxPoint &axis_pos)
Function Mirror Mirror the Dimension , relative to a given horizontal axis the text is not mirrored...
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
void SetPosition(const wxPoint &aPos) override
PNG memory record (file in memory).
Definition: bitmap_types.h:43
TEXTE_PCB class definition.
void SetText(const wxString &NewText)
wxPoint m_crossBarF
int m_Height
length of feature lines
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
wxPoint m_arrowD1F
void GetUnits(EDA_UNITS_T &aUnits, bool &aUseMils) const
TEXTE_PCB & Text() const
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
int GetWidth() const
DIMENSION(BOARD_ITEM *aParent)
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
const wxString GetText() const
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aColorMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
TEXTE_PCB m_Text
int m_Shape
Currently always 0.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
wxPoint m_featureLineDF
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
double GetAngle() const
Function GetAngle Returns angle of the crossbar.
static const int delta[8][2]
Definition: solve.cpp:112
void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
static wxPoint ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
wxPoint m_featureLineGO
EDA_UNITS_T m_Unit
0 = inches, 1 = mm
PCB_LAYER_ID
A quick note on layer IDs:
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void SetValue(int aValue)
bool m_UseMils
If inches, use mils.
const wxPoint & GetEnd()
Function GetEnd.
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void SetTextSize(const wxSize &aTextSize)
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
const wxPoint & GetOrigin() const
Function GetOrigin.
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
void SetShape(int aShape)
wxPoint m_arrowG1F
wxPoint m_arrowD2F
wxPoint m_arrowG2F
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
wxString GetClass() const override
Function GetClass returns the class name.
void AdjustDimensionDetails()
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension...
void SetUnits(EDA_UNITS_T aUnits, bool aUseMils)
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
int m_Width
Line width.
int GetShape() const
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
void Move(const wxPoint &offset) override
Function Move.
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
TEXTE_PCB & Text()
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
static bool ClassOf(const EDA_ITEM *aItem)
wxPoint m_crossBarO
const wxPoint GetPosition() const override
int GetValue() const
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
void SetWidth(int aWidth)
void UpdateHeight()
Function UpdateHeight Updates stored height basing on points coordinates.
wxPoint m_featureLineDO
int GetHeight() const
Function GetHeight Returns the length of feature lines.
int m_Value
value of PCB dimensions.
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
EDA_UNITS_T
Definition: common.h:159
Class DIMENSION.
wxPoint m_featureLineGF