KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_pin.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) 2018 CERN
5 * Copyright (C) 2019-2023 KiCad Developers, see AUTHOR.txt for contributors.
6 * @author Jon Evans <[email protected]>
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 along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef _SCH_PIN_CONNECTION_H
23#define _SCH_PIN_CONNECTION_H
24
25#include <lib_pin.h>
26#include <sch_item.h>
27#include <sch_sheet_path.h>
28
29#include <mutex>
30#include <map>
31
32class SCH_SYMBOL;
33class MSG_PANEL_ITEM;
34
35
36class SCH_PIN : public SCH_ITEM
37{
38public:
39 SCH_PIN( LIB_PIN* aLibPin, SCH_SYMBOL* aParentSymbol );
40
41 SCH_PIN( SCH_SYMBOL* aParentSymbol, const wxString& aNumber, const wxString& aAlt );
42
43 SCH_PIN( const SCH_PIN& aPin );
44
45 SCH_PIN& operator=( const SCH_PIN& aPin );
46
47 static inline bool ClassOf( const EDA_ITEM* aItem )
48 {
49 return aItem && SCH_PIN_T == aItem->Type();
50 }
51
52 wxString GetClass() const override
53 {
54 return wxT( "SCH_PIN" );
55 }
56
58
59 LIB_PIN* GetLibPin() const { return m_libPin; }
60
61 void ClearDefaultNetName( const SCH_SHEET_PATH* aPath );
62 wxString GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect = false );
63
64 wxString GetAlt() const { return m_alt; }
65 void SetAlt( const wxString& aAlt ) { m_alt = aAlt; }
66
67 const BOX2I ViewBBox() const override;
68
69 void ViewGetLayers( int aLayers[], int& aCount ) const override;
70
71 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
72 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
73
74 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {}
75
76 void Move( const VECTOR2I& aMoveVector ) override {}
77
78 void MirrorHorizontally( int aCenter ) override {}
79 void MirrorVertically( int aCenter ) override {}
80 void Rotate( const VECTOR2I& aCenter ) override {}
81
82 VECTOR2I GetPosition() const override { return GetTransformedPosition(); }
83 const VECTOR2I GetLocalPosition() const { return m_position; }
84 void SetPosition( const VECTOR2I& aPosition ) override { m_position = aPosition; }
85
86 /* Cannot use a default parameter here as it will not be compatible with the virtual. */
87 const BOX2I GetBoundingBox() const override { return GetBoundingBox( false, true, false ); }
88
93 const BOX2I GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNameAndNumber,
94 bool aIncludeElectricalType ) const;
95
96 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
97 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
98
99 EDA_ITEM* Clone() const override;
100
101 bool IsConnectable() const override { return true; }
102
103 bool IsDangling() const override
104 {
105 if( GetType() == ELECTRICAL_PINTYPE::PT_NC || GetType() == ELECTRICAL_PINTYPE::PT_NIC )
106 return false;
107
108 return m_isDangling;
109 }
110
111 void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
112
113 void SetLibPin( LIB_PIN* aLibPin ) { m_libPin = aLibPin; }
114
119 bool IsStacked( const SCH_PIN* aPin ) const;
120
121 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
122 {
123 return m_isDangling && GetPosition() == aPos;
124 }
125
128
129 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
130
131 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override;
132
133 /*
134 * While many of these are currently simply covers for the equivalent LIB_PIN methods,
135 * the new Eeschema file format will soon allow us to override them at the schematic level.
136 */
137 bool IsVisible() const { return m_libPin->IsVisible(); }
138
139 wxString GetName() const;
140 wxString GetShownName() const;
141
142 wxString GetNumber() const { return m_number; }
143 wxString GetShownNumber() const;
144
145 void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
146
148
150 {
152 }
153
155
157
158 int GetLength() const;
159
160 bool IsGlobalPower() const { return m_libPin->IsGlobalPower(); }
161
162 bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
163
164 const wxString& GetOperatingPoint() const { return m_operatingPoint; }
165 void SetOperatingPoint( const wxString& aText ) { m_operatingPoint = aText; }
166
167#if defined(DEBUG)
168 void Show( int nestLevel, std::ostream& os ) const override {}
169#endif
170
171private:
173
174 wxString m_number;
175 wxString m_alt;
178
180 std::recursive_mutex m_netmap_mutex;
181 std::map<const SCH_SHEET_PATH, std::pair<wxString, bool>> m_net_name_map;
182
184};
185
186#endif
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
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsGlobalPower() const
Return whether this pin forms a global power connection: i.e., is part of a power symbol and of type ...
Definition: lib_pin.h:207
wxString const GetCanonicalElectricalTypeName() const
Definition: lib_pin.h:87
bool IsVisible() const
Definition: lib_pin.h:97
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:150
void SetAlt(const wxString &aAlt)
Definition: sch_pin.h:65
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_pin.cpp:195
int GetLength() const
Definition: sch_pin.cpp:141
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_pin.h:74
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_pin.cpp:163
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: sch_pin.cpp:203
wxString GetAlt() const
Definition: sch_pin.h:64
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: sch_pin.cpp:147
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_pin.h:84
void SetNumber(const wxString &aNumber)
Definition: sch_pin.h:145
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_pin.h:80
SCH_PIN & operator=(const SCH_PIN &aPin)
Definition: sch_pin.cpp:71
wxString GetShownNumber() const
Definition: sch_pin.cpp:108
std::map< const SCH_SHEET_PATH, std::pair< wxString, bool > > m_net_name_map
Definition: sch_pin.h:181
const wxString & GetOperatingPoint() const
Definition: sch_pin.h:164
bool IsGlobalPower() const
Definition: sch_pin.h:160
bool IsVisible() const
Definition: sch_pin.h:137
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
Definition: sch_pin.cpp:412
wxString GetName() const
Definition: sch_pin.cpp:85
void SetLibPin(LIB_PIN *aLibPin)
Definition: sch_pin.h:113
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_pin.h:79
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:59
bool m_isDangling
Definition: sch_pin.h:177
bool IsConnectable() const override
Definition: sch_pin.h:101
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_pin.cpp:153
wxString GetNumber() const
Definition: sch_pin.h:142
bool IsDangling() const override
Definition: sch_pin.h:103
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_pin.h:78
std::recursive_mutex m_netmap_mutex
The name that this pin connection will drive onto a net.
Definition: sch_pin.h:180
PIN_ORIENTATION GetOrientation() const
Definition: sch_pin.cpp:135
wxString GetClass() const override
Return the class name.
Definition: sch_pin.h:52
VECTOR2I GetPosition() const override
Definition: sch_pin.h:82
LIB_PIN * m_libPin
Definition: sch_pin.h:172
wxString GetCanonicalElectricalTypeName() const
Definition: sch_pin.h:149
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
Definition: sch_pin.cpp:176
VECTOR2I m_position
Definition: sch_pin.h:176
const VECTOR2I GetLocalPosition() const
Definition: sch_pin.h:83
wxString m_operatingPoint
Definition: sch_pin.h:183
wxString GetShownName() const
Definition: sch_pin.cpp:94
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_pin.h:76
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_pin.h:47
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_pin.cpp:380
wxString m_alt
Definition: sch_pin.h:175
void SetOperatingPoint(const wxString &aText)
Definition: sch_pin.h:165
VECTOR2I GetTransformedPosition() const
Definition: sch_pin.cpp:357
void ClearDefaultNetName(const SCH_SHEET_PATH *aPath)
Definition: sch_pin.cpp:260
void SetIsDangling(bool isDangling)
Definition: sch_pin.h:111
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_pin.h:121
bool IsStacked(const SCH_PIN *aPin) const
Definition: sch_pin.cpp:250
wxString m_number
Definition: sch_pin.h:174
SCH_SYMBOL * GetParentSymbol() const
Definition: sch_pin.cpp:189
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_pin.cpp:406
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_pin.h:87
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath, bool aForceNoConnect=false)
Definition: sch_pin.cpp:271
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:126
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:117
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:81
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition: pin_type.h:36
PIN_ORIENTATION
The symbol library pin object orientations.
Definition: pin_type.h:75
GRAPHIC_PINSHAPE
Definition: pin_type.h:56
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SCH_PIN_T
Definition: typeinfo.h:158