61class wxFindReplaceData;
94 m_IuScale( aIuScale ),
95 m_bounding_box_cache_valid( false ),
96 m_bounding_box_cache_line( -1 ),
97 m_bounding_box_cache_inverted( false )
106 m_IuScale( aText.m_IuScale )
120 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aText.
m_render_cache )
123 m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
152 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aText.
m_render_cache )
155 m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
305 penWidth = aDefaultPenWidth;
309 else if( penWidth <= 1 )
452std::vector<std::unique_ptr<KIFONT::GLYPH>>*
495 m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( aPoly ) );
518 wxArrayString strings;
526 if( strings.GetCount() )
528 if( aLine >= 0 && ( aLine <
static_cast<int>( strings.GetCount() ) ) )
529 text = strings.Item( aLine );
531 text = strings.Item( 0 );
541 int overbarOffset = 0;
551 if(
text.Contains( wxT(
"~{" ) ) )
552 overbarOffset = extents.
y / 14;
562 for(
unsigned ii = 1; ii < strings.GetCount(); ii++ )
564 text = strings.Item( ii );
566 textsize.
x = std::max( textsize.
x, extents.
x );
655 std::vector<VECTOR2I> positions;
656 wxArrayString strings;
659 positions.reserve( strings.Count() );
663 for(
unsigned ii = 0; ii < strings.Count(); ii++ )
664 printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
690 pos.
y -= ( aLineCount - 1 ) * offset.
y / 2;
694 pos.
y -= ( aLineCount - 1 ) * offset.
y;
705 for(
int ii = 0; ii < aLineCount; ii++ )
707 aPositions.push_back( (
VECTOR2I) pos );
715 const wxString& aText,
const VECTOR2I& aPos )
721 penWidth = -penWidth;
748 wxString stylemsg[4] = {
755 return stylemsg[style];
764 return wxEmptyString;
785 aFormatter->
Print( aNestLevel + 1,
"(effects" );
787 aFormatter->
Print( 0,
" (font" );
790 aFormatter->
Print( 0,
" (face \"%s\")",
GetFont()->NameAsToken() );
793 aFormatter->
Print( 0,
" (size %s %s)",
799 aFormatter->
Print( 0,
" (line_spacing %s)",
805 aFormatter->
Print( 0,
" (thickness %s)",
810 aFormatter->
Print( 0,
" bold" );
813 aFormatter->
Print( 0,
" italic" );
817 aFormatter->
Print( 0,
" (color %d %d %d %s)",
824 aFormatter->
Print( 0,
")");
829 aFormatter->
Print( 0,
" (justify");
838 aFormatter->
Print( 0,
" mirror" );
840 aFormatter->
Print( 0,
")" );
844 aFormatter->
Print( 0,
" hide" );
851 aFormatter->
Print( 0,
")\n" );
856 bool aUseTextRotation )
const
858 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
864 if( aUseTextRotation )
876 shape->AddShape(
new SHAPE_SEGMENT( aPt1, aPt2, penWidth ) );
883 for(
const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
884 triShape->
Append( point.x, point.y );
886 shape->AddShape( triShape );
898 shape->AddShape(
new SHAPE_SEGMENT( aPt1, aPt2, penWidth ) );
903 shape->AddShape( aPoly.Clone() );
917#define TEST( a, b ) { if( a != b ) return a - b; }
918#define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
919#define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
964 corners[1].
y = corners[0].
y;
966 corners[2].
x = corners[1].
x;
968 corners[3].
y = corners[2].
y;
969 corners[3].
x = corners[0].
x;
977 aBuffer->
Append( corner.x, corner.y );
990 if( uri.Create( aURL ) && uri.HasScheme() )
992 const wxString& scheme = uri.GetScheme();
993 return scheme == wxT(
"file" ) || scheme == wxT(
"http" ) || scheme == wxT(
"https" );
1002 return aHref.StartsWith( wxT(
"#" ), aDestination );
1008 return wxT(
"#" ) + aDestination;
1032 const wxString textProps =
_(
"Text Properties" );
void SetOrigin(const Vec &pos)
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetOrigin() const
void SetX(coord_type val)
bool Intersects(const BOX2< Vec > &aRect) const
void SetY(coord_type val)
coord_type GetHeight() const
coord_type GetWidth() const
void SetSize(const Vec &size)
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
coord_type GetRight() const
coord_type GetBottom() const
static bool Replace(const EDA_SEARCH_DATA &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void TransformBoundingBoxToPolygon(SHAPE_POLY_SET *aBuffer, int aClearance) const
Convert the text bounding box to a rectangular polygon depending on the text orientation,...
int GetTextHeight() const
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
COLOR4D GetTextColor() const
wxString GetTextStyleName() const
bool IsDefaultFormatting() const
static bool IsGotoPageHref(const wxString &aHref, wxString *aDestination=nullptr)
Check if aHref is a valid internal hyperlink.
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_render_cache
wxString GetFontName() const
void SetupRenderCache(const wxString &aResolvedText, const EDA_ANGLE &aAngle)
BOX2I m_bounding_box_cache
bool IsMultilineAllowed() const
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
int GetInterline() const
Return the distance between two lines of text.
virtual bool IsVisible() const
void SetTextPos(const VECTOR2I &aPoint)
bool m_shown_text_has_text_var_refs
KIFONT::FONT * GetFont() const
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
void SetMirrored(bool isMirrored)
int m_bounding_box_cache_line
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
virtual EDA_ANGLE GetDrawRotation() const
virtual VECTOR2I GetDrawPos() const
EDA_TEXT & operator=(const EDA_TEXT &aItem)
void printOneLineOfText(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aFillMode, const wxString &aText, const VECTOR2I &aPos)
Print each line of this EDA_TEXT.
virtual bool HasHyperlink() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
wxString GetHyperlink() const
void Offset(const VECTOR2I &aOffset)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
void SetTextWidth(int aWidth)
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
int Compare(const EDA_TEXT *aOther) const
std::reference_wrapper< const EDA_IU_SCALE > m_IuScale
virtual void SetVisible(bool aVisible)
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
bool m_bounding_box_cache_valid
void GetLinePositions(std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
static wxString GotoPageHref(const wxString &aDestination)
Generate a href to a page in the current schematic.
virtual void ClearBoundingBoxCache()
virtual KIFONT::FONT * getDrawFont() const
double GetLineSpacing() const
VECTOR2I m_render_cache_offset
void SetLineSpacing(double aLineSpacing)
void AddRenderCacheGlyph(const SHAPE_POLY_SET &aPoly)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
void SetTextHeight(int aHeight)
EDA_ANGLE m_render_cache_angle
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
bool m_bounding_box_cache_inverted
virtual void ClearRenderCache()
const TEXT_ATTRIBUTES & GetAttributes() const
static bool ValidateHyperlink(const wxString &aURL)
Check if aURL is a valid hyperlink.
VECTOR2I m_bounding_box_cache_pos
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
wxString m_render_cache_text
double GetTextAngleDegrees() const
void SetTextAngleDegrees(double aOrientation)
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, bool aUseTextRotation=true) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
void SetHyperlink(wxString aLink)
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
void SetKeepUpright(bool aKeepUpright)
void CopyText(const EDA_TEXT &aSrc)
GR_TEXT_V_ALIGN_T GetVertJustify() const
void SetTextSize(const VECTOR2I &aNewSize)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
int GetTextThickness() const
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aDisplay_mode=FILLED)
Print this text object to the device context aDC.
void SetItalic(bool aItalic)
void SwapText(EDA_TEXT &aTradingPartner)
void SetMultilineAllowed(bool aAllow)
void SetFont(KIFONT::FONT *aFont)
VECTOR2I GetTextSize() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
TEXT_ATTRIBUTES m_attributes
static ENUM_MAP< T > & Instance()
FONT is an abstract base class for both outline and stroke fonts.
virtual double GetInterline(double aGlyphHeight, double aLineSpacing=1.0) const =0
Compute the distance (interline) between 2 lines of text (for multiline texts).
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
const wxString & GetName() const
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic) const
Compute the boundary limits of aText (the bounding box of all shapes).
Class OUTLINE_FONT implements outline font drawing.
void GetLinesAsGlyphs(std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs) const
A color representation with 4 components: red, green, blue, alpha.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const wxString & GetDefaultFont() const
wxDC * GetPrintDC() const
PROPERTY_BASE & SetValidator(PROPERTY_VALIDATOR_FN &&aValidator)
Provide class metadata.Helper macro to map type hashes to names.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
static VALIDATOR_RESULT RangeIntValidator(const wxAny &&aValue, EDA_ITEM *aItem)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
void Append(int aX, int aY)
Append a new point at the end of the polygon.
bool m_KeepUpright
If true, keep rotation angle between -90...90 degrees for readability.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
static constexpr EDA_ANGLE & ANGLE_0
static struct EDA_TEXT_DESC _EDA_TEXT_DESC
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
static constexpr double ITALIC_TILT
Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted ...
int GetPenSizeForBold(int aTextSize)
void GRPrintText(wxDC *aDC, const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, KIFONT::FONT *aFont)
Print a graphic text through wxDC.
int GetPenSizeForNormal(int aTextSize)
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
Some functions to handle hotkeys in KiCad.
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
#define TEXTS_MAX_SIZE
Maximum text size in internal units (10 inches)
#define TEXTS_MIN_SIZE
Minimum text size in internal units (1 mil)
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_DEGREE
Angle expressed in degrees.
@ PT_SIZE
Size expressed in distance units (mm/inch)
wxString UnescapeString(const wxString &aSource)
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".