KiCad PCB EDA Suite
sch_label.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2015 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <base_units.h>
27#include <pgm_base.h>
28#include <sch_edit_frame.h>
29#include <plotters/plotter.h>
30#include <widgets/msgpanel.h>
31#include <bitmaps.h>
32#include <string_utils.h>
33#include <schematic.h>
35#include <sch_painter.h>
36#include <default_values.h>
37#include <wx/debug.h>
38#include <wx/log.h>
42#include <core/kicad_algo.h>
43#include <trigo.h>
44#include <sch_label.h>
45
47
48
49bool IncrementLabelMember( wxString& name, int aIncrement )
50{
51 if( name.IsEmpty() )
52 return true;
53
54 wxString suffix;
55 wxString digits;
56 wxString outputFormat;
57 wxString outputNumber;
58 int ii = name.Len() - 1;
59 int dCount = 0;
60
61 while( ii >= 0 && !wxIsdigit( name.GetChar( ii ) ) )
62 {
63 suffix = name.GetChar( ii ) + suffix;
64 ii--;
65 }
66
67 while( ii >= 0 && wxIsdigit( name.GetChar( ii ) ) )
68 {
69 digits = name.GetChar( ii ) + digits;
70 ii--;
71 dCount++;
72 }
73
74 if( digits.IsEmpty() )
75 return true;
76
77 long number = 0;
78
79 if( digits.ToLong( &number ) )
80 {
81 number += aIncrement;
82
83 // Don't let result go below zero
84
85 if( number > -1 )
86 {
87 name.Remove( ii + 1 );
88 //write out a format string with correct number of leading zeroes
89 outputFormat.Printf( wxS( "%%0%dld" ), dCount );
90 //write out the number using the format string
91 outputNumber.Printf( outputFormat, number );
92 name << outputNumber << suffix;
93 return true;
94 }
95 }
96
97 return false;
98}
99
100
101/* Coding polygons for global symbol graphic shapes.
102 * the first parml is the number of corners
103 * others are the corners coordinates in reduced units
104 * the real coordinate is the reduced coordinate * text half size
105 */
106static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
107static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
108static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
109static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
110
111static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
112static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
113static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
114static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
115
116static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
117static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
118static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
119static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
120
121static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
122static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
123static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
124static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
125
126static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
127static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
128static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
129static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
130
131static int* TemplateShape[5][4] =
132{
138};
139
140
142{
143 switch( aType )
144 {
145 case LABEL_FLAG_SHAPE::L_INPUT: return _( "Input" );
146 case LABEL_FLAG_SHAPE::L_OUTPUT: return _( "Output" );
147 case LABEL_FLAG_SHAPE::L_BIDI: return _( "Bidirectional" );
148 case LABEL_FLAG_SHAPE::L_TRISTATE: return _( "Tri-State" );
149 case LABEL_FLAG_SHAPE::L_UNSPECIFIED: return _( "Passive" );
150 default: return wxT( "???" );
151 }
152}
153
154
155SCH_LABEL_BASE::SCH_LABEL_BASE( const VECTOR2I& aPos, const wxString& aText, KICAD_T aType ) :
156 SCH_TEXT( aPos, aText, aType ),
157 m_shape( L_UNSPECIFIED ),
158 m_connectionType( CONNECTION_TYPE::NONE ),
159 m_isDangling( true ),
160 m_lastResolvedColor( COLOR4D::UNSPECIFIED )
161{
162 SetMultilineAllowed( false );
163 ClearFieldsAutoplaced(); // fiels are not yet autoplaced.
164}
165
166
168 SCH_TEXT( aLabel ),
169 m_shape( aLabel.m_shape ),
170 m_connectionType( aLabel.m_connectionType ),
171 m_isDangling( aLabel.m_isDangling ),
172 m_lastResolvedColor( aLabel.m_lastResolvedColor )
173{
174 SetMultilineAllowed( false );
175
176 m_fields = aLabel.m_fields;
177
178 for( SCH_FIELD& field : m_fields )
179 field.SetParent( this );
180}
181
182
183const wxString SCH_LABEL_BASE::GetDefaultFieldName( const wxString& aName, bool aUseDefaultName )
184{
185 if( aName == wxT( "Intersheetrefs" ) )
186 return _( "Sheet References" );
187 else if( aName == wxT( "Netclass" ) )
188 return _( "Net Class" );
189 else if( aName.IsEmpty() && aUseDefaultName )
190 return _( "Field" );
191 else
192 return aName;
193}
194
195
196bool SCH_LABEL_BASE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
197{
198 if( SCH_TEXT::IsType( aScanTypes ) )
199 return true;
200
201 for( KICAD_T scanType : aScanTypes )
202 {
203 if( scanType == SCH_LABEL_LOCATE_ANY_T )
204 return true;
205 }
206
207 wxCHECK_MSG( Schematic(), false, wxT( "No parent SCHEMATIC set for SCH_LABEL!" ) );
208
209 // Ensure m_connected_items for Schematic()->CurrentSheet() exists.
210 // Can be not the case when "this" is living in clipboard
211 if( m_connected_items.find( Schematic()->CurrentSheet() ) == m_connected_items.end() )
212 return false;
213
214 const SCH_ITEM_SET& item_set = m_connected_items.at( Schematic()->CurrentSheet() );
215
216 for( KICAD_T scanType : aScanTypes )
217 {
218 if( scanType == SCH_LABEL_LOCATE_WIRE_T )
219 {
220 for( SCH_ITEM* connection : item_set )
221 {
222 if( connection->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T } ) )
223 return true;
224 }
225 }
226
227 if ( scanType == SCH_LABEL_LOCATE_BUS_T )
228 {
229 for( SCH_ITEM* connection : item_set )
230 {
231 if( connection->IsType( { SCH_ITEM_LOCATE_BUS_T } ) )
232 return true;
233 }
234 }
235 }
236
237 return false;
238}
239
240
242{
243 SCH_TEXT::SwapData( aItem );
244
245 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
246
247 m_fields.swap( label->m_fields );
248 std::swap( m_fieldsAutoplaced, label->m_fieldsAutoplaced );
249
250 for( SCH_FIELD& field : m_fields )
251 field.SetParent( this );
252
253 for( SCH_FIELD& field : label->m_fields )
254 field.SetParent( label );
255
256 std::swap( m_shape, label->m_shape );
257 std::swap( m_connectionType, label->m_connectionType );
258 std::swap( m_isDangling, label->m_isDangling );
259 std::swap( m_lastResolvedColor, label->m_lastResolvedColor );
260}
261
262
264{
265 if( GetTextColor() != COLOR4D::UNSPECIFIED )
267 else if( !IsConnectivityDirty() )
268 m_lastResolvedColor = GetEffectiveNetClass()->GetSchematicColor();
269
270 return m_lastResolvedColor;
271}
272
273
275{
276 VECTOR2I text_offset;
277
278 // add an offset to x (or y) position to aid readability of text on a wire or line
279 int dist = GetTextOffset( aSettings ) + GetPenWidth();
280
281 switch( GetTextSpinStyle() )
282 {
284 case TEXT_SPIN_STYLE::BOTTOM: text_offset.x = -dist; break; // Vert Orientation
285 default:
287 case TEXT_SPIN_STYLE::RIGHT: text_offset.y = -dist; break; // Horiz Orientation
288 }
289
290 return text_offset;
291}
292
293
294void SCH_LABEL_BASE::Rotate( const VECTOR2I& aCenter )
295{
296 VECTOR2I pt = GetTextPos();
297 RotatePoint( pt, aCenter, ANGLE_90 );
298 VECTOR2I offset = pt - GetTextPos();
299
300 Rotate90( false );
301
302 SetTextPos( GetTextPos() + offset );
303
304 for( SCH_FIELD& field : m_fields )
305 field.SetTextPos( field.GetTextPos() + offset );
306}
307
308
309void SCH_LABEL_BASE::Rotate90( bool aClockwise )
310{
311 SCH_TEXT::Rotate90( aClockwise );
312
314 {
315 AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
316 }
317 else
318 {
319 for( SCH_FIELD& field : m_fields )
320 {
321 if( field.GetTextAngle().IsVertical()
322 && field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
323 {
324 if( !aClockwise )
325 field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
326
327 field.SetTextAngle( ANGLE_HORIZONTAL );
328 }
329 else if( field.GetTextAngle().IsVertical()
330 && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
331 {
332 if( !aClockwise )
333 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
334
335 field.SetTextAngle( ANGLE_HORIZONTAL );
336 }
337 else if( field.GetTextAngle().IsHorizontal()
338 && field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
339 {
340 if( aClockwise )
341 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
342
343 field.SetTextAngle( ANGLE_VERTICAL );
344 }
345 else if( field.GetTextAngle().IsHorizontal()
346 && field.GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT )
347 {
348 if( aClockwise )
349 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
350
351 field.SetTextAngle( ANGLE_VERTICAL );
352 }
353
354 VECTOR2I pos = field.GetTextPos();
355 RotatePoint( pos, GetPosition(), aClockwise ? -ANGLE_90 : ANGLE_90 );
356 field.SetTextPos( pos );
357 }
358 }
359}
360
361
362bool SCH_LABEL_BASE::IncrementLabel( int aIncrement )
363{
364 wxString text = GetText();
365
366 if( IncrementLabelMember( text, aIncrement ) )
367 {
368 SetText( text );
369 return true;
370 }
371
372 return false;
373}
374
375
376void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
377{
378 int margin = GetTextOffset() * 2;
379 int labelLen = GetBodyBoundingBox().GetSizeMax();
380 int accumulated = GetTextHeight() / 2;
381
382 if( Type() == SCH_GLOBAL_LABEL_T )
383 accumulated += margin + GetPenWidth() + margin;
384
385 for( SCH_FIELD& field : m_fields )
386 {
387 VECTOR2I offset( 0, 0 );
388
389 switch( GetTextSpinStyle() )
390 {
391 default:
393 field.SetTextAngle( ANGLE_HORIZONTAL );
394 field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
395
396 if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
397 offset.x = - ( labelLen + margin );
398 else
399 offset.y = accumulated + field.GetTextHeight() / 2;
400
401 break;
402
404 field.SetTextAngle( ANGLE_VERTICAL );
405 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
406
407 if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
408 offset.y = - ( labelLen + margin );
409 else
410 offset.x = accumulated + field.GetTextHeight() / 2;
411
412 break;
413
415 field.SetTextAngle( ANGLE_HORIZONTAL );
416 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
417
418 if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
419 offset.x = labelLen + margin;
420 else
421 offset.y = accumulated + field.GetTextHeight() / 2;
422
423 break;
424
426 field.SetTextAngle( ANGLE_VERTICAL );
427 field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
428
429 if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
430 offset.y = labelLen + margin;
431 else
432 offset.x = accumulated + field.GetTextHeight() / 2;
433
434 break;
435 }
436
437 field.SetTextPos( GetTextPos() + offset );
438
439 if( field.GetCanonicalName() != wxT( "Intersheetrefs" ) )
440 accumulated += field.GetTextHeight() + margin;
441 }
442
444}
445
446
447void SCH_LABEL_BASE::GetIntersheetRefs( std::vector<std::pair<wxString, wxString>>* pages )
448{
449 wxCHECK( pages, /* void */ );
450
451 if( Schematic() )
452 {
453 auto it = Schematic()->GetPageRefsMap().find( GetText() );
454
455 if( it != Schematic()->GetPageRefsMap().end() )
456 {
457 std::vector<int> pageListCopy;
458
459 pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
460
461 if( !Schematic()->Settings().m_IntersheetRefsListOwnPage )
462 {
463 int currentPage = Schematic()->CurrentSheet().GetVirtualPageNumber();
464 alg::delete_matching( pageListCopy, currentPage );
465
466 if( pageListCopy.empty() )
467 return;
468 }
469
470 std::sort( pageListCopy.begin(), pageListCopy.end() );
471
472 std::map<int, wxString> sheetPages = Schematic()->GetVirtualPageToSheetPagesMap();
473 std::map<int, wxString> sheetNames = Schematic()->GetVirtualPageToSheetNamesMap();
474
475 for( int pageNum : pageListCopy )
476 pages->push_back( { sheetPages[ pageNum ], sheetNames[ pageNum ] } );
477 }
478 }
479}
480
481
482void SCH_LABEL_BASE::GetContextualTextVars( wxArrayString* aVars ) const
483{
484 for( const SCH_FIELD& field : m_fields )
485 aVars->push_back( field.GetCanonicalName().Upper() );
486
487 aVars->push_back( wxT( "OP" ) );
488 aVars->push_back( wxT( "CONNECTION_TYPE" ) );
489 aVars->push_back( wxT( "SHORT_NET_NAME" ) );
490 aVars->push_back( wxT( "NET_NAME" ) );
491 aVars->push_back( wxT( "NET_CLASS" ) );
492}
493
494
495bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
496{
497 static wxRegEx operatingPoint( wxT( "^"
498 "OP"
499 "(.([0-9])?([a-zA-Z]*))?"
500 "$" ) );
501
502 if( !Schematic() )
503 return false;
504
505 if( operatingPoint.Matches( *token ) )
506 {
507 int precision = 3;
508 wxString precisionStr( operatingPoint.GetMatch( *token, 2 ) );
509 wxString range( operatingPoint.GetMatch( *token, 3 ) );
510
511 if( !precisionStr.IsEmpty() )
512 precision = precisionStr[0] - '0';
513
514 if( range.IsEmpty() )
515 range = wxS( "~V" );
516
517 const SCH_CONNECTION* connection = Connection();
518 *token = wxS( "?" );
519
520 if( connection )
521 *token = Schematic()->GetOperatingPoint( connection->Name( false ), precision, range );
522
523 return true;
524 }
525
526 if( token->Contains( ':' ) )
527 {
528 if( Schematic()->ResolveCrossReference( token, aDepth + 1 ) )
529 return true;
530 }
531
533 && token->IsSameAs( wxT( "CONNECTION_TYPE" ) ) )
534 {
535 const SCH_LABEL_BASE* label = static_cast<const SCH_LABEL_BASE*>( this );
536 *token = getElectricalTypeLabel( label->GetShape() );
537 return true;
538 }
539 else if( token->IsSameAs( wxT( "SHORT_NET_NAME" ) ) )
540 {
541 const SCH_CONNECTION* connection = Connection();
542 *token = wxEmptyString;
543
544 if( connection )
545 *token = connection->LocalName();
546
547 return true;
548 }
549 else if( token->IsSameAs( wxT( "NET_NAME" ) ) )
550 {
551 const SCH_CONNECTION* connection = Connection();
552 *token = wxEmptyString;
553
554 if( connection )
555 *token = connection->Name();
556
557 return true;
558 }
559 else if( token->IsSameAs( wxT( "NET_CLASS" ) ) )
560 {
561 const SCH_CONNECTION* connection = Connection();
562 *token = wxEmptyString;
563
564 if( connection )
565 *token = GetEffectiveNetClass()->GetName();
566
567 return true;
568 }
569
570 for( const SCH_FIELD& field : m_fields)
571 {
572 if( token->IsSameAs( field.GetName() ) )
573 {
574 *token = field.GetShownText( aDepth + 1 );
575 return true;
576 }
577 }
578
579 // See if parent can resolve it (these will recurse to ancestors)
580
581 if( Type() == SCH_SHEET_PIN_T && m_parent )
582 {
583 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
584
585 if( sheet->ResolveTextVar( token, aDepth + 1 ) )
586 return true;
587 }
588 else if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() )
589 {
590 if( sheet->ResolveTextVar( token, aDepth + 1 ) )
591 return true;
592 }
593
594 return false;
595}
596
597
598wxString SCH_LABEL_BASE::GetShownText( int aDepth, bool aAllowExtraText ) const
599{
600 std::function<bool( wxString* )> textResolver =
601 [&]( wxString* token ) -> bool
602 {
603 return ResolveTextVar( token, aDepth );
604 };
605
606 wxString text = EDA_TEXT::GetShownText();
607
608 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
609 {
610 text = wxS( "" );
611 }
612 else if( HasTextVars() )
613 {
614 if( aDepth < 10 )
615 text = ExpandTextVars( text, &textResolver );
616 }
617
618 return text;
619}
620
621
622void SCH_LABEL_BASE::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
623{
624 for( SCH_FIELD& field : m_fields )
625 aFunction( &field );
626}
627
628
629bool SCH_LABEL_BASE::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
630{
631 return SCH_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
632}
633
634
635bool SCH_LABEL_BASE::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
636{
637 EDA_SEARCH_DATA localSearchData( aSearchData );
638 localSearchData.findString = EscapeString( aSearchData.findString, CTX_NETNAME );
639 localSearchData.replaceString = EscapeString( aSearchData.replaceString, CTX_NETNAME );
640
641 return EDA_TEXT::Replace( localSearchData );
642}
643
644
646 const std::vector<KICAD_T>& aScanTypes )
647{
648 if( IsType( aScanTypes ) )
649 {
650 if( INSPECT_RESULT::QUIT == aInspector( this, nullptr ) )
652 }
653
654 for( KICAD_T scanType : aScanTypes )
655 {
656 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
657 {
658 for( SCH_FIELD& field : m_fields )
659 {
660 if( INSPECT_RESULT::QUIT == aInspector( &field, this ) )
662 }
663 }
664 }
665
667}
668
669
670void SCH_LABEL_BASE::GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList )
671{
672 DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
673 aItemList.push_back( item );
674}
675
676
677std::vector<VECTOR2I> SCH_LABEL_BASE::GetConnectionPoints() const
678{
679 return { GetTextPos() };
680}
681
682
683void SCH_LABEL_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
684{
685 aCount = 5;
686 aLayers[0] = LAYER_DANGLING;
687 aLayers[1] = LAYER_DEVICE;
688 aLayers[2] = LAYER_NETCLASS_REFS;
689 aLayers[3] = LAYER_FIELDS;
690 aLayers[4] = LAYER_SELECTION_SHADOWS;
691}
692
693
695{
696 double ratio;
697
698 if( aSettings )
699 ratio = static_cast<const SCH_RENDER_SETTINGS*>( aSettings )->m_LabelSizeRatio;
700 else if( Schematic() )
702 else
703 ratio = DEFAULT_LABEL_SIZE_RATIO; // For previews (such as in Preferences), etc.
704
705 return KiROUND( ratio * GetTextSize().y );
706}
707
708
710{
711 // build the bounding box of the label only, without taking into account its fields
712
713 BOX2I box;
714 std::vector<VECTOR2I> pts;
715
716 CreateGraphicShape( nullptr, pts, GetTextPos() );
717
718 for( const VECTOR2I& pt : pts )
719 box.Merge( pt );
720
722 box.Normalize();
723 return box;
724}
725
726
728{
729 // build the bounding box of the entire label, including its fields
730
732
733 for( const SCH_FIELD& field : m_fields )
734 {
735 if( field.IsVisible() )
736 {
737 BOX2I fieldBBox = field.GetBoundingBox();
738
739 if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
740 fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
741
742 box.Merge( fieldBBox );
743 }
744 }
745
746 box.Normalize();
747
748 return box;
749}
750
751
752bool SCH_LABEL_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
753{
754 BOX2I bbox = GetBodyBoundingBox();
755 bbox.Inflate( aAccuracy );
756
757 if( bbox.Contains( aPosition ) )
758 return true;
759
760 for( const SCH_FIELD& field : m_fields )
761 {
762 if( field.IsVisible() )
763 {
764 BOX2I fieldBBox = field.GetBoundingBox();
765 fieldBBox.Inflate( aAccuracy );
766
767 if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
768 fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
769
770 if( fieldBBox.Contains( aPosition ) )
771 return true;
772 }
773 }
774
775 return false;
776}
777
778
779bool SCH_LABEL_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
780{
781 BOX2I rect = aRect;
782
783 rect.Inflate( aAccuracy );
784
785 if( aContained )
786 {
787 return rect.Contains( GetBoundingBox() );
788 }
789 else
790 {
791 if( rect.Intersects( GetBodyBoundingBox() ) )
792 return true;
793
794 for( const SCH_FIELD& field : m_fields )
795 {
796 if( field.IsVisible() )
797 {
798 BOX2I fieldBBox = field.GetBoundingBox();
799
800 if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
801 fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
802
803 if( rect.Intersects( fieldBBox ) )
804 return true;
805 }
806 }
807
808 return false;
809 }
810}
811
812
813bool SCH_LABEL_BASE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
814 const SCH_SHEET_PATH* aPath )
815{
816 bool previousState = m_isDangling;
817 m_isDangling = true;
819
820 for( unsigned ii = 0; ii < aItemList.size(); ii++ )
821 {
822 DANGLING_END_ITEM& item = aItemList[ii];
823
824 if( item.GetItem() == this )
825 continue;
826
827 switch( item.GetType() )
828 {
829 case PIN_END:
830 case LABEL_END:
831 case SHEET_LABEL_END:
832 case NO_CONNECT_END:
833 if( GetTextPos() == item.GetPosition() )
834 {
835 m_isDangling = false;
836
837 if( aPath && item.GetType() != PIN_END )
838 AddConnectionTo( *aPath, static_cast<SCH_ITEM*>( item.GetItem() ) );
839 }
840
841 break;
842
843 case BUS_END:
846
847 case WIRE_END:
848 {
849 DANGLING_END_ITEM& nextItem = aItemList[++ii];
850
851 int accuracy = 1; // We have rounding issues with an accuracy of 0
852
854 nextItem.GetPosition(), accuracy );
855
856 if( !m_isDangling )
857 {
860
861 // Add the line to the connected items, since it won't be picked
862 // up by a search of intersecting connection points
863 if( aPath )
864 {
865 auto sch_item = static_cast<SCH_ITEM*>( item.GetItem() );
866 AddConnectionTo( *aPath, sch_item );
867 sch_item->AddConnectionTo( *aPath, this );
868 }
869 }
870 }
871 break;
872
873 default:
874 break;
875 }
876
877 if( !m_isDangling )
878 break;
879 }
880
881 if( m_isDangling )
883
884 return previousState != m_isDangling;
885}
886
887
888void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
889{
890 wxString msg;
891
892 switch( Type() )
893 {
894 case SCH_LABEL_T: msg = _( "Label" ); break;
895 case SCH_DIRECTIVE_LABEL_T: msg = _( "Directive Label" ); break;
896 case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
897 case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
898 case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
899 default: return;
900 }
901
902 // Don't use GetShownText() here; we want to show the user the variable references
903 aList.emplace_back( msg, UnescapeString( GetText() ) );
904
905 // Display electrical type if it is relevant
907 aList.emplace_back( _( "Type" ), getElectricalTypeLabel( GetShape() ) );
908
909 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
910
911 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
912 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
913 aList.emplace_back( _( "Style" ), textStyle[style] );
914
915 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
916
917 switch( GetTextSpinStyle() )
918 {
919 case TEXT_SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
920 case TEXT_SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
921 case TEXT_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
922 case TEXT_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
923 default: msg = wxT( "???" ); break;
924 }
925
926 aList.emplace_back( _( "Justification" ), msg );
927
928 SCH_CONNECTION* conn = nullptr;
929
930 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
931 conn = Connection();
932
933 if( conn )
934 {
935 conn->AppendInfoToMsgPanel( aList );
936
937 if( !conn->IsBus() )
938 {
939 aList.emplace_back( _( "Resolved Netclass" ),
940 UnescapeString( GetEffectiveNetClass()->GetName() ) );
941 }
942 }
943}
944
945
946void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
947{
948 static std::vector<VECTOR2I> s_poly;
949
950 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
951 SCH_CONNECTION* connection = Connection();
952 int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
953 COLOR4D color = settings->GetLayerColor( layer );
954 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
955
956 if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
958
959 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
960 aPlotter->SetCurrentLineWidth( penWidth );
961
962 KIFONT::FONT* font = GetFont();
963
964 if( !font )
965 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
966
967 VECTOR2I textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() );
968 CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() );
969
971 attrs.m_StrokeWidth = penWidth;
972 attrs.m_Multiline = false;
973
974 if( aBackground )
975 {
976 // No filled shapes (yet)
977 }
978 else
979 {
980 aPlotter->PlotText( textpos, color, GetShownText(), attrs, font );
981
982 if( s_poly.size() )
983 aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth );
984
985 // Plot attributes to a hypertext menu
986 std::vector<wxString> properties;
987
988 if( connection )
989 {
990 properties.emplace_back(
991 wxString::Format( wxT( "!%s = %s" ), _( "Net" ), connection->Name() ) );
992
993 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Resolved netclass" ),
994 GetEffectiveNetClass()->GetName() ) );
995 }
996
997 for( const SCH_FIELD& field : GetFields() )
998 {
999 properties.emplace_back(
1000 wxString::Format( wxT( "!%s = %s" ), field.GetName(), field.GetShownText() ) );
1001 }
1002
1003 if( !properties.empty() )
1004 aPlotter->HyperlinkMenu( GetBodyBoundingBox(), properties );
1005
1006 if( Type() == SCH_HIER_LABEL_T )
1007 {
1008 aPlotter->Bookmark( GetBodyBoundingBox(), GetShownText(), _( "Hierarchical Labels" ) );
1009 }
1010 }
1011
1012 for( const SCH_FIELD& field : m_fields )
1013 field.Plot( aPlotter, aBackground );
1014}
1015
1016
1017void SCH_LABEL_BASE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
1018{
1019 static std::vector<VECTOR2I> s_poly;
1020
1021 SCH_CONNECTION* connection = Connection();
1022 int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
1023 wxDC* DC = aSettings->GetPrintDC();
1024 COLOR4D color = aSettings->GetLayerColor( layer );
1025 bool blackAndWhiteMode = GetGRForceBlackPenState();
1026 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
1027 VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings );
1028
1029 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
1030 color = GetTextColor();
1031
1032 EDA_TEXT::Print( aSettings, text_offset, color );
1033
1034 CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset );
1035
1036 if( !s_poly.empty() )
1037 GRPoly( DC, s_poly.size(), &s_poly[0], false, penWidth, color, color );
1038
1039 for( SCH_FIELD& field : m_fields )
1040 field.Print( aSettings, aOffset );
1041}
1042
1044{
1046}
1047
1049{
1050 m_autoRotateOnPlacement = autoRotate;
1051}
1052
1053SCH_LABEL::SCH_LABEL( const VECTOR2I& pos, const wxString& text ) :
1055{
1058 m_isDangling = true;
1059}
1060
1061
1063{
1064 BOX2I rect = GetTextBox();
1065
1066 rect.Offset( 0, -GetTextOffset() );
1068
1069 if( !GetTextAngle().IsZero() )
1070 {
1071 // Rotate rect
1072 VECTOR2I pos = rect.GetOrigin();
1073 VECTOR2I end = rect.GetEnd();
1074
1075 RotatePoint( pos, GetTextPos(), GetTextAngle() );
1076 RotatePoint( end, GetTextPos(), GetTextAngle() );
1077
1078 rect.SetOrigin( pos );
1079 rect.SetEnd( end );
1080
1081 rect.Normalize();
1082 }
1083
1084 // Labels have a position point that is outside of the TextBox
1085 rect.Merge( GetPosition() );
1086
1087 return rect;
1088}
1089
1090
1091wxString SCH_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
1092{
1093 return wxString::Format( _( "Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) );
1094}
1095
1096
1098{
1100}
1101
1102
1104 SCH_LABEL_BASE( pos, wxEmptyString, SCH_DIRECTIVE_LABEL_T )
1105{
1110 m_isDangling = true;
1111}
1112
1113
1115{
1116 SCH_LABEL_BASE::SwapData( aItem );
1117 SCH_DIRECTIVE_LABEL* label = static_cast<SCH_DIRECTIVE_LABEL*>( aItem );
1118
1119 std::swap( m_pinLength, label->m_pinLength );
1120 std::swap( m_symbolSize, label->m_symbolSize );
1121}
1122
1123
1125 SCH_LABEL_BASE( aClassLabel )
1126{
1127 m_pinLength = aClassLabel.m_pinLength;
1128 m_symbolSize = aClassLabel.m_symbolSize;
1129}
1130
1131
1133{
1134 int pen = 0;
1135
1136 if( Schematic() )
1138
1139 return GetEffectiveTextPenWidth( pen );
1140}
1141
1142
1144 std::vector<VECTOR2I>& aPoints,
1145 const VECTOR2I& aPos ) const
1146{
1147 int symbolSize = m_symbolSize;
1148
1149 aPoints.clear();
1150
1151 switch( m_shape )
1152 {
1154 symbolSize = KiROUND( symbolSize * 0.7 );
1156
1158 // First 3 points are used for generating shape
1159 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1160 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1161 aPoints.emplace_back( VECTOR2I( 0, m_pinLength ) );
1162 // These points are just used to bulk out the bounding box
1163 aPoints.emplace_back( VECTOR2I( -m_symbolSize, m_pinLength ) );
1164 aPoints.emplace_back( VECTOR2I( 0, m_pinLength ) );
1165 aPoints.emplace_back( VECTOR2I( m_symbolSize, m_pinLength + symbolSize ) );
1166 break;
1167
1169 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1170 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1171 aPoints.emplace_back( VECTOR2I( -2 * m_symbolSize, m_pinLength ) );
1172 aPoints.emplace_back( VECTOR2I( 0, m_pinLength + symbolSize ) );
1173 aPoints.emplace_back( VECTOR2I( 2 * m_symbolSize, m_pinLength ) );
1174 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1175 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1176 break;
1177
1179 symbolSize = KiROUND( symbolSize * 0.8 );
1180
1181 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1182 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1183 aPoints.emplace_back( VECTOR2I( -2 * symbolSize, m_pinLength - symbolSize ) );
1184 aPoints.emplace_back( VECTOR2I( -2 * symbolSize, m_pinLength + symbolSize ) );
1185 aPoints.emplace_back( VECTOR2I( 2 * symbolSize, m_pinLength + symbolSize ) );
1186 aPoints.emplace_back( VECTOR2I( 2 * symbolSize, m_pinLength - symbolSize ) );
1187 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1188 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1189 break;
1190
1191 default:
1192 break;
1193 }
1194
1195 // Rotate outlines and move corners to real position
1196 for( VECTOR2I& aPoint : aPoints )
1197 {
1198 switch( GetTextSpinStyle() )
1199 {
1200 default:
1201 case TEXT_SPIN_STYLE::LEFT: break;
1202 case TEXT_SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
1203 case TEXT_SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
1204 case TEXT_SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
1205 }
1206
1207 aPoint += aPos;
1208 }
1209}
1210
1211
1213{
1214 int margin = GetTextOffset();
1215 int symbolWidth = m_symbolSize;
1216 int origin = m_pinLength;
1217
1219 symbolWidth *= 2;
1220
1221 if( IsItalic() )
1222 margin = KiROUND( margin * 1.5 );
1223
1224 VECTOR2I offset;
1225
1226 for( SCH_FIELD& field : m_fields )
1227 {
1228 switch( GetTextSpinStyle() )
1229 {
1230 default:
1232 field.SetTextAngle( ANGLE_HORIZONTAL );
1233 offset = { symbolWidth + margin, origin };
1234 break;
1235
1237 field.SetTextAngle( ANGLE_VERTICAL );
1238 offset = { -origin, -( symbolWidth + margin ) };
1239 break;
1240
1242 field.SetTextAngle( ANGLE_HORIZONTAL );
1243 offset = { symbolWidth + margin, -origin };
1244 break;
1245
1247 field.SetTextAngle( ANGLE_VERTICAL );
1248 offset = { origin, -( symbolWidth + margin ) };
1249 break;
1250 }
1251
1252 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1253 field.SetTextPos( GetPosition() + offset );
1254
1255 origin -= field.GetTextHeight() + margin;
1256 }
1257
1259}
1260
1261
1263{
1264 if( m_fields.empty() )
1265 {
1266 return _( "Directive Label" );
1267 }
1268 else
1269 {
1270 return wxString::Format( _( "Directive Label [%s %s]" ),
1271 m_fields[0].GetName(),
1272 m_fields[0].GetShownText() );
1273 }
1274}
1275
1276
1277SCH_GLOBALLABEL::SCH_GLOBALLABEL( const VECTOR2I& pos, const wxString& text ) :
1279{
1282 m_isDangling = true;
1283
1285
1286 m_fields.emplace_back( SCH_FIELD( pos, 0, this, wxT( "Sheet References" ) ) );
1287 m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) );
1288 m_fields[0].SetVisible( false );
1289 m_fields[0].SetLayer( LAYER_INTERSHEET_REFS );
1290 m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
1291}
1292
1293
1295 SCH_LABEL_BASE( aGlobalLabel )
1296{
1297}
1298
1299
1301{
1302 int horiz = GetLabelBoxExpansion( aSettings );
1303
1304 // Center the text on the center line of "E" instead of "R" to make room for an overbar
1305 int vert = GetTextHeight() * 0.0715;
1306
1307 switch( m_shape )
1308 {
1312 horiz += GetTextHeight() * 3 / 4; // Use three-quarters-height as proxy for triangle size
1313 break;
1314
1317 default:
1318 break;
1319 }
1320
1321 switch( GetTextSpinStyle() )
1322 {
1323 default:
1324 case TEXT_SPIN_STYLE::LEFT: return VECTOR2I( -horiz, vert );
1325 case TEXT_SPIN_STYLE::UP: return VECTOR2I( vert, -horiz );
1326 case TEXT_SPIN_STYLE::RIGHT: return VECTOR2I( horiz, vert );
1327 case TEXT_SPIN_STYLE::BOTTOM: return VECTOR2I( vert, horiz );
1328 }
1329}
1330
1331
1333{
1334 SCH_TEXT::SetTextSpinStyle( aSpinStyle );
1336}
1337
1338
1340{
1341 SCH_TEXT::MirrorSpinStyle( aLeftRight );
1342
1343 for( SCH_FIELD& field : m_fields )
1344 {
1345 if( ( aLeftRight && field.GetTextAngle().IsHorizontal() )
1346 || ( !aLeftRight && field.GetTextAngle().IsVertical() ) )
1347 {
1348 if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
1349 field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
1350 else
1351 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1352 }
1353
1354 VECTOR2I pos = field.GetTextPos();
1356
1357 if( aLeftRight )
1358 pos.x = GetPosition().x + delta.x;
1359 else
1360 pos.y = GetPosition().y + delta.y;
1361
1362 field.SetTextPos( pos );
1363 }
1364}
1365
1366
1368{
1369 VECTOR2I old_pos = GetPosition();
1371
1372 for( SCH_FIELD& field : m_fields )
1373 {
1374 switch( field.GetHorizJustify() )
1375 {
1377 field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
1378 break;
1379
1381 break;
1382
1384 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1385 break;
1386 }
1387
1388 VECTOR2I pos = field.GetTextPos();
1389 VECTOR2I delta = old_pos - pos;
1390 pos.x = GetPosition().x + delta.x;
1391
1392 field.SetPosition( pos );
1393 }
1394}
1395
1396
1398{
1399 VECTOR2I old_pos = GetPosition();
1400 SCH_TEXT::MirrorVertically( aCenter );
1401
1402 for( SCH_FIELD& field : m_fields )
1403 {
1404 VECTOR2I pos = field.GetTextPos();
1405 VECTOR2I delta = old_pos - pos;
1406 pos.y = GetPosition().y + delta.y;
1407
1408 field.SetPosition( pos );
1409 }
1410}
1411
1412
1413bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
1414{
1415 if( token->IsSameAs( wxT( "INTERSHEET_REFS" ) ) && Schematic() )
1416 {
1417 SCHEMATIC_SETTINGS& settings = Schematic()->Settings();
1418 wxString ref;
1419 auto it = Schematic()->GetPageRefsMap().find( GetText() );
1420
1421 if( it == Schematic()->GetPageRefsMap().end() )
1422 {
1423 ref = "?";
1424 }
1425 else
1426 {
1427 std::vector<int> pageListCopy;
1428
1429 pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
1430 std::sort( pageListCopy.begin(), pageListCopy.end() );
1431
1432 if( !settings.m_IntersheetRefsListOwnPage )
1433 {
1434 int currentPage = Schematic()->CurrentSheet().GetVirtualPageNumber();
1435 alg::delete_matching( pageListCopy, currentPage );
1436 }
1437
1438 std::map<int, wxString> sheetPages = Schematic()->GetVirtualPageToSheetPagesMap();
1439
1440 if( ( settings.m_IntersheetRefsFormatShort ) && ( pageListCopy.size() > 2 ) )
1441 {
1442 ref.Append( wxString::Format( wxT( "%s..%s" ),
1443 sheetPages[pageListCopy.front()],
1444 sheetPages[pageListCopy.back()] ) );
1445 }
1446 else
1447 {
1448 for( const int& pageNo : pageListCopy )
1449 ref.Append( wxString::Format( wxT( "%s," ), sheetPages[pageNo] ) );
1450
1451 if( !ref.IsEmpty() && ref.Last() == ',' )
1452 ref.RemoveLast();
1453 }
1454 }
1455
1456 *token = settings.m_IntersheetRefsPrefix + ref + settings.m_IntersheetRefsSuffix;
1457 return true;
1458 }
1459
1460 return SCH_LABEL_BASE::ResolveTextVar( token, aDepth );
1461}
1462
1463
1464void SCH_GLOBALLABEL::ViewGetLayers( int aLayers[], int& aCount ) const
1465{
1466 aCount = 6;
1467 aLayers[0] = LAYER_DANGLING;
1468 aLayers[1] = LAYER_DEVICE;
1469 aLayers[2] = LAYER_INTERSHEET_REFS;
1470 aLayers[3] = LAYER_NETCLASS_REFS;
1471 aLayers[4] = LAYER_FIELDS;
1472 aLayers[5] = LAYER_SELECTION_SHADOWS;
1473}
1474
1475
1477 std::vector<VECTOR2I>& aPoints,
1478 const VECTOR2I& aPos ) const
1479{
1480 int margin = GetLabelBoxExpansion( aRenderSettings );
1481 int halfSize = ( GetTextHeight() / 2 ) + margin;
1482 int linewidth = GetPenWidth();
1483 int symb_len = GetTextBox().GetWidth() + 2 * margin;
1484
1485 int x = symb_len + linewidth + 3;
1486 int y = halfSize + linewidth + 3;
1487
1488 aPoints.clear();
1489
1490 // Create outline shape : 6 points
1491 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1492 aPoints.emplace_back( VECTOR2I( 0, -y ) ); // Up
1493 aPoints.emplace_back( VECTOR2I( -x, -y ) ); // left
1494 aPoints.emplace_back( VECTOR2I( -x, 0 ) ); // Up left
1495 aPoints.emplace_back( VECTOR2I( -x, y ) ); // left down
1496 aPoints.emplace_back( VECTOR2I( 0, y ) ); // down
1497
1498 int x_offset = 0;
1499
1500 switch( m_shape )
1501 {
1503 x_offset = -halfSize;
1504 aPoints[0].x += halfSize;
1505 break;
1506
1508 aPoints[3].x -= halfSize;
1509 break;
1510
1513 x_offset = -halfSize;
1514 aPoints[0].x += halfSize;
1515 aPoints[3].x -= halfSize;
1516 break;
1517
1519 default:
1520 break;
1521 }
1522
1523 // Rotate outlines and move corners in real position
1524 for( VECTOR2I& aPoint : aPoints )
1525 {
1526 aPoint.x += x_offset;
1527
1528 switch( GetTextSpinStyle() )
1529 {
1530 default:
1531 case TEXT_SPIN_STYLE::LEFT: break;
1532 case TEXT_SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
1533 case TEXT_SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
1534 case TEXT_SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
1535 }
1536
1537 aPoint += aPos;
1538 }
1539
1540 aPoints.push_back( aPoints[0] ); // closing
1541}
1542
1543
1545{
1546 return wxString::Format( _( "Global Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) );
1547}
1548
1549
1551{
1552 return BITMAPS::add_glabel;
1553}
1554
1555
1556SCH_HIERLABEL::SCH_HIERLABEL( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
1557 SCH_LABEL_BASE( pos, text, aType )
1558{
1561 m_isDangling = true;
1562}
1563
1564
1566{
1567 SCH_TEXT::SetTextSpinStyle( aSpinStyle );
1569}
1570
1571
1573 std::vector<VECTOR2I>& aPoints, const VECTOR2I& aPos ) const
1574{
1575 CreateGraphicShape( aSettings, aPoints, aPos, m_shape );
1576}
1577
1578
1580 std::vector<VECTOR2I>& aPoints, const VECTOR2I& aPos,
1581 LABEL_FLAG_SHAPE aShape ) const
1582{
1583 int* Template = TemplateShape[static_cast<int>( aShape )][static_cast<int>( m_spin_style )];
1584 int halfSize = GetTextHeight() / 2;
1585 int imax = *Template;
1586 Template++;
1587
1588 aPoints.clear();
1589
1590 for( int ii = 0; ii < imax; ii++ )
1591 {
1592 VECTOR2I corner;
1593 corner.x = ( halfSize * (*Template) ) + aPos.x;
1594 Template++;
1595
1596 corner.y = ( halfSize * (*Template) ) + aPos.y;
1597 Template++;
1598
1599 aPoints.push_back( corner );
1600 }
1601}
1602
1603
1605{
1606 int penWidth = GetEffectiveTextPenWidth();
1607 int margin = GetTextOffset();
1608
1609 int x = GetTextPos().x;
1610 int y = GetTextPos().y;
1611
1612 int height = GetTextHeight() + penWidth + margin;
1613 int length = GetTextBox().GetWidth();
1614
1615 length += height; // add height for triangular shapes
1616
1617 int dx, dy;
1618
1619 switch( GetTextSpinStyle() )
1620 {
1621 default:
1623 dx = -length;
1624 dy = height;
1626 y -= height / 2;
1627 break;
1628
1630 dx = height;
1631 dy = -length;
1632 x -= height / 2;
1634 break;
1635
1637 dx = length;
1638 dy = height;
1640 y -= height / 2;
1641 break;
1642
1644 dx = height;
1645 dy = length;
1646 x -= height / 2;
1648 break;
1649 }
1650
1651 BOX2I box( VECTOR2I( x, y ), VECTOR2I( dx, dy ) );
1652 box.Normalize();
1653 return box;
1654}
1655
1656
1658{
1659 VECTOR2I text_offset;
1660 int dist = GetTextOffset( aSettings );
1661
1662 dist += GetTextWidth();
1663
1664 switch( GetTextSpinStyle() )
1665 {
1666 default:
1667 case TEXT_SPIN_STYLE::LEFT: text_offset.x = -dist; break; // Orientation horiz normale
1668 case TEXT_SPIN_STYLE::UP: text_offset.y = -dist; break; // Orientation vert UP
1669 case TEXT_SPIN_STYLE::RIGHT: text_offset.x = dist; break; // Orientation horiz inverse
1670 case TEXT_SPIN_STYLE::BOTTOM: text_offset.y = dist; break; // Orientation vert BOTTOM
1671 }
1672
1673 return text_offset;
1674}
1675
1676
1677wxString SCH_HIERLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
1678{
1679 return wxString::Format( _( "Hierarchical Label '%s'" ),
1681}
1682
1683
1685{
1687}
1688
1689
1691{
1692 wxString msg =
1693#include "sch_text_help_md.h"
1694 ;
1695
1696 HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) );
1697 wxSize sz( 320, 320 );
1698
1699 dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) );
1700 dlg->SetDialogSizeInDU( sz.x, sz.y );
1701
1702 wxString html_txt;
1703 ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt );
1704 dlg->AddHTML_Text( html_txt );
1705 dlg->ShowModeless();
1706
1707 return dlg;
1708}
int color
Definition: DXF_plotter.cpp:57
const char * name
Definition: DXF_plotter.cpp:56
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
@ add_line_label
@ add_hierarchical_label
void SetOrigin(const Vec &pos)
Definition: box2.h:202
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
int GetSizeMax() const
Definition: box2.h:200
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
coord_type GetWidth() const
Definition: box2.h:187
const Vec GetEnd() const
Definition: box2.h:185
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
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:82
DANGLING_END_T GetType() const
Definition: sch_item.h:126
EDA_ITEM * GetItem() const
Definition: sch_item.h:124
VECTOR2I GetPosition() const
Definition: sch_item.h:123
The base class for create windows for drawing purpose.
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 void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496
int GetTextHeight() const
Definition: eda_text.h:202
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:505
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
COLOR4D GetTextColor() const
Definition: eda_text.h:205
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 SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:373
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
int GetTextWidth() const
Definition: eda_text.h:199
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:250
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:320
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:103
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
bool IsBold() const
Definition: eda_text.h:133
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:165
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 Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aDisplay_mode=FILLED)
Print this text object to the device context aDC.
Definition: eda_text.cpp:650
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:234
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
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:138
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
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.
wxDC * GetPrintDC() const
Store schematic specific render settings.
Definition: sch_painter.h:71
Base plotter engine class.
Definition: plotter.h:110
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
Definition: plotter.h:477
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
Definition: plotter.cpp:758
bool GetColorMode() const
Definition: plotter.h:138
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:466
These settings were stored in SCH_BASE_FRAME previously.
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:122
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
Definition: schematic.cpp:630
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:205
std::map< wxString, std::set< int > > & GetPageRefsMap()
Definition: schematic.h:163
std::map< int, wxString > GetVirtualPageToSheetPagesMap() const
Definition: schematic.cpp:374
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
Definition: schematic.cpp:358
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString LocalName() const
wxString Name(bool aIgnoreSheet=false) const
bool IsBus() const
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_label.cpp:1114
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:1212
SCH_DIRECTIVE_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0))
Definition: sch_label.cpp:1103
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_label.cpp:1143
int GetPenWidth() const override
Definition: sch_label.cpp:1132
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1262
Schematic editor (Eeschema) main window.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_label.cpp:1464
void CreateGraphicShape(const RENDER_SETTINGS *aRenderSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_label.cpp:1476
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_label.cpp:1397
bool ResolveTextVar(wxString *token, int aDepth) const override
Resolve any references to system tokens supported by the label.
Definition: sch_label.cpp:1413
void MirrorSpinStyle(bool aLeftRight) override
Definition: sch_label.cpp:1339
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:1300
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1544
SCH_GLOBALLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
Definition: sch_label.cpp:1277
void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_label.cpp:1332
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1550
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_label.cpp:1367
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:1604
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_label.cpp:1572
SCH_HIERLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
Definition: sch_label.cpp:1556
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1684
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:1657
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1677
void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_label.cpp:1565
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
Definition: sch_item.cpp:193
std::map< SCH_SHEET_PATH, SCH_ITEM_SET, SHEET_PATH_CMP > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:498
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:166
void ClearFieldsAutoplaced()
Definition: sch_item.h:427
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:493
bool IsConnectivityDirty() const
Definition: sch_item.h:413
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:146
SCH_LAYER_ID m_layer
Definition: sch_item.h:491
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:162
SCH_LABEL_BASE(const VECTOR2I &aPos, const wxString &aText, KICAD_T aType)
Definition: sch_label.cpp:155
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_label.cpp:683
COLOR4D m_lastResolvedColor
Definition: sch_label.h:227
bool m_isDangling
Definition: sch_label.h:224
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: sch_label.cpp:645
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_label.cpp:629
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_label.cpp:752
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
Definition: sch_label.cpp:670
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1043
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_label.cpp:294
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_label.cpp:598
std::vector< SCH_FIELD > m_fields
Definition: sch_label.h:219
CONNECTION_TYPE m_connectionType
Definition: sch_label.h:223
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_label.cpp:241
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
Resolve any references to system tokens supported by the label.
Definition: sch_label.cpp:495
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_label.cpp:677
COLOR4D GetLabelColor() const
Definition: sch_label.cpp:263
const BOX2I GetBoundingBox() const override
Return the bounding box of the label including its fields.
Definition: sch_label.cpp:727
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_label.cpp:196
bool m_autoRotateOnPlacement
Definition: sch_label.h:225
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &offset) override
Print a schematic item.
Definition: sch_label.cpp:1017
int GetLabelBoxExpansion(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_label.cpp:694
bool IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_label.cpp:362
void SetAutoRotateOnPlacement(bool autoRotate=true)
setAutoRotateOnPlacement
Definition: sch_label.cpp:1048
void Rotate90(bool aClockwise) override
Definition: sch_label.cpp:309
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
Definition: sch_label.cpp:813
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_label.cpp:888
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:183
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:376
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
Definition: sch_label.cpp:622
LABEL_FLAG_SHAPE GetShape() const override
Definition: sch_label.h:73
LABEL_FLAG_SHAPE m_shape
Definition: sch_label.h:221
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this label.
Definition: sch_label.cpp:482
virtual const BOX2I GetBodyBoundingBox() const
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:709
virtual void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &Pos) const
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_label.h:159
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:90
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
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
Definition: sch_label.cpp:946
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
Definition: sch_label.cpp:635
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_label.cpp:1091
SCH_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
Definition: sch_label.cpp:1053
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:1062
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1097
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.
int GetVirtualPageNumber() const
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:237
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_text.cpp:149
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Definition: sch_label.cpp:1690
VECTOR2I GetPosition() const override
Definition: sch_text.h:203
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:170
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_text.cpp:140
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:226
TEXT_SPIN_STYLE GetTextSpinStyle() const
Definition: sch_text.h:148
int GetPenWidth() const override
Definition: sch_text.cpp:273
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:188
TEXT_SPIN_STYLE m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:238
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:179
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_text.cpp:258
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
#define DEFAULT_LABEL_SIZE_RATIO
The offset of the pin name string from the end of the pin in mils.
#define DANGLING_SYMBOL_SIZE
< The size of the rectangle indicating an unconnected wire or label
#define _(s)
static constexpr EDA_ANGLE & ANGLE_180
Definition: eda_angle.h:433
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:426
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
INSPECT_RESULT
Definition: eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:78
void GRPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
Definition: gr_basic.cpp:341
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
@ NONE
Definition: kibis.h:53
@ LAYER_DANGLING
Definition: layer_ids.h:368
@ LAYER_DEVICE
Definition: layer_ids.h:357
@ LAYER_HIERLABEL
Definition: layer_ids.h:349
@ LAYER_GLOBLABEL
Definition: layer_ids.h:348
@ LAYER_BUS
Definition: layer_ids.h:345
@ LAYER_FIELDS
Definition: layer_ids.h:354
@ LAYER_LOCLABEL
Definition: layer_ids.h:347
@ LAYER_NETCLASS_REFS
Definition: layer_ids.h:356
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:381
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:355
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
Message panel definition file.
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:215
void delete_matching(_Container &__c, _Value __value)
Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything).
Definition: kicad_algo.h:164
see class PGM_BASE
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
CONNECTION_TYPE
@ BUS
This item represents a bus vector.
@ NET
This item represents a net.
@ NONE
No connection to this item.
@ NO_CONNECT_END
Definition: sch_item.h:73
@ SHEET_LABEL_END
Definition: sch_item.h:72
@ LABEL_END
Definition: sch_item.h:69
@ BUS_END
Definition: sch_item.h:66
@ PIN_END
Definition: sch_item.h:68
@ WIRE_END
Definition: sch_item.h:65
std::vector< SCH_ITEM * > SCH_ITEM_SET
Definition: sch_item.h:136
@ FIELDS_AUTOPLACED_AUTO
Definition: sch_item.h:57
static int TemplateIN_HI[]
Definition: sch_label.cpp:107
static int TemplateUNSPC_HI[]
Definition: sch_label.cpp:117
static int TemplateOUT_HN[]
Definition: sch_label.cpp:111
static int Template3STATE_HN[]
Definition: sch_label.cpp:126
static int TemplateBIDI_HN[]
Definition: sch_label.cpp:121
static int * TemplateShape[5][4]
Definition: sch_label.cpp:131
bool IncrementLabelMember(wxString &name, int aIncrement)
Definition: sch_label.cpp:49
static int TemplateIN_HN[]
Definition: sch_label.cpp:106
static int TemplateIN_BOTTOM[]
Definition: sch_label.cpp:109
static int TemplateUNSPC_HN[]
Definition: sch_label.cpp:116
static int Template3STATE_BOTTOM[]
Definition: sch_label.cpp:129
static int TemplateBIDI_BOTTOM[]
Definition: sch_label.cpp:124
static int Template3STATE_UP[]
Definition: sch_label.cpp:128
static int TemplateOUT_UP[]
Definition: sch_label.cpp:113
static int TemplateOUT_HI[]
Definition: sch_label.cpp:112
static int TemplateUNSPC_UP[]
Definition: sch_label.cpp:118
static int TemplateUNSPC_BOTTOM[]
Definition: sch_label.cpp:119
static int TemplateOUT_BOTTOM[]
Definition: sch_label.cpp:114
static int Template3STATE_HI[]
Definition: sch_label.cpp:127
static int TemplateIN_UP[]
Definition: sch_label.cpp:108
wxString getElectricalTypeLabel(LABEL_FLAG_SHAPE aType)
Definition: sch_label.cpp:141
static int TemplateBIDI_UP[]
Definition: sch_label.cpp:123
static int TemplateBIDI_HI[]
Definition: sch_label.cpp:122
LABEL_FLAG_SHAPE
Definition: sch_text.h:96
@ L_BIDI
Definition: sch_text.h:99
@ L_TRISTATE
Definition: sch_text.h:100
@ L_UNSPECIFIED
Definition: sch_text.h:101
@ F_DOT
Definition: sch_text.h:104
@ F_ROUND
Definition: sch_text.h:105
@ L_OUTPUT
Definition: sch_text.h:98
@ F_DIAMOND
Definition: sch_text.h:106
@ L_INPUT
Definition: sch_text.h:97
@ F_RECTANGLE
Definition: sch_text.h:107
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_NETNAME
Definition: string_utils.h:54
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
wxString replaceString
constexpr int delta
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_CENTER
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:154
@ SCH_LABEL_T
Definition: typeinfo.h:151
@ SCH_LOCATE_ANY_T
Definition: typeinfo.h:183
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:175
@ SCH_LABEL_LOCATE_WIRE_T
Definition: typeinfo.h:176
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_LABEL_LOCATE_BUS_T
Definition: typeinfo.h:177
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590