KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_text.cpp
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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2015 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <base_units.h>
27#include <pgm_base.h>
28#include <sch_edit_frame.h>
29#include <sch_plotter.h>
30#include <widgets/msgpanel.h>
31#include <bitmaps.h>
32#include <string_utils.h>
33#include <sch_text.h>
34#include <schematic.h>
36#include <sch_painter.h>
37#include <default_values.h>
38#include <wx/debug.h>
39#include <wx/log.h>
43#include <core/mirror.h>
44#include <core/kicad_algo.h>
46#include <trigo.h>
47
49
50
51SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
52 SCH_ITEM( nullptr, aType ),
54{
56
57 SetTextPos( pos );
58 SetMultilineAllowed( true );
59
60 m_excludedFromSim = false;
61}
62
63
65 SCH_ITEM( aText ),
66 EDA_TEXT( aText )
67{
69}
70
71
73{
74 // Fudge factor to match KiCad 6
75 return VECTOR2I( 0, -2500 );
76}
77
78
80{
83
84 SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) );
85}
86
87
88void SCH_TEXT::MirrorVertically( int aCenter )
89{
92
93 SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) );
94}
95
96
97void SCH_TEXT::Rotate( const VECTOR2I& aCenter )
98{
99 VECTOR2I pt = GetTextPos();
100 RotatePoint( pt, aCenter, ANGLE_90 );
101 VECTOR2I offset = pt - GetTextPos();
102
103 Rotate90( false );
104
105 SetTextPos( GetTextPos() + offset );
106}
107
108
109void SCH_TEXT::Rotate90( bool aClockwise )
110{
111 if( ( GetTextAngle() == ANGLE_HORIZONTAL && aClockwise )
112 || ( GetTextAngle() == ANGLE_VERTICAL && !aClockwise ) )
113 {
114 FlipHJustify();
115 }
116
118}
119
120
121void SCH_TEXT::MirrorSpinStyle( bool aLeftRight )
122{
123 if( ( GetTextAngle() == ANGLE_HORIZONTAL && aLeftRight )
124 || ( GetTextAngle() == ANGLE_VERTICAL && !aLeftRight ) )
125 {
126 FlipHJustify();
127 }
128}
129
130
132{
133 SCH_ITEM::SwapFlags( aItem );
134
135 SCH_TEXT* item = static_cast<SCH_TEXT*>( aItem );
136
137 std::swap( m_layer, item->m_layer );
138
139 SwapText( *item );
140 SwapAttributes( *item );
141}
142
143
144bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
145{
146 if( Type() != aItem.Type() )
147 return Type() < aItem.Type();
148
149 auto other = static_cast<const SCH_TEXT*>( &aItem );
150
151 if( GetLayer() != other->GetLayer() )
152 return GetLayer() < other->GetLayer();
153
154 if( GetPosition().x != other->GetPosition().x )
155 return GetPosition().x < other->GetPosition().x;
156
157 if( GetPosition().y != other->GetPosition().y )
158 return GetPosition().y < other->GetPosition().y;
159
160 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
161 return GetExcludedFromSim() - other->GetExcludedFromSim();
162
163 return GetText() < other->GetText();
164}
165
166
167int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const
168{
169 double ratio;
170
171 if( aSettings )
172 ratio = static_cast<const SCH_RENDER_SETTINGS*>( aSettings )->m_TextOffsetRatio;
173 else if( Schematic() )
175 else
176 ratio = DEFAULT_TEXT_OFFSET_RATIO; // For previews (such as in Preferences), etc.
177
178 return KiROUND( ratio * GetTextSize().y );
179}
180
181
183{
185}
186
187
189{
191
192 if( !font )
194
195 return font;
196}
197
198
199void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
200{
202 bool blackAndWhiteMode = GetGRForceBlackPenState();
203 VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings );
204
205 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
206 color = aSettings->GetLayerColor( m_layer );
207
208 KIFONT::FONT* font = GetFont();
209
210 if( !font )
211 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
212
213 // Adjust text drawn in an outline font to more closely mimic the positioning of
214 // SCH_FIELD text.
215 if( font->IsOutline() )
216 {
217 BOX2I firstLineBBox = GetTextBox( 0 );
218 int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
219 int adjust = KiROUND( sizeDiff * 0.4 );
220 VECTOR2I adjust_offset( 0, - adjust );
221
222 RotatePoint( adjust_offset, GetDrawRotation() );
223 text_offset += adjust_offset;
224 }
225
226 EDA_TEXT::Print( aSettings, text_offset, color );
227}
228
229
231{
232 BOX2I bbox = GetTextBox();
233
234 if( !GetTextAngle().IsZero() ) // Rotate bbox.
235 {
236 VECTOR2I pos = bbox.GetOrigin();
237 VECTOR2I end = bbox.GetEnd();
238
241
242 bbox.SetOrigin( pos );
243 bbox.SetEnd( end );
244 }
245
246 bbox.Normalize();
247 return bbox;
248}
249
250
251wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
252 int aDepth ) const
253{
254 SCH_SHEET* sheet = nullptr;
255
256 if( aPath )
257 sheet = aPath->Last();
258 else if( SCHEMATIC* schematic = Schematic() )
259 sheet = schematic->CurrentSheet().Last();
260
261 std::function<bool( wxString* )> textResolver =
262 [&]( wxString* token ) -> bool
263 {
264 if( sheet )
265 {
266 if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) )
267 return true;
268 }
269
270 return false;
271 };
272
273 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
274
275 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
276 {
277 text = wxS( "" );
278 }
279 else if( HasTextVars() )
280 {
281 if( aDepth < 10 )
282 text = ExpandTextVars( text, &textResolver );
283 }
284
285 return text;
286}
287
288
290{
291 wxCHECK_MSG( IsHypertext(), /* void */,
292 wxT( "Calling a hypertext menu on a SCH_TEXT with no hyperlink?" ) );
293
295 navTool->HypertextCommand( m_hyperlink );
296}
297
298
299wxString SCH_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
300{
301 return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
302}
303
304
306{
307 return BITMAPS::text;
308}
309
310
311bool SCH_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
312{
313 BOX2I bBox = GetBoundingBox();
314 bBox.Inflate( aAccuracy );
315 return bBox.Contains( aPosition );
316}
317
318
319bool SCH_TEXT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
320{
321 BOX2I bBox = GetBoundingBox();
322 bBox.Inflate( aAccuracy );
323
324 if( aContained )
325 return aRect.Contains( bBox );
326
327 return aRect.Intersects( bBox );
328}
329
330
331void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const
332{
333 aCount = 2;
334 aLayers[0] = m_layer;
335 aLayers[1] = LAYER_SELECTION_SHADOWS;
336}
337
338
339void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground,
340 const SCH_PLOT_SETTINGS& aPlotSettings ) const
341{
342 if( aBackground )
343 return;
344
345 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
346 SCH_CONNECTION* connection = Connection();
347 int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
349 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
350 VECTOR2I text_offset = GetSchematicTextOffset( aPlotter->RenderSettings() );
351
352 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
353 color = settings->GetLayerColor( layer );
354
355 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
356 aPlotter->SetCurrentLineWidth( penWidth );
357
358 KIFONT::FONT* font = GetFont();
359
360 if( !font )
361 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
362
363 // Adjust text drawn in an outline font to more closely mimic the positioning of
364 // SCH_FIELD text.
365 if( font->IsOutline() )
366 {
367 BOX2I firstLineBBox = GetTextBox( 0 );
368 int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
369 int adjust = KiROUND( sizeDiff * 0.4 );
370 VECTOR2I adjust_offset( 0, - adjust );
371
372 RotatePoint( adjust_offset, GetDrawRotation() );
373 text_offset += adjust_offset;
374 }
375
376 std::vector<VECTOR2I> positions;
377 wxArrayString strings_list;
378 wxStringSplit( GetShownText( true ), strings_list, '\n' );
379 positions.reserve( strings_list.Count() );
380
381 GetLinePositions( positions, (int) strings_list.Count() );
382
384 attrs.m_StrokeWidth = penWidth;
385 attrs.m_Multiline = false;
386
387 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
388 {
389 VECTOR2I textpos = positions[ii] + text_offset;
390 wxString& txt = strings_list.Item( ii );
391 aPlotter->PlotText( textpos, color, txt, attrs, font, GetFontMetrics() );
392 }
393
394 if( HasHyperlink() )
395 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
396}
397
398
399void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
400{
401 wxString msg;
402
403 // Don't use GetShownText() here; we want to show the user the variable references
404 aList.emplace_back( _( "Graphic Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
405
407 aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
408
409 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
410
411 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
412 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
413 aList.emplace_back( _( "Style" ), textStyle[style] );
414
415 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
416
417 switch( GetHorizJustify() )
418 {
419 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Align left" ); break;
420 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Align center" ); break;
421 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Align right" ); break;
423 }
424
425 aList.emplace_back( _( "Justification" ), msg );
426}
427
428bool SCH_TEXT::operator==( const SCH_ITEM& aOther ) const
429{
430 if( Type() != aOther.Type() )
431 return false;
432
433 const SCH_TEXT* other = static_cast<const SCH_TEXT*>( &aOther );
434
435 if( GetLayer() != other->GetLayer() )
436 return false;
437
438 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
439 return false;
440
441 return EDA_TEXT::operator==( *other );
442}
443
444
445double SCH_TEXT::Similarity( const SCH_ITEM& aOther ) const
446{
447 if( Type() != aOther.Type() )
448 return 0.0;
449
450 const SCH_TEXT* other = static_cast<const SCH_TEXT*>( &aOther );
451
452 double retval = 1.0;
453
454 if( GetLayer() != other->GetLayer() )
455 retval *= 0.9;
456
457 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
458 retval *= 0.9;
459
460 retval *= EDA_TEXT::Similarity( *other );
461
462 return retval;
463}
464
465
466#if defined(DEBUG)
467
468void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
469{
470 // XML output:
471 wxString s = GetClass();
472
473 NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
474 << " layer=\"" << m_layer << '"'
475 << '>'
476 << TO_UTF8( GetText() )
477 << "</" << s.Lower().mb_str() << ">\n";
478}
479
480#endif
481
482
483static struct SCH_TEXT_DESC
484{
486 {
493
494 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) );
495 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
496 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
497 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
498 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
499
500 propMgr.AddProperty( new PROPERTY<SCH_TEXT, int>( _HKI( "Text Size" ),
501 &SCH_TEXT::SetSchTextSize, &SCH_TEXT::GetSchTextSize, PROPERTY_DISPLAY::PT_SIZE ),
502 _HKI( "Text Properties" ) );
503
504 // Orientation is exposed differently in schematic; mask the base for now
505 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
506 }
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
void SetOrigin(const Vec &pos)
Definition: box2.h:203
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:120
const Vec & GetOrigin() const
Definition: box2.h:184
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:270
coord_type GetHeight() const
Definition: box2.h:189
const Vec GetEnd() const
Definition: box2.h:186
bool Contains(const Vec &aPoint) const
Definition: box2.h:142
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:256
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:567
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:231
COLOR4D GetTextColor() const
Definition: eda_text.h:228
bool IsItalic() const
Definition: eda_text.h:141
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
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:419
void SetTextX(int aX)
Definition: eda_text.cpp:425
KIFONT::FONT * GetFont() const
Definition: eda_text.h:208
void SetTextY(int aY)
Definition: eda_text.cpp:431
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:338
wxString m_hyperlink
A hyperlink URL.
Definition: eda_text.h:413
int GetTextWidth() const
Definition: eda_text.h:222
virtual bool HasHyperlink() const
Definition: eda_text.h:358
wxString GetHyperlink() const
Definition: eda_text.h:359
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:161
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:114
void GetLinePositions(std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:755
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1151
void FlipHJustify()
Definition: eda_text.h:169
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:192
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:324
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:311
bool IsBold() const
Definition: eda_text.h:145
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:106
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:205
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aDisplay_mode=FILLED)
Print this text object to the device context aDC.
Definition: eda_text.cpp:731
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:304
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:354
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:260
VECTOR2I GetTextSize() const
Definition: eda_text.h:219
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:146
virtual bool IsOutline() const
Definition: font.h:139
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Store schematic specific render settings.
Definition: sch_painter.h:72
Base plotter engine class.
Definition: plotter.h:104
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:135
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition: plotter.h:452
bool GetColorMode() const
Definition: plotter.h:132
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Definition: plotter.cpp:753
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Definition: schematic.h:75
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool IsBus() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:323
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:272
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:267
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:147
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:331
SCH_LAYER_ID m_layer
Definition: sch_item.h:538
Handle actions specific to the schematic editor.
void HypertextCommand(const wxString &href)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:237
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_text.cpp:289
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
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_text.cpp:88
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
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:445
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
SCH_TEXT(const VECTOR2I &aPos={ 0, 0 }, const wxString &aText=wxEmptyString, KICAD_T aType=SCH_TEXT_T)
Definition: sch_text.cpp:51
bool GetExcludedFromSim() const override
Definition: sch_text.h:82
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:428
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_text.cpp:167
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
#define DEFAULT_TEXT_OFFSET_RATIO
Ratio of the font height to space around global labels.
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:437
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:432
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:431
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
@ LAYER_NOTES
Definition: layer_ids.h:369
@ LAYER_BUS
Definition: layer_ids.h:356
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:393
T MIRRORVAL(T aPoint, T aMirrorRef)
Returns the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:31
Message panel definition file.
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:210
wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Definition: ui_common.cpp:192
see class PGM_BASE
#define TYPE_HASH(x)
Definition: property.h:67
#define REGISTER_TYPE(x)
Definition: property_mgr.h:366
static struct SCH_TEXT_DESC _SCH_TEXT_DESC
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:391
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:228
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:44
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588