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 <sch_item.h>
26 #include <sch_sheet_path.h>
27 #include <lib_pin.h>
28 
29 #include <mutex>
30 #include <map>
31 
32 class SCH_COMPONENT;
33 
34 class SCH_PIN : public SCH_ITEM
35 {
37 
38  wxPoint m_position;
40 
42  std::mutex m_netmap_mutex;
43  std::map<const SCH_SHEET_PATH, wxString> m_net_name_map;
44 
45 public:
46  SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent );
47 
48  SCH_PIN( const SCH_PIN& aPin );
49 
50  SCH_PIN& operator=( const SCH_PIN& aPin );
51 
52  static inline bool ClassOf( const EDA_ITEM* aItem )
53  {
54  return aItem && SCH_PIN_T == aItem->Type();
55  }
56 
57  wxString GetClass() const override
58  {
59  return wxT( "SCH_PIN" );
60  }
61 
63 
64  LIB_PIN* GetLibPin() const { return m_libPin; }
65 
66  wxString GetDefaultNetName( const SCH_SHEET_PATH aPath );
67 
68  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
69  void GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) override;
70 
71  void Print( wxDC* aDC, const wxPoint& aOffset ) override {}
72 
73  void Move( const wxPoint& aMoveVector ) override {}
74 
75  void MirrorY( int aYaxis_position ) override {}
76  void MirrorX( int aXaxis_position ) override {}
77 
78  void Rotate( wxPoint aPosition ) override {}
79 
80  wxPoint GetPosition() const override { return m_position; }
81  void SetPosition( const wxPoint& aPosition ) override { m_position = aPosition; }
82 
83  const EDA_RECT GetBoundingBox() const override;
84  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
85 
86  bool IsDangling() const override { return m_isDangling; }
87  void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
88 
90  wxPoint GetTransformedPosition() const;
91 
92  bool Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override;
93 
94  /*
95  * While many of these are currently simply covers for the equivalent LIB_PIN methods,
96  * the new EESchema file format will soon allow us to override them at the SCH level.
97  */
98  bool IsVisible() const { return m_libPin->IsVisible(); }
99 
100  const wxString& GetName() const { return m_libPin->GetName(); }
101 
102  const wxString& GetNumber() const { return m_libPin->GetNumber(); }
103 
105 
106  bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); }
107 
108 
109 #if defined(DEBUG)
110  void Show( int nestLevel, std::ostream& os ) const override {}
111 #endif
112 };
113 
114 #endif
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_pin.h:75
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:64
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_pin.h:73
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_pin.cpp:70
const wxString & GetName() const
Definition: sch_pin.h:100
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:137
bool IsVisible() const
Definition: sch_pin.h:98
void SetIsDangling(bool isDangling)
Definition: sch_pin.h:87
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
Definition: sch_pin.h:71
std::mutex m_netmap_mutex
The name that this pin connection will drive onto a net.
Definition: sch_pin.h:42
std::map< const SCH_SHEET_PATH, wxString > m_net_name_map
Definition: sch_pin.h:43
wxString GetDefaultNetName(const SCH_SHEET_PATH aPath)
Definition: sch_pin.cpp:84
bool IsDangling() const override
Definition: sch_pin.h:86
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_pin.h:80
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:349
const wxString & GetNumber() const
Definition: sch_pin.h:102
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_pin.h:78
bool m_isDangling
Definition: sch_pin.h:39
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_pin.h:52
const wxString & GetName() const
Definition: lib_pin.h:149
SCH_PIN(LIB_PIN *aLibPin, SCH_COMPONENT *aParentComponent)
Definition: sch_pin.cpp:28
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:343
Class SCH_SHEET_PATH.
SCH_PIN & operator=(const SCH_PIN &aPin)
Definition: sch_pin.cpp:46
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_pin.h:81
const wxString & GetNumber() const
Definition: lib_pin.h:177
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:232
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_pin.h:57
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:37
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.h:104
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
bool IsPowerConnection() const
Definition: sch_pin.h:106
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: sch_pin.cpp:58
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_pin.cpp:123
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void GetMsgPanelInfo(EDA_UNITS_T aUnits, MSG_PANEL_ITEMS &aList) override
Definition: sch_pin.cpp:78
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:64
LIB_PIN * m_libPin
Definition: sch_pin.h:36
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
EDA_UNITS_T
Definition: common.h:133
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_pin.h:76
wxPoint GetTransformedPosition() const
Returns the pin's position in global coordinates.
Definition: sch_pin.cpp:116
wxPoint m_position
Definition: sch_pin.h:38