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 MODULE;
42 class MSG_PANEL_ITEM;
43 class PCB_BASE_FRAME;
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  bool IsType( const KICAD_T aScanTypes[] ) const override
78  {
79  if( BOARD_ITEM::IsType( aScanTypes ) )
80  return true;
81 
82  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
83  {
84  if( *p == PCB_LOCATE_TEXT_T )
85  return true;
86  }
87 
88  return false;
89  }
90 
91  bool Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override
92  {
93  return BOARD_ITEM::Matches( GetShownText(), aSearchData );
94  }
95 
96  virtual const wxPoint GetPosition() const override
97  {
98  return EDA_TEXT::GetTextPos();
99  }
100 
101  virtual void SetPosition( const wxPoint& aPos ) override
102  {
103  EDA_TEXT::SetTextPos( aPos );
104  SetLocalCoord();
105  }
106 
107  void SetTextAngle( double aAngle ) override;
108 
112  void KeepUpright( double aOldOrientation, double aNewOrientation );
113 
119  {
120  return m_keepUpright;
121  }
122 
123  void SetKeepUpright( bool aKeepUpright )
124  {
125  m_keepUpright = aKeepUpright;
126  }
127 
130  void Rotate( const wxPoint& aOffset, double aAngle ) override;
131 
133  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
134 
135  bool IsParentFlipped() const;
136 
141  void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
142 
144  void Move( const wxPoint& aMoveVector ) override;
145 
147  // reference and value from deletion, and for identification)
148  void SetType( TEXT_TYPE aType ) { m_Type = aType; }
149  TEXT_TYPE GetType() const { return m_Type; }
150 
155  void SetEffects( const TEXTE_MODULE& aSrc )
156  {
157  EDA_TEXT::SetEffects( aSrc );
158  SetLocalCoord();
159  // SetType( aSrc.GetType() );
160  }
161 
166  void SwapEffects( TEXTE_MODULE& aTradingPartner )
167  {
168  EDA_TEXT::SwapEffects( aTradingPartner );
169  SetLocalCoord();
170  aTradingPartner.SetLocalCoord();
171  // std::swap( m_Type, aTradingPartner.m_Type );
172  }
173 
174  // The Pos0 accessors are for module-relative coordinates
175  void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
176  const wxPoint& GetPos0() const { return m_Pos0; }
177 
178  int GetLength() const; // text length
179 
184  double GetDrawRotation() const;
185  double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; }
186 
187  // Virtual function
188  const EDA_RECT GetBoundingBox() const override;
189 
191  void SetDrawCoord();
192 
194  void SetLocalCoord();
195 
196  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
197 
198  bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override;
199  bool TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy = 0 ) const override;
200 
201  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override
202  {
203  return TextHitTest( aPosition, aAccuracy );
204  }
205 
206  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override
207  {
208  return TextHitTest( aRect, aContained, aAccuracy );
209  }
210 
211  wxString GetClass() const override
212  {
213  return wxT( "MTEXT" );
214  }
215 
216  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
217 
218  BITMAP_DEF GetMenuImage() const override;
219 
220  EDA_ITEM* Clone() const override;
221 
222  virtual wxString GetShownText( int aDepth = 0 ) const override;
223 
224  virtual const BOX2I ViewBBox() const override;
225 
226  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
227 
228  virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
229 
230 #if defined(DEBUG)
231  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
232 #endif
233 
234 private:
235  /* Note: orientation in 1/10 deg relative to the footprint
236  * Physical orient is m_Orient + m_Parent->m_Orient
237  */
238 
240 
242 
245 
247 };
248 
249 #endif // TEXT_MODULE_H_
EDA_UNITS
Definition: common.h:198
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.
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to re...
Definition: richio.h:81
void SetKeepUpright(bool aKeepUpright)
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
Definition: eda_text.cpp:146
PNG memory record (file in memory).
Definition: bitmap_def.h:29
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)
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)
Set the text effects from another instance.
Definition: eda_text.cpp:132
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:246
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 IsType(const KICAD_T aScanTypes[]) const override
Function IsType Checks whether the item is one of the listed types.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
The base class for create windows for drawing purpose.
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.
double GetDrawRotationRadians() const
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:112
bool IsKeepUpright()
bool m_keepUpright
if true, keep rotation angle between -90 .
TEXT_TYPE GetType() const
bool HitTest(const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
Function HitTest tests if aRect intersects or is contained within the bounding box of an item.
wxString GetClass() const override
Function GetClass returns the class name.
virtual bool IsType(const KICAD_T aScanTypes[]) const
Function IsType Checks whether the item is one of the listed types.
Definition: base_struct.h:262
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 SetTextAngle(double aAngle) override
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
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip entity during module flip.
int GetLength() const
void SetLocalCoord()
Set relative coordinates.
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
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.
bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
void SetDrawCoord()
Set absolute coordinates.
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:159
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:247
void SetEffects(const TEXTE_MODULE &aSrc)
Function SetEffects sets the text effects from another instance.
bool IsParentFlipped() const
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
VIEW.
Definition: view.h:61
TEXT_TYPE m_Type
0=ref, 1=val, etc.
double GetDrawRotation() const
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:457
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193