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 
92  void Rotate( const wxPoint& aOffset, double aAngle ) override;
93 
95  void Flip( const wxPoint& aCentre ) override;
96 
101  void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
102 
104  void Move( const wxPoint& aMoveVector ) override;
105 
107  // reference and value from deletion, and for identification)
108  void SetType( TEXT_TYPE aType ) { m_Type = aType; }
109  TEXT_TYPE GetType() const { return m_Type; }
110 
115  void SetEffects( const TEXTE_MODULE& aSrc )
116  {
117  EDA_TEXT::SetEffects( aSrc );
118  SetLocalCoord();
119  // SetType( aSrc.GetType() );
120  }
121 
126  void SwapEffects( TEXTE_MODULE& aTradingPartner )
127  {
128  EDA_TEXT::SwapEffects( aTradingPartner );
129  SetLocalCoord();
130  aTradingPartner.SetLocalCoord();
131  // std::swap( m_Type, aTradingPartner.m_Type );
132  }
133 
134  // The Pos0 accessors are for module-relative coordinates
135  void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
136  const wxPoint& GetPos0() const { return m_Pos0; }
137 
138  int GetLength() const; // text length
139 
144  double GetDrawRotation() const;
145  double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; }
146 
147  // Virtual function
148  const EDA_RECT GetBoundingBox() const override;
149 
151  void SetDrawCoord();
152 
154  void SetLocalCoord();
155 
156  /* drawing functions */
157 
166  void Draw( EDA_DRAW_PANEL* aPanel,
167  wxDC* aDC,
168  GR_DRAWMODE aDrawMode,
169  const wxPoint& aOffset = ZeroOffset ) override;
170 
180  void DrawUmbilical( EDA_DRAW_PANEL* aPanel,
181  wxDC* aDC,
182  GR_DRAWMODE aDrawMode,
183  const wxPoint& aOffset = ZeroOffset );
184 
185  void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
186 
187  virtual bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override;
188 
189  virtual bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const override;
190 
191  virtual bool HitTest( const wxPoint& aPosition ) const override
192  {
193  return TextHitTest( aPosition );
194  }
195 
196  virtual bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override
197  {
198  return TextHitTest( aRect, aContained, aAccuracy );
199  }
200 
201  wxString GetClass() const override
202  {
203  return wxT( "MTEXT" );
204  }
205 
206  wxString GetSelectMenuText() const override;
207 
208  BITMAP_DEF GetMenuImage() const override;
209 
210  EDA_ITEM* Clone() const override;
211 
212  virtual wxString GetShownText() const override;
213 
214  virtual const BOX2I ViewBBox() const override;
215 
216  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
217 
218  virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
219 
220 #if defined(DEBUG)
221  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
222 #endif
223 
224 private:
225  /* Note: orientation in 1/10 deg relative to the footprint
226  * Physical orient is m_Orient + m_Parent->m_Orient
227  */
228 
230 
232 };
234 
235 #endif // TEXT_MODULE_H_
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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 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:38
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
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
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
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.
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:114
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
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...
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
void SetLocalCoord()
Set relative coordinates.
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...
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.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
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 edition 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:58
virtual const wxPoint & GetPosition() const override
TEXT_TYPE m_Type
0=ref, 1=val, etc.
double GetDrawRotationRadians() const