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-2020 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 <gal/color4d.h>
34 #include <sch_item.h>
35 
36 #define TARGET_BUSENTRY_RADIUS Mils2iu( 12 ) // Circle diameter drawn at the ends
37 
38 
43 {
44 protected:
45  wxPoint m_pos;
46  wxSize m_size;
50 
51 public:
52  SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
53 
54  bool IsDanglingStart() const { return m_isDanglingStart; }
55  bool IsDanglingEnd() const { return m_isDanglingEnd; }
56 
57  // Do not create a copy constructor. The one generated by the compiler is adequate.
58 
60 
66  bool IsMovableFromAnchorPoint() override { return false; }
67 
68  wxPoint GetEnd() const;
69 
70  wxSize GetSize() const { return m_size; }
71 
72  void SetSize( const wxSize& aSize ) { m_size = aSize; }
73 
74  void SetPenWidth( int aWidth ) { m_stroke.SetWidth( aWidth ); }
75 
76  virtual bool HasLineStroke() const override { return true; }
77  virtual STROKE_PARAMS GetStroke() const override { return m_stroke; }
78  virtual void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; }
79 
81  void SetStrokeStyle( PLOT_DASH_TYPE aStyle ) { m_stroke.SetPlotStyle( aStyle ); }
82 
83  COLOR4D GetStrokeColor() const;
84  void SetStrokeColor( const COLOR4D& aColor ) { m_stroke.SetColor( aColor ); }
85 
86  void SwapData( SCH_ITEM* aItem ) override;
87 
88  void ViewGetLayers( int aLayers[], int& aCount ) const override;
89 
90  void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
91 
92  const EDA_RECT GetBoundingBox() const override;
93 
94  void Move( const wxPoint& aMoveVector ) override
95  {
96  m_pos += aMoveVector;
97  }
98 
99  void MirrorY( int aYaxis_position ) override;
100  void MirrorX( int aXaxis_position ) override;
101  void Rotate( wxPoint aPosition ) override;
102 
103  bool IsDangling() const override;
104 
105  bool IsConnectable() const override { return true; }
106 
107  std::vector<wxPoint> GetConnectionPoints() const override;
108 
109  wxPoint GetPosition() const override { return m_pos; }
110  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
111 
112  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
113  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
114 
115  void Plot( PLOTTER* aPlotter ) override;
116 
117  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
118 
119  bool operator <( const SCH_ITEM& aItem ) const override;
120 
121 #if defined(DEBUG)
122  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
123 #endif
124 
125 private:
126  bool doIsConnected( const wxPoint& aPosition ) const override;
127 };
128 
133 {
134 public:
135  SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
136 
138 
139  static inline bool ClassOf( const EDA_ITEM* aItem )
140  {
141  return aItem && SCH_BUS_WIRE_ENTRY_T == aItem->Type();
142  }
143 
144  wxString GetClass() const override
145  {
146  return wxT( "SCH_BUS_WIRE_ENTRY" );
147  }
148 
149  int GetPenWidth() const override;
150 
151  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
152 
153  bool CanConnect( const SCH_ITEM* aItem ) const override
154  {
155  return aItem->Type() == SCH_LINE_T &&
156  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
157  }
158 
159  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
160 
161  EDA_ITEM* Clone() const override;
162 
163  virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
164 
165  BITMAP_DEF GetMenuImage() const override;
166 
167  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
168  const SCH_SHEET_PATH* aPath = nullptr ) override;
169 
175 };
176 
181 {
182 public:
183  SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
184 
186 
187  static inline bool ClassOf( const EDA_ITEM* aItem )
188  {
189  return aItem && SCH_BUS_BUS_ENTRY_T == aItem->Type();
190  }
191 
192  wxString GetClass() const override
193  {
194  return wxT( "SCH_BUS_BUS_ENTRY" );
195  }
196 
197  int GetPenWidth() const override;
198 
199  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
200 
201  bool CanConnect( const SCH_ITEM* aItem ) const override
202  {
203  return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
204  }
205 
206  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
207 
208  EDA_ITEM* Clone() const override;
209 
210  BITMAP_DEF GetMenuImage() const override;
211 
212  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
213  const SCH_SHEET_PATH* aPath = nullptr ) override;
214 
220 };
221 
222 #endif // _SCH_BUS_ENTRY_H_
Class for a bus to bus entry.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
void SetWidth(int aWidth)
Definition: sch_item.h:170
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bus_entry.h:94
bool doIsConnected(const wxPoint &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
PNG memory record (file in memory).
Definition: bitmap_def.h:29
virtual bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition: sch_bus_entry.h:76
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
void SetSize(const wxSize &aSize)
Definition: sch_bus_entry.h:72
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
void SetPenWidth(int aWidth)
Definition: sch_bus_entry.h:74
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:77
~SCH_BUS_BUS_ENTRY()
SCH_BUS_BUS_ENTRY(const wxPoint &pos=wxPoint(0, 0), bool aFlipY=false)
bool IsConnectable() const override
SCH_BUS_ENTRY_BASE(KICAD_T aType, const wxPoint &pos=wxPoint(0, 0), bool aFlipY=false)
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
SCH_BUS_WIRE_ENTRY(const wxPoint &pos=wxPoint(0, 0), bool aFlipY=false)
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
wxString GetClass() const override
Function GetClass returns the class name.
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
Definition: sch_item.h:173
wxPoint m_pos
Definition: sch_bus_entry.h:45
bool CanConnect(const SCH_ITEM *aItem) const override
wxSize m_size
Definition: sch_bus_entry.h:46
The base class for create windows for drawing purpose.
void SwapData(SCH_ITEM *aItem) override
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:55
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:42
virtual bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Returns true if this item should propagate connection info to aItem.
PLOT_DASH_TYPE GetStrokeStyle() const
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
void SetStrokeColor(const COLOR4D &aColor)
Definition: sch_bus_entry.h:84
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_bus_entry.h:78
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:54
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
wxString GetClass() const override
Function GetClass returns the class name.
void SetStrokeStyle(PLOT_DASH_TYPE aStyle)
Definition: sch_bus_entry.h:81
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:66
bool m_isDanglingStart
Definition: sch_bus_entry.h:47
static bool ClassOf(const EDA_ITEM *aItem)
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
STROKE_PARAMS m_stroke
Definition: sch_bus_entry.h:49
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
PLOT_DASH_TYPE
Dashed line types.
Definition: plotter.h:104
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:285
EDA_UNITS
Definition: eda_units.h:38
Base plotter engine class.
Definition: plotter.h:131
wxSize GetSize() const
Definition: sch_bus_entry.h:70
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
int GetPenWidth() const override
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Simple container to manage line stroke parameters.
Definition: sch_item.h:153
void MirrorX(int aXaxis_position) override
Mirror 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:48
void Plot(PLOTTER *aPlotter) override
Plot the schematic item to aPlotter.
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
Class for a wire to bus entry.
void SetColor(const COLOR4D &aColor)
Definition: sch_item.h:176
COLOR4D GetStrokeColor() const
bool operator<(const SCH_ITEM &aItem) const override
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
~SCH_BUS_ENTRY_BASE()
Definition: sch_bus_entry.h:59
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
Mirror item relative to the Y axis about aYaxis_position.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
int GetPenWidth() const override
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
wxPoint GetEnd() const
static bool ClassOf(const EDA_ITEM *aItem)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100
wxPoint GetPosition() const override