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) 2012 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 
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 <class_drawpanel.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  return GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
113 }
114 
115 
116 void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
117  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
118  const TRANSFORM& aTransform )
119 {
120  wxPoint text_pos;
121  COLOR4D color = COLOR4D::UNSPECIFIED;
122  int linewidth = GetPenSize();
123 
124  if( IsBold() )
125  linewidth = GetPenSizeForBold( GetTextWidth() );
126  else
127  linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
128 
129  if( !IsVisible() && ( aColor == COLOR4D::UNSPECIFIED ) )
130  {
131  color = GetInvisibleItemColor();
132  }
133  else if( IsSelected() && ( aColor == COLOR4D::UNSPECIFIED ) )
134  {
135  color = GetItemSelectedColor();
136  }
137  else
138  {
139  color = aColor;
140  }
141 
142  if( color == COLOR4D::UNSPECIFIED )
143  color = GetDefaultColor();
144 
145  text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
146 
147  wxString text;
148 
149  if( aData )
150  text = *(wxString*)aData;
151  else
152  text = m_Text;
153 
154  GRSetDrawMode( aDC, aDrawMode );
155  EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
156 
157  DrawGraphicText( clipbox, aDC, text_pos, color, text,
160  linewidth, IsItalic(), IsBold() );
161 
162  /* Set to one (1) to draw bounding box around field text to validate
163  * bounding box calculation. */
164 #if 0
165  EDA_RECT bBox = GetBoundingBox();
166  bBox.RevertYAxis();
167  bBox = aTransform.TransformCoordinate( bBox );
168  bBox.Move( aOffset );
169  GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA );
170 #endif
171 }
172 
173 
174 bool LIB_FIELD::HitTest( const wxPoint& aPosition ) const
175 {
176  // Because HitTest is mainly used to select the field
177  // return always false if this field is void
178  if( IsVoid() )
179  return false;
180 
181  return HitTest( aPosition, 0, DefaultTransform );
182 }
183 
184 
185 bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
186 {
187  if( aThreshold < 0 )
188  aThreshold = 0;
189 
190  // Build a temporary copy of the text for hit testing
191  EDA_TEXT tmp_text( *this );
192 
193  // Reference designator text has one or 2 additional character (displays
194  // U? or U?A)
195  if( m_id == REFERENCE )
196  {
197  wxString extended_text = tmp_text.GetText();
198  extended_text.Append('?');
199  const LIB_PART* parent = static_cast<const LIB_PART*>( m_Parent );
200 
201  if ( parent && ( parent->GetUnitCount() > 1 ) )
202  extended_text.Append('A');
203  tmp_text.SetText( extended_text );
204  }
205 
206  tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) );
207 
208  /* The text orientation may need to be flipped if the
209  * transformation matrix causes xy axes to be flipped.
210  * this simple algo works only for schematic matrix (rot 90 or/and mirror)
211  */
212  bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
213  tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
214 
215  return tmp_text.TextHitTest( aPosition );
216 }
217 
218 
220 {
221  LIB_FIELD* newfield = new LIB_FIELD( m_id );
222 
223  Copy( newfield );
224 
225  return (EDA_ITEM*) newfield;
226 }
227 
228 
229 void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
230 {
231  aTarget->m_Text = m_Text;
232  aTarget->m_name = m_name;
233 
234  aTarget->SetEffects( *this );
235  aTarget->SetParent( m_Parent );
236 }
237 
238 
239 int LIB_FIELD::compare( const LIB_ITEM& other ) const
240 {
241  wxASSERT( other.Type() == LIB_FIELD_T );
242 
243  const LIB_FIELD* tmp = ( LIB_FIELD* ) &other;
244 
245  if( m_id != tmp->m_id )
246  return m_id - tmp->m_id;
247 
248  int result = m_Text.CmpNoCase( tmp->m_Text );
249 
250  if( result != 0 )
251  return result;
252 
253  if( GetTextPos().x != tmp->GetTextPos().x )
254  return GetTextPos().x - tmp->GetTextPos().x;
255 
256  if( GetTextPos().y != tmp->GetTextPos().y )
257  return GetTextPos().y - tmp->GetTextPos().y;
258 
259  if( GetTextWidth() != tmp->GetTextWidth() )
260  return GetTextWidth() - tmp->GetTextWidth();
261 
262  if( GetTextHeight() != tmp->GetTextHeight() )
263  return GetTextHeight() - tmp->GetTextHeight();
264 
265  return 0;
266 }
267 
268 
269 void LIB_FIELD::SetOffset( const wxPoint& aOffset )
270 {
271  EDA_TEXT::Offset( aOffset );
272 }
273 
274 
275 bool LIB_FIELD::Inside( EDA_RECT& rect ) const
276 {
277  return rect.Intersects( GetBoundingBox() );
278 }
279 
280 
281 void LIB_FIELD::Move( const wxPoint& newPosition )
282 {
283  EDA_TEXT::SetTextPos( newPosition );
284 }
285 
286 
288 {
289  int x = GetTextPos().x;
290 
291  x -= center.x;
292  x *= -1;
293  x += center.x;
294 
295  SetTextX( x );
296 }
297 
298 
299 void LIB_FIELD::MirrorVertical( const wxPoint& center )
300 {
301  int y = GetTextPos().y;
302 
303  y -= center.y;
304  y *= -1;
305  y += center.y;
306 
307  SetTextY( y );
308 }
309 
310 
311 void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
312 {
313  int rot_angle = aRotateCCW ? -900 : 900;
314 
315  wxPoint pt = GetTextPos();
316  RotatePoint( &pt, center, rot_angle );
317  SetTextPos( pt );
318 
319  SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
320 }
321 
322 
323 void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
324  const TRANSFORM& aTransform )
325 {
326  if( IsVoid() )
327  return;
328 
329  /* Calculate the text orientation, according to the component
330  * orientation/mirror */
331  int orient = GetTextAngle();
332 
333  if( aTransform.y1 ) // Rotate component 90 deg.
334  {
335  if( orient == TEXT_ANGLE_HORIZ )
336  orient = TEXT_ANGLE_VERT;
337  else
338  orient = TEXT_ANGLE_HORIZ;
339  }
340 
341  EDA_RECT BoundaryBox = GetBoundingBox();
342  BoundaryBox.RevertYAxis();
343 
346  wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
347  + aOffset;
348 
349  aPlotter->Text( textpos, GetDefaultColor(), GetShownText(),
350  orient, GetTextSize(),
351  hjustify, vjustify,
352  GetPenSize(), IsItalic(), IsBold() );
353 }
354 
355 
356 wxString LIB_FIELD::GetFullText( int unit ) const
357 {
358  if( m_id != REFERENCE )
359  return GetText();
360 
361  wxString text = GetText();
362  text << wxT( "?" );
363 
364  if( GetParent()->IsMulti() )
365  text << LIB_PART::SubReference( unit );
366 
367  return text;
368 }
369 
370 
372 {
373  /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
374  * calling GetTextBox() that works using top to bottom Y axis orientation.
375  */
376  EDA_RECT rect = GetTextBox( -1, -1, true );
377  rect.RevertYAxis();
378 
379  // We are using now a bottom to top Y axis.
380  wxPoint orig = rect.GetOrigin();
381  wxPoint end = rect.GetEnd();
382 
383  RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
384  RotatePoint( &end, GetTextPos(), -GetTextAngle() );
385 
386  rect.SetOrigin( orig );
387  rect.SetEnd( end );
388 
389  // We are using now a top to bottom Y axis:
390  rect.RevertYAxis();
391 
392  return rect;
393 }
394 
395 
397 {
398  COLOR4D color;
399 
400  switch( m_id )
401  {
402  case REFERENCE:
404  break;
405 
406  case VALUE:
407  color = GetLayerColor( LAYER_VALUEPART );
408  break;
409 
410  default:
411  color = GetLayerColor( LAYER_FIELDS );
412  break;
413  }
414 
415  return color;
416 }
417 
418 
420 {
421  if( InEditMode() )
422  {
423  m_rotate = true;
424  }
425  else
426  {
428  }
429 }
430 
431 
432 wxString LIB_FIELD::GetName( bool aTranslate ) const
433 {
434  wxString name;
435 
436  switch( m_id )
437  {
438  case REFERENCE:
439  if( aTranslate )
440  name = _( "Reference" );
441  else
442  name = wxT( "Reference" );
443  break;
444 
445  case VALUE:
446  if( aTranslate )
447  name = _( "Value" );
448  else
449  name = wxT( "Value" );
450  break;
451 
452  case FOOTPRINT:
453  if( aTranslate )
454  name = _( "Footprint" );
455  else
456  name = wxT( "Footprint" );
457  break;
458 
459  case DATASHEET:
460  if( aTranslate )
461  name = _( "Datasheet" );
462  else
463  name = wxT( "Datasheet" );
464  break;
465 
466  default:
467  if( m_name.IsEmpty() )
468  {
469  if( aTranslate )
470  name.Printf( _( "Field%d" ), m_id );
471  else
472  name.Printf( wxT( "Field%d" ), m_id );
473  }
474  else
475  name = m_name;
476  }
477 
478  return name;
479 }
480 
481 
482 void LIB_FIELD::SetName( const wxString& aName )
483 {
484  // Mandatory field names are fixed.
485 
486  // So what? Why should the low level code be in charge of such a policy issue?
487  // Besides, m_id is a relic that is untrustworthy now.
488  if( m_id >=0 && m_id < MANDATORY_FIELDS )
489  {
490  DBG(printf( "trying to set a MANDATORY_FIELD's name\n" );)
491  return;
492  }
493 
494  if( m_name != aName )
495  {
496  m_name = aName;
497  SetModified();
498  }
499 }
500 
501 
502 void LIB_FIELD::SetText( const wxString& aText )
503 {
504  if( aText == GetText() )
505  return;
506 
507  wxString oldValue( m_Text );
508  wxString newValue( aText );
509 
510  if( m_id == VALUE && m_Parent != NULL )
511  {
512  LIB_PART* parent = GetParent();
513 
514  // Set the parent component and root alias to the new name.
515  if( parent->GetName().CmpNoCase( aText ) != 0 )
516  {
517  ReplaceIllegalFileNameChars( newValue, '_' );
518  parent->SetName( newValue );
519  }
520  }
521 
522  if( InEditMode() )
523  {
524  m_Text = oldValue;
525  m_savedText = newValue;
526  m_updateText = true;
527  }
528  else
529  {
530  m_Text = newValue;
531  }
532 }
533 
534 
536 {
537  return wxString::Format( _( "Field %s %s" ),
538  GetChars( GetName() ),
540 }
541 
542 
543 void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
544 {
545  wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
546  wxT( "Invalid edit mode for LIB_FIELD object." ) );
547 
548  if( aEditMode == IS_MOVED )
549  {
551  m_initialCursorPos = aPosition;
553  }
554  else
555  {
556  SetTextPos( aPosition );
557  }
558 
559  m_Flags = aEditMode;
560 }
561 
562 
563 bool LIB_FIELD::ContinueEdit( const wxPoint aPosition )
564 {
565  wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0, false,
566  wxT( "Bad call to ContinueEdit(). Text is not being edited." ) );
567 
568  return false;
569 }
570 
571 
572 void LIB_FIELD::EndEdit( const wxPoint& aPosition, bool aAbort )
573 {
574  wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
575  wxT( "Bad call to EndEdit(). Text is not being edited." ) );
576 
577  m_Flags = 0;
578  m_rotate = false;
579  m_updateText = false;
580  SetEraseLastDrawItem( false );
581 }
582 
583 
584 void LIB_FIELD::calcEdit( const wxPoint& aPosition )
585 {
586  if( m_rotate )
587  {
589  m_rotate = false;
590  }
591 
592  if( m_updateText )
593  {
594  std::swap( m_Text, m_savedText );
595  m_updateText = false;
596  }
597 
598  if( m_Flags == IS_NEW )
599  {
600  SetTextPos( aPosition );
601  }
602  else if( m_Flags == IS_MOVED )
603  {
604  Move( m_initialPos + aPosition - m_initialCursorPos );
605  }
606 }
607 
608 
610 {
611  wxString msg;
612 
613  LIB_ITEM::GetMsgPanelInfo( aList );
614 
615  // Display style:
616  msg = GetTextStyleName();
617  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) );
618 
619  msg = StringFromValue( g_UserUnit, GetTextWidth(), true );
620  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) );
621 
622  msg = StringFromValue( g_UserUnit, GetTextHeight(), true );
623  aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) );
624 
625  // Display field name (ref, value ...)
626  msg = GetName();
627  aList.push_back( MSG_PANEL_ITEM( _( "Field" ), msg, BROWN ) );
628 
629  // Display field text:
630  aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetShownText(), BROWN ) );
631 }
632 
633 
635 {
636  return move_xpm;
637 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:154
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
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_field.cpp:299
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:227
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:239
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 Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
wxString m_Text
Definition: eda_text.h:344
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:79
PNG memory record (file in memory).
Definition: bitmap_types.h:41
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
wxString m_savedText
Temporary storage for the string when edition.
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:318
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
bool IsItalic() const
Definition: eda_text.h:168
void SetEraseLastDrawItem(bool aErase=true)
Implementation of conversion functions that require both schematic and board internal units...
void SetEffects(const EDA_TEXT &aSrc)
Function SetEffects sets the text effects from another instance.
Definition: eda_text.cpp:55
Definition: colors.h:61
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:205
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
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 SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
void SetVisible(bool aVisible)
Definition: eda_text.h:173
bool IsSelected() const
Definition: base_struct.h:232
bool InEditMode() const
Return the draw item editing mode status.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Function ReplaceIllegalFileNameChars checks aName for illegal file name characters.
Definition: string.cpp:570
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:634
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_field.cpp:287
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:356
const EDA_RECT GetBoundingBox() const override
Definition: lib_field.cpp:371
bool m_updateText
Flag to indicate text change occurred while editing.
Definition: lib_field.h:66
COLOR4D GetDefaultColor() override
Definition: lib_field.cpp:396
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:482
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
void GetMsgPanelInfo(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:609
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:188
#define TEXT_ANGLE_VERT
Definition: common.h:92
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:572
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
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
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:174
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:224
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:133
#define IS_NEW
New item, just created.
Definition: base_struct.h:109
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
int y1
Definition: transform.h:49
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1098
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:102
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:502
void calcEdit(const wxPoint &aPosition) override
Calculate the new circle at aPosition when editing.
Definition: lib_field.cpp:584
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:543
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_field.cpp:281
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:224
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:254
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:128
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:275
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:323
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:219
unsigned STATUS_FLAGS
Definition: base_struct.h:142
EDA_RECT * GetClipBox()
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:432
const wxPoint GetEnd() const
Definition: eda_rect.h:114
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
int GetUnitCount() const
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
void SetTextWidth(int aWidth)
Definition: eda_text.h:215
int m_id
Definition: lib_field.h:61
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:189
void Rotate() override
Rotate the draw item.
Definition: lib_field.cpp:419
Base plotter engine class.
Definition: plotter.h:96
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
virtual void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
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
see class PGM_BASE
TRANSFORM DefaultTransform
Definition: eeschema.cpp:58
wxString GetTextStyleName()
Function GetTextStyleName.
Definition: eda_text.cpp:380
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:164
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:186
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_field.cpp:535
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:218
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
int GetTextHeight() const
Definition: eda_text.h:219
void Copy(LIB_FIELD *aTarget) const
Copy parameters of this field to another field.
Definition: lib_field.cpp:229
const wxString & GetName() const
virtual void SetName(const wxString &aName)
COLOR4D GetItemSelectedColor()
void SetOffset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_field.cpp:269
int GetPenSize() const override
Definition: lib_field.cpp:110
#define DBG(x)
Definition: fctsys.h:33
const wxSize & GetTextSize() const
Definition: eda_text.h:213
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:116
bool m_rotate
Flag to indicate a rotation occurred while editing.
Definition: lib_field.h:65
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_field.cpp:563
void SetTextY(int aY)
Definition: eda_text.h:225
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:139
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:108
Definition: colors.h:62