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 = aText.m_isDangling;
128  m_spin_style = aText.m_spin_style;
129 }
130 
131 
133 {
134  return new SCH_TEXT( *this );
135 }
136 
137 
138 void SCH_TEXT::IncrementLabel( int aIncrement )
139 {
140  IncrementLabelMember( m_Text, aIncrement );
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 
466 BITMAP_DEF SCH_TEXT::GetMenuImage() const
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  // Two thicknesses are set here:
527  // The first is for EDA_TEXT, which controls the interline spacing based on text thickness
528  // The second is for the output that sets the actual stroke size
529  SetThickness( thickness );
530  aPlotter->SetCurrentLineWidth( thickness );
531 
532  if( IsMultilineAllowed() )
533  {
534  std::vector<wxPoint> positions;
535  wxArrayString strings_list;
536  wxStringSplit( GetShownText(), strings_list, '\n' );
537  positions.reserve( strings_list.Count() );
538 
539  GetPositionsOfLinesOfMultilineText(positions, (int) strings_list.Count() );
540 
541  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
542  {
543  wxPoint textpos = positions[ii] + GetSchematicTextOffset();
544  wxString& txt = strings_list.Item( ii );
545  aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(),
547  thickness, IsItalic(), IsBold() );
548  }
549  }
550  else
551  {
552  wxPoint textpos = GetTextPos() + GetSchematicTextOffset();
553 
554  aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
556  thickness, IsItalic(), IsBold() );
557  }
558 
559  // Draw graphic symbol for global or hierarchical labels
560  CreateGraphicShape( Poly, GetTextPos() );
561 
562  aPlotter->SetCurrentLineWidth( GetPenSize() );
563 
564  if( Poly.size() )
565  aPlotter->PlotPoly( Poly, NO_FILL );
566 }
567 
568 
569 /*
570  * Display the type, shape, size and some other props to the Message panel
571  */
573 {
574  wxString msg;
575 
576  switch( Type() )
577  {
578  case SCH_TEXT_T: msg = _( "Graphic Text" ); break;
579  case SCH_LABEL_T: msg = _( "Label" ); break;
580  case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
581  case SCH_HIERARCHICAL_LABEL_T: msg = _( "Hierarchical Label" ); break;
582  case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
583  default: return;
584  }
585 
586  aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );
587 
588  switch( GetLabelSpinStyle() )
589  {
590  case 0: msg = _( "Horizontal" ); break;
591  case 1: msg = _( "Vertical up" ); break;
592  case 2: msg = _( "Horizontal invert" ); break;
593  case 3: msg = _( "Vertical down" ); break;
594  default: msg = wxT( "???" ); break;
595  }
596 
597  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
598 
599  wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
600  int style = 0;
601 
602  if( IsItalic() )
603  style = 1;
604 
605  if( IsBold() )
606  style += 2;
607 
608  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
609 
610 
611  // Display electricat type if it is relevant
612  if( (Type() == SCH_GLOBAL_LABEL_T) ||
613  (Type() == SCH_HIERARCHICAL_LABEL_T ) ||
614  (Type() == SCH_SHEET_PIN_T ) )
615  {
616  switch( GetShape() )
617  {
618  case NET_INPUT: msg = _( "Input" ); break;
619  case NET_OUTPUT: msg = _( "Output" ); break;
620  case NET_BIDI: msg = _( "Bidirectional" ); break;
621  case NET_TRISTATE: msg = _( "Tri-State" ); break;
622  case NET_UNSPECIFIED: msg = _( "Passive" ); break;
623  default: msg = wxT( "???" ); break;
624  }
625 
626  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );
627  }
628 
629  // Display text size (X or Y value, with are the same value in Eeschema)
630  msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
631  aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );
632 }
633 
634 #if defined(DEBUG)
635 
636 void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
637 {
638  // XML output:
639  wxString s = GetClass();
640 
641  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
642  << " layer=\"" << m_Layer << '"'
643  << " shape=\"" << m_shape << '"'
644  << " dangling=\"" << m_isDangling << '"'
645  << '>'
646  << TO_UTF8( m_Text )
647  << "</" << s.Lower().mb_str() << ">\n";
648 }
649 
650 #endif
651 
652 
653 SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
654  SCH_TEXT( pos, text, SCH_LABEL_T )
655 {
657  m_shape = NET_INPUT;
658  m_isDangling = true;
659  SetMultilineAllowed( false );
660 }
661 
662 
664 {
665  return new SCH_LABEL( *this );
666 }
667 
668 
670 {
671  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
672  EDA_RECT rect = GetTextBox( -1, linewidth );
673 
674  if( GetTextAngle() != 0.0 )
675  {
676  // Rotate rect
677  wxPoint pos = rect.GetOrigin();
678  wxPoint end = rect.GetEnd();
679 
680  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
681  RotatePoint( &end, GetTextPos(), GetTextAngle() );
682 
683  rect.SetOrigin( pos );
684  rect.SetEnd( end );
685 
686  rect.Normalize();
687  }
688 
689  return rect;
690 }
691 
692 
694 {
695  return wxString::Format( _( "Label %s" ), ShortenedShownText() );
696 }
697 
698 
699 BITMAP_DEF SCH_LABEL::GetMenuImage() const
700 {
701  return add_line_label_xpm;
702 }
703 
704 
705 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
706  SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
707 {
709  m_shape = NET_BIDI;
710  m_isDangling = true;
711  SetMultilineAllowed( false );
712 }
713 
714 
716 {
717  return new SCH_GLOBALLABEL( *this );
718 }
719 
720 
722 {
723  wxPoint text_offset;
724  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
725 
726  width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
727  int halfSize = GetTextWidth() / 2;
728  int offset = width;
729 
730  switch( m_shape )
731  {
732  case NET_INPUT:
733  case NET_BIDI:
734  case NET_TRISTATE:
735  offset += halfSize;
736  break;
737 
738  case NET_OUTPUT:
739  case NET_UNSPECIFIED:
740  offset += TXT_MARGIN;
741  break;
742 
743  default:
744  break;
745  }
746 
747  switch( GetLabelSpinStyle() )
748  {
749  default:
750  case 0: text_offset.x -= offset; break; // Orientation horiz normal
751  case 1: text_offset.y -= offset; break; // Orientation vert UP
752  case 2: text_offset.x += offset; break; // Orientation horiz inverse
753  case 3: text_offset.y += offset; break; // Orientation vert BOTTOM
754  }
755 
756  return text_offset;
757 }
758 
759 
761 {
762  m_spin_style = aSpinStyle;
763 
764  switch( aSpinStyle )
765  {
766  default:
767  case 0: // Horiz Normal Orientation
771  break;
772 
773  case 1: // Vert Orientation UP
777  break;
778 
779  case 2: // Horiz Orientation
783  break;
784 
785  case 3: // Vert Orientation BOTTOM
789  break;
790  }
791 }
792 
793 
795  wxDC* DC,
796  const wxPoint& aOffset,
797  GR_DRAWMODE DrawMode,
798  COLOR4D Color )
799 {
800  static std::vector <wxPoint> Poly;
801  COLOR4D color;
802  wxPoint text_offset = aOffset + GetSchematicTextOffset();
803 
804  if( Color != COLOR4D::UNSPECIFIED )
805  color = Color;
806  else
808 
809  GRSetDrawMode( DC, DrawMode );
810 
811  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
812 
813  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
814 
815  int save_width = GetThickness();
816  SetThickness( linewidth );
817 
818  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
819  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
820 
821  SetThickness( save_width ); // restore initial value
822 
823  CreateGraphicShape( Poly, GetTextPos() + aOffset );
824  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
825 
826  if( m_isDangling && panel )
827  DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color );
828 
829  // Enable these line to draw the bounding box (debug tests purposes only)
830 #if DRAW_BBOX
831  {
832  EDA_RECT BoundaryBox = GetBoundingBox();
833  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
834  }
835 #endif
836 }
837 
838 
839 void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
840 {
841  int halfSize = GetTextHeight() / 2;
842  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
843 
844  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
845 
846  aPoints.clear();
847 
848  int symb_len = LenSize( GetShownText(), linewidth ) + ( TXT_MARGIN * 2 );
849 
850  // Create outline shape : 6 points
851  int x = symb_len + linewidth + 3;
852 
853  // Use negation bar Y position to calculate full vertical size
854  // Search for overbar symbol
855  bool hasOverBar = false;
856 
857  for( unsigned ii = 1; ii < m_Text.size(); ii++ )
858  {
859  if( m_Text[ii-1] == '~' && m_Text[ii] != '~' )
860  {
861  hasOverBar = true;
862  break;
863  }
864  }
865 
866  #define Y_CORRECTION 1.40
867  // Note: this factor is due to the fact the Y size of a few letters like [
868  // are bigger than the y size value, and we need a margin for the graphic symbol.
869  int y = KiROUND( halfSize * Y_CORRECTION );
870 
871  // Note: this factor is due to the fact we need a margin for the graphic symbol.
872  #define Y_OVERBAR_CORRECTION 1.2
873  if( hasOverBar )
874  y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth )
876 
877  // Gives room for line thickess and margin
878  y += linewidth // for line thickess
879  + linewidth/2; // for margin
880 
881  // Starting point(anchor)
882  aPoints.push_back( wxPoint( 0, 0 ) );
883  aPoints.push_back( wxPoint( 0, -y ) ); // Up
884  aPoints.push_back( wxPoint( -x, -y ) ); // left
885  aPoints.push_back( wxPoint( -x, 0 ) ); // Up left
886  aPoints.push_back( wxPoint( -x, y ) ); // left down
887  aPoints.push_back( wxPoint( 0, y ) ); // down
888 
889  int x_offset = 0;
890 
891  switch( m_shape )
892  {
893  case NET_INPUT:
894  x_offset = -halfSize;
895  aPoints[0].x += halfSize;
896  break;
897 
898  case NET_OUTPUT:
899  aPoints[3].x -= halfSize;
900  break;
901 
902  case NET_BIDI:
903  case NET_TRISTATE:
904  x_offset = -halfSize;
905  aPoints[0].x += halfSize;
906  aPoints[3].x -= halfSize;
907  break;
908 
909  case NET_UNSPECIFIED:
910  default:
911  break;
912  }
913 
914  int angle = 0;
915 
916  switch( GetLabelSpinStyle() )
917  {
918  default:
919  case 0: break; // Orientation horiz normal
920  case 1: angle = -900; break; // Orientation vert UP
921  case 2: angle = 1800; break; // Orientation horiz inverse
922  case 3: angle = 900; break; // Orientation vert BOTTOM
923  }
924 
925  // Rotate outlines and move corners in real position
926  for( wxPoint& aPoint : aPoints )
927  {
928  aPoint.x += x_offset;
929 
930  if( angle )
931  RotatePoint( &aPoint, angle );
932 
933  aPoint += Pos;
934  }
935 
936  aPoints.push_back( aPoints[0] ); // closing
937 }
938 
939 
941 {
942  int x, y, dx, dy, length, height;
943 
944  x = GetTextPos().x;
945  y = GetTextPos().y;
946  dx = dy = 0;
947 
948  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
949 
950  height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN;
951 
952  // text X size add height for triangular shapes(bidirectional)
953  length = LenSize( GetShownText(), width ) + height + DANGLING_SYMBOL_SIZE;
954 
955  switch( GetLabelSpinStyle() ) // respect orientation
956  {
957  default:
958  case 0: // Horiz Normal Orientation (left justified)
959  dx = -length;
960  dy = height;
962  y -= height / 2;
963  break;
964 
965  case 1: // Vert Orientation UP
966  dx = height;
967  dy = -length;
968  x -= height / 2;
970  break;
971 
972  case 2: // Horiz Orientation - Right justified
973  dx = length;
974  dy = height;
976  y -= height / 2;
977  break;
978 
979  case 3: // Vert Orientation BOTTOM
980  dx = height;
981  dy = length;
982  x -= height / 2;
984  break;
985  }
986 
987  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
988  box.Normalize();
989  return box;
990 }
991 
992 
994 {
995  return wxString::Format( _( "Global Label %s" ), ShortenedShownText() );
996 }
997 
998 
1000 {
1001  return add_glabel_xpm;
1002 }
1003 
1004 
1005 
1006 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
1007  SCH_TEXT( pos, text, aType )
1008 {
1010  m_shape = NET_INPUT;
1011  m_isDangling = true;
1012  SetMultilineAllowed( false );
1013 }
1014 
1015 
1017 {
1018  return new SCH_HIERLABEL( *this );
1019 }
1020 
1021 
1022 void SCH_HIERLABEL::SetLabelSpinStyle( int aSpinStyle )
1023 {
1024  m_spin_style = aSpinStyle;
1025 
1026  switch( aSpinStyle )
1027  {
1028  default:
1029  case 0: // Horiz Normal Orientation
1033  break;
1034 
1035  case 1: // Vert Orientation UP
1039  break;
1040 
1041  case 2: // Horiz Orientation
1045  break;
1046 
1047  case 3: // Vert Orientation BOTTOM
1051  break;
1052  }
1053 }
1054 
1055 
1057  wxDC* DC,
1058  const wxPoint& offset,
1059  GR_DRAWMODE DrawMode,
1060  COLOR4D Color )
1061 {
1062  static std::vector <wxPoint> Poly;
1063  COLOR4D color;
1064  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1065  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
1066 
1067  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1068 
1069  if( Color != COLOR4D::UNSPECIFIED )
1070  color = Color;
1071  else
1073 
1074  GRSetDrawMode( DC, DrawMode );
1075 
1076  int save_width = GetThickness();
1077  SetThickness( linewidth );
1078 
1079  wxPoint text_offset = offset + GetSchematicTextOffset();
1080  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
1081 
1082  SetThickness( save_width ); // restore initial value
1083 
1084  CreateGraphicShape( Poly, GetTextPos() + offset );
1085  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1086 
1087  if( m_isDangling && panel )
1088  DrawDanglingSymbol( panel, DC, GetTextPos() + offset, color );
1089 
1090  // Enable these line to draw the bounding box (debug tests purposes only)
1091 #if DRAW_BBOX
1092  {
1093  EDA_RECT BoundaryBox = GetBoundingBox();
1094  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
1095  }
1096 #endif
1097 }
1098 
1099 
1100 void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1101 {
1102  int* Template = TemplateShape[m_shape][m_spin_style];
1103  int halfSize = GetTextWidth() / 2;
1104  int imax = *Template; Template++;
1105 
1106  aPoints.clear();
1107 
1108  for( int ii = 0; ii < imax; ii++ )
1109  {
1110  wxPoint corner;
1111  corner.x = ( halfSize * (*Template) ) + Pos.x;
1112  Template++;
1113 
1114  corner.y = ( halfSize * (*Template) ) + Pos.y;
1115  Template++;
1116 
1117  aPoints.push_back( corner );
1118  }
1119 }
1120 
1121 
1123 {
1124  int x, y, dx, dy, length, height;
1125 
1126  x = GetTextPos().x;
1127  y = GetTextPos().y;
1128  dx = dy = 0;
1129 
1130  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1131 
1132  height = GetTextHeight() + width + 2 * TXT_MARGIN;
1133  length = LenSize( GetShownText(), width )
1134  + height // add height for triangular shapes
1135  + 2 * DANGLING_SYMBOL_SIZE;
1136 
1137  switch( GetLabelSpinStyle() )
1138  {
1139  default:
1140  case 0: // Horiz Normal Orientation (left justified)
1141  dx = -length;
1142  dy = height;
1143  x += DANGLING_SYMBOL_SIZE;
1144  y -= height / 2;
1145  break;
1146 
1147  case 1: // Vert Orientation UP
1148  dx = height;
1149  dy = -length;
1150  x -= height / 2;
1151  y += DANGLING_SYMBOL_SIZE;
1152  break;
1153 
1154  case 2: // Horiz Orientation - Right justified
1155  dx = length;
1156  dy = height;
1157  x -= DANGLING_SYMBOL_SIZE;
1158  y -= height / 2;
1159  break;
1160 
1161  case 3: // Vert Orientation BOTTOM
1162  dx = height;
1163  dy = length;
1164  x -= height / 2;
1165  y -= DANGLING_SYMBOL_SIZE;
1166  break;
1167  }
1168 
1169  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1170  box.Normalize();
1171  return box;
1172 }
1173 
1174 
1176 {
1177  wxPoint text_offset;
1178  int width = std::max( GetThickness(), GetDefaultLineThickness() );
1179  int ii = GetTextWidth() + TXT_MARGIN + width;
1180 
1181  switch( GetLabelSpinStyle() )
1182  {
1183  default:
1184  case 0: text_offset.x = -ii; break; // Orientation horiz normale
1185  case 1: text_offset.y = -ii; break; // Orientation vert UP
1186  case 2: text_offset.x = ii; break; // Orientation horiz inverse
1187  case 3: text_offset.y = ii; break; // Orientation vert BOTTOM
1188  }
1189 
1190  return text_offset;
1191 }
1192 
1193 
1195 {
1196  return wxString::Format( _( "Hierarchical Label %s" ), ShortenedShownText() );
1197 }
1198 
1199 
1201 {
1202  return add_hierarchical_label_xpm;
1203 }
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:187
bool IsBold() const
Definition: eda_text.h:186
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:699
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:993
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
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:84
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:121
bool IsSelected() const
Definition: base_struct.h:224
#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:794
SCH_GLOBALLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:705
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 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
double GetTextAngle() const
Definition: eda_text.h:177
static int TemplateOUT_HI[]
Definition: sch_text.cpp:79
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:144
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:89
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
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'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
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:1056
EDA_ITEM * m_Comp
bool Contains(const wxPoint &aPoint) const
Function Contains.
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
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:999
This file contains miscellaneous commonly used macros and functions.
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
int GetTextHeight() const
Definition: eda_text.h:234
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
bool IsItalic() const
Definition: eda_text.h:183
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
int GetLabelSpinStyle() const
Definition: sch_text.h:116
#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
const EDA_ITEM * GetItem() const
#define SELECTED
Definition: base_struct.h:121
const wxPoint GetEnd() const
Definition: eda_rect.h:114
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:663
int LenSize(const wxString &aLine, int aThickness) const
Function LenSize.
Definition: eda_text.cpp:67
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:1016
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
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
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:721
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
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
void SetEnd(int x, int y)
Definition: eda_rect.h:134
static int TemplateIN_HI[]
Definition: sch_text.cpp:74
const wxSize & GetTextSize() const
Definition: eda_text.h:228
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
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:80
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:839
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:940
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:1122
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.
void SetMultilineAllowed(bool aAllow)
Function SetMultiLineAllowed.
Definition: eda_text.h:200
bool IsMultilineAllowed() const
Definition: eda_text.h:201
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:1194
static int TemplateBIDI_BOTTOM[]
Definition: sch_text.cpp:91
bool IsBusLabel(const wxString &aLabel)
Function IsBusLabel test if aLabel has a bus notation.
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
void Normalize()
Function Normalize ensures that the height ant width are positive.
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1100
Base plotter engine class.
Definition: plotter.h:97
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:1022
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
int GetTextWidth() const
Definition: eda_text.h:231
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's internal state for displ...
Definition: sch_text.cpp:572
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:109
DANGLING_END_T GetType() const
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
wxPoint Centre() const
Definition: eda_rect.h:60
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:669
SCH_HIERLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_HIERARCHICAL_LABEL_T)
Definition: sch_text.cpp:1006
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
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
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...
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:715
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:693
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1200
int GetState(int type) const
Definition: base_struct.h:240
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:653
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:760
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:1175
EDA_UNITS_T
Definition: common.h:160
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...
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:118
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
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