KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_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) 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_TEXTBOX_H
26#define PCB_TEXTBOX_H
27
28#include <eda_text.h>
29#include <pcb_shape.h>
30
31
32class LINE_READER;
33class MSG_PANEL_ITEM;
34
35
36class PCB_TEXTBOX : public PCB_SHAPE, public EDA_TEXT
37{
38public:
39 PCB_TEXTBOX( BOARD_ITEM* aParent, KICAD_T aType = PCB_TEXTBOX_T );
40
41 // Do not create a copy constructor & operator=.
42 // The ones generated by the compiler are adequate.
43
45
46 static inline bool ClassOf( const EDA_ITEM* aItem )
47 {
48 return aItem && PCB_TEXTBOX_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 GetFriendlyName() const override { return _( "Text Box" ); }
66
67 VECTOR2I GetTopLeft() const override;
68 VECTOR2I GetBotRight() const override;
69
70 void SetTop( int aVal ) override;
71 void SetLeft( int aVal ) override;
72 void SetRight( int aVal ) override;
73 void SetBottom( int aVal ) override;
74
75 void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) override;
76
77 int GetLegacyTextMargin() const;
78
79 void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
80 void SetMarginTop( int aTop ) { m_marginTop = aTop; }
81 void SetMarginRight( int aRight ) { m_marginRight = aRight; }
82 void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
83
84 int GetMarginLeft() const { return m_marginLeft; }
85 int GetMarginTop() const { return m_marginTop; }
86 int GetMarginRight() const { return m_marginRight; }
87 int GetMarginBottom() const { return m_marginBottom; }
88
89 VECTOR2I GetDrawPos() const override;
90
91 void SetTextAngle( const EDA_ANGLE& aAngle ) override;
92
93 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
94
96 void SetVisible( bool aVisible ) override { /* do nothing */}
97 bool IsVisible() const override { return true; }
98
99 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
100
101 std::vector<VECTOR2I> GetAnchorAndOppositeCorner() const;
102
103 void Move( const VECTOR2I& aMoveVector ) override;
104
105 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
106
107 void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis ) override;
108
109 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
110
111 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
112
113 bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
114
115 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
116
117 wxString GetClass() const override
118 {
119 return wxT( "PCB_TEXTBOX" );
120 }
121
131 void TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
132 ERROR_LOC aErrorLoc ) const;
133
134 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
135 int aMaxError, ERROR_LOC aErrorLoc,
136 bool aIgnoreLineWidth = false ) const override;
137
138 // @copydoc BOARD_ITEM::GetEffectiveShape
139 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
140 FLASHING aFlash = FLASHING::DEFAULT ) const override;
141
142 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
143
144 BITMAPS GetMenuImage() const override;
145
146 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
147
148 void ViewGetLayers( int aLayers[], int& aCount ) const override;
149
150 EDA_ITEM* Clone() const override;
151
153 bool IsBorderEnabled() const;
154
156 void SetBorderEnabled( bool enabled );
157
158 void SetBorderWidth( const int aSize );
159 int GetBorderWidth() const { return m_stroke.GetWidth(); }
160
161 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
162
163 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
164
165protected:
167
168 virtual void swapData( BOARD_ITEM* aImage ) override;
169
170 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
171
172private:
177};
178
179#endif // #define PCB_TEXTBOX_H
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:77
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:97
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:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:175
STROKE_PARAMS m_stroke
Definition: eda_shape.h:396
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:83
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
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
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
virtual void swapData(BOARD_ITEM *aImage) override
void SetBorderWidth(const int aSize)
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
wxString GetFriendlyName() const override
Definition: pcb_textbox.h:65
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetMarginBottom() const
Definition: pcb_textbox.h:87
const KIFONT::METRICS & getFontMetrics() const override
Definition: pcb_textbox.h:170
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the shape to a closed polygon.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
bool m_borderEnabled
Controls drawing the border (as defined by the stroke members)
Definition: pcb_textbox.h:166
int m_marginLeft
Definition: pcb_textbox.h:173
int m_marginBottom
Definition: pcb_textbox.h:176
bool operator==(const BOARD_ITEM &aBoardItem) const override
void SetBorderEnabled(bool enabled)
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...
void SetVisible(bool aVisible) override
PCB_TEXTBOXes are always visible:
Definition: pcb_textbox.h:96
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: pcb_textbox.h:51
int m_marginRight
Definition: pcb_textbox.h:175
std::vector< VECTOR2I > GetAnchorAndOppositeCorner() const
EDA_ITEM * Clone() const override
Tests whether the border is disabled, as configured by the stroke.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
VECTOR2I GetDrawPos() const override
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.
void SetMarginTop(int aTop)
Definition: pcb_textbox.h:80
void SetLeft(int aVal) override
int GetMarginLeft() const
Definition: pcb_textbox.h:84
void SetMarginLeft(int aLeft)
Definition: pcb_textbox.h:79
void SetMarginBottom(int aBottom)
Definition: pcb_textbox.h:82
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_textbox.h:46
int GetMarginRight() const
Definition: pcb_textbox.h:86
void SetRight(int aVal) override
void SetTop(int aVal) override
int GetMarginTop() const
Definition: pcb_textbox.h:85
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
void SetTextAngle(const EDA_ANGLE &aAngle) override
void SetMarginRight(int aRight)
Definition: pcb_textbox.h:81
void Move(const VECTOR2I &aMoveVector) override
Move this object.
int GetLegacyTextMargin() const
Definition: pcb_textbox.cpp:75
void SetBottom(int aVal) override
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
VECTOR2I GetTopLeft() const override
Definition: pcb_textbox.cpp:81
VECTOR2I GetBotRight() const override
Definition: pcb_textbox.cpp:96
bool IsVisible() const override
Definition: pcb_textbox.h:97
int GetBorderWidth() const
Definition: pcb_textbox.h:159
wxString GetClass() const override
Return the class name.
Definition: pcb_textbox.h:117
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_textbox.cpp:63
void ViewGetLayers(int aLayers[], int &aCount) const override
Represent a set of closed polygons.
int GetWidth() const
Definition: stroke_params.h:91
#define _(s)
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:149
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_LOCATE_TEXT_T
Definition: typeinfo.h:126