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-2016 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 <class_drawpanel.h>
36 #include <drawtxt.h>
37 #include <schframe.h>
38 #include <plot_common.h>
39 #include <msgpanel.h>
40 #include <gal/stroke_font.h>
41 #include <bitmaps.h>
42 
43 #include <protos.h>
44 #include <sch_text.h>
45 #include <class_netlist_object.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;
115  m_spin_style = 0;
116 
117  SetMultilineAllowed( true );
118 }
119 
120 
121 SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
122  SCH_ITEM( aText ),
123  EDA_TEXT( aText )
124 {
125  m_shape = aText.m_shape;
126  m_isDangling = false;
127  m_spin_style = aText.m_spin_style;
128 }
129 
130 
132 {
133  return new SCH_TEXT( *this );
134 }
135 
136 
137 void SCH_TEXT::IncrementLabel( int aIncrement )
138 {
139  IncrementLabelMember( m_Text, aIncrement );
140 }
141 
142 
144 {
145  wxPoint text_offset;
146 
147  // add an offset to x ( or y) position to allow a text to
148  // be on a wire or a line and be readable
149  int thick_offset = TXT_MARGIN +
150  ( GetPenSize() + GetDefaultLineThickness() ) / 2;
151 
152  switch( GetLabelSpinStyle() )
153  {
154  default:
155  case 0: // Horiz Normal Orientation (left justified)
156  text_offset.y = -thick_offset;
157  break;
158 
159  case 1: // Vert Orientation UP
160  text_offset.x = -thick_offset;
161  break;
162 
163  case 2: // Horiz Orientation - Right justified
164  text_offset.y = -thick_offset;
165  break;
166 
167  case 3: // Vert Orientation BOTTOM
168  text_offset.x = -thick_offset;
169  break;
170  }
171 
172  return text_offset;
173 }
174 
175 
176 bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation )
177 {
178  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
179 
180  if( SCH_ITEM::Matches( m_Text, aSearchData ) )
181  {
182  EDA_RECT BoundaryBox = GetBoundingBox();
183 
184  if( aFindLocation )
185  *aFindLocation = BoundaryBox.Centre();
186 
187  return true;
188  }
189 
190  return false;
191 }
192 
193 
194 void SCH_TEXT::MirrorY( int aYaxis_position )
195 {
196  // Text is NOT really mirrored; it is moved to a suitable horizontal position
197  switch( GetLabelSpinStyle() )
198  {
199  case 0: // horizontal text
200  SetLabelSpinStyle( 2 );
201  break;
202 
203  case 2: // invert horizontal text
204  SetLabelSpinStyle( 0 );
205  break;
206 
207  case 1: // Vert Orientation UP
208  case 3: // Vert Orientation BOTTOM
209  default:
210  break;
211  }
212 
213  SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
214 }
215 
216 
217 void SCH_TEXT::MirrorX( int aXaxis_position )
218 {
219  // Text is NOT really mirrored; it is moved to a suitable vertical position
220  switch( GetLabelSpinStyle() )
221  {
222  case 1: // Vert Orientation UP
223  SetLabelSpinStyle( 3 );
224  break;
225 
226  case 3: // Vert Orientation BOTTOM
227  SetLabelSpinStyle( 1 );
228  break;
229 
230  case 0: // horizontal text
231  case 2: // invert horizontal text
232  default:
233  break;
234  }
235 
236  SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
237 }
238 
239 
240 void SCH_TEXT::Rotate( wxPoint aPosition )
241 {
242  int dy;
243 
244  wxPoint pt = GetTextPos();
245  RotatePoint( &pt, aPosition, 900 );
246  SetTextPos( pt );
247 
248  SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 );
249 
250  switch( GetLabelSpinStyle() )
251  {
252  case 0: // horizontal text
253  dy = GetTextHeight();
254  break;
255 
256  case 1: // Vert Orientation UP
257  dy = 0;
258  break;
259 
260  case 2: // invert horizontal text
261  dy = GetTextHeight();
262  break;
263 
264  case 3: // Vert Orientation BOTTOM
265  dy = 0;
266  break;
267 
268  default:
269  dy = 0;
270  break;
271  }
272 
273  SetTextY( GetTextPos().y + dy );
274 }
275 
276 
277 void SCH_TEXT::SetLabelSpinStyle( int aSpinStyle )
278 {
279  m_spin_style = aSpinStyle;
280 
281  switch( aSpinStyle )
282  {
283  default:
284  case 0: // Horiz Normal Orientation (left justified)
288  break;
289 
290  case 1: // Vert Orientation UP
294  break;
295 
296  case 2: // Horiz Orientation - Right justified
300  break;
301 
302  case 3: // Vert Orientation BOTTOM
306  break;
307  }
308 }
309 
310 
312 {
313  SCH_TEXT* item = (SCH_TEXT*) aItem;
314 
315  std::swap( m_Text, item->m_Text );
316  std::swap( m_Layer, item->m_Layer );
317 
318  std::swap( m_shape, item->m_shape );
319  std::swap( m_isDangling, item->m_isDangling );
320  std::swap( m_spin_style, item->m_spin_style );
321 
322  SwapEffects( *item );
323 }
324 
325 
327 {
328  int pensize = GetThickness();
329 
330  if( pensize == 0 ) // Use default values for pen size
331  {
332  if( IsBold() )
333  pensize = GetPenSizeForBold( GetTextWidth() );
334  else
335  pensize = GetDefaultLineThickness();
336  }
337 
338  // Clip pen size for small texts:
339  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
340  return pensize;
341 }
342 
343 
344 void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
345  GR_DRAWMODE DrawMode, COLOR4D Color )
346 {
347  COLOR4D color;
348  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
349  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
350 
351  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
352 
353  if( Color != COLOR4D::UNSPECIFIED )
354  color = Color;
355  else
357 
358  GRSetDrawMode( DC, DrawMode );
359 
360  wxPoint text_offset = aOffset + GetSchematicTextOffset();
361 
362  int savedWidth = GetThickness();
363  SetThickness( linewidth ); // Set the minimum width
364 
365  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
366 
367  SetThickness( savedWidth );
368 
369  if( m_isDangling && panel)
370  DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color );
371 
372  // Enable these line to draw the bounding box (debug tests purposes only)
373 #if DRAW_BBOX
374  {
375  EDA_RECT BoundaryBox = GetBoundingBox();
376  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
377  }
378 #endif
379 }
380 
381 
382 bool SCH_TEXT::Save( FILE* aFile ) const
383 {
384  bool success = true;
385  const char* shape = "~";
386 
387  if( IsItalic() )
388  shape = "Italic";
389 
390  // For compatibility reason, the text must be saved in only one text line
391  // so we replace all E.O.L. by \\n
392  wxString text = m_Text;
393 
394  text.Replace( wxT("\n"), wxT( "\\n" ) );
395 
396  // Here we should have no CR or LF character in line
397  // This is not always the case if a multiline text was copied (using a copy/paste function)
398  // from a text that uses E.O.L characters that differs from the current EOL format
399  // This is mainly the case under Linux using LF symbol when copying a text from
400  // Windows (using CRLF symbol)
401  // So we must just remove the extra CR left (or LF left under MacOSX)
402  for( unsigned ii = 0; ii < text.Len(); )
403  {
404  if( text[ii] == 0x0A || text[ii] == 0x0D )
405  text.erase( ii, 1 );
406  else
407  ii++;
408  }
409 
410  if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
412  shape, GetThickness(), TO_UTF8( text ) ) == EOF )
413  {
414  success = false;
415  }
416 
417  return success;
418 }
419 
420 
421 bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg )
422 {
423  char Name1[256];
424  char Name2[256];
425  char Name3[256];
426  int thickness = 0, orient = 0;
427  int x, y, size = 0;
428 
429  Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
430 
431  char* sline = (char*) aLine;
432 
433  while( ( *sline != ' ' ) && *sline )
434  sline++;
435 
436  // sline points the start of parameters
437  int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y,
438  &orient, &size, Name2, Name3, &thickness );
439 
440  if( ii < 4 )
441  {
442  aErrorMsg.Printf( wxT( "Eeschema file text load error at line %d" ),
443  aLine.LineNumber() );
444  return false;
445  }
446 
447  if( !aLine.ReadLine() )
448  {
449  aErrorMsg.Printf( wxT( "Eeschema file text load error at line %d" ),
450  aLine.LineNumber() );
451  return false;
452  }
453 
454  if( size == 0 )
455  size = GetDefaultTextSize();
456 
457  char* text = strtok( (char*) aLine, "\n\r" );
458 
459  if( text == NULL )
460  {
461  aErrorMsg.Printf( wxT( "Eeschema file text load error at line %d" ),
462  aLine.LineNumber() );
463  return false;
464  }
465 
466  wxString val = FROM_UTF8( text );
467 
468  for( ; ; )
469  {
470  int i = val.find( wxT( "\\n" ) );
471 
472  if( i == wxNOT_FOUND )
473  break;
474 
475  val.erase( i, 2 );
476  val.insert( i, wxT( "\n" ) );
477  }
478 
479  m_Text = val;
480 
481  SetTextSize( wxSize( size, size ) );
482  SetTextPos( wxPoint( x, y ) );
483 
484  SetLabelSpinStyle( orient );
485 
486  if( isdigit( Name3[0] ) )
487  {
488  thickness = atol( Name3 );
489  SetBold( thickness != 0 );
490  SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
491  }
492 
493  if( strncasecmp( Name2, "Italic", 6 ) == 0 )
494  SetItalic( true );
495 
496  return true;
497 }
498 
499 
500 void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
501 {
502  // Normal text labels cannot be tested for dangling ends.
503  if( Type() == SCH_TEXT_T )
504  return;
505 
506  DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
507  aItemList.push_back( item );
508 }
509 
510 
511 bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
512 {
513  // Normal text labels cannot be tested for dangling ends.
514  if( Type() == SCH_TEXT_T )
515  return false;
516 
517  bool previousState = m_isDangling;
518  m_isDangling = true;
519 
520  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
521  {
522  DANGLING_END_ITEM& item = aItemList[ii];
523 
524  if( item.GetItem() == this )
525  continue;
526 
527  switch( item.GetType() )
528  {
529  case PIN_END:
530  case LABEL_END:
531  case SHEET_LABEL_END:
532  if( GetTextPos() == item.GetPosition() )
533  m_isDangling = false;
534 
535  break;
536 
537  case WIRE_START_END:
538  case BUS_START_END:
539  {
540  // These schematic items have created 2 DANGLING_END_ITEM one per end. But being
541  // a paranoid programmer, I'll check just in case.
542  ii++;
543 
544  wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
545  wxT( "Dangling end type list overflow. Bad programmer!" ) );
546 
547  DANGLING_END_ITEM & nextItem = aItemList[ii];
548  m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetTextPos() );
549  }
550  break;
551 
552  default:
553  break;
554  }
555 
556  if( !m_isDangling )
557  break;
558  }
559 
560  return previousState != m_isDangling;
561 }
562 
563 
564 bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect )
565 {
566  bool previousState = IsSelected();
567 
568  if( aRect.Contains( GetTextPos() ) )
569  SetFlags( SELECTED );
570  else
571  ClearFlags( SELECTED );
572 
573  return previousState != IsSelected();
574 }
575 
576 
577 void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
578 {
579  // Normal text labels do not have connection points. All others do.
580  if( Type() == SCH_TEXT_T )
581  return;
582 
583  aPoints.push_back( GetTextPos() );
584 }
585 
586 
588 {
589  // We must pass the effective text thickness to GetTextBox
590  // when calculating the bounding box
591  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
592 
593  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
594 
595  EDA_RECT rect = GetTextBox( -1, linewidth );
596 
597  if( GetTextAngle() ) // Rotate rect
598  {
599  wxPoint pos = rect.GetOrigin();
600  wxPoint end = rect.GetEnd();
601 
602  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
603  RotatePoint( &end, GetTextPos(), GetTextAngle() );
604 
605  rect.SetOrigin( pos );
606  rect.SetEnd( end );
607  }
608 
609  rect.Normalize();
610  return rect;
611 }
612 
613 
615 {
616  wxString msg;
617  msg.Printf( _( "Graphic Text %s" ), GetChars( ShortenedShownText() ) );
618  return msg;
619 }
620 
621 
623 {
624  return add_text_xpm;
625 }
626 
627 
629  SCH_SHEET_PATH* aSheetPath )
630 {
631  if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
632  return;
633 
634  NETLIST_OBJECT* item = new NETLIST_OBJECT();
635  item->m_SheetPath = *aSheetPath;
636  item->m_SheetPathInclude = *aSheetPath;
637  item->m_Comp = (SCH_ITEM*) this;
638  item->m_Type = NET_LABEL;
639 
640  if( GetLayer() == LAYER_GLOBLABEL )
641  item->m_Type = NET_GLOBLABEL;
642  else if( GetLayer() == LAYER_HIERLABEL )
643  item->m_Type = NET_HIERLABEL;
644 
645  item->m_Label = m_Text;
646  item->m_Start = item->m_End = GetTextPos();
647 
648  aNetListItems.push_back( item );
649 
650  // If a bus connects to label
651  if( IsBusLabel( m_Text ) )
652  item->ConvertBusToNetListItems( aNetListItems );
653 }
654 
655 
656 bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
657 {
658  EDA_RECT bBox = GetBoundingBox();
659  bBox.Inflate( aAccuracy );
660  return bBox.Contains( aPosition );
661 }
662 
663 
664 bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
665 {
666  EDA_RECT bBox = GetBoundingBox();
667  bBox.Inflate( aAccuracy );
668 
669  if( aContained )
670  return aRect.Contains( bBox );
671 
672  return aRect.Intersects( bBox );
673 }
674 
675 
676 void SCH_TEXT::Plot( PLOTTER* aPlotter )
677 {
678  static std::vector <wxPoint> Poly;
679  COLOR4D color = GetLayerColor( GetLayer() );
680  int thickness = GetPenSize();
681 
682  aPlotter->SetCurrentLineWidth( thickness );
683 
684  if( IsMultilineAllowed() )
685  {
686  std::vector<wxPoint> positions;
687  wxArrayString strings_list;
688  wxStringSplit( GetShownText(), strings_list, '\n' );
689  positions.reserve( strings_list.Count() );
690 
691  GetPositionsOfLinesOfMultilineText(positions, strings_list.Count() );
692 
693  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
694  {
695  wxPoint textpos = positions[ii] + GetSchematicTextOffset();
696  wxString& txt = strings_list.Item( ii );
697  aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(),
699  thickness, IsItalic(), IsBold() );
700  }
701  }
702  else
703  {
704  wxPoint textpos = GetTextPos() + GetSchematicTextOffset();
705 
706  aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
708  thickness, IsItalic(), IsBold() );
709  }
710 
711  // Draw graphic symbol for global or hierarchical labels
712  CreateGraphicShape( Poly, GetTextPos() );
713 
714  aPlotter->SetCurrentLineWidth( GetPenSize() );
715 
716  if( Poly.size() )
717  aPlotter->PlotPoly( Poly, NO_FILL );
718 }
719 
720 
721 /*
722  * Display the type, shape, size and some other props to the Message panel
723  */
725 {
726  wxString msg;
727 
728  switch( Type() )
729  {
730  case SCH_TEXT_T:
731  msg = _( "Graphic Text" );
732  break;
733 
734  case SCH_LABEL_T:
735  msg = _( "Label" );
736  break;
737 
738  case SCH_GLOBAL_LABEL_T:
739  msg = _( "Global Label" );
740  break;
741 
743  msg = _( "Hierarchical Label" );
744  break;
745 
746  case SCH_SHEET_PIN_T:
747  msg = _( "Hierarchical Sheet Pin" );
748  break;
749 
750  default:
751  return;
752  }
753 
754  aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );
755 
756  switch( GetLabelSpinStyle() )
757  {
758  case 0: // horizontal text
759  msg = _( "Horizontal" );
760  break;
761 
762  case 1: // Vert Orientation UP
763  msg = _( "Vertical up" );
764  break;
765 
766  case 2: // invert horizontal text
767  msg = _( "Horizontal invert" );
768  break;
769 
770  case 3: // Vert Orientation Down
771  msg = _( "Vertical down" );
772  break;
773 
774  default:
775  msg = wxT( "???" );
776  break;
777  }
778 
779  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
780 
781  wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
782  int style = 0;
783 
784  if( IsItalic() )
785  style = 1;
786 
787  if( IsBold() )
788  style += 2;
789 
790  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
791 
792 
793  // Display electricat type if it is relevant
794  if( (Type() == SCH_GLOBAL_LABEL_T) ||
795  (Type() == SCH_HIERARCHICAL_LABEL_T ) ||
796  (Type() == SCH_SHEET_PIN_T ) )
797  {
798  switch( GetShape() )
799  {
800  case NET_INPUT: msg = _( "Input" ); break;
801  case NET_OUTPUT: msg = _( "Output" ); break;
802  case NET_BIDI: msg = _( "Bidirectional" ); break;
803  case NET_TRISTATE: msg = _( "Tri-State" ); break;
804  case NET_UNSPECIFIED: msg = _( "Passive" ); break;
805  default: msg = wxT( "???" ); break;
806  }
807 
808  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );
809  }
810 
811  // Display text size (X or Y value, with are the same value in Eeschema)
812  msg = StringFromValue( g_UserUnit, GetTextWidth(), true );
813  aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );
814 }
815 
816 #if defined(DEBUG)
817 
818 void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
819 {
820  // XML output:
821  wxString s = GetClass();
822 
823  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
824  << " layer=\"" << m_Layer << '"'
825  << " shape=\"" << m_shape << '"'
826  << " dangling=\"" << m_isDangling << '"'
827  << '>'
828  << TO_UTF8( m_Text )
829  << "</" << s.Lower().mb_str() << ">\n";
830 }
831 
832 #endif
833 
834 
835 SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
836  SCH_TEXT( pos, text, SCH_LABEL_T )
837 {
839  m_shape = NET_INPUT;
840  m_isDangling = true;
841  SetMultilineAllowed( false );
842 }
843 
844 
846 {
847  return new SCH_LABEL( *this );
848 }
849 
850 
852 {
854 }
855 
856 
857 void SCH_LABEL::SetLabelSpinStyle( int aOrientation )
858 {
859  SCH_TEXT::SetLabelSpinStyle( aOrientation );
860 }
861 
862 
863 void SCH_LABEL::MirrorX( int aXaxis_position )
864 {
865  // Text is NOT really mirrored; it is moved to a suitable position
866  switch( GetLabelSpinStyle() )
867  {
868  case 1: // Vert Orientation UP
869  SetLabelSpinStyle( 3 );
870  break;
871 
872  case 3: // Vert Orientation BOTTOM
873  SetLabelSpinStyle( 1 );
874  break;
875 
876  case 0: // horizontal text
877  case 2: // invert horizontal text
878  default:
879  break;
880  }
881 
882  SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) );
883 }
884 
885 
886 void SCH_LABEL::Rotate( wxPoint aPosition )
887 {
888  wxPoint pt = GetTextPos();
889  RotatePoint( &pt, aPosition, 900 );
890  SetTextPos( pt );
891 
892  SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 );
893 }
894 
895 
896 bool SCH_LABEL::Save( FILE* aFile ) const
897 {
898  bool success = true;
899  const char* shape = "~";
900 
901  if( IsItalic() )
902  shape = "Italic";
903 
904  if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
905  GetTextPos().x, GetTextPos().y, GetLabelSpinStyle(), GetTextWidth(), shape,
906  GetThickness(), TO_UTF8( m_Text ) ) == EOF )
907  {
908  success = false;
909  }
910 
911  return success;
912 }
913 
914 
915 bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
916 {
917  char Name1[256];
918  char Name2[256];
919  char Name3[256];
920  int thickness = 0, size = 0, orient = 0;
921  int x, y;
922 
923  Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
924 
925  char* sline = (char*) aLine;
926 
927  while( ( *sline != ' ' ) && *sline )
928  sline++;
929 
930  // sline points the start of parameters
931  int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y,
932  &orient, &size, Name2, Name3, &thickness );
933 
934  if( ii < 4 )
935  {
936  aErrorMsg.Printf( wxT( "Eeschema file label load error at line %d" ),
937  aLine.LineNumber() );
938  return false;
939  }
940 
941  if( !aLine.ReadLine() )
942  {
943  aErrorMsg.Printf( wxT( "Eeschema file label load error atline %d" ),
944  aLine.LineNumber() );
945  return false;
946  }
947 
948  if( size == 0 )
949  size = GetDefaultTextSize();
950 
951  char* text = strtok( (char*) aLine, "\n\r" );
952 
953  if( text == NULL )
954  {
955  aErrorMsg.Printf( wxT( "Eeschema file label load error at line %d" ),
956  aLine.LineNumber() );
957  return false;
958  }
959 
960  m_Text = FROM_UTF8( text );
961 
962  SetTextSize( wxSize( size, size ) );
963  SetTextPos( wxPoint( x, y ) );
964 
965  SetLabelSpinStyle( orient );
966 
967  if( isdigit( Name3[0] ) )
968  {
969  thickness = atol( Name3 );
970  SetBold( thickness != 0 );
971  SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
972  }
973 
974  if( strcasecmp( Name2, "Italic" ) == 0 )
975  SetItalic( true );
976 
977  return true;
978 }
979 
980 
981 void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
982  GR_DRAWMODE DrawMode, COLOR4D Color )
983 {
984  SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
985 }
986 
987 
989 {
990  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
991  EDA_RECT rect = GetTextBox( -1, linewidth );
992 
993  if( GetTextAngle() != 0.0 )
994  {
995  // Rotate rect
996  wxPoint pos = rect.GetOrigin();
997  wxPoint end = rect.GetEnd();
998 
999  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
1000  RotatePoint( &end, GetTextPos(), GetTextAngle() );
1001 
1002  rect.SetOrigin( pos );
1003  rect.SetEnd( end );
1004 
1005  rect.Normalize();
1006  }
1007 
1008  return rect;
1009 }
1010 
1011 
1013 {
1014  wxString msg;
1015  msg.Printf( _( "Label %s" ), GetChars( ShortenedShownText() ) );
1016  return msg;
1017 }
1018 
1019 
1021 {
1022  return add_line_label_xpm;
1023 }
1024 
1025 
1026 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
1027  SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
1028 {
1030  m_shape = NET_BIDI;
1031  m_isDangling = true;
1032  SetMultilineAllowed( false );
1033 }
1034 
1035 
1037 {
1038  return new SCH_GLOBALLABEL( *this );
1039 }
1040 
1041 
1042 bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
1043 {
1044  bool success = true;
1045  const char* shape = "~";
1046 
1047  if( IsItalic() )
1048  shape = "Italic";
1049 
1050  if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
1052  SheetLabelType[m_shape], shape, GetThickness(), TO_UTF8( m_Text ) ) == EOF )
1053  {
1054  success = false;
1055  }
1056 
1057  return success;
1058 }
1059 
1060 
1061 bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
1062 {
1063  char Name1[256];
1064  char Name2[256];
1065  char Name3[256];
1066  int thickness = 0, size = 0, orient = 0;
1067  int x, y;
1068 
1069  Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
1070 
1071  char* sline = (char*) aLine;
1072 
1073  while( (*sline != ' ' ) && *sline )
1074  sline++;
1075 
1076  // sline points the start of parameters
1077  int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &x, &y,
1078  &orient, &size, Name2, Name3, &thickness );
1079 
1080  if( ii < 4 )
1081  {
1082  aErrorMsg.Printf( wxT( "Eeschema file global label load error at line %d" ),
1083  aLine.LineNumber() );
1084  return false;
1085  }
1086 
1087  if( !aLine.ReadLine() )
1088  {
1089  aErrorMsg.Printf( wxT( "Eeschema file global label load error at line %d" ),
1090  aLine.LineNumber() );
1091  return false;
1092  }
1093 
1094  if( size == 0 )
1095  size = GetDefaultTextSize();
1096 
1097  char* text = strtok( (char*) aLine, "\n\r" );
1098 
1099  if( text == NULL )
1100  {
1101  aErrorMsg.Printf( wxT( "Eeschema file global label load error at line %d" ),
1102  aLine.LineNumber() );
1103  return false;
1104  }
1105 
1106  m_Text = FROM_UTF8( text );
1107 
1108  SetTextSize( wxSize( size, size ) );
1109  SetTextPos( wxPoint( x, y ) );
1110 
1111  SetLabelSpinStyle( orient );
1112 
1113  m_shape = NET_INPUT;
1114  SetBold( thickness != 0 );
1115  SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
1116 
1117  if( strcasecmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
1118  m_shape = NET_OUTPUT;
1119 
1120  if( strcasecmp( Name2, SheetLabelType[NET_BIDI] ) == 0 )
1121  m_shape = NET_BIDI;
1122 
1123  if( strcasecmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 )
1125 
1126  if( strcasecmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 )
1128 
1129  if( strcasecmp( Name3, "Italic" ) == 0 )
1130  SetItalic( true );
1131 
1132  return true;
1133 }
1134 
1135 
1136 void SCH_GLOBALLABEL::MirrorY( int aYaxis_position )
1137 {
1138  /* The global label is NOT really mirrored.
1139  * for an horizontal label, the schematic orientation is changed.
1140  * for a vertical label, the schematic orientation is not changed.
1141  * and the label is moved to a suitable position
1142  */
1143  switch( GetLabelSpinStyle() )
1144  {
1145  case 0: // horizontal text
1146  SetLabelSpinStyle( 2 );
1147  break;
1148 
1149  case 2: // invert horizontal text
1150  SetLabelSpinStyle( 0 );
1151  break;
1152  }
1153 
1154  SetTextX( ::Mirror( GetTextPos().x, aYaxis_position ) );
1155 }
1156 
1157 
1158 void SCH_GLOBALLABEL::MirrorX( int aXaxis_position )
1159 {
1160  switch( GetLabelSpinStyle() )
1161  {
1162  case 1: // vertical text
1163  SetLabelSpinStyle( 3 );
1164  break;
1165 
1166  case 3: // invert vertical text
1167  SetLabelSpinStyle( 1 );
1168  break;
1169  }
1170 
1171  SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) );
1172 }
1173 
1174 
1176 {
1177  wxPoint pt = GetTextPos();
1178  RotatePoint( &pt, aPosition, 900 );
1179  SetTextPos( pt );
1180 
1181  SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 );
1182 }
1183 
1184 
1186 {
1187  wxPoint text_offset;
1188  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1189 
1190  width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
1191  int halfSize = GetTextWidth() / 2;
1192  int offset = width;
1193 
1194  switch( m_shape )
1195  {
1196  case NET_INPUT:
1197  case NET_BIDI:
1198  case NET_TRISTATE:
1199  offset += halfSize;
1200  break;
1201 
1202  case NET_OUTPUT:
1203  case NET_UNSPECIFIED:
1204  offset += TXT_MARGIN;
1205  break;
1206 
1207  default:
1208  break;
1209  }
1210 
1211  switch( GetLabelSpinStyle() )
1212  {
1213  case 0: // Orientation horiz normal
1214  text_offset.x -= offset;
1215  break;
1216 
1217  case 1: // Orientation vert UP
1218  text_offset.y -= offset;
1219  break;
1220 
1221  case 2: // Orientation horiz inverse
1222  text_offset.x += offset;
1223  break;
1224 
1225  case 3: // Orientation vert BOTTOM
1226  text_offset.y += offset;
1227  break;
1228  }
1229 
1230  return text_offset;
1231 }
1232 
1233 
1235 {
1236  m_spin_style = aSpinStyle;
1237 
1238  switch( aSpinStyle )
1239  {
1240  default:
1241  case 0: // Horiz Normal Orientation
1245  break;
1246 
1247  case 1: // Vert Orientation UP
1251  break;
1252 
1253  case 2: // Horiz Orientation
1257  break;
1258 
1259  case 3: // Vert Orientation BOTTOM
1263  break;
1264  }
1265 }
1266 
1267 
1269  wxDC* DC,
1270  const wxPoint& aOffset,
1271  GR_DRAWMODE DrawMode,
1272  COLOR4D Color )
1273 {
1274  static std::vector <wxPoint> Poly;
1275  COLOR4D color;
1276  wxPoint text_offset = aOffset + GetSchematicTextOffset();
1277 
1278  if( Color != COLOR4D::UNSPECIFIED )
1279  color = Color;
1280  else
1282 
1283  GRSetDrawMode( DC, DrawMode );
1284 
1285  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1286 
1287  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1288 
1289  int save_width = GetThickness();
1290  SetThickness( linewidth );
1291 
1292  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
1293  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
1294 
1295  SetThickness( save_width ); // restore initial value
1296 
1297  CreateGraphicShape( Poly, GetTextPos() + aOffset );
1298  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1299 
1300  if( m_isDangling && panel )
1301  DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color );
1302 
1303  // Enable these line to draw the bounding box (debug tests purposes only)
1304 #if DRAW_BBOX
1305  {
1306  EDA_RECT BoundaryBox = GetBoundingBox();
1307  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
1308  }
1309 #endif
1310 }
1311 
1312 
1313 void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1314 {
1315  int halfSize = GetTextHeight() / 2;
1316  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1317 
1318  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1319 
1320  aPoints.clear();
1321 
1322  int symb_len = LenSize( GetShownText() ) + ( TXT_MARGIN * 2 );
1323 
1324  // Create outline shape : 6 points
1325  int x = symb_len + linewidth + 3;
1326 
1327  // Use negation bar Y position to calculate full vertical size
1328  // Search for overbar symbol
1329  bool hasOverBar = false;
1330 
1331  for( unsigned ii = 1; ii < m_Text.size(); ii++ )
1332  {
1333  if( m_Text[ii-1] == '~' && m_Text[ii] != '~' )
1334  {
1335  hasOverBar = true;
1336  break;
1337  }
1338  }
1339 
1340  #define Y_CORRECTION 1.40
1341  // Note: this factor is due to the fact the Y size of a few letters like [
1342  // are bigger than the y size value, and we need a margin for the graphic symbol.
1343  int y = KiROUND( halfSize * Y_CORRECTION );
1344 
1345  // Note: this factor is due to the fact we need a margin for the graphic symbol.
1346  #define Y_OVERBAR_CORRECTION 1.2
1347  if( hasOverBar )
1348  y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth )
1350 
1351  // Gives room for line thickess and margin
1352  y += linewidth // for line thickess
1353  + linewidth/2; // for margin
1354 
1355  // Starting point(anchor)
1356  aPoints.push_back( wxPoint( 0, 0 ) );
1357  aPoints.push_back( wxPoint( 0, -y ) ); // Up
1358  aPoints.push_back( wxPoint( -x, -y ) ); // left
1359  aPoints.push_back( wxPoint( -x, 0 ) ); // Up left
1360  aPoints.push_back( wxPoint( -x, y ) ); // left down
1361  aPoints.push_back( wxPoint( 0, y ) ); // down
1362 
1363  int x_offset = 0;
1364 
1365  switch( m_shape )
1366  {
1367  case NET_INPUT:
1368  x_offset = -halfSize;
1369  aPoints[0].x += halfSize;
1370  break;
1371 
1372  case NET_OUTPUT:
1373  aPoints[3].x -= halfSize;
1374  break;
1375 
1376  case NET_BIDI:
1377  case NET_TRISTATE:
1378  x_offset = -halfSize;
1379  aPoints[0].x += halfSize;
1380  aPoints[3].x -= halfSize;
1381  break;
1382 
1383  case NET_UNSPECIFIED:
1384  default:
1385  break;
1386  }
1387 
1388  int angle = 0;
1389 
1390  switch( GetLabelSpinStyle() )
1391  {
1392  case 0: // Orientation horiz normal
1393  break;
1394 
1395  case 1: // Orientation vert UP
1396  angle = -900;
1397  break;
1398 
1399  case 2: // Orientation horiz inverse
1400  angle = 1800;
1401  break;
1402 
1403  case 3: // Orientation vert BOTTOM
1404  angle = 900;
1405  break;
1406  }
1407 
1408  // Rotate outlines and move corners in real position
1409  for( unsigned ii = 0; ii < aPoints.size(); ii++ )
1410  {
1411  aPoints[ii].x += x_offset;
1412 
1413  if( angle )
1414  RotatePoint( &aPoints[ii], angle );
1415 
1416  aPoints[ii] += Pos;
1417  }
1418 
1419  aPoints.push_back( aPoints[0] ); // closing
1420 }
1421 
1422 
1424 {
1425  int x, y, dx, dy, length, height;
1426 
1427  x = GetTextPos().x;
1428  y = GetTextPos().y;
1429  dx = dy = 0;
1430 
1431  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1432 
1433  height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN;
1434 
1435  // text X size add height for triangular shapes(bidirectional)
1436  length = LenSize( GetShownText() ) + height + DANGLING_SYMBOL_SIZE;
1437 
1438  switch( GetLabelSpinStyle() ) // respect orientation
1439  {
1440  case 0: // Horiz Normal Orientation (left justified)
1441  dx = -length;
1442  dy = height;
1443  x += DANGLING_SYMBOL_SIZE;
1444  y -= height / 2;
1445  break;
1446 
1447  case 1: // Vert Orientation UP
1448  dx = height;
1449  dy = -length;
1450  x -= height / 2;
1451  y += DANGLING_SYMBOL_SIZE;
1452  break;
1453 
1454  case 2: // Horiz Orientation - Right justified
1455  dx = length;
1456  dy = height;
1457  x -= DANGLING_SYMBOL_SIZE;
1458  y -= height / 2;
1459  break;
1460 
1461  case 3: // Vert Orientation BOTTOM
1462  dx = height;
1463  dy = length;
1464  x -= height / 2;
1465  y -= DANGLING_SYMBOL_SIZE;
1466  break;
1467  }
1468 
1469  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1470  box.Normalize();
1471  return box;
1472 }
1473 
1474 
1476 {
1477  wxString msg;
1478  msg.Printf( _( "Global Label %s" ), GetChars( ShortenedShownText() ) );
1479  return msg;
1480 }
1481 
1482 
1484 {
1485  return add_glabel_xpm;
1486 }
1487 
1488 
1489 
1490 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
1491  SCH_TEXT( pos, text, aType )
1492 {
1494  m_shape = NET_INPUT;
1495  m_isDangling = true;
1496  SetMultilineAllowed( false );
1497 }
1498 
1499 
1501 {
1502  return new SCH_HIERLABEL( *this );
1503 }
1504 
1505 
1506 bool SCH_HIERLABEL::Save( FILE* aFile ) const
1507 {
1508  bool success = true;
1509  const char* shape = "~";
1510 
1511  if( IsItalic() )
1512  shape = "Italic";
1513 
1514  if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
1516  SheetLabelType[m_shape], shape, GetThickness(), TO_UTF8( m_Text ) ) == EOF )
1517  {
1518  success = false;
1519  }
1520 
1521  return success;
1522 }
1523 
1524 
1525 bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
1526 {
1527  char Name1[256];
1528  char Name2[256];
1529  char Name3[256];
1530  int thickness = 0, size = 0, orient = 0;
1531  int x, y;
1532 
1533  Name1[0] = 0; Name2[0] = 0; Name3[0] = 0;
1534 
1535  char* sline = (char*) aLine;
1536 
1537  while( (*sline != ' ' ) && *sline )
1538  sline++;
1539 
1540  // sline points the start of parameters
1541  int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1,
1542  &x, &y,
1543  &orient, &size, Name2, Name3, &thickness );
1544 
1545  if( ii < 4 )
1546  {
1547  aErrorMsg.Printf( wxT( "Eeschema file hierarchical label load error at line %d" ),
1548  aLine.LineNumber() );
1549  return false;
1550  }
1551 
1552  if( !aLine.ReadLine() )
1553  {
1554  aErrorMsg.Printf( wxT( "Eeschema file hierarchical label load error at line %d" ),
1555  aLine.LineNumber() );
1556  return false;
1557  }
1558 
1559  if( size == 0 )
1560  size = GetDefaultTextSize();
1561 
1562  char* text = strtok( (char*) aLine, "\n\r" );
1563 
1564  if( text == NULL )
1565  {
1566  aErrorMsg.Printf( wxT( "Eeschema file hierarchical label load error at line %d" ),
1567  aLine.LineNumber() );
1568  return false;
1569  }
1570 
1571  m_Text = FROM_UTF8( text );
1572 
1573  SetTextSize( wxSize( size, size ) );
1574  SetTextPos( wxPoint( x, y ) );
1575 
1576  SetLabelSpinStyle( orient );
1577  m_shape = NET_INPUT;
1578  SetBold( thickness != 0 );
1579 
1580  SetThickness( IsBold() ? GetPenSizeForBold( size ) : 0 );
1581 
1582  if( strcasecmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
1583  m_shape = NET_OUTPUT;
1584 
1585  if( strcasecmp( Name2, SheetLabelType[NET_BIDI] ) == 0 )
1586  m_shape = NET_BIDI;
1587 
1588  if( strcasecmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 )
1590 
1591  if( strcasecmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 )
1593 
1594  if( strcasecmp( Name3, "Italic" ) == 0 )
1595  SetItalic( true );
1596 
1597  return true;
1598 }
1599 
1600 
1601 void SCH_HIERLABEL::SetLabelSpinStyle( int aSpinStyle )
1602 {
1603  m_spin_style = aSpinStyle;
1604 
1605  switch( aSpinStyle )
1606  {
1607  default:
1608  case 0: // Horiz Normal Orientation
1612  break;
1613 
1614  case 1: // Vert Orientation UP
1618  break;
1619 
1620  case 2: // Horiz Orientation
1624  break;
1625 
1626  case 3: // Vert Orientation BOTTOM
1630  break;
1631  }
1632 }
1633 
1634 
1636  wxDC* DC,
1637  const wxPoint& offset,
1638  GR_DRAWMODE DrawMode,
1639  COLOR4D Color )
1640 {
1641  static std::vector <wxPoint> Poly;
1642  COLOR4D color;
1643  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1644  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
1645 
1646  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1647 
1648  if( Color != COLOR4D::UNSPECIFIED )
1649  color = Color;
1650  else
1652 
1653  GRSetDrawMode( DC, DrawMode );
1654 
1655  int save_width = GetThickness();
1656  SetThickness( linewidth );
1657 
1658  wxPoint text_offset = offset + GetSchematicTextOffset();
1659  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
1660 
1661  SetThickness( save_width ); // restore initial value
1662 
1663  CreateGraphicShape( Poly, GetTextPos() + offset );
1664  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1665 
1666  if( m_isDangling && panel )
1667  DrawDanglingSymbol( panel, DC, GetTextPos() + offset, color );
1668 
1669  // Enable these line to draw the bounding box (debug tests purposes only)
1670 #if DRAW_BBOX
1671  {
1672  EDA_RECT BoundaryBox = GetBoundingBox();
1673  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
1674  }
1675 #endif
1676 }
1677 
1678 
1679 void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1680 {
1681  int* Template = TemplateShape[m_shape][m_spin_style];
1682  int halfSize = GetTextWidth() / 2;
1683 
1684  int imax = *Template; Template++;
1685 
1686  aPoints.clear();
1687 
1688  for( int ii = 0; ii < imax; ii++ )
1689  {
1690  wxPoint corner;
1691  corner.x = ( halfSize * (*Template) ) + Pos.x;
1692  Template++;
1693 
1694  corner.y = ( halfSize * (*Template) ) + Pos.y;
1695  Template++;
1696 
1697  aPoints.push_back( corner );
1698  }
1699 }
1700 
1701 
1703 {
1704  int x, y, dx, dy, length, height;
1705 
1706  x = GetTextPos().x;
1707  y = GetTextPos().y;
1708  dx = dy = 0;
1709 
1710  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1711 
1712  height = GetTextHeight() + width + 2 * TXT_MARGIN;
1713  length = LenSize( GetShownText() )
1714  + height // add height for triangular shapes
1715  + 2 * DANGLING_SYMBOL_SIZE;
1716 
1717  switch( GetLabelSpinStyle() )
1718  {
1719  case 0: // Horiz Normal Orientation (left justified)
1720  dx = -length;
1721  dy = height;
1722  x += DANGLING_SYMBOL_SIZE;
1723  y -= height / 2;
1724  break;
1725 
1726  case 1: // Vert Orientation UP
1727  dx = height;
1728  dy = -length;
1729  x -= height / 2;
1730  y += DANGLING_SYMBOL_SIZE;
1731  break;
1732 
1733  case 2: // Horiz Orientation - Right justified
1734  dx = length;
1735  dy = height;
1736  x -= DANGLING_SYMBOL_SIZE;
1737  y -= height / 2;
1738  break;
1739 
1740  case 3: // Vert Orientation BOTTOM
1741  dx = height;
1742  dy = length;
1743  x -= height / 2;
1744  y -= DANGLING_SYMBOL_SIZE;
1745  break;
1746  }
1747 
1748  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1749  box.Normalize();
1750  return box;
1751 }
1752 
1753 
1755 {
1756  wxPoint text_offset;
1757 
1758  int width = std::max( GetThickness(), GetDefaultLineThickness() );
1759 
1760  int ii = GetTextWidth() + TXT_MARGIN + width;
1761 
1762  switch( GetLabelSpinStyle() )
1763  {
1764  case 0: // Orientation horiz normale
1765  text_offset.x = -ii;
1766  break;
1767 
1768  case 1: // Orientation vert UP
1769  text_offset.y = -ii;
1770  break;
1771 
1772  case 2: // Orientation horiz inverse
1773  text_offset.x = ii;
1774  break;
1775 
1776  case 3: // Orientation vert BOTTOM
1777  text_offset.y = ii;
1778  break;
1779  }
1780 
1781  return text_offset;
1782 }
1783 
1784 
1785 void SCH_HIERLABEL::MirrorY( int aYaxis_position )
1786 {
1787  /* The hierarchical label is NOT really mirrored for an horizontal label, the schematic
1788  * orientation is changed. For a vertical label, the schematic orientation is not changed
1789  * and the label is moved to a suitable position.
1790  */
1791  switch( GetLabelSpinStyle() )
1792  {
1793  case 0: // horizontal text
1794  SetLabelSpinStyle( 2 );
1795  break;
1796 
1797  case 2: // invert horizontal text
1798  SetLabelSpinStyle( 0 );
1799  break;
1800  }
1801 
1802  SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
1803 }
1804 
1805 
1806 void SCH_HIERLABEL::MirrorX( int aXaxis_position )
1807 {
1808  switch( GetLabelSpinStyle() )
1809  {
1810  case 1: // vertical text
1811  SetLabelSpinStyle( 3 );
1812  break;
1813 
1814  case 3: // invert vertical text
1815  SetLabelSpinStyle( 1 );
1816  break;
1817  }
1818 
1819  SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
1820 }
1821 
1822 
1824 {
1825  wxPoint pt = GetTextPos();
1826  RotatePoint( &pt, aPosition, 900 );
1827  SetTextPos( pt );
1828 
1829  SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 );
1830 }
1831 
1832 
1834 {
1835  wxString msg;
1836  msg.Printf( _( "Hierarchical Label %s" ), GetChars( ShortenedShownText() ) );
1837  return msg;
1838 }
1839 
1840 
1842 {
1843  return add_hierarchical_label_xpm;
1844 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:156
Definition: colors.h:57
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Function wxStringSplit splits aString to a string list separated at aSplitter.
Definition: common.cpp:237
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1012
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:121
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:112
bool IsBusLabel(const wxString &aLabel)
Function IsBusLabel test if aLabel has a bus notation.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1020
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
const wxString traceFindItem
Flag to enable find item tracing using the WXTRACE environment variable.
static double GetInterline(double aGlyphHeight, double aGlyphThickness)
Compute the X and Y size of a given text.
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:767
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void SwapEffects(EDA_TEXT &aTradingPartner)
Function SwapEffects swaps the text effects of the two involved instances.
Definition: eda_text.cpp:74
static int TemplateUNSPC_HN[]
Definition: sch_text.cpp:82
wxPoint GetPosition() const
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_text.cpp:656
wxString m_Text
Definition: eda_text.h:348
static int Template3STATE_HI[]
Definition: sch_text.cpp:93
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:83
bool IsMultilineAllowed() const
Definition: eda_text.h:188
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:159
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:92
PNG memory record (file in memory).
Definition: bitmap_types.h:38
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
virtual void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:344
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:128
bool IsItalic() const
Definition: eda_text.h:170
virtual bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_text.cpp:382
virtual int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_text.cpp:326
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:1026
bool Contains(const wxPoint &aPoint) const
Function Contains.
void GetMsgPanelInfo(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:724
bool m_isDangling
True if not connected to another object if the object derive from SCH_TEXT supports connections...
Definition: sch_text.h:65
static int TemplateOUT_HN[]
Definition: sch_text.cpp:77
#define DANGLING_SYMBOL_SIZE
Definition: general.h:42
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_text.cpp:176
virtual void SetLabelSpinStyle(int aSpinStyle)
Function SetLabelSpinStyle sets a spin or rotation angle, along with specific horizontal and vertical...
Definition: sch_text.cpp:277
#define Y_CORRECTION
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:203
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:400
void SetItalic(bool isItalic)
Definition: eda_text.h:169
int GetTextWidth() const
Definition: eda_text.h:218
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 Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:1823
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
static int TemplateIN_UP[]
Definition: sch_text.cpp:74
int GetLabelSpinStyle() const
Definition: sch_text.h:119
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:1806
bool IsSelected() const
Definition: base_struct.h:221
const EDA_ITEM * GetItem() const
static int TemplateOUT_HI[]
Definition: sch_text.cpp:78
wxPoint GetSchematicTextOffset() const override
Function GetSchematicTextOffset (virtual)
Definition: sch_text.cpp:851
void SetOrigin(const wxPoint &pos)
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:88
SCH_SHEET_PATH m_SheetPath
virtual bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_text.cpp:421
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
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
int GetState(int type) const
Definition: base_struct.h:237
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_text.cpp:896
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
#define TEXT_ANGLE_VERT
Definition: common.h:113
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:1158
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:90
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_text.cpp:1785
virtual void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:217
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:981
double GetTextAngle() const
Definition: eda_text.h:164
bool IsBold() const
Definition: eda_text.h:173
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1483
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
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...
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_text.cpp:915
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: drawtxt.cpp:227
COLOR4D GetLayerColor(LAYERSCH_ID aLayer)
Definition: eeschema.cpp:166
static int TemplateIN_BOTTOM[]
Definition: sch_text.cpp:75
void SetTextX(int aX)
Definition: eda_text.h:226
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:114
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_text.cpp:1061
#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
const wxPoint & GetOrigin() const
static int TemplateOUT_BOTTOM[]
Definition: sch_text.cpp:80
#define SELECTED
Definition: base_struct.h:120
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:845
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:115
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:131
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_text.cpp:577
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:1500
wxPoint GetSchematicTextOffset() const override
Function GetSchematicTextOffset (virtual)
Definition: sch_text.cpp:1185
void SetLabelSpinStyle(int aSpinStyle) override
Function SetLabelSpinStyle sets a spin or rotation angle, along with specific horizontal and vertical...
Definition: sch_text.cpp:857
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
virtual wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:614
void SetEnd(int x, int y)
static int TemplateIN_HI[]
Definition: sch_text.cpp:73
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...
Definition: drawtxt.cpp:67
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:1635
static int Template3STATE_UP[]
Definition: sch_text.cpp:94
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:137
static int TemplateBIDI_HN[]
Definition: sch_text.cpp:87
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Function CreateGraphicShape Calculates the graphic shape (a polygon) associated to the text...
Definition: sch_text.cpp:1313
EDA_RECT * GetClipBox()
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:327
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_text.cpp:1423
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
virtual 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:500
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:1702
virtual const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_text.cpp:587
Class SCH_SHEET_PATH.
wxPoint Centre() const
DANGLING_END_T GetType() const
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:886
bool Load(LINE_READER &aLine, wxString &aErrorMsg) override
Function Load reads a schematic item from aLine in a .sch file.
Definition: sch_text.cpp:1525
void SetMultilineAllowed(bool aAllow)
Function SetMultiLineAllowed.
Definition: eda_text.h:187
static int TemplateBIDI_BOTTOM[]
Definition: sch_text.cpp:90
const wxPoint GetEnd() const
EDA_UNITS_T g_UserUnit
display units
Definition: common.cpp:57
Definition of the NETLIST_OBJECT class.
void Normalize()
Function Normalize ensures that the height ant width are positive.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Function CreateGraphicShape Calculates the graphic shape (a polygon) associated to the text...
Definition: sch_text.cpp:1679
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_text.cpp:1042
LAYERSCH_ID m_Layer
Base plotter engine class.
Definition: plot_common.h:86
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:1268
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
void SetLabelSpinStyle(int aSpinStyle) override
Function SetLabelSpinStyle sets a spin or rotation angle, along with specific horizontal and vertical...
Definition: sch_text.cpp:1601
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: drawtxt.cpp:49
virtual void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos)
Function CreateGraphicShape Calculates the graphic shape (a polygon) associated to the text...
Definition: sch_text.h:144
virtual bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_text.cpp:564
virtual char * ReadLine()=0
Function ReadLine reads a line of text into the buffer and increments the line number counter...
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:92
virtual void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_text.cpp:676
#define max(a, b)
Definition: auxiliary.h:86
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
virtual bool IsDanglingStateChanged(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:511
#define TXT_MARGIN
Definition: sch_text.cpp:54
virtual void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:311
virtual void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:240
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_text.h:94
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
virtual BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:622
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1833
Class EDA_RECT handles the component boundary box.
int m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:76
T Mirror(T aPoint, T aMirrorRef)
Function MIRROR Mirror aPoint in aMirrorRef.
Definition: macros.h:106
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:863
virtual wxPoint GetSchematicTextOffset() const
Function GetSchematicTextOffset (virtual)
Definition: sch_text.cpp:143
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:151
void IncrementLabelMember(wxString &name, int aIncrement)
Definition: edit_label.cpp:293
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_text.cpp:988
int GetTextHeight() const
Definition: eda_text.h:221
SCH_HIERLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_HIERARCHICAL_LABEL_T)
Definition: sch_text.cpp:1490
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1475
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
This file is part of the common libary.
PINSHEETLABEL_SHAPE m_shape
Definition: sch_text.h:61
LAYERSCH_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Class DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be conn...
const wxSize & GetTextSize() const
Definition: eda_text.h:215
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:1036
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
void DrawDanglingSymbol(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &pos, COLOR4D Color)
Definition: eeredraw.cpp:37
static int TemplateUNSPC_BOTTOM[]
Definition: sch_text.cpp:85
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_text.cpp:1506
int LenSize(const wxString &aLine) const
Function LenSize.
Definition: eda_text.cpp:80
Message panel definition file.
virtual void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_text.cpp:194
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1841
void SetBold(bool aBold)
Definition: eda_text.h:172
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Implementation of the label properties dialog.
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:1175
SCH_LABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:835
void SetLabelSpinStyle(int aSpinStyle) override
Function SetLabelSpinStyle sets a spin or rotation angle, along with specific horizontal and vertical...
Definition: sch_text.cpp:1234
wxPoint GetSchematicTextOffset() const override
Function GetSchematicTextOffset (virtual)
Definition: sch_text.cpp:1754
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_text.cpp:1136
virtual 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:628
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:148
void SetTextY(int aY)
Definition: eda_text.h:227
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:292
void ConvertBusToNetListItems(NETLIST_OBJECT_LIST &aNetListItems)
Function ConvertBusToNetListItems breaks the text of a bus label type net list object into as many me...
int GetDefaultTextSize()
Default size for text in general.
void IncrementLabel(int aIncrement)
Function IncrementLabel increments the label text, if it ends with a number.
Definition: sch_text.cpp:137
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62