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, [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 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;
34
35
36class PCB_TEXT : public BOARD_ITEM, public EDA_TEXT
37{
38public:
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 std::vector<KICAD_T>& aScanTypes ) const override
52 {
53 if( BOARD_ITEM::IsType( aScanTypes ) )
54 return true;
55
56 for( KICAD_T scanType : aScanTypes )
57 {
58 if( scanType == PCB_LOCATE_TEXT_T )
59 return true;
60 }
61
62 return false;
63 }
64
65 wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
66
68 void SetVisible( bool aVisible ) override { /* do nothing */}
69 bool IsVisible() const override { return true; }
70
71 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
72 {
73 return BOARD_ITEM::Matches( GetShownText(), aSearchData );
74 }
75
76 virtual VECTOR2I GetPosition() const override
77 {
78 return EDA_TEXT::GetTextPos();
79 }
80
81 virtual void SetPosition( const VECTOR2I& aPos ) override
82 {
84 }
85
86 void Move( const VECTOR2I& aMoveVector ) override
87 {
88 EDA_TEXT::Offset( aMoveVector );
89 }
90
91 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
92
93 void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis );
94
95 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
96
97 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
98
99 bool TextHitTest( const VECTOR2I& aPoint, int aAccuracy = 0 ) const override;
100 bool TextHitTest( const BOX2I& aRect, bool aContains, int aAccuracy = 0 ) const override;
101
102 bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override
103 {
104 return TextHitTest( aPosition, aAccuracy );
105 }
106
107 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
108 {
109 return TextHitTest( aRect, aContained, aAccuracy );
110 }
111
112 wxString GetClass() const override
113 {
114 return wxT( "PCB_TEXT" );
115 }
116
126 void TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
127 int aError, ERROR_LOC aErrorLoc ) const;
128
129 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
130 int aError, ERROR_LOC aErrorLoc,
131 bool aIgnoreLineWidth = false ) const override;
132
133 // @copydoc BOARD_ITEM::GetEffectiveShape
134 virtual std::shared_ptr<SHAPE>
136 FLASHING aFlash = FLASHING::DEFAULT ) const override;
137
138 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
139
140 BITMAPS GetMenuImage() const override;
141
143 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
144
145 // Virtual function
146 const BOX2I GetBoundingBox() const override;
147
148 EDA_ITEM* Clone() const override;
149
150#if defined(DEBUG)
151 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
152#endif
153
154protected:
155 virtual void swapData( BOARD_ITEM* aImage ) override;
156
157 int getKnockoutMargin() const;
158};
159
160#endif // #define PCB_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:58
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
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:384
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
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:208
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:389
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
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
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:128
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition: pcb_text.cpp:326
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_text.cpp:275
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:283
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:102
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: pcb_text.h:71
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition: pcb_text.h:107
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_text.cpp:235
bool IsVisible() const override
Definition: pcb_text.h:69
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_text.h:46
~PCB_TEXT()
Definition: pcb_text.cpp:50
virtual VECTOR2I GetPosition() const override
Definition: pcb_text.h:76
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pcb_text.h:51
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:55
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_text.cpp:103
int getKnockoutMargin() const
Definition: pcb_text.cpp:149
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_text.cpp:214
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_text.cpp:158
void SetVisible(bool aVisible) override
PCB_TEXTs are always visible:
Definition: pcb_text.h:68
bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
Definition: pcb_text.cpp:172
virtual void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_text.h:81
wxString GetClass() const override
Return the class name.
Definition: pcb_text.h:112
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_text.h:86
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_text.cpp:269
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
Definition: pcb_text.cpp:289
PCB_TEXT(BOARD_ITEM *parent)
Definition: pcb_text.cpp:42
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_text.cpp:202
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: pcb_text.cpp:255
BITMAPS GetMenuImage() const override
Definition: pcb_text.cpp:263
Represent a set of closed polygons.
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_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_LOCATE_TEXT_T
Definition: typeinfo.h:123