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  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,
89  GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
90 
91  const EDA_RECT GetBoundingBox() const override;
92 
93  void Move( const wxPoint& aMoveVector ) override
94  {
95  m_pos += aMoveVector;
96  }
97 
98 
99  void MirrorY( int aYaxis_position ) override;
100 
101  void MirrorX( int aXaxis_position ) override;
102 
103  void Rotate( wxPoint aPosition ) override;
104 
105  bool IsDangling() const override;
106 
107  bool IsSelectStateChanged( const wxRect& aRect ) override;
108 
109  bool IsConnectable() const override { return true; }
110 
111  void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
112 
113  wxPoint GetPosition() const override { return m_pos; }
114 
115  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
116 
117  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
118 
119  bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
120 
121  void Plot( PLOTTER* aPlotter ) override;
122 
123 #if defined(DEBUG)
124  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
125 #endif
126 
127 private:
128  bool doIsConnected( const wxPoint& aPosition ) const override;
129 };
130 
135 {
136 public:
137  SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
138 
140 
141  wxString GetClass() const override
142  {
143  return wxT( "SCH_BUS_WIRE_ENTRY" );
144  }
145 
146  int GetPenSize() const override;
147 
148  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
149 
150  bool CanConnect( const SCH_ITEM* aItem ) const override
151  {
152  return aItem->Type() == SCH_LINE_T &&
153  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
154  }
155 
156  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
157 
158  EDA_ITEM* Clone() const override;
159 
160  BITMAP_DEF GetMenuImage() const override;
161 
162  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
163 };
164 
169 {
170 public:
171  SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
172 
174 
175  wxString GetClass() const override
176  {
177  return wxT( "SCH_BUS_BUS_ENTRY" );
178  }
179 
180  int GetPenSize() const override;
181 
182  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
183 
184  bool CanConnect( const SCH_ITEM* aItem ) const override
185  {
186  return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
187  }
188 
189  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
190 
191  EDA_ITEM* Clone() const override;
192 
193  BITMAP_DEF GetMenuImage() const override;
194 
195  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList ) override;
196 };
197 
198 #endif // _SCH_BUS_ENTRY_H_
Class for a bus to bus entry.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
wxSize GetSize() const
Definition: sch_bus_entry.h:80
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:52
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_bus_entry.h:93
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:43
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
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 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.
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
virtual wxString GetSelectMenuText(EDA_UNITS_T aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
wxSize m_size
Definition: sch_bus_entry.h:45
char GetBusEntryShape() const
function GetBusEntryShape
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
virtual bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList)
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it&#39;s dangling state...
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:64
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:97
bool IsDanglingStart() const
Definition: sch_bus_entry.h:51
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:154
SCH_BUS_ENTRY_BASE(KICAD_T aType, const wxPoint &pos=wxPoint(0, 0), char shape= '\\')
Class for a wire to bus entry.
~SCH_BUS_ENTRY_BASE()
Definition: sch_bus_entry.h:56
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...
EDA_UNITS_T
Definition: common.h:159
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.