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 #include <trace_helpers.h>
54 
55 
56 SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, const wxString& aName ) :
57  SCH_ITEM( aParent, SCH_FIELD_T ),
58  EDA_TEXT()
59 {
60  SetTextPos( aPos );
61  m_id = aFieldId;
62  m_name = aName;
63 
64  SetVisible( false );
66 }
67 
68 
70 {
71 }
72 
73 
75 {
76  return new SCH_FIELD( *this );
77 }
78 
79 
80 const wxString SCH_FIELD::GetFullyQualifiedText() const
81 {
82  wxString text = m_Text;
83 
84  /* For more than one part per package, we must add the part selection
85  * A, B, ... or 1, 2, .. to the reference. */
86  if( m_id == REFERENCE )
87  {
88  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
89 
90  wxCHECK_MSG( component != NULL, text,
91  wxT( "No component associated with field" ) + text );
92 
93  if( component->GetUnitCount() > 1 )
94  text << LIB_PART::SubReference( component->GetUnit() );
95  }
96 
97  return text;
98 }
99 
100 
102 {
103  int pensize = GetThickness();
104 
105  if( pensize == 0 ) // Use default values for pen size
106  {
107  if( IsBold() )
108  pensize = GetPenSizeForBold( GetTextWidth() );
109  else
110  pensize = GetDefaultLineThickness();
111  }
112 
113  // Clip pen size for small texts:
114  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
115  return pensize;
116 }
117 
118 
119 void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
120  GR_DRAWMODE aDrawMode, COLOR4D aColor )
121 {
122  int orient;
123  COLOR4D color;
124  wxPoint textpos;
125  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
126  int lineWidth = GetThickness();
127 
128  if( lineWidth == 0 ) // Use default values for pen size
129  {
130  if( IsBold() )
131  lineWidth = GetPenSizeForBold( GetTextWidth() );
132  else
133  lineWidth = GetDefaultLineThickness();
134  }
135 
136  // Clip pen size for small texts:
137  lineWidth = Clamp_Text_PenSize( lineWidth, GetTextSize(), IsBold() );
138 
139  if( ( !IsVisible() && !m_forceVisible) || IsVoid() )
140  return;
141 
142  GRSetDrawMode( aDC, aDrawMode );
143 
144  // Calculate the text orientation according to the component orientation.
145  orient = GetTextAngle();
146 
147  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
148  {
149  if( orient == TEXT_ANGLE_HORIZ )
150  orient = TEXT_ANGLE_VERT;
151  else
152  orient = TEXT_ANGLE_HORIZ;
153  }
154 
155  /* Calculate the text justification, according to the component
156  * orientation/mirror this is a bit complicated due to cumulative
157  * calculations:
158  * - numerous cases (mirrored or not, rotation)
159  * - the DrawGraphicText function recalculate also H and H justifications
160  * according to the text orientation.
161  * - When a component is mirrored, the text is not mirrored and
162  * justifications are complicated to calculate
163  * so the more easily way is to use no justifications ( Centered text )
164  * and use GetBoundaryBox to know the text coordinate considered as centered
165  */
166  EDA_RECT boundaryBox = GetBoundingBox();
167  textpos = boundaryBox.Centre() + aOffset;
168 
169  if( m_forceVisible )
170  {
171  color = COLOR4D( DARKGRAY );
172  }
173  else
174  {
175  if( m_id == REFERENCE )
177  else if( m_id == VALUE )
178  color = GetLayerColor( LAYER_VALUEPART );
179  else
180  color = GetLayerColor( LAYER_FIELDS );
181  }
182 
183  EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
184  DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
186  lineWidth, IsItalic(), IsBold() );
187 
188  // While moving: don't loose visual contact to which component this label belongs.
189  if ( IsWireImage() )
190  {
191  const wxPoint origin = parentComponent->GetPosition();
192  textpos = GetTextPos() - origin;
193  textpos = parentComponent->GetScreenCoord( textpos );
194  textpos += parentComponent->GetPosition();
195  GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY );
196  }
197 
198  /* Enable this to draw the bounding box around the text field to validate
199  * the bounding box calculations.
200  */
201 #if 0
202 
203  // Draw boundary box:
204  GRRect( aPanel->GetClipBox(), aDC, boundaryBox, 0, BROWN );
205 
206  // Draw the text anchor point
207 
208  /* Calculate the text position, according to the component
209  * orientation/mirror */
210  textpos = m_Pos - parentComponent->GetPosition();
211  textpos = parentComponent->GetScreenCoord( textpos );
212  textpos += parentComponent->GetPosition();
213  const int len = 10;
214  GRLine( clipbox, aDC,
215  textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE );
216  GRLine( clipbox, aDC,
217  textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE );
218 #endif
219 }
220 
221 
222 void SCH_FIELD::ImportValues( const LIB_FIELD& aSource )
223 {
224  SetEffects( aSource );
225 }
226 
227 
228 void SCH_FIELD::ExportValues( LIB_FIELD& aDest ) const
229 {
230  aDest.SetId( GetId() );
231  aDest.SetText( m_Text ); // Set field value
232  aDest.SetName( GetName() );
233 
234  aDest.SetEffects( *this );
235 }
236 
237 
239 {
240  wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_FIELD_T),
241  wxT( "Cannot swap field data with invalid item." ) );
242 
243  SCH_FIELD* item = (SCH_FIELD*) aItem;
244 
245  std::swap( m_Text, item->m_Text );
246  std::swap( m_Layer, item->m_Layer );
247 
248  SwapEffects( *item );
249 }
250 
251 
253 {
254  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
255  int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
256 
257  // We must pass the effective text thickness to GetTextBox
258  // when calculating the bounding box
259  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
260 
261  // Calculate the text bounding box:
262  EDA_RECT rect;
263 
264  if( m_id == REFERENCE ) // multi units have one letter or more added to reference
265  {
266  SCH_FIELD text( *this ); // Make a local copy to change text
267  // because GetBoundingBox() is const
268  text.SetText( GetFullyQualifiedText() );
269  rect = text.GetTextBox( -1, linewidth );
270  }
271  else
272  rect = GetTextBox( -1, linewidth );
273 
274  // Calculate the bounding box position relative to the component:
275  wxPoint origin = parentComponent->GetPosition();
276  wxPoint pos = GetTextPos() - origin;
277  wxPoint begin = rect.GetOrigin() - origin;
278  wxPoint end = rect.GetEnd() - origin;
279  RotatePoint( &begin, pos, GetTextAngle() );
280  RotatePoint( &end, pos, GetTextAngle() );
281 
282  // Due to the Y axis direction, we must mirror the bounding box,
283  // relative to the text position:
284  MIRROR( begin.y, pos.y );
285  MIRROR( end.y, pos.y );
286 
287  // Now, apply the component transform (mirror/rot)
288  begin = parentComponent->GetTransform().TransformCoordinate( begin );
289  end = parentComponent->GetTransform().TransformCoordinate( end );
290  rect.SetOrigin( begin);
291  rect.SetEnd( end);
292  rect.Move( origin );
293  rect.Normalize();
294  return rect;
295 }
296 
297 
299 {
300  wxPoint render_center = GetBoundingBox().Centre();
301  wxPoint pos = GetPosition();
302 
303  switch( GetHorizJustify() )
304  {
306  return render_center.x < pos.x;
308  return render_center.x > pos.x;
309  default:
310  return false;
311  }
312 }
313 
314 
315 void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
316 {
317  frame->GetCanvas()->SetMouseCapture( NULL, NULL );
318 
319  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
320 
321  // save old cmp in undo list
322  frame->SaveUndoItemInUndoList( component );
323 
324  Draw( frame->GetCanvas(), DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
325  ClearFlags();
326  frame->GetScreen()->SetCurItem( NULL );
327  frame->OnModify();
328 }
329 
330 
331 bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
332 {
333  bool match;
334  wxString text = GetFullyQualifiedText();
335 
336  // User defined fields have an ID of -1.
337  if( ((m_id > VALUE || m_id < REFERENCE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS))
338  || ((m_id == REFERENCE) && !(aSearchData.GetFlags() & FR_REPLACE_REFERENCES)) )
339  return false;
340 
341  wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() );
342 
343  // Take sheet path into account which effects the reference field and the unit for
344  // components with multiple parts.
345  if( m_id == REFERENCE && aAuxData != NULL )
346  {
347  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
348 
349  wxCHECK_MSG( component != NULL, false, wxT( "No symbol 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 symbol reference field call." ) ) ;
383 
384  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
385 
386  wxCHECK_MSG( component != NULL, false,
387  wxT( "No symbol 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:209
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:91
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:101
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:179
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
SCH_FIELD(const wxPoint &aPos, int aFieldId, SCH_COMPONENT *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:56
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:351
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:74
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:222
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:80
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:411
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:315
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:119
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:219
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:216
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".
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, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
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:451
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1098
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:228
EDA_RECT * GetClipBox()
wxLogTrace helper definitions.
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: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: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: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
const wxChar *const traceFindItem
Flag to enable find debug tracing.
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:252
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_field.cpp:238
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:162
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:265
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_field.cpp:331
bool IsHorizJustifyFlipped() const
Function IsHorizJustifyFlipped Returns whether the field will be rendered with the horizontal justifi...
Definition: sch_field.cpp:298
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:213
Basic classes for most KiCad items.
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:231
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:183
#define VALUE
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: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