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 
64 LIB_FIELD::LIB_FIELD( int aID, wxString& aName ) :
65  LIB_ITEM( LIB_FIELD_T, NULL )
66 {
67  Init( aID );
68  m_name = aName;
69 }
70 
71 
73 {
74 }
75 
76 
77 void LIB_FIELD::operator=( const LIB_FIELD& field )
78 {
79  m_id = field.m_id;
80  m_Text = field.m_Text;
81  m_name = field.m_name;
82  m_Parent = field.m_Parent;
83 
84  SetEffects( field );
85 }
86 
87 
88 void LIB_FIELD::Init( int id )
89 {
90  m_id = id;
91 
94 
95  SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this.
96 
97  m_rotate = false;
98  m_updateText = false;
99 
100  // fields in RAM must always have names, because we are trying to get
101  // less dependent on field ids and more dependent on names.
102  // Plus assumptions are made in the field editors.
104 
105  switch( id )
106  {
107  case DATASHEET:
108  case FOOTPRINT:
109  // by contrast, VALUE and REFERENCE are are always constructed as
110  // initially visible, and template fieldsnames' initial visibility
111  // is controlled by the template fieldname configuration record.
112  SetVisible( false );
113  break;
114  }
115 }
116 
117 
119 {
120  int pensize = GetThickness();
121 
122  if( pensize == 0 ) // Use default values for pen size
123  {
124  if( IsBold() )
125  pensize = GetPenSizeForBold( GetTextWidth() );
126  else
127  pensize = GetDefaultLineThickness();
128  }
129 
130  // Clip pen size for small texts:
131  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
132  return pensize;
133 }
134 
135 
136 void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
137  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
138  const TRANSFORM& aTransform )
139 {
140  wxPoint text_pos;
141  COLOR4D color = COLOR4D::UNSPECIFIED;
142  int linewidth = GetPenSize();
143 
144  if( !IsVisible() && ( aColor == COLOR4D::UNSPECIFIED ) )
145  {
146  color = GetInvisibleItemColor();
147  }
148  else if( IsSelected() && ( aColor == COLOR4D::UNSPECIFIED ) )
149  {
150  color = GetItemSelectedColor();
151  }
152  else
153  {
154  color = aColor;
155  }
156 
157  if( color == COLOR4D::UNSPECIFIED )
158  color = GetDefaultColor();
159 
160  text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
161 
162  wxString text;
163 
164  if( aData )
165  text = *(wxString*)aData;
166  else
167  text = m_Text;
168 
169  GRSetDrawMode( aDC, aDrawMode );
170  EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
171 
172  DrawGraphicText( clipbox, aDC, text_pos, color, text,
175  linewidth, IsItalic(), IsBold() );
176 
177  /* Set to one (1) to draw bounding box around field text to validate
178  * bounding box calculation. */
179 #if 0
180  EDA_RECT bBox = GetBoundingBox();
181  bBox.RevertYAxis();
182  bBox = aTransform.TransformCoordinate( bBox );
183  bBox.Move( aOffset );
184  GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA );
185 #endif
186 }
187 
188 
189 bool LIB_FIELD::HitTest( const wxPoint& aPosition ) const
190 {
191  // Because HitTest is mainly used to select the field
192  // return always false if this field is void
193  if( IsVoid() )
194  return false;
195 
196  return HitTest( aPosition, 0, DefaultTransform );
197 }
198 
199 
200 bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
201 {
202  if( aThreshold < 0 )
203  aThreshold = 0;
204 
205  // Build a temporary copy of the text for hit testing
206  EDA_TEXT tmp_text( *this );
207 
208  // Reference designator text has one or 2 additional character (displays
209  // U? or U?A)
210  if( m_id == REFERENCE )
211  {
212  wxString extended_text = tmp_text.GetText();
213  extended_text.Append('?');
214  const LIB_PART* parent = static_cast<const LIB_PART*>( m_Parent );
215 
216  if ( parent && ( parent->GetUnitCount() > 1 ) )
217  extended_text.Append('A');
218  tmp_text.SetText( extended_text );
219  }
220 
221  tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) );
222 
223  /* The text orientation may need to be flipped if the
224  * transformation matrix causes xy axes to be flipped.
225  * this simple algo works only for schematic matrix (rot 90 or/and mirror)
226  */
227  bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
228  tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
229 
230  return tmp_text.TextHitTest( aPosition );
231 }
232 
233 
235 {
236  LIB_FIELD* newfield = new LIB_FIELD( m_id );
237 
238  Copy( newfield );
239 
240  return (EDA_ITEM*) newfield;
241 }
242 
243 
244 void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
245 {
246  aTarget->m_Text = m_Text;
247  aTarget->m_name = m_name;
248 
249  aTarget->SetEffects( *this );
250  aTarget->SetParent( m_Parent );
251 }
252 
253 
254 int LIB_FIELD::compare( const LIB_ITEM& other ) const
255 {
256  wxASSERT( other.Type() == LIB_FIELD_T );
257 
258  const LIB_FIELD* tmp = ( LIB_FIELD* ) &other;
259 
260  if( m_id != tmp->m_id )
261  return m_id - tmp->m_id;
262 
263  int result = m_Text.CmpNoCase( tmp->m_Text );
264 
265  if( result != 0 )
266  return result;
267 
268  if( GetTextPos().x != tmp->GetTextPos().x )
269  return GetTextPos().x - tmp->GetTextPos().x;
270 
271  if( GetTextPos().y != tmp->GetTextPos().y )
272  return GetTextPos().y - tmp->GetTextPos().y;
273 
274  if( GetTextWidth() != tmp->GetTextWidth() )
275  return GetTextWidth() - tmp->GetTextWidth();
276 
277  if( GetTextHeight() != tmp->GetTextHeight() )
278  return GetTextHeight() - tmp->GetTextHeight();
279 
280  return 0;
281 }
282 
283 
284 void LIB_FIELD::SetOffset( const wxPoint& aOffset )
285 {
286  EDA_TEXT::Offset( aOffset );
287 }
288 
289 
290 bool LIB_FIELD::Inside( EDA_RECT& rect ) const
291 {
292  return rect.Intersects( GetBoundingBox() );
293 }
294 
295 
296 void LIB_FIELD::Move( const wxPoint& newPosition )
297 {
298  EDA_TEXT::SetTextPos( newPosition );
299 }
300 
301 
302 void LIB_FIELD::MirrorHorizontal( const wxPoint& center )
303 {
304  int x = GetTextPos().x;
305 
306  x -= center.x;
307  x *= -1;
308  x += center.x;
309 
310  SetTextX( x );
311 }
312 
313 
314 void LIB_FIELD::MirrorVertical( const wxPoint& center )
315 {
316  int y = GetTextPos().y;
317 
318  y -= center.y;
319  y *= -1;
320  y += center.y;
321 
322  SetTextY( y );
323 }
324 
325 
326 void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
327 {
328  int rot_angle = aRotateCCW ? -900 : 900;
329 
330  wxPoint pt = GetTextPos();
331  RotatePoint( &pt, center, rot_angle );
332  SetTextPos( pt );
333 
334  SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
335 }
336 
337 
338 void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
339  const TRANSFORM& aTransform )
340 {
341  if( IsVoid() )
342  return;
343 
344  /* Calculate the text orientation, according to the component
345  * orientation/mirror */
346  int orient = GetTextAngle();
347 
348  if( aTransform.y1 ) // Rotate component 90 deg.
349  {
350  if( orient == TEXT_ANGLE_HORIZ )
351  orient = TEXT_ANGLE_VERT;
352  else
353  orient = TEXT_ANGLE_HORIZ;
354  }
355 
356  EDA_RECT BoundaryBox = GetBoundingBox();
357  BoundaryBox.RevertYAxis();
358 
361  wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
362  + aOffset;
363 
364  aPlotter->Text( textpos, GetDefaultColor(), GetShownText(),
365  orient, GetTextSize(),
366  hjustify, vjustify,
367  GetPenSize(), IsItalic(), IsBold() );
368 }
369 
370 
371 wxString LIB_FIELD::GetFullText( int unit ) const
372 {
373  if( m_id != REFERENCE )
374  return GetText();
375 
376  wxString text = GetText();
377  text << wxT( "?" );
378 
379  if( GetParent()->IsMulti() )
380  text << LIB_PART::SubReference( unit );
381 
382  return text;
383 }
384 
385 
387 {
388  /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
389  * calling GetTextBox() that works using top to bottom Y axis orientation.
390  */
391  EDA_RECT rect = GetTextBox( -1, -1, true );
392  rect.RevertYAxis();
393 
394  // We are using now a bottom to top Y axis.
395  wxPoint orig = rect.GetOrigin();
396  wxPoint end = rect.GetEnd();
397 
398  RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
399  RotatePoint( &end, GetTextPos(), -GetTextAngle() );
400 
401  rect.SetOrigin( orig );
402  rect.SetEnd( end );
403 
404  // We are using now a top to bottom Y axis:
405  rect.RevertYAxis();
406 
407  return rect;
408 }
409 
410 
411 void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
412 {
413  aCount = 1;
414 
415  switch( m_id )
416  {
417  case REFERENCE: aLayers[0] = LAYER_REFERENCEPART; break;
418  case VALUE: aLayers[0] = LAYER_VALUEPART; break;
419  default: aLayers[0] = LAYER_FIELDS; break;
420  }
421 }
422 
423 
425 {
426  switch( m_id )
427  {
429  case VALUE: return GetLayerColor( LAYER_VALUEPART );
430  default: return GetLayerColor( LAYER_FIELDS );
431  }
432 }
433 
434 
436 {
437  if( InEditMode() )
438  {
439  m_rotate = true;
440  }
441  else
442  {
444  }
445 }
446 
447 
448 wxString LIB_FIELD::GetName( bool aTranslate ) const
449 {
450  wxString name;
451 
452  switch( m_id )
453  {
454  case REFERENCE:
455  if( aTranslate )
456  name = _( "Reference" );
457  else
458  name = wxT( "Reference" );
459  break;
460 
461  case VALUE:
462  if( aTranslate )
463  name = _( "Value" );
464  else
465  name = wxT( "Value" );
466  break;
467 
468  case FOOTPRINT:
469  if( aTranslate )
470  name = _( "Footprint" );
471  else
472  name = wxT( "Footprint" );
473  break;
474 
475  case DATASHEET:
476  if( aTranslate )
477  name = _( "Datasheet" );
478  else
479  name = wxT( "Datasheet" );
480  break;
481 
482  default:
483  if( m_name.IsEmpty() )
484  {
485  if( aTranslate )
486  name.Printf( _( "Field%d" ), m_id );
487  else
488  name.Printf( wxT( "Field%d" ), m_id );
489  }
490  else
491  name = m_name;
492  }
493 
494  return name;
495 }
496 
497 
498 void LIB_FIELD::SetName( const wxString& aName )
499 {
500  // Mandatory field names are fixed.
501 
502  // So what? Why should the low level code be in charge of such a policy issue?
503  // Besides, m_id is a relic that is untrustworthy now.
504  if( m_id >=0 && m_id < MANDATORY_FIELDS )
505  {
506  DBG(printf( "trying to set a MANDATORY_FIELD's name\n" );)
507  return;
508  }
509 
510  if( m_name != aName )
511  {
512  m_name = aName;
513  SetModified();
514  }
515 }
516 
517 
518 void LIB_FIELD::SetText( const wxString& aText )
519 {
520  if( aText == GetText() )
521  return;
522 
523  wxString oldValue( m_Text );
524  wxString newValue( aText );
525 
526  if( InEditMode() )
527  {
528  m_Text = oldValue;
529  m_savedText = newValue;
530  m_updateText = true;
531  }
532  else
533  {
534  m_Text = newValue;
535  }
536 }
537 
538 
540 {
541  return wxString::Format( _( "Field %s \"%s\"" ), GetName(), ShortenedShownText() );
542 }
543 
544 
545 void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
546 {
547  wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
548  wxT( "Invalid edit mode for LIB_FIELD object." ) );
549 
550  if( aEditMode == IS_MOVED )
551  {
553  m_initialCursorPos = aPosition;
554  }
555  else
556  {
557  SetTextPos( aPosition );
558  }
559 
560  m_Flags = aEditMode;
561 }
562 
563 
564 bool LIB_FIELD::ContinueEdit( const wxPoint aPosition )
565 {
566  wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0, false,
567  wxT( "Bad call to ContinueEdit(). Text is not being edited." ) );
568 
569  return false;
570 }
571 
572 
573 void LIB_FIELD::EndEdit( const wxPoint& aPosition, bool aAbort )
574 {
575  wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
576  wxT( "Bad call to EndEdit(). Text is not being edited." ) );
577 
578  m_Flags = 0;
579  m_rotate = false;
580  m_updateText = 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( aUnits, aList );
614 
615  // Display style:
616  msg = GetTextStyleName();
617  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) );
618 
619  msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
620  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) );
621 
622  msg = MessageTextFromValue( aUnits, GetTextHeight(), true );
623  aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) );
624 
625  // Display field name (ref, value ...)
626  aList.push_back( MSG_PANEL_ITEM( _( "Field" ), GetName(), BROWN ) );
627 
628  // Display field text:
629  aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetShownText(), BROWN ) );
630 }
631 
632 
634 {
635  return move_xpm;
636 }
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:314
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:254
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:584
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:539
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:633
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_field.cpp:302
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:371
const EDA_RECT GetBoundingBox() const override
Definition: lib_field.cpp:386
bool m_updateText
Flag to indicate text change occurred while editing.
Definition: lib_field.h:66
COLOR4D GetDefaultColor() override
Definition: lib_field.cpp:424
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:498
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: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: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:573
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:189
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:411
#define VALUE
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:77
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:518
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:545
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_field.cpp:296
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:158
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:290
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:338
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:234
unsigned STATUS_FLAGS
Definition: base_struct.h:147
void Init(int idfield)
Object constructor initialization helper.
Definition: lib_field.cpp:88
wxPoint Centre() const
Definition: eda_rect.h:60
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:448
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:435
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:168
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:244
COLOR4D GetItemSelectedColor()
void SetOffset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_field.cpp:284
int GetPenSize() const override
Definition: lib_field.cpp:118
#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.
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:136
bool m_rotate
Flag to indicate a rotation occurred while editing.
Definition: lib_field.h:65
EDA_UNITS_T
Definition: common.h:160
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_field.cpp:564
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