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-2022 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( "%%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( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
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( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
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( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
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( Type() == SCH_GLOBAL_LABEL_T && field.GetId() == 0 )
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( Type() != SCH_GLOBAL_LABEL_T || field.GetId() > 0 )
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
482bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
483{
484 if( token->Contains( ':' ) )
485 {
486 if( !Schematic() )
487 return false;
488
489 if( Schematic()->ResolveCrossReference( token, aDepth ) )
490 return true;
491 }
492
494 && token->IsSameAs( wxT( "CONNECTION_TYPE" ) ) )
495 {
496 const SCH_LABEL_BASE* label = static_cast<const SCH_LABEL_BASE*>( this );
497 *token = getElectricalTypeLabel( label->GetShape() );
498 return true;
499 }
500 else if( token->IsSameAs( wxT( "SHORT_NET_NAME" ) ) )
501 {
502 const SCH_CONNECTION* connection = Connection();
503 *token = wxEmptyString;
504
505 if( connection )
506 *token = connection->LocalName();
507
508 return true;
509 }
510 else if( token->IsSameAs( wxT( "NET_NAME" ) ) )
511 {
512 const SCH_CONNECTION* connection = Connection();
513 *token = wxEmptyString;
514
515 if( connection )
516 *token = connection->Name();
517
518 return true;
519 }
520 else if( token->IsSameAs( wxT( "NET_CLASS" ) ) )
521 {
522 const SCH_CONNECTION* connection = Connection();
523 *token = wxEmptyString;
524
525 if( connection )
526 *token = GetEffectiveNetClass()->GetName();
527
528 return true;
529 }
530
531 for( size_t i = 0; i < m_fields.size(); ++i )
532 {
533 if( token->IsSameAs( m_fields[i].GetName() ) )
534 {
535 *token = m_fields[i].GetShownText( aDepth + 1 );
536 return true;
537 }
538 }
539
540 if( Type() == SCH_SHEET_PIN_T && m_parent )
541 {
542 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
543
544 if( sheet->ResolveTextVar( token, aDepth ) )
545 return true;
546 }
547 else if( Schematic() )
548 {
549 if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() )
550 {
551 if( sheet->ResolveTextVar( token, aDepth ) )
552 return true;
553 }
554 }
555
556 return false;
557}
558
559
560wxString SCH_LABEL_BASE::GetShownText( int aDepth, bool aAllowExtraText ) const
561{
562 std::function<bool( wxString* )> textResolver =
563 [&]( wxString* token ) -> bool
564 {
565 return ResolveTextVar( token, aDepth );
566 };
567
568 std::function<bool( wxString* )> schematicTextResolver =
569 [&]( wxString* token ) -> bool
570 {
571 return Schematic()->ResolveTextVar( token, aDepth + 1 );
572 };
573
574 wxString text = EDA_TEXT::GetShownText();
575
576 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
577 {
578 text = wxS( "" );
579 }
580 else if( HasTextVars() )
581 {
582 PROJECT* project = nullptr;
583
584 if( Schematic() )
585 project = &Schematic()->Prj();
586
587 if( aDepth < 10 )
588 text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project );
589 }
590
591 return text;
592}
593
594
595void SCH_LABEL_BASE::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
596{
597 for( SCH_FIELD& field : m_fields )
598 aFunction( &field );
599}
600
601
602bool SCH_LABEL_BASE::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
603{
604 return SCH_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
605}
606
607
608bool SCH_LABEL_BASE::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
609{
610 EDA_SEARCH_DATA localSearchData( aSearchData );
611 localSearchData.findString = EscapeString( aSearchData.findString, CTX_NETNAME );
612 localSearchData.replaceString = EscapeString( aSearchData.replaceString, CTX_NETNAME );
613
614 return EDA_TEXT::Replace( localSearchData );
615}
616
617
619 const std::vector<KICAD_T>& aScanTypes )
620{
621 if( IsType( aScanTypes ) )
622 {
623 if( INSPECT_RESULT::QUIT == aInspector( this, nullptr ) )
625 }
626
627 for( KICAD_T scanType : aScanTypes )
628 {
629 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
630 {
631 for( SCH_FIELD& field : m_fields )
632 {
633 if( INSPECT_RESULT::QUIT == aInspector( &field, this ) )
635 }
636 }
637 }
638
640}
641
642
643void SCH_LABEL_BASE::GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList )
644{
645 DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
646 aItemList.push_back( item );
647}
648
649
650std::vector<VECTOR2I> SCH_LABEL_BASE::GetConnectionPoints() const
651{
652 return { GetTextPos() };
653}
654
655
656void SCH_LABEL_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
657{
658 aCount = 5;
659 aLayers[0] = LAYER_DANGLING;
660 aLayers[1] = LAYER_DEVICE;
661 aLayers[2] = LAYER_NETCLASS_REFS;
662 aLayers[3] = LAYER_FIELDS;
663 aLayers[4] = LAYER_SELECTION_SHADOWS;
664}
665
666
668{
669 double ratio;
670
671 if( aSettings )
672 ratio = static_cast<const SCH_RENDER_SETTINGS*>( aSettings )->m_LabelSizeRatio;
673 else if( Schematic() )
675 else
676 ratio = DEFAULT_LABEL_SIZE_RATIO; // For previews (such as in Preferences), etc.
677
678 return KiROUND( ratio * GetTextSize().y );
679}
680
681
683{
684 // build the bounding box of the label only, without taking into account its fields
685
686 BOX2I box;
687 std::vector<VECTOR2I> pts;
688
689 CreateGraphicShape( nullptr, pts, GetTextPos() );
690
691 for( const VECTOR2I& pt : pts )
692 box.Merge( pt );
693
695 box.Normalize();
696 return box;
697}
698
699
701{
702 // build the bounding box of the entire label, including its fields
703
705
706 for( const SCH_FIELD& field : m_fields )
707 {
708 if( field.IsVisible() )
709 {
710 BOX2I fieldBBox = field.GetBoundingBox();
711
712 if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
713 fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
714
715 box.Merge( fieldBBox );
716 }
717 }
718
719 box.Normalize();
720
721 return box;
722}
723
724
725bool SCH_LABEL_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
726{
727 BOX2I bbox = GetBodyBoundingBox();
728 bbox.Inflate( aAccuracy );
729
730 if( bbox.Contains( aPosition ) )
731 return true;
732
733 for( const SCH_FIELD& field : m_fields )
734 {
735 if( field.IsVisible() )
736 {
737 BOX2I fieldBBox = field.GetBoundingBox();
738 fieldBBox.Inflate( aAccuracy );
739
740 if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
741 fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
742
743 if( fieldBBox.Contains( aPosition ) )
744 return true;
745 }
746 }
747
748 return false;
749}
750
751
752bool SCH_LABEL_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
753{
754 BOX2I rect = aRect;
755
756 rect.Inflate( aAccuracy );
757
758 if( aContained )
759 {
760 return rect.Contains( GetBoundingBox() );
761 }
762 else
763 {
764 if( rect.Intersects( GetBodyBoundingBox() ) )
765 return true;
766
767 for( const SCH_FIELD& field : m_fields )
768 {
769 if( field.IsVisible() )
770 {
771 BOX2I fieldBBox = field.GetBoundingBox();
772
773 if( Type() == SCH_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
774 fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
775
776 if( rect.Intersects( fieldBBox ) )
777 return true;
778 }
779 }
780
781 return false;
782 }
783}
784
785
786bool SCH_LABEL_BASE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
787 const SCH_SHEET_PATH* aPath )
788{
789 bool previousState = m_isDangling;
790 m_isDangling = true;
792
793 for( unsigned ii = 0; ii < aItemList.size(); ii++ )
794 {
795 DANGLING_END_ITEM& item = aItemList[ii];
796
797 if( item.GetItem() == this )
798 continue;
799
800 switch( item.GetType() )
801 {
802 case PIN_END:
803 case LABEL_END:
804 case SHEET_LABEL_END:
805 case NO_CONNECT_END:
806 if( GetTextPos() == item.GetPosition() )
807 {
808 m_isDangling = false;
809
810 if( aPath && item.GetType() != PIN_END )
811 AddConnectionTo( *aPath, static_cast<SCH_ITEM*>( item.GetItem() ) );
812 }
813
814 break;
815
816 case BUS_END:
819
820 case WIRE_END:
821 {
822 DANGLING_END_ITEM& nextItem = aItemList[++ii];
823
824 int accuracy = 1; // We have rounding issues with an accuracy of 0
825
827 nextItem.GetPosition(), accuracy );
828
829 if( !m_isDangling )
830 {
833
834 // Add the line to the connected items, since it won't be picked
835 // up by a search of intersecting connection points
836 if( aPath )
837 {
838 auto sch_item = static_cast<SCH_ITEM*>( item.GetItem() );
839 AddConnectionTo( *aPath, sch_item );
840 sch_item->AddConnectionTo( *aPath, this );
841 }
842 }
843 }
844 break;
845
846 default:
847 break;
848 }
849
850 if( !m_isDangling )
851 break;
852 }
853
854 if( m_isDangling )
856
857 return previousState != m_isDangling;
858}
859
860
861void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
862{
863 wxString msg;
864
865 switch( Type() )
866 {
867 case SCH_LABEL_T: msg = _( "Label" ); break;
868 case SCH_DIRECTIVE_LABEL_T: msg = _( "Directive Label" ); break;
869 case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
870 case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
871 case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
872 default: return;
873 }
874
875 // Don't use GetShownText() here; we want to show the user the variable references
876 aList.emplace_back( msg, UnescapeString( GetText() ) );
877
878 // Display electrical type if it is relevant
880 aList.emplace_back( _( "Type" ), getElectricalTypeLabel( GetShape() ) );
881
882 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
883
884 wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
885 int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
886 aList.emplace_back( _( "Style" ), textStyle[style] );
887
888 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
889
890 switch( GetTextSpinStyle() )
891 {
892 case TEXT_SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
893 case TEXT_SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
894 case TEXT_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
895 case TEXT_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
896 default: msg = wxT( "???" ); break;
897 }
898
899 aList.emplace_back( _( "Justification" ), msg );
900
901 SCH_CONNECTION* conn = nullptr;
902
903 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
904 conn = Connection();
905
906 if( conn )
907 {
908 conn->AppendInfoToMsgPanel( aList );
909
910 if( !conn->IsBus() )
911 {
912 aList.emplace_back( _( "Resolved Netclass" ),
913 UnescapeString( GetEffectiveNetClass()->GetName() ) );
914 }
915 }
916}
917
918
919void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
920{
921 static std::vector<VECTOR2I> s_poly;
922
923 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
924 SCH_CONNECTION* connection = Connection();
925 int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
926 COLOR4D color = settings->GetLayerColor( layer );
927 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
928
929 if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
931
932 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
933 aPlotter->SetCurrentLineWidth( penWidth );
934
935 KIFONT::FONT* font = GetFont();
936
937 if( !font )
938 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
939
940 VECTOR2I textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() );
941 CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() );
942
943 if( aBackground )
944 {
945 // No filled shapes (yet)
946 }
947 else
948 {
949 aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
950 GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold(),
951 false, font );
952
953 if( s_poly.size() )
954 aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth );
955
956 // Plot attributes to a hypertext menu
957 std::vector<wxString> properties;
958
959 if( connection )
960 {
961 properties.emplace_back(
962 wxString::Format( wxT( "!%s = %s" ), _( "Net" ), connection->Name() ) );
963
964 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Resolved netclass" ),
965 GetEffectiveNetClass()->GetName() ) );
966 }
967
968 for( const SCH_FIELD& field : GetFields() )
969 {
970 properties.emplace_back(
971 wxString::Format( wxT( "!%s = %s" ), field.GetName(), field.GetShownText() ) );
972 }
973
974 if( !properties.empty() )
975 aPlotter->HyperlinkMenu( GetBodyBoundingBox(), properties );
976
977 if( Type() == SCH_HIER_LABEL_T )
978 {
979 aPlotter->Bookmark( GetBodyBoundingBox(), GetShownText(), _( "Hierarchical Labels" ) );
980 }
981 }
982
983 for( const SCH_FIELD& field : m_fields )
984 field.Plot( aPlotter, aBackground );
985}
986
987
988void SCH_LABEL_BASE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
989{
990 static std::vector<VECTOR2I> s_poly;
991
992 SCH_CONNECTION* connection = Connection();
993 int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
994 wxDC* DC = aSettings->GetPrintDC();
995 COLOR4D color = aSettings->GetLayerColor( layer );
996 bool blackAndWhiteMode = GetGRForceBlackPenState();
997 int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
998 VECTOR2I text_offset = aOffset + GetSchematicTextOffset( aSettings );
999
1000 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
1001 color = GetTextColor();
1002
1003 EDA_TEXT::Print( aSettings, text_offset, color );
1004
1005 CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset );
1006
1007 if( !s_poly.empty() )
1008 GRPoly( DC, s_poly.size(), &s_poly[0], false, penWidth, color, color );
1009
1010 for( SCH_FIELD& field : m_fields )
1011 field.Print( aSettings, aOffset );
1012}
1013
1015{
1017}
1018
1020{
1021 m_autoRotateOnPlacement = autoRotate;
1022}
1023
1024SCH_LABEL::SCH_LABEL( const VECTOR2I& pos, const wxString& text ) :
1026{
1029 m_isDangling = true;
1030}
1031
1032
1034{
1035 BOX2I rect = GetTextBox();
1036
1037 rect.Offset( 0, -GetTextOffset() );
1039
1040 if( !GetTextAngle().IsZero() )
1041 {
1042 // Rotate rect
1043 VECTOR2I pos = rect.GetOrigin();
1044 VECTOR2I end = rect.GetEnd();
1045
1046 RotatePoint( pos, GetTextPos(), GetTextAngle() );
1047 RotatePoint( end, GetTextPos(), GetTextAngle() );
1048
1049 rect.SetOrigin( pos );
1050 rect.SetEnd( end );
1051
1052 rect.Normalize();
1053 }
1054
1055 // Labels have a position point that is outside of the TextBox
1056 rect.Merge( GetPosition() );
1057
1058 return rect;
1059}
1060
1061
1062wxString SCH_LABEL::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
1063{
1064 return wxString::Format( _( "Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) );
1065}
1066
1067
1069{
1071}
1072
1073
1075 SCH_LABEL_BASE( pos, wxEmptyString, SCH_DIRECTIVE_LABEL_T )
1076{
1081 m_isDangling = true;
1082}
1083
1084
1086{
1087 SCH_LABEL_BASE::SwapData( aItem );
1088 SCH_DIRECTIVE_LABEL* label = static_cast<SCH_DIRECTIVE_LABEL*>( aItem );
1089
1090 std::swap( m_pinLength, label->m_pinLength );
1091 std::swap( m_symbolSize, label->m_symbolSize );
1092}
1093
1094
1096 SCH_LABEL_BASE( aClassLabel )
1097{
1098 m_pinLength = aClassLabel.m_pinLength;
1099 m_symbolSize = aClassLabel.m_symbolSize;
1100}
1101
1102
1104{
1105 int pen = 0;
1106
1107 if( Schematic() )
1109
1110 return GetEffectiveTextPenWidth( pen );
1111}
1112
1113
1115 std::vector<VECTOR2I>& aPoints,
1116 const VECTOR2I& aPos ) const
1117{
1118 int symbolSize = m_symbolSize;
1119
1120 aPoints.clear();
1121
1122 switch( m_shape )
1123 {
1125 symbolSize = KiROUND( symbolSize * 0.7 );
1127
1129 // First 3 points are used for generating shape
1130 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1131 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1132 aPoints.emplace_back( VECTOR2I( 0, m_pinLength ) );
1133 // These points are just used to bulk out the bounding box
1134 aPoints.emplace_back( VECTOR2I( -m_symbolSize, m_pinLength ) );
1135 aPoints.emplace_back( VECTOR2I( 0, m_pinLength ) );
1136 aPoints.emplace_back( VECTOR2I( m_symbolSize, m_pinLength + symbolSize ) );
1137 break;
1138
1140 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1141 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1142 aPoints.emplace_back( VECTOR2I( -2 * m_symbolSize, m_pinLength ) );
1143 aPoints.emplace_back( VECTOR2I( 0, m_pinLength + symbolSize ) );
1144 aPoints.emplace_back( VECTOR2I( 2 * m_symbolSize, m_pinLength ) );
1145 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1146 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1147 break;
1148
1150 symbolSize = KiROUND( symbolSize * 0.8 );
1151
1152 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1153 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1154 aPoints.emplace_back( VECTOR2I( -2 * symbolSize, m_pinLength - symbolSize ) );
1155 aPoints.emplace_back( VECTOR2I( -2 * symbolSize, m_pinLength + symbolSize ) );
1156 aPoints.emplace_back( VECTOR2I( 2 * symbolSize, m_pinLength + symbolSize ) );
1157 aPoints.emplace_back( VECTOR2I( 2 * symbolSize, m_pinLength - symbolSize ) );
1158 aPoints.emplace_back( VECTOR2I( 0, m_pinLength - symbolSize ) );
1159 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1160 break;
1161
1162 default:
1163 break;
1164 }
1165
1166 // Rotate outlines and move corners to real position
1167 for( VECTOR2I& aPoint : aPoints )
1168 {
1169 switch( GetTextSpinStyle() )
1170 {
1171 default:
1172 case TEXT_SPIN_STYLE::LEFT: break;
1173 case TEXT_SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
1174 case TEXT_SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
1175 case TEXT_SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
1176 }
1177
1178 aPoint += aPos;
1179 }
1180}
1181
1182
1184{
1185 int margin = GetTextOffset();
1186 int symbolWidth = m_symbolSize;
1187 int origin = m_pinLength;
1188
1190 symbolWidth *= 2;
1191
1192 if( IsItalic() )
1193 margin = KiROUND( margin * 1.5 );
1194
1195 VECTOR2I offset;
1196
1197 for( SCH_FIELD& field : m_fields )
1198 {
1199 switch( GetTextSpinStyle() )
1200 {
1201 default:
1203 field.SetTextAngle( ANGLE_HORIZONTAL );
1204 offset = { symbolWidth + margin, origin };
1205 break;
1206
1208 field.SetTextAngle( ANGLE_VERTICAL );
1209 offset = { -origin, -( symbolWidth + margin ) };
1210 break;
1211
1213 field.SetTextAngle( ANGLE_HORIZONTAL );
1214 offset = { symbolWidth + margin, -origin };
1215 break;
1216
1218 field.SetTextAngle( ANGLE_VERTICAL );
1219 offset = { origin, -( symbolWidth + margin ) };
1220 break;
1221 }
1222
1223 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1224 field.SetTextPos( GetPosition() + offset );
1225
1226 origin -= field.GetTextHeight() + margin;
1227 }
1228
1230}
1231
1232
1234{
1235 if( m_fields.empty() )
1236 {
1237 return _( "Directive Label" );
1238 }
1239 else
1240 {
1241 return wxString::Format( _( "Directive Label [%s %s]" ),
1242 m_fields[0].GetName(),
1243 m_fields[0].GetShownText() );
1244 }
1245}
1246
1247
1248SCH_GLOBALLABEL::SCH_GLOBALLABEL( const VECTOR2I& pos, const wxString& text ) :
1250{
1253 m_isDangling = true;
1254
1256
1257 m_fields.emplace_back( SCH_FIELD( pos, 0, this, _( "Sheet References" ) ) );
1258 m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) );
1259 m_fields[0].SetVisible( false );
1260 m_fields[0].SetLayer( LAYER_INTERSHEET_REFS );
1261 m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
1262}
1263
1264
1266 SCH_LABEL_BASE( aGlobalLabel )
1267{
1268}
1269
1270
1272{
1273 int horiz = GetLabelBoxExpansion( aSettings );
1274
1275 // Center the text on the center line of "E" instead of "R" to make room for an overbar
1276 int vert = GetTextHeight() * 0.0715;
1277
1278 switch( m_shape )
1279 {
1283 horiz += GetTextHeight() * 3 / 4; // Use three-quarters-height as proxy for triangle size
1284 break;
1285
1288 default:
1289 break;
1290 }
1291
1292 switch( GetTextSpinStyle() )
1293 {
1294 default:
1295 case TEXT_SPIN_STYLE::LEFT: return VECTOR2I( -horiz, vert );
1296 case TEXT_SPIN_STYLE::UP: return VECTOR2I( vert, -horiz );
1297 case TEXT_SPIN_STYLE::RIGHT: return VECTOR2I( horiz, vert );
1298 case TEXT_SPIN_STYLE::BOTTOM: return VECTOR2I( vert, horiz );
1299 }
1300}
1301
1302
1304{
1305 SCH_TEXT::SetTextSpinStyle( aSpinStyle );
1307}
1308
1309
1311{
1312 SCH_TEXT::MirrorSpinStyle( aLeftRight );
1313
1314 for( SCH_FIELD& field : m_fields )
1315 {
1316 if( ( aLeftRight && field.GetTextAngle().IsHorizontal() )
1317 || ( !aLeftRight && field.GetTextAngle().IsVertical() ) )
1318 {
1319 if( field.GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT )
1320 field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
1321 else
1322 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1323 }
1324
1325 VECTOR2I pos = field.GetTextPos();
1327
1328 if( aLeftRight )
1329 pos.x = GetPosition().x + delta.x;
1330 else
1331 pos.y = GetPosition().y + delta.y;
1332
1333 field.SetTextPos( pos );
1334 }
1335}
1336
1337
1339{
1340 VECTOR2I old_pos = GetPosition();
1342
1343 for( SCH_FIELD& field : m_fields )
1344 {
1345 switch( field.GetHorizJustify() )
1346 {
1348 field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
1349 break;
1350
1352 break;
1353
1355 field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1356 break;
1357 }
1358
1359 VECTOR2I pos = field.GetTextPos();
1360 VECTOR2I delta = old_pos - pos;
1361 pos.x = GetPosition().x + delta.x;
1362
1363 field.SetPosition( pos );
1364 }
1365}
1366
1367
1369{
1370 VECTOR2I old_pos = GetPosition();
1371 SCH_TEXT::MirrorVertically( aCenter );
1372
1373 for( SCH_FIELD& field : m_fields )
1374 {
1375 VECTOR2I pos = field.GetTextPos();
1376 VECTOR2I delta = old_pos - pos;
1377 pos.y = GetPosition().y + delta.y;
1378
1379 field.SetPosition( pos );
1380 }
1381}
1382
1383
1384bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
1385{
1386 if( token->IsSameAs( wxT( "INTERSHEET_REFS" ) ) && Schematic() )
1387 {
1388 SCHEMATIC_SETTINGS& settings = Schematic()->Settings();
1389 wxString ref;
1390 auto it = Schematic()->GetPageRefsMap().find( GetText() );
1391
1392 if( it == Schematic()->GetPageRefsMap().end() )
1393 {
1394 ref = "?";
1395 }
1396 else
1397 {
1398 std::vector<int> pageListCopy;
1399
1400 pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
1401 std::sort( pageListCopy.begin(), pageListCopy.end() );
1402
1403 if( !settings.m_IntersheetRefsListOwnPage )
1404 {
1405 int currentPage = Schematic()->CurrentSheet().GetVirtualPageNumber();
1406 alg::delete_matching( pageListCopy, currentPage );
1407 }
1408
1409 std::map<int, wxString> sheetPages = Schematic()->GetVirtualPageToSheetPagesMap();
1410
1411 if( ( settings.m_IntersheetRefsFormatShort ) && ( pageListCopy.size() > 2 ) )
1412 {
1413 ref.Append( wxString::Format( wxT( "%s..%s" ),
1414 sheetPages[pageListCopy.front()],
1415 sheetPages[pageListCopy.back()] ) );
1416 }
1417 else
1418 {
1419 for( const int& pageNo : pageListCopy )
1420 ref.Append( wxString::Format( wxT( "%s," ), sheetPages[pageNo] ) );
1421
1422 if( !ref.IsEmpty() && ref.Last() == ',' )
1423 ref.RemoveLast();
1424 }
1425 }
1426
1427 *token = settings.m_IntersheetRefsPrefix + ref + settings.m_IntersheetRefsSuffix;
1428 return true;
1429 }
1430
1431 return SCH_LABEL_BASE::ResolveTextVar( token, aDepth );
1432}
1433
1434
1435void SCH_GLOBALLABEL::ViewGetLayers( int aLayers[], int& aCount ) const
1436{
1437 aCount = 6;
1438 aLayers[0] = LAYER_DANGLING;
1439 aLayers[1] = LAYER_DEVICE;
1440 aLayers[2] = LAYER_INTERSHEET_REFS;
1441 aLayers[3] = LAYER_NETCLASS_REFS;
1442 aLayers[4] = LAYER_FIELDS;
1443 aLayers[5] = LAYER_SELECTION_SHADOWS;
1444}
1445
1446
1448 std::vector<VECTOR2I>& aPoints,
1449 const VECTOR2I& aPos ) const
1450{
1451 int margin = GetLabelBoxExpansion( aRenderSettings );
1452 int halfSize = ( GetTextHeight() / 2 ) + margin;
1453 int linewidth = GetPenWidth();
1454 int symb_len = GetTextBox().GetWidth() + 2 * margin;
1455
1456 int x = symb_len + linewidth + 3;
1457 int y = halfSize + linewidth + 3;
1458
1459 aPoints.clear();
1460
1461 // Create outline shape : 6 points
1462 aPoints.emplace_back( VECTOR2I( 0, 0 ) );
1463 aPoints.emplace_back( VECTOR2I( 0, -y ) ); // Up
1464 aPoints.emplace_back( VECTOR2I( -x, -y ) ); // left
1465 aPoints.emplace_back( VECTOR2I( -x, 0 ) ); // Up left
1466 aPoints.emplace_back( VECTOR2I( -x, y ) ); // left down
1467 aPoints.emplace_back( VECTOR2I( 0, y ) ); // down
1468
1469 int x_offset = 0;
1470
1471 switch( m_shape )
1472 {
1474 x_offset = -halfSize;
1475 aPoints[0].x += halfSize;
1476 break;
1477
1479 aPoints[3].x -= halfSize;
1480 break;
1481
1484 x_offset = -halfSize;
1485 aPoints[0].x += halfSize;
1486 aPoints[3].x -= halfSize;
1487 break;
1488
1490 default:
1491 break;
1492 }
1493
1494 // Rotate outlines and move corners in real position
1495 for( VECTOR2I& aPoint : aPoints )
1496 {
1497 aPoint.x += x_offset;
1498
1499 switch( GetTextSpinStyle() )
1500 {
1501 default:
1502 case TEXT_SPIN_STYLE::LEFT: break;
1503 case TEXT_SPIN_STYLE::UP: RotatePoint( aPoint, -ANGLE_90 ); break;
1504 case TEXT_SPIN_STYLE::RIGHT: RotatePoint( aPoint, ANGLE_180 ); break;
1505 case TEXT_SPIN_STYLE::BOTTOM: RotatePoint( aPoint, ANGLE_90 ); break;
1506 }
1507
1508 aPoint += aPos;
1509 }
1510
1511 aPoints.push_back( aPoints[0] ); // closing
1512}
1513
1514
1516{
1517 return wxString::Format( _( "Global Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) );
1518}
1519
1520
1522{
1523 return BITMAPS::add_glabel;
1524}
1525
1526
1527SCH_HIERLABEL::SCH_HIERLABEL( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
1528 SCH_LABEL_BASE( pos, text, aType )
1529{
1532 m_isDangling = true;
1533}
1534
1535
1537{
1538 SCH_TEXT::SetTextSpinStyle( aSpinStyle );
1540}
1541
1542
1544 std::vector<VECTOR2I>& aPoints, const VECTOR2I& aPos ) const
1545{
1546 CreateGraphicShape( aSettings, aPoints, aPos, m_shape );
1547}
1548
1549
1551 std::vector<VECTOR2I>& aPoints, const VECTOR2I& aPos,
1552 LABEL_FLAG_SHAPE aShape ) const
1553{
1554 int* Template = TemplateShape[static_cast<int>( aShape )][static_cast<int>( m_spin_style )];
1555 int halfSize = GetTextHeight() / 2;
1556 int imax = *Template;
1557 Template++;
1558
1559 aPoints.clear();
1560
1561 for( int ii = 0; ii < imax; ii++ )
1562 {
1563 VECTOR2I corner;
1564 corner.x = ( halfSize * (*Template) ) + aPos.x;
1565 Template++;
1566
1567 corner.y = ( halfSize * (*Template) ) + aPos.y;
1568 Template++;
1569
1570 aPoints.push_back( corner );
1571 }
1572}
1573
1574
1576{
1577 int penWidth = GetEffectiveTextPenWidth();
1578 int margin = GetTextOffset();
1579
1580 int x = GetTextPos().x;
1581 int y = GetTextPos().y;
1582
1583 int height = GetTextHeight() + penWidth + margin;
1584 int length = GetTextBox().GetWidth();
1585
1586 length += height; // add height for triangular shapes
1587
1588 int dx, dy;
1589
1590 switch( GetTextSpinStyle() )
1591 {
1592 default:
1594 dx = -length;
1595 dy = height;
1597 y -= height / 2;
1598 break;
1599
1601 dx = height;
1602 dy = -length;
1603 x -= height / 2;
1605 break;
1606
1608 dx = length;
1609 dy = height;
1611 y -= height / 2;
1612 break;
1613
1615 dx = height;
1616 dy = length;
1617 x -= height / 2;
1619 break;
1620 }
1621
1622 BOX2I box( VECTOR2I( x, y ), VECTOR2I( dx, dy ) );
1623 box.Normalize();
1624 return box;
1625}
1626
1627
1629{
1630 VECTOR2I text_offset;
1631 int dist = GetTextOffset( aSettings );
1632
1633 dist += GetTextWidth();
1634
1635 switch( GetTextSpinStyle() )
1636 {
1637 default:
1638 case TEXT_SPIN_STYLE::LEFT: text_offset.x = -dist; break; // Orientation horiz normale
1639 case TEXT_SPIN_STYLE::UP: text_offset.y = -dist; break; // Orientation vert UP
1640 case TEXT_SPIN_STYLE::RIGHT: text_offset.x = dist; break; // Orientation horiz inverse
1641 case TEXT_SPIN_STYLE::BOTTOM: text_offset.y = dist; break; // Orientation vert BOTTOM
1642 }
1643
1644 return text_offset;
1645}
1646
1647
1648wxString SCH_HIERLABEL::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
1649{
1650 return wxString::Format( _( "Hierarchical Label '%s'" ),
1652}
1653
1654
1656{
1658}
1659
1660
1662{
1663 wxString msg =
1664#include "sch_text_help_md.h"
1665 ;
1666
1667 HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) );
1668 wxSize sz( 320, 320 );
1669
1670 dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) );
1671 dlg->SetDialogSizeInDU( sz.x, sz.y );
1672
1673 wxString html_txt;
1674 ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt );
1675 dlg->AddHTML_Text( html_txt );
1676 dlg->ShowModeless();
1677
1678 return dlg;
1679}
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:384
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:498
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:503
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:371
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:248
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
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
bool IsBold() const
Definition: eda_text.h:133
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
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:648
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:232
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:65
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.
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 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
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
Definition: plotter.h:457
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:446
Container for project specific data.
Definition: project.h:63
These settings were stored in SCH_BASE_FRAME previously.
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:120
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: schematic.cpp:123
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
std::map< wxString, std::set< int > > & GetPageRefsMap()
Definition: schematic.h:161
std::map< int, wxString > GetVirtualPageToSheetPagesMap() const
Definition: schematic.cpp:308
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
Definition: schematic.cpp:292
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:76
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:1085
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_label.cpp:1183
SCH_DIRECTIVE_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0))
Definition: sch_label.cpp:1074
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:1114
int GetPenWidth() const override
Definition: sch_label.cpp:1103
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_label.cpp:1233
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:50
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:1435
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:1447
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_label.cpp:1368
bool ResolveTextVar(wxString *token, int aDepth) const override
Definition: sch_label.cpp:1384
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_label.cpp:1515
void MirrorSpinStyle(bool aLeftRight) override
Definition: sch_label.cpp:1310
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:1271
SCH_GLOBALLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
Definition: sch_label.cpp:1248
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:1303
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1521
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_label.cpp:1338
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:1575
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:1543
SCH_HIERLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
Definition: sch_label.cpp:1527
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_label.cpp:1648
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1655
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:1628
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:1536
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:656
COLOR4D m_lastResolvedColor
Definition: sch_label.h:217
bool m_isDangling
Definition: sch_label.h:214
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:618
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_label.cpp:602
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:725
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:643
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1014
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:560
std::vector< SCH_FIELD > m_fields
Definition: sch_label.h:209
CONNECTION_TYPE m_connectionType
Definition: sch_label.h:213
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
Definition: sch_label.cpp:482
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_label.cpp:650
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:700
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:215
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &offset) override
Print a schematic item.
Definition: sch_label.cpp:988
int GetLabelBoxExpansion(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_label.cpp:667
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:1019
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:786
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:861
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:595
LABEL_FLAG_SHAPE GetShape() const override
Definition: sch_label.h:73
LABEL_FLAG_SHAPE m_shape
Definition: sch_label.h:211
virtual const BOX2I GetBodyBoundingBox() const
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:682
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:149
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:919
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:608
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_label.cpp:1062
SCH_LABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString)
Definition: sch_label.cpp:1024
const BOX2I GetBodyBoundingBox() const override
Return the bounding box of the label only, without taking in account its fields.
Definition: sch_label.cpp:1033
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_label.cpp:1068
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:55
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:233
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:1661
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:57
#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:416
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:409
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
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:332
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:156
@ 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:203
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:618