KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef SCH_SHEEET_PIN_H
26#define SCH_SHEEET_PIN_H
27
28#include <sch_label.h>
29
30class KIID;
31class LINE_READER;
32class SCH_SHEET;
33
34
45enum class SHEET_SIDE
46{
47 LEFT = 0,
48 RIGHT,
49 TOP,
50 BOTTOM,
52};
53
54
66{
67public:
68 SCH_SHEET_PIN( SCH_SHEET* parent, const VECTOR2I& pos = VECTOR2I( 0, 0 ),
69 const wxString& text = wxEmptyString );
70
71 // Do not create a copy constructor. The one generated by the compiler is adequate.
72
74
75 static inline bool ClassOf( const EDA_ITEM* aItem )
76 {
77 return aItem && SCH_SHEET_PIN_T == aItem->Type();
78 }
79
80 wxString GetClass() const override
81 {
82 return wxT( "SCH_SHEET_PIN" );
83 }
84
85 bool operator ==( const SCH_SHEET_PIN* aPin ) const;
86 bool operator!=( const SCH_SHEET_PIN* aRhs ) const { return !( this == aRhs ); }
87
89 {
90 switch( aSide )
91 {
92 case SHEET_SIDE::TOP: return SHEET_SIDE::BOTTOM;
93 case SHEET_SIDE::BOTTOM: return SHEET_SIDE::TOP;
94 case SHEET_SIDE::LEFT: return SHEET_SIDE::RIGHT;
95 case SHEET_SIDE::RIGHT: return SHEET_SIDE::LEFT;
96 default: return SHEET_SIDE::UNDEFINED;
97 }
98 }
99
106 bool IsMovableFromAnchorPoint() const override { return true; }
107
114 void CreateGraphicShape( const RENDER_SETTINGS* aSettings, std::vector<VECTOR2I>& aPoints,
115 const VECTOR2I& aPos ) const override;
116
117 int GetPenWidth() const override;
118
124 int GetNumber() const { return m_number; }
125
131 void SetNumber( int aNumber );
132
133 void SetSide( SHEET_SIDE aEdge );
134
135 SHEET_SIDE GetSide() const;
136
141 void ConstrainOnEdge( VECTOR2I aPos, bool aAllowEdgeSwitch );
142
149 SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_parent; }
150
151#if defined(DEBUG)
152 void Show( int nestLevel, std::ostream& os ) const override;
153#endif
154
155 // Geometric transforms (used in block operations):
156
157 void Move( const VECTOR2I& aMoveVector ) override
158 {
159 Offset( aMoveVector );
160 }
161
162 void MirrorVertically( int aCenter ) override;
163 void MirrorHorizontally( int aCenter ) override;
164 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
165
166 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
167 {
168 return SCH_ITEM::Matches( GetText(), aSearchData );
169 }
170
171 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData = nullptr ) override
172 {
173 return EDA_TEXT::Replace( aSearchData );
174 }
175
176 bool IsReplaceable() const override { return true; }
177
178 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
179
180 bool IsConnectable() const override { return true; }
181
182 bool HasConnectivityChanges( const SCH_ITEM* aItem,
183 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
184
185 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
186
187 BITMAPS GetMenuImage() const override;
188
189 void SetPosition( const VECTOR2I& aPosition ) override
190 {
191 ConstrainOnEdge( aPosition, true );
192 }
193
194 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
195 {
196 return m_isDangling && GetPosition() == aPos;
197 }
198
199 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
200
201 EDA_ITEM* Clone() const override;
202
203 double Similarity( const SCH_ITEM& aOther ) const override;
204
205 bool operator==( const SCH_ITEM& aOther ) const override;
206
207protected:
208 void swapData( SCH_ITEM* aItem ) override;
209
210private:
215
217};
218
219#endif // SCH_SHEEET_PIN_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:95
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:107
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:382
EDA_ITEM * m_parent
Linked list: Link (parent struct).
Definition: eda_item.h:506
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:589
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:479
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Definition: kiid.h:49
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
bool m_isDangling
Definition: sch_label.h:372
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.
Definition: sch_sheet_pin.h:66
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.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
SHEET_SIDE m_edge
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)
Definition: sch_sheet_pin.h:75
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 ConstrainOnEdge(VECTOR2I aPos, bool aAllowEdgeSwitch)
Adjust label position to edge based on proximity to vertical or horizontal edge of the parent sheet.
int GetPenWidth() const override
bool IsConnectable() const override
static SHEET_SIDE GetOppositeSide(SHEET_SIDE aSide)
Definition: sch_sheet_pin.h:88
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.
Definition: sch_sheet_pin.h:80
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.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator!=(const SCH_SHEET_PIN *aRhs) const
Definition: sch_sheet_pin.h:86
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 SetSide(SHEET_SIDE aEdge)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:47
VECTOR2I GetPosition() const override
Definition: sch_text.h:139
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
Definition: sch_sheet_pin.h:46
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695