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 <class_drawpanel.h>
36 #include <drawtxt.h>
37 #include <schframe.h>
38 #include <class_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 <class_netlist_object.h>
46 
47 
48 extern void IncrementLabelMember( wxString& name, int aIncrement );
49 
50 // Only for tests: set DRAW_BBOX to 1 to draw the bounding box of labels
51 #define DRAW_BBOX 0
52 
53 // Margin in internal units (mils) between labels and wires
54 #define TXT_MARGIN 4
55 
56 // Names of sheet label types.
57 const char* SheetLabelType[] =
58 {
59  "Input",
60  "Output",
61  "BiDi",
62  "3State",
63  "UnSpc",
64  "???"
65 };
66 
67 /* Coding polygons for global symbol graphic shapes.
68  * the first parml is the number of corners
69  * others are the corners coordinates in reduced units
70  * the real coordinate is the reduced coordinate * text half size
71  */
72 static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
73 static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
74 static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
75 static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
76 
77 static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
78 static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
79 static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
80 static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
81 
82 static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
83 static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
84 static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
85 static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
86 
87 static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
88 static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
89 static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
90 static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
91 
92 static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
93 static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
94 static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
95 static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
96 
97 static int* TemplateShape[5][4] =
98 {
104 };
105 
106 
107 SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
108  SCH_ITEM( NULL, aType ),
109  EDA_TEXT( text ),
110  m_shape( NET_INPUT )
111 {
113  SetTextPos( pos );
114  m_isDangling = false;
115  m_spin_style = 0;
116 
117  SetMultilineAllowed( true );
118 }
119 
120 
121 SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) :
122  SCH_ITEM( aText ),
123  EDA_TEXT( aText )
124 {
125  m_shape = aText.m_shape;
126  m_isDangling = false;
127  m_spin_style = aText.m_spin_style;
128 }
129 
130 
132 {
133  return new SCH_TEXT( *this );
134 }
135 
136 
137 void SCH_TEXT::IncrementLabel( int aIncrement )
138 {
139  IncrementLabelMember( m_Text, aIncrement );
140 }
141 
142 
144 {
145  wxPoint text_offset;
146 
147  // add an offset to x ( or y) position to allow a text to
148  // be on a wire or a line and be readable
149  int thick_offset = TXT_MARGIN +
150  ( GetPenSize() + GetDefaultLineThickness() ) / 2;
151 
152  switch( GetLabelSpinStyle() )
153  {
154  default:
155  case 0: // Horiz Normal Orientation (left justified)
156  text_offset.y = -thick_offset;
157  break;
158 
159  case 1: // Vert Orientation UP
160  text_offset.x = -thick_offset;
161  break;
162 
163  case 2: // Horiz Orientation - Right justified
164  text_offset.y = -thick_offset;
165  break;
166 
167  case 3: // Vert Orientation BOTTOM
168  text_offset.x = -thick_offset;
169  break;
170  }
171 
172  return text_offset;
173 }
174 
175 
176 bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation )
177 {
178  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
179 
180  if( SCH_ITEM::Matches( m_Text, aSearchData ) )
181  {
182  EDA_RECT BoundaryBox = GetBoundingBox();
183 
184  if( aFindLocation )
185  *aFindLocation = BoundaryBox.Centre();
186 
187  return true;
188  }
189 
190  return false;
191 }
192 
193 
194 void SCH_TEXT::MirrorY( int aYaxis_position )
195 {
196  // Text is NOT really mirrored; it is moved to a suitable horizontal position
197  switch( GetLabelSpinStyle() )
198  {
199  case 0: // horizontal text
200  SetLabelSpinStyle( 2 );
201  break;
202 
203  case 2: // invert horizontal text
204  SetLabelSpinStyle( 0 );
205  break;
206 
207  case 1: // Vert Orientation UP
208  case 3: // Vert Orientation BOTTOM
209  default:
210  break;
211  }
212 
213  SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
214 }
215 
216 
217 void SCH_TEXT::MirrorX( int aXaxis_position )
218 {
219  // Text is NOT really mirrored; it is moved to a suitable vertical position
220  switch( GetLabelSpinStyle() )
221  {
222  case 1: // Vert Orientation UP
223  SetLabelSpinStyle( 3 );
224  break;
225 
226  case 3: // Vert Orientation BOTTOM
227  SetLabelSpinStyle( 1 );
228  break;
229 
230  case 0: // horizontal text
231  case 2: // invert horizontal text
232  default:
233  break;
234  }
235 
236  SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
237 }
238 
239 
240 void SCH_TEXT::Rotate( wxPoint aPosition )
241 {
242  int dy;
243 
244  wxPoint pt = GetTextPos();
245  RotatePoint( &pt, aPosition, 900 );
246  SetTextPos( pt );
247 
248  SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 );
249 
250  switch( GetLabelSpinStyle() )
251  {
252  case 0: // horizontal text
253  dy = GetTextHeight();
254  break;
255 
256  case 1: // Vert Orientation UP
257  dy = 0;
258  break;
259 
260  case 2: // invert horizontal text
261  dy = GetTextHeight();
262  break;
263 
264  case 3: // Vert Orientation BOTTOM
265  dy = 0;
266  break;
267 
268  default:
269  dy = 0;
270  break;
271  }
272 
273  SetTextY( GetTextPos().y + dy );
274 }
275 
276 
277 void SCH_TEXT::SetLabelSpinStyle( int aSpinStyle )
278 {
279  m_spin_style = aSpinStyle;
280 
281  switch( aSpinStyle )
282  {
283  default:
284  case 0: // Horiz Normal Orientation (left justified)
288  break;
289 
290  case 1: // Vert Orientation UP
294  break;
295 
296  case 2: // Horiz Orientation - Right justified
300  break;
301 
302  case 3: // Vert Orientation BOTTOM
306  break;
307  }
308 }
309 
310 
312 {
313  SCH_TEXT* item = (SCH_TEXT*) aItem;
314 
315  std::swap( m_Text, item->m_Text );
316  std::swap( m_Layer, item->m_Layer );
317 
318  std::swap( m_shape, item->m_shape );
319  std::swap( m_isDangling, item->m_isDangling );
320  std::swap( m_spin_style, item->m_spin_style );
321 
322  SwapEffects( *item );
323 }
324 
325 
327 {
328  int pensize = GetThickness();
329 
330  if( pensize == 0 ) // Use default values for pen size
331  {
332  if( IsBold() )
333  pensize = GetPenSizeForBold( GetTextWidth() );
334  else
335  pensize = GetDefaultLineThickness();
336  }
337 
338  // Clip pen size for small texts:
339  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
340  return pensize;
341 }
342 
343 
344 void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
345  GR_DRAWMODE DrawMode, COLOR4D Color )
346 {
347  COLOR4D color;
348  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
349  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
350 
351  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
352 
353  if( Color != COLOR4D::UNSPECIFIED )
354  color = Color;
355  else
357 
358  GRSetDrawMode( DC, DrawMode );
359 
360  wxPoint text_offset = aOffset + GetSchematicTextOffset();
361 
362  int savedWidth = GetThickness();
363  SetThickness( linewidth ); // Set the minimum width
364 
365  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
366 
367  SetThickness( savedWidth );
368 
369  if( m_isDangling && panel)
370  DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color );
371 
372  // Enable these line to draw the bounding box (debug tests purposes only)
373 #if DRAW_BBOX
374  {
375  EDA_RECT BoundaryBox = GetBoundingBox();
376  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
377  }
378 #endif
379 }
380 
381 
382 void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
383 {
384  // Normal text labels cannot be tested for dangling ends.
385  if( Type() == SCH_TEXT_T )
386  return;
387 
388  DANGLING_END_ITEM item( LABEL_END, this, GetTextPos() );
389  aItemList.push_back( item );
390 }
391 
392 
393 bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
394 {
395  // Normal text labels cannot be tested for dangling ends.
396  if( Type() == SCH_TEXT_T )
397  return false;
398 
399  bool previousState = m_isDangling;
400  m_isDangling = true;
401 
402  for( unsigned ii = 0; ii < aItemList.size(); ii++ )
403  {
404  DANGLING_END_ITEM& item = aItemList[ii];
405 
406  if( item.GetItem() == this )
407  continue;
408 
409  switch( item.GetType() )
410  {
411  case PIN_END:
412  case LABEL_END:
413  case SHEET_LABEL_END:
414  if( GetTextPos() == item.GetPosition() )
415  m_isDangling = false;
416 
417  break;
418 
419  case WIRE_START_END:
420  case BUS_START_END:
421  {
422  // These schematic items have created 2 DANGLING_END_ITEM one per end. But being
423  // a paranoid programmer, I'll check just in case.
424  ii++;
425 
426  wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
427  wxT( "Dangling end type list overflow. Bad programmer!" ) );
428 
429  DANGLING_END_ITEM & nextItem = aItemList[ii];
430  m_isDangling = !IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetTextPos() );
431  }
432  break;
433 
434  default:
435  break;
436  }
437 
438  if( !m_isDangling )
439  break;
440  }
441 
442  return previousState != m_isDangling;
443 }
444 
445 
446 bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect )
447 {
448  bool previousState = IsSelected();
449 
450  if( aRect.Contains( GetTextPos() ) )
451  SetFlags( SELECTED );
452  else
453  ClearFlags( SELECTED );
454 
455  return previousState != IsSelected();
456 }
457 
458 
459 void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
460 {
461  // Normal text labels do not have connection points. All others do.
462  if( Type() == SCH_TEXT_T )
463  return;
464 
465  aPoints.push_back( GetTextPos() );
466 }
467 
468 
470 {
471  // We must pass the effective text thickness to GetTextBox
472  // when calculating the bounding box
473  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
474 
475  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
476 
477  EDA_RECT rect = GetTextBox( -1, linewidth );
478 
479  if( GetTextAngle() ) // Rotate rect
480  {
481  wxPoint pos = rect.GetOrigin();
482  wxPoint end = rect.GetEnd();
483 
484  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
485  RotatePoint( &end, GetTextPos(), GetTextAngle() );
486 
487  rect.SetOrigin( pos );
488  rect.SetEnd( end );
489  }
490 
491  rect.Normalize();
492  return rect;
493 }
494 
495 
497 {
498  wxString msg;
499  msg.Printf( _( "Graphic Text %s" ), GetChars( ShortenedShownText() ) );
500  return msg;
501 }
502 
503 
505 {
506  return text_xpm;
507 }
508 
509 
511  SCH_SHEET_PATH* aSheetPath )
512 {
513  if( GetLayer() == LAYER_NOTES || GetLayer() == LAYER_SHEETLABEL )
514  return;
515 
516  NETLIST_OBJECT* item = new NETLIST_OBJECT();
517  item->m_SheetPath = *aSheetPath;
518  item->m_SheetPathInclude = *aSheetPath;
519  item->m_Comp = (SCH_ITEM*) this;
520  item->m_Type = NET_LABEL;
521 
522  if( GetLayer() == LAYER_GLOBLABEL )
523  item->m_Type = NET_GLOBLABEL;
524  else if( GetLayer() == LAYER_HIERLABEL )
525  item->m_Type = NET_HIERLABEL;
526 
527  item->m_Label = m_Text;
528  item->m_Start = item->m_End = GetTextPos();
529 
530  aNetListItems.push_back( item );
531 
532  // If a bus connects to label
533  if( IsBusLabel( m_Text ) )
534  item->ConvertBusToNetListItems( aNetListItems );
535 }
536 
537 
538 bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
539 {
540  EDA_RECT bBox = GetBoundingBox();
541  bBox.Inflate( aAccuracy );
542  return bBox.Contains( aPosition );
543 }
544 
545 
546 bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
547 {
548  EDA_RECT bBox = GetBoundingBox();
549  bBox.Inflate( aAccuracy );
550 
551  if( aContained )
552  return aRect.Contains( bBox );
553 
554  return aRect.Intersects( bBox );
555 }
556 
557 
558 void SCH_TEXT::Plot( PLOTTER* aPlotter )
559 {
560  static std::vector <wxPoint> Poly;
562  int thickness = GetPenSize();
563 
564  aPlotter->SetCurrentLineWidth( thickness );
565 
566  if( IsMultilineAllowed() )
567  {
568  std::vector<wxPoint> positions;
569  wxArrayString strings_list;
570  wxStringSplit( GetShownText(), strings_list, '\n' );
571  positions.reserve( strings_list.Count() );
572 
573  GetPositionsOfLinesOfMultilineText(positions, strings_list.Count() );
574 
575  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
576  {
577  wxPoint textpos = positions[ii] + GetSchematicTextOffset();
578  wxString& txt = strings_list.Item( ii );
579  aPlotter->Text( textpos, color, txt, GetTextAngle(), GetTextSize(),
581  thickness, IsItalic(), IsBold() );
582  }
583  }
584  else
585  {
586  wxPoint textpos = GetTextPos() + GetSchematicTextOffset();
587 
588  aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(),
590  thickness, IsItalic(), IsBold() );
591  }
592 
593  // Draw graphic symbol for global or hierarchical labels
594  CreateGraphicShape( Poly, GetTextPos() );
595 
596  aPlotter->SetCurrentLineWidth( GetPenSize() );
597 
598  if( Poly.size() )
599  aPlotter->PlotPoly( Poly, NO_FILL );
600 }
601 
602 
603 /*
604  * Display the type, shape, size and some other props to the Message panel
605  */
607 {
608  wxString msg;
609 
610  switch( Type() )
611  {
612  case SCH_TEXT_T:
613  msg = _( "Graphic Text" );
614  break;
615 
616  case SCH_LABEL_T:
617  msg = _( "Label" );
618  break;
619 
620  case SCH_GLOBAL_LABEL_T:
621  msg = _( "Global Label" );
622  break;
623 
625  msg = _( "Hierarchical Label" );
626  break;
627 
628  case SCH_SHEET_PIN_T:
629  msg = _( "Hierarchical Sheet Pin" );
630  break;
631 
632  default:
633  return;
634  }
635 
636  aList.push_back( MSG_PANEL_ITEM( msg, GetShownText(), DARKCYAN ) );
637 
638  switch( GetLabelSpinStyle() )
639  {
640  case 0: // horizontal text
641  msg = _( "Horizontal" );
642  break;
643 
644  case 1: // Vert Orientation UP
645  msg = _( "Vertical up" );
646  break;
647 
648  case 2: // invert horizontal text
649  msg = _( "Horizontal invert" );
650  break;
651 
652  case 3: // Vert Orientation Down
653  msg = _( "Vertical down" );
654  break;
655 
656  default:
657  msg = wxT( "???" );
658  break;
659  }
660 
661  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, BROWN ) );
662 
663  wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
664  int style = 0;
665 
666  if( IsItalic() )
667  style = 1;
668 
669  if( IsBold() )
670  style += 2;
671 
672  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
673 
674 
675  // Display electricat type if it is relevant
676  if( (Type() == SCH_GLOBAL_LABEL_T) ||
677  (Type() == SCH_HIERARCHICAL_LABEL_T ) ||
678  (Type() == SCH_SHEET_PIN_T ) )
679  {
680  switch( GetShape() )
681  {
682  case NET_INPUT: msg = _( "Input" ); break;
683  case NET_OUTPUT: msg = _( "Output" ); break;
684  case NET_BIDI: msg = _( "Bidirectional" ); break;
685  case NET_TRISTATE: msg = _( "Tri-State" ); break;
686  case NET_UNSPECIFIED: msg = _( "Passive" ); break;
687  default: msg = wxT( "???" ); break;
688  }
689 
690  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, BLUE ) );
691  }
692 
693  // Display text size (X or Y value, with are the same value in Eeschema)
694  msg = StringFromValue( g_UserUnit, GetTextWidth(), true );
695  aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) );
696 }
697 
698 #if defined(DEBUG)
699 
700 void SCH_TEXT::Show( int nestLevel, std::ostream& os ) const
701 {
702  // XML output:
703  wxString s = GetClass();
704 
705  NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
706  << " layer=\"" << m_Layer << '"'
707  << " shape=\"" << m_shape << '"'
708  << " dangling=\"" << m_isDangling << '"'
709  << '>'
710  << TO_UTF8( m_Text )
711  << "</" << s.Lower().mb_str() << ">\n";
712 }
713 
714 #endif
715 
716 
717 SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
718  SCH_TEXT( pos, text, SCH_LABEL_T )
719 {
721  m_shape = NET_INPUT;
722  m_isDangling = true;
723  SetMultilineAllowed( false );
724 }
725 
726 
728 {
729  return new SCH_LABEL( *this );
730 }
731 
732 
734 {
736 }
737 
738 
739 void SCH_LABEL::SetLabelSpinStyle( int aOrientation )
740 {
741  SCH_TEXT::SetLabelSpinStyle( aOrientation );
742 }
743 
744 
745 void SCH_LABEL::MirrorX( int aXaxis_position )
746 {
747  // Text is NOT really mirrored; it is moved to a suitable position
748  switch( GetLabelSpinStyle() )
749  {
750  case 1: // Vert Orientation UP
751  SetLabelSpinStyle( 3 );
752  break;
753 
754  case 3: // Vert Orientation BOTTOM
755  SetLabelSpinStyle( 1 );
756  break;
757 
758  case 0: // horizontal text
759  case 2: // invert horizontal text
760  default:
761  break;
762  }
763 
764  SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) );
765 }
766 
767 
768 void SCH_LABEL::Rotate( wxPoint aPosition )
769 {
770  wxPoint pt = GetTextPos();
771  RotatePoint( &pt, aPosition, 900 );
772  SetTextPos( pt );
773 
774  SetLabelSpinStyle( (GetLabelSpinStyle() + 1) % 4 );
775 }
776 
777 
778 void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
779  GR_DRAWMODE DrawMode, COLOR4D Color )
780 {
781  SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
782 }
783 
784 
786 {
787  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
788  EDA_RECT rect = GetTextBox( -1, linewidth );
789 
790  if( GetTextAngle() != 0.0 )
791  {
792  // Rotate rect
793  wxPoint pos = rect.GetOrigin();
794  wxPoint end = rect.GetEnd();
795 
796  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
797  RotatePoint( &end, GetTextPos(), GetTextAngle() );
798 
799  rect.SetOrigin( pos );
800  rect.SetEnd( end );
801 
802  rect.Normalize();
803  }
804 
805  return rect;
806 }
807 
808 
810 {
811  wxString msg;
812  msg.Printf( _( "Label %s" ), GetChars( ShortenedShownText() ) );
813  return msg;
814 }
815 
816 
818 {
819  return add_line_label_xpm;
820 }
821 
822 
823 SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
824  SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T )
825 {
827  m_shape = NET_BIDI;
828  m_isDangling = true;
829  SetMultilineAllowed( false );
830 }
831 
832 
834 {
835  return new SCH_GLOBALLABEL( *this );
836 }
837 
838 
839 void SCH_GLOBALLABEL::MirrorY( int aYaxis_position )
840 {
841  /* The global label is NOT really mirrored.
842  * for an horizontal label, the schematic orientation is changed.
843  * for a vertical label, the schematic orientation is not changed.
844  * and the label is moved to a suitable position
845  */
846  switch( GetLabelSpinStyle() )
847  {
848  case 0: // horizontal text
849  SetLabelSpinStyle( 2 );
850  break;
851 
852  case 2: // invert horizontal text
853  SetLabelSpinStyle( 0 );
854  break;
855  }
856 
857  SetTextX( ::Mirror( GetTextPos().x, aYaxis_position ) );
858 }
859 
860 
861 void SCH_GLOBALLABEL::MirrorX( int aXaxis_position )
862 {
863  switch( GetLabelSpinStyle() )
864  {
865  case 1: // vertical text
866  SetLabelSpinStyle( 3 );
867  break;
868 
869  case 3: // invert vertical text
870  SetLabelSpinStyle( 1 );
871  break;
872  }
873 
874  SetTextY( ::Mirror( GetTextPos().y, aXaxis_position ) );
875 }
876 
877 
879 {
880  wxPoint pt = GetTextPos();
881  RotatePoint( &pt, aPosition, 900 );
882  SetTextPos( pt );
883 
884  SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 );
885 }
886 
887 
889 {
890  wxPoint text_offset;
891  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
892 
893  width = Clamp_Text_PenSize( width, GetTextSize(), IsBold() );
894  int halfSize = GetTextWidth() / 2;
895  int offset = width;
896 
897  switch( m_shape )
898  {
899  case NET_INPUT:
900  case NET_BIDI:
901  case NET_TRISTATE:
902  offset += halfSize;
903  break;
904 
905  case NET_OUTPUT:
906  case NET_UNSPECIFIED:
907  offset += TXT_MARGIN;
908  break;
909 
910  default:
911  break;
912  }
913 
914  switch( GetLabelSpinStyle() )
915  {
916  case 0: // Orientation horiz normal
917  text_offset.x -= offset;
918  break;
919 
920  case 1: // Orientation vert UP
921  text_offset.y -= offset;
922  break;
923 
924  case 2: // Orientation horiz inverse
925  text_offset.x += offset;
926  break;
927 
928  case 3: // Orientation vert BOTTOM
929  text_offset.y += offset;
930  break;
931  }
932 
933  return text_offset;
934 }
935 
936 
938 {
939  m_spin_style = aSpinStyle;
940 
941  switch( aSpinStyle )
942  {
943  default:
944  case 0: // Horiz Normal Orientation
948  break;
949 
950  case 1: // Vert Orientation UP
954  break;
955 
956  case 2: // Horiz Orientation
960  break;
961 
962  case 3: // Vert Orientation BOTTOM
966  break;
967  }
968 }
969 
970 
972  wxDC* DC,
973  const wxPoint& aOffset,
974  GR_DRAWMODE DrawMode,
975  COLOR4D Color )
976 {
977  static std::vector <wxPoint> Poly;
978  COLOR4D color;
979  wxPoint text_offset = aOffset + GetSchematicTextOffset();
980 
981  if( Color != COLOR4D::UNSPECIFIED )
982  color = Color;
983  else
985 
986  GRSetDrawMode( DC, DrawMode );
987 
988  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
989 
990  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
991 
992  int save_width = GetThickness();
993  SetThickness( linewidth );
994 
995  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
996  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
997 
998  SetThickness( save_width ); // restore initial value
999 
1000  CreateGraphicShape( Poly, GetTextPos() + aOffset );
1001  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1002 
1003  if( m_isDangling && panel )
1004  DrawDanglingSymbol( panel, DC, GetTextPos() + aOffset, color );
1005 
1006  // Enable these line to draw the bounding box (debug tests purposes only)
1007 #if DRAW_BBOX
1008  {
1009  EDA_RECT BoundaryBox = GetBoundingBox();
1010  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
1011  }
1012 #endif
1013 }
1014 
1015 
1016 void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1017 {
1018  int halfSize = GetTextHeight() / 2;
1019  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1020 
1021  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1022 
1023  aPoints.clear();
1024 
1025  int symb_len = LenSize( GetShownText() ) + ( TXT_MARGIN * 2 );
1026 
1027  // Create outline shape : 6 points
1028  int x = symb_len + linewidth + 3;
1029 
1030  // Use negation bar Y position to calculate full vertical size
1031  // Search for overbar symbol
1032  bool hasOverBar = false;
1033 
1034  for( unsigned ii = 1; ii < m_Text.size(); ii++ )
1035  {
1036  if( m_Text[ii-1] == '~' && m_Text[ii] != '~' )
1037  {
1038  hasOverBar = true;
1039  break;
1040  }
1041  }
1042 
1043  #define Y_CORRECTION 1.40
1044  // Note: this factor is due to the fact the Y size of a few letters like [
1045  // are bigger than the y size value, and we need a margin for the graphic symbol.
1046  int y = KiROUND( halfSize * Y_CORRECTION );
1047 
1048  // Note: this factor is due to the fact we need a margin for the graphic symbol.
1049  #define Y_OVERBAR_CORRECTION 1.2
1050  if( hasOverBar )
1051  y = KiROUND( KIGFX::STROKE_FONT::GetInterline( halfSize, linewidth )
1053 
1054  // Gives room for line thickess and margin
1055  y += linewidth // for line thickess
1056  + linewidth/2; // for margin
1057 
1058  // Starting point(anchor)
1059  aPoints.push_back( wxPoint( 0, 0 ) );
1060  aPoints.push_back( wxPoint( 0, -y ) ); // Up
1061  aPoints.push_back( wxPoint( -x, -y ) ); // left
1062  aPoints.push_back( wxPoint( -x, 0 ) ); // Up left
1063  aPoints.push_back( wxPoint( -x, y ) ); // left down
1064  aPoints.push_back( wxPoint( 0, y ) ); // down
1065 
1066  int x_offset = 0;
1067 
1068  switch( m_shape )
1069  {
1070  case NET_INPUT:
1071  x_offset = -halfSize;
1072  aPoints[0].x += halfSize;
1073  break;
1074 
1075  case NET_OUTPUT:
1076  aPoints[3].x -= halfSize;
1077  break;
1078 
1079  case NET_BIDI:
1080  case NET_TRISTATE:
1081  x_offset = -halfSize;
1082  aPoints[0].x += halfSize;
1083  aPoints[3].x -= halfSize;
1084  break;
1085 
1086  case NET_UNSPECIFIED:
1087  default:
1088  break;
1089  }
1090 
1091  int angle = 0;
1092 
1093  switch( GetLabelSpinStyle() )
1094  {
1095  case 0: // Orientation horiz normal
1096  break;
1097 
1098  case 1: // Orientation vert UP
1099  angle = -900;
1100  break;
1101 
1102  case 2: // Orientation horiz inverse
1103  angle = 1800;
1104  break;
1105 
1106  case 3: // Orientation vert BOTTOM
1107  angle = 900;
1108  break;
1109  }
1110 
1111  // Rotate outlines and move corners in real position
1112  for( unsigned ii = 0; ii < aPoints.size(); ii++ )
1113  {
1114  aPoints[ii].x += x_offset;
1115 
1116  if( angle )
1117  RotatePoint( &aPoints[ii], angle );
1118 
1119  aPoints[ii] += Pos;
1120  }
1121 
1122  aPoints.push_back( aPoints[0] ); // closing
1123 }
1124 
1125 
1127 {
1128  int x, y, dx, dy, length, height;
1129 
1130  x = GetTextPos().x;
1131  y = GetTextPos().y;
1132  dx = dy = 0;
1133 
1134  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1135 
1136  height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN;
1137 
1138  // text X size add height for triangular shapes(bidirectional)
1139  length = LenSize( GetShownText() ) + height + DANGLING_SYMBOL_SIZE;
1140 
1141  switch( GetLabelSpinStyle() ) // respect orientation
1142  {
1143  case 0: // Horiz Normal Orientation (left justified)
1144  dx = -length;
1145  dy = height;
1146  x += DANGLING_SYMBOL_SIZE;
1147  y -= height / 2;
1148  break;
1149 
1150  case 1: // Vert Orientation UP
1151  dx = height;
1152  dy = -length;
1153  x -= height / 2;
1154  y += DANGLING_SYMBOL_SIZE;
1155  break;
1156 
1157  case 2: // Horiz Orientation - Right justified
1158  dx = length;
1159  dy = height;
1160  x -= DANGLING_SYMBOL_SIZE;
1161  y -= height / 2;
1162  break;
1163 
1164  case 3: // Vert Orientation BOTTOM
1165  dx = height;
1166  dy = length;
1167  x -= height / 2;
1168  y -= DANGLING_SYMBOL_SIZE;
1169  break;
1170  }
1171 
1172  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1173  box.Normalize();
1174  return box;
1175 }
1176 
1177 
1179 {
1180  wxString msg;
1181  msg.Printf( _( "Global Label %s" ), GetChars( ShortenedShownText() ) );
1182  return msg;
1183 }
1184 
1185 
1187 {
1188  return add_glabel_xpm;
1189 }
1190 
1191 
1192 
1193 SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
1194  SCH_TEXT( pos, text, aType )
1195 {
1197  m_shape = NET_INPUT;
1198  m_isDangling = true;
1199  SetMultilineAllowed( false );
1200 }
1201 
1202 
1204 {
1205  return new SCH_HIERLABEL( *this );
1206 }
1207 
1208 
1209 void SCH_HIERLABEL::SetLabelSpinStyle( int aSpinStyle )
1210 {
1211  m_spin_style = aSpinStyle;
1212 
1213  switch( aSpinStyle )
1214  {
1215  default:
1216  case 0: // Horiz Normal Orientation
1220  break;
1221 
1222  case 1: // Vert Orientation UP
1226  break;
1227 
1228  case 2: // Horiz Orientation
1232  break;
1233 
1234  case 3: // Vert Orientation BOTTOM
1238  break;
1239  }
1240 }
1241 
1242 
1244  wxDC* DC,
1245  const wxPoint& offset,
1246  GR_DRAWMODE DrawMode,
1247  COLOR4D Color )
1248 {
1249  static std::vector <wxPoint> Poly;
1250  COLOR4D color;
1251  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1252  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
1253 
1254  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
1255 
1256  if( Color != COLOR4D::UNSPECIFIED )
1257  color = Color;
1258  else
1260 
1261  GRSetDrawMode( DC, DrawMode );
1262 
1263  int save_width = GetThickness();
1264  SetThickness( linewidth );
1265 
1266  wxPoint text_offset = offset + GetSchematicTextOffset();
1267  EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, COLOR4D::UNSPECIFIED );
1268 
1269  SetThickness( save_width ); // restore initial value
1270 
1271  CreateGraphicShape( Poly, GetTextPos() + offset );
1272  GRPoly( clipbox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
1273 
1274  if( m_isDangling && panel )
1275  DrawDanglingSymbol( panel, DC, GetTextPos() + offset, color );
1276 
1277  // Enable these line to draw the bounding box (debug tests purposes only)
1278 #if DRAW_BBOX
1279  {
1280  EDA_RECT BoundaryBox = GetBoundingBox();
1281  GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
1282  }
1283 #endif
1284 }
1285 
1286 
1287 void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& Pos )
1288 {
1289  int* Template = TemplateShape[m_shape][m_spin_style];
1290  int halfSize = GetTextWidth() / 2;
1291 
1292  int imax = *Template; Template++;
1293 
1294  aPoints.clear();
1295 
1296  for( int ii = 0; ii < imax; ii++ )
1297  {
1298  wxPoint corner;
1299  corner.x = ( halfSize * (*Template) ) + Pos.x;
1300  Template++;
1301 
1302  corner.y = ( halfSize * (*Template) ) + Pos.y;
1303  Template++;
1304 
1305  aPoints.push_back( corner );
1306  }
1307 }
1308 
1309 
1311 {
1312  int x, y, dx, dy, length, height;
1313 
1314  x = GetTextPos().x;
1315  y = GetTextPos().y;
1316  dx = dy = 0;
1317 
1318  int width = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
1319 
1320  height = GetTextHeight() + width + 2 * TXT_MARGIN;
1321  length = LenSize( GetShownText() )
1322  + height // add height for triangular shapes
1323  + 2 * DANGLING_SYMBOL_SIZE;
1324 
1325  switch( GetLabelSpinStyle() )
1326  {
1327  case 0: // Horiz Normal Orientation (left justified)
1328  dx = -length;
1329  dy = height;
1330  x += DANGLING_SYMBOL_SIZE;
1331  y -= height / 2;
1332  break;
1333 
1334  case 1: // Vert Orientation UP
1335  dx = height;
1336  dy = -length;
1337  x -= height / 2;
1338  y += DANGLING_SYMBOL_SIZE;
1339  break;
1340 
1341  case 2: // Horiz Orientation - Right justified
1342  dx = length;
1343  dy = height;
1344  x -= DANGLING_SYMBOL_SIZE;
1345  y -= height / 2;
1346  break;
1347 
1348  case 3: // Vert Orientation BOTTOM
1349  dx = height;
1350  dy = length;
1351  x -= height / 2;
1352  y -= DANGLING_SYMBOL_SIZE;
1353  break;
1354  }
1355 
1356  EDA_RECT box( wxPoint( x, y ), wxSize( dx, dy ) );
1357  box.Normalize();
1358  return box;
1359 }
1360 
1361 
1363 {
1364  wxPoint text_offset;
1365 
1366  int width = std::max( GetThickness(), GetDefaultLineThickness() );
1367 
1368  int ii = GetTextWidth() + TXT_MARGIN + width;
1369 
1370  switch( GetLabelSpinStyle() )
1371  {
1372  case 0: // Orientation horiz normale
1373  text_offset.x = -ii;
1374  break;
1375 
1376  case 1: // Orientation vert UP
1377  text_offset.y = -ii;
1378  break;
1379 
1380  case 2: // Orientation horiz inverse
1381  text_offset.x = ii;
1382  break;
1383 
1384  case 3: // Orientation vert BOTTOM
1385  text_offset.y = ii;
1386  break;
1387  }
1388 
1389  return text_offset;
1390 }
1391 
1392 
1393 void SCH_HIERLABEL::MirrorY( int aYaxis_position )
1394 {
1395  /* The hierarchical label is NOT really mirrored for an horizontal label, the schematic
1396  * orientation is changed. For a vertical label, the schematic orientation is not changed
1397  * and the label is moved to a suitable position.
1398  */
1399  switch( GetLabelSpinStyle() )
1400  {
1401  case 0: // horizontal text
1402  SetLabelSpinStyle( 2 );
1403  break;
1404 
1405  case 2: // invert horizontal text
1406  SetLabelSpinStyle( 0 );
1407  break;
1408  }
1409 
1410  SetTextX( Mirror( GetTextPos().x, aYaxis_position ) );
1411 }
1412 
1413 
1414 void SCH_HIERLABEL::MirrorX( int aXaxis_position )
1415 {
1416  switch( GetLabelSpinStyle() )
1417  {
1418  case 1: // vertical text
1419  SetLabelSpinStyle( 3 );
1420  break;
1421 
1422  case 3: // invert vertical text
1423  SetLabelSpinStyle( 1 );
1424  break;
1425  }
1426 
1427  SetTextY( Mirror( GetTextPos().y, aXaxis_position ) );
1428 }
1429 
1430 
1432 {
1433  wxPoint pt = GetTextPos();
1434  RotatePoint( &pt, aPosition, 900 );
1435  SetTextPos( pt );
1436 
1437  SetLabelSpinStyle( (GetLabelSpinStyle() + 3) % 4 );
1438 }
1439 
1440 
1442 {
1443  wxString msg;
1444  msg.Printf( _( "Hierarchical Label %s" ), GetChars( ShortenedShownText() ) );
1445  return msg;
1446 }
1447 
1448 
1450 {
1451  return add_hierarchical_label_xpm;
1452 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:156
Definition: colors.h:57
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Function wxStringSplit splits aString to a string list separated at aSplitter.
Definition: common.cpp:137
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:809
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:118
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:90
bool IsBusLabel(const wxString &aLabel)
Function IsBusLabel test if aLabel has a bus notation.
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:817
static int Template3STATE_HN[]
Definition: sch_text.cpp:92
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:39
static double GetInterline(double aGlyphHeight, double aGlyphThickness)
Compute the distance (interline) between 2 lines of text (for multiline texts).
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:774
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:82
wxPoint GetPosition() const
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_text.cpp:538
wxString m_Text
Definition: eda_text.h:346
static int Template3STATE_HI[]
Definition: sch_text.cpp:93
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:83
bool IsMultilineAllowed() const
Definition: eda_text.h:188
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:79
PNG memory record (file in memory).
Definition: bitmap_types.h:38
virtual void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:344
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:296
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:106
bool IsItalic() const
Definition: eda_text.h:170
virtual int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_text.cpp:326
static int TemplateOUT_UP[]
Definition: sch_text.cpp:79
SCH_SHEET_PATH m_SheetPathInclude
SCH_GLOBALLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:823
bool Contains(const wxPoint &aPoint) const
Function Contains.
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: sch_text.cpp:606
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:77
#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:176
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:277
#define Y_CORRECTION
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:203
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:414
int GetTextWidth() const
Definition: eda_text.h:218
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i...
static int TemplateUNSPC_UP[]
Definition: sch_text.cpp:84
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:1431
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
static int TemplateIN_UP[]
Definition: sch_text.cpp:74
int GetLabelSpinStyle() const
Definition: sch_text.h:116
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:1414
bool IsSelected() const
Definition: base_struct.h:235
const EDA_ITEM * GetItem() const
static int TemplateOUT_HI[]
Definition: sch_text.cpp:78
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:733
void SetOrigin(const wxPoint &pos)
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:88
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
SCH_SHEET_PATH m_SheetPath
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
const char * SheetLabelType[]
Definition: sch_text.cpp:57
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL)=0
Function PlotPoly.
NETLIST_ITEM_T m_Type
int GetState(int type) const
Definition: base_struct.h:251
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
#define TEXT_ANGLE_VERT
Definition: common.h:91
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:861
static int Template3STATE_BOTTOM[]
Definition: sch_text.cpp:95
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_text.cpp:1393
virtual void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:217
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:778
double GetTextAngle() const
Definition: eda_text.h:164
bool IsBold() const
Definition: eda_text.h:173
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1186
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
This file contains miscellaneous commonly used macros and functions.
Class NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected item...
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: drawtxt.cpp:229
static int TemplateIN_BOTTOM[]
Definition: sch_text.cpp:75
void SetTextX(int aX)
Definition: eda_text.h:226
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:114
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
const wxPoint & GetOrigin() const
static int TemplateOUT_BOTTOM[]
Definition: sch_text.cpp:80
#define SELECTED
Definition: base_struct.h:134
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1076
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:727
const wxString traceFindItem
Flag to enable finding schematic item debug output.
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:102
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:131
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_text.cpp:459
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:1203
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:888
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:739
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
virtual wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:496
void SetEnd(int x, int y)
static int TemplateIN_HI[]
Definition: sch_text.cpp:73
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
Definition: drawtxt.cpp:67
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:1243
static int Template3STATE_UP[]
Definition: sch_text.cpp:94
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:151
static int TemplateBIDI_HN[]
Definition: sch_text.cpp:87
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1016
EDA_RECT * GetClipBox()
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a ...
Definition: eda_text.cpp:314
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_text.cpp:1126
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:382
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:1310
virtual const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_text.cpp:469
Class SCH_SHEET_PATH.
wxPoint Centre() const
DANGLING_END_T GetType() const
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:768
void SetMultilineAllowed(bool aAllow)
Function SetMultiLineAllowed.
Definition: eda_text.h:187
static int TemplateBIDI_BOTTOM[]
Definition: sch_text.cpp:90
const wxPoint GetEnd() const
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
Definition of the NETLIST_OBJECT class.
void Normalize()
Function Normalize ensures that the height ant width are positive.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1287
Base plotter engine class.
Definition: class_plotter.h:97
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, const wxPoint &offset, GR_DRAWMODE draw_mode, COLOR4D Color=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_text.cpp:971
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:1209
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: drawtxt.cpp:49
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:446
static int TemplateBIDI_UP[]
Definition: sch_text.cpp:89
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
virtual void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_text.cpp:558
#define max(a, b)
Definition: auxiliary.h:86
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
virtual bool IsDanglingStateChanged(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Definition: sch_text.cpp:393
#define TXT_MARGIN
Definition: sch_text.cpp:54
virtual void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_text.cpp:311
virtual void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:240
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_text.h: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:107
virtual BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:504
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1441
Class EDA_RECT handles the component boundary box.
int m_spin_style
The orientation of text and any associated drawing elements of derived objects.
Definition: sch_text.h:76
T Mirror(T aPoint, T aMirrorRef)
Function MIRROR Mirror aPoint in aMirrorRef.
Definition: macros.h:106
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_text.cpp:745
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:143
static int * TemplateShape[5][4]
Definition: sch_text.cpp:97
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
void IncrementLabelMember(wxString &name, int aIncrement)
Definition: edit_label.cpp:293
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_text.cpp:785
const char * name
int GetTextHeight() const
Definition: eda_text.h:221
SCH_HIERLABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString, KICAD_T aType=SCH_HIERARCHICAL_LABEL_T)
Definition: sch_text.cpp:1193
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_text.cpp:1178
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
This file is part of the common libary.
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:215
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_text.cpp:833
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
static int TemplateUNSPC_BOTTOM[]
Definition: sch_text.cpp:85
int LenSize(const wxString &aLine) const
Function LenSize.
Definition: eda_text.cpp:67
Message panel definition file.
virtual void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_text.cpp:194
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_text.cpp:1449
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Implementation of the label properties dialog.
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_text.cpp:878
SCH_LABEL(const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
Definition: sch_text.cpp:717
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:937
wxPoint GetSchematicTextOffset() const override
Definition: sch_text.cpp:1362
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_text.cpp:839
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:510
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
static int TemplateIN_HN[]
Definition: sch_text.cpp:72
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:148
void SetTextY(int aY)
Definition: eda_text.h:227
void Draw(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode=FILLED, COLOR4D aAnchor_color=COLOR4D::UNSPECIFIED)
Function Draw.
Definition: eda_text.cpp:279
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:137
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62