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 12 // Circle diameter drawn at the ends
36 
37 
42 {
43 protected:
44  wxPoint m_pos;
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 
64  bool IsMovableFromAnchorPoint() override { return false; }
65 
66  wxPoint m_End() const;
67 
72  char GetBusEntryShape() const;
73 
78  void SetBusEntryShape( char aShape );
79 
80  wxSize GetSize() const { return m_size; }
81 
82  void SetSize( const wxSize& aSize ) { m_size = aSize; }
83 
84  void SwapData( SCH_ITEM* aItem ) override;
85 
86  void ViewGetLayers( int aLayers[], int& aCount ) const override;
87 
88  void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override;
89 
90  const EDA_RECT GetBoundingBox() const override;
91 
92  void Move( const wxPoint& aMoveVector ) override
93  {
94  m_pos += aMoveVector;
95  }
96 
97  void MirrorY( int aYaxis_position ) override;
98  void MirrorX( int aXaxis_position ) override;
99  void Rotate( wxPoint aPosition ) override;
100 
101  bool IsDangling() const override;
102 
103  bool IsConnectable() const override { return true; }
104 
105  void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
106 
107  wxPoint GetPosition() const override { return m_pos; }
108  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
109 
110  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
111  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
112 
113  void Plot( PLOTTER* aPlotter ) override;
114 
115  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
116 
117 #if defined(DEBUG)
118  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
119 #endif
120 
121 private:
122  bool doIsConnected( const wxPoint& aPosition ) const override;
123 };
124 
129 {
130 public:
131  SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
132 
134 
135  wxString GetClass() const override
136  {
137  return wxT( "SCH_BUS_WIRE_ENTRY" );
138  }
139 
140  int GetPenSize() const override;
141 
142  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
143 
144  bool CanConnect( const SCH_ITEM* aItem ) const override
145  {
146  return aItem->Type() == SCH_LINE_T &&
147  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
148  }
149 
150  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
151 
152  EDA_ITEM* Clone() const override;
153 
154  virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
155 
156  BITMAP_DEF GetMenuImage() const override;
157 
158  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
159 
165 };
166 
171 {
172 public:
173  SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
174 
176 
177  wxString GetClass() const override
178  {
179  return wxT( "SCH_BUS_BUS_ENTRY" );
180  }
181 
182  int GetPenSize() const override;
183 
184  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
185 
186  bool CanConnect( const SCH_ITEM* aItem ) const override
187  {
188  return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
189  }
190 
191  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
192 
193  EDA_ITEM* Clone() const override;
194 
195  BITMAP_DEF GetMenuImage() const override;
196 
197  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
198 
204 };
205 
206 #endif // _SCH_BUS_ENTRY_H_
Class for a bus to bus entry.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList) 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:92
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
bool doIsConnected(const wxPoint &aPosition) const override
Function doIsConnected provides the object specific test to see if it is connected to aPosition.
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:82
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 UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
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.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset) override
Function Draw Draw a schematic item.
wxPoint m_pos
Definition: sch_bus_entry.h:44
bool CanConnect(const SCH_ITEM *aItem) const override
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
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='\\')
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
Virtual function IsMovableFromAnchorPoint Return true for items which are moved with the anchor point...
Definition: sch_bus_entry.h:64
bool m_isDanglingStart
Definition: sch_bus_entry.h:46
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
function GetBusEntryShape
void SetBusEntryShape(char aShape)
function SetBusEntryShape
wxPoint m_End() const
int GetPenSize() const override
Function GetPenSize virtual pure.
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:193
Base plotter engine class.
Definition: plotter.h:97
wxSize GetSize() const
Definition: sch_bus_entry.h:80
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.
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Class 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.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Class for a wire to bus entry.
~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.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
EDA_UNITS_T
Definition: common.h:157
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
wxPoint GetPosition() const override
Function GetPosition.