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-2017 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_struct.h>
34 
35 #define TARGET_BUSENTRY_RADIUS 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  // Do not create a copy constructor. The one generated by the compiler is adequate.
52 
54 
61  bool IsMovableFromAnchorPoint() override { return false; }
62 
63  wxPoint m_End() const;
64 
69  char GetBusEntryShape() const;
70 
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 Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
84  GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
85 
86  const EDA_RECT GetBoundingBox() const override;
87 
88  void Move( const wxPoint& aMoveVector ) override
89  {
90  m_pos += aMoveVector;
91  }
92 
93 
94  void MirrorY( int aYaxis_position ) override;
95 
96  void MirrorX( int aXaxis_position ) override;
97 
98  void Rotate( wxPoint aPosition ) override;
99 
100  bool IsDangling() const override;
101 
102  bool IsSelectStateChanged( const wxRect& aRect ) override;
103 
104  bool IsConnectable() const override { return true; }
105 
106  void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
107 
108  wxPoint GetPosition() const override { return m_pos; }
109 
110  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
111 
112  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
113 
114  bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
115 
116  void Plot( PLOTTER* aPlotter ) override;
117 
118 #if defined(DEBUG)
119  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
120 #endif
121 
122 private:
123  bool doIsConnected( const wxPoint& aPosition ) const override;
124 };
125 
130 {
131 public:
132  SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
133 
135 
136  wxString GetClass() const override
137  {
138  return wxT( "SCH_BUS_WIRE_ENTRY" );
139  }
140 
141  int GetPenSize() const override;
142 
143  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
144 
145  bool CanConnect( const SCH_ITEM* aItem ) const override
146  {
147  return aItem->Type() == SCH_LINE_T &&
148  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
149  }
150 
151  wxString GetSelectMenuText() const override;
152 
153  EDA_ITEM* Clone() const override;
154 
155  BITMAP_DEF GetMenuImage() const override;
156 
157  bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) override;
158 };
159 
164 {
165 public:
166  SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
167 
169 
170  wxString GetClass() const override
171  {
172  return wxT( "SCH_BUS_BUS_ENTRY" );
173  }
174 
175  int GetPenSize() const override;
176 
177  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
178 
179  bool CanConnect( const SCH_ITEM* aItem ) const override
180  {
181  return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
182  }
183 
184  wxString GetSelectMenuText() const override;
185 
186  EDA_ITEM* Clone() const override;
187 
188  BITMAP_DEF GetMenuImage() const override;
189 
190  bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) override;
191 };
192 
193 #endif // _SCH_BUS_ENTRY_H_
Class for a bus to bus entry.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
wxSize GetSize() const
Definition: sch_bus_entry.h:77
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_bus_entry.h:88
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_types.h:41
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
Base schematic object class definition.
virtual void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList)
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points...
bool CanConnect(const SCH_ITEM *aItem) const override
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
~SCH_BUS_BUS_ENTRY()
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item...
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.
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
wxPoint m_pos
Definition: sch_bus_entry.h:44
wxPoint m_End() const
bool CanConnect(const SCH_ITEM *aItem) const override
wxSize m_size
Definition: sch_bus_entry.h:45
char GetBusEntryShape() const
function GetBusEntryShape
virtual wxString GetSelectMenuText() const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
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
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
bool IsDangling() const override
wxString GetClass() const override
Function GetClass returns the class name.
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
bool IsMovableFromAnchorPoint() override
Virtual function IsMovableFromAnchorPoint Return true for items which are moved with the anchor point...
Definition: sch_bus_entry.h:61
bool m_isDanglingStart
Definition: sch_bus_entry.h:46
void SetBusEntryShape(char aShape)
function SetBusEntryShape
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Base plotter engine class.
Definition: plotter.h:96
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
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
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:180
SCH_BUS_ENTRY_BASE(KICAD_T aType, const wxPoint &pos=wxPoint(0, 0), char shape= '\\')
virtual bool IsDanglingStateChanged(std::vector< DANGLING_END_ITEM > &aItemList)
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it&#39;s dangling state...
Class for a wire to bus entry.
~SCH_BUS_ENTRY_BASE()
Definition: sch_bus_entry.h:53
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
~SCH_BUS_WIRE_ENTRY()
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...
virtual BITMAP_DEF GetMenuImage() const
Function GetMenuImage returns a pointer to an image to be used in menus.
virtual int GetPenSize() const
Function GetPenSize virtual pure.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetPosition() const override
Function GetPosition.