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  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  void SetValue( int aValue ) { m_Value = aValue; }
87 
88  int GetValue() const { return m_Value; }
89 
90  const wxPoint& GetPosition() const override;
91 
92  void SetPosition( const wxPoint& aPos ) override;
93 
94  void SetTextSize( const wxSize& aTextSize )
95  {
96  m_Text.SetTextSize( aTextSize );
97  }
98 
99  void SetLayer( PCB_LAYER_ID aLayer ) override;
100 
101  void SetShape( int aShape ) { m_Shape = aShape; }
102  int GetShape() const { return m_Shape; }
103 
104  int GetWidth() const { return m_Width; }
105  void SetWidth( int aWidth ) { m_Width = aWidth; }
106 
112  void SetOrigin( const wxPoint& aOrigin );
113 
118  const wxPoint& GetOrigin() const
119  {
120  return m_featureLineGO;
121  }
122 
128  void SetEnd( const wxPoint& aEnd );
129 
134  const wxPoint& GetEnd()
135  {
136  return m_featureLineDO;
137  }
138 
144  void SetHeight( int aHeight );
145 
150  int GetHeight() const
151  {
152  return m_Height;
153  }
154 
159  void UpdateHeight();
160 
166  double GetAngle() const
167  {
168  wxPoint delta( m_featureLineDO - m_featureLineGO );
169 
170  return atan2( (double)delta.y, (double)delta.x );
171  }
172 
178  void AdjustDimensionDetails( bool aDoNotChangeText = false );
179 
180  void SetText( const wxString& NewText );
181  const wxString GetText() const;
182 
183  TEXTE_PCB& Text() { return m_Text; }
184  TEXTE_PCB& Text() const { return *(const_cast<TEXTE_PCB*> (&m_Text)); }
185 
186  void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
187  GR_DRAWMODE aColorMode, const wxPoint& offset = ZeroOffset ) override;
188 
193  void Move( const wxPoint& offset ) override;
194 
195  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
196 
197  void Flip( const wxPoint& aCentre ) override;
198 
206  void Mirror( const wxPoint& axis_pos );
207 
208  void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
209 
210  bool HitTest( const wxPoint& aPosition ) const override;
211 
212  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
213 
214  wxString GetClass() const override
215  {
216  return wxT( "DIMENSION" );
217  }
218 
219  // Virtual function
220  const EDA_RECT GetBoundingBox() const override;
221 
222  wxString GetSelectMenuText() const override;
223 
224  BITMAP_DEF GetMenuImage() const override;
225 
226  EDA_ITEM* Clone() const override;
227 
228  virtual const BOX2I ViewBBox() const override;
229 
230 #if defined(DEBUG)
231  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
232 #endif
233 };
234 
235 #endif // DIMENSION_H_
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 SetPosition(const wxPoint &aPos) override
PNG memory record (file in memory).
Definition: bitmap_types.h:38
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
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:214
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)
const wxPoint & GetEnd()
Function GetEnd.
void SetTextSize(const wxSize &aTextSize)
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
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
wxString GetClass() const override
Function GetClass returns the class name.
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void AdjustDimensionDetails(bool aDoNotChangeText=false)
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension...
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 GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
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.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
wxPoint m_crossBarO
int GetValue() const
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
const wxPoint & GetPosition() const override
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:144
Class DIMENSION.
wxPoint m_featureLineGF