KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef SCH_TEXTBOX_H
21#define SCH_TEXTBOX_H
22
23
24#include <eda_text.h>
25#include <sch_shape.h>
26#include <schematic.h>
27
28
30
32{
33 class SchematicTextBox;
34}
35
36class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT
37{
38public:
39 SCH_TEXTBOX( SCH_LAYER_ID aLayer = LAYER_NOTES, int aLineWidth = 0,
40 FILL_T aFillType = FILL_T::NO_FILL, const wxString& aText = wxEmptyString,
41 KICAD_T aType = SCH_TEXTBOX_T );
42
43 SCH_TEXTBOX( const SCH_TEXTBOX& aText );
44
46
47 void Serialize( google::protobuf::Any& aContainer ) const override;
48 bool Deserialize( const google::protobuf::Any& aContainer ) override;
49
50 void Serialize( kiapi::schematic::types::SchematicTextBox& aOutput,
51 const EDA_IU_SCALE& aScale ) const;
52 bool Deserialize( const kiapi::schematic::types::SchematicTextBox& aInput,
53 const EDA_IU_SCALE& aScale );
54
55 static bool ClassOf( const EDA_ITEM* aItem )
56 {
57 return aItem && SCH_TEXTBOX_T == aItem->Type();
58 }
59
60 wxString GetClass() const override
61 {
62 return wxT( "SCH_TEXTBOX" );
63 }
64
65 int GetLegacyTextMargin() const;
66
72 VECTOR2I GetMinSize() const;
73
74 void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
75 void SetMarginTop( int aTop ) { m_marginTop = aTop; }
76 void SetMarginRight( int aRight ) { m_marginRight = aRight; }
77 void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
78
79 int GetMarginLeft() const { return m_marginLeft; }
80 int GetMarginTop() const { return m_marginTop; }
81 int GetMarginRight() const { return m_marginRight; }
82 int GetMarginBottom() const { return m_marginBottom; }
83
84 int GetSchTextSize() const { return GetTextWidth(); }
85 void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
86
87 VECTOR2I GetDrawPos() const override;
88
89 KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const override;
90
91 virtual wxString GetShownText( const RENDER_SETTINGS* aSettings, const SCH_SHEET_PATH* aPath,
92 RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const;
93
94 wxString GetShownText( RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override
95 {
96 SCH_SHEET_PATH* sheetPath = nullptr;
97
98 if( SCHEMATIC* schematic = Schematic() )
99 sheetPath = &schematic->CurrentSheet();
100
101 return GetShownText( nullptr, sheetPath, aContext, aDepth );
102 }
103
104 bool HasHypertext() const override;
105 bool HasHoveredHypertext() const override;
106 void DoHypertextAction( EDA_DRAW_FRAME* aFrame, const VECTOR2I& aMousePos ) const override;
107
108 void SetExcludedFromSim( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
109 const wxString& aVariantName = wxEmptyString ) override
110 {
111 m_excludedFromSim = aExclude;
112 }
113
114 bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
115 const wxString& aVariantName = wxEmptyString ) const override
116 {
117 return m_excludedFromSim;
118 }
119
120 bool operator<( const SCH_ITEM& aItem ) const override;
121
122 void Move( const VECTOR2I& aMoveVector ) override
123 {
124 EDA_SHAPE::move( aMoveVector );
125 EDA_TEXT::Offset( aMoveVector );
126 }
127
128 void MirrorHorizontally( int aCenter ) override;
129 void MirrorVertically( int aCenter ) override;
130 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
131
132 virtual void Rotate90( bool aClockwise );
133
134 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
135
136 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
137 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
138
139 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
140 {
141 return SCH_ITEM::Matches( GetText(), aSearchData );
142 }
143
144 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
145 {
146 return EDA_TEXT::Replace( aSearchData );
147 }
148
149 virtual bool IsReplaceable() const override { return true; }
150
151 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
152
153 BITMAPS GetMenuImage() const override;
154
155 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
156 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
157
158 EDA_ITEM* Clone() const override
159 {
160 return new SCH_TEXTBOX( *this );
161 }
162
163 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
164
165 double Similarity( const SCH_ITEM& aOther ) const override;
166
167 bool operator==( const SCH_ITEM& aOther ) const override;
168
169protected:
170 void swapData( SCH_ITEM* aItem ) override;
171
172 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
173
174 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
175
176protected:
182};
183
184
185#endif /* SCH_TEXTBOX_H */
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:482
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
void move(const VECTOR2I &aMoveVector)
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:495
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
virtual void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:558
virtual int GetTextWidth() const
Definition eda_text.h:304
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition eda_text.cpp:445
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
Definition eda_text.cpp:98
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition plotter.h:136
Holds all the data relating to one schematic.
Definition schematic.h:148
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:281
const KIFONT::METRICS & GetFontMetrics() const
Definition sch_item.cpp:815
SCH_SHAPE(SHAPE_T aShape=SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
Definition sch_shape.cpp:41
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetMarginBottom(int aBottom)
Definition sch_textbox.h:77
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
int GetMarginBottom() const
Definition sch_textbox.h:82
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
bool m_excludedFromSim
bool operator==(const SCH_ITEM &aOther) const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetLegacyTextMargin() const
int GetMarginLeft() const
Definition sch_textbox.h:79
int GetSchTextSize() const
Definition sch_textbox.h:84
virtual bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
virtual wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition sch_textbox.h:94
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator<(const SCH_ITEM &aItem) const override
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetClass() const override
Return the class name.
Definition sch_textbox.h:60
bool HasHypertext() const override
Indicates that the item has at least one hypertext action.
const KIFONT::METRICS & getFontMetrics() const override
VECTOR2I GetDrawPos() const override
int GetMarginRight() const
Definition sch_textbox.h:81
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
VECTOR2I GetMinSize() const
Return the minimum height needed to contain the textbox's wrapped text content plus margins.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
bool HasHoveredHypertext() const override
Indicates that a hypertext link is currently active.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_textbox.h:55
int GetMarginTop() const
Definition sch_textbox.h:80
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
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 SetMarginLeft(int aLeft)
Definition sch_textbox.h:74
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void DoHypertextAction(EDA_DRAW_FRAME *aFrame, const VECTOR2I &aMousePos) const override
virtual void Rotate90(bool aClockwise)
void SetMarginRight(int aRight)
Definition sch_textbox.h:76
void SetSchTextSize(int aSize)
Definition sch_textbox.h:85
KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const override
SCH_TEXTBOX(SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, const wxString &aText=wxEmptyString, KICAD_T aType=SCH_TEXTBOX_T)
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetExcludedFromSim(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetMarginTop(int aTop)
Definition sch_textbox.h:75
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
RESOLUTION_CONTEXT
Definition common.h:87
FILL_T
Definition eda_fill.h:29
@ NO_FILL
Definition eda_fill.h:30
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:471
@ LAYER_NOTES
Definition layer_ids.h:489
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ SCH_TEXTBOX_T
Definition typeinfo.h:148
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683