KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_sheet_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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SCH_SHEEET_PIN_H
22#define SCH_SHEEET_PIN_H
23
24#include <sch_label.h>
25
26class KIID;
27class LINE_READER;
28class SCH_SHEET;
29
31{
32 class SheetPin;
33}
34
35
54
55
67{
68public:
69 SCH_SHEET_PIN( SCH_SHEET* parent, const VECTOR2I& pos = VECTOR2I( 0, 0 ),
70 const wxString& text = wxEmptyString );
71
72 void Serialize( google::protobuf::Any& aContainer ) const override;
73 bool Deserialize( const google::protobuf::Any& aContainer ) override;
74
75 void Serialize( kiapi::schematic::types::SheetPin& aOutput ) const;
76 bool Deserialize( const kiapi::schematic::types::SheetPin& aInput );
77
78 // Do not create a copy constructor. The one generated by the compiler is adequate.
79
81
82 static inline bool ClassOf( const EDA_ITEM* aItem )
83 {
84 return aItem && SCH_SHEET_PIN_T == aItem->Type();
85 }
86
87 wxString GetClass() const override
88 {
89 return wxT( "SCH_SHEET_PIN" );
90 }
91
92 wxString GetFriendlyName() const override
93 {
94 return _( "Sheet Pin" );
95 }
96
97 bool operator ==( const SCH_SHEET_PIN* aPin ) const;
98 bool operator!=( const SCH_SHEET_PIN* aRhs ) const { return !( this == aRhs ); }
99
101 {
102 switch( aSide )
103 {
108 default: return SHEET_SIDE::UNDEFINED;
109 }
110 }
111
118 bool IsMovableFromAnchorPoint() const override { return true; }
119
127 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
128 const VECTOR2I& aPos ) const override;
129
130 int GetPenWidth() const override;
131
137 int GetNumber() const { return m_number; }
138
144 void SetNumber( int aNumber );
145
146 void SetSide( SHEET_SIDE aEdge );
147
148 SHEET_SIDE GetSide() const;
149
154 void ConstrainOnEdge( const VECTOR2I& aPos, bool aAllowEdgeSwitch );
155
162 SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_parent; }
163
164 bool IsLocked() const override;
165
166#if defined(DEBUG)
167 void Show( int nestLevel, std::ostream& os ) const override;
168#endif
169
170 // Geometric transforms (used in block operations):
171
172 void Move( const VECTOR2I& aMoveVector ) override
173 {
174 Offset( aMoveVector );
175 }
176
177 void MirrorVertically( int aCenter ) override;
178 void MirrorHorizontally( int aCenter ) override;
179 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
180
181 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
182 {
183 return SCH_ITEM::Matches( GetText(), aSearchData );
184 }
185
186 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData = nullptr ) override
187 {
188 return EDA_TEXT::Replace( aSearchData );
189 }
190
191 bool IsReplaceable() const override { return true; }
192
193 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
194
195 bool IsConnectable() const override { return true; }
196
197 bool HasConnectivityChanges( const SCH_ITEM* aItem,
198 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
199
200 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
201
202 BITMAPS GetMenuImage() const override;
203
204 void SetPosition( const VECTOR2I& aPosition ) override
205 {
206 ConstrainOnEdge( aPosition, true );
207 }
208
209 void CalcEdit( const VECTOR2I& aPosition ) override { ConstrainOnEdge( aPosition, true ); }
210
211 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
212 {
213 return m_isDangling && GetPosition() == aPos;
214 }
215
216 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
217
218 EDA_ITEM* Clone() const override;
219
220 double Similarity( const SCH_ITEM& aOther ) const override;
221
222 bool operator==( const SCH_ITEM& aOther ) const override;
223
224protected:
225 void swapData( SCH_ITEM* aItem ) override;
226
227private:
232
234};
235
236#endif // SCH_SHEEET_PIN_H
BITMAPS
A list of all bitmap identifiers.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:484
EDA_ITEM * m_parent
Owner.
Definition eda_item.h:609
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
virtual void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:575
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition eda_text.cpp:450
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Definition kiid.h:46
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:65
SCH_HIERLABEL(const VECTOR2I &aPos=VECTOR2I(0, 0), const wxString &aText=wxEmptyString, KICAD_T aType=SCH_HIER_LABEL_T)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData=nullptr) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
void SetNumber(int aNumber)
Set the sheet label number.
bool IsLocked() const override
SCH_SHEET_PIN(SCH_SHEET *parent, const VECTOR2I &pos=VECTOR2I(0, 0), const wxString &text=wxEmptyString)
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
SHEET_SIDE m_edge
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void SetPosition(const VECTOR2I &aPosition) override
int m_number
Label number use for saving sheet label to file.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
static bool ClassOf(const EDA_ITEM *aItem)
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int GetPenWidth() const override
bool IsConnectable() const override
static SHEET_SIDE GetOppositeSide(SHEET_SIDE aSide)
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
SHEET_SIDE GetSide() const
wxString GetClass() const override
Return the class name.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
int GetNumber() const
Get the sheet label number.
bool operator==(const SCH_SHEET_PIN *aPin) const
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
wxString GetFriendlyName() const override
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator!=(const SCH_SHEET_PIN *aRhs) const
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
void ConstrainOnEdge(const VECTOR2I &aPos, bool aAllowEdgeSwitch)
Adjust label position to edge based on proximity to vertical or horizontal edge of the parent sheet.
void SetSide(SHEET_SIDE aEdge)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
VECTOR2I GetPosition() const override
Definition sch_text.h:143
#define _(s)
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
@ SCH_SHEET_PIN_T
Definition typeinfo.h:170
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708