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-2022 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
25#include <eda_item.h>
26#include <string_utils.h>
27#include <sch_draw_panel.h>
28#include <eda_draw_frame.h>
29#include <plotters/plotter.h>
30#include <trigo.h>
31#include <base_units.h>
32#include <widgets/msgpanel.h>
33#include <bitmaps.h>
34#include <general.h>
35#include <lib_symbol.h>
36#include <transform.h>
37#include <lib_field.h>
38#include <template_fieldnames.h>
40
41
42LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId ) :
43 LIB_ITEM( LIB_FIELD_T, aParent ),
45{
46 Init( aId );
47}
48
49
51 LIB_ITEM( LIB_FIELD_T, nullptr ),
53{
54 Init( aId );
55}
56
57
58LIB_FIELD::LIB_FIELD( int aId, const wxString& aName ) :
59 LIB_ITEM( LIB_FIELD_T, nullptr ),
61{
62 Init( aId );
63 m_name = aName;
64}
65
66
68{
69}
70
71
73{
74 m_id = field.m_id;
75 m_name = field.m_name;
76 m_parent = field.m_parent;
78 m_showName = field.m_showName;
81
82 SetText( field.GetText() );
83 SetAttributes( field );
84
85 return *this;
86}
87
88
89void LIB_FIELD::Init( int aId )
90{
91 wxCHECK2( aId >= 0, aId = MANDATORY_FIELDS );
92
93 m_id = aId;
94
95 SetTextAngle( ANGLE_HORIZONTAL ); // constructor already did this.
96
97 // Fields in RAM must always have names, because we are trying to get less dependent on
98 // field ids and more dependent on names. Plus assumptions are made in the field editors.
100
101 // By contrast, VALUE and REFERENCE are are always constructed as initially visible, and
102 // template fieldsnames' initial visibility is controlled by the template fieldname config.
103 if( aId == DATASHEET_FIELD || aId == FOOTPRINT_FIELD )
104 SetVisible( false );
105
106 m_autoAdded = false;
107 m_showName = false;
108 m_allowAutoPlace = true;
109 m_showInChooser = true;
110}
111
112
113void LIB_FIELD::SetId( int aId )
114{
115 wxCHECK2( aId >= 0, aId = MANDATORY_FIELDS );
116 m_id = aId;
117}
118
119
121{
123}
124
125
127{
129
130 if( !font )
132
133 return font;
134}
135
136
137void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
138 const TRANSFORM& aTransform, bool aDimmed )
139{
140 wxDC* DC = aSettings->GetPrintDC();
142 COLOR4D bg = aSettings->GetBackgroundColor();
143 bool blackAndWhiteMode = GetGRForceBlackPenState();
144 int penWidth = GetEffectivePenWidth( aSettings );
145 VECTOR2I text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
146 wxString text = aData ? *static_cast<wxString*>( aData ) : GetText();
147
148 if( blackAndWhiteMode || bg == COLOR4D::UNSPECIFIED )
149 bg = COLOR4D::WHITE;
150
151 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
153
154 if( aDimmed )
155 color = color.Mix( bg, 0.5f );
156
157 KIFONT::FONT* font = GetFont();
158
159 if( !font )
160 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
161
163 GetVertJustify(), penWidth, IsItalic(), IsBold(), font );
164}
165
166
167bool LIB_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
168{
169 // Because HitTest is mainly used to select the field return false if it is empty
170 if( GetText().IsEmpty() )
171 return false;
172
173 // Build a temporary copy of the text for hit testing
174 EDA_TEXT tmp_text( *this );
175
176 // Reference designator text has one or 2 additional character (displays U? or U?A)
177 if( m_id == REFERENCE_FIELD )
178 {
179 const LIB_SYMBOL* parent = dynamic_cast<const LIB_SYMBOL*>( m_parent );
180
181 wxString extended_text = tmp_text.GetText();
182 extended_text.Append('?');
183
184 if ( parent && parent->GetUnitCount() > 1 )
185 extended_text.Append('A');
186
187 tmp_text.SetText( extended_text );
188 }
189
191
192 // The text orientation may need to be flipped if the transformation matrix causes xy axes
193 // to be flipped. This simple algo works only for schematic matrix (rot 90 or/and mirror)
194 bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
196
197 return tmp_text.TextHitTest( aPosition, aAccuracy );
198}
199
200
202{
203 LIB_FIELD* newfield = new LIB_FIELD( m_id );
204
205 Copy( newfield );
206
207 return (EDA_ITEM*) newfield;
208}
209
210
211void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
212{
213 aTarget->m_name = m_name;
214 aTarget->m_showName = m_showName;
217
218 aTarget->CopyText( *this );
219 aTarget->SetAttributes( *this );
220 aTarget->SetParent( m_parent );
221 aTarget->SetAutoAdded( IsAutoAdded() );
222}
223
224
225int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
226{
227 wxASSERT( aOther.Type() == LIB_FIELD_T );
228
229 int retv = LIB_ITEM::compare( aOther, aCompareFlags );
230
231 if( retv )
232 return retv;
233
234 const LIB_FIELD* tmp = ( LIB_FIELD* ) &aOther;
235
236 // Equality test will vary depending whether or not the field is mandatory. Otherwise,
237 // sorting is done by ordinal.
238 if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
239 {
240 // Mandatory fields have fixed ordinals and their names can vary due to translated field
241 // names. Optional fields have fixed names and their ordinals can vary.
242 if( IsMandatory() )
243 {
244 if( m_id != tmp->m_id )
245 return m_id - tmp->m_id;
246 }
247 else
248 {
249 retv = m_name.Cmp( tmp->m_name );
250
251 if( retv )
252 return retv;
253 }
254 }
255 else
256 {
257 if( m_id != tmp->m_id )
258 return m_id - tmp->m_id;
259 }
260
261 retv = GetText().CmpNoCase( tmp->GetText() );
262
263 if( retv != 0 )
264 return retv;
265
266 if( GetTextPos().x != tmp->GetTextPos().x )
267 return GetTextPos().x - tmp->GetTextPos().x;
268
269 if( GetTextPos().y != tmp->GetTextPos().y )
270 return GetTextPos().y - tmp->GetTextPos().y;
271
272 if( GetTextWidth() != tmp->GetTextWidth() )
273 return GetTextWidth() - tmp->GetTextWidth();
274
275 if( GetTextHeight() != tmp->GetTextHeight() )
276 return GetTextHeight() - tmp->GetTextHeight();
277
278 return 0;
279}
280
281
282void LIB_FIELD::Offset( const VECTOR2I& aOffset )
283{
284 EDA_TEXT::Offset( aOffset );
285}
286
287
288void LIB_FIELD::MoveTo( const VECTOR2I& 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
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
318void LIB_FIELD::Rotate( const VECTOR2I& center, bool aRotateCCW )
319{
320 EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90;
321
322 VECTOR2I pt = GetTextPos();
323 RotatePoint( pt, center, rot_angle );
324 SetTextPos( pt );
325
327}
328
329
330void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
331 const TRANSFORM& aTransform, bool aDimmed ) const
332{
333 if( GetText().IsEmpty() || aBackground )
334 return;
335
336 RENDER_SETTINGS* renderSettings = aPlotter->RenderSettings();
337
338 // Calculate the text orientation, according to the symbol orientation/mirror.
339 EDA_ANGLE orient = GetTextAngle();
340
341 if( aTransform.y1 ) // Rotate symbol 90 deg.
342 {
343 if( orient.IsHorizontal() )
344 orient = ANGLE_VERTICAL;
345 else
346 orient = ANGLE_HORIZONTAL;
347 }
348
349 BOX2I bbox = GetBoundingBox();
350 bbox.RevertYAxis();
351
354 VECTOR2I textpos = aTransform.TransformCoordinate( bbox.Centre() ) + aOffset;
355
357 COLOR4D bg;
358
359 if( aPlotter->GetColorMode() )
360 {
361 if( GetTextColor() != COLOR4D::UNSPECIFIED )
363 else
364 color = renderSettings->GetLayerColor( GetDefaultLayer() );
365
366 bg = renderSettings->GetBackgroundColor();
367
368 if( bg == COLOR4D::UNSPECIFIED )
369 bg = COLOR4D::WHITE;
370 }
371 else
372 {
374 bg = COLOR4D::WHITE;
375 }
376
377 if( aDimmed )
378 color = color.Mix( bg, 0.5f );
379
380 int penWidth = GetEffectivePenWidth( renderSettings );
381 KIFONT::FONT* font = GetFont();
382
383 if( !font )
384 font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
385
386 aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,
387 penWidth, IsItalic(), IsBold(), false, font );
388}
389
390
391wxString LIB_FIELD::GetFullText( int unit ) const
392{
393 if( m_id != REFERENCE_FIELD )
394 return GetText();
395
396 wxString text = GetText();
397 text << wxT( "?" );
398
399 wxCHECK( GetParent(), text );
400
401 if( GetParent()->IsMulti() )
403
404 return text;
405}
406
407
408wxString LIB_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const
409{
410 wxString text = EDA_TEXT::GetShownText( aDepth );
411
412 if( IsNameShown() )
413 text = GetName() << wxT( ": " ) << text;
414
415 return text;
416}
417
418
420{
421 /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
422 * calling GetTextBox() that works using top to bottom Y axis orientation.
423 */
424 BOX2I bbox = GetTextBox( -1, true );
425 bbox.RevertYAxis();
426
427 // We are using now a bottom to top Y axis.
428 VECTOR2I orig = bbox.GetOrigin();
429 VECTOR2I end = bbox.GetEnd();
430
431 RotatePoint( orig, GetTextPos(), -GetTextAngle() );
432 RotatePoint( end, GetTextPos(), -GetTextAngle() );
433
434 bbox.SetOrigin( orig );
435 bbox.SetEnd( end );
436
437 // We are using now a top to bottom Y axis:
438 bbox.RevertYAxis();
439
440 return bbox;
441}
442
443
444void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
445{
446 aCount = 2;
447
448 switch( m_id )
449 {
450 case REFERENCE_FIELD: aLayers[0] = LAYER_REFERENCEPART; break;
451 case VALUE_FIELD: aLayers[0] = LAYER_VALUEPART; break;
452 default: aLayers[0] = LAYER_FIELDS; break;
453 }
454
455 aLayers[1] = LAYER_SELECTION_SHADOWS;
456}
457
458
460{
461 switch( m_id )
462 {
464 case VALUE_FIELD: return LAYER_VALUEPART;
465 default: return LAYER_FIELDS;
466 }
467}
468
469
470wxString LIB_FIELD::GetName( bool aUseDefaultName ) const
471{
472 if( m_name.IsEmpty() && aUseDefaultName )
474
475 return m_name;
476}
477
478
480{
481 switch( m_id )
482 {
483 case REFERENCE_FIELD:
484 case VALUE_FIELD:
485 case FOOTPRINT_FIELD:
486 case DATASHEET_FIELD:
488 }
489
490 return m_name;
491}
492
493
494void LIB_FIELD::SetName( const wxString& aName )
495{
496 // Mandatory field names are fixed.
497 if( IsMandatory() )
498 {
499 wxFAIL_MSG( "trying to set a MANDATORY_FIELD's name\n" );
500 return;
501 }
502
503 if( m_name != aName )
504 {
505 m_name = aName;
506 SetModified();
507 }
508}
509
510
511wxString LIB_FIELD::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
512{
514}
515
516
517void LIB_FIELD::BeginEdit( const VECTOR2I& aPosition )
518{
519 SetTextPos( aPosition );
520}
521
522
523void LIB_FIELD::CalcEdit( const VECTOR2I& aPosition )
524{
525 SetTextPos( aPosition );
526}
527
528
529void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
530{
531 wxString msg;
532
533 LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
534
535 aList.emplace_back( _( "Field" ), GetName() );
536
537 // Don't use GetShownText() here; we want to show the user the variable references
538 aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
539
540 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
541
542 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
543
544 aList.emplace_back( _( "Style" ), GetTextStyleName() );
545
546 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
547
548 switch ( GetHorizJustify() )
549 {
550 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
551 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
552 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
553 }
554
555 aList.emplace_back( _( "H Justification" ), msg );
556
557 switch ( GetVertJustify() )
558 {
559 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
560 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
561 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
562 }
563
564 aList.emplace_back( _( "V Justification" ), msg );
565}
566
567
569{
570 return BITMAPS::move;
571}
572
573
575{
576 return m_id >= 0 && m_id < MANDATORY_FIELDS;
577}
int color
Definition: DXF_plotter.cpp:57
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
void SetOrigin(const Vec &pos)
Definition: box2.h:202
const Vec & GetOrigin() const
Definition: box2.h:183
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: box2.h:689
const Vec GetEnd() const
Definition: box2.h:185
Vec Centre() const
Definition: box2.h:70
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
bool IsHorizontal() const
Definition: eda_angle.h:174
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
void SetModified()
Definition: eda_item.cpp:64
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:498
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
int GetTextHeight() const
Definition: eda_text.h:195
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:503
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:201
COLOR4D GetTextColor() const
Definition: eda_text.h:198
wxString GetTextStyleName() const
Definition: eda_text.cpp:736
bool IsItalic() const
Definition: eda_text.h:123
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
Definition: eda_text.cpp:264
virtual bool IsVisible() const
Definition: eda_text.h:129
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:371
void SetTextX(int aX)
Definition: eda_text.cpp:377
KIFONT::FONT * GetFont() const
Definition: eda_text.h:181
void SetTextY(int aY)
Definition: eda_text.cpp:383
int GetTextWidth() const
Definition: eda_text.h:192
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:389
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:142
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:623
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
bool IsBold() const
Definition: eda_text.h:126
void CopyText(const EDA_TEXT &aSrc)
Definition: eda_text.cpp:174
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:145
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
VECTOR2I GetTextSize() const
Definition: eda_text.h:189
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
wxDC * GetPrintDC() const
Field object used in symbol libraries.
Definition: lib_field.h:60
bool IsAutoAdded() const
Definition: lib_field.h:178
bool m_allowAutoPlace
This field can be autoplaced when converted to a SCH_FIELD.
Definition: lib_field.h:228
void SetAutoAdded(bool aAutoAdded)
Definition: lib_field.h:179
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_field.cpp:201
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_field.cpp:282
void Init(int aId)
Object constructor initialization helper.
Definition: lib_field.cpp:89
bool m_autoAdded
Was this field automatically added to a LIB_SYMBOL?
Definition: lib_field.h:226
int m_id
Definition: lib_field.h:224
KIFONT::FONT * getDrawFont() const override
Definition: lib_field.cpp:126
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_field.cpp:318
wxString m_name
Name (not the field text value itself, that is #EDA_TEXT::m_Text)
Definition: lib_field.h:225
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: lib_field.cpp:444
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the field.
Definition: lib_field.cpp:137
SCH_LAYER_ID GetDefaultLayer() const
Definition: lib_field.cpp:459
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Definition: lib_field.cpp:330
void SetId(int aId)
Definition: lib_field.cpp:113
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:494
void Copy(LIB_FIELD *aTarget) const
Copy parameters of this field to another field.
Definition: lib_field.cpp:211
bool m_showInChooser
This field is available as a data column for the chooser.
Definition: lib_field.h:229
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:391
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: lib_field.cpp:470
bool IsNameShown() const
Definition: lib_field.h:181
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_field.cpp:517
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: lib_field.cpp:479
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_field.cpp:568
int GetPenWidth() const override
Definition: lib_field.cpp:120
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_field.cpp:294
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the new circle at aPosition when editing.
Definition: lib_field.cpp:523
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_field.cpp:306
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_field.cpp:419
bool IsMandatory() const
Definition: lib_field.cpp:574
LIB_FIELD(int aId=2)
Definition: lib_field.cpp:50
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_field.cpp:288
LIB_FIELD & operator=(const LIB_FIELD &field)
Definition: lib_field.cpp:72
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: lib_field.cpp:511
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: lib_field.cpp:529
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: lib_field.cpp:167
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: lib_field.cpp:408
bool m_showName
Render the field's name in addition to its value.
Definition: lib_field.h:227
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_field.cpp:225
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
const wxString & GetDefaultFont() const
Definition: lib_item.cpp:128
virtual int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_item.cpp:74
virtual int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const
Definition: lib_item.h:155
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_item.cpp:47
LIB_SYMBOL * GetParent() const
Definition: lib_item.h:168
Define a library symbol object.
Definition: lib_symbol.h:98
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:588
int GetUnitCount() const override
For items with units, return the number of units.
Base plotter engine class.
Definition: plotter.h:110
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
Definition: plotter.cpp:714
bool GetColorMode() const
Definition: plotter.h:138
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:47
int y1
Definition: transform.h:50
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
int x1
Definition: transform.h:49
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
@ WHITE
Definition: color4d.h:48
@ BLACK
Definition: color4d.h:44
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:409
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
TRANSFORM DefaultTransform
Definition: eeschema.cpp:68
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:156
void GRPrintText(wxDC *aDC, const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, KIFONT::FONT *aFont)
Print a graphic text through wxDC.
Definition: gr_text.cpp:129
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:341
@ LAYER_HIDDEN
Definition: layer_ids.h:380
@ LAYER_VALUEPART
Definition: layer_ids.h:353
@ LAYER_FIELDS
Definition: layer_ids.h:354
@ LAYER_REFERENCEPART
Definition: layer_ids.h:352
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:381
Message panel definition file.
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:203
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString UnescapeString(const wxString &aSource)
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
GR_TEXT_V_ALIGN_T
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
@ LIB_FIELD_T
Definition: typeinfo.h:208