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 <draw_graphic_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 
43 #include <sch_text.h>
44 #include <netlist_object.h>
45 #include <trace_helpers.h>
46 
47 
48 extern void IncrementLabelMember( wxString& name, int aIncrement );
49 
50 // Only for tests: set DRAW_BBOX to 1 to draw the bounding box of labels
51 #define DRAW_BBOX 0
52 
53 // Margin in internal units (mils) between labels and wires
54 #define TXT_MARGIN 4
55 
56 // Names of sheet label types.
57 const char* SheetLabelType[] =
58 {
59  "Input",
60  "Output",
61  "BiDi",
62  "3State",
63  "UnSpc",
64  "???"
65 };
66 
67 /* Coding polygons for global symbol graphic shapes.
68  * the first parml is the number of corners
69  * others are the corners coordinates in reduced units
70  * the real coordinate is the reduced coordinate * text half size
71  */
72 static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
73 static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
74 static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
75 static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
76 
77 static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
78 static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
79 static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
80 static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
81 
82 static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
83 static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
84 static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
85 static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
86 
87 static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
88 static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
89 static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
90 static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
91 
92 static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
93 static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
94 static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
95 static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
96 
97 static int* TemplateShape[5][4] =
98 {
104 };
105 
106 
107 SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
108  SCH_ITEM( NULL, aType ),
109  EDA_TEXT( text ),
110  m_shape( NET_INPUT )
111 {
113  SetTextPos( pos );
114  m_isDangling = false;
116  m_spin_style = 0;
117 
118  SetMultilineAllowed( true );
119 }
120 
121 
122 SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
123  SCH_ITEM( aText ),
124  EDA_TEXT( aText )
125 {
126  m_shape = aText.m_shape;
127  m_isDangling = aText.m_isDangling;
128  m_spin_style = aText.m_spin_style;
129 }
130 
131 
133 {
134  return new SCH_TEXT( *this );
135 }
136 
137 
138 void SCH_TEXT::IncrementLabel( int aIncrement )
139 {
140  IncrementLabelMember( m_Text, aIncrement );
142 }
143 
144 
146 {
147  wxPoint text_offset;
148 
149  // add an offset to x (or y) position to aid readability of text on a wire or line
150  int thick_offset = TXT_MARGIN + ( GetPenSize() + GetDefaultLineThickness() ) / 2;
151 
152  switch( GetLabelSpinStyle() )
153  {
154  default:
155  case 0: text_offset.y = -thick_offset; break; // Horiz Normal Orientation (left justified)
156  case 1: text_offset.x = -thick_offset; break; // Vert Orientation UP
157  case 2: text_offset.y = -thick_offset; break; // Horiz Orientation - Right justified
158  case 3: text_offset.x = -thick_offset; break; // Vert Orientation BOTTOM
159  }
160 
161  return text_offset;
162 }
163 
164 
165 bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation )
166 {
167  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) );
168 
169  if( SCH_ITEM::Matches( m_Text, aSearchData ) )
170  {
171  EDA_RECT BoundaryBox = GetBoundingBox();
172 
173  if( aFindLocation )
174  *aFindLocation = BoundaryBox.Centre();
175 
176  return true;
177  }
178 
179  return false;
180 }
181 
182 
183 void SCH_TEXT::MirrorY( int aYaxis_position )
184 {
185  // Text is NOT really mirrored; it is moved to a suitable horizontal position
186  switch( GetLabelSpinStyle() )
187  {
188  default:
189  case 0: SetLabelSpinStyle( 2 ); break; // horizontal text
190  case 1: break; // Vert Orientation UP
191  case 2: SetLabelSpinStyle( 0 ); break; // invert horizontal text
192  case 3: break; // Vert Orientation BOTTOM
193  }
194 
195  SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
196 }
197 
198 
199 void SCH_TEXT::MirrorX( int aXaxis_position )
200 {
201  // Text is NOT really mirrored; it is moved to a suitable vertical position
202  switch( GetLabelSpinStyle() )
203  {
204  default:
205  case 0: break; // horizontal text
206  case 1: SetLabelSpinStyle( 3 ); break; // Vert Orientation UP
207  case 2: break; // invert horizontal text
208  case 3: SetLabelSpinStyle( 1 ); break; // Vert Orientation BOTTOM
209  }
210 
211  SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
212 }
213 
214 
215 void SCH_TEXT::Rotate( wxPoint aPosition )
216 {
217  int dy;
218 
219  wxPoint pt = GetTextPos();
220  RotatePoint( &pt, aPosition, 900 );
221  SetTextPos( pt );
222 
223  int spin = GetLabelSpinStyle();
224 
225  // Global and hierarchical labels spin backwards. Fix here because
226  // changing SetLabelSpinStyle would break existing designs.
227  if( this->Type() == SCH_GLOBAL_LABEL_T || this->Type() == SCH_HIER_LABEL_T )
228  SetLabelSpinStyle( ( spin - 1 >= 0 ? ( spin - 1 ) : 3 ) );
229  else
230  SetLabelSpinStyle( ( spin + 1 ) % 4 );
231 
232  if( this->Type() == SCH_TEXT_T )
233  {
234  switch( GetLabelSpinStyle() )
235  {
236  case 0: dy = GetTextHeight(); break; // horizontal text
237  case 1: dy = 0; break; // Vert Orientation UP
238  case 2: dy = GetTextHeight(); break; // invert horizontal text
239  case 3: dy = 0; break; // Vert Orientation BOTTOM
240  default: dy = 0; break;
241  }
242 
243  SetTextY( GetTextPos().y + dy );
244  }
245 }
246 
247 
248 void SCH_TEXT::SetLabelSpinStyle( int aSpinStyle )
249 {
250  m_spin_style = aSpinStyle;
251 
252  switch( aSpinStyle )
253  {
254  default:
255  case 0: // Horiz Normal Orientation (left justified)
259  break;
260 
261  case 1: // Vert Orientation UP
265  break;
266 
267  case 2: // Horiz Orientation - Right justified
271  break;
272 
273  case 3: // Vert Orientation BOTTOM
277  break;
278  }
279 }
280 
281 
283 {
284  SCH_TEXT* item = (SCH_TEXT*) aItem;
285 
286  std::swap( m_Text, item->m_Text );
287  std::swap( m_Layer, item->m_Layer );
288 
289  std::swap( m_shape, item->m_shape );
290  std::swap( m_isDangling, item->m_isDangling );
291  std::swap( m_spin_style, item->m_spin_style );
292 
293  SwapEffects( *item );
294 }
295 
296 
298 {
299  int pensize = GetThickness();
300 
301  if( pensize == 0 ) // Use default values for pen size
302  {
303  if( IsBold() )
304  pensize = GetPenSizeForBold( GetTextWidth() );
305  else
306  pensize = GetDefaultLineThickness();
307  }
308 
309  // Clip pen size for small texts:
310  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
311  return pensize;
312 }
313 
314 
315 void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset )
316 {
318  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
319  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
320 
321  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
322 
323  wxPoint text_offset = aOffset + GetSchematicTextOffset();
324 
325  int savedWidth = GetThickness();
326  SetThickness( linewidth ); // Set the minimum width
327 
328  EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE );
329 
330  SetThickness( savedWidth );
331 }
332 
333 
334 void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
335 {
336  // Normal text labels cannot be tested for dangling ends.
337  if( Type() == SCH_TEXT_T )
338  return;
339 
340  DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
341  aItemList.push_back( item );
342 }
343 
344 
345 bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList )
346 {
347  // Normal text labels cannot be tested for dangling ends.
348  if( Type() == SCH_TEXT_T )
349  return false;
350 
351  bool previousState = m_isDangling;
352  m_isDangling = true;
354 
355  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
356  {
357  DANGLING_END_ITEM& item = aItemList[ii];
358 
359  if( item.GetItem() == this )
360  continue;
361 
362  switch( item.GetType() )
363  {
364  case PIN_END:
365  case LABEL_END:
366  case SHEET_LABEL_END:
367  case NO_CONNECT_END:
368  if( GetTextPos() == item.GetPosition() )
369  {
370  m_isDangling = false;
371 
372  if( item.GetType() != PIN_END )
373  m_connected_items.insert( static_cast< SCH_ITEM* >( item.GetItem() ) );
374  }
375 
376  break;
377 
378 
379  case BUS_START_END:
381  // fall through
382 
383  case WIRE_START_END:
384  {
385  // These schematic items have created 2 DANGLING_END_ITEM one per end. But being
386  // a paranoid programmer, I'll check just in case.
387  ii++;
388 
389  wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
390  wxT( "Dangling end type list overflow. Bad programmer!" ) );
391 
392  DANGLING_END_ITEM & nextItem = aItemList[ii];
393  m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetTextPos() );
394 
395  if( !m_isDangling )
396  {
399 
400  // Add the line to the connected items, since it won't be picked
401  // up by a search of intersecting connection points
402  auto sch_item = static_cast< SCH_ITEM* >( item.GetItem() );
403  AddConnectionTo( sch_item );
404  sch_item->AddConnectionTo( this );
405  }
406  }
407  break;
408 
409  default:
410  break;
411  }
412 
413  if( !m_isDangling )
414  break;
415  }
416 
417  if( m_isDangling )
419 
420  return previousState != m_isDangling;
421 }
422 
423 
424 void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
425 {
426  // Normal text labels do not have connection points. All others do.
427  if( Type() == SCH_TEXT_T )
428  return;
429 
430  aPoints.push_back( GetTextPos() );
431 }
432 
433 
435 {
436  // We must pass the effective text thickness to GetTextBox
437  // when calculating the bounding box
438  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
439 
440  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
441 
442  EDA_RECT rect = GetTextBox( -1, linewidth );
443 
444  if( GetTextAngle() != 0 ) // Rotate rect
445  {
446  wxPoint pos = rect.GetOrigin();
447  wxPoint end = rect.GetEnd();
448 
449  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
450  RotatePoint( &end, GetTextPos(), GetTextAngle() );
451 
452  rect.SetOrigin( pos );
453  rect.SetEnd( end );
454  }
455 
456  rect.Normalize();
457  return rect;
458 }
459 
460 
461 wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS_T aUnits ) const
462 {
463  return wxString::Format( _( "Graphic Text \"%s\"" ), GetChars( ShortenedShownText() ) );
464 }
465 
466 
467 BITMAP_DEF SCH_TEXT::GetMenuImage() const
468 {
469  return text_xpm;
470 }
471 
472 
474  SCH_SHEET_PATH* aSheetPath )
475 {
476  if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
477  return;
478 
479  NETLIST_OBJECT* item = new NETLIST_OBJECT();
480  item->m_SheetPath = *aSheetPath;
481  item->m_SheetPathInclude = *aSheetPath;
482  item->m_Comp = (SCH_ITEM*) this;
483  item->m_Type = NET_LABEL;
484 
485  if( GetLayer() == LAYER_GLOBLABEL )
486  item->m_Type = NET_GLOBLABEL;
487  else if( GetLayer() == LAYER_HIERLABEL )
488  item->m_Type = NET_HIERLABEL;
489 
490  item->m_Label = m_Text;
491  item->m_Start = item->m_End = GetTextPos();
492 
493  aNetListItems.push_back( item );
494 
495  // If a bus connects to label
496  if( Connection( *aSheetPath )->IsBusLabel( m_Text ) )
497  {
498  item->ConvertBusToNetListItems( aNetListItems );
499  }
500 }
501 
502 
503 bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
504 {
505  EDA_RECT bBox = GetBoundingBox();
506  bBox.Inflate( aAccuracy );
507  return bBox.Contains( aPosition );
508 }
509 
510 
511 bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
512 {
513  EDA_RECT bBox = GetBoundingBox();
514  bBox.Inflate( aAccuracy );
515 
516  if( aContained )
517  return aRect.Contains( bBox );
518 
519  return aRect.Intersects( bBox );
520 }
521 
522 
523 void SCH_TEXT::Plot( PLOTTER* aPlotter )
524 {
525  static std::vector <wxPoint> Poly;
527  int tmp = GetThickness();
528  int thickness = GetPenSize();
529 
530  // Two thicknesses are set here:
531  // The first is for EDA_TEXT, which controls the interline spacing based on text thickness
532  // The second is for the output that sets the actual stroke size
533  SetThickness( thickness );
534  aPlotter->SetCurrentLineWidth( thickness );
535 
536  if( IsMultilineAllowed() )
537  {
538  std::vector<wxPoint> positions;
539  wxArrayString strings_list;
540  wxStringSplit( GetShownText(), strings_list, '\n' );
541  positions.reserve( strings_list.Count() );
542 
543  GetPositionsOfLinesOfMultilineText(positions, (int) strings_list.Count() );
544 
545  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
546  {
547  wxPoint textpos = positions[ii] + GetSchematicTextOffset();
548  wxString& txt = strings_list.Item( ii );
549  aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(),
551  thickness, IsItalic(), IsBold() );
552  }
553  }
554  else
555  {
556  wxPoint textpos = GetTextPos() + GetSchematicTextOffset();
557 
558  aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
560  thickness, IsItalic(), IsBold() );
561  }
562 
563  // Draw graphic symbol for global or hierarchical labels
564  CreateGraphicShape( Poly, GetTextPos() );
565 
566  aPlotter->SetCurrentLineWidth( GetPenSize() );
567 
568  if( Poly.size() )
569  aPlotter->PlotPoly( Poly, NO_FILL );
570 
571  SetThickness( tmp );
572 }
573 
574 
576 {
577  wxString msg;
578 
579  switch( Type() )
580  {
581  case SCH_TEXT_T: msg = _( "Graphic Text" ); break;
582  case SCH_LABEL_T: msg = _( "Label" ); break;
583  case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
584  case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
585  case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
586  default: return;
587  }
588 
589  aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );
590 
591  switch( GetLabelSpinStyle() )
592  {
593  case 0: msg = _( "Horizontal" ); break;
594  case 1: msg = _( "Vertical up" ); break;
595  case 2: msg = _( "Horizontal invert" ); break;
596  case 3: msg = _( "Vertical down" ); break;
597  default: msg = wxT( "???" ); break;
598  }
599 
600  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
601 
602  wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
603  int style = 0;
604 
605  if( IsItalic() )
606  style = 1;
607 
608  if( IsBold() )
609  style += 2;
610 
611  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
612 
613 
614  // Display electricat type if it is relevant
615  if( (Type() == SCH_GLOBAL_LABEL_T) ||
616  (Type() == SCH_HIER_LABEL_T ) ||
617  (Type() == SCH_SHEET_PIN_T ) )
618  {
619  switch( GetShape() )
620  {
621  case NET_INPUT: msg = _( "Input" ); break;
622  case NET_OUTPUT: msg = _( "Output" ); break;
623  case NET_BIDI: msg = _( "Bidirectional" ); break;
624  case NET_TRISTATE: msg = _( "Tri-State" ); break;
625  case NET_UNSPECIFIED: msg = _( "Passive" ); break;
626  default: msg = wxT( "???" ); break;
627  }
628 
629  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );
630  }
631 
632  // Display text size (X or Y value, with are the same value in Eeschema)
633  msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
634  aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );
635 
636 #if defined(DEBUG)
637 
638  if( auto conn = Connection( *g_CurrentSheet ) )
639  {
640  conn->AppendDebugInfoToMsgPanel( aList );
641  }
642 
643  msg.Printf( "%p", this );
644  aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) );
645 
646 #endif
647 }
648 
649 #if defined(DEBUG)
650 
651 void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
652 {
653  // XML output:
654  wxString s = GetClass();
655 
656  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
657  << " layer=\"" << m_Layer << '"'
658  << " shape=\"" << m_shape << '"'
659  << " dangling=\"" << m_isDangling << '"'
660  << '>'
661  << TO_UTF8( m_Text )
662  << "</" << s.Lower().mb_str() << ">\n";
663 }
664 
665 #endif
666 
667 
668 SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
669  SCH_TEXT( pos, text, SCH_LABEL_T )
670 {
672  m_shape = NET_INPUT;
673  m_isDangling = true;
674  SetMultilineAllowed( false );
675 }
676 
677 
679 {
680  return new SCH_LABEL( *this );
681 }
682 
683 
685 {
686  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
687  EDA_RECT rect = GetTextBox( -1, linewidth );
688 
689  if( GetTextAngle() != 0.0 )
690  {
691  // Rotate rect
692  wxPoint pos = rect.GetOrigin();
693  wxPoint end = rect.GetEnd();
694 
695  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
696  RotatePoint( &end, GetTextPos(), GetTextAngle() );
697 
698  rect.SetOrigin( pos );
699  rect.SetEnd( end );
700 
701  rect.Normalize();
702  }
703 
704  return rect;
705 }
706 
707 
709 {
710  return wxString::Format( _( "Label %s" ), ShortenedShownText() );
711 }
712 
713 
714 BITMAP_DEF SCH_LABEL::GetMenuImage() const
715 {
716  return add_line_label_xpm;
717 }
718 
719 
720 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
721  SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
722 {
724  m_shape = NET_BIDI;
725  m_isDangling = true;
726  SetMultilineAllowed( false );
727 }
728 
729 
731 {
732  return new SCH_GLOBALLABEL( *this );
733 }
734 
735 
737 {
738  wxPoint text_offset;
739  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
740 
741  width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
742  int halfSize = GetTextWidth() / 2;
743  int offset = width;
744 
745  switch( m_shape )
746  {
747  case NET_INPUT:
748  case NET_BIDI:
749  case NET_TRISTATE:
750  offset += halfSize;
751  break;
752 
753  case NET_OUTPUT:
754  case NET_UNSPECIFIED:
755  offset += TXT_MARGIN;
756  break;
757 
758  default:
759  break;
760  }
761 
762  switch( GetLabelSpinStyle() )
763  {
764  default:
765  case 0: text_offset.x -= offset; break; // Orientation horiz normal
766  case 1: text_offset.y -= offset; break; // Orientation vert UP
767  case 2: text_offset.x += offset; break; // Orientation horiz inverse
768  case 3: text_offset.y += offset; break; // Orientation vert BOTTOM
769  }
770 
771  return text_offset;
772 }
773 
774 
776 {
777  m_spin_style = aSpinStyle;
778 
779  switch( aSpinStyle )
780  {
781  default:
782  case 0: // Horiz Normal Orientation
786  break;
787 
788  case 1: // Vert Orientation UP
792  break;
793 
794  case 2: // Horiz Orientation
798  break;
799 
800  case 3: // Vert Orientation BOTTOM
804  break;
805  }
806 }
807 
808 
809 void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset )
810 {
811  static std::vector <wxPoint> Poly;
813  wxPoint text_offset = aOffset + GetSchematicTextOffset();
814 
815  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
816 
817  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
818 
819  int save_width = GetThickness();
820  SetThickness( linewidth );
821 
822  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
823  EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE );
824 
825  SetThickness( save_width ); // restore initial value
826 
827  CreateGraphicShape( Poly, GetTextPos() + aOffset );
828  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
829 }
830 
831 
832 void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
833 {
834  int halfSize = GetTextHeight() / 2;
835  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
836 
837  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
838 
839  aPoints.clear();
840 
841  int symb_len = LenSize( GetShownText(), linewidth ) + ( TXT_MARGIN * 2 );
842 
843  // Create outline shape : 6 points
844  int x = symb_len + linewidth + 3;
845 
846  // Use negation bar Y position to calculate full vertical size
847  // Search for overbar symbol
848  bool hasOverBar = false;
849 
850  for( unsigned ii = 1; ii < m_Text.size(); ii++ )
851  {
852  if( m_Text[ii-1] == '~' && m_Text[ii] != '~' )
853  {
854  hasOverBar = true;
855  break;
856  }
857  }
858 
859  #define Y_CORRECTION 1.40
860  // Note: this factor is due to the fact the Y size of a few letters like [
861  // are bigger than the y size value, and we need a margin for the graphic symbol.
862  int y = KiROUND( halfSize * Y_CORRECTION );
863 
864  // Note: this factor is due to the fact we need a margin for the graphic symbol.
865  #define Y_OVERBAR_CORRECTION 1.2
866  if( hasOverBar )
867  y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth )
869 
870  // Gives room for line thickess and margin
871  y += linewidth // for line thickess
872  + linewidth/2; // for margin
873 
874  // Starting point(anchor)
875  aPoints.push_back( wxPoint( 0, 0 ) );
876  aPoints.push_back( wxPoint( 0, -y ) ); // Up
877  aPoints.push_back( wxPoint( -x, -y ) ); // left
878  aPoints.push_back( wxPoint( -x, 0 ) ); // Up left
879  aPoints.push_back( wxPoint( -x, y ) ); // left down
880  aPoints.push_back( wxPoint( 0, y ) ); // down
881 
882  int x_offset = 0;
883 
884  switch( m_shape )
885  {
886  case NET_INPUT:
887  x_offset = -halfSize;
888  aPoints[0].x += halfSize;
889  break;
890 
891  case NET_OUTPUT:
892  aPoints[3].x -= halfSize;
893  break;
894 
895  case NET_BIDI:
896  case NET_TRISTATE:
897  x_offset = -halfSize;
898  aPoints[0].x += halfSize;
899  aPoints[3].x -= halfSize;
900  break;
901 
902  case NET_UNSPECIFIED:
903  default:
904  break;
905  }
906 
907  int angle = 0;
908 
909  switch( GetLabelSpinStyle() )
910  {
911  default:
912  case 0: break; // Orientation horiz normal
913  case 1: angle = -900; break; // Orientation vert UP
914  case 2: angle = 1800; break; // Orientation horiz inverse
915  case 3: angle = 900; break; // Orientation vert BOTTOM
916  }
917 
918  // Rotate outlines and move corners in real position
919  for( wxPoint& aPoint : aPoints )
920  {
921  aPoint.x += x_offset;
922 
923  if( angle )
924  RotatePoint( &aPoint, angle );
925 
926  aPoint += Pos;
927  }
928 
929  aPoints.push_back( aPoints[0] ); // closing
930 }
931 
932 
934 {
935  int x, y, dx, dy, length, height;
936 
937  x = GetTextPos().x;
938  y = GetTextPos().y;
939  dx = dy = 0;
940 
941  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
942 
943  height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN;
944 
945  // text X size add height for triangular shapes(bidirectional)
946  length = LenSize( GetShownText(), width ) + height + DANGLING_SYMBOL_SIZE;
947 
948  switch( GetLabelSpinStyle() ) // respect orientation
949  {
950  default:
951  case 0: // Horiz Normal Orientation (left justified)
952  dx = -length;
953  dy = height;
955  y -= height / 2;
956  break;
957 
958  case 1: // Vert Orientation UP
959  dx = height;
960  dy = -length;
961  x -= height / 2;
963  break;
964 
965  case 2: // Horiz Orientation - Right justified
966  dx = length;
967  dy = height;
969  y -= height / 2;
970  break;
971 
972  case 3: // Vert Orientation BOTTOM
973  dx = height;
974  dy = length;
975  x -= height / 2;
977  break;
978  }
979 
980  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
981  box.Normalize();
982  return box;
983 }
984 
985 
987 {
988  return wxString::Format( _( "Global Label %s" ), ShortenedShownText() );
989 }
990 
991 
993 {
994  return add_glabel_xpm;
995 }
996 
997 
998 
999 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
1000  SCH_TEXT( pos, text, aType )
1001 {
1003  m_shape = NET_INPUT;
1004  m_isDangling = true;
1005  SetMultilineAllowed( false );
1006 }
1007 
1008 
1010 {
1011  return new SCH_HIERLABEL( *this );
1012 }
1013 
1014 
1015 void SCH_HIERLABEL::SetLabelSpinStyle( int aSpinStyle )
1016 {
1017  m_spin_style = aSpinStyle;
1018 
1019  switch( aSpinStyle )
1020  {
1021  default:
1022  case 0: // Horiz Normal Orientation
1026  break;
1027 
1028  case 1: // Vert Orientation UP
1032  break;
1033 
1034  case 2: // Horiz Orientation
1038  break;
1039 
1040  case 3: // Vert Orientation BOTTOM
1044  break;
1045  }
1046 }
1047 
1048 
1049 void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset )
1050 {
1051  static std::vector <wxPoint> Poly;
1052  auto conn = Connection( *g_CurrentSheet );
1053  COLOR4D color = GetLayerColor( ( conn && conn->IsBus() ) ? LAYER_BUS : m_Layer );
1054  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1055  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
1056 
1057  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1058 
1059  int save_width = GetThickness();
1060  SetThickness( linewidth );
1061 
1062  wxPoint text_offset = offset + GetSchematicTextOffset();
1063  EDA_TEXT::Draw( clipbox, DC, text_offset, color, GR_DEFAULT_DRAWMODE );
1064 
1065  SetThickness( save_width ); // restore initial value
1066 
1067  CreateGraphicShape( Poly, GetTextPos() + offset );
1068  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1069 }
1070 
1071 
1072 void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1073 {
1074  int* Template = TemplateShape[m_shape][m_spin_style];
1075  int halfSize = GetTextWidth() / 2;
1076  int imax = *Template; Template++;
1077 
1078  aPoints.clear();
1079 
1080  for( int ii = 0; ii < imax; ii++ )
1081  {
1082  wxPoint corner;
1083  corner.x = ( halfSize * (*Template) ) + Pos.x;
1084  Template++;
1085 
1086  corner.y = ( halfSize * (*Template) ) + Pos.y;
1087  Template++;
1088 
1089  aPoints.push_back( corner );
1090  }
1091 }
1092 
1093 
1095 {
1096  int x, y, dx, dy, length, height;
1097 
1098  x = GetTextPos().x;
1099  y = GetTextPos().y;
1100  dx = dy = 0;
1101 
1102  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1103 
1104  height = GetTextHeight() + width + 2 * TXT_MARGIN;
1105  length = LenSize( GetShownText(), width )
1106  + height // add height for triangular shapes
1107  + 2 * DANGLING_SYMBOL_SIZE;
1108 
1109  switch( GetLabelSpinStyle() )
1110  {
1111  default:
1112  case 0: // Horiz Normal Orientation (left justified)
1113  dx = -length;
1114  dy = height;
1115  x += DANGLING_SYMBOL_SIZE;
1116  y -= height / 2;
1117  break;
1118 
1119  case 1: // Vert Orientation UP
1120  dx = height;
1121  dy = -length;
1122  x -= height / 2;
1123  y += DANGLING_SYMBOL_SIZE;
1124  break;
1125 
1126  case 2: // Horiz Orientation - Right justified
1127  dx = length;
1128  dy = height;
1129  x -= DANGLING_SYMBOL_SIZE;
1130  y -= height / 2;
1131  break;
1132 
1133  case 3: // Vert Orientation BOTTOM
1134  dx = height;
1135  dy = length;
1136  x -= height / 2;
1137  y -= DANGLING_SYMBOL_SIZE;
1138  break;
1139  }
1140 
1141  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1142  box.Normalize();
1143  return box;
1144 }
1145 
1146 
1148 {
1149  wxPoint text_offset;
1150  int width = std::max( GetThickness(), GetDefaultLineThickness() );
1151  int ii = GetTextWidth() + TXT_MARGIN + width;
1152 
1153  switch( GetLabelSpinStyle() )
1154  {
1155  default:
1156  case 0: text_offset.x = -ii; break; // Orientation horiz normale
1157  case 1: text_offset.y = -ii; break; // Orientation vert UP
1158  case 2: text_offset.x = ii; break; // Orientation horiz inverse
1159  case 3: text_offset.y = ii; break; // Orientation vert BOTTOM
1160  }
1161 
1162  return text_offset;
1163 }
1164 
1165 
1167 {
1168  return wxString::Format( _( "Hierarchical Label %s" ), ShortenedShownText() );
1169 }
1170 
1171 
1173 {
1174  return add_hierarchical_label_xpm;
1175 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:173
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:188
SCH_HIERLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
Definition: sch_text.cpp:999
bool IsBold() const
Definition: eda_text.h:190
SCH_LAYER_ID m_Layer
Definition: sch_item.h:119
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:714
static int Template3STATE_HN[]
Definition: sch_text.cpp:92
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:39
static double GetInterline(double aGlyphHeight, double aGlyphThickness)
Compute the distance (interline) between 2 lines of text (for multiline texts).
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:701
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
void SwapEffects(EDA_TEXT &aTradingPartner)
Function SwapEffects swaps the text effects of the two involved instances.
Definition: eda_text.cpp:77
static int TemplateUNSPC_HN[]
Definition: sch_text.cpp:82
wxPoint GetPosition() const
Definition: sch_item.h:100
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:986
wxString m_Text
Definition: eda_text.h:378
static int Template3STATE_HI[]
Definition: sch_text.cpp:93
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:83
void AddConnectionTo(SCH_ITEM *aItem)
Adds a connection link between this item and another.
Definition: sch_item.cpp:142
No connection to this item.
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
#define TEXT_ANGLE_VERT
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_text.cpp:297
static int TemplateOUT_UP[]
Definition: sch_text.cpp:79
SCH_SHEET_PATH m_SheetPathInclude
SCH_GLOBALLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:720
wxString m_shown_text
Cache of unescaped text for efficient access.
Definition: eda_text.h:381
bool m_isDangling
True if not connected to another object if the object derive from SCH_TEXT supports connections.
Definition: sch_text.h:66
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
static int TemplateOUT_HN[]
Definition: sch_text.cpp:77
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:503
#define DANGLING_SYMBOL_SIZE
Definition: general.h:45
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_text.cpp:165
virtual void SetLabelSpinStyle(int aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:248
#define Y_CORRECTION
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:458
int color
Definition: DXF_plotter.cpp:62
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:84
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:240
static int TemplateIN_UP[]
Definition: sch_text.cpp:74
double GetTextAngle() const
Definition: eda_text.h:181
static int TemplateOUT_HI[]
Definition: sch_text.cpp:78
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:145
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:88
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
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:345
virtual EDA_RECT * GetClipBox()
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
const char * SheetLabelType[]
Definition: sch_text.cpp:57
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
NETLIST_ITEM_T m_Type
CONNECTION_TYPE m_connectionType
Definition: sch_text.h:68
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
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:125
bool Contains(const wxPoint &aPoint) const
Function Contains.
static int Template3STATE_BOTTOM[]
Definition: sch_text.cpp:95
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:199
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:992
This file contains miscellaneous commonly used macros and functions.
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
int GetTextHeight() const
Definition: eda_text.h:238
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.
static int TemplateIN_BOTTOM[]
Definition: sch_text.cpp:75
void SetTextX(int aX)
Definition: eda_text.h:243
bool IsItalic() const
Definition: eda_text.h:187
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels,...
Definition: eda_text.h:128
int GetLabelSpinStyle() const
Definition: sch_text.h:119
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:47
static int TemplateOUT_BOTTOM[]
Definition: sch_text.cpp:80
const wxPoint GetEnd() const
Definition: eda_rect.h:114
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:678
int LenSize(const wxString &aLine, int aThickness) const
Function LenSize.
Definition: eda_text.cpp:83
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:132
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_text.cpp:424
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:1009
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:119
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:736
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:809
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:461
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:1049
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
void SetEnd(int x, int y)
Definition: eda_rect.h:134
static int TemplateIN_HI[]
Definition: sch_text.cpp:73
This item represents a net.
const wxSize & GetTextSize() const
Definition: eda_text.h:232
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:211
static int Template3STATE_UP[]
Definition: sch_text.cpp:94
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:96
EDA_ITEM * GetItem() const
Definition: sch_item.h:101
static int TemplateBIDI_HN[]
Definition: sch_text.cpp:87
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:832
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:933
wxLogTrace helper definitions.
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:334
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:1094
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:434
Class SCH_SHEET_PATH.
void SetMultilineAllowed(bool aAllow)
Function SetMultiLineAllowed.
Definition: eda_text.h:204
bool IsMultilineAllowed() const
Definition: eda_text.h:205
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:127
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1166
static int TemplateBIDI_BOTTOM[]
Definition: sch_text.cpp:90
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:193
void Normalize()
Function Normalize ensures that the height ant width are positive.
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1072
Base plotter engine class.
Definition: plotter.h:97
#define GR_DEFAULT_DRAWMODE
Definition: general.h:75
void SetLabelSpinStyle(int aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:1015
virtual void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos)
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.h:142
int GetTextWidth() const
Definition: eda_text.h:235
static int TemplateBIDI_UP[]
Definition: sch_text.cpp:89
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:100
const wxChar *const traceFindItem
Flag to enable find debug tracing.
const char * name
Definition: DXF_plotter.cpp:61
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:523
#define max(a, b)
Definition: auxiliary.h:86
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:210
#define TXT_MARGIN
Definition: sch_text.cpp:54
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:282
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:215
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_text.h:96
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
#define Y_OVERBAR_CORRECTION
SCH_TEXT(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_TEXT_T)
Definition: sch_text.cpp:107
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:467
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void GetMsgPanelInfo(EDA_UNITS_T 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:575
int m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:79
T Mirror(T aPoint, T aMirrorRef)
Function MIRROR Mirror aPoint in aMirrorRef.
Definition: macros.h:117
DANGLING_END_T GetType() const
Definition: sch_item.h:103
static int * TemplateShape[5][4]
Definition: sch_text.cpp:97
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void IncrementLabelMember(wxString &name, int aIncrement)
Definition: edit_label.cpp:167
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
wxPoint Centre() const
Definition: eda_rect.h:60
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:315
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:684
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a ...
Definition: eda_text.cpp:331
PINSHEETLABEL_SHAPE m_shape
Definition: sch_text.h:62
static const char * text_xpm[]
Class DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be conn...
Definition: sch_item.h:67
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:152
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:730
Class 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:85
Definition of the NETLIST_OBJECT class.
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:183
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:708
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1172
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
Implementation of the label properties dialog.
SCH_LABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:668
void SetLabelSpinStyle(int aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:775
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:1147
EDA_UNITS_T
Definition: common.h:157
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:473
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:72
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:165
void SetTextY(int aY)
Definition: eda_text.h:244
void Draw(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode=FILLED, COLOR4D aAnchor_color=COLOR4D::UNSPECIFIED)
Function Draw.
Definition: eda_text.cpp:296
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:121
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
void IncrementLabel(int aIncrement)
Increment the label text, if it ends with a number.
Definition: sch_text.cpp:138
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
This item represents a bus vector.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62