KiCad PCB EDA Suite
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 KiCad Developers, see change_log.txt for contributors.
6  * @author Jon Evans <jon@craftyjon.com>
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 #include <widgets/msgpanel.h>
29 
30 #include <mutex>
31 #include <map>
32 
33 class SCH_COMPONENT;
34 
35 class SCH_PIN : public SCH_ITEM
36 {
38 
39  wxString m_number;
40  wxString m_alt;
41  wxPoint m_position;
43 
45  std::recursive_mutex m_netmap_mutex;
46  std::map<const SCH_SHEET_PATH, std::pair<wxString, bool>> m_net_name_map;
47 
48 public:
49  SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentSymbol );
50 
51  SCH_PIN( SCH_COMPONENT* aParentSymbol, const wxString& aNumber, const wxString& aAlt );
52 
53  SCH_PIN( const SCH_PIN& aPin );
54 
55  SCH_PIN& operator=( const SCH_PIN& aPin );
56 
57  static inline bool ClassOf( const EDA_ITEM* aItem )
58  {
59  return aItem && SCH_PIN_T == aItem->Type();
60  }
61 
62  wxString GetClass() const override
63  {
64  return wxT( "SCH_PIN" );
65  }
66 
68 
69  LIB_PIN* GetLibPin() const { return m_libPin; }
70 
71  void ClearDefaultNetName( const SCH_SHEET_PATH* aPath );
72  wxString GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoConnect = false );
73 
74  wxString GetAlt() const { return m_alt; }
75  void SetAlt( const wxString& aAlt ) { m_alt = aAlt; }
76 
77  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
78  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) override;
79 
80  void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override {}
81 
82  void Move( const wxPoint& aMoveVector ) override {}
83 
84  void MirrorHorizontally( int aCenter ) override {}
85  void MirrorVertically( int aCenter ) override {}
86 
87  void Rotate( wxPoint aPosition ) override {}
88 
89  wxPoint GetPosition() const override { return GetTransformedPosition(); }
90  const wxPoint GetLocalPosition() const { return m_position; }
91  void SetPosition( const wxPoint& aPosition ) override { m_position = aPosition; }
92 
93  const EDA_RECT GetBoundingBox() const override;
94  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
95 
96  bool IsDangling() const override { return m_isDangling; }
97  void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
98 
99  bool IsPointClickableAnchor( const wxPoint& aPos ) const override { return m_isDangling && GetPosition() == aPos; }
100 
102  wxPoint GetTransformedPosition() const;
103 
104  bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;
105 
106  bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override;
107 
108  /*
109  * While many of these are currently simply covers for the equivalent LIB_PIN methods,
110  * the new EESchema file format will soon allow us to override them at the SCH level.
111  */
112  bool IsVisible() const { return m_libPin->IsVisible(); }
113 
114  wxString GetName() const;
115 
116  wxString GetNumber() const { return m_number; }
117  void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
118 
119  ELECTRICAL_PINTYPE GetType() const;
120 
122  {
124  }
125 
126  GRAPHIC_PINSHAPE GetShape() const;
127 
128  int GetOrientation() const;
129 
130  int GetLength() const;
131 
132  bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); }
133 
134  bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
135 
136 
137 #if defined(DEBUG)
138  void Show( int nestLevel, std::ostream& os ) const override {}
139 #endif
140 };
141 
142 #endif
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:69
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_pin.cpp:147
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_pin.h:82
bool Replace(const wxFindReplaceData &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:128
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: sch_pin.cpp:296
const wxPoint GetLocalPosition() const
Definition: sch_pin.h:90
int GetLength() const
Definition: sch_pin.cpp:112
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_pin.h:80
bool IsVisible() const
Definition: sch_pin.h:112
SCH_COMPONENT * GetParentSymbol() const
Definition: sch_pin.cpp:141
void SetIsDangling(bool isDangling)
Definition: sch_pin.h:97
void ClearDefaultNetName(const SCH_SHEET_PATH *aPath)
Definition: sch_pin.cpp:224
wxString GetAlt() const
Definition: sch_pin.h:74
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath, bool aForceNoConnect=false)
Definition: sch_pin.cpp:235
wxString GetNumber() const
Definition: sch_pin.h:116
GRAPHIC_PINSHAPE
Definition: pin_type.h:54
The base class for create windows for drawing purpose.
bool IsDangling() const override
Definition: sch_pin.h:96
wxPoint GetPosition() const override
Definition: sch_pin.h:89
bool IsPointClickableAnchor(const wxPoint &aPos) const override
Definition: sch_pin.h:99
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN.
Definition: lib_pin.h:234
SCH_PIN(LIB_PIN *aLibPin, SCH_COMPONENT *aParentSymbol)
Definition: sch_pin.cpp:29
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_pin.h:84
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_pin.h:87
bool m_isDangling
Definition: sch_pin.h:42
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_pin.h:57
int GetOrientation() const
Definition: sch_pin.cpp:106
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_pin.cpp:118
bool IsVisible() const
Definition: lib_pin.h:147
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:97
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::recursive_mutex m_netmap_mutex
The name that this pin connection will drive onto a net.
Definition: sch_pin.h:45
SCH_PIN & operator=(const SCH_PIN &aPin)
Definition: sch_pin.cpp:65
void SetPosition(const wxPoint &aPosition) override
Definition: sch_pin.h:91
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_pin.h:85
wxString m_number
Definition: sch_pin.h:39
void SetNumber(const wxString &aNumber)
Definition: sch_pin.h:117
EDA_UNITS
Definition: eda_units.h:38
wxString GetClass() const override
Return the class name.
Definition: sch_pin.h:62
wxString GetCanonicalElectricalTypeName() const
Definition: sch_pin.h:121
wxString m_alt
Definition: sch_pin.h:40
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:34
std::map< const SCH_SHEET_PATH, std::pair< wxString, bool > > m_net_name_map
Definition: sch_pin.h:46
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:88
void SetAlt(const wxString &aAlt)
Definition: sch_pin.h:75
Handle the component boundary box.
Definition: eda_rect.h:42
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, MSG_PANEL_ITEMS &aList) override
Definition: sch_pin.cpp:155
Schematic symbol object.
Definition: sch_symbol.h:79
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Returns true if this item should propagate connection info to aItem.
Definition: sch_pin.cpp:303
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
bool IsPowerConnection() const
Definition: sch_pin.h:132
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_pin.cpp:282
wxString const GetCanonicalElectricalTypeName() const
Definition: lib_pin.h:137
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Message panel definition file.
LIB_PIN * m_libPin
Definition: sch_pin.h:37
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
wxString GetName() const
Definition: sch_pin.cpp:79
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
wxPoint GetTransformedPosition() const
Returns the pin's position in global coordinates.
Definition: sch_pin.cpp:275
wxPoint m_position
Definition: sch_pin.h:41