KiCad PCB EDA Suite
sch_text.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 <stambaughw@gmail.com>
6  * Copyright (C) 1992-2021 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 
31 #include <sch_symbol.h>
32 #include <sch_edit_frame.h>
33 #include <plotter.h>
34 #include <widgets/msgpanel.h>
35 #include <gal/stroke_font.h>
36 #include <bitmaps.h>
37 #include <kicad_string.h>
38 #include <sch_text.h>
39 #include <schematic.h>
41 #include <sch_painter.h>
42 #include <default_values.h>
43 #include <wx/debug.h>
44 #include <wx/log.h>
46 #include <project/project_file.h>
47 #include <project/net_settings.h>
48 #include <core/mirror.h>
49 #include <dialog_helpers.h>
50 #include <trigo.h>
51 
53 
54 
55 bool IncrementLabelMember( wxString& name, int aIncrement )
56 {
57  int ii, nn;
58  long number = 0;
59 
60  ii = name.Len() - 1;
61  nn = 0;
62 
63  // No number found, but simply repeating the same label is valid
64 
65  if( !wxIsdigit( name.GetChar( ii ) ) )
66  return true;
67 
68  while( ii >= 0 && wxIsdigit( name.GetChar( ii ) ) )
69  {
70  ii--;
71  nn++;
72  }
73 
74  ii++; /* digits are starting at ii position */
75  wxString litt_number = name.Right( nn );
76 
77  if( litt_number.ToLong( &number ) )
78  {
79  number += aIncrement;
80 
81  // Don't let result go below zero
82 
83  if( number > -1 )
84  {
85  name.Remove( ii );
86  name << number;
87  return true;
88  }
89  }
90  return false;
91 }
92 
93 
94 /* Coding polygons for global symbol graphic shapes.
95  * the first parml is the number of corners
96  * others are the corners coordinates in reduced units
97  * the real coordinate is the reduced coordinate * text half size
98  */
99 static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
100 static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
101 static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
102 static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
103 
104 static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
105 static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
106 static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
107 static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
108 
109 static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
110 static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
111 static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
112 static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
113 
114 static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
115 static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
116 static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
117 static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
118 
119 static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
120 static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
121 static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
122 static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
123 
124 static int* TemplateShape[5][4] =
125 {
131 };
132 
133 
135 {
136  SPIN newSpin = m_spin;
137 
138  switch( m_spin )
139  {
140  case LABEL_SPIN_STYLE::LEFT: newSpin = LABEL_SPIN_STYLE::UP; break;
141  case LABEL_SPIN_STYLE::UP: newSpin = LABEL_SPIN_STYLE::RIGHT; break;
142  case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::BOTTOM; break;
143  case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::LEFT; break;
144  default: wxLogWarning( "RotateCW encountered unknown current spin style" ); break;
145  }
146 
147  return LABEL_SPIN_STYLE( newSpin );
148 }
149 
150 
152 {
153  SPIN newSpin = m_spin;
154 
155  switch( m_spin )
156  {
157  case LABEL_SPIN_STYLE::LEFT: newSpin = LABEL_SPIN_STYLE::BOTTOM; break;
158  case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::RIGHT; break;
159  case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::UP; break;
160  case LABEL_SPIN_STYLE::UP: newSpin = LABEL_SPIN_STYLE::LEFT; break;
161  default: wxLogWarning( "RotateCCW encountered unknown current spin style" ); break;
162  }
163 
164  return LABEL_SPIN_STYLE( newSpin );
165 }
166 
167 
169 {
170  SPIN newSpin = m_spin;
171 
172  switch( m_spin )
173  {
174  case LABEL_SPIN_STYLE::UP: newSpin = LABEL_SPIN_STYLE::BOTTOM; break;
175  case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::UP; break;
176  case LABEL_SPIN_STYLE::LEFT: break;
177  case LABEL_SPIN_STYLE::RIGHT: break;
178  default: wxLogWarning( "MirrorX encountered unknown current spin style" ); break;
179  }
180 
181  return LABEL_SPIN_STYLE( newSpin );
182 }
183 
184 
186 {
187  SPIN newSpin = m_spin;
188 
189  switch( m_spin )
190  {
191  case LABEL_SPIN_STYLE::LEFT: newSpin = LABEL_SPIN_STYLE::RIGHT; break;
192  case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::LEFT; break;
193  case LABEL_SPIN_STYLE::UP: break;
194  case LABEL_SPIN_STYLE::BOTTOM: break;
195  default: wxLogWarning( "MirrorY encountered unknown current spin style" ); break;
196  }
197 
198  return LABEL_SPIN_STYLE( newSpin );
199 }
200 
201 
202 SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
203  SCH_ITEM( NULL, aType ),
204  EDA_TEXT( text ),
205  m_shape( PINSHEETLABEL_SHAPE::PS_INPUT ),
206  m_isDangling( false ),
207  m_connectionType( CONNECTION_TYPE::NONE ),
208  m_spin_style( LABEL_SPIN_STYLE::LEFT )
209 {
211 
212  SetTextPos( pos );
213  SetMultilineAllowed( true );
214 }
215 
216 
217 SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
218  SCH_ITEM( aText ),
219  EDA_TEXT( aText ),
220  m_shape( aText.m_shape ),
221  m_isDangling( aText.m_isDangling ),
222  m_connectionType( aText.m_connectionType ),
223  m_spin_style( aText.m_spin_style )
224 { }
225 
226 
228 {
229  return new SCH_TEXT( *this );
230 }
231 
232 
233 bool SCH_TEXT::IncrementLabel( int aIncrement )
234 {
235  wxString text = GetText();
236  bool ReturnVal = IncrementLabelMember( text, aIncrement );
237 
238  if( ReturnVal )
239  SetText( text );
240 
241  return ReturnVal;
242 }
243 
244 
245 wxPoint SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
246 {
247  wxPoint text_offset;
248 
249  // add an offset to x (or y) position to aid readability of text on a wire or line
250  int dist = GetTextOffset( aSettings ) + GetPenWidth();
251 
252  switch( GetLabelSpinStyle() )
253  {
256  text_offset.x = -dist;
257  break; // Vert Orientation
258  default:
261  text_offset.y = -dist;
262  break; // Horiz Orientation
263  }
264 
265  return text_offset;
266 }
267 
268 
269 void SCH_TEXT::MirrorHorizontally( int aCenter )
270 {
271  // Text is NOT really mirrored; it is moved to a suitable horizontal position
272  SetLabelSpinStyle( GetLabelSpinStyle().MirrorY() );
273 
274  SetTextX( MIRRORVAL( GetTextPos().x, aCenter ) );
275 }
276 
277 
278 void SCH_TEXT::MirrorVertically( int aCenter )
279 {
280  // Text is NOT really mirrored; it is moved to a suitable vertical position
281  SetLabelSpinStyle( GetLabelSpinStyle().MirrorX() );
282 
283  SetTextY( MIRRORVAL( GetTextPos().y, aCenter ) );
284 }
285 
286 
287 void SCH_TEXT::Rotate( const wxPoint& aCenter )
288 {
289  wxPoint pt = GetTextPos();
290  RotatePoint( &pt, aCenter, 900 );
291  wxPoint offset = pt - GetTextPos();
292 
293  Rotate90( false );
294 
295  SetTextPos( GetTextPos() + offset );
296 }
297 
298 
299 void SCH_TEXT::Rotate90( bool aClockwise )
300 {
301  if( aClockwise )
302  SetLabelSpinStyle( GetLabelSpinStyle().RotateCW() );
303  else
304  SetLabelSpinStyle( GetLabelSpinStyle().RotateCCW() );
305 }
306 
307 
308 void SCH_TEXT::MirrorSpinStyle( bool aLeftRight )
309 {
310  if( aLeftRight )
311  SetLabelSpinStyle( GetLabelSpinStyle().MirrorY() );
312  else
313  SetLabelSpinStyle( GetLabelSpinStyle().MirrorX() );
314 }
315 
316 
318 {
319  m_spin_style = aSpinStyle;
320 
321  // Assume "Right" and Left" mean which side of the anchor the text will be on
322  // Thus we want to left justify text up against the anchor if we are on the right
323  switch( aSpinStyle )
324  {
325  default:
326  wxASSERT_MSG( 1, "Bad spin style" );
327  break;
328 
329  case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
330  //
331  m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
335  break;
336 
337  case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
341  break;
342 
343  case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
347  break;
348 
349  case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
353  break;
354  }
355 }
356 
357 
359 {
360  SCH_TEXT* item = (SCH_TEXT*) aItem;
361 
362  std::swap( m_layer, item->m_layer );
363 
364  std::swap( m_shape, item->m_shape );
365  std::swap( m_isDangling, item->m_isDangling );
366  std::swap( m_spin_style, item->m_spin_style );
367 
368  SwapText( *item );
369  SwapEffects( *item );
370 }
371 
372 
373 bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
374 {
375  if( Type() != aItem.Type() )
376  return Type() < aItem.Type();
377 
378  auto other = static_cast<const SCH_TEXT*>( &aItem );
379 
380  if( GetLayer() != other->GetLayer() )
381  return GetLayer() < other->GetLayer();
382 
383  if( GetPosition().x != other->GetPosition().x )
384  return GetPosition().x < other->GetPosition().x;
385 
386  if( GetPosition().y != other->GetPosition().y )
387  return GetPosition().y < other->GetPosition().y;
388 
389  return GetText() < other->GetText();
390 }
391 
392 
393 int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const
394 {
395  double ratio;
396 
397  if( aSettings )
398  ratio = static_cast<const SCH_RENDER_SETTINGS*>( aSettings )->m_TextOffsetRatio;
399  else if( Schematic() )
400  ratio = Schematic()->Settings().m_TextOffsetRatio;
401  else
402  ratio = DEFAULT_TEXT_OFFSET_RATIO; // For previews (such as in Preferences), etc.
403 
404  return KiROUND( ratio * GetTextSize().y );
405 
406  return 0;
407 }
408 
409 
411 {
412  return GetEffectiveTextPenWidth();
413 }
414 
415 
416 void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
417 {
418  COLOR4D color = aSettings->GetLayerColor( m_layer );
419  wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings );
420 
421  EDA_TEXT::Print( aSettings, text_offset, color );
422 }
423 
424 
425 void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
426 {
427  // Normal text labels cannot be tested for dangling ends.
428  if( Type() == SCH_TEXT_T )
429  return;
430 
431  DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
432  aItemList.push_back( item );
433 }
434 
435 
436 bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
437  const SCH_SHEET_PATH* aPath )
438 {
439  // Normal text labels cannot be tested for dangling ends.
440  if( Type() == SCH_TEXT_T )
441  return false;
442 
443  bool previousState = m_isDangling;
444  m_isDangling = true;
446 
447  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
448  {
449  DANGLING_END_ITEM& item = aItemList[ii];
450 
451  if( item.GetItem() == this )
452  continue;
453 
454  switch( item.GetType() )
455  {
456  case PIN_END:
457  case LABEL_END:
458  case SHEET_LABEL_END:
459  case NO_CONNECT_END:
460  if( GetTextPos() == item.GetPosition() )
461  {
462  m_isDangling = false;
463 
464  if( aPath && item.GetType() != PIN_END )
465  m_connected_items[ *aPath ].insert( static_cast<SCH_ITEM*>( item.GetItem() ) );
466  }
467 
468  break;
469 
470  case BUS_START_END:
473 
474  case WIRE_START_END:
475  {
476  // These schematic items have created 2 DANGLING_END_ITEM one per end. But being
477  // a paranoid programmer, I'll check just in case.
478  ii++;
479 
480  wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
481  wxT( "Dangling end type list overflow. Bad programmer!" ) );
482 
483  int accuracy = 1; // We have rounding issues with an accuracy of 0
484 
485  DANGLING_END_ITEM & nextItem = aItemList[ii];
487  nextItem.GetPosition(), accuracy );
488 
489  if( !m_isDangling )
490  {
493 
494  // Add the line to the connected items, since it won't be picked
495  // up by a search of intersecting connection points
496  if( aPath )
497  {
498  auto sch_item = static_cast<SCH_ITEM*>( item.GetItem() );
499  AddConnectionTo( *aPath, sch_item );
500  sch_item->AddConnectionTo( *aPath, this );
501  }
502  }
503  }
504  break;
505 
506  default:
507  break;
508  }
509 
510  if( !m_isDangling )
511  break;
512  }
513 
514  if( m_isDangling )
516 
517  return previousState != m_isDangling;
518 }
519 
520 
521 std::vector<wxPoint> SCH_TEXT::GetConnectionPoints() const
522 {
523  // Normal text labels do not have connection points. All others do.
524  if( Type() == SCH_TEXT_T )
525  return {};
526 
527  return { GetTextPos() };
528 }
529 
530 
532 {
533  EDA_RECT rect = GetTextBox();
534 
535  if( GetTextAngle() != 0 ) // Rotate rect
536  {
537  wxPoint pos = rect.GetOrigin();
538  wxPoint end = rect.GetEnd();
539 
540  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
541  RotatePoint( &end, GetTextPos(), GetTextAngle() );
542 
543  rect.SetOrigin( pos );
544  rect.SetEnd( end );
545  }
546 
547  rect.Normalize();
548  return rect;
549 }
550 
551 
553 {
554  switch( aType )
555  {
556  case PINSHEETLABEL_SHAPE::PS_INPUT: return _( "Input" );
557  case PINSHEETLABEL_SHAPE::PS_OUTPUT: return _( "Output" );
558  case PINSHEETLABEL_SHAPE::PS_BIDI: return _( "Bidirectional" );
559  case PINSHEETLABEL_SHAPE::PS_TRISTATE: return _( "Tri-State" );
560  case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: return _( "Passive" );
561  default: return wxT( "???" );
562  }
563 }
564 
565 
566 void SCH_TEXT::GetContextualTextVars( wxArrayString* aVars ) const
567 {
569  aVars->push_back( wxT( "CONNECTION_TYPE" ) );
570 
571  if( Type() == SCH_SHEET_PIN_T && m_parent )
572  static_cast<SCH_SHEET*>( m_parent )->GetContextualTextVars( aVars );
573 }
574 
575 
576 wxString SCH_TEXT::GetShownText( int aDepth ) const
577 {
578  std::function<bool( wxString* )> textResolver =
579  [&]( wxString* token ) -> bool
580  {
581  if( ( Type() == SCH_GLOBAL_LABEL_T
582  || Type() == SCH_HIER_LABEL_T
583  || Type() == SCH_SHEET_PIN_T )
584  && token->IsSameAs( wxT( "CONNECTION_TYPE" ) ) )
585  {
586  *token = getElectricalTypeLabel( GetShape() );
587  return true;
588  }
589 
590  if( Type() == SCH_SHEET_PIN_T && m_parent )
591  {
592  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
593 
594  if( sheet->ResolveTextVar( token, aDepth ) )
595  return true;
596  }
597 
598  if( Type() == SCH_TEXT_T )
599  {
600  if( token->Contains( ':' ) )
601  {
602  if( Schematic()->ResolveCrossReference( token, aDepth ) )
603  return true;
604  }
605  else
606  {
607  SCHEMATIC* schematic = Schematic();
608  SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
609 
610  if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
611  return true;
612  }
613  }
614 
615  return false;
616  };
617 
618  bool processTextVars = false;
619  wxString text = EDA_TEXT::GetShownText( &processTextVars );
620 
621  if( text == "~" ) // Legacy placeholder for empty string
622  {
623  text = "";
624  }
625  else if( processTextVars )
626  {
627  wxCHECK_MSG( Schematic(), wxEmptyString, "No parent SCHEMATIC set for SCH_TEXT!" );
628 
629  PROJECT* project = nullptr;
630 
631  if( Schematic() )
632  project = &Schematic()->Prj();
633 
634  if( aDepth < 10 )
635  text = ExpandTextVars( text, &textResolver, nullptr, project );
636  }
637 
638  return text;
639 }
640 
641 
642 wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
643 {
644  return wxString::Format( _( "Graphic Text '%s'" ), ShortenedShownText() );
645 }
646 
647 
649 {
650  return BITMAPS::text;
651 }
652 
653 
654 bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
655 {
656  EDA_RECT bBox = GetBoundingBox();
657  bBox.Inflate( aAccuracy );
658  return bBox.Contains( aPosition );
659 }
660 
661 
662 bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
663 {
664  EDA_RECT bBox = GetBoundingBox();
665  bBox.Inflate( aAccuracy );
666 
667  if( aContained )
668  return aRect.Contains( bBox );
669 
670  return aRect.Intersects( bBox );
671 }
672 
673 
674 void SCH_TEXT::Plot( PLOTTER* aPlotter ) const
675 {
676  static std::vector<wxPoint> s_poly;
677 
678  RENDER_SETTINGS* settings = aPlotter->RenderSettings();
679  SCH_CONNECTION* connection = Connection();
680  int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
681  COLOR4D color = settings->GetLayerColor( layer );
682  int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
683 
684  penWidth = std::max( penWidth, settings->GetMinPenWidth() );
685  aPlotter->SetCurrentLineWidth( penWidth );
686 
687  if( IsMultilineAllowed() )
688  {
689  std::vector<wxPoint> positions;
690  wxArrayString strings_list;
691  wxStringSplit( GetShownText(), strings_list, '\n' );
692  positions.reserve( strings_list.Count() );
693 
694  GetLinePositions( positions, (int) strings_list.Count() );
695 
696  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
697  {
698  wxPoint textpos = positions[ii] + GetSchematicTextOffset( aPlotter->RenderSettings() );
699  wxString& txt = strings_list.Item( ii );
700  aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(),
701  GetVertJustify(), penWidth, IsItalic(), IsBold() );
702  }
703  }
704  else
705  {
706  wxPoint textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() );
707 
708  aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
709  GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() );
710  }
711 
712  // Draw graphic symbol for global or hierarchical labels
713  CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() );
714 
715  if( s_poly.size() )
716  aPlotter->PlotPoly( s_poly, FILL_TYPE::NO_FILL, penWidth );
717 }
718 
719 
721 {
722  wxString msg;
723 
724  switch( Type() )
725  {
726  case SCH_TEXT_T: msg = _( "Graphic Text" ); break;
727  case SCH_LABEL_T: msg = _( "Label" ); break;
728  case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
729  case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
730  case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
731  default: return;
732  }
733 
734  // Don't use GetShownText() here; we want to show the user the variable references
735  aList.push_back( MSG_PANEL_ITEM( msg, UnescapeString( GetText() ) ) );
736 
737  switch( GetLabelSpinStyle() )
738  {
739  case LABEL_SPIN_STYLE::LEFT: msg = _( "Align right" ); break;
740  case LABEL_SPIN_STYLE::UP: msg = _( "Align bottom" ); break;
741  case LABEL_SPIN_STYLE::RIGHT: msg = _( "Align left" ); break;
742  case LABEL_SPIN_STYLE::BOTTOM: msg = _( "Align top" ); break;
743  default: msg = wxT( "???" ); break;
744  }
745 
746  aList.push_back( MSG_PANEL_ITEM( _( "Justification" ), msg, BROWN ) );
747 
748  wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
749  int style = 0;
750 
751  if( IsItalic() )
752  style = 1;
753 
754  if( IsBold() )
755  style += 2;
756 
757  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style] ) );
758 
759  // Display electrical type if it is relevant
761  {
762  msg = getElectricalTypeLabel( GetShape() );
763  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg ) );
764  }
765 
766  // Display text size (X or Y value, with are the same value in Eeschema)
767  msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextWidth() );
768  aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg ) );
769 
770  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
771 
772  if( frame )
773  {
774  if( SCH_CONNECTION* conn = Connection() )
775  {
776  conn->AppendInfoToMsgPanel( aList );
777 
778  NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
779  const wxString& netname = conn->Name( true );
780 
781  if( netSettings.m_NetClassAssignments.count( netname ) )
782  {
783  const wxString& netclassName = netSettings.m_NetClassAssignments[ netname ];
784  aList.push_back( MSG_PANEL_ITEM( _( "Assigned Netclass" ), netclassName ) );
785  }
786  }
787  }
788 }
789 
790 #if defined(DEBUG)
791 
792 void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
793 {
794  // XML output:
795  wxString s = GetClass();
796 
797  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
798  << " layer=\"" << m_layer << '"'
799  << " shape=\"" << static_cast<int>( m_shape ) << '"'
800  << " dangling=\"" << m_isDangling << '"'
801  << '>'
802  << TO_UTF8( GetText() )
803  << "</" << s.Lower().mb_str() << ">\n";
804 }
805 
806 #endif
807 
808 
809 SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text )
810  : SCH_TEXT( pos, text, SCH_LABEL_T )
811 {
814  m_isDangling = true;
815  SetMultilineAllowed( false );
816 }
817 
818 
820 {
821  return new SCH_LABEL( *this );
822 }
823 
824 
825 bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const
826 {
827  static KICAD_T wireTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, EOT };
828  static KICAD_T busTypes[] = { SCH_LINE_LOCATE_BUS_T, EOT };
829 
830  if( SCH_ITEM::IsType( aScanTypes ) )
831  return true;
832 
833  wxCHECK_MSG( Schematic(), false, "No parent SCHEMATIC set for SCH_LABEL!" );
834 
835  SCH_SHEET_PATH current = Schematic()->CurrentSheet();
836 
837  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
838  {
839  if( *p == SCH_LABEL_LOCATE_WIRE_T )
840  {
841  wxASSERT( m_connected_items.count( current ) );
842 
843  for( SCH_ITEM* connection : m_connected_items.at( current ) )
844  {
845  if( connection->IsType( wireTypes ) )
846  return true;
847  }
848  }
849  else if ( *p == SCH_LABEL_LOCATE_BUS_T )
850  {
851  wxASSERT( m_connected_items.count( current ) );
852 
853  for( SCH_ITEM* connection : m_connected_items.at( current ) )
854  {
855  if( connection->IsType( busTypes ) )
856  return true;
857  }
858  }
859  }
860 
861  return false;
862 }
863 
864 
866 {
867  EDA_RECT rect = GetTextBox();
868 
869  rect.Offset( 0, -GetTextOffset() );
870 
871  if( GetTextAngle() != 0.0 )
872  {
873  // Rotate rect
874  wxPoint pos = rect.GetOrigin();
875  wxPoint end = rect.GetEnd();
876 
877  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
878  RotatePoint( &end, GetTextPos(), GetTextAngle() );
879 
880  rect.SetOrigin( pos );
881  rect.SetEnd( end );
882 
883  rect.Normalize();
884  }
885 
886  // Labels have a position point that is outside of the TextBox
887  rect.Merge( GetPosition() );
888 
889  return rect;
890 }
891 
892 
893 wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
894 {
895  return wxString::Format( _( "Label '%s'" ), ShortenedShownText() );
896 }
897 
898 
900 {
902 }
903 
904 
905 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
907  m_intersheetRefsField( { 0, 0 }, 0, this )
908 {
909  m_layer = LAYER_GLOBLABEL;
911  m_isDangling = true;
912  SetMultilineAllowed( false );
913 
914  SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
915 
916  m_intersheetRefsField.SetText( wxT( "${INTERSHEET_REFS}" ) );
917  m_intersheetRefsField.SetLayer( LAYER_GLOBLABEL );
918  m_intersheetRefsField.SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
919  m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO;
920 }
921 
922 
924  SCH_TEXT( aGlobalLabel ),
925  m_intersheetRefsField( { 0, 0 }, 0, this )
926 {
927  m_intersheetRefsField = aGlobalLabel.m_intersheetRefsField;
928 
929  // Re-parent the fields, which before this had aGlobalLabel as parent
930  m_intersheetRefsField.SetParent( this );
931 
932  m_fieldsAutoplaced = aGlobalLabel.m_fieldsAutoplaced;
933 }
934 
935 
937 {
938  return new SCH_GLOBALLABEL( *this );
939 }
940 
941 
943 {
944  SCH_TEXT::SwapData( aItem );
945 
946  SCH_GLOBALLABEL* globalLabel = static_cast<SCH_GLOBALLABEL*>( aItem );
947 
948  // Swap field data wholesale...
949  std::swap( m_intersheetRefsField, globalLabel->m_intersheetRefsField );
950 
951  // ...and then reset parent pointers.
952  globalLabel->m_intersheetRefsField.SetParent( globalLabel );
954 }
955 
956 
957 SEARCH_RESULT SCH_GLOBALLABEL::Visit( INSPECTOR aInspector, void* testData,
958  const KICAD_T aFilterTypes[] )
959 {
960  KICAD_T stype;
961 
962  for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
963  {
964  // If caller wants to inspect my type
965  if( stype == SCH_LOCATE_ANY_T || stype == Type() )
966  {
967  if( SEARCH_RESULT::QUIT == aInspector( this, NULL ) )
968  return SEARCH_RESULT::QUIT;
969  }
970 
971  if( stype == SCH_LOCATE_ANY_T || stype == SCH_FIELD_T )
972  {
973  if( SEARCH_RESULT::QUIT == aInspector( GetIntersheetRefs(), this ) )
974  return SEARCH_RESULT::QUIT;
975  }
976  }
977 
979 }
980 
981 
982 void SCH_GLOBALLABEL::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
983 {
984  aFunction( &m_intersheetRefsField );
985 }
986 
987 
989 {
990  wxPoint text_offset;
991  int dist = GetTextOffset( aSettings );
992 
993  switch( m_shape )
994  {
998  dist += GetTextHeight() * 3 / 4; // Use three-quarters-height as proxy for triangle size
999  break;
1000 
1003  default:
1004  break;
1005  }
1006 
1007  switch( GetLabelSpinStyle() )
1008  {
1009  default:
1010  case LABEL_SPIN_STYLE::LEFT: text_offset.x -= dist; break;
1011  case LABEL_SPIN_STYLE::UP: text_offset.y -= dist; break;
1012  case LABEL_SPIN_STYLE::RIGHT: text_offset.x += dist; break;
1013  case LABEL_SPIN_STYLE::BOTTOM: text_offset.y += dist; break;
1014  }
1015 
1016  return text_offset;
1017 }
1018 
1019 
1021 {
1022  m_spin_style = aSpinStyle;
1023 
1024  switch( aSpinStyle )
1025  {
1026  default:
1027  wxASSERT_MSG( 1, "Bad spin style" );
1030 
1031  case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
1034  break;
1035 
1036  case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
1039  break;
1040 
1041  case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation
1044  break;
1045 
1046  case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
1049  break;
1050  }
1051 }
1052 
1053 
1054 void SCH_GLOBALLABEL::Rotate( const wxPoint& aCenter )
1055 {
1056  wxPoint pt = GetTextPos();
1057  RotatePoint( &pt, aCenter, 900 );
1058  wxPoint offset = pt - GetTextPos();
1059 
1060  Rotate90( false );
1061 
1062  SetTextPos( GetTextPos() + offset );
1064 }
1065 
1066 
1067 void SCH_GLOBALLABEL::Rotate90( bool aClockwise )
1068 {
1069  SCH_TEXT::Rotate90( aClockwise );
1070 
1073  {
1074  if( !aClockwise )
1076 
1078  }
1081  {
1082  if( !aClockwise )
1084 
1086  }
1089  {
1090  if( aClockwise )
1092 
1094  }
1097  {
1098  if( aClockwise )
1100 
1102  }
1103 
1104  wxPoint pos = m_intersheetRefsField.GetTextPos();
1105  RotatePoint( &pos, GetPosition(), aClockwise ? -900 : 900 );
1107 }
1108 
1109 
1110 void SCH_GLOBALLABEL::MirrorSpinStyle( bool aLeftRight )
1111 {
1112  SCH_TEXT::MirrorSpinStyle( aLeftRight );
1113 
1114  if( ( aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_HORIZ )
1115  || ( !aLeftRight && m_intersheetRefsField.GetTextAngle() == TEXT_ANGLE_VERT ) )
1116  {
1119  else
1121  }
1122 
1123  wxPoint pos = m_intersheetRefsField.GetTextPos();
1124  wxPoint delta = GetPosition() - pos;
1125 
1126  if( aLeftRight )
1127  pos.x = GetPosition().x + delta.x;
1128  else
1129  pos.y = GetPosition().y + delta.y;
1130 
1132 }
1133 
1134 
1136 {
1137  wxPoint old_pos = GetPosition();
1138  SCH_TEXT::MirrorHorizontally( aCenter );
1139 
1142  else
1144 
1145  wxPoint pos = m_intersheetRefsField.GetTextPos();
1146  wxPoint delta = old_pos - pos;
1147  pos.x = GetPosition().x + delta.x;
1148 
1150 }
1151 
1152 
1154 {
1155  wxPoint old_pos = GetPosition();
1156  SCH_TEXT::MirrorVertically( aCenter );
1157  wxPoint pos = m_intersheetRefsField.GetTextPos();
1158  wxPoint delta = old_pos - pos;
1159  pos.y = GetPosition().y + delta.y;
1160 
1162 }
1163 
1164 
1166 {
1171 
1173  AutoplaceFields( nullptr, false );
1174 }
1175 
1176 
1177 void SCH_GLOBALLABEL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
1178 {
1179  int margin = GetTextOffset();
1180  int labelLen = GetBoundingBoxBase().GetSizeMax();
1181  int penOffset = GetPenWidth() / 2;
1182 
1183  // Set both axes to penOffset; we're going to overwrite the text axis below
1184  wxPoint offset( -penOffset, -penOffset );
1185 
1186  switch( GetLabelSpinStyle() )
1187  {
1188  default:
1192  offset.x = - ( labelLen + margin / 2 );
1193  break;
1194 
1195  case LABEL_SPIN_STYLE::UP:
1198  offset.y = - ( labelLen + margin / 2 );
1199  break;
1200 
1204  offset.x = labelLen + margin /2 ;
1205  break;
1206 
1210  offset.y = labelLen + margin / 2;
1211  break;
1212  }
1213 
1215 
1217 }
1218 
1219 
1220 bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
1221 {
1222  if( token->IsSameAs( wxT( "INTERSHEET_REFS" ) ) && Schematic() )
1223  {
1224  SCHEMATIC_SETTINGS& settings = Schematic()->Settings();
1225  wxString ref;
1226  auto it = Schematic()->GetPageRefsMap().find( GetText() );
1227 
1228  if( it == Schematic()->GetPageRefsMap().end() )
1229  {
1230  ref = "?";
1231  }
1232  else
1233  {
1234  std::vector<wxString> pageListCopy;
1235 
1236  pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
1237  std::sort( pageListCopy.begin(), pageListCopy.end() );
1238 
1239  if( !settings.m_IntersheetRefsListOwnPage )
1240  {
1241  wxString currentPage = Schematic()->CurrentSheet().GetPageNumber();
1242  pageListCopy.erase( std::remove( pageListCopy.begin(),
1243  pageListCopy.end(),
1244  currentPage ), pageListCopy.end() );
1245  }
1246 
1247  if( ( settings.m_IntersheetRefsFormatShort ) && ( pageListCopy.size() > 2 ) )
1248  {
1249  ref.Append( wxString::Format( wxT( "%s..%s" ),
1250  pageListCopy.front(),
1251  pageListCopy.back() ) );
1252  }
1253  else
1254  {
1255  for( const wxString& pageNo : pageListCopy )
1256  ref.Append( wxString::Format( wxT( "%s," ), pageNo ) );
1257 
1258  if( !ref.IsEmpty() && ref.Last() == ',' )
1259  ref.RemoveLast();
1260  }
1261  }
1262 
1263  *token = settings.m_IntersheetRefsPrefix + ref + settings.m_IntersheetRefsSuffix;
1264  return true;
1265  }
1266 
1267  return false;
1268 }
1269 
1270 
1271 void SCH_GLOBALLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
1272 {
1273  static std::vector<wxPoint> s_poly;
1274 
1275  SCH_CONNECTION* connection = Connection();
1276  int layer = ( connection && connection->IsBus() ) ? LAYER_BUS : m_layer;
1277  wxDC* DC = aSettings->GetPrintDC();
1278  COLOR4D color = aSettings->GetLayerColor( layer );
1279  int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
1280  wxPoint text_offset = aOffset + GetSchematicTextOffset( aSettings );
1281 
1282  EDA_TEXT::Print( aSettings, text_offset, color );
1283 
1284  CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset );
1285  GRPoly( nullptr, DC, s_poly.size(), &s_poly[0], false, penWidth, color, color );
1286 
1288  m_intersheetRefsField.Print( aSettings, aOffset );
1289 }
1290 
1291 
1292 void SCH_GLOBALLABEL::Plot( PLOTTER* aPlotter ) const
1293 {
1294  SCH_TEXT::Plot( aPlotter );
1295 
1296  bool show = Schematic()->Settings().m_IntersheetRefsShow;
1297 
1298  if ( show )
1299  m_intersheetRefsField.Plot( aPlotter );
1300 }
1301 
1302 
1304  std::vector<wxPoint>& aPoints, const wxPoint& Pos ) const
1305 {
1306  int margin = GetTextOffset( aRenderSettings );
1307  int halfSize = ( GetTextHeight() / 2 ) + margin;
1308  int linewidth = GetPenWidth();
1309  int symb_len = LenSize( GetShownText(), linewidth ) + 2 * margin;
1310 
1311  int x = symb_len + linewidth + 3;
1312  int y = halfSize + linewidth + 3;
1313 
1314  aPoints.clear();
1315 
1316  // Create outline shape : 6 points
1317  aPoints.emplace_back( wxPoint( 0, 0 ) );
1318  aPoints.emplace_back( wxPoint( 0, -y ) ); // Up
1319  aPoints.emplace_back( wxPoint( -x, -y ) ); // left
1320  aPoints.emplace_back( wxPoint( -x, 0 ) ); // Up left
1321  aPoints.emplace_back( wxPoint( -x, y ) ); // left down
1322  aPoints.emplace_back( wxPoint( 0, y ) ); // down
1323 
1324  int x_offset = 0;
1325 
1326  switch( m_shape )
1327  {
1329  x_offset = -halfSize;
1330  aPoints[0].x += halfSize;
1331  break;
1332 
1334  aPoints[3].x -= halfSize;
1335  break;
1336 
1339  x_offset = -halfSize;
1340  aPoints[0].x += halfSize;
1341  aPoints[3].x -= halfSize;
1342  break;
1343 
1345  default:
1346  break;
1347  }
1348 
1349  int angle = 0;
1350 
1351  switch( GetLabelSpinStyle() )
1352  {
1353  default:
1354  case LABEL_SPIN_STYLE::LEFT: break;
1355  case LABEL_SPIN_STYLE::UP: angle = -900; break;
1356  case LABEL_SPIN_STYLE::RIGHT: angle = 1800; break;
1357  case LABEL_SPIN_STYLE::BOTTOM: angle = 900; break;
1358  }
1359 
1360  // Rotate outlines and move corners in real position
1361  for( wxPoint& aPoint : aPoints )
1362  {
1363  aPoint.x += x_offset;
1364 
1365  if( angle )
1366  RotatePoint( &aPoint, angle );
1367 
1368  aPoint += Pos;
1369  }
1370 
1371  aPoints.push_back( aPoints[0] ); // closing
1372 }
1373 
1374 
1376 {
1377  // build the bounding box on the global label only, without taking in account
1378  // the intersheets references, just the bounding box of the graphic shape
1379  int x = GetTextPos().x;
1380  int y = GetTextPos().y;
1381  int penWidth = GetEffectiveTextPenWidth();
1382  int margin = GetTextOffset();
1383  int height = ( ( GetTextHeight() * 15 ) / 10 ) + penWidth + margin;
1384  int length = LenSize( GetShownText(), penWidth )
1385  + height // add height for triangular shapes
1386  - margin; // margin added to height not needed here
1387 
1388  int dx, dy;
1389 
1390  switch( GetLabelSpinStyle() ) // respect orientation
1391  {
1392  default:
1394  dx = -length;
1395  dy = height;
1396  y -= height / 2;
1397  break;
1398 
1399  case LABEL_SPIN_STYLE::UP:
1400  dx = height;
1401  dy = -length;
1402  x -= height / 2;
1403  break;
1404 
1406  dx = length;
1407  dy = height;
1408  y -= height / 2;
1409  break;
1410 
1412  dx = height;
1413  dy = length;
1414  x -= height / 2;
1415  break;
1416  }
1417 
1418  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1419 
1420  box.Normalize();
1421  return box;
1422 }
1423 
1424 
1426 {
1427  // build the bounding box on the global label only, including the intersheets references
1428  // full bounding box if they are shown
1429 
1430  EDA_RECT box( GetBoundingBoxBase() );
1431 
1432  // Note: Schematic() can be null in preference preview panel
1433  if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow )
1434  {
1436  box.Normalize();
1437  }
1438 
1439  return box;
1440 }
1441 
1442 
1444 {
1445  return wxString::Format( _( "Global Label '%s'" ), ShortenedShownText() );
1446 }
1447 
1448 
1450 {
1451  return BITMAPS::add_glabel;
1452 }
1453 
1454 
1455 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType )
1456  : SCH_TEXT( pos, text, aType )
1457 {
1460  m_isDangling = true;
1461  SetMultilineAllowed( false );
1462 }
1463 
1464 
1466 {
1467  return new SCH_HIERLABEL( *this );
1468 }
1469 
1470 
1472 {
1473  m_spin_style = aSpinStyle;
1474 
1475  // Assume "Right" and Left" mean which side of the port symbol the text will be on
1476  // If we are left of the symbol, we want to right justify to line up with the symbol
1477  switch( aSpinStyle )
1478  {
1479  default:
1480  wxLogWarning( "SetLabelSpinStyle bad spin style" );
1481  break;
1482 
1484  //
1485  m_spin_style = LABEL_SPIN_STYLE::LEFT; // Handle the error spin style by resetting
1489  break;
1490 
1491  case LABEL_SPIN_STYLE::UP:
1495  break;
1496 
1501  break;
1502 
1507  break;
1508  }
1509 }
1510 
1511 
1512 void SCH_HIERLABEL::Print( const RENDER_SETTINGS* aSettings, const wxPoint& offset )
1513 {
1514  wxCHECK_RET( Schematic(), "No parent SCHEMATIC set for SCH_LABEL!" );
1515 
1516  static std::vector <wxPoint> Poly;
1517 
1518  wxDC* DC = aSettings->GetPrintDC();
1519  SCH_CONNECTION* conn = Connection();
1520  bool isBus = conn && conn->IsBus();
1521  COLOR4D color = aSettings->GetLayerColor( isBus ? LAYER_BUS : m_layer );
1522  int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
1523  wxPoint textOffset = offset + GetSchematicTextOffset( aSettings );
1524 
1525  EDA_TEXT::Print( aSettings, textOffset, color );
1526 
1527  CreateGraphicShape( aSettings, Poly, GetTextPos() + offset );
1528  GRPoly( nullptr, DC, Poly.size(), &Poly[0], false, penWidth, color, color );
1529 }
1530 
1531 
1533  std::vector<wxPoint>& aPoints, const wxPoint& aPos ) const
1534 {
1535  CreateGraphicShape( aSettings, aPoints, aPos, m_shape );
1536 }
1537 
1538 
1540  std::vector<wxPoint>& aPoints, const wxPoint& aPos,
1541  PINSHEETLABEL_SHAPE aShape ) const
1542 {
1543  int* Template = TemplateShape[static_cast<int>( aShape )][static_cast<int>( m_spin_style )];
1544  int halfSize = GetTextHeight() / 2;
1545  int imax = *Template;
1546  Template++;
1547 
1548  aPoints.clear();
1549 
1550  for( int ii = 0; ii < imax; ii++ )
1551  {
1552  wxPoint corner;
1553  corner.x = ( halfSize * (*Template) ) + aPos.x;
1554  Template++;
1555 
1556  corner.y = ( halfSize * (*Template) ) + aPos.y;
1557  Template++;
1558 
1559  aPoints.push_back( corner );
1560  }
1561 }
1562 
1563 
1565 {
1566  int penWidth = GetEffectiveTextPenWidth();
1567  int margin = GetTextOffset();
1568 
1569  int x = GetTextPos().x;
1570  int y = GetTextPos().y;
1571 
1572  int height = GetTextHeight() + penWidth + margin;
1573  int length = LenSize( GetShownText(), penWidth )
1574  + height; // add height for triangular shapes
1575 
1576  int dx, dy;
1577 
1578  switch( GetLabelSpinStyle() )
1579  {
1580  default:
1582  dx = -length;
1583  dy = height;
1584  x += Mils2iu( DANGLING_SYMBOL_SIZE );
1585  y -= height / 2;
1586  break;
1587 
1588  case LABEL_SPIN_STYLE::UP:
1589  dx = height;
1590  dy = -length;
1591  x -= height / 2;
1592  y += Mils2iu( DANGLING_SYMBOL_SIZE );
1593  break;
1594 
1596  dx = length;
1597  dy = height;
1598  x -= Mils2iu( DANGLING_SYMBOL_SIZE );
1599  y -= height / 2;
1600  break;
1601 
1603  dx = height;
1604  dy = length;
1605  x -= height / 2;
1606  y -= Mils2iu( DANGLING_SYMBOL_SIZE );
1607  break;
1608  }
1609 
1610  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1611  box.Normalize();
1612  return box;
1613 }
1614 
1615 
1617 {
1618  wxPoint text_offset;
1619  int dist = GetTextOffset( aSettings );
1620 
1621  dist += GetTextWidth();
1622 
1623  switch( GetLabelSpinStyle() )
1624  {
1625  default:
1626  case LABEL_SPIN_STYLE::LEFT: text_offset.x = -dist; break; // Orientation horiz normale
1627  case LABEL_SPIN_STYLE::UP: text_offset.y = -dist; break; // Orientation vert UP
1628  case LABEL_SPIN_STYLE::RIGHT: text_offset.x = dist; break; // Orientation horiz inverse
1629  case LABEL_SPIN_STYLE::BOTTOM: text_offset.y = dist; break; // Orientation vert BOTTOM
1630  }
1631 
1632  return text_offset;
1633 }
1634 
1635 
1637 {
1638  return wxString::Format( _( "Hierarchical Label '%s'" ), ShortenedShownText() );
1639 }
1640 
1641 
1643 {
1645 }
1646 
1647 
1648 HTML_MESSAGE_BOX* SCH_TEXT::ShowSyntaxHelp( wxWindow* aParentWindow )
1649 {
1650  wxString msg =
1651 #include "sch_text_help_md.h"
1652  ;
1653 
1654  HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) );
1655  wxSize sz( 320, 320 );
1656 
1657  dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) );
1658  dlg->SetDialogSizeInDU( sz.x, sz.y );
1659 
1660  wxString html_txt;
1661  ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt );
1662  dlg->m_htmlWindow->AppendToPage( html_txt );
1663  dlg->ShowModeless();
1664 
1665  return dlg;
1666 }
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_text.cpp:278
const EDA_RECT GetBoundingBoxBase() const
Return the bounding box on the global label only, without taking in account the intersheet references...
Definition: sch_text.cpp:1375
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
Definition: sch_text.cpp:982
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:50
bool IsBold() const
Definition: eda_text.h:190
void Offset(int dx, int dy)
Definition: eda_rect.h:147
static int Template3STATE_HN[]
Definition: sch_text.cpp:119
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:44
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:103
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
Definition: eda_text.cpp:143
static int TemplateUNSPC_HN[]
Definition: sch_text.cpp:109
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
wxPoint GetPosition() const
Definition: sch_item.h:129
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
static int Template3STATE_HI[]
Definition: sch_text.cpp:120
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:206
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:110
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
Container for project specific data.
Definition: project.h:62
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_text.cpp:1054
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:64
Holds all the data relating to one schematic.
Definition: schematic.h:59
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
static int TemplateOUT_UP[]
Definition: sch_text.cpp:106
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &offset) override
Print a schematic item.
Definition: sch_text.cpp:1271
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
Definition: sch_item.cpp:170
LABEL_SPIN_STYLE m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:274
wxPoint 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_text.cpp:988
bool m_isDangling
True if not connected to another object if the object derive from SCH_TEXT supports connections.
Definition: sch_text.h:260
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:540
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_text.cpp:1443
static int TemplateOUT_HN[]
Definition: sch_text.cpp:104
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: sch_text.cpp:654
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:129
void SetItalic(bool isItalic)
Definition: eda_text.h:186
int color
Definition: DXF_plotter.cpp:60
EDA_RECT 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:229
static int TemplateUNSPC_UP[]
Definition: sch_text.cpp:111
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:253
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
static int TemplateIN_UP[]
Definition: sch_text.cpp:101
void Plot(PLOTTER *aPlotter) const override
Plot the schematic item to aPlotter.
Definition: sch_text.cpp:1292
Definition: color4d.h:61
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
double GetTextAngle() const
Definition: eda_text.h:181
static int TemplateOUT_HI[]
Definition: sch_text.cpp:105
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_text.cpp:642
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:115
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_text.cpp:893
Schematic editor (Eeschema) main window.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:244
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
CONNECTION_TYPE
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &offset) override
Print a schematic item.
Definition: sch_text.cpp:1512
SCH_GLOBALLABEL(const wxPoint &aPos=wxPoint(0, 0), const wxString &aText=wxEmptyString)
Definition: sch_text.cpp:905
int GetTextThickness() const
Definition: eda_text.h:167
The base class for create windows for drawing purpose.
CONNECTION_TYPE m_connectionType
Definition: sch_text.h:262
virtual wxPoint GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Definition: sch_text.cpp:245
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:498
static int Template3STATE_BOTTOM[]
Definition: sch_text.cpp:122
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:94
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
void MirrorSpinStyle(bool aLeftRight) override
Definition: sch_text.cpp:1110
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:149
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_text.cpp:1642
int GetTextHeight() const
Definition: eda_text.h:251
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:131
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
static int TemplateIN_BOTTOM[]
Definition: sch_text.cpp:102
int GetPenWidth() const override
Definition: sch_text.cpp:410
void SetTextX(int aX)
Definition: eda_text.h:256
bool IsItalic() const
Definition: eda_text.h:187
No connection to this item.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:119
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static int TemplateOUT_BOTTOM[]
Definition: sch_text.cpp:107
void GetContextualTextVars(wxArrayString *aVars) const
Return the set of contextual text variable tokens for this text item.
Definition: sch_text.cpp:566
const wxPoint GetEnd() const
Definition: eda_rect.h:103
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:819
int LenSize(const wxString &aLine, int aThickness) const
Definition: eda_text.cpp:194
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: sch_text.cpp:1220
SCH_LAYER_ID m_layer
Definition: sch_item.h:496
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_text.cpp:287
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:227
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:1465
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:205
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:114
#define NULL
#define DANGLING_SYMBOL_SIZE
wxPoint 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_text.cpp:1616
const wxPoint GetOrigin() const
Definition: eda_rect.h:101
void SetEnd(int x, int y)
Definition: eda_rect.h:182
static int TemplateIN_HI[]
Definition: sch_text.cpp:100
wxString GetPageNumber() const
const wxSize & GetTextSize() const
Definition: eda_text.h:245
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
static int Template3STATE_UP[]
Definition: sch_text.cpp:121
bool IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:233
LABEL_SPIN_STYLE()=default
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:214
Helper dialog and control classes.
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:208
EDA_ITEM * GetItem() const
Definition: sch_item.h:130
static int TemplateBIDI_HN[]
Definition: sch_text.cpp:114
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_text.cpp:269
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:1471
#define _(s)
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
const EDA_RECT GetBoundingBox() const override
Return the bounding box on the global label only, including the intersheet references.
Definition: sch_text.cpp:1425
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
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_text.cpp:425
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1532
wxDC * GetPrintDC() const
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:1564
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:159
int GetTextOffset(const RENDER_SETTINGS *aSettings=nullptr) const
Definition: sch_text.cpp:393
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const 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_text.cpp:957
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:531
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
HTML_MESSAGE_BOX.
void UpdateIntersheetRefProps()
Definition: sch_text.cpp:1165
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:576
wxPoint GetPosition() const override
Definition: sch_text.h:237
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &offset) override
Print a schematic item.
Definition: sch_text.cpp:416
LABEL_SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
Definition: sch_text.cpp:185
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SET > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:503
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.h:202
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_text.cpp:1153
bool IsMultilineAllowed() const
Definition: eda_text.h:203
static int TemplateBIDI_BOTTOM[]
Definition: sch_text.cpp:117
This item represents a net.
LABEL_SPIN_STYLE RotateCCW()
Definition: sch_text.cpp:151
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: string.cpp:895
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
virtual void Rotate90(bool aClockwise)
Definition: sch_text.cpp:299
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:272
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_text.cpp:1135
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
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
EDA_UNITS
Definition: eda_units.h:38
void SetDialogSizeInDU(int aWidth, int aHeight)
set the dialog size, using a "logical" value.
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:403
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_text.cpp:899
No updates are required.
Definition: view_item.h:51
virtual void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< wxPoint > &aPoints, const wxPoint &Pos) const
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.h:181
Base plotter engine class.
Definition: plotter.h:121
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_text.cpp:373
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Definition: sch_text.cpp:1648
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:135
PINSHEETLABEL_SHAPE
Definition: sch_text.h:95
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, COLOR4D aColor, OUTLINE_MODE aDisplay_mode=FILLED)
Print this text object to the device context aDC.
Definition: eda_text.cpp:407
LABEL_SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
Definition: sch_text.cpp:168
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:156
int GetTextWidth() const
Definition: eda_text.h:248
static int TemplateBIDI_UP[]
Definition: sch_text.cpp:116
LABEL_SPIN_STYLE RotateCW()
Definition: sch_text.cpp:134
const char * name
Definition: DXF_plotter.cpp:59
SCH_FIELD m_intersheetRefsField
Definition: sch_text.h:423
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
void CreateGraphicShape(const RENDER_SETTINGS *aRenderSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1303
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:268
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_text.cpp:521
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:358
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:214
virtual wxString GetClass() const override
Return the class name.
Definition: sch_text.h:130
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
Handle the component boundary box.
Definition: eda_rect.h:42
DANGLING_END_T GetType() const
Definition: sch_item.h:132
T MIRRORVAL(T aPoint, T aMirrorRef)
Returns the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:31
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:70
static int * TemplateShape[5][4]
Definition: sch_text.cpp:124
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_text.cpp:1177
These settings were stored in SCH_BASE_FRAME previously.
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_text.cpp:436
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
void GetLinePositions(std::vector< wxPoint > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:430
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:865
std::map< wxString, std::set< wxString > > & GetPageRefsMap()
Definition: schematic.h:160
Store schematic specific render settings.
Definition: sch_painter.h:70
wxString getElectricalTypeLabel(PINSHEETLABEL_SHAPE aType)
Definition: sch_text.cpp:552
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_text.cpp:1449
int GetDefaultPenWidth() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
void Plot(PLOTTER *aPlotter) const override
Plot the schematic item to aPlotter.
Definition: sch_text.cpp:674
virtual void Text(const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=nullptr)
Draw text with the plotter.
Definition: gr_text.cpp:217
PINSHEETLABEL_SHAPE m_shape
Definition: sch_text.h:256
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:166
virtual void MirrorSpinStyle(bool aLeftRight)
Definition: sch_text.cpp:308
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:87
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:211
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:174
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:1020
bool IsType(const KICAD_T aScanTypes[]) const override
Check whether the item is one of the listed types.
Definition: sch_text.cpp:825
SCH_HIERLABEL(const wxPoint &aPos=wxPoint(0, 0), const wxString &aText=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
Definition: sch_text.cpp:1455
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:936
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
static int TemplateUNSPC_BOTTOM[]
Definition: sch_text.cpp:112
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:317
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119
bool IsBus() const
SEARCH_RESULT
Definition: eda_item.h:41
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_text.cpp:1636
Message panel definition file.
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_field.cpp:204
void Rotate90(bool aClockwise) override
Definition: sch_text.cpp:1067
SCH_TEXT(const wxPoint &aPos=wxPoint(0, 0), const wxString &aText=wxEmptyString, KICAD_T aType=SCH_TEXT_T)
Definition: sch_text.cpp:202
void SetBold(bool aBold)
Definition: eda_text.h:189
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:693
SCH_LABEL(const wxPoint &aPos=wxPoint(0, 0), const wxString &aText=wxEmptyString)
Definition: sch_text.cpp:809
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
int GetSizeMax() const
Definition: eda_rect.h:96
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:141
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:942
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_text.cpp:648
void Plot(PLOTTER *aPlotter) const override
Plot the schematic item to aPlotter.
Definition: sch_field.cpp:643
#define DEFAULT_TEXT_OFFSET_RATIO
The offset of the pin name string from the end of the pin in mils.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
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_text.cpp:720
This item represents a bus vector.
bool IncrementLabelMember(wxString &name, int aIncrement)
Definition: sch_text.cpp:55
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
static int TemplateIN_HN[]
Definition: sch_text.cpp:99
void SetTextY(int aY)
Definition: eda_text.h:257
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:161
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103