KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_field_properties.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) 2012 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2016 Wayne Stambaugh, [email protected]
6 * Copyright The KiCad Developers, see AITHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
24#include <widgets/font_choice.h>
27#include <bitmaps.h>
28#include <kiway.h>
29#include <kiway_mail.h>
30#include <confirm.h>
31#include <common.h>
32#include <string_utils.h>
33#include <sch_edit_frame.h>
34#include <sch_collectors.h>
35#include <sch_symbol.h>
36#include <template_fieldnames.h>
37#include <sch_validators.h>
38#include <schematic.h>
39#include <sch_commit.h>
41#include <sch_text.h>
42#include <scintilla_tricks.h>
44
45
47 const SCH_FIELD* aField ) :
48 DIALOG_FIELD_PROPERTIES_BASE( aParent, wxID_ANY, aTitle ),
49 m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
50 m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
52 m_font( nullptr ),
53 m_firstFocus( true ),
54 m_scintillaTricks( nullptr ),
55 m_field( aField )
56{
57 COLOR_SETTINGS* colorSettings = aParent->GetColorSettings();
58 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
59
60 wxASSERT( m_field );
61
62 m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
63 m_note->Show( false );
64
65 m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), true,
66 // onAcceptFn
67 [this]( wxKeyEvent& aEvent )
68 {
69 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
70 } );
71
72 m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
73
74#ifdef __WXGTK__
75 m_StyledTextCtrl->SetExtraAscent( 6 );
76 m_StyledTextCtrl->SetExtraDescent( 6 );
77#elif defined ( __WXMSW__ )
78 // Do nothing: SetExtraAscent() + SetExtraDescent(), when set to a value not 0
79 // Generate a strange bug: the text is not always shown (Perhaps a wxMSW bug)
80 // and this call is not needed on WXMSW
81#else
82 m_StyledTextCtrl->SetExtraAscent( 1 );
83 m_StyledTextCtrl->SetExtraDescent( 2 );
84#endif
85
86#ifdef _WIN32
87 // Without this setting, on Windows, some esoteric unicode chars create display issue
88 // in a wxStyledTextCtrl.
89 // for SetTechnology() info, see https://www.scintilla.org/ScintillaDoc.html#SCI_SETTECHNOLOGY
90 m_StyledTextCtrl->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE);
91#endif
92
93 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
94 m_textColorSwatch->SetSwatchBackground( schematicBackground );
95
96 m_separator1->SetIsSeparator();
97
98 m_horizontal->SetIsRadioButton();
100 m_vertical->SetIsRadioButton();
102
103 m_separator2->SetIsSeparator();
104
105 m_bold->SetIsCheckButton();
107 m_italic->SetIsCheckButton();
109
110 m_separator3->SetIsSeparator();
111
112 m_hAlignLeft->SetIsRadioButton();
114 m_hAlignCenter->SetIsRadioButton();
116 m_hAlignRight->SetIsRadioButton();
118
119 m_separator4->SetIsSeparator();
120
121 m_vAlignTop->SetIsRadioButton();
123 m_vAlignCenter->SetIsRadioButton();
125 m_vAlignBottom->SetIsRadioButton();
127
128 m_separator5->SetIsSeparator();
129
130 m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
131 m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
132
133 m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
134 m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
135 m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
136
137 m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
138 m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
139 m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
140
141 // show text variable cross-references in a human-readable format
142 if( aField->Schematic() )
143 {
144 const SCH_SHEET_PATH& sheetPath = aField->Schematic()->CurrentSheet();
145 wxString variant = aField->Schematic()->GetCurrentVariant();
146
147 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText( &sheetPath, variant ) );
148 }
149 else
150 {
151 m_text = aField->GetText();
152 }
153
154 m_font = m_field->GetFont();
155 m_isItalic = aField->IsItalic();
156 m_isBold = aField->IsBold();
157 m_color = aField->GetTextColor();
158 m_position = aField->GetTextPos();
159 m_size = aField->GetTextWidth();
163 m_isVisible = aField->IsVisible();
164
165 m_isSheetFilename = false;
166 m_fieldId = aField->GetId();
167
168 if( aField->GetParent() && aField->GetParent()->Type() == LIB_SYMBOL_T )
169 {
170 const LIB_SYMBOL* symbol = static_cast<const LIB_SYMBOL*>( aField->GetParentSymbol() );
171
172 /*
173 * Symbol netlist format:
174 * pinNumber pinName <tab> pinNumber pinName...
175 * fpFilter fpFilter...
176 */
177 wxString netlist;
178 wxArrayString pins;
179
180 for( const SCH_PIN* pin : symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
181 {
182 bool valid = false;
183 auto expanded = pin->GetStackedPinNumbers( &valid );
184
185 if( valid && !expanded.empty() )
186 {
187 for( const wxString& num : expanded )
188 pins.push_back( num + ' ' + pin->GetShownName() );
189 }
190 else
191 {
192 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
193 }
194 }
195
196 if( !pins.IsEmpty() )
197 {
198 wxString dbg = wxJoin( pins, '\t' );
199 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (LIB_SYMBOL): %s" ), dbg );
200 netlist << EscapeString( dbg, CTX_LINE );
201 }
202
203 netlist << wxS( "\r" );
204
205 wxArrayString fpFilters = symbol->GetFPFilters();
206
207 if( !fpFilters.IsEmpty() )
208 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
209
210 netlist << wxS( "\r" );
211
213 }
214 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
215 {
216 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aField->GetParentSymbol() );
217 SCH_SHEET_PATH sheetPath = static_cast<SCH_EDIT_FRAME*>( aParent )->GetCurrentSheet();
218
219 /*
220 * Symbol netlist format:
221 * pinNumber pinName <tab> pinNumber pinName...
222 * fpFilter fpFilter...
223 */
224 wxString netlist;
225
226 // We need the list of pins of the lib symbol, not just the pins of the current
227 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
228 // select/filter right footprints
229 wxArrayString pins;
230
231 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = symbol->GetLibSymbolRef();
232
233 if( lib_symbol )
234 {
235 for( SCH_PIN* pin : lib_symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
236 {
237 bool valid = false;
238 auto expanded = pin->GetStackedPinNumbers( &valid );
239 if( valid && !expanded.empty() )
240 {
241 for( const wxString& num : expanded )
242 pins.push_back( num + ' ' + pin->GetShownName() );
243 }
244 else
245 {
246 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
247 }
248 }
249 }
250
251 if( !pins.IsEmpty() )
252 {
253 wxString dbg = wxJoin( pins, '\t' );
254 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (SCH_SYMBOL): %s" ), dbg );
255 netlist << EscapeString( dbg, CTX_LINE );
256 }
257
258 netlist << wxS( "\r" );
259
260 wxArrayString fpFilters;
261
262 if( symbol->GetLibSymbolRef() ) // can be null with very old schematic
263 fpFilters = symbol->GetLibSymbolRef()->GetFPFilters();
264
265 if( !fpFilters.IsEmpty() )
266 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
267
268 netlist << wxS( "\r" );
269
271 }
272
273 if( aField->GetId() == FIELD_T::SHEET_FILENAME )
274 {
275 m_isSheetFilename = true;
276 m_note->Show( true );
277 }
278
279 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
280
281 m_position = m_field->GetPosition();
282
283 m_isNameVisible = m_field->IsNameShown();
284 m_allowAutoplace = m_field->CanAutoplace();
285
286 m_horizontalJustification = m_field->GetEffectiveHorizJustify();
287 m_verticalJustification = m_field->GetEffectiveVertJustify();
288
289 m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
291 m_StyledTextCtrl->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED,
293
294 m_nameVisible->Show();
295 m_cbAllowAutoPlace->Show();
296
297 init();
298
299 if( m_isSheetFilename || m_field->IsGeneratedField() )
300 {
301 m_StyledTextCtrl->Enable( false );
302 m_TextCtrl->Enable( false );
303 }
304}
305
306
312
313
315{
316 // Disable options for graphic text editing which are not needed for fields.
317 m_commonToAllBodyStyles->Show( false );
318 m_commonToAllUnits->Show( false );
319
320 // Predefined fields cannot contain some chars and cannot be empty, so they need a
321 // SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
328 {
329 m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
331
332 m_StyledTextCtrl->Show( false );
333 m_StyledTextCtrlBorder->Show( false );
334 }
335 else
336 {
338
339 m_TextCtrl->Show( false );
340 }
341
342 // Show the unit selector for reference fields on multi-unit schematic symbols
343 bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE
344 && m_field->GetParentSymbol()
345 && m_field->GetParentSymbol()->Type() == SCH_SYMBOL_T
346 && m_field->GetParentSymbol()->IsMultiUnit();
347
348 m_unitLabel->Show( showUnitSelector );
349 m_unitChoice->Show( showUnitSelector );
350
351 // Show the footprint selection dialog if this is the footprint field.
354
355 m_TextCtrl->Enable( true );
356
357 GetSizer()->SetSizeHints( this );
358
359 // Adjust the height of the scintilla editor after the first layout to show a single line
360 // (multiline text is not supported in fields and will be removed)
361 if( m_StyledTextCtrl->IsShown() )
362 {
363 wxSize maxSize;
364 maxSize.x = -1; // Do not fix the max width
365 maxSize.y = m_StyledTextCtrl->TextHeight( 0 );
366 m_StyledTextCtrl->SetMaxSize( maxSize );
367 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
368 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
369 }
370
372
373 // Now all widgets have the size fixed, call FinishDialogSettings
375}
376
377
379{
380 // pick a footprint using the footprint picker.
381 wxString fpid;
382
383 if( m_StyledTextCtrl->IsShown() )
384 fpid = m_StyledTextCtrl->GetValue();
385 else
386 fpid = m_TextCtrl->GetValue();
387
388 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, this ) )
389 {
391 frame->KiwayMailIn( event );
392
393 if( frame->ShowModal( &fpid, this ) )
394 {
395 if( m_StyledTextCtrl->IsShown() )
396 m_StyledTextCtrl->SetValue( fpid );
397 else
398 m_TextCtrl->SetValue( fpid );
399 }
400
401 frame->Destroy();
402 }
403}
404
405
407{
408 if( m_firstFocus )
409 {
410#ifdef __WXGTK__
411 // Force an update of the text control before setting the text selection
412 // This is needed because GTK seems to ignore the selection on first update
413 //
414 // Note that we can't do this on OSX as it tends to provoke Apple's
415 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
416 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
418 m_TextCtrl->Update();
419#endif
420
422 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
424 m_TextCtrl->SetSelection( -1, -1 );
425
426 m_firstFocus = false;
427 }
428
429 event.Skip();
430}
431
432
433void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
434{
435 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
436 {
437 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
438 btn->Check( false );
439 }
440}
441
442
443void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
444{
446 {
447 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
448 btn->Check( false );
449 }
450}
451
452
453void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
454{
456 {
457 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
458 btn->Check( false );
459 }
460}
461
462
464{
465 if( m_TextCtrl->IsShown() )
466 {
467 m_TextCtrl->SetValue( EscapeString( m_text, CTX_LINE ) );
468 }
469 else if( m_StyledTextCtrl->IsShown() )
470 {
472 m_StyledTextCtrl->EmptyUndoBuffer();
473 }
474
475 if( m_unitChoice->IsShown() )
476 {
477 const SYMBOL* parent = m_field->GetParentSymbol();
478
479 // Control shouldn't be shown for non-schematic symbols
480 wxCHECK( parent->Type() == SCH_SYMBOL_T, true );
481
482 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( parent );
483
484 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
485 m_unitChoice->Append( symbol->GetUnitDisplayName( ii, false ) );
486
487 if( symbol->GetUnit() <= (int) m_unitChoice->GetCount() )
488 m_unitChoice->SetSelection( symbol->GetUnit() - 1 );
489 }
490
491 m_fontCtrl->SetFontSelection( m_font );
492
493 m_posX.SetValue( m_position.x );
494 m_posY.SetValue( m_position.y );
495 m_textSize.SetValue( m_size );
496
497 m_horizontal->Check( !m_isVertical );
498 m_vertical->Check( m_isVertical );
499
500 m_italic->Check( m_isItalic );
501 m_bold->Check( m_isBold );
502
503 m_textColorSwatch->SetSwatchColor( m_color, false );
504
506 {
507 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
508 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
509 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
511 }
512
513 switch ( m_verticalJustification )
514 {
515 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
516 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
517 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
519 }
520
521 m_visible->SetValue( m_isVisible );
522 m_nameVisible->SetValue( m_isNameVisible );
524
525 return true;
526}
527
528
530{
531 if( m_TextCtrl->IsShown() )
532 m_text = UnescapeString( m_TextCtrl->GetValue() );
533 else if( m_StyledTextCtrl->IsShown() )
534 m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
535
538
539 m_position = VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() );
540 m_size = m_textSize.GetIntValue();
541
542 if( m_fontCtrl->HaveFontSelection() )
543 m_font = m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() );
544
545 m_isVertical = m_vertical->IsChecked();
546
547 m_isBold = m_bold->IsChecked();
548 m_isItalic = m_italic->IsChecked();
549 m_color = m_textColorSwatch->GetSwatchColor();
550
551 if( m_hAlignLeft->IsChecked() )
553 else if( m_hAlignCenter->IsChecked() )
555 else
557
558 if( m_vAlignTop->IsChecked() )
560 else if( m_vAlignCenter->IsChecked() )
562 else
564
565 m_isVisible = m_visible->GetValue();
566 m_isNameVisible = m_nameVisible->GetValue();
568
569 const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( m_field->GetParentSymbol() );
570
571 if( m_fieldId == FIELD_T::REFERENCE && symbol && symbol->Schematic() )
572 {
573 wxString base;
574 wxString msg = symbol->BaseRefFromUser( symbol->Schematic()->CurrentSheet(), m_text, base );
575
576 if( !msg.IsEmpty() )
577 {
578 DisplayError( this, msg );
579 return false;
580 }
581
582 m_text = base;
583 }
584
585 return true;
586}
587
588
590{
591 if( aField->GetTextWidth() != m_size )
592 aField->SetTextSize( VECTOR2I( m_size, m_size ) );
593
594 aField->SetFont( m_font );
595 aField->SetVisible( m_isVisible );
597 aField->SetItalic( m_isItalic );
598 aField->SetBold( m_isBold );
599 aField->SetTextColor( m_color );
600}
601
602
604{
605 if( aField->Schematic() )
606 {
607 const SCH_SHEET_PATH& sheetPath = aField->Schematic()->CurrentSheet();
608 wxString variant = aField->Schematic()->GetCurrentVariant();
609
610 aField->SetText( m_text, &sheetPath, variant );
611 }
612 else
613 {
614 aField->SetText( m_text );
615 }
616
617 updateText( aField );
618
619 aField->SetNameShown( m_isNameVisible );
621
624 aField->SetTextPos( m_position );
625}
626
627
628void DIALOG_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
629{
630 m_field->OnScintillaCharAdded( m_scintillaTricks, aEvent );
631}
632
633
635 SCH_SHEET_PATH* aSheetPath )
636{
637 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
638 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
639 bool fieldTextSet = false;
640 SCH_SHEET_PATH sheetPath;
641 wxString variantName;
642
643 // convert any text variable cross-references to their UUIDs
645
646 if( aField->GetId() != FIELD_T::SHEET_FILENAME )
647 {
648 SCH_BASE_FRAME* parentFrame = GetParent();
649
650 if( parentFrame )
651 m_text = ConvertPathToFileUri( m_text, &parentFrame->Prj() );
652 }
653
654 if( aField->Schematic() )
655 {
656 sheetPath = aField->Schematic()->CurrentSheet();
657 variantName = aField->Schematic()->GetCurrentVariant();
658 }
659
660 if( parent && parent->Type() == SCH_SYMBOL_T )
661 {
662 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
663
665 symbol->SetUserRef( *aSheetPath, m_text );
666 else
667 symbol->SetFieldText( aField->GetName(), m_text, &sheetPath, variantName );
668
669 fieldTextSet = true;
670
671 // Set the unit selection in multiple units per package
672 if( m_unitChoice->IsShown() )
673 {
674 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
675 symbol->SetUnitSelection( aSheetPath, unit_selection );
676 symbol->SetUnit( unit_selection );
677 }
678 }
679 else if( parent && parent->Type() == SCH_SHEET_T )
680 {
681 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( parent );
682
683 if( !aField->IsMandatory() )
684 {
685 sheet->SetFieldText( aField->GetName(), m_text, &sheetPath, variantName );
686 fieldTextSet = true;
687 }
688 }
689 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
690 {
692 {
693 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
694 {
695 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
696 "controlled globally from "
697 "Schematic Setup > General > Formatting" ) );
698 }
699 }
700 }
701
702 bool positioningModified = false;
703
704 if( aField->GetPosition() != m_position )
705 positioningModified = true;
706
707 if( aField->GetTextAngle().IsVertical() != m_isVertical )
708 positioningModified = true;
709
711 positioningModified = true;
712
714 positioningModified = true;
715
716 // Changing a sheetname need to update the hierarchy navigator
717 bool needUpdateHierNav = false;
718
720 needUpdateHierNav = m_text != aField->GetText();
721
722 if( !fieldTextSet )
723 aField->SetText( m_text );
724
725 updateText( aField );
726 aField->SetPosition( m_position );
727
728 aField->SetNameShown( m_isNameVisible );
730
731 // Note that we must set justifications before we can ask if they're flipped. If the old
732 // justification is center then it won't know (whereas if the new justification is center
733 // the we don't care).
736
737 if( aField->IsHorizJustifyFlipped() )
739
740 if( aField->IsVertJustifyFlipped() )
742
743 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
744 // Of course the symbol must be annotated to collect other units.
745 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
746 {
747 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
748
749 if( symbol->IsAnnotated( aSheetPath ) && ( m_fieldId == FIELD_T::VALUE
752 {
753 wxString ref = symbol->GetRef( aSheetPath );
754 int unit = symbol->GetUnit();
755 LIB_ID libId = symbol->GetLibId();
756
757 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().Hierarchy() )
758 {
759 SCH_SCREEN* screen = sheet.LastScreen();
760 std::vector<SCH_SYMBOL*> otherUnits;
761
762 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
763
764 for( SCH_SYMBOL* otherUnit : otherUnits )
765 {
766 aCommit->Modify( otherUnit, screen );
767 otherUnit->GetField( m_fieldId )->SetText( m_text, &sheet, variantName );
768 editFrame->UpdateItem( otherUnit, false, true );
769 }
770 }
771 }
772 }
773
774 if( positioningModified && parent )
776
777 // Update the hierarchy navigator labels if needed.
778 if( editFrame && needUpdateHierNav )
780}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
@ text_align_right
@ text_valign_top
@ text_align_left
@ text_valign_center
@ text_align_center
@ text_horizontal
@ text_valign_bottom
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
DIALOG_FIELD_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Text Item Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void onOrientButton(wxCommandEvent &aEvent)
void OnTextValueSelectButtonClick(wxCommandEvent &aEvent) override
Handle the select button next to the text value field.
DIALOG_FIELD_PROPERTIES(SCH_BASE_FRAME *aParent, const wxString &aTitle, const SCH_FIELD *aField)
GR_TEXT_H_ALIGN_T m_horizontalJustification
void updateText(SCH_FIELD *aField)
void onVAlignButton(wxCommandEvent &aEvent)
void UpdateField(SCH_FIELD *aField)
void onScintillaCharAdded(wxStyledTextEvent &aEvent)
void OnSetFocusText(wxFocusEvent &event) override
Used to select the variant part of some text fields (for instance, the question mark or number in a r...
void onHAlignButton(wxCommandEvent &aEvent)
GR_TEXT_V_ALIGN_T m_verticalJustification
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition dialog_shim.h:95
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool IsVertical() const
Definition eda_angle.h:147
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM * GetParent() const
Definition eda_item.h:112
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
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:379
virtual int GetTextWidth() const
Definition eda_text.h:304
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:239
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
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition eda_text.h:242
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
A text control validator used for validating the text allowed in fields.
Definition validators.h:137
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
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.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition kiway_mail.h:34
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
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.
SCHEMATIC_SETTINGS & Settings() const
wxString ConvertKIIDsToRefs(const wxString &aSource) const
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
wxString ConvertRefsToKIIDs(const wxString &aSource) const
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:399
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
Schematic editor (Eeschema) main window.
SCHEMATIC & Schematic() const
void UpdateLabelsHierarchyNavigator()
Update the hierarchy navigation tree labels.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
bool IsMandatory() const
VECTOR2I GetPosition() const override
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
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 SetText(const wxString &aText) override
void SetNameShown(bool aShown=true)
Definition sch_field.h:226
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:350
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:302
int GetUnit() const
Definition sch_item.h:243
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:679
virtual void SetUnit(int aUnit)
Definition sch_item.h:242
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:50
void SetFieldText(SCH_FIELD *aField, const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath, const wxString &aVariantName)
Schematic symbol object.
Definition sch_symbol.h:76
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the display name for a given unit aUnit.
void SetFieldText(SCH_FIELD *aField, const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath, const wxString &aVariantName)
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
wxString BaseRefFromUser(const SCH_SHEET_PATH &aSheet, const wxString &aText, wxString &aBase, const SCHEMATIC *aSchematic=nullptr) const
Convert a reference typed on aSheet to the base reference.
const LIB_ID & GetLibId() const override
Definition sch_symbol.h:166
void SetUserRef(const SCH_SHEET_PATH &aSheet, const wxString &aBase)
Set a base reference chosen by the user on aSheet.
int GetUnitCount() const override
Return the number of units per package of the symbol.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:185
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:60
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
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
This file is part of the common library.
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:469
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:468
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:40
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:519
@ MAIL_SYMBOL_NETLIST
Definition mail_type.h:41
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
@ AUTOPLACE_NONE
Definition sch_item.h:74
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
@ INTERSHEET_REFS
Global label cross-reference page numbers.
@ 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".
std::string netlist
KIBIS_PIN * pin
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ 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_GLOBAL_LABEL_T
Definition typeinfo.h:164
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
Definition of file extensions used in Kicad.