KiCad PCB EDA Suite
pcb_text.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-2011 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 
25 #ifndef PCB_TEXT_H
26 #define PCB_TEXT_H
27 
28 #include <eda_text.h>
29 #include <board_item.h>
30 
31 
32 class LINE_READER;
33 class MSG_PANEL_ITEM;
34 
35 
36 class PCB_TEXT : public BOARD_ITEM, public EDA_TEXT
37 {
38 public:
39  PCB_TEXT( BOARD_ITEM* parent );
40 
41  // Do not create a copy constructor & operator=.
42  // The ones generated by the compiler are adequate.
43 
44  ~PCB_TEXT();
45 
46  static inline bool ClassOf( const EDA_ITEM* aItem )
47  {
48  return aItem && PCB_TEXT_T == aItem->Type();
49  }
50 
51  bool IsType( const KICAD_T aScanTypes[] ) const override
52  {
53  if( BOARD_ITEM::IsType( aScanTypes ) )
54  return true;
55 
56  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
57  {
58  if( *p == PCB_LOCATE_TEXT_T )
59  return true;
60  }
61 
62  return false;
63  }
64 
65  wxString GetShownText( int aDepth = 0 ) const override;
66 
67  bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
68  {
69  return BOARD_ITEM::Matches( GetShownText(), aSearchData );
70  }
71 
72  virtual wxPoint GetPosition() const override
73  {
74  return EDA_TEXT::GetTextPos();
75  }
76 
77  virtual void SetPosition( const wxPoint& aPos ) override
78  {
79  EDA_TEXT::SetTextPos( aPos );
80  }
81 
82  void Move( const wxPoint& aMoveVector ) override
83  {
84  EDA_TEXT::Offset( aMoveVector );
85  }
86 
87  void SetTextAngle( double aAngle ) override;
88 
89  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
90 
91  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
92 
93  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
94 
95  bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override;
96  bool TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy = 0 ) const override;
97 
98  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override
99  {
100  return TextHitTest( aPosition, aAccuracy );
101  }
102 
106  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override
107  {
108  return TextHitTest( aRect, aContained, aAccuracy );
109  }
110 
111  wxString GetClass() const override
112  {
113  return wxT( "PTEXT" );
114  }
115 
126  PCB_LAYER_ID aLayer, int aClearanceValue,
127  int aError, ERROR_LOC aErrorLoc ) const;
128 
130  int aClearanceValue, int aError, ERROR_LOC aErrorLoc,
131  bool aIgnoreLineWidth = false ) const override;
132 
133  // @copydoc BOARD_ITEM::GetEffectiveShape
134  virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
135 
136  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
137 
138  BITMAPS GetMenuImage() const override;
139 
140  // Virtual function
141  const EDA_RECT GetBoundingBox() const override;
142 
143  EDA_ITEM* Clone() const override;
144 
145  virtual void SwapData( BOARD_ITEM* aImage ) override;
146 
147 #if defined(DEBUG)
148  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
149 #endif
150 };
151 
152 #endif // #define PCB_TEXT_H
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:259
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:365
bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
Definition: pcb_text.cpp:144
virtual void SetPosition(const wxPoint &aPos) override
Definition: pcb_text.h:77
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_text.cpp:209
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_text.cpp:173
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_text.cpp:197
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
void TransformTextShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc) const
Function TransformTextShapeWithClearanceToPolygon Convert the text to a polygonSet describing the act...
void SetTextAngle(double aAngle) override
Definition: pcb_text.cpp:105
wxString GetClass() const override
Return the class name.
Definition: pcb_text.h:111
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:253
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: pcb_text.cpp:111
The base class for create windows for drawing purpose.
PCB_TEXT(BOARD_ITEM *parent)
Definition: pcb_text.cpp:43
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_text.cpp:217
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:119
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:56
~PCB_TEXT()
Definition: pcb_text.cpp:51
PCB_LAYER_ID
A quick note on layer IDs:
virtual wxPoint GetPosition() const override
Definition: pcb_text.h:72
Represent a set of closed polygons.
bool IsType(const KICAD_T aScanTypes[]) const override
Check whether the item is one of the listed types.
Definition: pcb_text.h:51
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_text.h:46
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pcb_text.cpp:191
bool HitTest(const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
Definition: pcb_text.h:106
EDA_UNITS
Definition: eda_units.h:38
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_text.h:82
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_text.h:98
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_text.cpp:163
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_text.cpp:203
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: pcb_text.h:67
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_text.cpp:133
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113