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>
39#include <sch_textbox.h>
41
42
43SCH_TEXTBOX::SCH_TEXTBOX( SCH_LAYER_ID aLayer, int aLineWidth, FILL_T aFillType,
44 const wxString& aText, KICAD_T aType ) :
45 SCH_SHAPE( SHAPE_T::RECTANGLE, aLayer, aLineWidth, aFillType, aType ),
46 EDA_TEXT( schIUScale, aText )
47{
48 m_layer = aLayer;
49
52 SetMultilineAllowed( true );
53
54 m_excludedFromSim = false;
55
56 int defaultMargin = GetLegacyTextMargin();
57 m_marginLeft = defaultMargin;
58 m_marginTop = defaultMargin;
59 m_marginRight = defaultMargin;
60 m_marginBottom = defaultMargin;
61}
62
63
65 SCH_SHAPE( aText ),
66 EDA_TEXT( aText )
67{
73}
74
75
77{
78 if( m_layer == LAYER_DEVICE )
79 return KiROUND( GetTextSize().y * 0.8 );
80 else
81 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
82}
83
84
86{
88
89 // Text is NOT really mirrored; it just has its justification flipped
91 {
96 }
97}
98
99
101{
103
104 // Text is NOT really mirrored; it just has its justification flipped
106 {
111 }
112}
113
114
115void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
116{
117 SCH_SHAPE::Rotate( aCenter, aRotateCCW );
119}
120
121
122void SCH_TEXTBOX::Rotate90( bool aClockwise )
123{
125}
126
127
129{
130 BOX2I bbox = BOX2I( m_start, m_end - m_start );
131
132 bbox.Normalize();
133
134 VECTOR2I pos( bbox.GetLeft() + m_marginLeft, bbox.GetBottom() - m_marginBottom );
135
136 if( GetTextAngle().IsVertical() )
137 {
138 switch( GetHorizJustify() )
139 {
141 pos.y = bbox.GetBottom() - m_marginBottom;
142 break;
144 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
145 break;
147 pos.y = bbox.GetTop() + m_marginTop;
148 break;
150 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
151 break;
152 }
153
154 switch( GetVertJustify() )
155 {
157 pos.x = bbox.GetLeft() + m_marginLeft;
158 break;
160 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
161 break;
163 pos.x = bbox.GetRight() - m_marginRight;
164 break;
166 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
167 break;
168 }
169 }
170 else
171 {
172 switch( GetHorizJustify() )
173 {
175 pos.x = bbox.GetLeft() + m_marginLeft;
176 break;
178 pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
179 break;
181 pos.x = bbox.GetRight() - m_marginRight;
182 break;
184 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
185 break;
186 }
187
188 switch( GetVertJustify() )
189 {
191 pos.y = bbox.GetTop() + m_marginTop;
192 break;
194 pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
195 break;
197 pos.y = bbox.GetBottom() - m_marginBottom;
198 break;
200 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
201 break;
202 }
203 }
204
205 return pos;
206}
207
208
210{
211 SCH_SHAPE::swapData( aItem );
212
213 SCH_TEXTBOX* item = static_cast<SCH_TEXTBOX*>( aItem );
214
215 std::swap( m_layer, item->m_layer );
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 )
267
268 return font;
269}
270
271
272wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
273 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 VECTOR2I size = GetEnd() - GetStart();
301 int colWidth;
302
303 if( GetTextAngle().IsVertical() )
304 colWidth = abs( size.y ) - ( GetMarginTop() + GetMarginBottom() );
305 else
306 colWidth = abs( size.x ) - ( GetMarginLeft() + GetMarginRight() );
307
309 IsBold(), IsItalic() );
310
311 return text;
312}
313
314
315bool SCH_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
316{
317 BOX2I rect = GetBoundingBox();
318
319 rect.Inflate( aAccuracy );
320
321 return rect.Contains( aPosition );
322}
323
324
325bool SCH_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
326{
327 BOX2I rect = aRect;
328
329 rect.Inflate( aAccuracy );
330
331 if( aContained )
332 return rect.Contains( GetBoundingBox() );
333
334 return rect.Intersects( GetBoundingBox() );
335}
336
337
339{
340 if( HasHyperlink() )
341 return true;
342
343 return IsURL( GetShownText( false ) );
344}
345
346
348{
349 wxCHECK_MSG( IsHypertext(), /* void */,
350 wxT( "Calling a hypertext menu on a SCH_TEXTBOX with no hyperlink?" ) );
351
353
354 if( HasHyperlink() )
355 navTool->HypertextCommand( m_hyperlink );
356 else
357 navTool->HypertextCommand( GetShownText( false ) );
358}
359
360
361wxString SCH_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
362{
363 return wxString::Format( _( "Text Box" ) );
364}
365
366
368{
369 return BITMAPS::add_textbox;
370}
371
372
373void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
374 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
375{
376 if( IsPrivate() )
377 return;
378
379 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
380
381 if( aBackground )
382 return;
383
384 SCH_SHEET_PATH* sheet = Schematic() ? &Schematic()->CurrentSheet() : nullptr;
385 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
386 int penWidth = GetEffectivePenWidth( renderSettings );
388 COLOR4D bg = renderSettings->GetBackgroundColor();
389
390 KIFONT::FONT* font = getDrawFont();
391
393
394 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
395 color = renderSettings->GetLayerColor( m_layer );
396
397 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
398 bg = COLOR4D::WHITE;
399
400 if( aDimmed )
401 {
402 color.Desaturate( );
403 color = color.Mix( bg, 0.5f );
404 }
405
406 penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
407 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
408 aPlotter->SetCurrentLineWidth( penWidth );
409
410 TEXT_ATTRIBUTES attrs;
411 std::vector<VECTOR2I> positions;
412 wxArrayString strings_list;
413
414 wxStringSplit( GetShownText( sheet, true ), strings_list, '\n' );
415 positions.reserve( strings_list.Count() );
416
417 if( renderSettings->m_Transform != TRANSFORM() || aOffset != VECTOR2I() )
418 {
419 SCH_TEXTBOX temp( *this );
420
421 if( renderSettings->m_Transform.y1 )
422 {
425 }
426
427 temp.SetStart( renderSettings->TransformCoordinate( m_start ) + aOffset );
428 temp.SetEnd( renderSettings->TransformCoordinate( m_end ) + aOffset );
429
430 attrs = temp.GetAttributes();
431 temp.GetLinePositions( positions, (int) strings_list.Count() );
432 }
433 else
434 {
435 attrs = GetAttributes();
436 GetLinePositions( positions, (int) strings_list.Count() );
437 }
438
439 attrs.m_StrokeWidth = penWidth;
440 attrs.m_Multiline = false;
441
442 for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
443 {
444 aPlotter->PlotText( positions[ii], color, strings_list.Item( ii ), attrs, font,
445 GetFontMetrics() );
446 }
447
448 if( HasHyperlink() )
449 aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
450}
451
452
453void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
454{
455 // Don't use GetShownText() here; we want to show the user the variable references
456 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
457
459 aList.emplace_back( _( "Exclude from" ), _( "Simulation" ) );
460
461 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
462
463 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
464 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
465 aList.emplace_back( _( "Style" ), textStyle[style] );
466
467 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
468
469 aList.emplace_back( _( "Box Width" ),
470 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
471
472 aList.emplace_back( _( "Box Height" ),
473 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) );
474
475 m_stroke.GetMsgPanelInfo( aFrame, aList );
476}
477
478
479bool SCH_TEXTBOX::operator==( const SCH_ITEM& aOther ) const
480{
481 if( Type() != aOther.Type() )
482 return false;
483
484 const SCH_TEXTBOX& other = static_cast<const SCH_TEXTBOX&>( aOther );
485
487 return false;
488
489 if( GetMarginLeft() != other.GetMarginLeft() )
490 return false;
491
492 if( GetMarginTop() != other.GetMarginTop() )
493 return false;
494
495 if( GetMarginRight() != other.GetMarginRight() )
496 return false;
497
498 if( GetMarginBottom() != other.GetMarginBottom() )
499 return false;
500
501 return SCH_SHAPE::operator==( aOther ) && EDA_TEXT::operator==( other );
502}
503
504
505double SCH_TEXTBOX::Similarity( const SCH_ITEM& aOther ) const
506{
507 if( m_Uuid == aOther.m_Uuid )
508 return 1.0;
509
510 if( aOther.Type() != Type() )
511 return 0.0;
512
513 auto other = static_cast<const SCH_TEXTBOX&>( aOther );
514
515 double similarity = SimilarityBase( other );
516
517 if( m_excludedFromSim != other.m_excludedFromSim )
518 similarity *= 0.9;
519
520 if( GetMarginLeft() != other.GetMarginLeft() )
521 similarity *= 0.9;
522
523 if( GetMarginTop() != other.GetMarginTop() )
524 similarity *= 0.9;
525
526 if( GetMarginRight() != other.GetMarginRight() )
527 similarity *= 0.9;
528
529 if( GetMarginBottom() != other.GetMarginBottom() )
530 similarity *= 0.9;
531
532 similarity *= SCH_SHAPE::Similarity( aOther );
533 similarity *= EDA_TEXT::Similarity( other );
534
535 return similarity;
536}
537
538
539int SCH_TEXTBOX::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
540{
541 wxASSERT( aOther.Type() == SCH_TEXTBOX_T );
542
543 int retv = SCH_SHAPE::compare( aOther, aCompareFlags );
544
545 if( retv )
546 return retv;
547
548 const SCH_TEXTBOX* tmp = static_cast<const SCH_TEXTBOX*>( &aOther );
549
550 int result = GetText().CmpNoCase( tmp->GetText() );
551
552 if( result != 0 )
553 return result;
554
555 if( GetTextWidth() != tmp->GetTextWidth() )
556 return GetTextWidth() - tmp->GetTextWidth();
557
558 if( GetTextHeight() != tmp->GetTextHeight() )
559 return GetTextHeight() - tmp->GetTextHeight();
560
561 if( IsBold() != tmp->IsBold() )
562 return IsBold() - tmp->IsBold();
563
564 if( IsItalic() != tmp->IsItalic() )
565 return IsItalic() - tmp->IsItalic();
566
567 if( GetHorizJustify() != tmp->GetHorizJustify() )
568 return GetHorizJustify() - tmp->GetHorizJustify();
569
570 if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() )
572
573 if( GetMarginLeft() != tmp->GetMarginLeft() )
574 return GetMarginLeft() - tmp->GetMarginLeft();
575
576 if( GetMarginTop() != tmp->GetMarginTop() )
577 return GetMarginTop() - tmp->GetMarginTop();
578
579 if( GetMarginRight() != tmp->GetMarginRight() )
580 return GetMarginRight() - tmp->GetMarginRight();
581
582 if( GetMarginBottom() != tmp->GetMarginBottom() )
583 return GetMarginBottom() - tmp->GetMarginBottom();
584
585 return 0;
586}
587
588
589static struct SCH_TEXTBOX_DESC
590{
592 {
595
602
603 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
604
605 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
606 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
607 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
608
609 const wxString marginProps = _( "Margins" );
610
611 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Left" ),
613 PROPERTY_DISPLAY::PT_SIZE ),
614 marginProps );
615 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Top" ),
617 PROPERTY_DISPLAY::PT_SIZE ),
618 marginProps );
619 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Right" ),
621 PROPERTY_DISPLAY::PT_SIZE ),
622 marginProps );
623 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Margin Bottom" ),
625 PROPERTY_DISPLAY::PT_SIZE ),
626 marginProps );
627
628 propMgr.AddProperty( new PROPERTY<SCH_TEXTBOX, int>( _HKI( "Text Size" ),
630 PROPERTY_DISPLAY::PT_SIZE ),
631 _HKI( "Text Properties" ) );
632
633 propMgr.Mask( TYPE_HASH( SCH_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
634 }
int color
Definition: DXF_plotter.cpp:60
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:112
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
BOX2< VECTOR2I > BOX2I
Definition: box2.h:922
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
constexpr coord_type GetLeft() const
Definition: box2.h:228
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr coord_type GetRight() const
Definition: box2.h:217
constexpr coord_type GetTop() const
Definition: box2.h:229
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
constexpr coord_type GetBottom() const
Definition: box2.h:222
int AsTenthsOfADegree() const
Definition: eda_angle.h:118
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition: eda_item.h:501
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:108
VECTOR2I m_start
Definition: eda_shape.h:500
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:501
virtual int GetWidth() const
Definition: eda_shape.h:156
STROKE_PARAMS m_stroke
Definition: eda_shape.h:487
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
int GetTextHeight() const
Definition: eda_text.h:265
COLOR4D GetTextColor() const
Definition: eda_text.h:268
bool IsItalic() const
Definition: eda_text.h:167
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:145
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:245
wxString m_hyperlink
A hyperlink URL.
Definition: eda_text.h:452
int GetTextWidth() const
Definition: eda_text.h:262
virtual bool HasHyperlink() const
Definition: eda_text.h:397
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:417
wxString GetHyperlink() const
Definition: eda_text.h:398
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:198
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:903
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1286
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:229
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:465
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:452
bool IsBold() const
Definition: eda_text.h:182
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:201
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:299
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:445
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:393
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:401
VECTOR2I GetTextSize() const
Definition: eda_text.h:259
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:409
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition: font.cpp:147
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
int GetDefaultPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Base plotter engine class.
Definition: plotter.h:105
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition: plotter.h:459
bool GetColorMode() const
Definition: plotter.h:133
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Definition: plotter.cpp:754
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
Definition: schematic.h:148
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:501
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:652
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:177
bool IsPrivate() const
Definition: sch_item.h:244
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:290
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:510
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:519
SCH_LAYER_ID m_layer
Definition: sch_item.h:705
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:327
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.
Definition: sch_shape.cpp:107
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:424
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:140
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.cpp:303
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_shape.cpp:113
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:119
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:413
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:54
VECTOR2I GetPosition() const override
Definition: sch_shape.h:81
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:442
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:47
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:220
void SetMarginBottom(int aBottom)
Definition: sch_textbox.h:61
int m_marginRight
Definition: sch_textbox.h:153
int m_marginBottom
Definition: sch_textbox.h:154
int GetMarginBottom() const
Definition: sch_textbox.h:66
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_textbox.cpp:85
bool m_excludedFromSim
Definition: sch_textbox.h:150
bool operator==(const SCH_ITEM &aOther) const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetLegacyTextMargin() const
Definition: sch_textbox.cpp:76
int GetMarginLeft() const
Definition: sch_textbox.h:63
int GetSchTextSize() const
Definition: sch_textbox.h:68
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
bool GetExcludedFromSim() const override
Definition: sch_textbox.h:90
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
int m_marginLeft
Definition: sch_textbox.h:151
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
SCH_TEXTBOX(SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, const wxString &aText=wxEmptyString, KICAD_T aType=SCH_TEXTBOX_T)
Definition: sch_textbox.cpp:43
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
KIFONT::FONT * getDrawFont() const override
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
void SetMarginTop(int aTop)
Definition: sch_textbox.h:59
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
KIGFX::COLOR4D GetColor() const
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, int aFlags)
Definition: common.cpp:59
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:401
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:400
SHAPE_T
Definition: eda_shape.h:43
FILL_T
Definition: eda_shape.h:56
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:438
@ LAYER_DEVICE
Definition: layer_ids.h:455
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:197
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:393
see class PGM_BASE
#define TYPE_HASH(x)
Definition: property.h:72
#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.
bool IsURL(wxString aStr)
Performs a URL sniff-test on a string.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TEXTBOX_T
Definition: typeinfo.h:152
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695