KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 The 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
32class LINE_READER;
33class MSG_PANEL_ITEM;
34class FOOTPRINT;
35
36
37class PCB_TEXT : public BOARD_ITEM, public EDA_TEXT
38{
39public:
40 PCB_TEXT( BOARD_ITEM* parent, KICAD_T idtype = PCB_TEXT_T );
41
42 PCB_TEXT( FOOTPRINT* aParent, KICAD_T idtype = PCB_TEXT_T );
43
44 // Do not create a copy constructor & operator=.
45 // The ones generated by the compiler are adequate.
46
47 ~PCB_TEXT();
48
49 void CopyFrom( const BOARD_ITEM* aOther ) override;
50
51 static inline bool ClassOf( const EDA_ITEM* aItem )
52 {
53 return aItem && PCB_TEXT_T == aItem->Type();
54 }
55
56 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
57 {
58 if( BOARD_ITEM::IsType( aScanTypes ) )
59 return true;
60
61 for( KICAD_T scanType : aScanTypes )
62 {
63 if( scanType == PCB_LOCATE_TEXT_T )
64 return true;
65 }
66
67 return false;
68 }
69
70 void Serialize( google::protobuf::Any &aContainer ) const override;
71 bool Deserialize( const google::protobuf::Any &aContainer ) override;
72
73 void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) override;
74
78 void KeepUpright();
79
80 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
81
82 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
83
84 virtual VECTOR2I GetPosition() const override
85 {
86 return EDA_TEXT::GetTextPos();
87 }
88
89 virtual void SetPosition( const VECTOR2I& aPos ) override
90 {
92 }
93
94 void Move( const VECTOR2I& aMoveVector ) override
95 {
96 EDA_TEXT::Offset( aMoveVector );
97 }
98
99 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
100
101 void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
102
103 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
104
105 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
106
107 bool TextHitTest( const VECTOR2I& aPoint, int aAccuracy = 0 ) const override;
108 bool TextHitTest( const BOX2I& aRect, bool aContains, int aAccuracy = 0 ) const override;
109
110 bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override
111 {
112 return TextHitTest( aPosition, aAccuracy );
113 }
114
115 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
116 {
117 return TextHitTest( aRect, aContained, aAccuracy );
118 }
119
120 wxString GetClass() const override
121 {
122 return wxT( "PCB_TEXT" );
123 }
124
133 void TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
134 ERROR_LOC aErrorLoc ) const;
135
136 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
137 int aMaxError, ERROR_LOC aErrorLoc,
138 bool aIgnoreLineWidth = false ) const override;
139
140 // @copydoc BOARD_ITEM::GetEffectiveShape
141 virtual std::shared_ptr<SHAPE>
143 FLASHING aFlash = FLASHING::DEFAULT ) const override;
144
145 virtual wxString GetTextTypeDescription() const;
146
147 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
148
149 BITMAPS GetMenuImage() const override;
150
155 EDA_ANGLE GetDrawRotation() const override;
156
157 const BOX2I ViewBBox() const override;
158
159 std::vector<int> ViewGetLayers() const override;
160
162 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
163
164 // Virtual function
165 const BOX2I GetBoundingBox() const override;
166
167 EDA_ITEM* Clone() const override;
168
169 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
170
171 bool operator==( const PCB_TEXT& aOther ) const;
172 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
173
174#if defined(DEBUG)
175 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
176#endif
177
178protected:
183 void buildBoundingHull( SHAPE_POLY_SET* aBuffer, const SHAPE_POLY_SET& aRenderedText,
184 int aClearance ) const;
185
186 virtual void swapData( BOARD_ITEM* aImage ) override;
187
188 int getKnockoutMargin() const;
189
190 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
191};
192
193#endif // #define PCB_TEXT_H
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
Container for design settings for a BOARD object.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:78
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:107
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:95
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:107
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:180
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:260
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:571
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:589
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
void CopyFrom(const BOARD_ITEM *aOther) override
Definition: pcb_text.cpp:84
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:269
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_text.cpp:606
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition: pcb_text.cpp:577
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: pcb_text.cpp:436
const KIFONT::METRICS & getFontMetrics() const override
Definition: pcb_text.h:190
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_text.cpp:204
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_text.cpp:410
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_text.cpp:462
virtual 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: pcb_text.cpp:470
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_text.h:110
void KeepUpright()
Called when rotating the parent footprint.
Definition: pcb_text.cpp:317
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: pcb_text.cpp:176
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_text.cpp:91
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition: pcb_text.h:115
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:140
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
Definition: pcb_text.cpp:389
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_text.cpp:219
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_text.h:51
~PCB_TEXT()
Definition: pcb_text.cpp:79
virtual VECTOR2I GetPosition() const override
Definition: pcb_text.h:84
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pcb_text.h:56
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_text.cpp:307
bool operator==(const PCB_TEXT &aOther) const
Definition: pcb_text.cpp:600
int getKnockoutMargin() const
Definition: pcb_text.cpp:301
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
Definition: pcb_text.cpp:514
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_text.cpp:338
virtual wxString GetTextTypeDescription() const
Definition: pcb_text.cpp:430
std::vector< int > ViewGetLayers() const override
Definition: pcb_text.cpp:210
void buildBoundingHull(SHAPE_POLY_SET *aBuffer, const SHAPE_POLY_SET &aRenderedText, int aClearance) const
Build a nominally rectangular bounding box for the rendered text.
Definition: pcb_text.cpp:485
bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
Definition: pcb_text.cpp:353
virtual void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_text.h:89
wxString GetClass() const override
Return the class name.
Definition: pcb_text.h:120
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_text.h:94
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_text.cpp:456
EDA_ANGLE GetDrawRotation() const override
Definition: pcb_text.cpp:182
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_text.cpp:115
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_text.cpp:377
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_text.cpp:450
Represent a set of closed polygons.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:184
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
FLIP_DIRECTION
Definition: mirror.h:27
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_LOCATE_TEXT_T
Definition: typeinfo.h:126