KiCad PCB EDA Suite
fp_textbox.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) 2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef FP_TEXTBOX_H
25#define FP_TEXTBOX_H
26
27#include <eda_text.h>
28#include <fp_shape.h>
29
30class LINE_READER;
31class FOOTPRINT;
32class MSG_PANEL_ITEM;
33class PCB_BASE_FRAME;
34class SHAPE;
35
36
37class FP_TEXTBOX : public FP_SHAPE, public EDA_TEXT
38{
39public:
40 FP_TEXTBOX( FOOTPRINT* aParentFootprint );
41
42 // Do not create a copy constructor & operator=.
43 // The ones generated by the compiler are adequate.
44
46
47 static inline bool ClassOf( const EDA_ITEM* aItem )
48 {
49 return aItem && aItem->Type() == PCB_FP_TEXT_T;
50 }
51
52 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
53 {
54 if( BOARD_ITEM::IsType( aScanTypes ) )
55 return true;
56
57 for( KICAD_T scanType : aScanTypes )
58 {
59 if( scanType == PCB_LOCATE_TEXT_T )
60 return true;
61 }
62
63 return false;
64 }
65
66 VECTOR2I GetTopLeft() const override;
67 VECTOR2I GetBotRight() const override;
68
69 void SetTop( int aVal ) override;
70 void SetLeft( int aVal ) override;
71 void SetRight( int aVal ) override;
72 void SetBottom( int aVal ) override;
73
74 wxString GetParentAsString() const;
75
76 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
77 {
78 return BOARD_ITEM::Matches( GetShownText(), aSearchData );
79 }
80
81 int GetTextMargin() const;
82
83 virtual EDA_ANGLE GetDrawRotation() const override;
84
85 VECTOR2I GetDrawPos() const override;
86
87 std::vector<VECTOR2I> GetAnchorAndOppositeCorner() const;
88
89 void Move( const VECTOR2I& aMoveVector ) override;
90
91 void Rotate( const VECTOR2I& aOffset, const EDA_ANGLE& aAngle ) override;
92
93 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
94
98 void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis ) override;
99
100 // The Pos0 accessors are for footprint-relative coordinates.
101 void SetPos0( const VECTOR2I& aPos ) { m_Pos0 = aPos; SetDrawCoord(); }
102 const VECTOR2I& GetPos0() const { return m_Pos0; }
103
104 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
105
106 bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
107 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
108
109 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
110 int aError, ERROR_LOC aErrorLoc,
111 bool aIgnoreLineWidth = false ) const override;
112
113 void TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
114 int aError, ERROR_LOC aErrorLoc ) const;
115
116 // @copydoc BOARD_ITEM::GetEffectiveShape
117 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
118 FLASHING aFlash = FLASHING::DEFAULT ) const override;
119
120 wxString GetClass() const override
121 {
122 return wxT( "FP_TEXTBOX" );
123 }
124
125 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
126
127 BITMAPS GetMenuImage() const override;
128
129 EDA_ITEM* Clone() const override;
130
131 virtual wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
132
133 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
134
135 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
136
137#if defined(DEBUG)
138 virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
139#endif
140
141private:
144};
145
146#endif // FP_TEXTBOX_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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: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:181
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
virtual void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:80
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
Definition: fp_textbox.cpp:229
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: fp_textbox.cpp:393
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: fp_textbox.cpp:360
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_textbox.cpp:422
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: fp_textbox.cpp:473
VECTOR2I m_Pos0
text coordinates relative to the footprint anchor, orient 0.
Definition: fp_textbox.h:142
FP_TEXTBOX(FOOTPRINT *aParentFootprint)
Definition: fp_textbox.cpp:37
void SetBottom(int aVal) override
Definition: fp_textbox.cpp:101
void SetTop(int aVal) override
Definition: fp_textbox.cpp:90
wxString GetParentAsString() const
Definition: fp_textbox.cpp:500
int GetTextMargin() const
Definition: fp_textbox.cpp:54
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: fp_textbox.cpp:330
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: fp_textbox.cpp:252
VECTOR2I GetDrawPos() const override
Definition: fp_textbox.cpp:191
void SetPos0(const VECTOR2I &aPos)
Definition: fp_textbox.h:101
void SetRight(int aVal) override
Definition: fp_textbox.cpp:123
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Definition: fp_textbox.cpp:433
virtual EDA_ANGLE GetDrawRotation() const override
Definition: fp_textbox.cpp:134
static bool ClassOf(const EDA_ITEM *aItem)
Definition: fp_textbox.h:47
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: fp_textbox.h:52
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_textbox.cpp:303
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
Mirror the textbox's position, but not the text (or its justification).
Definition: fp_textbox.cpp:289
const VECTOR2I & GetPos0() const
Definition: fp_textbox.h:102
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip entity relative to aCentre.
Definition: fp_textbox.cpp:266
std::vector< VECTOR2I > GetAnchorAndOppositeCorner() const
Definition: fp_textbox.cpp:148
void SetLeft(int aVal) override
Definition: fp_textbox.cpp:112
void Rotate(const VECTOR2I &aOffset, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: fp_textbox.cpp:259
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: fp_textbox.cpp:349
VECTOR2I GetTopLeft() const override
Definition: fp_textbox.cpp:60
wxString GetClass() const override
Return the class name.
Definition: fp_textbox.h:120
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: fp_textbox.cpp:337
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: fp_textbox.h:76
VECTOR2I GetBotRight() const override
Definition: fp_textbox.cpp:75
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_textbox.cpp:343
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
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