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>
46 #include <trace_helpers.h>
47 
48 #include <wx/debug.h>
49 
50 
51 extern void IncrementLabelMember( wxString& name, int aIncrement );
52 
53 // Only for tests: set DRAW_BBOX to 1 to draw the bounding box of labels
54 #define DRAW_BBOX 0
55 
56 // Margin in internal units (mils) between labels and wires
57 #define TXT_MARGIN 4
58 
59 /* Coding polygons for global symbol graphic shapes.
60  * the first parml is the number of corners
61  * others are the corners coordinates in reduced units
62  * the real coordinate is the reduced coordinate * text half size
63  */
64 static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
65 static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
66 static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
67 static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
68 
69 static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
70 static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
71 static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
72 static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
73 
74 static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
75 static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
76 static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
77 static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
78 
79 static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
80 static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
81 static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
82 static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
83 
84 static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
85 static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
86 static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
87 static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
88 
89 static int* TemplateShape[5][4] =
90 {
96 };
97 
98 
99 SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType )
100  : SCH_ITEM( NULL, aType ), EDA_TEXT( text ), m_shape( PINSHEETLABEL_SHAPE::PS_INPUT )
101 {
103  m_isDangling = false;
106 
107  SetTextPos( pos );
108  SetMultilineAllowed( true );
109 }
110 
111 
112 SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
113  SCH_ITEM( aText ),
114  EDA_TEXT( aText )
115 {
116  m_shape = aText.m_shape;
117  m_isDangling = aText.m_isDangling;
118  m_spin_style = aText.m_spin_style;
120 }
121 
122 
124 {
125  return new SCH_TEXT( *this );
126 }
127 
128 
129 void SCH_TEXT::IncrementLabel( int aIncrement )
130 {
131  wxString text = GetText();
132  IncrementLabelMember( text, aIncrement );
133  SetText(text );
134 }
135 
136 
138 {
139  wxPoint text_offset;
140 
141  // add an offset to x (or y) position to aid readability of text on a wire or line
142  int thick_offset = Mils2iu( TXT_MARGIN ) + ( GetPenSize() + GetDefaultLineThickness() ) / 2;
143 
144  switch( GetLabelSpinStyle() )
145  {
148  text_offset.x = -thick_offset;
149  break; // Vert Orientation
150  default:
153  text_offset.y = -thick_offset;
154  break; // Horiz Orientation
155  }
156 
157  return text_offset;
158 }
159 
160 
161 void SCH_TEXT::MirrorY( int aYaxis_position )
162 {
163  // Text is NOT really mirrored; it is moved to a suitable horizontal position
165 
166  SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
167 }
168 
169 
170 void SCH_TEXT::MirrorX( int aXaxis_position )
171 {
172  // Text is NOT really mirrored; it is moved to a suitable vertical position
174 
175  SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
176 }
177 
178 
179 void SCH_TEXT::Rotate( wxPoint aPosition )
180 {
181  int dy = 0;
182 
183  wxPoint pt = GetTextPos();
184  RotatePoint( &pt, aPosition, 900 );
185  SetTextPos( pt );
186 
187  SetLabelSpinStyle( GetLabelSpinStyle().RotateCW() );
188 
189  if( this->Type() == SCH_TEXT_T )
190  {
191  switch( GetLabelSpinStyle() )
192  {
195  dy = GetTextHeight();
196  break;
199  default:
200  dy = 0;
201  dy = 0;
202  break;
203  }
204 
205  SetTextY( GetTextPos().y + dy );
206  }
207 }
208 
209 
211 {
212  m_spin_style = aSpinStyle;
213 
214  // Assume "Right" and Left" mean which side of the anchor the text will be on
215  // Thus we want to left justify text up agaisnt the anchor if we are on the right
216  switch( aSpinStyle )
217  {
218  default:
219  wxASSERT_MSG( 1, "Bad spin style" );
220  break;
221 
222  case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
223  //
224  m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
228  break;
229 
230  case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
234  break;
235 
236  case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation - Right justified
240  break;
241 
242  case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
246  break;
247  }
248 }
249 
250 
252 {
253  SCH_TEXT* item = (SCH_TEXT*) aItem;
254 
255  std::swap( m_Layer, item->m_Layer );
256 
257  std::swap( m_shape, item->m_shape );
258  std::swap( m_isDangling, item->m_isDangling );
259  std::swap( m_spin_style, item->m_spin_style );
260 
261  SwapText( *item );
262  SwapEffects( *item );
263 }
264 
265 
267 {
268  int pensize = GetThickness();
269 
270  if( pensize == 0 ) // Use default values for pen size
271  {
272  if( IsBold() )
273  pensize = GetPenSizeForBold( GetTextWidth() );
274  else
275  pensize = GetDefaultLineThickness();
276  }
277 
278  // Clip pen size for small texts:
279  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
280  return pensize;
281 }
282 
283 
284 void SCH_TEXT::Print( wxDC* DC, const wxPoint& aOffset )
285 {
287  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
288 
289  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
290 
291  wxPoint text_offset = aOffset + GetSchematicTextOffset();
292 
293  int savedWidth = GetThickness();
294  SetThickness( linewidth ); // Set the minimum width
295 
296  EDA_TEXT::Print( DC, text_offset, color );
297 
298  SetThickness( savedWidth );
299 }
300 
301 
302 void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
303 {
304  // Normal text labels cannot be tested for dangling ends.
305  if( Type() == SCH_TEXT_T )
306  return;
307 
308  DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
309  aItemList.push_back( item );
310 }
311 
312 
313 bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
314 {
315  // Normal text labels cannot be tested for dangling ends.
316  if( Type() == SCH_TEXT_T )
317  return false;
318 
319  bool previousState = m_isDangling;
320  m_isDangling = true;
322 
323  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
324  {
325  DANGLING_END_ITEM& item = aItemList[ii];
326 
327  if( item.GetItem() == this )
328  continue;
329 
330  switch( item.GetType() )
331  {
332  case PIN_END:
333  case LABEL_END:
334  case SHEET_LABEL_END:
335  case NO_CONNECT_END:
336  if( GetTextPos() == item.GetPosition() )
337  {
338  m_isDangling = false;
339 
340  if( item.GetType() != PIN_END )
341  m_connected_items.insert( static_cast< SCH_ITEM* >( item.GetItem() ) );
342  }
343 
344  break;
345 
346 
347  case BUS_START_END:
349  // fall through
350 
351  case WIRE_START_END:
352  {
353  // These schematic items have created 2 DANGLING_END_ITEM one per end. But being
354  // a paranoid programmer, I'll check just in case.
355  ii++;
356 
357  wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
358  wxT( "Dangling end type list overflow. Bad programmer!" ) );
359 
360  DANGLING_END_ITEM & nextItem = aItemList[ii];
361  m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetTextPos() );
362 
363  if( !m_isDangling )
364  {
367 
368  // Add the line to the connected items, since it won't be picked
369  // up by a search of intersecting connection points
370  auto sch_item = static_cast< SCH_ITEM* >( item.GetItem() );
371  AddConnectionTo( sch_item );
372  sch_item->AddConnectionTo( this );
373  }
374  }
375  break;
376 
377  default:
378  break;
379  }
380 
381  if( !m_isDangling )
382  break;
383  }
384 
385  if( m_isDangling )
387 
388  return previousState != m_isDangling;
389 }
390 
391 
392 void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
393 {
394  // Normal text labels do not have connection points. All others do.
395  if( Type() == SCH_TEXT_T )
396  return;
397 
398  aPoints.push_back( GetTextPos() );
399 }
400 
401 
403 {
404  // We must pass the effective text thickness to GetTextBox
405  // when calculating the bounding box
406  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
407 
408  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
409 
410  EDA_RECT rect = GetTextBox( -1, linewidth, false, GetTextMarkupFlags() );
411 
412  if( GetTextAngle() != 0 ) // Rotate rect
413  {
414  wxPoint pos = rect.GetOrigin();
415  wxPoint end = rect.GetEnd();
416 
417  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
418  RotatePoint( &end, GetTextPos(), GetTextAngle() );
419 
420  rect.SetOrigin( pos );
421  rect.SetEnd( end );
422  }
423 
424  rect.Normalize();
425  return rect;
426 }
427 
428 
429 wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
430 {
431  return wxString::Format( _( "Graphic Text \"%s\"" ), GetChars( ShortenedShownText() ) );
432 }
433 
434 
436 {
437  return text_xpm;
438 }
439 
440 
442  SCH_SHEET_PATH* aSheetPath )
443 {
444  if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
445  return;
446 
447  NETLIST_OBJECT* item = new NETLIST_OBJECT();
448  item->m_SheetPath = *aSheetPath;
449  item->m_SheetPathInclude = *aSheetPath;
450  item->m_Comp = (SCH_ITEM*) this;
451  item->m_Type = NETLIST_ITEM::LABEL;
452 
453  if( GetLayer() == LAYER_GLOBLABEL )
455  else if( GetLayer() == LAYER_HIERLABEL )
457 
458  item->m_Label = GetText();
459  item->m_Start = item->m_End = GetTextPos();
460 
461  aNetListItems.push_back( item );
462 
463  // If a bus connects to label
464  if( Connection( *aSheetPath )->IsBusLabel( GetText() ) )
465  item->ConvertBusToNetListItems( aNetListItems );
466 }
467 
468 
469 bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
470 {
471  EDA_RECT bBox = GetBoundingBox();
472  bBox.Inflate( aAccuracy );
473  return bBox.Contains( aPosition );
474 }
475 
476 
477 bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
478 {
479  EDA_RECT bBox = GetBoundingBox();
480  bBox.Inflate( aAccuracy );
481 
482  if( aContained )
483  return aRect.Contains( bBox );
484 
485  return aRect.Intersects( bBox );
486 }
487 
488 
489 void SCH_TEXT::Plot( PLOTTER* aPlotter )
490 {
491  static std::vector<wxPoint> Poly;
493  int tmp = GetThickness();
494  int thickness = GetPenSize();
495 
496  // Two thicknesses are set here:
497  // The first is for EDA_TEXT, which controls the interline spacing based on text thickness
498  // The second is for the output that sets the actual stroke size
499  SetThickness( thickness );
500  aPlotter->SetCurrentLineWidth( thickness );
501 
502  if( IsMultilineAllowed() )
503  {
504  std::vector<wxPoint> positions;
505  wxArrayString strings_list;
506  wxStringSplit( GetShownText(), strings_list, '\n' );
507  positions.reserve( strings_list.Count() );
508 
509  GetPositionsOfLinesOfMultilineText(positions, (int) strings_list.Count() );
510 
511  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
512  {
513  wxPoint textpos = positions[ii] + GetSchematicTextOffset();
514  wxString& txt = strings_list.Item( ii );
515  aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(), GetHorizJustify(),
516  GetVertJustify(), thickness, IsItalic(), IsBold() );
517  }
518  }
519  else
520  {
521  wxPoint textpos = GetTextPos() + GetSchematicTextOffset();
522 
523  aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
524  GetHorizJustify(), GetVertJustify(), thickness, IsItalic(), IsBold() );
525  }
526 
527  // Draw graphic symbol for global or hierarchical labels
528  CreateGraphicShape( Poly, GetTextPos() );
529 
530  aPlotter->SetCurrentLineWidth( GetPenSize() );
531 
532  if( Poly.size() )
533  aPlotter->PlotPoly( Poly, NO_FILL );
534 
535  SetThickness( tmp );
536 }
537 
538 
540 {
541  wxString msg;
542 
543  switch( Type() )
544  {
545  case SCH_TEXT_T: msg = _( "Graphic Text" ); break;
546  case SCH_LABEL_T: msg = _( "Label" ); break;
547  case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
548  case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
549  case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
550  default: return;
551  }
552 
553  aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );
554 
555  switch( GetLabelSpinStyle() )
556  {
557  case LABEL_SPIN_STYLE::LEFT: msg = _( "Horizontal left" ); break;
558  case LABEL_SPIN_STYLE::UP: msg = _( "Vertical up" ); break;
559  case LABEL_SPIN_STYLE::RIGHT: msg = _( "Horizontal right" ); break;
560  case LABEL_SPIN_STYLE::BOTTOM: msg = _( "Vertical down" ); break;
561  default: msg = wxT( "???" ); break;
562  }
563 
564  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
565 
566  wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
567  int style = 0;
568 
569  if( IsItalic() )
570  style = 1;
571 
572  if( IsBold() )
573  style += 2;
574 
575  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
576 
577  // Display electrical type if it is relevant
579  {
580  switch( GetShape() )
581  {
582  case PINSHEETLABEL_SHAPE::PS_INPUT: msg = _( "Input" ); break;
583  case PINSHEETLABEL_SHAPE::PS_OUTPUT: msg = _( "Output" ); break;
584  case PINSHEETLABEL_SHAPE::PS_BIDI: msg = _( "Bidirectional" ); break;
585  case PINSHEETLABEL_SHAPE::PS_TRISTATE: msg = _( "Tri-State" ); break;
586  case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: msg = _( "Passive" ); break;
587  default: msg = wxT( "???" ); break;
588  }
589 
590  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );
591  }
592 
593  // Display text size (X or Y value, with are the same value in Eeschema)
594  msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
595  aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );
596 
597 #if defined(DEBUG)
598  if( auto conn = Connection( *g_CurrentSheet ) )
599  conn->AppendDebugInfoToMsgPanel( aList );
600 
601  msg.Printf( "%p", this );
602  aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) );
603 
604 #endif
605 }
606 
607 #if defined(DEBUG)
608 
609 void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
610 {
611  // XML output:
612  wxString s = GetClass();
613 
614  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
615  << " layer=\"" << m_Layer << '"'
616  << " shape=\"" << static_cast<int>( m_shape ) << '"'
617  << " dangling=\"" << m_isDangling << '"'
618  << '>'
619  << TO_UTF8( GetText() )
620  << "</" << s.Lower().mb_str() << ">\n";
621 }
622 
623 #endif
624 
625 
626 SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text )
627  : SCH_TEXT( pos, text, SCH_LABEL_T )
628 {
631  m_isDangling = true;
632  SetMultilineAllowed( false );
633 }
634 
635 
637 {
638  return new SCH_LABEL( *this );
639 }
640 
641 
642 bool SCH_LABEL::IsType( const KICAD_T aScanTypes[] ) const
643 {
644  static KICAD_T wireTypes[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
645  static KICAD_T busTypes[] = { SCH_LINE_LOCATE_BUS_T, EOT };
646 
647  if( SCH_ITEM::IsType( aScanTypes ) )
648  return true;
649 
650  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
651  {
652  if( *p == SCH_LABEL_LOCATE_WIRE_T )
653  {
654  for( SCH_ITEM* connection : m_connected_items )
655  {
656  if( connection->IsType( wireTypes ) )
657  return true;
658  }
659  }
660  else if ( *p == SCH_LABEL_LOCATE_BUS_T )
661  {
662  for( SCH_ITEM* connection : m_connected_items )
663  {
664  if( connection->IsType( busTypes ) )
665  return true;
666  }
667  }
668  }
669 
670  return false;
671 }
672 
673 
675 {
676  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
677  EDA_RECT rect = GetTextBox( -1, linewidth, false, GetTextMarkupFlags() );
678 
679  if( GetTextAngle() != 0.0 )
680  {
681  // Rotate rect
682  wxPoint pos = rect.GetOrigin();
683  wxPoint end = rect.GetEnd();
684 
685  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
686  RotatePoint( &end, GetTextPos(), GetTextAngle() );
687 
688  rect.SetOrigin( pos );
689  rect.SetEnd( end );
690 
691  rect.Normalize();
692  }
693 
694  return rect;
695 }
696 
697 
698 wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const
699 {
700  return wxString::Format( _( "Label %s" ), ShortenedShownText() );
701 }
702 
703 
705 {
706  return add_line_label_xpm;
707 }
708 
709 
710 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text )
711  : SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
712 {
715  m_isDangling = true;
716  SetMultilineAllowed( false );
717 }
718 
719 
721 {
722  return new SCH_GLOBALLABEL( *this );
723 }
724 
725 
727 {
728  wxPoint text_offset;
729  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
730 
731  width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
732  int halfSize = GetTextWidth() / 2;
733  int offset = width;
734 
735  switch( m_shape )
736  {
740  offset += halfSize;
741  break;
742 
745  offset += TXT_MARGIN;
746  break;
747 
748  default:
749  break;
750  }
751 
752  switch( GetLabelSpinStyle() )
753  {
754  default:
756  text_offset.x -= offset;
757  break; // Orientation horiz normal
759  text_offset.y -= offset;
760  break; // Orientation vert UP
762  text_offset.x += offset;
763  break; // Orientation horiz inverse
765  text_offset.y += offset;
766  break; // Orientation vert BOTTOM
767  }
768 
769  return text_offset;
770 }
771 
772 
774 {
775  m_spin_style = aSpinStyle;
776 
777  switch( aSpinStyle )
778  {
779  default:
780  wxASSERT_MSG( 1, "Bad spin style" );
781  break;
782 
783  case LABEL_SPIN_STYLE::RIGHT: // Horiz Normal Orientation
784  //
785  m_spin_style = LABEL_SPIN_STYLE::RIGHT; // Handle the error spin style by resetting
789  break;
790 
791  case LABEL_SPIN_STYLE::UP: // Vert Orientation UP
795  break;
796 
797  case LABEL_SPIN_STYLE::LEFT: // Horiz Orientation
801  break;
802 
803  case LABEL_SPIN_STYLE::BOTTOM: // Vert Orientation BOTTOM
807  break;
808  }
809 }
810 
811 
812 void SCH_GLOBALLABEL::Print( wxDC* DC, const wxPoint& aOffset )
813 {
814  static std::vector <wxPoint> Poly;
816  wxPoint text_offset = aOffset + GetSchematicTextOffset();
817 
818  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
819 
820  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
821 
822  int save_width = GetThickness();
823  SetThickness( linewidth );
824 
825  EDA_TEXT::Print( DC, text_offset, color );
826 
827  SetThickness( save_width ); // restore initial value
828 
829  CreateGraphicShape( Poly, GetTextPos() + aOffset );
830  GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
831 }
832 
833 
834 void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
835 {
836  int halfSize = GetTextHeight() / 2;
837  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
838 
839  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
840 
841  aPoints.clear();
842 
843  int symb_len = LenSize( GetShownText(), linewidth, GetTextMarkupFlags() ) + ( TXT_MARGIN * 2 );
844 
845  // Create outline shape : 6 points
846  int x = symb_len + linewidth + 3;
847 
848  // Use negation bar Y position to calculate full vertical size
849  // Search for overbar symbol
850  wxString test = GetText();
851  test.Replace( "~~", "" );
852  bool hasOverBar = test.find( "~" ) != wxString::npos;
853 
854  #define V_MARGIN 1.40
855  // Note: this factor is due to the fact the Y size of a few letters like '[' are bigger
856  // than the y size value, and we need a margin for the graphic symbol.
857  int y = KiROUND( halfSize * V_MARGIN );
858 
859  #define OVERBAR_V_MARGIN 1.2
860  // Note: this factor is due to the fact we need a margin for the graphic symbol.
861  if( hasOverBar )
863 
864  // Gives room for line thickess and margin
865  y += linewidth; // for line thickess
866  y += linewidth / 2; // for margin
867 
868  // Starting point(anchor)
869  aPoints.emplace_back( wxPoint( 0, 0 ) );
870  aPoints.emplace_back( wxPoint( 0, -y ) ); // Up
871  aPoints.emplace_back( wxPoint( -x, -y ) ); // left
872  aPoints.emplace_back( wxPoint( -x, 0 ) ); // Up left
873  aPoints.emplace_back( wxPoint( -x, y ) ); // left down
874  aPoints.emplace_back( wxPoint( 0, y ) ); // down
875 
876  int x_offset = 0;
877 
878  switch( m_shape )
879  {
881  x_offset = -halfSize;
882  aPoints[0].x += halfSize;
883  break;
884 
886  aPoints[3].x -= halfSize;
887  break;
888 
891  x_offset = -halfSize;
892  aPoints[0].x += halfSize;
893  aPoints[3].x -= halfSize;
894  break;
895 
897  default:
898  break;
899  }
900 
901  int angle = 0;
902 
903  switch( GetLabelSpinStyle() )
904  {
905  default:
907  break; // Orientation horiz normal
909  angle = -900;
910  break; // Orientation vert UP
912  angle = 1800;
913  break; // Orientation horiz inverse
915  angle = 900;
916  break; // Orientation vert BOTTOM
917  }
918 
919  // Rotate outlines and move corners in real position
920  for( wxPoint& aPoint : aPoints )
921  {
922  aPoint.x += x_offset;
923 
924  if( angle )
925  RotatePoint( &aPoint, angle );
926 
927  aPoint += Pos;
928  }
929 
930  aPoints.push_back( aPoints[0] ); // closing
931 }
932 
933 
935 {
936  int x, y, dx, dy, length, height;
937 
938  x = GetTextPos().x;
939  y = GetTextPos().y;
940  dx = dy = 0;
941 
942  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
943 
944  height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN;
945 
946  // text X size add height for triangular shapes(bidirectional)
947  length = LenSize( GetShownText(), width, GetTextMarkupFlags() ) + height +
948  Mils2iu( DANGLING_SYMBOL_SIZE );
949 
950  switch( GetLabelSpinStyle() ) // respect orientation
951  {
952  default:
954  dx = -length;
955  dy = height;
956  x += Mils2iu( DANGLING_SYMBOL_SIZE );
957  y -= height / 2;
958  break;
959 
961  dx = height;
962  dy = -length;
963  x -= height / 2;
964  y += Mils2iu( DANGLING_SYMBOL_SIZE );
965  break;
966 
968  dx = length;
969  dy = height;
970  x -= Mils2iu( DANGLING_SYMBOL_SIZE );
971  y -= height / 2;
972  break;
973 
975  dx = height;
976  dy = length;
977  x -= height / 2;
978  y -= Mils2iu( DANGLING_SYMBOL_SIZE );
979  break;
980  }
981 
982  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
983  box.Normalize();
984  return box;
985 }
986 
987 
989 {
990  return wxString::Format( _( "Global Label %s" ), ShortenedShownText() );
991 }
992 
993 
995 {
996  return add_glabel_xpm;
997 }
998 
999 
1000 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType )
1001  : SCH_TEXT( pos, text, aType )
1002 {
1005  m_isDangling = true;
1006  SetMultilineAllowed( false );
1007 }
1008 
1009 
1011 {
1012  return new SCH_HIERLABEL( *this );
1013 }
1014 
1015 
1017 {
1018  m_spin_style = aSpinStyle;
1019 
1020  // Assume "Right" and Left" mean which side of the port symbol the text will be on
1021  // If we are left of the symbol, we want to right justify to line up with the symbol
1022  switch( aSpinStyle )
1023  {
1024  default:
1025  wxLogWarning( "SetLabelSpinStyle bad spin style" );
1026  break;
1027 
1029  //
1030  m_spin_style = LABEL_SPIN_STYLE::LEFT; // Handle the error spin style by resetting
1034  break;
1035 
1036  case LABEL_SPIN_STYLE::UP:
1040  break;
1041 
1046  break;
1047 
1052  break;
1053  }
1054 }
1055 
1056 
1057 void SCH_HIERLABEL::Print( wxDC* DC, const wxPoint& offset )
1058 {
1059  static std::vector <wxPoint> Poly;
1060 
1061  auto conn = Connection( *g_CurrentSheet );
1062  COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer );
1063  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1064 
1065  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1066 
1067  int save_width = GetThickness();
1068  SetThickness( linewidth );
1069 
1070  wxPoint text_offset = offset + GetSchematicTextOffset();
1071  EDA_TEXT::Print( DC, text_offset, color );
1072 
1073  SetThickness( save_width ); // restore initial value
1074 
1075  CreateGraphicShape( Poly, GetTextPos() + offset );
1076  GRPoly( nullptr, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1077 }
1078 
1079 
1080 void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1081 {
1082  int* Template = TemplateShape[static_cast<int>( m_shape )][static_cast<int>( m_spin_style )];
1083  int halfSize = GetTextWidth() / 2;
1084  int imax = *Template; Template++;
1085 
1086  aPoints.clear();
1087 
1088  for( int ii = 0; ii < imax; ii++ )
1089  {
1090  wxPoint corner;
1091  corner.x = ( halfSize * (*Template) ) + Pos.x;
1092  Template++;
1093 
1094  corner.y = ( halfSize * (*Template) ) + Pos.y;
1095  Template++;
1096 
1097  aPoints.push_back( corner );
1098  }
1099 }
1100 
1101 
1103 {
1104  int x, y, dx, dy, length, height;
1105 
1106  x = GetTextPos().x;
1107  y = GetTextPos().y;
1108  dx = dy = 0;
1109 
1110  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1111 
1112  height = GetTextHeight() + width + 2 * TXT_MARGIN;
1113  length = LenSize( GetShownText(), width, GetTextMarkupFlags() )
1114  + height // add height for triangular shapes
1115  + 2 * Mils2iu( DANGLING_SYMBOL_SIZE );
1116 
1117  switch( GetLabelSpinStyle() )
1118  {
1119  default:
1121  dx = -length;
1122  dy = height;
1123  x += Mils2iu( DANGLING_SYMBOL_SIZE );
1124  y -= height / 2;
1125  break;
1126 
1127  case LABEL_SPIN_STYLE::UP:
1128  dx = height;
1129  dy = -length;
1130  x -= height / 2;
1131  y += Mils2iu( DANGLING_SYMBOL_SIZE );
1132  break;
1133 
1135  dx = length;
1136  dy = height;
1137  x -= Mils2iu( DANGLING_SYMBOL_SIZE );
1138  y -= height / 2;
1139  break;
1140 
1142  dx = height;
1143  dy = length;
1144  x -= height / 2;
1145  y -= Mils2iu( DANGLING_SYMBOL_SIZE );
1146  break;
1147  }
1148 
1149  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1150  box.Normalize();
1151  return box;
1152 }
1153 
1154 
1156 {
1157  wxPoint text_offset;
1158  int width = std::max( GetThickness(), GetDefaultLineThickness() );
1159  int ii = GetTextWidth() + TXT_MARGIN + width;
1160 
1161  switch( GetLabelSpinStyle() )
1162  {
1163  default:
1165  text_offset.x = -ii;
1166  break; // Orientation horiz normale
1167  case LABEL_SPIN_STYLE::UP:
1168  text_offset.y = -ii;
1169  break; // Orientation vert UP
1171  text_offset.x = ii;
1172  break; // Orientation horiz inverse
1174  text_offset.y = ii;
1175  break; // Orientation vert BOTTOM
1176  }
1177 
1178  return text_offset;
1179 }
1180 
1181 
1183 {
1184  return wxString::Format( _( "Hierarchical Label %s" ), ShortenedShownText() );
1185 }
1186 
1187 
1189 {
1191 }
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:186
SCH_HIERLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
Definition: sch_text.cpp:1000
EDA_UNITS
Definition: common.h:72
bool IsBold() const
Definition: eda_text.h:167
SCH_LAYER_ID m_Layer
Definition: sch_item.h:141
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:704
static int Template3STATE_HN[]
Definition: sch_text.cpp:84
void Print(wxDC *DC, const wxPoint &offset) override
Function Print Print a schematic item.
Definition: sch_text.cpp:284
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:74
wxPoint GetPosition() const
Definition: sch_item.h:122
static int Template3STATE_HI[]
Definition: sch_text.cpp:85
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:184
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:75
void AddConnectionTo(SCH_ITEM *aItem)
Adds a connection link between this item and another.
Definition: sch_item.cpp:144
PNG memory record (file in memory).
Definition: bitmap_def.h:29
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:266
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:71
SCH_SHEET_PATH m_SheetPathInclude
SCH_GLOBALLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:710
#define V_MARGIN
LABEL_SPIN_STYLE m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:198
bool m_isDangling
True if not connected to another object if the object derive from SCH_TEXT supports connections.
Definition: sch_text.h:185
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:127
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:988
static int TemplateOUT_HN[]
Definition: sch_text.cpp:69
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:469
#define DANGLING_SYMBOL_SIZE
Definition: general.h:45
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:76
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:231
static int TemplateIN_UP[]
Definition: sch_text.cpp:66
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)
Function IsPointOnSegment.
Definition: trigo.cpp:42
static int TemplateOUT_HI[]
Definition: sch_text.cpp:70
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:137
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:429
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:80
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:698
SCH_SHEET_PATH m_SheetPath
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Definition: sch_text.cpp:313
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
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:187
EDA_ITEM * m_Comp
std::unordered_set< SCH_ITEM * > m_connected_items
Stores pointers to other items that are connected to this one (schematic only)
Definition: sch_item.h:147
const BITMAP_OPAQUE add_line_label_xpm[1]
bool Contains(const wxPoint &aPoint) const
Function Contains.
static int Template3STATE_BOTTOM[]
Definition: sch_text.cpp:87
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:170
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:994
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
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:67
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:72
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:636
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:123
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_text.cpp:392
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:1010
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:726
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:65
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:86
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:123
static int TemplateBIDI_HN[]
Definition: sch_text.cpp:79
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:834
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:1016
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:934
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:284
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:302
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:1102
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:238
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:402
SCH_SHEET_PATH.
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:82
void Print(wxDC *DC, const wxPoint &offset) override
Function Print Print a schematic item.
Definition: sch_text.cpp:1057
This item represents a net.
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:212
void Normalize()
Function Normalize ensures that the height ant width are positive.
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:1080
Base plotter engine class.
Definition: plotter.h:103
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:131
PINSHEETLABEL_SHAPE
Definition: sch_text.h:164
virtual void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos)
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.h:264
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:539
int GetTextWidth() const
Definition: eda_text.h:226
static int TemplateBIDI_UP[]
Definition: sch_text.cpp:81
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:489
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:186
#define _(s)
Definition: 3d_actions.cpp:31
int LenSize(const wxString &aLine, int aThickness, int aMarkupFlags) const
Definition: eda_text.cpp:150
#define TXT_MARGIN
Definition: sch_text.cpp:57
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:251
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:179
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_text.h:219
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:99
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:435
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:125
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:89
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
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:674
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:181
DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be connected ...
Definition: sch_item.h:67
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:773
bool IsType(const KICAD_T aScanTypes[]) const override
Function IsType Checks whether the item is one of the listed types.
Definition: sch_text.cpp:642
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:720
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:77
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:210
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:1182
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:161
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:1188
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136
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:626
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:1155
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:441
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:64
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:812
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:243
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
void IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:129
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:39
Definition: colors.h:62