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-2019 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 
93  void KeepUpright( double aOldOrientation, double aNewOrientation );
94 
100  {
101  return m_keepUpright;
102  }
103 
104  void SetKeepUpright( bool aKeepUpright )
105  {
106  m_keepUpright = aKeepUpright;
107  }
108 
111  void Rotate( const wxPoint& aOffset, double aAngle ) override;
112 
114  void Flip( const wxPoint& aCentre ) override;
115 
116  bool IsParentFlipped() const;
117 
122  void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
123 
125  void Move( const wxPoint& aMoveVector ) override;
126 
128  // reference and value from deletion, and for identification)
129  void SetType( TEXT_TYPE aType ) { m_Type = aType; }
130  TEXT_TYPE GetType() const { return m_Type; }
131 
136  void SetEffects( const TEXTE_MODULE& aSrc )
137  {
138  EDA_TEXT::SetEffects( aSrc );
139  SetLocalCoord();
140  // SetType( aSrc.GetType() );
141  }
142 
147  void SwapEffects( TEXTE_MODULE& aTradingPartner )
148  {
149  EDA_TEXT::SwapEffects( aTradingPartner );
150  SetLocalCoord();
151  aTradingPartner.SetLocalCoord();
152  // std::swap( m_Type, aTradingPartner.m_Type );
153  }
154 
155  // The Pos0 accessors are for module-relative coordinates
156  void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
157  const wxPoint& GetPos0() const { return m_Pos0; }
158 
159  int GetLength() const; // text length
160 
165  double GetDrawRotation() const;
166  double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; }
167 
168  // Virtual function
169  const EDA_RECT GetBoundingBox() const override;
170 
172  void SetDrawCoord();
173 
175  void SetLocalCoord();
176 
177  /* drawing functions */
178 
187  void Draw( EDA_DRAW_PANEL* aPanel,
188  wxDC* aDC,
189  GR_DRAWMODE aDrawMode,
190  const wxPoint& aOffset = ZeroOffset ) override;
191 
201  void DrawUmbilical( EDA_DRAW_PANEL* aPanel,
202  wxDC* aDC,
203  GR_DRAWMODE aDrawMode,
204  const wxPoint& aOffset = ZeroOffset );
205 
206  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
207 
208  virtual bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override;
209 
210  virtual bool TextHitTest( const EDA_RECT& aRect, bool aContains = false, int aAccuracy = 0 ) const override;
211 
212  virtual bool HitTest( const wxPoint& aPosition ) const override
213  {
214  return TextHitTest( aPosition );
215  }
216 
217  virtual bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override
218  {
219  return TextHitTest( aRect, aContained, aAccuracy );
220  }
221 
222  wxString GetClass() const override
223  {
224  return wxT( "MTEXT" );
225  }
226 
227  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
228 
229  BITMAP_DEF GetMenuImage() const override;
230 
231  EDA_ITEM* Clone() const override;
232 
233  virtual wxString GetShownText() const override;
234 
235  virtual const BOX2I ViewBBox() const override;
236 
237  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
238 
239  virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
240 
241 #if defined(DEBUG)
242  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
243 #endif
244 
245 private:
246  /* Note: orientation in 1/10 deg relative to the footprint
247  * Physical orient is m_Orient + m_Parent->m_Orient
248  */
249 
251 
252  wxPoint m_Pos0;
253 
256 
258 };
259 
260 #endif // TEXT_MODULE_H_
TEXT_TYPE
Text module type: there must be only one (and only one) for each of the reference and value texts in ...
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
void KeepUpright(double aOldOrientation, double aNewOrientation)
Called when rotating the parent footprint.
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.
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:241
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.
double GetDrawRotationRadians() const
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:128
bool IsKeepUpright()
bool m_keepUpright
if true, keep rotation angle between -90 .
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.
TEXT_TYPE GetType() const
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)
const wxPoint & GetPos0() const
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...
int GetLength() const
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'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:156
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...
const wxPoint & GetTextPos() const
Definition: eda_text.h:242
void SetEffects(const TEXTE_MODULE &aSrc)
Function SetEffects sets the text effects from another instance.
bool IsParentFlipped() const
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.
double GetDrawRotation() const
EDA_UNITS_T
Definition: common.h:157
KICAD_T Type() const
Function Type()
Definition: base_struct.h:203