KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fields_data_model.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 <author>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20#include <nlohmann/json.hpp>
21#include <wx/string.h>
22#include <wx/debug.h>
23#include <wx/grid.h>
24#include <wx/settings.h>
25#include <common.h>
26#include <widgets/wx_grid.h>
27#include <sch_reference_list.h>
28#include <sch_commit.h>
29#include <sch_screen.h>
30#include "string_utils.h"
31
32#include "fields_data_model.h"
33
34
40class GRID_CELL_RESOLVED_TEXT_RENDERER : public wxGridCellStringRenderer
41{
42public:
44 wxGridCellStringRenderer()
45 {
46 }
47
48 void Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, const wxRect& aRect, int aRow, int aCol,
49 bool isSelected ) override
50 {
51 wxString value = aGrid.GetCellValue( aRow, aCol );
52
53 if( auto* model = dynamic_cast<FIELDS_EDITOR_GRID_DATA_MODEL*>( aGrid.GetTable() ) )
54 value = model->GetResolvedValue( aRow, aCol );
55
56 wxRect rect = aRect;
57 rect.Inflate( -1 );
58
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 );
62 }
63
64 wxSize GetBestSize( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, int aRow, int aCol ) override
65 {
66 wxString value = aGrid.GetCellValue( aRow, aCol );
67
68 if( auto* model = dynamic_cast<FIELDS_EDITOR_GRID_DATA_MODEL*>( aGrid.GetTable() ) )
69 value = model->GetResolvedValue( aRow, aCol );
70
71 return wxGridCellStringRenderer::DoGetBestSize( aAttr, aDC, value );
72 }
73
74 wxGridCellRenderer* Clone() const override { return new GRID_CELL_RESOLVED_TEXT_RENDERER(); }
75};
76
77
86static KIID_PATH makeDataStoreKey( const SCH_SHEET_PATH& aSheetPath, const SCH_SYMBOL& aSymbol )
87{
88 KIID_PATH path = aSheetPath.Path();
89 path.push_back( aSymbol.m_Uuid );
90 return path;
91}
92
93
95{
96 switch( aCol )
97 {
98 case DISPLAY_NAME_COLUMN: return _( "Field" );
99 case LABEL_COLUMN: return m_forBOM ? _( "BOM Name" ) : _( "Label" );
100 case SHOW_FIELD_COLUMN: return _( "Include" );
101 case GROUP_BY_COLUMN: return _( "Group By" );
102 default: return wxT( "unknown column" );
103 };
104}
105
106
107wxString VIEW_CONTROLS_GRID_DATA_MODEL::GetValue( int aRow, int aCol )
108{
109 wxCHECK( aRow < GetNumberRows(), wxT( "bad row!" ) );
110
111 BOM_FIELD& rowData = m_fields[aRow];
112
113 switch( aCol )
114 {
116 for( FIELD_T fieldId : MANDATORY_FIELDS )
117 {
118 if( GetDefaultFieldName( fieldId, !DO_TRANSLATE ) == rowData.name )
119 return GetDefaultFieldName( fieldId, DO_TRANSLATE );
120 }
121
122 return rowData.name;
123
124 case LABEL_COLUMN:
125 return rowData.label;
126
127 default:
128 // we can't assert here because wxWidgets sometimes calls this without checking
129 // the column type when trying to see if there's an overflow
130 return wxT( "bad wxWidgets!" );
131 }
132}
133
134
136{
137 wxCHECK( aRow < GetNumberRows(), false );
138
139 BOM_FIELD& rowData = m_fields[aRow];
140
141 switch( aCol )
142 {
143 case SHOW_FIELD_COLUMN: return rowData.show;
144 case GROUP_BY_COLUMN: return rowData.groupBy;
145
146 default:
147 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
148 return false;
149 }
150}
151
152
153void VIEW_CONTROLS_GRID_DATA_MODEL::SetValue( int aRow, int aCol, const wxString &aValue )
154{
155 wxCHECK( aRow < GetNumberRows(), /*void*/ );
156
157 BOM_FIELD& rowData = m_fields[aRow];
158
159 switch( aCol )
160 {
162 // Not editable
163 break;
164
165 case LABEL_COLUMN:
166 rowData.label = aValue;
167 break;
168
169 default:
170 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
171 }
172
173 GetView()->Refresh();
174}
175
176
177void VIEW_CONTROLS_GRID_DATA_MODEL::SetValueAsBool( int aRow, int aCol, bool aValue )
178{
179 wxCHECK( aRow < GetNumberRows(), /*void*/ );
180
181 BOM_FIELD& rowData = m_fields[aRow];
182
183 switch( aCol )
184 {
185 case SHOW_FIELD_COLUMN: rowData.show = aValue; break;
186 case GROUP_BY_COLUMN: rowData.groupBy = aValue; break;
187
188 default:
189 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
190 }
191}
192
193
194void VIEW_CONTROLS_GRID_DATA_MODEL::AppendRow( const wxString& aFieldName, const wxString& aBOMName,
195 bool aShow, bool aGroupBy )
196{
197 m_fields.emplace_back( BOM_FIELD{ aFieldName, aBOMName, aShow, aGroupBy } );
198
199 if( wxGrid* grid = GetView() )
200 {
201 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
202 grid->ProcessTableMessage( msg );
203 }
204}
205
206
208{
209 wxCHECK( aRow >= 0 && aRow < GetNumberRows(), /* void */ );
210
211 m_fields.erase( m_fields.begin() + aRow );
212
213 if( wxGrid* grid = GetView() )
214 {
215 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow, 1 );
216 grid->ProcessTableMessage( msg );
217 }
218}
219
220
222{
223 wxCHECK( aRow >= 0 && aRow < GetNumberRows(), wxEmptyString );
224
225 BOM_FIELD& rowData = m_fields[aRow];
226
227 return rowData.name;
228}
229
230
231void VIEW_CONTROLS_GRID_DATA_MODEL::SetCanonicalFieldName( int aRow, const wxString& aName )
232{
233 wxCHECK( aRow >= 0 && aRow < GetNumberRows(), /* void */ );
234
235 BOM_FIELD& rowData = m_fields[aRow];
236
237 rowData.name = aName;
238}
239
240
241const wxString FIELDS_EDITOR_GRID_DATA_MODEL::QUANTITY_VARIABLE = wxS( "${QUANTITY}" );
242const wxString FIELDS_EDITOR_GRID_DATA_MODEL::ITEM_NUMBER_VARIABLE = wxS( "${ITEM_NUMBER}" );
243
244
245void FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn( const wxString& aFieldName, const wxString& aLabel,
246 bool aAddedByUser, const wxString& aVariantName )
247{
248 // Don't add a field twice
249 if( GetFieldNameCol( aFieldName ) != -1 )
250 return;
251
252 m_cols.push_back( { aFieldName, aLabel, aAddedByUser, false, false } );
253
254 for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
255 updateDataStoreSymbolField( m_symbolsList[i], aFieldName, aVariantName );
256}
257
258
260 const wxString& aFieldName,
261 const wxString& aVariantName )
262{
263 const SCH_SYMBOL* symbol = aSymbolRef.GetSymbol();
264
265 if( !symbol )
266 return;
267
268 KIID_PATH key = makeDataStoreKey( aSymbolRef.GetSheetPath(), *symbol );
269
270 if( isAttribute( aFieldName ) )
271 {
272 m_dataStore[key][aFieldName] = getAttributeValue( aSymbolRef, aFieldName, aVariantName );
273 }
274 else if( const SCH_FIELD* field = symbol->FindFieldCaseInsensitive( aFieldName ) )
275 {
276 if( field->IsPrivate() )
277 {
278 m_dataStore[key][aFieldName] = wxEmptyString;
279 return;
280 }
281
282 wxString value = symbol->Schematic()->ConvertKIIDsToRefs( field->GetText( &aSymbolRef.GetSheetPath(),
283 aVariantName ) );
284
285 m_dataStore[key][aFieldName] = value;
286 }
287 else if( IsGeneratedField( aFieldName ) )
288 {
289 // Handle generated fields with variables as names (e.g. ${QUANTITY}) that are not present in
290 // the symbol by giving them the correct value
291 m_dataStore[key][aFieldName] = aFieldName;
292 }
293 else
294 {
295 m_dataStore[key][aFieldName] = wxEmptyString;
296 }
297}
298
299
301{
302 for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
303 {
304 if( SCH_SYMBOL* symbol = m_symbolsList[i].GetSymbol() )
305 {
306 KIID_PATH key = makeDataStoreKey( m_symbolsList[i].GetSheetPath(), *symbol );
307 m_dataStore[key].erase( m_cols[aCol].m_fieldName );
308 }
309 }
310
311 m_cols.erase( m_cols.begin() + aCol );
312
313 if( wxGrid* grid = GetView() )
314 {
315 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_COLS_DELETED, aCol, 1 );
316 grid->ProcessTableMessage( msg );
317 }
318}
319
320
321void FIELDS_EDITOR_GRID_DATA_MODEL::RenameColumn( int aCol, const wxString& newName )
322{
323 for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
324 {
325 SCH_SYMBOL* symbol = m_symbolsList[i].GetSymbol();
326 KIID_PATH key = makeDataStoreKey( m_symbolsList[i].GetSheetPath(), *symbol );
327
328 // Careful; field may have already been renamed from another sheet instance
329 if( auto node = m_dataStore[key].extract( m_cols[aCol].m_fieldName ) )
330 {
331 node.key() = newName;
332 m_dataStore[key].insert( std::move( node ) );
333 }
334 }
335
336 m_cols[aCol].m_fieldName = newName;
337 m_cols[aCol].m_label = newName;
338}
339
340
341int FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldNameCol( const wxString& aFieldName ) const
342{
343 for( size_t i = 0; i < m_cols.size(); i++ )
344 {
345 if( m_cols[i].m_fieldName.CmpNoCase( aFieldName ) == 0 )
346 return static_cast<int>( i );
347 }
348
349 return -1;
350}
351
352
354{
355 std::vector<BOM_FIELD> fields;
356
357 for( const DATA_MODEL_COL& col : m_cols )
358 fields.push_back( { col.m_fieldName, col.m_label, col.m_show, col.m_group } );
359
360 return fields;
361}
362
363
364void FIELDS_EDITOR_GRID_DATA_MODEL::SetFieldsOrder( const std::vector<wxString>& aNewOrder )
365{
366 size_t foundCount = 0;
367
368 for( const wxString& newField : aNewOrder )
369 {
370 if( foundCount >= m_cols.size() )
371 break;
372
373 for( DATA_MODEL_COL& col : m_cols )
374 {
375 if( col.m_fieldName == newField )
376 {
377 std::swap( m_cols[foundCount], col );
378 foundCount++;
379 break;
380 }
381 }
382 }
383}
384
385
387{
388 // Check if aCol is the first visible column
389 for( int col = 0; col < aCol; ++col )
390 {
391 if( m_cols[col].m_show )
392 return false;
393 }
394
395 return true;
396}
397
398
399wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( int aRow, int aCol )
400{
401 GetView()->SetReadOnly( aRow, aCol, IsExpanderColumn( aCol ) );
402 return GetValue( m_rows[aRow], aCol );
403}
404
405
407{
408 return GetValue( m_rows[aRow], aCol, wxT( ", " ), wxT( "-" ), true, false );
409}
410
411
412wxGridCellAttr* FIELDS_EDITOR_GRID_DATA_MODEL::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind )
413{
414 wxGridCellAttr* attr = nullptr;
415 bool needsUrlEditor = false;
416 bool needsVariantHighlight = false;
417 bool needsTextVarRenderer = false;
418 wxColour highlightColor;
419
420 // Check if we need URL editor
422 || IsURL( GetValue( m_rows[aRow], aCol ) ) )
423 {
424 if( m_urlEditor )
425 needsUrlEditor = true;
426 }
427
428 // Check if the raw value contains a text variable that should be resolved for display
429 if( aRow >= 0 && aRow < (int) m_rows.size() && aCol >= 0 && aCol < (int) m_cols.size() && !ColIsReference( aCol )
430 && !ColIsQuantity( aCol ) && !ColIsItemNumber( aCol ) )
431 {
432 wxString rawValue = GetValue( m_rows[aRow], aCol );
433
434 if( rawValue.Contains( wxT( "${" ) ) )
435 needsTextVarRenderer = true;
436 }
437
438 // Check if we need variant highlighting
439 if( !m_currentVariant.IsEmpty() && aRow >= 0 && aRow < (int) m_rows.size()
440 && aCol >= 0 && aCol < (int) m_cols.size() )
441 {
442 const wxString& fieldName = m_cols[aCol].m_fieldName;
443
444 // Skip Reference and generated fields (like ${QUANTITY}) for highlighting
445 if( !ColIsReference( aCol ) && !ColIsQuantity( aCol ) && !ColIsItemNumber( aCol ) )
446 {
447 const DATA_MODEL_ROW& row = m_rows[aRow];
448
449 // Check if any symbol in this row has a variant-specific value
450 for( const SCH_REFERENCE& ref : row.m_Refs )
451 {
452 wxString defaultValue = getDefaultFieldValue( ref, fieldName );
453
454 KIID_PATH symbolKey = KIID_PATH();
455
456 if( const SCH_SYMBOL* symbol = ref.GetSymbol() )
457 {
458 symbolKey = ref.GetSheetPath().Path();
459 symbolKey.push_back( symbol->m_Uuid );
460 }
461
462 // Get the current value from the data store
463 wxString currentValue;
464
465 if( m_dataStore.contains( symbolKey ) && m_dataStore[symbolKey].contains( fieldName ) )
466 currentValue = m_dataStore[symbolKey][fieldName];
467
468 if( currentValue != defaultValue )
469 {
470 needsVariantHighlight = true;
471
472 // Use a subtle highlight color that works in both light and dark themes
473 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
474 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
475
476 if( isDark )
477 highlightColor = wxColour( 80, 80, 40 ); // Dark gold/brown
478 else
479 highlightColor = wxColour( 255, 255, 200 ); // Light yellow
480
481 break;
482 }
483 }
484 }
485 }
486
487 // If we don't need any custom attributes, use the base class behavior
488 if( !needsUrlEditor && !needsVariantHighlight && !needsTextVarRenderer )
489 return WX_GRID_TABLE_BASE::GetAttr( aRow, aCol, aKind );
490
491 // URL cells: use m_urlEditor as base, potentially with variant highlight overlay
492 if( needsUrlEditor )
493 {
494 if( needsVariantHighlight )
495 {
496 // Clone the URL editor attribute and add highlight color
497 attr = m_urlEditor->Clone();
498 attr->SetBackgroundColour( highlightColor );
499 }
500 else
501 {
502 // Just use the URL editor attribute directly
503 m_urlEditor->IncRef();
504 attr = m_urlEditor;
505 }
506
507 return enhanceAttr( attr, aRow, aCol, aKind );
508 }
509
510 // Non-URL cells: start with column attributes if they exist.
511 // This preserves checkbox renderers and other column-specific settings.
512 if( m_colAttrs.find( aCol ) != m_colAttrs.end() && m_colAttrs[aCol] )
513 {
514 attr = m_colAttrs[aCol]->Clone();
515 }
516 else
517 {
518 attr = new wxGridCellAttr();
519 }
520
521 if( needsVariantHighlight )
522 attr->SetBackgroundColour( highlightColor );
523
524 if( needsTextVarRenderer )
525 {
526 if( !m_textVarRenderer )
528
529 m_textVarRenderer->IncRef();
530 attr->SetRenderer( m_textVarRenderer );
531
532 // Tint text-var cells if not already highlighted by variant
533 if( !needsVariantHighlight )
534 {
535 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
536 bool isDark = ( bg.Red() + bg.Green() + bg.Blue() ) < 384;
537
538 attr->SetBackgroundColour( isDark ? wxColour( 80, 70, 30 ) // Dark amber
539 : wxColour( 255, 252, 200 ) ); // Light yellow
540 }
541 }
542
543 return enhanceAttr( attr, aRow, aCol, aKind );
544}
545
546
548 const wxString& refDelimiter,
549 const wxString& refRangeDelimiter,
550 bool resolveVars,
551 bool listMixedValues )
552{
553 std::vector<SCH_REFERENCE> references;
554 std::set<wxString> mixedValues;
555 wxString fieldValue;
556
557 for( const SCH_REFERENCE& ref : group.m_Refs )
558 {
559 if( ColIsReference( aCol ) || ColIsQuantity( aCol ) || ColIsItemNumber( aCol ) )
560 {
561 references.push_back( ref );
562 }
563 else // Other columns are either a single value or ROW_MULTI_ITEMS
564 {
565 KIID_PATH symbolKey = makeDataStoreKey( ref.GetSheetPath(), *ref.GetSymbol() );
566
567 if( !m_dataStore.contains( symbolKey ) || !m_dataStore[symbolKey].contains( m_cols[aCol].m_fieldName ) )
568 return INDETERMINATE_STATE;
569
570 wxString refFieldValue = m_dataStore[symbolKey][m_cols[aCol].m_fieldName];
571
572 if( resolveVars )
573 {
574 if( IsGeneratedField( m_cols[aCol].m_fieldName ) )
575 {
576 // Generated fields (e.g. ${QUANTITY}) can't have un-applied values as they're
577 // read-only. Resolve them against the field.
578 refFieldValue = getFieldShownText( ref, m_cols[aCol].m_fieldName );
579 }
580 else if( refFieldValue.Contains( wxT( "${" ) ) )
581 {
582 // Resolve variables in the un-applied value using the parent symbol and instance
583 // data.
584 std::function<bool( wxString* )> symbolResolver =
585 [&]( wxString* token ) -> bool
586 {
587 return ref.GetSymbol()->ResolveTextVar( &ref.GetSheetPath(), token );
588 };
589
590 refFieldValue = ExpandTextVars( refFieldValue, & symbolResolver );
591 }
592 }
593
594 if( listMixedValues )
595 mixedValues.insert( refFieldValue );
596 else if( &ref == &group.m_Refs.front() )
597 fieldValue = refFieldValue;
598 else if( fieldValue != refFieldValue )
599 return INDETERMINATE_STATE;
600 }
601 }
602
603 if( listMixedValues )
604 {
605 fieldValue = wxEmptyString;
606
607 for( const wxString& value : mixedValues )
608 {
609 if( value.IsEmpty() )
610 continue;
611 else if( fieldValue.IsEmpty() )
612 fieldValue = value;
613 else
614 fieldValue += "," + value;
615 }
616 }
617
618 if( ColIsReference( aCol ) || ColIsQuantity( aCol ) || ColIsItemNumber( aCol ) )
619 {
620 // Remove duplicates (other units of multi-unit parts)
621 std::sort( references.begin(), references.end(),
622 []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool
623 {
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;
627 } );
628
629 auto logicalEnd = std::unique( references.begin(), references.end(),
630 []( const SCH_REFERENCE& l, const SCH_REFERENCE& r ) -> bool
631 {
632 // If unannotated then we can't tell what units belong together
633 // so we have to leave them all
634 if( l.GetRefNumber() == wxT( "?" ) )
635 return false;
636
637 wxString l_ref( l.GetRef() << l.GetRefNumber() );
638 wxString r_ref( r.GetRef() << r.GetRefNumber() );
639 return l_ref == r_ref;
640 } );
641
642 references.erase( logicalEnd, references.end() );
643 }
644
645 if( ColIsReference( aCol ) )
646 fieldValue = SCH_REFERENCE_LIST::Shorthand( references, refDelimiter, refRangeDelimiter );
647 else if( ColIsQuantity( aCol ) )
648 fieldValue = wxString::Format( wxT( "%d" ), (int) references.size() );
649 else if( ColIsItemNumber( aCol ) && group.m_Flag != CHILD_ITEM )
650 fieldValue = wxString::Format( wxT( "%d" ), group.m_ItemNumber );
651
652 return fieldValue;
653}
654
655
656void FIELDS_EDITOR_GRID_DATA_MODEL::SetValue( int aRow, int aCol, const wxString& aValue )
657{
658 wxCHECK_RET( aCol >= 0 && aCol < static_cast<int>( m_cols.size() ), wxS( "Invalid column number" ) );
659
660 // Can't modify references or generated fields (e.g. ${QUANTITY})
661 if( ColIsReference( aCol )
662 || ( IsGeneratedField( m_cols[aCol].m_fieldName ) && !ColIsAttribute( aCol ) ) )
663 {
664 return;
665 }
666
667 if( aValue == INDETERMINATE_STATE )
668 return;
669
670 DATA_MODEL_ROW& rowGroup = m_rows[aRow];
671
672 const SCH_SYMBOL* sharedSymbol = nullptr;
673 bool isSharedInstance = false;
674
675 for( const SCH_REFERENCE& ref : rowGroup.m_Refs )
676 {
677 const SCH_SCREEN* screen = nullptr;
678
679 // Check to see if the symbol associated with this row has more than one instance.
680 if( const SCH_SYMBOL* symbol = ref.GetSymbol() )
681 {
682 screen = static_cast<const SCH_SCREEN*>( symbol->GetParent() );
683
684 isSharedInstance = ( screen && ( screen->GetRefCount() > 1 ) );
685 sharedSymbol = symbol;
686 }
687
688 KIID_PATH key = makeDataStoreKey( ref.GetSheetPath(), *ref.GetSymbol() );
689 m_dataStore[key][m_cols[aCol].m_fieldName] = aValue;
690 }
691
692 // Update all of the other instances for the shared symbol as required.
693 if( isSharedInstance
694 && ( ( rowGroup.m_Flag == GROUP_SINGLETON ) || ( rowGroup.m_Flag == CHILD_ITEM ) ) )
695 {
696 for( DATA_MODEL_ROW& row : m_rows )
697 {
698 if( row.m_ItemNumber == aRow + 1 )
699 continue;
700
701 for( const SCH_REFERENCE& ref : row.m_Refs )
702 {
703 if( ref.GetSymbol() != sharedSymbol )
704 continue;
705
706 KIID_PATH key = makeDataStoreKey( ref.GetSheetPath(), *ref.GetSymbol() );
707 m_dataStore[key][m_cols[aCol].m_fieldName] = aValue;
708 }
709 }
710 }
711
712 m_edited = true;
713}
714
715
717{
718 wxCHECK( aCol >= 0 && aCol < static_cast<int>( m_cols.size() ), false );
719 return m_cols[aCol].m_fieldName == GetCanonicalFieldName( FIELD_T::REFERENCE );
720}
721
722
724{
725 wxCHECK( aCol >= 0 && aCol < static_cast<int>( m_cols.size() ), false );
726 return m_cols[aCol].m_fieldName == GetCanonicalFieldName( FIELD_T::VALUE );
727}
728
729
731{
732 wxCHECK( aCol >= 0 && aCol < static_cast<int>( m_cols.size() ), false );
733 return m_cols[aCol].m_fieldName == QUANTITY_VARIABLE;
734}
735
736
738{
739 wxCHECK( aCol >= 0 && aCol < static_cast<int>( m_cols.size() ), false );
740 return m_cols[aCol].m_fieldName == ITEM_NUMBER_VARIABLE;
741}
742
743
745{
746 wxCHECK( aCol >= 0 && aCol < static_cast<int>( m_cols.size() ), false );
747 return isAttribute( m_cols[aCol].m_fieldName );
748}
749
750
752 const DATA_MODEL_ROW& rhGroup,
753 FIELDS_EDITOR_GRID_DATA_MODEL* dataModel, int sortCol,
754 bool ascending )
755{
756 // Empty rows always go to the bottom, whether ascending or descending
757 if( lhGroup.m_Refs.size() == 0 )
758 return true;
759 else if( rhGroup.m_Refs.size() == 0 )
760 return false;
761
762 // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
763 // to get the opposite sort. i.e. ~(a<b) != (a>b)
764 auto local_cmp =
765 [ ascending ]( const auto a, const auto b )
766 {
767 if( ascending )
768 return a < b;
769 else
770 return a > b;
771 };
772
773 // Primary sort key is sortCol; secondary is always REFERENCE (column 0)
774 if( sortCol < 0 || sortCol >= dataModel->GetNumberCols() )
775 sortCol = 0;
776
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 );
779
780 if( lhs == rhs || dataModel->ColIsReference( sortCol ) )
781 {
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 );
785 }
786 else
787 {
788 return local_cmp( ValueStringCompare( lhs, rhs ), 0 );
789 }
790}
791
792
794{
796
797 // We're going to sort the rows based on their first reference, so the first reference
798 // had better be the lowest one.
799 for( DATA_MODEL_ROW& row : m_rows )
800 {
801 std::sort( row.m_Refs.begin(), row.m_Refs.end(),
802 []( const SCH_REFERENCE& lhs, const SCH_REFERENCE& rhs )
803 {
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;
807 } );
808 }
809
810 std::sort( m_rows.begin(), m_rows.end(),
811 [this]( const DATA_MODEL_ROW& lhs, const DATA_MODEL_ROW& rhs ) -> bool
812 {
813 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
814 } );
815
816 // Time to renumber the item numbers
817 int itemNumber = 1;
818
819 for( DATA_MODEL_ROW& row : m_rows )
820 {
821 row.m_ItemNumber = itemNumber++;
822 }
823
825}
826
827
829{
830 // If items are unannotated then we can't tell if they're units of the same symbol or not
831 if( lhRef.GetRefNumber() == wxT( "?" ) )
832 return false;
833
834 return ( lhRef.GetRef() == rhRef.GetRef() && lhRef.GetRefNumber() == rhRef.GetRefNumber() );
835}
836
837
839{
841 bool matchFound = false;
842
843 if( refCol == -1 )
844 return false;
845
846 // First check the reference column. This can be done directly out of the
847 // SCH_REFERENCEs as the references can't be edited in the grid.
848 if( m_cols[refCol].m_group )
849 {
850 // if we're grouping by reference, then only the prefix must match
851 if( lhRef.GetRef() != rhRef.GetRef() )
852 return false;
853
854 matchFound = true;
855 }
856
857 KIID_PATH lhRefKey = makeDataStoreKey( lhRef.GetSheetPath(), *lhRef.GetSymbol() );
858 KIID_PATH rhRefKey = makeDataStoreKey( rhRef.GetSheetPath(), *rhRef.GetSymbol() );
859
860 // Now check all the other columns.
861 for( size_t i = 0; i < m_cols.size(); ++i )
862 {
863 //Handled already
864 if( static_cast<int>( i ) == refCol )
865 continue;
866
867 if( !m_cols[i].m_group )
868 continue;
869
870 // If the field is generated (e.g. ${QUANTITY}), we need to resolve it through the symbol
871 // to get the actual current value; otherwise we need to pull it out of the store so the
872 // refresh can regroup based on values that haven't been applied to the schematic yet.
873 wxString lh, rh;
874
875 if( IsGeneratedField( m_cols[i].m_fieldName )
876 || IsGeneratedField( m_dataStore[lhRefKey][m_cols[i].m_fieldName] ) )
877 {
878 lh = getFieldShownText( lhRef, m_cols[i].m_fieldName );
879 }
880 else
881 {
882 lh = m_dataStore[lhRefKey][m_cols[i].m_fieldName];
883 }
884
885 if( IsGeneratedField( m_cols[i].m_fieldName )
886 || IsGeneratedField( m_dataStore[rhRefKey][m_cols[i].m_fieldName] ) )
887 {
888 rh = getFieldShownText( rhRef, m_cols[i].m_fieldName );
889 }
890 else
891 {
892 rh = m_dataStore[rhRefKey][m_cols[i].m_fieldName];
893 }
894
895 if( lh != rh )
896 return false;
897
898 matchFound = true;
899 }
900
901 return matchFound;
902}
903
904
906 const wxString& aFieldName )
907{
908 SCH_FIELD* field = aRef.GetSymbol()->GetField( aFieldName );
909
910 if( field )
911 {
912 if( field->IsPrivate() )
913 return wxEmptyString;
914 else
915 return field->GetShownText( &aRef.GetSheetPath(), false );
916 }
917
918 // Handle generated fields with variables as names (e.g. ${QUANTITY}) that are not present in
919 // the symbol by giving them the correct value by resolving against the symbol
920 if( IsGeneratedField( aFieldName ) )
921 {
922 int depth = 0;
923 const SCH_SHEET_PATH& path = aRef.GetSheetPath();
924
925 std::function<bool( wxString* )> symbolResolver =
926 [&]( wxString* token ) -> bool
927 {
928 return aRef.GetSymbol()->ResolveTextVar( &path, token, depth + 1 );
929 };
930
931 return ExpandTextVars( aFieldName, &symbolResolver );
932 }
933
934 return wxEmptyString;
935}
936
937
938bool FIELDS_EDITOR_GRID_DATA_MODEL::isAttribute( const wxString& aFieldName )
939{
940 return aFieldName == wxS( "${DNP}" )
941 || aFieldName == wxS( "${EXCLUDE_FROM_BOARD}" )
942 || aFieldName == wxS( "${EXCLUDE_FROM_BOM}" )
943 || aFieldName == wxS( "${EXCLUDE_FROM_SIM}" );
944}
945
946
947wxString FIELDS_EDITOR_GRID_DATA_MODEL::getAttributeValue( const SCH_REFERENCE& aRef, const wxString& aAttributeName,
948 const wxString& aVariantName )
949{
950 if( aAttributeName == wxS( "${DNP}" ) )
951 return aRef.GetSymbolDNP( aVariantName ) ? wxS( "1" ) : wxS( "0" );
952
953 if( aAttributeName == wxS( "${EXCLUDE_FROM_BOARD}" ) )
954 return aRef.GetSymbolExcludedFromBoard() ? wxS( "1" ) : wxS( "0" );
955
956 if( aAttributeName == wxS( "${EXCLUDE_FROM_BOM}" ) )
957 return aRef.GetSymbolExcludedFromBOM( aVariantName ) ? wxS( "1" ) : wxS( "0" );
958
959 if( aAttributeName == wxS( "${EXCLUDE_FROM_SIM}" ) )
960 return aRef.GetSymbolExcludedFromSim( aVariantName ) ? wxS( "1" ) : wxS( "0" );
961
962 return wxS( "0" );
963}
964
965
967 const wxString& aFieldName )
968{
969 const SCH_SYMBOL* symbol = aRef.GetSymbol();
970
971 if( !symbol )
972 return wxEmptyString;
973
974 // For attributes, get the default (non-variant) value
975 if( isAttribute( aFieldName ) )
976 return getAttributeValue( aRef, aFieldName, wxEmptyString );
977
978 // For regular fields, get the text without variant override
979 if( const SCH_FIELD* field = symbol->GetField( aFieldName ) )
980 {
981 if( field->IsPrivate() )
982 return wxEmptyString;
983
984 // Get the field text with empty variant name (default value)
985 wxString value = symbol->Schematic()->ConvertKIIDsToRefs(
986 field->GetText( &aRef.GetSheetPath(), wxEmptyString ) );
987 return value;
988 }
989
990 // For generated fields, return the field name itself
991 if( IsGeneratedField( aFieldName ) )
992 return aFieldName;
993
994 return wxEmptyString;
995}
996
997
999 const wxString& aAttributeName,
1000 const wxString& aValue,
1001 const wxString& aVariantName )
1002{
1003 bool attrChanged = false;
1004 bool newValue = aValue == wxS( "1" );
1005
1006 if( aAttributeName == wxS( "${DNP}" ) )
1007 {
1008 attrChanged = aRef.GetSymbolDNP( aVariantName ) != newValue;
1009 aRef.SetSymbolDNP( newValue, aVariantName );
1010 }
1011 else if( aAttributeName == wxS( "${EXCLUDE_FROM_BOARD}" ) )
1012 {
1013 attrChanged = aRef.GetSymbolExcludedFromBoard() != newValue;
1014 aRef.SetSymbolExcludedFromBoard( newValue );
1015 }
1016 else if( aAttributeName == wxS( "${EXCLUDE_FROM_BOM}" ) )
1017 {
1018 attrChanged = aRef.GetSymbolExcludedFromBOM( aVariantName ) != newValue;
1019 aRef.SetSymbolExcludedFromBOM( newValue, aVariantName );
1020 }
1021 else if( aAttributeName == wxS( "${EXCLUDE_FROM_SIM}" ) )
1022 {
1023 attrChanged = aRef.GetSymbolExcludedFromSim( aVariantName ) != newValue;
1024 aRef.SetSymbolExcludedFromSim( newValue, aVariantName );
1025 }
1026
1027 return attrChanged;
1028}
1029
1030
1035
1036
1041
1042
1044{
1045 if( !m_rebuildsEnabled )
1046 return;
1047
1048 if( GetView() )
1049 {
1050 // Commit any pending in-place edits before the row gets moved out from under
1051 // the editor.
1052 static_cast<WX_GRID*>( GetView() )->CommitPendingChanges( true );
1053
1054 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, m_rows.size() );
1055 GetView()->ProcessTableMessage( msg );
1056 }
1057
1058 m_rows.clear();
1059
1060 EDA_COMBINED_MATCHER matcher( m_filter.Lower(), CTX_SEARCH );
1061
1062 for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
1063 {
1065
1066 if( !m_filter.IsEmpty() && !matcher.Find( ref.GetFullRef().Lower() ) )
1067 continue;
1068
1069 if( m_excludeDNP )
1070 {
1071 bool isDNP = false;
1072
1073 if( !m_variantNames.empty() )
1074 {
1075 for( const wxString& variantName : m_variantNames )
1076 {
1077 if( ref.GetSymbol()->ResolveDNP( &ref.GetSheetPath(), variantName )
1078 || ref.GetSheetPath().GetDNP( variantName ) )
1079 {
1080 isDNP = true;
1081 break;
1082 }
1083 }
1084 }
1085 else
1086 {
1087 isDNP = ref.GetSymbol()->ResolveDNP( &ref.GetSheetPath(), m_currentVariant )
1089 }
1090
1091 if( isDNP )
1092 continue;
1093 }
1094
1095 if( !m_includeExcluded )
1096 {
1097 bool isExcluded = false;
1098
1099 if( !m_variantNames.empty() )
1100 {
1101 for( const wxString& variantName : m_variantNames )
1102 {
1103 if( ref.GetSymbol()->ResolveExcludedFromBOM( &ref.GetSheetPath(), variantName )
1104 || ref.GetSheetPath().GetExcludedFromBOM( variantName ) )
1105 {
1106 isExcluded = true;
1107 break;
1108 }
1109 }
1110 }
1111 else
1112 {
1113 isExcluded = ref.GetSymbol()->ResolveExcludedFromBOM( &ref.GetSheetPath(), m_currentVariant )
1115 }
1116
1117 if( isExcluded )
1118 continue;
1119 }
1120
1121 // Check if the symbol if on the current sheet or, in the sheet path somewhere
1122 // depending on scope
1123 if( ( m_scope == SCOPE::SCOPE_SHEET && ref.GetSheetPath() != m_path )
1124 || ( m_scope == SCOPE::SCOPE_SHEET_RECURSIVE
1125 && !ref.GetSheetPath().IsContainedWithin( m_path ) ) )
1126 {
1127 continue;
1128 }
1129
1130 bool matchFound = false;
1131
1132 // Performance optimization for ungrouped case to skip the N^2 for loop
1133 if( !m_groupingEnabled && !ref.IsMultiUnit() )
1134 {
1135 m_rows.emplace_back( DATA_MODEL_ROW( ref, GROUP_SINGLETON ) );
1136 continue;
1137 }
1138
1139 // See if we already have a row which this symbol fits into
1140 for( DATA_MODEL_ROW& row : m_rows )
1141 {
1142 // all group members must have identical refs so just use the first one
1143 SCH_REFERENCE rowRef = row.m_Refs[0];
1144
1145 if( unitMatch( ref, rowRef ) )
1146 {
1147 matchFound = true;
1148 row.m_Refs.push_back( ref );
1149 break;
1150 }
1151 else if( m_groupingEnabled && groupMatch( ref, rowRef ) )
1152 {
1153 matchFound = true;
1154 row.m_Refs.push_back( ref );
1155 row.m_Flag = GROUP_COLLAPSED;
1156 break;
1157 }
1158 }
1159
1160 if( !matchFound )
1161 m_rows.emplace_back( DATA_MODEL_ROW( ref, GROUP_SINGLETON ) );
1162 }
1163
1164 if( GetView() )
1165 {
1166 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_rows.size() );
1167 GetView()->ProcessTableMessage( msg );
1168 }
1169
1170 Sort();
1171}
1172
1173
1175{
1176 std::vector<DATA_MODEL_ROW> children;
1177
1178 for( SCH_REFERENCE& ref : m_rows[aRow].m_Refs )
1179 {
1180 bool matchFound = false;
1181
1182 // See if we already have a child group which this symbol fits into
1183 for( DATA_MODEL_ROW& child : children )
1184 {
1185 // group members are by definition all matching, so just check
1186 // against the first member
1187 if( unitMatch( ref, child.m_Refs[0] ) )
1188 {
1189 matchFound = true;
1190 child.m_Refs.push_back( ref );
1191 break;
1192 }
1193 }
1194
1195 if( !matchFound )
1196 children.emplace_back( DATA_MODEL_ROW( ref, CHILD_ITEM ) );
1197 }
1198
1199 if( children.size() < 2 )
1200 return;
1201
1202 std::sort( children.begin(), children.end(),
1203 [this]( const DATA_MODEL_ROW& lhs, const DATA_MODEL_ROW& rhs ) -> bool
1204 {
1205 return cmp( lhs, rhs, this, m_sortColumn, m_sortAscending );
1206 } );
1207
1208 m_rows[aRow].m_Flag = GROUP_EXPANDED;
1209 m_rows.insert( m_rows.begin() + aRow + 1, children.begin(), children.end() );
1210
1211 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, aRow, children.size() );
1212 GetView()->ProcessTableMessage( msg );
1213}
1214
1215
1217{
1218 auto firstChild = m_rows.begin() + aRow + 1;
1219 auto afterLastChild = firstChild;
1220 int deleted = 0;
1221
1222 while( afterLastChild != m_rows.end() && afterLastChild->m_Flag == CHILD_ITEM )
1223 {
1224 deleted++;
1225 afterLastChild++;
1226 }
1227
1228 m_rows[aRow].m_Flag = GROUP_COLLAPSED;
1229 m_rows.erase( firstChild, afterLastChild );
1230
1231 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow + 1, deleted );
1232 GetView()->ProcessTableMessage( msg );
1233}
1234
1235
1237{
1238 DATA_MODEL_ROW& group = m_rows[aRow];
1239
1240 if( group.m_Flag == GROUP_COLLAPSED )
1241 ExpandRow( aRow );
1242 else if( group.m_Flag == GROUP_EXPANDED )
1243 CollapseRow( aRow );
1244}
1245
1246
1248{
1249 for( size_t i = 0; i < m_rows.size(); ++i )
1250 {
1251 if( m_rows[i].m_Flag == GROUP_EXPANDED )
1252 {
1253 CollapseRow( i );
1255 }
1256 }
1257}
1258
1259
1261{
1262 for( size_t i = 0; i < m_rows.size(); ++i )
1263 {
1264 if( m_rows[i].m_Flag == GROUP_COLLAPSED_DURING_SORT )
1265 ExpandRow( i );
1266 }
1267}
1268
1269
1271 const wxString& aVariantName )
1272{
1273 bool symbolModified = false;
1274 std::unique_ptr<SCH_SYMBOL> symbolCopy;
1275
1276 for( size_t i = 0; i < m_symbolsList.GetCount(); i++ )
1277 {
1278 SCH_SYMBOL* symbol = m_symbolsList[i].GetSymbol();
1279 SCH_SYMBOL* nextSymbol = nullptr;
1280
1281 if( ( i + 1 ) < m_symbolsList.GetCount() )
1282 nextSymbol = m_symbolsList[i + 1].GetSymbol();
1283
1284 if( i == 0 )
1285 symbolCopy = std::make_unique<SCH_SYMBOL>( *symbol );
1286
1287 KIID_PATH key = makeDataStoreKey( m_symbolsList[i].GetSheetPath(), *symbol );
1288 const std::map<wxString, wxString>& fieldStore = m_dataStore[key];
1289
1290 for( const auto& [srcName, srcValue] : fieldStore )
1291 {
1292 // Attributes bypass the field logic, so handle them first
1293 if( isAttribute( srcName ) )
1294 {
1295 symbolModified |= setAttributeValue( m_symbolsList[i], srcName, srcValue, aVariantName );
1296 continue;
1297 }
1298
1299 // Skip generated fields with variables as names (e.g. ${QUANTITY});
1300 // they can't be edited
1301 if( IsGeneratedField( srcName ) )
1302 continue;
1303
1304 SCH_FIELD* destField = symbol->FindFieldCaseInsensitive( srcName );
1305
1306 if( destField && !destField->IsMandatory() && destField->GetName() != srcName )
1307 {
1308 destField->SetName( srcName );
1309 symbolModified = true;
1310 }
1311
1312 if( destField && destField->IsPrivate() )
1313 {
1314 if( srcValue.IsEmpty() )
1315 continue;
1316 else
1317 destField->SetPrivate( false );
1318 }
1319
1320 int col = GetFieldNameCol( srcName );
1321 bool userAdded = ( col != -1 && m_cols[col].m_userAdded );
1322
1323 // Add a not existing field if it has a value for this symbol
1324 bool createField = !destField && ( !srcValue.IsEmpty() || userAdded );
1325
1326 if( createField )
1327 {
1328 destField = symbol->AddField( SCH_FIELD( symbol, FIELD_T::USER, srcName ) );
1329 destField->SetTextAngle( symbol->GetField( FIELD_T::REFERENCE )->GetTextAngle() );
1330
1331 if( const TEMPLATE_FIELDNAME* srcTemplate = aTemplateFieldnames.GetFieldName( srcName ) )
1332 destField->SetVisible( srcTemplate->m_Visible );
1333 else
1334 destField->SetVisible( false );
1335
1336 destField->SetTextPos( symbol->GetPosition() );
1337 symbolModified = true;
1338 }
1339
1340 if( !destField )
1341 continue;
1342
1343 // Reference is not editable from this dialog
1344 if( destField->GetId() == FIELD_T::REFERENCE )
1345 continue;
1346
1347 wxString previousValue = destField->GetText( &m_symbolsList[i].GetSheetPath(), aVariantName );
1348
1349 destField->SetText( symbol->Schematic()->ConvertRefsToKIIDs( srcValue ), &m_symbolsList[i].GetSheetPath(),
1350 aVariantName );
1351
1352 if( !createField && ( previousValue != srcValue ) )
1353 symbolModified = true;
1354 }
1355
1356 for( int ii = static_cast<int>( symbol->GetFields().size() ) - 1; ii >= 0; ii-- )
1357 {
1358 if( symbol->GetFields()[ii].IsMandatory() || symbol->GetFields()[ii].IsPrivate() )
1359 continue;
1360
1361 const wxString& existingName = symbol->GetFields()[ii].GetName();
1362
1363 bool stillTracked = std::any_of( fieldStore.begin(), fieldStore.end(),
1364 [&]( const auto& kv )
1365 {
1366 return kv.first.IsSameAs( existingName, false );
1367 } );
1368
1369 if( !stillTracked )
1370 {
1371 symbol->GetFields().erase( symbol->GetFields().begin() + ii );
1372 symbolModified = true;
1373 }
1374 }
1375
1376 if( symbolModified && ( symbol != nextSymbol ) )
1377 aCommit.Modified( symbol, symbolCopy.release(), m_symbolsList[i].GetSheetPath().LastScreen() );
1378
1379 // Only reset the modified flag and next symbol copy if the next symbol is different from the current one.
1380 if( symbol != nextSymbol )
1381 {
1382 if( nextSymbol )
1383 symbolCopy = std::make_unique<SCH_SYMBOL>( *nextSymbol );
1384 else
1385 symbolCopy.reset( nullptr );
1386
1387 symbolModified = false;
1388 }
1389 }
1390
1391 m_edited = false;
1392}
1393
1394
1396{
1397 int width = 0;
1398
1399 if( ColIsReference( aCol ) )
1400 {
1401 for( int row = 0; row < GetNumberRows(); ++row )
1402 width = std::max( width, KIUI::GetTextSize( GetValue( row, aCol ), GetView() ).x );
1403 }
1404 else
1405 {
1406 wxString fieldName = GetColFieldName( aCol ); // symbol fieldName or Qty string
1407
1408 for( unsigned symbolRef = 0; symbolRef < m_symbolsList.GetCount(); ++symbolRef )
1409 {
1410 KIID_PATH key = makeDataStoreKey( m_symbolsList[symbolRef].GetSheetPath(),
1411 *m_symbolsList[symbolRef].GetSymbol() );
1412 wxString text = m_dataStore[key][fieldName];
1413
1414 width = std::max( width, KIUI::GetTextSize( text, GetView() ).x );
1415 }
1416 }
1417
1418 return width;
1419}
1420
1421
1422void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyBomPreset( const BOM_PRESET& aPreset, const wxString& aVariantName )
1423{
1424 // Hide and un-group everything by default
1425 for( size_t i = 0; i < m_cols.size(); i++ )
1426 {
1427 SetShowColumn( i, false );
1428 SetGroupColumn( i, false );
1429 }
1430
1431 std::set<wxString> seen;
1432 std::vector<wxString> order;
1433
1434 // Set columns that are present and shown
1435 for( const BOM_FIELD& field : aPreset.fieldsOrdered )
1436 {
1437 // Ignore empty fields
1438 if( !field.name || seen.count( field.name ) )
1439 continue;
1440
1441 seen.insert( field.name );
1442 order.emplace_back( field.name );
1443
1444 int col = GetFieldNameCol( field.name );
1445
1446 // Add any missing fields, if the user doesn't add any data
1447 // they won't be saved to the symbols anyway
1448 if( col == -1 )
1449 {
1450 AddColumn( field.name, field.label, true, aVariantName );
1451 col = GetFieldNameCol( field.name );
1452 }
1453 else
1454 {
1455 SetColLabelValue( col, field.label );
1456 }
1457
1458 SetGroupColumn( col, field.groupBy );
1459 SetShowColumn( col, field.show );
1460 }
1461
1462 // Set grouping columns
1464
1465 SetFieldsOrder( order );
1466
1467 // Set our sorting
1468 int sortCol = GetFieldNameCol( aPreset.sortField );
1469
1470 if( sortCol == -1 )
1472
1473 SetSorting( sortCol, aPreset.sortAsc );
1474
1475 SetFilter( aPreset.filterString );
1476 SetExcludeDNP( aPreset.excludeDNP );
1478 SetCurrentVariant( aVariantName );
1479
1480 RebuildRows();
1481}
1482
1483
1485{
1486 BOM_PRESET current;
1487 current.readOnly = false;
1488 current.fieldsOrdered = GetFieldsOrdered();
1489
1490 if( GetSortCol() >= 0 && GetSortCol() < GetNumberCols() )
1491 current.sortField = GetColFieldName( GetSortCol() );
1492
1493 current.sortAsc = GetSortAsc();
1494 current.filterString = GetFilter();
1495 current.groupSymbols = GetGroupingEnabled();
1496 current.excludeDNP = GetExcludeDNP();
1498
1499 return current;
1500}
1501
1502
1504{
1505 wxString out;
1506
1507 if( m_cols.empty() )
1508 return out;
1509
1510 int last_col = -1;
1511
1512 // Find the location for the line terminator
1513 for( size_t col = 0; col < m_cols.size(); col++ )
1514 {
1515 if( m_cols[col].m_show )
1516 last_col = static_cast<int>( col );
1517 }
1518
1519 // No shown columns
1520 if( last_col == -1 )
1521 return out;
1522
1523 auto formatField =
1524 [&]( wxString field, bool last ) -> wxString
1525 {
1526 if( !settings.keepLineBreaks )
1527 {
1528 field.Replace( wxS( "\r" ), wxS( "" ) );
1529 field.Replace( wxS( "\n" ), wxS( "" ) );
1530 }
1531
1532 if( !settings.keepTabs )
1533 {
1534 field.Replace( wxS( "\t" ), wxS( "" ) );
1535 }
1536
1537 if( !settings.stringDelimiter.IsEmpty() )
1538 {
1539 field.Replace( settings.stringDelimiter,
1540 settings.stringDelimiter + settings.stringDelimiter );
1541 }
1542
1543 return settings.stringDelimiter + field + settings.stringDelimiter
1544 + ( last ? wxString( wxS( "\n" ) ) : settings.fieldDelimiter );
1545 };
1546
1547 // Column names
1548 for( size_t col = 0; col < m_cols.size(); col++ )
1549 {
1550 if( !m_cols[col].m_show )
1551 continue;
1552
1553 out.Append( formatField( m_cols[col].m_label, col == static_cast<size_t>( last_col ) ) );
1554 }
1555
1556 // Data rows
1557 for( size_t row = 0; row < m_rows.size(); row++ )
1558 {
1559 // Don't output child rows
1560 if( GetRowFlags( static_cast<int>( row ) ) == CHILD_ITEM )
1561 continue;
1562
1563 for( size_t col = 0; col < m_cols.size(); col++ )
1564 {
1565 if( !m_cols[col].m_show )
1566 continue;
1567
1568 // Get the unannotated version of the field, e.g. no "> " or "v " by
1569 out.Append( formatField( GetExportValue( static_cast<int>( row ), static_cast<int>( col ),
1570 settings.refDelimiter, settings.refRangeDelimiter ),
1571 col == static_cast<size_t>( last_col ) ) );
1572 }
1573 }
1574
1575 return out;
1576}
1577
1578
1580{
1581 bool refListChanged = false;
1582
1583 for( const SCH_REFERENCE& ref : aRefs )
1584 {
1585 if( !m_symbolsList.Contains( ref ) )
1586 {
1587 SCH_SYMBOL* symbol = ref.GetSymbol();
1588
1589 m_symbolsList.AddItem( ref );
1590
1591 KIID_PATH key = makeDataStoreKey( ref.GetSheetPath(), *symbol );
1592
1593 // Update the fields of every reference
1594 for( const SCH_FIELD& field : symbol->GetFields() )
1595 {
1596 if( !field.IsPrivate() )
1597 {
1598 wxString name = field.GetCanonicalName();
1599 wxString value = symbol->Schematic()->ConvertKIIDsToRefs( field.GetText() );
1600
1601 m_dataStore[key][name] = value;
1602 }
1603 }
1604
1605 for( const DATA_MODEL_COL& col : m_cols )
1606 m_dataStore[key].try_emplace( col.m_fieldName, wxEmptyString );
1607
1608 refListChanged = true;
1609 }
1610 }
1611
1612 if( refListChanged )
1613 m_symbolsList.SortBySymbolPtr();
1614}
1615
1616
1618{
1619 // The schematic event listener passes us the symbol after it has been removed,
1620 // so we can't just work with a SCH_REFERENCE_LIST like the other handlers as the
1621 // references are already gone. Instead we need to prune our list.
1622
1623 // Since we now use full KIID_PATH as keys, we need to find and remove all entries
1624 // that correspond to this symbol (their keys end with the symbol's UUID)
1625 KIID symbolUuid = aSymbol.m_Uuid;
1626 std::vector<KIID_PATH> keysToRemove;
1627
1628 for( const auto& [key, value] : m_dataStore )
1629 {
1630 if( !key.empty() && ( key.back() == symbolUuid ) )
1631 keysToRemove.push_back( key );
1632 }
1633
1634 for( const KIID_PATH& key : keysToRemove )
1635 m_dataStore.erase( key );
1636
1637 // Remove all refs that match this symbol using remove_if
1638 m_symbolsList.erase( std::remove_if( m_symbolsList.begin(), m_symbolsList.end(),
1639 [&aSymbol]( const SCH_REFERENCE& ref ) -> bool
1640 {
1641 return ref.GetSymbol()->m_Uuid == aSymbol.m_Uuid;
1642 } ),
1643 m_symbolsList.end() );
1644}
1645
1646
1648{
1649 for( const SCH_REFERENCE& ref : aRefs )
1650 {
1651 int index = m_symbolsList.FindRefByFullPath( ref.GetFullPath() );
1652
1653 if( index != -1 )
1654 {
1655 KIID_PATH key = makeDataStoreKey( ref.GetSheetPath(), *ref.GetSymbol() );
1656 m_dataStore.erase( key );
1657 m_symbolsList.RemoveItem( index );
1658 }
1659 }
1660}
1661
1662
1664 const wxString& aVariantName )
1665{
1666 bool refListChanged = false;
1667
1668 for( const SCH_REFERENCE& ref : aRefs )
1669 {
1670 // Update the fields of every reference. Do this by iterating through the data model
1671 // columns; we must have all fields in the symbol added to the data model at this point,
1672 // and some of the data model columns may be variables that are not present in the symbol
1673 for( const DATA_MODEL_COL& col : m_cols )
1674 updateDataStoreSymbolField( ref, col.m_fieldName, aVariantName );
1675
1676 if( SCH_REFERENCE* listRef = m_symbolsList.FindItem( ref ) )
1677 {
1678 *listRef = ref;
1679 }
1680 else
1681 {
1682 m_symbolsList.AddItem( ref );
1683 refListChanged = true;
1684 }
1685 }
1686
1687 if( refListChanged )
1688 m_symbolsList.SortBySymbolPtr();
1689}
1690
1691
1693{
1694 // Serialize the un-applied edit store keyed by symbol identity (sheet path + UUID), so that
1695 // restoring it is independent of the current row grouping/order.
1696 nlohmann::json j = nlohmann::json::object();
1697
1698 for( const auto& [key, fields] : m_dataStore )
1699 {
1700 nlohmann::json jfields = nlohmann::json::object();
1701
1702 for( const auto& [name, value] : fields )
1703 jfields[std::string( name.ToUTF8() )] = std::string( value.ToUTF8() );
1704
1705 j[std::string( key.AsString().ToUTF8() )] = jfields;
1706 }
1707
1708 return wxString( j.dump() );
1709}
1710
1711
1713{
1714 nlohmann::json j = nlohmann::json::parse( aState.ToStdString(), nullptr, false );
1715
1716 if( !j.is_object() )
1717 return;
1718
1719 for( auto it = j.begin(); it != j.end(); ++it )
1720 {
1721 KIID_PATH key( wxString::FromUTF8( it.key().c_str() ) );
1722 std::map<wxString, wxString>& fields = m_dataStore[key];
1723
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() );
1727 }
1728
1729 m_edited = true;
1730 RebuildRows();
1731
1732 if( GetView() )
1733 GetView()->ForceRefresh();
1734}
1735
1736
1737bool FIELDS_EDITOR_GRID_DATA_MODEL::DeleteRows( size_t aPosition, size_t aNumRows )
1738{
1739 size_t curNumRows = m_rows.size();
1740
1741 if( aPosition >= curNumRows )
1742 {
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 ) );
1747
1748 return false;
1749 }
1750
1751 if( aNumRows > curNumRows - aPosition )
1752 {
1753 aNumRows = curNumRows - aPosition;
1754 }
1755
1756 if( aNumRows >= curNumRows )
1757 {
1758 m_rows.clear();
1759 m_dataStore.clear();
1760 }
1761 else
1762 {
1763 const auto first = m_rows.begin() + aPosition;
1764 std::vector<SCH_REFERENCE> dataMapRefs = first->m_Refs;
1765 m_rows.erase( first, first + aNumRows );
1766
1767 for( const SCH_REFERENCE& ref : dataMapRefs )
1768 m_dataStore.erase( ref.GetSheetPath().Path() );
1769 }
1770
1771 if( GetView() )
1772 {
1773 wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPosition, aNumRows );
1774 GetView()->ProcessTableMessage( msg );
1775 }
1776
1777 return true;
1778}
1779
1780
1781std::vector<FIELD_CASE_CONFLICT> DetectFieldCaseConflicts( const SCH_REFERENCE_LIST& aSymbols )
1782{
1783 std::vector<FIELD_CASE_CONFLICT> conflicts;
1784
1785 for( unsigned i = 0; i < aSymbols.GetCount(); ++i )
1786 {
1787 SCH_SYMBOL* symbol = aSymbols[i].GetSymbol();
1788
1789 if( !symbol )
1790 continue;
1791
1792 std::map<wxString, std::vector<std::pair<wxString, wxString>>> groups;
1793
1794 for( const SCH_FIELD& field : symbol->GetFields() )
1795 {
1796 if( field.IsMandatory() || field.IsPrivate() )
1797 continue;
1798
1799 groups[field.GetName().Lower()].emplace_back( field.GetName(), field.GetText() );
1800 }
1801
1802 for( const auto& [key, members] : groups )
1803 {
1804 if( members.size() < 2 )
1805 continue;
1806
1808 c.symbol = symbol;
1809 c.sheetPath = aSymbols[i].GetSheetPath();
1810 c.reference = symbol->GetRef( &c.sheetPath );
1811 c.caseFoldedKey = key;
1812 c.variants = members;
1813 conflicts.push_back( std::move( c ) );
1814 }
1815 }
1816
1817 return conflicts;
1818}
int index
const char * name
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition commit.cpp:160
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
Look in all existing matchers, return the earliest match of any of the existing.
const KIID m_Uuid
Definition eda_item.h:535
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:172
void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:580
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:385
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:298
int GetFieldNameCol(const wxString &aFieldName) const
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser, const wxString &aVariantName)
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.
wxGridCellRenderer * m_textVarRenderer
Renderer for cells with text variable references.
void UpdateReferences(const SCH_REFERENCE_LIST &aRefs, const wxString &aVariantName)
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)
void updateDataStoreSymbolField(const SCH_REFERENCE &aSymbolRef, const wxString &aFieldName, const wxString &aVariantName)
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)
wxString GetExportValue(int aRow, int aCol, const wxString &refDelimiter, const wxString &refRangeDelimiter)
wxString getDefaultFieldValue(const SCH_REFERENCE &aRef, const wxString &aFieldName)
Get the default (non-variant) value for a field.
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)
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
static const wxString QUANTITY_VARIABLE
void SetGroupColumn(int aCol, bool group)
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
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)
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.
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
Definition kiid.h:48
wxString ConvertKIIDsToRefs(const wxString &aSource) const
wxString ConvertRefsToKIIDs(const wxString &aSource) const
bool IsMandatory() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:132
FIELD_T GetId() const
Definition sch_field.h:136
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)
Definition sch_item.h:251
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:272
bool IsPrivate() const
Definition sch_item.h:252
bool ResolveExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:318
bool ResolveDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:366
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)
wxString GetRef() const
bool GetSymbolExcludedFromBoard() const
wxString GetFullRef(bool aIncludeUnit=true) const
Return reference name with unit altogether.
bool GetSymbolExcludedFromSim(const wxString &aVariant=wxEmptyString) const
bool IsMultiUnit() const
wxString GetRefNumber() const
void SetSymbolDNP(bool aEnable, const wxString &aVariant=wxEmptyString)
int GetRefCount() const
Definition sch_screen.h:172
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.
bool GetDNP() const
Schematic symbol object.
Definition sch_symbol.h:73
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
Definition sch_symbol.h:889
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 GetColLabelValue(int aCol) override
std::vector< BOM_FIELD > m_fields
void SetValue(int aRow, int aCol, const wxString &aValue) 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)
Definition wx_grid.cpp:47
std::map< int, wxGridCellAttr * > m_colAttrs
Definition wx_grid.h:104
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
Definition wx_grid.h:68
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition common.cpp:63
bool IsGeneratedField(const wxString &aSource)
Returns true if the string is generated, e.g contains a single text var reference.
Definition common.cpp:460
The common library.
#define _(s)
@ CTX_SEARCH
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 LABEL_COLUMN
#define DISPLAY_NAME_COLUMN
#define GROUP_BY_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...
Definition ui_common.cpp:78
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 label
wxString name
wxString fieldDelimiter
wxString stringDelimiter
wxString refRangeDelimiter
wxString refDelimiter
wxString sortField
bool groupSymbols
std::vector< BOM_FIELD > fieldsOrdered
bool includeExcludedFromBOM
bool excludeDNP
wxString filterString
std::vector< SCH_REFERENCE > m_Refs
SCH_SHEET_PATH sheetPath
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.
#define DO_TRANSLATE
#define MANDATORY_FIELDS
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)
std::string path
KIBIS_MODEL * model
#define kv
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition ui_common.h:46
GROUP_COLLAPSED_DURING_SORT
Definition wx_grid.h:47
GROUP_COLLAPSED
Definition wx_grid.h:46
GROUP_EXPANDED
Definition wx_grid.h:48
GROUP_SINGLETON
Definition wx_grid.h:45