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 Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override
78  {
79  return BOARD_ITEM::Matches( GetShownText(), aSearchData );
80  }
81 
82  virtual const wxPoint GetPosition() const override
83  {
84  return EDA_TEXT::GetTextPos();
85  }
86 
87  virtual void SetPosition( const wxPoint& aPos ) override
88  {
89  EDA_TEXT::SetTextPos( aPos );
90  SetLocalCoord();
91  }
92 
93  void SetTextAngle( double aAngle );
94 
98  void KeepUpright( double aOldOrientation, double aNewOrientation );
99 
105  {
106  return m_keepUpright;
107  }
108 
109  void SetKeepUpright( bool aKeepUpright )
110  {
111  m_keepUpright = aKeepUpright;
112  }
113 
116  void Rotate( const wxPoint& aOffset, double aAngle ) override;
117 
119  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
120 
121  bool IsParentFlipped() const;
122 
127  void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
128 
130  void Move( const wxPoint& aMoveVector ) override;
131 
133  // reference and value from deletion, and for identification)
134  void SetType( TEXT_TYPE aType ) { m_Type = aType; }
135  TEXT_TYPE GetType() const { return m_Type; }
136 
141  void SetEffects( const TEXTE_MODULE& aSrc )
142  {
143  EDA_TEXT::SetEffects( aSrc );
144  SetLocalCoord();
145  // SetType( aSrc.GetType() );
146  }
147 
152  void SwapEffects( TEXTE_MODULE& aTradingPartner )
153  {
154  EDA_TEXT::SwapEffects( aTradingPartner );
155  SetLocalCoord();
156  aTradingPartner.SetLocalCoord();
157  // std::swap( m_Type, aTradingPartner.m_Type );
158  }
159 
160  // The Pos0 accessors are for module-relative coordinates
161  void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
162  const wxPoint& GetPos0() const { return m_Pos0; }
163 
164  int GetLength() const; // text length
165 
170  double GetDrawRotation() const;
171  double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; }
172 
173  // Virtual function
174  const EDA_RECT GetBoundingBox() const override;
175 
177  void SetDrawCoord();
178 
180  void SetLocalCoord();
181 
182  /* drawing functions */
183 
191  void Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset = ZeroOffset ) override;
192 
193  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
194 
195  bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override;
196  bool TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy = 0 ) const override;
197 
198  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override
199  {
200  return TextHitTest( aPosition, aAccuracy );
201  }
202 
203  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override
204  {
205  return TextHitTest( aRect, aContained, aAccuracy );
206  }
207 
208  wxString GetClass() const override
209  {
210  return wxT( "MTEXT" );
211  }
212 
213  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
214 
215  BITMAP_DEF GetMenuImage() const override;
216 
217  EDA_ITEM* Clone() const override;
218 
219  virtual wxString GetShownText() const override;
220 
221  virtual const BOX2I ViewBBox() const override;
222 
223  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
224 
225  virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
226 
227 #if defined(DEBUG)
228  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
229 #endif
230 
231 private:
232  /* Note: orientation in 1/10 deg relative to the footprint
233  * Physical orient is m_Orient + m_Parent->m_Orient
234  */
235 
237 
238  wxPoint m_Pos0;
239 
242 
244 };
245 
246 #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.
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
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:132
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:119
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:229
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.
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
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:109
bool IsKeepUpright()
void Print(PCB_BASE_FRAME *aFrame, wxDC *aDC, const wxPoint &aOffset=ZeroOffset) override
Function Print Print the text according to the footprint pos and orient.
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.
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 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...
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip entity during module flip.
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 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
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:163
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:230
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
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:492
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_UNITS_T
Definition: common.h:154
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210