KiCad PCB EDA Suite
lib_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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2018 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 
29 #include <fctsys.h>
30 #include <pgm_base.h>
31 #include <gr_basic.h>
32 #include <macros.h>
33 #include <base_struct.h>
34 #include <draw_graphic_text.h>
35 #include <kicad_string.h>
36 #include <sch_draw_panel.h>
37 #include <plotter.h>
38 #include <trigo.h>
39 #include <base_units.h>
40 #include <msgpanel.h>
41 #include <bitmaps.h>
42 
43 #include <general.h>
44 #include <class_libentry.h>
45 #include <transform.h>
46 #include <lib_field.h>
47 #include <template_fieldnames.h>
48 
49 
50 LIB_FIELD::LIB_FIELD(LIB_PART * aParent, int idfield ) :
51  LIB_ITEM( LIB_FIELD_T, aParent )
52 {
53  Init( idfield );
54 }
55 
56 
57 LIB_FIELD::LIB_FIELD( int idfield ) :
58  LIB_ITEM( LIB_FIELD_T, NULL )
59 {
60  Init( idfield );
61 }
62 
63 
65 {
66 }
67 
68 
69 void LIB_FIELD::operator=( const LIB_FIELD& field )
70 {
71  m_id = field.m_id;
72  m_Text = field.m_Text;
73  m_name = field.m_name;
74  m_Parent = field.m_Parent;
75 
76  SetEffects( field );
77 }
78 
79 
80 void LIB_FIELD::Init( int id )
81 {
82  m_id = id;
83 
86 
87  SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this.
88 
89  m_rotate = false;
90  m_updateText = false;
91 
92  // fields in RAM must always have names, because we are trying to get
93  // less dependent on field ids and more dependent on names.
94  // Plus assumptions are made in the field editors.
96 
97  switch( id )
98  {
99  case DATASHEET:
100  case FOOTPRINT:
101  // by contrast, VALUE and REFERENCE are are always constructed as
102  // initially visible, and template fieldsnames' initial visibility
103  // is controlled by the template fieldname configuration record.
104  SetVisible( false );
105  break;
106  }
107 }
108 
109 
111 {
112  int pensize = GetThickness();
113 
114  if( pensize == 0 ) // Use default values for pen size
115  {
116  if( IsBold() )
117  pensize = GetPenSizeForBold( GetTextWidth() );
118  else
119  pensize = GetDefaultLineThickness();
120  }
121 
122  // Clip pen size for small texts:
123  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
124  return pensize;
125 }
126 
127 
128 void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
129  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
130  const TRANSFORM& aTransform )
131 {
132  wxPoint text_pos;
133  COLOR4D color = COLOR4D::UNSPECIFIED;
134  int linewidth = GetPenSize();
135 
136  if( !IsVisible() && ( aColor == COLOR4D::UNSPECIFIED ) )
137  {
138  color = GetInvisibleItemColor();
139  }
140  else if( IsSelected() && ( aColor == COLOR4D::UNSPECIFIED ) )
141  {
142  color = GetItemSelectedColor();
143  }
144  else
145  {
146  color = aColor;
147  }
148 
149  if( color == COLOR4D::UNSPECIFIED )
150  color = GetDefaultColor();
151 
152  text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
153 
154  wxString text;
155 
156  if( aData )
157  text = *(wxString*)aData;
158  else
159  text = m_Text;
160 
161  GRSetDrawMode( aDC, aDrawMode );
162  EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
163 
164  DrawGraphicText( clipbox, aDC, text_pos, color, text,
167  linewidth, IsItalic(), IsBold() );
168 
169  /* Set to one (1) to draw bounding box around field text to validate
170  * bounding box calculation. */
171 #if 0
172  EDA_RECT bBox = GetBoundingBox();
173  bBox.RevertYAxis();
174  bBox = aTransform.TransformCoordinate( bBox );
175  bBox.Move( aOffset );
176  GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA );
177 #endif
178 }
179 
180 
181 bool LIB_FIELD::HitTest( const wxPoint& aPosition ) const
182 {
183  // Because HitTest is mainly used to select the field
184  // return always false if this field is void
185  if( IsVoid() )
186  return false;
187 
188  return HitTest( aPosition, 0, DefaultTransform );
189 }
190 
191 
192 bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
193 {
194  if( aThreshold < 0 )
195  aThreshold = 0;
196 
197  // Build a temporary copy of the text for hit testing
198  EDA_TEXT tmp_text( *this );
199 
200  // Reference designator text has one or 2 additional character (displays
201  // U? or U?A)
202  if( m_id == REFERENCE )
203  {
204  wxString extended_text = tmp_text.GetText();
205  extended_text.Append('?');
206  const LIB_PART* parent = static_cast<const LIB_PART*>( m_Parent );
207 
208  if ( parent && ( parent->GetUnitCount() > 1 ) )
209  extended_text.Append('A');
210  tmp_text.SetText( extended_text );
211  }
212 
213  tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) );
214 
215  /* The text orientation may need to be flipped if the
216  * transformation matrix causes xy axes to be flipped.
217  * this simple algo works only for schematic matrix (rot 90 or/and mirror)
218  */
219  bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
220  tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
221 
222  return tmp_text.TextHitTest( aPosition );
223 }
224 
225 
227 {
228  LIB_FIELD* newfield = new LIB_FIELD( m_id );
229 
230  Copy( newfield );
231 
232  return (EDA_ITEM*) newfield;
233 }
234 
235 
236 void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
237 {
238  aTarget->m_Text = m_Text;
239  aTarget->m_name = m_name;
240 
241  aTarget->SetEffects( *this );
242  aTarget->SetParent( m_Parent );
243 }
244 
245 
246 int LIB_FIELD::compare( const LIB_ITEM& other ) const
247 {
248  wxASSERT( other.Type() == LIB_FIELD_T );
249 
250  const LIB_FIELD* tmp = ( LIB_FIELD* ) &other;
251 
252  if( m_id != tmp->m_id )
253  return m_id - tmp->m_id;
254 
255  int result = m_Text.CmpNoCase( tmp->m_Text );
256 
257  if( result != 0 )
258  return result;
259 
260  if( GetTextPos().x != tmp->GetTextPos().x )
261  return GetTextPos().x - tmp->GetTextPos().x;
262 
263  if( GetTextPos().y != tmp->GetTextPos().y )
264  return GetTextPos().y - tmp->GetTextPos().y;
265 
266  if( GetTextWidth() != tmp->GetTextWidth() )
267  return GetTextWidth() - tmp->GetTextWidth();
268 
269  if( GetTextHeight() != tmp->GetTextHeight() )
270  return GetTextHeight() - tmp->GetTextHeight();
271 
272  return 0;
273 }
274 
275 
276 void LIB_FIELD::SetOffset( const wxPoint& aOffset )
277 {
278  EDA_TEXT::Offset( aOffset );
279 }
280 
281 
282 bool LIB_FIELD::Inside( EDA_RECT& rect ) const
283 {
284  return rect.Intersects( GetBoundingBox() );
285 }
286 
287 
288 void LIB_FIELD::Move( const wxPoint& newPosition )
289 {
290  EDA_TEXT::SetTextPos( newPosition );
291 }
292 
293 
295 {
296  int x = GetTextPos().x;
297 
298  x -= center.x;
299  x *= -1;
300  x += center.x;
301 
302  SetTextX( x );
303 }
304 
305 
306 void LIB_FIELD::MirrorVertical( const wxPoint& center )
307 {
308  int y = GetTextPos().y;
309 
310  y -= center.y;
311  y *= -1;
312  y += center.y;
313 
314  SetTextY( y );
315 }
316 
317 
318 void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
319 {
320  int rot_angle = aRotateCCW ? -900 : 900;
321 
322  wxPoint pt = GetTextPos();
323  RotatePoint( &pt, center, rot_angle );
324  SetTextPos( pt );
325 
326  SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
327 }
328 
329 
330 void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
331  const TRANSFORM& aTransform )
332 {
333  if( IsVoid() )
334  return;
335 
336  /* Calculate the text orientation, according to the component
337  * orientation/mirror */
338  int orient = GetTextAngle();
339 
340  if( aTransform.y1 ) // Rotate component 90 deg.
341  {
342  if( orient == TEXT_ANGLE_HORIZ )
343  orient = TEXT_ANGLE_VERT;
344  else
345  orient = TEXT_ANGLE_HORIZ;
346  }
347 
348  EDA_RECT BoundaryBox = GetBoundingBox();
349  BoundaryBox.RevertYAxis();
350 
353  wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
354  + aOffset;
355 
356  aPlotter->Text( textpos, GetDefaultColor(), GetShownText(),
357  orient, GetTextSize(),
358  hjustify, vjustify,
359  GetPenSize(), IsItalic(), IsBold() );
360 }
361 
362 
363 wxString LIB_FIELD::GetFullText( int unit ) const
364 {
365  if( m_id != REFERENCE )
366  return GetText();
367 
368  wxString text = GetText();
369  text << wxT( "?" );
370 
371  if( GetParent()->IsMulti() )
372  text << LIB_PART::SubReference( unit );
373 
374  return text;
375 }
376 
377 
379 {
380  /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
381  * calling GetTextBox() that works using top to bottom Y axis orientation.
382  */
383  EDA_RECT rect = GetTextBox( -1, -1, true );
384  rect.RevertYAxis();
385 
386  // We are using now a bottom to top Y axis.
387  wxPoint orig = rect.GetOrigin();
388  wxPoint end = rect.GetEnd();
389 
390  RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
391  RotatePoint( &end, GetTextPos(), -GetTextAngle() );
392 
393  rect.SetOrigin( orig );
394  rect.SetEnd( end );
395 
396  // We are using now a top to bottom Y axis:
397  rect.RevertYAxis();
398 
399  return rect;
400 }
401 
402 
403 void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
404 {
405  aCount = 1;
406 
407  switch( m_id )
408  {
409  case REFERENCE: aLayers[0] = LAYER_REFERENCEPART; break;
410  case VALUE: aLayers[0] = LAYER_VALUEPART; break;
411  default: aLayers[0] = LAYER_FIELDS; break;
412  }
413 }
414 
415 
417 {
418  switch( m_id )
419  {
421  case VALUE: return GetLayerColor( LAYER_VALUEPART );
422  default: return GetLayerColor( LAYER_FIELDS );
423  }
424 }
425 
426 
428 {
429  if( InEditMode() )
430  {
431  m_rotate = true;
432  }
433  else
434  {
436  }
437 }
438 
439 
440 wxString LIB_FIELD::GetName( bool aTranslate ) const
441 {
442  wxString name;
443 
444  switch( m_id )
445  {
446  case REFERENCE:
447  if( aTranslate )
448  name = _( "Reference" );
449  else
450  name = wxT( "Reference" );
451  break;
452 
453  case VALUE:
454  if( aTranslate )
455  name = _( "Value" );
456  else
457  name = wxT( "Value" );
458  break;
459 
460  case FOOTPRINT:
461  if( aTranslate )
462  name = _( "Footprint" );
463  else
464  name = wxT( "Footprint" );
465  break;
466 
467  case DATASHEET:
468  if( aTranslate )
469  name = _( "Datasheet" );
470  else
471  name = wxT( "Datasheet" );
472  break;
473 
474  default:
475  if( m_name.IsEmpty() )
476  {
477  if( aTranslate )
478  name.Printf( _( "Field%d" ), m_id );
479  else
480  name.Printf( wxT( "Field%d" ), m_id );
481  }
482  else
483  name = m_name;
484  }
485 
486  return name;
487 }
488 
489 
490 void LIB_FIELD::SetName( const wxString& aName )
491 {
492  // Mandatory field names are fixed.
493 
494  // So what? Why should the low level code be in charge of such a policy issue?
495  // Besides, m_id is a relic that is untrustworthy now.
496  if( m_id >=0 && m_id < MANDATORY_FIELDS )
497  {
498  DBG(printf( "trying to set a MANDATORY_FIELD's name\n" );)
499  return;
500  }
501 
502  if( m_name != aName )
503  {
504  m_name = aName;
505  SetModified();
506  }
507 }
508 
509 
510 void LIB_FIELD::SetText( const wxString& aText )
511 {
512  if( aText == GetText() )
513  return;
514 
515  wxString oldValue( m_Text );
516  wxString newValue( aText );
517 
518  if( InEditMode() )
519  {
520  m_Text = oldValue;
521  m_savedText = newValue;
522  m_updateText = true;
523  }
524  else
525  {
526  m_Text = newValue;
527  }
528 }
529 
530 
532 {
533  return wxString::Format( _( "Field %s \"%s\"" ), GetName(), ShortenedShownText() );
534 }
535 
536 
537 void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
538 {
539  wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
540  wxT( "Invalid edit mode for LIB_FIELD object." ) );
541 
542  if( aEditMode == IS_MOVED )
543  {
545  m_initialCursorPos = aPosition;
546  }
547  else
548  {
549  SetTextPos( aPosition );
550  }
551 
552  m_Flags = aEditMode;
553 }
554 
555 
556 bool LIB_FIELD::ContinueEdit( const wxPoint aPosition )
557 {
558  wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0, false,
559  wxT( "Bad call to ContinueEdit(). Text is not being edited." ) );
560 
561  return false;
562 }
563 
564 
565 void LIB_FIELD::EndEdit( const wxPoint& aPosition, bool aAbort )
566 {
567  wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
568  wxT( "Bad call to EndEdit(). Text is not being edited." ) );
569 
570  m_Flags = 0;
571  m_rotate = false;
572  m_updateText = false;
573 }
574 
575 
576 void LIB_FIELD::CalcEdit( const wxPoint& aPosition )
577 {
578  if( m_rotate )
579  {
581  m_rotate = false;
582  }
583 
584  if( m_updateText )
585  {
586  std::swap( m_Text, m_savedText );
587  m_updateText = false;
588  }
589 
590  if( m_Flags == IS_NEW )
591  {
592  SetTextPos( aPosition );
593  }
594  else if( m_Flags == IS_MOVED )
595  {
596  Move( m_initialPos + aPosition - m_initialCursorPos );
597  }
598 }
599 
600 
602 {
603  wxString msg;
604 
605  LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
606 
607  // Display style:
608  msg = GetTextStyleName();
609  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) );
610 
611  msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
612  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) );
613 
614  msg = MessageTextFromValue( aUnits, GetTextHeight(), true );
615  aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) );
616 
617  // Display field name (ref, value ...)
618  aList.push_back( MSG_PANEL_ITEM( _( "Field" ), GetName(), BROWN ) );
619 
620  // Display field text:
621  aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetShownText(), BROWN ) );
622 }
623 
624 
626 {
627  return move_xpm;
628 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:169
Definition: colors.h:57
#define TEXT_ANGLE_HORIZ
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_field.cpp:306
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:242
void SetModified()
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_field.cpp:246
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 Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:62
wxString m_Text
Definition: eda_text.h:374
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
name of datasheet
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:80
PNG memory record (file in memory).
Definition: bitmap_types.h:43
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
wxString m_savedText
Temporary storage for the string when editing.
Definition: lib_field.h:64
LIB_FIELD(int idfield=2)
Definition: lib_field.cpp:57
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
#define TEXT_ANGLE_VERT
Implementation of conversion functions that require both schematic and board internal units...
void CalcEdit(const wxPoint &aPosition) override
Calculate the new circle at aPosition when editing.
Definition: lib_field.cpp:576
void SetEffects(const EDA_TEXT &aSrc)
Function SetEffects sets the text effects from another instance.
Definition: eda_text.cpp:55
Definition: colors.h:61
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
int color
Definition: DXF_plotter.cpp:62
Field object used in symbol libraries.
Definition: lib_field.h:59
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_field.cpp:531
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 SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
void SetVisible(bool aVisible)
Definition: eda_text.h:188
bool IsSelected() const
Definition: base_struct.h:224
bool InEditMode() const
Return the draw item editing mode status.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
int x1
Definition: transform.h:48
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_field.cpp:625
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_field.cpp:294
virtual EDA_RECT * GetClipBox()
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:363
const EDA_RECT GetBoundingBox() const override
Definition: lib_field.cpp:378
bool m_updateText
Flag to indicate text change occurred while editing.
Definition: lib_field.h:66
COLOR4D GetDefaultColor() override
Definition: lib_field.cpp:416
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:490
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_field.cpp:601
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size) ...
Definition: eda_rect.h:144
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
COLOR4D GetInvisibleItemColor()
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
void EndEdit(const wxPoint &aPosition, bool aAbort=false) override
End an object editing action.
Definition: lib_field.cpp:565
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
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Definition: lib_field.cpp:181
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.
void SetTextX(int aX)
Definition: eda_text.h:239
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
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
int y1
Definition: transform.h:49
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
Definition: lib_field.cpp:403
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1003
LIB_PART * GetParent() const
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
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 operator=(const LIB_FIELD &field)
Definition: lib_field.cpp:69
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:510
void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aStartPoint=wxPoint(0, 0)) override
Begin an editing a component library draw item in aEditMode at aPosition.
Definition: lib_field.cpp:537
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_field.cpp:288
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Function TextHitTest Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:255
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
bool IsVoid() const
Definition: lib_field.h:156
Class LIB_ITEM definition.
void SetEnd(int x, int y)
Definition: eda_rect.h:134
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
Definition: lib_field.cpp:282
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_field.cpp:330
Define a library symbol object.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_field.cpp:226
unsigned STATUS_FLAGS
Definition: base_struct.h:147
void Init(int idfield)
Object constructor initialization helper.
Definition: lib_field.cpp:80
wxPoint Centre() const
Definition: eda_rect.h:60
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:440
const wxPoint GetEnd() const
Definition: eda_rect.h:114
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:69
int GetUnitCount() const
void SetTextWidth(int aWidth)
Definition: eda_text.h:230
int m_id
Definition: lib_field.h:61
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
void Rotate() override
Rotate the draw item.
Definition: lib_field.cpp:427
Base plotter engine class.
Definition: plotter.h:97
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
see class PGM_BASE
TRANSFORM DefaultTransform
Definition: eeschema.cpp:59
wxString GetTextStyleName()
Function GetTextStyleName.
Definition: eda_text.cpp:381
const char * name
Definition: DXF_plotter.cpp:61
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 IsVisible() const
Definition: lib_field.h:166
wxPoint m_initialPos
Temporary position when moving an existing item.
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:178
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static wxString SubReference(int aUnit, bool aAddSeparator=true)
void SetTextHeight(int aHeight)
Definition: eda_text.h:233
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
int GetTextHeight() const
Definition: eda_text.h:234
void Copy(LIB_FIELD *aTarget) const
Copy parameters of this field to another field.
Definition: lib_field.cpp:236
COLOR4D GetItemSelectedColor()
void SetOffset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_field.cpp:276
int GetPenSize() const override
Definition: lib_field.cpp:110
#define DBG(x)
Definition: fctsys.h:33
const wxSize & GetTextSize() const
Definition: eda_text.h:228
Basic classes for most KiCad items.
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
wxString m_name
Name (not the field text value itself, that is .m_Text)
Definition: lib_field.h:62
Message panel definition file.
#define VALUE
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform) override
Draw the field.
Definition: lib_field.cpp:128
bool m_rotate
Flag to indicate a rotation occurred while editing.
Definition: lib_field.h:65
EDA_UNITS_T
Definition: common.h:159
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_field.cpp:556
void SetTextY(int aY)
Definition: eda_text.h:240
int GetDefaultTextSize()
Default size for text in general.
wxPoint m_initialCursorPos
Initial cursor position at the beginning of a move.
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
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
Definition: colors.h:62