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 )
401 GetView()->SetReadOnly( aRow, aCol,
409 return GetValue(
m_rows[aRow], aCol, wxT(
", " ), wxT(
"-" ),
true,
false );
415 wxGridCellAttr* attr =
nullptr;
416 bool needsUrlEditor =
false;
417 bool needsVariantHighlight =
false;
418 bool needsTextVarRenderer =
false;
419 wxColour highlightColor;
426 needsUrlEditor =
true;
435 if( rawValue.Contains( wxT(
"${" ) ) )
436 needsTextVarRenderer =
true;
441 && aCol >= 0 && aCol < (
int)
m_cols.size() )
443 const wxString& fieldName =
m_cols[aCol].m_fieldName;
460 symbolKey.push_back( symbol->m_Uuid );
464 wxString currentValue;
469 if( currentValue != defaultValue )
471 needsVariantHighlight =
true;
474 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
475 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
478 highlightColor = wxColour( 80, 80, 40 );
480 highlightColor = wxColour( 255, 255, 200 );
489 if( !needsUrlEditor && !needsVariantHighlight && !needsTextVarRenderer )
495 if( needsVariantHighlight )
499 attr->SetBackgroundColour( highlightColor );
519 attr =
new wxGridCellAttr();
522 if( needsVariantHighlight )
523 attr->SetBackgroundColour( highlightColor );
525 if( needsTextVarRenderer )
534 if( !needsVariantHighlight )
536 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
537 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
539 attr->SetBackgroundColour( isDark ? wxColour( 80, 70, 30 )
540 : wxColour( 255, 252, 200 ) );
549 const wxString& refDelimiter,
550 const wxString& refRangeDelimiter,
552 bool listMixedValues )
554 std::vector<SCH_REFERENCE> references;
555 std::set<wxString> mixedValues;
562 references.push_back( ref );
576 refFieldValue = wxS(
"1" );
586 else if( refFieldValue.Contains( wxT(
"${" ) ) )
590 std::function<bool( wxString* )> symbolResolver =
591 [&]( wxString* token ) ->
bool
596 refFieldValue =
ExpandTextVars( refFieldValue, & symbolResolver );
600 if( listMixedValues )
601 mixedValues.insert( refFieldValue );
602 else if( &ref == &
group.m_Refs.front() )
603 fieldValue = refFieldValue;
604 else if( fieldValue != refFieldValue )
609 if( listMixedValues )
611 fieldValue = wxEmptyString;
613 for(
const wxString& value : mixedValues )
615 if( value.IsEmpty() )
617 else if( fieldValue.IsEmpty() )
620 fieldValue +=
"," + value;
627 std::sort( references.begin(), references.end(),
630 wxString l_ref( l.GetRef() << l.GetRefNumber() );
631 wxString r_ref( r.GetRef() << r.GetRefNumber() );
632 return StrNumCmp( l_ref, r_ref, true ) < 0;
635 auto logicalEnd = std::unique( references.begin(), references.end(),
640 if( l.GetRefNumber() == wxT(
"?" ) )
643 wxString l_ref( l.GetRef() << l.GetRefNumber() );
644 wxString r_ref( r.GetRef() << r.GetRefNumber() );
645 return l_ref == r_ref;
648 references.erase( logicalEnd, references.end() );
654 fieldValue = wxString::Format( wxT(
"%d" ), (
int) references.size() );
656 fieldValue = wxString::Format( wxT(
"%d" ),
group.m_ItemNumber );
664 wxCHECK_RET( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ), wxS(
"Invalid column number" ) );
679 bool isSharedInstance =
false;
688 screen =
static_cast<const SCH_SCREEN*
>( symbol->GetParent() );
690 isSharedInstance = ( screen && ( screen->
GetRefCount() > 1 ) );
691 sharedSymbol = symbol;
704 if( row.m_ItemNumber == aRow + 1 )
724 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
731 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
738 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
745 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
752 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
763 if( lhGroup.
m_Refs.size() == 0 )
765 else if( rhGroup.
m_Refs.size() == 0 )
771 [ ascending ](
const auto a,
const auto b )
783 wxString lhs = dataModel->
GetValue( lhGroup, sortCol, wxT(
", " ), wxT(
"-" ),
true ).Trim(
true ).Trim(
false );
784 wxString rhs = dataModel->
GetValue( rhGroup, sortCol, wxT(
", " ), wxT(
"-" ),
true ).Trim(
true ).Trim(
false );
788 wxString lhRef = lhGroup.
m_Refs[0].GetRef() + lhGroup.
m_Refs[0].GetRefNumber();
789 wxString rhRef = rhGroup.
m_Refs[0].GetRef() + rhGroup.
m_Refs[0].GetRefNumber();
790 return local_cmp(
StrNumCmp( lhRef, rhRef,
true ), 0 );
807 std::sort( row.m_Refs.begin(), row.m_Refs.end(),
810 wxString lhs_ref( lhs.GetRef() << lhs.GetRefNumber() );
811 wxString rhs_ref( rhs.GetRef() << rhs.GetRefNumber() );
812 return StrNumCmp( lhs_ref, rhs_ref, true ) < 0;
819 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
827 row.m_ItemNumber = itemNumber++;
847 bool matchFound =
false;
854 if(
m_cols[refCol].m_group )
867 for(
size_t i = 0; i <
m_cols.size(); ++i )
870 if(
static_cast<int>( i ) == refCol )
912 const wxString& aFieldName )
919 return wxEmptyString;
931 std::function<bool( wxString* )> symbolResolver =
932 [&]( wxString* token ) ->
bool
940 return wxEmptyString;
946 return aFieldName == wxS(
"${DNP}" )
947 || aFieldName == wxS(
"${EXCLUDE_FROM_BOARD}" )
948 || aFieldName == wxS(
"${EXCLUDE_FROM_BOM}" )
949 || aFieldName == wxS(
"${EXCLUDE_FROM_SIM}" );
954 const wxString& aVariantName )
956 if( aAttributeName == wxS(
"${DNP}" ) )
957 return aRef.
GetSymbolDNP( aVariantName ) ? wxS(
"1" ) : wxS(
"0" );
959 if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
962 if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
965 if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
973 const wxString& aAttributeName )
const
977 if( aAttributeName == wxS(
"${DNP}" ) )
979 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
981 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
983 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
1008 const wxString& aFieldName )
1013 return wxEmptyString;
1022 if( field->IsPrivate() )
1023 return wxEmptyString;
1027 field->GetText( &aRef.
GetSheetPath(), wxEmptyString ) );
1035 return wxEmptyString;
1040 const wxString& aAttributeName,
1041 const wxString& aValue,
1042 const wxString& aVariantName )
1044 bool attrChanged =
false;
1045 bool newValue = aValue == wxS(
"1" );
1047 if( aAttributeName == wxS(
"${DNP}" ) )
1049 attrChanged = aRef.
GetSymbolDNP( aVariantName ) != newValue;
1052 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
1057 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
1062 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
1093 static_cast<WX_GRID*
>( GetView() )->CommitPendingChanges(
true );
1095 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0,
m_rows.size() );
1096 GetView()->ProcessTableMessage( msg );
1138 bool isExcluded =
false;
1165 || (
m_scope == SCOPE::SCOPE_SHEET_RECURSIVE
1171 bool matchFound =
false;
1189 row.m_Refs.push_back( ref );
1195 row.m_Refs.push_back( ref );
1207 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_rows.size() );
1208 GetView()->ProcessTableMessage( msg );
1217 std::vector<DATA_MODEL_ROW> children;
1221 bool matchFound =
false;
1231 child.m_Refs.push_back( ref );
1240 if( children.size() < 2 )
1243 std::sort( children.begin(), children.end(),
1246 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
1250 m_rows.insert(
m_rows.begin() + aRow + 1, children.begin(), children.end() );
1252 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, aRow, children.size() );
1253 GetView()->ProcessTableMessage( msg );
1259 auto firstChild =
m_rows.begin() + aRow + 1;
1260 auto afterLastChild = firstChild;
1263 while( afterLastChild !=
m_rows.end() && afterLastChild->m_Flag == CHILD_ITEM )
1270 m_rows.erase( firstChild, afterLastChild );
1272 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow + 1, deleted );
1273 GetView()->ProcessTableMessage( msg );
1290 for(
size_t i = 0; i <
m_rows.size(); ++i )
1303 for(
size_t i = 0; i <
m_rows.size(); ++i )
1312 const wxString& aVariantName )
1314 bool symbolModified =
false;
1315 std::unique_ptr<SCH_SYMBOL> symbolCopy;
1326 symbolCopy = std::make_unique<SCH_SYMBOL>( *symbol );
1329 const std::map<wxString, wxString>& fieldStore =
m_dataStore[key];
1331 for(
const auto& [srcName, srcValue] : fieldStore )
1349 destField->
SetName( srcName );
1350 symbolModified =
true;
1353 if( destField && destField->
IsPrivate() )
1355 if( srcValue.IsEmpty() )
1362 bool userAdded = ( col != -1 &&
m_cols[col].m_userAdded );
1365 bool createField = !destField && ( !srcValue.IsEmpty() || userAdded );
1373 destField->
SetVisible( srcTemplate->m_Visible );
1378 symbolModified =
true;
1393 if( !createField && ( previousValue != srcValue ) )
1394 symbolModified =
true;
1397 for(
int ii =
static_cast<int>( symbol->
GetFields().size() ) - 1; ii >= 0; ii-- )
1402 const wxString& existingName = symbol->
GetFields()[ii].GetName();
1404 bool stillTracked = std::any_of( fieldStore.begin(), fieldStore.end(),
1405 [&](
const auto&
kv )
1407 return kv.first.IsSameAs( existingName, false );
1413 symbolModified =
true;
1417 if( symbolModified && ( symbol != nextSymbol ) )
1421 if( symbol != nextSymbol )
1424 symbolCopy = std::make_unique<SCH_SYMBOL>( *nextSymbol );
1426 symbolCopy.reset(
nullptr );
1428 symbolModified =
false;
1449 for(
unsigned symbolRef = 0; symbolRef <
m_symbolsList.GetCount(); ++symbolRef )
1466 for(
size_t i = 0; i <
m_cols.size(); i++ )
1472 std::set<wxString> seen;
1473 std::vector<wxString> order;
1479 if( !field.
name || seen.count( field.
name ) )
1482 seen.insert( field.
name );
1483 order.emplace_back( field.
name );
1554 for(
size_t col = 0; col <
m_cols.size(); col++ )
1557 last_col =
static_cast<int>( col );
1561 if( last_col == -1 )
1565 [&]( wxString field,
bool last ) -> wxString
1569 field.Replace( wxS(
"\r" ), wxS(
"" ) );
1570 field.Replace( wxS(
"\n" ), wxS(
"" ) );
1575 field.Replace( wxS(
"\t" ), wxS(
"" ) );
1589 for(
size_t col = 0; col <
m_cols.size(); col++ )
1591 if( !
m_cols[col].m_show )
1594 out.Append( formatField(
m_cols[col].m_label, col ==
static_cast<size_t>( last_col ) ) );
1598 for(
size_t row = 0; row <
m_rows.size(); row++ )
1601 if(
GetRowFlags(
static_cast<int>( row ) ) == CHILD_ITEM )
1604 for(
size_t col = 0; col <
m_cols.size(); col++ )
1606 if( !
m_cols[col].m_show )
1610 out.Append( formatField(
GetExportValue(
static_cast<int>( row ),
static_cast<int>( col ),
1612 col ==
static_cast<size_t>( last_col ) ) );
1622 bool refListChanged =
false;
1637 if( !field.IsPrivate() )
1639 wxString
name = field.GetCanonicalName();
1647 m_dataStore[key].try_emplace( col.m_fieldName, wxEmptyString );
1649 refListChanged =
true;
1653 if( refListChanged )
1667 std::vector<KIID_PATH> keysToRemove;
1671 if( !key.empty() && ( key.back() == symbolUuid ) )
1672 keysToRemove.push_back( key );
1675 for(
const KIID_PATH& key : keysToRemove )
1682 return ref.GetSymbol()->m_Uuid == aSymbol.m_Uuid;
1705 const wxString& aVariantName )
1707 bool refListChanged =
false;
1724 refListChanged =
true;
1728 if( refListChanged )
1737 nlohmann::json j = nlohmann::json::object();
1741 nlohmann::json jfields = nlohmann::json::object();
1743 for(
const auto& [
name, value] : fields )
1744 jfields[std::string(
name.ToUTF8() )] = std::string( value.ToUTF8() );
1746 j[std::string( key.AsString().ToUTF8() )] = jfields;
1749 return wxString( j.dump() );
1755 nlohmann::json j = nlohmann::json::parse( aState.ToStdString(),
nullptr,
false );
1757 if( !j.is_object() )
1760 for(
auto it = j.begin(); it != j.end(); ++it )
1762 KIID_PATH key( wxString::FromUTF8( it.key().c_str() ) );
1763 std::map<wxString, wxString>& fields =
m_dataStore[key];
1765 for(
auto fit = it.value().begin(); fit != it.value().end(); ++fit )
1766 fields[wxString::FromUTF8( fit.key().c_str() )] =
1767 wxString::FromUTF8( fit.value().get<std::string>().c_str() );
1774 GetView()->ForceRefresh();
1780 size_t curNumRows =
m_rows.size();
1782 if( aPosition >= curNumRows )
1784 wxFAIL_MSG( wxString::Format( wxT(
"Called FIELDS_EDITOR_GRID_DATA_MODEL::DeleteRows(aPosition=%lu, "
1785 "aNumRows=%lu)\nPosition value is invalid for present table with %lu rows" ),
1786 (
unsigned long) aPosition, (
unsigned long) aNumRows,
1787 (
unsigned long) curNumRows ) );
1792 if( aNumRows > curNumRows - aPosition )
1794 aNumRows = curNumRows - aPosition;
1797 if( aNumRows >= curNumRows )
1804 const auto first =
m_rows.begin() + aPosition;
1805 std::vector<SCH_REFERENCE> dataMapRefs = first->m_Refs;
1806 m_rows.erase( first, first + aNumRows );
1814 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPosition, aNumRows );
1815 GetView()->ProcessTableMessage( msg );
1824 std::vector<FIELD_CASE_CONFLICT> conflicts;
1826 for(
unsigned i = 0; i < aSymbols.
GetCount(); ++i )
1828 SCH_SYMBOL* symbol = aSymbols[i].GetSymbol();
1833 std::map<wxString, std::vector<std::pair<wxString, wxString>>> groups;
1837 if( field.IsMandatory() || field.IsPrivate() )
1840 groups[field.GetName().Lower()].emplace_back( field.GetName(), field.GetText() );
1843 for(
const auto& [key, members] : groups )
1845 if( members.size() < 2 )
1850 c.
sheetPath = aSymbols[i].GetSheetPath();
1854 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.
virtual void SetTextPos(const VECTOR2I &aPoint)
virtual void SetVisible(bool aVisible)
virtual EDA_ANGLE GetTextAngle() const
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
bool attributeInheritedFromSheet(const SCH_REFERENCE &aRef, const wxString &aAttributeName) const
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)
bool rowAttributeInheritedFromSheet(const DATA_MODEL_ROW &aGroup, 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