KiCad PCB EDA Suite
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 <plotters/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
52{
53 SPIN newSpin = m_spin;
54
55 switch( m_spin )
56 {
57 case TEXT_SPIN_STYLE::LEFT: newSpin = TEXT_SPIN_STYLE::UP; break;
58 case TEXT_SPIN_STYLE::UP: newSpin = TEXT_SPIN_STYLE::RIGHT; break;
61 }
62
63 return TEXT_SPIN_STYLE( newSpin );
64}
65
66
68{
69 SPIN newSpin = m_spin;
70
71 switch( m_spin )
72 {
75 case TEXT_SPIN_STYLE::RIGHT: newSpin = TEXT_SPIN_STYLE::UP; break;
76 case TEXT_SPIN_STYLE::UP: newSpin = TEXT_SPIN_STYLE::LEFT; break;
77 }
78
79 return TEXT_SPIN_STYLE( newSpin );
80}
81
82
84{
85 SPIN newSpin = m_spin;
86
87 switch( m_spin )
88 {
89 case TEXT_SPIN_STYLE::UP: newSpin = TEXT_SPIN_STYLE::BOTTOM; break;
90 case TEXT_SPIN_STYLE::BOTTOM: newSpin = TEXT_SPIN_STYLE::UP; break;
91 case TEXT_SPIN_STYLE::LEFT: break;
92 case TEXT_SPIN_STYLE::RIGHT: break;
93 }
94
95 return TEXT_SPIN_STYLE( newSpin );
96}
97
98
100{
101 SPIN newSpin = m_spin;
102
103 switch( m_spin )
104 {
105 case TEXT_SPIN_STYLE::LEFT: newSpin = TEXT_SPIN_STYLE::RIGHT; break;
106 case TEXT_SPIN_STYLE::RIGHT: newSpin = TEXT_SPIN_STYLE::LEFT; break;
107 case TEXT_SPIN_STYLE::UP: break;
108 case TEXT_SPIN_STYLE::BOTTOM: break;
109 }
110
111 return TEXT_SPIN_STYLE( newSpin );
112}
113
114
115SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
116 SCH_ITEM( nullptr, aType ),
118{
120
121 SetTextPos( pos );
123 SetMultilineAllowed( true );
124}
125
126
128 SCH_ITEM( aText ),
129 EDA_TEXT( aText ),
130 m_spin_style( aText.m_spin_style )
131{ }
132
133
135{
136 return VECTOR2I( 0, 0 );
137}
138
139
141{
142 // Text is NOT really mirrored; it is moved to a suitable horizontal position
143 SetTextSpinStyle( GetTextSpinStyle().MirrorY() );
144
145 SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) );
146}
147
148
149void SCH_TEXT::MirrorVertically( int aCenter )
150{
151 // Text is NOT really mirrored; it is moved to a suitable vertical position
152 SetTextSpinStyle( GetTextSpinStyle().MirrorX() );
153
154 SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) );
155}
156
157
158void SCH_TEXT::Rotate( const VECTOR2I& aCenter )
159{
160 VECTOR2I pt = GetTextPos();
161 RotatePoint( pt, aCenter, ANGLE_90 );
162 VECTOR2I offset = pt - GetTextPos();
163
164 Rotate90( false );
165
166 SetTextPos( GetTextPos() + offset );
167}
168
169
170void SCH_TEXT::Rotate90( bool aClockwise )
171{
172 if( aClockwise )
173 SetTextSpinStyle( GetTextSpinStyle().RotateCW() );
174 else
175 SetTextSpinStyle( GetTextSpinStyle().RotateCCW() );
176}
177
178
179void SCH_TEXT::MirrorSpinStyle( bool aLeftRight )
180{
181 if( aLeftRight )
182 SetTextSpinStyle( GetTextSpinStyle().MirrorY() );
183 else
184 SetTextSpinStyle( GetTextSpinStyle().MirrorX() );
185}
186
187
189{
190 m_spin_style = aSpinStyle;
191
192 // Assume "Right" and Left" mean which side of the anchor the text will be on
193 // Thus we want to left justify text up against the anchor if we are on the right
194 switch( aSpinStyle )
195 {
196 default:
197 wxFAIL_MSG( "Bad spin style" );
198 m_spin_style = TEXT_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
200
201 case TEXT_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
204 break;
205
206 case TEXT_SPIN_STYLE::UP: // Vert Orientation UP
209 break;
210
211 case TEXT_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
214 break;
215
216 case TEXT_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
219 break;
220 }
221
223}
224
225
227{
228 SCH_TEXT* item = static_cast<SCH_TEXT*>( aItem );
229
230 std::swap( m_layer, item->m_layer );
231 std::swap( m_spin_style, item->m_spin_style );
232
233 SwapText( *item );
234 SwapAttributes( *item );
235}
236
237
238bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
239{
240 if( Type() != aItem.Type() )
241 return Type() < aItem.Type();
242
243 auto other = static_cast<const SCH_TEXT*>( &aItem );
244
245 if( GetLayer() != other->GetLayer() )
246 return GetLayer() < other->GetLayer();
247
248 if( GetPosition().x != other->GetPosition().x )
249 return GetPosition().x < other->GetPosition().x;
250
251 if( GetPosition().y != other->GetPosition().y )
252 return GetPosition().y < other->GetPosition().y;
253
254 return GetText() < other->GetText();
255}
256
257
258int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const
259{
260 double ratio;
261
262 if( aSettings )
263 ratio = static_cast<const SCH_RENDER_SETTINGS*>( aSettings )->m_TextOffsetRatio;
264 else if( Schematic() )
266 else
267 ratio = DEFAULT_TEXT_OFFSET_RATIO; // For previews (such as in Preferences), etc.
268
269 return KiROUND( ratio * GetTextSize().y );
270}
271
272
274{
276}
277
278
280{
282
283 if( !font )
285
286 return font;
287}
288
289
290void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
291{
293 bool blackAndWhiteMode = GetGRForceBlackPenState();
294 VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings );
295
296 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
297 color = aSettings->GetLayerColor( m_layer );
298
299 KIFONT::FONT* font = GetFont();
300
301 if( !font )
302 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
303
304 // Adjust text drawn in an outline font to more closely mimic the positioning of
305 // SCH_FIELD text.
306 if( font->IsOutline() )
307 {
308 BOX2I firstLineBBox = GetTextBox( 0 );
309 int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
310 int adjust = KiROUND( sizeDiff * 0.4 );
311 VECTOR2I adjust_offset( 0, - adjust );
312
313 RotatePoint( adjust_offset, GetDrawRotation() );
314 text_offset += adjust_offset;
315 }
316
317 EDA_TEXT::Print( aSettings, text_offset, color );
318}
319
320
322{
323 BOX2I bbox = GetTextBox();
324
325 if( !GetTextAngle().IsZero() ) // Rotate bbox.
326 {
327 VECTOR2I pos = bbox.GetOrigin();
328 VECTOR2I end = bbox.GetEnd();
329
332
333 bbox.SetOrigin( pos );
334 bbox.SetEnd( end );
335 }
336
337 bbox.Normalize();
338 return bbox;
339}
340
341
342wxString SCH_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
343{
344 std::function<bool( wxString* )> textResolver =
345 [&]( wxString* token ) -> bool
346 {
347 if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() )
348 {
349 if( sheet->ResolveTextVar( token, aDepth + 1 ) )
350 return true;
351 }
352
353 return false;
354 };
355
356 wxString text = EDA_TEXT::GetShownText();
357
358 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
359 {
360 text = wxS( "" );
361 }
362 else if( HasTextVars() )
363 {
364 if( aDepth < 10 )
365 text = ExpandTextVars( text, &textResolver );
366 }
367
368 return text;
369}
370
371
373{
374 wxCHECK_MSG( IsHypertext(), /* void */,
375 "Calling a hypertext menu on a SCH_TEXT with no hyperlink?" );
376
378 navTool->HypertextCommand( m_hyperlink );
379}
380
381
382wxString SCH_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
383{
384 return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) );
385}
386
387
389{
390 return BITMAPS::text;
391}
392
393
394bool SCH_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
395{
396 BOX2I bBox = GetBoundingBox();
397 bBox.Inflate( aAccuracy );
398 return bBox.Contains( aPosition );
399}
400
401
402bool SCH_TEXT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
403{
404 BOX2I bBox = GetBoundingBox();
405 bBox.Inflate( aAccuracy );
406
407 if( aContained )
408 return aRect.Contains( bBox );
409
410 return aRect.Intersects( bBox );
411}
412
413
414void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const
415{
416 aCount = 2;
417 aLayers[0] = m_layer;
418 aLayers[1] = LAYER_SELECTION_SHADOWS;
419}
420
421
422void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground ) const
423{
424 if( aBackground )
425 return;
426
427 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
428 SCH_CONNECTION* connection = Connection();
429 int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
431 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
432 VECTOR2I text_offset = GetSchematicTextOffset( aPlotter->RenderSettings() );
433
434 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
435 color = settings->GetLayerColor( layer );
436
437 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
438 aPlotter->SetCurrentLineWidth( penWidth );
439
440 KIFONT::FONT* font = GetFont();
441
442 if( !font )
443 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
444
445 // Adjust text drawn in an outline font to more closely mimic the positioning of
446 // SCH_FIELD text.
447 if( font->IsOutline() )
448 {
449 BOX2I firstLineBBox = GetTextBox( 0 );
450 int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
451 int adjust = KiROUND( sizeDiff * 0.4 );
452 VECTOR2I adjust_offset( 0, - adjust );
453
454 RotatePoint( adjust_offset, GetDrawRotation() );
455 text_offset += adjust_offset;
456 }
457
458 std::vector<VECTOR2I> positions;
459 wxArrayString strings_list;
460 wxStringSplit( GetShownText(), strings_list, '\n' );
461 positions.reserve( strings_list.Count() );
462
463 GetLinePositions( positions, (int) strings_list.Count() );
464
466 attrs.m_StrokeWidth = penWidth;
467 attrs.m_Multiline = false;
468
469 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
470 {
471 VECTOR2I textpos = positions[ii] + text_offset;
472 wxString& txt = strings_list.Item( ii );
473 aPlotter->PlotText( textpos, color, txt, attrs, font );
474 }
475
476 if( HasHyperlink() )
477 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
478}
479
480
481void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
482{
483 wxString msg;
484
485 // Don't use GetShownText() here; we want to show the user the variable references
486 aList.emplace_back( _( "Graphic Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
487
488 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
489
490 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
491 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
492 aList.emplace_back( _( "Style" ), textStyle[style] );
493
494 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
495
496 switch( GetTextSpinStyle() )
497 {
498 case TEXT_SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
499 case TEXT_SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
500 case TEXT_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
501 case TEXT_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
502 default: msg = wxT( "???" ); break;
503 }
504
505 aList.emplace_back( _( "Justification" ), msg );
506}
507
508
509#if defined(DEBUG)
510
511void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
512{
513 // XML output:
514 wxString s = GetClass();
515
516 NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
517 << " layer=\"" << m_layer << '"'
518 << '>'
519 << TO_UTF8( GetText() )
520 << "</" << s.Lower().mb_str() << ">\n";
521}
522
523#endif
524
525
int color
Definition: DXF_plotter.cpp:57
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:202
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
const Vec & GetOrigin() const
Definition: box2.h:183
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
coord_type GetHeight() const
Definition: box2.h:188
const Vec GetEnd() const
Definition: box2.h:185
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
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:72
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:505
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
COLOR4D GetTextColor() const
Definition: eda_text.h:205
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:373
void SetTextX(int aX)
Definition: eda_text.cpp:379
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
void SetTextY(int aY)
Definition: eda_text.cpp:385
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:317
wxString m_hyperlink
A hyperlink URL.
Definition: eda_text.h:386
int GetTextWidth() const
Definition: eda_text.h:199
virtual bool HasHyperlink() const
Definition: eda_text.h:333
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:250
wxString GetHyperlink() const
Definition: eda_text.h:334
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:103
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:673
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:286
bool IsBold() const
Definition: eda_text.h:133
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:195
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
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:650
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:275
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:234
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:242
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:138
virtual bool IsOutline() const
Definition: font.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
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:71
Base plotter engine class.
Definition: plotter.h:110
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition: plotter.h:455
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
Definition: plotter.cpp:758
bool GetColorMode() const
Definition: plotter.h:138
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:122
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
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:147
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:286
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:246
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:146
SCH_LAYER_ID m_layer
Definition: sch_item.h:491
Handle actions specific to the schematic editor.
void HypertextCommand(const wxString &href)
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
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_text.cpp:372
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_text.h:133
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_text.cpp:388
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_text.cpp:149
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
Definition: sch_text.cpp:422
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:342
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_text.cpp:238
VECTOR2I GetPosition() const override
Definition: sch_text.h:203
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:170
KIFONT::FONT * getDrawFont() const override
Definition: sch_text.cpp:279
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_text.cpp:140
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_text.cpp:158
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:226
TEXT_SPIN_STYLE GetTextSpinStyle() const
Definition: sch_text.h:148
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:321
virtual wxString GetClass() const override
Return the class name.
Definition: sch_text.h:126
int GetPenWidth() const override
Definition: sch_text.cpp:273
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:188
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:414
TEXT_SPIN_STYLE m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:238
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &offset) override
Print a schematic item.
Definition: sch_text.cpp:290
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:394
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_text.cpp:382
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:481
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:134
SCH_TEXT(const VECTOR2I &aPos={ 0, 0 }, const wxString &aText=wxEmptyString, KICAD_T aType=SCH_TEXT_T)
Definition: sch_text.cpp:115
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:179
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_text.cpp:258
TEXT_SPIN_STYLE RotateCW()
Definition: sch_text.cpp:51
TEXT_SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
Definition: sch_text.cpp:99
TEXT_SPIN_STYLE RotateCCW()
Definition: sch_text.cpp:67
TEXT_SPIN_STYLE()=default
TEXT_SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
Definition: sch_text.cpp:83
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
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 _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:426
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
@ LAYER_NOTES
Definition: layer_ids.h:358
@ LAYER_BUS
Definition: layer_ids.h:345
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:381
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
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:215
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:197
see class PGM_BASE
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
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:590