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 IsHypertext() const override
81 {
82 return HasHyperlink();
83 }
84
85 void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
86
87 void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
88 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
89
96 virtual VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const;
97
98 const BOX2I GetBoundingBox() const override;
99
100 bool operator<( const SCH_ITEM& aItem ) const override;
101
102 int GetTextOffset( const RENDER_SETTINGS* aSettings = nullptr ) const;
103
104 int GetPenWidth() const override;
105
106 void Move( const VECTOR2I& aMoveVector ) override
107 {
108 EDA_TEXT::Offset( aMoveVector );
109 }
110
111 void NormalizeJustification( bool inverse );
112
113 void MirrorHorizontally( int aCenter ) override;
114 void MirrorVertically( int aCenter ) override;
115 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
116
117 virtual void Rotate90( bool aClockwise );
118 virtual void MirrorSpinStyle( bool aLeftRight );
119
120 void BeginEdit( const VECTOR2I& aStartPoint ) override;
121 void CalcEdit( const VECTOR2I& aPosition ) override;
122
123 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
124 {
125 return SCH_ITEM::Matches( GetText(), aSearchData );
126 }
127
128 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
129 {
130 return EDA_TEXT::Replace( aSearchData );
131 }
132
133 bool IsReplaceable() const override { return true; }
134
135 std::vector<int> ViewGetLayers() const override;
136
137 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
138
139 BITMAPS GetMenuImage() const override;
140
141 VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
142 void SetPosition( const VECTOR2I& aPosition ) override
143 {
144 EDA_TEXT::SetTextPos( aPosition );
145 }
146
147 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
148 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
149 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
150
151 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
152 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
153
154 EDA_ITEM* Clone() const override
155 {
156 return new SCH_TEXT( *this );
157 }
158
159 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
160
161 double Similarity( const SCH_ITEM& aItem ) const override;
162
163 bool operator==( const SCH_ITEM& aItem ) const override;
164
165#if defined(DEBUG)
166 void Show( int nestLevel, std::ostream& os ) const override;
167#endif
168
169 static HTML_MESSAGE_BOX* ShowSyntaxHelp( wxWindow* aParentWindow );
170
171protected:
172 void swapData( SCH_ITEM* aItem ) override;
173
174 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
175
186 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
187
188protected:
190};
191
192
193#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: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:401
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:39
const VECTOR2I & GetTextPos() const
Definition eda_text.h:272
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:534
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:97
void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:579
int GetTextWidth() const
Definition eda_text.h:263
virtual bool HasHyperlink() const
Definition eda_text.h:399
void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:597
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition eda_text.cpp:487
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
Definition eda_text.cpp:96
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:131
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition plotter.h:121
Holds all the data relating to one schematic.
Definition schematic.h:88
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:171
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:217
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:51
const KIFONT::METRICS & GetFontMetrics() const
Definition sch_item.cpp:593
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:375
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_text.h:47
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition sch_text.cpp:365
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_text.h:154
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:641
const KIFONT::METRICS & getFontMetrics() const override
Definition sch_text.h:174
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition sch_text.h:80
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition sch_text.cpp:382
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:232
KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const override
Definition sch_text.cpp:285
bool m_excludedFromSim
Definition sch_text.h:189
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition sch_text.h:106
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition sch_text.cpp:159
~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:198
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition sch_text.cpp:428
wxString GetClass() const override
Return the class name.
Definition sch_text.h:52
void NormalizeJustification(bool inverse)
Definition sch_text.cpp:80
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
bool operator<(const SCH_ITEM &aItem) const override
Definition sch_text.cpp:241
VECTOR2I GetPosition() const override
Definition sch_text.h:141
virtual void Rotate90(bool aClockwise)
Definition sch_text.cpp:210
void SetPosition(const VECTOR2I &aPosition) override
Definition sch_text.h:142
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:128
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition sch_text.h:123
void SetExcludedFromSim(bool aExclude) override
Definition sch_text.h:87
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:434
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition sch_text.cpp:120
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:617
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_text.cpp:296
int GetPenWidth() const override
Definition sch_text.cpp:279
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:317
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:443
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:388
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition sch_text.h:133
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:551
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition sch_text.cpp:422
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:73
bool GetExcludedFromSim() const override
Definition sch_text.h:88
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:222
bool operator==(const SCH_ITEM &aItem) const override
Definition sch_text.cpp:600
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition sch_text.cpp:264
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:51
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:448
@ LAYER_NOTES
Definition layer_ids.h:466
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:78
@ SCH_TEXT_T
Definition typeinfo.h:153
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695