KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_field.h
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) 2019 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
30#ifndef CLASS_LIBENTRY_FIELDS_H
31#define CLASS_LIBENTRY_FIELDS_H
32
33#include <eda_text.h>
34#include <lib_item.h>
35
36
38
39
60class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
61{
62public:
63 LIB_FIELD( int aId = 2 );
64
65 LIB_FIELD( int aId, const wxString& aName );
66
67 LIB_FIELD( LIB_SYMBOL* aParent, int aId = 2, const wxString& aName = wxEmptyString );
68
69 // Do not create a copy constructor. The one generated by the compiler is adequate.
70
71 wxString GetClass() const override
72 {
73 return wxT( "LIB_FIELD" );
74 }
75
76 static inline bool ClassOf( const EDA_ITEM* aItem )
77 {
78 return aItem && aItem->Type() == LIB_FIELD_T;
79 }
80
81 wxString GetTypeName() const override
82 {
83 return _( "Field" );
84 }
85
89 void Init( int aId );
90
100 wxString GetName( bool aUseDefaultName = true ) const;
101
106 wxString GetCanonicalName() const;
107
117 void SetName( const wxString& aName );
118
119 int GetId() const { return m_id; }
120 void SetId( int aId );
121
122 int GetPenWidth() const override;
123
124 KIFONT::FONT* getDrawFont() const override;
125
131 void Copy( LIB_FIELD* aTarget ) const;
132
133 void ViewGetLayers( int aLayers[], int& aCount ) const override;
134
135 const BOX2I GetBoundingBox() const override;
136
137 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
138
139 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
140
141 LIB_FIELD& operator=( const LIB_FIELD& field );
142
153 wxString GetFullText( int unit = 1 ) const;
154
155 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
156
158
159 void BeginEdit( const VECTOR2I& aStartPoint ) override;
160
161 void Offset( const VECTOR2I& aOffset ) override;
162
163 void MoveTo( const VECTOR2I& aPosition ) override;
164
165 VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
166
167 void MirrorHorizontal( const VECTOR2I& aCenter ) override;
168 void MirrorVertical( const VECTOR2I& aCenter ) override;
169 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
170
171 void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
172 const TRANSFORM& aTransform, bool aDimmed ) const override;
173
174 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
175
176 BITMAPS GetMenuImage() const override;
177
178 EDA_ITEM* Clone() const override;
179
180 bool IsMandatory() const;
181
182 bool IsAutoAdded() const { return m_autoAdded; }
183 void SetAutoAdded( bool aAutoAdded ) { m_autoAdded = aAutoAdded; }
184
185 bool IsNameShown() const { return m_showName; }
186 void SetNameShown( bool aShown = true ) { m_showName = aShown; }
187
188 bool CanAutoplace() const { return m_allowAutoPlace; }
189 void SetCanAutoplace( bool aCanPlace ) { m_allowAutoPlace = aCanPlace; }
190
191 bool ShowInChooser() const { return m_showInChooser; }
192 void SetShowInChooser( bool aShow = true ) { m_showInChooser = aShow; }
193
194private:
195
208 int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
209
216 void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
217 const TRANSFORM& aTransform, bool aDimmed ) override;
218
224 void CalcEdit( const VECTOR2I& aPosition ) override;
225
226 friend class SCH_LEGACY_PLUGIN_CACHE; // Required to access m_name.
227
228 int m_id;
229 wxString m_name;
234};
235
236#endif // CLASS_LIBENTRY_FIELDS_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:211
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Field object used in symbol libraries.
Definition: lib_field.h:61
bool IsAutoAdded() const
Definition: lib_field.h:182
bool m_allowAutoPlace
This field can be autoplaced when converted to a SCH_FIELD.
Definition: lib_field.h:232
void SetAutoAdded(bool aAutoAdded)
Definition: lib_field.h:183
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_field.cpp:196
wxString GetClass() const override
Return the class name.
Definition: lib_field.h:71
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_field.cpp:291
void Init(int aId)
Object constructor initialization helper.
Definition: lib_field.cpp:84
bool m_autoAdded
Was this field automatically added to a LIB_SYMBOL?
Definition: lib_field.h:230
bool ShowInChooser() const
Definition: lib_field.h:191
int m_id
Definition: lib_field.h:228
KIFONT::FONT * getDrawFont() const override
Definition: lib_field.cpp:118
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_field.cpp:327
wxString m_name
Name (not the field text value itself, that is #EDA_TEXT::m_Text)
Definition: lib_field.h:229
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:462
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the field.
Definition: lib_field.cpp:129
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_field.h:81
bool CanAutoplace() const
Definition: lib_field.h:188
SCH_LAYER_ID GetDefaultLayer() const
Definition: lib_field.cpp:477
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:339
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: lib_field.cpp:529
void SetId(int aId)
Definition: lib_field.cpp:106
void SetName(const wxString &aName)
Set a user definable field name to aName.
Definition: lib_field.cpp:512
void SetShowInChooser(bool aShow=true)
Definition: lib_field.h:192
VECTOR2I GetPosition() const override
Definition: lib_field.h:165
void Copy(LIB_FIELD *aTarget) const
Copy parameters of this field to another field.
Definition: lib_field.cpp:206
bool m_showInChooser
This field is available as a data column for the chooser.
Definition: lib_field.h:233
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:409
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: lib_field.cpp:488
bool IsNameShown() const
Definition: lib_field.h:185
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_field.cpp:537
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:497
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_field.cpp:589
int GetPenWidth() const override
Definition: lib_field.cpp:112
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: lib_field.cpp:426
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_field.cpp:303
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the new circle at aPosition when editing.
Definition: lib_field.cpp:543
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_field.cpp:315
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_field.cpp:437
bool IsMandatory() const
Definition: lib_field.cpp:595
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_field.cpp:297
void SetNameShown(bool aShown=true)
Definition: lib_field.h:186
LIB_FIELD & operator=(const LIB_FIELD &field)
Definition: lib_field.cpp:67
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:549
void SetCanAutoplace(bool aCanPlace)
Definition: lib_field.h:189
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:162
static bool ClassOf(const EDA_ITEM *aItem)
Definition: lib_field.h:76
int GetId() const
Definition: lib_field.h:119
bool m_showName
Render the field's name in addition to its value.
Definition: lib_field.h:231
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:220
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
Define a library symbol object.
Definition: lib_symbol.h:99
Base plotter engine class.
Definition: plotter.h:110
A cache assistant for KiCad legacy symbol libraries.
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
#define _(s)
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:345
@ LIB_FIELD_T
Definition: typeinfo.h:198