KiCad PCB EDA Suite
EDA_TEXT Class Reference

Class EDA_TEXT is 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:
LIB_FIELD LIB_TEXT SCH_FIELD SCH_TEXT TEXTE_MODULE TEXTE_PCB WS_DRAW_ITEM_TEXT SCH_GLOBALLABEL SCH_HIERLABEL SCH_LABEL SCH_SHEET_PIN

Public Member Functions

 EDA_TEXT (const wxString &text=wxEmptyString)
 
 EDA_TEXT (const EDA_TEXT &aText)
 
virtual ~EDA_TEXT ()
 
virtual const wxString & GetText () const
 Function GetText returns the string associated with the text object. More...
 
virtual wxString GetShownText () const
 Returns the string actually shown after processing of the base text. More...
 
wxString ShortenedShownText () const
 Returns a shortened version (max 15 characters) of the shown text. More...
 
virtual void SetText (const wxString &aText)
 
void SetThickness (int aNewThickness)
 Function SetThickness sets pen width. More...
 
int GetThickness () const
 Function GetThickness returns pen width. More...
 
void SetTextAngle (double aAngle)
 
double GetTextAngle () const
 
double GetTextAngleDegrees () const
 
double GetTextAngleRadians () const
 
void SetItalic (bool isItalic)
 
bool IsItalic () const
 
void SetBold (bool aBold)
 
bool IsBold () const
 
void SetVisible (bool aVisible)
 
bool IsVisible () const
 
void SetMirrored (bool isMirrored)
 
bool IsMirrored () const
 
void SetMultilineAllowed (bool aAllow)
 Function SetMultiLineAllowed. More...
 
bool IsMultilineAllowed () const
 
EDA_TEXT_HJUSTIFY_T GetHorizJustify () const
 
EDA_TEXT_VJUSTIFY_T GetVertJustify () const
 
void SetHorizJustify (EDA_TEXT_HJUSTIFY_T aType)
 
void SetVertJustify (EDA_TEXT_VJUSTIFY_T aType)
 
void SetEffects (const EDA_TEXT &aSrc)
 Function SetEffects sets the text effects from another instance. More...
 
void SwapEffects (EDA_TEXT &aTradingPartner)
 Function SwapEffects swaps the text effects of the two involved instances. More...
 
bool IsDefaultFormatting () const
 
void SetTextSize (const wxSize &aNewSize)
 
const wxSize & GetTextSize () const
 
void SetTextWidth (int aWidth)
 
int GetTextWidth () const
 
void SetTextHeight (int aHeight)
 
int GetTextHeight () const
 
void SetTextPos (const wxPoint &aPoint)
 
const wxPoint & GetTextPos () const
 
void SetTextX (int aX)
 
void SetTextY (int aY)
 
void Offset (const wxPoint &aOffset)
 
void Empty ()
 
void Print (wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aDisplay_mode=FILLED)
 Function Print. More...
 
void TransformTextShapeToSegmentList (std::vector< wxPoint > &aCornerBuffer) const
 Convert the text shape to a list of segment each segment is stored as 2 wxPoints: the starting point and the ending point there are therefore 2*n points. More...
 
void TransformBoundingBoxWithClearanceToPolygon (SHAPE_POLY_SET *aCornerBuffer, int aClearanceValue) const
 Function TransformBoundingBoxWithClearanceToPolygon 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. More...
 
virtual bool TextHitTest (const wxPoint &aPoint, int aAccuracy=0) const
 Function TextHitTest Test if aPoint is within the bounds of this object. More...
 
virtual bool TextHitTest (const EDA_RECT &aRect, bool aContains, int aAccuracy=0) const
 Function TextHitTest (overloaded) Tests if object bounding box is contained within or intersects aRect. More...
 
int LenSize (const wxString &aLine, int aThickness) const
 Function LenSize. More...
 
EDA_RECT GetTextBox (int aLine=-1, int aThickness=-1, bool aInvertY=false) const
 Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones filling, locate functions....) More...
 
int GetInterline (int aTextThickness=-1) const
 Return the distance between two lines of text. More...
 
wxString GetTextStyleName ()
 Function GetTextStyleName. More...
 
void GetPositionsOfLinesOfMultilineText (std::vector< wxPoint > &aPositions, int aLineCount) const
 Function GetPositionsOfLinesOfMultilineText Populates 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
 Function Format outputs the object to aFormatter in s-expression form. More...
 

Static Public Member Functions

static int MapOrientation (KICAD_T labelType, int aOrientation)
 
static EDA_TEXT_HJUSTIFY_T MapHorizJustify (int aHorizJustify)
 
static EDA_TEXT_VJUSTIFY_T MapVertJustify (int aVertJustify)
 

Protected Attributes

wxString m_Text
 
wxString m_shown_text
 Cache of unescaped text for efficient access. More...
 

Private Types

enum  TE_FLAGS {
  TE_MIRROR, TE_ITALIC, TE_BOLD, TE_MULTILINE,
  TE_VISIBLE
}
 EDA_TEXT effects bools. More...
 

Private Member Functions

void printOneLineOfText (wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aFillMode, const wxString &aText, const wxPoint &aPos)
 Function printOneLineOfText Used to print each line of this EDA_TEXT, that can be multiline. More...
 

Private Attributes

TEXT_EFFECTS m_e
 

Detailed Description

Class EDA_TEXT is 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 109 of file eda_text.h.

Member Enumeration Documentation

◆ TE_FLAGS

enum EDA_TEXT::TE_FLAGS
private

EDA_TEXT effects bools.

Enumerator
TE_MIRROR 
TE_ITALIC 
TE_BOLD 
TE_MULTILINE 
TE_VISIBLE 

Definition at line 380 of file eda_text.h.

380  {
381  // start at zero, sequence is irrelevant
382  TE_MIRROR,
383  TE_ITALIC,
384  TE_BOLD,
385  TE_MULTILINE,
386  TE_VISIBLE,
387  };

Constructor & Destructor Documentation

◆ EDA_TEXT() [1/2]

EDA_TEXT::EDA_TEXT ( const wxString &  text = wxEmptyString)

Definition at line 89 of file eda_text.cpp.

89  :
90  m_Text( text ),
91  m_e( 1<<TE_VISIBLE )
92 {
93  int sz = Mils2iu( DEFAULT_SIZE_TEXT );
94  SetTextSize( wxSize( sz, sz ) );
95  m_shown_text = UnescapeString( text );
96 }
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
Definition: eda_text.h:69
wxString m_Text
Definition: eda_text.h:356
wxString m_shown_text
Cache of unescaped text for efficient access.
Definition: eda_text.h:359
TEXT_EFFECTS m_e
Definition: eda_text.h:377
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:208
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123

References DEFAULT_SIZE_TEXT, m_shown_text, SetTextSize(), and UnescapeString().

◆ EDA_TEXT() [2/2]

EDA_TEXT::EDA_TEXT ( const EDA_TEXT aText)

Definition at line 99 of file eda_text.cpp.

99  :
100  m_Text( aText.m_Text ),
101  m_e( aText.m_e )
102 {
104 }
wxString m_Text
Definition: eda_text.h:356
wxString m_shown_text
Cache of unescaped text for efficient access.
Definition: eda_text.h:359
TEXT_EFFECTS m_e
Definition: eda_text.h:377
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123

References m_shown_text, m_Text, and UnescapeString().

◆ ~EDA_TEXT()

EDA_TEXT::~EDA_TEXT ( )
virtual

Definition at line 107 of file eda_text.cpp.

108 {
109 }

Member Function Documentation

◆ Empty()

void EDA_TEXT::Empty ( )
inline

Definition at line 225 of file eda_text.h.

225 { m_Text.Empty(); }
wxString m_Text
Definition: eda_text.h:356

References m_Text.

Referenced by SCH_LEGACY_PLUGIN_CACHE::LoadPart().

◆ Format()

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

Function Format outputs 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 463 of file eda_text.cpp.

464 {
465 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
466  // and does not define FormatInternalUnits, used here
467  // however this function should exist
468 
469  aFormatter->Print( aNestLevel + 1, "(effects" );
470 
471  // Text size
472  aFormatter->Print( 0, " (font" );
473 
474  aFormatter->Print( 0, " (size %s %s)",
475  FormatInternalUnits( GetTextHeight() ).c_str(),
476  FormatInternalUnits( GetTextWidth() ).c_str() );
477 
478  if( GetThickness() )
479  aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetThickness() ).c_str() );
480 
481  if( IsBold() )
482  aFormatter->Print( 0, " bold" );
483 
484  if( IsItalic() )
485  aFormatter->Print( 0, " italic" );
486 
487  aFormatter->Print( 0, ")"); // (font
488 
489  if( IsMirrored() ||
492  {
493  aFormatter->Print( 0, " (justify");
494 
496  aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
497 
499  aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
500 
501  if( IsMirrored() )
502  aFormatter->Print( 0, " mirror" );
503  aFormatter->Print( 0, ")" ); // (justify
504  }
505 
506  if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
507  aFormatter->Print( 0, " hide" );
508 
509  aFormatter->Print( 0, ")\n" ); // (justify
510 
511 #endif
512 }
bool IsBold() const
Definition: eda_text.h:167
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
bool IsMirrored() const
Definition: eda_text.h:173
bool IsVisible() const
Definition: eda_text.h:170
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
int GetTextHeight() const
Definition: eda_text.h:215
bool IsItalic() const
Definition: eda_text.h:164
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
int GetTextWidth() const
Definition: eda_text.h:212
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
#define CTL_OMIT_HIDE
Definition: eda_text.h:39
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:465

References CTL_OMIT_HIDE, FormatInternalUnits(), GetHorizJustify(), GetTextHeight(), GetTextWidth(), GetThickness(), GetVertJustify(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, IsBold(), IsItalic(), IsMirrored(), IsVisible(), and OUTPUTFORMATTER::Print().

◆ GetHorizJustify()

EDA_TEXT_HJUSTIFY_T EDA_TEXT::GetHorizJustify ( ) const
inline

Definition at line 184 of file eda_text.h.

184 { return EDA_TEXT_HJUSTIFY_T( m_e.hjustify ); };
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:44
TEXT_EFFECTS m_e
Definition: eda_text.h:377
signed char hjustify
horizontal justification
Definition: eda_text.h:90

References TEXT_EFFECTS::hjustify, and m_e.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::SCH_PAINTER::draw(), export_vrml_pcbtext(), export_vrml_text_module(), AUTOPLACER::field_horiz_placement(), TEXTE_PCB::Flip(), TEXTE_MODULE::Flip(), Format(), GetTextBox(), hash_eda(), IsDefaultFormatting(), SCH_FIELD::IsHorizJustifyFlipped(), TEXTE_MODULE::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EDIT_TOOL::Mirror(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), LIB_FIELD::print(), TEXTE_MODULE::Print(), printOneLineOfText(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), KIGFX::GAL::SetTextAttributes(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), TransformTextShapeToSegmentList(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ GetInterline()

int EDA_TEXT::GetInterline ( int  aTextThickness = -1) 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.

Parameters
aTextThicknessOverrides the current thickness when greater than 0. this is needed when the current m_Thickness is 0 and a default line thickness is used

Definition at line 159 of file eda_text.cpp.

160 {
161  int thickness = aTextThickness <= 0 ? GetThickness() : aTextThickness;
162 
163  return KiROUND( KIGFX::STROKE_FONT::GetInterline( GetTextHeight(), thickness ) );
164 }
static double GetInterline(double aGlyphHeight, double aGlyphThickness)
Compute the distance (interline) between 2 lines of text (for multiline texts).
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
int GetTextHeight() const
Definition: eda_text.h:215

References KIGFX::STROKE_FONT::GetInterline(), GetTextHeight(), GetThickness(), and KiROUND().

Referenced by GetPositionsOfLinesOfMultilineText(), and GetTextBox().

◆ GetPositionsOfLinesOfMultilineText()

void EDA_TEXT::GetPositionsOfLinesOfMultilineText ( std::vector< wxPoint > &  aPositions,
int  aLineCount 
) const

Function GetPositionsOfLinesOfMultilineText Populates 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 wxPoint positions
aLineCountis the number of lines (not recalculated here for efficiency reasons

Definition at line 367 of file eda_text.cpp.

369 {
370  wxPoint pos = GetTextPos(); // Position of first line of the
371  // multiline text according to
372  // the center of the multiline text block
373 
374  wxPoint offset; // Offset to next line.
375 
376  offset.y = GetInterline();
377 
378  if( aLineCount > 1 )
379  {
380  switch( GetVertJustify() )
381  {
383  break;
384 
386  pos.y -= ( aLineCount - 1 ) * offset.y / 2;
387  break;
388 
390  pos.y -= ( aLineCount - 1 ) * offset.y;
391  break;
392  }
393  }
394 
395  // Rotate the position of the first line
396  // around the center of the multiline text block
397  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
398 
399  // Rotate the offset lines to increase happened in the right direction
400  RotatePoint( &offset, GetTextAngle() );
401 
402  for( int ii = 0; ii < aLineCount; ii++ )
403  {
404  aPositions.push_back( pos );
405  pos += offset;
406  }
407 }
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
int GetInterline(int aTextThickness=-1) const
Return the distance between two lines of text.
Definition: eda_text.cpp:159
double GetTextAngle() const
Definition: eda_text.h:158
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
const wxPoint & GetTextPos() const
Definition: eda_text.h:218

References GetInterline(), GetTextAngle(), GetTextPos(), GetVertJustify(), GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, and RotatePoint().

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), export_vrml_pcbtext(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), Print(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), and TransformTextShapeToSegmentList().

◆ GetShownText()

◆ GetText()

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

Function GetText returns the string associated with the text object.

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

Definition at line 124 of file eda_text.h.

124 { return m_Text; }
wxString m_Text
Definition: eda_text.h:356

References m_Text.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), SCH_EAGLE_PLUGIN::addImplicitConnections(), SIM_PLOT_FRAME::AddTuner(), SCH_EDITOR_CONTROL::BackAnnotateFootprints(), SCH_SHEET::CleanupSheet(), SCH_REFERENCE::CompareValue(), SCH_SHEET::ComponentCount(), SCH_EDIT_FRAME::ConvertTextType(), CreateComponentsSection(), SCH_EDIT_FRAME::CreateNewText(), SCH_EDIT_FRAME::CreateSheetPin(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::SCH_PAINTER::draw(), PCB_IO::format(), FormatProbeItem(), LIB_FIELD::GetFullText(), getMatchingTextItem(), SCH_COMPONENT::GetRef(), LIB_ALIAS::GetSearchText(), NETLIST_EXPORTER_PSPICE::GetSpiceField(), NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(), DIMENSION::GetText(), TEXT_MOD_GRID_TABLE::GetValue(), hash_eda(), SCH_SHEET::HasUndefinedPins(), LIB_FIELD::HitTest(), SCH_EDIT_FRAME::ImportHierLabel(), GENERAL_COLLECTOR::Inspect(), SCH_SCREEN::IsTerminalPoint(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EAGLE_PLUGIN::loadSchematic(), SCH_EAGLE_PLUGIN::loadSegments(), SCH_COMPONENT::operator==(), PCB_PARSER::parseDIMENSION(), DRAWING_TOOL::PlaceText(), LIB_TEXT::Plot(), BRDITEMS_PLOTTER::PlotAllTextsModule(), DIALOG_RESCUE_EACH::PopulateInstanceList(), TEXTE_MODULE::Print(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), processTextItem(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::SaveSymbol(), SCH_LEGACY_PLUGIN::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_COMPONENT::SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), SCH_COMPONENT::SetRef(), EE_INSPECTION_TOOL::ShowDatasheet(), SCH_REFERENCE_LIST::sortByReferenceOnly(), TestMultiunitFootprints(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), DIALOG_SCH_EDIT_SHEET_PIN::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), TransformBoundingBoxWithClearanceToPolygon(), TransformTextShapeToSegmentList(), TUNER_SLIDER::TUNER_SLIDER(), DIALOG_UPDATE_FIELDS::updateFields(), SCH_COMPONENT::UpdateFields(), DIALOG_FOOTPRINT_FP_EDITOR::Validate(), DIALOG_FOOTPRINT_BOARD_EDITOR::Validate(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ GetTextAngle()

double EDA_TEXT::GetTextAngle ( ) const
inline

Definition at line 158 of file eda_text.h.

158 { return m_e.angle; }
TEXT_EFFECTS m_e
Definition: eda_text.h:377
double angle
now: 0.1 degrees; future: degrees
Definition: eda_text.h:94

References TEXT_EFFECTS::angle, and m_e.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), CreateComponentsSection(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::WS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), export_vrml_pcbtext(), TEXTE_MODULE::Flip(), PCB_IO::format(), LIB_TEXT::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), TEXTE_MODULE::GetDrawRotation(), TEXTE_PCB::GetMsgPanelInfo(), GetPositionsOfLinesOfMultilineText(), GetTextAngleDegrees(), GetTextAngleRadians(), TEXT_MOD_GRID_TABLE::GetValue(), hash_eda(), LIB_TEXT::HitTest(), LIB_FIELD::HitTest(), TEXTE_MODULE::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), DIMENSION::Mirror(), EAGLE_PLUGIN::orientModuleText(), PCB_PARSER::parseMODULE_unchecked(), LIB_TEXT::Plot(), SCH_FIELD::Plot(), SCH_TEXT::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), PlotWorkSheet(), LIB_TEXT::print(), LIB_FIELD::print(), SCH_FIELD::Print(), printOneLineOfText(), SCH_EDIT_TOOL::Rotate(), TEXTE_PCB::Rotate(), LIB_TEXT::Rotate(), TEXTE_MODULE::Rotate(), LIB_FIELD::Rotate(), DIMENSION::Rotate(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::SetComponentFootprint(), TextHitTest(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), TransformBoundingBoxWithClearanceToPolygon(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), TransformTextShapeToSegmentList(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ GetTextAngleDegrees()

double EDA_TEXT::GetTextAngleDegrees ( ) const
inline

Definition at line 160 of file eda_text.h.

160 { return GetTextAngle() / 10.0; }
double GetTextAngle() const
Definition: eda_text.h:158

References GetTextAngle().

Referenced by TEXTE_MODULE::GetMsgPanelInfo(), and DIALOG_TEXT_PROPERTIES::TransferDataToWindow().

◆ GetTextAngleRadians()

double EDA_TEXT::GetTextAngleRadians ( ) const
inline

Definition at line 161 of file eda_text.h.

161 { return GetTextAngle() * M_PI/1800; }
double GetTextAngle() const
Definition: eda_text.h:158

References GetTextAngle().

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

◆ GetTextBox()

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

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

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
Parameters
aLineThe line of text to consider. for single line text, aLine is unused If aLine == -1, the full area (considering all lines) is returned
aThicknessOverrides the current penwidth when greater than 0. This is needed when the current penwidth is 0 and a default penwidth is used.
aInvertYInvert the Y axis when calculating bounding box.

Definition at line 167 of file eda_text.cpp.

168 {
169  EDA_RECT rect;
170  wxArrayString strings;
171  wxString text = GetShownText();
172  int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness;
173  int linecount = 1;
174  bool hasOverBar = false; // true if the first line of text as an overbar
175 
176  if( IsMultilineAllowed() )
177  {
178  wxStringSplit( text, strings, '\n' );
179 
180  if( strings.GetCount() ) // GetCount() == 0 for void strings
181  {
182  if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
183  text = strings.Item( aLine );
184  else
185  text = strings.Item( 0 );
186 
187  linecount = strings.GetCount();
188  }
189  }
190 
191  // Search for overbar symbol. Only text is scanned,
192  // because only this line can change the bounding box
193  for( unsigned ii = 1; ii < text.size(); ii++ )
194  {
195  if( text[ii-1] == '~' && text[ii] != '~' )
196  {
197  hasOverBar = true;
198  break;
199  }
200  }
201 
202  // calculate the H and V size
204  text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
205  int dy = GetInterline( thickness );
206 
207  // Creates bounding box (rectangle) for an horizontal
208  // and left and top justified text. the bounding box will be moved later
209  // according to the actual text options
210  wxSize textsize = wxSize( dx, dy );
211  wxPoint pos = GetTextPos();
212 
213  if( aInvertY )
214  pos.y = -pos.y;
215 
216  rect.SetOrigin( pos );
217 
218  // The bbox vertical size returned by GetInterline( aThickness )
219  // includes letters like j and y and ] + interval between lines.
220  // The interval below the last line is not usefull, and we can use its half value
221  // as vertical margin above the text
222  // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
223  rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
224 
225  if( hasOverBar )
226  { // A overbar adds an extra size to the text
227  // Height from the base line text of chars like [ or {
228  double curr_height = GetTextHeight() * 1.15;
229  int extra_height = KiROUND(
230  basic_gal.GetStrokeFont().ComputeOverbarVerticalPosition( GetTextHeight(), thickness ) - curr_height );
231  extra_height += thickness/2;
232  textsize.y += extra_height;
233  rect.Move( wxPoint( 0, -extra_height ) );
234  }
235 
236  // for multiline texts and aLine < 0, merge all rectangles
237  // ( if aLine < 0, we want the full text bounding box )
238  if( IsMultilineAllowed() && aLine < 0 )
239  {
240  for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
241  {
242  text = strings.Item( ii );
244  text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
245  textsize.x = std::max( textsize.x, dx );
246  textsize.y += dy;
247  }
248  }
249 
250  rect.SetSize( textsize );
251 
252  /* Now, calculate the rect origin, according to text justification
253  * At this point the rectangle origin is the text origin (m_Pos).
254  * This is true only for left and top text justified texts (using top to bottom Y axis
255  * orientation). and must be recalculated for others justifications
256  * also, note the V justification is relative to the first line
257  */
258  switch( GetHorizJustify() )
259  {
261  if( IsMirrored() )
262  rect.SetX( rect.GetX() - rect.GetWidth() );
263  break;
264 
266  rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
267  break;
268 
270  if( !IsMirrored() )
271  rect.SetX( rect.GetX() - rect.GetWidth() );
272  break;
273  }
274 
275  dy = GetTextHeight() + thickness;
276 
277  switch( GetVertJustify() )
278  {
280  break;
281 
283  rect.SetY( rect.GetY() - ( dy / 2) );
284  break;
285 
287  rect.SetY( rect.GetY() - dy );
288  break;
289  }
290 
291  if( linecount > 1 )
292  {
293  int yoffset;
294  linecount -= 1;
295 
296  switch( GetVertJustify() )
297  {
299  break;
300 
302  yoffset = linecount * GetInterline() / 2;
303  rect.SetY( rect.GetY() - yoffset );
304  break;
305 
307  yoffset = linecount * GetInterline( aThickness );
308  rect.SetY( rect.GetY() - yoffset );
309  break;
310  }
311  }
312 
313  rect.Normalize(); // Make h and v sizes always >= 0
314 
315  return rect;
316 }
const STROKE_FONT & GetStrokeFont() const
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:188
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
bool IsMirrored() const
Definition: eda_text.h:173
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
int GetX() const
Definition: eda_rect.h:109
int GetInterline(int aTextThickness=-1) const
Return the distance between two lines of text.
Definition: eda_text.cpp:159
int GetWidth() const
Definition: eda_rect.h:117
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
int GetTextHeight() const
Definition: eda_text.h:215
double ComputeOverbarVerticalPosition(double aGlyphHeight, double aGlyphThickness) const
Compute the vertical position of an overbar, sometimes used in texts.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const wxSize & GetTextSize() const
Definition: eda_text.h:209
void SetX(int val)
Definition: eda_rect.h:130
VECTOR2D ComputeStringBoundaryLimits(const UTF8 &aText, const VECTOR2D &aGlyphSize, double aGlyphThickness) const
Compute the boundary limits of aText (the bounding box of all shapes).
bool IsMultilineAllowed() const
Definition: eda_text.h:182
void SetY(int val)
Definition: eda_rect.h:131
void Normalize()
Function Normalize ensures that the height ant width are positive.
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
int GetY() const
Definition: eda_rect.h:110
const wxPoint & GetTextPos() const
Definition: eda_text.h:218
BASIC_GAL basic_gal(basic_displayOptions)
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129

References basic_gal, KIGFX::STROKE_FONT::ComputeOverbarVerticalPosition(), KIGFX::STROKE_FONT::ComputeStringBoundaryLimits(), GetHorizJustify(), GetInterline(), GetShownText(), KIGFX::GAL::GetStrokeFont(), GetTextHeight(), GetTextPos(), GetTextSize(), GetThickness(), GetVertJustify(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, IsMirrored(), IsMultilineAllowed(), KiROUND(), max, EDA_RECT::Move(), EDA_RECT::Normalize(), EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), EDA_RECT::SetX(), EDA_RECT::SetY(), wxStringSplit(), and VECTOR2< T >::x.

Referenced by TEXTE_PCB::Flip(), LIB_TEXT::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), TEXTE_MODULE::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), DIMENSION::GetBoundingBox(), WS_DRAW_ITEM_TEXT::GetBoundingBox(), DRC::testCopperTextItem(), TEXTE_MODULE::TextHitTest(), TextHitTest(), TransformBoundingBoxWithClearanceToPolygon(), and TEXTE_MODULE::ViewBBox().

◆ GetTextHeight()

◆ GetTextPos()

const wxPoint& EDA_TEXT::GetTextPos ( ) const
inline

Definition at line 218 of file eda_text.h.

218 { return m_e.pos; }
TEXT_EFFECTS m_e
Definition: eda_text.h:377
wxPoint pos
Definition: eda_text.h:95

References m_e, and TEXT_EFFECTS::pos.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), LIB_TEXT::compare(), LIB_FIELD::compare(), SCH_SHEET_PIN::ConstrainOnEdge(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), SCH_LABEL::doIsConnected(), SCH_GLOBALLABEL::doIsConnected(), SCH_HIERLABEL::doIsConnected(), KIGFX::WS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), export_vrml_pcbtext(), export_vrml_text_module(), TEXTE_PCB::Flip(), TEXTE_MODULE::Flip(), PCB_IO::format(), LIB_TEXT::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), TEXTE_MODULE::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), SCH_GLOBALLABEL::GetBoundingBox(), SCH_HIERLABEL::GetBoundingBox(), SCH_TEXT::GetConnectionPoints(), SCH_TEXT::GetEndPoints(), SCH_SHEET_PIN::GetEndPoints(), SCH_FIELD::GetLibPosition(), SCH_TEXT::GetNetListItem(), TEXTE_PCB::GetPosition(), TEXTE_MODULE::GetPosition(), DIMENSION::GetPosition(), LIB_TEXT::GetPosition(), SCH_FIELD::GetPosition(), SCH_TEXT::GetPosition(), LIB_FIELD::GetPosition(), WS_DRAW_ITEM_TEXT::GetPosition(), GetPositionsOfLinesOfMultilineText(), WS_DRAW_ITEM_TEXT::GetSelectMenuText(), GetTextBox(), LIB_TEXT::HitTest(), LIB_FIELD::HitTest(), TEXTE_MODULE::Mirror(), DIMENSION::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_FIELD::MirrorHorizontal(), LIB_TEXT::MirrorVertical(), LIB_FIELD::MirrorVertical(), SCH_TEXT::MirrorX(), SCH_SHEET_PIN::MirrorX(), SCH_COMPONENT::MirrorX(), SCH_TEXT::MirrorY(), SCH_SHEET_PIN::MirrorY(), SCH_COMPONENT::MirrorY(), PCB_PARSER::parseDIMENSION(), DRAWING_TOOL::PlaceText(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), LIB_FIELD::print(), TEXTE_MODULE::Print(), Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), TEXTE_PCB::Rotate(), LIB_TEXT::Rotate(), TEXTE_MODULE::Rotate(), SCH_FIELD::Rotate(), SCH_TEXT::Rotate(), SCH_SHEET_PIN::Rotate(), LIB_FIELD::Rotate(), DIMENSION::Rotate(), SCH_COMPONENT::Rotate(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::SetComponentFootprint(), TEXTE_MODULE::SetDrawCoord(), TEXTE_MODULE::SetLocalCoord(), SCH_COMPONENT::SetRef(), TEXTE_MODULE::TextHitTest(), TextHitTest(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), TransformBoundingBoxWithClearanceToPolygon(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), TransformTextShapeToSegmentList(), SCH_TEXT::UpdateDanglingState(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), DIALOG_UPDATE_FIELDS::updateFields(), and TEXTE_MODULE::ViewBBox().

◆ GetTextSize()

const wxSize& EDA_TEXT::GetTextSize ( ) const
inline

Definition at line 209 of file eda_text.h.

209 { return m_e.size; };
TEXT_EFFECTS m_e
Definition: eda_text.h:377
wxSize size
Definition: eda_text.h:92

References m_e, and TEXT_EFFECTS::size.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), SCH_EDIT_FRAME::ConvertTextType(), SCH_GLOBALLABEL::CreateGraphicShape(), MWAVE::CreateMicrowaveInductor(), SCH_EDIT_FRAME::CreateSheetPin(), KIGFX::SCH_PAINTER::draw(), export_vrml_pcbtext(), export_vrml_text_module(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_TEXT::GetPenSize(), LIB_FIELD::GetPenSize(), SCH_FIELD::GetPenSize(), SCH_TEXT::GetPenSize(), SCH_GLOBALLABEL::GetSchematicTextOffset(), GetTextBox(), LenSize(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), EAGLE_PLUGIN::orientModuleText(), LIB_TEXT::Plot(), SCH_FIELD::Plot(), SCH_TEXT::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), LIB_TEXT::print(), LIB_FIELD::print(), SCH_TEXT::Print(), SCH_FIELD::Print(), TEXTE_MODULE::Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), printOneLineOfText(), SCH_SCREEN::SetComponentFootprint(), KIGFX::GAL::SetTextAttributes(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), TransformTextShapeToSegmentList(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ GetTextStyleName()

wxString EDA_TEXT::GetTextStyleName ( )

Function GetTextStyleName.

Returns
a wxString with the style name( Normal, Italic, Bold, Bold+Italic)

Definition at line 428 of file eda_text.cpp.

429 {
430  int style = 0;
431 
432  if( IsItalic() )
433  style = 1;
434 
435  if( IsBold() )
436  style += 2;
437 
438  wxString stylemsg[4] = {
439  _("Normal"),
440  _("Italic"),
441  _("Bold"),
442  _("Bold+Italic")
443  };
444 
445  return stylemsg[style];
446 }
bool IsBold() const
Definition: eda_text.h:167
bool IsItalic() const
Definition: eda_text.h:164
#define _(s)

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

Referenced by LIB_FIELD::GetMsgPanelInfo().

◆ GetTextWidth()

◆ GetThickness()

int EDA_TEXT::GetThickness ( ) const
inline

Function GetThickness returns pen width.

Definition at line 148 of file eda_text.h.

148 { return m_e.penwidth; };
TEXT_EFFECTS m_e
Definition: eda_text.h:377
int penwidth
Definition: eda_text.h:93

References m_e, and TEXT_EFFECTS::penwidth.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), DIMENSION::AdjustDimensionDetails(), SCH_EDIT_FRAME::ConvertTextType(), SCH_GLOBALLABEL::CreateGraphicShape(), KIGFX::WS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), export_vrml_pcbtext(), export_vrml_text_module(), Format(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), SCH_GLOBALLABEL::GetBoundingBox(), SCH_HIERLABEL::GetBoundingBox(), GetInterline(), TEXTE_PCB::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), TEXTE_MODULE::GetMsgPanelInfo(), LIB_TEXT::GetPenSize(), LIB_FIELD::GetPenSize(), SCH_FIELD::GetPenSize(), SCH_TEXT::GetPenSize(), WS_DRAW_ITEM_TEXT::GetPenWidth(), SCH_GLOBALLABEL::GetSchematicTextOffset(), SCH_HIERLABEL::GetSchematicTextOffset(), GetTextBox(), TEXT_MOD_GRID_TABLE::GetValue(), LIB_TEXT::GetWidth(), LIB_FIELD::GetWidth(), IsDefaultFormatting(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), SCH_TEXT::Print(), SCH_FIELD::Print(), TEXTE_MODULE::Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), printOneLineOfText(), SCH_LEGACY_PLUGIN::saveText(), PNS_KICAD_IFACE::syncTextItem(), DRC::testCopperTextItem(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), and TransformTextShapeToSegmentList().

◆ GetVertJustify()

◆ IsBold()

◆ IsDefaultFormatting()

bool EDA_TEXT::IsDefaultFormatting ( ) const

Definition at line 449 of file eda_text.cpp.

450 {
451  return ( IsVisible()
452  && !IsMirrored()
455  && GetThickness() == 0
456  && !IsItalic()
457  && !IsBold()
458  && !IsMultilineAllowed()
459  );
460 }
bool IsBold() const
Definition: eda_text.h:167
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
bool IsMirrored() const
Definition: eda_text.h:173
bool IsVisible() const
Definition: eda_text.h:170
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
bool IsItalic() const
Definition: eda_text.h:164
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
bool IsMultilineAllowed() const
Definition: eda_text.h:182

References GetHorizJustify(), GetThickness(), GetVertJustify(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, IsBold(), IsItalic(), IsMirrored(), IsMultilineAllowed(), and IsVisible().

◆ IsItalic()

bool EDA_TEXT::IsItalic ( ) const
inline

Definition at line 164 of file eda_text.h.

164 { return m_e.Bit( TE_ITALIC ); }
TEXT_EFFECTS m_e
Definition: eda_text.h:377
void Bit(int aBit, bool aValue)
Definition: eda_text.h:97

References TEXT_EFFECTS::Bit(), m_e, and TE_ITALIC.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), SCH_EDIT_FRAME::ConvertTextType(), SCH_EDIT_FRAME::CreateNewText(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::SCH_PAINTER::draw(), export_vrml_pcbtext(), export_vrml_text_module(), Format(), SCH_TEXT::GetMsgPanelInfo(), GetTextStyleName(), TEXT_MOD_GRID_TABLE::GetValueAsBool(), hash_eda(), IsDefaultFormatting(), LenSize(), LIB_TEXT::Plot(), SCH_FIELD::Plot(), SCH_TEXT::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), LIB_TEXT::print(), LIB_FIELD::print(), SCH_FIELD::Print(), TEXTE_MODULE::Print(), printOneLineOfText(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), KIGFX::GAL::SetTextAttributes(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), TransformTextShapeToSegmentList(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ IsMirrored()

◆ IsMultilineAllowed()

◆ IsVisible()

◆ LenSize()

int EDA_TEXT::LenSize ( const wxString &  aLine,
int  aThickness 
) const

Function LenSize.

Returns
the text length in internal units
Parameters
aLine: the line of text to consider. For single line text, this parameter is always m_Text
aThickness: the stroke width of the text

Definition at line 131 of file eda_text.cpp.

132 {
135  basic_gal.SetLineWidth( aThickness );
137 
138  VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
139 
140  return KiROUND( tsize.x );
141 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const wxSize & GetTextSize() const
Definition: eda_text.h:209
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
BASIC_GAL basic_gal(basic_displayOptions)

References basic_gal, KIGFX::GAL::GetTextLineSize(), GetTextSize(), IsBold(), IsItalic(), KiROUND(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetLineWidth(), and VECTOR2< T >::x.

Referenced by SCH_GLOBALLABEL::CreateGraphicShape(), SCH_GLOBALLABEL::GetBoundingBox(), and SCH_HIERLABEL::GetBoundingBox().

◆ MapHorizJustify()

EDA_TEXT_HJUSTIFY_T EDA_TEXT::MapHorizJustify ( int  aHorizJustify)
static

Definition at line 61 of file eda_text.cpp.

62 {
63  wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
64 
65  if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
67 
68  if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
69  return GR_TEXT_HJUSTIFY_LEFT;
70 
71  return (EDA_TEXT_HJUSTIFY_T) aHorizJustify;
72 }
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:44

References GR_TEXT_HJUSTIFY_LEFT, and GR_TEXT_HJUSTIFY_RIGHT.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and DIALOG_EDIT_ONE_FIELD::updateText().

◆ MapOrientation()

int EDA_TEXT::MapOrientation ( KICAD_T  labelType,
int  aOrientation 
)
static

Definition at line 47 of file eda_text.cpp.

48 {
49  if( labelType == SCH_LABEL_T )
50  return aOrientation;
51 
52  switch( aOrientation )
53  {
54  case 0: return 2;
55  case 2: return 0;
56  default: return aOrientation;
57  }
58 }

References SCH_LABEL_T.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), and DIALOG_LABEL_EDITOR::TransferDataToWindow().

◆ MapVertJustify()

EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify ( int  aVertJustify)
static

Definition at line 75 of file eda_text.cpp.

76 {
77  wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
78 
79  if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
81 
82  if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
83  return GR_TEXT_VJUSTIFY_TOP;
84 
85  return (EDA_TEXT_VJUSTIFY_T) aVertJustify;
86 }
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:51

References GR_TEXT_VJUSTIFY_BOTTOM, and GR_TEXT_VJUSTIFY_TOP.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and DIALOG_EDIT_ONE_FIELD::updateText().

◆ Offset()

◆ Print()

void EDA_TEXT::Print ( wxDC *  aDC,
const wxPoint &  aOffset,
COLOR4D  aColor,
EDA_DRAW_MODE_T  aDisplay_mode = FILLED 
)

Function Print.

Parameters
aDC= the current Device Context
aOffset= draw offset (usually (0,0))
aColor= text color
aDisplay_mode= FILLED or SKETCH

Definition at line 344 of file eda_text.cpp.

345 {
346  if( IsMultilineAllowed() )
347  {
348  std::vector<wxPoint> positions;
349  wxArrayString strings;
350  wxStringSplit( GetShownText(), strings, '\n' );
351 
352  positions.reserve( strings.Count() );
353 
354  GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
355 
356  for( unsigned ii = 0; ii < strings.Count(); ii++ )
357  {
358  wxString& txt = strings.Item( ii );
359  printOneLineOfText( aDC, aOffset, aColor, aFillMode, txt, positions[ii] );
360  }
361  }
362  else
363  printOneLineOfText( aDC, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
364 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:188
void printOneLineOfText(wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aFillMode, const wxString &aText, const wxPoint &aPos)
Function printOneLineOfText Used to print each line of this EDA_TEXT, that can be multiline.
Definition: eda_text.cpp:409
bool IsMultilineAllowed() const
Definition: eda_text.h:182
const wxPoint & GetTextPos() const
Definition: eda_text.h:218
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a ...
Definition: eda_text.cpp:367
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129

References GetPositionsOfLinesOfMultilineText(), GetShownText(), GetTextPos(), IsMultilineAllowed(), printOneLineOfText(), and wxStringSplit().

Referenced by TEXTE_PCB::Print(), SCH_TEXT::Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), and WS_DRAW_ITEM_TEXT::PrintWsItem().

◆ printOneLineOfText()

void EDA_TEXT::printOneLineOfText ( wxDC *  aDC,
const wxPoint &  aOffset,
COLOR4D  aColor,
EDA_DRAW_MODE_T  aFillMode,
const wxString &  aText,
const wxPoint &  aPos 
)
private

Function printOneLineOfText Used to print each line of this EDA_TEXT, that can be multiline.

Parameters
aDC= the current Device Context
aOffset= draw offset (usually (0,0))
aColor= text color
aFillMode= FILLED or SKETCH
aText= the single line of text to draw.
aPos= the position of this line ).

Definition at line 409 of file eda_text.cpp.

412 {
413  int width = GetThickness();
414 
415  if( aFillMode == SKETCH )
416  width = -width;
417 
418  wxSize size = GetTextSize();
419 
420  if( IsMirrored() )
421  size.x = -size.x;
422 
423  GRText( aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
424  GetVertJustify(), width, IsItalic(), IsBold() );
425 }
bool IsBold() const
Definition: eda_text.h:167
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
bool IsMirrored() const
Definition: eda_text.h:173
double GetTextAngle() const
Definition: eda_text.h:158
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
bool IsItalic() const
Definition: eda_text.h:164
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
const wxSize & GetTextSize() const
Definition: eda_text.h:209
void GRText(wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function GRText Draw a graphic text (like module texts)
Definition: gr_text.cpp:124

References GetHorizJustify(), GetTextAngle(), GetTextSize(), GetThickness(), GetVertJustify(), GRText(), IsBold(), IsItalic(), IsMirrored(), and SKETCH.

Referenced by Print().

◆ SetBold()

◆ SetEffects()

void EDA_TEXT::SetEffects ( const EDA_TEXT aSrc)

Function SetEffects sets the text effects from another instance.

(TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual text string itself.)

Definition at line 119 of file eda_text.cpp.

120 {
121  m_e = aSrc.m_e;
122 }
TEXT_EFFECTS m_e
Definition: eda_text.h:377

References m_e.

Referenced by LIB_TEXT::Clone(), LIB_FIELD::Copy(), SCH_FIELD::ImportValues(), LIB_FIELD::operator=(), and TEXTE_MODULE::SetEffects().

◆ SetHorizJustify()

◆ SetItalic()

◆ SetMirrored()

◆ SetMultilineAllowed()

void EDA_TEXT::SetMultilineAllowed ( bool  aAllow)
inline

Function SetMultiLineAllowed.

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 181 of file eda_text.h.

181 { m_e.Bit( TE_MULTILINE, aAllow ); }
TEXT_EFFECTS m_e
Definition: eda_text.h:377
void Bit(int aBit, bool aValue)
Definition: eda_text.h:97

References TEXT_EFFECTS::Bit(), m_e, and TE_MULTILINE.

Referenced by SCH_GLOBALLABEL::SCH_GLOBALLABEL(), SCH_HIERLABEL::SCH_HIERLABEL(), SCH_LABEL::SCH_LABEL(), SCH_TEXT::SCH_TEXT(), WS_DATA_ITEM_TEXT::SyncDrawItems(), and TEXTE_PCB::TEXTE_PCB().

◆ SetText()

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

Reimplemented in LIB_FIELD, and LIB_TEXT.

Definition at line 112 of file eda_text.cpp.

113 {
114  m_Text = aText;
115  m_shown_text = UnescapeString( aText );
116 }
wxString m_Text
Definition: eda_text.h:356
wxString m_shown_text
Cache of unescaped text for efficient access.
Definition: eda_text.h:359
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123

References m_shown_text, m_Text, and UnescapeString().

Referenced by SCH_EAGLE_PLUGIN::addImplicitConnections(), GRAPHICS_IMPORTER_PCBNEW::AddText(), PCAD2KICAD::PCB_TEXT::AddToBoard(), PCAD2KICAD::PCB_MODULE::AddToBoard(), FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), SCH_EDITOR_CONTROL::BackAnnotateFootprints(), SCH_EDIT_FRAME::CreateNewText(), SCH_FIELD::GetBoundingBox(), LIB_FIELD::HitTest(), LEGACY_PLUGIN::loadMODULE_TEXT(), FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), TUNER_SLIDER::onSave(), EAGLE_PLUGIN::orientModuleText(), EAGLE_PLUGIN::packageText(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), processTextItem(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), SCH_COMPONENT::SetRef(), DIMENSION::SetText(), TEXT_MOD_GRID_TABLE::SetValue(), DIALOG_SCH_EDIT_SHEET_PIN::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_SPICE_MODEL::TransferDataFromWindow(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), DIALOG_UPDATE_FIELDS::updateFields(), and SCH_COMPONENT::UpdateFields().

◆ SetTextAngle()

◆ SetTextHeight()

void EDA_TEXT::SetTextHeight ( int  aHeight)
inline

Definition at line 214 of file eda_text.h.

214 { m_e.size.y = aHeight; }
TEXT_EFFECTS m_e
Definition: eda_text.h:377
wxSize size
Definition: eda_text.h:92

References m_e, and TEXT_EFFECTS::size.

Referenced by GRAPHICS_IMPORTER_PCBNEW::AddText(), LIB_FIELD::Init(), and TEXT_MOD_GRID_TABLE::SetValue().

◆ SetTextPos()

void EDA_TEXT::SetTextPos ( const wxPoint &  aPoint)
inline

Definition at line 217 of file eda_text.h.

217 { m_e.pos = aPoint; }
TEXT_EFFECTS m_e
Definition: eda_text.h:377
wxPoint pos
Definition: eda_text.h:95

References m_e, and TEXT_EFFECTS::pos.

Referenced by GRAPHICS_IMPORTER_PCBNEW::AddText(), PCAD2KICAD::PCB_TEXT::AddToBoard(), DIMENSION::AdjustDimensionDetails(), LIB_TEXT::BeginEdit(), LIB_FIELD::BeginEdit(), LIB_FIELD::CalcEdit(), LIB_TEXT::CalcEdit(), LIB_TEXT::HitTest(), LIB_FIELD::HitTest(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), DIMENSION::Mirror(), SCH_COMPONENT::MirrorX(), SCH_COMPONENT::MirrorY(), LIB_TEXT::MoveTo(), LIB_FIELD::MoveTo(), EAGLE_PLUGIN::orientModuleText(), EAGLE_PLUGIN::packageText(), DRAWING_TOOL::PlaceText(), TEXTE_PCB::Rotate(), LIB_TEXT::Rotate(), TEXTE_MODULE::Rotate(), SCH_FIELD::Rotate(), SCH_TEXT::Rotate(), SCH_SHEET_PIN::Rotate(), LIB_FIELD::Rotate(), DIMENSION::Rotate(), SCH_COMPONENT::Rotate(), SCH_FIELD::SCH_FIELD(), SCH_SHEET_PIN::SCH_SHEET_PIN(), SCH_TEXT::SCH_TEXT(), SCH_SCREEN::SetComponentFootprint(), TEXTE_MODULE::SetDrawCoord(), TEXTE_PCB::SetPosition(), TEXTE_MODULE::SetPosition(), DIMENSION::SetPosition(), SCH_FIELD::SetPosition(), SCH_TEXT::SetPosition(), WS_DRAW_ITEM_TEXT::SetPosition(), SCH_COMPONENT::SetRef(), TEXTE_MODULE::TEXTE_MODULE(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_UPDATE_FIELDS::updateFields(), SCH_COMPONENT::UpdateFields(), DIALOG_EDIT_ONE_FIELD::updateText(), and WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT().

◆ SetTextSize()

void EDA_TEXT::SetTextSize ( const wxSize &  aNewSize)
inline

Definition at line 208 of file eda_text.h.

208 { m_e.size = aNewSize; };
TEXT_EFFECTS m_e
Definition: eda_text.h:377
wxSize size
Definition: eda_text.h:92

References m_e, and TEXT_EFFECTS::size.

Referenced by SCH_EAGLE_PLUGIN::addImplicitConnections(), SCH_EDIT_FRAME::ConvertTextType(), PCB_EDIT_FRAME::CreateMuWaveBaseFootprint(), PCB_BASE_FRAME::CreateNewModule(), SCH_EDIT_FRAME::CreateNewText(), SCH_EDIT_FRAME::CreateSheetPin(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), dummy(), KIGFX::dummy(), EDA_TEXT(), LIB_TEXT::LIB_TEXT(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN_CACHE::loadText(), SCH_EAGLE_PLUGIN::loadTextAttributes(), DIALOG_FOOTPRINT_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField(), EAGLE_PLUGIN::orientModuleText(), EAGLE_PLUGIN::packageText(), PCB_PARSER::parseEDA_TEXT(), DRAWING_TOOL::PlaceText(), SCH_SCREEN::SetComponentFootprint(), DIMENSION::SetTextSize(), PCAD2KICAD::SetTextSizeFromStrokeFontHeight(), PCAD2KICAD::SetTextSizeFromTrueTypeFontHeight(), DIALOG_LIB_EDIT_TEXT::TransferDataFromWindow(), DIALOG_SCH_EDIT_SHEET_PIN::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), DIALOG_UPDATE_FIELDS::updateFields(), DIALOG_EDIT_ONE_FIELD::updateText(), and WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT().

◆ SetTextWidth()

void EDA_TEXT::SetTextWidth ( int  aWidth)
inline

Definition at line 211 of file eda_text.h.

211 { m_e.size.x = aWidth; }
TEXT_EFFECTS m_e
Definition: eda_text.h:377
wxSize size
Definition: eda_text.h:92

References m_e, and TEXT_EFFECTS::size.

Referenced by GRAPHICS_IMPORTER_PCBNEW::AddText(), LIB_FIELD::Init(), and TEXT_MOD_GRID_TABLE::SetValue().

◆ SetTextX()

◆ SetTextY()

◆ SetThickness()

◆ SetVertJustify()

◆ SetVisible()

◆ ShortenedShownText()

wxString EDA_TEXT::ShortenedShownText ( ) const

Returns a shortened version (max 15 characters) of the shown text.

Definition at line 144 of file eda_text.cpp.

145 {
146  wxString tmp = GetShownText();
147 
148  tmp.Replace( wxT( "\n" ), wxT( " " ) );
149  tmp.Replace( wxT( "\r" ), wxT( " " ) );
150  tmp.Replace( wxT( "\t" ), wxT( " " ) );
151 
152  if( tmp.Length() > 15 )
153  tmp = tmp.Left( 12 ) + wxT( "..." );
154 
155  return tmp;
156 }
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129

References GetShownText().

Referenced by CONNECTION_GRAPH::ercCheckLabels(), LIB_TEXT::GetSelectMenuText(), TEXTE_PCB::GetSelectMenuText(), SCH_SHEET_PIN::GetSelectMenuText(), SCH_TEXT::GetSelectMenuText(), TEXTE_MODULE::GetSelectMenuText(), LIB_FIELD::GetSelectMenuText(), SCH_LABEL::GetSelectMenuText(), SCH_GLOBALLABEL::GetSelectMenuText(), and SCH_HIERLABEL::GetSelectMenuText().

◆ SwapEffects()

void EDA_TEXT::SwapEffects ( EDA_TEXT aTradingPartner)

Function SwapEffects swaps the text effects of the two involved instances.

(TEXT_EFECTS is not exposed in the public API, but includes everything except the actual text string itself.)

Definition at line 125 of file eda_text.cpp.

126 {
127  std::swap( m_e, aTradingPartner.m_e );
128 }
TEXT_EFFECTS m_e
Definition: eda_text.h:377

References m_e.

Referenced by SCH_FIELD::SwapData(), SCH_TEXT::SwapData(), and TEXTE_MODULE::SwapEffects().

◆ TextHitTest() [1/2]

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

Function TextHitTest Test if aPoint is within the bounds of this object.

Parameters
aPoint-A wxPoint to test
aAccuracy- Amount to inflate the bounding box.
Returns
bool - true if a hit, else false

Reimplemented in TEXTE_MODULE.

Definition at line 319 of file eda_text.cpp.

320 {
321  EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
322  wxPoint location = aPoint;
323 
324  rect.Inflate( aAccuracy );
325  RotatePoint( &location, GetTextPos(), -GetTextAngle() );
326 
327  return rect.Contains( location );
328 }
double GetTextAngle() const
Definition: eda_text.h:158
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:167
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxPoint & GetTextPos() const
Definition: eda_text.h:218
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

References EDA_RECT::Contains(), GetTextAngle(), GetTextBox(), GetTextPos(), EDA_RECT::Inflate(), and RotatePoint().

Referenced by LIB_TEXT::HitTest(), TEXTE_PCB::HitTest(), LIB_FIELD::HitTest(), DIMENSION::HitTest(), and WS_DRAW_ITEM_TEXT::HitTest().

◆ TextHitTest() [2/2]

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

Function TextHitTest (overloaded) Tests if object bounding box is contained within or intersects aRect.

Parameters
aRect- Rect to test against.
aContains- Test for containment instead of intersection if true.
aAccuracy- Amount to inflate the bounding box.
Returns
bool - true if a hit, else false

Reimplemented in TEXTE_MODULE.

Definition at line 331 of file eda_text.cpp.

332 {
333  EDA_RECT rect = aRect;
334 
335  rect.Inflate( aAccuracy );
336 
337  if( aContains )
338  return rect.Contains( GetTextBox( -1 ) );
339 
340  return rect.Intersects( GetTextBox( -1 ), GetTextAngle() );
341 }
double GetTextAngle() const
Definition: eda_text.h:158
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:167
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

References EDA_RECT::Contains(), GetTextAngle(), GetTextBox(), EDA_RECT::Inflate(), and EDA_RECT::Intersects().

◆ TransformBoundingBoxWithClearanceToPolygon()

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

Function TransformBoundingBoxWithClearanceToPolygon 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
aCornerBuffer= a buffer to store the polygon
aClearanceValue= the clearance around the text bounding box to the real clearance value (usually near from 1.0)

Definition at line 349 of file board_items_to_polygon_shape_transform.cpp.

351 {
352  if( GetText().Length() == 0 )
353  return;
354 
355  wxPoint corners[4]; // Buffer of polygon corners
356 
357  EDA_RECT rect = GetTextBox( -1 );
358  rect.Inflate( aClearanceValue );
359  corners[0].x = rect.GetOrigin().x;
360  corners[0].y = rect.GetOrigin().y;
361  corners[1].y = corners[0].y;
362  corners[1].x = rect.GetRight();
363  corners[2].x = corners[1].x;
364  corners[2].y = rect.GetBottom();
365  corners[3].y = corners[2].y;
366  corners[3].x = corners[0].x;
367 
368  aCornerBuffer->NewOutline();
369 
370  for( int ii = 0; ii < 4; ii++ )
371  {
372  // Rotate polygon
373  RotatePoint( &corners[ii].x, &corners[ii].y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
374  aCornerBuffer->Append( corners[ii].x, corners[ii].y );
375  }
376 }
double GetTextAngle() const
Definition: eda_text.h:158
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int GetBottom() const
Definition: eda_rect.h:122
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:167
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
int GetRight() const
Definition: eda_rect.h:119
int NewOutline()
Creates a new empty polygon in the set and returns its index
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxPoint & GetTextPos() const
Definition: eda_text.h:218
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References SHAPE_POLY_SET::Append(), EDA_RECT::GetBottom(), EDA_RECT::GetOrigin(), EDA_RECT::GetRight(), GetText(), GetTextAngle(), GetTextBox(), GetTextPos(), EDA_RECT::Inflate(), SHAPE_POLY_SET::NewOutline(), and RotatePoint().

Referenced by ZONE_FILLER::addKnockout().

◆ TransformTextShapeToSegmentList()

void EDA_TEXT::TransformTextShapeToSegmentList ( std::vector< wxPoint > &  aCornerBuffer) const

Convert the text shape to a list of segment each segment is stored as 2 wxPoints: the starting point and the ending point there are therefore 2*n points.

Parameters
aCornerBuffer= a buffer to store the polygon

Definition at line 527 of file eda_text.cpp.

528 {
529  wxSize size = GetTextSize();
530 
531  if( IsMirrored() )
532  size.x = -size.x;
533 
534  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
535 
536  if( IsMultilineAllowed() )
537  {
538  wxArrayString strings_list;
539  wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
540  std::vector<wxPoint> positions;
541  positions.reserve( strings_list.Count() );
542  GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );
543 
544  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
545  {
546  wxString txt = strings_list.Item( ii );
547  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
549  &aCornerBuffer );
550  }
551  }
552  else
553  {
554  GRText( NULL, GetTextPos(), color, GetText(), GetTextAngle(), size, GetHorizJustify(),
556  &aCornerBuffer );
557  }
558 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:188
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
bool IsMirrored() const
Definition: eda_text.h:173
int color
Definition: DXF_plotter.cpp:62
static void addTextSegmToBuffer(int x0, int y0, int xf, int yf, void *aData)
Definition: eda_text.cpp:519
double GetTextAngle() const
Definition: eda_text.h:158
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
bool IsItalic() const
Definition: eda_text.h:164
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
const wxSize & GetTextSize() const
Definition: eda_text.h:209
bool IsMultilineAllowed() const
Definition: eda_text.h:182
void GRText(wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function GRText Draw a graphic text (like module texts)
Definition: gr_text.cpp:124
const wxPoint & GetTextPos() const
Definition: eda_text.h:218
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a ...
Definition: eda_text.cpp:367
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129
Definition: colors.h:45
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References addTextSegmToBuffer(), BLACK, color, GetHorizJustify(), GetPositionsOfLinesOfMultilineText(), GetShownText(), GetText(), GetTextAngle(), GetTextPos(), GetTextSize(), GetThickness(), GetVertJustify(), GRText(), IsItalic(), IsMirrored(), IsMultilineAllowed(), and wxStringSplit().

Referenced by PNS_KICAD_IFACE::syncTextItem(), and DRC::testCopperTextItem().

Member Data Documentation

◆ m_e

◆ m_shown_text

wxString EDA_TEXT::m_shown_text
protected

Cache of unescaped text for efficient access.

Definition at line 359 of file eda_text.h.

Referenced by EDA_TEXT(), GetShownText(), SCH_TEXT::IncrementLabel(), and SetText().

◆ m_Text


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