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@verizon.net>
6  * Copyright (C) 1992-2019 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 <fctsys.h>
32 #include <gr_basic.h>
33 #include <macros.h>
34 #include <trigo.h>
35 #include <sch_draw_panel.h>
36 #include <gr_text.h>
37 #include <sch_edit_frame.h>
38 #include <plotter.h>
39 #include <msgpanel.h>
40 #include <gal/stroke_font.h>
41 #include <bitmaps.h>
42 #include <math/util.h> // for KiROUND
43 
44 #include <sch_text.h>
45 #include <netlist_object.h>
47 #include <trace_helpers.h>
48 
49 #include <wx/debug.h>
50 
51 
52 extern void IncrementLabelMember( wxString& name, int aIncrement );
53 
54 /* Coding polygons for global symbol graphic shapes.
55  * the first parml is the number of corners
56  * others are the corners coordinates in reduced units
57  * the real coordinate is the reduced coordinate * text half size
58  */
59 static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
60 static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
61 static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
62 static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
63 
64 static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
65 static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
66 static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
67 static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
68 
69 static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
70 static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
71 static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
72 static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
73 
74 static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
75 static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
76 static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
77 static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
78 
79 static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
80 static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
81 static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
82 static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
83 
84 static int* TemplateShape[5][4] =
85 {
91 };
92 
93 
94 SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType )
95  : SCH_ITEM( NULL, aType ), EDA_TEXT( text ), m_shape( PINSHEETLABEL_SHAPE::PS_INPUT )
96 {
98  m_isDangling = false;
101 
102  SetTextPos( pos );
103  SetMultilineAllowed( true );
104 }
105 
106 
107 SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
108  SCH_ITEM( aText ),
109  EDA_TEXT( aText )
110 {
111  m_shape = aText.m_shape;
112  m_isDangling = aText.m_isDangling;
113  m_spin_style = aText.m_spin_style;
115 }
116 
117 
119 {
120  return new SCH_TEXT( *this );
121 }
122 
123 
124 void SCH_TEXT::IncrementLabel( int aIncrement )
125 {
126  wxString text = GetText();
127  IncrementLabelMember( text, aIncrement );
128  SetText(text );
129 }
130 
131 
133 {
134  wxPoint text_offset;
135 
136  // add an offset to x (or y) position to aid readability of text on a wire or line
137  int thick_offset = KiROUND( GetTextOffsetRatio() * GetTextSize().y );
138  thick_offset += ( GetPenSize() + GetDefaultLineThickness() ) / 2;
139 
140  switch( GetLabelSpinStyle() )
141  {
144  text_offset.x = -thick_offset;
145  break; // Vert Orientation
146  default:
149  text_offset.y = -thick_offset;
150  break; // Horiz Orientation
151  }
152 
153  return text_offset;
154 }
155 
156 
157 void SCH_TEXT::MirrorY( int aYaxis_position )
158 {
159  // Text is NOT really mirrored; it is moved to a suitable horizontal position
161 
162  SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
163 }
164 
165 
166 void SCH_TEXT::MirrorX( int aXaxis_position )
167 {
168  // Text is NOT really mirrored; it is moved to a suitable vertical position
170 
171  SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
172 }
173 
174 
175 void SCH_TEXT::Rotate( wxPoint aPosition )
176 {
177  int dy = 0;
178 
179  wxPoint pt = GetTextPos();
180  RotatePoint( &pt, aPosition, 900 );
181  SetTextPos( pt );
182 
183  SetLabelSpinStyle( GetLabelSpinStyle().RotateCW() );
184 
185  if( this->Type() == SCH_TEXT_T )
186  {
187  switch( GetLabelSpinStyle() )
188  {
191  dy = GetTextHeight();
192  break;
195  default:
196  dy = 0;
197  dy = 0;
198  break;
199  }
200 
201  SetTextY( GetTextPos().y + dy );
202  }
203 }
204 
205 
207 {
208  m_spin_style = aSpinStyle;
209 
210  // Assume "Right" and Left" mean which side of the anchor the text will be on
211  // Thus we want to left justify text up agaisnt the anchor if we are on the right
212  switch( aSpinStyle )
213  {
214  default:
215  wxASSERT_MSG( 1, "Bad spin style" );
216  break;
217 
218  case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
219  //
220  m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
224  break;
225 
226  case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
230  break;
231 
232  case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
236  break;
237 
238  case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
242  break;
243  }
244 }
245 
246 
248 {
249  SCH_TEXT* item = (SCH_TEXT*) aItem;
250 
251  std::swap( m_Layer, item->m_Layer );
252 
253  std::swap( m_shape, item->m_shape );
254  std::swap( m_isDangling, item->m_isDangling );
255  std::swap( m_spin_style, item->m_spin_style );
256 
257  SwapText( *item );
258  SwapEffects( *item );
259 }
260 
261 
262 bool SCH_TEXT::operator<( const SCH_ITEM& aItem ) const
263 {
264  if( Type() != aItem.Type() )
265  return Type() < aItem.Type();
266 
267  auto other = static_cast<const SCH_TEXT*>( &aItem );
268 
269  if( GetLayer() != other->GetLayer() )
270  return GetLayer() < other->GetLayer();
271 
272  if( GetPosition().x != other->GetPosition().x )
273  return GetPosition().x < other->GetPosition().x;
274 
275  if( GetPosition().y != other->GetPosition().y )
276  return GetPosition().y < other->GetPosition().y;
277 
278  return GetText() < other->GetText();
279 }
280 
281 
283 {
284  int pensize = GetThickness();
285 
286  if( pensize == 0 ) // Use default values for pen size
287  {
288  if( IsBold() )
289  pensize = GetPenSizeForBold( GetTextWidth() );
290  else
291  pensize = GetDefaultLineThickness();
292  }
293 
294  // Clip pen size for small texts:
295  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
296  return pensize;
297 }
298 
299 
300 void SCH_TEXT::Print( wxDC* DC, const wxPoint& aOffset )
301 {
303  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
304 
305  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
306 
307  wxPoint text_offset = aOffset + GetSchematicTextOffset();
308 
309  int savedWidth = GetThickness();
310  SetThickness( linewidth ); // Set the minimum width
311 
312  EDA_TEXT::Print( DC, text_offset, color );
313 
314  SetThickness( savedWidth );
315 }
316 
317 
318 void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
319 {
320  // Normal text labels cannot be tested for dangling ends.
321  if( Type() == SCH_TEXT_T )
322  return;
323 
324  DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
325  aItemList.push_back( item );
326 }
327 
328 
329 bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
330  const SCH_SHEET_PATH* aPath )
331 {
332  // Normal text labels cannot be tested for dangling ends.
333  if( Type() == SCH_TEXT_T )
334  return false;
335 
336  bool previousState = m_isDangling;
337  m_isDangling = true;
339 
340  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
341  {
342  DANGLING_END_ITEM& item = aItemList[ii];
343 
344  if( item.GetItem() == this )
345  continue;
346 
347  switch( item.GetType() )
348  {
349  case PIN_END:
350  case LABEL_END:
351  case SHEET_LABEL_END:
352  case NO_CONNECT_END:
353  if( GetTextPos() == item.GetPosition() )
354  {
355  m_isDangling = false;
356 
357  if( aPath && item.GetType() != PIN_END )
358  m_connected_items[ *aPath ].insert( static_cast<SCH_ITEM*>( item.GetItem() ) );
359  }
360 
361  break;
362 
363 
364  case BUS_START_END:
366  // fall through
367 
368  case WIRE_START_END:
369  {
370  // These schematic items have created 2 DANGLING_END_ITEM one per end. But being
371  // a paranoid programmer, I'll check just in case.
372  ii++;
373 
374  wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
375  wxT( "Dangling end type list overflow. Bad programmer!" ) );
376 
377  DANGLING_END_ITEM & nextItem = aItemList[ii];
378  m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetTextPos() );
379 
380  if( !m_isDangling )
381  {
384 
385  // Add the line to the connected items, since it won't be picked
386  // up by a search of intersecting connection points
387  if( aPath )
388  {
389  auto sch_item = static_cast<SCH_ITEM*>( item.GetItem() );
390  AddConnectionTo( *aPath, sch_item );
391  sch_item->AddConnectionTo( *aPath, this );
392  }
393  }
394  }
395  break;
396 
397  default:
398  break;
399  }
400 
401  if( !m_isDangling )
402  break;
403  }
404 
405  if( m_isDangling )
407 
408  return previousState != m_isDangling;
409 }
410 
411 
412 void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
413 {
414  // Normal text labels do not have connection points. All others do.
415  if( Type() == SCH_TEXT_T )
416  return;
417 
418  aPoints.push_back( GetTextPos() );
419 }
420 
421 
423 {
424  // We must pass the effective text thickness to GetTextBox
425  // when calculating the bounding box
426  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
427 
428  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
429 
430  EDA_RECT rect = GetTextBox( -1, linewidth, false, GetTextMarkupFlags() );
431 
432  if( GetTextAngle() != 0 ) // Rotate rect
433  {
434  wxPoint pos = rect.GetOrigin();
435  wxPoint end = rect.GetEnd();
436 
437  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
438  RotatePoint( &end, GetTextPos(), GetTextAngle() );
439 
440  rect.SetOrigin( pos );
441  rect.SetEnd( end );
442  }
443 
444  rect.Normalize();
445  return rect;
446 }
447 
448 
449 wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
450 {
451  return wxString::Format( _( "Graphic Text \"%s\"" ), GetChars( ShortenedShownText() ) );
452 }
453 
454 
456 {
457  return text_xpm;
458 }
459 
460 
462  SCH_SHEET_PATH* aSheetPath )
463 {
464  if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
465  return;
466 
467  NETLIST_OBJECT* item = new NETLIST_OBJECT();
468  item->m_SheetPath = *aSheetPath;
469  item->m_SheetPathInclude = *aSheetPath;
470  item->m_Comp = (SCH_ITEM*) this;
471  item->m_Type = NETLIST_ITEM::LABEL;
472 
473  if( GetLayer() == LAYER_GLOBLABEL )
475  else if( GetLayer() == LAYER_HIERLABEL )
477 
478  item->m_Label = GetText();
479  item->m_Start = item->m_End = GetTextPos();
480 
481  aNetListItems.push_back( item );
482 
483  // If a bus connects to label
484  if( Connection( *aSheetPath )->IsBusLabel( GetText() ) )
485  item->ConvertBusToNetListItems( aNetListItems );
486 }
487 
488 
489 bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
490 {
491  EDA_RECT bBox = GetBoundingBox();
492  bBox.Inflate( aAccuracy );
493  return bBox.Contains( aPosition );
494 }
495 
496 
497 bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
498 {
499  EDA_RECT bBox = GetBoundingBox();
500  bBox.Inflate( aAccuracy );
501 
502  if( aContained )
503  return aRect.Contains( bBox );
504 
505  return aRect.Intersects( bBox );
506 }
507 
508 
509 void SCH_TEXT::Plot( PLOTTER* aPlotter )
510 {
511  static std::vector<wxPoint> Poly;
512  COLOR4D color = aPlotter->ColorSettings()->GetColor( GetLayer() );
513  int tmp = GetThickness();
514  int thickness = GetPenSize();
515 
516  // Two thicknesses are set here:
517  // The first is for EDA_TEXT, which controls the interline spacing based on text thickness
518  // The second is for the output that sets the actual stroke size
519  SetThickness( thickness );
520  aPlotter->SetCurrentLineWidth( thickness );
521 
522  if( IsMultilineAllowed() )
523  {
524  std::vector<wxPoint> positions;
525  wxArrayString strings_list;
526  wxStringSplit( GetShownText(), strings_list, '\n' );
527  positions.reserve( strings_list.Count() );
528 
529  GetPositionsOfLinesOfMultilineText(positions, (int) strings_list.Count() );
530 
531  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
532  {
533  wxPoint textpos = positions[ii] + GetSchematicTextOffset();
534  wxString& txt = strings_list.Item( ii );
535  aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(),
536  GetVertJustify(), thickness, IsItalic(), IsBold() );
537  }
538  }
539  else
540  {
541  wxPoint textpos = GetTextPos() + GetSchematicTextOffset();
542 
543  aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
544  GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() );
545  }
546 
547  // Draw graphic symbol for global or hierarchical labels
548  CreateGraphicShape( Poly, GetTextPos() );
549 
550  aPlotter->SetCurrentLineWidth( GetPenSize() );
551 
552  if( Poly.size() )
553  aPlotter->PlotPoly( Poly, NO_FILL );
554 
555  SetThickness( tmp );
556 }
557 
558 
560 {
561  wxString msg;
562 
563  switch( Type() )
564  {
565  case SCH_TEXT_T: msg = _( "Graphic Text" ); break;
566  case SCH_LABEL_T: msg = _( "Label" ); break;
567  case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
568  case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
569  case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
570  default: return;
571  }
572 
573  aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );
574 
575  switch( GetLabelSpinStyle() )
576  {
577  case LABEL_SPIN_STYLE::LEFT: msg = _( "Horizontal left" ); break;
578  case LABEL_SPIN_STYLE::UP: msg = _( "Vertical up" ); break;
579  case LABEL_SPIN_STYLE::RIGHT: msg = _( "Horizontal right" ); break;
580  case LABEL_SPIN_STYLE::BOTTOM: msg = _( "Vertical down" ); break;
581  default: msg = wxT( "???" ); break;
582  }
583 
584  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
585 
586  wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
587  int style = 0;
588 
589  if( IsItalic() )
590  style = 1;
591 
592  if( IsBold() )
593  style += 2;
594 
595  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
596 
597  // Display electrical type if it is relevant
599  {
600  switch( GetShape() )
601  {
602  case PINSHEETLABEL_SHAPE::PS_INPUT: msg = _( "Input" ); break;
603  case PINSHEETLABEL_SHAPE::PS_OUTPUT: msg = _( "Output" ); break;
604  case PINSHEETLABEL_SHAPE::PS_BIDI: msg = _( "Bidirectional" ); break;
605  case PINSHEETLABEL_SHAPE::PS_TRISTATE: msg = _( "Tri-State" ); break;
606  case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: msg = _( "Passive" ); break;
607  default: msg = wxT( "???" ); break;
608  }
609 
610  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );
611  }
612 
613  // Display text size (X or Y value, with are the same value in Eeschema)
614  msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
615  aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );
616 
617 #if defined(DEBUG)
618  if( auto conn = Connection( *g_CurrentSheet ) )
619  conn->AppendDebugInfoToMsgPanel( aList );
620 
621  msg.Printf( "%p", this );
622  aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) );
623 
624 #endif
625 }
626 
627 #if defined(DEBUG)
628 
629 void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
630 {
631  // XML output:
632  wxString s = GetClass();
633 
634  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
635  << " layer=\"" << m_Layer << '"'
636  << " shape=\"" << static_cast<int>( m_shape ) << '"'
637  << " dangling=\"" << m_isDangling << '"'
638  << '>'
639  << TO_UTF8( GetText() )
640  << "</" << s.Lower().mb_str() << ">\n";
641 }
642 
643 #endif
644 
645 
646 SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text )
647  : SCH_TEXT( pos, text, SCH_LABEL_T )
648 {
651  m_isDangling = true;
652  SetMultilineAllowed( false );
653 }
654 
655 
657 {
658  return new SCH_LABEL( *this );
659 }
660 
661 
662 bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const
663 {
664  static KICAD_T wireTypes[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
665  static KICAD_T busTypes[] = { SCH_LINE_LOCATE_BUS_T, EOT };
666 
667  if( SCH_ITEM::IsType( aScanTypes ) )
668  return true;
669 
670  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
671  {
672  if( *p == SCH_LABEL_LOCATE_WIRE_T )
673  {
674  wxASSERT( m_connected_items.count( *g_CurrentSheet ) );
675 
676  for( SCH_ITEM* connection : m_connected_items.at( *g_CurrentSheet ) )
677  {
678  if( connection->IsType( wireTypes ) )
679  return true;
680  }
681  }
682  else if ( *p == SCH_LABEL_LOCATE_BUS_T )
683  {
684  wxASSERT( m_connected_items.count( *g_CurrentSheet ) );
685 
686  for( SCH_ITEM* connection : m_connected_items.at( *g_CurrentSheet ) )
687  {
688  if( connection->IsType( busTypes ) )
689  return true;
690  }
691  }
692  }
693 
694  return false;
695 }
696 
697 
699 {
700  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
701  EDA_RECT rect = GetTextBox( -1, linewidth, false, GetTextMarkupFlags() );
702 
703  if( GetTextAngle() != 0.0 )
704  {
705  // Rotate rect
706  wxPoint pos = rect.GetOrigin();
707  wxPoint end = rect.GetEnd();
708 
709  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
710  RotatePoint( &end, GetTextPos(), GetTextAngle() );
711 
712  rect.SetOrigin( pos );
713  rect.SetEnd( end );
714 
715  rect.Normalize();
716  }
717 
718  return rect;
719 }
720 
721 
722 wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
723 {
724  return wxString::Format( _( "Label %s" ), ShortenedShownText() );
725 }
726 
727 
729 {
730  return add_line_label_xpm;
731 }
732 
733 
734 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text )
735  : SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
736 {
739  m_isDangling = true;
740  SetMultilineAllowed( false );
741 }
742 
743 
745 {
746  return new SCH_GLOBALLABEL( *this );
747 }
748 
749 
751 {
752  wxPoint text_offset;
753  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
754 
755  width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
756  int halfSize = GetTextWidth() / 2;
757  int offset = width;
758 
759  switch( m_shape )
760  {
764  offset += halfSize;
765  break;
766 
769  offset += KiROUND( GetTextOffsetRatio() * GetTextSize().y );
770  ;
771  break;
772 
773  default:
774  break;
775  }
776 
777  switch( GetLabelSpinStyle() )
778  {
779  default:
781  text_offset.x -= offset;
782  break; // Orientation horiz normal
784  text_offset.y -= offset;
785  break; // Orientation vert UP
787  text_offset.x += offset;
788  break; // Orientation horiz inverse
790  text_offset.y += offset;
791  break; // Orientation vert BOTTOM
792  }
793 
794  return text_offset;
795 }
796 
797 
799 {
800  m_spin_style = aSpinStyle;
801 
802  switch( aSpinStyle )
803  {
804  default:
805  wxASSERT_MSG( 1, "Bad spin style" );
806  break;
807 
808  case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
809  //
810  m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
814  break;
815 
816  case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
820  break;
821 
822  case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation
826  break;
827 
828  case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
832  break;
833  }
834 }
835 
836 
837 void SCH_GLOBALLABEL::Print( wxDC* DC, const wxPoint& aOffset )
838 {
839  static std::vector <wxPoint> Poly;
841  wxPoint text_offset = aOffset + GetSchematicTextOffset();
842 
843  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
844 
845  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
846 
847  int save_width = GetThickness();
848  SetThickness( linewidth );
849 
850  EDA_TEXT::Print( DC, text_offset, color );
851 
852  SetThickness( save_width ); // restore initial value
853 
854  CreateGraphicShape( Poly, GetTextPos() + aOffset );
855  GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
856 }
857 
858 
859 void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
860 {
861  int halfSize = GetTextHeight() / 2;
862  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
863 
864  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
865 
866  aPoints.clear();
867 
868  int symb_len = LenSize( GetShownText(), linewidth, GetTextMarkupFlags() ) + ( TXT_MARGIN * 2 );
869 
870  // Create outline shape : 6 points
871  int x = symb_len + linewidth + 3;
872 
873  // Use negation bar Y position to calculate full vertical size
874  // Search for overbar symbol
875  wxString test = GetText();
876  test.Replace( "~~", "" );
877  bool hasOverBar = test.find( "~" ) != wxString::npos;
878 
879  #define V_MARGIN 1.40
880  // Note: this factor is due to the fact the Y size of a few letters like '[' are bigger
881  // than the y size value, and we need a margin for the graphic symbol.
882  int y = KiROUND( halfSize * V_MARGIN );
883 
884  #define OVERBAR_V_MARGIN 1.2
885  // Note: this factor is due to the fact we need a margin for the graphic symbol.
886  if( hasOverBar )
888 
889  // Gives room for line thickess and margin
890  y += linewidth; // for line thickess
891  y += linewidth / 2; // for margin
892 
893  // Starting point(anchor)
894  aPoints.emplace_back( wxPoint( 0, 0 ) );
895  aPoints.emplace_back( wxPoint( 0, -y ) ); // Up
896  aPoints.emplace_back( wxPoint( -x, -y ) ); // left
897  aPoints.emplace_back( wxPoint( -x, 0 ) ); // Up left
898  aPoints.emplace_back( wxPoint( -x, y ) ); // left down
899  aPoints.emplace_back( wxPoint( 0, y ) ); // down
900 
901  int x_offset = 0;
902 
903  switch( m_shape )
904  {
906  x_offset = -halfSize;
907  aPoints[0].x += halfSize;
908  break;
909 
911  aPoints[3].x -= halfSize;
912  break;
913 
916  x_offset = -halfSize;
917  aPoints[0].x += halfSize;
918  aPoints[3].x -= halfSize;
919  break;
920 
922  default:
923  break;
924  }
925 
926  int angle = 0;
927 
928  switch( GetLabelSpinStyle() )
929  {
930  default:
932  break; // Orientation horiz normal
934  angle = -900;
935  break; // Orientation vert UP
937  angle = 1800;
938  break; // Orientation horiz inverse
940  angle = 900;
941  break; // Orientation vert BOTTOM
942  }
943 
944  // Rotate outlines and move corners in real position
945  for( wxPoint& aPoint : aPoints )
946  {
947  aPoint.x += x_offset;
948 
949  if( angle )
950  RotatePoint( &aPoint, angle );
951 
952  aPoint += Pos;
953  }
954 
955  aPoints.push_back( aPoints[0] ); // closing
956 }
957 
958 
960 {
961  int x, y, dx, dy, length, height;
962 
963  x = GetTextPos().x;
964  y = GetTextPos().y;
965  dx = dy = 0;
966 
967  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
968 
969  height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN;
970 
971  // text X size add height for triangular shapes(bidirectional)
972  length = LenSize( GetShownText(), width, GetTextMarkupFlags() ) + height +
973  Mils2iu( DANGLING_SYMBOL_SIZE );
974 
975  switch( GetLabelSpinStyle() ) // respect orientation
976  {
977  default:
979  dx = -length;
980  dy = height;
981  x += Mils2iu( DANGLING_SYMBOL_SIZE );
982  y -= height / 2;
983  break;
984 
986  dx = height;
987  dy = -length;
988  x -= height / 2;
989  y += Mils2iu( DANGLING_SYMBOL_SIZE );
990  break;
991 
993  dx = length;
994  dy = height;
995  x -= Mils2iu( DANGLING_SYMBOL_SIZE );
996  y -= height / 2;
997  break;
998 
1000  dx = height;
1001  dy = length;
1002  x -= height / 2;
1003  y -= Mils2iu( DANGLING_SYMBOL_SIZE );
1004  break;
1005  }
1006 
1007  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1008  box.Normalize();
1009  return box;
1010 }
1011 
1012 
1014 {
1015  return wxString::Format( _( "Global Label %s" ), ShortenedShownText() );
1016 }
1017 
1018 
1020 {
1021  return add_glabel_xpm;
1022 }
1023 
1024 
1025 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType )
1026  : SCH_TEXT( pos, text, aType )
1027 {
1030  m_isDangling = true;
1031  SetMultilineAllowed( false );
1032 }
1033 
1034 
1036 {
1037  return new SCH_HIERLABEL( *this );
1038 }
1039 
1040 
1042 {
1043  m_spin_style = aSpinStyle;
1044 
1045  // Assume "Right" and Left" mean which side of the port symbol the text will be on
1046  // If we are left of the symbol, we want to right justify to line up with the symbol
1047  switch( aSpinStyle )
1048  {
1049  default:
1050  wxLogWarning( "SetLabelSpinStyle bad spin style" );
1051  break;
1052 
1054  //
1055  m_spin_style = LABEL_SPIN_STYLE::LEFT; // Handle the error spin style by resetting
1059  break;
1060 
1061  case LABEL_SPIN_STYLE::UP:
1065  break;
1066 
1071  break;
1072 
1077  break;
1078  }
1079 }
1080 
1081 
1082 void SCH_HIERLABEL::Print( wxDC* DC, const wxPoint& offset )
1083 {
1084  static std::vector <wxPoint> Poly;
1085 
1086  auto conn = Connection( *g_CurrentSheet );
1087  COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer );
1088  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1089 
1090  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1091 
1092  int save_width = GetThickness();
1093  SetThickness( linewidth );
1094 
1095  wxPoint text_offset = offset + GetSchematicTextOffset();
1096  EDA_TEXT::Print( DC, text_offset, color );
1097 
1098  SetThickness( save_width ); // restore initial value
1099 
1100  CreateGraphicShape( Poly, GetTextPos() + offset );
1101  GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1102 }
1103 
1104 
1105 void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1106 {
1107  int* Template = TemplateShape[static_cast<int>( m_shape )][static_cast<int>( m_spin_style )];
1108  int halfSize = GetTextWidth() / 2;
1109  int imax = *Template; Template++;
1110 
1111  aPoints.clear();
1112 
1113  for( int ii = 0; ii < imax; ii++ )
1114  {
1115  wxPoint corner;
1116  corner.x = ( halfSize * (*Template) ) + Pos.x;
1117  Template++;
1118 
1119  corner.y = ( halfSize * (*Template) ) + Pos.y;
1120  Template++;
1121 
1122  aPoints.push_back( corner );
1123  }
1124 }
1125 
1126 
1128 {
1129  int x, y, dx, dy, length, height;
1130 
1131  x = GetTextPos().x;
1132  y = GetTextPos().y;
1133  dx = dy = 0;
1134 
1135  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1136 
1137  height = GetTextHeight() + width + 2 * TXT_MARGIN;
1138  length = LenSize( GetShownText(), width, GetTextMarkupFlags() )
1139  + height // add height for triangular shapes
1140  + 2 * Mils2iu( DANGLING_SYMBOL_SIZE );
1141 
1142  switch( GetLabelSpinStyle() )
1143  {
1144  default:
1146  dx = -length;
1147  dy = height;
1148  x += Mils2iu( DANGLING_SYMBOL_SIZE );
1149  y -= height / 2;
1150  break;
1151 
1152  case LABEL_SPIN_STYLE::UP:
1153  dx = height;
1154  dy = -length;
1155  x -= height / 2;
1156  y += Mils2iu( DANGLING_SYMBOL_SIZE );
1157  break;
1158 
1160  dx = length;
1161  dy = height;
1162  x -= Mils2iu( DANGLING_SYMBOL_SIZE );
1163  y -= height / 2;
1164  break;
1165 
1167  dx = height;
1168  dy = length;
1169  x -= height / 2;
1170  y -= Mils2iu( DANGLING_SYMBOL_SIZE );
1171  break;
1172  }
1173 
1174  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1175  box.Normalize();
1176  return box;
1177 }
1178 
1179 
1181 {
1182  wxPoint text_offset;
1183  int thickness = std::max( GetThickness(), GetDefaultLineThickness() );
1184  int offset = KiROUND( GetTextOffsetRatio() * GetTextSize().y );
1185  int total_offset = GetTextWidth() + offset + thickness;
1186 
1187  switch( GetLabelSpinStyle() )
1188  {
1189  default:
1191  text_offset.x = -total_offset;
1192  break; // Orientation horiz normale
1193  case LABEL_SPIN_STYLE::UP:
1194  text_offset.y = -total_offset;
1195  break; // Orientation vert UP
1197  text_offset.x = total_offset;
1198  break; // Orientation horiz inverse
1200  text_offset.y = total_offset;
1201  break; // Orientation vert BOTTOM
1202  }
1203 
1204  return text_offset;
1205 }
1206 
1207 
1209 {
1210  return wxString::Format( _( "Hierarchical Label %s" ), ShortenedShownText() );
1211 }
1212 
1213 
1215 {
1217 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:150
Definition: colors.h:57
#define TEXT_ANGLE_HORIZ
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:336
SCH_HIERLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
Definition: sch_text.cpp:1025
EDA_UNITS
Definition: common.h:184
bool IsBold() const
Definition: eda_text.h:167
SCH_LAYER_ID m_Layer
Definition: sch_item.h:152
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:728
static int Template3STATE_HN[]
Definition: sch_text.cpp:79
void Print(wxDC *DC, const wxPoint &offset) override
Function Print Print a schematic item.
Definition: sch_text.cpp:300
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
Definition: eda_text.cpp:138
static int TemplateUNSPC_HN[]
Definition: sch_text.cpp:69
wxPoint GetPosition() const
Definition: sch_item.h:131
static int Template3STATE_HI[]
Definition: sch_text.cpp:80
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:184
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:70
PNG memory record (file in memory).
Definition: bitmap_def.h:29
std::unordered_map< SCH_SHEET_PATH, ITEM_SET > m_connected_items
Stores pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:159
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: gr_text.cpp:66
#define TEXT_ANGLE_VERT
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_text.cpp:282
static double GetInterline(double aGlyphHeight)
Compute the distance (interline) between 2 lines of text (for multiline texts).
static int TemplateOUT_UP[]
Definition: sch_text.cpp:66
SCH_SHEET_PATH m_SheetPathInclude
SCH_GLOBALLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:734
#define V_MARGIN
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Adds a connection link between this item and another.
Definition: sch_item.cpp:144
LABEL_SPIN_STYLE m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:197
bool m_isDangling
True if not connected to another object if the object derive from SCH_TEXT supports connections.
Definition: sch_text.h:184
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:542
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1013
static int TemplateOUT_HN[]
Definition: sch_text.cpp:64
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_text.cpp:489
#define DANGLING_SYMBOL_SIZE
Definition: general.h:43
int color
Definition: DXF_plotter.cpp:61
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
static int TemplateUNSPC_UP[]
Definition: sch_text.cpp:71
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:231
static int TemplateIN_UP[]
Definition: sch_text.cpp:61
const BITMAP_OPAQUE text_xpm[1]
Definition: text.cpp:27
double GetTextAngle() const
Definition: eda_text.h:158
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:42
static int TemplateOUT_HI[]
Definition: sch_text.cpp:65
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:132
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:449
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:75
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:722
SCH_SHEET_PATH m_SheetPath
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
const BITMAP_OPAQUE add_hierarchical_label_xpm[1]
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
CONNECTION_TYPE m_connectionType
Definition: sch_text.h:186
EDA_ITEM * m_Comp
const BITMAP_OPAQUE add_line_label_xpm[1]
bool Contains(const wxPoint &aPoint) const
Function Contains.
static int Template3STATE_BOTTOM[]
Definition: sch_text.cpp:82
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:166
double GetTextOffsetRatio()
Amount to offset text above/below wires & busses.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1019
This file contains miscellaneous commonly used macros and functions.
NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected items in a...
int GetTextHeight() const
Definition: eda_text.h:229
#define TXT_MARGIN
The thickness to draw busses that do not have a specific width (can be changed in preference menu)
Definition: general.h:51
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=NULL)
Draws text with the plotter.
Definition: gr_text.cpp:232
static int TemplateIN_BOTTOM[]
Definition: sch_text.cpp:62
void SetTextX(int aX)
Definition: eda_text.h:234
bool IsItalic() const
Definition: eda_text.h:164
No connection to this item.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:109
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
static int TemplateOUT_BOTTOM[]
Definition: sch_text.cpp:67
const wxPoint GetEnd() const
Definition: eda_rect.h:116
int GetTextMarkupFlags()
Definition: gr_text.cpp:55
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:656
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:81
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:118
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_text.cpp:412
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:1035
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:183
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
#define NULL
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:750
COLOR_SETTINGS * ColorSettings()
Definition: plotter.h:145
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
#define OVERBAR_V_MARGIN
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:184
void SetEnd(int x, int y)
Definition: eda_rect.h:192
static int TemplateIN_HI[]
Definition: sch_text.cpp:60
const wxSize & GetTextSize() const
Definition: eda_text.h:223
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:187
static int Template3STATE_UP[]
Definition: sch_text.cpp:81
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper for all the old plotting/printing code while it still exists.
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:163
EDA_ITEM * GetItem() const
Definition: sch_item.h:132
static int TemplateBIDI_HN[]
Definition: sch_text.cpp:74
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:859
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:1041
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:959
wxLogTrace helper definitions.
virtual bool IsType(const KICAD_T aScanTypes[]) const
Function IsType Checks whether the item is one of the listed types.
Definition: base_struct.h:286
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points.
Definition: sch_text.cpp:318
Definition: colors.h:60
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:1127
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:237
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:422
SCH_SHEET_PATH.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_text.h:317
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.h:180
bool IsMultilineAllowed() const
Definition: eda_text.h:181
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet Note: the returned value can ...
Definition: sch_item.cpp:128
void Print(wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aDisplay_mode=FILLED)
Print this text object to the device context aDC.
Definition: eda_text.cpp:361
static int TemplateBIDI_BOTTOM[]
Definition: sch_text.cpp:77
void Print(wxDC *DC, const wxPoint &offset) override
Function Print Print a schematic item.
Definition: sch_text.cpp:1082
This item represents a net.
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:224
void Normalize()
Function Normalize ensures that the height ant width are positive.
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aUseMils, EDA_DATA_TYPE aType)
Definition: base_units.cpp:127
const BITMAP_OPAQUE add_glabel_xpm[1]
Definition: add_glabel.cpp:42
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1105
Base plotter engine class.
Definition: plotter.h:104
COLOR4D GetColor(int aLayer) const
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_text.cpp:262
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:131
PINSHEETLABEL_SHAPE
Definition: sch_text.h:163
virtual void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos)
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.h:263
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: sch_text.cpp:559
int GetTextWidth() const
Definition: eda_text.h:226
static int TemplateBIDI_UP[]
Definition: sch_text.cpp:76
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
const char * name
Definition: DXF_plotter.cpp:60
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_text.cpp:509
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:186
#define _(s)
Definition: 3d_actions.cpp:33
int LenSize(const wxString &aLine, int aThickness, int aMarkupFlags) const
Definition: eda_text.cpp:150
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:247
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:175
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_text.h:218
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
SCH_TEXT(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_TEXT_T)
Definition: sch_text.cpp:94
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:455
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
T Mirror(T aPoint, T aMirrorRef)
Function MIRROR Mirror aPoint in aMirrorRef.
Definition: macros.h:118
DANGLING_END_T GetType() const
Definition: sch_item.h:134
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:61
static int * TemplateShape[5][4]
Definition: sch_text.cpp:84
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Definition: sch_text.cpp:329
void IncrementLabelMember(wxString &name, int aIncrement)
Definition: edit_label.cpp:281
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:698
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
void GetPositionsOfLinesOfMultilineText(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:384
PINSHEETLABEL_SHAPE m_shape
Definition: sch_text.h:180
DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be connected ...
Definition: sch_item.h:76
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
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:798
bool IsType(const KICAD_T aScanTypes[]) const override
Function IsType Checks whether the item is one of the listed types.
Definition: sch_text.cpp:662
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:744
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
static int TemplateUNSPC_BOTTOM[]
Definition: sch_text.cpp:72
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:206
Definition of the NETLIST_OBJECT class.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1208
Message panel definition file.
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_text.cpp:157
NETLIST_ITEM m_Type
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1214
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
SCH_LABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:646
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:1180
This item represents a bus vector.
void GetNetListItem(NETLIST_OBJECT_LIST &aNetListItems, SCH_SHEET_PATH *aSheetPath) override
Function GetNetListItem creates a new NETLIST_OBJECT for the schematic object and adds it to aNetList...
Definition: sch_text.cpp:461
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
static int TemplateIN_HN[]
Definition: sch_text.cpp:59
void SetThickness(int aNewThickness)
Set the pen width.
Definition: eda_text.h:143
void SetTextY(int aY)
Definition: eda_text.h:235
void Print(wxDC *DC, const wxPoint &offset) override
Function Print Print a schematic item.
Definition: sch_text.cpp:837
void ConvertBusToNetListItems(NETLIST_OBJECT_LIST &aNetListItems)
Function ConvertBusToNetListItems breaks the text of a bus label type net list object into as many me...
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:242
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
void IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:124
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
Definition: colors.h:62