KiCad PCB EDA Suite
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 (C) 2004-2022 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/*
26 * Fields are texts attached to a symbol, some of which have a special meaning.
27 * Fields 0 and 1 are very important: reference and value.
28 * Field 2 is used as default footprint name.
29 * Field 3 is used to point to a datasheet (usually a URL).
30 * Fields 4+ are user fields. They can be renamed and can appear in reports.
31 */
32
33#include <wx/log.h>
34#include <wx/menu.h>
35#include <base_units.h>
36#include <common.h> // for ExpandTextVars
37#include <eda_item.h>
38#include <sch_edit_frame.h>
39#include <plotters/plotter.h>
40#include <bitmaps.h>
41#include <core/kicad_algo.h>
42#include <core/mirror.h>
43#include <kiway.h>
44#include <general.h>
45#include <symbol_library.h>
46#include <sch_symbol.h>
47#include <sch_field.h>
48#include <sch_label.h>
49#include <schematic.h>
51#include <string_utils.h>
52#include <trace_helpers.h>
53#include <trigo.h>
54#include <eeschema_id.h>
55#include <tool/tool_manager.h>
57#include <font/outline_font.h>
58
59SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent,
60 const wxString& aName ) :
61 SCH_ITEM( aParent, SCH_FIELD_T ),
62 EDA_TEXT( schIUScale, wxEmptyString ),
63 m_id( 0 ),
64 m_name( aName ),
65 m_showName( false ),
66 m_allowAutoPlace( true ),
67 m_renderCacheValid( false ),
68 m_lastResolvedColor( COLOR4D::UNSPECIFIED )
69{
70 SetTextPos( aPos );
71 SetId( aFieldId ); // will also set the layer
72 SetVisible( false );
73}
74
75
77 SCH_ITEM( aField ),
78 EDA_TEXT( aField )
79{
80 m_id = aField.m_id;
81 m_name = aField.m_name;
82 m_showName = aField.m_showName;
84
85 m_renderCache.clear();
86
87 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
88 {
89 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
90 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
91 }
92
95
97}
98
99
101{
102 EDA_TEXT::operator=( aField );
103
104 m_id = aField.m_id;
105 m_name = aField.m_name;
106 m_showName = aField.m_showName;
108
109 m_renderCache.clear();
110
111 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
112 {
113 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
114 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
115 }
116
119
121
122 return *this;
123}
124
125
127{
128 return new SCH_FIELD( *this );
129}
130
131
132void SCH_FIELD::SetId( int aId )
133{
134 m_id = aId;
135
136 if( m_parent && m_parent->Type() == SCH_SHEET_T )
137 {
138 switch( m_id )
139 {
140 case SHEETNAME: SetLayer( LAYER_SHEETNAME ); break;
142 default: SetLayer( LAYER_SHEETFIELDS ); break;
143 }
144 }
145 else if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
146 {
147 switch( m_id )
148 {
150 case VALUE_FIELD: SetLayer( LAYER_VALUEPART ); break;
151 default: SetLayer( LAYER_FIELDS ); break;
152 }
153 }
154 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
155 {
156 // We can't use defined IDs for labels because there can be multiple net class
157 // assignments.
158
159 if( GetCanonicalName() == wxT( "Netclass" ) )
161 else if( GetCanonicalName() == wxT( "Intersheetrefs" ) )
163 else
165 }
166}
167
168
169wxString SCH_FIELD::GetShownText( int aDepth ) const
170{
171 std::function<bool( wxString* )> symbolResolver =
172 [&]( wxString* token ) -> bool
173 {
174 if( token->Contains( ':' ) )
175 {
176 if( Schematic()->ResolveCrossReference( token, aDepth ) )
177 return true;
178 }
179 else
180 {
181 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
182
183 if( parentSymbol->ResolveTextVar( token, aDepth + 1 ) )
184 return true;
185
186 SCHEMATIC* schematic = parentSymbol->Schematic();
187 SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
188
189 if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
190 return true;
191 }
192
193 return false;
194 };
195
196 std::function<bool( wxString* )> sheetResolver =
197 [&]( wxString* token ) -> bool
198 {
199 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
200 return sheet->ResolveTextVar( token, aDepth + 1 );
201 };
202
203 std::function<bool( wxString* )> labelResolver =
204 [&]( wxString* token ) -> bool
205 {
206 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
207 return label->ResolveTextVar( token, aDepth + 1 );
208 };
209
210 PROJECT* project = nullptr;
211 wxString text = EDA_TEXT::GetShownText();
212
213 if( IsNameShown() )
214 text = GetName() << wxS( ": " ) << text;
215
216 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
217 {
218 text = wxS( "" );
219 }
220 else if( HasTextVars() )
221 {
222 if( Schematic() )
223 project = &Schematic()->Prj();
224
225 if( aDepth < 10 )
226 {
227 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
228 text = ExpandTextVars( text, &symbolResolver, nullptr, project );
229 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
230 text = ExpandTextVars( text, &sheetResolver, nullptr, project );
231 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
232 text = ExpandTextVars( text, &labelResolver, nullptr, project );
233 else
235 }
236 }
237
238 // WARNING: the IDs of FIELDS and SHEETS overlap, so one must check *both* the
239 // id and the parent's type.
240
241 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
242 {
243 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
244
245 if( m_id == REFERENCE_FIELD )
246 {
247 // For more than one part per package, we must add the part selection
248 // A, B, ... or 1, 2, .. to the reference.
249 if( parentSymbol->GetUnitCount() > 1 )
250 text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
251 }
252 }
253 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
254 {
255 if( m_id == SHEETFILENAME )
256 text = _( "File:" ) + wxS( " " )+ text;
257 }
258
259 return text;
260}
261
262
264{
266}
267
268
270{
272
273 if( !font )
275
276 return font;
277}
278
279
281{
284}
285
286
288{
290 m_renderCacheValid = false;
291}
292
293
294std::vector<std::unique_ptr<KIFONT::GLYPH>>*
295SCH_FIELD::GetRenderCache( const wxString& forResolvedText, const VECTOR2I& forPosition,
296 TEXT_ATTRIBUTES& aAttrs ) const
297{
298 if( GetDrawFont()->IsOutline() )
299 {
300 if( m_renderCache.empty() || !m_renderCacheValid )
301 {
302 m_renderCache.clear();
303
304 KIFONT::OUTLINE_FONT* font = static_cast<KIFONT::OUTLINE_FONT*>( GetDrawFont() );
305 font->GetLinesAsGlyphs( &m_renderCache, forResolvedText, forPosition, aAttrs );
306
307 m_renderCachePos = forPosition;
308 m_renderCacheValid = true;
309 }
310
311 if( m_renderCachePos != forPosition )
312 {
313 VECTOR2I delta = forPosition - m_renderCachePos;
314
315 for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_renderCache )
316 static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( delta );
317
318 m_renderCachePos = forPosition;
319 }
320
321 return &m_renderCache;
322 }
323
324 return nullptr;
325}
326
327
328void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
329{
330 wxDC* DC = aSettings->GetPrintDC();
332 bool blackAndWhiteMode = GetGRForceBlackPenState();
333 VECTOR2I textpos;
334 int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
335
336 if( ( !IsVisible() && !IsForceVisible() ) || IsVoid() )
337 return;
338
339 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
341
342 // Calculate the text orientation according to the symbol orientation.
343 EDA_ANGLE orient = GetTextAngle();
344
345 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
346 {
347 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
348
349 if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
350 {
351 if( orient == ANGLE_HORIZONTAL )
352 orient = ANGLE_VERTICAL;
353 else
354 orient = ANGLE_HORIZONTAL;
355 }
356 }
357
358 /*
359 * Calculate the text justification, according to the symbol orientation/mirror.
360 * This is a bit complicated due to cumulative calculations:
361 * - numerous cases (mirrored or not, rotation)
362 * - the GRText function will also recalculate H and V justifications according to the text
363 * orientation.
364 * - When a symbol is mirrored, the text is not mirrored and justifications are complicated
365 * to calculate so the more easily way is to use no justifications (centered text) and use
366 * GetBoundingBox to know the text coordinate considered as centered
367 */
368 textpos = GetBoundingBox().Centre() + aOffset;
369
372}
373
374
375void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
376{
377 SetAttributes( aSource );
378 SetNameShown( aSource.IsNameShown() );
379 SetCanAutoplace( aSource.CanAutoplace() );
380}
381
382
384{
385 wxCHECK_RET( ( aItem != nullptr ) && ( aItem->Type() == SCH_FIELD_T ),
386 wxT( "Cannot swap field data with invalid item." ) );
387
388 SCH_FIELD* item = (SCH_FIELD*) aItem;
389
390 std::swap( m_layer, item->m_layer );
391 std::swap( m_showName, item->m_showName );
392 std::swap( m_allowAutoPlace, item->m_allowAutoPlace );
393 SwapText( *item );
394 SwapAttributes( *item );
395
396 std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
397}
398
399
401{
402 if( GetTextColor() != COLOR4D::UNSPECIFIED )
403 {
405 }
406 else
407 {
408 SCH_LABEL_BASE* parentLabel = dynamic_cast<SCH_LABEL_BASE*>( GetParent() );
409
410 if( parentLabel && !parentLabel->IsConnectivityDirty() )
411 m_lastResolvedColor = parentLabel->GetEffectiveNetClass()->GetSchematicColor();
412 }
413
414 return m_lastResolvedColor;
415}
416
417
419{
420 // Calculate the text orientation according to the symbol orientation.
421 EDA_ANGLE orient = GetTextAngle();
422
423 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
424 {
425 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
426
427 if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
428 {
429 if( orient.IsHorizontal() )
430 orient = ANGLE_VERTICAL;
431 else
432 orient = ANGLE_HORIZONTAL;
433 }
434 }
435
436 return orient;
437}
438
439
441{
442 // Calculate the text bounding box:
443 BOX2I bbox = GetTextBox();
444
445 // Calculate the bounding box position relative to the parent:
446 VECTOR2I origin = GetParentPosition();
447 VECTOR2I pos = GetTextPos() - origin;
448 VECTOR2I begin = bbox.GetOrigin() - origin;
449 VECTOR2I end = bbox.GetEnd() - origin;
450 RotatePoint( begin, pos, GetTextAngle() );
451 RotatePoint( end, pos, GetTextAngle() );
452
453 // Now, apply the symbol transform (mirror/rot)
454 TRANSFORM transform;
455
456 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
457 {
458 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
459
460 // Due to the Y axis direction, we must mirror the bounding box,
461 // relative to the text position:
462 MIRROR( begin.y, pos.y );
463 MIRROR( end.y, pos.y );
464
465 transform = parentSymbol->GetTransform();
466 }
467 else
468 {
469 transform = TRANSFORM( 1, 0, 0, 1 ); // identity transform
470 }
471
472 bbox.SetOrigin( transform.TransformCoordinate( begin ) );
473 bbox.SetEnd( transform.TransformCoordinate( end ) );
474
475 bbox.Move( origin );
476 bbox.Normalize();
477
478 return bbox;
479}
480
481
483{
484 VECTOR2I render_center = GetBoundingBox().Centre();
485 VECTOR2I pos = GetPosition();
486
487 switch( GetHorizJustify() )
488 {
490 if( GetDrawRotation().IsVertical() )
491 return render_center.y > pos.y;
492 else
493 return render_center.x < pos.x;
495 if( GetDrawRotation().IsVertical() )
496 return render_center.y < pos.y;
497 else
498 return render_center.x > pos.x;
499 default:
500 return false;
501 }
502}
503
504
506{
507 switch( GetHorizJustify() )
508 {
513 default:
515 }
516}
517
518
520{
521 VECTOR2I render_center = GetBoundingBox().Centre();
522 VECTOR2I pos = GetPosition();
523
524 switch( GetVertJustify() )
525 {
527 if( GetDrawRotation().IsVertical() )
528 return render_center.x < pos.x;
529 else
530 return render_center.y < pos.y;
532 if( GetDrawRotation().IsVertical() )
533 return render_center.x > pos.x;
534 else
535 return render_center.y > pos.y;
536 default:
537 return false;
538 }
539}
540
541
543{
544 switch( GetVertJustify() )
545 {
550 default:
552 }
553}
554
555
557{
558 return GetText().Len() == 0;
559}
560
561
562bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
563{
564 bool searchHiddenFields = false;
565 bool searchAndReplace = false;
566 bool replaceReferences = false;
567
568 try
569 {
570 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData ); // downcast
571 searchHiddenFields = schSearchData.searchAllFields;
572 searchAndReplace = schSearchData.searchAndReplace;
573 replaceReferences = schSearchData.replaceReferences;
574 }
575 catch( const std::bad_cast& )
576 {
577 }
578
579 wxString text = GetShownText();
580
581 if( !IsVisible() && !searchHiddenFields )
582 return false;
583
585 {
586 if( searchAndReplace && !replaceReferences )
587 return false;
588
589 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
590 wxASSERT( aAuxData );
591
592 // Take sheet path into account which effects the reference field and the unit for
593 // symbols with multiple parts.
594 if( aAuxData )
595 {
596 text = parentSymbol->GetRef((SCH_SHEET_PATH*) aAuxData );
597
598 if( SCH_ITEM::Matches( text, aSearchData ) )
599 return true;
600
601 if( parentSymbol->GetUnitCount() > 1 )
602 text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
603 }
604 }
605
606 return SCH_ITEM::Matches( text, aSearchData );
607}
608
609
611{
612 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
613 {
614 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
615
616 if( m_id == VALUE_FIELD )
617 {
618 if( parentSymbol->GetLibSymbolRef() && parentSymbol->GetLibSymbolRef()->IsPower() )
619 return false;
620 }
621 }
622 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
623 {
624 // See comments in SCH_FIELD::Replace(), below.
625 if( m_id == SHEETFILENAME )
626 return false;
627 }
628 else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
629 {
630 if( m_id == 0 /* IntersheetRefs */ )
631 return false;
632 }
633
634 return true;
635}
636
637
638bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
639{
640 bool replaceReferences = false;
641
642 try
643 {
644 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
645 replaceReferences = schSearchData.replaceReferences;
646 }
647 catch( const std::bad_cast& )
648 {
649 }
650
651 wxString text;
652 bool resolve = false; // Replace in source text, not shown text
653 bool isReplaced = false;
654
655 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
656 {
657 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
658
659 switch( m_id )
660 {
661 case REFERENCE_FIELD:
662 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
663
664 if( !replaceReferences )
665 return false;
666
667 text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
668 isReplaced = EDA_ITEM::Replace( aSearchData, text );
669
670 if( isReplaced )
671 parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
672
673 break;
674
675 case VALUE_FIELD:
676 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) );
677
678 text = parentSymbol->GetValue((SCH_SHEET_PATH*) aAuxData, resolve );
679 isReplaced = EDA_ITEM::Replace( aSearchData, text );
680
681 if( isReplaced )
682 parentSymbol->SetValue( (SCH_SHEET_PATH*) aAuxData, text );
683
684 break;
685
686 case FOOTPRINT_FIELD:
687 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) );
688
689 text = parentSymbol->GetFootprint((SCH_SHEET_PATH*) aAuxData, resolve );
690 isReplaced = EDA_ITEM::Replace( aSearchData, text );
691
692 if( isReplaced )
693 parentSymbol->SetFootprint( (SCH_SHEET_PATH*) aAuxData, text );
694
695 break;
696
697 default:
698 isReplaced = EDA_TEXT::Replace( aSearchData );
699 }
700 }
701 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
702 {
703 isReplaced = EDA_TEXT::Replace( aSearchData );
704
705 if( m_id == SHEETFILENAME && isReplaced )
706 {
707 // If we allowed this we'd have a bunch of work to do here, including warning
708 // about it not being undoable, checking for recursive hierarchies, reloading
709 // sheets, etc. See DIALOG_SHEET_PROPERTIES::TransferDataFromWindow().
710 }
711 }
712 else
713 {
714 isReplaced = EDA_TEXT::Replace( aSearchData );
715 }
716
717 return isReplaced;
718}
719
720
721void SCH_FIELD::Rotate( const VECTOR2I& aCenter )
722{
723 VECTOR2I pt = GetPosition();
724 RotatePoint( pt, aCenter, ANGLE_90 );
725 SetPosition( pt );
726}
727
728
729wxString SCH_FIELD::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
730{
732}
733
734
735void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
736{
737 wxString msg;
738
739 aList.emplace_back( _( "Symbol Field" ), GetName() );
740
741 // Don't use GetShownText() here; we want to show the user the variable references
742 aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
743
744 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
745
746 aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
747
748 aList.emplace_back( _( "Style" ), GetTextStyleName() );
749
750 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
751
752 switch ( GetHorizJustify() )
753 {
754 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
755 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
756 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
757 }
758
759 aList.emplace_back( _( "H Justification" ), msg );
760
761 switch ( GetVertJustify() )
762 {
763 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
764 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
765 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
766 }
767
768 aList.emplace_back( _( "V Justification" ), msg );
769}
770
771
773{
774 constexpr int START_ID = 1;
775
776 if( IsHypertext() )
777 {
778 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
779 std::vector<std::pair<wxString, wxString>> pages;
780 wxMenu menu;
781 wxString href;
782
783 label->GetIntersheetRefs( &pages );
784
785 for( int i = 0; i < (int) pages.size(); ++i )
786 {
787 menu.Append( i + START_ID, wxString::Format( _( "Go to Page %s (%s)" ),
788 pages[i].first,
789 pages[i].second ) );
790 }
791
792 menu.AppendSeparator();
793 menu.Append( 999 + START_ID, _( "Back to Previous Selected Sheet" ) );
794
795 int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
796
797 if( sel >= 0 && sel < (int) pages.size() )
798 href = wxT( "#" ) + pages[ sel ].first;
799 else if( sel == 999 )
801
802 if( !href.IsEmpty() )
803 {
805 navTool->HypertextCommand( href );
806 }
807 }
808}
809
810
811wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
812{
813 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
814 {
815 if( m_id >= 0 && m_id < MANDATORY_FIELDS )
817 else if( m_name.IsEmpty() && aUseDefaultName )
819 else
820 return m_name;
821 }
822 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
823 {
824 if( m_id >= 0 && m_id < SHEET_MANDATORY_FIELDS )
826 else if( m_name.IsEmpty() && aUseDefaultName )
828 else
829 return m_name;
830 }
831 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
832 {
833 return SCH_LABEL_BASE::GetDefaultFieldName( m_name, aUseDefaultName );
834 }
835 else
836 {
837 wxFAIL_MSG( "Unhandled field owner type." );
838 return m_name;
839 }
840}
841
842
844{
845 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
846 {
847 switch( m_id )
848 {
849 case REFERENCE_FIELD: return wxT( "Reference" );
850 case VALUE_FIELD: return wxT( "Value" );
851 case FOOTPRINT_FIELD: return wxT( "Footprint" );
852 case DATASHEET_FIELD: return wxT( "Datasheet" );
853 default: return m_name;
854 }
855 }
856 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
857 {
858 switch( m_id )
859 {
860 case SHEETNAME: return wxT( "Sheetname" );
861 case SHEETFILENAME: return wxT( "Sheetfile" );
862 default: return m_name;
863 }
864 }
865 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
866 {
867 // These should be stored in canonical format, but just in case:
868 if( m_name == _( "Net Class" ) )
869 return wxT( "Netclass" );
870 else if (m_name == _( "Sheet References" ) )
871 return wxT( "Intersheetrefs" );
872 else
873 return m_name;
874 }
875 else
876 {
877 if( m_parent )
878 {
879 wxFAIL_MSG( wxString::Format( "Unhandled field owner type (id %d, parent type %d).",
880 m_id, m_parent->Type() ) );
881 }
882
883 return m_name;
884 }
885}
886
887
889{
890 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
891 {
892 switch( m_id )
893 {
897 default: return BITMAPS::text;
898 }
899 }
900
901 return BITMAPS::text;
902}
903
904
905bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
906{
907 // Do not hit test hidden or empty fields.
908 if( !IsVisible() || IsVoid() )
909 return false;
910
911 BOX2I rect = GetBoundingBox();
912
913 rect.Inflate( aAccuracy );
914
915 if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
916 {
917 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
918 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
919 }
920
921 return rect.Contains( aPosition );
922}
923
924
925bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
926{
927 // Do not hit test hidden fields.
928 if( !IsVisible() || IsVoid() )
929 return false;
930
931 BOX2I rect = aRect;
932
933 rect.Inflate( aAccuracy );
934
935 if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
936 {
937 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
938 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
939 }
940
941 if( aContained )
942 return rect.Contains( GetBoundingBox() );
943
944 return rect.Intersects( GetBoundingBox() );
945}
946
947
948void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const
949{
950 if( IsVoid() || aBackground )
951 return;
952
953 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
954 COLOR4D color = settings->GetLayerColor( GetLayer() );
955 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
956
958
959 if( !aPlotter->GetColorMode() )
960 bg = COLOR4D::WHITE;
961
962 if( SCH_SYMBOL* parent = dyn_cast<SCH_SYMBOL*>( m_parent ); parent && parent->GetDNP() )
963 color = color.Mix( bg, 0.5f );
964
965 if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
967
968 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
969
970 if( !IsVisible() )
971 return;
972
973 // Calculate the text orientation, according to the symbol orientation/mirror
974 EDA_ANGLE orient = GetTextAngle();
975 VECTOR2I textpos = GetTextPos();
978
979 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
980 {
981 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
982
983 if( parentSymbol->GetDNP() )
984 color = color.Mix( bg, 0.5f );
985
986 if( parentSymbol->GetTransform().y1 ) // Rotate symbol 90 deg.
987 {
988 if( orient.IsHorizontal() )
989 orient = ANGLE_VERTICAL;
990 else
991 orient = ANGLE_HORIZONTAL;
992 }
993
994 /*
995 * Calculate the text justification, according to the symbol orientation/mirror. This is
996 * a bit complicated due to cumulative calculations:
997 * - numerous cases (mirrored or not, rotation)
998 * - the plotter's Text() function will also recalculate H and V justifications according
999 * to the text orientation
1000 * - when a symbol is mirrored the text is not, and justifications become a nightmare
1001 *
1002 * So the easier way is to use no justifications (centered text) and use GetBoundingBox to
1003 * know the text coordinate considered as centered.
1004 */
1005 hjustify = GR_TEXT_H_ALIGN_CENTER;
1006 vjustify = GR_TEXT_V_ALIGN_CENTER;
1007 textpos = GetBoundingBox().Centre();
1008 }
1009
1010 aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,
1011 penWidth, IsItalic(), IsBold(), false, GetDrawFont() );
1012
1013 if( IsHypertext() )
1014 {
1015 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
1016 std::vector<std::pair<wxString, wxString>> pages;
1017 std::vector<wxString> pageHrefs;
1018 BOX2I bbox = GetBoundingBox();
1019
1020 label->GetIntersheetRefs( &pages );
1021
1022 for( const std::pair<wxString, wxString>& page : pages )
1023 pageHrefs.push_back( wxT( "#" ) + page.first );
1024
1025 bbox.Offset( label->GetSchematicTextOffset( settings ) );
1026
1027 aPlotter->HyperlinkMenu( bbox, pageHrefs );
1028 }
1029}
1030
1031
1032void SCH_FIELD::SetPosition( const VECTOR2I& aPosition )
1033{
1034 // Actual positions are calculated by the rotation/mirror transform of the parent symbol
1035 // of the field. The inverse transform is used to calculate the position relative to the
1036 // parent symbol.
1037 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
1038 {
1039 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
1040 VECTOR2I relPos = aPosition - parentSymbol->GetPosition();
1041
1042 relPos = parentSymbol->GetTransform().InverseTransform().TransformCoordinate( relPos );
1043
1044 SetTextPos( relPos + parentSymbol->GetPosition() );
1045 return;
1046 }
1047
1048 SetTextPos( aPosition );
1049}
1050
1051
1053{
1054 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
1055 {
1056 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
1057 VECTOR2I relativePos = GetTextPos() - parentSymbol->GetPosition();
1058
1059 relativePos = parentSymbol->GetTransform().TransformCoordinate( relativePos );
1060
1061 return relativePos + parentSymbol->GetPosition();
1062 }
1063
1064 return GetTextPos();
1065}
1066
1067
1069{
1070 return m_parent ? m_parent->GetPosition() : VECTOR2I( 0, 0 );
1071}
1072
1073
1074bool SCH_FIELD::operator <( const SCH_ITEM& aItem ) const
1075{
1076 if( Type() != aItem.Type() )
1077 return Type() < aItem.Type();
1078
1079 auto field = static_cast<const SCH_FIELD*>( &aItem );
1080
1081 if( GetId() != field->GetId() )
1082 return GetId() < field->GetId();
1083
1084 if( GetText() != field->GetText() )
1085 return GetText() < field->GetText();
1086
1087 if( GetLibPosition().x != field->GetLibPosition().x )
1088 return GetLibPosition().x < field->GetLibPosition().x;
1089
1090 if( GetLibPosition().y != field->GetLibPosition().y )
1091 return GetLibPosition().y < field->GetLibPosition().y;
1092
1093 return GetName() < field->GetName();
1094}
int color
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
@ edit_comp_value
@ edit_comp_footprint
@ edit_comp_ref
void SetOrigin(const Vec &pos)
Definition: box2.h:202
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
const Vec & GetOrigin() const
Definition: box2.h:183
void Offset(coord_type dx, coord_type dy)
Definition: box2.h:224
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
const Vec GetEnd() const
Definition: box2.h:185
void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: box2.h:111
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
Vec Centre() const
Definition: box2.h:70
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
bool IsHorizontal() const
Definition: eda_angle.h:174
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:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
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:183
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496
bool IsForceVisible() const
Definition: eda_item.h:203
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:168
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:502
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:198
COLOR4D GetTextColor() const
Definition: eda_text.h:195
wxString GetTextStyleName() const
Definition: eda_text.cpp:730
bool IsItalic() const
Definition: eda_text.h:120
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:117
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
Definition: eda_text.cpp:264
virtual bool IsVisible() const
Definition: eda_text.h:126
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
KIFONT::FONT * GetFont() const
Definition: eda_text.h:178
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:95
EDA_TEXT & operator=(const EDA_TEXT &aItem)
Definition: eda_text.cpp:136
int GetTextWidth() const
Definition: eda_text.h:189
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:139
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:318
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:100
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
virtual void ClearBoundingBoxCache()
Definition: eda_text.cpp:444
virtual void ClearRenderCache()
Definition: eda_text.cpp:438
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
Definition: eda_text.cpp:284
bool IsBold() const
Definition: eda_text.h:123
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:142
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:273
VECTOR2I GetTextSize() const
Definition: eda_text.h:186
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
Class OUTLINE_FONT implements outline font drawing.
Definition: outline_font.h:50
void GetLinesAsGlyphs(std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs) const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Field object used in symbol libraries.
Definition: lib_field.h:60
bool CanAutoplace() const
Definition: lib_field.h:184
bool IsNameShown() const
Definition: lib_field.h:181
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:588
Base plotter engine class.
Definition: plotter.h:110
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
Definition: plotter.cpp:714
bool GetColorMode() const
Definition: plotter.h:138
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:446
Container for project specific data.
Definition: project.h:63
Holds all the data relating to one schematic.
Definition: schematic.h:60
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:259
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:50
void ClearRenderCache() override
Definition: sch_field.cpp:287
COLOR4D m_lastResolvedColor
Definition: sch_field.h:256
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:542
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:440
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_renderCache
Definition: sch_field.h:254
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
Definition: sch_field.cpp:948
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1052
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:638
bool m_showName
Render the field name in addition to its value.
Definition: sch_field.h:249
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_field.cpp:721
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_field.cpp:328
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_field.cpp:126
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_field.cpp:888
bool IsNameShown() const
Definition: sch_field.h:149
bool IsVoid() const
Definition: sch_field.cpp:556
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.h:92
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:905
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:482
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:519
EDA_ANGLE GetDrawRotation() const override
Adjusters to allow EDA_TEXT to draw/print/etc.
Definition: sch_field.cpp:418
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_field.cpp:562
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:169
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:153
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_field.cpp:772
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_field.cpp:729
KIFONT::FONT * GetDrawFont() const override
Definition: sch_field.cpp:269
int GetPenWidth() const override
Definition: sch_field.cpp:263
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:843
COLOR4D GetFieldColor() const
Definition: sch_field.cpp:400
int GetId() const
Definition: sch_field.h:116
SCH_FIELD & operator=(const SCH_FIELD &aField)
Definition: sch_field.cpp:100
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_field.cpp:1074
VECTOR2I GetLibPosition() const
Definition: sch_field.h:224
SCH_FIELD(const VECTOR2I &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:59
bool m_renderCacheValid
Definition: sch_field.h:252
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_field.cpp:610
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:505
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:811
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1032
void ImportValues(const LIB_FIELD &aSource)
Copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:375
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:383
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_field.h:184
VECTOR2I m_renderCachePos
Definition: sch_field.h:253
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) const
Definition: sch_field.cpp:295
void SetId(int aId)
Definition: sch_field.cpp:132
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:735
void ClearCaches() override
Definition: sch_field.cpp:280
VECTOR2I GetParentPosition() const
Definition: sch_field.cpp:1068
int m_id
Field index,.
Definition: sch_field.h:245
wxString m_name
Definition: sch_field.h:247
void SetNameShown(bool aShown=true)
Definition: sch_field.h:150
bool m_allowAutoPlace
This field can be autoplaced.
Definition: sch_field.h:250
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:1248
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:286
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:166
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:253
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:246
bool IsConnectivityDirty() const
Definition: sch_item.h:404
SCH_LAYER_ID m_layer
Definition: sch_item.h:482
void GetIntersheetRefs(std::vector< std::pair< wxString, wxString > > *pages)
Builds an array of { pageNumber, pageName } pairs.
Definition: sch_label.cpp:447
virtual bool ResolveTextVar(wxString *token, int aDepth) const
Definition: sch_label.cpp:480
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:183
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:274
Handle actions specific to the schematic editor.
static wxString g_BackLink
void HypertextCommand(const wxString &href)
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:55
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
Definition: sch_sheet.cpp:54
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:232
Schematic symbol object.
Definition: sch_symbol.h:79
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:429
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:679
int GetUnit() const
Definition: sch_symbol.h:225
const wxString GetFootprint(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific footprint assignment for the given sheet path.
Definition: sch_symbol.cpp:717
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:516
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:738
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
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:558
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:707
TRANSFORM & GetTransform()
Definition: sch_symbol.h:275
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific value for the given sheet path.
Definition: sch_symbol.cpp:651
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:189
bool GetDNP() const
Definition: sch_symbol.h:739
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:47
int y1
Definition: transform.h:50
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:56
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
@ WHITE
Definition: color4d.h:48
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:57
The common library.
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:409
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:156
void GRPrintText(wxDC *aDC, const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, KIFONT::FONT *aFont)
Print a graphic text through wxDC.
Definition: gr_text.cpp:129
@ LAYER_SHEETNAME
Definition: layer_ids.h:363
@ LAYER_HIDDEN
Definition: layer_ids.h:380
@ LAYER_VALUEPART
Definition: layer_ids.h:353
@ LAYER_FIELDS
Definition: layer_ids.h:354
@ LAYER_SHEETFIELDS
Definition: layer_ids.h:365
@ LAYER_REFERENCEPART
Definition: layer_ids.h:352
@ LAYER_NETCLASS_REFS
Definition: layer_ids.h:356
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:355
@ LAYER_SHEETFILENAME
Definition: layer_ids.h:364
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:203
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:47
@ SHEETNAME
Definition: sch_sheet.h:43
@ SHEETFILENAME
Definition: sch_sheet.h:44
wxString UnescapeString(const wxString &aSource)
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
Definition for symbol library class.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
constexpr int delta
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
GR_TEXT_V_ALIGN_T
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
@ SCH_SYMBOL_T
Definition: typeinfo.h:155
@ SCH_FIELD_T
Definition: typeinfo.h:154
@ SCH_SHEET_T
Definition: typeinfo.h:157
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:151
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618