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...
 
void SwapText (EDA_TEXT &aTradingPartner)
 
bool Replace (wxFindReplaceData &aSearchData)
 Helper function used in search and replace dialog performs a text replace using the find and replace criteria in aSearchData. 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 () 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)
 

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

wxString m_text
 
wxString m_shown_text
 
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 384 of file eda_text.h.

384  {
385  // start at zero, sequence is irrelevant
386  TE_MIRROR,
387  TE_ITALIC,
388  TE_BOLD,
389  TE_MULTILINE,
390  TE_VISIBLE,
391  };

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_shown_text
Definition: eda_text.h:363
TEXT_EFFECTS m_e
Definition: eda_text.h:381
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:220
wxString m_text
Definition: eda_text.h:362
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_shown_text
Definition: eda_text.h:363
TEXT_EFFECTS m_e
Definition: eda_text.h:381
wxString m_text
Definition: eda_text.h:362
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 237 of file eda_text.h.

237 { m_text.Empty(); }
wxString m_text
Definition: eda_text.h:362

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 474 of file eda_text.cpp.

475 {
476 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
477  // and does not define FormatInternalUnits, used here
478  // however this function should exist
479 
480  aFormatter->Print( aNestLevel + 1, "(effects" );
481 
482  // Text size
483  aFormatter->Print( 0, " (font" );
484 
485  aFormatter->Print( 0, " (size %s %s)",
486  FormatInternalUnits( GetTextHeight() ).c_str(),
487  FormatInternalUnits( GetTextWidth() ).c_str() );
488 
489  if( GetThickness() )
490  aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetThickness() ).c_str() );
491 
492  if( IsBold() )
493  aFormatter->Print( 0, " bold" );
494 
495  if( IsItalic() )
496  aFormatter->Print( 0, " italic" );
497 
498  aFormatter->Print( 0, ")"); // (font
499 
500  if( IsMirrored() ||
503  {
504  aFormatter->Print( 0, " (justify");
505 
507  aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
508 
510  aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
511 
512  if( IsMirrored() )
513  aFormatter->Print( 0, " mirror" );
514  aFormatter->Print( 0, ")" ); // (justify
515  }
516 
517  if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
518  aFormatter->Print( 0, " hide" );
519 
520  aFormatter->Print( 0, ")\n" ); // (justify
521 
522 #endif
523 }
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:227
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:224
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:381
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 ( ) 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 172 of file eda_text.cpp.

173 {
175 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
static double GetInterline(double aGlyphHeight)
Compute the distance (interline) between 2 lines of text (for multiline texts).
int GetTextHeight() const
Definition: eda_text.h:227

References KIGFX::STROKE_FONT::GetInterline(), GetTextHeight(), 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 378 of file eda_text.cpp.

380 {
381  wxPoint pos = GetTextPos(); // Position of first line of the
382  // multiline text according to
383  // the center of the multiline text block
384 
385  wxPoint offset; // Offset to next line.
386 
387  offset.y = GetInterline();
388 
389  if( aLineCount > 1 )
390  {
391  switch( GetVertJustify() )
392  {
394  break;
395 
397  pos.y -= ( aLineCount - 1 ) * offset.y / 2;
398  break;
399 
401  pos.y -= ( aLineCount - 1 ) * offset.y;
402  break;
403  }
404  }
405 
406  // Rotate the position of the first line
407  // around the center of the multiline text block
408  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
409 
410  // Rotate the offset lines to increase happened in the right direction
411  RotatePoint( &offset, GetTextAngle() );
412 
413  for( int ii = 0; ii < aLineCount; ii++ )
414  {
415  aPositions.push_back( pos );
416  pos += offset;
417  }
418 }
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:172
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
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:230

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:362

References m_text.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), SCH_EAGLE_PLUGIN::addImplicitConnections(), SIM_PLOT_FRAME::AddTuner(), SCH_EDITOR_CONTROL::BackAnnotateFootprints(), SCH_SHEET::CleanupSheet(), LIB_TEXT::Clone(), LIB_TEXT::compare(), LIB_FIELD::compare(), SCH_REFERENCE::CompareValue(), SCH_SHEET::ComponentCount(), SCH_EDIT_FRAME::ConvertTextType(), LIB_FIELD::Copy(), CreateComponentsSection(), SCH_GLOBALLABEL::CreateGraphicShape(), 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(), SCH_FIELD::GetFullyQualifiedText(), TEXTE_MODULE::GetLength(), getMatchingTextItem(), SCH_TEXT::GetNetListItem(), SCH_COMPONENT::GetRef(), LIB_ALIAS::GetSearchText(), TEXTE_MODULE::GetShownText(), 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(), SCH_TEXT::IncrementLabel(), GENERAL_COLLECTOR::Inspect(), SCH_SCREEN::IsTerminalPoint(), SCH_FIELD::IsVoid(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EAGLE_PLUGIN::loadSchematic(), SCH_EAGLE_PLUGIN::loadSegments(), SCH_TEXT::Matches(), SCH_SHEET_PIN::Matches(), LIB_FIELD::operator=(), SCH_COMPONENT::operator==(), PCB_PARSER::parseDIMENSION(), DRAWING_TOOL::PlaceText(), LIB_TEXT::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotAllTextsModule(), DIALOG_RESCUE_EACH::PopulateInstanceList(), LIB_FIELD::print(), TEXTE_MODULE::Print(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), processTextItem(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::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_EDIT_COMPONENTS_LIBID::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(), TEXTE_MODULE::ViewGetLOD(), 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:381
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(), SCH_FIELD::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), SCH_TEXT::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(), LIB_FIELD::Plot(), SCH_FIELD::Plot(), SCH_TEXT::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 178 of file eda_text.cpp.

179 {
180  EDA_RECT rect;
181  wxArrayString strings;
182  wxString text = GetShownText();
183  int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness;
184  int linecount = 1;
185  bool hasOverBar = false; // true if the first line of text as an overbar
186 
187  if( IsMultilineAllowed() )
188  {
189  wxStringSplit( text, strings, '\n' );
190 
191  if( strings.GetCount() ) // GetCount() == 0 for void strings
192  {
193  if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
194  text = strings.Item( aLine );
195  else
196  text = strings.Item( 0 );
197 
198  linecount = strings.GetCount();
199  }
200  }
201 
202  // Search for overbar symbol. Only text is scanned,
203  // because only this line can change the bounding box
204  for( unsigned ii = 1; ii < text.size(); ii++ )
205  {
206  if( text[ii-1] == '~' && text[ii] != '~' )
207  {
208  hasOverBar = true;
209  break;
210  }
211  }
212 
213  // calculate the H and V size
215  text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
216  int dy = GetInterline();
217 
218  // Creates bounding box (rectangle) for an horizontal
219  // and left and top justified text. the bounding box will be moved later
220  // according to the actual text options
221  wxSize textsize = wxSize( dx, dy );
222  wxPoint pos = GetTextPos();
223 
224  if( aInvertY )
225  pos.y = -pos.y;
226 
227  rect.SetOrigin( pos );
228 
229  // The bbox vertical size returned by GetInterline( aThickness )
230  // includes letters like j and y and ] + interval between lines.
231  // The interval below the last line is not usefull, and we can use its half value
232  // as vertical margin above the text
233  // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
234  rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
235 
236  if( hasOverBar )
237  { // A overbar adds an extra size to the text
238  // Height from the base line text of chars like [ or {
239  double curr_height = GetTextHeight() * 1.15;
240  int extra_height = KiROUND(
241  basic_gal.GetStrokeFont().ComputeOverbarVerticalPosition( GetTextHeight(), thickness ) - curr_height );
242  extra_height += thickness/2;
243  textsize.y += extra_height;
244  rect.Move( wxPoint( 0, -extra_height ) );
245  }
246 
247  // for multiline texts and aLine < 0, merge all rectangles
248  // ( if aLine < 0, we want the full text bounding box )
249  if( IsMultilineAllowed() && aLine < 0 )
250  {
251  for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
252  {
253  text = strings.Item( ii );
255  text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
256  textsize.x = std::max( textsize.x, dx );
257  textsize.y += dy;
258  }
259  }
260 
261  rect.SetSize( textsize );
262 
263  /* Now, calculate the rect origin, according to text justification
264  * At this point the rectangle origin is the text origin (m_Pos).
265  * This is true only for left and top text justified texts (using top to bottom Y axis
266  * orientation). and must be recalculated for others justifications
267  * also, note the V justification is relative to the first line
268  */
269  switch( GetHorizJustify() )
270  {
272  if( IsMirrored() )
273  rect.SetX( rect.GetX() - rect.GetWidth() );
274  break;
275 
277  rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
278  break;
279 
281  if( !IsMirrored() )
282  rect.SetX( rect.GetX() - rect.GetWidth() );
283  break;
284  }
285 
286  dy = GetTextHeight() + thickness;
287 
288  switch( GetVertJustify() )
289  {
291  break;
292 
294  rect.SetY( rect.GetY() - ( dy / 2) );
295  break;
296 
298  rect.SetY( rect.GetY() - dy );
299  break;
300  }
301 
302  if( linecount > 1 )
303  {
304  int yoffset;
305  linecount -= 1;
306 
307  switch( GetVertJustify() )
308  {
310  break;
311 
313  yoffset = linecount * GetInterline() / 2;
314  rect.SetY( rect.GetY() - yoffset );
315  break;
316 
318  yoffset = linecount * GetInterline();
319  rect.SetY( rect.GetY() - yoffset );
320  break;
321  }
322  }
323 
324  rect.Normalize(); // Make h and v sizes always >= 0
325 
326  return rect;
327 }
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
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:172
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:115
int GetX() const
Definition: eda_rect.h:109
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:227
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:221
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:230
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(), SCH_FIELD::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), SCH_TEXT::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 230 of file eda_text.h.

230 { return m_e.pos; }
TEXT_EFFECTS m_e
Definition: eda_text.h:381
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(), SCH_FIELD::GetBoundingBox(), TEXTE_PCB::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(), LIB_TEXT::GetPosition(), DIMENSION::GetPosition(), LIB_FIELD::GetPosition(), SCH_FIELD::GetPosition(), SCH_TEXT::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 221 of file eda_text.h.

221 { return m_e.size; };
TEXT_EFFECTS m_e
Definition: eda_text.h:381
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(), LIB_FIELD::Plot(), SCH_FIELD::Plot(), SCH_TEXT::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 439 of file eda_text.cpp.

440 {
441  int style = 0;
442 
443  if( IsItalic() )
444  style = 1;
445 
446  if( IsBold() )
447  style += 2;
448 
449  wxString stylemsg[4] = {
450  _("Normal"),
451  _("Italic"),
452  _("Bold"),
453  _("Bold+Italic")
454  };
455 
456  return stylemsg[style];
457 }
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:381
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::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(), LIB_TEXT::GetMsgPanelInfo(), TEXTE_PCB::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(), KIGFX::SCH_PAINTER::getTextThickness(), 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 460 of file eda_text.cpp.

461 {
462  return ( IsVisible()
463  && !IsMirrored()
466  && GetThickness() == 0
467  && !IsItalic()
468  && !IsBold()
469  && !IsMultilineAllowed()
470  );
471 }
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:381
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(), LIB_FIELD::Plot(), SCH_FIELD::Plot(), SCH_TEXT::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 144 of file eda_text.cpp.

145 {
148  basic_gal.SetLineWidth( (float) aThickness );
150 
151  VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
152 
153  return KiROUND( tsize.x );
154 }
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:115
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:221
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 355 of file eda_text.cpp.

356 {
357  if( IsMultilineAllowed() )
358  {
359  std::vector<wxPoint> positions;
360  wxArrayString strings;
361  wxStringSplit( GetShownText(), strings, '\n' );
362 
363  positions.reserve( strings.Count() );
364 
365  GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
366 
367  for( unsigned ii = 0; ii < strings.Count(); ii++ )
368  {
369  wxString& txt = strings.Item( ii );
370  printOneLineOfText( aDC, aOffset, aColor, aFillMode, txt, positions[ii] );
371  }
372  }
373  else
374  printOneLineOfText( aDC, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
375 }
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:420
bool IsMultilineAllowed() const
Definition: eda_text.h:182
const wxPoint & GetTextPos() const
Definition: eda_text.h:230
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:378
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 420 of file eda_text.cpp.

423 {
424  int width = GetThickness();
425 
426  if( aFillMode == SKETCH )
427  width = -width;
428 
429  wxSize size = GetTextSize();
430 
431  if( IsMirrored() )
432  size.x = -size.x;
433 
434  GRText( aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
435  GetVertJustify(), width, IsItalic(), IsBold() );
436 }
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:221
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:126

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

Referenced by Print().

◆ Replace()

bool EDA_TEXT::Replace ( wxFindReplaceData &  aSearchData)

Helper function used in search and replace dialog performs a text replace using the find and replace criteria in aSearchData.

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

Definition at line 138 of file eda_text.cpp.

139 {
140  return EDA_ITEM::Replace( aSearchData, m_text );
141 }
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
wxString m_text
Definition: eda_text.h:362

References m_text, and EDA_ITEM::Replace().

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

◆ 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:381

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:381
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

Definition at line 112 of file eda_text.cpp.

113 {
114  m_text = aText;
115  m_shown_text = UnescapeString( aText );
116 }
wxString m_shown_text
Definition: eda_text.h:363
wxString m_text
Definition: eda_text.h:362
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(), LIB_TEXT::Clone(), LIB_FIELD::Copy(), LIB_EDIT_FRAME::CreateNewPart(), SCH_EDIT_FRAME::CreateNewText(), dummy(), KIGFX::dummy(), SCH_FIELD::GetBoundingBox(), LIB_FIELD::HitTest(), SCH_TEXT::IncrementLabel(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadLibrary(), LEGACY_PLUGIN::loadMODULE_TEXT(), FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary(), SCH_LEGACY_PLUGIN_CACHE::LoadPart(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN_CACHE::loadText(), TUNER_SLIDER::onSave(), LIB_FIELD::operator=(), EAGLE_PLUGIN::orientModuleText(), EAGLE_PLUGIN::packageText(), LIB_EDIT_TOOL::Paste(), LIB_PART::PlotLibFields(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), processTextItem(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), LIB_PART::SetName(), SCH_COMPONENT::SetRef(), DIMENSION::SetText(), TEXT_MOD_GRID_TABLE::SetValue(), DIALOG_LIB_EDIT_TEXT::TransferDataFromWindow(), DIALOG_SCH_EDIT_SHEET_PIN::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_SPICE_MODEL::TransferDataFromWindow(), DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_LIB_EDIT_ONE_FIELD::UpdateField(), 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 226 of file eda_text.h.

226 { m_e.size.y = aHeight; }
TEXT_EFFECTS m_e
Definition: eda_text.h:381
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 229 of file eda_text.h.

229 { m_e.pos = aPoint; }
TEXT_EFFECTS m_e
Definition: eda_text.h:381
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_TEXT::CalcEdit(), LIB_FIELD::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 220 of file eda_text.h.

220 { m_e.size = aNewSize; };
TEXT_EFFECTS m_e
Definition: eda_text.h:381
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 223 of file eda_text.h.

223 { m_e.size.x = aWidth; }
TEXT_EFFECTS m_e
Definition: eda_text.h:381
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 157 of file eda_text.cpp.

158 {
159  wxString tmp = GetShownText();
160 
161  tmp.Replace( wxT( "\n" ), wxT( " " ) );
162  tmp.Replace( wxT( "\r" ), wxT( " " ) );
163  tmp.Replace( wxT( "\t" ), wxT( " " ) );
164 
165  if( tmp.Length() > 15 )
166  tmp = tmp.Left( 12 ) + wxT( "..." );
167 
168  return tmp;
169 }
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(), LIB_FIELD::GetSelectMenuText(), TEXTE_MODULE::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 132 of file eda_text.cpp.

133 {
134  std::swap( m_e, aTradingPartner.m_e );
135 }
TEXT_EFFECTS m_e
Definition: eda_text.h:381

References m_e.

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

◆ SwapText()

void EDA_TEXT::SwapText ( EDA_TEXT aTradingPartner)

Definition at line 125 of file eda_text.cpp.

126 {
127  std::swap( m_text, aTradingPartner.m_text );
128  std::swap( m_shown_text, aTradingPartner.m_shown_text );
129 }
wxString m_shown_text
Definition: eda_text.h:363
wxString m_text
Definition: eda_text.h:362

References m_shown_text, and m_text.

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

◆ 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 330 of file eda_text.cpp.

331 {
332  EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
333  wxPoint location = aPoint;
334 
335  rect.Inflate( aAccuracy );
336  RotatePoint( &location, GetTextPos(), -GetTextAngle() );
337 
338  return rect.Contains( location );
339 }
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:178
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxPoint & GetTextPos() const
Definition: eda_text.h:230
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 342 of file eda_text.cpp.

343 {
344  EDA_RECT rect = aRect;
345 
346  rect.Inflate( aAccuracy );
347 
348  if( aContains )
349  return rect.Contains( GetTextBox( -1 ) );
350 
351  return rect.Intersects( GetTextBox( -1 ), GetTextAngle() );
352 }
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:178
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:178
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:230
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 538 of file eda_text.cpp.

539 {
540  wxSize size = GetTextSize();
541 
542  if( IsMirrored() )
543  size.x = -size.x;
544 
545  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
546 
547  if( IsMultilineAllowed() )
548  {
549  wxArrayString strings_list;
550  wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
551  std::vector<wxPoint> positions;
552  positions.reserve( strings_list.Count() );
553  GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );
554 
555  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
556  {
557  wxString txt = strings_list.Item( ii );
558  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
560  &aCornerBuffer );
561  }
562  }
563  else
564  {
565  GRText( NULL, GetTextPos(), color, GetText(), GetTextAngle(), size, GetHorizJustify(),
567  &aCornerBuffer );
568  }
569 }
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:530
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:221
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:126
const wxPoint & GetTextPos() const
Definition: eda_text.h:230
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:378
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
private

Definition at line 363 of file eda_text.h.

Referenced by EDA_TEXT(), GetShownText(), SetText(), and SwapText().

◆ m_text

wxString EDA_TEXT::m_text
private

Definition at line 362 of file eda_text.h.

Referenced by EDA_TEXT(), Empty(), GetText(), Replace(), SetText(), and SwapText().


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