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
76SCH_FIELD::SCH_FIELD( SCH_ITEM* aParent, int aFieldId, const wxString& aName ) :
77 SCH_FIELD( VECTOR2I(), aFieldId, aParent, aName )
78{
79}
80
81
83 SCH_ITEM( aField ),
84 EDA_TEXT( aField )
85{
86 m_id = aField.m_id;
87 m_name = aField.m_name;
88 m_showName = aField.m_showName;
90
91 m_renderCache.clear();
92
93 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
94 {
95 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
96 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
97 }
98
101
103}
104
105
107{
108 EDA_TEXT::operator=( aField );
109
110 m_id = aField.m_id;
111 m_name = aField.m_name;
112 m_showName = aField.m_showName;
114
115 m_renderCache.clear();
116
117 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
118 {
119 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
120 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
121 }
122
125
127
128 return *this;
129}
130
131
133{
134 return new SCH_FIELD( *this );
135}
136
137
138void SCH_FIELD::SetId( int aId )
139{
140 m_id = aId;
141
142 if( m_parent && m_parent->Type() == SCH_SHEET_T )
143 {
144 switch( m_id )
145 {
146 case SHEETNAME: SetLayer( LAYER_SHEETNAME ); break;
148 default: SetLayer( LAYER_SHEETFIELDS ); break;
149 }
150 }
151 else if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
152 {
153 switch( m_id )
154 {
156 case VALUE_FIELD: SetLayer( LAYER_VALUEPART ); break;
157 default: SetLayer( LAYER_FIELDS ); break;
158 }
159 }
160 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
161 {
162 // We can't use defined IDs for labels because there can be multiple net class
163 // assignments.
164
165 if( GetCanonicalName() == wxT( "Netclass" ) )
167 else if( GetCanonicalName() == wxT( "Intersheetrefs" ) )
169 else
171 }
172}
173
174
175wxString SCH_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const
176{
177 std::function<bool( wxString* )> symbolResolver =
178 [&]( wxString* token ) -> bool
179 {
180 return static_cast<SCH_SYMBOL*>( m_parent )->ResolveTextVar( token, aDepth + 1 );
181 };
182
183 std::function<bool( wxString* )> sheetResolver =
184 [&]( wxString* token ) -> bool
185 {
186 return static_cast<SCH_SHEET*>( m_parent )->ResolveTextVar( token, aDepth + 1 );
187 };
188
189 std::function<bool( wxString* )> labelResolver =
190 [&]( wxString* token ) -> bool
191 {
192 return static_cast<SCH_LABEL_BASE*>( m_parent )->ResolveTextVar( token, aDepth + 1 );
193 };
194
195 wxString text = EDA_TEXT::GetShownText();
196
197 if( IsNameShown() )
198 text = GetName() << wxS( ": " ) << text;
199
200 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
201 {
202 text = wxS( "" );
203 }
204 else if( HasTextVars() )
205 {
206 if( aDepth < 10 )
207 {
208 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
209 text = ExpandTextVars( text, &symbolResolver );
210 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
211 text = ExpandTextVars( text, &sheetResolver );
212 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
213 text = ExpandTextVars( text, &labelResolver );
214 else if( Schematic() )
216 }
217 }
218
219 // WARNING: the IDs of FIELDS and SHEETS overlap, so one must check *both* the
220 // id and the parent's type.
221
222 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
223 {
224 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
225
226 if( m_id == REFERENCE_FIELD )
227 {
228 // For more than one part per package, we must add the part selection
229 // A, B, ... or 1, 2, .. to the reference.
230 if( parentSymbol->GetUnitCount() > 1 )
231 text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
232 }
233 }
234 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
235 {
236 if( m_id == SHEETFILENAME && aAllowExtraText )
237 text = _( "File:" ) + wxS( " " )+ text;
238 }
239
240 return text;
241}
242
243
245{
247}
248
249
251{
253
254 if( !font )
256
257 return font;
258}
259
260
262{
265}
266
267
269{
271 m_renderCacheValid = false;
272}
273
274
275std::vector<std::unique_ptr<KIFONT::GLYPH>>*
276SCH_FIELD::GetRenderCache( const wxString& forResolvedText, const VECTOR2I& forPosition,
277 TEXT_ATTRIBUTES& aAttrs ) const
278{
279 KIFONT::FONT* font = GetFont();
280
281 if( !font )
283
284 if( font->IsOutline() )
285 {
286 KIFONT::OUTLINE_FONT* outlineFont = static_cast<KIFONT::OUTLINE_FONT*>( font );
287
288 if( m_renderCache.empty() || !m_renderCacheValid )
289 {
290 m_renderCache.clear();
291
292 outlineFont->GetLinesAsGlyphs( &m_renderCache, forResolvedText, forPosition, aAttrs );
293
294 m_renderCachePos = forPosition;
295 m_renderCacheValid = true;
296 }
297
298 if( m_renderCachePos != forPosition )
299 {
300 VECTOR2I delta = forPosition - m_renderCachePos;
301
302 for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_renderCache )
303 static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( delta );
304
305 m_renderCachePos = forPosition;
306 }
307
308 return &m_renderCache;
309 }
310
311 return nullptr;
312}
313
314
315void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
316{
317 wxDC* DC = aSettings->GetPrintDC();
319 bool blackAndWhiteMode = GetGRForceBlackPenState();
320 VECTOR2I textpos;
321 int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
322
323 if( ( !IsVisible() && !IsForceVisible() ) || GetShownText().IsEmpty() )
324 return;
325
326 COLOR4D bg = aSettings->GetBackgroundColor();
327
328 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
329 bg = COLOR4D::WHITE;
330
331 if( IsForceVisible() )
332 bg = aSettings->GetLayerColor( LAYER_HIDDEN );
333
334 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
336
337 // Calculate the text orientation according to the symbol orientation.
338 EDA_ANGLE orient = GetTextAngle();
339
340 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
341 {
342 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
343
344 if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
345 {
346 if( orient == ANGLE_HORIZONTAL )
347 orient = ANGLE_VERTICAL;
348 else
349 orient = ANGLE_HORIZONTAL;
350 }
351
352 if( parentSymbol && parentSymbol->GetDNP() )
353 {
354 color.Desaturate();
355 color = color.Mix( bg, 0.5f );
356 }
357 }
358
359 KIFONT::FONT* font = GetFont();
360
361 if( !font )
362 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
363
364 /*
365 * Calculate the text justification, according to the symbol orientation/mirror.
366 * This is a bit complicated due to cumulative calculations:
367 * - numerous cases (mirrored or not, rotation)
368 * - the GRText function will also recalculate H and V justifications according to the text
369 * orientation.
370 * - When a symbol is mirrored, the text is not mirrored and justifications are complicated
371 * to calculate so the more easily way is to use no justifications (centered text) and use
372 * GetBoundingBox to know the text coordinate considered as centered
373 */
374 textpos = GetBoundingBox().Centre() + aOffset;
375
377 GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), font );
378}
379
380
381void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
382{
383 SetAttributes( aSource );
384 SetNameShown( aSource.IsNameShown() );
385 SetCanAutoplace( aSource.CanAutoplace() );
386}
387
388
390{
391 wxCHECK_RET( ( aItem != nullptr ) && ( aItem->Type() == SCH_FIELD_T ),
392 wxT( "Cannot swap field data with invalid item." ) );
393
394 SCH_FIELD* item = (SCH_FIELD*) aItem;
395
396 std::swap( m_layer, item->m_layer );
397 std::swap( m_showName, item->m_showName );
398 std::swap( m_allowAutoPlace, item->m_allowAutoPlace );
399 SwapText( *item );
400 SwapAttributes( *item );
401
402 std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
403}
404
405
407{
408 if( GetTextColor() != COLOR4D::UNSPECIFIED )
409 {
411 }
412 else
413 {
414 SCH_LABEL_BASE* parentLabel = dynamic_cast<SCH_LABEL_BASE*>( GetParent() );
415
416 if( parentLabel && !parentLabel->IsConnectivityDirty() )
417 m_lastResolvedColor = parentLabel->GetEffectiveNetClass()->GetSchematicColor();
418 else
420 }
421
422 return m_lastResolvedColor;
423}
424
425
427{
428 // Calculate the text orientation according to the symbol orientation.
429 EDA_ANGLE orient = GetTextAngle();
430
431 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
432 {
433 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
434
435 if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
436 {
437 if( orient.IsHorizontal() )
438 orient = ANGLE_VERTICAL;
439 else
440 orient = ANGLE_HORIZONTAL;
441 }
442 }
443
444 return orient;
445}
446
447
449{
450 // Calculate the text bounding box:
451 BOX2I bbox = GetTextBox();
452
453 // Calculate the bounding box position relative to the parent:
454 VECTOR2I origin = GetParentPosition();
455 VECTOR2I pos = GetTextPos() - origin;
456 VECTOR2I begin = bbox.GetOrigin() - origin;
457 VECTOR2I end = bbox.GetEnd() - origin;
458 RotatePoint( begin, pos, GetTextAngle() );
459 RotatePoint( end, pos, GetTextAngle() );
460
461 // Now, apply the symbol transform (mirror/rot)
462 TRANSFORM transform;
463
464 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
465 {
466 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
467
468 // Due to the Y axis direction, we must mirror the bounding box,
469 // relative to the text position:
470 MIRROR( begin.y, pos.y );
471 MIRROR( end.y, pos.y );
472
473 transform = parentSymbol->GetTransform();
474 }
475 else
476 {
477 transform = TRANSFORM( 1, 0, 0, 1 ); // identity transform
478 }
479
480 bbox.SetOrigin( transform.TransformCoordinate( begin ) );
481 bbox.SetEnd( transform.TransformCoordinate( end ) );
482
483 bbox.Move( origin );
484 bbox.Normalize();
485
486 return bbox;
487}
488
489
491{
492 VECTOR2I render_center = GetBoundingBox().Centre();
493 VECTOR2I pos = GetPosition();
494
495 switch( GetHorizJustify() )
496 {
498 if( GetDrawRotation().IsVertical() )
499 return render_center.y > pos.y;
500 else
501 return render_center.x < pos.x;
503 if( GetDrawRotation().IsVertical() )
504 return render_center.y < pos.y;
505 else
506 return render_center.x > pos.x;
507 default:
508 return false;
509 }
510}
511
512
514{
515 switch( GetHorizJustify() )
516 {
521 default:
523 }
524}
525
526
528{
529 VECTOR2I render_center = GetBoundingBox().Centre();
530 VECTOR2I pos = GetPosition();
531
532 switch( GetVertJustify() )
533 {
535 if( GetDrawRotation().IsVertical() )
536 return render_center.x < pos.x;
537 else
538 return render_center.y < pos.y;
540 if( GetDrawRotation().IsVertical() )
541 return render_center.x > pos.x;
542 else
543 return render_center.y > pos.y;
544 default:
545 return false;
546 }
547}
548
549
551{
552 switch( GetVertJustify() )
553 {
558 default:
560 }
561}
562
563
564bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
565{
566 bool searchHiddenFields = false;
567 bool searchAndReplace = false;
568 bool replaceReferences = false;
569
570 try
571 {
572 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData ); // downcast
573 searchHiddenFields = schSearchData.searchAllFields;
574 searchAndReplace = schSearchData.searchAndReplace;
575 replaceReferences = schSearchData.replaceReferences;
576 }
577 catch( const std::bad_cast& )
578 {
579 }
580
581 wxString text = GetShownText();
582
583 if( !IsVisible() && !searchHiddenFields )
584 return false;
585
587 {
588 if( searchAndReplace && !replaceReferences )
589 return false;
590
591 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
592 wxASSERT( aAuxData );
593
594 // Take sheet path into account which effects the reference field and the unit for
595 // symbols with multiple parts.
596 if( aAuxData )
597 {
598 text = parentSymbol->GetRef((SCH_SHEET_PATH*) aAuxData );
599
600 if( SCH_ITEM::Matches( text, aSearchData ) )
601 return true;
602
603 if( parentSymbol->GetUnitCount() > 1 )
604 text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
605 }
606 }
607
608 return SCH_ITEM::Matches( text, aSearchData );
609}
610
611
613{
614 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
615 {
616 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
617
618 if( m_id == VALUE_FIELD )
619 {
620 if( parentSymbol->GetLibSymbolRef() && parentSymbol->GetLibSymbolRef()->IsPower() )
621 return false;
622 }
623 }
624 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
625 {
626 // See comments in SCH_FIELD::Replace(), below.
627 if( m_id == SHEETFILENAME )
628 return false;
629 }
630 else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
631 {
632 if( m_id == 0 /* IntersheetRefs */ )
633 return false;
634 }
635
636 return true;
637}
638
639
640bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
641{
642 bool replaceReferences = false;
643
644 try
645 {
646 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
647 replaceReferences = schSearchData.replaceReferences;
648 }
649 catch( const std::bad_cast& )
650 {
651 }
652
653 wxString text;
654 bool resolve = false; // Replace in source text, not shown text
655 bool isReplaced = false;
656
657 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
658 {
659 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
660
661 switch( m_id )
662 {
663 case REFERENCE_FIELD:
664 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
665
666 if( !replaceReferences )
667 return false;
668
669 text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
670 isReplaced = EDA_ITEM::Replace( aSearchData, text );
671
672 if( isReplaced )
673 parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
674
675 break;
676
677 case VALUE_FIELD:
678 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) );
679
680 text = parentSymbol->GetValueFieldText( resolve );
681 isReplaced = EDA_ITEM::Replace( aSearchData, text );
682
683 if( isReplaced )
684 parentSymbol->SetValueFieldText( text );
685
686 break;
687
688 case FOOTPRINT_FIELD:
689 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) );
690
691 text = parentSymbol->GetFootprintFieldText( resolve );
692 isReplaced = EDA_ITEM::Replace( aSearchData, text );
693
694 if( isReplaced )
695 parentSymbol->SetFootprintFieldText( text );
696
697 break;
698
699 default:
700 isReplaced = EDA_TEXT::Replace( aSearchData );
701 }
702 }
703 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
704 {
705 isReplaced = EDA_TEXT::Replace( aSearchData );
706
707 if( m_id == SHEETFILENAME && isReplaced )
708 {
709 // If we allowed this we'd have a bunch of work to do here, including warning
710 // about it not being undoable, checking for recursive hierarchies, reloading
711 // sheets, etc. See DIALOG_SHEET_PROPERTIES::TransferDataFromWindow().
712 }
713 }
714 else
715 {
716 isReplaced = EDA_TEXT::Replace( aSearchData );
717 }
718
719 return isReplaced;
720}
721
722
723void SCH_FIELD::Rotate( const VECTOR2I& aCenter )
724{
725 VECTOR2I pt = GetPosition();
726 RotatePoint( pt, aCenter, ANGLE_90 );
727 SetPosition( pt );
728}
729
730
731wxString SCH_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
732{
734}
735
736
737void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
738{
739 wxString msg;
740
741 aList.emplace_back( _( "Symbol Field" ), GetName() );
742
743 // Don't use GetShownText() here; we want to show the user the variable references
744 aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
745
746 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
747
748 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
749
750 aList.emplace_back( _( "Style" ), GetTextStyleName() );
751
752 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
753
754 switch ( GetHorizJustify() )
755 {
756 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
757 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
758 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
759 }
760
761 aList.emplace_back( _( "H Justification" ), msg );
762
763 switch ( GetVertJustify() )
764 {
765 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
766 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
767 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
768 }
769
770 aList.emplace_back( _( "V Justification" ), msg );
771}
772
773
775{
776 constexpr int START_ID = 1;
777
778 if( IsHypertext() )
779 {
780 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
781 std::vector<std::pair<wxString, wxString>> pages;
782 wxMenu menu;
783 wxString href;
784
785 label->GetIntersheetRefs( &pages );
786
787 for( int i = 0; i < (int) pages.size(); ++i )
788 {
789 menu.Append( i + START_ID, wxString::Format( _( "Go to Page %s (%s)" ),
790 pages[i].first,
791 pages[i].second ) );
792 }
793
794 menu.AppendSeparator();
795 menu.Append( 999 + START_ID, _( "Back to Previous Selected Sheet" ) );
796
797 int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
798
799 if( sel >= 0 && sel < (int) pages.size() )
800 href = wxT( "#" ) + pages[ sel ].first;
801 else if( sel == 999 )
803
804 if( !href.IsEmpty() )
805 {
807 navTool->HypertextCommand( href );
808 }
809 }
810}
811
812
813wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
814{
815 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
816 {
817 if( m_id >= 0 && m_id < MANDATORY_FIELDS )
819 else if( m_name.IsEmpty() && aUseDefaultName )
821 else
822 return m_name;
823 }
824 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
825 {
826 if( m_id >= 0 && m_id < SHEET_MANDATORY_FIELDS )
828 else if( m_name.IsEmpty() && aUseDefaultName )
830 else
831 return m_name;
832 }
833 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
834 {
835 return SCH_LABEL_BASE::GetDefaultFieldName( m_name, aUseDefaultName );
836 }
837 else
838 {
839 wxFAIL_MSG( "Unhandled field owner type." );
840 return m_name;
841 }
842}
843
844
846{
847 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
848 {
849 switch( m_id )
850 {
851 case REFERENCE_FIELD: return wxT( "Reference" );
852 case VALUE_FIELD: return wxT( "Value" );
853 case FOOTPRINT_FIELD: return wxT( "Footprint" );
854 case DATASHEET_FIELD: return wxT( "Datasheet" );
855 default: return m_name;
856 }
857 }
858 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
859 {
860 switch( m_id )
861 {
862 case SHEETNAME: return wxT( "Sheetname" );
863 case SHEETFILENAME: return wxT( "Sheetfile" );
864 default: return m_name;
865 }
866 }
867 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
868 {
869 // These should be stored in canonical format, but just in case:
870 if( m_name == _( "Net Class" ) || m_name == wxT( "Net Class" ) )
871 return wxT( "Netclass" );
872 else if( m_name == _( "Sheet References" )
873 || m_name == wxT( "Sheet References" )
874 || m_name == wxT( "Intersheet References" ) )
875 return wxT( "Intersheetrefs" );
876 else
877 return m_name;
878 }
879 else
880 {
881 if( m_parent )
882 {
883 wxFAIL_MSG( wxString::Format( "Unhandled field owner type (id %d, parent type %d).",
884 m_id, m_parent->Type() ) );
885 }
886
887 return m_name;
888 }
889}
890
891
893{
894 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
895 {
896 switch( m_id )
897 {
901 default: return BITMAPS::text;
902 }
903 }
904
905 return BITMAPS::text;
906}
907
908
909bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
910{
911 // Do not hit test hidden or empty fields.
912 if( !IsVisible() || GetShownText().IsEmpty() )
913 return false;
914
915 BOX2I rect = GetBoundingBox();
916
917 rect.Inflate( aAccuracy );
918
919 if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
920 {
921 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
922 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
923 }
924
925 return rect.Contains( aPosition );
926}
927
928
929bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
930{
931 // Do not hit test hidden fields.
932 if( !IsVisible() || GetShownText().IsEmpty() )
933 return false;
934
935 BOX2I rect = aRect;
936
937 rect.Inflate( aAccuracy );
938
939 if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
940 {
941 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
942 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
943 }
944
945 if( aContained )
946 return rect.Contains( GetBoundingBox() );
947
948 return rect.Intersects( GetBoundingBox() );
949}
950
951
952void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const
953{
954 if( GetShownText().IsEmpty() || aBackground )
955 return;
956
957 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
958 COLOR4D color = settings->GetLayerColor( GetLayer() );
959 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
960
961 COLOR4D bg = settings->GetBackgroundColor();;
962
963 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
964 bg = COLOR4D::WHITE;
965
966 if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
968
969 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
970
971 if( !IsVisible() )
972 return;
973
974 // Calculate the text orientation, according to the symbol orientation/mirror
975 EDA_ANGLE orient = GetTextAngle();
976 VECTOR2I textpos = GetTextPos();
979
980 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
981 {
982 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
983
984 if( parentSymbol->GetDNP() )
985 {
986 color.Desaturate();
987 color = color.Mix( bg, 0.5f );
988 }
989
990 if( parentSymbol->GetTransform().y1 ) // Rotate symbol 90 deg.
991 {
992 if( orient.IsHorizontal() )
993 orient = ANGLE_VERTICAL;
994 else
995 orient = ANGLE_HORIZONTAL;
996 }
997
998 /*
999 * Calculate the text justification, according to the symbol orientation/mirror. This is
1000 * a bit complicated due to cumulative calculations:
1001 * - numerous cases (mirrored or not, rotation)
1002 * - the plotter's Text() function will also recalculate H and V justifications according
1003 * to the text orientation
1004 * - when a symbol is mirrored the text is not, and justifications become a nightmare
1005 *
1006 * So the easier way is to use no justifications (centered text) and use GetBoundingBox to
1007 * know the text coordinate considered as centered.
1008 */
1009 hjustify = GR_TEXT_H_ALIGN_CENTER;
1010 vjustify = GR_TEXT_V_ALIGN_CENTER;
1011 textpos = GetBoundingBox().Centre();
1012 }
1013
1014 KIFONT::FONT* font = GetFont();
1015
1016 if( !font )
1017 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
1018
1019 aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,
1020 penWidth, IsItalic(), IsBold(), false, font );
1021
1022 if( IsHypertext() )
1023 {
1024 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
1025 std::vector<std::pair<wxString, wxString>> pages;
1026 std::vector<wxString> pageHrefs;
1027 BOX2I bbox = GetBoundingBox();
1028
1029 label->GetIntersheetRefs( &pages );
1030
1031 for( const std::pair<wxString, wxString>& page : pages )
1032 pageHrefs.push_back( wxT( "#" ) + page.first );
1033
1034 bbox.Offset( label->GetSchematicTextOffset( settings ) );
1035
1036 aPlotter->HyperlinkMenu( bbox, pageHrefs );
1037 }
1038}
1039
1040
1041void SCH_FIELD::SetPosition( const VECTOR2I& aPosition )
1042{
1043 // Actual positions are calculated by the rotation/mirror transform of the parent symbol
1044 // of the field. The inverse transform is used to calculate the position relative to the
1045 // parent symbol.
1046 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
1047 {
1048 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
1049 VECTOR2I relPos = aPosition - parentSymbol->GetPosition();
1050
1051 relPos = parentSymbol->GetTransform().InverseTransform().TransformCoordinate( relPos );
1052
1053 SetTextPos( relPos + parentSymbol->GetPosition() );
1054 return;
1055 }
1056
1057 SetTextPos( aPosition );
1058}
1059
1060
1062{
1063 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
1064 {
1065 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
1066 VECTOR2I relativePos = GetTextPos() - parentSymbol->GetPosition();
1067
1068 relativePos = parentSymbol->GetTransform().TransformCoordinate( relativePos );
1069
1070 return relativePos + parentSymbol->GetPosition();
1071 }
1072
1073 return GetTextPos();
1074}
1075
1076
1078{
1079 return m_parent ? m_parent->GetPosition() : VECTOR2I( 0, 0 );
1080}
1081
1082
1083bool SCH_FIELD::operator <( const SCH_ITEM& aItem ) const
1084{
1085 if( Type() != aItem.Type() )
1086 return Type() < aItem.Type();
1087
1088 auto field = static_cast<const SCH_FIELD*>( &aItem );
1089
1090 if( GetId() != field->GetId() )
1091 return GetId() < field->GetId();
1092
1093 if( GetText() != field->GetText() )
1094 return GetText() < field->GetText();
1095
1096 if( GetLibPosition().x != field->GetLibPosition().x )
1097 return GetLibPosition().x < field->GetLibPosition().x;
1098
1099 if( GetLibPosition().y != field->GetLibPosition().y )
1100 return GetLibPosition().y < field->GetLibPosition().y;
1101
1102 return GetName() < field->GetName();
1103}
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:181
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:201
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:503
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
COLOR4D GetTextColor() const
Definition: eda_text.h:205
wxString GetTextStyleName() const
Definition: eda_text.cpp:736
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
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:136
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
EDA_TEXT & operator=(const EDA_TEXT &aItem)
Definition: eda_text.cpp:136
int GetTextWidth() const
Definition: eda_text.h:199
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
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:103
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:133
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:273
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
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
virtual bool IsOutline() const
Definition: font.h:113
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 wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
wxDC * GetPrintDC() const
Field object used in symbol libraries.
Definition: lib_field.h:61
bool CanAutoplace() const
Definition: lib_field.h:183
bool IsNameShown() const
Definition: lib_field.h:180
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:584
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
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
void ClearRenderCache() override
Definition: sch_field.cpp:268
COLOR4D m_lastResolvedColor
Definition: sch_field.h:261
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
Definition: sch_field.cpp:550
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:175
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:448
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_renderCache
Definition: sch_field.h:259
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
Definition: sch_field.cpp:952
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1061
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:640
bool m_showName
Render the field name in addition to its value.
Definition: sch_field.h:254
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_field.cpp:723
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_field.cpp:315
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_field.cpp:132
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_field.cpp:892
bool IsNameShown() const
Definition: sch_field.h:158
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.h:95
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:909
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:490
bool IsVertJustifyFlipped() const
Definition: sch_field.cpp:527
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_field.cpp:731
EDA_ANGLE GetDrawRotation() const override
Adjusters to allow EDA_TEXT to draw/print/etc.
Definition: sch_field.cpp:426
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_field.cpp:564
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:162
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
Definition: sch_field.cpp:774
int GetPenWidth() const override
Definition: sch_field.cpp:244
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:845
COLOR4D GetFieldColor() const
Definition: sch_field.cpp:406
int GetId() const
Definition: sch_field.h:125
SCH_FIELD & operator=(const SCH_FIELD &aField)
Definition: sch_field.cpp:106
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_field.cpp:1083
VECTOR2I GetLibPosition() const
Definition: sch_field.h:226
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:257
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_field.cpp:612
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
Definition: sch_field.cpp:513
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:813
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1041
void ImportValues(const LIB_FIELD &aSource)
Copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:381
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:389
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_field.h:186
VECTOR2I m_renderCachePos
Definition: sch_field.h:258
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) const
Definition: sch_field.cpp:276
void SetId(int aId)
Definition: sch_field.cpp:138
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:737
void ClearCaches() override
Definition: sch_field.cpp:261
VECTOR2I GetParentPosition() const
Definition: sch_field.cpp:1077
int m_id
Field index,.
Definition: sch_field.h:250
wxString m_name
Definition: sch_field.h:252
void SetNameShown(bool aShown=true)
Definition: sch_field.h:159
KIFONT::FONT * getDrawFont() const override
Definition: sch_field.cpp:250
bool m_allowAutoPlace
This field can be autoplaced.
Definition: sch_field.h:255
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:1259
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:413
SCH_LAYER_ID m_layer
Definition: sch_item.h:491
void GetIntersheetRefs(std::vector< std::pair< wxString, wxString > > *pages)
Builds an array of { pageNumber, pageName } pairs.
Definition: sch_label.cpp:447
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...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
Definition: sch_sheet.cpp:55
Schematic symbol object.
Definition: sch_symbol.h:81
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:423
int GetUnit() const
Definition: sch_symbol.h:228
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:822
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:652
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:694
const wxString GetFootprintFieldText(bool aResolve) const
Definition: sch_symbol.cpp:828
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:837
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:712
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:813
TRANSFORM & GetTransform()
Definition: sch_symbol.h:283
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:192
bool GetDNP() const
Definition: sch_symbol.h:753
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:60
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:45
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:58
The common library.
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:419
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:420
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:425
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
PROJECT & Prj()
Definition: kicad.cpp:573
@ 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_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:215
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:49
@ SHEETNAME
Definition: sch_sheet.h:45
@ SHEETFILENAME
Definition: sch_sheet.h:46
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:156
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618