KiCad PCB EDA Suite
sch_bus_entry.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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2004-2019 KiCad Developers, see change_log.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 
30 #ifndef _SCH_BUS_ENTRY_H_
31 #define _SCH_BUS_ENTRY_H_
32 
33 #include <sch_item.h>
34 
35 #define TARGET_BUSENTRY_RADIUS Mils2iu( 12 ) // Circle diameter drawn at the ends
36 
37 
42 {
43 protected:
45  wxSize m_size;
47 
48 public:
49  SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
50 
51  bool IsDanglingStart() const { return m_isDanglingStart; }
52  bool IsDanglingEnd() const { return m_isDanglingEnd; }
53 
54  // Do not create a copy constructor. The one generated by the compiler is adequate.
55 
57 
63  bool IsMovableFromAnchorPoint() override { return false; }
64 
65  wxPoint m_End() const;
66 
70  char GetBusEntryShape() const;
71 
75  void SetBusEntryShape( char aShape );
76 
77  wxSize GetSize() const { return m_size; }
78 
79  void SetSize( const wxSize& aSize ) { m_size = aSize; }
80 
81  void SwapData( SCH_ITEM* aItem ) override;
82 
83  void ViewGetLayers( int aLayers[], int& aCount ) const override;
84 
85  void Print( wxDC* aDC, const wxPoint& aOffset ) override;
86 
87  const EDA_RECT GetBoundingBox() const override;
88 
89  void Move( const wxPoint& aMoveVector ) override
90  {
91  m_pos += aMoveVector;
92  }
93 
94  void MirrorY( int aYaxis_position ) override;
95  void MirrorX( int aXaxis_position ) override;
96  void Rotate( wxPoint aPosition ) override;
97 
98  bool IsDangling() const override;
99 
100  bool IsConnectable() const override { return true; }
101 
102  void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
103 
104  wxPoint GetPosition() const override { return m_pos; }
105  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
106 
107  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
108  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
109 
110  void Plot( PLOTTER* aPlotter ) override;
111 
112  void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
113 
114  bool operator <( const SCH_ITEM& aItem ) const override;
115 
116 #if defined(DEBUG)
117  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
118 #endif
119 
120 private:
121  bool doIsConnected( const wxPoint& aPosition ) const override;
122 };
123 
128 {
129 public:
130  SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
131 
133 
134  static inline bool ClassOf( const EDA_ITEM* aItem )
135  {
136  return aItem && SCH_BUS_WIRE_ENTRY_T == aItem->Type();
137  }
138 
139  wxString GetClass() const override
140  {
141  return wxT( "SCH_BUS_WIRE_ENTRY" );
142  }
143 
144  int GetPenSize() const override;
145 
146  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
147 
148  bool CanConnect( const SCH_ITEM* aItem ) const override
149  {
150  return aItem->Type() == SCH_LINE_T &&
151  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
152  }
153 
154  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
155 
156  EDA_ITEM* Clone() const override;
157 
158  virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
159 
160  BITMAP_DEF GetMenuImage() const override;
161 
162  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
163  const SCH_SHEET_PATH* aPath = nullptr ) override;
164 
170 };
171 
176 {
177 public:
178  SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
179 
181 
182  static inline bool ClassOf( const EDA_ITEM* aItem )
183  {
184  return aItem && SCH_BUS_BUS_ENTRY_T == aItem->Type();
185  }
186 
187  wxString GetClass() const override
188  {
189  return wxT( "SCH_BUS_BUS_ENTRY" );
190  }
191 
192  int GetPenSize() const override;
193 
194  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
195 
196  bool CanConnect( const SCH_ITEM* aItem ) const override
197  {
198  return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
199  }
200 
201  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
202 
203  EDA_ITEM* Clone() const override;
204 
205  BITMAP_DEF GetMenuImage() const override;
206 
207  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
208  const SCH_SHEET_PATH* aPath = nullptr ) override;
209 
215 };
216 
217 #endif // _SCH_BUS_ENTRY_H_
EDA_UNITS
Definition: common.h:184
Class for a bus to bus entry.
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_bus_entry.h:89
bool doIsConnected(const wxPoint &aPosition) const override
Function doIsConnected provides the object specific test to see if it is connected to aPosition.
PNG memory record (file in memory).
Definition: bitmap_def.h:29
int GetPenSize() const override
Function GetPenSize virtual pure.
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
void SetSize(const wxSize &aSize)
Definition: sch_bus_entry.h:79
SCH_ITEM * m_connected_bus_item
Pointer to the bus item (usually a bus wire) connected to this bus-wire entry, if it is connected to ...
SCH_ITEM * m_connected_bus_items[2]
Pointer to the bus items (usually bus wires) connected to this bus-bus entry (either or both may be n...
bool CanConnect(const SCH_ITEM *aItem) const override
~SCH_BUS_BUS_ENTRY()
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item.
SCH_BUS_WIRE_ENTRY(const wxPoint &pos=wxPoint(0, 0), char shape='\\')
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
wxString GetClass() const override
Function GetClass returns the class name.
wxPoint m_pos
Definition: sch_bus_entry.h:44
bool CanConnect(const SCH_ITEM *aItem) const override
wxSize m_size
Definition: sch_bus_entry.h:45
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:52
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
virtual bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Returns true if this item should propagate connection info to aItem.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
SCH_BUS_ENTRY_BASE(KICAD_T aType, const wxPoint &pos=wxPoint(0, 0), char shape='\\')
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
bool IsDangling() const override
bool IsDanglingStart() const
Definition: sch_bus_entry.h:51
wxString GetClass() const override
Function GetClass returns the class name.
bool IsMovableFromAnchorPoint() override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
Definition: sch_bus_entry.h:63
bool m_isDanglingStart
Definition: sch_bus_entry.h:46
static bool ClassOf(const EDA_ITEM *aItem)
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points.
char GetBusEntryShape() const
void SetBusEntryShape(char aShape)
SCH_SHEET_PATH.
wxPoint m_End() const
int GetPenSize() const override
Function GetPenSize virtual pure.
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:224
Base plotter engine class.
Definition: plotter.h:104
wxSize GetSize() const
Definition: sch_bus_entry.h:77
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
bool m_isDanglingEnd
Definition: sch_bus_entry.h:46
SCH_BUS_BUS_ENTRY(const wxPoint &pos=wxPoint(0, 0), char shape='\\')
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
Class for a wire to bus entry.
bool operator<(const SCH_ITEM &aItem) const override
~SCH_BUS_ENTRY_BASE()
Definition: sch_bus_entry.h:56
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
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.
~SCH_BUS_WIRE_ENTRY()
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
static bool ClassOf(const EDA_ITEM *aItem)
wxPoint GetPosition() const override
Function GetPosition.