KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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) 2022 CERN
6 * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <eda_item.h>
27#include <string_utils.h>
28#include <sch_draw_panel.h>
29#include <eda_draw_frame.h>
30#include <plotters/plotter.h>
31#include <font/font.h>
32#include <trigo.h>
33#include <base_units.h>
34#include <widgets/msgpanel.h>
35#include <bitmaps.h>
36#include <lib_symbol.h>
37#include <transform.h>
38#include <template_fieldnames.h>
40
41
42LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId, const wxString& aName ) :
43 LIB_ITEM( LIB_FIELD_T, aParent ),
45{
46 Init( aId );
47 m_name = aName;
48}
49
50
52 LIB_ITEM( LIB_FIELD_T, nullptr ),
54{
55 Init( aId );
56}
57
58
59LIB_FIELD::LIB_FIELD( int aId, const wxString& aName ) :
60 LIB_ITEM( LIB_FIELD_T, nullptr ),
62{
63 Init( aId );
64 m_name = aName;
65}
66
67
69{
70 m_id = field.m_id;
71 m_name = field.m_name;
72 m_parent = field.m_parent;
74 m_showName = field.m_showName;
77
78 SetText( field.GetText() );
79 SetAttributes( field );
80
81 return *this;
82}
83
84
85void LIB_FIELD::Init( int aId )
86{
87 m_id = aId;
88
89 SetTextAngle( ANGLE_HORIZONTAL ); // constructor already did this.
90
91 // Fields in RAM must always have names, because we are trying to get less dependent on
92 // field ids and more dependent on names. Plus assumptions are made in the field editors.
94
95 // By contrast, VALUE and REFERENCE are are always constructed as initially visible, and
96 // template fieldsnames' initial visibility is controlled by the template fieldname config.
97 if( aId != VALUE_FIELD && aId != REFERENCE_FIELD && aId < MANDATORY_FIELDS )
98 SetVisible( false );
99
100 m_autoAdded = false;
101 m_showName = false;
102 m_allowAutoPlace = true;
103 m_showInChooser = true;
104}
105
106
107void LIB_FIELD::SetId( int aId )
108{
109 m_id = aId;
110}
111
112
114{
116}
117
118
120{
122
123 if( !font )
125
126 return font;
127}
128
129
130void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
131 const TRANSFORM& aTransform, bool aDimmed )
132{
133 wxDC* DC = aSettings->GetPrintDC();
135 COLOR4D bg = aSettings->GetBackgroundColor();
136 bool blackAndWhiteMode = GetGRForceBlackPenState();
137 int penWidth = GetEffectivePenWidth( aSettings );
138 VECTOR2I text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
139 wxString text = aData ? *static_cast<wxString*>( aData ) : GetText();
140
141 if( blackAndWhiteMode || bg == COLOR4D::UNSPECIFIED )
142 bg = COLOR4D::WHITE;
143
144 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
146
147 if( aDimmed )
148 {
149 color.Desaturate( );
150 color = color.Mix( bg, 0.5f );
151 }
152
153 KIFONT::FONT* font = GetFont();
154
155 if( !font )
156 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
157
159 GetVertJustify(), penWidth, IsItalic(), IsBold(), font, GetFontMetrics() );
160}
161
162
163bool LIB_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
164{
165 // Because HitTest is mainly used to select the field return false if it is empty
166 if( GetText().IsEmpty() )
167 return false;
168
169 // Build a temporary copy of the text for hit testing
170 EDA_TEXT tmp_text( *this );
171
172 // Reference designator text has one or 2 additional character (displays U? or U?A)
173 if( m_id == REFERENCE_FIELD )
174 {
175 const LIB_SYMBOL* parent = dynamic_cast<const LIB_SYMBOL*>( m_parent );
176
177 wxString extended_text = tmp_text.GetText();
178 extended_text.Append('?');
179
180 if ( parent && parent->GetUnitCount() > 1 )
181 extended_text.Append('A');
182
183 tmp_text.SetText( extended_text );
184 }
185
187
188 // The text orientation may need to be flipped if the transformation matrix causes xy axes
189 // to be flipped. This simple algo works only for schematic matrix (rot 90 or/and mirror)
190 bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
192
193 return tmp_text.TextHitTest( aPosition, aAccuracy );
194}
195
196
198{
199 LIB_FIELD* newfield = new LIB_FIELD( m_id );
200
201 Copy( newfield );
202
203 return (EDA_ITEM*) newfield;
204}
205
206
207void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
208{
209 aTarget->m_name = m_name;
210 aTarget->m_showName = m_showName;
213
214 aTarget->CopyText( *this );
215 aTarget->SetAttributes( *this );
216 aTarget->SetParent( m_parent );
217 aTarget->SetAutoAdded( IsAutoAdded() );
218}
219
220
221int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
222{
223 wxASSERT( aOther.Type() == LIB_FIELD_T );
224
225 int retv = LIB_ITEM::compare( aOther, aCompareFlags );
226
227 if( retv )
228 return retv;
229
230 const LIB_FIELD* tmp = ( LIB_FIELD* ) &aOther;
231
232 // Equality test will vary depending whether or not the field is mandatory. Otherwise,
233 // sorting is done by ordinal.
234 if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
235 {
236 // Mandatory fields have fixed ordinals and their names can vary due to translated field
237 // names. Optional fields have fixed names and their ordinals can vary.
238 if( IsMandatory() )
239 {
240 if( m_id != tmp->m_id )
241 return m_id - tmp->m_id;
242 }
243 else
244 {
245 retv = m_name.Cmp( tmp->m_name );
246
247 if( retv )
248 return retv;
249 }
250 }
251 else // assume we're sorting
252 {
253 if( m_id != tmp->m_id )
254 return m_id - tmp->m_id;
255 }
256
257 bool ignoreFieldText = false;
258
259 if( m_id == REFERENCE_FIELD && ( aCompareFlags & COMPARE_FLAGS::EQUALITY ) )
260 ignoreFieldText = true;
261
262 if( m_id == VALUE_FIELD && ( aCompareFlags & COMPARE_FLAGS::ERC ) )
263 ignoreFieldText = true;
264
265 if( !ignoreFieldText )
266 {
267 retv = GetText().CmpNoCase( tmp->GetText() );
268
269 if( retv != 0 )
270 return retv;
271 }
272
273 if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
274 {
275 if( GetTextPos().x != tmp->GetTextPos().x )
276 return GetTextPos().x - tmp->GetTextPos().x;
277
278 if( GetTextPos().y != tmp->GetTextPos().y )
279 return GetTextPos().y - tmp->GetTextPos().y;
280 }
281
282 if( GetTextWidth() != tmp->GetTextWidth() )
283 return GetTextWidth() - tmp->GetTextWidth();
284
285 if( GetTextHeight() != tmp->GetTextHeight() )
286 return GetTextHeight() - tmp->GetTextHeight();
287
288 return 0;
289}
290
291
292void LIB_FIELD::Offset( const VECTOR2I& aOffset )
293{
294 EDA_TEXT::Offset( aOffset );
295}
296
297
298void LIB_FIELD::MoveTo( const VECTOR2I& newPosition )
299{
300 EDA_TEXT::SetTextPos( newPosition );
301}
302
303
305{
306 int x = GetTextPos().x;
307
308 x -= center.x;
309 x *= -1;
310 x += center.x;
311
312 SetTextX( x );
313}
314
315
317{
318 int y = GetTextPos().y;
319
320 y -= center.y;
321 y *= -1;
322 y += center.y;
323
324 SetTextY( y );
325}
326
327
328void LIB_FIELD::Rotate( const VECTOR2I& center, bool aRotateCCW )
329{
330 EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90;
331
332 VECTOR2I pt = GetTextPos();
333 RotatePoint( pt, center, rot_angle );
334 SetTextPos( pt );
335
337}
338
339
340void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
341 const TRANSFORM& aTransform, bool aDimmed ) const
342{
343 if( GetText().IsEmpty() || aBackground )
344 return;
345
346 RENDER_SETTINGS* renderSettings = aPlotter->RenderSettings();
347
348 // Calculate the text orientation, according to the symbol orientation/mirror.
349 EDA_ANGLE orient = GetTextAngle();
350
351 if( aTransform.y1 ) // Rotate symbol 90 deg.
352 {
353 if( orient.IsHorizontal() )
354 orient = ANGLE_VERTICAL;
355 else
356 orient = ANGLE_HORIZONTAL;
357 }
358
359 BOX2I bbox = GetBoundingBox();
360 bbox.RevertYAxis();
361
364 VECTOR2I textpos = aTransform.TransformCoordinate( bbox.Centre() ) + aOffset;
365
367 COLOR4D bg;
368
369 if( aPlotter->GetColorMode() )
370 {
371 if( GetTextColor() != COLOR4D::UNSPECIFIED )
373 else
374 color = renderSettings->GetLayerColor( GetDefaultLayer() );
375
376 bg = renderSettings->GetBackgroundColor();
377
378 if( bg == COLOR4D::UNSPECIFIED )
379 bg = COLOR4D::WHITE;
380 }
381 else
382 {
383 color = COLOR4D::BLACK;
384 bg = COLOR4D::WHITE;
385 }
386
387 if( aDimmed )
388 {
389 color.Desaturate( );
390 color = color.Mix( bg, 0.5f );
391 }
392
393 int penWidth = GetEffectivePenWidth( renderSettings );
394 KIFONT::FONT* font = GetFont();
395
396 if( !font )
397 font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() );
398
400 attrs.m_StrokeWidth = penWidth;
401 attrs.m_Halign = hjustify;
402 attrs.m_Valign = vjustify;
403 attrs.m_Angle = orient;
404 attrs.m_Multiline = false;
405
406 aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font, GetFontMetrics() );
407}
408
409
410wxString LIB_FIELD::GetFullText( int unit ) const
411{
412 if( m_id != REFERENCE_FIELD )
413 return GetText();
414
415 wxString text = GetText();
416 text << wxT( "?" );
417
418 wxCHECK( GetParent(), text );
419
420 if( GetParent()->IsMulti() )
422
423 return text;
424}
425
426
427wxString LIB_FIELD::GetShownText( bool aAllowExtraText, int aDepth ) const
428{
429 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
430
431 if( IsNameShown() && aAllowExtraText )
432 text = GetName() << wxT( ": " ) << text;
433
434 return text;
435}
436
437
439{
440 /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
441 * calling GetTextBox() that works using top to bottom Y axis orientation.
442 */
443 BOX2I bbox = GetTextBox( -1, true );
444 bbox.RevertYAxis();
445
446 // We are using now a bottom to top Y axis.
447 VECTOR2I orig = bbox.GetOrigin();
448 VECTOR2I end = bbox.GetEnd();
449
450 RotatePoint( orig, GetTextPos(), -GetTextAngle() );
451 RotatePoint( end, GetTextPos(), -GetTextAngle() );
452
453 bbox.SetOrigin( orig );
454 bbox.SetEnd( end );
455
456 // We are using now a top to bottom Y axis:
457 bbox.RevertYAxis();
458
459 return bbox;
460}
461
462
463void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
464{
465 aCount = 2;
466
467 switch( m_id )
468 {
469 case REFERENCE_FIELD: aLayers[0] = LAYER_REFERENCEPART; break;
470 case VALUE_FIELD: aLayers[0] = LAYER_VALUEPART; break;
471 default: aLayers[0] = LAYER_FIELDS; break;
472 }
473
474 aLayers[1] = LAYER_SELECTION_SHADOWS;
475}
476
477
479{
480 switch( m_id )
481 {
483 case VALUE_FIELD: return LAYER_VALUEPART;
484 default: return LAYER_FIELDS;
485 }
486}
487
488
489wxString LIB_FIELD::GetName( bool aUseDefaultName ) const
490{
491 if( m_name.IsEmpty() && aUseDefaultName )
493
494 return m_name;
495}
496
497
499{
500 if( m_id < MANDATORY_FIELDS )
502
503 return m_name;
504}
505
506
507void LIB_FIELD::SetName( const wxString& aName )
508{
509 // Mandatory field names are fixed.
510 if( IsMandatory() )
511 {
512 wxFAIL_MSG( wxS( "trying to set a MANDATORY_FIELD's name\n" ) );
513 return;
514 }
515
516 m_name = aName;
517}
518
519
520wxString LIB_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
521{
522 return wxString::Format( "%s '%s'",
525}
526
527
528void LIB_FIELD::BeginEdit( const VECTOR2I& aPosition )
529{
530 SetTextPos( aPosition );
531}
532
533
534void LIB_FIELD::CalcEdit( const VECTOR2I& aPosition )
535{
536 SetTextPos( aPosition );
537}
538
539
540void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
541{
542 wxString msg;
543
544 LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
545
546 // Don't use GetShownText(); we want to see the variable references here
547 aList.emplace_back( _( "Field" ), UnescapeString( GetName() ) );
548
549 // Don't use GetShownText() here; we want to show the user the variable references
550 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
551
552 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
553
554 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
555
556 aList.emplace_back( _( "Style" ), GetTextStyleName() );
557
558 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
559
560 switch ( GetHorizJustify() )
561 {
562 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
563 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
564 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
565 }
566
567 aList.emplace_back( _( "H Justification" ), msg );
568
569 switch ( GetVertJustify() )
570 {
571 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
572 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
573 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
574 }
575
576 aList.emplace_back( _( "V Justification" ), msg );
577}
578
579
581{
582 return BITMAPS::move;
583}
584
585
587{
588 return m_id >= 0 && m_id < MANDATORY_FIELDS;
589}
590
591
592static struct LIB_FIELD_DESC
593{
595 {
602
603 propMgr.AddProperty( new PROPERTY<LIB_FIELD, bool>( _HKI( "Show Field Name" ),
605
606 propMgr.AddProperty( new PROPERTY<LIB_FIELD, bool>( _HKI( "Allow Autoplacement" ),
608
609 propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) );
610 propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Thickness" ) );
611 propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) );
612 propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
613 propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) );
614 propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) );
615
616 propMgr.Mask( TYPE_HASH( LIB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) );
617 }
int color
Definition: DXF_plotter.cpp:58
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:203
const Vec & GetOrigin() const
Definition: box2.h:184
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: box2.h:690
const Vec GetEnd() const
Definition: box2.h:186
Vec Centre() const
Definition: box2.h:71
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:256
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
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:485
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
int GetTextHeight() const
Definition: eda_text.h:213
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:546
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:219
COLOR4D GetTextColor() const
Definition: eda_text.h:216
wxString GetTextStyleName() const
Definition: eda_text.cpp:791
bool IsItalic() const
Definition: eda_text.h:141
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
virtual bool IsVisible() const
Definition: eda_text.h:147
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:398
void SetTextX(int aX)
Definition: eda_text.cpp:404
KIFONT::FONT * GetFont() const
Definition: eda_text.h:199
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:273
void SetTextY(int aY)
Definition: eda_text.cpp:410
int GetTextWidth() const
Definition: eda_text.h:210
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:416
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:160
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:226
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:677
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:183
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:305
bool IsBold() const
Definition: eda_text.h:144
void CopyText(const EDA_TEXT &aSrc)
Definition: eda_text.cpp:187
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:163
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:106
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:180
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:202
VECTOR2I GetTextSize() const
Definition: eda_text.h:207
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:146
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:62
bool IsAutoAdded() const
Definition: lib_field.h:189
bool m_allowAutoPlace
This field can be autoplaced when converted to a SCH_FIELD.
Definition: lib_field.h:239
void SetAutoAdded(bool aAutoAdded)
Definition: lib_field.h:190
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_field.cpp:197
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_field.cpp:292
void Init(int aId)
Object constructor initialization helper.
Definition: lib_field.cpp:85
bool m_autoAdded
Was this field automatically added to a LIB_SYMBOL?
Definition: lib_field.h:237
int m_id
Definition: lib_field.h:235
KIFONT::FONT * getDrawFont() const override
Definition: lib_field.cpp:119
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_field.cpp:328
wxString m_name
Name (not the field text value itself, that is #EDA_TEXT::m_Text)
Definition: lib_field.h:236
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:463
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the field.
Definition: lib_field.cpp:130
bool CanAutoplace() const
Definition: lib_field.h:195
SCH_LAYER_ID GetDefaultLayer() const
Definition: lib_field.cpp:478
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:340
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: lib_field.cpp:520
void SetId(int aId)
Definition: lib_field.cpp:107
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:507
void Copy(LIB_FIELD *aTarget) const
Copy parameters of this field to another field.
Definition: lib_field.cpp:207
bool m_showInChooser
This field is available as a data column for the chooser.
Definition: lib_field.h:240
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:410
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: lib_field.cpp:489
bool IsNameShown() const
Definition: lib_field.h:192
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_field.cpp:528
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:498
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_field.cpp:580
int GetPenWidth() const override
Definition: lib_field.cpp:113
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: lib_field.cpp:427
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_field.cpp:304
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the new circle at aPosition when editing.
Definition: lib_field.cpp:534
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_field.cpp:316
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_field.cpp:438
bool IsMandatory() const
Definition: lib_field.cpp:586
LIB_FIELD(int aId=2)
Definition: lib_field.cpp:51
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_field.cpp:298
void SetNameShown(bool aShown=true)
Definition: lib_field.h:193
LIB_FIELD & operator=(const LIB_FIELD &field)
Definition: lib_field.cpp:68
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:540
void SetCanAutoplace(bool aCanPlace)
Definition: lib_field.h:196
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:163
bool m_showName
Render the field's name in addition to its value.
Definition: lib_field.h:238
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:221
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
const wxString & GetDefaultFont() const
Definition: lib_item.cpp:142
@ EQUALITY
Definition: lib_item.h:92
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:73
virtual int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const
Definition: lib_item.h:189
const KIFONT::METRICS & GetFontMetrics() const
Definition: lib_item.cpp:150
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:46
LIB_SYMBOL * GetParent() const
Definition: lib_item.h:202
Define a library symbol object.
Definition: lib_symbol.h:99
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:770
int GetUnitCount() const override
For items with units, return the number of units.
Base plotter engine class.
Definition: plotter.h:104
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:135
bool GetColorMode() const
Definition: plotter.h:132
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Definition: plotter.cpp:753
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
int y1
Definition: transform.h:49
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:44
int x1
Definition: transform.h:48
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:433
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:434
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:439
TRANSFORM DefaultTransform
Definition: transform.cpp:32
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
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, const KIFONT::METRICS &aFontMetrics)
Print a graphic text through wxDC.
Definition: gr_text.cpp:142
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:346
@ LAYER_HIDDEN
Definition: layer_ids.h:386
@ LAYER_VALUEPART
Definition: layer_ids.h:358
@ LAYER_FIELDS
Definition: layer_ids.h:359
@ LAYER_REFERENCEPART
Definition: layer_ids.h:357
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:387
static struct LIB_FIELD_DESC _LIB_FIELD_DESC
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:219
wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Definition: ui_common.cpp:201
#define TYPE_HASH(x)
Definition: property.h:64
#define REGISTER_TYPE(x)
Definition: property_mgr.h:356
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.
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 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:207