KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
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 SCH_TEXT_H
26#define SCH_TEXT_H
27
28
29#include <eda_text.h>
30#include <sch_item.h>
31#include <sch_connection.h> // for CONNECTION_TYPE
32#include <schematic.h>
33
34
36
37class SCH_TEXT : public SCH_ITEM, public EDA_TEXT
38{
39public:
40 SCH_TEXT( const VECTOR2I& aPos = { 0, 0 }, const wxString& aText = wxEmptyString,
41 SCH_LAYER_ID aLayer = LAYER_NOTES, KICAD_T aType = SCH_TEXT_T );
42
43 SCH_TEXT( const SCH_TEXT& aText );
44
45 ~SCH_TEXT() override { }
46
47 static bool ClassOf( const EDA_ITEM* aItem )
48 {
49 return aItem && SCH_TEXT_T == aItem->Type();
50 }
51
52 wxString GetClass() const override
53 {
54 return wxT( "SCH_TEXT" );
55 }
56
57 wxString GetFriendlyName() const override
58 {
59 return _( "Text" );
60 }
61
62 KIFONT::FONT* GetDrawFont( const RENDER_SETTINGS* aSettings ) const override;
63
64 virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
65 int aDepth = 0 ) const;
66
67 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
68 {
69 SCHEMATIC* schematic = Schematic();
70
71 if( schematic )
72 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
73 else
74 return GetText();
75 }
76
77 int GetSchTextSize() const { return GetTextWidth(); }
78 void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
79
80 bool HasHypertext() const override;
81 bool HasHoveredHypertext() const override;
82 void DoHypertextAction( EDA_DRAW_FRAME* aFrame, const VECTOR2I& aMousePos ) const override;
83
84 void SetExcludedFromSim( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
85 const wxString& aVariantName = wxEmptyString ) override
86 {
87 m_excludedFromSim = aExclude;
88 }
89
90 bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
91 const wxString& aVariantName = wxEmptyString ) const override
92 {
93 return m_excludedFromSim;
94 }
95
102 virtual VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const;
103
104 const BOX2I GetBoundingBox() const override;
105
106 bool operator<( const SCH_ITEM& aItem ) const override;
107
108 int GetTextOffset( const RENDER_SETTINGS* aSettings = nullptr ) const;
109
110 int GetPenWidth() const override;
111
112 void Move( const VECTOR2I& aMoveVector ) override
113 {
114 EDA_TEXT::Offset( aMoveVector );
115 }
116
117 void NormalizeJustification( bool inverse );
118
119 void MirrorHorizontally( int aCenter ) override;
120 void MirrorVertically( int aCenter ) override;
121 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
122
123 virtual void Rotate90( bool aClockwise );
124 virtual void MirrorSpinStyle( bool aLeftRight );
125
126 void BeginEdit( const VECTOR2I& aStartPoint ) override;
127 void CalcEdit( const VECTOR2I& aPosition ) override;
128
129 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
130 {
131 return SCH_ITEM::Matches( GetText(), aSearchData );
132 }
133
134 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
135 {
136 return EDA_TEXT::Replace( aSearchData );
137 }
138
139 bool IsReplaceable() const override { return true; }
140
141 std::vector<int> ViewGetLayers() const override;
142
143 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
144
145 BITMAPS GetMenuImage() const override;
146
147 VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
148 void SetPosition( const VECTOR2I& aPosition ) override
149 {
150 EDA_TEXT::SetTextPos( aPosition );
151 }
152
153 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
154 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
155 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
156
158
159 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
160 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
161
162 EDA_ITEM* Clone() const override
163 {
164 return new SCH_TEXT( *this );
165 }
166
167 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
168
169 double Similarity( const SCH_ITEM& aItem ) const override;
170
171 bool operator==( const SCH_ITEM& aItem ) const override;
172
173#if defined(DEBUG)
174 void Show( int nestLevel, std::ostream& os ) const override;
175#endif
176
177 static HTML_MESSAGE_BOX* ShowSyntaxHelp( wxWindow* aParentWindow );
178
179protected:
180 void swapData( SCH_ITEM* aItem ) override;
181
182 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
183
194 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
195
196protected:
198};
199
200
201#endif /* SCH_TEXT_H */
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:111
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:407
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
const VECTOR2I & GetTextPos() const
Definition eda_text.h:273
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:546
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:590
int GetTextWidth() const
Definition eda_text.h:264
void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:608
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition eda_text.cpp:500
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
Definition eda_text.cpp:100
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:98
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:88
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:187
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:254
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
const KIFONT::METRICS & GetFontMetrics() const
Definition sch_item.cpp:759
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition sch_text.cpp:388
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_text.h:47
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_text.h:162
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition sch_text.cpp:714
const KIFONT::METRICS & getFontMetrics() const override
Definition sch_text.h:182
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition sch_text.cpp:395
int GetSchTextSize() const
Definition sch_text.h:77
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition sch_text.cpp:233
KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const override
Definition sch_text.cpp:286
bool m_excludedFromSim
Definition sch_text.h:197
void SetExcludedFromSim(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Definition sch_text.h:84
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition sch_text.h:90
void DoHypertextAction(EDA_DRAW_FRAME *aFrame, const VECTOR2I &aMousePos) const override
Definition sch_text.cpp:377
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition sch_text.h:112
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition sch_text.cpp:162
~SCH_TEXT() override
Definition sch_text.h:45
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition sch_text.cpp:201
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition sch_text.cpp:441
wxString GetClass() const override
Return the class name.
Definition sch_text.h:52
void NormalizeJustification(bool inverse)
Definition sch_text.cpp:83
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
bool operator<(const SCH_ITEM &aItem) const override
Definition sch_text.cpp:242
VECTOR2I GetPosition() const override
Definition sch_text.h:147
VECTOR2I GetOffsetToMatchSCH_FIELD(SCH_RENDER_SETTINGS *aRenderSettings) const
Definition sch_text.cpp:456
virtual void Rotate90(bool aClockwise)
Definition sch_text.cpp:213
void SetPosition(const VECTOR2I &aPosition) override
Definition sch_text.h:148
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 ...
Definition sch_text.h:134
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition sch_text.h:129
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition sch_text.cpp:447
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition sch_text.cpp:123
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition sch_text.cpp:690
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_text.cpp:297
int GetPenWidth() const override
Definition sch_text.cpp:280
bool HasHoveredHypertext() const override
Indicates that a hypertext link is currently active.
Definition sch_text.cpp:371
void SetSchTextSize(int aSize)
Definition sch_text.h:78
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition sch_text.cpp:318
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.
Definition sch_text.cpp:473
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition sch_text.cpp:401
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition sch_text.h:139
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 sch_text.cpp:624
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition sch_text.cpp:435
virtual VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Definition sch_text.cpp:76
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition sch_text.h:67
wxString GetFriendlyName() const override
Definition sch_text.h:57
virtual void MirrorSpinStyle(bool aLeftRight)
Definition sch_text.cpp:224
bool HasHypertext() const override
Indicates that the item has at least one hypertext action.
Definition sch_text.cpp:365
bool operator==(const SCH_ITEM &aItem) const override
Definition sch_text.cpp:673
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition sch_text.cpp:265
SCH_TEXT(const VECTOR2I &aPos={ 0, 0 }, const wxString &aText=wxEmptyString, SCH_LAYER_ID aLayer=LAYER_NOTES, KICAD_T aType=SCH_TEXT_T)
Definition sch_text.cpp:55
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
#define _(s)
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:449
@ LAYER_NOTES
Definition layer_ids.h:467
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:78
@ SCH_TEXT_T
Definition typeinfo.h:155
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695