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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <embedded_files.h>
25#include <kiway.h>
26#include <kiway_player.h>
27#include <dialog_shim.h>
28#include <fields_grid_table.h>
29#include <sch_base_frame.h>
30#include <sch_field.h>
31#include <sch_label.h>
32#include <sch_validators.h>
33#include <validators.h>
34#include <sch_edit_frame.h>
35#include <symbol_library.h>
36#include <schematic.h>
37#include <template_fieldnames.h>
42#include "eda_doc.h"
44#include "font/fontconfig.h"
47#include <wx/settings.h>
48#include <string_utils.h>
50#include <pgm_base.h>
51#include <project_sch.h>
52
53
54enum
55{
58};
59
60
61#define DEFAULT_FONT_NAME _( "Default Font" )
62
63
64static wxString netList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH& aSheetPath )
65{
66 /*
67 * Symbol netlist format:
68 * pinNumber pinName <tab> pinNumber pinName...
69 * fpFilter fpFilter...
70 */
71 wxString netlist;
72
73 // We need the list of pins of the lib symbol, not just the pins of the current
74 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
75 // select/filter right footprints
76 wxArrayString pins;
77
78 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = aSymbol->GetLibSymbolRef();
79
80 if( lib_symbol )
81 {
82 for( SCH_PIN* pin : lib_symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
83 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
84 }
85
86 if( !pins.IsEmpty() )
87 netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
88
89 netlist << wxS( "\r" );
90
91 if( lib_symbol )
92 {
93 wxArrayString fpFilters = lib_symbol->GetFPFilters();
94
95 if( !fpFilters.IsEmpty() )
96 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
97 }
98
99 netlist << wxS( "\r" );
100
101 return netlist;
102}
103
104
105static wxString netList( LIB_SYMBOL* aSymbol )
106{
107 /*
108 * Symbol netlist format:
109 * pinNumber pinName <tab> pinNumber pinName...
110 * fpFilter fpFilter...
111 */
112 wxString netlist;
113 wxArrayString pins;
114
115 for( SCH_PIN* pin : aSymbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
116 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
117
118 if( !pins.IsEmpty() )
119 netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
120
121 netlist << wxS( "\r" );
122
123 wxArrayString fpFilters = aSymbol->GetFPFilters();
124
125 if( !fpFilters.IsEmpty() )
126 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
127
128 netlist << wxS( "\r" );
129
130 return netlist;
131}
132
133
135 LIB_SYMBOL* aSymbol, std::vector<EMBEDDED_FILES*> aFilesStack ) :
136 m_frame( aFrame ),
137 m_dialog( aDialog ),
138 m_parentType( SCH_SYMBOL_T ),
139 m_part( aSymbol ),
140 m_filesStack( aFilesStack ),
141 m_symbolNetlist( netList( aSymbol ) ),
142 m_fieldNameValidator( FIELD_T::USER ),
143 m_referenceValidator( FIELD_T::REFERENCE ),
144 m_valueValidator( FIELD_T::VALUE ),
145 m_urlValidator( FIELD_T::USER ),
146 m_nonUrlValidator( FIELD_T::USER ),
147 m_filepathValidator( FIELD_T::SHEET_FILENAME )
148{
149 initGrid( aGrid );
150}
151
152
154 SCH_SYMBOL* aSymbol ) :
155 m_frame( aFrame ),
156 m_dialog( aDialog ),
157 m_parentType( SCH_SYMBOL_T ),
158 m_part( aSymbol->GetLibSymbolRef().get() ),
159 m_symbolNetlist( netList( aSymbol, aFrame->GetCurrentSheet() ) ),
160 m_fieldNameValidator( FIELD_T::USER ),
161 m_referenceValidator( FIELD_T::REFERENCE ),
162 m_valueValidator( FIELD_T::VALUE ),
163 m_urlValidator( FIELD_T::USER ),
164 m_nonUrlValidator( FIELD_T::USER ),
165 m_filepathValidator( FIELD_T::SHEET_FILENAME )
166{
167 m_filesStack.push_back( aSymbol->Schematic() );
168
169 if( m_part )
170 m_filesStack.push_back( m_part );
171
172 initGrid( aGrid );
173}
174
175
177 SCH_SHEET* aSheet ) :
178 m_frame( aFrame ),
179 m_dialog( aDialog ),
180 m_parentType( SCH_SHEET_T ),
181 m_part( nullptr ),
182 m_fieldNameValidator( FIELD_T::USER ),
183 m_referenceValidator( FIELD_T::SHEET_NAME ),
184 m_valueValidator( FIELD_T::VALUE ),
185 m_urlValidator( FIELD_T::USER ),
186 m_nonUrlValidator( FIELD_T::USER ),
187 m_filepathValidator( FIELD_T::SHEET_FILENAME )
188{
189 m_filesStack.push_back( aSheet->Schematic() );
190
191 initGrid( aGrid );
192}
193
194
196 SCH_LABEL_BASE* aLabel ) :
197 m_frame( aFrame ),
198 m_dialog( aDialog ),
199 m_parentType( SCH_LABEL_LOCATE_ANY_T ),
200 m_part( nullptr ),
201 m_fieldNameValidator( FIELD_T::USER ),
202 m_referenceValidator( FIELD_T::USER ),
203 m_valueValidator( FIELD_T::USER ),
204 m_urlValidator( FIELD_T::USER ),
205 m_nonUrlValidator( FIELD_T::USER ),
206 m_filepathValidator( FIELD_T::USER )
207{
208 m_filesStack.push_back( aLabel->Schematic() );
209
210 initGrid( aGrid );
211}
212
213
215{
216 int mandatoryRows = 0;
217
218 for( const SCH_FIELD& field : *this )
219 {
220 if( field.IsMandatory() )
221 mandatoryRows++;
222 }
223
224 return mandatoryRows;
225}
226
227
229{
230 std::vector<SCH_FIELD>::push_back( aField );
231
232 m_isInherited.resize( size() );
233 m_parentFields.resize( size() );
234}
235
236
238{
239 // Build the various grid cell attributes.
240 // NOTE: validators and cellAttrs are member variables to get the destruction order
241 // right. wxGrid is VERY cranky about this.
242
243 m_readOnlyAttr = new wxGridCellAttr;
244 m_readOnlyAttr->SetReadOnly( true );
245
246 m_fieldNameAttr = new wxGridCellAttr;
248 nameEditor->SetValidator( m_fieldNameValidator );
249 m_fieldNameAttr->SetEditor( nameEditor );
250
251 m_referenceAttr = new wxGridCellAttr;
252 GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
253 referenceEditor->SetValidator( m_referenceValidator );
254 m_referenceAttr->SetEditor( referenceEditor );
255
256 m_valueAttr = new wxGridCellAttr;
257
259 {
260 GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
261 valueEditor->SetValidator( m_valueValidator );
262 m_valueAttr->SetEditor( valueEditor );
263 }
264 else
265 {
266 GRID_CELL_STC_EDITOR* valueEditor = new GRID_CELL_STC_EDITOR( true, true,
267 [this]( wxStyledTextEvent& aEvent, SCINTILLA_TRICKS* aScintillaTricks )
268 {
269 SCH_FIELD* valueField = this->GetField( FIELD_T::VALUE );
270 valueField->OnScintillaCharAdded( aScintillaTricks, aEvent );
271 } );
272
273 m_valueAttr->SetEditor( valueEditor );
274 }
275
276 m_footprintAttr = new wxGridCellAttr;
278 fpIdEditor->SetValidator( m_nonUrlValidator );
279 m_footprintAttr->SetEditor( fpIdEditor );
280
281 m_urlAttr = new wxGridCellAttr;
282 SEARCH_STACK* prjSearchStack = PROJECT_SCH::SchSearchS( &m_frame->Prj() );
283 GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( m_dialog, prjSearchStack, m_filesStack );
284 urlEditor->SetValidator( m_urlValidator );
285 m_urlAttr->SetEditor( urlEditor );
286
287 m_nonUrlAttr = new wxGridCellAttr;
288 GRID_CELL_TEXT_EDITOR* nonUrlEditor = new GRID_CELL_TEXT_EDITOR();
289 nonUrlEditor->SetValidator( m_nonUrlValidator );
290 m_nonUrlAttr->SetEditor( nonUrlEditor );
291
293 m_filepathAttr = new wxGridCellAttr;
294
295 // Create a wild card using wxFileDialog syntax.
296 wxString wildCard( _( "Schematic Files" ) );
297 std::vector<std::string> exts;
298 exts.push_back( FILEEXT::KiCadSchematicFileExtension );
299 wildCard += AddFileExtListToFilter( exts );
300
301 auto filepathEditor = new GRID_CELL_PATH_EDITOR( m_dialog, aGrid, &m_curdir, wildCard );
302 filepathEditor->SetValidator( m_filepathValidator );
303 m_filepathAttr->SetEditor( filepathEditor );
304
305 m_boolAttr = new wxGridCellAttr;
306 m_boolAttr->SetRenderer( new wxGridCellBoolRenderer() );
307 m_boolAttr->SetEditor( new wxGridCellBoolEditor() );
308 m_boolAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
309
310 wxArrayString vAlignNames;
311 vAlignNames.Add( _( "Top" ) );
312 vAlignNames.Add( _( "Center" ) );
313 vAlignNames.Add( _( "Bottom" ) );
314 m_vAlignAttr = new wxGridCellAttr;
315 m_vAlignAttr->SetEditor( new wxGridCellChoiceEditor( vAlignNames ) );
316 m_vAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
317
318 wxArrayString hAlignNames;
319 hAlignNames.Add( _( "Left" ) );
320 hAlignNames.Add(_( "Center" ) );
321 hAlignNames.Add(_( "Right" ) );
322 m_hAlignAttr = new wxGridCellAttr;
323 m_hAlignAttr->SetEditor( new wxGridCellChoiceEditor( hAlignNames ) );
324 m_hAlignAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
325
326 wxArrayString orientationNames;
327 orientationNames.Add( _( "Horizontal" ) );
328 orientationNames.Add(_( "Vertical" ) );
329 m_orientationAttr = new wxGridCellAttr;
330 m_orientationAttr->SetEditor( new wxGridCellChoiceEditor( orientationNames ) );
331 m_orientationAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
332
333 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
334 wxArrayString existingNetclasses;
335
336 wxArrayString fonts;
337 std::vector<std::string> fontNames;
338
339 if( editFrame )
340 {
341 // Load the combobox with existing existingNetclassNames
342 PROJECT_FILE& projectFile = editFrame->Prj().GetProjectFile();
343 const std::shared_ptr<NET_SETTINGS>& settings = projectFile.NetSettings();
344
345 existingNetclasses.push_back( settings->GetDefaultNetclass()->GetName() );
346
347 for( const auto& [name, netclass] : settings->GetNetclasses() )
348 existingNetclasses.push_back( name );
349
350 // We don't need to re-cache the embedded fonts when looking at symbols in the schematic
351 // editor because the fonts are all available in the schematic.
352 const std::vector<wxString>* fontFiles = nullptr;
353
356
357 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
358 fontFiles, false );
359 }
360 else
361 {
362 const std::vector<wxString>* fontFiles = m_part->GetEmbeddedFiles()->UpdateFontFiles();
363
364 // If there are font files embedded, we want to re-cache our fonts for each symbol that
365 // we are looking at in the symbol editor.
366 Fontconfig()->ListFonts( fontNames, std::string( Pgm().GetLanguageTag().utf8_str() ),
367 fontFiles, !fontFiles->empty() );
368 }
369
370 m_netclassAttr = new wxGridCellAttr;
371 m_netclassAttr->SetEditor( new GRID_CELL_COMBOBOX( existingNetclasses ) );
372
373 for( const std::string& name : fontNames )
374 fonts.Add( wxString( name ) );
375
376 fonts.Sort();
377 fonts.Insert( KICAD_FONT_NAME, 0 );
378 fonts.Insert( DEFAULT_FONT_NAME, 0 );
379
380 m_fontAttr = new wxGridCellAttr;
381 m_fontAttr->SetEditor( new GRID_CELL_COMBOBOX( fonts ) );
382
383 m_colorAttr = new wxGridCellAttr;
384 m_colorAttr->SetRenderer( new GRID_CELL_COLOR_RENDERER( m_dialog ) );
385 m_colorAttr->SetEditor( new GRID_CELL_COLOR_SELECTOR( m_dialog, aGrid ) );
386
387 m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
388
389 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
390}
391
392
394{
395 m_readOnlyAttr->DecRef();
396 m_fieldNameAttr->DecRef();
397 m_boolAttr->DecRef();
398 m_referenceAttr->DecRef();
399 m_valueAttr->DecRef();
400 m_footprintAttr->DecRef();
401 m_urlAttr->DecRef();
402 m_nonUrlAttr->DecRef();
403 m_filepathAttr->DecRef();
404 m_vAlignAttr->DecRef();
405 m_hAlignAttr->DecRef();
406 m_orientationAttr->DecRef();
407 m_netclassAttr->DecRef();
408 m_fontAttr->DecRef();
409 m_colorAttr->DecRef();
410
411 for( SCH_FIELD& field : m_parentFields )
412 field.SetParent( nullptr );
413
414 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &FIELDS_GRID_TABLE::onUnitsChanged, this );
415}
416
417
418void FIELDS_GRID_TABLE::onUnitsChanged( wxCommandEvent& aEvent )
419{
420 if( GetView() )
421 GetView()->ForceRefresh();
422
423 aEvent.Skip();
424}
425
426
428{
431 {
432 return FDC_SCH_EDIT_COUNT;
433 }
434 else
435 {
437 }
438}
439
440
442{
445 {
446 int visibleRows = 0;
447
448 for( const SCH_FIELD& field : *this )
449 {
450 if( !field.IsPrivate() )
451 visibleRows++;
452 }
453
454 return visibleRows;
455 }
456
457 return (int) this->size();
458}
459
460
462{
465 {
466 int visibleRow = 0;
467
468 for( SCH_FIELD& field : *this )
469 {
470 if( field.IsPrivate() )
471 continue;
472
473 if( visibleRow == aRow )
474 return field;
475
476 ++visibleRow;
477 }
478
479 wxFAIL_MSG( wxT( "Row index off end of visible row count" ) );
480 }
481
482 return this->at( aRow );
483}
484
485
487{
488 switch( aCol )
489 {
490 case FDC_NAME: return _( "Name" );
491 case FDC_VALUE: return _( "Value" );
492 case FDC_SHOWN: return _( "Show" );
493 case FDC_SHOW_NAME: return _( "Show Name" );
494 case FDC_H_ALIGN: return _( "H Align" );
495 case FDC_V_ALIGN: return _( "V Align" );
496 case FDC_ITALIC: return _( "Italic" );
497 case FDC_BOLD: return _( "Bold" );
498 case FDC_TEXT_SIZE: return _( "Text Size" );
499 case FDC_ORIENTATION: return _( "Orientation" );
500 case FDC_POSX: return _( "X Position" );
501 case FDC_POSY: return _( "Y Position" );
502 case FDC_FONT: return _( "Font" );
503 case FDC_COLOR: return _( "Color" );
504 case FDC_ALLOW_AUTOPLACE: return _( "Allow Autoplacement" );
505 case FDC_PRIVATE: return _( "Private" );
506 default: wxFAIL; return wxEmptyString;
507 }
508}
509
510
511bool FIELDS_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
512{
513 switch( aCol )
514 {
515 case FDC_NAME:
516 case FDC_VALUE:
517 case FDC_H_ALIGN:
518 case FDC_V_ALIGN:
519 case FDC_TEXT_SIZE:
520 case FDC_ORIENTATION:
521 case FDC_POSX:
522 case FDC_POSY:
523 case FDC_FONT:
524 case FDC_COLOR:
525 return aTypeName == wxGRID_VALUE_STRING;
526
527 case FDC_SHOWN:
528 case FDC_SHOW_NAME:
529 case FDC_ITALIC:
530 case FDC_BOLD:
532 case FDC_PRIVATE:
533 return aTypeName == wxGRID_VALUE_BOOL;
534
535 default:
536 wxFAIL;
537 return false;
538 }
539}
540
541
542bool FIELDS_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
543{
544 return CanGetValueAs( aRow, aCol, aTypeName );
545}
546
547
548wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind )
549{
550 wxCHECK( aRow < GetNumberRows(), nullptr );
551
552 const SCH_FIELD& field = getField( aRow );
553 wxGridCellAttr* attr = nullptr;
554
555 switch( aCol )
556 {
557 case FDC_NAME:
558 if( field.IsMandatory() )
559 {
560 attr = m_fieldNameAttr->Clone();
561 attr->SetReadOnly( true );
562 }
563 else
564 {
565 m_fieldNameAttr->IncRef();
566 attr = m_fieldNameAttr;
567 }
568
569 break;
570
571 case FDC_VALUE:
572 if( field.GetId() == FIELD_T::REFERENCE )
573 {
574 m_referenceAttr->IncRef();
575 attr = m_referenceAttr;
576 }
577 else if( field.GetId() == FIELD_T::VALUE )
578 {
579 m_valueAttr->IncRef();
580 attr = m_valueAttr;
581 }
582 else if( field.GetId() == FIELD_T::FOOTPRINT )
583 {
584 // Power symbols have do not appear in the board, so don't allow
585 // a footprint (m_part can be nullptr when loading a old schematic
586 // (for instance Kicad 4) with libraries missing)
587 if( m_part && m_part->IsPower() )
588 {
589 m_readOnlyAttr->IncRef();
590 attr = m_readOnlyAttr;
591 }
592 else
593 {
594 m_footprintAttr->IncRef();
595 attr = m_footprintAttr;
596 }
597 }
598 else if( field.GetId() == FIELD_T::DATASHEET )
599 {
600 m_urlAttr->IncRef();
601 attr = m_urlAttr;
602 }
603 else if( field.GetId() == FIELD_T::SHEET_NAME )
604 {
605 m_referenceAttr->IncRef();
606 attr = m_referenceAttr;
607 }
608 else if( field.GetId() == FIELD_T::SHEET_FILENAME )
609 {
610 m_filepathAttr->IncRef();
611 attr = m_filepathAttr;
612 }
614 && field.GetCanonicalName() == wxT( "Netclass" ) )
615 {
616 m_netclassAttr->IncRef();
617 attr = m_netclassAttr;
618 }
619 else
620 {
621 wxString fn = GetValue( aRow, FDC_NAME );
622
624
625 const TEMPLATE_FIELDNAME* templateFn =
626 settings ? settings->m_TemplateFieldNames.GetFieldName( fn ) : nullptr;
627
628 if( ( templateFn && templateFn->m_URL ) || field.IsHypertext() )
629 {
630 m_urlAttr->IncRef();
631 attr = m_urlAttr;
632 }
633 else
634 {
635 m_nonUrlAttr->IncRef();
636 attr = m_nonUrlAttr;
637 }
638 }
639
640 break;
641
642 case FDC_TEXT_SIZE:
643 case FDC_POSX:
644 case FDC_POSY:
645 break;
646
647 case FDC_H_ALIGN:
648 m_hAlignAttr->IncRef();
649 attr = m_hAlignAttr;
650 break;
651
652 case FDC_V_ALIGN:
653 m_vAlignAttr->IncRef();
654 attr = m_vAlignAttr;
655 break;
656
657 case FDC_ORIENTATION:
658 m_orientationAttr->IncRef();
659 attr = m_orientationAttr;
660 break;
661
662 case FDC_SHOWN:
663 case FDC_SHOW_NAME:
664 case FDC_ITALIC:
665 case FDC_BOLD:
667 case FDC_PRIVATE:
668 m_boolAttr->IncRef();
669 attr = m_boolAttr;
670 break;
671
672 case FDC_FONT:
673 m_fontAttr->IncRef();
674 attr = m_fontAttr;
675 break;
676
677 case FDC_COLOR:
678 m_colorAttr->IncRef();
679 attr = m_colorAttr;
680 break;
681
682 default:
683 attr = nullptr;
684 break;
685 }
686
687 if( !attr )
688 return nullptr;
689
690 attr = enhanceAttr( attr, aRow, aCol, aKind );
691
692 if( IsInherited( aRow ) )
693 {
694 wxGridCellAttr* text_attr = attr ? attr->Clone() : new wxGridCellAttr;
695 wxFont font;
696
697 if( !text_attr->HasFont() )
698 font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
699 else
700 font = text_attr->GetFont();
701
702 font.MakeItalic();
703 text_attr->SetFont( font );
704 text_attr->SetTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
705
706 if( attr )
707 attr->DecRef();
708
709 attr = text_attr;
710 }
711
712 return attr;
713}
714
715
716wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol )
717{
718 wxCHECK( aRow < GetNumberRows(), wxEmptyString );
719
720 wxGrid* grid = GetView();
721 const SCH_FIELD& field = getField( aRow );
722
723 if( grid->GetGridCursorRow() == aRow && grid->GetGridCursorCol() == aCol
724 && grid->IsCellEditControlShown() )
725 {
726 auto it = m_evalOriginal.find( { aRow, aCol } );
727
728 if( it != m_evalOriginal.end() )
729 return it->second;
730 }
731
732 switch( aCol )
733 {
734 case FDC_NAME:
735 // Use default field names for mandatory and system fields because they are translated
736 // according to the current locale
738 {
740 }
741 else
742 {
743 if( field.IsMandatory() )
744 return GetDefaultFieldName( field.GetId(), DO_TRANSLATE );
745 else
746 return field.GetName( false );
747 }
748
749 case FDC_VALUE:
750 return EscapeString( UnescapeString( field.GetText() ), CTX_LINE );
751
752 case FDC_SHOWN:
753 return StringFromBool( field.IsVisible() );
754
755 case FDC_SHOW_NAME:
756 return StringFromBool( field.IsNameShown() );
757
758 case FDC_H_ALIGN:
759 switch ( field.GetEffectiveHorizJustify() )
760 {
761 case GR_TEXT_H_ALIGN_LEFT: return _( "Left" );
762 case GR_TEXT_H_ALIGN_CENTER: return _( "Center" );
763 case GR_TEXT_H_ALIGN_RIGHT: return _( "Right" );
765 }
766
767 break;
768
769 case FDC_V_ALIGN:
770 switch ( field.GetEffectiveVertJustify() )
771 {
772 case GR_TEXT_V_ALIGN_TOP: return _( "Top" );
773 case GR_TEXT_V_ALIGN_CENTER: return _( "Center" );
774 case GR_TEXT_V_ALIGN_BOTTOM: return _( "Bottom" );
776 }
777
778 break;
779
780 case FDC_ITALIC:
781 return StringFromBool( field.IsItalic() );
782
783 case FDC_BOLD:
784 return StringFromBool( field.IsBold() );
785
786 case FDC_TEXT_SIZE:
787 return m_frame->StringFromValue( field.GetTextHeight(), true );
788
789 case FDC_ORIENTATION:
790 if( field.GetTextAngle().IsHorizontal() )
791 return _( "Horizontal" );
792 else
793 return _( "Vertical" );
794
795 case FDC_POSX:
796 return m_frame->StringFromValue( field.GetTextPos().x, true );
797
798 case FDC_POSY:
799 return m_frame->StringFromValue( field.GetTextPos().y, true );
800
801 case FDC_FONT:
802 if( field.GetFont() )
803 return field.GetFont()->GetName();
804 else
805 return DEFAULT_FONT_NAME;
806
807 case FDC_COLOR:
808 return field.GetTextColor().ToCSSString();
809
811 return StringFromBool( field.CanAutoplace() );
812
813 case FDC_PRIVATE:
814 return StringFromBool( field.IsPrivate() );
815
816 default:
817 // we can't assert here because wxWidgets sometimes calls this without checking
818 // the column type when trying to see if there's an overflow
819 break;
820 }
821
822 return wxT( "bad wxWidgets!" );
823}
824
825
826bool FIELDS_GRID_TABLE::GetValueAsBool( int aRow, int aCol )
827{
828 wxCHECK( aRow < GetNumberRows(), false );
829 const SCH_FIELD& field = getField( aRow );
830
831 switch( aCol )
832 {
833 case FDC_SHOWN: return field.IsVisible();
834 case FDC_SHOW_NAME: return field.IsNameShown();
835 case FDC_ITALIC: return field.IsItalic();
836 case FDC_BOLD: return field.IsBold();
837 case FDC_ALLOW_AUTOPLACE: return field.CanAutoplace();
838 case FDC_PRIVATE: return field.IsPrivate();
839 default:
840 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
841 return false;
842 }
843}
844
845
846void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
847{
848 wxCHECK( aRow < GetNumberRows(), /*void*/ );
849 SCH_FIELD& field = getField( aRow );
850 VECTOR2I pos;
851 wxString value = aValue;
852
853 switch( aCol )
854 {
855 case FDC_TEXT_SIZE:
856 case FDC_POSX:
857 case FDC_POSY:
858 m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
859
860 if( m_eval->Process( value ) )
861 {
862 m_evalOriginal[ { aRow, aCol } ] = value;
863 value = m_eval->Result();
864 }
865
866 break;
867
868 default:
869 break;
870 }
871
872 switch( aCol )
873 {
874 case FDC_NAME:
875 field.SetName( value );
876 break;
877
878 case FDC_VALUE:
879 {
880 if( m_parentType == SCH_SHEET_T && field.GetId() == FIELD_T::SHEET_FILENAME )
881 {
883 }
884 else if( m_parentType == LIB_SYMBOL_T && field.GetId() == FIELD_T::VALUE )
885 {
886 value = EscapeString( value, CTX_LIBID );
887 }
888
889 field.SetText( UnescapeString( value ) );
890 break;
891 }
892
893 case FDC_SHOWN:
894 field.SetVisible( BoolFromString( value ) );
895 break;
896
897 case FDC_SHOW_NAME:
898 field.SetNameShown( BoolFromString( value ) );
899 break;
900
901 case FDC_H_ALIGN:
902 {
903 GR_TEXT_H_ALIGN_T horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
904
905 if( value == _( "Left" ) )
906 horizontalJustification = GR_TEXT_H_ALIGN_LEFT;
907 else if( value == _( "Center" ) )
908 horizontalJustification = GR_TEXT_H_ALIGN_CENTER;
909 else if( value == _( "Right" ) )
910 horizontalJustification = GR_TEXT_H_ALIGN_RIGHT;
911
912 // Note that we must set justifications before we can ask if they're flipped. If the old
913 // justification is center then it won't know (whereas if the new justification is center
914 // the we don't care).
915 field.SetHorizJustify( horizontalJustification );
916
917 if( field.IsHorizJustifyFlipped() )
918 field.SetHorizJustify( EDA_TEXT::MapHorizJustify( - horizontalJustification ) );
919
920 break;
921 }
922
923 case FDC_V_ALIGN:
924 {
925 GR_TEXT_V_ALIGN_T verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
926
927 if( value == _( "Top" ) )
928 verticalJustification = GR_TEXT_V_ALIGN_TOP;
929 else if( value == _( "Center" ) )
930 verticalJustification = GR_TEXT_V_ALIGN_CENTER;
931 else if( value == _( "Bottom" ) )
932 verticalJustification = GR_TEXT_V_ALIGN_BOTTOM;
933
934 // Note that we must set justifications before we can ask if they're flipped. If the old
935 // justification is center then it won't know (whereas if the new justification is center
936 // the we don't care).
937 field.SetVertJustify( verticalJustification );
938
939 if( field.IsVertJustifyFlipped() )
940 field.SetVertJustify( EDA_TEXT::MapVertJustify( -verticalJustification ) );
941
942 break;
943 }
944
945 case FDC_ITALIC:
946 field.SetItalic( BoolFromString( value ) );
947 break;
948
949 case FDC_BOLD:
950 field.SetBold( BoolFromString( value ) );
951 break;
952
953 case FDC_TEXT_SIZE:
955 m_frame->ValueFromString( value ) ) );
956 break;
957
958 case FDC_ORIENTATION:
959 if( value == _( "Horizontal" ) )
961 else if( value == _( "Vertical" ) )
963 else
964 wxFAIL_MSG( wxT( "unknown orientation: " ) + value );
965
966 break;
967
968 case FDC_POSX:
969 case FDC_POSY:
970 pos = field.GetTextPos();
971
972 if( aCol == FDC_POSX )
973 pos.x = m_frame->ValueFromString( value );
974 else
975 pos.y = m_frame->ValueFromString( value );
976
977 field.SetTextPos( pos );
978 break;
979
980 case FDC_FONT:
981 if( value == DEFAULT_FONT_NAME )
982 field.SetFont( nullptr );
983 else if( value == KICAD_FONT_NAME )
984 field.SetFont( KIFONT::FONT::GetFont( wxEmptyString, field.IsBold(), field.IsItalic() ) );
985 else
986 field.SetFont( KIFONT::FONT::GetFont( aValue, field.IsBold(), field.IsItalic() ) );
987
988 break;
989
990 case FDC_COLOR:
991 field.SetTextColor( wxColor( value ) );
992 break;
993
995 field.SetCanAutoplace( BoolFromString( value ) );
996 break;
997
998 case FDC_PRIVATE:
999 field.SetPrivate( BoolFromString( value ) );
1000 break;
1001
1002 default:
1003 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
1004 break;
1005 }
1006
1007 m_dialog->OnModify();
1008
1009 GetView()->Refresh();
1010}
1011
1012
1013void FIELDS_GRID_TABLE::SetValueAsBool( int aRow, int aCol, bool aValue )
1014{
1015 wxCHECK( aRow < GetNumberRows(), /*void*/ );
1016 SCH_FIELD& field = getField( aRow );
1017
1018 switch( aCol )
1019 {
1020 case FDC_SHOWN:
1021 field.SetVisible( aValue );
1022 break;
1023
1024 case FDC_SHOW_NAME:
1025 field.SetNameShown( aValue );
1026 break;
1027
1028 case FDC_ITALIC:
1029 field.SetItalic( aValue );
1030 break;
1031
1032 case FDC_BOLD:
1033 field.SetBold( aValue );
1034 break;
1035
1037 field.SetCanAutoplace( aValue );
1038 break;
1039
1040 case FDC_PRIVATE:
1041 field.SetPrivate( aValue );
1042 break;
1043
1044 default:
1045 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
1046 break;
1047 }
1048
1049 m_dialog->OnModify();
1050}
1051
1052
1053wxString FIELDS_GRID_TABLE::StringFromBool( bool aValue ) const
1054{
1055 if( aValue )
1056 return wxT( "1" );
1057 else
1058 return wxT( "0" );
1059}
1060
1061
1062bool FIELDS_GRID_TABLE::BoolFromString( const wxString& aValue ) const
1063{
1064 if( aValue == wxS( "1" ) )
1065 {
1066 return true;
1067 }
1068 else if( aValue == wxS( "0" ) )
1069 {
1070 return false;
1071 }
1072 else
1073 {
1074 wxFAIL_MSG( wxString::Format( "string '%s' can't be converted to boolean correctly and "
1075 "will be perceived as FALSE", aValue ) );
1076 return false;
1077 }
1078}
1079
1080
1082{
1083 for( SCH_FIELD& field : *this )
1084 {
1085 if( field.GetId() == aFieldId )
1086 return &field;
1087 }
1088
1089 return nullptr;
1090}
1091
1092
1094{
1095 for( int ii = 0; ii < (int) this->size(); ++ii )
1096 {
1097 if( this->at( ii ).GetId() == aFieldId )
1098 return ii;
1099 }
1100
1101 return -1;
1102}
1103
1105{
1106 push_back( aParent );
1107 back().SetParent( m_part );
1108 m_isInherited.back() = true;
1109 m_parentFields.back() = aParent;
1110}
1111
1113{
1114 if( m_isInherited.size() > aRow )
1115 {
1116 // You can't erase inherited fields, but you can reset them to the parent value.
1117 if( m_isInherited[aRow] )
1118 {
1119 at( aRow ) = m_parentFields[aRow];
1120 return false;
1121 }
1122
1123 m_isInherited.erase( m_isInherited.begin() + aRow );
1124 }
1125
1126 if( m_parentFields.size() > aRow )
1127 m_parentFields.erase( m_parentFields.begin() + aRow );
1128
1129 std::vector<SCH_FIELD>::erase( begin() + aRow );
1130 return true;
1131}
1132
1133void FIELDS_GRID_TABLE::SwapRows( size_t a, size_t b )
1134{
1135 wxCHECK( a < this->size() && b < this->size(), /*void*/ );
1136
1137 std::swap( at( a ), at( b ) );
1138
1139 bool tmpInherited = m_isInherited[a];
1141 m_isInherited[b] = tmpInherited;
1142
1143 std::swap( m_parentFields[a], m_parentFields[b] );
1144}
1145
1146
1148{
1149 for( SCH_FIELD& field : *this )
1150 field.SetParent( nullptr );
1151
1152 for( SCH_FIELD& field : m_parentFields )
1153 field.SetParent( nullptr );
1154}
1155
1156
1158{
1159 return static_cast<FIELDS_GRID_TABLE*>( m_grid->GetTable() )->GetFieldRow( aFieldId );
1160}
1161
1162
1163void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
1164{
1165 if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::FOOTPRINT )
1166 && m_grid->GetGridCursorCol() == FDC_VALUE
1167 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE ) )
1168 {
1169 menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
1170 _( "Browse for footprint" ) );
1171 menu.AppendSeparator();
1172 }
1173 else if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::DATASHEET )
1174 && m_grid->GetGridCursorCol() == FDC_VALUE
1175 && !m_grid->IsReadOnly( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE ) )
1176 {
1177 menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
1178 _( "Show datasheet in browser" ) );
1179 menu.AppendSeparator();
1180 }
1181
1182 GRID_TRICKS::showPopupMenu( menu, aEvent );
1183}
1184
1185
1186void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
1187{
1188 if( event.GetId() == MYID_SELECT_FOOTPRINT )
1189 {
1190 // pick a footprint using the footprint picker.
1191 wxString fpid = m_grid->GetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE );
1192
1193 if( KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, m_dlg ) )
1194 {
1195 if( frame->ShowModal( &fpid, m_dlg ) )
1196 m_grid->SetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE, fpid );
1197
1198 frame->Destroy();
1199 }
1200 }
1201 else if (event.GetId() == MYID_SHOW_DATASHEET )
1202 {
1203 wxString datasheet_uri = m_grid->GetCellValue( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE );
1204
1206 m_filesStack );
1207 }
1208 else
1209 {
1211 }
1212}
1213
1214
const char * name
Definition: DXF_plotter.cpp:62
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:61
void OnModify()
bool IsHorizontal() const
Definition: eda_angle.h:142
FRAME_T GetFrameType() const
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:113
int GetTextHeight() const
Definition: eda_text.h:264
void SetTextColor(const COLOR4D &aColor)
Definition: eda_text.h:266
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:270
COLOR4D GetTextColor() const
Definition: eda_text.h:267
bool IsItalic() const
Definition: eda_text.h:166
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:533
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
virtual bool IsVisible() const
Definition: eda_text.h:184
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:578
KIFONT::FONT * GetFont() const
Definition: eda_text.h:244
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:417
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:386
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:67
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition: eda_text.cpp:335
bool IsBold() const
Definition: eda_text.h:181
static GR_TEXT_V_ALIGN_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:81
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:299
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:307
void SetFont(KIFONT::FONT *aFont)
Definition: eda_text.cpp:499
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:409
const std::vector< wxString > * UpdateFontFiles()
Helper function to get a list of fonts for fontconfig to add to the library.
const std::vector< wxString > * GetFontFiles() const
If we just need the cached version of the font files, we can use this function which is const and wil...
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
std::vector< bool > m_isInherited
bool IsInherited(size_t aRow) const
SCH_FIELD * GetField(FIELD_T aFieldId)
wxString StringFromBool(bool aValue) const
bool GetValueAsBool(int aRow, int aCol) override
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
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol, std::vector< EMBEDDED_FILES * > aFilesStack={})
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
int getVisibleRowCount() const
DIALOG_SHIM * m_dialog
wxGridCellAttr * m_footprintAttr
wxGridCellAttr * m_boolAttr
std::vector< EMBEDDED_FILES * > m_filesStack
int GetFieldRow(FIELD_T aFieldId)
bool BoolFromString(const wxString &aValue) const
wxGridCellAttr * m_fontAttr
wxGridCellAttr * m_urlAttr
wxGridCellAttr * m_valueAttr
wxGridCellAttr * m_hAlignAttr
void AddInheritedField(const SCH_FIELD &aParent)
wxGridCellAttr * m_orientationAttr
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * m_vAlignAttr
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
void SwapRows(size_t a, size_t b)
void onUnitsChanged(wxCommandEvent &aEvent)
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
std::vector< SCH_FIELD > m_parentFields
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.
Definition: grid_tricks.h:128
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:147
const wxString & GetName() const
Definition: font.h:149
wxString ToCSSString() const
Definition: color4d.cpp:147
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:395
Define a library symbol object.
Definition: lib_symbol.h:85
std::vector< SCH_PIN * > GetPins(int aUnit, int aBodyStyle) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:799
bool IsPower() const override
Definition: lib_symbol.cpp:469
wxArrayString GetFPFilters() const
Definition: lib_symbol.h:218
EMBEDDED_FILES * GetEmbeddedFiles() override
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:68
SCHEMATIC_SETTINGS * m_SchematicSettings
Definition: project_file.h:151
std::shared_ptr< NET_SETTINGS > & NetSettings()
Definition: project_file.h:99
static SEARCH_STACK * SchSearchS(PROJECT *aProject)
Accessor for Eeschema search stack.
Definition: project_sch.cpp:41
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:149
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:204
These are loaded from Eeschema settings but then overwritten by the project settings.
TEMPLATES m_TemplateFieldNames
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: schematic.cpp:927
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Schematic editor (Eeschema) main window.
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:617
bool IsMandatory() const
Definition: sch_field.cpp:1359
bool IsNameShown() const
Definition: sch_field.h:202
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.cpp:1018
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:517
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:574
FIELD_T GetId() const
Definition: sch_field.h:116
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:214
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:1117
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:560
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1103
void SetName(const wxString &aName)
Definition: sch_field.cpp:1079
bool CanAutoplace() const
Definition: sch_field.h:213
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1089
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
Definition: sch_field.cpp:688
void SetNameShown(bool aShown=true)
Definition: sch_field.h:203
void SetPrivate(bool aPrivate)
Definition: sch_item.h:253
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:246
bool IsPrivate() const
Definition: sch_item.h:254
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:216
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:105
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:47
Schematic symbol object.
Definition: sch_symbol.h:75
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:183
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
Look for files in a number of paths.
Definition: search_stack.h:43
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
EDA_UNITS GetUserUnits() const
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
int ValueFromString(const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aTextValue in aUnits to internal units used by the frame.
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition: wx_grid.cpp:45
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:429
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:408
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:407
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:62
This file is part of the common library.
#define DEFAULT_FONT_NAME
static wxString netList(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH &aSheetPath)
@ MYID_SHOW_DATASHEET
@ MYID_SELECT_FOOTPRINT
@ 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
FONTCONFIG * Fontconfig()
Definition: fontconfig.cpp:103
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_FOOTPRINT_CHOOSER
Definition: frame_type.h:44
@ GRIDTRICKS_FIRST_CLIENT_ID
Definition: grid_tricks.h:48
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.
Definition: pgm_base.cpp:902
see class PGM_BASE
Definitions of control validators for schematic dialogs.
wxString UnescapeString(const wxString &aSource)
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
Definition: string_utils.h:59
@ CTX_LIBID
Definition: string_utils.h:54
Hold a name of a symbol's field, field value, and default visibility.
Definition for symbol library class.
wxString GetDefaultFieldName(FIELD_T aFieldId, bool aTranslateForHI)
Return a default symbol field name for a mandatory field type.
#define DO_TRANSLATE
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ SHEET_FILENAME
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
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:149
@ SCH_SYMBOL_T
Definition: typeinfo.h:173
@ SCH_SHEET_T
Definition: typeinfo.h:176
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:192
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:46
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
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.