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) 2022 CERN
6 * Copyright (C) 2004-2022 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 <trigo.h>
32#include <base_units.h>
33#include <widgets/msgpanel.h>
34#include <bitmaps.h>
35#include <general.h>
36#include <lib_symbol.h>
37#include <transform.h>
38#include <lib_field.h>
39#include <template_fieldnames.h>
41
42
43LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId, const wxString& aName ) :
44 LIB_ITEM( LIB_FIELD_T, aParent ),
46{
47 Init( aId );
48 m_name = aName;
49}
50
51
53 LIB_ITEM( LIB_FIELD_T, nullptr ),
55{
56 Init( aId );
57}
58
59
60LIB_FIELD::LIB_FIELD( int aId, const wxString& aName ) :
61 LIB_ITEM( LIB_FIELD_T, nullptr ),
63{
64 Init( aId );
65 m_name = aName;
66}
67
68
70{
71 m_id = field.m_id;
72 m_name = field.m_name;
73 m_parent = field.m_parent;
75 m_showName = field.m_showName;
78
79 SetText( field.GetText() );
80 SetAttributes( field );
81
82 return *this;
83}
84
85
86void LIB_FIELD::Init( int aId )
87{
88 m_id = aId;
89
90 SetTextAngle( ANGLE_HORIZONTAL ); // constructor already did this.
91
92 // Fields in RAM must always have names, because we are trying to get less dependent on
93 // field ids and more dependent on names. Plus assumptions are made in the field editors.
95
96 // By contrast, VALUE and REFERENCE are are always constructed as initially visible, and
97 // template fieldsnames' initial visibility is controlled by the template fieldname config.
98 if( aId == DATASHEET_FIELD || aId == FOOTPRINT_FIELD )
99 SetVisible( false );
100
101 m_autoAdded = false;
102 m_showName = false;
103 m_allowAutoPlace = true;
104 m_showInChooser = true;
105}
106
107
108void LIB_FIELD::SetId( int aId )
109{
110 m_id = aId;
111}
112
113
115{
117}
118
119
121{
123
124 if( !font )
126
127 return font;
128}
129
130
131void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
132 const TRANSFORM& aTransform, bool aDimmed )
133{
134 wxDC* DC = aSettings->GetPrintDC();
136 COLOR4D bg = aSettings->GetBackgroundColor();
137 bool blackAndWhiteMode = GetGRForceBlackPenState();
138 int penWidth = GetEffectivePenWidth( aSettings );
139 VECTOR2I text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
140 wxString text = aData ? *static_cast<wxString*>( aData ) : GetText();
141
142 if( blackAndWhiteMode || bg == COLOR4D::UNSPECIFIED )
143 bg = COLOR4D::WHITE;
144
145 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
147
148 if( aDimmed )
149 {
150 color.Desaturate( );
151 color = color.Mix( bg, 0.5f );
152 }
153
154 KIFONT::FONT* font = GetFont();
155
156 if( !font )
157 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
158
160 GetVertJustify(), penWidth, IsItalic(), IsBold(), font );
161}
162
163
164bool LIB_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
165{
166 // Because HitTest is mainly used to select the field return false if it is empty
167 if( GetText().IsEmpty() )
168 return false;
169
170 // Build a temporary copy of the text for hit testing
171 EDA_TEXT tmp_text( *this );
172
173 // Reference designator text has one or 2 additional character (displays U? or U?A)
174 if( m_id == REFERENCE_FIELD )
175 {
176 const LIB_SYMBOL* parent = dynamic_cast<const LIB_SYMBOL*>( m_parent );
177
178 wxString extended_text = tmp_text.GetText();
179 extended_text.Append('?');
180
181 if ( parent && parent->GetUnitCount() > 1 )
182 extended_text.Append('A');
183
184 tmp_text.SetText( extended_text );
185 }
186
188
189 // The text orientation may need to be flipped if the transformation matrix causes xy axes
190 // to be flipped. This simple algo works only for schematic matrix (rot 90 or/and mirror)
191 bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL );
193
194 return tmp_text.TextHitTest( aPosition, aAccuracy );
195}
196
197
199{
200 LIB_FIELD* newfield = new LIB_FIELD( m_id );
201
202 Copy( newfield );
203
204 return (EDA_ITEM*) newfield;
205}
206
207
208void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
209{
210 aTarget->m_name = m_name;
211 aTarget->m_showName = m_showName;
214
215 aTarget->CopyText( *this );
216 aTarget->SetAttributes( *this );
217 aTarget->SetParent( m_parent );
218 aTarget->SetAutoAdded( IsAutoAdded() );
219}
220
221
222int LIB_FIELD::compare( const LIB_ITEM& aOther, int aCompareFlags ) const
223{
224 wxASSERT( aOther.Type() == LIB_FIELD_T );
225
226 int retv = LIB_ITEM::compare( aOther, aCompareFlags );
227
228 if( retv )
229 return retv;
230
231 const LIB_FIELD* tmp = ( LIB_FIELD* ) &aOther;
232
233 // Equality test will vary depending whether or not the field is mandatory. Otherwise,
234 // sorting is done by ordinal.
235 if( aCompareFlags & LIB_ITEM::COMPARE_FLAGS::EQUALITY )
236 {
237 // Mandatory fields have fixed ordinals and their names can vary due to translated field
238 // names. Optional fields have fixed names and their ordinals can vary.
239 if( IsMandatory() )
240 {
241 if( m_id != tmp->m_id )
242 return m_id - tmp->m_id;
243 }
244 else
245 {
246 retv = m_name.Cmp( tmp->m_name );
247
248 if( retv )
249 return retv;
250 }
251 }
252 else
253 {
254 if( m_id != tmp->m_id )
255 return m_id - tmp->m_id;
256 }
257
258 retv = GetText().CmpNoCase( tmp->GetText() );
259
260 if( retv != 0 )
261 return retv;
262
263 if( GetTextPos().x != tmp->GetTextPos().x )
264 return GetTextPos().x - tmp->GetTextPos().x;
265
266 if( GetTextPos().y != tmp->GetTextPos().y )
267 return GetTextPos().y - tmp->GetTextPos().y;
268
269 if( GetTextWidth() != tmp->GetTextWidth() )
270 return GetTextWidth() - tmp->GetTextWidth();
271
272 if( GetTextHeight() != tmp->GetTextHeight() )
273 return GetTextHeight() - tmp->GetTextHeight();
274
275 return 0;
276}
277
278
279void LIB_FIELD::Offset( const VECTOR2I& aOffset )
280{
281 EDA_TEXT::Offset( aOffset );
282}
283
284
285void LIB_FIELD::MoveTo( const VECTOR2I& newPosition )
286{
287 EDA_TEXT::SetTextPos( newPosition );
288}
289
290
292{
293 int x = GetTextPos().x;
294
295 x -= center.x;
296 x *= -1;
297 x += center.x;
298
299 SetTextX( x );
300}
301
302
304{
305 int y = GetTextPos().y;
306
307 y -= center.y;
308 y *= -1;
309 y += center.y;
310
311 SetTextY( y );
312}
313
314
315void LIB_FIELD::Rotate( const VECTOR2I& center, bool aRotateCCW )
316{
317 EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90;
318
319 VECTOR2I pt = GetTextPos();
320 RotatePoint( pt, center, rot_angle );
321 SetTextPos( pt );
322
324}
325
326
327void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
328 const TRANSFORM& aTransform, bool aDimmed ) const
329{
330 if( GetText().IsEmpty() || aBackground )
331 return;
332
333 RENDER_SETTINGS* renderSettings = aPlotter->RenderSettings();
334
335 // Calculate the text orientation, according to the symbol orientation/mirror.
336 EDA_ANGLE orient = GetTextAngle();
337
338 if( aTransform.y1 ) // Rotate symbol 90 deg.
339 {
340 if( orient.IsHorizontal() )
341 orient = ANGLE_VERTICAL;
342 else
343 orient = ANGLE_HORIZONTAL;
344 }
345
346 BOX2I bbox = GetBoundingBox();
347 bbox.RevertYAxis();
348
351 VECTOR2I textpos = aTransform.TransformCoordinate( bbox.Centre() ) + aOffset;
352
354 COLOR4D bg;
355
356 if( aPlotter->GetColorMode() )
357 {
358 if( GetTextColor() != COLOR4D::UNSPECIFIED )
360 else
361 color = renderSettings->GetLayerColor( GetDefaultLayer() );
362
363 bg = renderSettings->GetBackgroundColor();
364
365 if( bg == COLOR4D::UNSPECIFIED )
366 bg = COLOR4D::WHITE;
367 }
368 else
369 {
371 bg = COLOR4D::WHITE;
372 }
373
374 if( aDimmed )
375 {
376 color.Desaturate( );
377 color = color.Mix( bg, 0.5f );
378 }
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
387 attrs.m_StrokeWidth = penWidth;
388 attrs.m_Halign = hjustify;
389 attrs.m_Valign = vjustify;
390 attrs.m_Angle = orient;
391 attrs.m_Multiline = false;
392
393 aPlotter->PlotText( textpos, color, GetShownText(), attrs, font );
394}
395
396
397wxString LIB_FIELD::GetFullText( int unit ) const
398{
399 if( m_id != REFERENCE_FIELD )
400 return GetText();
401
402 wxString text = GetText();
403 text << wxT( "?" );
404
405 wxCHECK( GetParent(), text );
406
407 if( GetParent()->IsMulti() )
409
410 return text;
411}
412
413
414wxString LIB_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const
415{
416 wxString text = EDA_TEXT::GetShownText( aDepth );
417
418 if( IsNameShown() )
419 text = GetName() << wxT( ": " ) << text;
420
421 return text;
422}
423
424
426{
427 /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
428 * calling GetTextBox() that works using top to bottom Y axis orientation.
429 */
430 BOX2I bbox = GetTextBox( -1, true );
431 bbox.RevertYAxis();
432
433 // We are using now a bottom to top Y axis.
434 VECTOR2I orig = bbox.GetOrigin();
435 VECTOR2I end = bbox.GetEnd();
436
437 RotatePoint( orig, GetTextPos(), -GetTextAngle() );
438 RotatePoint( end, GetTextPos(), -GetTextAngle() );
439
440 bbox.SetOrigin( orig );
441 bbox.SetEnd( end );
442
443 // We are using now a top to bottom Y axis:
444 bbox.RevertYAxis();
445
446 return bbox;
447}
448
449
450void LIB_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
451{
452 aCount = 2;
453
454 switch( m_id )
455 {
456 case REFERENCE_FIELD: aLayers[0] = LAYER_REFERENCEPART; break;
457 case VALUE_FIELD: aLayers[0] = LAYER_VALUEPART; break;
458 default: aLayers[0] = LAYER_FIELDS; break;
459 }
460
461 aLayers[1] = LAYER_SELECTION_SHADOWS;
462}
463
464
466{
467 switch( m_id )
468 {
470 case VALUE_FIELD: return LAYER_VALUEPART;
471 default: return LAYER_FIELDS;
472 }
473}
474
475
476wxString LIB_FIELD::GetName( bool aUseDefaultName ) const
477{
478 if( m_name.IsEmpty() && aUseDefaultName )
480
481 return m_name;
482}
483
484
486{
487 switch( m_id )
488 {
489 case REFERENCE_FIELD:
490 case VALUE_FIELD:
491 case FOOTPRINT_FIELD:
492 case DATASHEET_FIELD:
494 }
495
496 return m_name;
497}
498
499
500void LIB_FIELD::SetName( const wxString& aName )
501{
502 // Mandatory field names are fixed.
503 if( IsMandatory() )
504 {
505 wxFAIL_MSG( wxS( "trying to set a MANDATORY_FIELD's name\n" ) );
506 return;
507 }
508
509 if( m_name != aName )
510 {
511 m_name = aName;
512 SetModified();
513 }
514}
515
516
517wxString LIB_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
518{
520}
521
522
523void LIB_FIELD::BeginEdit( const VECTOR2I& aPosition )
524{
525 SetTextPos( aPosition );
526}
527
528
529void LIB_FIELD::CalcEdit( const VECTOR2I& aPosition )
530{
531 SetTextPos( aPosition );
532}
533
534
535void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
536{
537 wxString msg;
538
539 LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
540
541 aList.emplace_back( _( "Field" ), GetName() );
542
543 // Don't use GetShownText() here; we want to show the user the variable references
544 aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
545
546 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
547
548 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
549
550 aList.emplace_back( _( "Style" ), GetTextStyleName() );
551
552 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
553
554 switch ( GetHorizJustify() )
555 {
556 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
557 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
558 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
559 }
560
561 aList.emplace_back( _( "H Justification" ), msg );
562
563 switch ( GetVertJustify() )
564 {
565 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
566 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
567 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
568 }
569
570 aList.emplace_back( _( "V Justification" ), msg );
571}
572
573
575{
576 return BITMAPS::move;
577}
578
579
581{
582 return m_id >= 0 && m_id < MANDATORY_FIELDS;
583}
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:496
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:202
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:505
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
COLOR4D GetTextColor() const
Definition: eda_text.h:205
wxString GetTextStyleName() const
Definition: eda_text.cpp:738
bool IsItalic() const
Definition: eda_text.h:130
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:266
virtual bool IsVisible() const
Definition: eda_text.h:136
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:373
void SetTextX(int aX)
Definition: eda_text.cpp:379
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
void SetTextY(int aY)
Definition: eda_text.cpp:385
int GetTextWidth() const
Definition: eda_text.h:199
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:391
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:219
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:625
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
bool IsBold() const
Definition: eda_text.h:133
void CopyText(const EDA_TEXT &aSrc)
Definition: eda_text.cpp:176
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:165
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:195
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:196
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:138
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
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:61
bool IsAutoAdded() const
Definition: lib_field.h:177
bool m_allowAutoPlace
This field can be autoplaced when converted to a SCH_FIELD.
Definition: lib_field.h:227
void SetAutoAdded(bool aAutoAdded)
Definition: lib_field.h:178
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_field.cpp:198
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_field.cpp:279
void Init(int aId)
Object constructor initialization helper.
Definition: lib_field.cpp:86
bool m_autoAdded
Was this field automatically added to a LIB_SYMBOL?
Definition: lib_field.h:225
int m_id
Definition: lib_field.h:223
KIFONT::FONT * getDrawFont() const override
Definition: lib_field.cpp:120
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_field.cpp:315
wxString m_name
Name (not the field text value itself, that is #EDA_TEXT::m_Text)
Definition: lib_field.h:224
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:450
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the field.
Definition: lib_field.cpp:131
SCH_LAYER_ID GetDefaultLayer() const
Definition: lib_field.cpp:465
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:327
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: lib_field.cpp:517
void SetId(int aId)
Definition: lib_field.cpp:108
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:500
void Copy(LIB_FIELD *aTarget) const
Copy parameters of this field to another field.
Definition: lib_field.cpp:208
bool m_showInChooser
This field is available as a data column for the chooser.
Definition: lib_field.h:228
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:397
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: lib_field.cpp:476
bool IsNameShown() const
Definition: lib_field.h:180
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_field.cpp:523
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:485
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_field.cpp:574
int GetPenWidth() const override
Definition: lib_field.cpp:114
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_field.cpp:291
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the new circle at aPosition when editing.
Definition: lib_field.cpp:529
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_field.cpp:303
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_field.cpp:425
bool IsMandatory() const
Definition: lib_field.cpp:580
LIB_FIELD(int aId=2)
Definition: lib_field.cpp:52
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_field.cpp:285
LIB_FIELD & operator=(const LIB_FIELD &field)
Definition: lib_field.cpp:69
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:535
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:164
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:414
bool m_showName
Render the field's name in addition to its value.
Definition: lib_field.h:226
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:222
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:99
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:581
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 PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
Definition: plotter.cpp:758
bool GetColorMode() const
Definition: plotter.h:138
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: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:46
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:46
@ BLACK
Definition: color4d.h:42
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:426
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
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)
Print a graphic text through wxDC.
Definition: gr_text.cpp:141
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:215
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
TRANSFORM DefaultTransform
Definition: transform.cpp:34
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
@ LIB_FIELD_T
Definition: typeinfo.h:208