KiCad PCB EDA Suite
eda_text.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #include <algorithm> // for max
31 #include <stddef.h> // for NULL
32 #include <type_traits> // for swap
33 #include <vector> // for vector
34 
35 #include <base_struct.h> // for EDA_ITEM
36 #include <base_units.h>
37 #include <basic_gal.h> // for BASIC_GAL, basic_gal
38 #include <common.h> // for wxStringSplit
39 #include <convert_to_biu.h> // for Mils2iu
40 #include <core/typeinfo.h> // for KICAD_T, SCH_LABEL_T, SCH_TEXT_T, SCH_G...
41 #include <eda_rect.h> // for EDA_RECT
42 #include <eda_text.h> // for EDA_TEXT, TEXT_EFFECTS, GR_TEXT_VJUSTIF...
43 #include <gal/color4d.h> // for COLOR4D, COLOR4D::BLACK
44 #include <gal/stroke_font.h> // for STROKE_FONT
45 #include <gr_text.h> // for GRText
46 #include <kicad_string.h> // for UnescapeString
47 #include <math/util.h> // for KiROUND
48 #include <math/vector2d.h> // for VECTOR2D
49 #include <trigo.h> // for RotatePoint
50 
51 #include <wx/debug.h> // for wxASSERT
52 #include <wx/wx.h> // for wxPoint, wxString, wxArrayString, wxSize
53 
54 class OUTPUTFORMATTER;
55 class wxFindReplaceData;
56 
57 
59 {
60  wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
61 
62  if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
64 
65  if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
66  return GR_TEXT_HJUSTIFY_LEFT;
67 
68  return (EDA_TEXT_HJUSTIFY_T) aHorizJustify;
69 }
70 
71 
73 {
74  wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
75 
76  if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
78 
79  if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
80  return GR_TEXT_VJUSTIFY_TOP;
81 
82  return (EDA_TEXT_VJUSTIFY_T) aVertJustify;
83 }
84 
85 
86 EDA_TEXT::EDA_TEXT( const wxString& text ) :
87  m_text( text ),
88  m_e( 1<<TE_VISIBLE )
89 {
90  int sz = Mils2iu( DEFAULT_SIZE_TEXT );
91  SetTextSize( wxSize( sz, sz ) );
93 
94  if( !text.IsEmpty() )
95  {
96  m_shown_text = UnescapeString( text );
97  m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
98  }
99 }
100 
101 
102 EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
103  m_text( aText.m_text ),
104  m_e( aText.m_e )
105 {
107  m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
108 }
109 
110 
112 {
113 }
114 
115 
116 void EDA_TEXT::SetText( const wxString& aText )
117 {
118  m_text = aText;
119  m_shown_text = UnescapeString( aText );
120  m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
121 }
122 
123 
124 void EDA_TEXT::CopyText( const EDA_TEXT& aSrc )
125 {
126  m_text = aSrc.m_text;
127  m_shown_text = aSrc.m_shown_text;
129 }
130 
131 
132 void EDA_TEXT::SetEffects( const EDA_TEXT& aSrc )
133 {
134  m_e = aSrc.m_e;
135 }
136 
137 
138 void EDA_TEXT::SwapText( EDA_TEXT& aTradingPartner )
139 {
140  std::swap( m_text, aTradingPartner.m_text );
141  std::swap( m_shown_text, aTradingPartner.m_shown_text );
143 }
144 
145 
146 void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
147 {
148  std::swap( m_e, aTradingPartner.m_e );
149 }
150 
151 
152 int EDA_TEXT::GetEffectiveTextPenWidth( int aDefaultWidth ) const
153 {
154  int width = GetTextThickness();
155 
156  if( width <= 1 )
157  {
158  width = aDefaultWidth;
159 
160  if( IsBold() )
161  width = GetPenSizeForBold( GetTextWidth() );
162  else if( width <= 1 )
163  width = GetPenSizeForNormal( GetTextWidth() );
164  }
165 
166  // Clip pen size for small texts:
168 
169  return width;
170 }
171 
172 
173 bool EDA_TEXT::Replace( wxFindReplaceData& aSearchData )
174 {
175  bool retval = EDA_ITEM::Replace( aSearchData, m_text );
177  m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
178 
179  return retval;
180 }
181 
182 
183 int EDA_TEXT::LenSize( const wxString& aLine, int aThickness ) const
184 {
187  basic_gal.SetLineWidth( (float) aThickness );
189 
190  VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
191 
192  return KiROUND( tsize.x );
193 }
194 
195 
197 {
198  wxString tmp = GetShownText();
199 
200  tmp.Replace( wxT( "\n" ), wxT( " " ) );
201  tmp.Replace( wxT( "\r" ), wxT( " " ) );
202  tmp.Replace( wxT( "\t" ), wxT( " " ) );
203 
204  if( tmp.Length() > 36 )
205  tmp = tmp.Left( 34 ) + wxT( "..." );
206 
207  return tmp;
208 }
209 
210 
212 {
214 }
215 
216 
217 EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
218 {
219  EDA_RECT rect;
220  wxArrayString strings;
221  wxString text = GetShownText();
222  int thickness = GetEffectiveTextPenWidth();
223  int linecount = 1;
224  bool hasOverBar = false; // true if the first line of text as an overbar
225 
226  if( IsMultilineAllowed() )
227  {
228  wxStringSplit( text, strings, '\n' );
229 
230  if( strings.GetCount() ) // GetCount() == 0 for void strings
231  {
232  if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
233  text = strings.Item( aLine );
234  else
235  text = strings.Item( 0 );
236 
237  linecount = strings.GetCount();
238  }
239  }
240 
241  // Search for overbar symbol. Only text is scanned,
242  // because only this line can change the bounding box
243  for( unsigned ii = 1; ii < text.size(); ii++ )
244  {
245  if( text[ii-1] == '~' && text[ii] != '~' )
246  {
247  hasOverBar = true;
248  break;
249  }
250  }
251 
252  // calculate the H and V size
253  const auto& font = basic_gal.GetStrokeFont();
254  VECTOR2D fontSize( GetTextSize() );
255  double penWidth( thickness );
256  int dx = KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth ).x );
257  int dy = GetInterline();
258 
259  // Creates bounding box (rectangle) for horizontal, left and top justified text. The
260  // bounding box will be moved later according to the actual text options
261  wxSize textsize = wxSize( dx, dy );
262  wxPoint pos = GetTextPos();
263 
264  if( aInvertY )
265  pos.y = -pos.y;
266 
267  rect.SetOrigin( pos );
268 
269  // The bbox vertical size returned by GetInterline( aThickness )
270  // includes letters like j and y and ] + interval between lines.
271  // The interval below the last line is not usefull, and we can use its half value
272  // as vertical margin above the text
273  // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
274  rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
275 
276  if( hasOverBar )
277  { // A overbar adds an extra size to the text
278  // Height from the base line text of chars like [ or {
279  double curr_height = GetTextHeight() * 1.15;
280  double overbarPosition = font.ComputeOverbarVerticalPosition( fontSize.y, penWidth );
281  int extra_height = KiROUND( overbarPosition - curr_height );
282 
283  extra_height += thickness / 2;
284  textsize.y += extra_height;
285  rect.Move( wxPoint( 0, -extra_height ) );
286  }
287 
288  // for multiline texts and aLine < 0, merge all rectangles
289  // ( if aLine < 0, we want the full text bounding box )
290  if( IsMultilineAllowed() && aLine < 0 )
291  {
292  for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
293  {
294  text = strings.Item( ii );
295  dx = KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth ).x );
296  textsize.x = std::max( textsize.x, dx );
297  textsize.y += dy;
298  }
299  }
300 
301  rect.SetSize( textsize );
302 
303  /* Now, calculate the rect origin, according to text justification
304  * At this point the rectangle origin is the text origin (m_Pos).
305  * This is true only for left and top text justified texts (using top to bottom Y axis
306  * orientation). and must be recalculated for others justifications
307  * also, note the V justification is relative to the first line
308  */
309  switch( GetHorizJustify() )
310  {
312  if( IsMirrored() )
313  rect.SetX( rect.GetX() - rect.GetWidth() );
314  break;
315 
317  rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
318  break;
319 
321  if( !IsMirrored() )
322  rect.SetX( rect.GetX() - rect.GetWidth() );
323  break;
324  }
325 
326  dy = GetTextHeight() + thickness;
327 
328  switch( GetVertJustify() )
329  {
331  break;
332 
334  rect.SetY( rect.GetY() - ( dy / 2) );
335  break;
336 
338  rect.SetY( rect.GetY() - dy );
339  break;
340  }
341 
342  if( linecount > 1 )
343  {
344  int yoffset;
345  linecount -= 1;
346 
347  switch( GetVertJustify() )
348  {
350  break;
351 
353  yoffset = linecount * GetInterline() / 2;
354  rect.SetY( rect.GetY() - yoffset );
355  break;
356 
358  yoffset = linecount * GetInterline();
359  rect.SetY( rect.GetY() - yoffset );
360  break;
361  }
362  }
363 
364  rect.Normalize(); // Make h and v sizes always >= 0
365 
366  return rect;
367 }
368 
369 
370 bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
371 {
372  EDA_RECT rect = GetTextBox();
373  wxPoint location = aPoint;
374 
375  rect.Inflate( aAccuracy );
376  RotatePoint( &location, GetTextPos(), -GetTextAngle() );
377 
378  return rect.Contains( location );
379 }
380 
381 
382 bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
383 {
384  EDA_RECT rect = aRect;
385 
386  rect.Inflate( aAccuracy );
387 
388  if( aContains )
389  return rect.Contains( GetTextBox() );
390 
391  return rect.Intersects( GetTextBox(), GetTextAngle() );
392 }
393 
394 
395 void EDA_TEXT::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, COLOR4D aColor,
396  EDA_DRAW_MODE_T aFillMode )
397 {
398  if( IsMultilineAllowed() )
399  {
400  std::vector<wxPoint> positions;
401  wxArrayString strings;
402  wxStringSplit( GetShownText(), strings, '\n' );
403 
404  positions.reserve( strings.Count() );
405 
406  GetLinePositions( positions, strings.Count());
407 
408  for( unsigned ii = 0; ii < strings.Count(); ii++ )
409  printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
410  }
411  else
412  {
413  printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
414  }
415 }
416 
417 
418 void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& aPositions, int aLineCount ) const
419 {
420  wxPoint pos = GetTextPos(); // Position of first line of the
421  // multiline text according to
422  // the center of the multiline text block
423 
424  wxPoint offset; // Offset to next line.
425 
426  offset.y = GetInterline();
427 
428  if( aLineCount > 1 )
429  {
430  switch( GetVertJustify() )
431  {
433  break;
434 
436  pos.y -= ( aLineCount - 1 ) * offset.y / 2;
437  break;
438 
440  pos.y -= ( aLineCount - 1 ) * offset.y;
441  break;
442  }
443  }
444 
445  // Rotate the position of the first line
446  // around the center of the multiline text block
447  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
448 
449  // Rotate the offset lines to increase happened in the right direction
450  RotatePoint( &offset, GetTextAngle() );
451 
452  for( int ii = 0; ii < aLineCount; ii++ )
453  {
454  aPositions.push_back( pos );
455  pos += offset;
456  }
457 }
458 
459 void EDA_TEXT::printOneLineOfText( RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
460  COLOR4D aColor, EDA_DRAW_MODE_T aFillMode,
461  const wxString& aText, const wxPoint &aPos )
462 {
463  wxDC* DC = aSettings->GetPrintDC();
464  int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() );
465 
466  if( aFillMode == SKETCH )
467  penWidth = -penWidth;
468 
469  wxSize size = GetTextSize();
470 
471  if( IsMirrored() )
472  size.x = -size.x;
473 
474  GRText( DC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
475  GetVertJustify(), penWidth, IsItalic(), IsBold() );
476 }
477 
478 
480 {
481  int style = 0;
482 
483  if( IsItalic() )
484  style = 1;
485 
486  if( IsBold() )
487  style += 2;
488 
489  wxString stylemsg[4] = {
490  _("Normal"),
491  _("Italic"),
492  _("Bold"),
493  _("Bold+Italic")
494  };
495 
496  return stylemsg[style];
497 }
498 
499 
501 {
502  return ( IsVisible()
503  && !IsMirrored()
506  && GetTextThickness() == 0
507  && !IsItalic()
508  && !IsBold()
509  && !IsMultilineAllowed()
510  );
511 }
512 
513 
514 void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
515 {
516 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
517  // and does not define FormatInternalUnits, used here
518  // however this function should exist
519 
520  aFormatter->Print( aNestLevel + 1, "(effects" );
521 
522  // Text size
523  aFormatter->Print( 0, " (font" );
524 
525  aFormatter->Print( 0, " (size %s %s)",
526  FormatInternalUnits( GetTextHeight() ).c_str(),
527  FormatInternalUnits( GetTextWidth() ).c_str() );
528 
529  if( GetTextThickness() )
530  aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetTextThickness() ).c_str() );
531 
532  if( IsBold() )
533  aFormatter->Print( 0, " bold" );
534 
535  if( IsItalic() )
536  aFormatter->Print( 0, " italic" );
537 
538  aFormatter->Print( 0, ")"); // (font
539 
540  if( IsMirrored() ||
543  {
544  aFormatter->Print( 0, " (justify");
545 
547  aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
548 
550  aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
551 
552  if( IsMirrored() )
553  aFormatter->Print( 0, " mirror" );
554  aFormatter->Print( 0, ")" ); // (justify
555  }
556 
557  if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
558  aFormatter->Print( 0, " hide" );
559 
560  aFormatter->Print( 0, ")\n" ); // (justify
561 
562 #endif
563 }
564 
565 // Convert the text shape to a list of segment
566 // each segment is stored as 2 wxPoints: its starting point and its ending point
567 // we are using GRText to create the segments and therefore a call-back function is needed
568 
569 // This is a call back function, used by GRText to put each segment in buffer
570 static void addTextSegmToBuffer( int x0, int y0, int xf, int yf, void* aData )
571 {
572  std::vector<wxPoint>* cornerBuffer = static_cast<std::vector<wxPoint>*>( aData );
573  cornerBuffer->push_back( wxPoint( x0, y0 ) );
574  cornerBuffer->push_back( wxPoint( xf, yf ) );
575 }
576 
577 
578 void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuffer ) const
579 {
580  wxSize size = GetTextSize();
581 
582  if( IsMirrored() )
583  size.x = -size.x;
584 
585  bool forceBold = true;
586  int penWidth = 0; // use max-width for bold text
587 
588  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
589 
590  if( IsMultilineAllowed() )
591  {
592  wxArrayString strings_list;
593  wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
594  std::vector<wxPoint> positions;
595  positions.reserve( strings_list.Count() );
596  GetLinePositions( positions, strings_list.Count());
597 
598  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
599  {
600  wxString txt = strings_list.Item( ii );
601  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
602  GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer,
603  &aCornerBuffer );
604  }
605  }
606  else
607  {
609  GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer,
610  &aCornerBuffer );
611  }
612 }
613 
614 
615 static struct EDA_TEXT_DESC
616 {
618  {
620  .Map( GR_TEXT_HJUSTIFY_LEFT, _( "Left" ) )
621  .Map( GR_TEXT_HJUSTIFY_CENTER, _( "Center" ) )
622  .Map( GR_TEXT_HJUSTIFY_RIGHT, _( "Right" ) );
624  .Map( GR_TEXT_VJUSTIFY_TOP, _( "Top" ) )
625  .Map( GR_TEXT_VJUSTIFY_CENTER, _( "Center" ) )
626  .Map( GR_TEXT_VJUSTIFY_BOTTOM, _( "Bottom" ) );
627 
630  propMgr.AddProperty( new PROPERTY<EDA_TEXT, wxString>( _( "Text" ),
632  propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _( "Thickness" ),
634  propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _( "Italic" ),
636  propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _( "Bold" ),
638  propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _( "Mirrored" ),
640  propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _( "Visible" ),
642  propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _( "Width" ),
644  propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _( "Height" ),
646  propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, EDA_TEXT_HJUSTIFY_T>( _( "Horizontal Justification" ),
648  propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, EDA_TEXT_VJUSTIFY_T>( _( "Vertical Justification" ),
650  }
652 
void SetMirrored(bool isMirrored)
Definition: eda_text.h:187
const STROKE_FONT & GetStrokeFont() const
EDA_TEXT(const wxString &text=wxEmptyString)
Definition: eda_text.cpp:86
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:341
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:182
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:211
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
Definition: eda_text.cpp:146
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
Definition: eda_text.h:73
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsMirrored() const
Definition: eda_text.h:188
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: gr_text.cpp:51
void CopyText(const EDA_TEXT &aSrc)
Definition: eda_text.cpp:124
static double GetInterline(double aGlyphHeight)
Compute the distance (interline) between 2 lines of text (for multiline texts).
Implementation of conversion functions that require both schematic and board internal units.
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
int GetX() const
Definition: eda_rect.h:111
wxString m_shown_text
Definition: eda_text.h:369
bool IsVisible() const
Definition: eda_text.h:185
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
Definition: eda_text.cpp:132
void SetItalic(bool isItalic)
Definition: eda_text.h:178
TEXT_EFFECTS m_e
Definition: eda_text.h:372
int color
Definition: DXF_plotter.cpp:61
EDA_RECT GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:217
void SetVisible(bool aVisible)
Definition: eda_text.h:184
int GetWidth() const
Definition: eda_rect.h:119
static void addTextSegmToBuffer(int x0, int y0, int xf, int yf, void *aData)
Definition: eda_text.cpp:570
static ENUM_MAP< T > & Instance()
Definition: property.h:515
double GetTextAngle() const
Definition: eda_text.h:173
bool m_shown_text_has_text_var_refs
Definition: eda_text.h:370
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
static struct EDA_TEXT_DESC _EDA_TEXT_DESC
OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a convenient ...
Definition: richio.h:327
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
Definition: color4d.h:44
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
int GetTextThickness() const
Definition: eda_text.h:158
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names
Definition: property_mgr.h:244
bool Contains(const wxPoint &aPoint) const
Function Contains.
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aDisplay_mode=FILLED)
Print this text object to the device context aDC.
Definition: eda_text.cpp:395
int GetTextHeight() const
Definition: eda_text.h:244
bool IsItalic() const
Definition: eda_text.h:179
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:112
void SetFontBold(const bool aBold)
Set bold property of current font.
int LenSize(const wxString &aLine, int aThickness) const
Definition: eda_text.cpp:183
Display value expressed in distance units (mm/inch)
Definition: property.h:47
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:72
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
static EDA_TEXT_HJUSTIFY_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:58
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
EDA_DRAW_MODE_T
Definition: eda_text.h:62
const wxSize & GetTextSize() const
Definition: eda_text.h:238
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:202
int GetPenSizeForNormal(int aTextSize)
Function GetPensizeForNormal.
Definition: gr_text.cpp:57
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:578
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:196
#define ENUM_TO_WXANY(type)
Definition: property.h:588
void SetX(int val)
Definition: eda_rect.h:168
virtual ~EDA_TEXT()
Definition: eda_text.cpp:111
void printOneLineOfText(RENDER_SETTINGS *aSettings, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aFillMode, const wxString &aText, const wxPoint &aPos)
Print each line of this EDA_TEXT.
Definition: eda_text.cpp:459
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:514
bool IsDefaultFormatting() const
Definition: eda_text.cpp:500
wxString m_text
Definition: eda_text.h:368
static EDA_TEXT_VJUSTIFY_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:72
bool IsMultilineAllowed() const
Definition: eda_text.h:196
void SetY(int val)
Definition: eda_rect.h:174
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:134
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
void SetTextWidth(int aWidth)
Definition: eda_text.h:240
void Normalize()
Function Normalize ensures that the height ant width are positive.
void SetSize(const wxSize &size)
Definition: eda_rect.h:144
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:138
int GetTextWidth() const
Definition: eda_text.h:241
wxString GetTextStyleName()
Definition: eda_text.cpp:479
#define ALLOW_BOLD_THICKNESS
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:201
bool Replace(wxFindReplaceData &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:173
#define _(s)
Definition: 3d_actions.cpp:33
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
void AddProperty(PROPERTY_BASE *aProperty)
Registers a property.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:370
void SetTextHeight(int aHeight)
Definition: eda_text.h:243
int GetY() const
Definition: eda_rect.h:112
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
The common library.
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
void GetLinePositions(std::vector< wxPoint > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:418
int GetDefaultPenWidth() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
Provides class metadata.
Definition: property_mgr.h:58
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:157
BASIC_GAL basic_gal(basic_displayOptions)
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:42
void SetBold(bool aBold)
Definition: eda_text.h:181
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:133
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:560
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99