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-2022 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( token->Contains( ':' ) )
348 {
349 if( Schematic()->ResolveCrossReference( token, aDepth ) )
350 return true;
351 }
352 else
353 {
354 SCHEMATIC* schematic = Schematic();
355 SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
356
357 if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
358 return true;
359 }
360
361 return false;
362 };
363
364 std::function<bool( wxString* )> schematicTextResolver =
365 [&]( wxString* token ) -> bool
366 {
367 return Schematic()->ResolveTextVar( token, aDepth + 1 );
368 };
369
370 wxString text = EDA_TEXT::GetShownText();
371
372 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
373 {
374 text = wxS( "" );
375 }
376 else if( HasTextVars() )
377 {
378 PROJECT* project = nullptr;
379
380 if( Schematic() )
381 project = &Schematic()->Prj();
382
383 if( aDepth < 10 )
384 text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project );
385 }
386
387 return text;
388}
389
390
392{
393 wxCHECK_MSG( IsHypertext(), /* void */,
394 "Calling a hypertext menu on a SCH_TEXT with no hyperlink?" );
395
397 navTool->HypertextCommand( m_hyperlink );
398}
399
400
401wxString SCH_TEXT::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
402{
403 return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) );
404}
405
406
408{
409 return BITMAPS::text;
410}
411
412
413bool SCH_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
414{
415 BOX2I bBox = GetBoundingBox();
416 bBox.Inflate( aAccuracy );
417 return bBox.Contains( aPosition );
418}
419
420
421bool SCH_TEXT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
422{
423 BOX2I bBox = GetBoundingBox();
424 bBox.Inflate( aAccuracy );
425
426 if( aContained )
427 return aRect.Contains( bBox );
428
429 return aRect.Intersects( bBox );
430}
431
432
433void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const
434{
435 aCount = 2;
436 aLayers[0] = m_layer;
437 aLayers[1] = LAYER_SELECTION_SHADOWS;
438}
439
440
441void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground ) const
442{
443 if( aBackground )
444 return;
445
446 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
447 SCH_CONNECTION* connection = Connection();
448 int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
450 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
451 VECTOR2I text_offset = GetSchematicTextOffset( aPlotter->RenderSettings() );
452
453 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
454 color = settings->GetLayerColor( layer );
455
456 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
457 aPlotter->SetCurrentLineWidth( penWidth );
458
459 KIFONT::FONT* font = GetFont();
460
461 if( !font )
462 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
463
464 // Adjust text drawn in an outline font to more closely mimic the positioning of
465 // SCH_FIELD text.
466 if( font->IsOutline() )
467 {
468 BOX2I firstLineBBox = GetTextBox( 0 );
469 int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
470 int adjust = KiROUND( sizeDiff * 0.4 );
471 VECTOR2I adjust_offset( 0, - adjust );
472
473 RotatePoint( adjust_offset, GetDrawRotation() );
474 text_offset += adjust_offset;
475 }
476
477 std::vector<VECTOR2I> positions;
478 wxArrayString strings_list;
479 wxStringSplit( GetShownText(), strings_list, '\n' );
480 positions.reserve( strings_list.Count() );
481
482 GetLinePositions( positions, (int) strings_list.Count() );
483
484 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
485 {
486 VECTOR2I textpos = positions[ii] + text_offset;
487 wxString& txt = strings_list.Item( ii );
488 aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(),
489 GetVertJustify(), penWidth, IsItalic(), IsBold(), false, font );
490 }
491
492 if( HasHyperlink() )
493 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
494}
495
496
497void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
498{
499 wxString msg;
500
501 // Don't use GetShownText() here; we want to show the user the variable references
502 aList.emplace_back( _( "Graphic Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
503
504 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
505
506 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
507 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
508 aList.emplace_back( _( "Style" ), textStyle[style] );
509
510 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
511
512 switch( GetTextSpinStyle() )
513 {
514 case TEXT_SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
515 case TEXT_SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
516 case TEXT_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
517 case TEXT_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
518 default: msg = wxT( "???" ); break;
519 }
520
521 aList.emplace_back( _( "Justification" ), msg );
522}
523
524
525#if defined(DEBUG)
526
527void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
528{
529 // XML output:
530 wxString s = GetClass();
531
532 NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
533 << " layer=\"" << m_layer << '"'
534 << '>'
535 << TO_UTF8( GetText() )
536 << "</" << s.Lower().mb_str() << ">\n";
537}
538
539#endif
540
541
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:503
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:371
void SetTextX(int aX)
Definition: eda_text.cpp:377
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
void SetTextY(int aY)
Definition: eda_text.cpp:383
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:248
wxString GetHyperlink() const
Definition: eda_text.h:334
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
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:671
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:284
bool IsBold() const
Definition: eda_text.h:133
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
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:648
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:273
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:232
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
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:65
virtual bool IsOutline() const
Definition: font.h:113
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:71
Base plotter engine class.
Definition: plotter.h:110
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
Definition: plotter.cpp:714
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition: plotter.h:435
bool GetColorMode() const
Definition: plotter.h:138
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
Container for project specific data.
Definition: project.h:64
Holds all the data relating to one schematic.
Definition: schematic.h:61
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:120
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: schematic.cpp:123
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:76
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:259
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:55
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:233
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_text.cpp:391
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:407
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:441
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
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_text.cpp:401
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:433
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:413
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:497
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:57
#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:408
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:409
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:156
@ 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:203
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:185
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:618