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