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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef SYMBOL_H
25#define SYMBOL_H
26
27#include <lib_id.h>
28#include <sch_item.h>
29#include <sch_field.h>
30#include <sch_pin.h>
31
32// @todo Move this to transform alone with all of the transform manipulation code.
35{
36 SYM_NORMAL, // Normal orientation, no rotation or mirror
37 SYM_ROTATE_CLOCKWISE, // Rotate -90
39 SYM_ORIENT_0, // No rotation and no mirror id SYM_NORMAL
40 SYM_ORIENT_90, // Rotate 90, no mirror
41 SYM_ORIENT_180, // Rotate 180, no mirror
42 SYM_ORIENT_270, // Rotate -90, no mirror
43 SYM_MIRROR_X = 0x100, // Mirror around X axis
44 SYM_MIRROR_Y = 0x200 // Mirror around Y axis
45};
46
47
48// Cover for SYMBOL_ORIENTATION_T for property manager (in order to expose only a subset of
49// SYMBOL_ORIENTATION_T's values).
51{
56};
57
58
62class SYMBOL : public SCH_ITEM
63{
64public:
65 SYMBOL( KICAD_T idType ) :
66 SYMBOL( nullptr, idType )
67 { }
68
69 SYMBOL( EDA_ITEM* aParent, KICAD_T idType ) :
70 SCH_ITEM( aParent, idType ),
71 m_pinNameOffset( 0 ),
72 m_showPinNames( true ),
73 m_showPinNumbers( true ),
74 m_excludedFromSim( false ),
75 m_excludedFromBOM( false ),
76 m_excludedFromBoard( false ),
77 m_DNP( false )
78 { }
79
80 SYMBOL( const SYMBOL& base ) :
81 SCH_ITEM( base ),
88 m_DNP( base.m_DNP )
89 { }
90
91 SYMBOL& operator=( const SYMBOL& aItem )
92 {
93 SCH_ITEM::operator=( aItem );
94
98
102 m_DNP = aItem.m_DNP;
103
104 return *this;
105 };
106
107 ~SYMBOL() override { };
108
109 virtual const LIB_ID& GetLibId() const = 0;
110 virtual wxString GetDescription() const = 0;
111 virtual wxString GetKeyWords() const = 0;
112
113 virtual bool IsPower() const = 0;
114 virtual bool IsNormal() const = 0;
115
121 virtual bool HasAlternateBodyStyle() const = 0;
122
126 virtual bool IsMulti() const = 0;
127
131 virtual int GetUnitCount() const = 0;
132
133 virtual const wxString GetRef( const SCH_SHEET_PATH* aSheet,
134 bool aIncludeUnit = false ) const = 0;
135
136 virtual const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
137 bool aAllowExtraText ) const = 0;
138
139 virtual void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) = 0;
140
141 virtual std::vector<SCH_PIN*> GetPins() const = 0;
142
150 void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; }
151 int GetPinNameOffset() const { return m_pinNameOffset; }
152
156 virtual void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
157 virtual bool GetShowPinNames() const { return m_showPinNames; }
158
162 virtual void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
163 virtual bool GetShowPinNumbers() const { return m_showPinNumbers; }
164
168 void SetExcludedFromSim( bool aExcludeFromSim ) override { m_excludedFromSim = aExcludeFromSim; }
169 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
170
174 void SetExcludedFromBOM( bool aExcludeFromBOM ) { m_excludedFromBOM = aExcludeFromBOM; }
175 bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
176
180 void SetExcludedFromBoard( bool aExcludeFromBoard ) { m_excludedFromBoard = aExcludeFromBoard; }
182
186 bool GetDNP() const { return m_DNP; }
187 void SetDNP( bool aDNP ) { m_DNP = aDNP; }
188
189 virtual int GetOrientation() const { return SYM_NORMAL; }
190
191 const TRANSFORM& GetTransform() const { return m_transform; }
193 void SetTransform( const TRANSFORM& aTransform ) { m_transform = aTransform; }
194
195 void SetPreviewUnit( int aUnit ) { m_previewUnit = aUnit; }
196 void SetPreviewBodyStyle( int aBodyStyle ) { m_previewBodyStyle = aBodyStyle; }
197
201 virtual BOX2I GetBodyBoundingBox() const = 0;
202
206 virtual BOX2I GetBodyAndPinsBoundingBox() const = 0;
207
208 std::vector<int> ViewGetLayers() const override;
209
210protected:
212
217
221 bool m_DNP;
222
225};
226
227#endif // SYMBOL_H
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:101
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:63
SYMBOL(EDA_ITEM *aParent, KICAD_T idType)
Definition: symbol.h:69
bool m_DNP
True if symbol is set to 'Do Not Populate'.
Definition: symbol.h:221
virtual void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)=0
void SetDNP(bool aDNP)
Definition: symbol.h:187
~SYMBOL() override
Definition: symbol.h:107
void SetPreviewBodyStyle(int aBodyStyle)
Definition: symbol.h:196
TRANSFORM & GetTransform()
Definition: symbol.h:192
void SetPreviewUnit(int aUnit)
Definition: symbol.h:195
virtual bool IsMulti() const =0
virtual BOX2I GetBodyAndPinsBoundingBox() const =0
Return a bounding box for the symbol body and pins but not the fields.
bool m_showPinNumbers
Definition: symbol.h:216
bool GetExcludedFromBoard() const
Definition: symbol.h:181
virtual int GetUnitCount() const =0
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
SYMBOL(KICAD_T idType)
Definition: symbol.h:65
void SetTransform(const TRANSFORM &aTransform)
Definition: symbol.h:193
bool m_excludedFromSim
Definition: symbol.h:218
virtual bool IsPower() const =0
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition: symbol.h:162
bool GetExcludedFromBOM() const
Definition: symbol.h:175
int m_previewBodyStyle
Definition: symbol.h:224
bool m_showPinNames
Definition: symbol.h:215
const TRANSFORM & GetTransform() const
Definition: symbol.h:191
void SetExcludedFromSim(bool aExcludeFromSim) override
Set or clear the exclude from simulation flag.
Definition: symbol.h:168
int GetPinNameOffset() const
Definition: symbol.h:151
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:156
bool m_excludedFromBOM
Definition: symbol.h:219
virtual bool IsNormal() const =0
virtual wxString GetDescription() const =0
SYMBOL(const SYMBOL &base)
Definition: symbol.h:80
virtual const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const =0
bool GetDNP() const
Set or clear the 'Do Not Populate' flag.
Definition: symbol.h:186
virtual std::vector< SCH_PIN * > GetPins() const =0
bool m_excludedFromBoard
Definition: symbol.h:220
virtual bool GetShowPinNames() const
Definition: symbol.h:157
void SetExcludedFromBOM(bool aExcludeFromBOM)
Set or clear the exclude from schematic bill of materials flag.
Definition: symbol.h:174
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition: symbol.h:150
virtual int GetOrientation() const
Definition: symbol.h:189
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:27
virtual wxString GetKeyWords() const =0
SYMBOL & operator=(const SYMBOL &aItem)
Definition: symbol.h:91
void SetExcludedFromBoard(bool aExcludeFromBoard)
Set or clear exclude from board netlist flag.
Definition: symbol.h:180
virtual bool GetShowPinNumbers() const
Definition: symbol.h:163
virtual const LIB_ID & GetLibId() const =0
int m_previewUnit
Definition: symbol.h:223
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: symbol.h:211
virtual bool HasAlternateBodyStyle() const =0
Test if symbol has more than one body conversion type (DeMorgan).
int m_pinNameOffset
The offset in mils to draw the pin name.
Definition: symbol.h:213
bool GetExcludedFromSim() const override
Definition: symbol.h:169
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
SYMBOL_ORIENTATION_PROP
Definition: symbol.h:51
@ SYMBOL_ANGLE_180
Definition: symbol.h:54
@ SYMBOL_ANGLE_0
Definition: symbol.h:52
@ SYMBOL_ANGLE_90
Definition: symbol.h:53
@ SYMBOL_ANGLE_270
Definition: symbol.h:55
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
Definition: symbol.h:35
@ SYM_ORIENT_270
Definition: symbol.h:42
@ SYM_ROTATE_CLOCKWISE
Definition: symbol.h:37
@ SYM_ROTATE_COUNTERCLOCKWISE
Definition: symbol.h:38
@ SYM_MIRROR_Y
Definition: symbol.h:44
@ SYM_ORIENT_180
Definition: symbol.h:41
@ SYM_MIRROR_X
Definition: symbol.h:43
@ SYM_NORMAL
Definition: symbol.h:36
@ SYM_ORIENT_90
Definition: symbol.h:40
@ SYM_ORIENT_0
Definition: symbol.h:39
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78