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 The 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 <advanced_config.h>
27#include <base_units.h>
28#include <pgm_base.h>
29#include <sch_edit_frame.h>
30#include <sch_plotter.h>
31#include <widgets/msgpanel.h>
32#include <bitmaps.h>
33#include <string_utils.h>
34#include <sch_text.h>
35#include <schematic.h>
37#include <sch_painter.h>
38#include <default_values.h>
39#include <wx/debug.h>
40#include <wx/log.h>
44#include <core/mirror.h>
45#include <core/kicad_algo.h>
47#include <trigo.h>
48
49
50SCH_TEXT::SCH_TEXT( const VECTOR2I& aPos, const wxString& aText, SCH_LAYER_ID aLayer,
51 KICAD_T aType ) :
52 SCH_ITEM( nullptr, aType ),
53 EDA_TEXT( schIUScale, aText )
54{
55 m_layer = aLayer;
56
57 SetTextPos( aPos );
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{
82 return;
83
84 VECTOR2I delta( 0, 0 );
85 BOX2I bbox = GetTextBox();
86
87 if( GetTextAngle().IsHorizontal() )
88 {
90 delta.x = bbox.GetWidth() / 2;
92 delta.x = - bbox.GetWidth() / 2;
93
95 delta.y = - bbox.GetHeight() / 2;
97 delta.y = bbox.GetHeight() / 2;
98 }
99 else
100 {
102 delta.y = bbox.GetWidth() / 2;
104 delta.y = - bbox.GetWidth() / 2;
105
107 delta.x = + bbox.GetHeight() / 2;
109 delta.x = - bbox.GetHeight() / 2;
110 }
111
112 if( inverse )
114 else
116}
117
118
120{
121 if( m_layer == LAYER_DEVICE )
122 {
123 NormalizeJustification( false );
124 int x = GetTextPos().x;
125
126 x -= aCenter;
127 x *= -1;
128 x += aCenter;
129
130 if( GetTextAngle().IsHorizontal() )
131 {
136 }
137 else
138 {
143 }
144
145 SetTextX( x );
147 }
148 else
149 {
151 FlipHJustify();
152
153 SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) );
154 }
155}
156
157
158void SCH_TEXT::MirrorVertically( int aCenter )
159{
160 if( m_layer == LAYER_DEVICE )
161 {
162 NormalizeJustification( false );
163 int y = GetTextPos().y;
164
165 y -= aCenter;
166 y *= -1;
167 y += aCenter;
168
169 if( GetTextAngle().IsHorizontal() )
170 {
175 }
176 else
177 {
182 }
183
184 SetTextY( y );
186 }
187 else
188 {
190 FlipHJustify();
191
192 SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) );
193 }
194}
195
196
197void SCH_TEXT::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
198{
199 VECTOR2I pt = GetTextPos();
200 RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
201 VECTOR2I offset = pt - GetTextPos();
202
203 Rotate90( false );
204
205 SetTextPos( GetTextPos() + offset );
206}
207
208
209void SCH_TEXT::Rotate90( bool aClockwise )
210{
211 if( ( GetTextAngle() == ANGLE_HORIZONTAL && aClockwise )
212 || ( GetTextAngle() == ANGLE_VERTICAL && !aClockwise ) )
213 {
214 FlipHJustify();
215 }
216
218}
219
220
221void SCH_TEXT::MirrorSpinStyle( bool aLeftRight )
222{
223 if( ( GetTextAngle() == ANGLE_HORIZONTAL && aLeftRight )
224 || ( GetTextAngle() == ANGLE_VERTICAL && !aLeftRight ) )
225 {
226 FlipHJustify();
227 }
228}
229
230
232{
233 SCH_TEXT* item = static_cast<SCH_TEXT*>( aItem );
234
235 std::swap( m_layer, item->m_layer );
236
237 SwapText( *item );
238 SwapAttributes( *item );
239}
240
241
242bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
243{
244 if( Type() != aItem.Type() )
245 return Type() < aItem.Type();
246
247 auto other = static_cast<const SCH_TEXT*>( &aItem );
248
249 if( GetLayer() != other->GetLayer() )
250 return GetLayer() < other->GetLayer();
251
252 if( GetPosition().x != other->GetPosition().x )
253 return GetPosition().x < other->GetPosition().x;
254
255 if( GetPosition().y != other->GetPosition().y )
256 return GetPosition().y < other->GetPosition().y;
257
258 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
259 return GetExcludedFromSim() - other->GetExcludedFromSim();
260
261 return GetText() < other->GetText();
262}
263
264
265int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const
266{
267 double ratio;
268
269 if( aSettings )
270 ratio = static_cast<const SCH_RENDER_SETTINGS*>( aSettings )->m_TextOffsetRatio;
271 else if( Schematic() )
273 else
274 ratio = DEFAULT_TEXT_OFFSET_RATIO; // For previews (such as in Preferences), etc.
275
276 return KiROUND( ratio * GetTextSize().y );
277}
278
279
281{
283}
284
285
287{
289
290 if( !font )
292
293 return font;
294}
295
296
298{
299 BOX2I bbox = GetTextBox();
300
301 if( !GetTextAngle().IsZero() ) // Rotate bbox.
302 {
303 VECTOR2I pos = bbox.GetOrigin();
304 VECTOR2I end = bbox.GetEnd();
305
308
309 bbox.SetOrigin( pos );
310 bbox.SetEnd( end );
311 }
312
313 bbox.Normalize();
314 return bbox;
315}
316
317
318wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
319 int aDepth ) const
320{
321 SCH_SHEET* sheet = nullptr;
322
323 if( aPath )
324 sheet = aPath->Last();
325 else if( SCHEMATIC* schematic = Schematic() )
326 sheet = schematic->CurrentSheet().Last();
327
328 std::function<bool( wxString* )> textResolver =
329 [&]( wxString* token ) -> bool
330 {
331 if( SCH_SYMBOL* sch_symbol = dynamic_cast<SCH_SYMBOL*>( m_parent ) )
332 {
333 if( sch_symbol->ResolveTextVar( aPath, token, aDepth + 1 ) )
334 return true;
335 }
336 else if( LIB_SYMBOL* lib_symbol = dynamic_cast<LIB_SYMBOL*>( m_parent ) )
337 {
338 if( lib_symbol->ResolveTextVar( token, aDepth + 1 ) )
339 return true;
340 }
341
342 if( sheet )
343 {
344 if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) )
345 return true;
346 }
347
348 return false;
349 };
350
351 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
352
353 if( HasTextVars() )
354 {
355 if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
356 text = ExpandTextVars( text, &textResolver );
357 }
358
359 return text;
360}
361
362
364{
365 wxCHECK_MSG( IsHypertext(), /* void */,
366 wxT( "Calling a hypertext menu on a SCH_TEXT with no hyperlink?" ) );
367
369 navTool->HypertextCommand( m_hyperlink );
370}
371
372
373wxString SCH_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
374{
375 return wxString::Format( _( "Graphic Text '%s'" ),
376 aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
377}
378
379
381{
382 return BITMAPS::text;
383}
384
385
386bool SCH_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
387{
388 BOX2I bBox = GetBoundingBox();
389 bBox.Inflate( aAccuracy );
390 return bBox.Contains( aPosition );
391}
392
393
394bool SCH_TEXT::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
395{
397 return false;
398
399 BOX2I rect = aRect;
400 BOX2I bBox = GetBoundingBox();
401
402 rect.Inflate( aAccuracy );
403
404 if( aContained )
405 return aRect.Contains( bBox );
406
407 return aRect.Intersects( bBox );
408}
409
410
411void SCH_TEXT::BeginEdit( const VECTOR2I& aPosition )
412{
413 SetTextPos( aPosition );
414}
415
416
417void SCH_TEXT::CalcEdit( const VECTOR2I& aPosition )
418{
419 SetTextPos( aPosition );
420}
421
422
423std::vector<int> SCH_TEXT::ViewGetLayers() const
424{
425 if( IsPrivate() )
427
429}
430
431
432void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
433 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
434{
435 if( aBackground || IsPrivate() )
436 return;
437
438 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
440 COLOR4D bg = renderSettings->GetBackgroundColor();
441
442 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
443 {
444 SCH_CONNECTION* connection = Connection();
445
446 if( connection && connection->IsBus() )
447 color = renderSettings->GetLayerColor( LAYER_BUS );
448 else
449 color = renderSettings->GetLayerColor( m_layer );
450 }
451
452 if( !IsVisible() )
453 bg = renderSettings->GetLayerColor( LAYER_HIDDEN );
454 else if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
455 bg = COLOR4D::WHITE;
456
457 if( aDimmed )
458 {
459 color.Desaturate( );
460 color = color.Mix( bg, 0.5f );
461 }
462
463 int penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
464 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
465 aPlotter->SetCurrentLineWidth( penWidth );
466
467 KIFONT::FONT* font = GetFont();
468
469 if( !font )
470 font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
471
473 attrs.m_StrokeWidth = penWidth;
474
475 if( m_layer == LAYER_DEVICE )
476 {
477 BOX2I bBox = GetBoundingBox();
478
479 /*
480 * Calculate the text justification, according to the symbol orientation/mirror. This is
481 * a bit complicated due to cumulative calculations:
482 * - numerous cases (mirrored or not, rotation)
483 * - the plotter's Text() function will also recalculate H and V justifications according
484 * to the text orientation
485 * - when a symbol is mirrored the text is not, and justifications become a nightmare
486 *
487 * So the easier way is to use no justifications (centered text) and use GetBoundingBox to
488 * know the text coordinate considered as centered.
489 */
490 VECTOR2I txtpos = bBox.Centre();
493
494 // The text orientation may need to be flipped if the transformation matrix causes xy
495 // axes to be flipped.
496 if( ( renderSettings->m_Transform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ) )
498 else
499 attrs.m_Angle = ANGLE_VERTICAL;
500
501 aPlotter->PlotText( renderSettings->TransformCoordinate( txtpos ) + aOffset, color,
502 GetText(), attrs, font, GetFontMetrics() );
503 }
504 else
505 {
507 VECTOR2I text_offset = GetSchematicTextOffset( aPlotter->RenderSettings() );
508
509 // Adjust text drawn in an outline font to more closely mimic the positioning of
510 // SCH_FIELD text.
511 if( font->IsOutline() )
512 {
513 BOX2I firstLineBBox = GetTextBox( 0 );
514 int sizeDiff = firstLineBBox.GetHeight() - GetTextSize().y;
515 int adjust = KiROUND( sizeDiff * 0.4 );
516 VECTOR2I adjust_offset( 0, - adjust );
517
518 RotatePoint( adjust_offset, GetDrawRotation() );
519 text_offset += adjust_offset;
520 }
521
522 std::vector<VECTOR2I> positions;
523 wxArrayString strings_list;
524 wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
525 positions.reserve( strings_list.Count() );
526
527 GetLinePositions( positions, (int) strings_list.Count() );
528
529 attrs.m_Multiline = false;
530
531 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
532 {
533 VECTOR2I textpos = positions[ii] + text_offset;
534 wxString& txt = strings_list.Item( ii );
535 aPlotter->PlotText( textpos, color, txt, attrs, font, GetFontMetrics() );
536 }
537
538 if( HasHyperlink() )
539 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
540 }
541}
542
543
544void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
545{
546 wxString msg;
547
548 // Don't use GetShownText() here; we want to show the user the variable references
549 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
550
552 aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
553
554 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
555
556 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
557 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
558 aList.emplace_back( _( "Style" ), textStyle[style] );
559
560 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
561
562 switch( GetHorizJustify() )
563 {
564 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Align left" ); break;
565 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Align center" ); break;
566 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Align right" ); break;
568 }
569
570 if( m_layer == LAYER_DEVICE )
571 {
572 aList.emplace_back( _( "H Justification" ), msg );
573
574 switch ( GetVertJustify() )
575 {
576 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
577 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
578 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
580 }
581
582 aList.emplace_back( _( "V Justification" ), msg );
583 }
584 else
585 {
586 aList.emplace_back( _( "Justification" ), msg );
587 }
588}
589
590
591bool SCH_TEXT::operator==( const SCH_ITEM& aOther ) const
592{
593 if( Type() != aOther.Type() )
594 return false;
595
596 const SCH_TEXT* other = static_cast<const SCH_TEXT*>( &aOther );
597
598 if( GetLayer() != other->GetLayer() )
599 return false;
600
601 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
602 return false;
603
604 return EDA_TEXT::operator==( *other );
605}
606
607
608double SCH_TEXT::Similarity( const SCH_ITEM& aOther ) const
609{
610 if( m_Uuid == aOther.m_Uuid )
611 return 1.0;
612
613 if( Type() != aOther.Type() )
614 return 0.0;
615
616 const SCH_TEXT* other = static_cast<const SCH_TEXT*>( &aOther );
617
618 double retval = SimilarityBase( aOther );
619
620 if( GetLayer() != other->GetLayer() )
621 retval *= 0.9;
622
623 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
624 retval *= 0.9;
625
626 retval *= EDA_TEXT::Similarity( *other );
627
628 return retval;
629}
630
631
632int SCH_TEXT::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
633{
634 wxASSERT( aOther.Type() == SCH_TEXT_T );
635
636 int retv = SCH_ITEM::compare( aOther, aCompareFlags );
637
638 if( retv )
639 return retv;
640
641 const SCH_TEXT& tmp = static_cast<const SCH_TEXT&>( aOther );
642
643 int result = GetText().CmpNoCase( tmp.GetText() );
644
645 if( result != 0 )
646 return result;
647
648 if( GetTextPos().x != tmp.GetTextPos().x )
649 return GetTextPos().x - tmp.GetTextPos().x;
650
651 if( GetTextPos().y != tmp.GetTextPos().y )
652 return GetTextPos().y - tmp.GetTextPos().y;
653
654 if( GetTextWidth() != tmp.GetTextWidth() )
655 return GetTextWidth() - tmp.GetTextWidth();
656
657 if( GetTextHeight() != tmp.GetTextHeight() )
658 return GetTextHeight() - tmp.GetTextHeight();
659
660 return 0;
661}
662
663
664#if defined(DEBUG)
665
666void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
667{
668 // XML output:
669 wxString s = GetClass();
670
671 NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
672 << " layer=\"" << m_layer << '"'
673 << '>'
674 << TO_UTF8( GetText() )
675 << "</" << s.Lower().mb_str() << ">\n";
676}
677
678#endif
679
680
681static struct SCH_TEXT_DESC
682{
684 {
691
692 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) );
693 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
694 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
695 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
696
697 propMgr.AddProperty( new PROPERTY<SCH_TEXT, int>( _HKI( "Text Size" ),
698 &SCH_TEXT::SetSchTextSize, &SCH_TEXT::GetSchTextSize, PROPERTY_DISPLAY::PT_SIZE ),
699 _HKI( "Text Properties" ) );
700
701 // Orientation is exposed differently in schematic; mask the base for now
702 propMgr.Mask( TYPE_HASH( SCH_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
703 }
int color
Definition: DXF_plotter.cpp:63
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr const Vec GetEnd() const
Definition: box2.h:212
constexpr void SetOrigin(const Vec &pos)
Definition: box2.h:237
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
constexpr size_type GetWidth() const
Definition: box2.h:214
constexpr Vec Centre() const
Definition: box2.h:97
constexpr size_type GetHeight() const
Definition: box2.h:215
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr const Vec & GetOrigin() const
Definition: box2.h:210
constexpr void SetEnd(coord_type x, coord_type y)
Definition: box2.h:297
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition: eda_item.h:507
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:109
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:518
EDA_ITEM * m_parent
Owner.
Definition: eda_item.h:519
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
int GetTextHeight() const
Definition: eda_text.h:264
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:270
COLOR4D GetTextColor() const
Definition: eda_text.h:267
bool IsItalic() const
Definition: eda_text.h:166
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
virtual bool IsVisible() const
Definition: eda_text.h:184
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:578
void SetTextX(int aX)
Definition: eda_text.cpp:584
KIFONT::FONT * GetFont() const
Definition: eda_text.h:244
BOX2I GetTextBox(int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:730
void SetTextY(int aY)
Definition: eda_text.cpp:590
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:373
wxString m_hyperlink
A hyperlink URL.
Definition: eda_text.h:447
int GetTextWidth() const
Definition: eda_text.h:261
virtual bool HasHyperlink() const
Definition: eda_text.h:394
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:417
wxString GetHyperlink() const
Definition: eda_text.h:395
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:197
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:116
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:901
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1280
void FlipHJustify()
Definition: eda_text.h:205
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:228
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:465
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:452
bool IsBold() const
Definition: eda_text.h:181
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:200
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:108
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:299
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:445
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:390
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:401
VECTOR2I GetTextSize() const
Definition: eda_text.h:258
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:409
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, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition: font.cpp:147
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.
Define a library symbol object.
Definition: lib_symbol.h:85
Base plotter engine class.
Definition: plotter.h:121
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:152
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition: plotter.h:460
bool GetColorMode() const
Definition: plotter.h:149
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=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Definition: plotter.cpp:687
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:87
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:317
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:167
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:168
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:571
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:685
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:212
bool IsPrivate() const
Definition: sch_item.h:250
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:309
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_item.cpp:532
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:318
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:581
SCH_LAYER_ID m_layer
Definition: sch_item.h:738
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
Definition: sch_item.h:346
Handle actions specific to the schematic editor.
void HypertextCommand(const wxString &aHref)
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
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:47
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:220
Schematic symbol object.
Definition: sch_symbol.h:75
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_text.cpp:373
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_text.cpp:363
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:632
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_text.h:78
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_text.cpp:380
int GetSchTextSize() const
Definition: sch_text.h:75
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:231
bool m_excludedFromSim
Definition: sch_text.h:188
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_text.cpp:158
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_text.cpp:197
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_text.cpp:417
wxString GetClass() const override
Return the class name.
Definition: sch_text.h:52
void NormalizeJustification(bool inverse)
Definition: sch_text.cpp:79
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_text.cpp:242
VECTOR2I GetPosition() const override
Definition: sch_text.h:139
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:209
KIFONT::FONT * getDrawFont() const override
Definition: sch_text.cpp:286
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:423
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_text.cpp:119
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:608
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:297
int GetPenWidth() const override
Definition: sch_text.cpp:280
void SetSchTextSize(int aSize)
Definition: sch_text.h:76
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_text.cpp:318
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:432
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:386
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:544
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: sch_text.cpp:411
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:86
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:221
bool operator==(const SCH_ITEM &aItem) const override
Definition: sch_text.cpp:591
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_text.cpp:265
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:50
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
int x1
Definition: transform.h:48
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, int aFlags)
Definition: common.cpp:59
#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:406
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:401
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:400
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:409
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:439
@ LAYER_DEVICE
Definition: layer_ids.h:456
@ LAYER_HIDDEN
Definition: layer_ids.h:482
@ LAYER_PRIVATE_NOTES
Definition: layer_ids.h:458
@ LAYER_BUS
Definition: layer_ids.h:443
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:484
constexpr T MIRRORVAL(T aPoint, T aMirrorRef)
Returns the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:36
Message panel definition file.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:221
KICOMMON_API 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:203
see class PGM_BASE
#define TYPE_HASH(x)
Definition: property.h:72
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
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:429
VECTOR2I end
constexpr int delta
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
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:229
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TEXT_T
Definition: typeinfo.h:152
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:46
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695