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 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_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 void CopyFrom( const BOARD_ITEM* aOther ) override;
47
48 static inline bool ClassOf( const EDA_ITEM* aItem )
49 {
50 return aItem && PCB_TEXTBOX_T == aItem->Type();
51 }
52
53 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
54 {
55 if( BOARD_ITEM::IsType( aScanTypes ) )
56 return true;
57
58 for( KICAD_T scanType : aScanTypes )
59 {
60 if( scanType == PCB_LOCATE_TEXT_T )
61 return true;
62 }
63
64 return false;
65 }
66
67 void Serialize( google::protobuf::Any &aContainer ) const override;
68 bool Deserialize( const google::protobuf::Any &aContainer ) override;
69
70 wxString GetFriendlyName() const override { return _( "Text Box" ); }
71
72 VECTOR2I GetTopLeft() const override;
73 VECTOR2I GetBotRight() const override;
74
80 VECTOR2I GetMinSize() const;
81
82 void SetTop( int aVal ) override;
83 void SetLeft( int aVal ) override;
84 void SetRight( int aVal ) override;
85 void SetBottom( int aVal ) override;
86
87 void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) override;
88
89 int GetLegacyTextMargin() const;
90
91 void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
92 void SetMarginTop( int aTop ) { m_marginTop = aTop; }
93 void SetMarginRight( int aRight ) { m_marginRight = aRight; }
94 void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
95
96 int GetMarginLeft() const { return m_marginLeft; }
97 int GetMarginTop() const { return m_marginTop; }
98 int GetMarginRight() const { return m_marginRight; }
99 int GetMarginBottom() const { return m_marginBottom; }
100
101 VECTOR2I GetDrawPos() const override;
102 VECTOR2I GetDrawPos( bool aIsFlipped ) const;
103
104 void SetTextAngle( const EDA_ANGLE& aAngle ) override;
105
106 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
107
108 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
109
110 void Move( const VECTOR2I& aMoveVector ) override;
111
112 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
113
114 void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
115
116 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
117
118 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
119
120 bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
121
122 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
123
124 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
125
126 wxString GetClass() const override
127 {
128 return wxT( "PCB_TEXTBOX" );
129 }
130
140 void TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
141 ERROR_LOC aErrorLoc ) const;
142
143 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
144 int aMaxError, ERROR_LOC aErrorLoc,
145 bool aIgnoreLineWidth = false ) const override;
146
147 // @copydoc BOARD_ITEM::GetEffectiveShape
148 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
149 FLASHING aFlash = FLASHING::DEFAULT ) const override;
150
151 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
152
153 BITMAPS GetMenuImage() const override;
154
155 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
156
157 std::vector<int> ViewGetLayers() const override;
158
159 EDA_ITEM* Clone() const override;
160
162 bool IsBorderEnabled() const;
163
165 void SetBorderEnabled( bool enabled );
166
167 void SetBorderWidth( const int aSize );
168 int GetBorderWidth() const { return m_stroke.GetWidth(); }
169
170 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
171
172 bool operator==( const PCB_TEXTBOX& aOther ) const;
173 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
174
175protected:
176 EDA_ANGLE getDrawRotation() const override { return GetDrawRotation(); }
177
178 virtual void swapData( BOARD_ITEM* aImage ) override;
179
180 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
181
182protected:
184
185private:
190};
191
192#endif // #define PCB_TEXTBOX_H
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
const KIFONT::METRICS & GetFontMetrics() const
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:99
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:111
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:198
STROKE_PARAMS m_stroke
Definition eda_shape.h:495
virtual EDA_ANGLE GetDrawRotation() const
Definition eda_text.h:379
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
Definition eda_text.cpp:100
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:66
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:54
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T aItemType, SHAPE_T aShapeType)
Definition pcb_shape.cpp: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:70
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetMarginBottom() const
Definition pcb_textbox.h:99
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings, bool aCheckSide) override
PCB_TEXTBOX(BOARD_ITEM *aParent, KICAD_T aType=PCB_TEXTBOX_T)
const KIFONT::METRICS & getFontMetrics() const override
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)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void SetBorderEnabled(bool enabled)
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
VECTOR2I GetMinSize() const
Return the minimum height needed to contain the textbox's wrapped text content plus margins.
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...
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition pcb_textbox.h:53
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
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.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
VECTOR2I GetDrawPos() const override
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
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:92
void SetLeft(int aVal) override
int GetMarginLeft() const
Definition pcb_textbox.h:96
void SetMarginLeft(int aLeft)
Definition pcb_textbox.h:91
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void SetMarginBottom(int aBottom)
Definition pcb_textbox.h:94
static bool ClassOf(const EDA_ITEM *aItem)
Definition pcb_textbox.h:48
int GetMarginRight() const
Definition pcb_textbox.h:98
void SetRight(int aVal) override
std::vector< int > ViewGetLayers() const override
void SetTop(int aVal) override
int GetMarginTop() const
Definition pcb_textbox.h:97
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
bool operator==(const PCB_TEXTBOX &aOther) const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetMarginRight(int aRight)
Definition pcb_textbox.h:93
void Move(const VECTOR2I &aMoveVector) override
Move this object.
int GetLegacyTextMargin() const
EDA_ANGLE getDrawRotation() const override
void SetBottom(int aVal) override
VECTOR2I GetTopLeft() const override
VECTOR2I GetBotRight() const override
void CopyFrom(const BOARD_ITEM *aOther) override
int GetBorderWidth() const
wxString GetClass() const override
Return the class name.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
#define _(s)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:184
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:185
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_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:93
@ PCB_LOCATE_TEXT_T
Definition typeinfo.h:130
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695