24#include <google/protobuf/any.pb.h>
49#include <api/schematic/schematic_types.pb.h>
89 kiapi::schematic::types::SchematicTextBox textBox;
91 textBox.mutable_id()->set_value(
m_Uuid.AsStdString() );
92 textBox.set_locked(
IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
99 types::TextBox&
text = *textBox.mutable_textbox();
104 types::TextAttributes* attrs =
text.mutable_attributes();
107 attrs->set_font_name(
GetFont()->GetName().ToUTF8() );
115 attrs->set_bold(
IsBold() );
125 types::StrokeAttributes* stroke = textBox.mutable_graphic_attributes()->mutable_stroke();
132 types::GraphicFillAttributes* fill = textBox.mutable_graphic_attributes()->mutable_fill();
138 aContainer.PackFrom( textBox );
146 kiapi::schematic::types::SchematicTextBox textBox;
148 if( !aContainer.UnpackTo( &textBox ) )
152 SetLocked( textBox.locked() == types::LockedState::LS_LOCKED );
156 SetText( wxString::FromUTF8( textBox.textbox().text() ) );
158 if( textBox.has_margin_left() )
161 if( textBox.has_margin_top() )
164 if( textBox.has_margin_right() )
167 if( textBox.has_margin_bottom() )
170 if( textBox.textbox().has_attributes() )
174 attrs.
m_Bold = textBox.textbox().attributes().bold();
175 attrs.
m_Italic = textBox.textbox().attributes().italic();
176 attrs.
m_Underlined = textBox.textbox().attributes().underlined();
177 attrs.
m_Mirrored = textBox.textbox().attributes().mirrored();
178 attrs.
m_Multiline = textBox.textbox().attributes().multiline();
179 attrs.
m_KeepUpright = textBox.textbox().attributes().keep_upright();
182 if( textBox.textbox().attributes().has_color() )
187 if( !textBox.textbox().attributes().font_name().empty() )
194 attrs.
m_LineSpacing = textBox.textbox().attributes().line_spacing();
197 textBox.textbox().attributes().horizontal_alignment() );
199 textBox.textbox().attributes().vertical_alignment() );
204 if( textBox.has_graphic_attributes() )
206 if( textBox.graphic_attributes().stroke().has_color() )
211 if( textBox.graphic_attributes().fill().has_color() )
368 auto other =
static_cast<const SCH_TEXTBOX*
>( &aItem );
370 if(
GetLayer() != other->GetLayer() )
371 return GetLayer() < other->GetLayer();
394 return GetText() < other->GetText();
418 sheet = aPath->
Last();
420 std::function<bool( wxString* )> textResolver = [&]( wxString* token ) ->
bool
448 text.Replace( wxT(
"<<<ESC_DOLLAR:" ), wxT(
"${" ) );
449 text.Replace( wxT(
"<<<ESC_AT:" ), wxT(
"@{" ) );
509 return wxString::Format(
_(
"Text box '%s'" ),
521 const VECTOR2I& aOffset,
bool aDimmed )
526 SCH_SHAPE::Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
553 color = color.
Mix( bg, 0.5f );
557 penWidth = std::max( penWidth, renderSettings->
GetMinPenWidth() );
561 std::vector<VECTOR2I> positions;
562 wxArrayString strings_list;
565 positions.reserve( strings_list.Count() );
580 temp.
GetLinePositions( renderSettings, positions, (
int) strings_list.Count() );
591 for(
unsigned ii = 0; ii < strings_list.Count(); ii++ )
609 aList.emplace_back(
_(
"Exclude from" ),
_(
"Simulation" ) );
611 aList.emplace_back(
_(
"Font" ),
GetFont() ?
GetFont()->GetName() :
_(
"Default" ) );
613 wxString textStyle[] = {
_(
"Normal" ),
_(
"Italic" ),
_(
"Bold" ),
_(
"Bold Italic" ) };
615 aList.emplace_back(
_(
"Style" ), textStyle[style] );
623 m_stroke.GetMsgPanelInfo( aFrame, aList );
661 auto other =
static_cast<const SCH_TEXTBOX&
>( aOther );
758 const wxString marginProps =
_(
"Margins" );
775 _HKI(
"Text Properties" ) );
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
static const COLOR4D WHITE
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
int AsTenthsOfADegree() const
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
FILL_T GetFillMode() const
void SetLineStyle(const LINE_STYLE aStyle)
void SetFillColor(const COLOR4D &aColor)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
LINE_STYLE GetLineStyle() const
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
COLOR4D GetFillColor() const
void SetEnd(const VECTOR2I &aEnd)
virtual int GetWidth() const
void SetWidth(int aWidth)
void SetFillMode(FILL_T aFill)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
int GetTextHeight() const
COLOR4D GetTextColor() const
const EDA_ANGLE & GetTextAngle() const
bool IsMultilineAllowed() const
virtual const wxString & GetText() const
Return the string associated with the text object.
bool IsKeepUpright() const
KIFONT::FONT * GetFont() const
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
wxString m_hyperlink
A hyperlink URL.
BOX2I GetTextBox(const RENDER_SETTINGS *aSettings, int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
virtual bool HasHyperlink() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
wxString GetHyperlink() const
GR_TEXT_H_ALIGN_T GetHorizJustify() const
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
double GetLineSpacing() const
double Similarity(const EDA_TEXT &aOther) const
const TEXT_ATTRIBUTES & GetAttributes() const
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.
double GetTextAngleDegrees() const
void GetLinePositions(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
GR_TEXT_V_ALIGN_T GetVertJustify() const
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
int GetTextThickness() const
void SwapText(EDA_TEXT &aTradingPartner)
bool operator==(const EDA_TEXT &aRhs) const
void SetMultilineAllowed(bool aAllow)
VECTOR2I GetTextSize() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
void LinebreakText(wxString &aText, int aColumnWidth, const VECTOR2I &aGlyphSize, int aThickness, bool aBold, bool aItalic) const
Insert characters into text to ensure that no lines are wider than aColumnWidth.
A color representation with 4 components: red, green, blue, alpha.
std::shared_ptr< wxString > m_text
COLOR4D & Desaturate()
Removes color (in HSL model)
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
int GetMinPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Base plotter engine class.
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
bool GetColorMode() const
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
SCH_SHEET_PATH & CurrentSheet() const
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void SetLocked(bool aLocked) override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
const wxString & GetDefaultFont(const RENDER_SETTINGS *aSettings) const
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
const KIFONT::METRICS & GetFontMetrics() const
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
void SetPosition(const VECTOR2I &aPos) override
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
SCH_SHAPE(SHAPE_T aShape=SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool operator==(const SCH_ITEM &aOther) const override
STROKE_PARAMS GetStroke() const override
VECTOR2I GetPosition() const override
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
void SetMarginBottom(int aBottom)
int GetMarginBottom() const
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
virtual wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
bool operator==(const SCH_ITEM &aOther) const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetLegacyTextMargin() const
int GetMarginLeft() const
int GetSchTextSize() const
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator<(const SCH_ITEM &aItem) const override
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool HasHypertext() const override
Indicates that the item has at least one hypertext action.
VECTOR2I GetDrawPos() const override
int GetMarginRight() const
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
VECTOR2I GetMinSize() const
Return the minimum height needed to contain the textbox's wrapped text content plus margins.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
bool HasHoveredHypertext() const override
Indicates that a hypertext link is currently active.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void SetMarginLeft(int aLeft)
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void DoHypertextAction(EDA_DRAW_FRAME *aFrame, const VECTOR2I &aMousePos) const override
virtual void Rotate90(bool aClockwise)
void SetMarginRight(int aRight)
void SetSchTextSize(int aSize)
KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const override
SCH_TEXTBOX(SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, const wxString &aText=wxEmptyString, KICAD_T aType=SCH_TEXTBOX_T)
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetExcludedFromSim(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetMarginTop(int aTop)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
KIGFX::COLOR4D GetColor() const
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString ResolveTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, int &aDepth)
Multi-pass text variable expansion and math expression evaluation.
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
a few functions useful in geometry calculations.
SCH_LAYER_ID
Eeschema drawing layers.
Message panel definition file.
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
KICOMMON_API void PackColor(types::Color &aOutput, const KIGFX::COLOR4D &aInput)
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API KIGFX::COLOR4D UnpackColor(const types::Color &aInput)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ PT_SIZE
Size expressed in distance units (mm/inch)
static struct SCH_TEXTBOX_DESC _SCH_TEXTBOX_DESC
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
wxString result
Test unit parsing edge cases and error handling.
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_INDETERMINATE
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I