KiCad PCB EDA Suite
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 (C) 1992-2021 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_text.h>
29 
30 class KIID;
31 class LINE_READER;
32 class SCH_SHEET;
33 
34 
45 enum class SHEET_SIDE
46 {
47  LEFT = 0,
48  RIGHT,
49  TOP,
50  BOTTOM,
51  UNDEFINED
52 };
53 
54 
66 {
67 public:
68  SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos = wxPoint( 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 
93  bool IsMovableFromAnchorPoint() const override { return true; }
94 
95  void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
96 
103  void CreateGraphicShape( const RENDER_SETTINGS* aSettings,
104  std::vector <wxPoint>& aPoints, const wxPoint& aPos ) const override;
105 
106  void SwapData( SCH_ITEM* aItem ) override;
107 
108  int GetPenWidth() const override;
109 
115  int GetNumber() const { return m_number; }
116 
122  void SetNumber( int aNumber );
123 
124  void SetEdge( SHEET_SIDE aEdge );
125 
126  SHEET_SIDE GetEdge() const;
127 
132  void ConstrainOnEdge( wxPoint Pos );
133 
140  SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_parent; }
141 
142 #if defined(DEBUG)
143  void Show( int nestLevel, std::ostream& os ) const override;
144 #endif
145 
146  // Geometric transforms (used in block operations):
147 
148  void Move( const wxPoint& aMoveVector ) override
149  {
150  Offset( aMoveVector );
151  }
152 
153  void MirrorVertically( int aCenter ) override;
154  void MirrorHorizontally( int aCenter ) override;
155  void Rotate( const wxPoint& aCenter ) override;
156 
157  bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
158  {
159  return SCH_ITEM::Matches( GetText(), aSearchData );
160  }
161 
162  bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData = nullptr ) override
163  {
164  return EDA_TEXT::Replace( aSearchData );
165  }
166 
167  bool IsReplaceable() const override { return true; }
168 
169  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
170 
171  bool IsConnectable() const override { return true; }
172 
173  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
174 
175  BITMAPS GetMenuImage() const override;
176 
177  void SetPosition( const wxPoint& aPosition ) override { ConstrainOnEdge( aPosition ); }
178 
179  bool IsPointClickableAnchor( const wxPoint& aPos ) const override
180  {
181  return m_isDangling && GetPosition() == aPos;
182  }
183 
184  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
185 
186  EDA_ITEM* Clone() const override;
187 
188 private:
189  int m_number;
190 
195 };
196 
197 #endif // _SCH_SHEEET_PIN_H_
bool Replace(const wxFindReplaceData &aSearchData, void *aAuxData=nullptr) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
bool IsPointClickableAnchor(const wxPoint &aPos) const override
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:252
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:365
SCH_SHEET * GetParent() const
Get the parent sheet object of this sheet pin.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
SCH_SHEET_PIN(SCH_SHEET *parent, const wxPoint &pos=wxPoint(0, 0), const wxString &text=wxEmptyString)
bool m_isDangling
True if not connected to another object if the object derive from SCH_TEXT supports connections.
Definition: sch_text.h:262
bool Replace(const wxFindReplaceData &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:170
wxString GetClass() const override
Return the class name.
Definition: sch_sheet_pin.h:80
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool IsConnectable() const override
SHEET_SIDE GetEdge() const
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: kiid.h:44
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
Definition: sch_sheet_pin.h:93
void SetEdge(SHEET_SIDE aEdge)
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
int GetNumber() const
Get the sheet label number.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void ConstrainOnEdge(wxPoint Pos)
Adjust label position to edge based on proximity to vertical or horizontal edge of the parent sheet.
wxPoint GetPosition() const override
Definition: sch_text.h:239
int GetPenWidth() const override
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
EDA_UNITS
Definition: eda_units.h:38
void SetPosition(const wxPoint &aPosition) override
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void SetNumber(int aNumber)
Set the sheet label number.
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
int m_number
Label number use for saving sheet label to file.
bool operator==(const SCH_SHEET_PIN *aPin) const
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
Definition: sch_sheet_pin.h:45
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_sheet_pin.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
SHEET_SIDE m_edge
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113