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-2011 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 
44 {
45 protected:
47  wxSize m_size;
49 
50 public:
51  SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
52 
53  // Do not create a copy constructor. The one generated by the compiler is adequate.
54 
56 
63  bool IsMovableFromAnchorPoint() override { return false; }
64 
65  wxPoint m_End() const;
66 
71  char GetBusEntryShape() const;
72 
77  void SetBusEntryShape( char aShape );
78 
79  wxSize GetSize() const { return m_size; }
80 
81  void SetSize( const wxSize& aSize ) { m_size = aSize; }
82 
83  void SwapData( SCH_ITEM* aItem ) override;
84 
85  void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
86  GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
87 
88  static bool Load( LINE_READER& aLine, wxString& aErrorMsg, SCH_ITEM **out );
89 
90  const EDA_RECT GetBoundingBox() const override;
91 
92  void Move( const wxPoint& aMoveVector ) override
93  {
94  m_pos += aMoveVector;
95  }
96 
97 
98  void MirrorY( int aYaxis_position ) override;
99 
100  void MirrorX( int aXaxis_position ) override;
101 
102  void Rotate( wxPoint aPosition ) override;
103 
104  void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
105 
106  bool IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList ) override;
107 
108  bool IsDangling() const override;
109 
110  bool IsSelectStateChanged( const wxRect& aRect ) override;
111 
112  bool IsConnectable() const override { return true; }
113 
114  void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
115 
116  BITMAP_DEF GetMenuImage() const override;
117 
118  wxPoint GetPosition() const override { return m_pos; }
119 
120  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
121 
122  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
123 
124  bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
125 
126  void Plot( PLOTTER* aPlotter ) override;
127 
128 #if defined(DEBUG)
129  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
130 #endif
131 };
132 
139 {
140 public:
141  SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
142 
144 
145  wxString GetClass() const override
146  {
147  return wxT( "SCH_BUS_WIRE_ENTRY" );
148  }
149 
150  bool Save( FILE* aFile ) const override;
151 
152  int GetPenSize() const override;
153 
154  wxString GetSelectMenuText() const override;
155 
156  EDA_ITEM* Clone() const override;
157 };
158 
165 {
166 public:
167  SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
168 
170 
171  wxString GetClass() const override
172  {
173  return wxT( "SCH_BUS_BUS_ENTRY" );
174  }
175 
176  bool Save( FILE* aFile ) const override;
177 
178  int GetPenSize() const override;
179 
180  wxString GetSelectMenuText() const override;
181 
182  EDA_ITEM* Clone() const override;
183 };
184 
185 #endif // _SCH_BUS_ENTRY_H_
Class SCH_BUS_WIRE_ENTRY.
wxSize GetSize() const
Definition: sch_bus_entry.h:79
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_bus_entry.h:92
PNG memory record (file in memory).
Definition: bitmap_types.h:38
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:81
Base schematic object class definition.
~SCH_BUS_BUS_ENTRY()
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item...
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 SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
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:46
wxPoint m_End() const
wxSize m_size
Definition: sch_bus_entry.h:47
char GetBusEntryShape() const
function GetBusEntryShape
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
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:90
SCH_BUS_BUS_ENTRY(const wxPoint &pos=wxPoint(0, 0), char shape= '\\')
Class SCH_BUS_ENTRY_BASE.
Definition: sch_bus_entry.h:43
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
SCH_BUS_WIRE_ENTRY(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
wxString GetClass() const override
Function GetClass returns the class name.
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
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:63
bool m_isDanglingStart
Definition: sch_bus_entry.h:48
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void SetBusEntryShape(char aShape)
function SetBusEntryShape
int GetPenSize() const override
Function GetPenSize virtual pure.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
static bool Load(LINE_READER &aLine, wxString &aErrorMsg, SCH_ITEM **out)
Base plotter engine class.
Definition: plot_common.h:86
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.
bool m_isDanglingEnd
Definition: sch_bus_entry.h:48
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:151
SCH_BUS_ENTRY_BASE(KICAD_T aType, const wxPoint &pos=wxPoint(0, 0), char shape= '\\')
Class SCH_BUS_WIRE_ENTRY.
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
~SCH_BUS_ENTRY_BASE()
Definition: sch_bus_entry.h:55
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...
bool IsDanglingStateChanged(std::vector< DANGLING_END_ITEM > &aItemList) override
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it's dangling state...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetPosition() const override
Function GetPosition.