32#include <api/schematic/schematic_types.pb.h>
54 kiapi::schematic::types::SchematicTableCell cell;
57 if( !aContainer.PackFrom( cell ) )
58 wxFAIL_MSG( wxT(
"Failed to pack SCH_TABLECELL" ) );
64 if( !aCell.has_text_box() )
81 kiapi::schematic::types::SchematicTableCell cell;
83 if( !aContainer.UnpackTo( &cell ) )
105 return wxString::Format(
_(
"Table Cell %s" ),
GetAddr() );
113 for(
int row = 0; row <
table->GetRowCount(); ++row )
115 for(
int col = 0; col <
table->GetColCount(); ++col )
117 if(
table->GetCell( row, col ) ==
this )
130 for(
int row = 0; row <
table->GetRowCount(); ++row )
132 for(
int col = 0; col <
table->GetColCount(); ++col )
134 if(
table->GetCell( row, col ) ==
this )
145 return wxString::Format( wxT(
"%c%d" ),
'A' +
GetColumn() % 26,
GetRow() );
161 if( aAddr.IsEmpty() )
169 while( i < aAddr.Length() && wxIsalpha( aAddr[i] ) )
171 colPart += wxToupper( aAddr[i] );
176 if( colPart.IsEmpty() )
181 for(
size_t j = 0; j < colPart.Length(); j++ )
183 aCol = aCol * 26 + ( colPart[j] -
'A' + 1 );
188 wxString rowPart = aAddr.Mid( i );
189 if( rowPart.IsEmpty() )
194 if( !rowPart.ToLong( &rowNum ) || rowNum < 0 )
212 sheet = aPath->
Last();
219 std::function<bool( wxString* )> tableCellResolver =
220 [&]( wxString* token ) ->
bool
222 if( token->IsSameAs( wxT(
"ROW" ) ) )
224 *token = wxString::Format( wxT(
"%d" ),
GetRow() );
227 else if( token->IsSameAs( wxT(
"COL" ) ) )
229 *token = wxString::Format( wxT(
"%d" ),
GetColumn() );
232 else if( token->IsSameAs( wxT(
"ADDR" ) ) )
237 else if( token->StartsWith( wxT(
"CELL(" ) ) && token->EndsWith( wxT(
")" ) ) )
240 wxString args = token->Mid( 5, token->Length() - 6 );
241 args.Trim(
true ).Trim(
false );
246 *token = wxT(
"<Unresolved: CELL() requires table context>" );
254 if( args.StartsWith( wxT(
"\"" ) ) && args.EndsWith( wxT(
"\"" ) ) )
256 wxString addr = args.Mid( 1, args.Length() - 2 );
259 *token = wxString::Format( wxT(
"<Unresolved: Invalid cell address: %s>" ), addr );
264 else if( args.Find(
',' ) != wxNOT_FOUND )
266 wxString rowStr = args.BeforeFirst(
',' ).Trim(
true ).Trim(
false );
267 wxString colStr = args.AfterFirst(
',' ).Trim(
true ).Trim(
false );
270 if( !rowStr.ToLong( &rowNum ) || !colStr.ToLong( &colNum ) )
272 *token = wxString::Format( wxT(
"<Unresolved: Invalid cell coordinates: %s>" ), args );
282 *token = wxString::Format( wxT(
"<Unresolved: Invalid CELL() syntax: %s>" ), args );
287 if( targetRow < 0 || targetRow >=
table->GetRowCount() || targetCol < 0
288 || targetCol >=
table->GetColCount() )
291 if( targetRow >= 0 && targetCol >= 0 )
293 char colLetter =
'A' + ( targetCol % 26 );
294 cellAddr = wxString::Format( wxT(
"%c%d" ), colLetter, targetRow );
300 *token = wxString::Format( wxT(
"<Unresolved: Cell %s not found>" ), cellAddr );
310 if( aDepth >= maxDepth )
312 *token = wxT(
"<Circular reference>" );
316 *token = targetCell->
GetShownText( aSettings, aPath, aContext, aDepth + 1 );
321 *token = wxT(
"<Unresolved: Cell not found>" );
397 int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
399 const int cell_body_style = -1;
402 SCH_TEXTBOX::Plot( aPlotter, aBackground, aPlotOpts, aUnit, cell_body_style, aOffset, aDimmed );
408 aList.emplace_back(
_(
"Table Cell" ),
GetAddr() );
416 aList.emplace_back(
_(
"Font" ),
GetFont() ?
GetFont()->GetName() :
_(
"Default" ) );
418 wxString textStyle[] = {
_(
"Normal" ),
_(
"Italic" ),
_(
"Bold" ),
_(
"Bold Italic" ) };
420 aList.emplace_back(
_(
"Style" ), textStyle[style] );
433 double similarity = 1.0;
454 return *
this == other;
504 const wxString tableProps =
_(
"Table" );
514 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)
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)
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
@ PT_SIZE
Size expressed in distance units (mm/inch)
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
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