KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fields_grid_table.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <font/font.h>
21#include <embedded_files.h>
22#include <kiway.h>
23#include <dialog_shim.h>
24#include <fields_grid_table.h>
25#include <sch_base_frame.h>
26#include <sch_field.h>
27#include <sch_label.h>
28#include <sch_validators.h>
29#include <validators.h>
30#include <sch_edit_frame.h>
31#include <schematic.h>
32#include <template_fieldnames.h>
37#include "eda_doc.h"
39#include "font/fontconfig.h"
42#include <wx/settings.h>
43#include <string_utils.h>
45#include <pgm_base.h>
46#include <project_sch.h>
47
48
49enum
50{
53};
54
55
56#define DEFAULT_FONT_NAME _( "Default Font" )
57
58
60{
61 /*
62 * Symbol netlist format:
63 * pinNumber pinName <tab> pinNumber pinName...
64 * fpFilter fpFilter...
65 */
66 wxString netlist;
67 wxArrayString pins;
68
69 if( aSymbol )
70 {
71 for( const SCH_PIN* pin : aSymbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
72 {
73 bool valid = false;
74 std::vector<wxString> expanded = pin->GetStackedPinNumbers( &valid );
75
76 if( valid && !expanded.empty() )
77 {
78 for( const wxString& number : expanded )
79 pins.push_back( number + ' ' + pin->GetShownName() );
80 }
81 else
82 {
83 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
84 }
85 }
86 }
87
88 if( !pins.IsEmpty() )
89 {
90 wxString pinList = wxJoin( pins, '\t' );
91 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins: %s" ), pinList );
92 netlist << EscapeString( pinList, CTX_LINE );
93 }
94
95 netlist << wxS( "\r" );
96
97 if( aSymbol )
98 {
99 wxArrayString fpFilters = aSymbol->GetFPFilters();
100
101 if( !fpFilters.IsEmpty() )
102 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
103 }
104
105 netlist << wxS( "\r" );
106
107 return netlist;
108}
109
110
111wxString BuildFootprintChooserSymbolNetlist( const std::vector<LIB_SYMBOL*>& aSymbols )
112{
113 if( aSymbols.empty() || !aSymbols.front() )
114 return wxEmptyString;
115
116 wxString symbolNetlist = BuildFootprintChooserSymbolNetlist( aSymbols.front() );
117
118 for( size_t i = 1; i < aSymbols.size(); ++i )
119 {
120 // A grouped-row edit applies to every symbol in the row. Only provide chooser filters
121 // when they describe all of those symbols accurately.
122 if( !aSymbols[i] || BuildFootprintChooserSymbolNetlist( aSymbols[i] ) != symbolNetlist )
123 return wxEmptyString;
124 }
125
126 return symbolNetlist;
127}
128
129
130std::vector<SCH_FIELD> GetSheetFieldsForEditing( const SCH_SHEET& aSheet )
131{
132 std::vector<SCH_FIELD> fields = aSheet.GetFields();
133
134 if( !FindField( fields, FIELD_T::SHEET_REF_SUFFIX ) )
135 {
136 SCH_FIELD suffix( nullptr, FIELD_T::SHEET_REF_SUFFIX,
138 suffix.SetVisible( false );
139 suffix.SetPosition( aSheet.GetPosition() );
142 fields.push_back( suffix );
143 }
144
145 std::stable_sort( fields.begin(), fields.end(),
146 []( const SCH_FIELD& a, const SCH_FIELD& b )
147 {
148 if( a.IsMandatory() != b.IsMandatory() )
149 return a.IsMandatory();
150
151 if( !a.IsMandatory() )
152 {
153 bool aSuffix = a.GetId() == FIELD_T::SHEET_REF_SUFFIX;
154 bool bSuffix = b.GetId() == FIELD_T::SHEET_REF_SUFFIX;
155
156 if( aSuffix != bSuffix )
157 return aSuffix;
158 }
159
160 return a.GetOrdinal() < b.GetOrdinal();
161 } );
162
163 return fields;
164}
165
166
168 LIB_SYMBOL* aSymbol, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
169 m_frame( aFrame ),
170 m_dialog( aDialog ),
172 m_part( aSymbol ),
173 m_filesStack( aFilesStack ),
181{
182 initGrid( aGrid );
183}
184
185
187 SCH_SYMBOL* aSymbol, LIB_SYMBOL* aPart,
188 std::vector<EMBEDDED_FILES*>& aFilesStack ) :
189 m_frame( aFrame ),
190 m_dialog( aDialog ),
192 m_part( aPart ),
193 m_filesStack( aFilesStack ),
194 m_symbolNetlist( BuildFootprintChooserSymbolNetlist( aSymbol->GetLibSymbolRef().get() ) ),
201{
202 initGrid( aGrid );
203}
204
205
207 SCH_SHEET* aSheet, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
208 m_frame( aFrame ),
209 m_dialog( aDialog ),
211 m_part( nullptr ),
212 m_filesStack( aFilesStack ),
219{
220 initGrid( aGrid );
221}
222
223
225 SCH_LABEL_BASE* aLabel, std::vector<EMBEDDED_FILES*>& aFilesStack ) :
226 m_frame( aFrame ),
227 m_dialog( aDialog ),
229 m_part( nullptr ),
230 m_filesStack( aFilesStack ),
237{
238 initGrid( aGrid );
239}
240
241
243{
244 int mandatoryRows = 0;
245
246 for( const SCH_FIELD& field : *this )
247 {
248 if( field.IsMandatory() && ( !privateFieldsAreHidden() || !field.IsPrivate() ) )
249 mandatoryRows++;
250 }
251
252 return mandatoryRows;
253}
254
255
257{
258 std::vector<SCH_FIELD>::push_back( aField );
259
260 m_inheritance.resize( size() );
261}
262
263
265{
266 // Build the various grid cell attributes.
267 // NOTE: validators and cellAttrs are member variables to get the destruction order
268 // right. wxGrid is VERY cranky about this.
269
270 m_readOnlyAttr = new wxGridCellAttr;
271 m_readOnlyAttr->SetReadOnly( true );
272
273 m_fieldNameAttr = new wxGridCellAttr;
275 nameEditor->SetValidator( m_fieldNameValidator );
276 m_fieldNameAttr->SetEditor( nameEditor );
277
278 m_referenceAttr = new wxGridCellAttr;
279 GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
280 referenceEditor->SetValidator( m_referenceValidator );
281 m_referenceAttr->SetEditor( referenceEditor );
282
283 m_valueAttr = new wxGridCellAttr;
284
286 {
287 GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
288 valueEditor->SetValidator( m_valueValidator );
289 m_valueAttr->SetEditor( valueEditor );
290 }
291 else
292 {
293 GRID_CELL_STC_EDITOR* valueEditor = new GRID_CELL_STC_EDITOR( true, true,
294 [this]( wxStyledTextEvent& aEvent, SCINTILLA_TRICKS* aScintillaTricks )
295 {
296 SCH_FIELD* valueField = this->GetField( FIELD_T::VALUE );
297 valueField->OnScintillaCharAdded( aScintillaTricks, aEvent );
298 } );
299
300 m_valueAttr->SetEditor( valueEditor );
301 }
302
303 m_footprintAttr = new wxGridCellAttr;
305 m_dialog,
306 [this]( int )
307 {
308 return m_symbolNetlist;
309 } );
310 fpIdEditor->SetValidator( m_nonUrlValidator );
311 m_footprintAttr->SetEditor( fpIdEditor );
312
313 m_urlAttr = new wxGridCellAttr;
314 SEARCH_STACK* prjSearchStack = PROJECT_SCH::SchSearchS( &m_frame->Prj() );
315 GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( m_dialog, prjSearchStack, m_filesStack );
316 urlEditor->SetValidator( m_urlValidator );
317 m_urlAttr->SetEditor( urlEditor );
318
319 m_nonUrlAttr = new wxGridCellAttr;
320 GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
321 nonUrlEditor->SetValidator( m_nonUrlValidator );
322 m_nonUrlAttr->SetEditor( nonUrlEditor );
323
324 m_curdir = m_frame->Prj().GetProjectPath();
325 m_filepathAttr = new wxGridCellAttr;
326
327 // Create a wild card using wxFileDialog syntax.
328 wxString wildCard( _( "Schematic Files" ) );
329 std::vector<std::string> exts;
330 exts.push_back( FILEEXT::KiCadSchematicFileExtension );
331 wildCard += AddFileExtListToFilter( exts );
332
333 auto filepathEditor = new GRID_CELL_PATH_EDITOR( m_dialog, aGrid, &m_curdir, wildCard );
334 filepathEditor->SetValidator( m_filepathValidator );
335 m_filepathAttr->SetEditor( filepathEditor );
336
337 m_boolAttr = new wxGridCellAttr;
338 m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
339 m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
340 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
341
342 wxArrayString vAlignNames;
343 vAlignNames.Add( _( "Top" ) );
344 vAlignNames.Add( _( "Center" ) );
345 vAlignNames.Add( _( "Bottom" ) );
346 m_vAlignAttr = new wxGridCellAttr;
347 m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
348 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
349
350 wxArrayString hAlignNames;
351 hAlignNames.Add( _( "Left" ) );
352 hAlignNames.Add(_( "Center" ) );
353 hAlignNames.Add(_( "Right" ) );
354 m_hAlignAttr = new wxGridCellAttr;
355 m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
356 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
357
358 wxArrayString orientationNames;
359 orientationNames.Add( _( "Horizontal" ) );
360 orientationNames.Add(_( "Vertical" ) );
361 m_orientationAttr = new wxGridCellAttr;
362 m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
363 m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
364
365 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
366 wxArrayString existingNetclasses;
367
368 wxArrayString fonts;
369 std::vector<std::string> fontNames;
370
371 if( editFrame )
372 {
373 // Load the combobox with existing existingNetclassNames
374 PROJECT_FILE& projectFile = editFrame->Prj().GetProjectFile();
375 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.NetSettings();
376
377 existingNetclasses.push_back( settings->GetDefaultNetclass()->GetName() );
378
379 for( const auto& [name, netclass] : settings->GetNetclasses() )
380 existingNetclasses.push_back( name );
381
382 // We don't need to re-cache the embedded fonts when looking at symbols in the schematic
383 // editor because the fonts are all available in the schematic.
384 const std::vector<wxString>* fontFiles = nullptr;
385
386 if( m_frame->GetScreen() && m_frame->GetScreen()->Schematic() )
387 fontFiles = m_frame->GetScreen()->Schematic()->GetEmbeddedFiles()->GetFontFiles();
388
389 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
390 fontFiles, false );
391 }
392 else
393 {
394 const std::vector<wxString>* fontFiles = m_part->GetEmbeddedFiles()->UpdateFontFiles();
395
396 // If there are font files embedded, we want to re-cache our fonts for each symbol that
397 // we are looking at in the symbol editor.
398 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
399 fontFiles, !fontFiles->empty() );
400 }
401
402 m_netclassAttr = new wxGridCellAttr;
403 m_netclassAttr->SetEditor( new GRID_CELL_COMBOBOX( existingNetclasses ) );
404
405 for( const std::string& name : fontNames )
406 fonts.Add( wxString( name ) );
407
408 fonts.Sort();
409 fonts.Insert( KICAD_FONT_NAME, 0 );
410 fonts.Insert( DEFAULT_FONT_NAME, 0 );
411
412 m_fontAttr = new wxGridCellAttr;
413 m_fontAttr->SetEditor( new GRID_CELL_COMBOBOX( fonts ) );
414
415 m_colorAttr = new wxGridCellAttr;
416 m_colorAttr->SetRenderer( new GRID_CELL_COLOR_RENDERER( m_dialog ) );
417 m_colorAttr->SetEditor( new GRID_CELL_COLOR_SELECTOR( m_dialog, aGrid ) );
418
419 m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
420
422
423 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
424}
425
426
428{
429 m_readOnlyAttr->DecRef();
430 m_fieldNameAttr->DecRef();
431 m_boolAttr->DecRef();
432 m_referenceAttr->DecRef();
433 m_valueAttr->DecRef();
434 m_footprintAttr->DecRef();
435 m_urlAttr->DecRef();
436 m_nonUrlAttr->DecRef();
437 m_filepathAttr->DecRef();
438 m_vAlignAttr->DecRef();
439 m_hAlignAttr->DecRef();
440 m_orientationAttr->DecRef();
441 m_netclassAttr->DecRef();
442 m_fontAttr->DecRef();
443 m_colorAttr->DecRef();
444
445 for( INHERITANCE& inheritance : m_inheritance )
446 inheritance.m_parentField.SetParent( nullptr );
447
448 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
449}
450
451
452void FIELDS_GRID_TABLE::onUnitsChanged( wxCommandEvent& aEvent )
453{
454 if( GetView() )
455 GetView()->ForceRefresh();
456
457 aEvent.Skip();
458}
459
460
462{
463 if( m_frame->GetFrameType() == FRAME_SCH
464 || m_frame->GetFrameType() == FRAME_SCH_VIEWER )
465 {
466 return FDC_SCH_EDIT_COUNT;
467 }
468 else
469 {
471 }
472}
473
474
476{
477 return m_frame->GetFrameType() == FRAME_SCH || m_frame->GetFrameType() == FRAME_SCH_VIEWER;
478}
479
480
482{
483 wxCHECK_MSG( aRow >= 0 && aRow < getVisibleRowCount(), -1, wxT( "Invalid field row" ) );
484
486 return aRow;
487
488 int visibleRow = 0;
489
490 for( int fieldIndex = 0; fieldIndex < static_cast<int>( size() ); ++fieldIndex )
491 {
492 if( at( fieldIndex ).IsPrivate() )
493 continue;
494
495 if( visibleRow == aRow )
496 return fieldIndex;
497
498 ++visibleRow;
499 }
500
501 wxFAIL_MSG( wxT( "Row index off end of visible row count" ) );
502 return -1;
503}
504
505
507{
509 {
510 int visibleRows = 0;
511
512 for( const SCH_FIELD& field : *this )
513 {
514 if( !field.IsPrivate() )
515 visibleRows++;
516 }
517
518 return visibleRows;
519 }
520
521 return (int) this->size();
522}
523
524
526{
527 return at( getFieldIndex( aRow ) );
528}
529
530
532{
533 switch( aCol )
534 {
535 case FDC_NAME: return _( "Name" );
536 case FDC_VALUE: return _( "Value" );
537 case FDC_SHOWN: return _( "Show" );
538 case FDC_SHOW_NAME: return _( "Show Name" );
539 case FDC_H_ALIGN: return _( "H Align" );
540 case FDC_V_ALIGN: return _( "V Align" );
541 case FDC_ITALIC: return _( "Italic" );
542 case FDC_BOLD: return _( "Bold" );
543 case FDC_TEXT_SIZE: return _( "Text Size" );
544 case FDC_ORIENTATION: return _( "Orientation" );
545 case FDC_POSX: return _( "X Position" );
546 case FDC_POSY: return _( "Y Position" );
547 case FDC_FONT: return _( "Font" );
548 case FDC_COLOR: return _( "Color" );
549 case FDC_ALLOW_AUTOPLACE: return _( "Allow Autoplacement" );
550 case FDC_PRIVATE: return _( "Private" );
551 default: wxFAIL; return wxEmptyString;
552 }
553}
554
555
556bool FIELDS_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
557{
558 switch( aCol )
559 {
560 case FDC_NAME:
561 case FDC_VALUE:
562 case FDC_H_ALIGN:
563 case FDC_V_ALIGN:
564 case FDC_TEXT_SIZE:
565 case FDC_ORIENTATION:
566 case FDC_POSX:
567 case FDC_POSY:
568 case FDC_FONT:
569 case FDC_COLOR:
570 return aTypeName == wxGRID_VALUE_STRING;
571
572 case FDC_SHOWN:
573 case FDC_SHOW_NAME:
574 case FDC_ITALIC:
575 case FDC_BOLD:
577 case FDC_PRIVATE:
578 return aTypeName == wxGRID_VALUE_BOOL;
579
580 default:
581 wxFAIL;
582 return false;
583 }
584}
585
586
587bool FIELDS_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
588{
589 return CanGetValueAs( aRow, aCol, aTypeName );
590}
591
592
593wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind )
594{
595 wxCHECK( aRow < GetNumberRows(), nullptr );
596
597 const SCH_FIELD& field = getField( aRow );
598 wxGridCellAttr* attr = nullptr;
599
600 switch( aCol )
601 {
602 case FDC_NAME:
603 if( field.IsMandatory() || field.GetId() == FIELD_T::SHEET_REF_SUFFIX )
604 {
605 attr = m_fieldNameAttr->Clone();
606 attr->SetReadOnly( true );
607 }
608 else
609 {
610 m_fieldNameAttr->IncRef();
611 attr = m_fieldNameAttr;
612 }
613
614 break;
615
616 case FDC_VALUE:
617 if( field.GetId() == FIELD_T::REFERENCE )
618 {
619 m_referenceAttr->IncRef();
620 attr = m_referenceAttr;
621 }
622 else if( field.GetId() == FIELD_T::VALUE )
623 {
624 m_valueAttr->IncRef();
625 attr = m_valueAttr;
626 }
627 else if( field.GetId() == FIELD_T::FOOTPRINT )
628 {
629 // Power symbols have do not appear in the board, so don't allow
630 // a footprint (m_part can be nullptr when loading a old schematic
631 // (for instance Kicad 4) with libraries missing)
632 if( m_part && m_part->IsPower() )
633 {
634 m_readOnlyAttr->IncRef();
635 attr = m_readOnlyAttr;
636 }
637 else
638 {
639 m_footprintAttr->IncRef();
640 attr = m_footprintAttr;
641 }
642 }
643 else if( field.GetId() == FIELD_T::DATASHEET )
644 {
645 m_urlAttr->IncRef();
646 attr = m_urlAttr;
647 }
648 else if( field.GetId() == FIELD_T::SHEET_NAME )
649 {
650 m_referenceAttr->IncRef();
651 attr = m_referenceAttr;
652 }
653 else if( field.GetId() == FIELD_T::SHEET_FILENAME )
654 {
655 m_filepathAttr->IncRef();
656 attr = m_filepathAttr;
657 }
659 && field.GetUntranslatedName() == wxT( "Netclass" ) )
660 {
661 m_netclassAttr->IncRef();
662 attr = m_netclassAttr;
663 }
664 else
665 {
666 wxString fn = GetValue( aRow, FDC_NAME );
667
668 const TEMPLATE_FIELDNAME* templateFn =
669 m_frame->Prj().GetProjectFile().m_TemplateFieldNames.GetFieldName( fn );
670
671 if( ( templateFn && templateFn->m_URL ) || field.HasHypertext() )
672 {
673 m_urlAttr->IncRef();
674 attr = m_urlAttr;
675 }
676 else
677 {
678 m_nonUrlAttr->IncRef();
679 attr = m_nonUrlAttr;
680 }
681 }
682
683 break;
684
685 case FDC_TEXT_SIZE:
686 case FDC_POSX:
687 case FDC_POSY:
688 break;
689
690 case FDC_H_ALIGN:
691 m_hAlignAttr->IncRef();
692 attr = m_hAlignAttr;
693 break;
694
695 case FDC_V_ALIGN:
696 m_vAlignAttr->IncRef();
697 attr = m_vAlignAttr;
698 break;
699
700 case FDC_ORIENTATION:
701 m_orientationAttr->IncRef();
702 attr = m_orientationAttr;
703 break;
704
705 case FDC_SHOWN:
706 case FDC_SHOW_NAME:
707 case FDC_ITALIC:
708 case FDC_BOLD:
710 case FDC_PRIVATE:
711 m_boolAttr->IncRef();
712 attr = m_boolAttr;
713 break;
714
715 case FDC_FONT:
716 m_fontAttr->IncRef();
717 attr = m_fontAttr;
718 break;
719
720 case FDC_COLOR:
721 m_colorAttr->IncRef();
722 attr = m_colorAttr;
723 break;
724
725 default:
726 attr = nullptr;
727 break;
728 }
729
730 if( !attr )
731 return nullptr;
732
733 attr = enhanceAttr( attr, aRow, aCol, aKind );
734
735 if( IsInherited( aRow ) )
736 {
737 wxGridCellAttr* text_attr = attr ? attr->Clone() : new wxGridCellAttr;
738 wxFont font;
739
740 if( !text_attr->HasFont() )
741 font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
742 else
743 font = text_attr->GetFont();
744
745 font.MakeItalic();
746 text_attr->SetFont( font );
747 text_attr->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
748
749 if( attr )
750 attr->DecRef();
751
752 attr = text_attr;
753 }
754
755 return attr;
756}
757
758
759wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol )
760{
761 wxCHECK( aRow < GetNumberRows(), wxEmptyString );
762
763 wxGrid* grid = GetView();
764 const SCH_FIELD& field = getField( aRow );
765
766 if( grid->GetGridCursorRow() == aRow && grid->GetGridCursorCol() == aCol
767 && grid->IsCellEditControlShown() )
768 {
769 auto it = m_evalOriginal.find( { aRow, aCol } );
770
771 if( it != m_evalOriginal.end() )
772 return it->second;
773 }
774
775 switch( aCol )
776 {
777 case FDC_NAME:
778 // Use default field names for mandatory and system fields because they are translated
779 // according to the current locale
781 {
783 }
784 else
785 {
786 if( field.IsMandatory() || field.GetId() == FIELD_T::SHEET_REF_SUFFIX )
787 return GetDefaultFieldName( field.GetId(), TRANSLATED );
788 else
789 return field.GetName( false );
790 }
791
792 case FDC_VALUE:
793 return EscapeString( UnescapeString( field.GetText() ), CTX_LINE );
794
795 case FDC_SHOWN:
796 return StringFromBool( field.IsVisible() );
797
798 case FDC_SHOW_NAME:
799 return StringFromBool( field.IsNameShown() );
800
801 case FDC_H_ALIGN:
802 switch ( field.GetEffectiveHorizJustify() )
803 {
804 case GR_TEXT_H_ALIGN_LEFT: return _( "Left" );
805 case GR_TEXT_H_ALIGN_CENTER: return _( "Center" );
806 case GR_TEXT_H_ALIGN_RIGHT: return _( "Right" );
808 }
809
810 break;
811
812 case FDC_V_ALIGN:
813 switch ( field.GetEffectiveVertJustify() )
814 {
815 case GR_TEXT_V_ALIGN_TOP: return _( "Top" );
816 case GR_TEXT_V_ALIGN_CENTER: return _( "Center" );
817 case GR_TEXT_V_ALIGN_BOTTOM: return _( "Bottom" );
819 }
820
821 break;
822
823 case FDC_ITALIC:
824 return StringFromBool( field.IsItalic() );
825
826 case FDC_BOLD:
827 return StringFromBool( field.IsBold() );
828
829 case FDC_TEXT_SIZE:
830 return m_frame->StringFromValue( field.GetTextHeight(), true );
831
832 case FDC_ORIENTATION:
833 if( field.GetTextAngle().IsHorizontal() )
834 return _( "Horizontal" );
835 else
836 return _( "Vertical" );
837
838 case FDC_POSX:
839 return m_frame->StringFromValue( field.GetTextPos().x, true );
840
841 case FDC_POSY:
842 return m_frame->StringFromValue( field.GetTextPos().y, true );
843
844 case FDC_FONT:
845 if( field.GetFont() )
846 return field.GetFont()->GetName();
847 else
848 return DEFAULT_FONT_NAME;
849
850 case FDC_COLOR:
851 return field.GetTextColor().ToCSSString();
852
854 return StringFromBool( field.CanAutoplace() );
855
856 case FDC_PRIVATE:
857 return StringFromBool( field.IsPrivate() );
858
859 default:
860 // we can't assert here because wxWidgets sometimes calls this without checking
861 // the column type when trying to see if there's an overflow
862 break;
863 }
864
865 return wxT( "bad wxWidgets!" );
866}
867
868
869bool FIELDS_GRID_TABLE::GetValueAsBool( int aRow, int aCol )
870{
871 wxCHECK( aRow < GetNumberRows(), false );
872 const SCH_FIELD& field = getField( aRow );
873
874 switch( aCol )
875 {
876 case FDC_SHOWN: return field.IsVisible();
877 case FDC_SHOW_NAME: return field.IsNameShown();
878 case FDC_ITALIC: return field.IsItalic();
879 case FDC_BOLD: return field.IsBold();
880 case FDC_ALLOW_AUTOPLACE: return field.CanAutoplace();
881 case FDC_PRIVATE: return field.IsPrivate();
882 default:
883 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
884 return false;
885 }
886}
887
888
889void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
890{
891 wxCHECK( aRow < GetNumberRows(), /*void*/ );
892 SCH_FIELD& field = getField( aRow );
893 VECTOR2I pos;
894 wxString value = aValue;
895
896 if( aCol != FDC_VALUE )
897 value.Trim( true ).Trim( false );
898
899 if( aCol == FDC_TEXT_SIZE || aCol == FDC_POSX || aCol == FDC_POSY )
900 {
901 m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
902
903 if( m_eval->Process( value ) )
904 {
905 m_evalOriginal[ { aRow, aCol } ] = value;
906 value = m_eval->Result();
907 }
908 }
909
910 switch( aCol )
911 {
912 case FDC_NAME:
913 if( field.GetId() == FIELD_T::SHEET_REF_SUFFIX )
914 break;
915
919 {
920 break;
921 }
922
923 field.SetName( value );
924 break;
925
926 case FDC_VALUE:
928 {
930 }
931 else if( m_parentType == LIB_SYMBOL_T && field.GetId() == FIELD_T::VALUE )
932 {
933 value = EscapeString( value, CTX_LIBID );
934 }
935 else if( m_frame )
936 {
937 value = ConvertPathToFileUri( value, &m_frame->Prj() );
938 }
939
940 field.SetText( UnescapeString( value ) );
941 break;
942
943 case FDC_SHOWN:
944 field.SetVisible( BoolFromString( value ) );
945 break;
946
947 case FDC_SHOW_NAME:
948 field.SetNameShown( BoolFromString( value ) );
949 break;
950
951 case FDC_H_ALIGN:
952 {
953 GR_TEXT_H_ALIGN_T horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
954
955 if( value == _( "Left" ) )
956 horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
957 else if( value == _( "Center" ) )
958 horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
959 else if( value == _( "Right" ) )
960 horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
961
962 // Note that we must set justifications before we can ask if they're flipped. If the old
963 // justification is center then it won't know (whereas if the new justification is center
964 // the we don't care).
965 field.SetHorizJustify( horizontalJustification );
966
967 if( field.IsHorizJustifyFlipped() )
968 field.SetHorizJustify( EDA_TEXT::MapHorizJustify( - horizontalJustification ) );
969
970 break;
971 }
972
973 case FDC_V_ALIGN:
974 {
975 GR_TEXT_V_ALIGN_T verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
976
977 if( value == _( "Top" ) )
978 verticalJustification = GR_TEXT_V_ALIGN_TOP;
979 else if( value == _( "Center" ) )
980 verticalJustification = GR_TEXT_V_ALIGN_CENTER;
981 else if( value == _( "Bottom" ) )
982 verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
983
984 // Note that we must set justifications before we can ask if they're flipped. If the old
985 // justification is center then it won't know (whereas if the new justification is center
986 // the we don't care).
987 field.SetVertJustify( verticalJustification );
988
989 if( field.IsVertJustifyFlipped() )
990 field.SetVertJustify( EDA_TEXT::MapVertJustify( -verticalJustification ) );
991
992 break;
993 }
994
995 case FDC_ITALIC:
996 field.SetItalic( BoolFromString( value ) );
997 break;
998
999 case FDC_BOLD:
1000 field.SetBold( BoolFromString( value ) );
1001 break;
1002
1003 case FDC_TEXT_SIZE:
1004 field.SetTextSize( VECTOR2I( m_frame->ValueFromString( value ), m_frame->ValueFromString( value ) ) );
1005 break;
1006
1007 case FDC_ORIENTATION:
1008 if( value == _( "Horizontal" ) )
1010 else if( value == _( "Vertical" ) )
1012 else
1013 wxFAIL_MSG( wxT( "unknown orientation: " ) + value );
1014
1015 break;
1016
1017 case FDC_POSX:
1018 case FDC_POSY:
1019 pos = field.GetTextPos();
1020
1021 if( aCol == FDC_POSX )
1022 pos.x = m_frame->ValueFromString( value );
1023 else
1024 pos.y = m_frame->ValueFromString( value );
1025
1026 field.SetTextPos( pos );
1027 break;
1028
1029 case FDC_FONT:
1030 if( value == DEFAULT_FONT_NAME )
1031 field.SetFont( nullptr );
1032 else if( value == KICAD_FONT_NAME )
1033 field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
1034 else
1035 field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
1036
1037 break;
1038
1039 case FDC_COLOR:
1040 field.SetTextColor( wxColor( value ) );
1041 break;
1042
1044 field.SetCanAutoplace( BoolFromString( value ) );
1045 break;
1046
1047 case FDC_PRIVATE:
1048 field.SetPrivate( BoolFromString( value ) );
1049 break;
1050
1051 default:
1052 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
1053 break;
1054 }
1055
1056 m_dialog->OnModify();
1057
1058 GetView()->Refresh();
1059}
1060
1061
1062void FIELDS_GRID_TABLE::SetValueAsBool( int aRow, int aCol, bool aValue )
1063{
1064 wxCHECK( aRow < GetNumberRows(), /*void*/ );
1065 SCH_FIELD& field = getField( aRow );
1066
1067 switch( aCol )
1068 {
1069 case FDC_SHOWN:
1070 field.SetVisible( aValue );
1071 break;
1072
1073 case FDC_SHOW_NAME:
1074 field.SetNameShown( aValue );
1075 break;
1076
1077 case FDC_ITALIC:
1078 field.SetItalic( aValue );
1079 break;
1080
1081 case FDC_BOLD:
1082 field.SetBold( aValue );
1083 break;
1084
1086 field.SetCanAutoplace( aValue );
1087 break;
1088
1089 case FDC_PRIVATE:
1090 field.SetPrivate( aValue );
1091 break;
1092
1093 default:
1094 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
1095 break;
1096 }
1097
1098 m_dialog->OnModify();
1099}
1100
1101
1102wxString FIELDS_GRID_TABLE::StringFromBool( bool aValue ) const
1103{
1104 if( aValue )
1105 return wxT( "1" );
1106 else
1107 return wxT( "0" );
1108}
1109
1110
1111bool FIELDS_GRID_TABLE::BoolFromString( const wxString& aValue ) const
1112{
1113 if( aValue == wxS( "1" ) )
1114 {
1115 return true;
1116 }
1117 else if( aValue == wxS( "0" ) )
1118 {
1119 return false;
1120 }
1121 else
1122 {
1123 wxFAIL_MSG( wxString::Format( "string '%s' can't be converted to boolean correctly and "
1124 "will be perceived as FALSE", aValue ) );
1125 return false;
1126 }
1127}
1128
1129
1131{
1132 for( SCH_FIELD& field : *this )
1133 {
1134 if( field.GetId() == aFieldId )
1135 return &field;
1136 }
1137
1138 return nullptr;
1139}
1140
1141
1143{
1144 int visibleRow = 0;
1145
1146 for( const SCH_FIELD& field : *this )
1147 {
1148 if( field.GetId() == aFieldId )
1149 return privateFieldsAreHidden() && field.IsPrivate() ? -1 : visibleRow;
1150
1151 if( !privateFieldsAreHidden() || !field.IsPrivate() )
1152 ++visibleRow;
1153 }
1154
1155 return -1;
1156}
1157
1158
1159bool FIELDS_GRID_TABLE::IsInherited( size_t aRow ) const
1160{
1161 int fieldIndex = getFieldIndex( static_cast<int>( aRow ) );
1162
1163 if( fieldIndex < 0 || fieldIndex >= static_cast<int>( m_inheritance.size() ) )
1164 return false;
1165
1166 const INHERITANCE& inheritance = m_inheritance[fieldIndex];
1167
1168 // Any edit, including position or visibility, turns the row into an override
1169 return inheritance.m_derived && at( fieldIndex ).HasSameContent( inheritance.m_parentField );
1170}
1171
1172
1174{
1175 return m_inheritance.at( getFieldIndex( static_cast<int>( aRow ) ) ).m_parentField;
1176}
1177
1178
1179const wxString& FIELDS_GRID_TABLE::InheritedFrom( size_t aRow ) const
1180{
1181 return m_inheritance.at( getFieldIndex( static_cast<int>( aRow ) ) ).m_source;
1182}
1183
1184
1185void FIELDS_GRID_TABLE::AddInheritedField( const SCH_FIELD& aParent, const wxString& aSource )
1186{
1187 push_back( aParent );
1188 back().SetParent( m_part );
1189 m_inheritance.back().m_derived = true;
1190 SetFieldInherited( size() - 1, aParent, aSource );
1191}
1192
1193
1194void FIELDS_GRID_TABLE::SetFieldInherited( size_t aFieldIndex, const SCH_FIELD& aParent, const wxString& aSource )
1195{
1196 wxCHECK( aFieldIndex < size() && aFieldIndex < m_inheritance.size(), /*void*/ );
1197
1198 INHERITANCE& inheritance = m_inheritance[aFieldIndex];
1199 SCH_FIELD& field = at( aFieldIndex );
1200
1201 // Flatten() gives an empty mandatory field the ancestor's value, but any user field the symbol owns wins
1202 if( inheritance.m_derived || ( field.IsMandatory() && field.GetText().IsEmpty() ) )
1203 {
1204 field = aParent;
1205 inheritance.m_derived = true;
1206 }
1207
1208 inheritance.m_parentField = aParent;
1209 inheritance.m_parentField.SetParent( nullptr );
1210 inheritance.m_source = aSource;
1211 inheritance.m_hasParent = true;
1212}
1213
1214
1216{
1217 int fieldIndex = getFieldIndex( static_cast<int>( aRow ) );
1218
1219 if( fieldIndex < 0 || at( fieldIndex ).GetId() == FIELD_T::SHEET_REF_SUFFIX )
1220 return false;
1221
1222 if( m_inheritance.size() > static_cast<size_t>( fieldIndex ) )
1223 {
1224 INHERITANCE& inheritance = m_inheritance[fieldIndex];
1225
1226 // You can't erase inherited fields, but you can reset them to the parent value.
1227 if( inheritance.m_hasParent )
1228 {
1229 at( fieldIndex ) = inheritance.m_parentField;
1230 inheritance.m_derived = true;
1231 return false;
1232 }
1233
1234 m_inheritance.erase( m_inheritance.begin() + fieldIndex );
1235 }
1236
1237 std::vector<SCH_FIELD>::erase( begin() + fieldIndex );
1238 return true;
1239}
1240
1241void FIELDS_GRID_TABLE::SwapRows( size_t a, size_t b )
1242{
1243 int fieldIndexA = getFieldIndex( static_cast<int>( a ) );
1244 int fieldIndexB = getFieldIndex( static_cast<int>( b ) );
1245
1246 wxCHECK( fieldIndexA >= 0 && fieldIndexB >= 0, /*void*/ );
1247 wxCHECK( fieldIndexA < static_cast<int>( m_inheritance.size() )
1248 && fieldIndexB < static_cast<int>( m_inheritance.size() ),
1249 /*void*/ );
1250
1251 std::swap( at( fieldIndexA ), at( fieldIndexB ) );
1252 std::swap( m_inheritance[fieldIndexA], m_inheritance[fieldIndexB] );
1253}
1254
1255
1257{
1258 for( SCH_FIELD& field : *this )
1259 field.SetParent( nullptr );
1260
1261 for( INHERITANCE& inheritance : m_inheritance )
1262 inheritance.m_parentField.SetParent( nullptr );
1263}
1264
1265
1267{
1268 return static_cast<FIELDS_GRID_TABLE*>( m_grid->GetTable() )->GetFieldRow( aFieldId );
1269}
1270
1271
1272void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
1273{
1274 if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::FOOTPRINT )
1275 && m_grid->GetGridCursorCol() == FDC_VALUE
1276 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE ) )
1277 {
1278 menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ), _( "Browse for footprint" ) );
1279 menu.AppendSeparator();
1280 }
1281 else if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::DATASHEET )
1282 && m_grid->GetGridCursorCol() == FDC_VALUE
1283 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE ) )
1284 {
1285 menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ), _( "Show datasheet in browser" ) );
1286 menu.AppendSeparator();
1287 }
1288
1289 GRID_TRICKS::showPopupMenu( menu, aEvent );
1290}
1291
1292
1293void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
1294{
1295 if( event.GetId() == MYID_SELECT_FOOTPRINT )
1296 {
1297 // pick a footprint using the footprint picker.
1298 wxString fpid = m_grid->GetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE );
1299
1300 if( SelectFootprintFromChooser( m_dlg, fpid ) )
1301 m_grid->SetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE, fpid );
1302 }
1303 else if (event.GetId() == MYID_SHOW_DATASHEET )
1304 {
1305 wxString datasheet_uri = m_grid->GetCellValue( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE );
1306
1307 GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj(), PROJECT_SCH::SchSearchS( &m_dlg->Prj() ),
1308 m_filesStack );
1309 }
1310 else
1311 {
1313 }
1314}
const char * name
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:81
bool IsHorizontal() const
Definition eda_angle.h:141
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
virtual VECTOR2I GetTextSize() const
Definition eda_text.h:301
void SetTextColor(const COLOR4D &aColor)
Definition eda_text.h:309
COLOR4D GetTextColor() const
Definition eda_text.h:310
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:313
bool IsItalic() const
Definition eda_text.h:200
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:513
virtual bool IsVisible() const
Definition eda_text.h:226
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:557
virtual int GetTextHeight() const
Definition eda_text.h:307
KIFONT::FONT * GetFont() const
Definition eda_text.h:286
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:379
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:348
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition eda_text.cpp:70
virtual EDA_ANGLE GetTextAngle() const
Definition eda_text.h:178
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition eda_text.cpp:311
bool IsBold() const
Definition eda_text.h:215
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition eda_text.cpp:84
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:269
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:291
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:472
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:371
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
bool IsInherited(size_t aRow) const
const wxString & InheritedFrom(size_t aRow) const
SCH_FIELD * GetField(FIELD_T aFieldId)
wxString StringFromBool(bool aValue) const
bool GetValueAsBool(int aRow, int aCol) override
void SetFieldInherited(size_t aFieldIndex, const SCH_FIELD &aParent, const wxString &aSource)
Record the ancestor field that aFieldIndex resolves against.
FIELD_VALIDATOR m_fieldNameValidator
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void initGrid(WX_GRID *aGrid)
wxGridCellAttr * m_fieldNameAttr
int GetNumberRows() override
void push_back(const SCH_FIELD &field)
wxGridCellAttr * m_readOnlyAttr
int GetMandatoryRowCount() const
FIELD_VALIDATOR m_urlValidator
SCH_BASE_FRAME * m_frame
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
wxGridCellAttr * m_colorAttr
wxGridCellAttr * m_nonUrlAttr
bool EraseRow(size_t row)
wxGridCellAttr * m_referenceAttr
FIELD_VALIDATOR m_referenceValidator
FIELD_VALIDATOR m_valueValidator
std::map< std::pair< int, int >, wxString > m_evalOriginal
std::vector< INHERITANCE > m_inheritance
const SCH_FIELD & ParentField(size_t aRow) const
wxGridCellAttr * m_footprintAttr
wxGridCellAttr * m_boolAttr
int GetFieldRow(FIELD_T aFieldId)
bool BoolFromString(const wxString &aValue) const
wxGridCellAttr * m_fontAttr
wxGridCellAttr * m_urlAttr
wxGridCellAttr * m_valueAttr
wxGridCellAttr * m_hAlignAttr
wxGridCellAttr * m_orientationAttr
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * m_vAlignAttr
bool privateFieldsAreHidden() const
wxGridCellAttr * m_filepathAttr
SCH_FIELD & getField(int aRow)
wxGridCellAttr * m_netclassAttr
void SetValueAsBool(int aRow, int aCol, bool aValue) override
wxString GetValue(int aRow, int aCol) override
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol, std::vector< EMBEDDED_FILES * > &aFilesStack)
int getFieldIndex(int aRow) const
std::vector< EMBEDDED_FILES * > & m_filesStack
void SwapRows(size_t a, size_t b)
void AddInheritedField(const SCH_FIELD &aParent, const wxString &aSource)
Append a row for an ancestor field the symbol does not define.
void onUnitsChanged(wxCommandEvent &aEvent)
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
FIELD_VALIDATOR m_nonUrlValidator
FIELD_VALIDATOR m_filepathValidator
wxString GetColLabelValue(int aCol) override
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
int getFieldRow(FIELD_T aFieldId)
std::vector< EMBEDDED_FILES * > m_filesStack
void doPopupSelection(wxCommandEvent &event) override
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
virtual void SetValidator(const wxValidator &validator) override
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent)
WX_GRID * m_grid
I don't own the grid, but he owns me.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition font.cpp:144
const wxString & GetName() const
Definition font.h:112
wxString ToCSSString() const
Definition color4d.cpp:146
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Define a library symbol object.
Definition lib_symbol.h:114
wxArrayString GetFPFilters() const
Definition lib_symbol.h:254
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
The backing store for a PROJECT, in JSON format.
std::shared_ptr< NET_SETTINGS > & NetSettings()
static SEARCH_STACK * SchSearchS(PROJECT *aProject)
Accessor for Eeschema search stack.
virtual PROJECT_FILE & GetProjectFile() const
Definition project.h:201
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Schematic editor (Eeschema) main window.
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
bool IsMandatory() const
bool IsNameShown() const
Definition sch_field.h:225
bool HasHypertext() const override
Indicates that the item has at least one hypertext action.
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
bool IsVertJustifyFlipped() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:139
FIELD_T GetId() const
Definition sch_field.h:143
void SetCanAutoplace(bool aCanPlace)
Definition sch_field.h:237
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
int GetOrdinal() const
Definition sch_field.h:145
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
void SetName(const wxString &aName)
bool CanAutoplace() const
Definition sch_field.h:236
void SetText(const wxString &aText) override
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
void SetNameShown(bool aShown=true)
Definition sch_field.h:226
void SetPrivate(bool aPrivate)
Definition sch_item.h:258
bool IsPrivate() const
Definition sch_item.h:259
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:50
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:93
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
VECTOR2I GetPosition() const override
Definition sch_sheet.h:548
Schematic symbol object.
Definition sch_symbol.h:76
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
Look for files in a number of paths.
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition wx_grid.cpp:44
void SetupColumnAutosizer(int aFlexibleCol)
Set autosize behaviour using wxFormBuilder column widths as minimums, with a single specified growabl...
Definition wx_grid.cpp:1192
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition common.cpp:880
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:469
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:468
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, std::vector< EMBEDDED_FILES * > aFilesStack)
Open a document (file) with the suitable browser.
Definition eda_doc.cpp:59
This file is part of the common library.
#define DEFAULT_FONT_NAME
std::vector< SCH_FIELD > GetSheetFieldsForEditing(const SCH_SHEET &aSheet)
wxString BuildFootprintChooserSymbolNetlist(const LIB_SYMBOL *aSymbol)
@ FDC_TEXT_SIZE
@ FDC_BOLD
@ FDC_SCH_EDIT_COUNT
@ FDC_POSY
@ FDC_ITALIC
@ FDC_SHOW_NAME
@ FDC_NAME
@ FDC_H_ALIGN
@ FDC_COLOR
@ FDC_SHOWN
@ FDC_ALLOW_AUTOPLACE
@ FDC_VALUE
@ FDC_SYMBOL_EDITOR_COUNT
@ FDC_POSX
@ FDC_ORIENTATION
@ FDC_V_ALIGN
@ FDC_FONT
@ FDC_PRIVATE
wxString BuildFootprintChooserSymbolNetlist(const LIB_SYMBOL *aSymbol)
FONTCONFIG * Fontconfig()
@ FRAME_SCH_VIEWER
Definition frame_type.h:32
@ FRAME_SCH
Definition frame_type.h:30
bool SelectFootprintFromChooser(DIALOG_SHIM *aDialog, wxString &aFootprint, const wxString &aSymbolNetlist)
@ GRIDTRICKS_FIRST_CLIENT_ID
Definition grid_tricks.h:46
static const std::string KiCadSchematicFileExtension
@ USER
The main config directory (e.g. ~/.config/kicad/)
#define KICAD_FONT_NAME
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
Definition sch_field.h:390
Definitions of control validators for schematic dialogs.
wxString UnescapeString(const wxString &aSource)
wxString ConvertPathToFileUri(const wxString &aPath, const PROJECT *aProject)
Convert a file path to a file:// URI.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LINE
@ CTX_LIBID
bool m_derived
Row shows the ancestor's value instead of owning one.
Hold a name of a symbol's field, field value, and default visibility.
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
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...
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ SHEET_REF_SUFFIX
Optional sheet field appended to the references of the sheet's symbols.
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
@ UNTRANSLATED
@ TRANSLATED
std::string netlist
KIBIS_PIN * pin
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
@ LIB_SYMBOL_T
Definition typeinfo.h:144
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_SHEET_T
Definition typeinfo.h:171
@ SCH_LABEL_LOCATE_ANY_T
Definition typeinfo.h:187
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition ui_common.h:48
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.