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)
 
void CopyText (const EDA_TEXT &aSrc)
 
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, int aMarkupFlags) const
 Function LenSize. More...
 
EDA_RECT GetTextBox (int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) 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 int MapOrientation (KICAD_T fromLabelType, KICAD_T toLabelType, 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 392 of file eda_text.h.

392  {
393  // start at zero, sequence is irrelevant
394  TE_MIRROR,
395  TE_ITALIC,
396  TE_BOLD,
397  TE_MULTILINE,
398  TE_VISIBLE,
399  };

Constructor & Destructor Documentation

◆ EDA_TEXT() [1/2]

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

Definition at line 101 of file eda_text.cpp.

101  :
102  m_text( text ),
103  m_e( 1<<TE_VISIBLE )
104 {
105  int sz = Mils2iu( DEFAULT_SIZE_TEXT );
106  SetTextSize( wxSize( sz, sz ) );
107 
108  if( !text.IsEmpty() )
109  m_shown_text = UnescapeString( text );
110 }
#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:371
TEXT_EFFECTS m_e
Definition: eda_text.h:389
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
wxString m_text
Definition: eda_text.h:370
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131

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

113  :
114  m_text( aText.m_text ),
115  m_e( aText.m_e )
116 {
118 }
wxString m_shown_text
Definition: eda_text.h:371
TEXT_EFFECTS m_e
Definition: eda_text.h:389
wxString m_text
Definition: eda_text.h:370
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131

References m_shown_text, m_text, and UnescapeString().

◆ ~EDA_TEXT()

EDA_TEXT::~EDA_TEXT ( )
virtual

Definition at line 121 of file eda_text.cpp.

122 {
123 }

Member Function Documentation

◆ CopyText()

void EDA_TEXT::CopyText ( const EDA_TEXT aSrc)

Definition at line 133 of file eda_text.cpp.

134 {
135  m_text = aSrc.m_text;
136  m_shown_text = aSrc.m_shown_text;
137 }
wxString m_shown_text
Definition: eda_text.h:371
wxString m_text
Definition: eda_text.h:370

References m_shown_text, and m_text.

Referenced by LIB_FIELD::Copy().

◆ Empty()

void EDA_TEXT::Empty ( )
inline

Definition at line 239 of file eda_text.h.

239 { m_text.Empty(); }
wxString m_text
Definition: eda_text.h:370

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

496 {
497 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
498  // and does not define FormatInternalUnits, used here
499  // however this function should exist
500 
501  aFormatter->Print( aNestLevel + 1, "(effects" );
502 
503  // Text size
504  aFormatter->Print( 0, " (font" );
505 
506  aFormatter->Print( 0, " (size %s %s)",
507  FormatInternalUnits( GetTextHeight() ).c_str(),
508  FormatInternalUnits( GetTextWidth() ).c_str() );
509 
510  if( GetThickness() )
511  aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetThickness() ).c_str() );
512 
513  if( IsBold() )
514  aFormatter->Print( 0, " bold" );
515 
516  if( IsItalic() )
517  aFormatter->Print( 0, " italic" );
518 
519  aFormatter->Print( 0, ")"); // (font
520 
521  if( IsMirrored() ||
524  {
525  aFormatter->Print( 0, " (justify");
526 
528  aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
529 
531  aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
532 
533  if( IsMirrored() )
534  aFormatter->Print( 0, " mirror" );
535  aFormatter->Print( 0, ")" ); // (justify
536  }
537 
538  if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
539  aFormatter->Print( 0, " hide" );
540 
541  aFormatter->Print( 0, ")\n" ); // (justify
542 
543 #endif
544 }
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:229
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:226
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:478

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()

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

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

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

401 {
402  wxPoint pos = GetTextPos(); // Position of first line of the
403  // multiline text according to
404  // the center of the multiline text block
405 
406  wxPoint offset; // Offset to next line.
407 
408  offset.y = GetInterline();
409 
410  if( aLineCount > 1 )
411  {
412  switch( GetVertJustify() )
413  {
415  break;
416 
418  pos.y -= ( aLineCount - 1 ) * offset.y / 2;
419  break;
420 
422  pos.y -= ( aLineCount - 1 ) * offset.y;
423  break;
424  }
425  }
426 
427  // Rotate the position of the first line
428  // around the center of the multiline text block
429  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
430 
431  // Rotate the offset lines to increase happened in the right direction
432  RotatePoint( &offset, GetTextAngle() );
433 
434  for( int ii = 0; ii < aLineCount; ii++ )
435  {
436  aPositions.push_back( pos );
437  pos += offset;
438  }
439 }
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:193
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:206
const wxPoint & GetTextPos() const
Definition: eda_text.h:232

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

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(), 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_EDIT_SHEET_PIN::TransferDataToWindow(), DIALOG_LIB_EDIT_TEXT::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:389
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(), 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,
int  aMarkupFlags = 0 
) 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.
aMarkupFlagsa flagset of MARKUP_FLAG enums indicating which markup tokens should be processed

Definition at line 199 of file eda_text.cpp.

200 {
201  EDA_RECT rect;
202  wxArrayString strings;
203  wxString text = GetShownText();
204  int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness;
205  int linecount = 1;
206  bool hasOverBar = false; // true if the first line of text as an overbar
207 
208  if( IsMultilineAllowed() )
209  {
210  wxStringSplit( text, strings, '\n' );
211 
212  if( strings.GetCount() ) // GetCount() == 0 for void strings
213  {
214  if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
215  text = strings.Item( aLine );
216  else
217  text = strings.Item( 0 );
218 
219  linecount = strings.GetCount();
220  }
221  }
222 
223  // Search for overbar symbol. Only text is scanned,
224  // because only this line can change the bounding box
225  for( unsigned ii = 1; ii < text.size(); ii++ )
226  {
227  if( text[ii-1] == '~' && text[ii] != '~' )
228  {
229  hasOverBar = true;
230  break;
231  }
232  }
233 
234  // calculate the H and V size
235  const auto& font = basic_gal.GetStrokeFont();
236  VECTOR2D size( GetTextSize() );
237  double penWidth( thickness );
238  int dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, aMarkupFlags ).x );
239  int dy = GetInterline();
240 
241  // Creates bounding box (rectangle) for an horizontal
242  // and left and top justified text. the bounding box will be moved later
243  // according to the actual text options
244  wxSize textsize = wxSize( dx, dy );
245  wxPoint pos = GetTextPos();
246 
247  if( aInvertY )
248  pos.y = -pos.y;
249 
250  rect.SetOrigin( pos );
251 
252  // The bbox vertical size returned by GetInterline( aThickness )
253  // includes letters like j and y and ] + interval between lines.
254  // The interval below the last line is not usefull, and we can use its half value
255  // as vertical margin above the text
256  // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
257  rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
258 
259  if( hasOverBar )
260  { // A overbar adds an extra size to the text
261  // Height from the base line text of chars like [ or {
262  double curr_height = GetTextHeight() * 1.15;
263  int extra_height = KiROUND( font.ComputeOverbarVerticalPosition( size.y, penWidth ) - curr_height );
264  extra_height += thickness / 2;
265  textsize.y += extra_height;
266  rect.Move( wxPoint( 0, -extra_height ) );
267  }
268 
269  // for multiline texts and aLine < 0, merge all rectangles
270  // ( if aLine < 0, we want the full text bounding box )
271  if( IsMultilineAllowed() && aLine < 0 )
272  {
273  for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
274  {
275  text = strings.Item( ii );
276  dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, aMarkupFlags ).x );
277  textsize.x = std::max( textsize.x, dx );
278  textsize.y += dy;
279  }
280  }
281 
282  rect.SetSize( textsize );
283 
284  /* Now, calculate the rect origin, according to text justification
285  * At this point the rectangle origin is the text origin (m_Pos).
286  * This is true only for left and top text justified texts (using top to bottom Y axis
287  * orientation). and must be recalculated for others justifications
288  * also, note the V justification is relative to the first line
289  */
290  switch( GetHorizJustify() )
291  {
293  if( IsMirrored() )
294  rect.SetX( rect.GetX() - rect.GetWidth() );
295  break;
296 
298  rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
299  break;
300 
302  if( !IsMirrored() )
303  rect.SetX( rect.GetX() - rect.GetWidth() );
304  break;
305  }
306 
307  dy = GetTextHeight() + thickness;
308 
309  switch( GetVertJustify() )
310  {
312  break;
313 
315  rect.SetY( rect.GetY() - ( dy / 2) );
316  break;
317 
319  rect.SetY( rect.GetY() - dy );
320  break;
321  }
322 
323  if( linecount > 1 )
324  {
325  int yoffset;
326  linecount -= 1;
327 
328  switch( GetVertJustify() )
329  {
331  break;
332 
334  yoffset = linecount * GetInterline() / 2;
335  rect.SetY( rect.GetY() - yoffset );
336  break;
337 
339  yoffset = linecount * GetInterline();
340  rect.SetY( rect.GetY() - yoffset );
341  break;
342  }
343  }
344 
345  rect.Normalize(); // Make h and v sizes always >= 0
346 
347  return rect;
348 }
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:193
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
int GetX() const
Definition: eda_rect.h:111
int GetWidth() const
Definition: eda_rect.h:119
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
int GetTextHeight() const
Definition: eda_text.h:229
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
const wxSize & GetTextSize() const
Definition: eda_text.h:223
void SetX(int val)
Definition: eda_rect.h:168
bool IsMultilineAllowed() const
Definition: eda_text.h:182
void SetY(int val)
Definition: eda_rect.h:174
void Normalize()
Function Normalize ensures that the height ant width are positive.
void SetSize(const wxSize &size)
Definition: eda_rect.h:144
#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:112
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114

References basic_gal, 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 >::y.

Referenced by TEXTE_PCB::Flip(), LIB_TEXT::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), TEXTE_MODULE::GetBoundingBox(), DIMENSION::GetBoundingBox(), SCH_LABEL::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 232 of file eda_text.h.

232 { return m_e.pos; }
TEXT_EFFECTS m_e
Definition: eda_text.h:389
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(), LIB_FIELD::GetBoundingBox(), SCH_TEXT::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(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), TransformTextShapeToSegmentList(), SCH_TEXT::UpdateDanglingState(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), DIALOG_UPDATE_FIELDS::updateFields(), and TEXTE_MODULE::ViewBBox().

◆ GetTextSize()

◆ GetTextStyleName()

wxString EDA_TEXT::GetTextStyleName ( )

Function GetTextStyleName.

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

Definition at line 460 of file eda_text.cpp.

461 {
462  int style = 0;
463 
464  if( IsItalic() )
465  style = 1;
466 
467  if( IsBold() )
468  style += 2;
469 
470  wxString stylemsg[4] = {
471  _("Normal"),
472  _("Italic"),
473  _("Bold"),
474  _("Bold+Italic")
475  };
476 
477  return stylemsg[style];
478 }
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:389
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(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), and TransformTextShapeToSegmentList().

◆ GetVertJustify()

◆ IsBold()

◆ IsDefaultFormatting()

bool EDA_TEXT::IsDefaultFormatting ( ) const

Definition at line 481 of file eda_text.cpp.

482 {
483  return ( IsVisible()
484  && !IsMirrored()
487  && GetThickness() == 0
488  && !IsItalic()
489  && !IsBold()
490  && !IsMultilineAllowed()
491  );
492 }
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()

◆ IsMirrored()

◆ IsMultilineAllowed()

◆ IsVisible()

◆ LenSize()

int EDA_TEXT::LenSize ( const wxString &  aLine,
int  aThickness,
int  aMarkupFlags 
) 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
aMarkupFlagsa flagset of MARKUP_FLAG enums indicating which markup tokens should be processed

Definition at line 165 of file eda_text.cpp.

166 {
169  basic_gal.SetLineWidth( (float) aThickness );
171 
172  VECTOR2D tsize = basic_gal.GetTextLineSize( aLine, aMarkupFlags );
173 
174  return KiROUND( tsize.x );
175 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
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:223
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
BASIC_GAL basic_gal(basic_displayOptions)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
VECTOR2D GetTextLineSize(const UTF8 &aText, int aMarkupFlags=0) const
Compute the X and Y size of a given text.

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

74 {
75  wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
76 
77  if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
79 
80  if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
81  return GR_TEXT_HJUSTIFY_LEFT;
82 
83  return (EDA_TEXT_HJUSTIFY_T) aHorizJustify;
84 }
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() [1/2]

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 SCH_EDIT_FRAME::ConvertTextType(), MapOrientation(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), and DIALOG_LABEL_EDITOR::TransferDataToWindow().

◆ MapOrientation() [2/2]

int EDA_TEXT::MapOrientation ( KICAD_T  fromLabelType,
KICAD_T  toLabelType,
int  aOrientation 
)
static

Definition at line 61 of file eda_text.cpp.

62 {
63  bool fromNormal = ( ( fromLabelType == SCH_TEXT_T ) || ( fromLabelType == SCH_LABEL_T ) );
64  bool toNormal = ( ( toLabelType == SCH_TEXT_T ) || ( toLabelType == SCH_LABEL_T ) );
65 
66  if( fromNormal != toNormal )
67  return MapOrientation( SCH_GLOBAL_LABEL_T, aOrientation );
68  else
69  return aOrientation;
70 }
static int MapOrientation(KICAD_T labelType, int aOrientation)
Definition: eda_text.cpp:47

References MapOrientation(), SCH_GLOBAL_LABEL_T, SCH_LABEL_T, and SCH_TEXT_T.

◆ MapVertJustify()

EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify ( int  aVertJustify)
static

Definition at line 87 of file eda_text.cpp.

88 {
89  wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
90 
91  if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
93 
94  if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
95  return GR_TEXT_VJUSTIFY_TOP;
96 
97  return (EDA_TEXT_VJUSTIFY_T) aVertJustify;
98 }
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 376 of file eda_text.cpp.

377 {
378  if( IsMultilineAllowed() )
379  {
380  std::vector<wxPoint> positions;
381  wxArrayString strings;
382  wxStringSplit( GetShownText(), strings, '\n' );
383 
384  positions.reserve( strings.Count() );
385 
386  GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
387 
388  for( unsigned ii = 0; ii < strings.Count(); ii++ )
389  {
390  wxString& txt = strings.Item( ii );
391  printOneLineOfText( aDC, aOffset, aColor, aFillMode, txt, positions[ii] );
392  }
393  }
394  else
395  printOneLineOfText( aDC, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
396 }
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:441
bool IsMultilineAllowed() const
Definition: eda_text.h:182
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
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:399
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 441 of file eda_text.cpp.

444 {
445  int width = GetThickness();
446 
447  if( aFillMode == SKETCH )
448  width = -width;
449 
450  wxSize size = GetTextSize();
451 
452  if( IsMirrored() )
453  size.x = -size.x;
454 
455  GRText( aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
456  GetVertJustify(), width, IsItalic(), IsBold() );
457 }
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:223
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 159 of file eda_text.cpp.

160 {
161  return EDA_ITEM::Replace( aSearchData, m_text );
162 }
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:370

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

141 {
142  m_e = aSrc.m_e;
143 }
TEXT_EFFECTS m_e
Definition: eda_text.h:389

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:389
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 126 of file eda_text.cpp.

127 {
128  m_text = aText;
129  m_shown_text = UnescapeString( aText );
130 }
wxString m_shown_text
Definition: eda_text.h:371
wxString m_text
Definition: eda_text.h:370
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131

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_EDIT_FRAME::CreateNewPart(), 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_EDIT_FRAME::SetCurPart(), LIB_PART::SetName(), SCH_COMPONENT::SetRef(), DIMENSION::SetText(), TEXT_MOD_GRID_TABLE::SetValue(), DIALOG_EDIT_SHEET_PIN::TransferDataFromWindow(), DIALOG_LIB_EDIT_TEXT::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 228 of file eda_text.h.

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

231 { m_e.pos = aPoint; }
TEXT_EFFECTS m_e
Definition: eda_text.h:389
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(), 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 222 of file eda_text.h.

222 { m_e.size = aNewSize; };
TEXT_EFFECTS m_e
Definition: eda_text.h:389
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_EDIT_SHEET_PIN::TransferDataFromWindow(), DIALOG_LIB_EDIT_TEXT::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 225 of file eda_text.h.

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

179 {
180  wxString tmp = GetShownText();
181 
182  tmp.Replace( wxT( "\n" ), wxT( " " ) );
183  tmp.Replace( wxT( "\r" ), wxT( " " ) );
184  tmp.Replace( wxT( "\t" ), wxT( " " ) );
185 
186  if( tmp.Length() > 15 )
187  tmp = tmp.Left( 12 ) + wxT( "..." );
188 
189  return tmp;
190 }
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(), LIB_FIELD::GetSelectMenuText(), SCH_SHEET_PIN::GetSelectMenuText(), SCH_TEXT::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 153 of file eda_text.cpp.

154 {
155  std::swap( m_e, aTradingPartner.m_e );
156 }
TEXT_EFFECTS m_e
Definition: eda_text.h:389

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

147 {
148  std::swap( m_text, aTradingPartner.m_text );
149  std::swap( m_shown_text, aTradingPartner.m_shown_text );
150 }
wxString m_shown_text
Definition: eda_text.h:371
wxString m_text
Definition: eda_text.h:370

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

352 {
353  EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
354  wxPoint location = aPoint;
355 
356  rect.Inflate( aAccuracy );
357  RotatePoint( &location, GetTextPos(), -GetTextAngle() );
358 
359  return rect.Contains( location );
360 }
double GetTextAngle() const
Definition: eda_text.h:158
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:199
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
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 363 of file eda_text.cpp.

364 {
365  EDA_RECT rect = aRect;
366 
367  rect.Inflate( aAccuracy );
368 
369  if( aContains )
370  return rect.Contains( GetTextBox( -1 ) );
371 
372  return rect.Intersects( GetTextBox( -1 ), GetTextAngle() );
373 }
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, int aMarkupFlags=0) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:199
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 336 of file board_items_to_polygon_shape_transform.cpp.

338 {
339  if( GetText().Length() == 0 )
340  return;
341 
342  wxPoint corners[4]; // Buffer of polygon corners
343 
344  EDA_RECT rect = GetTextBox( -1 );
345  rect.Inflate( aClearanceValue );
346  corners[0].x = rect.GetOrigin().x;
347  corners[0].y = rect.GetOrigin().y;
348  corners[1].y = corners[0].y;
349  corners[1].x = rect.GetRight();
350  corners[2].x = corners[1].x;
351  corners[2].y = rect.GetBottom();
352  corners[3].y = corners[2].y;
353  corners[3].x = corners[0].x;
354 
355  aCornerBuffer->NewOutline();
356 
357  for( wxPoint& corner : corners )
358  {
359  // Rotate polygon
360  RotatePoint( &corner.x, &corner.y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
361  aCornerBuffer->Append( corner.x, corner.y );
362  }
363 }
double GetTextAngle() const
Definition: eda_text.h:158
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206
int GetBottom() const
Definition: eda_rect.h:124
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:199
int GetRight() const
Definition: eda_rect.h:121
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:232
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 559 of file eda_text.cpp.

560 {
561  wxSize size = GetTextSize();
562 
563  if( IsMirrored() )
564  size.x = -size.x;
565 
566  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
567 
568  if( IsMultilineAllowed() )
569  {
570  wxArrayString strings_list;
571  wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
572  std::vector<wxPoint> positions;
573  positions.reserve( strings_list.Count() );
574  GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );
575 
576  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
577  {
578  wxString txt = strings_list.Item( ii );
579  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
581  &aCornerBuffer );
582  }
583  }
584  else
585  {
586  GRText( NULL, GetTextPos(), color, GetText(), GetTextAngle(), size, GetHorizJustify(),
588  &aCornerBuffer );
589  }
590 }
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:551
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:223
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:232
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:399
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 371 of file eda_text.h.

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

◆ m_text

wxString EDA_TEXT::m_text
private

Definition at line 370 of file eda_text.h.

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


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