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).
327 {
328 m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
330
331 m_StyledTextCtrl->Show( false );
332 m_StyledTextCtrlBorder->Show( false );
333 }
334 else
335 {
337
338 m_TextCtrl->Show( false );
339 }
340
341 // Show the unit selector for reference fields on multi-unit schematic symbols
342 bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE
343 && m_field->GetParentSymbol()
344 && m_field->GetParentSymbol()->Type() == SCH_SYMBOL_T
345 && m_field->GetParentSymbol()->IsMultiUnit();
346
347 m_unitLabel->Show( showUnitSelector );
348 m_unitChoice->Show( showUnitSelector );
349
350 // Show the footprint selection dialog if this is the footprint field.
353
354 m_TextCtrl->Enable( true );
355
356 GetSizer()->SetSizeHints( this );
357
358 // Adjust the height of the scintilla editor after the first layout to show a single line
359 // (multiline text is not supported in fields and will be removed)
360 if( m_StyledTextCtrl->IsShown() )
361 {
362 wxSize maxSize;
363 maxSize.x = -1; // Do not fix the max width
364 maxSize.y = m_StyledTextCtrl->TextHeight( 0 );
365 m_StyledTextCtrl->SetMaxSize( maxSize );
366 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
367 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
368 }
369
371
372 // Now all widgets have the size fixed, call FinishDialogSettings
374}
375
376
378{
379 // pick a footprint using the footprint picker.
380 wxString fpid;
381
382 if( m_StyledTextCtrl->IsShown() )
383 fpid = m_StyledTextCtrl->GetValue();
384 else
385 fpid = m_TextCtrl->GetValue();
386
387 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, this ) )
388 {
390 frame->KiwayMailIn( event );
391
392 if( frame->ShowModal( &fpid, this ) )
393 {
394 if( m_StyledTextCtrl->IsShown() )
395 m_StyledTextCtrl->SetValue( fpid );
396 else
397 m_TextCtrl->SetValue( fpid );
398 }
399
400 frame->Destroy();
401 }
402}
403
404
406{
407 if( m_firstFocus )
408 {
409#ifdef __WXGTK__
410 // Force an update of the text control before setting the text selection
411 // This is needed because GTK seems to ignore the selection on first update
412 //
413 // Note that we can't do this on OSX as it tends to provoke Apple's
414 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
415 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
417 m_TextCtrl->Update();
418#endif
419
421 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
423 m_TextCtrl->SetSelection( -1, -1 );
424
425 m_firstFocus = false;
426 }
427
428 event.Skip();
429}
430
431
432void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
433{
434 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
435 {
436 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
437 btn->Check( false );
438 }
439}
440
441
442void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
443{
445 {
446 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
447 btn->Check( false );
448 }
449}
450
451
452void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
453{
455 {
456 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
457 btn->Check( false );
458 }
459}
460
461
463{
464 if( m_TextCtrl->IsShown() )
465 {
466 m_TextCtrl->SetValue( EscapeString( m_text, CTX_LINE ) );
467 }
468 else if( m_StyledTextCtrl->IsShown() )
469 {
471 m_StyledTextCtrl->EmptyUndoBuffer();
472 }
473
474 if( m_unitChoice->IsShown() )
475 {
476 const SYMBOL* parent = m_field->GetParentSymbol();
477
478 // Control shouldn't be shown for non-schematic symbols
479 wxCHECK( parent->Type() == SCH_SYMBOL_T, true );
480
481 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( parent );
482
483 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
484 m_unitChoice->Append( symbol->GetUnitDisplayName( ii, false ) );
485
486 if( symbol->GetUnit() <= (int) m_unitChoice->GetCount() )
487 m_unitChoice->SetSelection( symbol->GetUnit() - 1 );
488 }
489
490 m_fontCtrl->SetFontSelection( m_font );
491
492 m_posX.SetValue( m_position.x );
493 m_posY.SetValue( m_position.y );
494 m_textSize.SetValue( m_size );
495
496 m_horizontal->Check( !m_isVertical );
497 m_vertical->Check( m_isVertical );
498
499 m_italic->Check( m_isItalic );
500 m_bold->Check( m_isBold );
501
502 m_textColorSwatch->SetSwatchColor( m_color, false );
503
505 {
506 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
507 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
508 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
510 }
511
512 switch ( m_verticalJustification )
513 {
514 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
515 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
516 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
518 }
519
520 m_visible->SetValue( m_isVisible );
521 m_nameVisible->SetValue( m_isNameVisible );
523
524 return true;
525}
526
527
529{
530 if( m_TextCtrl->IsShown() )
531 m_text = UnescapeString( m_TextCtrl->GetValue() );
532 else if( m_StyledTextCtrl->IsShown() )
533 m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
534
537
538 m_position = VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() );
539 m_size = m_textSize.GetIntValue();
540
541 if( m_fontCtrl->HaveFontSelection() )
542 m_font = m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() );
543
544 m_isVertical = m_vertical->IsChecked();
545
546 m_isBold = m_bold->IsChecked();
547 m_isItalic = m_italic->IsChecked();
548 m_color = m_textColorSwatch->GetSwatchColor();
549
550 if( m_hAlignLeft->IsChecked() )
552 else if( m_hAlignCenter->IsChecked() )
554 else
556
557 if( m_vAlignTop->IsChecked() )
559 else if( m_vAlignCenter->IsChecked() )
561 else
563
564 m_isVisible = m_visible->GetValue();
565 m_isNameVisible = m_nameVisible->GetValue();
567
568 return true;
569}
570
571
573{
574 if( aField->GetTextWidth() != m_size )
575 aField->SetTextSize( VECTOR2I( m_size, m_size ) );
576
577 aField->SetFont( m_font );
578 aField->SetVisible( m_isVisible );
580 aField->SetItalic( m_isItalic );
581 aField->SetBold( m_isBold );
582 aField->SetTextColor( m_color );
583}
584
585
587{
588 if( aField->Schematic() )
589 {
590 const SCH_SHEET_PATH& sheetPath = aField->Schematic()->CurrentSheet();
591 wxString variant = aField->Schematic()->GetCurrentVariant();
592
593 aField->SetText( m_text, &sheetPath, variant );
594 }
595 else
596 {
597 aField->SetText( m_text );
598 }
599
600 updateText( aField );
601
602 aField->SetNameShown( m_isNameVisible );
604
607 aField->SetTextPos( m_position );
608}
609
610
611void DIALOG_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
612{
613 m_field->OnScintillaCharAdded( m_scintillaTricks, aEvent );
614}
615
616
618 SCH_SHEET_PATH* aSheetPath )
619{
620 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
621 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
622 bool fieldTextSet = false;
623 SCH_SHEET_PATH sheetPath;
624 wxString variantName;
625
626 // convert any text variable cross-references to their UUIDs
628
629 if( aField->GetId() != FIELD_T::SHEET_FILENAME )
630 {
631 SCH_BASE_FRAME* parentFrame = GetParent();
632
633 if( parentFrame )
634 m_text = ConvertPathToFileUri( m_text, &parentFrame->Prj() );
635 }
636
637 if( aField->Schematic() )
638 {
639 sheetPath = aField->Schematic()->CurrentSheet();
640 variantName = aField->Schematic()->GetCurrentVariant();
641 }
642
643 if( parent && parent->Type() == SCH_SYMBOL_T )
644 {
645 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
646
648 symbol->SetRef( aSheetPath, m_text );
649 else
650 symbol->SetFieldText( aField->GetName(), m_text, &sheetPath, variantName );
651
652 fieldTextSet = true;
653
654 // Set the unit selection in multiple units per package
655 if( m_unitChoice->IsShown() )
656 {
657 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
658 symbol->SetUnitSelection( aSheetPath, unit_selection );
659 symbol->SetUnit( unit_selection );
660 }
661 }
662 else if( parent && parent->Type() == SCH_SHEET_T )
663 {
664 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( parent );
665
666 if( !aField->IsMandatory() )
667 {
668 sheet->SetFieldText( aField->GetName(), m_text, &sheetPath, variantName );
669 fieldTextSet = true;
670 }
671 }
672 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
673 {
675 {
676 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
677 {
678 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
679 "controlled globally from "
680 "Schematic Setup > General > Formatting" ) );
681 }
682 }
683 }
684
685 bool positioningModified = false;
686
687 if( aField->GetPosition() != m_position )
688 positioningModified = true;
689
690 if( aField->GetTextAngle().IsVertical() != m_isVertical )
691 positioningModified = true;
692
694 positioningModified = true;
695
697 positioningModified = true;
698
699 // Changing a sheetname need to update the hierarchy navigator
700 bool needUpdateHierNav = false;
701
703 needUpdateHierNav = m_text != aField->GetText();
704
705 if( !fieldTextSet )
706 aField->SetText( m_text );
707
708 updateText( aField );
709 aField->SetPosition( m_position );
710
711 aField->SetNameShown( m_isNameVisible );
713
714 // Note that we must set justifications before we can ask if they're flipped. If the old
715 // justification is center then it won't know (whereas if the new justification is center
716 // the we don't care).
719
720 if( aField->IsHorizJustifyFlipped() )
722
723 if( aField->IsVertJustifyFlipped() )
725
726 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
727 // Of course the symbol must be annotated to collect other units.
728 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
729 {
730 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
731
732 if( symbol->IsAnnotated( aSheetPath ) && ( m_fieldId == FIELD_T::VALUE
735 {
736 wxString ref = symbol->GetRef( aSheetPath );
737 int unit = symbol->GetUnit();
738 LIB_ID libId = symbol->GetLibId();
739
740 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().Hierarchy() )
741 {
742 SCH_SCREEN* screen = sheet.LastScreen();
743 std::vector<SCH_SYMBOL*> otherUnits;
744
745 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
746
747 for( SCH_SYMBOL* otherUnit : otherUnits )
748 {
749 aCommit->Modify( otherUnit, screen );
750 otherUnit->GetField( m_fieldId )->SetText( m_text );
751 editFrame->UpdateItem( otherUnit, false, true );
752 }
753 }
754 }
755 }
756
757 if( positioningModified && parent )
759
760 // Update the hierarchy navigator labels if needed.
761 if( editFrame && needUpdateHierNav )
763}
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:398
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:79
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:148
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM * GetParent() const
Definition eda_item.h:110
void SetTextColor(const COLOR4D &aColor)
Definition eda_text.h:290
COLOR4D GetTextColor() const
Definition eda_text.h:291
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:294
bool IsItalic() const
Definition eda_text.h:190
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:532
virtual bool IsVisible() const
Definition eda_text.h:208
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:576
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:412
virtual int GetTextWidth() const
Definition eda_text.h:285
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:221
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:381
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition eda_text.cpp:70
virtual EDA_ANGLE GetTextAngle() const
Definition eda_text.h:168
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition eda_text.cpp:330
bool IsBold() const
Definition eda_text.h:205
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:224
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:294
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:302
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:495
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:404
A text control validator used for validating the text allowed in fields.
Definition validators.h:138
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:79
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
wxArrayString GetFPFilters() const
Definition lib_symbol.h:207
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:189
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.
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:128
FIELD_T GetId() const
Definition sch_field.h:132
void SetCanAutoplace(bool aCanPlace)
Definition sch_field.h:230
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:219
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:274
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:268
int GetUnit() const
Definition sch_item.h:233
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:624
virtual void SetUnit(int aUnit)
Definition sch_item.h:232
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:44
void SetFieldText(const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString)
Schematic symbol object.
Definition sch_symbol.h:69
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the display name for a given unit aUnit.
void SetFieldText(const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString)
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
const LIB_ID & GetLibId() const override
Definition sch_symbol.h:158
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:177
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:59
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:775
The common library.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
This file is part of the common library.
#define _(s)
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:408
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:407
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:40
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:486
@ MAIL_SYMBOL_NETLIST
Definition mail_type.h:42
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:66
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".
@ 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:145
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_SHEET_T
Definition typeinfo.h:172
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:165
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
Definition of file extensions used in Kicad.