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-2017 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 
30 /* Fields are texts attached to a component, having a special meaning
31  * Fields 0 and 1 are very important: reference and value
32  * Field 2 is used as default footprint name.
33  * Field 3 is reserved (not currently used
34  * Fields 4 and more are user fields.
35  * They can be renamed and can appear in reports
36  */
37 
38 #include <fctsys.h>
39 #include <class_drawpanel.h>
40 #include <base_struct.h>
41 #include <gr_basic.h>
42 #include <draw_graphic_text.h>
43 #include <macros.h>
44 #include <sch_edit_frame.h>
45 #include <plotter.h>
46 #include <bitmaps.h>
47 
48 #include <general.h>
49 #include <class_library.h>
50 #include <sch_component.h>
51 #include <sch_field.h>
52 #include <kicad_string.h>
53 
54 
55 SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, const wxString& aName ) :
56  SCH_ITEM( aParent, SCH_FIELD_T ),
57  EDA_TEXT()
58 {
59  SetTextPos( aPos );
60  m_id = aFieldId;
61  m_name = aName;
62 
63  SetVisible( false );
65 }
66 
67 
69 {
70 }
71 
72 
74 {
75  return new SCH_FIELD( *this );
76 }
77 
78 
79 const wxString SCH_FIELD::GetFullyQualifiedText() const
80 {
81  wxString text = m_Text;
82 
83  /* For more than one part per package, we must add the part selection
84  * A, B, ... or 1, 2, .. to the reference. */
85  if( m_id == REFERENCE )
86  {
87  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
88 
89  wxCHECK_MSG( component != NULL, text,
90  wxT( "No component associated with field" ) + text );
91 
92  if( component->GetUnitCount() > 1 )
93  text << LIB_PART::SubReference( component->GetUnit() );
94  }
95 
96  return text;
97 }
98 
99 
101 {
102  int pensize = GetThickness();
103 
104  if( pensize == 0 ) // Use default values for pen size
105  {
106  if( IsBold() )
107  pensize = GetPenSizeForBold( GetTextWidth() );
108  else
109  pensize = GetDefaultLineThickness();
110  }
111 
112  // Clip pen size for small texts:
113  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
114  return pensize;
115 }
116 
117 
118 void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
119  GR_DRAWMODE aDrawMode, COLOR4D aColor )
120 {
121  int orient;
122  COLOR4D color;
123  wxPoint textpos;
124  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
125  int lineWidth = GetThickness();
126 
127  if( lineWidth == 0 ) // Use default values for pen size
128  {
129  if( IsBold() )
130  lineWidth = GetPenSizeForBold( GetTextWidth() );
131  else
132  lineWidth = GetDefaultLineThickness();
133  }
134 
135  // Clip pen size for small texts:
136  lineWidth = Clamp_Text_PenSize( lineWidth, GetTextSize(), IsBold() );
137 
138  if( ( !IsVisible() && !m_forceVisible) || IsVoid() )
139  return;
140 
141  GRSetDrawMode( aDC, aDrawMode );
142 
143  // Calculate the text orientation according to the component orientation.
144  orient = GetTextAngle();
145 
146  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
147  {
148  if( orient == TEXT_ANGLE_HORIZ )
149  orient = TEXT_ANGLE_VERT;
150  else
151  orient = TEXT_ANGLE_HORIZ;
152  }
153 
154  /* Calculate the text justification, according to the component
155  * orientation/mirror this is a bit complicated due to cumulative
156  * calculations:
157  * - numerous cases (mirrored or not, rotation)
158  * - the DrawGraphicText function recalculate also H and H justifications
159  * according to the text orientation.
160  * - When a component is mirrored, the text is not mirrored and
161  * justifications are complicated to calculate
162  * so the more easily way is to use no justifications ( Centered text )
163  * and use GetBoundaryBox to know the text coordinate considered as centered
164  */
165  EDA_RECT boundaryBox = GetBoundingBox();
166  textpos = boundaryBox.Centre() + aOffset;
167 
168  if( m_forceVisible )
169  {
170  color = COLOR4D( DARKGRAY );
171  }
172  else
173  {
174  if( m_id == REFERENCE )
176  else if( m_id == VALUE )
177  color = GetLayerColor( LAYER_VALUEPART );
178  else
179  color = GetLayerColor( LAYER_FIELDS );
180  }
181 
182  EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
183  DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
185  lineWidth, IsItalic(), IsBold() );
186 
187  // While moving: don't loose visual contact to which component this label belongs.
188  if ( IsWireImage() )
189  {
190  const wxPoint origin = parentComponent->GetPosition();
191  textpos = GetTextPos() - origin;
192  textpos = parentComponent->GetScreenCoord( textpos );
193  textpos += parentComponent->GetPosition();
194  GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY );
195  }
196 
197  /* Enable this to draw the bounding box around the text field to validate
198  * the bounding box calculations.
199  */
200 #if 0
201 
202  // Draw boundary box:
203  GRRect( aPanel->GetClipBox(), aDC, boundaryBox, 0, BROWN );
204 
205  // Draw the text anchor point
206 
207  /* Calculate the text position, according to the component
208  * orientation/mirror */
209  textpos = m_Pos - parentComponent->GetPosition();
210  textpos = parentComponent->GetScreenCoord( textpos );
211  textpos += parentComponent->GetPosition();
212  const int len = 10;
213  GRLine( clipbox, aDC,
214  textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE );
215  GRLine( clipbox, aDC,
216  textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE );
217 #endif
218 }
219 
220 
221 void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
222 {
223  SetEffects( aSource );
224 }
225 
226 
227 void SCH_FIELD::ExportValues( LIB_FIELD& aDest ) const
228 {
229  aDest.SetId( GetId() );
230  aDest.SetText( m_Text ); // Set field value
231  aDest.SetName( GetName() );
232 
233  aDest.SetEffects( *this );
234 }
235 
236 
238 {
239  wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_FIELD_T),
240  wxT( "Cannot swap field data with invalid item." ) );
241 
242  SCH_FIELD* item = (SCH_FIELD*) aItem;
243 
244  std::swap( m_Text, item->m_Text );
245  std::swap( m_Layer, item->m_Layer );
246 
247  SwapEffects( *item );
248 }
249 
250 
252 {
253  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
254  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
255 
256  // We must pass the effective text thickness to GetTextBox
257  // when calculating the bounding box
258  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
259 
260  // Calculate the text bounding box:
261  EDA_RECT rect;
262 
263  if( m_id == REFERENCE ) // multi units have one letter or more added to reference
264  {
265  SCH_FIELD text( *this ); // Make a local copy to change text
266  // because GetBoundingBox() is const
267  text.SetText( GetFullyQualifiedText() );
268  rect = text.GetTextBox( -1, linewidth );
269  }
270  else
271  rect = GetTextBox( -1, linewidth );
272 
273  // Calculate the bounding box position relative to the component:
274  wxPoint origin = parentComponent->GetPosition();
275  wxPoint pos = GetTextPos() - origin;
276  wxPoint begin = rect.GetOrigin() - origin;
277  wxPoint end = rect.GetEnd() - origin;
278  RotatePoint( &begin, pos, GetTextAngle() );
279  RotatePoint( &end, pos, GetTextAngle() );
280 
281  // Due to the Y axis direction, we must mirror the bounding box,
282  // relative to the text position:
283  MIRROR( begin.y, pos.y );
284  MIRROR( end.y, pos.y );
285 
286  // Now, apply the component transform (mirror/rot)
287  begin = parentComponent->GetTransform().TransformCoordinate( begin );
288  end = parentComponent->GetTransform().TransformCoordinate( end );
289  rect.SetOrigin( begin);
290  rect.SetEnd( end);
291  rect.Move( origin );
292  rect.Normalize();
293  return rect;
294 }
295 
296 
298 {
299  wxPoint render_center = GetBoundingBox().Centre();
300  wxPoint pos = GetPosition();
301 
302  switch( GetHorizJustify() )
303  {
305  return render_center.x < pos.x;
307  return render_center.x > pos.x;
308  default:
309  return false;
310  }
311 }
312 
313 
314 void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
315 {
316  frame->GetCanvas()->SetMouseCapture( NULL, NULL );
317 
318  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
319 
320  // save old cmp in undo list
321  frame->SaveUndoItemInUndoList( component );
322 
323  Draw( frame->GetCanvas(), DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
324  ClearFlags();
325  frame->GetScreen()->SetCurItem( NULL );
326  frame->OnModify();
327 }
328 
329 
330 bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
331 {
332  bool match;
333  wxString text = GetFullyQualifiedText();
334 
335  // User defined fields have an ID of -1.
336  if( ((m_id > VALUE || m_id < REFERENCE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS))
337  || ((m_id == REFERENCE) && !(aSearchData.GetFlags() & FR_REPLACE_REFERENCES)) )
338  return false;
339 
340  wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() );
341 
342  // Take sheet path into account which effects the reference field and the unit for
343  // components with multiple parts.
344  if( m_id == REFERENCE && aAuxData != NULL )
345  {
346  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
347 
348  wxCHECK_MSG( component != NULL, false, wxT( "No symbol associated with field" ) + text );
349 
350  text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
351 
352  if( component->GetUnitCount() > 1 )
353  text << LIB_PART::SubReference( component->GetUnit() );
354  }
355 
356  match = SCH_ITEM::Matches( text, aSearchData );
357 
358  if( match )
359  {
360  if( aFindLocation )
361  *aFindLocation = GetBoundingBox().Centre();
362 
363  return true;
364  }
365 
366  return false;
367 }
368 
369 
370 bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
371 {
372  bool isReplaced;
373  wxString text = GetFullyQualifiedText();
374 
375  if( m_id == REFERENCE )
376  {
377  wxCHECK_MSG( aAuxData != NULL, false,
378  wxT( "Cannot replace reference designator without valid sheet path." ) );
379 
380  wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
381  wxT( "Invalid replace symbol reference field call." ) ) ;
382 
383  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
384 
385  wxCHECK_MSG( component != NULL, false,
386  wxT( "No symbol associated with field" ) + text );
387 
388  text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
389 
390  // if( component->GetUnitCount() > 1 )
391  // text << LIB_PART::SubReference( component->GetUnit() );
392 
393  isReplaced = EDA_ITEM::Replace( aSearchData, text );
394 
395  if( isReplaced )
396  component->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
397  }
398  else
399  {
400  isReplaced = EDA_ITEM::Replace( aSearchData, m_Text );
401  }
402 
403  return isReplaced;
404 }
405 
406 
407 void SCH_FIELD::Rotate( wxPoint aPosition )
408 {
409  wxPoint pt = GetTextPos();
410  RotatePoint( &pt, aPosition, 900 );
411  SetTextPos( pt );
412 }
413 
414 
416 {
417  wxString tmp;
418  tmp.Printf( _( "Field %s" ), GetChars( GetName() ) );
419 
420  return tmp;
421 }
422 
423 
424 wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
425 {
426  if( !m_name.IsEmpty() )
427  return m_name;
428  else if( aUseDefaultName )
430 
431  return wxEmptyString;
432 }
433 
434 
436 {
437  if( m_id == REFERENCE )
438  return edit_comp_ref_xpm;
439 
440  if( m_id == VALUE )
441  return edit_comp_value_xpm;
442 
443  if( m_id == FOOTPRINT )
444  return edit_comp_footprint_xpm;
445 
446  return edit_text_xpm;
447 }
448 
449 
450 bool SCH_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
451 {
452  // Do not hit test hidden or empty fields.
453  if( !IsVisible() || IsVoid() )
454  return false;
455 
456  EDA_RECT rect = GetBoundingBox();
457 
458  rect.Inflate( aAccuracy );
459 
460  return rect.Contains( aPosition );
461 }
462 
463 
464 bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
465 {
466  // Do not hit test hidden fields.
467  if( !IsVisible() || IsVoid() )
468  return false;
469 
470  EDA_RECT rect = aRect;
471 
472  rect.Inflate( aAccuracy );
473 
474  if( aContained )
475  return rect.Contains( GetBoundingBox() );
476 
477  return rect.Intersects( GetBoundingBox() );
478 }
479 
480 
481 void SCH_FIELD::Plot( PLOTTER* aPlotter )
482 {
483  SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
484 
485  wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
486  wxT( "Cannot plot field with invalid parent." ) );
487 
489 
490  if( !IsVisible() )
491  return;
492 
493  if( IsVoid() )
494  return;
495 
496  /* Calculate the text orientation, according to the component
497  * orientation/mirror */
498  int orient = GetTextAngle();
499 
500  if( parent->GetTransform().y1 ) // Rotate component 90 deg.
501  {
502  if( orient == TEXT_ANGLE_HORIZ )
503  orient = TEXT_ANGLE_VERT;
504  else
505  orient = TEXT_ANGLE_HORIZ;
506  }
507 
508  /* Calculate the text justification, according to the component
509  * orientation/mirror
510  * this is a bit complicated due to cumulative calculations:
511  * - numerous cases (mirrored or not, rotation)
512  * - the DrawGraphicText function recalculate also H and H justifications
513  * according to the text orientation.
514  * - When a component is mirrored, the text is not mirrored and
515  * justifications are complicated to calculate
516  * so the more easily way is to use no justifications ( Centered text )
517  * and use GetBoundaryBox to know the text coordinate considered as centered
518  */
519  EDA_RECT BoundaryBox = GetBoundingBox();
522  wxPoint textpos = BoundaryBox.Centre();
523 
524  int thickness = GetPenSize();
525 
526  aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
527  hjustify, vjustify,
528  thickness, IsItalic(), IsBold() );
529 }
530 
531 
532 void SCH_FIELD::SetPosition( const wxPoint& aPosition )
533 {
534  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
535 
536  wxPoint pos = ( (SCH_COMPONENT*) GetParent() )->GetPosition();
537 
538  // Actual positions are calculated by the rotation/mirror transform of the
539  // parent component of the field. The inverse transfrom is used to calculate
540  // the position relative to the parent component.
541  wxPoint pt = aPosition - pos;
542 
543  SetTextPos( pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ) );
544 }
545 
546 
548 {
549  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
550 
551  wxPoint pos = GetTextPos() - component->GetPosition();
552 
553  return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition();
554 }
Definition: colors.h:57
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
#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
Class SCH_FIELD instances are attached to a component and provide a place for the component&#39;s value...
Definition: sch_field.h:56
SCH_LAYER_ID m_Layer
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_field.cpp:100
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...
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:197
void SwapEffects(EDA_TEXT &aTradingPartner)
Function SwapEffects swaps the text effects of the two involved instances.
Definition: eda_text.cpp:61
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:424
SCH_FIELD(const wxPoint &aPos, int aFieldId, SCH_COMPONENT *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:55
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
wxString m_Text
Definition: eda_text.h:344
TRANSFORM & GetTransform() const
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
PNG memory record (file in memory).
Definition: bitmap_types.h:41
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
bool IsItalic() const
Definition: eda_text.h:168
bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:342
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
bool Contains(const wxPoint &aPoint) const
Function Contains.
int GetId() const
Definition: sch_field.h:87
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_field.cpp:73
wxPoint GetScreenCoord(const wxPoint &aPoint)
Returns the coordinate points relative to the orientation of the symbol to aPoint.
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:221
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:79
void SetEffects(const EDA_TEXT &aSrc)
Function SetEffects sets the text effects from another instance.
Definition: eda_text.cpp:55
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_field.cpp:547
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:429
int color
Definition: DXF_plotter.cpp:62
Field object used in symbol libraries.
Definition: lib_field.h:59
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...
void Place(SCH_EDIT_FRAME *frame, wxDC *DC)
Definition: sch_field.cpp:314
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_field.cpp:118
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
void SetVisible(bool aVisible)
Definition: eda_text.h:173
EDA_ITEM * GetParent() const
Definition: base_struct.h:237
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.h:116
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
Schematic editor (Eeschema) main window.
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
int GetUnitCount() const
Return the number of units per package of the symbol.
Search all fields in component, not just the value and reference fields.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:482
wxString m_name
Definition: sch_field.h:60
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:188
#define TEXT_ANGLE_VERT
Definition: common.h:92
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
double GetTextAngle() const
Definition: eda_text.h:162
bool IsBold() const
Definition: eda_text.h:171
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
void SaveUndoItemInUndoList(SCH_ITEM *aItem)
Swap the cloned item in member variable m_undoItem with aItem and saves it to the undo list then swap...
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.
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:112
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
int y1
Definition: transform.h:49
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
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_field.cpp:450
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1098
const wxString traceFindItem
Flag to enable finding schematic item debug output.
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:102
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:502
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
void SetEnd(int x, int y)
Definition: eda_rect.h:134
void SetLayer(SCH_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void ExportValues(LIB_FIELD &aDest) const
Function ImportValues copy parameters into a LIB_FIELD destination.
Definition: sch_field.cpp:227
EDA_RECT * GetClipBox()
int GetUnit() const
Class SCH_SHEET_PATH.
wxPoint Centre() const
Definition: eda_rect.h:60
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_field.cpp:435
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:380
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
const wxPoint GetEnd() const
Definition: eda_rect.h:114
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
void Normalize()
Function Normalize ensures that the height ant width are positive.
Base plotter engine class.
Definition: plotter.h:96
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
Definition the SCH_COMPONENT class for Eeschema.
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_field.cpp:481
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
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:370
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_field.cpp:251
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:237
bool IsVisible() const
Definition: eda_text.h:174
Used by replace to ignore the component reference designator field.
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:182
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
wxPoint GetPosition() const override
Function GetPosition.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:180
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_field.cpp:415
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_field.cpp:330
bool IsHorizJustifyFlipped() const
Function IsHorizJustifyFlipped Returns whether the field will be rendered with the horizontal justifi...
Definition: sch_field.cpp:297
void DrawGraphicText(EDA_RECT *aClipBox, 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), PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_field.cpp:407
const wxSize & GetTextSize() const
Definition: eda_text.h:213
Basic classes for most KiCad items.
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:249
Definition of the SCH_FIELD class for Eeschema.
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
int m_id
Field index,.
Definition: sch_field.h:58
bool m_forceVisible
Set to true to override the visibility setting of the item.
Definition: base_struct.h:201
#define VALUE
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_field.cpp:532
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void SetId(int aId)
Definition: lib_field.h:140
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:58
virtual void SetText(const wxString &aText)
Definition: eda_text.h:139
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62