KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
sch_field.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <wx/log.h>
26#include <wx/menu.h>
27
28#include <advanced_config.h>
29#include <base_units.h>
30#include <common.h> // for ExpandTextVars
31#include <sch_edit_frame.h>
32#include <plotters/plotter.h>
33#include <bitmaps.h>
34#include <kiway.h>
35#include <symbol_library.h>
37#include <string_utils.h>
38#include <trace_helpers.h>
39#include <tool/tool_manager.h>
41#include <font/outline_font.h>
42#include "sim/sim_lib_mgr.h"
43
44static const std::vector<KICAD_T> labelTypes = { SCH_LABEL_LOCATE_ANY_T };
45
46
48 SCH_ITEM( nullptr, SCH_FIELD_T ),
49 EDA_TEXT( schIUScale, wxEmptyString ),
50 m_id( FIELD_T::USER ),
51 m_ordinal( 0 ),
52 m_showName( false ),
53 m_allowAutoPlace( true ),
54 m_isNamedVariable( false ),
55 m_autoAdded( false ),
56 m_showInChooser( true ),
57 m_renderCacheValid( false ),
58 m_lastResolvedColor( COLOR4D::UNSPECIFIED )
59{
60}
61
62
63SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, FIELD_T aFieldId, SCH_ITEM* aParent,
64 const wxString& aName ) :
65 SCH_FIELD()
66{
67 m_parent = aParent;
68
69 if( !aName.IsEmpty() )
70 SetName( aName );
71 else
73
74 SetTextPos( aPos );
75 setId( aFieldId ); // will also set the layer
76 SetVisible( true );
77}
78
79
80SCH_FIELD::SCH_FIELD( SCH_ITEM* aParent, FIELD_T aFieldId, const wxString& aName ) :
81 SCH_FIELD( VECTOR2I(), aFieldId, aParent, aName )
82{
83 if( aFieldId == FIELD_T::USER && aParent )
84 {
85 if( aParent->Type() == SCH_SYMBOL_T )
86 m_ordinal = static_cast<SCH_SYMBOL*>( aParent )->GetNextFieldOrdinal();
87 else if( aParent->Type() == LIB_SYMBOL_T )
88 m_ordinal = static_cast<LIB_SYMBOL*>( aParent )->GetNextFieldOrdinal();
89 else if( aParent->Type() == SCH_SHEET_T )
90 m_ordinal = static_cast<SCH_SHEET*>( aParent )->GetNextFieldOrdinal();
91 else if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( aParent ) )
92 m_ordinal = label->GetNextFieldOrdinal();
93 }
94}
95
96
98 SCH_FIELD( VECTOR2I(), FIELD_T::USER, nullptr, wxEmptyString )
99{
100 SCH_ITEM::operator=( *aText );
101 EDA_TEXT::operator=( *aText );
102}
103
104
106 SCH_ITEM( aField ),
107 EDA_TEXT( aField )
108{
109 m_private = aField.m_private;
110 setId( aField.m_id ); // will also set the layer
111 m_ordinal = aField.m_ordinal;
112 m_name = aField.m_name;
113 m_showName = aField.m_showName;
116 m_autoAdded = aField.m_autoAdded;
118
119 m_renderCache.clear();
120
121 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
122 {
123 if( KIFONT::OUTLINE_GLYPH* outline = dynamic_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() ) )
124 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline ) );
125 else if( KIFONT::STROKE_GLYPH* stroke = dynamic_cast<KIFONT::STROKE_GLYPH*>( glyph.get() ) )
126 m_renderCache.emplace_back( std::make_unique<KIFONT::STROKE_GLYPH>( *stroke ) );
127 }
128
131
133}
134
135
137{
138 EDA_TEXT::operator=( aField );
139
140 m_private = aField.m_private;
141 setId( aField.m_id ); // will also set the layer
142 m_ordinal = aField.m_ordinal;
143 m_name = aField.m_name;
144 m_showName = aField.m_showName;
147
148 m_renderCache.clear();
149
150 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
151 {
152 if( KIFONT::OUTLINE_GLYPH* outline = dynamic_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() ) )
153 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline ) );
154 else if( KIFONT::STROKE_GLYPH* stroke = dynamic_cast<KIFONT::STROKE_GLYPH*>( glyph.get() ) )
155 m_renderCache.emplace_back( std::make_unique<KIFONT::STROKE_GLYPH>( *stroke ) );
156 }
157
160
162
163 return *this;
164}
165
166
168{
169 return new SCH_FIELD( *this );
170}
171
172
173void SCH_FIELD::Copy( SCH_FIELD* aTarget ) const
174{
175 *aTarget = *this;
176}
177
178
180{
181 m_id = aId;
183}
184
185
187{
189}
190
191
192wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
193 int aDepth ) const
194{
195 std::function<bool( wxString* )> libSymbolResolver =
196 [&]( wxString* token ) -> bool
197 {
198 LIB_SYMBOL* symbol = static_cast<LIB_SYMBOL*>( m_parent );
199 return symbol->ResolveTextVar( token, aDepth + 1 );
200 };
201
202 std::function<bool( wxString* )> symbolResolver =
203 [&]( wxString* token ) -> bool
204 {
205 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( m_parent );
206 return symbol->ResolveTextVar( aPath, token, aDepth + 1 );
207 };
208
209 std::function<bool( wxString* )> schematicResolver =
210 [&]( wxString* token ) -> bool
211 {
212 if( !aPath )
213 return false;
214
215 if( SCHEMATIC* schematic = Schematic() )
216 return schematic->ResolveTextVar( aPath, token, aDepth + 1 );
217
218 return false;
219 };
220
221 std::function<bool( wxString* )> sheetResolver =
222 [&]( wxString* token ) -> bool
223 {
224 if( !aPath )
225 return false;
226
227 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
228
229 SCHEMATIC* schematic = Schematic();
230 SCH_SHEET_PATH path = *aPath;
231 path.push_back( sheet );
232
233 bool retval = sheet->ResolveTextVar( &path, token, aDepth + 1 );
234
235 if( schematic )
236 retval |= schematic->ResolveTextVar( &path, token, aDepth + 1 );
237
238 return retval;
239 };
240
241 std::function<bool( wxString* )> labelResolver =
242 [&]( wxString* token ) -> bool
243 {
244 if( !aPath )
245 return false;
246
247 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
248 return label->ResolveTextVar( aPath, token, aDepth + 1 );
249 };
250
251 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
252
253 if( IsNameShown() && aAllowExtraText )
254 text = GetShownName() << wxS( ": " ) << text;
255
256 // The iteration here it to allow for nested variables in the
257 // text strings (e.g. ${${VAR}}). Although the symbols and sheets
258 // and labels recurse, text that is none of those types such as text
259 // boxes and labels do not. This only loops if there is still a
260 // variable to resolve.
261 for( int ii = aDepth;
262 ii < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth && text.Contains( wxT( "${" ) );
263 ++ii )
264 {
265 if( m_parent && m_parent->Type() == LIB_SYMBOL_T )
266 text = ExpandTextVars( text, &libSymbolResolver );
267 else if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
268 text = ExpandTextVars( text, &symbolResolver );
269 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
270 text = ExpandTextVars( text, &sheetResolver );
271 else if( m_parent && m_parent->IsType( labelTypes ) )
272 text = ExpandTextVars( text, &labelResolver );
273 else if( Schematic() )
274 {
276 text = ExpandTextVars( text, &schematicResolver );
277 }
278 }
279
280 if( m_id == FIELD_T::REFERENCE && aPath )
281 {
282 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
283
284 // For more than one part per package, we must add the part selection
285 // A, B, ... or 1, 2, .. to the reference.
286 if( parentSymbol && parentSymbol->GetUnitCount() > 1 )
287 text << parentSymbol->SubReference( parentSymbol->GetUnitSelection( aPath ) );
288 }
289
290 if( m_id == FIELD_T::SHEET_FILENAME && aAllowExtraText && !IsNameShown() )
291 text = _( "File:" ) + wxS( " " ) + text;
292
293 return text;
294}
295
296
297wxString SCH_FIELD::GetShownText( bool aAllowExtraText, int aDepth ) const
298{
299 if( SCHEMATIC* schematic = Schematic() )
300 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
301 else
302 return GetShownText( nullptr, aAllowExtraText, aDepth );
303}
304
305
306wxString SCH_FIELD::GetFullText( int unit ) const
307{
308 if( GetId() != FIELD_T::REFERENCE )
309 return GetText();
310
311 wxString text = GetText();
312 text << wxT( "?" );
313
314 if( GetParentSymbol() && GetParentSymbol()->IsMulti() )
315 text << LIB_SYMBOL::LetterSubReference( unit, 'A' );
316
317 return text;
318}
319
320
322{
324}
325
326
328{
330
331 if( !font )
333
334 return font;
335}
336
337
339{
342}
343
344
346{
348 m_renderCacheValid = false;
349}
350
351
352std::vector<std::unique_ptr<KIFONT::GLYPH>>*
353SCH_FIELD::GetRenderCache( const wxString& forResolvedText, const VECTOR2I& forPosition,
354 TEXT_ATTRIBUTES& aAttrs ) const
355{
356 KIFONT::FONT* font = GetFont();
357
358 if( !font )
360
361 if( font->IsOutline() )
362 {
363 KIFONT::OUTLINE_FONT* outlineFont = static_cast<KIFONT::OUTLINE_FONT*>( font );
364
365 if( m_renderCache.empty() || !m_renderCacheValid )
366 {
367 m_renderCache.clear();
368
369 outlineFont->GetLinesAsGlyphs( &m_renderCache, forResolvedText, forPosition, aAttrs,
370 GetFontMetrics() );
371
372 m_renderCachePos = forPosition;
373 m_renderCacheValid = true;
374 }
375
376 if( m_renderCachePos != forPosition )
377 {
378 VECTOR2I delta = forPosition - m_renderCachePos;
379
380 for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_renderCache )
381 {
382 if( glyph->IsOutline() )
383 static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( delta );
384 else
385 static_cast<KIFONT::STROKE_GLYPH*>( glyph.get() )->Move( delta );
386 }
387
388 m_renderCachePos = forPosition;
389 }
390
391 return &m_renderCache;
392 }
393
394 return nullptr;
395}
396
397
398void SCH_FIELD::ImportValues( const SCH_FIELD& aSource )
399{
400 SetAttributes( aSource );
401 SetVisible( aSource.IsVisible() );
402 SetNameShown( aSource.IsNameShown() );
403 SetCanAutoplace( aSource.CanAutoplace() );
404}
405
406
408{
409 wxCHECK_RET( aItem && aItem->Type() == SCH_FIELD_T, wxT( "Cannot swap with invalid item." ) );
410
411 SCH_ITEM::SwapFlags( aItem );
412
413 SCH_FIELD* item = static_cast<SCH_FIELD*>( aItem );
414
415 std::swap( m_layer, item->m_layer );
416 std::swap( m_showName, item->m_showName );
417 std::swap( m_allowAutoPlace, item->m_allowAutoPlace );
418 std::swap( m_isNamedVariable, item->m_isNamedVariable );
419 std::swap( m_private, item->m_private );
420 SwapText( *item );
421 SwapAttributes( *item );
422
423 std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
424}
425
426
428{
429 if( GetTextColor() != COLOR4D::UNSPECIFIED )
430 {
432 }
433 else
434 {
435 SCH_LABEL_BASE* parentLabel = dynamic_cast<SCH_LABEL_BASE*>( GetParent() );
436
437 if( parentLabel && !parentLabel->IsConnectivityDirty() )
438 m_lastResolvedColor = parentLabel->GetEffectiveNetClass()->GetSchematicColor();
439 else
441 }
442
443 return m_lastResolvedColor;
444}
445
446
447std::vector<int> SCH_FIELD::ViewGetLayers() const
448{
450}
451
452
454{
455 if( m_parent && m_parent->Type() == SCH_LABEL_T )
456 {
457 if( GetCanonicalName() == wxT( "Netclass" )
458 || GetCanonicalName() == wxT( "Component Class" ) )
459 {
460 return LAYER_NETCLASS_REFS;
461 }
462 }
463
464 switch( m_id )
465 {
466 case FIELD_T::REFERENCE: return LAYER_REFERENCEPART;
467 case FIELD_T::VALUE: return LAYER_VALUEPART;
468 case FIELD_T::SHEET_NAME: return LAYER_SHEETNAME;
469 case FIELD_T::SHEET_FILENAME: return LAYER_SHEETFILENAME;
470 case FIELD_T::SHEET_USER: return LAYER_SHEETFIELDS;
471 case FIELD_T::INTERSHEET_REFS: return LAYER_INTERSHEET_REFS;
472 default: return LAYER_FIELDS;
473 }
474}
475
476
478{
479 // Calculate the text orientation according to the symbol orientation.
480 EDA_ANGLE orient = GetTextAngle();
481
482 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
483 {
484 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
485
486 if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
487 {
488 if( orient.IsHorizontal() )
489 orient = ANGLE_VERTICAL;
490 else
491 orient = ANGLE_HORIZONTAL;
492 }
493 }
494
495 return orient;
496}
497
498
500{
501 BOX2I bbox = GetTextBox();
502
503 // Calculate the bounding box position relative to the parent:
504 VECTOR2I origin = GetParentPosition();
505 VECTOR2I pos = GetTextPos() - origin;
506 VECTOR2I begin = bbox.GetOrigin() - origin;
507 VECTOR2I end = bbox.GetEnd() - origin;
508 RotatePoint( begin, pos, GetTextAngle() );
509 RotatePoint( end, pos, GetTextAngle() );
510
511 // Now, apply the symbol transform (mirror/rot)
512 TRANSFORM transform;
513
514 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
515 transform = static_cast<SCH_SYMBOL*>( m_parent )->GetTransform();
516
517 bbox.SetOrigin( transform.TransformCoordinate( begin ) );
518 bbox.SetEnd( transform.TransformCoordinate( end ) );
519
520 bbox.Move( origin );
521 bbox.Normalize();
522
523 return bbox;
524}
525
526
528{
529 VECTOR2I render_center = GetBoundingBox().Centre();
530 VECTOR2I pos = GetPosition();
531
532 switch( GetHorizJustify() )
533 {
535 if( GetDrawRotation().IsVertical() )
536 return render_center.y > pos.y;
537 else
538 return render_center.x < pos.x;
540 if( GetDrawRotation().IsVertical() )
541 return render_center.y < pos.y;
542 else
543 return render_center.x > pos.x;
544 default:
545 return false;
546 }
547}
548
549
551{
552 GR_TEXT_H_ALIGN_T actualJustify;
553
554 switch( aJustify )
555 {
558 break;
561 break;
562 default:
563 actualJustify = aJustify;
564 }
565
566 SetHorizJustify( actualJustify );
567}
568
569
571{
572 switch( GetHorizJustify() )
573 {
578 default:
580 }
581}
582
583
585{
586 VECTOR2I render_center = GetBoundingBox().Centre();
587 VECTOR2I pos = GetPosition();
588
589 switch( GetVertJustify() )
590 {
592 if( GetDrawRotation().IsVertical() )
593 return render_center.x < pos.x;
594 else
595 return render_center.y < pos.y;
597 if( GetDrawRotation().IsVertical() )
598 return render_center.x > pos.x;
599 else
600 return render_center.y > pos.y;
601 default:
602 return false;
603 }
604}
605
606
608{
609 GR_TEXT_V_ALIGN_T actualJustify;
610
611 switch( aJustify )
612 {
615 break;
618 break;
619 default:
620 actualJustify = aJustify;
621 }
622
623 SetVertJustify( actualJustify );
624}
625
626
628{
629 switch( GetVertJustify() )
630 {
635 default:
637 }
638}
639
640
641bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
642{
643 bool searchHiddenFields = false;
644 bool searchAndReplace = false;
645 bool replaceReferences = false;
646
647 try
648 {
649 // downcast
650 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
651 searchHiddenFields = schSearchData.searchAllFields;
652 searchAndReplace = schSearchData.searchAndReplace;
653 replaceReferences = schSearchData.replaceReferences;
654 }
655 catch( const std::bad_cast& )
656 {
657 }
658
659 wxString text = UnescapeString( GetText() );
660
661 if( !IsVisible() && !searchHiddenFields )
662 return false;
663
664 if( m_id == FIELD_T::REFERENCE )
665 {
666 if( searchAndReplace && !replaceReferences )
667 return false;
668
669 SCH_SYMBOL* parentSymbol = dyn_cast<SCH_SYMBOL*>( m_parent );
670
671 // The parent might be a LIB_SYMBOL, in which case, we don't
672 // have a sheet path to resolve the reference.
673 if( !parentSymbol )
674 return false;
675
676 wxASSERT( aAuxData );
677
678 // Take sheet path into account which effects the reference field and the unit for
679 // symbols with multiple parts.
680 if( parentSymbol && aAuxData )
681 {
682 SCH_SHEET_PATH* sheet = (SCH_SHEET_PATH*) aAuxData;
683 text = parentSymbol->GetRef( sheet );
684
685 if( SCH_ITEM::Matches( text, aSearchData ) )
686 return true;
687
688 if( parentSymbol->GetUnitCount() > 1 )
689 text << parentSymbol->SubReference( parentSymbol->GetUnitSelection( sheet ) );
690 }
691 }
692
693 return SCH_ITEM::Matches( text, aSearchData );
694}
695
696
698 wxStyledTextEvent &aEvent ) const
699{
700 SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( GetParent() );
701 SCHEMATIC* schematic = parent ? parent->Schematic() : nullptr;
702
703 if( !schematic )
704 return;
705
706 wxStyledTextCtrl* scintilla = aScintillaTricks->Scintilla();
707 int key = aEvent.GetKey();
708
709 wxArrayString autocompleteTokens;
710 int pos = scintilla->GetCurrentPos();
711 int start = scintilla->WordStartPosition( pos, true );
712 wxString partial;
713
714 // Multi-line fields are not allowed. So remove '\n' if entered.
715 if( key == '\n' )
716 {
717 wxString text = scintilla->GetText();
718 int currpos = scintilla->GetCurrentPos();
719 text.Replace( wxS( "\n" ), wxS( "" ) );
720 scintilla->SetText( text );
721 scintilla->GotoPos( currpos-1 );
722 return;
723 }
724
725 auto textVarRef =
726 [&]( int pt )
727 {
728 return pt >= 2
729 && scintilla->GetCharAt( pt - 2 ) == '$'
730 && scintilla->GetCharAt( pt - 1 ) == '{';
731 };
732
733 // Check for cross-reference
734 if( start > 1 && scintilla->GetCharAt( start - 1 ) == ':' )
735 {
736 int refStart = scintilla->WordStartPosition( start - 1, true );
737
738 if( textVarRef( refStart ) )
739 {
740 partial = scintilla->GetRange( start, pos );
741
742 wxString ref = scintilla->GetRange( refStart, start - 1 );
743
744 if( ref == wxS( "OP" ) )
745 {
746 // SPICE operating points use ':' syntax for ports
747 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( parent ) )
748 {
749 NULL_REPORTER devnull;
750 SCH_SHEET_PATH& sheet = schematic->CurrentSheet();
751 SIM_LIB_MGR mgr( &schematic->Prj(), schematic );
752 SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, devnull ).model;
753
754 for( wxString pin : model.GetPinNames() )
755 {
756 if( pin.StartsWith( '<' ) && pin.EndsWith( '>' ) )
757 autocompleteTokens.push_back( pin.Mid( 1, pin.Length() - 2 ) );
758 else
759 autocompleteTokens.push_back( pin );
760 }
761 }
762 }
763 else
764 {
766 SCH_SYMBOL* refSymbol = nullptr;
767
768 schematic->Hierarchy().GetSymbols( refs );
769
770 for( size_t jj = 0; jj < refs.GetCount(); jj++ )
771 {
772 if( refs[ jj ].GetSymbol()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref )
773 {
774 refSymbol = refs[ jj ].GetSymbol();
775 break;
776 }
777 }
778
779 if( refSymbol )
780 refSymbol->GetContextualTextVars( &autocompleteTokens );
781 }
782 }
783 }
784 else if( textVarRef( start ) )
785 {
786 partial = scintilla->GetTextRange( start, pos );
787
788 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( parent );
789 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( parent );
790 SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( parent );
791
792 if( symbol )
793 {
794 symbol->GetContextualTextVars( &autocompleteTokens );
795
796 if( schematic->CurrentSheet().Last() )
797 schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
798 }
799
800 if( sheet )
801 sheet->GetContextualTextVars( &autocompleteTokens );
802
803 if( label )
804 label->GetContextualTextVars( &autocompleteTokens );
805
806 for( std::pair<wxString, wxString> entry : schematic->Prj().GetTextVars() )
807 autocompleteTokens.push_back( entry.first );
808 }
809
810 aScintillaTricks->DoAutocomplete( partial, autocompleteTokens );
811 scintilla->SetFocus();
812}
813
814
816{
817 // See comments in SCH_FIELD::Replace(), below.
818 if( m_id == FIELD_T::SHEET_FILENAME || m_id == FIELD_T::INTERSHEET_REFS )
819 return false;
820
821 return true;
822}
823
824
825bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
826{
827 bool replaceReferences = false;
828
829 try
830 {
831 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
832 replaceReferences = schSearchData.replaceReferences;
833 }
834 catch( const std::bad_cast& )
835 {
836 }
837
838 wxString text;
839 bool isReplaced = false;
840
841 if( m_id == FIELD_T::REFERENCE && m_parent && m_parent->Type() == SCH_SYMBOL_T )
842 {
843 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
844
845 if( !replaceReferences )
846 return false;
847
848 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
849
850 text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
851 isReplaced = EDA_ITEM::Replace( aSearchData, text );
852
853 if( isReplaced )
854 parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
855 }
856 else
857 {
858 isReplaced = EDA_TEXT::Replace( aSearchData );
859
860 if( m_id == FIELD_T::SHEET_FILENAME && isReplaced )
861 {
862 // If we allowed this we'd have a bunch of work to do here, including warning
863 // about it not being undoable, checking for recursive hierarchies, reloading
864 // sheets, etc. See DIALOG_SHEET_PROPERTIES::TransferDataFromWindow().
865 }
866 }
867
868 return isReplaced;
869}
870
871
872void SCH_FIELD::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
873{
875
876 if( GetTextAngle().IsVertical() )
877 {
878 switch( horizJustify )
879 {
881 if( aRotateCCW )
883
884 break;
886 if( aRotateCCW )
888 break;
891 }
892
894 }
895 else if( GetTextAngle().IsHorizontal() )
896 {
897 switch( horizJustify )
898 {
900 if( !aRotateCCW )
902 break;
904 if( !aRotateCCW )
906 break;
909 }
910
912 }
913 else
914 {
915 wxASSERT_MSG(
916 false,
917 wxString::Format( wxT( "SCH_FIELD text angle is not horizontal or vertical: %d" ),
918 GetTextAngle().AsDegrees() ) );
919 }
920
921 VECTOR2I pt = GetPosition();
922 RotatePoint( pt, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
923 SetPosition( pt );
924}
925
926
928{
929 int x = GetTextPos().x;
930
931 x -= aCenter;
932 x *= -1;
933 x += aCenter;
934
935 SetTextX( x );
936}
937
938
940{
941 int y = GetTextPos().y;
942
943 y -= aCenter;
944 y *= -1;
945 y += aCenter;
946
947 SetTextY( y );
948}
949
950
951void SCH_FIELD::BeginEdit( const VECTOR2I& aPosition )
952{
953 SetTextPos( aPosition );
954}
955
956
957void SCH_FIELD::CalcEdit( const VECTOR2I& aPosition )
958{
959 SetTextPos( aPosition );
960}
961
962
963wxString SCH_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
964{
965 return wxString::Format( _( "Field %s '%s'" ),
967 aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ) );
968}
969
970
971void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
972{
973 wxString msg;
974
975 aList.emplace_back( _( "Symbol Field" ), UnescapeString( GetName() ) );
976
977 // Don't use GetShownText() here; we want to show the user the variable references
978 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
979
980 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
981
982 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
983
984 aList.emplace_back( _( "Style" ), GetTextStyleName() );
985
986 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
987
988 switch ( GetHorizJustify() )
989 {
990 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
991 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
992 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
994 }
995
996 aList.emplace_back( _( "H Justification" ), msg );
997
998 switch ( GetVertJustify() )
999 {
1000 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
1001 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
1002 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
1004 }
1005
1006 aList.emplace_back( _( "V Justification" ), msg );
1007}
1008
1009
1011{
1012 constexpr int START_ID = 1;
1013
1014 if( IsHypertext() )
1015 {
1016 wxString href;
1017
1018 if( m_id == FIELD_T::INTERSHEET_REFS )
1019 {
1020 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
1021 SCH_SHEET_PATH* sheet = &label->Schematic()->CurrentSheet();
1022 wxMenu menu;
1023
1024 std::vector<std::pair<wxString, wxString>> pages;
1025
1026 label->GetIntersheetRefs( sheet, &pages );
1027
1028 for( int i = 0; i < (int) pages.size(); ++i )
1029 {
1030 menu.Append( i + START_ID, wxString::Format( _( "Go to Page %s (%s)" ),
1031 pages[i].first,
1032 pages[i].second ) );
1033 }
1034
1035 menu.AppendSeparator();
1036 menu.Append( 999 + START_ID, _( "Back to Previous Selected Sheet" ) );
1037
1038 int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
1039
1040 if( sel >= 0 && sel < (int) pages.size() )
1041 href = wxT( "#" ) + pages[ sel ].first;
1042 else if( sel == 999 )
1044 }
1045 else if( IsURL( GetShownText( false ) ) )
1046 {
1047 href = GetShownText( false );
1048 }
1049
1050 if( !href.IsEmpty() )
1051 {
1053 navTool->HypertextCommand( href );
1054 }
1055 }
1056}
1057
1058
1059void SCH_FIELD::SetName( const wxString& aName )
1060{
1061 m_name = aName;
1062 m_isNamedVariable = m_name.StartsWith( wxT( "${" ) );
1063
1064 if( m_isNamedVariable )
1065 EDA_TEXT::SetText( aName );
1066}
1067
1068
1069void SCH_FIELD::SetText( const wxString& aText )
1070{
1071 // Don't allow modification of text value when using named variables
1072 // as field name.
1073 if( m_isNamedVariable )
1074 return;
1075
1076 // Mandatory fields should not have leading or trailing whitespace.
1077 if( IsMandatory() )
1078 EDA_TEXT::SetText( aText.Strip( wxString::both ) );
1079 else
1080 EDA_TEXT::SetText( aText );
1081}
1082
1083
1084wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
1085{
1086 if( m_parent && m_parent->IsType( labelTypes ) )
1087 return SCH_LABEL_BASE::GetDefaultFieldName( m_name, aUseDefaultName );
1088
1089 if( IsMandatory() )
1090 return GetCanonicalFieldName( m_id );
1091 else if( m_name.IsEmpty() && aUseDefaultName )
1093 else
1094 return m_name;
1095}
1096
1097
1099{
1100 if( m_parent && m_parent->IsType( labelTypes ) )
1101 {
1102 // These should be stored in canonical format, but just in case:
1103 if( m_name == _( "Net Class" ) || m_name == wxT( "Net Class" ) )
1104 return wxT( "Netclass" );
1105 }
1106
1107 if( IsMandatory() )
1108 return GetCanonicalFieldName( m_id );
1109
1110 return m_name;
1111}
1112
1113
1115{
1116 if( m_parent && ( m_parent->Type() == SCH_SYMBOL_T || m_parent->Type() == LIB_SYMBOL_T ) )
1117 {
1118 switch( m_id )
1119 {
1120 case FIELD_T::REFERENCE: return BITMAPS::edit_comp_ref;
1121 case FIELD_T::VALUE: return BITMAPS::edit_comp_value;
1122 case FIELD_T::FOOTPRINT: return BITMAPS::edit_comp_footprint;
1123 default: return BITMAPS::text;
1124 }
1125 }
1126
1127 return BITMAPS::text;
1128}
1129
1130
1131bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1132{
1133 if( GetShownText( true ).IsEmpty() )
1134 return false;
1135
1136 BOX2I rect = GetBoundingBox();
1137
1138 // Text in symbol editor can have additional chars (ie: reference designators U? or U?A)
1139 if( m_parent && m_parent->Type() == LIB_SYMBOL_T )
1140 {
1141 SCH_FIELD temp( *this );
1142 temp.SetText( GetFullText() );
1143 rect = temp.GetBoundingBox();
1144 }
1145
1146 rect.Inflate( aAccuracy );
1147
1149 {
1150 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
1151 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
1152 }
1153
1154 return rect.Contains( aPosition );
1155}
1156
1157
1158bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1159{
1160 if( GetShownText( true ).IsEmpty() )
1161 return false;
1162
1164 return false;
1165
1166 BOX2I rect = aRect;
1167
1168 rect.Inflate( aAccuracy );
1169
1170 if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
1171 {
1172 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
1173 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
1174 }
1175
1176 if( aContained )
1177 return rect.Contains( GetBoundingBox() );
1178
1179 return rect.Intersects( GetBoundingBox() );
1180}
1181
1182
1183void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
1184 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
1185{
1186 wxString text;
1187
1188 if( Schematic() )
1189 text = GetShownText( &Schematic()->CurrentSheet(), true );
1190 else
1191 text = GetShownText( true );
1192
1193 if( ( !IsVisible() && !IsForceVisible() ) || text.IsEmpty() || aBackground )
1194 return;
1195
1196 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
1197 COLOR4D color = renderSettings->GetLayerColor( GetLayer() );
1198 int penWidth = GetEffectiveTextPenWidth( renderSettings->GetDefaultPenWidth() );
1199
1200 COLOR4D bg = renderSettings->GetBackgroundColor();;
1201
1202 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
1203 bg = COLOR4D::WHITE;
1204
1205 if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
1206 color = GetTextColor();
1207
1208 if( aDimmed )
1209 {
1210 color.Desaturate( );
1211 color = color.Mix( bg, 0.5f );
1212 }
1213
1214 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
1215
1216 // clamp the pen width to be sure the text is readable
1217 penWidth = std::min( penWidth, std::min( GetTextSize().x, GetTextSize().y ) / 4 );
1218
1219 if( !IsVisible() && !renderSettings->m_ShowHiddenFields )
1220 return;
1221
1222 // Calculate the text orientation, according to the symbol orientation/mirror
1223 EDA_ANGLE orient = GetTextAngle();
1224 VECTOR2I textpos = GetTextPos();
1226 GR_TEXT_V_ALIGN_T vjustify = GetVertJustify();
1227
1228 if( renderSettings->m_Transform.y1 ) // Rotate symbol 90 deg.
1229 {
1230 if( orient.IsHorizontal() )
1231 orient = ANGLE_VERTICAL;
1232 else
1233 orient = ANGLE_HORIZONTAL;
1234 }
1235
1236 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
1237 {
1238 /*
1239 * Calculate the text justification, according to the symbol orientation/mirror. This is
1240 * a bit complicated due to cumulative calculations:
1241 * - numerous cases (mirrored or not, rotation)
1242 * - the plotter's Text() function will also recalculate H and V justifications according
1243 * to the text orientation
1244 * - when a symbol is mirrored the text is not, and justifications become a nightmare
1245 *
1246 * So the easier way is to use no justifications (centered text) and use GetBoundingBox
1247 * to know the text coordinate considered as centered.
1248 */
1249 hjustify = GR_TEXT_H_ALIGN_CENTER;
1250 vjustify = GR_TEXT_V_ALIGN_CENTER;
1251 textpos = GetBoundingBox().Centre();
1252 }
1253 else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
1254 {
1255 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( m_parent );
1256 textpos += label->GetSchematicTextOffset( renderSettings );
1257 }
1258
1259 KIFONT::FONT* font = GetFont();
1260
1261 if( !font )
1262 font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
1263
1265 attrs.m_StrokeWidth = penWidth;
1266 attrs.m_Halign = hjustify;
1267 attrs.m_Valign = vjustify;
1268 attrs.m_Angle = orient;
1269 attrs.m_Multiline = false;
1270
1271 aPlotter->PlotText( textpos, color, text, attrs, font, GetFontMetrics() );
1272
1273 if( IsHypertext() && Schematic() )
1274 {
1275 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
1276 std::vector<std::pair<wxString, wxString>> pages;
1277 std::vector<wxString> pageHrefs;
1278 BOX2I bbox = GetBoundingBox();
1279
1280 wxCHECK( label, /* void */ );
1281
1282 label->GetIntersheetRefs( &Schematic()->CurrentSheet(), &pages );
1283
1284 for( const auto& [ pageNumber, sheetName ] : pages )
1285 pageHrefs.push_back( wxT( "#" ) + pageNumber );
1286
1287 bbox.Offset( label->GetSchematicTextOffset( renderSettings ) );
1288
1289 aPlotter->HyperlinkMenu( bbox, pageHrefs );
1290 }
1291}
1292
1293
1294void SCH_FIELD::SetPosition( const VECTOR2I& aPosition )
1295{
1296 // Actual positions are calculated by the rotation/mirror transform of the parent symbol
1297 // of the field. The inverse transform is used to calculate the position relative to the
1298 // parent symbol.
1299 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
1300 {
1301 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
1302 VECTOR2I relPos = aPosition - parentSymbol->GetPosition();
1303
1304 relPos = parentSymbol->GetTransform().InverseTransform().TransformCoordinate( relPos );
1305
1306 SetTextPos( relPos + parentSymbol->GetPosition() );
1307 return;
1308 }
1309
1310 SetTextPos( aPosition );
1311}
1312
1313
1315{
1316 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
1317 {
1318 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
1319 VECTOR2I relativePos = GetTextPos() - parentSymbol->GetPosition();
1320
1321 relativePos = parentSymbol->GetTransform().TransformCoordinate( relativePos );
1322
1323 return relativePos + parentSymbol->GetPosition();
1324 }
1325
1326 return GetTextPos();
1327}
1328
1329
1331{
1332 return m_parent ? m_parent->GetPosition() : VECTOR2I( 0, 0 );
1333}
1334
1335
1337{
1338 return m_id == FIELD_T::REFERENCE
1339 || m_id == FIELD_T::VALUE
1340 || m_id == FIELD_T::FOOTPRINT
1341 || m_id == FIELD_T::DATASHEET
1342 || m_id == FIELD_T::DESCRIPTION
1343 || m_id == FIELD_T::SHEET_NAME
1344 || m_id == FIELD_T::SHEET_FILENAME
1345 || m_id == FIELD_T::INTERSHEET_REFS;
1346}
1347
1348
1349bool SCH_FIELD::operator<( const SCH_ITEM& aItem ) const
1350{
1351 if( Type() != aItem.Type() )
1352 return Type() < aItem.Type();
1353
1354 auto field = static_cast<const SCH_FIELD*>( &aItem );
1355
1356 if( GetId() != field->GetId() )
1357 return GetId() < field->GetId();
1358
1359 if( GetText() != field->GetText() )
1360 return GetText() < field->GetText();
1361
1362 if( GetLibPosition().x != field->GetLibPosition().x )
1363 return GetLibPosition().x < field->GetLibPosition().x;
1364
1365 if( GetLibPosition().y != field->GetLibPosition().y )
1366 return GetLibPosition().y < field->GetLibPosition().y;
1367
1368 return GetName() < field->GetName();
1369}
1370
1371
1372bool SCH_FIELD::operator==(const SCH_ITEM& aOther) const
1373{
1374 if( Type() != aOther.Type() )
1375 return false;
1376
1377 const SCH_FIELD& field = static_cast<const SCH_FIELD&>( aOther );
1378
1379 return *this == field;
1380}
1381
1382
1383bool SCH_FIELD::operator==( const SCH_FIELD& aOther ) const
1384{
1385 // Identical fields of different symbols are not equal.
1386 if( !GetParentSymbol() || !aOther.GetParentSymbol()
1387 || GetParentSymbol()->m_Uuid != aOther.GetParentSymbol()->m_Uuid )
1388 {
1389 return false;
1390 }
1391
1392 if( IsMandatory() != aOther.IsMandatory() )
1393 return false;
1394
1395 if( IsMandatory() )
1396 {
1397 if( GetId() != aOther.GetId() )
1398 return false;
1399 }
1400 else
1401 {
1402 if( GetOrdinal() != aOther.GetOrdinal() )
1403 return false;
1404 }
1405
1406 if( GetPosition() != aOther.GetPosition() )
1407 return false;
1408
1409 if( IsNamedVariable() != aOther.IsNamedVariable() )
1410 return false;
1411
1412 if( IsNameShown() != aOther.IsNameShown() )
1413 return false;
1414
1415 if( CanAutoplace() != aOther.CanAutoplace() )
1416 return false;
1417
1418 return EDA_TEXT::operator==( aOther );
1419}
1420
1421
1422double SCH_FIELD::Similarity( const SCH_ITEM& aOther ) const
1423{
1424 if( Type() != aOther.Type() )
1425 return 0.0;
1426
1427 if( m_Uuid == aOther.m_Uuid )
1428 return 1.0;
1429
1430 const SCH_FIELD& field = static_cast<const SCH_FIELD&>( aOther );
1431
1432 double similarity = 0.99; // The UUIDs are different, so we start with non-identity
1433
1434 if( GetId() != field.GetId() )
1435 {
1436 // We don't allow swapping of mandatory fields, so these cannot be the same item
1437 if( IsMandatory() || field.IsMandatory() )
1438 return 0.0;
1439 else
1440 similarity *= 0.5;
1441 }
1442
1443 similarity *= SimilarityBase( aOther );
1444
1445 similarity *= EDA_TEXT::Similarity( field );
1446
1447 if( GetPosition() != field.GetPosition() )
1448 similarity *= 0.5;
1449
1450 if( IsNamedVariable() != field.IsNamedVariable() )
1451 similarity *= 0.5;
1452
1453 if( IsNameShown() != field.IsNameShown() )
1454 similarity *= 0.5;
1455
1456 if( CanAutoplace() != field.CanAutoplace() )
1457 similarity *= 0.5;
1458
1459 return similarity;
1460}
1461
1462
1463int SCH_FIELD::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
1464{
1465 wxASSERT( aOther.Type() == SCH_FIELD_T );
1466
1467 int compareFlags = aCompareFlags;
1468
1469 // For ERC tests, the field position has no matter, so do not test it
1470 if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC )
1472
1473 int retv = SCH_ITEM::compare( aOther, compareFlags );
1474
1475 if( retv )
1476 return retv;
1477
1478 const SCH_FIELD* tmp = static_cast<const SCH_FIELD*>( &aOther );
1479
1480 // Equality test will vary depending whether or not the field is mandatory. Otherwise,
1481 // sorting is done by ordinal.
1482 if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
1483 {
1484 // Mandatory fields have fixed ordinals and their names can vary due to translated field
1485 // names. Optional fields have fixed names and their ordinals can vary.
1486 if( IsMandatory() )
1487 {
1488 if( m_id != tmp->m_id )
1489 return (int) m_id - (int) tmp->m_id;
1490 }
1491 else
1492 {
1493 retv = m_name.Cmp( tmp->m_name );
1494
1495 if( retv )
1496 return retv;
1497 }
1498 }
1499 else // assume we're sorting
1500 {
1501 if( m_id != tmp->m_id )
1502 return (int) m_id - (int) tmp->m_id;
1503 }
1504
1505 bool ignoreFieldText = false;
1506
1507 if( m_id == FIELD_T::REFERENCE && !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) )
1508 ignoreFieldText = true;
1509
1510 if( m_id == FIELD_T::VALUE && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
1511 ignoreFieldText = true;
1512
1513 if( !ignoreFieldText )
1514 {
1515 retv = GetText().CmpNoCase( tmp->GetText() );
1516
1517 if( retv != 0 )
1518 return retv;
1519 }
1520
1521 if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
1522 {
1523 if( GetTextPos().x != tmp->GetTextPos().x )
1524 return GetTextPos().x - tmp->GetTextPos().x;
1525
1526 if( GetTextPos().y != tmp->GetTextPos().y )
1527 return GetTextPos().y - tmp->GetTextPos().y;
1528 }
1529
1530 // For ERC tests, the field size has no matter, so do not test it
1531 if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
1532 {
1533 if( GetTextWidth() != tmp->GetTextWidth() )
1534 return GetTextWidth() - tmp->GetTextWidth();
1535
1536 if( GetTextHeight() != tmp->GetTextHeight() )
1537 return GetTextHeight() - tmp->GetTextHeight();
1538 }
1539
1540 return 0;
1541}
1542
1543
1544static struct SCH_FIELD_DESC
1545{
1547 {
1548 // These are defined in EDA_TEXT as well but initialization order is
1549 // not defined, so this needs to be conditional. Defining in both
1550 // places leads to duplicate symbols.
1552
1553 if( h_inst.Choices().GetCount() == 0)
1554 {
1555 h_inst.Map( GR_TEXT_H_ALIGN_LEFT, _( "Left" ) );
1556 h_inst.Map( GR_TEXT_H_ALIGN_CENTER, _( "Center" ) );
1557 h_inst.Map( GR_TEXT_H_ALIGN_RIGHT, _( "Right" ) );
1558 }
1559
1561
1562 if( v_inst.Choices().GetCount() == 0)
1563 {
1564 v_inst.Map( GR_TEXT_V_ALIGN_TOP, _( "Top" ) );
1565 v_inst.Map( GR_TEXT_V_ALIGN_CENTER, _( "Center" ) );
1566 v_inst.Map( GR_TEXT_V_ALIGN_BOTTOM, _( "Bottom" ) );
1567 }
1568
1575
1576 const wxString textProps = _HKI( "Text Properties" );
1577
1579 _HKI( "Horizontal Justification" ), &SCH_FIELD::SetEffectiveHorizJustify,
1581
1582 propMgr.ReplaceProperty( TYPE_HASH( EDA_TEXT ), _HKI( "Horizontal Justification" ), horiz,
1583 textProps );
1584
1586 _HKI( "Vertical Justification" ), &SCH_FIELD::SetEffectiveVertJustify,
1588
1589 propMgr.ReplaceProperty( TYPE_HASH( EDA_TEXT ), _HKI( "Vertical Justification" ), vert,
1590 textProps );
1591
1592 propMgr.AddProperty( new PROPERTY<SCH_FIELD, bool>( _HKI( "Show Field Name" ),
1594
1595 propMgr.AddProperty( new PROPERTY<SCH_FIELD, bool>( _HKI( "Allow Autoplacement" ),
1597
1598 propMgr.Mask( TYPE_HASH( SCH_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) );
1599 propMgr.Mask( TYPE_HASH( SCH_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
1600 propMgr.Mask( TYPE_HASH( SCH_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) );
1601 propMgr.Mask( TYPE_HASH( SCH_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
1602 propMgr.Mask( TYPE_HASH( SCH_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
1603
1604
1605 propMgr.AddProperty( new PROPERTY<SCH_FIELD, int>( _HKI( "Text Size" ),
1606 &SCH_FIELD::SetSchTextSize, &SCH_FIELD::GetSchTextSize, PROPERTY_DISPLAY::PT_SIZE ),
1607 _HKI( "Text Properties" ) );
1608
1609 propMgr.Mask( TYPE_HASH( SCH_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
1610
1611 auto isNotNamedVariable =
1612 []( INSPECTABLE* aItem ) -> bool
1613 {
1614 if( SCH_FIELD* field = dynamic_cast<SCH_FIELD*>( aItem ) )
1615 return !field->IsNamedVariable();
1616
1617 return true;
1618 };
1619
1621 isNotNamedVariable );
1622
1623
1624 auto isNonMandatoryField =
1625 []( INSPECTABLE* aItem ) -> bool
1626 {
1627 if( SCH_FIELD* field = dynamic_cast<SCH_FIELD*>( aItem ) )
1628 return !field->IsMandatory();
1629
1630 return false;
1631 };
1632
1634 _HKI( "Private" ), isNonMandatoryField );
1635 }
1637
1638
int color
Definition: DXF_plotter.cpp:60
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr const Vec GetEnd() const
Definition: box2.h:212
constexpr void SetOrigin(const Vec &pos)
Definition: box2.h:237
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
constexpr Vec Centre() const
Definition: box2.h:97
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: box2.h:138
constexpr const Vec & GetOrigin() const
Definition: box2.h:210
constexpr void SetEnd(coord_type x, coord_type y)
Definition: box2.h:297
constexpr void Offset(coord_type dx, coord_type dy)
Definition: box2.h:259
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
bool IsHorizontal() const
Definition: eda_angle.h:138
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:95
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:248
const KIID m_Uuid
Definition: eda_item.h:494
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:107
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:505
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:382
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:180
EDA_ITEM * GetParent() const
Definition: eda_item.h:109
EDA_ITEM * m_parent
Linked list: Link (parent struct).
Definition: eda_item.h:506
bool IsForceVisible() const
Definition: eda_item.h:199
static bool Replace(const EDA_SEARCH_DATA &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
Definition: eda_item.cpp:208
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
int GetTextHeight() const
Definition: eda_text.h:254
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:260
COLOR4D GetTextColor() const
Definition: eda_text.h:257
wxString GetTextStyleName() const
Definition: eda_text.cpp:965
bool IsItalic() const
Definition: eda_text.h:156
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
virtual bool IsVisible() const
Definition: eda_text.h:174
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:571
void SetTextX(int aX)
Definition: eda_text.cpp:577
KIFONT::FONT * GetFont() const
Definition: eda_text.h:234
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:426
BOX2I GetTextBox(int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:723
void SetTextY(int aY)
Definition: eda_text.cpp:583
EDA_TEXT & operator=(const EDA_TEXT &aItem)
Definition: eda_text.cpp:154
int GetTextWidth() const
Definition: eda_text.h:251
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:410
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:187
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:479
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:379
virtual void ClearBoundingBoxCache()
Definition: eda_text.cpp:657
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1279
virtual void ClearRenderCache()
Definition: eda_text.cpp:651
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:218
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:458
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:445
bool IsBold() const
Definition: eda_text.h:171
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:190
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:109
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:270
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:292
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:438
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:382
VECTOR2I GetTextSize() const
Definition: eda_text.h:248
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:402
static ENUM_MAP< T > & Instance()
Definition: property.h:680
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:37
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition: font.cpp:147
virtual bool IsOutline() const
Definition: font.h:139
Class OUTLINE_FONT implements outline font drawing.
Definition: outline_font.h:53
void GetLinesAsGlyphs(std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs, const METRICS &aFontMetrics) const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
int GetDefaultPenWidth() const
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Define a library symbol object.
Definition: lib_symbol.h:85
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
Definition: lib_symbol.cpp:534
static wxString LetterSubReference(int aUnit, int aFirstId)
Definition: lib_symbol.cpp:515
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
A singleton reporter that reports to nowhere.
Definition: reporter.h:204
Base plotter engine class.
Definition: plotter.h:105
bool GetColorMode() const
Definition: plotter.h:133
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
Definition: plotter.cpp:754
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:470
virtual std::map< wxString, wxString > & GetTextVars() const
Definition: project.cpp:95
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void OverrideWriteability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override writeability functor for a base class property of a given derived class.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Definition: schematic.h:69
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:84
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:208
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
Definition: schematic.cpp:247
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:148
void ClearRenderCache() override
Definition: sch_field.cpp:345
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_field.cpp:1463
COLOR4D m_lastResolvedColor
Definition: sch_field.h:352
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:627
bool IsMandatory() const
Definition: sch_field.cpp:1336
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_field.cpp:963
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_field.cpp:872
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: sch_field.cpp:306
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:499
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_renderCache
Definition: sch_field.h:350
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:407
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1314
void SetEffectiveHorizJustify(GR_TEXT_H_ALIGN_T)
Definition: sch_field.cpp:550
int GetSchTextSize() const
Definition: sch_field.h:171
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData=nullptr) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
Definition: sch_field.cpp:825
bool m_showName
Render the field name in addition to its value.
Definition: sch_field.h:340
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
Definition: sch_field.cpp:1183
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_field.cpp:167
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_field.cpp:1114
bool IsNameShown() const
Definition: sch_field.h:208
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.h:96
bool m_autoAdded
Was this field automatically added to a LIB_SYMBOL?
Definition: sch_field.h:345
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_field.cpp:1422
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_field.cpp:1131
SCH_LAYER_ID GetDefaultLayer() const
Definition: sch_field.cpp:453
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:527
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:584
EDA_ANGLE GetDrawRotation() const override
Adjusters to allow EDA_TEXT to draw/print/etc.
Definition: sch_field.cpp:477
void SetEffectiveVertJustify(GR_TEXT_V_ALIGN_T)
Definition: sch_field.cpp:607
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_field.cpp:957
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_field.cpp:641
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_field.cpp:939
FIELD_T GetId() const
Definition: sch_field.h:124
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:220
bool m_isNamedVariable
If the field name is a variable name, e.g.
Definition: sch_field.h:342
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_field.cpp:1010
int GetPenWidth() const override
Definition: sch_field.cpp:321
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:1098
int m_ordinal
Sort order for non-mandatory fields.
Definition: sch_field.h:337
COLOR4D GetFieldColor() const
Definition: sch_field.cpp:427
bool IsNamedVariable() const
Named variables are fields whose names are variables like ${VAR}.
Definition: sch_field.h:217
bool operator==(const SCH_ITEM &aItem) const override
Definition: sch_field.cpp:1372
SCH_FIELD & operator=(const SCH_FIELD &aField)
Definition: sch_field.cpp:136
void ImportValues(const SCH_FIELD &aSource)
Copy parameters from a SCH_FIELD source.
Definition: sch_field.cpp:398
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_field.cpp:1349
FIELD_T m_id
Field id,.
Definition: sch_field.h:336
wxString GetShownName() const
Get the field's name as displayed on the schematic or in the symbol fields table.
Definition: sch_field.cpp:186
VECTOR2I GetLibPosition() const
Definition: sch_field.h:266
void setId(FIELD_T aId)
Definition: sch_field.cpp:179
int GetOrdinal() const
Definition: sch_field.h:126
bool IsEmpty()
Return true if both the name and value of the field are empty.
Definition: sch_field.h:163
bool m_renderCacheValid
Definition: sch_field.h:348
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: sch_field.cpp:951
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_field.cpp:815
void SetSchTextSize(int aSize)
Definition: sch_field.h:172
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:570
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition: sch_field.cpp:447
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1084
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1294
void SetName(const wxString &aName)
Definition: sch_field.cpp:1059
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_field.cpp:192
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_field.h:239
VECTOR2I m_renderCachePos
Definition: sch_field.h:349
bool CanAutoplace() const
Definition: sch_field.h:219
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) const
Definition: sch_field.cpp:353
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: sch_field.cpp:971
void ClearCaches() override
Definition: sch_field.cpp:338
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1069
VECTOR2I GetParentPosition() const
Definition: sch_field.cpp:1330
bool m_showInChooser
This field is available as a data column for the chooser.
Definition: sch_field.h:346
void OnScintillaCharAdded(SCINTILLA_TRICKS *aScintillaTricks, wxStyledTextEvent &aEvent) const
Definition: sch_field.cpp:697
wxString m_name
Definition: sch_field.h:338
void SetNameShown(bool aShown=true)
Definition: sch_field.h:209
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_field.cpp:927
void Copy(SCH_FIELD *aTarget) const
Copy parameters of this field to another field.
Definition: sch_field.cpp:173
KIFONT::FONT * getDrawFont() const override
Definition: sch_field.cpp:327
bool m_allowAutoPlace
This field can be autoplaced.
Definition: sch_field.h:341
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Definition: sch_label.cpp:1854
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:103
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:480
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:657
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:172
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:156
@ SKIP_TST_POS
Definition: sch_item.h:640
@ EQUALITY
Definition: sch_item.h:638
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:253
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:296
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:295
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_item.cpp:441
bool IsConnectivityDirty() const
Definition: sch_item.h:527
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:376
bool m_private
Definition: sch_item.h:713
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:489
SCH_LAYER_ID m_layer
Definition: sch_item.h:710
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
Definition: sch_item.h:332
void GetIntersheetRefs(const SCH_SHEET_PATH *aPath, std::vector< std::pair< wxString, wxString > > *pages)
Build an array of { pageNumber, pageName } pairs.
Definition: sch_label.cpp:638
virtual bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const
Resolve any references to system tokens supported by the label.
Definition: sch_label.cpp:693
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:202
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this label.
Definition: sch_label.cpp:675
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Definition: sch_label.cpp:356
Handle actions specific to the schematic editor.
static wxString g_BackLink
void HypertextCommand(const wxString &aHref)
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
size_t GetCount() const
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:47
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
Definition: sch_sheet.cpp:177
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this sheet.
Definition: sch_sheet.cpp:385
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:220
Schematic symbol object.
Definition: sch_symbol.h:75
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:730
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:653
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:771
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:739
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:434
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition: sch_symbol.cpp:611
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
wxStyledTextCtrl * Scintilla() const
void DoAutocomplete(const wxString &aPartial, const wxArrayString &aTokens)
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
virtual std::vector< std::string > GetPinNames() const
Definition: sim_model.h:462
const TRANSFORM & GetTransform() const
Definition: symbol.h:197
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
int y1
Definition: transform.h:49
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:59
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:44
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition: common.cpp:59
wxString GetTextVars(const wxString &aSource)
Returns any variables unexpanded, e.g.
Definition: common.cpp:121
The common library.
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:398
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:406
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
int m_ResolveTextRecursionDepth
The number of recursions to resolve text variables.
@ USER
The main config directory (e.g. ~/.config/kicad/)
PROJECT & Prj()
Definition: kicad.cpp:597
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:438
@ LAYER_SHEETNAME
Definition: layer_ids.h:461
@ LAYER_VALUEPART
Definition: layer_ids.h:450
@ LAYER_FIELDS
Definition: layer_ids.h:451
@ LAYER_SHEETFIELDS
Definition: layer_ids.h:463
@ LAYER_REFERENCEPART
Definition: layer_ids.h:449
@ LAYER_NETCLASS_REFS
Definition: layer_ids.h:453
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:483
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:452
@ LAYER_SHEETFILENAME
Definition: layer_ids.h:462
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:215
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Definition: ui_common.cpp:197
static GR_TEXT_H_ALIGN_T horizJustify(const char *horizontal)
#define TYPE_HASH(x)
Definition: property.h:71
#define DECLARE_ENUM_TO_WXANY(type)
Definition: property.h:746
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
static const std::vector< KICAD_T > labelTypes
Definition: sch_field.cpp:44
static struct SCH_FIELD_DESC _SCH_FIELD_DESC
wxString UnescapeString(const wxString &aSource)
bool IsURL(wxString aStr)
Performs a URL sniff-test on a string.
Definition for symbol library class.
wxString GetDefaultFieldName(FIELD_T aFieldId, bool aTranslateForHI)
Return a default symbol field name for a mandatory field type.
#define DO_TRANSLATE
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
wxString GetCanonicalFieldName(FIELD_T aFieldType)
VECTOR2I end
constexpr int delta
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:229
@ LIB_SYMBOL_T
Definition: typeinfo.h:148
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:190
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:46
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695