KiCad PCB EDA Suite
sch_field.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 /* Fields are texts attached to a component, having a special meaning
26  * Fields 0 and 1 are very important: reference and value
27  * Field 2 is used as default footprint name.
28  * Field 3 is reserved (not currently used
29  * Fields 4 and more are user fields.
30  * They can be renamed and can appear in reports
31  */
32 
33 #include <fctsys.h>
34 #include <base_struct.h>
35 #include <gr_basic.h>
36 #include <gr_text.h>
37 #include <macros.h>
38 #include <sch_edit_frame.h>
39 #include <plotter.h>
40 #include <bitmaps.h>
41 #include <kiway.h>
42 #include <general.h>
43 #include <class_library.h>
44 #include <sch_component.h>
45 #include <sch_field.h>
46 #include <schematic.h>
48 #include <kicad_string.h>
49 #include <trace_helpers.h>
50 
51 
52 SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_ITEM* aParent,
53  const wxString& aName ) :
54  SCH_ITEM( aParent, SCH_FIELD_T ),
55  EDA_TEXT( wxEmptyString ),
56  m_id( 0 ),
57  m_name( aName )
58 {
59  SetTextPos( aPos );
60  SetId( aFieldId ); // will also set the layer
61  SetVisible( false );
62 }
63 
64 
66 {
67 }
68 
69 
71 {
72  return new SCH_FIELD( *this );
73 }
74 
75 
76 void SCH_FIELD::SetId( int aId )
77 {
78  m_id = aId;
79 
80  if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
81  {
82  switch( m_id )
83  {
84  case SHEETNAME: SetLayer( LAYER_SHEETNAME ); break;
86  default: SetLayer( LAYER_SHEETFIELDS ); break;
87  }
88  }
89  else
90  {
91  switch( m_id )
92  {
93  case REFERENCE: SetLayer( LAYER_REFERENCEPART ); break;
94  case VALUE: SetLayer( LAYER_VALUEPART ); break;
95  default: SetLayer( LAYER_FIELDS ); break;
96  }
97  }
98 
99 }
100 
101 
102 wxString SCH_FIELD::GetShownText( int aDepth ) const
103 {
104  std::function<bool( wxString* )> symbolResolver =
105  [&]( wxString* token ) -> bool
106  {
107  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( m_Parent );
108  return component->ResolveTextVar( token, aDepth + 1 );
109  };
110 
111  std::function<bool( wxString* )> sheetResolver =
112  [&]( wxString* token ) -> bool
113  {
114  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_Parent );
115  return sheet->ResolveTextVar( token, aDepth + 1 );
116  };
117 
118  PROJECT* project = nullptr;
119  bool processTextVars = false;
120  wxString text = EDA_TEXT::GetShownText( &processTextVars );
121 
122  if( processTextVars )
123  {
124  if( Schematic() )
125  project = &Schematic()->Prj();
126 
127  if( aDepth < 10 )
128  {
129  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
130  text = ExpandTextVars( text, &symbolResolver, project );
131  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
132  text = ExpandTextVars( text, &sheetResolver, project );
133  else
134  text = ExpandTextVars( text, nullptr, project );
135  }
136  }
137 
138  // WARNING: the IDs of FIELDS and SHEETS overlap, so one must check *both* the
139  // id and the parent's type.
140 
141  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
142  {
143  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( m_Parent );
144 
145  if( m_id == REFERENCE )
146  {
147  // For more than one part per package, we must add the part selection
148  // A, B, ... or 1, 2, .. to the reference.
149  if( component->GetUnitCount() > 1 )
150  text << LIB_PART::SubReference( component->GetUnit() );
151  }
152  }
153  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
154  {
155  if( m_id == SHEETFILENAME )
156  text = _( "File: " ) + text;
157  }
158 
159  return text;
160 }
161 
162 
164 {
165  return GetEffectiveTextPenWidth();
166 }
167 
168 
169 void SCH_FIELD::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
170 {
171  wxDC* DC = aSettings->GetPrintDC();
173  int orient;
174  wxPoint textpos;
175  int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
176 
177  if( ( !IsVisible() && !IsForceVisible() ) || IsVoid() )
178  return;
179 
180  // Calculate the text orientation according to the component orientation.
181  orient = GetTextAngle();
182 
183  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
184  {
185  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
186 
187  if( parentComponent && parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
188  {
189  if( orient == TEXT_ANGLE_HORIZ )
190  orient = TEXT_ANGLE_VERT;
191  else
192  orient = TEXT_ANGLE_HORIZ;
193  }
194  }
195 
196  /* Calculate the text justification, according to the component
197  * orientation/mirror this is a bit complicated due to cumulative
198  * calculations:
199  * - numerous cases (mirrored or not, rotation)
200  * - the DrawGraphicText function recalculate also H and H justifications
201  * according to the text orientation.
202  * - When a component is mirrored, the text is not mirrored and
203  * justifications are complicated to calculate
204  * so the more easily way is to use no justifications ( Centered text )
205  * and use GetBoundaryBox to know the text coordinate considered as centered
206  */
207  EDA_RECT boundaryBox = GetBoundingBox();
208  textpos = boundaryBox.Centre() + aOffset;
209 
210  GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER,
211  GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() );
212 }
213 
214 
215 void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
216 {
217  SetEffects( aSource );
218 }
219 
220 
222 {
223  wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_FIELD_T),
224  wxT( "Cannot swap field data with invalid item." ) );
225 
226  SCH_FIELD* item = (SCH_FIELD*) aItem;
227 
228  std::swap( m_Layer, item->m_Layer );
229  SwapText( *item );
230  SwapEffects( *item );
231 }
232 
233 
235 {
236  // Calculate the text bounding box:
237  EDA_RECT rect = GetTextBox();
238 
239  // Calculate the bounding box position relative to the parent:
240  wxPoint origin = GetParentPosition();
241  wxPoint pos = GetTextPos() - origin;
242  wxPoint begin = rect.GetOrigin() - origin;
243  wxPoint end = rect.GetEnd() - origin;
244  RotatePoint( &begin, pos, GetTextAngle() );
245  RotatePoint( &end, pos, GetTextAngle() );
246 
247  // Now, apply the component transform (mirror/rot)
248  TRANSFORM transform;
249 
250  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
251  {
252  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
253 
254  // Due to the Y axis direction, we must mirror the bounding box,
255  // relative to the text position:
256  MIRROR( begin.y, pos.y );
257  MIRROR( end.y, pos.y );
258 
259  transform = parentComponent->GetTransform();
260  }
261  else
262  {
263  transform = TRANSFORM( 1, 0, 0, 1 ); // identity transform
264  }
265 
266  rect.SetOrigin( transform.TransformCoordinate( begin ) );
267  rect.SetEnd( transform.TransformCoordinate( end ) );
268 
269  rect.Move( origin );
270  rect.Normalize();
271 
272  return rect;
273 }
274 
275 
277 {
278  wxPoint render_center = GetBoundingBox().Centre();
279  wxPoint pos = GetPosition();
280 
281  switch( GetHorizJustify() )
282  {
284  return render_center.x < pos.x;
286  return render_center.x > pos.x;
287  default:
288  return false;
289  }
290 }
291 
292 
293 bool SCH_FIELD::IsVoid() const
294 {
295  return GetText().Len() == 0;
296 }
297 
298 
299 bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
300 {
301  wxString text = GetShownText();
302  int flags = aSearchData.GetFlags();
303  bool searchHiddenFields = flags & FR_SEARCH_ALL_FIELDS;
304  bool searchAndReplace = flags & FR_SEARCH_REPLACE;
305  bool replaceReferences = flags & FR_REPLACE_REFERENCES;
306 
307  wxLogTrace( traceFindItem, wxT( " child item " )
309 
310  if( !IsVisible() && !searchHiddenFields )
311  return false;
312 
313  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
314  {
315  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
316 
317  if( searchAndReplace && m_id == REFERENCE && !replaceReferences )
318  return false;
319 
320  // Take sheet path into account which effects the reference field and the unit for
321  // components with multiple parts.
322  if( m_id == REFERENCE && aAuxData != NULL )
323  {
324  text = parentComponent->GetRef( (SCH_SHEET_PATH*) aAuxData );
325 
326  if( parentComponent->GetUnitCount() > 1 )
327  text << LIB_PART::SubReference( parentComponent->GetUnit() );
328  }
329  }
330 
331  return SCH_ITEM::Matches( text, aSearchData );
332 }
333 
334 
336 {
337  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
338  {
339  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
340 
341  if( m_id == VALUE )
342  {
343  LIB_PART* part = parentComponent->GetPartRef().get();
344 
345  if( part && part->IsPower() )
346  return false;
347  }
348  }
349  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
350  {
351  // See comments in SCH_FIELD::Replace(), below.
352  if( m_id == SHEETFILENAME )
353  return false;
354  }
355 
356  return true;
357 }
358 
359 
360 bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
361 {
362  bool isReplaced = false;
363 
364  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
365  {
366  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
367 
368  if( m_id == REFERENCE )
369  {
370  wxCHECK_MSG( aAuxData != NULL, false,
371  wxT( "Cannot replace reference designator without valid sheet path." ) );
372 
373  wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
374  wxT( "Invalid replace symbol reference field call." ) ) ;
375 
376  wxString text = parentComponent->GetRef( (SCH_SHEET_PATH*) aAuxData );
377 
378  isReplaced = EDA_ITEM::Replace( aSearchData, text );
379 
380  if( isReplaced )
381  parentComponent->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
382  }
383  else
384  {
385  isReplaced = EDA_TEXT::Replace( aSearchData );
386  }
387  }
388  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
389  {
390  isReplaced = EDA_TEXT::Replace( aSearchData );
391 
392  if( m_id == SHEETFILENAME && isReplaced )
393  {
394  // If we allowed this we'd have a bunch of work to do here, including warning
395  // about it not being undoable, checking for recursive hierarchies, reloading
396  // sheets, etc. See DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow().
397  }
398  }
399 
400  return isReplaced;
401 }
402 
403 
404 void SCH_FIELD::Rotate( wxPoint aPosition )
405 {
406  wxPoint pt = GetTextPos();
407  RotatePoint( &pt, aPosition, 900 );
408  SetTextPos( pt );
409 }
410 
411 
412 wxString SCH_FIELD::GetSelectMenuText( EDA_UNITS aUnits ) const
413 {
414  return wxString::Format( _( "Field %s (%s)" ),
415  GetName(),
416  ShortenedShownText() );
417 }
418 
419 
420 wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
421 {
422  if( !m_name.IsEmpty() )
423  return m_name;
424  else if( aUseDefaultName )
425  {
426  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
428  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
430  }
431 
432  return wxEmptyString;
433 }
434 
435 
437 {
438  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
439  {
440  switch( m_id )
441  {
442  case REFERENCE: return wxT( "Reference" );
443  case VALUE: return wxT( "Value" );
444  case FOOTPRINT: return wxT( "Footprint" );
445  case DATASHEET: return wxT( "Datasheet" );
446  }
447  }
448  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
449  {
450  switch( m_id )
451  {
452  case SHEETNAME: return wxT( "Sheetname" );
453  case SHEETFILENAME: return wxT( "Sheetfile" );
454  }
455  }
456 
457  return m_name;
458 }
459 
460 
462 {
463  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
464  {
465  switch( m_id )
466  {
467  case REFERENCE: return edit_comp_ref_xpm;
468  case VALUE: return edit_comp_value_xpm;
469  case FOOTPRINT: return edit_comp_footprint_xpm;
470  default: return edit_text_xpm;
471  }
472  }
473 
474  return edit_text_xpm;
475 }
476 
477 
478 bool SCH_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
479 {
480  // Do not hit test hidden or empty fields.
481  if( !IsVisible() || IsVoid() )
482  return false;
483 
484  EDA_RECT rect = GetBoundingBox();
485 
486  rect.Inflate( aAccuracy );
487 
488  return rect.Contains( aPosition );
489 }
490 
491 
492 bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
493 {
494  // Do not hit test hidden fields.
495  if( !IsVisible() || IsVoid() )
496  return false;
497 
498  EDA_RECT rect = aRect;
499 
500  rect.Inflate( aAccuracy );
501 
502  if( aContained )
503  return rect.Contains( GetBoundingBox() );
504 
505  return rect.Intersects( GetBoundingBox() );
506 }
507 
508 
509 void SCH_FIELD::Plot( PLOTTER* aPlotter )
510 {
511  COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() );
512  int penWidth = GetEffectiveTextPenWidth(
513  aPlotter->RenderSettings()->GetDefaultPenWidth() );
514 
515  if( !IsVisible() )
516  return;
517 
518  if( IsVoid() )
519  return;
520 
521  // Calculate the text orientation, according to the component orientation/mirror
522  int orient = GetTextAngle();
523 
524  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
525  {
526  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
527 
528  if( parentComponent->GetTransform().y1 ) // Rotate component 90 deg.
529  {
530  if( orient == TEXT_ANGLE_HORIZ )
531  orient = TEXT_ANGLE_VERT;
532  else
533  orient = TEXT_ANGLE_HORIZ;
534  }
535  }
536 
537  /*
538  * Calculate the text justification, according to the component orientation/mirror
539  * this is a bit complicated due to cumulative calculations:
540  * - numerous cases (mirrored or not, rotation)
541  * - the DrawGraphicText function also recalculates H and H justifications according to the
542  * text orientation.
543  * - When a component is mirrored, the text is not mirrored and justifications are
544  * complicated to calculate
545  * so the easier way is to use no justifications (centered text) and use GetBoundaryBox to
546  * know the text coordinate considered as centered
547  */
548  EDA_RECT BoundaryBox = GetBoundingBox();
551  wxPoint textpos = BoundaryBox.Centre();
552 
553  aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,
554  penWidth, IsItalic(), IsBold() );
555 }
556 
557 
558 void SCH_FIELD::SetPosition( const wxPoint& aPosition )
559 {
560  // Actual positions are calculated by the rotation/mirror transform of the
561  // parent component of the field. The inverse transform is used to calculate
562  // the position relative to the parent component.
563  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
564  {
565  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
566  wxPoint relativePos = aPosition - parentComponent->GetPosition();
567 
568  relativePos = parentComponent->GetTransform().
569  InverseTransform().TransformCoordinate( relativePos );
570 
571  SetTextPos( relativePos + parentComponent->GetPosition() );
572  return;
573  }
574 
575  SetTextPos( aPosition );
576 }
577 
578 
580 {
581  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
582  {
583  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
584  wxPoint relativePos = GetTextPos() - parentComponent->GetPosition();
585 
586  relativePos = parentComponent->GetTransform().TransformCoordinate( relativePos );
587 
588  return relativePos + parentComponent->GetPosition();
589  }
590 
591  return GetTextPos();
592 }
593 
594 
596 {
597  return m_Parent ? m_Parent->GetPosition() : wxPoint( 0, 0 );
598 }
599 
600 
601 bool SCH_FIELD::operator <( const SCH_ITEM& aItem ) const
602 {
603  if( Type() != aItem.Type() )
604  return Type() < aItem.Type();
605 
606  auto field = static_cast<const SCH_FIELD*>( &aItem );
607 
608  if( GetId() != field->GetId() )
609  return GetId() < field->GetId();
610 
611  if( GetText() != field->GetText() )
612  return GetText() < field->GetText();
613 
614  if( GetLibPosition().x != field->GetLibPosition().x )
615  return GetLibPosition().x < field->GetLibPosition().x;
616 
617  if( GetLibPosition().y != field->GetLibPosition().y )
618  return GetLibPosition().y < field->GetLibPosition().y;
619 
620  return GetName() < field->GetName();
621 }
#define TEXT_ANGLE_HORIZ
EDA_UNITS
Definition: common.h:198
bool IsBold() const
Definition: eda_text.h:182
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_LAYER_ID m_Layer
Definition: sch_item.h:191
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
Definition: eda_text.cpp:146
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
name of datasheet
PROJECT holds project specific data.
Definition: project.h:61
PNG memory record (file in memory).
Definition: bitmap_def.h:29
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
#define TEXT_ANGLE_VERT
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_field.cpp:70
bool IsVisible() const
Definition: eda_text.h:185
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:215
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
Definition: eda_text.cpp:132
const BITMAP_OPAQUE edit_comp_value_xpm[1]
int color
Definition: DXF_plotter.cpp:61
Field object used in symbol libraries.
Definition: lib_field.h:59
EDA_RECT GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:217
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:246
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
int GetUnitCount() const
Return the number of units per package of the symbol.
void SetVisible(bool aVisible)
Definition: eda_text.h:184
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
double GetTextAngle() const
Definition: eda_text.h:173
int GetId() const
Definition: sch_field.h:114
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
const BITMAP_OPAQUE edit_comp_ref_xpm[1]
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_field.cpp:412
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
wxString m_name
Definition: sch_field.h:56
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
bool Contains(const wxPoint &aPoint) const
Function Contains.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:102
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:293
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
This file contains miscellaneous commonly used macros and functions.
virtual const wxPoint GetPosition() const
Definition: base_struct.h:337
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: gr_text.cpp:222
bool IsItalic() const
Definition: eda_text.h:179
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:112
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_field.cpp:601
int y1
Definition: transform.h:49
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:175
const wxPoint GetEnd() const
Definition: eda_rect.h:116
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:436
#define VALUE
int GetUnit() const
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
#define NULL
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
TRANSFORM & GetTransform() const
void SetEnd(int x, int y)
Definition: eda_rect.h:192
const wxSize & GetTextSize() const
Definition: eda_text.h:238
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:278
const wxPoint GetPosition() const override
Define a library symbol object.
SCH_FIELD(const wxPoint &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:52
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:196
wxLogTrace helper definitions.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_field.cpp:478
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:45
wxPoint GetLibPosition() const
Definition: sch_field.h:188
SCH_SHEET_PATH.
std::unique_ptr< LIB_PART > & GetPartRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_field.cpp:461
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
void GRText(wxDC *aDC, const wxPoint &aPos, 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, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function GRText Draw a graphic text (like module texts)
Definition: gr_text.cpp:134
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:271
void Normalize()
Function Normalize ensures that the height ant width are positive.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Base plotter engine class.
Definition: plotter.h:114
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:138
void Plot(PLOTTER *aPlotter) override
Plot the schematic item to aPlotter.
Definition: sch_field.cpp:509
bool IsForceVisible() const
Definition: base_struct.h:286
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:147
bool IsPower() const
const wxChar *const traceFindItem
Flag to enable find debug tracing.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
bool Replace(wxFindReplaceData &aSearchData, void *aAuxData=NULL) override
Function Replace performs a text replace using the find and replace criteria in aSearchData on items ...
Definition: sch_field.cpp:360
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:234
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_field.cpp:299
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_field.cpp:169
bool Replace(wxFindReplaceData &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:173
#define _(s)
Definition: 3d_actions.cpp:33
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:221
const BITMAP_OPAQUE edit_comp_footprint_xpm[1]
const wxPoint GetPosition() const override
Definition: sch_field.cpp:579
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:420
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Schematic symbol object.
Definition: sch_component.h:88
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:77
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
wxString ExpandTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aLocalResolver, const PROJECT *aProject)
Expand '${var-name}' templates in text.
Definition: common.cpp:382
wxPoint Centre() const
Definition: eda_rect.h:62
bool IsHorizJustifyFlipped() const
Function IsHorizJustifyFlipped Returns whether the field will be rendered with the horizontal justifi...
Definition: sch_field.cpp:276
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
int GetDefaultPenWidth() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
bool IsReplaceable() const override
Function IsReplaceable.
Definition: sch_field.cpp:335
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:201
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_field.cpp:404
Definition for part library class.
void SetId(int aId)
Definition: sch_field.cpp:76
wxPoint GetParentPosition() const
Definition: sch_field.cpp:595
int m_id
Field index,.
Definition: sch_field.h:54
void SetPosition(const wxPoint &aPosition) override
Set the schematic item position to aPosition.
Definition: sch_field.cpp:558
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:457
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:186
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:133
int GetPenWidth() const override
Definition: sch_field.cpp:163
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
const BITMAP_OPAQUE edit_text_xpm[1]
Definition: edit_text.cpp:59
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99