20#include <nlohmann/json.hpp>
24#include <wx/settings.h>
46 wxGridCellStringRenderer()
50 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
const wxRect& aRect,
int aRow,
int aCol,
51 bool isSelected )
override
53 wxString value = aGrid.GetCellValue( aRow, aCol );
56 value =
model->GetResolvedValue( aRow, aCol );
61 wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected );
62 SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected );
63 aGrid.DrawTextRectangle( aDC, value, rect, wxALIGN_LEFT, wxALIGN_CENTRE );
66 wxSize
GetBestSize( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC,
int aRow,
int aCol )
override
68 wxString value = aGrid.GetCellValue( aRow, aCol );
71 value =
model->GetResolvedValue( aRow, aCol );
73 return wxGridCellStringRenderer::DoGetBestSize( aAttr, aDC, value );
106 m_cols.push_back( { aFieldName, aLabel, aAddedByUser,
false,
false } );
114 const wxString& aFieldName )
129 if( field->IsPrivate() )
166 if( wxGrid*
grid = GetView() )
168 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_COLS_DELETED, aCol, 1 );
169 grid->ProcessTableMessage( msg );
184 node.key() = newName;
189 m_cols[aCol].m_fieldName = newName;
190 m_cols[aCol].m_label = newName;
196 for(
size_t i = 0; i <
m_cols.size(); i++ )
199 return static_cast<int>( i );
208 std::vector<BOM_FIELD> fields;
211 fields.push_back( { col.m_fieldName, col.m_label, col.m_show, col.m_group } );
219 size_t foundCount = 0;
221 for(
const wxString& newField : aNewOrder )
223 if( foundCount >=
m_cols.size() )
228 if( col.m_fieldName == newField )
230 std::swap(
m_cols[foundCount], col );
242 for(
int col = 0; col < aCol; ++col )
254 GetView()->SetReadOnly( aRow, aCol,
262 return GetValue(
m_rows[aRow], aCol, wxT(
", " ), wxT(
"-" ),
true,
false );
268 wxGridCellAttr* attr =
nullptr;
269 bool needsUrlEditor =
false;
270 bool needsVariantHighlight =
false;
271 bool needsTextVarRenderer =
false;
272 wxColour highlightColor;
279 needsUrlEditor =
true;
288 if( rawValue.Contains( wxT(
"${" ) ) )
289 needsTextVarRenderer =
true;
294 && aCol >= 0 && aCol < (
int)
m_cols.size() )
296 const wxString& fieldName =
m_cols[aCol].m_fieldName;
313 symbolKey.push_back( symbol->m_Uuid );
317 wxString currentValue;
322 if( currentValue != defaultValue )
324 needsVariantHighlight =
true;
326 bool isPriority2 =
false;
334 && variantData->m_SymbolOverride
335 && !variantData->m_Fields.count( fieldName ) )
341 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
342 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
346 highlightColor = isDark ? wxColour( 40, 60, 80 )
347 : wxColour( 220, 235, 255 );
351 highlightColor = isDark ? wxColour( 80, 80, 40 )
352 : wxColour( 255, 255, 200 );
362 if( !needsUrlEditor && !needsVariantHighlight && !needsTextVarRenderer )
368 if( needsVariantHighlight )
372 attr->SetBackgroundColour( highlightColor );
392 attr =
new wxGridCellAttr();
395 if( needsVariantHighlight )
396 attr->SetBackgroundColour( highlightColor );
398 if( needsTextVarRenderer )
407 if( !needsVariantHighlight )
409 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
410 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
412 attr->SetBackgroundColour( isDark ? wxColour( 80, 70, 30 )
413 : wxColour( 255, 252, 200 ) );
422 const wxString& refDelimiter,
423 const wxString& refRangeDelimiter,
425 bool listMixedValues )
427 std::vector<SCH_REFERENCE> references;
428 std::set<wxString> mixedValues;
435 references.push_back( ref );
449 refFieldValue = wxS(
"1" );
459 else if( refFieldValue.Contains( wxT(
"${" ) ) )
463 std::function<bool( wxString* )> symbolResolver = [&]( wxString* token ) ->
bool
468 refFieldValue =
ExpandTextVars( refFieldValue, & symbolResolver );
472 if( listMixedValues )
473 mixedValues.insert( refFieldValue );
474 else if( &ref == &
group.m_Refs.front() )
475 fieldValue = refFieldValue;
476 else if( fieldValue != refFieldValue )
481 if( listMixedValues )
483 fieldValue = wxEmptyString;
485 for(
const wxString& value : mixedValues )
487 if( value.IsEmpty() )
489 else if( fieldValue.IsEmpty() )
492 fieldValue +=
"," + value;
499 std::sort( references.begin(), references.end(),
502 wxString l_ref( l.GetRef() << l.GetRefNumber() );
503 wxString r_ref( r.GetRef() << r.GetRefNumber() );
504 return StrNumCmp( l_ref, r_ref, true ) < 0;
507 auto logicalEnd = std::unique( references.begin(), references.end(),
512 if( l.GetRefNumber() == wxT(
"?" ) )
515 wxString l_ref( l.GetRef() << l.GetRefNumber() );
516 wxString r_ref( r.GetRef() << r.GetRefNumber() );
517 return l_ref == r_ref;
520 references.erase( logicalEnd, references.end() );
526 fieldValue = wxString::Format( wxT(
"%d" ), (
int) references.size() );
528 fieldValue = wxString::Format( wxT(
"%d" ),
group.m_ItemNumber );
536 wxCHECK_RET( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ), wxS(
"Invalid column number" ) );
551 bool isSharedInstance =
false;
559 sharedSymbol = symbol;
572 if( row.m_ItemNumber == aRow + 1 )
592 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
599 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
606 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
613 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
620 wxCHECK( aCol >= 0 && aCol <
static_cast<int>(
m_cols.size() ),
false );
631 if( lhGroup.
m_Refs.size() == 0 )
633 else if( rhGroup.
m_Refs.size() == 0 )
639 [ ascending ](
const auto a,
const auto b )
651 wxString lhs = dataModel->
GetValue( lhGroup, sortCol, wxT(
", " ), wxT(
"-" ),
true ).Trim(
true ).Trim(
false );
652 wxString rhs = dataModel->
GetValue( rhGroup, sortCol, wxT(
", " ), wxT(
"-" ),
true ).Trim(
true ).Trim(
false );
656 wxString lhRef = lhGroup.
m_Refs[0].GetRef() + lhGroup.
m_Refs[0].GetRefNumber();
657 wxString rhRef = rhGroup.
m_Refs[0].GetRef() + rhGroup.
m_Refs[0].GetRefNumber();
658 return local_cmp(
StrNumCmp( lhRef, rhRef,
true ), 0 );
675 std::sort( row.m_Refs.begin(), row.m_Refs.end(),
678 wxString lhs_ref( lhs.GetRef() << lhs.GetRefNumber() );
679 wxString rhs_ref( rhs.GetRef() << rhs.GetRefNumber() );
680 return StrNumCmp( lhs_ref, rhs_ref, true ) < 0;
687 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
695 row.m_ItemNumber = itemNumber++;
715 bool matchFound =
false;
722 if(
m_cols[refCol].m_group )
735 for(
size_t i = 0; i <
m_cols.size(); ++i )
738 if(
static_cast<int>( i ) == refCol )
780 const wxString& aFieldName )
787 return wxEmptyString;
799 std::function<bool( wxString* )> symbolResolver = [&]( wxString* token ) ->
bool
807 return wxEmptyString;
813 return aFieldName == wxS(
"${DNP}" ) || aFieldName == wxS(
"${EXCLUDE_FROM_BOARD}" )
814 || aFieldName == wxS(
"${EXCLUDE_FROM_BOM}" ) || aFieldName == wxS(
"${EXCLUDE_FROM_POS_FILES}" )
815 || aFieldName == wxS(
"${EXCLUDE_FROM_SIM}" );
820 const wxString& aVariantName )
822 if( aAttributeName == wxS(
"${DNP}" ) )
823 return aRef.
GetSymbolDNP( aVariantName ) ? wxS(
"1" ) : wxS(
"0" );
825 if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
828 if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
831 if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
834 if( aAttributeName == wxS(
"${EXCLUDE_FROM_POS_FILES}" ) )
842 const wxString& aAttributeName )
const
846 if( aAttributeName == wxS(
"${DNP}" ) )
848 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
850 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
852 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
877 const wxString& aFieldName )
882 return wxEmptyString;
891 if( field->IsPrivate() )
892 return wxEmptyString;
896 field->GetText( &aRef.
GetSheetPath(), wxEmptyString ) );
904 return wxEmptyString;
909 const wxString& aAttributeName,
910 const wxString& aValue,
911 const wxString& aVariantName )
913 bool attrChanged =
false;
914 bool newValue = aValue == wxS(
"1" );
916 if( aAttributeName == wxS(
"${DNP}" ) )
918 attrChanged = aRef.
GetSymbolDNP( aVariantName ) != newValue;
923 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOARD}" ) )
930 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_BOM}" ) )
937 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_SIM}" ) )
944 else if( aAttributeName == wxS(
"${EXCLUDE_FROM_POS_FILES}" ) )
977 static_cast<WX_GRID*
>( GetView() )->CommitPendingChanges(
true );
979 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0,
m_rows.size() );
980 GetView()->ProcessTableMessage( msg );
1022 bool isExcluded =
false;
1049 || (
m_scope == SCOPE::SCOPE_SHEET_RECURSIVE
1055 bool matchFound =
false;
1073 row.m_Refs.push_back( ref );
1079 row.m_Refs.push_back( ref );
1091 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_rows.size() );
1092 GetView()->ProcessTableMessage( msg );
1101 std::vector<DATA_MODEL_ROW> children;
1105 bool matchFound =
false;
1115 child.m_Refs.push_back( ref );
1124 if( children.size() < 2 )
1127 std::sort( children.begin(), children.end(),
1130 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
1134 m_rows.insert(
m_rows.begin() + aRow + 1, children.begin(), children.end() );
1136 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, aRow, children.size() );
1137 GetView()->ProcessTableMessage( msg );
1143 auto firstChild =
m_rows.begin() + aRow + 1;
1144 auto afterLastChild = firstChild;
1147 while( afterLastChild !=
m_rows.end() && afterLastChild->m_Flag == CHILD_ITEM )
1154 m_rows.erase( firstChild, afterLastChild );
1156 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow + 1, deleted );
1157 GetView()->ProcessTableMessage( msg );
1174 for(
size_t i = 0; i <
m_rows.size(); ++i )
1187 for(
size_t i = 0; i <
m_rows.size(); ++i )
1196 const wxString& aVariantName )
1198 bool symbolModified =
false;
1199 std::unique_ptr<SCH_SYMBOL> symbolCopy;
1210 symbolCopy = std::make_unique<SCH_SYMBOL>( *symbol );
1213 const std::map<wxString, wxString>& fieldStore =
m_dataStore[key];
1215 for(
const auto& [srcName, srcValue] : fieldStore )
1231 if( destField && destField->
IsPrivate() )
1233 if( srcValue.IsEmpty() )
1240 bool userAdded = ( col != -1 &&
m_cols[col].m_userAdded );
1243 bool createField = !destField && ( !srcValue.IsEmpty() || userAdded );
1251 destField->
SetVisible( srcTemplate->m_Visible );
1256 symbolModified =
true;
1271 if( !createField && ( previousValue != srcValue ) )
1272 symbolModified =
true;
1275 for(
int ii =
static_cast<int>( symbol->
GetFields().size() ) - 1; ii >= 0; ii-- )
1280 const wxString& existingName = symbol->
GetFields()[ii].GetName();
1282 bool stillTracked = std::any_of( fieldStore.begin(), fieldStore.end(),
1283 [&](
const auto&
kv )
1285 return kv.first == existingName;
1291 symbolModified =
true;
1295 if( symbolModified && ( symbol != nextSymbol ) )
1299 if( symbol != nextSymbol )
1302 symbolCopy = std::make_unique<SCH_SYMBOL>( *nextSymbol );
1304 symbolCopy.reset(
nullptr );
1306 symbolModified =
false;
1327 for(
unsigned symbolRef = 0; symbolRef <
m_symbolsList.GetCount(); ++symbolRef )
1344 for(
size_t i = 0; i <
m_cols.size(); i++ )
1350 std::set<wxString> seen;
1351 std::vector<wxString> order;
1357 if( !field.
name || seen.count( field.
name ) )
1360 seen.insert( field.
name );
1361 order.emplace_back( field.
name );
1431 for(
size_t col = 0; col <
m_cols.size(); col++ )
1434 last_col =
static_cast<int>( col );
1438 if( last_col == -1 )
1442 out.Append( wxString::FromUTF8(
"\xEF\xBB\xBF" ) );
1445 [&]( wxString field,
bool last ) -> wxString
1449 field.Replace( wxS(
"\r" ), wxS(
"" ) );
1450 field.Replace( wxS(
"\n" ), wxS(
"" ) );
1455 field.Replace( wxS(
"\t" ), wxS(
"" ) );
1469 for(
size_t col = 0; col <
m_cols.size(); col++ )
1471 if( !
m_cols[col].m_show )
1474 out.Append( formatField(
m_cols[col].m_label, col ==
static_cast<size_t>( last_col ) ) );
1478 for(
size_t row = 0; row <
m_rows.size(); row++ )
1481 if(
GetRowFlags(
static_cast<int>( row ) ) == CHILD_ITEM )
1484 for(
size_t col = 0; col <
m_cols.size(); col++ )
1486 if( !
m_cols[col].m_show )
1490 out.Append( formatField(
GetExportValue(
static_cast<int>( row ),
static_cast<int>( col ),
1492 col ==
static_cast<size_t>( last_col ) ) );
1502 bool refListChanged =
false;
1517 if( !field.IsPrivate() )
1519 wxString
name = field.GetCanonicalName();
1527 m_dataStore[key].try_emplace( col.m_fieldName, wxEmptyString );
1529 refListChanged =
true;
1533 if( refListChanged )
1547 std::vector<KIID_PATH> keysToRemove;
1551 if( !key.empty() && ( key.back() == symbolUuid ) )
1552 keysToRemove.push_back( key );
1555 for(
const KIID_PATH& key : keysToRemove )
1562 return ref.GetSymbol()->m_Uuid == aSymbol.m_Uuid;
1586 bool refListChanged =
false;
1603 refListChanged =
true;
1607 if( refListChanged )
1616 nlohmann::json j = nlohmann::json::object();
1620 nlohmann::json jfields = nlohmann::json::object();
1622 for(
const auto& [
name, value] : fields )
1623 jfields[std::string(
name.ToUTF8() )] = std::string( value.ToUTF8() );
1625 j[std::string( key.AsString().ToUTF8() )] = jfields;
1628 return wxString( j.dump() );
1634 nlohmann::json j = nlohmann::json::parse( aState.ToStdString(),
nullptr,
false );
1636 if( !j.is_object() )
1639 for(
auto it = j.begin(); it != j.end(); ++it )
1641 KIID_PATH key( wxString::FromUTF8( it.key().c_str() ) );
1642 std::map<wxString, wxString>& fields =
m_dataStore[key];
1644 for(
auto fit = it.value().begin(); fit != it.value().end(); ++fit )
1645 fields[wxString::FromUTF8( fit.key().c_str() )] =
1646 wxString::FromUTF8( fit.value().get<std::string>().c_str() );
1653 GetView()->ForceRefresh();
1659 size_t curNumRows =
m_rows.size();
1661 if( aPosition >= curNumRows )
1663 wxFAIL_MSG( wxString::Format( wxT(
"Called FIELDS_EDITOR_GRID_DATA_MODEL::DeleteRows(aPosition=%lu, "
1664 "aNumRows=%lu)\nPosition value is invalid for present table with %lu rows" ),
1665 (
unsigned long) aPosition, (
unsigned long) aNumRows,
1666 (
unsigned long) curNumRows ) );
1671 if( aNumRows > curNumRows - aPosition )
1673 aNumRows = curNumRows - aPosition;
1676 if( aNumRows >= curNumRows )
1683 const auto first =
m_rows.begin() + aPosition;
1684 std::vector<SCH_REFERENCE> dataMapRefs = first->m_Refs;
1685 m_rows.erase( first, first + aNumRows );
1693 wxGridTableMessage msg(
this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPosition, aNumRows );
1694 GetView()->ProcessTableMessage( msg );
1703 std::vector<FIELD_CASE_CONFLICT> conflicts;
1705 for(
unsigned i = 0; i < aSymbols.
GetCount(); ++i )
1707 SCH_SYMBOL* symbol = aSymbols[i].GetSymbol();
1712 std::map<wxString, std::vector<std::pair<wxString, wxString>>> groups;
1716 if( field.IsMandatory() || field.IsPrivate() )
1719 groups[field.GetName().Lower()].emplace_back( field.GetName(), field.GetText() );
1722 for(
const auto& [key, members] : groups )
1724 if( members.size() < 2 )
1729 c.
sheetPath = aSymbols[i].GetSheetPath();
1733 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
wxString GetColFieldName(int aCol)
std::vector< DATA_MODEL_ROW > m_rows
void ApplyBomPreset(const BOM_PRESET &preset)
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.
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
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)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)
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
void updateDataStoreSymbolField(const SCH_REFERENCE &aSymbolRef, const wxString &aFieldName)
static bool cmp(const DATA_MODEL_ROW &lhGroup, const DATA_MODEL_ROW &rhGroup, FIELDS_EDITOR_GRID_DATA_MODEL *dataModel, int sortCol, bool ascending)
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 UpdateReferences(const SCH_REFERENCE_LIST &aRefs)
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 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
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
bool GetSymbolExcludedFromPosFiles(const wxString &aVariant=wxEmptyString) 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
void SetSymbolExcludedFromPosFiles(bool aEnable, const wxString &aVariant=wxEmptyString)
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 IsSharedPath() const
Determine if this sheet path is shared in a complex hierarchy.
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.
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.
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...
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...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
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.
bool includeByteOrderMark
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.
bool FieldNamesAreDuplicates(const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
Test whether two field names should be treated as duplicates for the purposes of field name uniquenes...
@ 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