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 <sch_draw_panel.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( MILLIMETRES ) );
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 
372 {
373  if( m_id != VALUE )
374  return true;
375 
376  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( GetParent() );
377  LIB_PART* part = component ? component->GetPartRef().lock().get() : nullptr;
378  bool isPower = part ? part->IsPower() : false;
379 
380  return !isPower;
381 }
382 
383 
384 bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
385 {
386  bool isReplaced;
387  wxString text = GetFullyQualifiedText();
388 
389  if( m_id == REFERENCE )
390  {
391  wxCHECK_MSG( aAuxData != NULL, false,
392  wxT( "Cannot replace reference designator without valid sheet path." ) );
393 
394  wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
395  wxT( "Invalid replace symbol reference field call." ) ) ;
396 
397  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
398 
399  wxCHECK_MSG( component != NULL, false,
400  wxT( "No symbol associated with field" ) + text );
401 
402  text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
403 
404  // if( component->GetUnitCount() > 1 )
405  // text << LIB_PART::SubReference( component->GetUnit() );
406 
407  isReplaced = EDA_ITEM::Replace( aSearchData, text );
408 
409  if( isReplaced )
410  component->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
411  }
412  else
413  {
414  isReplaced = EDA_ITEM::Replace( aSearchData, m_Text );
415  }
416 
417  return isReplaced;
418 }
419 
420 
421 void SCH_FIELD::Rotate( wxPoint aPosition )
422 {
423  wxPoint pt = GetTextPos();
424  RotatePoint( &pt, aPosition, 900 );
425  SetTextPos( pt );
426 }
427 
428 
430 {
431  return wxString::Format( _( "Field %s" ), GetName() );
432 }
433 
434 
435 wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
436 {
437  if( !m_name.IsEmpty() )
438  return m_name;
439  else if( aUseDefaultName )
441 
442  return wxEmptyString;
443 }
444 
445 
447 {
448  if( m_id == REFERENCE )
449  return edit_comp_ref_xpm;
450 
451  if( m_id == VALUE )
452  return edit_comp_value_xpm;
453 
454  if( m_id == FOOTPRINT )
455  return edit_comp_footprint_xpm;
456 
457  return edit_text_xpm;
458 }
459 
460 
461 bool SCH_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
462 {
463  // Do not hit test hidden or empty fields.
464  if( !IsVisible() || IsVoid() )
465  return false;
466 
467  EDA_RECT rect = GetBoundingBox();
468 
469  rect.Inflate( aAccuracy );
470 
471  return rect.Contains( aPosition );
472 }
473 
474 
475 bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
476 {
477  // Do not hit test hidden fields.
478  if( !IsVisible() || IsVoid() )
479  return false;
480 
481  EDA_RECT rect = aRect;
482 
483  rect.Inflate( aAccuracy );
484 
485  if( aContained )
486  return rect.Contains( GetBoundingBox() );
487 
488  return rect.Intersects( GetBoundingBox() );
489 }
490 
491 
492 void SCH_FIELD::Plot( PLOTTER* aPlotter )
493 {
494  SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
495 
496  wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
497  wxT( "Cannot plot field with invalid parent." ) );
498 
500 
501  if( !IsVisible() )
502  return;
503 
504  if( IsVoid() )
505  return;
506 
507  /* Calculate the text orientation, according to the component
508  * orientation/mirror */
509  int orient = GetTextAngle();
510 
511  if( parent->GetTransform().y1 ) // Rotate component 90 deg.
512  {
513  if( orient == TEXT_ANGLE_HORIZ )
514  orient = TEXT_ANGLE_VERT;
515  else
516  orient = TEXT_ANGLE_HORIZ;
517  }
518 
519  /* Calculate the text justification, according to the component
520  * orientation/mirror
521  * this is a bit complicated due to cumulative calculations:
522  * - numerous cases (mirrored or not, rotation)
523  * - the DrawGraphicText function recalculate also H and H justifications
524  * according to the text orientation.
525  * - When a component is mirrored, the text is not mirrored and
526  * justifications are complicated to calculate
527  * so the more easily way is to use no justifications ( Centered text )
528  * and use GetBoundaryBox to know the text coordinate considered as centered
529  */
530  EDA_RECT BoundaryBox = GetBoundingBox();
533  wxPoint textpos = BoundaryBox.Centre();
534 
535  int thickness = GetPenSize();
536 
537  aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
538  hjustify, vjustify,
539  thickness, IsItalic(), IsBold() );
540 }
541 
542 
543 void SCH_FIELD::SetPosition( const wxPoint& aPosition )
544 {
545  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
546 
547  wxPoint pos = ( (SCH_COMPONENT*) GetParent() )->GetPosition();
548 
549  // Actual positions are calculated by the rotation/mirror transform of the
550  // parent component of the field. The inverse transfrom is used to calculate
551  // the position relative to the parent component.
552  wxPoint pt = aPosition - pos;
553 
554  SetTextPos( pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ) );
555 }
556 
557 
559 {
560  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
561 
562  wxPoint pos = GetTextPos() - component->GetPosition();
563 
564  return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition();
565 }
Definition: colors.h:57
#define TEXT_ANGLE_HORIZ
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
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:171
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:435
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:62
PART_REF & GetPartRef()
wxString m_Text
Definition: eda_text.h:374
TRANSFORM & GetTransform() const
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
PNG memory record (file in memory).
Definition: bitmap_types.h:43
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool IsItalic() const
Definition: eda_text.h:183
bool IsPower() const
#define TEXT_ANGLE_VERT
bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
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:558
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:420
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:231
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:236
void SetVisible(bool aVisible)
Definition: eda_text.h:188
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
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.
virtual EDA_RECT * GetClipBox()
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:490
wxString m_name
Definition: sch_field.h:60
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
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:177
bool IsBold() const
Definition: eda_text.h:186
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
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:127
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
Return 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:461
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1003
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:103
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:510
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
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void SetLayer(SCH_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
SCH_DRAW_PANEL * GetCanvas() const override
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_field.cpp:429
void ExportValues(LIB_FIELD &aDest) const
Function ImportValues copy parameters into a LIB_FIELD destination.
Definition: sch_field.cpp:228
Define a library symbol object.
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:446
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:285
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:69
void Normalize()
Function Normalize ensures that the height ant width are positive.
Base plotter engine class.
Definition: 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.
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_field.cpp:492
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:384
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:189
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:204
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:154
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
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
bool IsReplaceable() const override
Function IsReplaceable.
Definition: sch_field.cpp:371
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_field.cpp:421
const wxSize & GetTextSize() const
Definition: eda_text.h:228
Basic classes for most KiCad items.
Definition for part library class.
bool IsWireImage() const
Definition: base_struct.h:223
Definition of the SCH_FIELD class for Eeschema.
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:175
#define VALUE
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_field.cpp:543
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_UNITS_T
Definition: common.h:159
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:154
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62