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