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 <msgpanel.h>
27 #include <sch_item.h>
28 #include <sch_sheet_path.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;
43 
45  std::recursive_mutex m_netmap_mutex;
46  std::map<const SCH_SHEET_PATH, wxString> m_net_name_map;
47 
48 public:
49  SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent );
50 
51  SCH_PIN( const SCH_PIN& aPin );
52 
53  SCH_PIN& operator=( const SCH_PIN& aPin );
54 
55  static inline bool ClassOf( const EDA_ITEM* aItem )
56  {
57  return aItem && SCH_PIN_T == aItem->Type();
58  }
59 
60  wxString GetClass() const override
61  {
62  return wxT( "SCH_PIN" );
63  }
64 
66 
67  LIB_PIN* GetLibPin() const { return m_libPin; }
68 
69  void ClearDefaultNetName( const SCH_SHEET_PATH* aPath );
70  wxString GetDefaultNetName( const SCH_SHEET_PATH& aPath );
71 
72  wxString GetAlt() const { return m_alt; }
73  void SetAlt( const wxString& aAlt ) { m_alt = aAlt; }
74 
75  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
76  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) override;
77 
78  void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override {}
79 
80  void Move( const wxPoint& aMoveVector ) override {}
81 
82  void MirrorY( int aYaxis_position ) override {}
83  void MirrorX( int aXaxis_position ) override {}
84 
85  void Rotate( wxPoint aPosition ) override {}
86 
87  wxPoint GetPosition() const override { return GetTransformedPosition(); }
88  const wxPoint GetLocalPosition() const { return m_position; }
89  void SetPosition( const wxPoint& aPosition ) override { m_position = aPosition; }
90 
91  const EDA_RECT GetBoundingBox() const override;
92  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
93 
94  bool IsDangling() const override { return m_isDangling; }
95  void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
96 
99 
100  bool Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override;
101 
102  bool Replace( wxFindReplaceData& aSearchData, void* aAuxData ) override;
103 
104  /*
105  * While many of these are currently simply covers for the equivalent LIB_PIN methods,
106  * the new EESchema file format will soon allow us to override them at the SCH level.
107  */
108  bool IsVisible() const { return m_libPin->IsVisible(); }
109 
110  wxString GetName() const;
111 
112  wxString GetNumber() const { return m_number; }
113  void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
114 
115  ELECTRICAL_PINTYPE GetType() const;
116 
117  GRAPHIC_PINSHAPE GetShape() const;
118 
119  int GetOrientation() const;
120 
121  int GetLength() const;
122 
123  bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); }
124 
125  bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
126 
127 
128 #if defined(DEBUG)
129  void Show( int nestLevel, std::ostream& os ) const override {}
130 #endif
131 };
132 
133 #endif
EDA_UNITS
Definition: common.h:198
void MirrorY(int aYaxis_position) override
Mirror item relative to the Y axis about aYaxis_position.
Definition: sch_pin.h:82
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:67
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_pin.cpp:133
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_pin.h:80
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_pin.cpp:273
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath)
Definition: sch_pin.cpp:220
const wxPoint GetLocalPosition() const
Definition: sch_pin.h:88
int GetLength() const
Definition: sch_pin.cpp:98
bool IsVisible() const
Definition: sch_pin.h:108
void SetIsDangling(bool isDangling)
Definition: sch_pin.h:95
void ClearDefaultNetName(const SCH_SHEET_PATH *aPath)
Definition: sch_pin.cpp:209
wxString GetAlt() const
Definition: sch_pin.h:72
std::map< const SCH_SHEET_PATH, wxString > m_net_name_map
Definition: sch_pin.h:46
wxString GetNumber() const
Definition: sch_pin.h:112
GRAPHIC_PINSHAPE
Definition: pin_type.h:53
The base class for create windows for drawing purpose.
bool IsDangling() const override
Definition: sch_pin.h:94
wxPoint GetPosition() const override
Definition: sch_pin.h:87
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
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_pin.h:85
bool m_isDangling
Definition: sch_pin.h:42
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_pin.h:55
SCH_PIN(LIB_PIN *aLibPin, SCH_COMPONENT *aParentComponent)
Definition: sch_pin.cpp:29
int GetOrientation() const
Definition: sch_pin.cpp:92
bool IsVisible() const
Definition: lib_pin.h:147
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:83
SCH_SHEET_PATH.
bool Replace(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Replace performs a text replace using the find and replace criteria in aSearchData on items ...
Definition: sch_pin.cpp:114
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:51
void SetPosition(const wxPoint &aPosition) override
Definition: sch_pin.h:89
wxString m_number
Definition: sch_pin.h:39
void SetNumber(const wxString &aNumber)
Definition: sch_pin.h:113
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_pin.h:60
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
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:74
void SetAlt(const wxString &aAlt)
Definition: sch_pin.h:73
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, MSG_PANEL_ITEMS &aList) override
Definition: sch_pin.cpp:141
Schematic symbol object.
Definition: sch_component.h:80
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Returns true if this item should propagate connection info to aItem.
Definition: sch_pin.cpp:280
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
bool IsPowerConnection() const
Definition: sch_pin.h:123
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_pin.cpp:104
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_pin.cpp:259
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Message panel definition file.
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:127
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:194
wxString GetName() const
Definition: sch_pin.cpp:65
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
void MirrorX(int aXaxis_position) override
Mirror item relative to the X axis about aXaxis_position.
Definition: sch_pin.h:83
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_pin.h:78
wxPoint GetTransformedPosition() const
Returns the pin's position in global coordinates.
Definition: sch_pin.cpp:252
wxPoint m_position
Definition: sch_pin.h:41