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 (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 SCH_TEXT_H
26#define SCH_TEXT_H
27
28
29#include <eda_text.h>
30#include <sch_item.h>
31#include <sch_field.h>
32#include <sch_connection.h> // for CONNECTION_TYPE
33#include <schematic.h>
34
35
37
38class SCH_TEXT : public SCH_ITEM, public EDA_TEXT
39{
40public:
41 SCH_TEXT( const VECTOR2I& aPos = { 0, 0 }, const wxString& aText = wxEmptyString,
42 KICAD_T aType = SCH_TEXT_T );
43
44 SCH_TEXT( const SCH_TEXT& aText );
45
47
48 static inline bool ClassOf( const EDA_ITEM* aItem )
49 {
50 return aItem && SCH_TEXT_T == aItem->Type();
51 }
52
53 virtual wxString GetClass() const override
54 {
55 return wxT( "SCH_TEXT" );
56 }
57
58 virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
59 int aDepth = 0 ) const;
60
61 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
62 {
63 SCHEMATIC* schematic = Schematic();
64
65 if( schematic )
66 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
67 else
68 return GetText();
69 }
70
71 int GetSchTextSize() const { return GetTextWidth(); }
72 void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
73
74 bool IsHypertext() const override
75 {
76 return HasHyperlink();
77 }
78
79 void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
80
81 void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
82 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
83
90 virtual VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const;
91
92 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
93
94 void SwapData( SCH_ITEM* aItem ) override;
95
96 const BOX2I GetBoundingBox() const override;
97
98 bool operator<( const SCH_ITEM& aItem ) const override;
99
100 int GetTextOffset( const RENDER_SETTINGS* aSettings = nullptr ) const;
101
102 int GetPenWidth() const override;
103
104 void Move( const VECTOR2I& aMoveVector ) override
105 {
106 EDA_TEXT::Offset( aMoveVector );
107 }
108
109 void MirrorHorizontally( int aCenter ) override;
110 void MirrorVertically( int aCenter ) override;
111 void Rotate( const VECTOR2I& aCenter ) override;
112
113 virtual void Rotate90( bool aClockwise );
114 virtual void MirrorSpinStyle( bool aLeftRight );
115
116 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
117 {
118 return SCH_ITEM::Matches( GetText(), aSearchData );
119 }
120
121 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
122 {
123 return EDA_TEXT::Replace( aSearchData );
124 }
125
126 virtual bool IsReplaceable() const override { return true; }
127
128 void ViewGetLayers( int aLayers[], int& aCount ) const override;
129
130 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
131
132 BITMAPS GetMenuImage() const override;
133
134 VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
135 void SetPosition( const VECTOR2I& aPosition ) override { EDA_TEXT::SetTextPos( aPosition ); }
136
137 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
138 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
139
140 void Plot( PLOTTER* aPlotter, bool aBackground,
141 const SCH_PLOT_SETTINGS& aPlotSettings ) const override;
142
143 EDA_ITEM* Clone() const override
144 {
145 return new SCH_TEXT( *this );
146 }
147
148 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
149
150 virtual double Similarity( const SCH_ITEM& aItem ) const override;
151
152 virtual bool operator==( const SCH_ITEM& aItem ) const override;
153
154#if defined(DEBUG)
155 void Show( int nestLevel, std::ostream& os ) const override;
156#endif
157
158 static HTML_MESSAGE_BOX* ShowSyntaxHelp( wxWindow* aParentWindow );
159
160protected:
161 KIFONT::FONT* getDrawFont() const override;
162
163 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
164
165protected:
167};
168
169
170#endif /* SCH_TEXT_H */
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:372
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:230
void SetTextSize(VECTOR2I aNewSize)
Definition: eda_text.cpp:358
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:401
int GetTextWidth() const
Definition: eda_text.h:221
virtual bool HasHyperlink() const
Definition: eda_text.h:357
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:419
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:329
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:104
Holds all the data relating to one schematic.
Definition: schematic.h:75
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:136
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:331
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_text.h:48
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_text.cpp:289
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_text.h:143
const KIFONT::METRICS & getFontMetrics() const override
Definition: sch_text.h:163
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_text.h:74
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_text.cpp:305
int GetSchTextSize() const
Definition: sch_text.h:71
bool m_excludedFromSim
Definition: sch_text.h:166
~SCH_TEXT()
Definition: sch_text.h:46
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_text.h:104
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_text.cpp:88
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Definition: sch_label.cpp:2050
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_text.cpp:144
VECTOR2I GetPosition() const override
Definition: sch_text.h:134
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:109
virtual bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_text.h:126
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_text.h:135
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:121
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_text.h:116
void SetExcludedFromSim(bool aExclude) override
Definition: sch_text.h:81
KIFONT::FONT * getDrawFont() const override
Definition: sch_text.cpp:188
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_text.cpp:79
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_text.cpp:97
virtual 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:444
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:131
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:230
virtual wxString GetClass() const override
Return the class name.
Definition: sch_text.h:53
int GetPenWidth() const override
Definition: sch_text.cpp:182
void SetSchTextSize(int aSize)
Definition: sch_text.h:72
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_text.cpp:251
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_text.cpp:331
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &offset) override
Print a schematic item.
Definition: sch_text.cpp:199
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:311
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_text.cpp:299
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:399
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:72
bool GetExcludedFromSim() const override
Definition: sch_text.h:82
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.h:61
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_SETTINGS &aPlotSettings) const override
Plot the schematic item to aPlotter.
Definition: sch_text.cpp:339
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:121
virtual bool operator==(const SCH_ITEM &aItem) const override
Definition: sch_text.cpp:427
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_text.cpp:167
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TEXT_T
Definition: typeinfo.h:150
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588