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 <base_units.h>
25#include <pgm_base.h>
26#include <sch_edit_frame.h>
27#include <plotters/plotter.h>
28#include <widgets/msgpanel.h>
29#include <bitmaps.h>
30#include <string_utils.h>
31#include <schematic.h>
33#include <sch_painter.h>
34#include <wx/log.h>
37#include <trigo.h>
38#include <sch_textbox.h>
40
41
42SCH_TEXTBOX::SCH_TEXTBOX( SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
43 const wxString& aText, KICAD_T aType ) :
44 SCH_SHAPE( SHAPE_T::RECTANGLE, aLayer, aLineWidth, aFillType, aType ),
45 EDA_TEXT( schIUScale, aText )
46{
47 m_layer = aLayer;
48
51 SetMultilineAllowed( true );
52
53 m_excludedFromSim = false;
54
55 int defaultMargin = GetLegacyTextMargin();
56 m_marginLeft = defaultMargin;
57 m_marginTop = defaultMargin;
58 m_marginRight = defaultMargin;
59 m_marginBottom = defaultMargin;
60}
61
62
64 SCH_SHAPE( aText ),
65 EDA_TEXT( aText )
66{
72}
73
74
76{
77 if( m_layer == LAYER_DEVICE )
78 return KiROUND( GetTextSize().y * 0.8 );
79 else
80 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
81}
82
83
85{
86 // Text is NOT really mirrored; it just has its justification flipped
88 {
93 }
94}
95
96
98{
99 // Text is NOT really mirrored; it just has its justification flipped
101 {
106 }
107}
108
109
110void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
111{
112 SCH_SHAPE::Rotate( aCenter, aRotateCCW );
114}
115
116
117void SCH_TEXTBOX::Rotate90( bool aClockwise )
118{
120}
121
122
124{
125 BOX2I bbox = BOX2I( m_start, m_end - m_start );
126
127 bbox.Normalize();
128
129 VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
130
131 if( GetTextAngle().IsVertical() )
132 {
133 switch( GetHorizJustify() )
134 {
136 pos.y = bbox.GetBottom() - m_marginBottom;
137 break;
139 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
140 break;
142 pos.y = bbox.GetTop() + m_marginTop;
143 break;
145 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
146 break;
147 }
148
149 switch( GetVertJustify() )
150 {
152 pos.x = bbox.GetLeft() + m_marginLeft;
153 break;
155 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
156 break;
158 pos.x = bbox.GetRight() - m_marginRight;
159 break;
161 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
162 break;
163 }
164 }
165 else
166 {
167 switch( GetHorizJustify() )
168 {
170 pos.x = bbox.GetLeft() + m_marginLeft;
171 break;
173 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
174 break;
176 pos.x = bbox.GetRight() - m_marginRight;
177 break;
179 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
180 break;
181 }
182
183 switch( GetVertJustify() )
184 {
186 pos.y = bbox.GetTop() + m_marginTop;
187 break;
189 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
190 break;
192 pos.y = bbox.GetBottom() - m_marginBottom;
193 break;
195 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
196 break;
197 }
198 }
199
200 return pos;
201}
202
203
205{
206 SCH_SHAPE::SwapData( aItem );
207
208 SCH_TEXTBOX* item = static_cast<SCH_TEXTBOX*>( aItem );
209
210 std::swap( m_layer, item->m_layer );
211 std::swap( m_marginLeft, item->m_marginLeft );
212 std::swap( m_marginTop, item->m_marginTop );
213 std::swap( m_marginRight, item->m_marginRight );
214 std::swap( m_marginBottom, item->m_marginBottom );
215
216 SwapText( *item );
217 SwapAttributes( *item );
218}
219
220
221bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
222{
223 if( Type() != aItem.Type() )
224 return Type() < aItem.Type();
225
226 auto other = static_cast<const SCH_TEXTBOX*>( &aItem );
227
228 if( GetLayer() != other->GetLayer() )
229 return GetLayer() < other->GetLayer();
230
231 if( GetPosition().x != other->GetPosition().x )
232 return GetPosition().x < other->GetPosition().x;
233
234 if( GetPosition().y != other->GetPosition().y )
235 return GetPosition().y < other->GetPosition().y;
236
237 if( GetMarginLeft() != other->GetMarginLeft() )
238 return GetMarginLeft() < other->GetMarginLeft();
239
240 if( GetMarginTop() != other->GetMarginTop() )
241 return GetMarginTop() < other->GetMarginTop();
242
243 if( GetMarginRight() != other->GetMarginRight() )
244 return GetMarginRight() < other->GetMarginRight();
245
246 if( GetMarginBottom() != other->GetMarginBottom() )
247 return GetMarginBottom() < other->GetMarginBottom();
248
249 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
250 return GetExcludedFromSim() - other->GetExcludedFromSim();
251
252 return GetText() < other->GetText();
253}
254
255
257{
259
260 if( !font )
262
263 return font;
264}
265
266
267void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
268 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
269{
270 if( IsPrivate() )
271 return;
272
273 wxDC* DC = aSettings->GetPrintDC();
274 int penWidth = GetEffectivePenWidth( aSettings );
275 bool blackAndWhiteMode = GetGRForceBlackPenState();
276 VECTOR2I pt1 = GetStart();
277 VECTOR2I pt2 = GetEnd();
279 COLOR4D bg = aSettings->GetBackgroundColor();
280 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
281
282 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
283 bg = COLOR4D::WHITE;
284
285 if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode && !aForceNoFill )
286 GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() );
287
288 if( penWidth > 0 )
289 {
290 penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
291
292 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
293 color = aSettings->GetLayerColor( m_layer );
294
295 if( aDimmed )
296 {
297 color.Desaturate( );
298 color = color.Mix( bg, 0.5f );
299 }
300
301 if( lineStyle == LINE_STYLE::DEFAULT )
302 lineStyle = LINE_STYLE::SOLID;
303
304 if( lineStyle == LINE_STYLE::SOLID )
305 {
306 GRRect( DC, pt1, pt2, penWidth, color );
307 }
308 else
309 {
310 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
311
312 for( SHAPE* shape : shapes )
313 {
314 STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
315 [&]( const VECTOR2I& a, const VECTOR2I& b )
316 {
317 VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
318 VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
319 GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
320 } );
321 }
322
323 for( SHAPE* shape : shapes )
324 delete shape;
325 }
326 }
327
329
330 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
331 color = aSettings->GetLayerColor( m_layer );
332
333 if( aDimmed )
334 {
335 color.Desaturate( );
336 color = color.Mix( bg, 0.5f );
337 }
338
339 EDA_TEXT::Print( aSettings, aOffset, color );
340}
341
342
343wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
344 int aDepth ) const
345{
346 SCH_SHEET* sheet = nullptr;
347
348 if( aPath )
349 sheet = aPath->Last();
350
351 std::function<bool( wxString* )> textResolver =
352 [&]( wxString* token ) -> bool
353 {
354 if( sheet )
355 {
356 if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) )
357 return true;
358 }
359
360 return false;
361 };
362
363 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
364
365 if( HasTextVars() )
366 {
367 if( aDepth < 10 )
368 text = ExpandTextVars( text, &textResolver );
369 }
370
371 VECTOR2I size = GetEnd() - GetStart();
372 int colWidth;
373
374 if( GetTextAngle().IsVertical() )
375 colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() );
376 else
377 colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
378
380 IsItalic() );
381
382 return text;
383}
384
385
386bool SCH_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
387{
388 BOX2I rect = GetBoundingBox();
389
390 rect.Inflate( aAccuracy );
391
392 return rect.Contains( aPosition );
393}
394
395
396bool SCH_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
397{
398 BOX2I rect = aRect;
399
400 rect.Inflate( aAccuracy );
401
402 if( aContained )
403 return rect.Contains( GetBoundingBox() );
404
405 return rect.Intersects( GetBoundingBox() );
406}
407
408
410{
411 wxCHECK_MSG( IsHypertext(), /* void */,
412 wxT( "Calling a hypertext menu on a SCH_TEXTBOX with no hyperlink?" ) );
413
415 navTool->HypertextCommand( m_hyperlink );
416}
417
418
419wxString SCH_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
420{
421 return wxString::Format( _( "Text Box" ) );
422}
423
424
426{
427 return BITMAPS::add_textbox;
428}
429
430
431void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
432 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
433{
434 if( IsPrivate() )
435 return;
436
437 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
438
439 if( aBackground )
440 return;
441
442 SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
443 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
444 int penWidth = GetEffectivePenWidth( renderSettings );
446 COLOR4D bg = renderSettings->GetBackgroundColor();
447 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
448
449 if( penWidth > 0 )
450 {
451 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
452 color = renderSettings->GetLayerColor( m_layer );
453
454 if( aDimmed )
455 {
456 color.Desaturate( );
457 color = color.Mix( bg, 0.5f );
458 }
459
460 if( lineStyle == LINE_STYLE::DEFAULT )
461 lineStyle = LINE_STYLE::SOLID;
462
463 aPlotter->SetColor( color );
464 aPlotter->SetDash( penWidth, lineStyle );
465 aPlotter->Rect( m_start, m_end, FILL_T::NO_FILL, penWidth );
466 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
467 }
468
469 KIFONT::FONT* font = getDrawFont();
470
472
473 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
474 color = renderSettings->GetLayerColor( m_layer );
475
476 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
477 bg = COLOR4D::WHITE;
478
479 if( aDimmed )
480 {
481 color.Desaturate( );
482 color = color.Mix( bg, 0.5f );
483 }
484
485 penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
486 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
487 aPlotter->SetCurrentLineWidth( penWidth );
488
489 TEXT_ATTRIBUTES attrs;
490 std::vector<VECTOR2I> positions;
491 wxArrayString strings_list;
492
493 wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
494 positions.reserve( strings_list.Count() );
495
496 if( renderSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
497 {
498 SCH_TEXTBOX temp( *this );
499
500 if( renderSettings->m_Transform.y1 )
501 {
504 }
505
506 temp.SetStart( renderSettings->TransformCoordinate( m_start ) + aOffset );
507 temp.SetEnd( renderSettings->TransformCoordinate( m_end ) + aOffset );
508
509 attrs = temp.GetAttributes();
510 temp.GetLinePositions( positions, (int) strings_list.Count() );
511 }
512 else
513 {
514 attrs = GetAttributes();
515 GetLinePositions( positions, (int) strings_list.Count() );
516 }
517
518 attrs.m_StrokeWidth = penWidth;
519 attrs.m_Multiline = false;
520
521 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
522 {
523 aPlotter->PlotText( positions[ii], color, strings_list.Item( ii ), attrs, font,
524 GetFontMetrics() );
525 }
526
527 if( HasHyperlink() )
528 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
529}
530
531
532void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
533{
534 // Don't use GetShownText() here; we want to show the user the variable references
535 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
536
538 aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
539
540 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
541
542 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
543 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
544 aList.emplace_back( _( "Style" ), textStyle[style] );
545
546 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
547
548 aList.emplace_back( _( "Box Width" ),
549 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
550
551 aList.emplace_back( _( "Box Height" ),
552 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) );
553
554 m_stroke.GetMsgPanelInfo( aFrame, aList );
555}
556
557
558bool SCH_TEXTBOX::operator==( const SCH_ITEM& aOther ) const
559{
560 if( Type() != aOther.Type() )
561 return false;
562
563 const SCH_TEXTBOX& other = static_cast<const SCH_TEXTBOX&>( aOther );
564
566 return false;
567
568 if( GetMarginLeft() != other.GetMarginLeft() )
569 return false;
570
571 if( GetMarginTop() != other.GetMarginTop() )
572 return false;
573
574 if( GetMarginRight() != other.GetMarginRight() )
575 return false;
576
577 if( GetMarginBottom() != other.GetMarginBottom() )
578 return false;
579
580 return SCH_SHAPE::operator==( aOther ) && EDA_TEXT::operator==( other );
581}
582
583
584double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
585{
586 if( m_Uuid == aOther.m_Uuid )
587 return 1.0;
588
589 if( aOther.Type() != Type() )
590 return 0.0;
591
592 auto other = static_cast<const SCH_TEXTBOX&>( aOther );
593
594 double similarity = SimilarityBase( other );
595
596 if( m_excludedFromSim != other.m_excludedFromSim )
597 similarity *= 0.9;
598
599 if( GetMarginLeft() != other.GetMarginLeft() )
600 similarity *= 0.9;
601
602 if( GetMarginTop() != other.GetMarginTop() )
603 similarity *= 0.9;
604
605 if( GetMarginRight() != other.GetMarginRight() )
606 similarity *= 0.9;
607
608 if( GetMarginBottom() != other.GetMarginBottom() )
609 similarity *= 0.9;
610
611 similarity *= SCH_SHAPE::Similarity( aOther );
612 similarity *= EDA_TEXT::Similarity( other );
613
614 return similarity;
615}
616
617
618int SCH_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
619{
620 wxASSERT( aOther.Type() == SCH_TEXTBOX_T );
621
622 int retv = SCH_SHAPE::compare( aOther, aCompareFlags );
623
624 if( retv )
625 return retv;
626
627 const SCH_TEXTBOX* tmp = static_cast<const SCH_TEXTBOX*>( &aOther );
628
629 int result = GetText().CmpNoCase( tmp->GetText() );
630
631 if( result != 0 )
632 return result;
633
634 if( GetTextWidth() != tmp->GetTextWidth() )
635 return GetTextWidth() - tmp->GetTextWidth();
636
637 if( GetTextHeight() != tmp->GetTextHeight() )
638 return GetTextHeight() - tmp->GetTextHeight();
639
640 if( IsBold() != tmp->IsBold() )
641 return IsBold() - tmp->IsBold();
642
643 if( IsItalic() != tmp->IsItalic() )
644 return IsItalic() - tmp->IsItalic();
645
646 if( GetHorizJustify() != tmp->GetHorizJustify() )
647 return GetHorizJustify() - tmp->GetHorizJustify();
648
649 if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() )
651
652 if( GetMarginLeft() != tmp->GetMarginLeft() )
653 return GetMarginLeft() - tmp->GetMarginLeft();
654
655 if( GetMarginTop() != tmp->GetMarginTop() )
656 return GetMarginTop() - tmp->GetMarginTop();
657
658 if( GetMarginRight() != tmp->GetMarginRight() )
659 return GetMarginRight() - tmp->GetMarginRight();
660
661 if( GetMarginBottom() != tmp->GetMarginBottom() )
662 return GetMarginBottom() - tmp->GetMarginBottom();
663
664 return 0;
665}
666
667
668static struct SCH_TEXTBOX_DESC
669{
671 {
674
681
682 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
683
684 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
685 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
686 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
687 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
688
689 const wxString marginProps = _( "Margins" );
690
691 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Left" ),
693 PROPERTY_DISPLAY::PT_SIZE ),
694 marginProps );
695 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Top" ),
697 PROPERTY_DISPLAY::PT_SIZE ),
698 marginProps );
699 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Right" ),
701 PROPERTY_DISPLAY::PT_SIZE ),
702 marginProps );
703 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Bottom" ),
705 PROPERTY_DISPLAY::PT_SIZE ),
706 marginProps );
707
708 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Text Size" ),
710 PROPERTY_DISPLAY::PT_SIZE ),
711 _HKI( "Text Properties" ) );
712
713 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
714 }
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:877
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:136
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:294
coord_type GetTop() const
Definition: box2.h:219
bool Contains(const Vec &aPoint) const
Definition: box2.h:158
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:541
coord_type GetRight() const
Definition: box2.h:207
coord_type GetLeft() const
Definition: box2.h:218
coord_type GetBottom() const
Definition: box2.h:212
int AsTenthsOfADegree() const
Definition: eda_angle.h:157
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition: eda_item.h:485
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
FILL_T GetFillMode() const
Definition: eda_shape.h:102
VECTOR2I m_start
Definition: eda_shape.h:418
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:162
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:129
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:125
COLOR4D GetFillColor() const
Definition: eda_shape.h:106
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:166
VECTOR2I m_end
Definition: eda_shape.h:419
virtual int GetWidth() const
Definition: eda_shape.h:110
STROKE_PARAMS m_stroke
Definition: eda_shape.h:408
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:83
int GetTextHeight() const
Definition: eda_text.h:228
COLOR4D GetTextColor() const
Definition: eda_text.h:231
bool IsItalic() const
Definition: eda_text.h:144
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
KIFONT::FONT * GetFont() const
Definition: eda_text.h:211
wxString m_hyperlink
A hyperlink URL.
Definition: eda_text.h:415
int GetTextWidth() const
Definition: eda_text.h:225
virtual bool HasHyperlink() const
Definition: eda_text.h:360
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:274
wxString GetHyperlink() const
Definition: eda_text.h:361
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:164
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:117
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:748
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1137
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:195
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:322
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:309
bool IsBold() const
Definition: eda_text.h:148
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:167
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:109
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:203
int GetTextThickness() const
Definition: eda_text.h:126
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:724
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:302
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:356
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:258
VECTOR2I GetTextSize() const
Definition: eda_text.h:222
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:266
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:146
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:588
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:104
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:453
bool GetColorMode() const
Definition: plotter.h:132
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Definition: plotter.cpp:753
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:136
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:453
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:678
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:145
bool IsPrivate() const
Definition: sch_item.h:243
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:289
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:461
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:470
SCH_LAYER_ID m_layer
Definition: sch_item.h:731
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:324
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:603
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:592
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:621
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:237
void 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:84
bool m_excludedFromSim
Definition: sch_textbox.h:157
bool operator==(const SCH_ITEM &aOther) const override
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:75
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:42
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:97
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
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:94
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:97
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:58
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:432
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:431
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:424
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:48
@ 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
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:118
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602