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-2019 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 <sch_draw_panel.h>
35 #include <base_struct.h>
36 #include <gr_basic.h>
37 #include <gr_text.h>
38 #include <macros.h>
39 #include <sch_edit_frame.h>
40 #include <plotter.h>
41 #include <bitmaps.h>
42 
43 #include <general.h>
44 #include <class_library.h>
45 #include <sch_component.h>
46 #include <sch_field.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, const wxString& aName ) :
53  SCH_ITEM( aParent, SCH_FIELD_T ),
54  EDA_TEXT()
55 {
56  SetTextPos( aPos );
57  m_id = aFieldId;
58  m_name = aName;
59 
60  SetVisible( false );
62 }
63 
64 
66 {
67 }
68 
69 
71 {
72  return new SCH_FIELD( *this );
73 }
74 
75 
76 const wxString SCH_FIELD::GetFullyQualifiedText() const
77 {
78  wxString text = GetText();
79 
80  // Note that the IDs of FIELDS and SHEETS overlap, so one must check *both* the
81  // id and the parent's type.
82 
83  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
84  {
85  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( m_Parent );
86 
87  if( m_id == REFERENCE )
88  {
89  // For more than one part per package, we must add the part selection
90  // A, B, ... or 1, 2, .. to the reference.
91  if( component->GetUnitCount() > 1 )
92  text << LIB_PART::SubReference( component->GetUnit() );
93  }
94  }
95 
96  if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
97  {
98  if( m_id == SHEETFILENAME )
99  text = _( "File: " ) + text;
100  }
101 
102  return text;
103 }
104 
105 
107 {
108  int pensize = GetThickness();
109 
110  if( pensize == 0 ) // Use default values for pen size
111  {
112  if( IsBold() )
113  pensize = GetPenSizeForBold( GetTextWidth() );
114  else
115  pensize = GetDefaultLineThickness();
116  }
117 
118  // Clip pen size for small texts:
119  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
120  return pensize;
121 }
122 
123 
124 void SCH_FIELD::Print( wxDC* aDC, const wxPoint& aOffset )
125 {
126  int orient;
127  COLOR4D color;
128  wxPoint textpos;
129  int lineWidth = GetThickness();
130 
131  if( lineWidth == 0 ) // Use default values for pen size
132  {
133  if( IsBold() )
134  lineWidth = GetPenSizeForBold( GetTextWidth() );
135  else
136  lineWidth = GetDefaultLineThickness();
137  }
138 
139  // Clip pen size for small texts:
140  lineWidth = Clamp_Text_PenSize( lineWidth, GetTextSize(), IsBold() );
141 
142  if( ( !IsVisible() && !m_forceVisible) || IsVoid() )
143  return;
144 
145  // Calculate the text orientation according to the component orientation.
146  orient = GetTextAngle();
147 
148  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
149  {
150  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
151 
152  if( parentComponent && parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
153  {
154  if( orient == TEXT_ANGLE_HORIZ )
155  orient = TEXT_ANGLE_VERT;
156  else
157  orient = TEXT_ANGLE_HORIZ;
158  }
159  }
160 
161  /* Calculate the text justification, according to the component
162  * orientation/mirror this is a bit complicated due to cumulative
163  * calculations:
164  * - numerous cases (mirrored or not, rotation)
165  * - the DrawGraphicText function recalculate also H and H justifications
166  * according to the text orientation.
167  * - When a component is mirrored, the text is not mirrored and
168  * justifications are complicated to calculate
169  * so the more easily way is to use no justifications ( Centered text )
170  * and use GetBoundaryBox to know the text coordinate considered as centered
171  */
172  EDA_RECT boundaryBox = GetBoundingBox();
173  textpos = boundaryBox.Centre() + aOffset;
174 
175  if( m_forceVisible )
176  color = COLOR4D( DARKGRAY );
177  else
179 
180  GRText( aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
182 }
183 
184 
185 void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
186 {
187  SetEffects( aSource );
188 }
189 
190 
192 {
193  wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_FIELD_T),
194  wxT( "Cannot swap field data with invalid item." ) );
195 
196  SCH_FIELD* item = (SCH_FIELD*) aItem;
197 
198  std::swap( m_Layer, item->m_Layer );
199  SwapText( *item );
200  SwapEffects( *item );
201 }
202 
203 
205 {
206  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
207 
208  // We must pass the effective text thickness to GetTextBox
209  // when calculating the bounding box
210  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
211 
212  // Calculate the text bounding box:
213  EDA_RECT rect;
214  SCH_FIELD text( *this ); // Make a local copy to change text
215  // because GetBoundingBox() is const
216  text.SetText( GetFullyQualifiedText() );
217  rect = text.GetTextBox( -1, linewidth, false, GetTextMarkupFlags() );
218 
219  // Calculate the bounding box position relative to the parent:
220  wxPoint origin = GetParentPosition();
221  wxPoint pos = GetTextPos() - origin;
222  wxPoint begin = rect.GetOrigin() - origin;
223  wxPoint end = rect.GetEnd() - origin;
224  RotatePoint( &begin, pos, GetTextAngle() );
225  RotatePoint( &end, pos, GetTextAngle() );
226 
227  // Now, apply the component transform (mirror/rot)
228  TRANSFORM transform;
229 
230  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
231  {
232  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
233 
234  // Due to the Y axis direction, we must mirror the bounding box,
235  // relative to the text position:
236  MIRROR( begin.y, pos.y );
237  MIRROR( end.y, pos.y );
238 
239  transform = parentComponent->GetTransform();
240  }
241  else
242  {
243  transform = TRANSFORM( 1, 0, 0, 1 ); // identity transform
244  }
245 
246  rect.SetOrigin( transform.TransformCoordinate( begin ) );
247  rect.SetEnd( transform.TransformCoordinate( end ) );
248 
249  rect.Move( origin );
250  rect.Normalize();
251 
252  return rect;
253 }
254 
255 
257 {
258  wxPoint render_center = GetBoundingBox().Centre();
259  wxPoint pos = GetPosition();
260 
261  switch( GetHorizJustify() )
262  {
264  return render_center.x < pos.x;
266  return render_center.x > pos.x;
267  default:
268  return false;
269  }
270 }
271 
272 
273 bool SCH_FIELD::IsVoid() const
274 {
275  return GetText().Len() == 0;
276 }
277 
278 
279 bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
280 {
281  wxString text = GetFullyQualifiedText();
282  int flags = aSearchData.GetFlags();
283  bool searchUserDefinedFields = flags & FR_SEARCH_ALL_FIELDS;
284  bool searchAndReplace = flags & FR_SEARCH_REPLACE;
285  bool replaceReferences = flags & FR_REPLACE_REFERENCES;
286 
287  wxLogTrace( traceFindItem, wxT( " child item " )
289 
290  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
291  {
292  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
293 
294  if( !searchUserDefinedFields && m_id >= MANDATORY_FIELDS )
295  return false;
296 
297  if( searchAndReplace && m_id == REFERENCE && !replaceReferences )
298  return false;
299 
300  // Take sheet path into account which effects the reference field and the unit for
301  // components with multiple parts.
302  if( m_id == REFERENCE && aAuxData != NULL )
303  {
304  text = parentComponent->GetRef( (SCH_SHEET_PATH*) aAuxData );
305 
306  if( parentComponent->GetUnitCount() > 1 )
307  text << LIB_PART::SubReference( parentComponent->GetUnit() );
308  }
309  }
310  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
311  {
312  if( !searchUserDefinedFields && m_id >= SHEET_MANDATORY_FIELDS )
313  return false;
314  }
315 
316  return SCH_ITEM::Matches( text, aSearchData );
317 }
318 
319 
321 {
322  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
323  {
324  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
325 
326  if( m_id == VALUE )
327  {
328  LIB_PART* part = parentComponent->GetPartRef().get();
329 
330  if( part && part->IsPower() )
331  return false;
332  }
333  }
334  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
335  {
336  // See comments in SCH_FIELD::Replace(), below.
337  if( m_id == SHEETFILENAME )
338  return false;
339  }
340 
341  return true;
342 }
343 
344 
345 bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
346 {
347  bool isReplaced = false;
348 
349  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T && m_id == REFERENCE )
350  {
351  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
352 
353  if( m_id == REFERENCE )
354  {
355  wxCHECK_MSG( aAuxData != NULL, false,
356  wxT( "Cannot replace reference designator without valid sheet path." ) );
357 
358  wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
359  wxT( "Invalid replace symbol reference field call." ) ) ;
360 
361  wxString text = parentComponent->GetRef( (SCH_SHEET_PATH*) aAuxData );
362 
363  isReplaced = EDA_ITEM::Replace( aSearchData, text );
364 
365  if( isReplaced )
366  parentComponent->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
367  }
368  else
369  {
370  isReplaced = EDA_TEXT::Replace( aSearchData );
371  }
372  }
373  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
374  {
375  isReplaced = EDA_TEXT::Replace( aSearchData );
376 
377  if( m_id == SHEETFILENAME && isReplaced )
378  {
379  // If we allowed this we'd have a bunch of work to do here, including warning
380  // about it not being undoable, checking for recursive hierarchies, reloading
381  // sheets, etc. See DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow().
382  }
383  }
384 
385  return isReplaced;
386 }
387 
388 
389 void SCH_FIELD::Rotate( wxPoint aPosition )
390 {
391  wxPoint pt = GetTextPos();
392  RotatePoint( &pt, aPosition, 900 );
393  SetTextPos( pt );
394 }
395 
396 
397 wxString SCH_FIELD::GetSelectMenuText( EDA_UNITS aUnits ) const
398 {
399  return wxString::Format( _( "Field %s" ), GetName() );
400 }
401 
402 
403 wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
404 {
405  if( !m_name.IsEmpty() )
406  return m_name;
407  else if( aUseDefaultName )
408  {
409  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
411  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
413  }
414 
415  return wxEmptyString;
416 }
417 
418 
420 {
421  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
422  {
423  switch( m_id )
424  {
425  case REFERENCE: return edit_comp_ref_xpm;
426  case VALUE: return edit_comp_value_xpm;
427  case FOOTPRINT: return edit_comp_footprint_xpm;
428  default: return edit_text_xpm;
429  }
430  }
431 
432  return edit_text_xpm;
433 }
434 
435 
436 bool SCH_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
437 {
438  // Do not hit test hidden or empty fields.
439  if( !IsVisible() || IsVoid() )
440  return false;
441 
442  EDA_RECT rect = GetBoundingBox();
443 
444  rect.Inflate( aAccuracy );
445 
446  return rect.Contains( aPosition );
447 }
448 
449 
450 bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
451 {
452  // Do not hit test hidden fields.
453  if( !IsVisible() || IsVoid() )
454  return false;
455 
456  EDA_RECT rect = aRect;
457 
458  rect.Inflate( aAccuracy );
459 
460  if( aContained )
461  return rect.Contains( GetBoundingBox() );
462 
463  return rect.Intersects( GetBoundingBox() );
464 }
465 
466 
467 void SCH_FIELD::Plot( PLOTTER* aPlotter )
468 {
469  COLOR4D color = aPlotter->ColorSettings()->GetColor( GetLayer() );
470 
471  if( !IsVisible() )
472  return;
473 
474  if( IsVoid() )
475  return;
476 
477  /* Calculate the text orientation, according to the component
478  * orientation/mirror */
479  int orient = GetTextAngle();
480 
481  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
482  {
483  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
484 
485  if( parentComponent->GetTransform().y1 ) // Rotate component 90 deg.
486  {
487  if( orient == TEXT_ANGLE_HORIZ )
488  orient = TEXT_ANGLE_VERT;
489  else
490  orient = TEXT_ANGLE_HORIZ;
491  }
492  }
493 
494  /* Calculate the text justification, according to the component
495  * orientation/mirror
496  * this is a bit complicated due to cumulative calculations:
497  * - numerous cases (mirrored or not, rotation)
498  * - the DrawGraphicText function recalculate also H and H justifications
499  * according to the text orientation.
500  * - When a component is mirrored, the text is not mirrored and
501  * justifications are complicated to calculate
502  * so the more easily way is to use no justifications ( Centered text )
503  * and use GetBoundaryBox to know the text coordinate considered as centered
504  */
505  EDA_RECT BoundaryBox = GetBoundingBox();
508  wxPoint textpos = BoundaryBox.Centre();
509 
510  int thickness = GetPenSize();
511 
512  aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
513  hjustify, vjustify,
514  thickness, IsItalic(), IsBold() );
515 }
516 
517 
518 void SCH_FIELD::SetPosition( const wxPoint& aPosition )
519 {
520  // Actual positions are calculated by the rotation/mirror transform of the
521  // parent component of the field. The inverse transform is used to calculate
522  // the position relative to the parent component.
523  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
524  {
525  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
526  wxPoint relativePos = aPosition - parentComponent->GetPosition();
527 
528  parentComponent->GetTransform().InverseTransform().TransformCoordinate( relativePos );
529 
530  SetTextPos( relativePos + parentComponent->GetPosition() );
531  }
532 
533  SetTextPos( aPosition );
534 }
535 
536 
538 {
539  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
540  {
541  SCH_COMPONENT* parentComponent = static_cast<SCH_COMPONENT*>( m_Parent );
542  wxPoint relativePos = GetTextPos() - parentComponent->GetPosition();
543 
544  parentComponent->GetTransform().TransformCoordinate( relativePos );
545 
546  return relativePos + parentComponent->GetPosition();
547  }
548 
549  return GetTextPos();
550 }
551 
552 
554 {
555  if( m_Parent && m_Parent->Type() == SCH_COMPONENT_T )
556  return static_cast<SCH_COMPONENT*>( m_Parent )->GetPosition();
557  else if( m_Parent && m_Parent->Type() == SCH_SHEET_T )
558  return static_cast<SCH_SHEET*>( m_Parent )->GetPosition();
559  else
560  return wxPoint();
561 }
562 
563 
564 bool SCH_FIELD::operator <( const SCH_ITEM& aItem ) const
565 {
566  if( Type() != aItem.Type() )
567  return Type() < aItem.Type();
568 
569  auto field = static_cast<const SCH_FIELD*>( &aItem );
570 
571  if( GetId() != field->GetId() )
572  return GetId() < field->GetId();
573 
574  if( GetText() != field->GetText() )
575  return GetText() < field->GetText();
576 
577  if( GetLibPosition().x != field->GetLibPosition().x )
578  return GetLibPosition().x < field->GetLibPosition().x;
579 
580  if( GetLibPosition().y != field->GetLibPosition().y )
581  return GetLibPosition().y < field->GetLibPosition().y;
582 
583  return GetName() < field->GetName();
584 }
#define TEXT_ANGLE_HORIZ
EDA_UNITS
Definition: common.h:184
bool IsBold() const
Definition: eda_text.h:167
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:152
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_field.cpp:106
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:183
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
Definition: eda_text.cpp:138
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:44
PNG memory record (file in memory).
Definition: bitmap_def.h:29
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: gr_text.cpp:66
#define TEXT_ANGLE_VERT
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:70
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:170
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:185
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
Definition: eda_text.cpp:125
const BITMAP_OPAQUE edit_comp_value_xpm[1]
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_field.cpp:537
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
int color
Definition: DXF_plotter.cpp:61
Field object used in symbol libraries.
Definition: lib_field.h:59
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:59
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:231
int GetUnitCount() const
Return the number of units per package of the symbol.
void SetVisible(bool aVisible)
Definition: eda_text.h:169
double GetTextAngle() const
Definition: eda_text.h:158
int GetId() const
Definition: sch_field.h:108
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
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:397
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
wxString m_name
Definition: sch_field.h:56
Field Reference of part, i.e. "IC21".
bool Contains(const wxPoint &aPoint) const
Function Contains.
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:273
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
This file contains miscellaneous commonly used macros and functions.
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:232
bool IsItalic() const
Definition: eda_text.h:164
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:109
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_field.cpp:564
int y1
Definition: transform.h:49
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:123
const wxPoint GetEnd() const
Definition: eda_rect.h:116
#define VALUE
int GetTextMarkupFlags()
Definition: gr_text.cpp:55
int GetUnit() const
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:81
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:183
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
#define NULL
COLOR_SETTINGS * ColorSettings()
Definition: plotter.h:145
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
TRANSFORM & GetTransform() const
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:184
void SetEnd(int x, int y)
Definition: eda_rect.h:192
const wxSize & GetTextSize() const
Definition: eda_text.h:223
void SetLayer(SCH_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Definition: sch_item.h:231
Define a library symbol object.
SCH_FIELD(const wxPoint &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:52
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper for all the old plotting/printing code while it still exists.
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:436
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:43
wxPoint GetLibPosition() const
Definition: sch_field.h:190
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:419
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
Definition: sch_field.cpp:124
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:143
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:51
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:224
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:104
COLOR4D GetColor(int aLayer) const
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:131
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_field.cpp:467
int GetTextWidth() const
Definition: eda_text.h:226
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:345
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:204
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_field.cpp:279
bool Replace(wxFindReplaceData &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:144
#define _(s)
Definition: 3d_actions.cpp:33
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:191
const BITMAP_OPAQUE edit_comp_footprint_xpm[1]
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:403
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static wxString SubReference(int aUnit, bool aAddSeparator=true)
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:76
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
wxPoint GetPosition() const override
Function GetPosition.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
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:256
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
bool IsReplaceable() const override
Function IsReplaceable.
Definition: sch_field.cpp:320
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_field.cpp:389
Definition for part library class.
wxPoint GetParentPosition() const
Definition: sch_field.cpp:553
int m_id
Field index,.
Definition: sch_field.h:54
bool m_forceVisible
Set to true to override the visibility setting of the item.
Definition: base_struct.h:186
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_field.cpp:518
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:473
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
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:212
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:40