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 
41 
43  std::mutex m_netmap_mutex;
44  std::map<const SCH_SHEET_PATH, wxString> m_net_name_map;
45 
46 public:
47  SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent );
48 
49  SCH_PIN( const SCH_PIN& aPin );
50 
51  SCH_PIN& operator=( const SCH_PIN& aPin );
52 
53  static inline bool ClassOf( const EDA_ITEM* aItem )
54  {
55  return aItem && SCH_PIN_T == aItem->Type();
56  }
57 
58  wxString GetClass() const override
59  {
60  return wxT( "SCH_PIN" );
61  }
62 
64 
65  LIB_PIN* GetLibPin() const { return m_libPin; }
66 
67  wxString GetDefaultNetName( const SCH_SHEET_PATH aPath );
68 
69  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
70  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) override;
71 
72  void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override {}
73 
74  void Move( const wxPoint& aMoveVector ) override {}
75 
76  void MirrorY( int aYaxis_position ) override {}
77  void MirrorX( int aXaxis_position ) override {}
78 
79  void Rotate( wxPoint aPosition ) override {}
80 
81  wxPoint GetPosition() const override { return GetTransformedPosition(); }
82  const wxPoint GetLocalPosition() const { return m_position; }
83  void SetPosition( const wxPoint& aPosition ) override { m_position = aPosition; }
84 
85  const EDA_RECT GetBoundingBox() const override;
86  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
87 
88  bool IsDangling() const override { return m_isDangling; }
89  void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
90 
93 
94  bool Matches( wxFindReplaceData& aSearchData, void* aAuxData ) override;
95 
96  /*
97  * While many of these are currently simply covers for the equivalent LIB_PIN methods,
98  * the new EESchema file format will soon allow us to override them at the SCH level.
99  */
100  bool IsVisible() const { return m_libPin->IsVisible(); }
101 
102  const wxString& GetName() const { return m_libPin->GetName(); }
103 
104  const wxString& GetNumber() const { return m_libPin->GetNumber(); }
105 
107 
108  bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); }
109 
110  bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
111 
112 
113 #if defined(DEBUG)
114  void Show( int nestLevel, std::ostream& os ) const override {}
115 #endif
116 };
117 
118 #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:76
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:65
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:70
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_pin.h:74
const wxString & GetName() const
Definition: sch_pin.h:102
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:137
const wxPoint GetLocalPosition() const
Definition: sch_pin.h:82
bool IsVisible() const
Definition: sch_pin.h:100
void SetIsDangling(bool isDangling)
Definition: sch_pin.h:89
std::mutex m_netmap_mutex
The name that this pin connection will drive onto a net.
Definition: sch_pin.h:43
std::map< const SCH_SHEET_PATH, wxString > m_net_name_map
Definition: sch_pin.h:44
The base class for create windows for drawing purpose.
wxString GetDefaultNetName(const SCH_SHEET_PATH aPath)
Definition: sch_pin.cpp:84
bool IsDangling() const override
Definition: sch_pin.h:88
wxPoint GetPosition() const override
Definition: sch_pin.h:81
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:353
const wxString & GetNumber() const
Definition: sch_pin.h:104
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_pin.h:79
bool m_isDangling
Definition: sch_pin.h:40
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_pin.h:53
const wxString & GetName() const
Definition: lib_pin.h:153
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:347
SCH_SHEET_PATH.
SCH_PIN & operator=(const SCH_PIN &aPin)
Definition: sch_pin.cpp:46
void SetPosition(const wxPoint &aPosition) override
Set the schematic item position to aPosition.
Definition: sch_pin.h:83
const wxString & GetNumber() const
Definition: lib_pin.h:181
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:236
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_pin.h:58
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:106
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:78
Schematic symbol object.
Definition: sch_component.h:88
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Returns true if this item should propagate connection info to aItem.
Definition: sch_pin.cpp:144
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:108
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.
Message panel definition file.
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:64
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:187
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:77
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_pin.h:72
wxPoint GetTransformedPosition() const
Returns the pin's position in global coordinates.
Definition: sch_pin.cpp:116
wxPoint m_position
Definition: sch_pin.h:39