KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef SYMBOL_H
21#define SYMBOL_H
22
23#include <lib_id.h>
24#include <sch_item.h>
25#include <sch_field.h>
26#include <sch_pin.h>
27
28// @todo Move this to transform alone with all of the transform manipulation code.
31{
32 SYM_NORMAL, // Normal orientation, no rotation or mirror
33 SYM_ROTATE_CLOCKWISE, // Rotate -90
35 SYM_ORIENT_0, // No rotation and no mirror id SYM_NORMAL
36 SYM_ORIENT_90, // Rotate 90, no mirror
37 SYM_ORIENT_180, // Rotate 180, no mirror
38 SYM_ORIENT_270, // Rotate -90, no mirror
39 SYM_MIRROR_X = 0x100, // Mirror around X axis
40 SYM_MIRROR_Y = 0x200 // Mirror around Y axis
41};
42
43
44// Cover for SYMBOL_ORIENTATION_T for property manager (in order to expose only a subset of
45// SYMBOL_ORIENTATION_T's values).
53
54
58class SYMBOL : public SCH_ITEM
59{
60public:
61 SYMBOL( KICAD_T idType ) :
62 SYMBOL( nullptr, idType )
63 { }
64
65 SYMBOL( EDA_ITEM* aParent, KICAD_T idType ) :
66 SCH_ITEM( aParent, idType ),
67 m_pinNameOffset( 0 ),
68 m_showPinNames( true ),
69 m_showPinNumbers( true ),
70 m_excludedFromSim( false ),
71 m_excludedFromBOM( false ),
72 m_excludedFromBoard( false ),
74 m_DNP( false )
75 { }
76
88
105
106 ~SYMBOL() override = default;
107
108 virtual const LIB_ID& GetLibId() const = 0;
109 virtual wxString GetDescription() const = 0;
110 virtual wxString GetShownDescription( int aDepth = 0 ) const = 0;
111 virtual wxString GetKeyWords() const = 0;
112 virtual wxString GetShownKeyWords( int aDepth = 0 ) const = 0;
113
114 virtual bool IsGlobalPower() const = 0;
115 virtual bool IsLocalPower() const = 0;
116 virtual bool IsPower() const = 0;
117 virtual bool IsNormal() const = 0;
118
122 virtual bool IsMultiUnit() const = 0;
123
127 virtual int GetUnitCount() const = 0;
128
132 virtual bool IsMultiBodyStyle() const = 0;
133
137 virtual int GetBodyStyleCount() const = 0;
138
139 virtual bool HasDeMorganBodyStyles() const = 0;
140
141 virtual const wxString GetRef( const SCH_SHEET_PATH* aSheet,
142 bool aIncludeUnit = false ) const = 0;
143
144 virtual const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
145 bool aAllowExtraText, const wxString& aVaraintName = wxEmptyString ) const = 0;
146
147 virtual void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) const = 0;
148
149 virtual std::vector<SCH_PIN*> GetPins() const = 0;
150
158 void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; }
159 int GetPinNameOffset() const { return m_pinNameOffset; }
160
164 virtual void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
165 virtual bool GetShowPinNames() const { return m_showPinNames; }
166
170 virtual void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
171 virtual bool GetShowPinNumbers() const { return m_showPinNumbers; }
172
176 virtual void SetExcludedFromSim( bool aExcludeFromSim, const SCH_SHEET_PATH* aInstance = nullptr,
177 const wxString& aVariantName = wxEmptyString ) override
178 {
179 m_excludedFromSim = aExcludeFromSim;
180 }
181
182 virtual bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
183 const wxString& aVariantName = wxEmptyString ) const override
184 {
185 return m_excludedFromSim;
186 }
187
191 virtual void SetExcludedFromBOM( bool aExcludeFromBOM, const SCH_SHEET_PATH* aInstance = nullptr,
192 const wxString& aVariantName = wxEmptyString ) override
193 {
194 m_excludedFromBOM = aExcludeFromBOM;
195 }
196
197 virtual bool GetExcludedFromBOM( const SCH_SHEET_PATH* aInstance = nullptr,
198 const wxString& aVariantName = wxEmptyString ) const override
199 {
200 return m_excludedFromBOM;
201 }
202
206 void SetExcludedFromBoard( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
207 const wxString& aVariantName = wxEmptyString ) override
208 {
209 m_excludedFromBoard = aExclude;
210 }
211
212 bool GetExcludedFromBoard( const SCH_SHEET_PATH* aInstance = nullptr,
213 const wxString& aVariantName = wxEmptyString ) const override
214 {
215 return m_excludedFromBoard;
216 }
217
221 void SetExcludedFromPosFiles( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
222 const wxString& aVariantName = wxEmptyString ) override
223 {
224 m_excludedFromPosFiles = aExclude;
225 }
226
227 bool GetExcludedFromPosFiles( const SCH_SHEET_PATH* aInstance = nullptr,
228 const wxString& aVariantName = wxEmptyString ) const override
229 {
231 }
232
236 virtual bool GetDNP( const SCH_SHEET_PATH* aInstance = nullptr,
237 const wxString& aVariantName = wxEmptyString ) const override { return m_DNP; }
238 virtual void SetDNP( bool aDNP, const SCH_SHEET_PATH* aInstance = nullptr,
239 const wxString& aVariantName = wxEmptyString ) override { m_DNP = aDNP; }
240
241 virtual int GetOrientation() const { return SYM_NORMAL; }
242
243 const TRANSFORM& GetTransform() const { return m_transform; }
245 void SetTransform( const TRANSFORM& aTransform ) { m_transform = aTransform; }
246
247 void SetPreviewUnit( int aUnit ) { m_previewUnit = aUnit; }
248 void SetPreviewBodyStyle( int aBodyStyle ) { m_previewBodyStyle = aBodyStyle; }
249
253 virtual BOX2I GetBodyBoundingBox() const = 0;
254
258 virtual BOX2I GetBodyAndPinsBoundingBox() const = 0;
259
260 std::vector<int> ViewGetLayers() const override;
261
262protected:
264
269
274 bool m_DNP;
275
278};
279
280#endif // SYMBOL_H
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition sch_item.cpp:78
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SYMBOL(EDA_ITEM *aParent, KICAD_T idType)
Definition symbol.h:65
bool m_DNP
True if symbol is set to 'Do Not Populate'.
Definition symbol.h:274
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:227
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Definition symbol.h:206
void SetPreviewBodyStyle(int aBodyStyle)
Definition symbol.h:248
TRANSFORM & GetTransform()
Definition symbol.h:244
void SetPreviewUnit(int aUnit)
Definition symbol.h:247
virtual BOX2I GetBodyAndPinsBoundingBox() const =0
Return a bounding box for the symbol body and pins but not the fields.
virtual bool IsGlobalPower() const =0
virtual void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const =0
bool m_showPinNumbers
Definition symbol.h:268
bool m_excludedFromPosFiles
Definition symbol.h:273
virtual const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVaraintName=wxEmptyString) const =0
virtual int GetUnitCount() const =0
virtual bool IsLocalPower() const =0
virtual bool HasDeMorganBodyStyles() const =0
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
SYMBOL(KICAD_T idType)
Definition symbol.h:61
void SetTransform(const TRANSFORM &aTransform)
Definition symbol.h:245
bool m_excludedFromSim
Definition symbol.h:270
virtual bool IsPower() const =0
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
Definition symbol.h:236
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition symbol.h:170
int m_previewBodyStyle
Definition symbol.h:277
bool m_showPinNames
Definition symbol.h:267
const TRANSFORM & GetTransform() const
Definition symbol.h:243
int GetPinNameOffset() const
Definition symbol.h:159
virtual BOX2I GetBodyBoundingBox() const =0
Return a bounding box for the symbol body but not the pins or fields.
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition symbol.h:164
virtual bool IsMultiUnit() const =0
bool m_excludedFromBOM
Definition symbol.h:271
virtual bool IsNormal() const =0
virtual wxString GetDescription() const =0
virtual void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
Definition symbol.h:176
SYMBOL(const SYMBOL &base)
Definition symbol.h:77
virtual wxString GetShownKeyWords(int aDepth=0) const =0
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:197
virtual void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Definition symbol.h:238
virtual std::vector< SCH_PIN * > GetPins() const =0
bool m_excludedFromBoard
Definition symbol.h:272
virtual bool GetShowPinNames() const
Definition symbol.h:165
~SYMBOL() override=default
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition symbol.h:158
virtual wxString GetShownDescription(int aDepth=0) const =0
virtual int GetOrientation() const
Definition symbol.h:241
virtual int GetBodyStyleCount() const =0
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition symbol.cpp:24
virtual wxString GetKeyWords() const =0
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:212
void SetExcludedFromPosFiles(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from position files flag.
Definition symbol.h:221
virtual bool IsMultiBodyStyle() const =0
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:182
SYMBOL & operator=(const SYMBOL &aItem)
Definition symbol.h:89
virtual bool GetShowPinNumbers() const
Definition symbol.h:171
virtual const LIB_ID & GetLibId() const =0
int m_previewUnit
Definition symbol.h:276
virtual void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
Definition symbol.h:191
TRANSFORM m_transform
The rotation/mirror transformation.
Definition symbol.h:263
int m_pinNameOffset
The offset in mils to draw the pin name.
Definition symbol.h:265
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:42
SYMBOL_ORIENTATION_PROP
Definition symbol.h:47
@ SYMBOL_ANGLE_180
Definition symbol.h:50
@ SYMBOL_ANGLE_0
Definition symbol.h:48
@ SYMBOL_ANGLE_90
Definition symbol.h:49
@ SYMBOL_ANGLE_270
Definition symbol.h:51
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
Definition symbol.h:31
@ SYM_ORIENT_270
Definition symbol.h:38
@ SYM_ROTATE_CLOCKWISE
Definition symbol.h:33
@ SYM_ROTATE_COUNTERCLOCKWISE
Definition symbol.h:34
@ SYM_MIRROR_Y
Definition symbol.h:40
@ SYM_ORIENT_180
Definition symbol.h:37
@ SYM_MIRROR_X
Definition symbol.h:39
@ SYM_NORMAL
Definition symbol.h:32
@ SYM_ORIENT_90
Definition symbol.h:36
@ SYM_ORIENT_0
Definition symbol.h:35
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71