KiCad PCB EDA Suite
EDA_TEXT Class Reference

A mix-in class (via multiple inheritance) that handles texts such as labels, parts, components, or footprints. More...

#include <eda_text.h>

Inheritance diagram for EDA_TEXT:
DS_DRAW_ITEM_TEXT FP_TEXT FP_TEXTBOX LIB_FIELD LIB_TEXT LIB_TEXTBOX PCB_TEXT PCB_TEXTBOX SCH_FIELD SCH_TEXT SCH_TEXTBOX

Public Member Functions

 EDA_TEXT (const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
 
 EDA_TEXT (const EDA_TEXT &aText)
 
virtual ~EDA_TEXT ()
 
EDA_TEXToperator= (const EDA_TEXT &aItem)
 
virtual const wxString & GetText () const
 Return the string associated with the text object. More...
 
virtual wxString GetShownText (int aDepth=0) const
 Return the string actually shown after processing of the base text. More...
 
bool HasTextVars () const
 Indicates the ShownText has text var references which need to be processed. More...
 
virtual void SetText (const wxString &aText)
 
void SetTextThickness (int aWidth)
 The TextThickness is that set by the user. More...
 
int GetTextThickness () const
 
int GetEffectiveTextPenWidth (int aDefaultPenWidth=0) const
 The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth. More...
 
virtual void SetTextAngle (const EDA_ANGLE &aAngle)
 
const EDA_ANGLEGetTextAngle () const
 
void SetItalic (bool aItalic)
 
bool IsItalic () const
 
void SetBold (bool aBold)
 
bool IsBold () const
 
virtual void SetVisible (bool aVisible)
 
virtual bool IsVisible () const
 
void SetMirrored (bool isMirrored)
 
bool IsMirrored () const
 
void SetMultilineAllowed (bool aAllow)
 
bool IsMultilineAllowed () const
 
void SetHorizJustify (GR_TEXT_H_ALIGN_T aType)
 
GR_TEXT_H_ALIGN_T GetHorizJustify () const
 
void SetVertJustify (GR_TEXT_V_ALIGN_T aType)
 
GR_TEXT_V_ALIGN_T GetVertJustify () const
 
void SetKeepUpright (bool aKeepUpright)
 
bool IsKeepUpright () const
 
void SetAttributes (const EDA_TEXT &aSrc)
 Set the text attributes from another instance. More...
 
void SwapAttributes (EDA_TEXT &aTradingPartner)
 Swap the text attributes of the two involved instances. More...
 
void SwapText (EDA_TEXT &aTradingPartner)
 
void CopyText (const EDA_TEXT &aSrc)
 
void SetAttributes (const TEXT_ATTRIBUTES &aTextAttrs)
 
const TEXT_ATTRIBUTESGetAttributes () const
 
bool Replace (const EDA_SEARCH_DATA &aSearchData)
 Helper function used in search and replace dialog. More...
 
bool IsDefaultFormatting () const
 
void SetFont (KIFONT::FONT *aFont)
 
KIFONT::FONTGetFont () const
 
wxString GetFontName () const
 
void SetLineSpacing (double aLineSpacing)
 
double GetLineSpacing () const
 
void SetTextSize (const VECTOR2I &aNewSize)
 
VECTOR2I GetTextSize () const
 
void SetTextWidth (int aWidth)
 
int GetTextWidth () const
 
void SetTextHeight (int aHeight)
 
int GetTextHeight () const
 
void SetTextColor (const COLOR4D &aColor)
 
COLOR4D GetTextColor () const
 
void SetTextPos (const VECTOR2I &aPoint)
 
const VECTOR2IGetTextPos () const
 
void SetTextX (int aX)
 
void SetTextY (int aY)
 
void Offset (const VECTOR2I &aOffset)
 
void Empty ()
 
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. More...
 
void TransformBoundingBoxWithClearanceToPolygon (SHAPE_POLY_SET *aCornerBuffer, int aClearanceValue) const
 Convert the text bounding box to a rectangular polygon depending on the text orientation, the bounding box is not always horizontal or vertical. More...
 
std::shared_ptr< SHAPE_COMPOUNDGetEffectiveTextShape (bool aTriangulate=true, bool aUseTextRotation=true) const
 build a list of segments (SHAPE_SEGMENT) to describe a text shape. More...
 
virtual bool TextHitTest (const VECTOR2I &aPoint, int aAccuracy=0) const
 Test if aPoint is within the bounds of this object. More...
 
virtual bool TextHitTest (const BOX2I &aRect, bool aContains, int aAccuracy=0) const
 Test if object bounding box is contained within or intersects aRect. More...
 
BOX2I GetTextBox (int aLine=-1, bool aInvertY=false) const
 Useful in multiline texts to calculate the full text or a line area (for zones filling, locate functions....) More...
 
int GetInterline () const
 Return the distance between two lines of text. More...
 
wxString GetTextStyleName () const
 
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 justification and the rotation of the whole text. More...
 
virtual void Format (OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
 Output the object to aFormatter in s-expression form. More...
 
virtual KIFONT::FONTGetDrawFont () const
 
virtual EDA_ANGLE GetDrawRotation () const
 
virtual VECTOR2I GetDrawPos () const
 
virtual void ClearRenderCache ()
 
virtual void ClearBoundingBoxCache ()
 
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache (const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
 
void SetupRenderCache (const wxString &aResolvedText, const EDA_ANGLE &aAngle)
 
void AddRenderCacheGlyph (const SHAPE_POLY_SET &aPoly)
 
int Compare (const EDA_TEXT *aOther) const
 
virtual bool HasHyperlink () const
 
wxString GetHyperlink () const
 
void SetHyperlink (wxString aLink)
 
void RemoveHyperlink ()
 

Static Public Member Functions

static GR_TEXT_H_ALIGN_T MapHorizJustify (int aHorizJustify)
 
static GR_TEXT_V_ALIGN_T MapVertJustify (int aVertJustify)
 
static bool ValidateHyperlink (const wxString &aURL)
 Check if aURL is a valid hyperlink. More...
 
static bool IsGotoPageHref (const wxString &aHref, wxString *aDestination=nullptr)
 Check if aHref is a valid internal hyperlink. More...
 
static wxString GotoPageHref (const wxString &aDestination)
 Generate a href to a page in the current schematic. More...
 

Protected Attributes

wxString m_hyperlink
 A hyperlink URL. More...
 

Private Member Functions

void cacheShownText ()
 
void printOneLineOfText (const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aFillMode, const wxString &aText, const VECTOR2I &aPos)
 Print each line of this EDA_TEXT. More...
 

Private Attributes

wxString m_text
 
wxString m_shown_text
 
bool m_shown_text_has_text_var_refs
 
std::reference_wrapper< const EDA_IU_SCALEm_IuScale
 
wxString m_render_cache_text
 
EDA_ANGLE m_render_cache_angle
 
VECTOR2I m_render_cache_offset
 
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_render_cache
 
bool m_bounding_box_cache_valid
 
VECTOR2I m_bounding_box_cache_pos
 
int m_bounding_box_cache_line
 
bool m_bounding_box_cache_inverted
 
BOX2I m_bounding_box_cache
 
TEXT_ATTRIBUTES m_attributes
 
VECTOR2I m_pos
 

Detailed Description

A mix-in class (via multiple inheritance) that handles texts such as labels, parts, components, or footprints.

Because it's a mix-in class, care is used to provide function names (accessors) that to not collide with function names likely to be seen in the combined derived classes.

Definition at line 71 of file eda_text.h.

Constructor & Destructor Documentation

◆ EDA_TEXT() [1/2]

EDA_TEXT::EDA_TEXT ( const EDA_IU_SCALE aIuScale,
const wxString &  aText = wxEmptyString 
)

Definition at line 90 of file eda_text.cpp.

90 :
91 m_text( aText ),
92 m_IuScale( aIuScale ),
96{
100}
wxString m_text
Definition: eda_text.h:377
int m_bounding_box_cache_line
Definition: eda_text.h:390
std::reference_wrapper< const EDA_IU_SCALE > m_IuScale
Definition: eda_text.h:381
bool m_bounding_box_cache_valid
Definition: eda_text.h:388
void cacheShownText()
Definition: eda_text.cpp:408
bool m_bounding_box_cache_inverted
Definition: eda_text.h:391
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
Definition: eda_text.h:61
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
Definition: eda_units.h:123
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References cacheShownText(), DEFAULT_SIZE_TEXT, m_IuScale, EDA_UNIT_UTILS::Mils2IU(), and SetTextSize().

◆ EDA_TEXT() [2/2]

EDA_TEXT::EDA_TEXT ( const EDA_TEXT aText)

Definition at line 103 of file eda_text.cpp.

103 :
104 m_IuScale( aText.m_IuScale )
105{
106 m_text = aText.m_text;
109
111 m_pos = aText.m_pos;
112
115
116 m_render_cache.clear();
117
118 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aText.m_render_cache )
119 {
120 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
121 m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
122 }
123
128}
VECTOR2I m_pos
Definition: eda_text.h:395
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_render_cache
Definition: eda_text.h:386
BOX2I m_bounding_box_cache
Definition: eda_text.h:392
bool m_shown_text_has_text_var_refs
Definition: eda_text.h:379
wxString m_shown_text
Definition: eda_text.h:378
EDA_ANGLE m_render_cache_angle
Definition: eda_text.h:384
wxString m_render_cache_text
Definition: eda_text.h:383
TEXT_ATTRIBUTES m_attributes
Definition: eda_text.h:394

References m_attributes, m_bounding_box_cache, m_bounding_box_cache_inverted, m_bounding_box_cache_line, m_bounding_box_cache_valid, m_pos, m_render_cache, m_render_cache_angle, m_render_cache_text, m_shown_text, m_shown_text_has_text_var_refs, and m_text.

◆ ~EDA_TEXT()

EDA_TEXT::~EDA_TEXT ( )
virtual

Definition at line 131 of file eda_text.cpp.

132{
133}

Member Function Documentation

◆ AddRenderCacheGlyph()

void EDA_TEXT::AddRenderCacheGlyph ( const SHAPE_POLY_SET aPoly)

Definition at line 490 of file eda_text.cpp.

491{
492 m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( aPoly ) );
493}

References m_render_cache.

◆ cacheShownText()

void EDA_TEXT::cacheShownText ( )
private

Definition at line 408 of file eda_text.cpp.

409{
410 if( m_text.IsEmpty() )
411 {
412 m_shown_text = wxEmptyString;
414 }
415 else
416 {
418 m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
419 }
420
423}
virtual void ClearRenderCache()
Definition: eda_text.cpp:438
wxString UnescapeString(const wxString &aSource)

References ClearRenderCache(), m_bounding_box_cache_valid, m_shown_text, m_shown_text_has_text_var_refs, m_text, and UnescapeString().

Referenced by EDA_TEXT(), Replace(), and SetText().

◆ ClearBoundingBoxCache()

void EDA_TEXT::ClearBoundingBoxCache ( )
virtual

Definition at line 444 of file eda_text.cpp.

445{
447}

References m_bounding_box_cache_valid.

Referenced by SCH_FIELD::ClearCaches().

◆ ClearRenderCache()

◆ Compare()

int EDA_TEXT::Compare ( const EDA_TEXT aOther) const

Definition at line 905 of file eda_text.cpp.

906{
907#define EPSILON 2 // Should be enough for rounding errors on calculated items
908
909#define TEST( a, b ) { if( a != b ) return a - b; }
910#define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
911#define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
912
913 TEST_PT( m_pos, aOther->m_pos );
914
919
929
930 int val = GetFontName().Cmp( aOther->GetFontName() );
931
932 if( val != 0 )
933 return val;
934
935 return m_text.Cmp( aOther->m_text );
936}
double AsDegrees() const
Definition: eda_angle.h:149
wxString GetFontName() const
Definition: eda_text.cpp:751
bool m_KeepUpright
If true, keep rotation angle between -90...90 degrees for readability.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
#define TEST_PT(a, b)
#define TEST(a, b)
#define TEST_E(a, b)

References EDA_ANGLE::AsDegrees(), GetFontName(), TEXT_ATTRIBUTES::m_Angle, m_attributes, TEXT_ATTRIBUTES::m_Bold, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_KeepUpright, TEXT_ATTRIBUTES::m_LineSpacing, TEXT_ATTRIBUTES::m_Mirrored, TEXT_ATTRIBUTES::m_Multiline, m_pos, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, m_text, TEXT_ATTRIBUTES::m_Underlined, TEXT_ATTRIBUTES::m_Valign, TEXT_ATTRIBUTES::m_Visible, TEST, TEST_E, and TEST_PT.

◆ CopyText()

◆ Empty()

void EDA_TEXT::Empty ( )

Definition at line 400 of file eda_text.cpp.

401{
402 m_text.Empty();
405}

References ClearRenderCache(), m_bounding_box_cache_valid, and m_text.

Referenced by SCH_LEGACY_PLUGIN_CACHE::LoadPart().

◆ Format()

void EDA_TEXT::Format ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
int  aControlBits 
) const
virtual

Output the object to aFormatter in s-expression form.

Parameters
aFormatterThe OUTPUTFORMATTER object to write to.
aNestLevelThe indentation next level.
aControlBitsThe control bit definition for object specific formatting.
Exceptions
IO_ERRORon write error.

Definition at line 775 of file eda_text.cpp.

776{
777 aFormatter->Print( aNestLevel + 1, "(effects" );
778
779 aFormatter->Print( 0, " (font" );
780
781 if( GetFont() && !GetFont()->GetName().IsEmpty() )
782 aFormatter->Print( 0, " (face \"%s\")", GetFont()->NameAsToken() );
783
784 // Text size
785 aFormatter->Print( 0, " (size %s %s)",
788
789 if( GetLineSpacing() != 1.0 )
790 {
791 aFormatter->Print( 0, " (line_spacing %s)",
792 FormatDouble2Str( GetLineSpacing() ).c_str() );
793 }
794
795 if( GetTextThickness() )
796 {
797 aFormatter->Print( 0, " (thickness %s)",
799 }
800
801 if( IsBold() )
802 aFormatter->Print( 0, " bold" );
803
804 if( IsItalic() )
805 aFormatter->Print( 0, " italic" );
806
807 if( GetTextColor() != COLOR4D::UNSPECIFIED )
808 {
809 aFormatter->Print( 0, " (color %d %d %d %s)",
810 KiROUND( GetTextColor().r * 255.0 ),
811 KiROUND( GetTextColor().g * 255.0 ),
812 KiROUND( GetTextColor().b * 255.0 ),
813 FormatDouble2Str( GetTextColor().a ).c_str() );
814 }
815
816 aFormatter->Print( 0, ")"); // (font
817
820 {
821 aFormatter->Print( 0, " (justify");
822
824 aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ? " left" : " right" );
825
827 aFormatter->Print( 0, GetVertJustify() == GR_TEXT_V_ALIGN_TOP ? " top" : " bottom" );
828
829 if( IsMirrored() )
830 aFormatter->Print( 0, " mirror" );
831
832 aFormatter->Print( 0, ")" ); // (justify
833 }
834
835 if( !( aControlBits & CTL_OMIT_HIDE ) && !IsVisible() )
836 aFormatter->Print( 0, " hide" );
837
838 if( HasHyperlink() )
839 {
840 aFormatter->Print( 0, " (href %s)", aFormatter->Quotew( GetHyperlink() ).c_str() );
841 }
842
843 aFormatter->Print( 0, ")\n" ); // (effects
844}
int GetTextHeight() const
Definition: eda_text.h:192
COLOR4D GetTextColor() const
Definition: eda_text.h:195
bool IsItalic() const
Definition: eda_text.h:120
virtual bool IsVisible() const
Definition: eda_text.h:126
KIFONT::FONT * GetFont() const
Definition: eda_text.h:178
int GetTextWidth() const
Definition: eda_text.h:189
virtual bool HasHyperlink() const
Definition: eda_text.h:324
wxString GetHyperlink() const
Definition: eda_text.h:325
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:139
double GetLineSpacing() const
Definition: eda_text.h:183
bool IsMirrored() const
Definition: eda_text.h:129
bool IsBold() const
Definition: eda_text.h:123
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:142
int GetTextThickness() const
Definition: eda_text.h:109
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:499
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:431
#define CTL_OMIT_HIDE
Definition: eda_text.h:53
E_SERIE r
Definition: eserie.cpp:41
std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
Definition: eda_units.cpp:143
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
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:80

References CTL_OMIT_HIDE, FormatDouble2Str(), EDA_UNIT_UTILS::FormatInternalUnits(), GetFont(), GetHorizJustify(), GetHyperlink(), GetLineSpacing(), GetTextColor(), GetTextHeight(), GetTextThickness(), GetTextWidth(), GetVertJustify(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, HasHyperlink(), IsBold(), IsItalic(), IsMirrored(), IsVisible(), KiROUND(), m_IuScale, OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), and r.

Referenced by SCH_SEXPR_PLUGIN_CACHE::saveField(), and SCH_SEXPR_PLUGIN::saveField().

◆ GetAttributes()

◆ GetDrawFont()

◆ GetDrawPos()

◆ GetDrawRotation()

◆ GetEffectiveTextPenWidth()

int EDA_TEXT::GetEffectiveTextPenWidth ( int  aDefaultPenWidth = 0) const

The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.

Definition at line 297 of file eda_text.cpp.

298{
299 int penWidth = GetTextThickness();
300
301 if( penWidth <= 1 )
302 {
303 penWidth = aDefaultPenWidth;
304
305 if( IsBold() )
306 penWidth = GetPenSizeForBold( GetTextWidth() );
307 else if( penWidth <= 1 )
308 penWidth = GetPenSizeForNormal( GetTextWidth() );
309 }
310
311 // Clip pen size for small texts:
312 penWidth = Clamp_Text_PenSize( penWidth, GetTextSize() );
313
314 return penWidth;
315}
VECTOR2I GetTextSize() const
Definition: eda_text.h:186
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:40
int GetPenSizeForNormal(int aTextSize)
Definition: gr_text.cpp:52
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
Definition: gr_text.cpp:75

References Clamp_Text_PenSize(), GetPenSizeForBold(), GetPenSizeForNormal(), GetTextSize(), GetTextThickness(), GetTextWidth(), and IsBold().

Referenced by BOARD_ADAPTER::addText(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), SCH_LABEL_BASE::GetBodyBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), GetEffectiveTextShape(), LIB_FIELD::GetPenWidth(), LIB_TEXT::GetPenWidth(), SCH_FIELD::GetPenWidth(), SCH_DIRECTIVE_LABEL::GetPenWidth(), SCH_TEXT::GetPenWidth(), GetTextBox(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_TEXT::Plot(), LIB_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), SCH_FIELD::Print(), LIB_TEXT::print(), LIB_TEXTBOX::print(), printOneLineOfText(), FP_TEXT::TransformTextShapeWithClearanceToPolygon(), FP_TEXTBOX::TransformTextShapeWithClearanceToPolygon(), PCB_TEXT::TransformTextShapeWithClearanceToPolygon(), PCB_TEXTBOX::TransformTextShapeWithClearanceToPolygon(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), PCB_DIM_ALIGNED::updateText(), and PCB_DIM_ORTHOGONAL::updateText().

◆ GetEffectiveTextShape()

std::shared_ptr< SHAPE_COMPOUND > EDA_TEXT::GetEffectiveTextShape ( bool  aTriangulate = true,
bool  aUseTextRotation = true 
) const

build a list of segments (SHAPE_SEGMENT) to describe a text shape.

Parameters
aTriangulatetrue to build also the triangulation of each shape
aUseTextRotationtrue to use the actual text draw rotation. false to build a list of shape for a not rotated text ("native" shapes).

Definition at line 847 of file eda_text.cpp.

849{
850 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
852 KIFONT::FONT* font = GetDrawFont();
853 int penWidth = GetEffectiveTextPenWidth();
855
856 if( aUseTextRotation )
857 attrs.m_Angle = GetDrawRotation();
858 else
859 attrs.m_Angle = ANGLE_0;
860
861 if( aTriangulate )
862 {
863 CALLBACK_GAL callback_gal(
864 empty_opts,
865 // Stroke callback
866 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
867 {
868 shape->AddShape( new SHAPE_SEGMENT( aPt1, aPt2, penWidth ) );
869 },
870 // Triangulation callback
871 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
872 {
873 SHAPE_SIMPLE* triShape = new SHAPE_SIMPLE;
874
875 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
876 triShape->Append( point.x, point.y );
877
878 shape->AddShape( triShape );
879 } );
880
881 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs );
882 }
883 else
884 {
885 CALLBACK_GAL callback_gal(
886 empty_opts,
887 // Stroke callback
888 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
889 {
890 shape->AddShape( new SHAPE_SEGMENT( aPt1, aPt2, penWidth ) );
891 },
892 // Outline callback
893 [&]( const SHAPE_LINE_CHAIN& aPoly )
894 {
895 shape->AddShape( aPoly.Clone() );
896 } );
897
898 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs );
899 }
900
901 return shape;
902}
virtual KIFONT::FONT * GetDrawFont() const
Definition: eda_text.cpp:426
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:309
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:95
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:310
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:162
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:159
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:42
void Append(int aX, int aY)
Append a new point at the end of the polygon.
Definition: shape_simple.h:135
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412

References ANGLE_0, SHAPE_SIMPLE::Append(), KIFONT::FONT::Draw(), GetAttributes(), GetDrawFont(), GetDrawPos(), GetDrawRotation(), GetEffectiveTextPenWidth(), GetShownText(), and TEXT_ATTRIBUTES::m_Angle.

Referenced by FP_TEXT::GetEffectiveShape(), FP_TEXTBOX::GetEffectiveShape(), PCB_TEXT::GetEffectiveShape(), PCB_TEXTBOX::GetEffectiveShape(), PCB_SELECTION_TOOL::hitTestDistance(), PNS_KICAD_IFACE_BASE::syncTextItem(), and TransformBoundingBoxWithClearanceToPolygon().

◆ GetFont()

◆ GetFontName()

wxString EDA_TEXT::GetFontName ( ) const

Definition at line 751 of file eda_text.cpp.

752{
753 if( GetFont() )
754 return GetFont()->GetName();
755 else
756 return wxEmptyString;
757}
const wxString & GetName() const
Definition: font.h:121

References GetFont(), and KIFONT::FONT::GetName().

Referenced by KI_TEST::CheckFpText(), Compare(), IsDefaultFormatting(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ GetHorizJustify()

GR_TEXT_H_ALIGN_T EDA_TEXT::GetHorizJustify ( ) const
inline

Definition at line 139 of file eda_text.h.

139{ return m_attributes.m_Halign; };

References m_attributes, and TEXT_ATTRIBUTES::m_Halign.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), KI_TEST::CheckFpText(), LIB_TEXTBOX::compare(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), EDA_TEXT_DESC::EDA_TEXT_DESC(), AUTOPLACER::fieldHPlacement(), Format(), LIB_TEXTBOX::GetDrawPos(), SCH_TEXTBOX::GetDrawPos(), FP_TEXTBOX::GetDrawPos(), PCB_TEXTBOX::GetDrawPos(), SCH_FIELD::GetEffectiveHorizJustify(), LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), SCH_FIELD::GetMsgPanelInfo(), GetTextBox(), hash_fp_item(), IsDefaultFormatting(), SCH_FIELD::IsHorizJustifyFlipped(), FP_TEXT::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EDIT_TOOL::Mirror(), FP_TEXT::Mirror(), PCB_TEXT::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_TEXTBOX::MirrorHorizontally(), SCH_TEXTBOX::MirrorHorizontally(), LIB_TEXT::MirrorVertical(), LIB_TEXTBOX::MirrorVertically(), SCH_TEXTBOX::MirrorVertically(), LIB_TEXT::NormalizeJustification(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), positioningChanged(), LIB_FIELD::print(), printOneLineOfText(), processTextItem(), LIB_TEXT::Rotate(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), textsNeedUpdate(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ GetHyperlink()

wxString EDA_TEXT::GetHyperlink ( ) const
inline

◆ GetInterline()

int EDA_TEXT::GetInterline ( ) const

Return the distance between two lines of text.

Calculates the distance (pitch) between two lines of text. This distance includes the interline distance plus room for characters like j, {, and [. It also used for single line text, to calculate the text bounding box.

Definition at line 496 of file eda_text.cpp.

497{
499}
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:496

References GetDrawFont(), GetInterline(), GetTextHeight(), and KiROUND().

Referenced by CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), GetInterline(), and GetLinePositions().

◆ GetLinePositions()

void EDA_TEXT::GetLinePositions ( std::vector< VECTOR2I > &  aPositions,
int  aLineCount 
) const

Populate aPositions with the position of each line of a multiline text, according to the vertical justification and the rotation of the whole text.

Parameters
aPositionsis the list to populate by the VECTOR2I positions.
aLineCountis the number of lines (not recalculated here for efficiency reasons.

Definition at line 670 of file eda_text.cpp.

671{
672 VECTOR2I pos = GetDrawPos(); // Position of first line of the multiline text according
673 // to the center of the multiline text block
674
675 VECTOR2I offset; // Offset to next line.
676
677 offset.y = GetInterline();
678
679 if( aLineCount > 1 )
680 {
681 switch( GetVertJustify() )
682 {
684 break;
685
687 pos.y -= ( aLineCount - 1 ) * offset.y / 2;
688 break;
689
691 pos.y -= ( aLineCount - 1 ) * offset.y;
692 break;
693 }
694 }
695
696 // Rotate the position of the first line around the center of the multiline text block
698
699 // Rotate the offset lines to increase happened in the right direction
700 RotatePoint( offset, GetDrawRotation() );
701
702 for( int ii = 0; ii < aLineCount; ii++ )
703 {
704 aPositions.push_back( (VECTOR2I) pos );
705 pos += offset;
706 }
707}
@ GR_TEXT_V_ALIGN_BOTTOM
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References GetDrawPos(), GetDrawRotation(), GetInterline(), GetVertJustify(), GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, RotatePoint(), and VECTOR2< T >::y.

Referenced by SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotPcbText(), and Print().

◆ GetLineSpacing()

double EDA_TEXT::GetLineSpacing ( ) const
inline

Definition at line 183 of file eda_text.h.

183{ return m_attributes.m_LineSpacing; }

References m_attributes, and TEXT_ATTRIBUTES::m_LineSpacing.

Referenced by KI_TEST::CheckFpText(), and Format().

◆ GetRenderCache()

std::vector< std::unique_ptr< KIFONT::GLYPH > > * EDA_TEXT::GetRenderCache ( const wxString &  forResolvedText,
const VECTOR2I aOffset = { 0, 0 } 
) const

Definition at line 451 of file eda_text.cpp.

452{
453 if( GetDrawFont()->IsOutline() )
454 {
455 EDA_ANGLE resolvedAngle = GetDrawRotation();
456
457 if( m_render_cache.empty()
458 || m_render_cache_text != forResolvedText
459 || m_render_cache_angle != resolvedAngle
460 || m_render_cache_offset != aOffset )
461 {
462 m_render_cache.clear();
463
464 KIFONT::OUTLINE_FONT* font = static_cast<KIFONT::OUTLINE_FONT*>( GetDrawFont() );
466
467 attrs.m_Angle = resolvedAngle;
468
469 font->GetLinesAsGlyphs( &m_render_cache, GetShownText(), GetDrawPos() + aOffset, attrs );
470 m_render_cache_angle = resolvedAngle;
471 m_render_cache_text = forResolvedText;
472 m_render_cache_offset = aOffset;
473 }
474
475 return &m_render_cache;
476 }
477
478 return nullptr;
479}
VECTOR2I m_render_cache_offset
Definition: eda_text.h:385
Class OUTLINE_FONT implements outline font drawing.
Definition: outline_font.h:50
void GetLinesAsGlyphs(std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs) const

References GetAttributes(), GetDrawFont(), GetDrawPos(), GetDrawRotation(), KIFONT::OUTLINE_FONT::GetLinesAsGlyphs(), GetShownText(), TEXT_ATTRIBUTES::m_Angle, m_render_cache, m_render_cache_angle, m_render_cache_offset, and m_render_cache_text.

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), and PCB_PLUGIN::formatRenderCache().

◆ GetShownText()

◆ GetText()

virtual const wxString & EDA_TEXT::GetText ( ) const
inlinevirtual

Return the string associated with the text object.

Returns
a const wxString reference containing the string of the item.

Definition at line 87 of file eda_text.h.

87{ return m_text; }

References m_text.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), SCH_EAGLE_PLUGIN::addImplicitConnections(), NETLIST_EXPORTER_XML::addSymbolFields(), SIM_PLOT_FRAME::AddTuner(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_FRAME::AutoRotateItem(), CONNECTION_GRAPH::buildConnectionGraph(), SCH_EDIT_TOOL::ChangeTextType(), KI_TEST::CheckFpText(), CheckLibSymbol(), SCH_SHEET::CleanupSheet(), LIB_TEXT::Clone(), LIB_FIELD::compare(), LIB_TEXT::compare(), LIB_TEXTBOX::compare(), SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo(), SCH_DRAWING_TOOLS::createNewText(), SCH_DRAWING_TOOLS::createSheetPin(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), KIGFX::SCH_VIEW::DisplaySymbol(), EDA_TEXT_DESC::EDA_TEXT_DESC(), CONNECTION_GRAPH::ercCheckHierSheets(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), LIB_SYMBOL::Flatten(), PCB_PLUGIN::format(), LIB_SYMBOL::GetFootprint(), SCH_SYMBOL::GetFootprint(), LIB_FIELD::GetFullText(), FOOTPRINT_INFO_GENERATOR::GetHtmlFieldRow(), SCH_LABEL_BASE::GetIntersheetRefs(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet(), FP_TEXT::GetLength(), getMatchingTextItem(), LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_FIELD::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), SCH_SYMBOL::GetRef(), FOOTPRINT::GetReference(), LIB_SYMBOL::GetSearchText(), PCB_DIMENSION_BASE::GetText(), FOOTPRINT::GetValue(), SCH_SYMBOL::GetValue(), hash_fp_item(), SCH_SHEET::HasUndefinedPins(), LIB_FIELD::HitTest(), SCH_DRAWING_TOOLS::importHierLabel(), SCH_LABEL_BASE::IncrementLabel(), GENERAL_COLLECTOR::Inspect(), SCH_FIELD::IsVoid(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EAGLE_PLUGIN::loadSchematic(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_EAGLE_PLUGIN::loadSegments(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), LIB_TEXTBOX::Matches(), SCH_SHEET_PIN::Matches(), SCH_TEXT::Matches(), SCH_TEXTBOX::Matches(), DIALOG_SHEET_PIN_PROPERTIES::onComboBox(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), SCH_FIELD::operator<(), SCH_TEXT::operator<(), SCH_TEXTBOX::operator<(), LIB_FIELD::operator=(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseSchematicSymbol(), SCH_EDITOR_CONTROL::Paste(), DRAWING_TOOL::PlaceText(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), DIALOG_RESCUE_EACH::PopulateInstanceList(), LIB_FIELD::print(), DIALOG_CHANGE_SYMBOLS::processSymbol(), processTextItem(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::RecomputeIntersheetRefs(), SCH_GLOBALLABEL::ResolveTextVar(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_SEXPR_PLUGIN::saveField(), CLIPBOARD_IO::SaveSelection(), SCH_LEGACY_PLUGIN::saveSheet(), SCH_LEGACY_PLUGIN_CACHE::SaveSymbol(), SCH_LEGACY_PLUGIN::saveSymbol(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN::saveText(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveTextBox(), SCH_SEXPR_PLUGIN::saveTextBox(), SCH_EDIT_FRAME::SendSelectItemsToPcb(), SCH_SCREEN::SetLegacySymbolInstanceData(), SYMBOL_EDIT_FRAME::setupUIConditions(), SYMBOL_VIEWER_FRAME::setupUIConditions(), EE_INSPECTION_TOOL::ShowDatasheet(), SCH_SHEET::SymbolCount(), textsNeedUpdate(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), TransformBoundingBoxWithClearanceToPolygon(), SCH_EDITOR_CONTROL::updatePastedSymbol(), SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo(), and FP_TEXT::ViewGetLOD().

◆ GetTextAngle()

const EDA_ANGLE & EDA_TEXT::GetTextAngle ( ) const
inline

Definition at line 117 of file eda_text.h.

117{ return m_attributes.m_Angle; }

References TEXT_ATTRIBUTES::m_Angle, and m_attributes.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), KI_TEST::CheckFpText(), LIB_TEXTBOX::compare(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), KIGFX::SCH_PAINTER::draw(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), FP_TEXT::Flip(), FP_TEXTBOX::Flip(), PCB_TEXT::Flip(), PCB_TEXTBOX::Flip(), PCB_PLUGIN::format(), SCH_LABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), LIB_TEXTBOX::GetDrawPos(), SCH_TEXTBOX::GetDrawPos(), GetDrawRotation(), SCH_FIELD::GetDrawRotation(), FP_TEXT::GetDrawRotation(), FP_TEXTBOX::GetDrawRotation(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), hash_fp_item(), LIB_FIELD::HitTest(), LIB_TEXT::HitTest(), FP_TEXT::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), FP_TEXT::Mirror(), PCB_TEXT::Mirror(), PCB_DIMENSION_BASE::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_TEXTBOX::MirrorHorizontally(), SCH_TEXTBOX::MirrorHorizontally(), LIB_TEXT::MirrorVertical(), LIB_TEXTBOX::MirrorVertically(), SCH_TEXTBOX::MirrorVertically(), LIB_TEXT::NormalizeJustification(), KI_TEST::kitest_cmp_drawings::operator()(), EAGLE_PLUGIN::orientFPText(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), positioningChanged(), SCH_FIELD::Print(), LIB_FIELD::print(), LIB_TEXT::print(), processTextItem(), SCH_EDIT_TOOL::Rotate(), SCH_TEXTBOX::Rotate(), LIB_TEXTBOX::Rotate(), LIB_FIELD::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), FP_TEXTBOX::Rotate(), PCB_DIMENSION_BASE::Rotate(), PCB_TEXT::Rotate(), PCB_TEXTBOX::Rotate(), SCH_TEXTBOX::Rotate90(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_SEXPR_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveTextBox(), SCH_SEXPR_PLUGIN::saveTextBox(), textsNeedUpdate(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), and PCB_DIM_LEADER::updateGeometry().

◆ GetTextBox()

BOX2I EDA_TEXT::GetTextBox ( int  aLine = -1,
bool  aInvertY = false 
) const

Useful in multiline texts to calculate the full text or a line area (for zones filling, locate functions....)

Parameters
aLineThe line of text to consider. Pass -1 for all lines.
aInvertYInvert the Y axis when calculating bounding box.
Returns
the rect containing the line of text (i.e. the position and the size of one line) this rectangle is calculated for 0 orient text. If orientation is not 0 the rect must be rotated to match the physical area

Definition at line 502 of file eda_text.cpp.

503{
504 VECTOR2I drawPos = GetDrawPos();
505
507 && m_bounding_box_cache_pos == drawPos
508 && m_bounding_box_cache_line == aLine
509 && m_bounding_box_cache_inverted == aInvertY )
510 {
512 }
513
514 BOX2I bbox;
515 wxArrayString strings;
516 wxString text = GetShownText();
517 int thickness = GetEffectiveTextPenWidth();
518
519 if( IsMultilineAllowed() )
520 {
521 wxStringSplit( text, strings, '\n' );
522
523 if( strings.GetCount() ) // GetCount() == 0 for void strings with multilines allowed
524 {
525 if( aLine >= 0 && ( aLine < static_cast<int>( strings.GetCount() ) ) )
526 text = strings.Item( aLine );
527 else
528 text = strings.Item( 0 );
529 }
530 }
531
532 // calculate the H and V size
533 KIFONT::FONT* font = GetDrawFont();
534 VECTOR2D fontSize( GetTextSize() );
535 bool bold = IsBold();
536 bool italic = IsItalic();
537 VECTOR2I extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic );
538 int overbarOffset = 0;
539
540 // Creates bounding box (rectangle) for horizontal, left and top justified text. The
541 // bounding box will be moved later according to the actual text options
542 wxSize textsize = wxSize( extents.x, extents.y );
543 VECTOR2I pos = drawPos;
544
545 if( IsMultilineAllowed() && aLine > 0 && aLine < (int) strings.GetCount() )
546 pos.y -= KiROUND( aLine * font->GetInterline( fontSize.y ) );
547
548 if( text.Contains( wxT( "~{" ) ) )
549 overbarOffset = extents.y / 14;
550
551 if( aInvertY )
552 pos.y = -pos.y;
553
554 bbox.SetOrigin( pos );
555
556 // for multiline texts and aLine < 0, merge all rectangles (aLine == -1 signals all lines)
557 if( IsMultilineAllowed() && aLine < 0 && strings.GetCount() )
558 {
559 for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
560 {
561 text = strings.Item( ii );
562 extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic );
563 textsize.x = std::max( textsize.x, extents.x );
564 }
565
566 // interline spacing is only *between* lines, so total height is the height of the first
567 // line plus the interline distance (with interline spacing) for all subsequent lines
568 textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) );
569 }
570
571 bbox.SetSize( textsize );
572
573 /*
574 * At this point the rectangle origin is the text origin (m_Pos). This is correct only for
575 * left and top justified, non-mirrored, non-overbarred texts. Recalculate for all others.
576 */
577 int italicOffset = IsItalic() ? fontSize.y * ITALIC_TILT : 0;
578
579 switch( GetHorizJustify() )
580 {
582 if( IsMirrored() )
583 bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) );
584 break;
585
587 bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) / 2 );
588 break;
589
591 if( !IsMirrored() )
592 bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) );
593 break;
594 }
595
596 switch( GetVertJustify() )
597 {
599 break;
600
602 bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) / 2 );
603 break;
604
606 bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) );
607 break;
608 }
609
610 bbox.Normalize(); // Make h and v sizes always >= 0
611
613 m_bounding_box_cache_pos = drawPos;
617
618 return bbox;
619}
void SetOrigin(const Vec &pos)
Definition: box2.h:202
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
void SetX(coord_type val)
Definition: box2.h:235
void SetY(coord_type val)
Definition: box2.h:240
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetY() const
Definition: box2.h:181
coord_type GetWidth() const
Definition: box2.h:187
void SetSize(const Vec &size)
Definition: box2.h:213
coord_type GetX() const
Definition: box2.h:180
bool IsMultilineAllowed() const
Definition: eda_text.h:136
VECTOR2I m_bounding_box_cache_pos
Definition: eda_text.h:389
virtual double GetInterline(double aGlyphHeight, double aLineSpacing=1.0) const =0
Compute the distance (interline) between 2 lines of text (for multiline texts).
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic) const
Compute the boundary limits of aText (the bounding box of all shapes).
Definition: font.cpp:271
static constexpr double ITALIC_TILT
Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted ...
Definition: font.h:60
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
@ GR_TEXT_H_ALIGN_RIGHT

References GetDrawFont(), GetDrawPos(), GetEffectiveTextPenWidth(), BOX2< Vec >::GetHeight(), GetHorizJustify(), KIFONT::FONT::GetInterline(), GetShownText(), GetTextSize(), GetVertJustify(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, IsBold(), IsItalic(), IsMirrored(), IsMultilineAllowed(), ITALIC_TILT, KiROUND(), m_bounding_box_cache, m_bounding_box_cache_inverted, m_bounding_box_cache_line, m_bounding_box_cache_pos, m_bounding_box_cache_valid, BOX2< Vec >::Normalize(), BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetSize(), BOX2< Vec >::SetX(), BOX2< Vec >::SetY(), KIFONT::FONT::StringBoundaryLimits(), text, wxStringSplit(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_GLOBALLABEL::CreateGraphicShape(), KIGFX::SCH_PAINTER::draw(), SCH_LABEL::GetBodyBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), DS_DRAW_ITEM_TEXT::GetBoundingBox(), FP_TEXT::GetBoundingBox(), PCB_DIMENSION_BASE::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), LIB_TEXT::HitTest(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), LIB_TEXT::NormalizeJustification(), SCH_TEXT::Plot(), SCH_TEXT::Print(), TextHitTest(), FP_TEXT::TextHitTest(), TransformBoundingBoxWithClearanceToPolygon(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), and FP_TEXT::ViewBBox().

◆ GetTextColor()

◆ GetTextHeight()

◆ GetTextPos()

const VECTOR2I & EDA_TEXT::GetTextPos ( ) const
inline

Definition at line 198 of file eda_text.h.

198{ return m_pos; }

References m_pos.

Referenced by SCH_LABEL_BASE::AutoplaceFields(), LIB_FIELD::compare(), LIB_TEXT::compare(), SCH_SHEET_PIN::ConstrainOnEdge(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), SCH_LABEL::doIsConnected(), SCH_GLOBALLABEL::doIsConnected(), SCH_HIERLABEL::doIsConnected(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), FP_TEXT::Flip(), FP_TEXTBOX::Flip(), PCB_TEXT::Flip(), PCB_PLUGIN::format(), SCH_LABEL_BASE::GetBodyBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), FP_TEXT::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_MOVE_TOOL::getConnectedItems(), SCH_LABEL_BASE::GetConnectionPoints(), GetDrawPos(), SCH_LABEL_BASE::GetEndPoints(), SCH_SHEET_PIN::GetEndPoints(), SCH_FIELD::GetLibPosition(), LIB_FIELD::GetPosition(), LIB_TEXT::GetPosition(), SCH_FIELD::GetPosition(), SCH_TEXT::GetPosition(), DS_DRAW_ITEM_TEXT::GetPosition(), FP_TEXT::GetPosition(), PCB_TEXT::GetPosition(), LIB_FIELD::HitTest(), LIB_TEXT::HitTest(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), FP_TEXT::Mirror(), PCB_TEXT::Mirror(), PCB_DIMENSION_BASE::Mirror(), LIB_FIELD::MirrorHorizontal(), LIB_TEXT::MirrorHorizontal(), SCH_SHEET_PIN::MirrorHorizontally(), SCH_TEXT::MirrorHorizontally(), LIB_FIELD::MirrorVertical(), LIB_TEXT::MirrorVertical(), SCH_SHEET_PIN::MirrorVertically(), SCH_TEXT::MirrorVertically(), LIB_TEXT::NormalizeJustification(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), DRAWING_TOOL::PlaceText(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), LIB_FIELD::print(), SCH_LABEL_BASE::Print(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_LABEL_BASE::Rotate(), SCH_SHEET_PIN::Rotate(), SCH_TEXT::Rotate(), LIB_FIELD::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), PCB_DIMENSION_BASE::Rotate(), PCB_TEXT::Rotate(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), FP_TEXT::SetDrawCoord(), FP_TEXT::SetLocalCoord(), FP_TEXT::TextHitTest(), FP_TEXT::TransformTextShapeWithClearanceToPolygon(), PCB_TEXT::TransformTextShapeWithClearanceToPolygon(), SCH_LABEL_BASE::UpdateDanglingState(), and FP_TEXT::ViewBBox().

◆ GetTextSize()

◆ GetTextStyleName()

wxString EDA_TEXT::GetTextStyleName ( ) const
Returns
a wxString with the style name( Normal, Italic, Bold, Bold+Italic).

Definition at line 730 of file eda_text.cpp.

731{
732 int style = 0;
733
734 if( IsItalic() )
735 style = 1;
736
737 if( IsBold() )
738 style += 2;
739
740 wxString stylemsg[4] = {
741 _("Normal"),
742 _("Italic"),
743 _("Bold"),
744 _("Bold+Italic")
745 };
746
747 return stylemsg[style];
748}
#define _(s)

References _, IsBold(), and IsItalic().

Referenced by LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), and SCH_FIELD::GetMsgPanelInfo().

◆ GetTextThickness()

◆ GetTextWidth()

int EDA_TEXT::GetTextWidth ( ) const
inline

Definition at line 189 of file eda_text.h.

189{ return m_attributes.m_Size.x; }

References m_attributes, TEXT_ATTRIBUTES::m_Size, and VECTOR2< T >::x.

Referenced by LIB_FIELD::compare(), LIB_TEXT::compare(), LIB_TEXTBOX::compare(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), EDA_TEXT_DESC::EDA_TEXT_DESC(), Format(), GetEffectiveTextPenWidth(), PCB_TEXT::getKnockoutMargin(), LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_FIELD::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), SCH_HIERLABEL::GetSchematicTextOffset(), hash_fp_item(), CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols(), SCH_EAGLE_PLUGIN::loadTextAttributes(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN::saveText(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), and DIALOG_FIELD_PROPERTIES::updateText().

◆ GetVertJustify()

◆ GotoPageHref()

wxString EDA_TEXT::GotoPageHref ( const wxString &  aDestination)
static

Generate a href to a page in the current schematic.

Parameters
aDestinationDestination sheet's page number.
Returns
A hyperlink href string that goes to the specified page.

Definition at line 1000 of file eda_text.cpp.

1001{
1002 return wxT( "#" ) + aDestination;
1003}

Referenced by SCH_SHEET::Plot().

◆ HasHyperlink()

virtual bool EDA_TEXT::HasHyperlink ( ) const
inlinevirtual

◆ HasTextVars()

bool EDA_TEXT::HasTextVars ( ) const
inline

◆ IsBold()

bool EDA_TEXT::IsBold ( ) const
inline

Definition at line 123 of file eda_text.h.

123{ return m_attributes.m_Bold; }

References m_attributes, and TEXT_ATTRIBUTES::m_Bold.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), KI_TEST::CheckFpText(), LIB_TEXTBOX::compare(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), KIGFX::DS_PAINTER::draw(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), EDA_TEXT_DESC::EDA_TEXT_DESC(), Format(), GetDrawFont(), LIB_FIELD::GetDrawFont(), LIB_TEXT::GetDrawFont(), LIB_TEXTBOX::GetDrawFont(), SCH_FIELD::GetDrawFont(), SCH_TEXT::GetDrawFont(), SCH_TEXTBOX::GetDrawFont(), GetEffectiveTextPenWidth(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), FP_TEXTBOX::GetShownText(), PCB_TEXTBOX::GetShownText(), GetTextBox(), GetTextStyleName(), hash_fp_item(), IsDefaultFormatting(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), SCH_FIELD::Print(), LIB_FIELD::print(), LIB_TEXT::print(), printOneLineOfText(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), textsNeedUpdate(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ IsDefaultFormatting()

bool EDA_TEXT::IsDefaultFormatting ( ) const

◆ IsGotoPageHref()

bool EDA_TEXT::IsGotoPageHref ( const wxString &  aHref,
wxString *  aDestination = nullptr 
)
static

Check if aHref is a valid internal hyperlink.

Parameters
aHrefString to validate
aDestination[optional] pointer to populate with the destination page
Returns
true if aHref is a valid internal hyperlink. Does not check if the destination page actually exists.

Definition at line 994 of file eda_text.cpp.

995{
996 return aHref.StartsWith( wxT( "#" ), aDestination );
997}

Referenced by PDF_PLOTTER::EndPlot(), SCH_NAVIGATE_TOOL::HypertextCommand(), and ValidateHyperlink().

◆ IsItalic()

bool EDA_TEXT::IsItalic ( ) const
inline

Definition at line 120 of file eda_text.h.

120{ return m_attributes.m_Italic; }

References m_attributes, and TEXT_ATTRIBUTES::m_Italic.

Referenced by SCH_DIRECTIVE_LABEL::AutoplaceFields(), SCH_EDIT_TOOL::ChangeTextType(), KI_TEST::CheckFpText(), LIB_TEXTBOX::compare(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), KIGFX::DS_PAINTER::draw(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), EDA_TEXT_DESC::EDA_TEXT_DESC(), Format(), GetDrawFont(), LIB_FIELD::GetDrawFont(), LIB_TEXT::GetDrawFont(), LIB_TEXTBOX::GetDrawFont(), SCH_FIELD::GetDrawFont(), SCH_TEXT::GetDrawFont(), SCH_TEXTBOX::GetDrawFont(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), FP_TEXTBOX::GetShownText(), PCB_TEXTBOX::GetShownText(), GetTextBox(), GetTextStyleName(), hash_fp_item(), IsDefaultFormatting(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_FIELD::Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), SCH_FIELD::Print(), LIB_FIELD::print(), LIB_TEXT::print(), printOneLineOfText(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN::saveText(), textsNeedUpdate(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ IsKeepUpright()

bool EDA_TEXT::IsKeepUpright ( ) const
inline

◆ IsMirrored()

◆ IsMultilineAllowed()

bool EDA_TEXT::IsMultilineAllowed ( ) const
inline

◆ IsVisible()

◆ MapHorizJustify()

GR_TEXT_H_ALIGN_T EDA_TEXT::MapHorizJustify ( int  aHorizJustify)
static

Definition at line 62 of file eda_text.cpp.

63{
64 wxASSERT( aHorizJustify >= GR_TEXT_H_ALIGN_LEFT && aHorizJustify <= GR_TEXT_H_ALIGN_RIGHT );
65
66 if( aHorizJustify > GR_TEXT_H_ALIGN_RIGHT )
68
69 if( aHorizJustify < GR_TEXT_H_ALIGN_LEFT )
71
72 return static_cast<GR_TEXT_H_ALIGN_T>( aHorizJustify );
73}
GR_TEXT_H_ALIGN_T

References GR_TEXT_H_ALIGN_LEFT, and GR_TEXT_H_ALIGN_RIGHT.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ MapVertJustify()

GR_TEXT_V_ALIGN_T EDA_TEXT::MapVertJustify ( int  aVertJustify)
static

Definition at line 76 of file eda_text.cpp.

77{
78 wxASSERT( aVertJustify >= GR_TEXT_V_ALIGN_TOP && aVertJustify <= GR_TEXT_V_ALIGN_BOTTOM );
79
80 if( aVertJustify > GR_TEXT_V_ALIGN_BOTTOM )
82
83 if( aVertJustify < GR_TEXT_V_ALIGN_TOP )
85
86 return static_cast<GR_TEXT_V_ALIGN_T>( aVertJustify );
87}
GR_TEXT_V_ALIGN_T

References GR_TEXT_V_ALIGN_BOTTOM, and GR_TEXT_V_ALIGN_TOP.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ Offset()

◆ operator=()

EDA_TEXT & EDA_TEXT::operator= ( const EDA_TEXT aItem)

Definition at line 136 of file eda_text.cpp.

137{
138 m_text = aText.m_text;
139 m_shown_text = aText.m_shown_text;
140 m_shown_text_has_text_var_refs = aText.m_shown_text_has_text_var_refs;
141
142 m_attributes = aText.m_attributes;
143 m_pos = aText.m_pos;
144
145 m_render_cache_text = aText.m_render_cache_text;
146 m_render_cache_angle = aText.m_render_cache_angle;
147
148 m_render_cache.clear();
149
150 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aText.m_render_cache )
151 {
152 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
153 m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
154 }
155
156 m_bounding_box_cache_valid = aText.m_bounding_box_cache_valid;
157 m_bounding_box_cache = aText.m_bounding_box_cache;
158
159 return *this;
160}

References m_attributes, m_bounding_box_cache, m_bounding_box_cache_valid, m_pos, m_render_cache, m_render_cache_angle, m_render_cache_text, m_shown_text, m_shown_text_has_text_var_refs, and m_text.

Referenced by SCH_FIELD::operator=().

◆ Print()

void EDA_TEXT::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.

Parameters
aDCthe current Device Context.
aOffsetdraw offset (usually (0,0)).
aColortext color.
aDisplay_modeFILLED or SKETCH.

Definition at line 647 of file eda_text.cpp.

649{
650 if( IsMultilineAllowed() )
651 {
652 std::vector<VECTOR2I> positions;
653 wxArrayString strings;
654 wxStringSplit( GetShownText(), strings, '\n' );
655
656 positions.reserve( strings.Count() );
657
658 GetLinePositions( positions, strings.Count() );
659
660 for( unsigned ii = 0; ii < strings.Count(); ii++ )
661 printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
662 }
663 else
664 {
665 printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetDrawPos() );
666 }
667}
void printOneLineOfText(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aFillMode, const wxString &aText, const VECTOR2I &aPos)
Print each line of this EDA_TEXT.
Definition: eda_text.cpp:710
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:670

References GetDrawPos(), GetLinePositions(), GetShownText(), IsMultilineAllowed(), printOneLineOfText(), and wxStringSplit().

Referenced by SCH_LABEL_BASE::Print(), SCH_TEXT::Print(), SCH_TEXTBOX::Print(), and DS_DRAW_ITEM_TEXT::PrintWsItem().

◆ printOneLineOfText()

void EDA_TEXT::printOneLineOfText ( const RENDER_SETTINGS aSettings,
const VECTOR2I aOffset,
const COLOR4D aColor,
OUTLINE_MODE  aFillMode,
const wxString &  aText,
const VECTOR2I aPos 
)
private

Print each line of this EDA_TEXT.

Parameters
aOffsetdraw offset (usually (0,0)).
aColortext color.
aFillModeFILLED or SKETCH
aTextthe single line of text to draw.
aPosthe position of this line ).

Definition at line 710 of file eda_text.cpp.

713{
714 wxDC* DC = aSettings->GetPrintDC();
715 int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
716
717 if( aFillMode == SKETCH )
718 penWidth = -penWidth;
719
720 VECTOR2I size = GetTextSize();
721
722 if( IsMirrored() )
723 size.x = -size.x;
724
725 GRPrintText( DC, aOffset + aPos, aColor, aText, GetDrawRotation(), size, GetHorizJustify(),
726 GetVertJustify(), penWidth, IsItalic(), IsBold(), GetDrawFont() );
727}
int GetDefaultPenWidth() const
wxDC * GetPrintDC() const
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)
Print a graphic text through wxDC.
Definition: gr_text.cpp:129
@ SKETCH
Definition: outline_mode.h:26

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), GetDrawFont(), GetDrawRotation(), GetEffectiveTextPenWidth(), GetHorizJustify(), KIGFX::RENDER_SETTINGS::GetPrintDC(), GetTextSize(), GetVertJustify(), GRPrintText(), IsBold(), IsItalic(), IsMirrored(), SKETCH, and VECTOR2< T >::x.

Referenced by Print().

◆ RemoveHyperlink()

void EDA_TEXT::RemoveHyperlink ( )
inline

Definition at line 327 of file eda_text.h.

327{ m_hyperlink = wxEmptyString; }

References m_hyperlink.

◆ Replace()

bool EDA_TEXT::Replace ( const EDA_SEARCH_DATA aSearchData)

Helper function used in search and replace dialog.

Perform a text replace using the find and replace criteria in aSearchData.

Parameters
aSearchDataA reference to a EDA_SEARCH_DATA object containing the search and replace criteria.
Returns
True if the text item was modified, otherwise false.

Definition at line 318 of file eda_text.cpp.

319{
320 bool retval = EDA_ITEM::Replace( aSearchData, m_text );
321
323
326
327 return retval;
328}
static bool Replace(const EDA_SEARCH_DATA &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
Definition: eda_item.cpp:168

References cacheShownText(), ClearRenderCache(), m_bounding_box_cache_valid, m_text, and EDA_ITEM::Replace().

Referenced by LIB_TEXTBOX::Replace(), SCH_TEXT::Replace(), SCH_TEXTBOX::Replace(), SCH_FIELD::Replace(), and SCH_SHEET_PIN::Replace().

◆ SetAttributes() [1/2]

◆ SetAttributes() [2/2]

void EDA_TEXT::SetAttributes ( const TEXT_ATTRIBUTES aTextAttrs)
inline

Definition at line 161 of file eda_text.h.

161{ m_attributes = aTextAttrs; }

References m_attributes.

◆ SetBold()

void EDA_TEXT::SetBold ( bool  aBold)

Definition at line 209 of file eda_text.cpp.

210{
211 m_attributes.m_Bold = aBold;
214}

References ClearRenderCache(), m_attributes, TEXT_ATTRIBUTES::m_Bold, and m_bounding_box_cache_valid.

Referenced by SCH_ALTIUM_PLUGIN::AddTextBox(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), SCH_DRAWING_TOOLS::createNewText(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), DS_DRAW_ITEM_TEXT::DS_DRAW_ITEM_TEXT(), EDA_TEXT_DESC::EDA_TEXT_DESC(), ALTIUM_PCB::HelperParseDimensions6Linear(), ALTIUM_PCB::HelperParseDimensions6Radial(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), SCH_LEGACY_PLUGIN::loadSymbol(), SCH_EAGLE_PLUGIN::loadTextAttributes(), DIALOG_LABEL_PROPERTIES::OnAddField(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_ALTIUM_PLUGIN::ParseHarnessPort(), SCH_ALTIUM_PLUGIN::ParseLabel(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and DIALOG_FIELD_PROPERTIES::updateText().

◆ SetFont()

◆ SetHorizJustify()

void EDA_TEXT::SetHorizJustify ( GR_TEXT_H_ALIGN_T  aType)

Definition at line 240 of file eda_text.cpp.

241{
242 m_attributes.m_Halign = aType;
245}

References ClearRenderCache(), m_attributes, m_bounding_box_cache_valid, and TEXT_ATTRIBUTES::m_Halign.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), GRAPHICS_IMPORTER_PCBNEW::AddText(), SCH_ALTIUM_PLUGIN::AddTextBox(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), eagleToKicadAlignment(), EDA_TEXT_DESC::EDA_TEXT_DESC(), FP_TEXTBOX::FP_TEXTBOX(), ALTIUM_PCB::HelperParseDimensions6Radial(), AUTOPLACER::justifyField(), FP_TEXT::KeepUpright(), LIB_TEXTBOX::LIB_TEXTBOX(), CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), LEGACY_PLUGIN::loadMODULE_TEXT(), FABMASTER::loadOutline(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN::loadSymbol(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), SCH_EDIT_TOOL::Mirror(), FP_TEXT::Mirror(), PCB_TEXT::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_TEXTBOX::MirrorHorizontally(), SCH_TEXTBOX::MirrorHorizontally(), LIB_TEXT::MirrorVertical(), LIB_TEXTBOX::MirrorVertically(), SCH_TEXTBOX::MirrorVertically(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_ALTIUM_PLUGIN::ParseHarnessPort(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), PCB_TEXTBOX::PCB_TEXTBOX(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), LIB_TEXT::Rotate(), SCH_TEXTBOX::SCH_TEXTBOX(), PCAD2KICAD::SetTextJustify(), SCH_TEXT::SetTextSpinStyle(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ SetHyperlink()

void EDA_TEXT::SetHyperlink ( wxString  aLink)
inline

◆ SetItalic()

void EDA_TEXT::SetItalic ( bool  aItalic)

Definition at line 201 of file eda_text.cpp.

202{
203 m_attributes.m_Italic = aItalic;
206}

References ClearRenderCache(), m_attributes, m_bounding_box_cache_valid, and TEXT_ATTRIBUTES::m_Italic.

Referenced by SCH_ALTIUM_PLUGIN::AddTextBox(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), PCAD2KICAD::PCB_TEXT::AddToBoard(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), PCB_BASE_FRAME::CreateNewFootprint(), SCH_DRAWING_TOOLS::createNewText(), DRAWING_TOOL::DrawDimension(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), DS_DRAW_ITEM_TEXT::DS_DRAW_ITEM_TEXT(), EDA_TEXT_DESC::EDA_TEXT_DESC(), ALTIUM_PCB::HelperParseDimensions6Linear(), ALTIUM_PCB::HelperParseDimensions6Radial(), SCH_LEGACY_PLUGIN_CACHE::loadField(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), LEGACY_PLUGIN::loadMODULE_TEXT(), FABMASTER::loadOutline(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_LEGACY_PLUGIN::loadSymbol(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DIALOG_LABEL_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_ALTIUM_PLUGIN::ParseHarnessPort(), SCH_ALTIUM_PLUGIN::ParseLabel(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and DIALOG_FIELD_PROPERTIES::updateText().

◆ SetKeepUpright()

◆ SetLineSpacing()

void EDA_TEXT::SetLineSpacing ( double  aLineSpacing)

◆ SetMirrored()

◆ SetMultilineAllowed()

void EDA_TEXT::SetMultilineAllowed ( bool  aAllow)
Parameters
aAllowtrue if ok to use multiline option, false if ok to use only single line text. (Single line is faster in calculations than multiline.)

Definition at line 232 of file eda_text.cpp.

233{
234 m_attributes.m_Multiline = aAllow;
237}

References ClearRenderCache(), m_attributes, m_bounding_box_cache_valid, and TEXT_ATTRIBUTES::m_Multiline.

Referenced by FP_TEXTBOX::FP_TEXTBOX(), LIB_TEXTBOX::LIB_TEXTBOX(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), PCB_TEXT::PCB_TEXT(), PCB_TEXTBOX::PCB_TEXTBOX(), SCH_LABEL_BASE::SCH_LABEL_BASE(), SCH_TEXT::SCH_TEXT(), and SCH_TEXTBOX::SCH_TEXTBOX().

◆ SetText()

void EDA_TEXT::SetText ( const wxString &  aText)
virtual

Definition at line 163 of file eda_text.cpp.

164{
165 m_text = aText;
166
168
171}

References cacheShownText(), ClearRenderCache(), m_bounding_box_cache_valid, and m_text.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), SCH_EAGLE_PLUGIN::addImplicitConnections(), GRAPHICS_IMPORTER_PCBNEW::AddText(), SCH_ALTIUM_PLUGIN::AddTextBox(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), PCAD2KICAD::PCB_TEXT::AddToBoard(), FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), LIB_TEXT::Clone(), ALTIUM_PCB::ConvertTexts6ToBoardItemOnLayer(), ALTIUM_PCB::ConvertTexts6ToFootprintItemOnLayer(), createBoard(), PCB_BASE_FRAME::CreateNewFootprint(), SYMBOL_EDIT_FRAME::CreateNewSymbol(), PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems(), DRAWING_TOOL::DrawBoardCharacteristics(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), DRAWING_TOOL::DrawSpecificationStackup(), FOOTPRINT::DuplicateItem(), EDA_TEXT_DESC::EDA_TEXT_DESC(), CADSTAR_SCH_ARCHIVE_LOADER::getKiCadSchText(), SCH_SYMBOL::GetValue(), LIB_FIELD::HitTest(), SCH_LABEL_BASE::IncrementLabel(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), CADSTAR_SCH_ARCHIVE_LOADER::loadBusses(), CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets(), SCH_LEGACY_PLUGIN_CACHE::loadDocs(), SCH_LEGACY_PLUGIN_CACHE::loadField(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), FABMASTER::loadFootprints(), SCH_EAGLE_PLUGIN::loadFrame(), FABMASTER::loadGraphics(), CADSTAR_SCH_ARCHIVE_LOADER::loadHierarchicalSheetPins(), SCH_EAGLE_PLUGIN::loadInstance(), SCH_EAGLE_PLUGIN::loadLibrary(), LEGACY_PLUGIN::loadMODULE_TEXT(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), FABMASTER::loadOutline(), SCH_LEGACY_PLUGIN_CACHE::LoadPart(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_LEGACY_PLUGIN::loadSheet(), SCH_EAGLE_PLUGIN::loadSheet(), CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(), SCH_LEGACY_PLUGIN::loadSymbol(), SCH_DATABASE_PLUGIN::loadSymbolFromRow(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), SCH_SHEET_LIST::MigrateSimModelNameFields(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), DIALOG_SHEET_PROPERTIES::OnUpdateUI(), LIB_FIELD::operator=(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_ALTIUM_PLUGIN::ParseFileName(), SCH_ALTIUM_PLUGIN::ParseHarnessEntry(), SCH_ALTIUM_PLUGIN::ParseHarnessPort(), SCH_ALTIUM_PLUGIN::ParseHarnessType(), SCH_ALTIUM_PLUGIN::ParseLabel(), SCH_ALTIUM_PLUGIN::ParseParameter(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_ALTIUM_PLUGIN::ParseSheetEntry(), SCH_ALTIUM_PLUGIN::ParseSheetName(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_BASE_FRAME::PickSymbolFromLibTree(), LIB_SYMBOL::PlotLibFields(), DIALOG_CHANGE_SYMBOLS::processSymbol(), processTextItem(), SYMBOL_EDITOR_CONTROL::RenameSymbol(), SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields(), CLIPBOARD_IO::SaveSelection(), SCH_SYMBOL::SCH_SYMBOL(), LIB_SYMBOL::SetName(), FOOTPRINT::SetReference(), FOOTPRINT::SetValue(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataToWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), SCH_SYMBOL::UpdateFields(), SCH_EDITOR_CONTROL::updatePastedSymbol(), SCH_SHEET_LIST::UpdateSymbolInstances(), PCB_DIMENSION_BASE::updateText(), and SIM_PLOT_FRAME::UpdateTunerValue().

◆ SetTextAngle()

void EDA_TEXT::SetTextAngle ( const EDA_ANGLE aAngle)
virtual

Definition at line 193 of file eda_text.cpp.

194{
195 m_attributes.m_Angle = aAngle;
198}

References ClearRenderCache(), TEXT_ATTRIBUTES::m_Angle, m_attributes, and m_bounding_box_cache_valid.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), GRAPHICS_IMPORTER_PCBNEW::AddText(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), PCAD2KICAD::PCB_TEXT::AddToBoard(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), ALTIUM_PCB::ConvertTexts6ToBoardItemOnLayer(), ALTIUM_PCB::ConvertTexts6ToFootprintItemOnLayer(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), eagleToKicadAlignment(), FP_TEXT::Flip(), FP_TEXTBOX::Flip(), PCB_TEXT::Flip(), PCB_TEXTBOX::Flip(), LIB_FIELD::HitTest(), LIB_TEXT::HitTest(), LIB_FIELD::Init(), FP_TEXT::KeepUpright(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN::loadSymbol(), PCB_DIMENSION_BASE::Mirror(), DIALOG_LABEL_PROPERTIES::OnAddField(), DIALOG_SHEET_PROPERTIES::OnAddField(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_EDIT_TOOL::Rotate(), SCH_TEXTBOX::Rotate(), LIB_TEXTBOX::Rotate(), LIB_FIELD::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), FP_TEXTBOX::Rotate(), PCB_DIMENSION_BASE::Rotate(), PCB_TEXT::Rotate(), PCB_TEXTBOX::Rotate(), SCH_TEXTBOX::Rotate90(), SCH_TEXT::SetTextSpinStyle(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), PCB_DIM_ALIGNED::updateText(), PCB_DIM_ORTHOGONAL::updateText(), PCB_DIM_RADIAL::updateText(), and DIALOG_FIELD_PROPERTIES::updateText().

◆ SetTextColor()

◆ SetTextHeight()

◆ SetTextPos()

void EDA_TEXT::SetTextPos ( const VECTOR2I aPoint)

Definition at line 371 of file eda_text.cpp.

372{
373 Offset( VECTOR2I( aPoint.x - m_pos.x, aPoint.y - m_pos.y ) );
374}
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:389

References m_pos, Offset(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), GRAPHICS_IMPORTER_PCBNEW::AddText(), PCAD2KICAD::PCB_TEXT::AddToBoard(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CADSTAR_SCH_ARCHIVE_LOADER::applyToLibraryFieldAttribute(), LIB_FIELD::BeginEdit(), LIB_TEXT::BeginEdit(), LIB_FIELD::CalcEdit(), LIB_TEXT::CalcEdit(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), DS_DRAW_ITEM_TEXT::DS_DRAW_ITEM_TEXT(), FP_TEXT::FP_TEXT(), LIB_FIELD::HitTest(), LIB_TEXT::HitTest(), CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), FABMASTER::loadOutline(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN::loadSymbol(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), PCB_DIMENSION_BASE::Mirror(), LIB_FIELD::MoveTo(), LIB_TEXT::MoveTo(), LIB_TEXT::NormalizeJustification(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), SCH_SEXPR_PARSER::parseSchText(), DRAWING_TOOL::PlaceText(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_LABEL_BASE::Rotate(), SCH_SHEET_PIN::Rotate(), SCH_TEXT::Rotate(), LIB_FIELD::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), PCB_DIMENSION_BASE::Rotate(), PCB_TEXT::Rotate(), SCH_FIELD::SCH_FIELD(), SCH_SHEET_PIN::SCH_SHEET_PIN(), SCH_TEXT::SCH_TEXT(), FP_TEXT::SetDrawCoord(), DS_DRAW_ITEM_TEXT::SetPosition(), FP_TEXT::SetPosition(), PCB_TEXT::SetPosition(), SCH_FIELD::SetPosition(), SCH_TEXT::SetPosition(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), SCH_SYMBOL::UpdateFields(), PCB_DIM_ALIGNED::updateText(), and PCB_DIM_ORTHOGONAL::updateText().

◆ SetTextSize()

void EDA_TEXT::SetTextSize ( const VECTOR2I aNewSize)

Definition at line 347 of file eda_text.cpp.

348{
349 m_attributes.m_Size = aNewSize;
352}

References ClearRenderCache(), m_attributes, m_bounding_box_cache_valid, and TEXT_ATTRIBUTES::m_Size.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), SCH_EAGLE_PLUGIN::addImplicitConnections(), SCH_ALTIUM_PLUGIN::AddTextBox(), CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings(), SCH_EDIT_TOOL::ChangeTextType(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), MICROWAVE_TOOL::createBaseFootprint(), PCB_BASE_FRAME::CreateNewFootprint(), SCH_DRAWING_TOOLS::createNewText(), SCH_DRAWING_TOOLS::createSheetPin(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), DRAWING_TOOL::DrawDimension(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), DS_DRAW_ITEM_TEXT::DS_DRAW_ITEM_TEXT(), EDA_TEXT(), CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart(), ALTIUM_PCB::HelperParseDimensions6Linear(), ALTIUM_PCB::HelperParseDimensions6Radial(), LIB_TEXT::LIB_TEXT(), LIB_TEXTBOX::LIB_TEXTBOX(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), SCH_EAGLE_PLUGIN::loadFrame(), LEGACY_PLUGIN::loadMODULE_TEXT(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_LEGACY_PLUGIN::loadSheet(), SCH_LEGACY_PLUGIN::loadSymbol(), SCH_EAGLE_PLUGIN::loadTextAttributes(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DIALOG_LIB_SYMBOL_PROPERTIES::OnAddField(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_ALTIUM_PLUGIN::ParseHarnessPort(), SCH_ALTIUM_PLUGIN::ParseLabel(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BACK_ANNOTATE::processNetNameChange(), PCB_DIMENSION_BASE::SetTextSize(), PCAD2KICAD::SetTextSizeFromStrokeFontHeight(), PCAD2KICAD::SetTextSizeFromTrueTypeFontHeight(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and DIALOG_FIELD_PROPERTIES::updateText().

◆ SetTextThickness()

void EDA_TEXT::SetTextThickness ( int  aWidth)

The TextThickness is that set by the user.

The EffectiveTextPenWidth also factors in bold text and thickness clamping.

Definition at line 185 of file eda_text.cpp.

186{
190}

References ClearRenderCache(), m_attributes, m_bounding_box_cache_valid, and TEXT_ATTRIBUTES::m_StrokeWidth.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), GRAPHICS_IMPORTER_PCBNEW::AddText(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), PCAD2KICAD::PCB_TEXT::AddToBoard(), CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), MICROWAVE_TOOL::createBaseFootprint(), PCB_BASE_FRAME::CreateNewFootprint(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), DRAWING_TOOL::DrawDimension(), DS_DRAW_ITEM_TEXT::DS_DRAW_ITEM_TEXT(), EDA_TEXT_DESC::EDA_TEXT_DESC(), FP_TEXT::FP_TEXT(), ALTIUM_PCB::HelperParseDimensions6Linear(), ALTIUM_PCB::HelperParseDimensions6Radial(), CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), LEGACY_PLUGIN::loadMODULE_TEXT(), FABMASTER::loadOutline(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_EAGLE_PLUGIN::loadTextAttributes(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow().

◆ SetTextWidth()

◆ SetTextX()

◆ SetTextY()

◆ SetupRenderCache()

void EDA_TEXT::SetupRenderCache ( const wxString &  aResolvedText,
const EDA_ANGLE aAngle 
)

Definition at line 482 of file eda_text.cpp.

483{
484 m_render_cache_text = aResolvedText;
485 m_render_cache_angle = aAngle;
486 m_render_cache.clear();
487}

References m_render_cache, m_render_cache_angle, and m_render_cache_text.

◆ SetVertJustify()

void EDA_TEXT::SetVertJustify ( GR_TEXT_V_ALIGN_T  aType)

Definition at line 248 of file eda_text.cpp.

249{
250 m_attributes.m_Valign = aType;
253}

References ClearRenderCache(), m_attributes, m_bounding_box_cache_valid, and TEXT_ATTRIBUTES::m_Valign.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), GRAPHICS_IMPORTER_PCBNEW::AddText(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), ALTIUM_PCB::ConvertTexts6ToEdaTextSettings(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), eagleToKicadAlignment(), EDA_TEXT_DESC::EDA_TEXT_DESC(), FP_TEXTBOX::FP_TEXTBOX(), ALTIUM_PCB::HelperParseDimensions6Radial(), AUTOPLACER::justifyField(), LIB_TEXTBOX::LIB_TEXTBOX(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN::loadSymbol(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), SCH_EDIT_TOOL::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_TEXT::MirrorVertical(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), PCB_TEXTBOX::PCB_TEXTBOX(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), LIB_TEXT::Rotate(), SCH_GLOBALLABEL::SCH_GLOBALLABEL(), SCH_TEXTBOX::SCH_TEXTBOX(), PCAD2KICAD::SetTextJustify(), SCH_TEXT::SetTextSpinStyle(), SCH_GLOBALLABEL::SetTextSpinStyle(), SCH_HIERLABEL::SetTextSpinStyle(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ SetVisible()

void EDA_TEXT::SetVisible ( bool  aVisible)
virtual

Reimplemented in PCB_TEXT, and PCB_TEXTBOX.

Definition at line 217 of file eda_text.cpp.

218{
219 m_attributes.m_Visible = aVisible;
221}

References ClearRenderCache(), m_attributes, and TEXT_ATTRIBUTES::m_Visible.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), SCH_EDITOR_CONTROL::AssignFootprints(), SCH_EDIT_TOOL::ChangeTextType(), PCB_BASE_FRAME::CreateNewFootprint(), EDA_TEXT_DESC::EDA_TEXT_DESC(), LIB_FIELD::Init(), CADSTAR_SCH_ARCHIVE_LOADER::loadBusses(), EAGLE_PLUGIN::loadElements(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), FABMASTER::loadFootprints(), SCH_EAGLE_PLUGIN::loadInstance(), SCH_EAGLE_PLUGIN::loadLibrary(), LEGACY_PLUGIN::loadMODULE_TEXT(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), SCH_LEGACY_PLUGIN_CACHE::LoadPart(), EAGLE_PLUGIN::loadPlain(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_LEGACY_PLUGIN::loadSymbol(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolFieldAttribute(), SCH_DATABASE_PLUGIN::loadSymbolFromRow(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), DIALOG_LABEL_PROPERTIES::OnAddField(), ALTIUM_PCB::ParseComponents6Data(), SCH_ALTIUM_PLUGIN::ParseDesignator(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_ALTIUM_PLUGIN::ParseFileName(), SCH_ALTIUM_PLUGIN::ParseHarnessType(), SCH_ALTIUM_PLUGIN::ParseParameter(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_SEXPR_PARSER::parseSchText(), SCH_ALTIUM_PLUGIN::ParseSheetName(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_CHANGE_SYMBOLS::processSymbol(), processTextItem(), SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields(), SCH_FIELD::SCH_FIELD(), DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow(), and DIALOG_FIELD_PROPERTIES::updateText().

◆ SwapAttributes()

void EDA_TEXT::SwapAttributes ( EDA_TEXT aTradingPartner)

Swap the text attributes of the two involved instances.

Definition at line 284 of file eda_text.cpp.

285{
286 std::swap( m_attributes, aTradingPartner.m_attributes );
287 std::swap( m_pos, aTradingPartner.m_pos );
288
290 aTradingPartner.ClearRenderCache();
291
293 aTradingPartner.m_bounding_box_cache_valid = false;
294}

References ClearRenderCache(), m_attributes, m_bounding_box_cache_valid, and m_pos.

Referenced by SCH_FIELD::SwapData(), SCH_TEXT::SwapData(), and SCH_TEXTBOX::SwapData().

◆ SwapText()

void EDA_TEXT::SwapText ( EDA_TEXT aTradingPartner)

Definition at line 273 of file eda_text.cpp.

274{
275 std::swap( m_text, aTradingPartner.m_text );
276 std::swap( m_shown_text, aTradingPartner.m_shown_text );
278
281}

References ClearRenderCache(), m_bounding_box_cache_valid, m_shown_text, m_shown_text_has_text_var_refs, and m_text.

Referenced by SCH_FIELD::SwapData(), SCH_TEXT::SwapData(), and SCH_TEXTBOX::SwapData().

◆ TextHitTest() [1/2]

bool EDA_TEXT::TextHitTest ( const BOX2I aRect,
bool  aContains,
int  aAccuracy = 0 
) const
virtual

Test if object bounding box is contained within or intersects aRect.

Parameters
aRectRect to test against.
aContainsTest for containment instead of intersection if true.
aAccuracyAmount to inflate the bounding box.
Returns
true if a hit, else false.

Reimplemented in FP_TEXT, and PCB_TEXT.

Definition at line 634 of file eda_text.cpp.

635{
636 BOX2I rect = aRect;
637
638 rect.Inflate( aAccuracy );
639
640 if( aContains )
641 return rect.Contains( GetTextBox() );
642
643 return rect.Intersects( GetTextBox(), GetDrawRotation() );
644}
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:502

References BOX2< Vec >::Contains(), GetDrawRotation(), GetTextBox(), BOX2< Vec >::Inflate(), and BOX2< Vec >::Intersects().

◆ TextHitTest() [2/2]

bool EDA_TEXT::TextHitTest ( const VECTOR2I aPoint,
int  aAccuracy = 0 
) const
virtual

Test if aPoint is within the bounds of this object.

Parameters
aPointA VECTOR2I to test.
aAccuracyAmount to inflate the bounding box.
Returns
true if a hit, else false.

Reimplemented in FP_TEXT, and PCB_TEXT.

Definition at line 622 of file eda_text.cpp.

623{
624 BOX2I rect = GetTextBox();
625 VECTOR2I location = aPoint;
626
627 rect.Inflate( aAccuracy );
628 RotatePoint( location, GetDrawPos(), -GetDrawRotation() );
629
630 return rect.Contains( location );
631}

References BOX2< Vec >::Contains(), GetDrawPos(), GetDrawRotation(), GetTextBox(), BOX2< Vec >::Inflate(), and RotatePoint().

Referenced by LIB_FIELD::HitTest(), LIB_TEXT::HitTest(), DS_DRAW_ITEM_TEXT::HitTest(), and PCB_TEXT::TextHitTest().

◆ TransformBoundingBoxWithClearanceToPolygon()

void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon ( SHAPE_POLY_SET aCornerBuffer,
int  aClearanceValue 
) const

Convert the text bounding box to a rectangular polygon depending on the text orientation, the bounding box is not always horizontal or vertical.

Used in filling zones calculations Circles and arcs are approximated by segments

Parameters
aCornerBuffera buffer to store the polygon.
aClearanceValuethe clearance around the text bounding box to the real clearance value (usually near from 1.0).

Definition at line 939 of file eda_text.cpp.

941{
942 if( GetText().Length() == 0 )
943 return;
944
945 VECTOR2I corners[4]; // Buffer of polygon corners
946
947 BOX2I rect = GetTextBox();
948
949 // TrueType bounding boxes aren't guaranteed to include all descenders, diacriticals, etc.
950 // Since we use this for zone knockouts and DRC, we need something more accurate.
951 if( GetDrawFont()->IsOutline() )
952 rect = GetEffectiveTextShape( false, false )->BBox();
953
954 rect.Inflate( aClearanceValue );
955
956 corners[0].x = rect.GetOrigin().x;
957 corners[0].y = rect.GetOrigin().y;
958 corners[1].y = corners[0].y;
959 corners[1].x = rect.GetRight();
960 corners[2].x = corners[1].x;
961 corners[2].y = rect.GetBottom();
962 corners[3].y = corners[2].y;
963 corners[3].x = corners[0].x;
964
965 aCornerBuffer->NewOutline();
966
967 for( VECTOR2I& corner : corners )
968 {
969 RotatePoint( corner, GetDrawPos(), GetDrawRotation() );
970
971 aCornerBuffer->Append( corner.x, corner.y );
972 }
973}
const Vec & GetOrigin() const
Definition: box2.h:183
coord_type GetRight() const
Definition: box2.h:189
coord_type GetBottom() const
Definition: box2.h:190
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, bool aUseTextRotation=true) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
Definition: eda_text.cpp:847
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.

References SHAPE_POLY_SET::Append(), BOX2< Vec >::GetBottom(), GetDrawFont(), GetDrawPos(), GetDrawRotation(), GetEffectiveTextShape(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetRight(), GetText(), GetTextBox(), BOX2< Vec >::Inflate(), SHAPE_POLY_SET::NewOutline(), RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOARD_ADAPTER::addText(), KIGFX::PCB_PAINTER::draw(), BRDITEMS_PLOTTER::PlotPcbText(), PCB_TEXT::TextHitTest(), FP_TEXT::TransformShapeWithClearanceToPolygon(), and PCB_TEXT::TransformShapeWithClearanceToPolygon().

◆ ValidateHyperlink()

bool EDA_TEXT::ValidateHyperlink ( const wxString &  aURL)
static

Check if aURL is a valid hyperlink.

Parameters
aURLString to validate
Returns
true if aURL is a valid hyperlink

Definition at line 976 of file eda_text.cpp.

977{
978 if( aURL.IsEmpty() || IsGotoPageHref( aURL ) )
979 return true;
980
981 // Limit valid urls to file, http and https for now. Note wxURL doesn't support https
982 wxURI uri;
983
984 if( uri.Create( aURL ) && uri.HasScheme() )
985 {
986 wxString scheme = uri.GetScheme();
987 return scheme == wxT( "file" ) || scheme == wxT( "http" ) || scheme == wxT( "https" );
988 }
989
990 return false;
991}
static bool IsGotoPageHref(const wxString &aHref, wxString *aDestination=nullptr)
Check if aHref is a valid internal hyperlink.
Definition: eda_text.cpp:994

References IsGotoPageHref().

Referenced by SCH_SEXPR_PARSER::parseEDA_TEXT(), and DIALOG_TEXT_PROPERTIES::TransferDataFromWindow().

Member Data Documentation

◆ m_attributes

◆ m_bounding_box_cache

BOX2I EDA_TEXT::m_bounding_box_cache
mutableprivate

Definition at line 392 of file eda_text.h.

Referenced by EDA_TEXT(), GetTextBox(), and operator=().

◆ m_bounding_box_cache_inverted

bool EDA_TEXT::m_bounding_box_cache_inverted
mutableprivate

Definition at line 391 of file eda_text.h.

Referenced by EDA_TEXT(), and GetTextBox().

◆ m_bounding_box_cache_line

int EDA_TEXT::m_bounding_box_cache_line
mutableprivate

Definition at line 390 of file eda_text.h.

Referenced by EDA_TEXT(), and GetTextBox().

◆ m_bounding_box_cache_pos

VECTOR2I EDA_TEXT::m_bounding_box_cache_pos
mutableprivate

Definition at line 389 of file eda_text.h.

Referenced by GetTextBox().

◆ m_bounding_box_cache_valid

◆ m_hyperlink

wxString EDA_TEXT::m_hyperlink
protected

A hyperlink URL.

If empty, this text object is not a hyperlink.

Definition at line 359 of file eda_text.h.

Referenced by SCH_TEXT::DoHypertextAction(), SCH_TEXTBOX::DoHypertextAction(), GetHyperlink(), HasHyperlink(), RemoveHyperlink(), and SetHyperlink().

◆ m_IuScale

std::reference_wrapper<const EDA_IU_SCALE> EDA_TEXT::m_IuScale
private

Definition at line 381 of file eda_text.h.

Referenced by EDA_TEXT(), and Format().

◆ m_pos

VECTOR2I EDA_TEXT::m_pos
private

◆ m_render_cache

std::vector<std::unique_ptr<KIFONT::GLYPH> > EDA_TEXT::m_render_cache
mutableprivate

◆ m_render_cache_angle

EDA_ANGLE EDA_TEXT::m_render_cache_angle
mutableprivate

Definition at line 384 of file eda_text.h.

Referenced by EDA_TEXT(), GetRenderCache(), operator=(), and SetupRenderCache().

◆ m_render_cache_offset

VECTOR2I EDA_TEXT::m_render_cache_offset
mutableprivate

Definition at line 385 of file eda_text.h.

Referenced by GetRenderCache().

◆ m_render_cache_text

wxString EDA_TEXT::m_render_cache_text
mutableprivate

Definition at line 383 of file eda_text.h.

Referenced by EDA_TEXT(), GetRenderCache(), operator=(), and SetupRenderCache().

◆ m_shown_text

wxString EDA_TEXT::m_shown_text
private

Definition at line 378 of file eda_text.h.

Referenced by cacheShownText(), CopyText(), EDA_TEXT(), GetShownText(), operator=(), and SwapText().

◆ m_shown_text_has_text_var_refs

bool EDA_TEXT::m_shown_text_has_text_var_refs
private

Definition at line 379 of file eda_text.h.

Referenced by cacheShownText(), CopyText(), EDA_TEXT(), HasTextVars(), operator=(), and SwapText().

◆ m_text

wxString EDA_TEXT::m_text
private

The documentation for this class was generated from the following files: