KiCad PCB EDA Suite
fp_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, [email protected]
5 * Copyright (C) 1992-2022 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 FP_TEXT_H
26#define FP_TEXT_H
27
28#include <eda_text.h>
29#include <board_item.h>
30
31class LINE_READER;
32class FOOTPRINT;
33class MSG_PANEL_ITEM;
34class PCB_BASE_FRAME;
35class SHAPE;
36
37
38class FP_TEXT : public BOARD_ITEM, public EDA_TEXT
39{
40public:
48 {
52 };
53
54 FP_TEXT( FOOTPRINT* aParentFootprint, TEXT_TYPE text_type = TEXT_is_DIVERS );
55
56 // Do not create a copy constructor & operator=.
57 // The ones generated by the compiler are adequate.
58
59 ~FP_TEXT();
60
61 static inline bool ClassOf( const EDA_ITEM* aItem )
62 {
63 return aItem && aItem->Type() == PCB_FP_TEXT_T;
64 }
65
66 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
67 {
68 if( BOARD_ITEM::IsType( aScanTypes ) )
69 return true;
70
71 for( KICAD_T scanType : aScanTypes )
72 {
73 if( scanType == PCB_LOCATE_TEXT_T )
74 return true;
75 }
76
77 return false;
78 }
79
80 wxString GetParentAsString() const { return m_parent->m_Uuid.AsString(); }
81
82 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
83 {
84 return BOARD_ITEM::Matches( GetShownText(), aSearchData );
85 }
86
87 virtual VECTOR2I GetPosition() const override
88 {
89 return EDA_TEXT::GetTextPos();
90 }
91
92 virtual void SetPosition( const VECTOR2I& aPos ) override
93 {
96 }
97
101 void KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation );
102
103 void Rotate( const VECTOR2I& aOffset, const EDA_ANGLE& aAngle ) override;
104
106 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
107
108 bool IsParentFlipped() const;
109
113 void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis );
114
115 void Move( const VECTOR2I& aMoveVector ) override;
116
119 void SetType( TEXT_TYPE aType ) { m_Type = aType; }
120 TEXT_TYPE GetType() const { return m_Type; }
121
122 // The Pos0 accessors are for footprint-relative coordinates.
123 void SetPos0( const VECTOR2I& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
124 const VECTOR2I& GetPos0() const { return m_Pos0; }
125
126 int GetLength() const; // text length
127
132 virtual EDA_ANGLE GetDrawRotation() const override;
133
134 // Virtual function
135 const BOX2I GetBoundingBox() const override;
136
138 void SetDrawCoord();
139
141 void SetLocalCoord();
142
143 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
144
145 bool TextHitTest( const VECTOR2I& aPoint, int aAccuracy = 0 ) const override;
146 bool TextHitTest( const BOX2I& aRect, bool aContains, int aAccuracy = 0 ) const override;
147
148 bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override
149 {
150 return TextHitTest( aPosition, aAccuracy );
151 }
152
153 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
154 {
155 return TextHitTest( aRect, aContained, aAccuracy );
156 }
157
159 int aClearance, int aError, ERROR_LOC aErrorLoc,
160 bool aIgnoreLineWidth ) const override;
161
163 PCB_LAYER_ID aLayer, int aClearanceValue,
164 int aError, ERROR_LOC aErrorLoc ) const;
165
166 // @copydoc BOARD_ITEM::GetEffectiveShape
167 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
168 FLASHING aFlash = FLASHING::DEFAULT ) const override;
169
170 wxString GetClass() const override
171 {
172 return wxT( "FP_TEXT" );
173 }
174
175 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
176
177 BITMAPS GetMenuImage() const override;
178
179 EDA_ITEM* Clone() const override;
180
181 virtual wxString GetShownText( int aDepth = 0 ) const override;
182
183 virtual const BOX2I ViewBBox() const override;
184
185 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
186
187 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
188
189#if defined(DEBUG)
190 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
191#endif
192
193private:
195
198};
199
200#endif // FP_TEXT_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
const KIID m_Uuid
Definition: eda_item.h:492
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:382
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:198
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: fp_text.cpp:358
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: fp_text.h:82
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: fp_text.cpp:334
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: fp_text.cpp:369
virtual EDA_ANGLE GetDrawRotation() const override
Definition: fp_text.cpp:244
~FP_TEXT()
Definition: fp_text.cpp:70
wxString GetClass() const override
Return the class name.
Definition: fp_text.h:170
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: fp_text.cpp:270
const BOX2I GetBoundingBox() const override
Set absolute coordinates.
Definition: fp_text.cpp:232
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Mirror text position.
Definition: fp_text.cpp:164
const VECTOR2I & GetPos0() const
Definition: fp_text.h:124
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
Definition: fp_text.h:148
bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
Definition: fp_text.cpp:75
VECTOR2I m_Pos0
text coordinates relative to the footprint anchor, orient 0.
Definition: fp_text.h:196
virtual void SetPosition(const VECTOR2I &aPos) override
Definition: fp_text.h:92
void SetType(TEXT_TYPE aType)
Definition: fp_text.h:119
void SetLocalCoord()
Definition: fp_text.cpp:217
virtual wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: fp_text.cpp:412
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: fp_text.cpp:346
void TransformTextShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc) const
Definition: fp_text.cpp:453
bool IsParentFlipped() const
Definition: fp_text.cpp:156
virtual VECTOR2I GetPosition() const override
Definition: fp_text.h:87
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth) const override
Convert the item shape to a closed polygon.
Definition: fp_text.cpp:484
void SetDrawCoord()
Set relative coordinates.
Definition: fp_text.cpp:200
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition: fp_text.h:153
TEXT_TYPE
Footprint text type: there must be only one (and only one) for each of the reference value texts in o...
Definition: fp_text.h:48
@ TEXT_is_REFERENCE
Definition: fp_text.h:49
@ TEXT_is_DIVERS
Definition: fp_text.h:51
@ TEXT_is_VALUE
Definition: fp_text.h:50
TEXT_TYPE m_Type
0=ref, 1=val, etc.
Definition: fp_text.h:194
void KeepUpright(const EDA_ANGLE &aOldOrientation, const EDA_ANGLE &aNewOrientation)
Called when rotating the parent footprint.
Definition: fp_text.cpp:101
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_text.cpp:340
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: fp_text.h:66
FP_TEXT(FOOTPRINT *aParentFootprint, TEXT_TYPE text_type=TEXT_is_DIVERS)
Definition: fp_text.cpp:41
void SetPos0(const VECTOR2I &aPos)
Definition: fp_text.h:123
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip entity during footprint flip.
Definition: fp_text.cpp:137
void Rotate(const VECTOR2I &aOffset, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: fp_text.cpp:120
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: fp_text.cpp:187
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: fp_text.cpp:313
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: fp_text.cpp:447
wxString GetParentAsString() const
Definition: fp_text.h:80
TEXT_TYPE GetType() const
Definition: fp_text.h:120
int GetLength() const
Definition: fp_text.cpp:194
static bool ClassOf(const EDA_ITEM *aItem)
Definition: fp_text.h:61
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
wxString AsString() const
Definition: kiid.cpp:249
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:81
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Represent a set of closed polygons.
An abstract shape on 2D plane.
Definition: shape.h:123
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_LOCATE_TEXT_T
Definition: typeinfo.h:123
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92