31#include <api/schematic/schematic_types.pb.h>
53 kiapi::schematic::types::SchematicTableCell cell;
55 aContainer.PackFrom( cell );
61 if( !aCell.has_text_box() )
78 kiapi::schematic::types::SchematicTableCell cell;
80 if( !aContainer.UnpackTo( &cell ) )
102 return wxString::Format(
_(
"Table Cell %s" ),
GetAddr() );
110 for(
int row = 0; row <
table->GetRowCount(); ++row )
112 for(
int col = 0; col <
table->GetColCount(); ++col )
114 if(
table->GetCell( row, col ) ==
this )
127 for(
int row = 0; row <
table->GetRowCount(); ++row )
129 for(
int col = 0; col <
table->GetColCount(); ++col )
131 if(
table->GetCell( row, col ) ==
this )
142 return wxString::Format( wxT(
"%c%d" ),
'A' +
GetColumn() % 26,
GetRow() );
158 if( aAddr.IsEmpty() )
166 while( i < aAddr.Length() && wxIsalpha( aAddr[i] ) )
168 colPart += wxToupper( aAddr[i] );
173 if( colPart.IsEmpty() )
178 for(
size_t j = 0; j < colPart.Length(); j++ )
180 aCol = aCol * 26 + ( colPart[j] -
'A' + 1 );
185 wxString rowPart = aAddr.Mid( i );
186 if( rowPart.IsEmpty() )
191 if( !rowPart.ToLong( &rowNum ) || rowNum < 0 )
209 sheet = aPath->
Last();
216 std::function<bool( wxString* )> tableCellResolver =
217 [&]( wxString* token ) ->
bool
219 if( token->IsSameAs( wxT(
"ROW" ) ) )
221 *token = wxString::Format( wxT(
"%d" ),
GetRow() );
224 else if( token->IsSameAs( wxT(
"COL" ) ) )
226 *token = wxString::Format( wxT(
"%d" ),
GetColumn() );
229 else if( token->IsSameAs( wxT(
"ADDR" ) ) )
234 else if( token->StartsWith( wxT(
"CELL(" ) ) && token->EndsWith( wxT(
")" ) ) )
237 wxString args = token->Mid( 5, token->Length() - 6 );
238 args.Trim(
true ).Trim(
false );
243 *token = wxT(
"<Unresolved: CELL() requires table context>" );
251 if( args.StartsWith( wxT(
"\"" ) ) && args.EndsWith( wxT(
"\"" ) ) )
253 wxString addr = args.Mid( 1, args.Length() - 2 );
256 *token = wxString::Format( wxT(
"<Unresolved: Invalid cell address: %s>" ), addr );
261 else if( args.Find(
',' ) != wxNOT_FOUND )
263 wxString rowStr = args.BeforeFirst(
',' ).Trim(
true ).Trim(
false );
264 wxString colStr = args.AfterFirst(
',' ).Trim(
true ).Trim(
false );
267 if( !rowStr.ToLong( &rowNum ) || !colStr.ToLong( &colNum ) )
269 *token = wxString::Format( wxT(
"<Unresolved: Invalid cell coordinates: %s>" ), args );
279 *token = wxString::Format( wxT(
"<Unresolved: Invalid CELL() syntax: %s>" ), args );
284 if( targetRow < 0 || targetRow >=
table->GetRowCount() || targetCol < 0
285 || targetCol >=
table->GetColCount() )
288 if( targetRow >= 0 && targetCol >= 0 )
290 char colLetter =
'A' + ( targetCol % 26 );
291 cellAddr = wxString::Format( wxT(
"%c%d" ), colLetter, targetRow );
297 *token = wxString::Format( wxT(
"<Unresolved: Cell %s not found>" ), cellAddr );
307 if( aDepth >= maxDepth )
309 *token = wxT(
"<Circular reference>" );
313 *token = targetCell->
GetShownText( aSettings, aPath, aContext, aDepth + 1 );
318 *token = wxT(
"<Unresolved: Cell not found>" );
394 int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
396 const int cell_body_style = -1;
399 SCH_TEXTBOX::Plot( aPlotter, aBackground, aPlotOpts, aUnit, cell_body_style, aOffset, aDimmed );
405 aList.emplace_back(
_(
"Table Cell" ),
GetAddr() );
413 aList.emplace_back(
_(
"Font" ),
GetFont() ?
GetFont()->GetName() :
_(
"Default" ) );
415 wxString textStyle[] = {
_(
"Normal" ),
_(
"Italic" ),
_(
"Bold" ),
_(
"Bold Italic" ) };
417 aList.emplace_back(
_(
"Style" ), textStyle[style] );
430 double similarity = 1.0;
451 return *
this == other;
501 const wxString tableProps =
_(
"Table" );
511 const wxString cellProps =
_(
"Cell Properties" );
constexpr EDA_IU_SCALE schIUScale
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual void SetFilled(bool aFlag)
void SetFillColor(const COLOR4D &aColor)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
COLOR4D GetFillColor() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual VECTOR2I GetTextSize() const
virtual const wxString & GetText() const
Return the string associated with the text object.
KIFONT::FONT * GetFont() const
virtual wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const
Return the string actually shown after processing of the base text.
virtual int GetTextWidth() const
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
virtual EDA_ANGLE GetTextAngle() const
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
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.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
PROPERTY_BASE & SetIsHiddenFromRulesEditor(bool aHide=true)
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_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
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.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const override
SCH_TABLECELL(int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool operator==(const SCH_TABLECELL &aOther) const
void SetRowSpan(int aSpan)
void SetColumnWidth(int aWidth)
void SetColSpan(int aSpan)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
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.
void SetRowHeight(int aHeight)
int GetColumnWidth() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
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.
int GetMarginBottom() const
bool operator==(const SCH_ITEM &aOther) const override
int GetMarginLeft() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
int GetMarginRight() const
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.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
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.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
void FinalizeTextVarExpansion(wxString &aText, RESOLUTION_CONTEXT aContext)
wxString ResolveTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, int &aDepth)
Multi-pass text variable expansion and math expression evaluation.
int m_ResolveTextRecursionDepth
The number of recursions to resolve text variables.
Message panel definition file.
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 PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ PT_SIZE
Size expressed in distance units (mm/inch)
static struct SCH_TABLECELL_DESC _SCH_TABLECELL_DESC
static bool parseCellAddress(const wxString &aAddr, int &aRow, int &aCol)
Parse a cell address string like "A0" or "B12" into 0-based row and column indices.
VECTOR2< int32_t > VECTOR2I