20#include <nlohmann/json.hpp>
24#include <wx/settings.h>
44 wxGridCellStringRenderer()
48 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
const wxRect& aRect,
int aRow,
int aCol,
49 bool isSelected )
override
51 wxString value = aGrid.GetCellValue( aRow, aCol );
54 value =
model->GetResolvedValue( aRow, aCol );
59 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
60 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
61 aGrid.DrawTextRectangle( aDC, value, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
64 wxSize
GetBestSize( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
int aRow,
int aCol )
override
66 wxString value = aGrid.GetCellValue( aRow, aCol );
69 value =
model->GetResolvedValue( aRow, aCol );
71 return wxGridCellStringRenderer::DoGetBestSize( aAttr, aDC, value );
102 default:
return wxT(
"unknown column" );
125 return rowData.
label;
130 return wxT(
"bad wxWidgets!" );
147 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
166 rowData.
label = aValue;
170 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a string value" ), aCol ) );
173 GetView()->Refresh();
189 wxFAIL_MSG( wxString::Format( wxT(
"column %d doesn't hold a bool value" ), aCol ) );
195 bool aShow,
bool aGroupBy )
199 if( wxGrid*
grid = GetView() )
201 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
202 grid->ProcessTableMessage( msg );
213 if( wxGrid*
grid = GetView() )
215 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow, 1 );
216 grid->ProcessTableMessage( msg );
223 wxCHECK( aRow >= 0 && aRow <
GetNumberRows(), wxEmptyString );
237 rowData.
name = aName;
246 bool aAddedByUser,
const wxString& aVariantName )
252 m_cols.push_back( { aFieldName, aLabel, aAddedByUser,
false,
false } );
260 const wxString& aFieldName,
261 const wxString& aVariantName )
276 if( field->IsPrivate() )
313 if( wxGrid*
grid = GetView() )
315 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_COLS_DELETED, aCol, 1 );
316 grid->ProcessTableMessage( msg );
331 node.key() = newName;
336 m_cols[aCol].m_fieldName = newName;
337 m_cols[aCol].m_label = newName;
343 for(
size_t i = 0; i <
m_cols.size(); i++ )
345 if(
m_cols[i].m_fieldName.CmpNoCase( aFieldName ) == 0 )
346 return static_cast<int>( i );
355 std::vector<BOM_FIELD> fields;
358 fields.push_back( { col.m_fieldName, col.m_label, col.m_show, col.m_group } );
366 size_t foundCount = 0;
368 for(
const wxString& newField : aNewOrder )
370 if( foundCount >=
m_cols.size() )
375 if( col.m_fieldName == newField )
377 std::swap(
m_cols[foundCount], col );
389 for(
int col = 0; col < aCol; ++col )
408 return GetValue(
m_rows[aRow], aCol, wxT(
", " ), wxT(
"-" ),
true,
false );
414 wxGridCellAttr* attr =
nullptr;
415 bool needsUrlEditor =
false;
416 bool needsVariantHighlight =
false;
417 bool needsTextVarRenderer =
false;
418 wxColour highlightColor;
425 needsUrlEditor =
true;
434 if( rawValue.Contains( wxT(
"${" ) ) )
435 needsTextVarRenderer =
true;
440 && aCol >= 0 && aCol < (
int)
m_cols.size() )
442 const wxString& fieldName =
m_cols[aCol].m_fieldName;
459 symbolKey.push_back( symbol->m_Uuid );
463 wxString currentValue;
468 if( currentValue != defaultValue )
470 needsVariantHighlight =
true;
473 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
474 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
477 highlightColor = wxColour( 80, 80, 40 );
479 highlightColor = wxColour( 255, 255, 200 );
488 if( !needsUrlEditor && !needsVariantHighlight && !needsTextVarRenderer )
494 if( needsVariantHighlight )
498 attr->SetBackgroundColour( highlightColor );
518 attr =
new wxGridCellAttr();
521 if( needsVariantHighlight )
522 attr->SetBackgroundColour( highlightColor );
524 if( needsTextVarRenderer )
533 if( !needsVariantHighlight )
535 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
536 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
538 attr->SetBackgroundColour( isDark ? wxColour( 80, 70, 30 )
539 : wxColour( 255, 252, 200 ) );
548 const wxString& refDelimiter,
549 const wxString& refRangeDelimiter,
551 bool listMixedValues )
553 std::vector<SCH_REFERENCE> references;
554 std::set<wxString> mixedValues;
561 references.push_back( ref );
580 else if( refFieldValue.Contains( wxT(
"${" ) ) )
584 std::function<bool( wxString* )> symbolResolver =
585 [&]( wxString* token ) ->
bool
590 refFieldValue =
ExpandTextVars( refFieldValue, & symbolResolver );
594 if( listMixedValues )
595 mixedValues.insert( refFieldValue );
596 else if( &ref == &
group.m_Refs.front() )
597 fieldValue = refFieldValue;
598 else if( fieldValue != refFieldValue )
603 if( listMixedValues )
605 fieldValue = wxEmptyString;
607 for(
const wxString& value : mixedValues )
609 if( value.IsEmpty() )
611 else if( fieldValue.IsEmpty() )
614 fieldValue +=
"," + value;
621 std::sort( references.begin(), references.end(),
624 wxString l_ref( l.GetRef() << l.GetRefNumber() );
625 wxString r_ref( r.GetRef() << r.GetRefNumber() );
626 return StrNumCmp( l_ref, r_ref, true ) < 0;
629 auto logicalEnd = std::unique( references.begin(), references.end(),
634 if( l.GetRefNumber() == wxT(
"?" ) )
637 wxString l_ref( l.GetRef() << l.GetRefNumber() );
638 wxString r_ref( r.GetRef() << r.GetRefNumber() );
639 return l_ref == r_ref;
642 references.erase( logicalEnd, references.end() );
648 fieldValue = wxString::Format( wxT(
"%d" ), (
int) references.size() );
650 fieldValue = wxString::Format( wxT(
"%d" ),
group.m_ItemNumber );
658 wxCHECK_RET( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ), wxS(
"Invalid column number" ) );
673 bool isSharedInstance =
false;
682 screen =
static_cast<const SCH_SCREEN*
>( symbol->GetParent() );
684 isSharedInstance = ( screen && ( screen->
GetRefCount() > 1 ) );
685 sharedSymbol = symbol;
698 if( row.m_ItemNumber == aRow + 1 )
718 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
725 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
732 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
739 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
746 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
757 if( lhGroup.
m_Refs.size() == 0 )
759 else if( rhGroup.
m_Refs.size() == 0 )
765 [ ascending ](
const auto a,
const auto b )
777 wxString lhs = dataModel->
GetValue( lhGroup, sortCol, wxT(
", " ), wxT(
"-" ),
true ).Trim(
true ).Trim(
false );
778 wxString rhs = dataModel->
GetValue( rhGroup, sortCol, wxT(
", " ), wxT(
"-" ),
true ).Trim(
true ).Trim(
false );
782 wxString lhRef = lhGroup.
m_Refs[0].GetRef() + lhGroup.
m_Refs[0].GetRefNumber();
783 wxString rhRef = rhGroup.
m_Refs[0].GetRef() + rhGroup.
m_Refs[0].GetRefNumber();
784 return local_cmp(
StrNumCmp( lhRef, rhRef,
true ), 0 );
801 std::sort( row.m_Refs.begin(), row.m_Refs.end(),
804 wxString lhs_ref( lhs.GetRef() << lhs.GetRefNumber() );
805 wxString rhs_ref( rhs.GetRef() << rhs.GetRefNumber() );
806 return StrNumCmp( lhs_ref, rhs_ref, true ) < 0;
813 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
821 row.m_ItemNumber = itemNumber++;
841 bool matchFound =
false;
848 if(
m_cols[refCol].m_group )
861 for(
size_t i = 0; i <
m_cols.size(); ++i )
864 if(
static_cast<int>( i ) == refCol )
906 const wxString& aFieldName )
913 return wxEmptyString;
925 std::function<bool( wxString* )> symbolResolver =
926 [&]( wxString* token ) ->
bool
934 return wxEmptyString;
940 return aFieldName == wxS(
"${DNP}" )
941 || aFieldName == wxS(
"${EXCLUDE_FROM_BOARD}" )
942 || aFieldName == wxS(
"${EXCLUDE_FROM_BOM}" )
943 || aFieldName == wxS(
"${EXCLUDE_FROM_SIM}" );
948 const wxString& aVariantName )
950 if( aAttributeName == wxS(
"${DNP}" ) )
951 return aRef.
GetSymbolDNP( aVariantName ) ? wxS(
"1" ) : wxS(
"0" );
953 if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
956 if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
959 if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
967 const wxString& aFieldName )
972 return wxEmptyString;
981 if( field->IsPrivate() )
982 return wxEmptyString;
986 field->GetText( &aRef.
GetSheetPath(), wxEmptyString ) );
994 return wxEmptyString;
999 const wxString& aAttributeName,
1000 const wxString& aValue,
1001 const wxString& aVariantName )
1003 bool attrChanged =
false;
1004 bool newValue = aValue == wxS(
"1" );
1006 if( aAttributeName == wxS(
"${DNP}" ) )
1008 attrChanged = aRef.
GetSymbolDNP( aVariantName ) != newValue;
1011 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
1016 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
1021 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
1052 static_cast<WX_GRID*
>( GetView() )->CommitPendingChanges(
true );
1054 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0,
m_rows.size() );
1055 GetView()->ProcessTableMessage( msg );
1097 bool isExcluded =
false;
1124 || (
m_scope == SCOPE::SCOPE_SHEET_RECURSIVE
1130 bool matchFound =
false;
1148 row.m_Refs.push_back( ref );
1154 row.m_Refs.push_back( ref );
1166 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_rows.size() );
1167 GetView()->ProcessTableMessage( msg );
1176 std::vector<DATA_MODEL_ROW> children;
1180 bool matchFound =
false;
1190 child.m_Refs.push_back( ref );
1199 if( children.size() < 2 )
1202 std::sort( children.begin(), children.end(),
1205 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
1209 m_rows.insert(
m_rows.begin() + aRow + 1, children.begin(), children.end() );
1211 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, aRow, children.size() );
1212 GetView()->ProcessTableMessage( msg );
1218 auto firstChild =
m_rows.begin() + aRow + 1;
1219 auto afterLastChild = firstChild;
1222 while( afterLastChild !=
m_rows.end() && afterLastChild->m_Flag == CHILD_ITEM )
1229 m_rows.erase( firstChild, afterLastChild );
1231 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow + 1, deleted );
1232 GetView()->ProcessTableMessage( msg );
1249 for(
size_t i = 0; i <
m_rows.size(); ++i )
1262 for(
size_t i = 0; i <
m_rows.size(); ++i )
1271 const wxString& aVariantName )
1273 bool symbolModified =
false;
1274 std::unique_ptr<SCH_SYMBOL> symbolCopy;
1285 symbolCopy = std::make_unique<SCH_SYMBOL>( *symbol );
1288 const std::map<wxString, wxString>& fieldStore =
m_dataStore[key];
1290 for(
const auto& [srcName, srcValue] : fieldStore )
1308 destField->
SetName( srcName );
1309 symbolModified =
true;
1312 if( destField && destField->
IsPrivate() )
1314 if( srcValue.IsEmpty() )
1321 bool userAdded = ( col != -1 &&
m_cols[col].m_userAdded );
1324 bool createField = !destField && ( !srcValue.IsEmpty() || userAdded );
1332 destField->
SetVisible( srcTemplate->m_Visible );
1337 symbolModified =
true;
1352 if( !createField && ( previousValue != srcValue ) )
1353 symbolModified =
true;
1356 for(
int ii =
static_cast<int>( symbol->
GetFields().size() ) - 1; ii >= 0; ii-- )
1361 const wxString& existingName = symbol->
GetFields()[ii].GetName();
1363 bool stillTracked = std::any_of( fieldStore.begin(), fieldStore.end(),
1364 [&](
const auto&
kv )
1366 return kv.first.IsSameAs( existingName, false );
1372 symbolModified =
true;
1376 if( symbolModified && ( symbol != nextSymbol ) )
1380 if( symbol != nextSymbol )
1383 symbolCopy = std::make_unique<SCH_SYMBOL>( *nextSymbol );
1385 symbolCopy.reset(
nullptr );
1387 symbolModified =
false;
1408 for(
unsigned symbolRef = 0; symbolRef <
m_symbolsList.GetCount(); ++symbolRef )
1425 for(
size_t i = 0; i <
m_cols.size(); i++ )
1431 std::set<wxString> seen;
1432 std::vector<wxString> order;
1438 if( !field.
name || seen.count( field.
name ) )
1441 seen.insert( field.
name );
1442 order.emplace_back( field.
name );
1513 for(
size_t col = 0; col <
m_cols.size(); col++ )
1516 last_col =
static_cast<int>( col );
1520 if( last_col == -1 )
1524 [&]( wxString field,
bool last ) -> wxString
1528 field.Replace( wxS(
"\r" ), wxS(
"" ) );
1529 field.Replace( wxS(
"\n" ), wxS(
"" ) );
1534 field.Replace( wxS(
"\t" ), wxS(
"" ) );
1548 for(
size_t col = 0; col <
m_cols.size(); col++ )
1550 if( !
m_cols[col].m_show )
1553 out.Append( formatField(
m_cols[col].m_label, col ==
static_cast<size_t>( last_col ) ) );
1557 for(
size_t row = 0; row <
m_rows.size(); row++ )
1560 if(
GetRowFlags(
static_cast<int>( row ) ) == CHILD_ITEM )
1563 for(
size_t col = 0; col <
m_cols.size(); col++ )
1565 if( !
m_cols[col].m_show )
1569 out.Append( formatField(
GetExportValue(
static_cast<int>( row ),
static_cast<int>( col ),
1571 col ==
static_cast<size_t>( last_col ) ) );
1581 bool refListChanged =
false;
1596 if( !field.IsPrivate() )
1598 wxString
name = field.GetCanonicalName();
1606 m_dataStore[key].try_emplace( col.m_fieldName, wxEmptyString );
1608 refListChanged =
true;
1612 if( refListChanged )
1626 std::vector<KIID_PATH> keysToRemove;
1630 if( !key.empty() && ( key.back() == symbolUuid ) )
1631 keysToRemove.push_back( key );
1634 for(
const KIID_PATH& key : keysToRemove )
1641 return ref.GetSymbol()->m_Uuid == aSymbol.m_Uuid;
1664 const wxString& aVariantName )
1666 bool refListChanged =
false;
1683 refListChanged =
true;
1687 if( refListChanged )
1696 nlohmann::json j = nlohmann::json::object();
1700 nlohmann::json jfields = nlohmann::json::object();
1702 for(
const auto& [
name, value] : fields )
1703 jfields[std::string(
name.ToUTF8() )] = std::string( value.ToUTF8() );
1705 j[std::string( key.AsString().ToUTF8() )] = jfields;
1708 return wxString( j.dump() );
1714 nlohmann::json j = nlohmann::json::parse( aState.ToStdString(),
nullptr,
false );
1716 if( !j.is_object() )
1719 for(
auto it = j.begin(); it != j.end(); ++it )
1721 KIID_PATH key( wxString::FromUTF8( it.key().c_str() ) );
1722 std::map<wxString, wxString>& fields =
m_dataStore[key];
1724 for(
auto fit = it.value().begin(); fit != it.value().end(); ++fit )
1725 fields[wxString::FromUTF8( fit.key().c_str() )] =
1726 wxString::FromUTF8( fit.value().get<std::string>().c_str() );
1733 GetView()->ForceRefresh();
1739 size_t curNumRows =
m_rows.size();
1741 if( aPosition >= curNumRows )
1743 wxFAIL_MSG( wxString::Format( wxT(
"Called FIELDS_EDITOR_GRID_DATA_MODEL::DeleteRows(aPosition=%lu, "
1744 "aNumRows=%lu)\nPosition value is invalid for present table with %lu rows" ),
1745 (
unsigned long) aPosition, (
unsigned long) aNumRows,
1746 (
unsigned long) curNumRows ) );
1751 if( aNumRows > curNumRows - aPosition )
1753 aNumRows = curNumRows - aPosition;
1756 if( aNumRows >= curNumRows )
1763 const auto first =
m_rows.begin() + aPosition;
1764 std::vector<SCH_REFERENCE> dataMapRefs = first->m_Refs;
1765 m_rows.erase( first, first + aNumRows );
1773 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPosition, aNumRows );
1774 GetView()->ProcessTableMessage( msg );
1783 std::vector<FIELD_CASE_CONFLICT> conflicts;
1785 for(
unsigned i = 0; i < aSymbols.
GetCount(); ++i )
1787 SCH_SYMBOL* symbol = aSymbols[i].GetSymbol();
1792 std::map<wxString, std::vector<std::pair<wxString, wxString>>> groups;
1796 if( field.IsMandatory() || field.IsPrivate() )
1799 groups[field.GetName().Lower()].emplace_back( field.GetName(), field.GetText() );
1802 for(
const auto& [key, members] : groups )
1804 if( members.size() < 2 )
1809 c.
sheetPath = aSymbols[i].GetSheetPath();
1813 conflicts.push_back( std::move( c ) );
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Look in all existing matchers, return the earliest match of any of the existing.
const EDA_ANGLE & GetTextAngle() const
void SetTextPos(const VECTOR2I &aPoint)
virtual void SetVisible(bool aVisible)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
int GetFieldNameCol(const wxString &aFieldName) const
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser, const wxString &aVariantName)
wxString GetColFieldName(int aCol)
std::vector< DATA_MODEL_ROW > m_rows
void SetFieldsOrder(const std::vector< wxString > &aNewOrder)
SCH_REFERENCE_LIST m_symbolsList
The flattened by hierarchy list of symbols.
void SetGroupingEnabled(bool group)
wxGridCellRenderer * m_textVarRenderer
Renderer for cells with text variable references.
void UpdateReferences(const SCH_REFERENCE_LIST &aRefs, const wxString &aVariantName)
bool ColIsItemNumber(int aCol)
int GetNumberCols() override
bool ColIsQuantity(int aCol)
wxString m_currentVariant
Current variant name for highlighting.
bool DeleteRows(size_t aPosition=0, size_t aNumRows=1) override
bool groupMatch(const SCH_REFERENCE &lhRef, const SCH_REFERENCE &rhRef)
wxGridCellAttr * m_urlEditor
void updateDataStoreSymbolField(const SCH_REFERENCE &aSymbolRef, const wxString &aFieldName, const wxString &aVariantName)
BOM_PRESET GetBomSettings()
bool unitMatch(const SCH_REFERENCE &lhRef, const SCH_REFERENCE &rhRef)
wxString SerializeUndoState() const override
wxString getAttributeValue(const SCH_REFERENCE &aRef, const wxString &aAttributeName, const wxString &aVariantNames)
bool ColIsReference(int aCol)
wxString GetExportValue(int aRow, int aCol, const wxString &refDelimiter, const wxString &refRangeDelimiter)
bool GetGroupingEnabled()
wxString getDefaultFieldValue(const SCH_REFERENCE &aRef, const wxString &aFieldName)
Get the default (non-variant) value for a field.
int GetNumberRows() override
void CollapseRow(int aRow)
wxString getFieldShownText(const SCH_REFERENCE &aRef, const wxString &aFieldName)
wxString GetResolvedValue(int aRow, int aCol)
void RenameColumn(int aCol, const wxString &newName)
FIELDS_EDITOR_GRID_DATA_MODEL(const SCH_REFERENCE_LIST &aSymbolsList, wxGridCellAttr *aURLEditor)
bool IsExpanderColumn(int aCol) const override
wxString Export(const BOM_FMT_PRESET &settings)
std::vector< wxString > m_variantNames
Variant names for multi-variant DNP filtering.
std::vector< DATA_MODEL_COL > m_cols
void SetSorting(int aCol, bool ascending)
void ExpandCollapseRow(int aRow)
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
void SetFilter(const wxString &aFilter)
bool setAttributeValue(SCH_REFERENCE &aRef, const wxString &aAttributeName, const wxString &aValue, const wxString &aVariantName=wxEmptyString)
Set the attribute value.
void RestoreUndoState(const wxString &aState) override
static bool cmp(const DATA_MODEL_ROW &lhGroup, const DATA_MODEL_ROW &rhGroup, FIELDS_EDITOR_GRID_DATA_MODEL *dataModel, int sortCol, bool ascending)
void ApplyBomPreset(const BOM_PRESET &preset, const wxString &aVariantName)
static const wxString ITEM_NUMBER_VARIABLE
void SetIncludeExcludedFromBOM(bool include)
bool isAttribute(const wxString &aFieldName)
wxString GetValue(int aRow, int aCol) override
int GetDataWidth(int aCol)
void RemoveColumn(int aCol)
GROUP_TYPE GetRowFlags(int aRow)
const wxString & GetFilter()
static const wxString QUANTITY_VARIABLE
bool ColIsValue(int aCol)
void SetGroupColumn(int aCol, bool group)
void SetExcludeDNP(bool exclude)
void RemoveSymbol(const SCH_SYMBOL &aSymbol)
std::vector< BOM_FIELD > GetFieldsOrdered()
void SetValue(int aRow, int aCol, const wxString &aValue) override
std::map< KIID_PATH, std::map< wxString, wxString > > m_dataStore
bool ColIsAttribute(int aCol)
void ApplyData(SCH_COMMIT &aCommit, TEMPLATES &aTemplateFieldnames, const wxString &aVariantName)
void SetColLabelValue(int aCol, const wxString &aLabel) override
void SetCurrentVariant(const wxString &aVariantName)
Set the current variant name for highlighting purposes.
void RemoveReferences(const SCH_REFERENCE_LIST &aRefs)
bool GetIncludeExcludedFromBOM()
void SetShowColumn(int aCol, bool show)
void AddReferences(const SCH_REFERENCE_LIST &aRefs)
Cell renderer that shows the expanded result of text variables (e.g.
GRID_CELL_RESOLVED_TEXT_RENDERER()
wxSize GetBestSize(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, int aRow, int aCol) override
wxGridCellRenderer * Clone() const override
void Draw(wxGrid &aGrid, wxGridCellAttr &aAttr, wxDC &aDC, const wxRect &aRect, int aRow, int aCol, bool isSelected) override
wxString ConvertKIIDsToRefs(const wxString &aSource) const
wxString ConvertRefsToKIIDs(const wxString &aSource) const
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
void SetPrivate(bool aPrivate)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool ResolveExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
bool ResolveDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
static wxString Shorthand(std::vector< SCH_REFERENCE > aList, const wxString &refDelimiter, const wxString &refRangeDelimiter)
Return a shorthand string representing all the references in the list.
A helper to define a symbol's reference designator in a schematic.
void SetSymbolExcludedFromBoard(bool aEnable)
const SCH_SHEET_PATH & GetSheetPath() const
void SetSymbolExcludedFromBOM(bool aEnable, const wxString &aVariant=wxEmptyString)
bool GetSymbolExcludedFromBOM(const wxString &aVariant=wxEmptyString) const
bool GetSymbolDNP(const wxString &aVariant=wxEmptyString) const
SCH_SYMBOL * GetSymbol() const
void SetSymbolExcludedFromSim(bool aEnable, const wxString &aVariant=wxEmptyString)
bool GetSymbolExcludedFromBoard() const
wxString GetFullRef(bool aIncludeUnit=true) const
Return reference name with unit altogether.
bool GetSymbolExcludedFromSim(const wxString &aVariant=wxEmptyString) const
wxString GetRefNumber() const
void SetSymbolDNP(bool aEnable, const wxString &aVariant=wxEmptyString)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool GetExcludedFromBOM() const
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
bool IsContainedWithin(const SCH_SHEET_PATH &aSheetPathToTest) const
Check if this path is contained inside aSheetPathToTest.
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
Search for a SCH_FIELD with aFieldName.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
VECTOR2I GetPosition() const override
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
void SetValueAsBool(int aRow, int aCol, bool aValue) override
wxString GetCanonicalFieldName(int aRow)
wxString GetColLabelValue(int aCol) override
std::vector< BOM_FIELD > m_fields
void SetValue(int aRow, int aCol, const wxString &aValue) override
int GetNumberRows() override
void AppendRow(const wxString &aFieldName, const wxString &aBOMName, bool aShow, bool aGroupBy)
bool GetValueAsBool(int aRow, int aCol) override
void SetCanonicalFieldName(int aRow, const wxString &aName)
wxString GetValue(int aRow, int aCol) override
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
std::map< int, wxGridCellAttr * > m_colAttrs
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
bool IsGeneratedField(const wxString &aSource)
Returns true if the string is generated, e.g contains a single text var reference.
std::vector< FIELD_CASE_CONFLICT > DetectFieldCaseConflicts(const SCH_REFERENCE_LIST &aSymbols)
static KIID_PATH makeDataStoreKey(const SCH_SHEET_PATH &aSheetPath, const SCH_SYMBOL &aSymbol)
Create a unique key for the data store by combining the KIID_PATH from the SCH_SHEET_PATH with the sy...
#define DISPLAY_NAME_COLUMN
#define SHOW_FIELD_COLUMN
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
int ValueStringCompare(const wxString &strFWord, const wxString &strSWord)
Compare strings like the strcmp function but handle numbers and modifiers within the string text corr...
bool IsURL(wxString aStr)
Performs a URL sniff-test on a string.
wxString refRangeDelimiter
std::vector< BOM_FIELD > fieldsOrdered
bool includeExcludedFromBOM
std::vector< SCH_REFERENCE > m_Refs
std::vector< std::pair< wxString, wxString > > variants
Hold a name of a symbol's field, field value, and default visibility.
wxString GetDefaultFieldName(FIELD_T aFieldId, bool aTranslateForHI)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
wxString GetCanonicalFieldName(FIELD_T aFieldType)
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
GROUP_COLLAPSED_DURING_SORT