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 The 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>
40#include <sch_textbox.h>
42
43
44SCH_TEXTBOX::SCH_TEXTBOX( SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
45 const wxString& aText, KICAD_T aType ) :
46 SCH_SHAPE( SHAPE_T::RECTANGLE, aLayer, aLineWidth, aFillType, aType ),
47 EDA_TEXT( schIUScale, aText )
48{
49 m_layer = aLayer;
50
53 SetMultilineAllowed( true );
54
55 m_excludedFromSim = false;
56
57 int defaultMargin = GetLegacyTextMargin();
58 m_marginLeft = defaultMargin;
59 m_marginTop = defaultMargin;
60 m_marginRight = defaultMargin;
61 m_marginBottom = defaultMargin;
62}
63
64
75
76
78{
79 if( m_layer == LAYER_DEVICE )
80 return KiROUND( GetTextSize().y * 0.8 );
81 else
82 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
83}
84
85
87{
89
90 // Text is NOT really mirrored; it just has its justification flipped
92 {
97 }
98}
99
100
102{
104
105 // Text is NOT really mirrored; it just has its justification flipped
107 {
112 }
113}
114
115
116void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
117{
118 SCH_SHAPE::Rotate( aCenter, aRotateCCW );
120}
121
122
127
128
130{
131 BOX2I bbox = BOX2I( m_start, m_end - m_start );
132
133 bbox.Normalize();
134
135 VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
136
137 if( GetTextAngle().IsVertical() )
138 {
139 switch( GetHorizJustify() )
140 {
142 pos.y = bbox.GetBottom() - m_marginBottom;
143 break;
145 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
146 break;
148 pos.y = bbox.GetTop() + m_marginTop;
149 break;
151 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
152 break;
153 }
154
155 switch( GetVertJustify() )
156 {
158 pos.x = bbox.GetLeft() + m_marginLeft;
159 break;
161 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
162 break;
164 pos.x = bbox.GetRight() - m_marginRight;
165 break;
167 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
168 break;
169 }
170 }
171 else
172 {
173 switch( GetHorizJustify() )
174 {
176 pos.x = bbox.GetLeft() + m_marginLeft;
177 break;
179 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
180 break;
182 pos.x = bbox.GetRight() - m_marginRight;
183 break;
185 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
186 break;
187 }
188
189 switch( GetVertJustify() )
190 {
192 pos.y = bbox.GetTop() + m_marginTop;
193 break;
195 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
196 break;
198 pos.y = bbox.GetBottom() - m_marginBottom;
199 break;
201 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
202 break;
203 }
204 }
205
206 return pos;
207}
208
209
211{
212 SCH_SHAPE::swapData( aItem );
213
214 SCH_TEXTBOX* item = static_cast<SCH_TEXTBOX*>( aItem );
215
216 std::swap( m_marginLeft, item->m_marginLeft );
217 std::swap( m_marginTop, item->m_marginTop );
218 std::swap( m_marginRight, item->m_marginRight );
219 std::swap( m_marginBottom, item->m_marginBottom );
220
221 SwapText( *item );
222 SwapAttributes( *item );
223}
224
225
226bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
227{
228 if( Type() != aItem.Type() )
229 return Type() < aItem.Type();
230
231 auto other = static_cast<const SCH_TEXTBOX*>( &aItem );
232
233 if( GetLayer() != other->GetLayer() )
234 return GetLayer() < other->GetLayer();
235
236 if( GetPosition().x != other->GetPosition().x )
237 return GetPosition().x < other->GetPosition().x;
238
239 if( GetPosition().y != other->GetPosition().y )
240 return GetPosition().y < other->GetPosition().y;
241
242 if( GetMarginLeft() != other->GetMarginLeft() )
243 return GetMarginLeft() < other->GetMarginLeft();
244
245 if( GetMarginTop() != other->GetMarginTop() )
246 return GetMarginTop() < other->GetMarginTop();
247
248 if( GetMarginRight() != other->GetMarginRight() )
249 return GetMarginRight() < other->GetMarginRight();
250
251 if( GetMarginBottom() != other->GetMarginBottom() )
252 return GetMarginBottom() < other->GetMarginBottom();
253
254 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
255 return GetExcludedFromSim() - other->GetExcludedFromSim();
256
257 return GetText() < other->GetText();
258}
259
260
262{
264
265 if( !font )
266 font = KIFONT::FONT::GetFont( GetDefaultFont( aSettings ), IsBold(), IsItalic() );
267
268 return font;
269}
270
271
272wxString SCH_TEXTBOX::GetShownText( const RENDER_SETTINGS* aSettings, const SCH_SHEET_PATH* aPath,
273 bool aAllowExtraText, int aDepth ) const
274{
275 SCH_SHEET* sheet = nullptr;
276
277 if( aPath )
278 sheet = aPath->Last();
279
280 std::function<bool( wxString* )> textResolver =
281 [&]( wxString* token ) -> bool
282 {
283 if( sheet )
284 {
285 if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) )
286 return true;
287 }
288
289 return false;
290 };
291
292 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
293
294 if( HasTextVars() )
295 {
296 if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
297 text = ExpandTextVars( text, &textResolver );
298 }
299
300 if( text.Contains( wxT( "@{" ) ) )
302
303 VECTOR2I size = GetEnd() - GetStart();
304 int colWidth;
305
306 if( GetTextAngle().IsVertical() )
307 colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() );
308 else
309 colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
310
312 IsBold(), IsItalic() );
313
314 return text;
315}
316
317
318bool SCH_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
319{
320 BOX2I rect = GetBoundingBox();
321
322 rect.Inflate( aAccuracy );
323
324 return rect.Contains( aPosition );
325}
326
327
328bool SCH_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
329{
330 BOX2I rect = aRect;
331
332 rect.Inflate( aAccuracy );
333
334 if( aContained )
335 return rect.Contains( GetBoundingBox() );
336
337 return rect.Intersects( GetBoundingBox() );
338}
339
340
341bool SCH_TEXTBOX::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
342{
343 return KIGEOM::BoxHitTest( aPoly, GetBoundingBox(), aContained );
344}
345
346
348{
349 if( HasHyperlink() )
350 return true;
351
352 return IsURL( GetShownText( false ) );
353}
354
355
357{
358 wxCHECK_MSG( IsHypertext(), /* void */,
359 wxT( "Calling a hypertext menu on a SCH_TEXTBOX with no hyperlink?" ) );
360
362
363 if( HasHyperlink() )
364 navTool->HypertextCommand( m_hyperlink );
365 else
366 navTool->HypertextCommand( GetShownText( false ) );
367}
368
369
370wxString SCH_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
371{
372 return wxString::Format( _( "Text box '%s'" ),
373 aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
374}
375
376
381
382
383void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
384 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
385{
386 if( IsPrivate() )
387 return;
388
389 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
390
391 if( aBackground )
392 return;
393
394 SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
395 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
396 int penWidth = GetEffectivePenWidth( renderSettings );
398 COLOR4D bg = renderSettings->GetBackgroundColor();
399
400 KIFONT::FONT* font = GetDrawFont( renderSettings );
401
403
404 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
405 color = renderSettings->GetLayerColor( m_layer );
406
407 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
408 bg = COLOR4D::WHITE;
409
410 if( aDimmed )
411 {
412 color.Desaturate( );
413 color = color.Mix( bg, 0.5f );
414 }
415
416 penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
417 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
418 aPlotter->SetCurrentLineWidth( penWidth );
419
420 TEXT_ATTRIBUTES attrs;
421 std::vector<VECTOR2I> positions;
422 wxArrayString strings_list;
423
424 wxStringSplit( GetShownText( renderSettings, sheet, true ), strings_list, '\n' );
425 positions.reserve( strings_list.Count() );
426
427 if( renderSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
428 {
429 SCH_TEXTBOX temp( *this );
430
431 if( renderSettings->m_Transform.y1 )
432 {
435 }
436
437 temp.SetStart( renderSettings->TransformCoordinate( m_start ) + aOffset );
438 temp.SetEnd( renderSettings->TransformCoordinate( m_end ) + aOffset );
439
440 attrs = temp.GetAttributes();
441 temp.GetLinePositions( renderSettings, positions, (int) strings_list.Count() );
442 }
443 else
444 {
445 attrs = GetAttributes();
446 GetLinePositions( renderSettings, positions, (int) strings_list.Count() );
447 }
448
449 attrs.m_StrokeWidth = penWidth;
450 attrs.m_Multiline = false;
451
452 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
453 {
454 aPlotter->PlotText( positions[ii], color, strings_list.Item( ii ), attrs, font,
455 GetFontMetrics() );
456 }
457
458 if( HasHyperlink() )
459 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
460}
461
462
463void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
464{
465 // Don't use GetShownText() here; we want to show the user the variable references
466 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
467
468 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
469
471 aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
472
473 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
474
475 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
476 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
477 aList.emplace_back( _( "Style" ), textStyle[style] );
478
479 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
480
481 aList.emplace_back( _( "Box Width" ),
482 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
483
484 aList.emplace_back( _( "Box Height" ),
485 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) );
486
487 m_stroke.GetMsgPanelInfo( aFrame, aList );
488}
489
490
491bool SCH_TEXTBOX::operator==( const SCH_ITEM& aOther ) const
492{
493 if( Type() != aOther.Type() )
494 return false;
495
496 const SCH_TEXTBOX& other = static_cast<const SCH_TEXTBOX&>( aOther );
497
499 return false;
500
501 if( GetMarginLeft() != other.GetMarginLeft() )
502 return false;
503
504 if( GetMarginTop() != other.GetMarginTop() )
505 return false;
506
507 if( GetMarginRight() != other.GetMarginRight() )
508 return false;
509
510 if( GetMarginBottom() != other.GetMarginBottom() )
511 return false;
512
513 return SCH_SHAPE::operator==( aOther ) && EDA_TEXT::operator==( other );
514}
515
516
517double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
518{
519 if( m_Uuid == aOther.m_Uuid )
520 return 1.0;
521
522 if( aOther.Type() != Type() )
523 return 0.0;
524
525 auto other = static_cast<const SCH_TEXTBOX&>( aOther );
526
527 double similarity = SimilarityBase( other );
528
529 if( m_excludedFromSim != other.m_excludedFromSim )
530 similarity *= 0.9;
531
532 if( GetMarginLeft() != other.GetMarginLeft() )
533 similarity *= 0.9;
534
535 if( GetMarginTop() != other.GetMarginTop() )
536 similarity *= 0.9;
537
538 if( GetMarginRight() != other.GetMarginRight() )
539 similarity *= 0.9;
540
541 if( GetMarginBottom() != other.GetMarginBottom() )
542 similarity *= 0.9;
543
544 similarity *= SCH_SHAPE::Similarity( aOther );
545 similarity *= EDA_TEXT::Similarity( other );
546
547 return similarity;
548}
549
550
551int SCH_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
552{
553 wxASSERT( aOther.Type() == SCH_TEXTBOX_T );
554
555 int retv = SCH_SHAPE::compare( aOther, aCompareFlags );
556
557 if( retv )
558 return retv;
559
560 const SCH_TEXTBOX* tmp = static_cast<const SCH_TEXTBOX*>( &aOther );
561
562 int result = GetText().CmpNoCase( tmp->GetText() );
563
564 if( result != 0 )
565 return result;
566
567 if( GetTextWidth() != tmp->GetTextWidth() )
568 return GetTextWidth() - tmp->GetTextWidth();
569
570 if( GetTextHeight() != tmp->GetTextHeight() )
571 return GetTextHeight() - tmp->GetTextHeight();
572
573 if( IsBold() != tmp->IsBold() )
574 return IsBold() - tmp->IsBold();
575
576 if( IsItalic() != tmp->IsItalic() )
577 return IsItalic() - tmp->IsItalic();
578
579 if( GetHorizJustify() != tmp->GetHorizJustify() )
580 return (int) GetHorizJustify() - (int) tmp->GetHorizJustify();
581
582 if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() )
584
585 if( GetMarginLeft() != tmp->GetMarginLeft() )
586 return GetMarginLeft() - tmp->GetMarginLeft();
587
588 if( GetMarginTop() != tmp->GetMarginTop() )
589 return GetMarginTop() - tmp->GetMarginTop();
590
591 if( GetMarginRight() != tmp->GetMarginRight() )
592 return GetMarginRight() - tmp->GetMarginRight();
593
594 if( GetMarginBottom() != tmp->GetMarginBottom() )
595 return GetMarginBottom() - tmp->GetMarginBottom();
596
597 return 0;
598}
599
600
601static struct SCH_TEXTBOX_DESC
602{
604 {
607
614
615 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
616 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Corner Radius" ) );
617
618 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
619 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
620 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
621
622 const wxString marginProps = _( "Margins" );
623
624 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Left" ),
627 marginProps );
628 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Top" ),
631 marginProps );
632 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Right" ),
635 marginProps );
636 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Bottom" ),
639 marginProps );
640
641 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Text Size" ),
644 _HKI( "Text Properties" ) );
645
646 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
647 }
int color
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
BITMAPS
A list of all bitmap identifiers.
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
static const COLOR4D WHITE
Definition color4d.h:401
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
int AsTenthsOfADegree() const
Definition eda_angle.h:118
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
VECTOR2I m_start
Definition eda_shape.h:507
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:215
void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:177
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:173
void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:219
VECTOR2I m_end
Definition eda_shape.h:508
virtual int GetWidth() const
Definition eda_shape.h:156
STROKE_PARAMS m_stroke
Definition eda_shape.h:493
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:266
COLOR4D GetTextColor() const
Definition eda_text.h:269
bool IsItalic() const
Definition eda_text.h:168
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:146
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:97
KIFONT::FONT * GetFont() const
Definition eda_text.h:246
wxString m_hyperlink
A hyperlink URL.
Definition eda_text.h:450
int GetTextWidth() const
Definition eda_text.h:263
virtual bool HasHyperlink() const
Definition eda_text.h:399
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:418
wxString GetHyperlink() const
Definition eda_text.h:400
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:199
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition eda_text.h:116
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
Definition eda_text.cpp:96
double Similarity(const EDA_TEXT &aOther) const
wxString EvaluateText(const wxString &aText) const
Definition eda_text.cpp:642
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:230
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:466
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition eda_text.cpp:453
void GetLinePositions(const RENDER_SETTINGS *aSettings, 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:912
bool IsBold() const
Definition eda_text.h:183
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition eda_text.h:202
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition eda_text.h:108
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:300
void SwapText(EDA_TEXT &aTradingPartner)
Definition eda_text.cpp:446
bool operator==(const EDA_TEXT &aRhs) const
Definition eda_text.h:395
void SetMultilineAllowed(bool aAllow)
Definition eda_text.cpp:402
VECTOR2I GetTextSize() const
Definition eda_text.h:260
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:410
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition font.cpp:147
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:572
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Base plotter engine class.
Definition plotter.h:121
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition plotter.h:461
bool GetColorMode() const
Definition plotter.h:149
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Definition plotter.cpp:695
Provide class metadata.Helper macro to map type hashes to names.
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()
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
Definition schematic.h:171
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition sch_item.cpp:637
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.h:688
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:217
bool IsPrivate() const
Definition sch_item.h:250
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:309
const wxString & GetDefaultFont(const RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:580
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:51
const KIFONT::METRICS & GetFontMetrics() const
Definition sch_item.cpp:593
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:602
SCH_LAYER_ID m_layer
Definition sch_item.h:739
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
Definition sch_item.h:346
Handle actions specific to the schematic editor.
void HypertextCommand(const wxString &aHref)
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition sch_shape.cpp:53
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
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.
SCH_SHAPE(SHAPE_T aShape=SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
Definition sch_shape.cpp:38
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool operator==(const SCH_ITEM &aOther) const override
STROKE_PARAMS GetStroke() const override
Definition sch_shape.h:58
VECTOR2I GetPosition() const override
Definition sch_shape.h:85
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:47
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
void SetMarginBottom(int aBottom)
Definition sch_textbox.h:61
int GetMarginBottom() const
Definition sch_textbox.h:66
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
bool m_excludedFromSim
virtual wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
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
int GetMarginLeft() const
Definition sch_textbox.h:63
int GetSchTextSize() const
Definition sch_textbox.h:68
bool GetExcludedFromSim() const override
Definition sch_textbox.h:92
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
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.
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
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
virtual void Rotate90(bool aClockwise)
void SetMarginRight(int aRight)
Definition sch_textbox.h:60
void SetSchTextSize(int aSize)
Definition sch_textbox.h:69
KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const override
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)
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.
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
void SetMarginTop(int aTop)
Definition sch_textbox.h:59
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
KIGFX::COLOR4D GetColor() const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:46
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition common.cpp:59
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:408
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:407
SHAPE_T
Definition eda_shape.h:43
FILL_T
Definition eda_shape.h:56
a few functions useful in geometry calculations.
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:448
@ LAYER_DEVICE
Definition layer_ids.h:465
Message panel definition file.
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
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.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
#define _HKI(x)
Definition page_info.cpp:44
see class PGM_BASE
#define TYPE_HASH(x)
Definition property.h:73
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:62
#define REGISTER_TYPE(x)
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.
bool IsURL(wxString aStr)
Performs a URL sniff-test on a string.
wxString result
Test unit parsing edge cases and error handling.
@ 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:154
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695