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 <drawtxt.h>
43 #include <macros.h>
44 #include <schframe.h>
45 #include <class_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, 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,
349  wxT( "No component associated with field" ) + text );
350 
351  text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
352 
353  if( component->GetUnitCount() > 1 )
354  text << LIB_PART::SubReference( component->GetUnit() );
355  }
356 
357  match = SCH_ITEM::Matches( text, aSearchData );
358 
359  if( match )
360  {
361  if( aFindLocation )
362  *aFindLocation = GetBoundingBox().Centre();
363 
364  return true;
365  }
366 
367  return false;
368 }
369 
370 
371 bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
372 {
373  bool isReplaced;
374  wxString text = GetFullyQualifiedText();
375 
376  if( m_id == REFERENCE )
377  {
378  wxCHECK_MSG( aAuxData != NULL, false,
379  wxT( "Cannot replace reference designator without valid sheet path." ) );
380 
381  wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
382  wxT( "Invalid replace component reference field call." ) ) ;
383 
384  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
385 
386  wxCHECK_MSG( component != NULL, false,
387  wxT( "No component associated with field" ) + text );
388 
389  text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
390 
391  // if( component->GetUnitCount() > 1 )
392  // text << LIB_PART::SubReference( component->GetUnit() );
393 
394  isReplaced = EDA_ITEM::Replace( aSearchData, text );
395 
396  if( isReplaced )
397  component->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
398  }
399  else
400  {
401  isReplaced = EDA_ITEM::Replace( aSearchData, m_Text );
402  }
403 
404  return isReplaced;
405 }
406 
407 
408 void SCH_FIELD::Rotate( wxPoint aPosition )
409 {
410  wxPoint pt = GetTextPos();
411  RotatePoint( &pt, aPosition, 900 );
412  SetTextPos( pt );
413 }
414 
415 
417 {
418  wxString tmp;
419  tmp.Printf( _( "Field %s" ), GetChars( GetName() ) );
420 
421  return tmp;
422 }
423 
424 
425 wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
426 {
427  if( !m_name.IsEmpty() )
428  return m_name;
429  else if( aUseDefaultName )
431 
432  return wxEmptyString;
433 }
434 
435 
437 {
438  if( m_id == REFERENCE )
439  return edit_comp_ref_xpm;
440 
441  if( m_id == VALUE )
442  return edit_comp_value_xpm;
443 
444  if( m_id == FOOTPRINT )
445  return edit_comp_footprint_xpm;
446 
447  return edit_text_xpm;
448 }
449 
450 
451 bool SCH_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
452 {
453  // Do not hit test hidden or empty fields.
454  if( !IsVisible() || IsVoid() )
455  return false;
456 
457  EDA_RECT rect = GetBoundingBox();
458 
459  rect.Inflate( aAccuracy );
460 
461  return rect.Contains( aPosition );
462 }
463 
464 
465 bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
466 {
467  // Do not hit test hidden fields.
468  if( !IsVisible() || IsVoid() )
469  return false;
470 
471  EDA_RECT rect = aRect;
472 
473  rect.Inflate( aAccuracy );
474 
475  if( aContained )
476  return rect.Contains( GetBoundingBox() );
477 
478  return rect.Intersects( GetBoundingBox() );
479 }
480 
481 
482 void SCH_FIELD::Plot( PLOTTER* aPlotter )
483 {
484  SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
485 
486  wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
487  wxT( "Cannot plot field with invalid parent." ) );
488 
490 
491  if( !IsVisible() )
492  return;
493 
494  if( IsVoid() )
495  return;
496 
497  /* Calculate the text orientation, according to the component
498  * orientation/mirror */
499  int orient = GetTextAngle();
500 
501  if( parent->GetTransform().y1 ) // Rotate component 90 deg.
502  {
503  if( orient == TEXT_ANGLE_HORIZ )
504  orient = TEXT_ANGLE_VERT;
505  else
506  orient = TEXT_ANGLE_HORIZ;
507  }
508 
509  /* Calculate the text justification, according to the component
510  * orientation/mirror
511  * this is a bit complicated due to cumulative calculations:
512  * - numerous cases (mirrored or not, rotation)
513  * - the DrawGraphicText function recalculate also H and H justifications
514  * according to the text orientation.
515  * - When a component is mirrored, the text is not mirrored and
516  * justifications are complicated to calculate
517  * so the more easily way is to use no justifications ( Centered text )
518  * and use GetBoundaryBox to know the text coordinate considered as centered
519  */
520  EDA_RECT BoundaryBox = GetBoundingBox();
523  wxPoint textpos = BoundaryBox.Centre();
524 
525  int thickness = GetPenSize();
526 
527  aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
528  hjustify, vjustify,
529  thickness, IsItalic(), IsBold() );
530 }
531 
532 
533 void SCH_FIELD::SetPosition( const wxPoint& aPosition )
534 {
535  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
536 
537  wxPoint pos = ( (SCH_COMPONENT*) GetParent() )->GetPosition();
538 
539  // Actual positions are calculated by the rotation/mirror transform of the
540  // parent component of the field. The inverse transfrom is used to calculate
541  // the position relative to the parent component.
542  wxPoint pt = aPosition - pos;
543 
544  SetTextPos( pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ) );
545 }
546 
547 
549 {
550  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
551 
552  wxPoint pos = GetTextPos() - component->GetPosition();
553 
554  return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition();
555 }
Definition: colors.h:57
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:90
Class SCH_FIELD instances are attached to a component and provide a place for the component'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
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)
Definition: drawtxt.cpp:122
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:182
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:425
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
wxString m_Text
Definition: eda_text.h:346
TRANSFORM & GetTransform() const
PNG memory record (file in memory).
Definition: bitmap_types.h:38
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:296
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
bool IsItalic() const
Definition: eda_text.h:170
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:337
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
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:548
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:414
Class LIB_FIELD is used in symbol libraries.
Definition: lib_field.h:60
int GetTextWidth() const
Definition: eda_text.h:218
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i...
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:223
void SetVisible(bool aVisible)
Definition: eda_text.h:175
EDA_ITEM * GetParent() const
Definition: base_struct.h:222
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)
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.
Definition: schframe.h:118
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)
Function SetName.
Definition: lib_field.cpp:655
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:190
#define TEXT_ANGLE_VERT
Definition: common.h:91
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
double GetTextAngle() const
Definition: eda_text.h:164
bool IsBold() const
Definition: eda_text.h:173
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
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...
Definition: schframe.cpp:609
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: drawtxt.cpp:229
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:114
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.
Definition: schframe.cpp:532
const wxPoint & GetOrigin() const
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:451
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1076
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
SCH_FIELD(const wxPoint &aPos, int aFieldId, SCH_COMPONENT *aParent, wxString aName=wxEmptyString)
Definition: sch_field.cpp:55
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:675
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
void SetEnd(int x, int y)
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
Definition: drawtxt.cpp:67
void 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
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_field.cpp:436
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:358
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
const wxPoint GetEnd() const
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
void Normalize()
Function Normalize ensures that the height ant width are positive.
Field Value of part, i.e. "3.3K".
Base plotter engine class.
Definition: class_plotter.h:97
#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.
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: drawtxt.cpp:49
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_field.cpp:482
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:371
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:176
Used by replace to ignore the component reference designator field.
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Class EDA_RECT handles the component boundary box.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Function SubReference.
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:165
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_field.cpp:416
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
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
This file is part of the common libary.
bool IsHorizJustifyFlipped() const
Function IsHorizJustifyFlipped Returns whether the field will be rendered with the horizontal justifi...
Definition: sch_field.cpp:297
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_field.cpp:408
const wxSize & GetTextSize() const
Definition: eda_text.h:215
Basic classes for most KiCad items.
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:234
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:186
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_field.cpp:533
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:138
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:141
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62