KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_textbox.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) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <advanced_config.h>
25#include <base_units.h>
26#include <pgm_base.h>
27#include <sch_edit_frame.h>
28#include <plotters/plotter.h>
29#include <widgets/msgpanel.h>
30#include <bitmaps.h>
31#include <string_utils.h>
32#include <schematic.h>
34#include <sch_painter.h>
35#include <wx/log.h>
38#include <trigo.h>
39#include <sch_textbox.h>
41
42
43SCH_TEXTBOX::SCH_TEXTBOX( SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
44 const wxString& aText, KICAD_T aType ) :
45 SCH_SHAPE( SHAPE_T::RECTANGLE, aLayer, aLineWidth, aFillType, aType ),
46 EDA_TEXT( schIUScale, aText )
47{
48 m_layer = aLayer;
49
52 SetMultilineAllowed( true );
53
54 m_excludedFromSim = false;
55
56 int defaultMargin = GetLegacyTextMargin();
57 m_marginLeft = defaultMargin;
58 m_marginTop = defaultMargin;
59 m_marginRight = defaultMargin;
60 m_marginBottom = defaultMargin;
61}
62
63
65 SCH_SHAPE( aText ),
66 EDA_TEXT( aText )
67{
73}
74
75
77{
78 if( m_layer == LAYER_DEVICE )
79 return KiROUND( GetTextSize().y * 0.8 );
80 else
81 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
82}
83
84
86{
87 // Text is NOT really mirrored; it just has its justification flipped
89 {
94 }
95}
96
97
99{
100 // Text is NOT really mirrored; it just has its justification flipped
102 {
107 }
108}
109
110
111void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
112{
113 SCH_SHAPE::Rotate( aCenter, aRotateCCW );
115}
116
117
118void SCH_TEXTBOX::Rotate90( bool aClockwise )
119{
121}
122
123
125{
126 BOX2I bbox = BOX2I( m_start, m_end - m_start );
127
128 bbox.Normalize();
129
130 VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
131
132 if( GetTextAngle().IsVertical() )
133 {
134 switch( GetHorizJustify() )
135 {
137 pos.y = bbox.GetBottom() - m_marginBottom;
138 break;
140 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
141 break;
143 pos.y = bbox.GetTop() + m_marginTop;
144 break;
146 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
147 break;
148 }
149
150 switch( GetVertJustify() )
151 {
153 pos.x = bbox.GetLeft() + m_marginLeft;
154 break;
156 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
157 break;
159 pos.x = bbox.GetRight() - m_marginRight;
160 break;
162 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
163 break;
164 }
165 }
166 else
167 {
168 switch( GetHorizJustify() )
169 {
171 pos.x = bbox.GetLeft() + m_marginLeft;
172 break;
174 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
175 break;
177 pos.x = bbox.GetRight() - m_marginRight;
178 break;
180 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
181 break;
182 }
183
184 switch( GetVertJustify() )
185 {
187 pos.y = bbox.GetTop() + m_marginTop;
188 break;
190 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
191 break;
193 pos.y = bbox.GetBottom() - m_marginBottom;
194 break;
196 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
197 break;
198 }
199 }
200
201 return pos;
202}
203
204
206{
207 SCH_SHAPE::SwapData( aItem );
208
209 SCH_TEXTBOX* item = static_cast<SCH_TEXTBOX*>( aItem );
210
211 std::swap( m_layer, item->m_layer );
212 std::swap( m_marginLeft, item->m_marginLeft );
213 std::swap( m_marginTop, item->m_marginTop );
214 std::swap( m_marginRight, item->m_marginRight );
215 std::swap( m_marginBottom, item->m_marginBottom );
216
217 SwapText( *item );
218 SwapAttributes( *item );
219}
220
221
222bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
223{
224 if( Type() != aItem.Type() )
225 return Type() < aItem.Type();
226
227 auto other = static_cast<const SCH_TEXTBOX*>( &aItem );
228
229 if( GetLayer() != other->GetLayer() )
230 return GetLayer() < other->GetLayer();
231
232 if( GetPosition().x != other->GetPosition().x )
233 return GetPosition().x < other->GetPosition().x;
234
235 if( GetPosition().y != other->GetPosition().y )
236 return GetPosition().y < other->GetPosition().y;
237
238 if( GetMarginLeft() != other->GetMarginLeft() )
239 return GetMarginLeft() < other->GetMarginLeft();
240
241 if( GetMarginTop() != other->GetMarginTop() )
242 return GetMarginTop() < other->GetMarginTop();
243
244 if( GetMarginRight() != other->GetMarginRight() )
245 return GetMarginRight() < other->GetMarginRight();
246
247 if( GetMarginBottom() != other->GetMarginBottom() )
248 return GetMarginBottom() < other->GetMarginBottom();
249
250 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
251 return GetExcludedFromSim() - other->GetExcludedFromSim();
252
253 return GetText() < other->GetText();
254}
255
256
258{
260
261 if( !font )
263
264 return font;
265}
266
267
268void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
269 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
270{
271 if( IsPrivate() )
272 return;
273
274 wxDC* DC = aSettings->GetPrintDC();
275 int penWidth = GetEffectivePenWidth( aSettings );
276 bool blackAndWhiteMode = GetGRForceBlackPenState();
277 VECTOR2I pt1 = GetStart();
278 VECTOR2I pt2 = GetEnd();
280 COLOR4D bg = aSettings->GetBackgroundColor();
281 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
282
283 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
284 bg = COLOR4D::WHITE;
285
286 if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode && !aForceNoFill )
287 GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() );
288
289 if( penWidth > 0 )
290 {
291 penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
292
293 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
294 color = aSettings->GetLayerColor( m_layer );
295
296 if( aDimmed )
297 {
298 color.Desaturate( );
299 color = color.Mix( bg, 0.5f );
300 }
301
302 if( lineStyle == LINE_STYLE::DEFAULT )
303 lineStyle = LINE_STYLE::SOLID;
304
305 if( lineStyle == LINE_STYLE::SOLID )
306 {
307 GRRect( DC, pt1, pt2, penWidth, color );
308 }
309 else
310 {
311 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
312
313 for( SHAPE* shape : shapes )
314 {
315 STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
316 [&]( const VECTOR2I& a, const VECTOR2I& b )
317 {
318 VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
319 VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
320 GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
321 } );
322 }
323
324 for( SHAPE* shape : shapes )
325 delete shape;
326 }
327 }
328
330
331 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
332 color = aSettings->GetLayerColor( m_layer );
333
334 if( aDimmed )
335 {
336 color.Desaturate( );
337 color = color.Mix( bg, 0.5f );
338 }
339
340 EDA_TEXT::Print( aSettings, aOffset, color );
341}
342
343
344wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
345 int aDepth ) const
346{
347 SCH_SHEET* sheet = nullptr;
348
349 if( aPath )
350 sheet = aPath->Last();
351
352 std::function<bool( wxString* )> textResolver =
353 [&]( wxString* token ) -> bool
354 {
355 if( sheet )
356 {
357 if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) )
358 return true;
359 }
360
361 return false;
362 };
363
364 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
365
366 if( HasTextVars() )
367 {
368 if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
369 text = ExpandTextVars( text, &textResolver );
370 }
371
372 VECTOR2I size = GetEnd() - GetStart();
373 int colWidth;
374
375 if( GetTextAngle().IsVertical() )
376 colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() );
377 else
378 colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
379
381 IsItalic() );
382
383 return text;
384}
385
386
387bool SCH_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
388{
389 BOX2I rect = GetBoundingBox();
390
391 rect.Inflate( aAccuracy );
392
393 return rect.Contains( aPosition );
394}
395
396
397bool SCH_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
398{
399 BOX2I rect = aRect;
400
401 rect.Inflate( aAccuracy );
402
403 if( aContained )
404 return rect.Contains( GetBoundingBox() );
405
406 return rect.Intersects( GetBoundingBox() );
407}
408
409
411{
412 wxCHECK_MSG( IsHypertext(), /* void */,
413 wxT( "Calling a hypertext menu on a SCH_TEXTBOX with no hyperlink?" ) );
414
416 navTool->HypertextCommand( m_hyperlink );
417}
418
419
420wxString SCH_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
421{
422 return wxString::Format( _( "Text Box" ) );
423}
424
425
427{
428 return BITMAPS::add_textbox;
429}
430
431
432void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
433 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
434{
435 if( IsPrivate() )
436 return;
437
438 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
439
440 if( aBackground )
441 return;
442
443 SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
444 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
445 int penWidth = GetEffectivePenWidth( renderSettings );
447 COLOR4D bg = renderSettings->GetBackgroundColor();
448 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
449
450 if( penWidth > 0 )
451 {
452 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
453 color = renderSettings->GetLayerColor( m_layer );
454
455 if( aDimmed )
456 {
457 color.Desaturate( );
458 color = color.Mix( bg, 0.5f );
459 }
460
461 if( lineStyle == LINE_STYLE::DEFAULT )
462 lineStyle = LINE_STYLE::SOLID;
463
464 aPlotter->SetColor( color );
465 aPlotter->SetDash( penWidth, lineStyle );
466 aPlotter->Rect( m_start, m_end, FILL_T::NO_FILL, penWidth );
467 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
468 }
469
470 KIFONT::FONT* font = getDrawFont();
471
473
474 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
475 color = renderSettings->GetLayerColor( m_layer );
476
477 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
478 bg = COLOR4D::WHITE;
479
480 if( aDimmed )
481 {
482 color.Desaturate( );
483 color = color.Mix( bg, 0.5f );
484 }
485
486 penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
487 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
488 aPlotter->SetCurrentLineWidth( penWidth );
489
490 TEXT_ATTRIBUTES attrs;
491 std::vector<VECTOR2I> positions;
492 wxArrayString strings_list;
493
494 wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
495 positions.reserve( strings_list.Count() );
496
497 if( renderSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
498 {
499 SCH_TEXTBOX temp( *this );
500
501 if( renderSettings->m_Transform.y1 )
502 {
505 }
506
507 temp.SetStart( renderSettings->TransformCoordinate( m_start ) + aOffset );
508 temp.SetEnd( renderSettings->TransformCoordinate( m_end ) + aOffset );
509
510 attrs = temp.GetAttributes();
511 temp.GetLinePositions( positions, (int) strings_list.Count() );
512 }
513 else
514 {
515 attrs = GetAttributes();
516 GetLinePositions( positions, (int) strings_list.Count() );
517 }
518
519 attrs.m_StrokeWidth = penWidth;
520 attrs.m_Multiline = false;
521
522 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
523 {
524 aPlotter->PlotText( positions[ii], color, strings_list.Item( ii ), attrs, font,
525 GetFontMetrics() );
526 }
527
528 if( HasHyperlink() )
529 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
530}
531
532
533void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
534{
535 // Don't use GetShownText() here; we want to show the user the variable references
536 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
537
539 aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
540
541 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
542
543 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
544 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
545 aList.emplace_back( _( "Style" ), textStyle[style] );
546
547 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
548
549 aList.emplace_back( _( "Box Width" ),
550 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
551
552 aList.emplace_back( _( "Box Height" ),
553 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) );
554
555 m_stroke.GetMsgPanelInfo( aFrame, aList );
556}
557
558
559bool SCH_TEXTBOX::operator==( const SCH_ITEM& aOther ) const
560{
561 if( Type() != aOther.Type() )
562 return false;
563
564 const SCH_TEXTBOX& other = static_cast<const SCH_TEXTBOX&>( aOther );
565
567 return false;
568
569 if( GetMarginLeft() != other.GetMarginLeft() )
570 return false;
571
572 if( GetMarginTop() != other.GetMarginTop() )
573 return false;
574
575 if( GetMarginRight() != other.GetMarginRight() )
576 return false;
577
578 if( GetMarginBottom() != other.GetMarginBottom() )
579 return false;
580
581 return SCH_SHAPE::operator==( aOther ) && EDA_TEXT::operator==( other );
582}
583
584
585double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
586{
587 if( m_Uuid == aOther.m_Uuid )
588 return 1.0;
589
590 if( aOther.Type() != Type() )
591 return 0.0;
592
593 auto other = static_cast<const SCH_TEXTBOX&>( aOther );
594
595 double similarity = SimilarityBase( other );
596
597 if( m_excludedFromSim != other.m_excludedFromSim )
598 similarity *= 0.9;
599
600 if( GetMarginLeft() != other.GetMarginLeft() )
601 similarity *= 0.9;
602
603 if( GetMarginTop() != other.GetMarginTop() )
604 similarity *= 0.9;
605
606 if( GetMarginRight() != other.GetMarginRight() )
607 similarity *= 0.9;
608
609 if( GetMarginBottom() != other.GetMarginBottom() )
610 similarity *= 0.9;
611
612 similarity *= SCH_SHAPE::Similarity( aOther );
613 similarity *= EDA_TEXT::Similarity( other );
614
615 return similarity;
616}
617
618
619int SCH_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
620{
621 wxASSERT( aOther.Type() == SCH_TEXTBOX_T );
622
623 int retv = SCH_SHAPE::compare( aOther, aCompareFlags );
624
625 if( retv )
626 return retv;
627
628 const SCH_TEXTBOX* tmp = static_cast<const SCH_TEXTBOX*>( &aOther );
629
630 int result = GetText().CmpNoCase( tmp->GetText() );
631
632 if( result != 0 )
633 return result;
634
635 if( GetTextWidth() != tmp->GetTextWidth() )
636 return GetTextWidth() - tmp->GetTextWidth();
637
638 if( GetTextHeight() != tmp->GetTextHeight() )
639 return GetTextHeight() - tmp->GetTextHeight();
640
641 if( IsBold() != tmp->IsBold() )
642 return IsBold() - tmp->IsBold();
643
644 if( IsItalic() != tmp->IsItalic() )
645 return IsItalic() - tmp->IsItalic();
646
647 if( GetHorizJustify() != tmp->GetHorizJustify() )
648 return GetHorizJustify() - tmp->GetHorizJustify();
649
650 if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() )
652
653 if( GetMarginLeft() != tmp->GetMarginLeft() )
654 return GetMarginLeft() - tmp->GetMarginLeft();
655
656 if( GetMarginTop() != tmp->GetMarginTop() )
657 return GetMarginTop() - tmp->GetMarginTop();
658
659 if( GetMarginRight() != tmp->GetMarginRight() )
660 return GetMarginRight() - tmp->GetMarginRight();
661
662 if( GetMarginBottom() != tmp->GetMarginBottom() )
663 return GetMarginBottom() - tmp->GetMarginBottom();
664
665 return 0;
666}
667
668
669static struct SCH_TEXTBOX_DESC
670{
672 {
675
682
683 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
684
685 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
686 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
687 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
688 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
689
690 const wxString marginProps = _( "Margins" );
691
692 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Left" ),
694 PROPERTY_DISPLAY::PT_SIZE ),
695 marginProps );
696 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Top" ),
698 PROPERTY_DISPLAY::PT_SIZE ),
699 marginProps );
700 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Right" ),
702 PROPERTY_DISPLAY::PT_SIZE ),
703 marginProps );
704 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Bottom" ),
706 PROPERTY_DISPLAY::PT_SIZE ),
707 marginProps );
708
709 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Text Size" ),
711 PROPERTY_DISPLAY::PT_SIZE ),
712 _HKI( "Text Properties" ) );
713
714 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
715 }
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
BOX2< VECTOR2I > BOX2I
Definition: box2.h:922
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 BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
constexpr coord_type GetLeft() const
Definition: box2.h:228
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr coord_type GetRight() const
Definition: box2.h:217
constexpr coord_type GetTop() const
Definition: box2.h:229
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
constexpr coord_type GetBottom() const
Definition: box2.h:222
int AsTenthsOfADegree() const
Definition: eda_angle.h:115
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
FILL_T GetFillMode() const
Definition: eda_shape.h:107
VECTOR2I m_start
Definition: eda_shape.h:425
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:167
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:134
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:130
COLOR4D GetFillColor() const
Definition: eda_shape.h:111
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:171
VECTOR2I m_end
Definition: eda_shape.h:426
virtual int GetWidth() const
Definition: eda_shape.h:115
STROKE_PARAMS m_stroke
Definition: eda_shape.h:415
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:247
COLOR4D GetTextColor() const
Definition: eda_text.h:250
bool IsItalic() const
Definition: eda_text.h:152
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:130
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
KIFONT::FONT * GetFont() const
Definition: eda_text.h:230
wxString m_hyperlink
A hyperlink URL.
Definition: eda_text.h:435
int GetTextWidth() const
Definition: eda_text.h:244
virtual bool HasHyperlink() const
Definition: eda_text.h:380
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:321
wxString GetHyperlink() const
Definition: eda_text.h:381
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:183
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:113
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:793
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1182
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:214
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:369
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:356
bool IsBold() const
Definition: eda_text.h:167
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:186
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:105
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:204
int GetTextThickness() const
Definition: eda_text.h:122
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:769
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:349
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:376
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:305
VECTOR2I GetTextSize() const
Definition: eda_text.h:241
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:313
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:146
void LinebreakText(wxString &aText, int aColumnWidth, const VECTOR2I &aGlyphSize, int aThickness, bool aBold, bool aItalic) const
Insert characters into text to ensure that no lines are wider than aColumnWidth.
Definition: font.cpp:589
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
int GetDefaultPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Base plotter engine class.
Definition: plotter.h:105
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition: plotter.h:454
bool GetColorMode() const
Definition: plotter.h:133
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:754
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColor(const COLOR4D &color)=0
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.
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:152
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:458
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:670
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
bool IsPrivate() const
Definition: sch_item.h:235
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:281
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:466
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:475
SCH_LAYER_ID m_layer
Definition: sch_item.h:723
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:316
Handle actions specific to the schematic editor.
void HypertextCommand(const wxString &href)
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition: sch_shape.h:97
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_shape.cpp:52
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_shape.cpp:606
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_shape.cpp:129
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.cpp:265
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:108
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:595
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:55
VECTOR2I GetPosition() const override
Definition: sch_shape.h:70
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_shape.cpp:624
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:254
void SetMarginBottom(int aBottom)
Definition: sch_textbox.h:61
int m_marginRight
Definition: sch_textbox.h:160
int m_marginBottom
Definition: sch_textbox.h:161
int GetMarginBottom() const
Definition: sch_textbox.h:66
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_textbox.cpp:85
bool m_excludedFromSim
Definition: sch_textbox.h:157
bool operator==(const SCH_ITEM &aOther) const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetLegacyTextMargin() const
Definition: sch_textbox.cpp:76
int GetMarginLeft() const
Definition: sch_textbox.h:63
int GetSchTextSize() const
Definition: sch_textbox.h:68
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
bool GetExcludedFromSim() const override
Definition: sch_textbox.h:94
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator<(const SCH_ITEM &aItem) const override
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &offset, bool aForceNoFill, bool aDimmed) override
Print an item.
VECTOR2I GetDrawPos() const override
int GetMarginRight() const
Definition: sch_textbox.h:65
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
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.
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_textbox.h:86
int GetMarginTop() const
Definition: sch_textbox.h:64
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.
void SetMarginLeft(int aLeft)
Definition: sch_textbox.h:58
int m_marginLeft
Definition: sch_textbox.h:158
virtual void Rotate90(bool aClockwise)
void SetMarginRight(int aRight)
Definition: sch_textbox.h:60
void SetSchTextSize(int aSize)
Definition: sch_textbox.h:69
SCH_TEXTBOX(SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, const wxString &aText=wxEmptyString, KICAD_T aType=SCH_TEXTBOX_T)
Definition: sch_textbox.cpp:43
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_textbox.cpp:98
KIFONT::FONT * getDrawFont() const override
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
void SetMarginTop(int aTop)
Definition: sch_textbox.h:59
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
An abstract shape on 2D plane.
Definition: shape.h:126
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:92
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:95
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
int y1
Definition: transform.h:49
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:59
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:398
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:55
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:396
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:171
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:403
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_DEVICE
Definition: layer_ids.h:370
Message panel definition file.
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:195
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
see class PGM_BASE
#define TYPE_HASH(x)
Definition: property.h:71
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
static struct SCH_TEXTBOX_DESC _SCH_TEXTBOX_DESC
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
@ 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
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TEXTBOX_T
Definition: typeinfo.h:152
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691