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