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 TEXTE_PCB;
40 class MSG_PANEL_ITEM;
41 
42 
61 class DIMENSION : public BOARD_ITEM
62 {
63  int m_Width;
64  int m_Shape;
66  bool m_UseMils;
67  int m_Value;
68  int m_Height;
70 
71 public:
72 // TODO private: These member should be private. they are public only due to legacy code
78 
79  DIMENSION( BOARD_ITEM* aParent );
80 
81  // Do not create a copy constructor & operator=.
82  // The ones generated by the compiler are adequate.
83 
84  ~DIMENSION();
85 
86  static inline bool ClassOf( const EDA_ITEM* aItem )
87  {
88  return aItem && PCB_DIMENSION_T == aItem->Type();
89  }
90 
91  void SetValue( int aValue ) { m_Value = aValue; }
92 
93  int GetValue() const { return m_Value; }
94 
95  const wxPoint GetPosition() const override;
96 
97  void SetPosition( const wxPoint& aPos ) override;
98 
99  void SetTextSize( const wxSize& aTextSize )
100  {
101  m_Text.SetTextSize( aTextSize );
102  }
103 
104  void SetLayer( PCB_LAYER_ID aLayer ) override;
105 
106  void SetShape( int aShape ) { m_Shape = aShape; }
107  int GetShape() const { return m_Shape; }
108 
109  int GetWidth() const { return m_Width; }
110  void SetWidth( int aWidth ) { m_Width = aWidth; }
111 
118  void SetOrigin( const wxPoint& aOrigin, int aPrecision );
119 
124  const wxPoint& GetOrigin() const
125  {
126  return m_featureLineGO;
127  }
128 
135  void SetEnd( const wxPoint& aEnd, int aPrecision );
136 
141  const wxPoint& GetEnd()
142  {
143  return m_featureLineDO;
144  }
145 
152  void SetHeight( int aHeight, int aPrecision );
153 
158  int GetHeight() const
159  {
160  return m_Height;
161  }
162 
167  void UpdateHeight();
168 
174  double GetAngle() const
175  {
177 
178  return atan2( (double)delta.y, (double)delta.x );
179  }
180 
186  void AdjustDimensionDetails( int aPrecision );
187 
188  void GetUnits( EDA_UNITS& aUnits, bool& aUseMils ) const
189  {
190  aUnits = m_Unit;
191  aUseMils = m_UseMils;
192  }
193 
194  void SetUnits( EDA_UNITS aUnits, bool aUseMils )
195  {
196  m_Unit = aUnits;
197  m_UseMils = aUseMils;
198  }
199 
200  void SetText( const wxString& NewText );
201  const wxString GetText() const;
202 
203  TEXTE_PCB& Text() { return m_Text; }
204  TEXTE_PCB& Text() const { return *(const_cast<TEXTE_PCB*> (&m_Text)); }
205 
206  void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override;
207 
212  void Move( const wxPoint& offset ) override;
213  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
214  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
215 
223  void Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight = false );
224 
225  void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
226 
227  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
228  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
229 
230  wxString GetClass() const override
231  {
232  return wxT( "DIMENSION" );
233  }
234 
235  // Virtual function
236  const EDA_RECT GetBoundingBox() const override;
237 
238  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
239 
240  BITMAP_DEF GetMenuImage() const override;
241 
242  EDA_ITEM* Clone() const override;
243 
244  virtual const BOX2I ViewBBox() const override;
245 
246  virtual void SwapData( BOARD_ITEM* aImage ) override;
247 
248 #if defined(DEBUG)
249  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
250 #endif
251 };
252 
253 #endif // DIMENSION_H_
EDA_UNITS
Definition: common.h:72
LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to re...
Definition: richio.h:81
void SetPosition(const wxPoint &aPos) override
int GetWidth() const
PNG memory record (file in memory).
Definition: bitmap_def.h:29
TEXTE_PCB class definition.
void SetText(const wxString &NewText)
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
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
DIMENSION(BOARD_ITEM *aParent)
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
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...
TEXTE_PCB m_Text
void SetHeight(int aHeight, int aPrecision)
Function SetHeight Sets the length of feature lines.
int m_Shape
Currently always 0.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
wxPoint m_featureLineDF
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.
void SetUnits(EDA_UNITS aUnits, bool aUseMils)
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
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
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.
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.
void SetOrigin(const wxPoint &aOrigin, int aPrecision)
Function SetOrigin Sets a new origin of the crossbar line.
const wxPoint & GetEnd()
Function GetEnd.
void SetEnd(const wxPoint &aEnd, int aPrecision)
Function SetEnd Sets a new end of the crossbar line.
void SetTextSize(const wxSize &aTextSize)
int GetValue() const
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.
const wxPoint & GetOrigin() const
Function GetOrigin.
int GetShape() const
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:99
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.
int m_Width
Line width.
void AdjustDimensionDetails(int aPrecision)
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension.
TEXTE_PCB & Text() const
double GetAngle() const
Function GetAngle Returns angle of the crossbar.
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.
TEXTE_PCB & Text()
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
void GetUnits(EDA_UNITS &aUnits, bool &aUseMils) const
static bool ClassOf(const EDA_ITEM *aItem)
wxPoint m_crossBarO
const wxPoint GetPosition() const override
const wxString GetText() const
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.
int GetHeight() const
Function GetHeight Returns the length of feature lines.
wxPoint m_featureLineDO
int m_Value
value of PCB dimensions.
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
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
wxPoint m_featureLineGF