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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
28#include <widgets/font_choice.h>
31#include <bitmaps.h>
32#include <kiway.h>
33#include <kiway_express.h>
34#include <confirm.h>
35#include <common.h>
36#include <string_utils.h>
37#include <sch_edit_frame.h>
38#include <sch_collectors.h>
39#include <sch_symbol.h>
40#include <template_fieldnames.h>
41#include <sch_validators.h>
42#include <schematic.h>
43#include <sch_commit.h>
45#include <sch_text.h>
46#include <scintilla_tricks.h>
48
49
51 const SCH_FIELD* aField ) :
52 DIALOG_FIELD_PROPERTIES_BASE( aParent, wxID_ANY, aTitle ),
53 m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
54 m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
56 m_font( nullptr ),
57 m_firstFocus( true ),
58 m_scintillaTricks( nullptr ),
59 m_field( aField )
60{
61 COLOR_SETTINGS* colorSettings = aParent->GetColorSettings();
62 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
63
64 wxASSERT( m_field );
65
66 m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
67 m_note->Show( false );
68
69 m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), true,
70 // onAcceptFn
71 [this]( wxKeyEvent& aEvent )
72 {
73 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
74 } );
75
76 m_StyledTextCtrl->SetEOLMode( wxSTC_EOL_LF ); // Normalize EOL across platforms
77
78#ifdef __WXGTK__
79 m_StyledTextCtrl->SetExtraAscent( 6 );
80 m_StyledTextCtrl->SetExtraDescent( 6 );
81#elif defined ( __WXMSW__ )
82 // Do nothing: SetExtraAscent() + SetExtraDescent(), when set to a value not 0
83 // Generate a strange bug: the text is not always shown (Perhaps a wxMSW bug)
84 // and this call is not needed on WXMSW
85#else
86 m_StyledTextCtrl->SetExtraAscent( 1 );
87 m_StyledTextCtrl->SetExtraDescent( 2 );
88#endif
89
90#ifdef _WIN32
91 // Without this setting, on Windows, some esoteric unicode chars create display issue
92 // in a wxStyledTextCtrl.
93 // for SetTechnology() info, see https://www.scintilla.org/ScintillaDoc.html#SCI_SETTECHNOLOGY
94 m_StyledTextCtrl->SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE);
95#endif
96
97 m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
98 m_textColorSwatch->SetSwatchBackground( schematicBackground );
99
100 m_separator1->SetIsSeparator();
101
102 m_horizontal->SetIsRadioButton();
104 m_vertical->SetIsRadioButton();
106
107 m_separator2->SetIsSeparator();
108
109 m_bold->SetIsCheckButton();
111 m_italic->SetIsCheckButton();
113
114 m_separator3->SetIsSeparator();
115
116 m_hAlignLeft->SetIsRadioButton();
118 m_hAlignCenter->SetIsRadioButton();
120 m_hAlignRight->SetIsRadioButton();
122
123 m_separator4->SetIsSeparator();
124
125 m_vAlignTop->SetIsRadioButton();
127 m_vAlignCenter->SetIsRadioButton();
129 m_vAlignBottom->SetIsRadioButton();
131
132 m_separator5->SetIsSeparator();
133
134 m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
135 m_vertical->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onOrientButton, this );
136
137 m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
138 m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
139 m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onHAlignButton, this );
140
141 m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
142 m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
143 m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_FIELD_PROPERTIES::onVAlignButton, this );
144
145 // show text variable cross-references in a human-readable format
146 if( aField->Schematic() )
147 {
148 const SCH_SHEET_PATH& sheetPath = aField->Schematic()->CurrentSheet();
149 wxString variant = aField->Schematic()->GetCurrentVariant();
150
151 m_text = aField->Schematic()->ConvertKIIDsToRefs( aField->GetText( &sheetPath, variant ) );
152 }
153 else
154 {
155 m_text = aField->GetText();
156 }
157
158 m_font = m_field->GetFont();
159 m_isItalic = aField->IsItalic();
160 m_isBold = aField->IsBold();
161 m_color = aField->GetTextColor();
162 m_position = aField->GetTextPos();
163 m_size = aField->GetTextWidth();
167 m_isVisible = aField->IsVisible();
168
169 m_isSheetFilename = false;
170 m_fieldId = aField->GetId();
171
172 if( aField->GetParent() && aField->GetParent()->Type() == LIB_SYMBOL_T )
173 {
174 const LIB_SYMBOL* symbol = static_cast<const LIB_SYMBOL*>( aField->GetParentSymbol() );
175
176 /*
177 * Symbol netlist format:
178 * pinNumber pinName <tab> pinNumber pinName...
179 * fpFilter fpFilter...
180 */
181 wxString netlist;
182 wxArrayString pins;
183
184 for( SCH_PIN* pin : symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
185 {
186 bool valid = false;
187 auto expanded = pin->GetStackedPinNumbers( &valid );
188
189 if( valid && !expanded.empty() )
190 {
191 for( const wxString& num : expanded )
192 pins.push_back( num + ' ' + pin->GetShownName() );
193 }
194 else
195 {
196 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
197 }
198 }
199
200 if( !pins.IsEmpty() )
201 {
202 wxString dbg = wxJoin( pins, '\t' );
203 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (LIB_SYMBOL): %s" ), dbg );
204 netlist << EscapeString( dbg, CTX_LINE );
205 }
206
207 netlist << wxS( "\r" );
208
209 wxArrayString fpFilters = symbol->GetFPFilters();
210
211 if( !fpFilters.IsEmpty() )
212 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
213
214 netlist << wxS( "\r" );
215
217 }
218 else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
219 {
220 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aField->GetParentSymbol() );
221 SCH_SHEET_PATH sheetPath = static_cast<SCH_EDIT_FRAME*>( aParent )->GetCurrentSheet();
222
223 /*
224 * Symbol netlist format:
225 * pinNumber pinName <tab> pinNumber pinName...
226 * fpFilter fpFilter...
227 */
228 wxString netlist;
229
230 // We need the list of pins of the lib symbol, not just the pins of the current
231 // sch symbol, that can be just an unit of a multi-unit symbol, to be able to
232 // select/filter right footprints
233 wxArrayString pins;
234
235 const std::unique_ptr< LIB_SYMBOL >& lib_symbol = symbol->GetLibSymbolRef();
236
237 if( lib_symbol )
238 {
239 for( SCH_PIN* pin : lib_symbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
240 {
241 bool valid = false;
242 auto expanded = pin->GetStackedPinNumbers( &valid );
243 if( valid && !expanded.empty() )
244 {
245 for( const wxString& num : expanded )
246 pins.push_back( num + ' ' + pin->GetShownName() );
247 }
248 else
249 {
250 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
251 }
252 }
253 }
254
255 if( !pins.IsEmpty() )
256 {
257 wxString dbg = wxJoin( pins, '\t' );
258 wxLogTrace( "FOOTPRINT_CHOOSER", wxS( "Chooser payload pins (SCH_SYMBOL): %s" ), dbg );
259 netlist << EscapeString( dbg, CTX_LINE );
260 }
261
262 netlist << wxS( "\r" );
263
264 wxArrayString fpFilters;
265
266 if( symbol->GetLibSymbolRef() ) // can be null with very old schematic
267 fpFilters = symbol->GetLibSymbolRef()->GetFPFilters();
268
269 if( !fpFilters.IsEmpty() )
270 netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
271
272 netlist << wxS( "\r" );
273
275 }
276
277 if( aField->GetId() == FIELD_T::SHEET_FILENAME )
278 {
279 m_isSheetFilename = true;
280 m_note->Show( true );
281 }
282
283 m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
284
285 m_position = m_field->GetPosition();
286
287 m_isNameVisible = m_field->IsNameShown();
288 m_allowAutoplace = m_field->CanAutoplace();
289
290 m_horizontalJustification = m_field->GetEffectiveHorizJustify();
291 m_verticalJustification = m_field->GetEffectiveVertJustify();
292
293 m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
295 m_StyledTextCtrl->Bind( wxEVT_STC_AUTOCOMP_CHAR_DELETED,
297
298 m_nameVisible->Show();
299 m_cbAllowAutoPlace->Show();
300
301 init();
302
303 if( m_isSheetFilename || m_field->IsGeneratedField() )
304 {
305 m_StyledTextCtrl->Enable( false );
306 m_TextCtrl->Enable( false );
307 }
308}
309
310
316
317
319{
320 // Disable options for graphic text editing which are not needed for fields.
321 m_commonToAllBodyStyles->Show( false );
322 m_commonToAllUnits->Show( false );
323
324 // Predefined fields cannot contain some chars and cannot be empty, so they need a
325 // SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
331 {
332 m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
334
335 m_StyledTextCtrl->Show( false );
336 m_StyledTextCtrlBorder->Show( false );
337 }
338 else
339 {
341
342 m_TextCtrl->Show( false );
343 }
344
345 // Show the unit selector for reference fields on multi-unit schematic symbols
346 bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE
347 && m_field->GetParentSymbol()
348 && m_field->GetParentSymbol()->Type() == SCH_SYMBOL_T
349 && m_field->GetParentSymbol()->IsMultiUnit();
350
351 m_unitLabel->Show( showUnitSelector );
352 m_unitChoice->Show( showUnitSelector );
353
354 // Show the footprint selection dialog if this is the footprint field.
357
358 m_TextCtrl->Enable( true );
359
360 GetSizer()->SetSizeHints( this );
361
362 // Adjust the height of the scintilla editor after the first layout to show a single line
363 // (multiline text is not supported in fields and will be removed)
364 if( m_StyledTextCtrl->IsShown() )
365 {
366 wxSize maxSize;
367 maxSize.x = -1; // Do not fix the max width
368 maxSize.y = m_StyledTextCtrl->TextHeight( 0 );
369 m_StyledTextCtrl->SetMaxSize( maxSize );
370 m_StyledTextCtrl->SetUseVerticalScrollBar( false );
371 m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
372 }
373
375
376 // Now all widgets have the size fixed, call FinishDialogSettings
378}
379
380
382{
383 // pick a footprint using the footprint picker.
384 wxString fpid;
385
386 if( m_StyledTextCtrl->IsShown() )
387 fpid = m_StyledTextCtrl->GetValue();
388 else
389 fpid = m_TextCtrl->GetValue();
390
391 if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, this ) )
392 {
394 frame->KiwayMailIn( event );
395
396 if( frame->ShowModal( &fpid, this ) )
397 {
398 if( m_StyledTextCtrl->IsShown() )
399 m_StyledTextCtrl->SetValue( fpid );
400 else
401 m_TextCtrl->SetValue( fpid );
402 }
403
404 frame->Destroy();
405 }
406}
407
408
410{
411 if( m_firstFocus )
412 {
413#ifdef __WXGTK__
414 // Force an update of the text control before setting the text selection
415 // This is needed because GTK seems to ignore the selection on first update
416 //
417 // Note that we can't do this on OSX as it tends to provoke Apple's
418 // "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
419 // bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
421 m_TextCtrl->Update();
422#endif
423
425 KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
427 m_TextCtrl->SetSelection( -1, -1 );
428
429 m_firstFocus = false;
430 }
431
432 event.Skip();
433}
434
435
436void DIALOG_FIELD_PROPERTIES::onOrientButton( wxCommandEvent& aEvent )
437{
438 for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } )
439 {
440 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
441 btn->Check( false );
442 }
443}
444
445
446void DIALOG_FIELD_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent )
447{
449 {
450 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
451 btn->Check( false );
452 }
453}
454
455
456void DIALOG_FIELD_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent )
457{
459 {
460 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
461 btn->Check( false );
462 }
463}
464
465
467{
468 if( m_TextCtrl->IsShown() )
469 {
470 m_TextCtrl->SetValue( EscapeString( m_text, CTX_LINE ) );
471 }
472 else if( m_StyledTextCtrl->IsShown() )
473 {
475 m_StyledTextCtrl->EmptyUndoBuffer();
476 }
477
478 if( m_unitChoice->IsShown() )
479 {
480 const SYMBOL* parent = m_field->GetParentSymbol();
481
482 // Control shouldn't be shown for non-schematic symbols
483 wxCHECK( parent->Type() == SCH_SYMBOL_T, true );
484
485 const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( parent );
486
487 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
488 m_unitChoice->Append( symbol->GetUnitDisplayName( ii, false ) );
489
490 if( symbol->GetUnit() <= (int) m_unitChoice->GetCount() )
491 m_unitChoice->SetSelection( symbol->GetUnit() - 1 );
492 }
493
494 m_fontCtrl->SetFontSelection( m_font );
495
496 m_posX.SetValue( m_position.x );
497 m_posY.SetValue( m_position.y );
498 m_textSize.SetValue( m_size );
499
500 m_horizontal->Check( !m_isVertical );
501 m_vertical->Check( m_isVertical );
502
503 m_italic->Check( m_isItalic );
504 m_bold->Check( m_isBold );
505
506 m_textColorSwatch->SetSwatchColor( m_color, false );
507
509 {
510 case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break;
511 case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break;
512 case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break;
514 }
515
516 switch ( m_verticalJustification )
517 {
518 case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break;
519 case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break;
520 case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break;
522 }
523
524 m_visible->SetValue( m_isVisible );
525 m_nameVisible->SetValue( m_isNameVisible );
527
528 return true;
529}
530
531
533{
534 if( m_TextCtrl->IsShown() )
535 m_text = UnescapeString( m_TextCtrl->GetValue() );
536 else if( m_StyledTextCtrl->IsShown() )
537 m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
538
541
542 m_position = VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() );
543 m_size = m_textSize.GetIntValue();
544
545 if( m_fontCtrl->HaveFontSelection() )
546 m_font = m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() );
547
548 m_isVertical = m_vertical->IsChecked();
549
550 m_isBold = m_bold->IsChecked();
551 m_isItalic = m_italic->IsChecked();
552 m_color = m_textColorSwatch->GetSwatchColor();
553
554 if( m_hAlignLeft->IsChecked() )
556 else if( m_hAlignCenter->IsChecked() )
558 else
560
561 if( m_vAlignTop->IsChecked() )
563 else if( m_vAlignCenter->IsChecked() )
565 else
567
568 m_isVisible = m_visible->GetValue();
569 m_isNameVisible = m_nameVisible->GetValue();
571
572 return true;
573}
574
575
577{
578 if( aField->GetTextWidth() != m_size )
579 aField->SetTextSize( VECTOR2I( m_size, m_size ) );
580
581 aField->SetFont( m_font );
582 aField->SetVisible( m_isVisible );
584 aField->SetItalic( m_isItalic );
585 aField->SetBold( m_isBold );
586 aField->SetTextColor( m_color );
587}
588
589
591{
592 if( aField->Schematic() )
593 {
594 const SCH_SHEET_PATH& sheetPath = aField->Schematic()->CurrentSheet();
595 wxString variant = aField->Schematic()->GetCurrentVariant();
596
597 aField->SetText( m_text, &sheetPath, variant );
598 }
599 else
600 {
601 aField->SetText( m_text );
602 }
603
604 updateText( aField );
605
606 aField->SetNameShown( m_isNameVisible );
608
611 aField->SetTextPos( m_position );
612}
613
614
615void DIALOG_FIELD_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent )
616{
617 m_field->OnScintillaCharAdded( m_scintillaTricks, aEvent );
618}
619
620
622 SCH_SHEET_PATH* aSheetPath )
623{
624 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
625 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
626 bool fieldTextSet = false;
627 SCH_SHEET_PATH sheetPath;
628 wxString variantName;
629
630 // convert any text variable cross-references to their UUIDs
632
633 if( aField->Schematic() )
634 {
635 sheetPath = aField->Schematic()->CurrentSheet();
636 variantName = aField->Schematic()->GetCurrentVariant();
637 }
638
639 if( parent && parent->Type() == SCH_SYMBOL_T )
640 {
641 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
642
644 symbol->SetRef( aSheetPath, m_text );
645 else
646 symbol->SetFieldText( aField->GetName(), m_text, &sheetPath, variantName );
647
648 fieldTextSet = true;
649
650 // Set the unit selection in multiple units per package
651 if( m_unitChoice->IsShown() )
652 {
653 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
654 symbol->SetUnitSelection( aSheetPath, unit_selection );
655 symbol->SetUnit( unit_selection );
656 }
657 }
658 else if( parent && parent->Type() == SCH_SHEET_T )
659 {
660 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( parent );
661
662 if( !aField->IsMandatory() )
663 {
664 sheet->SetFieldText( aField->GetName(), m_text, &sheetPath, variantName );
665 fieldTextSet = true;
666 }
667 }
668 else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
669 {
671 {
672 if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
673 {
674 DisplayInfoMessage( this, _( "Intersheet reference visibility is "
675 "controlled globally from "
676 "Schematic Setup > General > Formatting" ) );
677 }
678 }
679 }
680
681 bool positioningModified = false;
682
683 if( aField->GetPosition() != m_position )
684 positioningModified = true;
685
686 if( aField->GetTextAngle().IsVertical() != m_isVertical )
687 positioningModified = true;
688
690 positioningModified = true;
691
693 positioningModified = true;
694
695 // Changing a sheetname need to update the hierarchy navigator
696 bool needUpdateHierNav = false;
697
699 needUpdateHierNav = m_text != aField->GetText();
700
701 if( !fieldTextSet )
702 aField->SetText( m_text );
703
704 updateText( aField );
705 aField->SetPosition( m_position );
706
707 aField->SetNameShown( m_isNameVisible );
709
710 // Note that we must set justifications before we can ask if they're flipped. If the old
711 // justification is center then it won't know (whereas if the new justification is center
712 // the we don't care).
715
716 if( aField->IsHorizJustifyFlipped() )
718
719 if( aField->IsVertJustifyFlipped() )
721
722 // The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
723 // Of course the symbol must be annotated to collect other units.
724 if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
725 {
726 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
727
728 if( symbol->IsAnnotated( aSheetPath ) && ( m_fieldId == FIELD_T::VALUE
731 {
732 wxString ref = symbol->GetRef( aSheetPath );
733 int unit = symbol->GetUnit();
734 LIB_ID libId = symbol->GetLibId();
735
736 for( SCH_SHEET_PATH& sheet : editFrame->Schematic().Hierarchy() )
737 {
738 SCH_SCREEN* screen = sheet.LastScreen();
739 std::vector<SCH_SYMBOL*> otherUnits;
740
741 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
742
743 for( SCH_SYMBOL* otherUnit : otherUnits )
744 {
745 aCommit->Modify( otherUnit, screen );
746 otherUnit->GetField( m_fieldId )->SetText( m_text );
747 editFrame->UpdateItem( otherUnit, false, true );
748 }
749 }
750 }
751 }
752
753 if( positioningModified && parent )
755
756 // Update the hierarchy navigator labels if needed.
757 if( editFrame && needUpdateHierNav )
759}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
@ 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:402
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:106
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:82
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:110
EDA_ITEM * GetParent() const
Definition eda_item.h:112
void SetTextColor(const COLOR4D &aColor)
Definition eda_text.h:269
const VECTOR2I & GetTextPos() const
Definition eda_text.h:273
COLOR4D GetTextColor() const
Definition eda_text.h:270
bool IsItalic() const
Definition eda_text.h:169
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:147
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:541
virtual bool IsVisible() const
Definition eda_text.h:187
void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:585
int GetTextWidth() const
Definition eda_text.h:264
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:426
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:200
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:395
static GR_TEXT_H_ALIGN_T MapHorizJustify(int aHorizJustify)
Definition eda_text.cpp:70
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition eda_text.cpp:344
bool IsBold() const
Definition eda_text.h:184
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:203
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:308
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:316
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:508
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:418
A text control validator used for validating the text allowed in fields.
Definition validators.h:142
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
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:49
Define a library symbol object.
Definition lib_symbol.h:83
wxArrayString GetFPFilters() const
Definition lib_symbol.h:215
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
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:187
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:118
FIELD_T GetId() const
Definition sch_field.h:122
void SetCanAutoplace(bool aCanPlace)
Definition sch_field.h:220
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:209
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:253
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:247
int GetUnit() const
Definition sch_item.h:238
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:626
virtual void SetUnit(int aUnit)
Definition sch_item.h:237
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:48
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:76
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:165
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:184
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:63
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:628
The common library.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:230
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:44
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:488
@ MAIL_SYMBOL_NETLIST
Definition mail_type.h:45
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:69
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
@ 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".
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:152
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_SHEET_T
Definition typeinfo.h:179
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:172
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
Definition of file extensions used in Kicad.