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;
126
127 if( m_layer == LAYER_DEVICE ) // TODO: nuke symbol editor's upside-down coordinate system
128 {
129 bbox = BOX2I( VECTOR2I( std::min( m_start.x, m_end.x ), std::min( -m_start.y, -m_end.y ) ),
130 VECTOR2I( abs( m_end.x - m_start.x ), abs( m_end.y - m_start.y ) ) );
131 }
132 else
133 {
134 bbox = BOX2I( m_start, m_end - m_start );
135
136 bbox.Normalize();
137 }
138
139 VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
140
141 if( GetTextAngle().IsVertical() )
142 {
143 switch( GetHorizJustify() )
144 {
146 pos.y = bbox.GetBottom() - m_marginBottom;
147 break;
149 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
150 break;
152 pos.y = bbox.GetTop() + m_marginTop;
153 break;
155 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
156 break;
157 }
158
159 switch( GetVertJustify() )
160 {
162 pos.x = bbox.GetLeft() + m_marginLeft;
163 break;
165 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
166 break;
168 pos.x = bbox.GetRight() - m_marginRight;
169 break;
171 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
172 break;
173 }
174 }
175 else
176 {
177 switch( GetHorizJustify() )
178 {
180 pos.x = bbox.GetLeft() + m_marginLeft;
181 break;
183 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
184 break;
186 pos.x = bbox.GetRight() - m_marginRight;
187 break;
189 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
190 break;
191 }
192
193 switch( GetVertJustify() )
194 {
196 pos.y = bbox.GetTop() + m_marginTop;
197 break;
199 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
200 break;
202 pos.y = bbox.GetBottom() - m_marginBottom;
203 break;
205 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
206 break;
207 }
208 }
209
210 return pos;
211}
212
213
215{
216 SCH_SHAPE::SwapData( aItem );
217
218 SCH_TEXTBOX* item = static_cast<SCH_TEXTBOX*>( aItem );
219
220 std::swap( m_layer, item->m_layer );
221 std::swap( m_marginLeft, item->m_marginLeft );
222 std::swap( m_marginTop, item->m_marginTop );
223 std::swap( m_marginRight, item->m_marginRight );
224 std::swap( m_marginBottom, item->m_marginBottom );
225
226 SwapText( *item );
227 SwapAttributes( *item );
228}
229
230
231bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
232{
233 if( Type() != aItem.Type() )
234 return Type() < aItem.Type();
235
236 auto other = static_cast<const SCH_TEXTBOX*>( &aItem );
237
238 if( GetLayer() != other->GetLayer() )
239 return GetLayer() < other->GetLayer();
240
241 if( GetPosition().x != other->GetPosition().x )
242 return GetPosition().x < other->GetPosition().x;
243
244 if( GetPosition().y != other->GetPosition().y )
245 return GetPosition().y < other->GetPosition().y;
246
247 if( GetMarginLeft() != other->GetMarginLeft() )
248 return GetMarginLeft() < other->GetMarginLeft();
249
250 if( GetMarginTop() != other->GetMarginTop() )
251 return GetMarginTop() < other->GetMarginTop();
252
253 if( GetMarginRight() != other->GetMarginRight() )
254 return GetMarginRight() < other->GetMarginRight();
255
256 if( GetMarginBottom() != other->GetMarginBottom() )
257 return GetMarginBottom() < other->GetMarginBottom();
258
259 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
260 return GetExcludedFromSim() - other->GetExcludedFromSim();
261
262 return GetText() < other->GetText();
263}
264
265
267{
269
270 if( !font )
272
273 return font;
274}
275
276
277void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
278 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
279{
280 if( IsPrivate() )
281 return;
282
283 wxDC* DC = aSettings->GetPrintDC();
284 int penWidth = GetEffectivePenWidth( aSettings );
285 bool blackAndWhiteMode = GetGRForceBlackPenState();
286 VECTOR2I pt1 = GetStart();
287 VECTOR2I pt2 = GetEnd();
289 COLOR4D bg = aSettings->GetBackgroundColor();
290 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
291
292 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
293 bg = COLOR4D::WHITE;
294
295 if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode && !aForceNoFill )
296 GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() );
297
298 if( penWidth > 0 )
299 {
300 penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
301
302 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
303 color = aSettings->GetLayerColor( m_layer );
304
305 if( aDimmed )
306 {
307 color.Desaturate( );
308 color = color.Mix( bg, 0.5f );
309 }
310
311 if( lineStyle == LINE_STYLE::DEFAULT )
312 lineStyle = LINE_STYLE::SOLID;
313
314 if( lineStyle == LINE_STYLE::SOLID )
315 {
316 GRRect( DC, pt1, pt2, penWidth, color );
317 }
318 else
319 {
320 std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
321
322 for( SHAPE* shape : shapes )
323 {
324 STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
325 [&]( const VECTOR2I& a, const VECTOR2I& b )
326 {
327 if( m_layer == LAYER_DEVICE )
328 {
329 VECTOR2I ptA = aSettings->TransformCoordinate( a ) + aOffset;
330 VECTOR2I ptB = aSettings->TransformCoordinate( b ) + aOffset;
331 GRLine( DC, ptA.x, ptA.y, ptB.x, ptB.y, penWidth, color );
332 }
333 else
334 {
335 GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
336 }
337 } );
338 }
339
340 for( SHAPE* shape : shapes )
341 delete shape;
342 }
343 }
344
346
347 if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
348 color = aSettings->GetLayerColor( m_layer );
349
350 if( aDimmed )
351 {
352 color.Desaturate( );
353 color = color.Mix( bg, 0.5f );
354 }
355
356 if( m_layer == LAYER_DEVICE )
357 {
358 SCH_TEXTBOX temp( *this );
359
360 if( aSettings->m_Transform.y1 )
361 {
364 }
365
366 // NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates
367 temp.SetStart( VECTOR2I( pt1.x, -pt1.y ) );
368 temp.SetEnd( VECTOR2I( pt2.x, -pt2.y ) );
369
370 GRPrintText( DC, temp.GetDrawPos(), color, temp.GetShownText( true ), temp.GetTextAngle(),
371 temp.GetTextSize(), temp.GetHorizJustify(), temp.GetVertJustify(), penWidth,
372 temp.IsItalic(), temp.IsBold(), getDrawFont(), GetFontMetrics() );
373 }
374 else
375 {
376 EDA_TEXT::Print( aSettings, aOffset, color );
377 }
378}
379
380
381wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
382 int aDepth ) const
383{
384 SCH_SHEET* sheet = nullptr;
385
386 if( aPath )
387 sheet = aPath->Last();
388
389 std::function<bool( wxString* )> textResolver =
390 [&]( wxString* token ) -> bool
391 {
392 if( sheet )
393 {
394 if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) )
395 return true;
396 }
397
398 return false;
399 };
400
401 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
402
403 if( HasTextVars() )
404 {
405 if( aDepth < 10 )
406 text = ExpandTextVars( text, &textResolver );
407 }
408
409 VECTOR2I size = GetEnd() - GetStart();
410 int colWidth;
411
412 if( GetTextAngle().IsVertical() )
413 colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() );
414 else
415 colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
416
418 IsItalic() );
419
420 return text;
421}
422
423
424bool SCH_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
425{
426 BOX2I rect = GetBoundingBox();
427
428 rect.Inflate( aAccuracy );
429
430 return rect.Contains( aPosition );
431}
432
433
434bool SCH_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
435{
436 BOX2I rect = aRect;
437
438 rect.Inflate( aAccuracy );
439
440 if( aContained )
441 return rect.Contains( GetBoundingBox() );
442
443 return rect.Intersects( GetBoundingBox() );
444}
445
446
448{
449 wxCHECK_MSG( IsHypertext(), /* void */,
450 wxT( "Calling a hypertext menu on a SCH_TEXTBOX with no hyperlink?" ) );
451
453 navTool->HypertextCommand( m_hyperlink );
454}
455
456
457wxString SCH_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
458{
459 return wxString::Format( _( "Text Box" ) );
460}
461
462
464{
465 return BITMAPS::add_textbox;
466}
467
468
469void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
470 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
471{
472 if( IsPrivate() )
473 return;
474
475 if( aBackground )
476 {
477 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
478 return;
479 }
480
481 SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
482 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
483 int penWidth = GetEffectivePenWidth( renderSettings );
485 COLOR4D bg = renderSettings->GetBackgroundColor();
486 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
487
488 if( penWidth > 0 )
489 {
490 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
491 color = renderSettings->GetLayerColor( m_layer );
492
493 if( aDimmed )
494 {
495 color.Desaturate( );
496 color = color.Mix( bg, 0.5f );
497 }
498
499 if( lineStyle == LINE_STYLE::DEFAULT )
500 lineStyle = LINE_STYLE::SOLID;
501
502 aPlotter->SetColor( color );
503 aPlotter->SetDash( penWidth, lineStyle );
504 aPlotter->Rect( m_start, m_end, FILL_T::NO_FILL, penWidth );
505 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
506 }
507
508 KIFONT::FONT* font = getDrawFont();
509
511
512 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
513 color = renderSettings->GetLayerColor( m_layer );
514
515 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
516 bg = COLOR4D::WHITE;
517
518 if( aDimmed )
519 {
520 color.Desaturate( );
521 color = color.Mix( bg, 0.5f );
522 }
523
524 penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
525 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
526 aPlotter->SetCurrentLineWidth( penWidth );
527
528 std::vector<VECTOR2I> positions;
529 wxArrayString strings_list;
530 wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
531 positions.reserve( strings_list.Count() );
532
533 if( m_layer == LAYER_DEVICE )
534 {
535 VECTOR2I start = renderSettings->TransformCoordinate( m_start ) + aOffset;
536 VECTOR2I end = renderSettings->TransformCoordinate( m_end ) + aOffset;
537 SCH_TEXTBOX temp( *this );
538
539 if( renderSettings->m_Transform.y1 )
540 {
543 }
544
545 // NB: GetDrawPos() will want Symbol Editor (upside-down) coordinates
546 temp.SetStart( VECTOR2I( start.x, -start.y ) );
547 temp.SetEnd( VECTOR2I( end.x, -end.y ) );
548 temp.GetLinePositions( positions, (int) strings_list.Count() );
549 }
550 else
551 {
552 GetLinePositions( positions, (int) strings_list.Count() );
553 }
554
556 attrs.m_StrokeWidth = penWidth;
557 attrs.m_Multiline = false;
558
559 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
560 {
561 aPlotter->PlotText( positions[ii], color, strings_list.Item( ii ), attrs, font,
562 GetFontMetrics() );
563 }
564
565 if( HasHyperlink() )
566 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
567}
568
569
570void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
571{
572 // Don't use GetShownText() here; we want to show the user the variable references
573 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
574
576 aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
577
578 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
579
580 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
581 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
582 aList.emplace_back( _( "Style" ), textStyle[style] );
583
584 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
585
586 aList.emplace_back( _( "Box Width" ),
587 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
588
589 aList.emplace_back( _( "Box Height" ),
590 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) );
591
592 m_stroke.GetMsgPanelInfo( aFrame, aList );
593}
594
595
596bool SCH_TEXTBOX::operator==( const SCH_ITEM& aOther ) const
597{
598 if( Type() != aOther.Type() )
599 return false;
600
601 const SCH_TEXTBOX& other = static_cast<const SCH_TEXTBOX&>( aOther );
602
604 return false;
605
606 if( GetMarginLeft() != other.GetMarginLeft() )
607 return false;
608
609 if( GetMarginTop() != other.GetMarginTop() )
610 return false;
611
612 if( GetMarginRight() != other.GetMarginRight() )
613 return false;
614
615 if( GetMarginBottom() != other.GetMarginBottom() )
616 return false;
617
618 return SCH_SHAPE::operator==( aOther ) && EDA_TEXT::operator==( other );
619}
620
621
622double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
623{
624 if( m_Uuid == aOther.m_Uuid )
625 return 1.0;
626
627 if( aOther.Type() != Type() )
628 return 0.0;
629
630 auto other = static_cast<const SCH_TEXTBOX&>( aOther );
631
632 double similarity = SimilarityBase( other );
633
634 if( m_excludedFromSim != other.m_excludedFromSim )
635 similarity *= 0.9;
636
637 if( GetMarginLeft() != other.GetMarginLeft() )
638 similarity *= 0.9;
639
640 if( GetMarginTop() != other.GetMarginTop() )
641 similarity *= 0.9;
642
643 if( GetMarginRight() != other.GetMarginRight() )
644 similarity *= 0.9;
645
646 if( GetMarginBottom() != other.GetMarginBottom() )
647 similarity *= 0.9;
648
649 similarity *= SCH_SHAPE::Similarity( aOther );
650 similarity *= EDA_TEXT::Similarity( other );
651
652 return similarity;
653}
654
655
656int SCH_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
657{
658 wxASSERT( aOther.Type() == SCH_TEXTBOX_T );
659
660 int retv = SCH_SHAPE::compare( aOther, aCompareFlags );
661
662 if( retv )
663 return retv;
664
665 const SCH_TEXTBOX* tmp = static_cast<const SCH_TEXTBOX*>( &aOther );
666
667 int result = GetText().CmpNoCase( tmp->GetText() );
668
669 if( result != 0 )
670 return result;
671
672 if( GetTextWidth() != tmp->GetTextWidth() )
673 return GetTextWidth() - tmp->GetTextWidth();
674
675 if( GetTextHeight() != tmp->GetTextHeight() )
676 return GetTextHeight() - tmp->GetTextHeight();
677
678 if( IsBold() != tmp->IsBold() )
679 return IsBold() - tmp->IsBold();
680
681 if( IsItalic() != tmp->IsItalic() )
682 return IsItalic() - tmp->IsItalic();
683
684 if( GetHorizJustify() != tmp->GetHorizJustify() )
685 return GetHorizJustify() - tmp->GetHorizJustify();
686
687 if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() )
689
690 if( GetMarginLeft() != tmp->GetMarginLeft() )
691 return GetMarginLeft() - tmp->GetMarginLeft();
692
693 if( GetMarginTop() != tmp->GetMarginTop() )
694 return GetMarginTop() - tmp->GetMarginTop();
695
696 if( GetMarginRight() != tmp->GetMarginRight() )
697 return GetMarginRight() - tmp->GetMarginRight();
698
699 if( GetMarginBottom() != tmp->GetMarginBottom() )
700 return GetMarginBottom() - tmp->GetMarginBottom();
701
702 return 0;
703}
704
705
706static struct SCH_TEXTBOX_DESC
707{
709 {
712
719
720 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
721
722 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
723 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
724 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
725 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
726
727 const wxString marginProps = _( "Margins" );
728
729 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Left" ),
731 PROPERTY_DISPLAY::PT_SIZE ),
732 marginProps );
733 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Top" ),
735 PROPERTY_DISPLAY::PT_SIZE ),
736 marginProps );
737 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Right" ),
739 PROPERTY_DISPLAY::PT_SIZE ),
740 marginProps );
741 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Bottom" ),
743 PROPERTY_DISPLAY::PT_SIZE ),
744 marginProps );
745
746 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Text Size" ),
748 PROPERTY_DISPLAY::PT_SIZE ),
749 _HKI( "Text Properties" ) );
750
751 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
752 }
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:853
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:120
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:270
coord_type GetTop() const
Definition: box2.h:195
bool Contains(const Vec &aPoint) const
Definition: box2.h:142
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
coord_type GetRight() const
Definition: box2.h:190
coord_type GetLeft() const
Definition: box2.h:194
coord_type GetBottom() const
Definition: box2.h:191
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:406
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:150
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:154
VECTOR2I m_end
Definition: eda_shape.h:407
virtual int GetWidth() const
Definition: eda_shape.h:110
STROKE_PARAMS m_stroke
Definition: eda_shape.h:396
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:416
int GetTextWidth() const
Definition: eda_text.h:225
virtual bool HasHyperlink() const
Definition: eda_text.h:361
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:276
wxString GetHyperlink() const
Definition: eda_text.h:362
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:755
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1151
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:324
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:311
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:205
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:731
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:304
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:357
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:260
VECTOR2I GetTextSize() const
Definition: eda_text.h:222
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:268
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:172
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:435
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:655
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:139
bool IsPrivate() const
Definition: sch_item.h:241
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:287
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:443
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:452
SCH_LAYER_ID m_layer
Definition: sch_item.h:708
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:322
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:664
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:134
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.cpp:294
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:653
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:682
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
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
void GRPrintText(wxDC *aDC, const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics)
Print a graphic text through wxDC.
Definition: gr_text.cpp:142
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_DEVICE
Definition: layer_ids.h:369
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:192
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:366
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:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588