KiCad PCB EDA Suite
WS_DRAW_ITEM_TEXT Class Reference

#include <worksheet_shape_builder.h>

Inheritance diagram for WS_DRAW_ITEM_TEXT:
WS_DRAW_ITEM_BASE EDA_TEXT

Public Types

enum  WS_DRAW_TYPE {
  wsg_line, wsg_rect, wsg_poly, wsg_text,
  wsg_bitmap
}
 

Public Member Functions

 WS_DRAW_ITEM_TEXT (WORKSHEET_DATAITEM *aParent, wxString &aText, wxPoint aPos, wxSize aSize, int aPenWidth, COLOR4D aColor, bool aItalic=false, bool aBold=false)
 
virtual void DrawWsItem (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
 The function to draw a WS_DRAW_ITEM_TEXT. More...
 
int GetPenWidth ()
 
void SetTextAngle (double aAngle)
 
virtual bool HitTest (const wxPoint &aPosition) const override
 Virtual function return true if the point aPosition is on the text. More...
 
virtual bool HitTest (const EDA_RECT &aRect) const override
 Virtual function return true if the rect aRect intersects on the item. More...
 
virtual bool HitTestStartPoint (wxDC *aDC, const wxPoint &aPosition) override
 return true if the point aPosition is on the starting point of this item. More...
 
COLOR4D GetColor () const
 
WS_DRAW_TYPE GetType () const
 
WORKSHEET_DATAITEMGetParent () const
 
virtual void DrawWsItem (EDA_RECT *aClipBox, wxDC *aDC)
 The function to draw a WS_DRAW_ITEM. More...
 
virtual bool HitTestEndPoint (wxDC *aDC, const wxPoint &aPosition)
 return true if the point aPosition is near the ending point of this item This is avirtual function which should be overriden for items defien by 2 points the maxi dist is WORKSHEET_DATAITEM::GetMarkerSizeUi()/2 More...
 
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...
 
double GetTextAngle () const
 
double GetTextAngleDegrees () const
 
double GetTextAngleRadians () const
 
void SetItalic (bool isItalic)
 
bool IsItalic () const
 
void SetBold (bool aBold)
 
bool IsBold () const
 
void SetVisible (bool aVisible)
 
bool IsVisible () const
 
void SetMirrored (bool isMirrored)
 
bool IsMirrored () const
 
void SetMultilineAllowed (bool aAllow)
 Function SetMultiLineAllowed. More...
 
bool IsMultilineAllowed () const
 
EDA_TEXT_HJUSTIFY_T GetHorizJustify () const
 
EDA_TEXT_VJUSTIFY_T GetVertJustify () const
 
void SetHorizJustify (EDA_TEXT_HJUSTIFY_T aType)
 
void SetVertJustify (EDA_TEXT_VJUSTIFY_T aType)
 
void SetEffects (const EDA_TEXT &aSrc)
 Function SetEffects sets the text effects from another instance. More...
 
void SwapEffects (EDA_TEXT &aTradingPartner)
 Function SwapEffects swaps the text effects of the two involved instances. More...
 
bool IsDefaultFormatting () const
 
void SetTextSize (const wxSize &aNewSize)
 
const wxSize & GetTextSize () const
 
void SetTextWidth (int aWidth)
 
int GetTextWidth () const
 
void SetTextHeight (int aHeight)
 
int GetTextHeight () const
 
void SetTextPos (const wxPoint &aPoint)
 
const wxPoint & GetTextPos () const
 
void SetTextX (int aX)
 
void SetTextY (int aY)
 
void Offset (const wxPoint &aOffset)
 
void Empty ()
 
void Draw (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode=FILLED, COLOR4D aAnchor_color=COLOR4D::UNSPECIFIED)
 Function Draw. More...
 
void TransformTextShapeToSegmentList (std::vector< wxPoint > &aCornerBuffer) const
 Convert the text shape to a list of segment each segment is stored as 2 wxPoints: the starting point and the ending point there are therefore 2*n points. More...
 
void TransformBoundingBoxWithClearanceToPolygon (SHAPE_POLY_SET *aCornerBuffer, int aClearanceValue) const
 Function TransformBoundingBoxWithClearanceToPolygon Convert the text bounding box to a rectangular polygon depending on the text orientation, the bounding box is not always horizontal or vertical Used in filling zones calculations Circles and arcs are approximated by segments. More...
 
virtual bool TextHitTest (const wxPoint &aPoint, int aAccuracy=0) const
 Function TextHitTest Test if aPoint is within the bounds of this object. More...
 
virtual bool TextHitTest (const EDA_RECT &aRect, bool aContains, int aAccuracy=0) const
 Function TextHitTest (overloaded) Tests if object bounding box is contained within or intersects aRect. More...
 
int LenSize (const wxString &aLine, int aThickness) const
 Function LenSize. More...
 
EDA_RECT GetTextBox (int aLine=-1, int aThickness=-1, bool aInvertY=false) const
 Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones filling, locate functions....) More...
 
int GetInterline (int aTextThickness=-1) const
 Return the distance between two lines of text. More...
 
wxString GetTextStyleName ()
 Function GetTextStyleName. More...
 
void GetPositionsOfLinesOfMultilineText (std::vector< wxPoint > &aPositions, int aLineCount) const
 Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a multiline text, according to the vertical justification and the rotation of the whole text. More...
 
virtual void Format (OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
 Function Format outputs the object to aFormatter in s-expression form. More...
 

Public Attributes

int m_Flags
 

Protected Attributes

WS_DRAW_TYPE m_type
 
COLOR4D m_color
 
WORKSHEET_DATAITEMm_parent
 
wxString m_Text
 
wxString m_shown_text
 Cache of unescaped text for efficient access. More...
 
UNIQUE_MUTEX m_mutex
 

Detailed Description

Definition at line 284 of file worksheet_shape_builder.h.

Member Enumeration Documentation

◆ WS_DRAW_TYPE

Constructor & Destructor Documentation

◆ WS_DRAW_ITEM_TEXT()

WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT ( WORKSHEET_DATAITEM aParent,
wxString &  aText,
wxPoint  aPos,
wxSize  aSize,
int  aPenWidth,
COLOR4D  aColor,
bool  aItalic = false,
bool  aBold = false 
)

Definition at line 186 of file page_layout_graphic_items.cpp.

189  :
190  WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText )
191 {
192  SetTextPos( aPos );
193  SetTextSize( aSize );
194  SetThickness( aPenWidth );
195  SetItalic( aItalic );
196  SetBold( aBold );
197 }
EDA_TEXT(const wxString &text=wxEmptyString)
Definition: eda_text.cpp:41
void SetItalic(bool isItalic)
Definition: eda_text.h:186
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:240
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:231
WS_DRAW_ITEM_BASE(WORKSHEET_DATAITEM *aParent, WS_DRAW_TYPE aType, COLOR4D aColor)
void SetBold(bool aBold)
Definition: eda_text.h:189
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:165

References EDA_TEXT::SetBold(), EDA_TEXT::SetItalic(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), and EDA_TEXT::SetThickness().

Member Function Documentation

◆ Draw()

void EDA_TEXT::Draw ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aOffset,
COLOR4D  aColor,
GR_DRAWMODE  aDrawMode,
EDA_DRAW_MODE_T  aDisplay_mode = FILLED,
COLOR4D  aAnchor_color = COLOR4D::UNSPECIFIED 
)
inherited

Function Draw.

Parameters
aClipBox= the clipping rect, or NULL if no clipping
aDC= the current Device Context
aOffset= draw offset (usually (0,0))
aColor= text color
aDrawMode= GR_OR, GR_XOR.., -1 to use the current mode.
aDisplay_mode= FILLED or SKETCH
aAnchor_color= anchor color ( COLOR4D::UNSPECIFIED = do not draw anchor ).

Definition at line 296 of file eda_text.cpp.

299 {
300  if( IsMultilineAllowed() )
301  {
302  std::vector<wxPoint> positions;
303  wxArrayString strings;
304  wxStringSplit( GetShownText(), strings, '\n' );
305 
306  positions.reserve( strings.Count() );
307 
308  GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
309 
310  for( unsigned ii = 0; ii < strings.Count(); ii++ )
311  {
312  wxString& txt = strings.Item( ii );
313  drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
314  aDrawMode, aFillMode, txt, positions[ii] );
315  }
316  }
317  else
318  drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
319  aDrawMode, aFillMode, GetShownText(), GetTextPos() );
320 
321  // Draw text anchor, if requested
322  if( aAnchor_color != COLOR4D::UNSPECIFIED )
323  {
324  GRDrawAnchor( aClipBox, aDC,
325  GetTextPos().x + aOffset.x, GetTextPos().y + aOffset.y,
326  DIM_ANCRE_TEXTE, aAnchor_color );
327  }
328 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:188
void GRDrawAnchor(EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
Definition: gr_basic.cpp:1193
void drawOneLineOfText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode, const wxString &aText, const wxPoint &aPos)
Function drawOneLineOfText draws a single text line.
Definition: eda_text.cpp:373
#define DIM_ANCRE_TEXTE
Definition: eda_text.h:89
bool IsMultilineAllowed() const
Definition: eda_text.h:205
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
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:331
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:152

References DIM_ANCRE_TEXTE, EDA_TEXT::drawOneLineOfText(), EDA_TEXT::GetPositionsOfLinesOfMultilineText(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextPos(), GRDrawAnchor(), EDA_TEXT::IsMultilineAllowed(), and wxStringSplit().

Referenced by TEXTE_PCB::Draw(), SCH_TEXT::Draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), and DrawWsItem().

◆ DrawWsItem() [1/2]

virtual void WS_DRAW_ITEM_BASE::DrawWsItem ( EDA_RECT aClipBox,
wxDC *  aDC 
)
inlinevirtualinherited

The function to draw a WS_DRAW_ITEM.

Definition at line 91 of file worksheet_shape_builder.h.

92  {
93  wxPoint offset( 0, 0 );
94  DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, COLOR4D::UNSPECIFIED );
95  }
virtual void DrawWsItem(EDA_RECT *aClipBox, wxDC *aDC)
The function to draw a WS_DRAW_ITEM.

References UNSPECIFIED_DRAWMODE.

◆ DrawWsItem() [2/2]

void WS_DRAW_ITEM_TEXT::DrawWsItem ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aOffset,
GR_DRAWMODE  aDrawMode,
COLOR4D  aColor = COLOR4D::UNSPECIFIED 
)
overridevirtual

The function to draw a WS_DRAW_ITEM_TEXT.

Implements WS_DRAW_ITEM_BASE.

Definition at line 200 of file page_layout_graphic_items.cpp.

202 {
203  Draw( aClipBox, aDC, aOffset,
204  aColor == COLOR4D::UNSPECIFIED ? GetColor() : aColor,
205  aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode,
206  FILLED, COLOR4D::UNSPECIFIED );
207 }
void Draw(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode=FILLED, COLOR4D aAnchor_color=COLOR4D::UNSPECIFIED)
Function Draw.
Definition: eda_text.cpp:296

References EDA_TEXT::Draw(), FILLED, WS_DRAW_ITEM_BASE::GetColor(), GR_COPY, and UNSPECIFIED_DRAWMODE.

◆ Empty()

void EDA_TEXT::Empty ( )
inlineinherited

Definition at line 248 of file eda_text.h.

248 { m_Text.Empty(); }
wxString m_Text
Definition: eda_text.h:378

References EDA_TEXT::m_Text.

Referenced by SCH_LEGACY_PLUGIN_CACHE::LoadPart().

◆ Format()

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

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

433 {
434 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
435  // and does not define FormatInternalUnits, used here
436  // however this function should exist
437 
438  aFormatter->Print( aNestLevel + 1, "(effects" );
439 
440  // Text size
441  aFormatter->Print( 0, " (font" );
442 
443  aFormatter->Print( 0, " (size %s %s)",
444  FormatInternalUnits( GetTextHeight() ).c_str(),
445  FormatInternalUnits( GetTextWidth() ).c_str() );
446 
447  if( GetThickness() )
448  aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetThickness() ).c_str() );
449 
450  if( IsBold() )
451  aFormatter->Print( 0, " bold" );
452 
453  if( IsItalic() )
454  aFormatter->Print( 0, " italic" );
455 
456  aFormatter->Print( 0, ")"); // (font
457 
458  if( IsMirrored() ||
461  {
462  aFormatter->Print( 0, " (justify");
463 
465  aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
466 
468  aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
469 
470  if( IsMirrored() )
471  aFormatter->Print( 0, " mirror" );
472  aFormatter->Print( 0, ")" ); // (justify
473  }
474 
475  if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
476  aFormatter->Print( 0, " hide" );
477 
478  aFormatter->Print( 0, ")\n" ); // (justify
479 
480 #endif
481 }
bool IsBold() const
Definition: eda_text.h:190
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
bool IsMirrored() const
Definition: eda_text.h:196
bool IsVisible() const
Definition: eda_text.h:193
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
int GetTextHeight() const
Definition: eda_text.h:238
bool IsItalic() const
Definition: eda_text.h:187
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
int GetTextWidth() const
Definition: eda_text.h:235
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:58
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:457

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

◆ GetColor()

◆ GetHorizJustify()

EDA_TEXT_HJUSTIFY_T EDA_TEXT::GetHorizJustify ( ) const
inlineinherited

Definition at line 207 of file eda_text.h.

207 { return EDA_TEXT_HJUSTIFY_T( m_e.hjustify ); };
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:63
TEXT_EFFECTS m_e
Definition: eda_text.h:406
signed char hjustify
horizontal justification
Definition: eda_text.h:109

References TEXT_EFFECTS::hjustify, and EDA_TEXT::m_e.

Referenced by CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer(), CINFO3D_VISU::AddShapeWithClearanceToContainer(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::SCH_PAINTER::draw(), TEXTE_MODULE::Draw(), LIB_FIELD::drawGraphic(), EDA_TEXT::drawOneLineOfText(), export_vrml_pcbtext(), export_vrml_text_module(), AUTOPLACER::field_horiz_placement(), TEXTE_PCB::Flip(), TEXTE_MODULE::Flip(), EDA_TEXT::Format(), EDA_TEXT::GetTextBox(), hash_eda(), EDA_TEXT::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(), 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(), EDA_TEXT::TransformTextShapeToSegmentList(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ GetInterline()

int EDA_TEXT::GetInterline ( int  aTextThickness = -1) const
inherited

Return the distance between two lines of text.

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

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

Definition at line 111 of file eda_text.cpp.

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

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

Referenced by EDA_TEXT::GetPositionsOfLinesOfMultilineText(), and EDA_TEXT::GetTextBox().

◆ GetParent()

WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::GetParent ( void  ) const
inlineinherited

◆ GetPenWidth()

int WS_DRAW_ITEM_TEXT::GetPenWidth ( )
inline

Definition at line 298 of file worksheet_shape_builder.h.

298 { return GetThickness(); }
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171

References EDA_TEXT::GetThickness().

Referenced by PlotWorkSheet().

◆ GetPositionsOfLinesOfMultilineText()

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

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

333 {
334  wxPoint pos = GetTextPos(); // Position of first line of the
335  // multiline text according to
336  // the center of the multiline text block
337 
338  wxPoint offset; // Offset to next line.
339 
340  offset.y = GetInterline();
341 
342  if( aLineCount > 1 )
343  {
344  switch( GetVertJustify() )
345  {
347  break;
348 
350  pos.y -= ( aLineCount - 1 ) * offset.y / 2;
351  break;
352 
354  pos.y -= ( aLineCount - 1 ) * offset.y;
355  break;
356  }
357  }
358 
359  // Rotate the position of the first line
360  // around the center of the multiline text block
361  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
362 
363  // Rotate the offset lines to increase happened in the right direction
364  RotatePoint( &offset, GetTextAngle() );
365 
366  for( int ii = 0; ii < aLineCount; ii++ )
367  {
368  aPositions.push_back( pos );
369  pos += offset;
370  }
371 }
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
int GetInterline(int aTextThickness=-1) const
Return the distance between two lines of text.
Definition: eda_text.cpp:111
double GetTextAngle() const
Definition: eda_text.h:181
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
const wxPoint & GetTextPos() const
Definition: eda_text.h:241

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

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

◆ GetShownText()

◆ GetText()

virtual const wxString EDA_TEXT::GetText ( ) const
inlinevirtualinherited

Function GetText returns the string associated with the text object.

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

WARNING: this routine MUST NOT return a reference! While it would be faster, it would also defeat the use of RAII mutex locks in subclasses to get around wxString's multi-threading bugs in UTF-8 mode.

Reimplemented in SCH_FIELD.

Definition at line 147 of file eda_text.h.

147 { return m_Text; }
wxString m_Text
Definition: eda_text.h:378

References EDA_TEXT::m_Text.

Referenced by SCH_SHEET::CleanupSheet(), SCH_REFERENCE::CompareValue(), SCH_EDIT_FRAME::ConvertTextType(), CreateComponentsSection(), SCH_EDIT_FRAME::CreateNewText(), SCH_EDIT_FRAME::CreateSheetPin(), PCB_EDIT_FRAME::CreateTextePcb(), FOOTPRINT_EDIT_FRAME::CreateTextModule(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::SCH_PAINTER::draw(), TEXTE_MODULE::Draw(), PCB_IO::format(), LIB_FIELD::GetFullText(), getMatchingTextItem(), MODULE::GetReference(), LIB_ALIAS::GetSearchText(), DIMENSION::GetText(), TEXT_MOD_GRID_TABLE::GetValue(), MODULE::GetValue(), hash_eda(), SCH_SHEET::HasUndefinedPins(), LIB_FIELD::HitTest(), SCH_EDIT_FRAME::ImportSheetPin(), GENERAL_COLLECTOR::Inspect(), SCH_SCREEN::IsTerminalPoint(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EAGLE_PLUGIN::loadSegments(), PCB_PARSER::parseDIMENSION(), DRAWING_TOOL::PlaceText(), BRDITEMS_PLOTTER::PlotAllTextsModule(), processTextItem(), LIB_EDIT_FRAME::RedrawComponent(), SCH_LEGACY_PLUGIN_CACHE::SaveSymbol(), SCH_LEGACY_PLUGIN::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_COMPONENT::SCH_COMPONENT(), LIB_FIELD::SetText(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataFromWindow(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), DIALOG_SCH_EDIT_SHEET_PIN::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), EDA_TEXT::TransformTextShapeToSegmentList(), DIALOG_UPDATE_FIELDS::updateFields(), DIALOG_FOOTPRINT_FP_EDITOR::Validate(), and DIALOG_FOOTPRINT_BOARD_EDITOR::Validate().

◆ GetTextAngle()

double EDA_TEXT::GetTextAngle ( ) const
inlineinherited

Definition at line 181 of file eda_text.h.

181 { return m_e.angle; }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
double angle
now: 0.1 degrees; future: degrees
Definition: eda_text.h:113

References TEXT_EFFECTS::angle, and EDA_TEXT::m_e.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), LIB_FIELD::CalcEdit(), LIB_TEXT::CalcEdit(), CreateComponentsSection(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::SCH_PAINTER::draw(), SCH_FIELD::Draw(), KIGFX::WORKSHEET_VIEWITEM::draw(), LIB_TEXT::drawGraphic(), LIB_FIELD::drawGraphic(), EDA_TEXT::drawOneLineOfText(), export_vrml_pcbtext(), TEXTE_MODULE::Flip(), PCB_IO::format(), LIB_TEXT::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), TEXTE_MODULE::GetDrawRotation(), TEXTE_PCB::GetMsgPanelInfo(), EDA_TEXT::GetPositionsOfLinesOfMultilineText(), EDA_TEXT::GetTextAngleDegrees(), EDA_TEXT::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(), PCB_BASE_FRAME::PlaceTexteModule(), LIB_TEXT::Plot(), SCH_TEXT::Plot(), SCH_FIELD::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), PlotWorkSheet(), SCH_EDIT_TOOL::Rotate(), TEXTE_PCB::Rotate(), TEXTE_MODULE::Rotate(), LIB_TEXT::Rotate(), DIMENSION::Rotate(), LIB_FIELD::Rotate(), PCB_EDIT_FRAME::Rotate_Texte_Pcb(), PCB_BASE_FRAME::RotateTextModule(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::SetComponentFootprint(), PCB_BASE_FRAME::StartMoveTexteModule(), EDA_TEXT::TextHitTest(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), EDA_TEXT::TransformTextShapeToSegmentList(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ GetTextAngleDegrees()

double EDA_TEXT::GetTextAngleDegrees ( ) const
inlineinherited

Definition at line 183 of file eda_text.h.

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

References EDA_TEXT::GetTextAngle().

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

◆ GetTextAngleRadians()

double EDA_TEXT::GetTextAngleRadians ( ) const
inlineinherited

Definition at line 184 of file eda_text.h.

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

References EDA_TEXT::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
inherited

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

120 {
121  EDA_RECT rect;
122  wxArrayString strings;
123  wxString text = GetShownText();
124  int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness;
125  int linecount = 1;
126  bool hasOverBar = false; // true if the first line of text as an overbar
127 
128  if( IsMultilineAllowed() )
129  {
130  wxStringSplit( text, strings, '\n' );
131 
132  if( strings.GetCount() ) // GetCount() == 0 for void strings
133  {
134  if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
135  text = strings.Item( aLine );
136  else
137  text = strings.Item( 0 );
138 
139  linecount = strings.GetCount();
140  }
141  }
142 
143  // Search for overbar symbol. Only text is scanned,
144  // because only this line can change the bounding box
145  for( unsigned ii = 1; ii < text.size(); ii++ )
146  {
147  if( text[ii-1] == '~' && text[ii] != '~' )
148  {
149  hasOverBar = true;
150  break;
151  }
152  }
153 
154  // calculate the H and V size
156  text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
157  int dy = GetInterline( thickness );
158 
159  // Creates bounding box (rectangle) for an horizontal
160  // and left and top justified text. the bounding box will be moved later
161  // according to the actual text options
162  wxSize textsize = wxSize( dx, dy );
163  wxPoint pos = GetTextPos();
164 
165  if( aInvertY )
166  pos.y = -pos.y;
167 
168  rect.SetOrigin( pos );
169 
170  // The bbox vertical size returned by GetInterline( aThickness )
171  // includes letters like j and y and ] + interval between lines.
172  // The interval below the last line is not usefull, and we can use its half value
173  // as vertical margin above the text
174  // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
175  rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
176 
177  if( hasOverBar )
178  { // A overbar adds an extra size to the text
179  // Height from the base line text of chars like [ or {
180  double curr_height = GetTextHeight() * 1.15;
181  int extra_height = KiROUND(
182  basic_gal.GetStrokeFont().ComputeOverbarVerticalPosition( GetTextHeight(), thickness ) - curr_height );
183  extra_height += thickness/2;
184  textsize.y += extra_height;
185  rect.Move( wxPoint( 0, -extra_height ) );
186  }
187 
188  // for multiline texts and aLine < 0, merge all rectangles
189  // ( if aLine < 0, we want the full text bounding box )
190  if( IsMultilineAllowed() && aLine < 0 )
191  {
192  for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
193  {
194  text = strings.Item( ii );
196  text, VECTOR2D( GetTextSize() ), double( thickness ) ).x );
197  textsize.x = std::max( textsize.x, dx );
198  textsize.y += dy;
199  }
200  }
201 
202  rect.SetSize( textsize );
203 
204  /* Now, calculate the rect origin, according to text justification
205  * At this point the rectangle origin is the text origin (m_Pos).
206  * This is true only for left and top text justified texts (using top to bottom Y axis
207  * orientation). and must be recalculated for others justifications
208  * also, note the V justification is relative to the first line
209  */
210  switch( GetHorizJustify() )
211  {
213  if( IsMirrored() )
214  rect.SetX( rect.GetX() - rect.GetWidth() );
215  break;
216 
218  rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
219  break;
220 
222  if( !IsMirrored() )
223  rect.SetX( rect.GetX() - rect.GetWidth() );
224  break;
225  }
226 
227  dy = GetTextHeight() + thickness;
228 
229  switch( GetVertJustify() )
230  {
232  break;
233 
235  rect.SetY( rect.GetY() - ( dy / 2) );
236  break;
237 
239  rect.SetY( rect.GetY() - dy );
240  break;
241  }
242 
243  if( linecount > 1 )
244  {
245  int yoffset;
246  linecount -= 1;
247 
248  switch( GetVertJustify() )
249  {
251  break;
252 
254  yoffset = linecount * GetInterline() / 2;
255  rect.SetY( rect.GetY() - yoffset );
256  break;
257 
259  yoffset = linecount * GetInterline( aThickness );
260  rect.SetY( rect.GetY() - yoffset );
261  break;
262  }
263  }
264 
265  rect.Normalize(); // Make h and v sizes always >= 0
266 
267  return rect;
268 }
const STROKE_FONT & GetStrokeFont() const
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:188
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
bool IsMirrored() const
Definition: eda_text.h:196
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
int GetX() const
Definition: eda_rect.h:109
int GetInterline(int aTextThickness=-1) const
Return the distance between two lines of text.
Definition: eda_text.cpp:111
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:171
int GetTextHeight() const
Definition: eda_text.h:238
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:207
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const wxSize & GetTextSize() const
Definition: eda_text.h:232
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:205
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:241
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:152

References basic_gal, KIGFX::STROKE_FONT::ComputeOverbarVerticalPosition(), KIGFX::STROKE_FONT::ComputeStringBoundaryLimits(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetInterline(), EDA_TEXT::GetShownText(), KIGFX::GAL::GetStrokeFont(), EDA_TEXT::GetTextHeight(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetThickness(), EDA_TEXT::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, EDA_TEXT::IsMirrored(), EDA_TEXT::IsMultilineAllowed(), KiROUND(), max, EDA_RECT::Move(), EDA_RECT::Normalize(), EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), EDA_RECT::SetX(), EDA_RECT::SetY(), wxStringSplit(), and VECTOR2< T >::x.

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

◆ GetTextHeight()

◆ GetTextPos()

const wxPoint& EDA_TEXT::GetTextPos ( ) const
inlineinherited

Definition at line 241 of file eda_text.h.

241 { return m_e.pos; }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
wxPoint pos
Definition: eda_text.h:114

References EDA_TEXT::m_e, and TEXT_EFFECTS::pos.

Referenced by CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer(), CINFO3D_VISU::AddShapeWithClearanceToContainer(), LIB_TEXT::BeginEdit(), LIB_FIELD::BeginEdit(), PCB_EDIT_FRAME::BeginMoveDimensionText(), 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::SCH_PAINTER::draw(), KIGFX::WORKSHEET_VIEWITEM::draw(), TEXTE_MODULE::Draw(), KIGFX::PCB_PAINTER::draw(), SCH_GLOBALLABEL::Draw(), EDA_TEXT::Draw(), SCH_HIERLABEL::Draw(), WS_DRAW_ITEM_LIST::Draw(), LIB_FIELD::drawGraphic(), TEXTE_MODULE::DrawUmbilical(), export_vrml_pcbtext(), export_vrml_text_module(), TEXTE_PCB::Flip(), TEXTE_MODULE::Flip(), PCB_EDIT_FRAME::FlipTextePcb(), PCB_IO::format(), LIB_TEXT::GetBoundingBox(), TEXTE_PCB::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), TEXTE_MODULE::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), SCH_GLOBALLABEL::GetBoundingBox(), SCH_HIERLABEL::GetBoundingBox(), SCH_TEXT::GetConnectionPoints(), SCH_TEXT::GetEndPoints(), SCH_SHEET_PIN::GetEndPoints(), SCH_FIELD::GetLibPosition(), SCH_TEXT::GetNetListItem(), TEXTE_PCB::GetPosition(), TEXTE_MODULE::GetPosition(), DIMENSION::GetPosition(), LIB_TEXT::GetPosition(), SCH_TEXT::GetPosition(), SCH_FIELD::GetPosition(), LIB_FIELD::GetPosition(), EDA_TEXT::GetPositionsOfLinesOfMultilineText(), EDA_TEXT::GetTextBox(), LIB_TEXT::HitTest(), LIB_FIELD::HitTest(), HitTestStartPoint(), MarkItemsInBloc(), 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(), PCB_EDIT_FRAME::Place_Texte_Pcb(), PCB_EDIT_FRAME::PlaceDimensionText(), PCB_BASE_FRAME::PlaceTexteModule(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), TEXTE_PCB::Rotate(), TEXTE_MODULE::Rotate(), LIB_TEXT::Rotate(), SCH_FIELD::Rotate(), SCH_TEXT::Rotate(), SCH_SHEET_PIN::Rotate(), DIMENSION::Rotate(), LIB_FIELD::Rotate(), SCH_COMPONENT::Rotate(), PCB_EDIT_FRAME::Rotate_Texte_Pcb(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::SetComponentFootprint(), TEXTE_MODULE::SetDrawCoord(), TEXTE_MODULE::SetLocalCoord(), SCH_COMPONENT::SetRef(), PCB_BASE_FRAME::StartMoveTexteModule(), PCB_EDIT_FRAME::StartMoveTextePcb(), TEXTE_MODULE::TextHitTest(), EDA_TEXT::TextHitTest(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), EDA_TEXT::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
inlineinherited

Definition at line 232 of file eda_text.h.

232 { return m_e.size; };
TEXT_EFFECTS m_e
Definition: eda_text.h:406
wxSize size
Definition: eda_text.h:111

References EDA_TEXT::m_e, and TEXT_EFFECTS::size.

Referenced by CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer(), CINFO3D_VISU::AddShapeWithClearanceToContainer(), SCH_EDIT_FRAME::ConvertTextType(), SCH_GLOBALLABEL::CreateGraphicShape(), MWAVE::CreateMicrowaveInductor(), SCH_EDIT_FRAME::CreateSheetPin(), SCH_TEXT::Draw(), KIGFX::SCH_PAINTER::draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), LIB_TEXT::drawGraphic(), LIB_FIELD::drawGraphic(), EDA_TEXT::drawOneLineOfText(), 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(), EDA_TEXT::GetTextBox(), EDA_TEXT::LenSize(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), EAGLE_PLUGIN::orientModuleText(), LIB_TEXT::Plot(), SCH_TEXT::Plot(), SCH_FIELD::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), PCB_BASE_FRAME::ResetTextSize(), SCH_SCREEN::SetComponentFootprint(), KIGFX::GAL::SetTextAttributes(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), MODULE::TransformGraphicTextWithClearanceToPolygonSet(), TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(), EDA_TEXT::TransformTextShapeToSegmentList(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ GetTextStyleName()

wxString EDA_TEXT::GetTextStyleName ( )
inherited

Function GetTextStyleName.

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

Definition at line 397 of file eda_text.cpp.

398 {
399  int style = 0;
400 
401  if( IsItalic() )
402  style = 1;
403 
404  if( IsBold() )
405  style += 2;
406 
407  wxString stylemsg[4] = {
408  _("Normal"),
409  _("Italic"),
410  _("Bold"),
411  _("Bold+Italic")
412  };
413 
414  return stylemsg[style];
415 }
bool IsBold() const
Definition: eda_text.h:190
bool IsItalic() const
Definition: eda_text.h:187

References EDA_TEXT::IsBold(), and EDA_TEXT::IsItalic().

Referenced by LIB_FIELD::GetMsgPanelInfo().

◆ GetTextWidth()

◆ GetThickness()

int EDA_TEXT::GetThickness ( ) const
inlineinherited

Function GetThickness returns pen width.

Definition at line 171 of file eda_text.h.

171 { return m_e.penwidth; };
TEXT_EFFECTS m_e
Definition: eda_text.h:406
int penwidth
Definition: eda_text.h:112

References EDA_TEXT::m_e, and TEXT_EFFECTS::penwidth.

Referenced by CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer(), CINFO3D_VISU::AddShapeWithClearanceToContainer(), DIMENSION::AdjustDimensionDetails(), SCH_EDIT_FRAME::ConvertTextType(), SCH_GLOBALLABEL::CreateGraphicShape(), SCH_TEXT::Draw(), SCH_FIELD::Draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::WORKSHEET_VIEWITEM::draw(), TEXTE_MODULE::Draw(), KIGFX::PCB_PAINTER::draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), EDA_TEXT::drawOneLineOfText(), export_vrml_pcbtext(), export_vrml_text_module(), EDA_TEXT::Format(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), SCH_GLOBALLABEL::GetBoundingBox(), SCH_HIERLABEL::GetBoundingBox(), EDA_TEXT::GetInterline(), TEXTE_PCB::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), TEXTE_MODULE::GetMsgPanelInfo(), LIB_TEXT::GetPenSize(), LIB_FIELD::GetPenSize(), SCH_FIELD::GetPenSize(), SCH_TEXT::GetPenSize(), GetPenWidth(), SCH_GLOBALLABEL::GetSchematicTextOffset(), SCH_HIERLABEL::GetSchematicTextOffset(), EDA_TEXT::GetTextBox(), TEXT_MOD_GRID_TABLE::GetValue(), LIB_TEXT::GetWidth(), LIB_FIELD::GetWidth(), EDA_TEXT::IsDefaultFormatting(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PCB_BASE_FRAME::ResetTextSize(), 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 EDA_TEXT::TransformTextShapeToSegmentList().

◆ GetType()

WS_DRAW_TYPE WS_DRAW_ITEM_BASE::GetType ( ) const
inlineinherited

Definition at line 85 of file worksheet_shape_builder.h.

85 { return m_type; };

References WS_DRAW_ITEM_BASE::m_type.

Referenced by KIGFX::WORKSHEET_VIEWITEM::ViewDraw().

◆ GetVertJustify()

EDA_TEXT_VJUSTIFY_T EDA_TEXT::GetVertJustify ( ) const
inlineinherited

◆ HitTest() [1/2]

bool WS_DRAW_ITEM_TEXT::HitTest ( const wxPoint &  aPosition) const
overridevirtual

Virtual function return true if the point aPosition is on the text.

Implements WS_DRAW_ITEM_BASE.

Definition at line 210 of file page_layout_graphic_items.cpp.

211 {
212  return EDA_TEXT::TextHitTest( aPosition, 0 );
213 }
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Function TextHitTest Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:271

References EDA_TEXT::TextHitTest().

◆ HitTest() [2/2]

bool WS_DRAW_ITEM_TEXT::HitTest ( const EDA_RECT aRect) const
overridevirtual

Virtual function return true if the rect aRect intersects on the item.

Implements WS_DRAW_ITEM_BASE.

Definition at line 216 of file page_layout_graphic_items.cpp.

217 {
218  return EDA_TEXT::TextHitTest( aRect, 0, 0 );
219 }
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Function TextHitTest Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:271

References EDA_TEXT::TextHitTest().

◆ HitTestEndPoint()

virtual bool WS_DRAW_ITEM_BASE::HitTestEndPoint ( wxDC *  aDC,
const wxPoint &  aPosition 
)
inlinevirtualinherited

return true if the point aPosition is near the ending point of this item This is avirtual function which should be overriden for items defien by 2 points the maxi dist is WORKSHEET_DATAITEM::GetMarkerSizeUi()/2

Reimplemented in WS_DRAW_ITEM_RECT, and WS_DRAW_ITEM_LINE.

Definition at line 130 of file worksheet_shape_builder.h.

131  {
132  return false;
133  }

◆ HitTestStartPoint()

bool WS_DRAW_ITEM_TEXT::HitTestStartPoint ( wxDC *  aDC,
const wxPoint &  aPosition 
)
overridevirtual

return true if the point aPosition is on the starting point of this item.

Implements WS_DRAW_ITEM_BASE.

Definition at line 222 of file page_layout_graphic_items.cpp.

223 {
224  wxPoint pos = GetTextPos();
225  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
226 
227  if( std::abs( pos.x - aPosition.x) <= marker_size / 2 &&
228  std::abs( pos.y - aPosition.y) <= marker_size / 2 )
229  return true;
230 
231  return false;
232 }
#define abs(a)
Definition: auxiliary.h:84
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
static double getScaleFromZoom(wxDC *aDC)
static int GetMarkerSizeUi(double aZoomScale=1.0)

References abs, WORKSHEET_DATAITEM::GetMarkerSizeUi(), getScaleFromZoom(), and EDA_TEXT::GetTextPos().

◆ IsBold()

bool EDA_TEXT::IsBold ( ) const
inlineinherited

Definition at line 190 of file eda_text.h.

190 { return m_e.Bit( TE_BOLD ); }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
void Bit(int aBit, bool aValue)
Definition: eda_text.h:116

References TEXT_EFFECTS::Bit(), EDA_TEXT::m_e, and EDA_TEXT::TE_BOLD.

Referenced by SCH_EDIT_FRAME::ConvertTextType(), SCH_GLOBALLABEL::CreateGraphicShape(), SCH_EDIT_FRAME::CreateNewText(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), SCH_TEXT::Draw(), KIGFX::SCH_PAINTER::draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), LIB_TEXT::drawGraphic(), LIB_FIELD::drawGraphic(), EDA_TEXT::drawOneLineOfText(), EDA_TEXT::Format(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), SCH_TEXT::GetMsgPanelInfo(), LIB_TEXT::GetPenSize(), LIB_FIELD::GetPenSize(), SCH_FIELD::GetPenSize(), SCH_TEXT::GetPenSize(), SCH_GLOBALLABEL::GetSchematicTextOffset(), EDA_TEXT::GetTextStyleName(), hash_eda(), EDA_TEXT::IsDefaultFormatting(), EDA_TEXT::LenSize(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LIB_TEXT::Plot(), SCH_TEXT::Plot(), SCH_FIELD::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), KIGFX::GAL::SetTextAttributes(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ IsDefaultFormatting()

bool EDA_TEXT::IsDefaultFormatting ( ) const
inherited

Definition at line 418 of file eda_text.cpp.

419 {
420  return ( IsVisible()
421  && !IsMirrored()
424  && GetThickness() == 0
425  && !IsItalic()
426  && !IsBold()
427  && !IsMultilineAllowed()
428  );
429 }
bool IsBold() const
Definition: eda_text.h:190
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
bool IsMirrored() const
Definition: eda_text.h:196
bool IsVisible() const
Definition: eda_text.h:193
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
bool IsItalic() const
Definition: eda_text.h:187
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
bool IsMultilineAllowed() const
Definition: eda_text.h:205

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

◆ IsItalic()

bool EDA_TEXT::IsItalic ( ) const
inlineinherited

Definition at line 187 of file eda_text.h.

187 { return m_e.Bit( TE_ITALIC ); }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
void Bit(int aBit, bool aValue)
Definition: eda_text.h:116

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

Referenced by CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer(), CINFO3D_VISU::AddShapeWithClearanceToContainer(), SCH_EDIT_FRAME::ConvertTextType(), SCH_EDIT_FRAME::CreateNewText(), DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD(), KIGFX::SCH_PAINTER::draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), LIB_TEXT::drawGraphic(), LIB_FIELD::drawGraphic(), EDA_TEXT::drawOneLineOfText(), export_vrml_pcbtext(), export_vrml_text_module(), EDA_TEXT::Format(), SCH_TEXT::GetMsgPanelInfo(), EDA_TEXT::GetTextStyleName(), TEXT_MOD_GRID_TABLE::GetValueAsBool(), hash_eda(), EDA_TEXT::IsDefaultFormatting(), EDA_TEXT::LenSize(), LIB_TEXT::Plot(), SCH_TEXT::Plot(), SCH_FIELD::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotTextePcb(), BRDITEMS_PLOTTER::PlotTextModule(), PlotWorkSheet(), 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(), EDA_TEXT::TransformTextShapeToSegmentList(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ IsMirrored()

◆ IsMultilineAllowed()

◆ IsVisible()

◆ LenSize()

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

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

84 {
87  basic_gal.SetLineWidth( aThickness );
89 
90  VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
91 
92  return KiROUND( tsize.x );
93 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:190
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:187
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:232
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
BASIC_GAL basic_gal(basic_displayOptions)

References basic_gal, KIGFX::GAL::GetTextLineSize(), EDA_TEXT::GetTextSize(), EDA_TEXT::IsBold(), EDA_TEXT::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().

◆ Offset()

◆ SetBold()

◆ SetEffects()

void EDA_TEXT::SetEffects ( const EDA_TEXT aSrc)
inherited

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

72 {
73  m_e = aSrc.m_e;
74 }
TEXT_EFFECTS m_e
Definition: eda_text.h:406

References EDA_TEXT::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)
inlineinherited

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

204 { m_e.Bit( TE_MULTILINE, aAllow ); }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
void Bit(int aBit, bool aValue)
Definition: eda_text.h:116

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

Referenced by WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(), SCH_GLOBALLABEL::SCH_GLOBALLABEL(), SCH_HIERLABEL::SCH_HIERLABEL(), SCH_LABEL::SCH_LABEL(), SCH_TEXT::SCH_TEXT(), and TEXTE_PCB::TEXTE_PCB().

◆ SetText()

◆ SetTextAngle()

void WS_DRAW_ITEM_TEXT::SetTextAngle ( double  aAngle)
inline

Definition at line 300 of file worksheet_shape_builder.h.

301  {
303  }
void SetTextAngle(double aAngle)
Definition: eda_text.h:173
T NormalizeAngle360Min(T Angle)
Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0.
Definition: trigo.h:231

References NormalizeAngle360Min(), and EDA_TEXT::SetTextAngle().

Referenced by WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText().

◆ SetTextHeight()

void EDA_TEXT::SetTextHeight ( int  aHeight)
inlineinherited

Definition at line 237 of file eda_text.h.

237 { m_e.size.y = aHeight; }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
wxSize size
Definition: eda_text.h:111

References EDA_TEXT::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)
inlineinherited

Definition at line 240 of file eda_text.h.

240 { m_e.pos = aPoint; }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
wxPoint pos
Definition: eda_text.h:114

References EDA_TEXT::m_e, and TEXT_EFFECTS::pos.

Referenced by AbortMoveDimensionText(), GRAPHICS_IMPORTER_PCBNEW::AddText(), PCAD2KICAD::PCB_TEXT::AddToBoard(), DIMENSION::AdjustDimensionDetails(), LIB_TEXT::BeginEdit(), LIB_FIELD::BeginEdit(), LIB_FIELD::CalcEdit(), LIB_TEXT::CalcEdit(), PCB_EDIT_FRAME::CreateTextePcb(), 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(), Move_Texte_Pcb(), MoveDimensionText(), LIB_TEXT::MoveTo(), LIB_FIELD::MoveTo(), EAGLE_PLUGIN::orientModuleText(), EAGLE_PLUGIN::packageText(), PCB_EDIT_FRAME::PlaceDimensionText(), DRAWING_TOOL::PlaceText(), PCB_BASE_FRAME::PlaceTexteModule(), TEXTE_PCB::Rotate(), TEXTE_MODULE::Rotate(), LIB_TEXT::Rotate(), SCH_FIELD::Rotate(), SCH_TEXT::Rotate(), SCH_SHEET_PIN::Rotate(), DIMENSION::Rotate(), LIB_FIELD::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_TEXT::SetPosition(), SCH_FIELD::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().

◆ SetTextSize()

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

Definition at line 231 of file eda_text.h.

231 { m_e.size = aNewSize; };
TEXT_EFFECTS m_e
Definition: eda_text.h:406
wxSize size
Definition: eda_text.h:111

References EDA_TEXT::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(), PCB_EDIT_FRAME::CreateTextePcb(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawDimension(), dummy(), KIGFX::dummy(), EDA_TEXT::EDA_TEXT(), PCB_EDIT_FRAME::EditDimension(), SCH_EDIT_FRAME::ImportSheetPin(), 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(), PCB_BASE_FRAME::ResetTextSize(), 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(), DIALOG_UPDATE_FIELDS::updateFields(), DIALOG_EDIT_ONE_FIELD::updateText(), and WS_DRAW_ITEM_TEXT().

◆ SetTextWidth()

void EDA_TEXT::SetTextWidth ( int  aWidth)
inlineinherited

Definition at line 234 of file eda_text.h.

234 { m_e.size.x = aWidth; }
TEXT_EFFECTS m_e
Definition: eda_text.h:406
wxSize size
Definition: eda_text.h:111

References EDA_TEXT::m_e, and TEXT_EFFECTS::size.

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

◆ SetTextX()

void EDA_TEXT::SetTextX ( int  aX)
inlineinherited

◆ SetTextY()

◆ SetThickness()

◆ SetVertJustify()

◆ SetVisible()

◆ ShortenedShownText()

wxString EDA_TEXT::ShortenedShownText ( ) const
inherited

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

Definition at line 96 of file eda_text.cpp.

97 {
98  wxString tmp = GetShownText();
99 
100  tmp.Replace( wxT( "\n" ), wxT( " " ) );
101  tmp.Replace( wxT( "\r" ), wxT( " " ) );
102  tmp.Replace( wxT( "\t" ), wxT( " " ) );
103 
104  if( tmp.Length() > 15 )
105  tmp = tmp.Left( 12 ) + wxT( "..." );
106 
107  return tmp;
108 }
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:152

References EDA_TEXT::GetShownText().

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

◆ SwapEffects()

void EDA_TEXT::SwapEffects ( EDA_TEXT aTradingPartner)
inherited

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

78 {
79  std::swap( m_e, aTradingPartner.m_e );
80 }
TEXT_EFFECTS m_e
Definition: eda_text.h:406

References EDA_TEXT::m_e.

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

◆ TextHitTest() [1/2]

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

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

272 {
273  EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
274  wxPoint location = aPoint;
275 
276  rect.Inflate( aAccuracy );
277  RotatePoint( &location, GetTextPos(), -GetTextAngle() );
278 
279  return rect.Contains( location );
280 }
double GetTextAngle() const
Definition: eda_text.h:181
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
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:119
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

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

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

◆ TextHitTest() [2/2]

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

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

284 {
285  EDA_RECT rect = aRect;
286 
287  rect.Inflate( aAccuracy );
288 
289  if( aContains )
290  return rect.Contains( GetTextBox( -1 ) );
291 
292  return rect.Intersects( GetTextBox( -1 ), GetTextAngle() );
293 }
double GetTextAngle() const
Definition: eda_text.h:181
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:119
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(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextBox(), EDA_RECT::Inflate(), and EDA_RECT::Intersects().

◆ TransformBoundingBoxWithClearanceToPolygon()

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

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.

Function TransformBoundingBoxWithClearanceToPolygon Convert the text bounding box to a rectangular polygon 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)
aCornerBuffer= a buffer to store the polygon
aClearanceValue= the clearance around the text bounding box

Definition at line 410 of file board_items_to_polygon_shape_transform.cpp.

413 {
414  // Oh dear. When in UTF-8 mode, wxString puts string iterators in a linked list, and
415  // that linked list is not thread-safe.
416  std::lock_guard<std::mutex> guard( m_mutex );
417 
418  if( GetText().Length() == 0 )
419  return;
420 
421  wxPoint corners[4]; // Buffer of polygon corners
422 
423  EDA_RECT rect = GetTextBox( -1 );
424  rect.Inflate( aClearanceValue );
425  corners[0].x = rect.GetOrigin().x;
426  corners[0].y = rect.GetOrigin().y;
427  corners[1].y = corners[0].y;
428  corners[1].x = rect.GetRight();
429  corners[2].x = corners[1].x;
430  corners[2].y = rect.GetBottom();
431  corners[3].y = corners[2].y;
432  corners[3].x = corners[0].x;
433 
434  aCornerBuffer->NewOutline();
435 
436  for( int ii = 0; ii < 4; ii++ )
437  {
438  // Rotate polygon
439  RotatePoint( &corners[ii].x, &corners[ii].y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
440  aCornerBuffer->Append( corners[ii].x, corners[ii].y );
441  }
442 }
double GetTextAngle() const
Definition: eda_text.h:181
virtual const wxString GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:147
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
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:119
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:241
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)
UNIQUE_MUTEX m_mutex
Definition: eda_text.h:384

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

◆ TransformTextShapeToSegmentList()

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

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

497 {
498  wxSize size = GetTextSize();
499 
500  if( IsMirrored() )
501  size.x = -size.x;
502 
503  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by DrawGraphicText
504 
505  if( IsMultilineAllowed() )
506  {
507  wxArrayString strings_list;
508  wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
509  std::vector<wxPoint> positions;
510  positions.reserve( strings_list.Count() );
511  GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );
512 
513  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
514  {
515  wxString txt = strings_list.Item( ii );
516  DrawGraphicText( NULL, NULL, positions[ii], color,
517  txt, GetTextAngle(), size,
519  GetThickness(), IsItalic(),
520  true, addTextSegmToBuffer, &aCornerBuffer );
521  }
522  }
523  else
524  {
525  DrawGraphicText( NULL, NULL, GetTextPos(), color,
526  GetText(), GetTextAngle(), size,
528  GetThickness(), IsItalic(),
529  true, addTextSegmToBuffer, &aCornerBuffer );
530  }
531 }
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:208
bool IsMirrored() const
Definition: eda_text.h:196
int color
Definition: DXF_plotter.cpp:62
static void addTextSegmToBuffer(int x0, int y0, int xf, int yf, void *aData)
Definition: eda_text.cpp:489
double GetTextAngle() const
Definition: eda_text.h:181
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
virtual const wxString GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:147
void DrawGraphicText(EDA_RECT *aClipBox, 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 DrawGraphicText Draw a graphic text (like module texts)
bool IsItalic() const
Definition: eda_text.h:187
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
const wxSize & GetTextSize() const
Definition: eda_text.h:232
bool IsMultilineAllowed() const
Definition: eda_text.h:205
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
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:331
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:152
Definition: colors.h:45
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

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

Member Data Documentation

◆ m_color

COLOR4D WS_DRAW_ITEM_BASE::m_color
protectedinherited

◆ m_Flags

int WS_DRAW_ITEM_BASE::m_Flags
inherited

◆ m_mutex

UNIQUE_MUTEX EDA_TEXT::m_mutex
mutableprotectedinherited

Definition at line 384 of file eda_text.h.

Referenced by EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon().

◆ m_parent

WORKSHEET_DATAITEM* WS_DRAW_ITEM_BASE::m_parent
protectedinherited

◆ m_shown_text

wxString EDA_TEXT::m_shown_text
protectedinherited

Cache of unescaped text for efficient access.

Definition at line 381 of file eda_text.h.

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

◆ m_Text

◆ m_type

WS_DRAW_TYPE WS_DRAW_ITEM_BASE::m_type
protectedinherited

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