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-2014 KiCad Developers, see change_log.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 <plot_common.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 bool SCH_FIELD::Save( FILE* aFile ) const
315 {
316  char hjustify = 'C';
317 
319  hjustify = 'L';
321  hjustify = 'R';
322 
323  char vjustify = 'C';
324 
326  vjustify = 'B';
327  else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
328  vjustify = 'T';
329 
330  if( fprintf( aFile, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
331  m_id,
332  EscapedUTF8( m_Text ).c_str(), // wraps in quotes too
333  GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V',
334  GetTextPos().x, GetTextPos().y,
335  GetTextWidth(),
336  !IsVisible(),
337  hjustify, vjustify,
338  IsItalic() ? 'I' : 'N',
339  IsBold() ? 'B' : 'N' ) == EOF )
340  {
341  return false;
342  }
343 
344  // Save field name, if the name is user definable
345  if( m_id >= FIELD1 )
346  {
347  if( fprintf( aFile, " %s", EscapedUTF8( m_name ).c_str() ) == EOF )
348  {
349  return false;
350  }
351  }
352 
353  if( fprintf( aFile, "\n" ) == EOF )
354  {
355  return false;
356  }
357 
358  return true;
359 }
360 
361 
362 void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
363 {
364  frame->GetCanvas()->SetMouseCapture( NULL, NULL );
365 
366  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
367 
368  // save old cmp in undo list
369  frame->SaveUndoItemInUndoList( component );
370 
371  Draw( frame->GetCanvas(), DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
372  ClearFlags();
373  frame->GetScreen()->SetCurItem( NULL );
374  frame->OnModify();
375 }
376 
377 
378 bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
379 {
380  bool match;
381  wxString text = GetFullyQualifiedText();
382 
383  // User defined fields have an ID of -1.
384  if( ((m_id > VALUE || m_id < REFERENCE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS))
385  || ((m_id == REFERENCE) && !(aSearchData.GetFlags() & FR_REPLACE_REFERENCES)) )
386  return false;
387 
388  wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() );
389 
390  // Take sheet path into account which effects the reference field and the unit for
391  // components with multiple parts.
392  if( m_id == REFERENCE && aAuxData != NULL )
393  {
394  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
395 
396  wxCHECK_MSG( component != NULL, false,
397  wxT( "No component associated with field" ) + text );
398 
399  text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
400 
401  if( component->GetUnitCount() > 1 )
402  text << LIB_PART::SubReference( component->GetUnit() );
403  }
404 
405  match = SCH_ITEM::Matches( text, aSearchData );
406 
407  if( match )
408  {
409  if( aFindLocation )
410  *aFindLocation = GetBoundingBox().Centre();
411 
412  return true;
413  }
414 
415  return false;
416 }
417 
418 
419 bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
420 {
421  bool isReplaced;
422  wxString text = GetFullyQualifiedText();
423 
424  if( m_id == REFERENCE )
425  {
426  wxCHECK_MSG( aAuxData != NULL, false,
427  wxT( "Cannot replace reference designator without valid sheet path." ) );
428 
429  wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
430  wxT( "Invalid replace component reference field call." ) ) ;
431 
432  SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;
433 
434  wxCHECK_MSG( component != NULL, false,
435  wxT( "No component associated with field" ) + text );
436 
437  text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
438 
439  // if( component->GetUnitCount() > 1 )
440  // text << LIB_PART::SubReference( component->GetUnit() );
441 
442  isReplaced = EDA_ITEM::Replace( aSearchData, text );
443 
444  if( isReplaced )
445  component->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
446  }
447  else
448  {
449  isReplaced = EDA_ITEM::Replace( aSearchData, m_Text );
450  }
451 
452  return isReplaced;
453 }
454 
455 
456 void SCH_FIELD::Rotate( wxPoint aPosition )
457 {
458  wxPoint pt = GetTextPos();
459  RotatePoint( &pt, aPosition, 900 );
460  SetTextPos( pt );
461 }
462 
463 
465 {
466  wxString tmp;
467  tmp.Printf( _( "Field %s" ), GetChars( GetName() ) );
468 
469  return tmp;
470 }
471 
472 
473 wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
474 {
475  if( !m_name.IsEmpty() )
476  return m_name;
477  else if( aUseDefaultName )
479 
480  return wxEmptyString;
481 }
482 
483 
485 {
486  if( m_id == REFERENCE )
487  return edit_comp_ref_xpm;
488 
489  if( m_id == VALUE )
490  return edit_comp_value_xpm;
491 
492  if( m_id == FOOTPRINT )
493  return edit_comp_footprint_xpm;
494 
495  return edit_text_xpm;
496 }
497 
498 
499 bool SCH_FIELD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
500 {
501  // Do not hit test hidden or empty fields.
502  if( !IsVisible() || IsVoid() )
503  return false;
504 
505  EDA_RECT rect = GetBoundingBox();
506 
507  rect.Inflate( aAccuracy );
508 
509  return rect.Contains( aPosition );
510 }
511 
512 
513 bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
514 {
515  // Do not hit test hidden fields.
516  if( !IsVisible() || IsVoid() )
517  return false;
518 
519  EDA_RECT rect = aRect;
520 
521  rect.Inflate( aAccuracy );
522 
523  if( aContained )
524  return rect.Contains( GetBoundingBox() );
525 
526  return rect.Intersects( GetBoundingBox() );
527 }
528 
529 
530 void SCH_FIELD::Plot( PLOTTER* aPlotter )
531 {
532  SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
533 
534  wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
535  wxT( "Cannot plot field with invalid parent." ) );
536 
538 
539  if( !IsVisible() )
540  return;
541 
542  if( IsVoid() )
543  return;
544 
545  /* Calculate the text orientation, according to the component
546  * orientation/mirror */
547  int orient = GetTextAngle();
548 
549  if( parent->GetTransform().y1 ) // Rotate component 90 deg.
550  {
551  if( orient == TEXT_ANGLE_HORIZ )
552  orient = TEXT_ANGLE_VERT;
553  else
554  orient = TEXT_ANGLE_HORIZ;
555  }
556 
557  /* Calculate the text justification, according to the component
558  * orientation/mirror
559  * this is a bit complicated due to cumulative calculations:
560  * - numerous cases (mirrored or not, rotation)
561  * - the DrawGraphicText function recalculate also H and H justifications
562  * according to the text orientation.
563  * - When a component is mirrored, the text is not mirrored and
564  * justifications are complicated to calculate
565  * so the more easily way is to use no justifications ( Centered text )
566  * and use GetBoundaryBox to know the text coordinate considered as centered
567  */
568  EDA_RECT BoundaryBox = GetBoundingBox();
571  wxPoint textpos = BoundaryBox.Centre();
572 
573  int thickness = GetPenSize();
574 
575  aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
576  hjustify, vjustify,
577  thickness, IsItalic(), IsBold() );
578 }
579 
580 
581 void SCH_FIELD::SetPosition( const wxPoint& aPosition )
582 {
583  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
584 
585  wxPoint pos = ( (SCH_COMPONENT*) GetParent() )->GetPosition();
586 
587  // Actual positions are calculated by the rotation/mirror transform of the
588  // parent component of the field. The inverse transfrom is used to calculate
589  // the position relative to the parent component.
590  wxPoint pt = aPosition - pos;
591 
592  SetTextPos( pos + component->GetTransform().InverseTransform().TransformCoordinate( pt ) );
593 }
594 
595 
597 {
598  SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
599 
600  wxPoint pos = GetTextPos() - component->GetPosition();
601 
602  return component->GetTransform().TransformCoordinate( pos ) + component->GetPosition();
603 }
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:91
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:74
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:473
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:290
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:324
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:769
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 GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
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:68
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_field.cpp:596
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:362
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)
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_field.cpp:314
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:117
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:659
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:92
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)
Function SaveUndoItemInUndoList swaps the cloned item in member variable m_undoItem with aItem and sa...
Definition: schframe.cpp:605
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:528
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:499
std::string EscapedUTF8(const wxString &aString)
Function EscapedUTF8 returns an 8 bit UTF8 string given aString in unicode form.
Definition: string.cpp:137
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
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:115
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:679
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()
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
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:484
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".
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
Base plotter engine class.
Definition: plot_common.h:86
#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:530
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:419
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)
Function SetCurItem 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:464
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:378
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:456
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:581
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