KiCad PCB EDA Suite
class_text_mod.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 
31 #ifndef TEXT_MODULE_H_
32 #define TEXT_MODULE_H_
33 
34 
35 #include <eda_text.h>
36 #include <class_board_item.h>
37 
38 
39 class LINE_READER;
40 class EDA_RECT;
41 class EDA_DRAW_PANEL;
42 class MODULE;
43 class MSG_PANEL_ITEM;
44 
45 
46 #define UMBILICAL_COLOR LIGHTBLUE
47 
48 
49 class TEXTE_MODULE : public BOARD_ITEM, public EDA_TEXT
50 {
51 public:
58  enum TEXT_TYPE
59  {
63  };
64 
65  TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type = TEXT_is_DIVERS );
66 
67  // Do not create a copy constructor & operator=.
68  // The ones generated by the compiler are adequate.
69 
70  ~TEXTE_MODULE();
71 
72  static inline bool ClassOf( const EDA_ITEM* aItem )
73  {
74  return aItem && PCB_MODULE_TEXT_T == aItem->Type();
75  }
76 
77  virtual const wxPoint GetPosition() const override
78  {
79  return EDA_TEXT::GetTextPos();
80  }
81 
82  virtual void SetPosition( const wxPoint& aPos ) override
83  {
84  EDA_TEXT::SetTextPos( aPos );
85  SetLocalCoord();
86  }
87 
88  void SetTextAngle( double aAngle );
89 
91  {
92  return m_keepUpright;
93  }
94 
95  void SetKeepUpright( bool aKeepUpright )
96  {
97  m_keepUpright = aKeepUpright;
98  }
99 
102  void Rotate( const wxPoint& aOffset, double aAngle ) override;
103 
105  void Flip( const wxPoint& aCentre ) override;
106 
107  bool IsParentFlipped() const;
108 
113  void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
114 
116  void Move( const wxPoint& aMoveVector ) override;
117 
119  // reference and value from deletion, and for identification)
120  void SetType( TEXT_TYPE aType ) { m_Type = aType; }
121  TEXT_TYPE GetType() const { return m_Type; }
122 
127  void SetEffects( const TEXTE_MODULE& aSrc )
128  {
129  EDA_TEXT::SetEffects( aSrc );
130  SetLocalCoord();
131  // SetType( aSrc.GetType() );
132  }
133 
138  void SwapEffects( TEXTE_MODULE& aTradingPartner )
139  {
140  EDA_TEXT::SwapEffects( aTradingPartner );
141  SetLocalCoord();
142  aTradingPartner.SetLocalCoord();
143  // std::swap( m_Type, aTradingPartner.m_Type );
144  }
145 
146  // The Pos0 accessors are for module-relative coordinates
147  void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
148  const wxPoint& GetPos0() const { return m_Pos0; }
149 
150  int GetLength() const; // text length
151 
156  double GetDrawRotation() const;
157  double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; }
158 
159  // Virtual function
160  const EDA_RECT GetBoundingBox() const override;
161 
163  void SetDrawCoord();
164 
166  void SetLocalCoord();
167 
168  /* drawing functions */
169 
178  void Draw( EDA_DRAW_PANEL* aPanel,
179  wxDC* aDC,
180  GR_DRAWMODE aDrawMode,
181  const wxPoint& aOffset = ZeroOffset ) override;
182 
192  void DrawUmbilical( EDA_DRAW_PANEL* aPanel,
193  wxDC* aDC,
194  GR_DRAWMODE aDrawMode,
195  const wxPoint& aOffset = ZeroOffset );
196 
197  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
198 
199  virtual bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override;
200 
201  virtual bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const override;
202 
203  virtual bool HitTest( const wxPoint& aPosition ) const override
204  {
205  return TextHitTest( aPosition );
206  }
207 
208  virtual bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override
209  {
210  return TextHitTest( aRect, aContained, aAccuracy );
211  }
212 
213  wxString GetClass() const override
214  {
215  return wxT( "MTEXT" );
216  }
217 
218  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
219 
220  BITMAP_DEF GetMenuImage() const override;
221 
222  EDA_ITEM* Clone() const override;
223 
224  virtual wxString GetShownText() const override;
225 
226  virtual const BOX2I ViewBBox() const override;
227 
228  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
229 
230  virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
231 
232 #if defined(DEBUG)
233  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
234 #endif
235 
236 private:
237  /* Note: orientation in 1/10 deg relative to the footprint
238  * Physical orient is m_Orient + m_Parent->m_Orient
239  */
240 
242 
244 
247 };
248 
249 #endif // TEXT_MODULE_H_
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
TEXT_TYPE
Text module type: there must be only one (and only one) for each of the reference and value texts in ...
int GetLength() const
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void SetKeepUpright(bool aKeepUpright)
void SwapEffects(EDA_TEXT &aTradingPartner)
Function SwapEffects swaps the text effects of the two involved instances.
Definition: eda_text.cpp:61
double GetDrawRotation() const
PNG memory record (file in memory).
Definition: bitmap_types.h:41
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
TEXTE_MODULE(MODULE *parent, TEXT_TYPE text_type=TEXT_is_DIVERS)
static bool ClassOf(const EDA_ITEM *aItem)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
TEXT_TYPE GetType() const
const wxPoint & GetPos0() const
void Rotate(const wxPoint &aOffset, double aAngle) override
Rotate text, in footprint editor (for instance in footprint rotation transform)
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
void SetEffects(const EDA_TEXT &aSrc)
Function SetEffects sets the text effects from another instance.
Definition: eda_text.cpp:55
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
void SwapEffects(TEXTE_MODULE &aTradingPartner)
Function SwapEffects swaps the text effects of the two involved instances.
bool IsParentFlipped() const
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
Definition of base KiCad text object.
static wxPoint ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:127
bool IsKeepUpright()
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
wxString GetClass() const override
Function GetClass returns the class name.
void Flip(const wxPoint &aCentre) override
Flip entity during module flip.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
virtual void SetPosition(const wxPoint &aPos) override
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw Draw the text according to the footprint pos and orient.
void SetType(TEXT_TYPE aType)
void SetPos0(const wxPoint &aPos)
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void SetLocalCoord()
Set relative coordinates.
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...
virtual bool HitTest(const EDA_RECT &aRect, bool aContained=false, int aAccuracy=0) const override
Function HitTest tests if the aRect intersects or contains this object (depending on aContained)...
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
virtual const wxPoint GetPosition() const override
wxPoint m_Pos0
text coordinates relative to the footprint anchor, orient 0.
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const override
Function TextHitTest Test if aPoint is within the bounds of this object.
void SetDrawCoord()
Set absolute coordinates.
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:151
void DrawUmbilical(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset)
Function DrawUmbilical draws a line from the TEXTE_MODULE origin to parent MODULE origin...
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror text position in footprint editing the text itself is not mirrored, and the layer not modified...
void SetEffects(const TEXTE_MODULE &aSrc)
Function SetEffects sets the text effects from another instance.
void SetTextAngle(double aAngle)
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
Class VIEW.
Definition: view.h:61
TEXT_TYPE m_Type
0=ref, 1=val, etc.
EDA_UNITS_T
Definition: common.h:159
double GetDrawRotationRadians() const