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, [email protected]
5  * Copyright (C) 2004-2021 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 public:
45  SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
46 
47  bool IsDanglingStart() const { return m_isDanglingStart; }
48  bool IsDanglingEnd() const { return m_isDanglingEnd; }
49 
50  // Do not create a copy constructor. The one generated by the compiler is adequate.
51 
53 
54  void SetLastResolvedState( const SCH_ITEM* aItem ) override
55  {
56  const SCH_BUS_ENTRY_BASE* aEntry = dynamic_cast<const SCH_BUS_ENTRY_BASE*>( aItem );
57 
58  if( aEntry )
59  {
63  }
64  }
65 
71  bool IsMovableFromAnchorPoint() const override { return false; }
72 
73  wxPoint GetEnd() const;
74 
75  wxSize GetSize() const { return m_size; }
76  void SetSize( const wxSize& aSize ) { m_size = aSize; }
77 
78  void SetPenWidth( int aWidth ) { m_stroke.SetWidth( aWidth ); }
79 
80  virtual bool HasLineStroke() const override { return true; }
81  virtual STROKE_PARAMS GetStroke() const override { return m_stroke; }
82  virtual void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; }
83 
85  void SetStrokeStyle( PLOT_DASH_TYPE aStyle ) { m_stroke.SetPlotStyle( aStyle ); }
86 
87  COLOR4D GetStrokeColor() const;
88  void SetStrokeColor( const COLOR4D& aColor ) { m_stroke.SetColor( aColor ); }
89 
90  void SwapData( SCH_ITEM* aItem ) override;
91 
92  void ViewGetLayers( int aLayers[], int& aCount ) const override;
93 
94  void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
95 
96  const EDA_RECT GetBoundingBox() const override;
97 
98  void Move( const wxPoint& aMoveVector ) override
99  {
100  m_pos += aMoveVector;
101  }
102 
103  void MirrorHorizontally( int aCenter ) override;
104  void MirrorVertically( int aCenter ) override;
105  void Rotate( const wxPoint& aCenter ) override;
106 
107  bool IsDangling() const override;
108 
109  bool IsConnectable() const override { return true; }
110 
111  std::vector<wxPoint> GetConnectionPoints() const override;
112 
113  wxPoint GetPosition() const override { return m_pos; }
114  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
115 
116  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
117  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
118 
119  void Plot( PLOTTER* aPlotter ) const override;
120 
121  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
122 
123  bool operator <( const SCH_ITEM& aItem ) const override;
124 
125 #if defined(DEBUG)
126  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
127 #endif
128 
129 private:
130  bool doIsConnected( const wxPoint& aPosition ) const override;
131 
132 protected:
133  wxPoint m_pos;
134  wxSize m_size;
138 
139  // If real-time connectivity gets disabled (due to being too slow on a particular
140  // design), we can no longer rely on getting the NetClass to find netclass-specific
141  // linestyles, linewidths and colors.
143  mutable int m_lastResolvedWidth;
145 };
146 
151 {
152 public:
153  SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
154 
155  SCH_BUS_WIRE_ENTRY( const wxPoint& pos, int aQuadrant );
156 
158 
159  static inline bool ClassOf( const EDA_ITEM* aItem )
160  {
161  return aItem && SCH_BUS_WIRE_ENTRY_T == aItem->Type();
162  }
163 
164  wxString GetClass() const override
165  {
166  return wxT( "SCH_BUS_WIRE_ENTRY" );
167  }
168 
169  int GetPenWidth() const override;
170 
171  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
172 
173  bool CanConnect( const SCH_ITEM* aItem ) const override
174  {
175  return aItem->Type() == SCH_LINE_T &&
176  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
177  }
178 
179  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
180 
181  EDA_ITEM* Clone() const override;
182 
183  virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
184 
185  BITMAPS GetMenuImage() const override;
186 
187  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
188  const SCH_SHEET_PATH* aPath = nullptr ) override;
189 
195 };
196 
201 {
202 public:
203  SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
204 
206 
207  static inline bool ClassOf( const EDA_ITEM* aItem )
208  {
209  return aItem && SCH_BUS_BUS_ENTRY_T == aItem->Type();
210  }
211 
212  wxString GetClass() const override
213  {
214  return wxT( "SCH_BUS_BUS_ENTRY" );
215  }
216 
217  int GetPenWidth() const override;
218 
219  void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
220 
221  bool CanConnect( const SCH_ITEM* aItem ) const override
222  {
223  return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
224  }
225 
226  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
227 
228  EDA_ITEM* Clone() const override;
229 
230  BITMAPS GetMenuImage() const override;
231 
232  bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
233  const SCH_SHEET_PATH* aPath = nullptr ) override;
234 
240 };
241 
242 #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:153
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition: sch_bus_entry.h:54
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bus_entry.h:98
bool doIsConnected(const wxPoint &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
virtual bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition: sch_bus_entry.h:80
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetSize(const wxSize &aSize)
Definition: sch_bus_entry.h:76
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 ...
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
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:78
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:81
~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 Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return 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)
wxString GetClass() const override
Return the class name.
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
Definition: sch_item.h:156
wxPoint m_pos
bool CanConnect(const SCH_ITEM *aItem) const override
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
wxSize m_size
The base class for create windows for drawing purpose.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
COLOR4D m_lastResolvedColor
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:48
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:42
virtual bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
PLOT_DASH_TYPE GetStrokeStyle() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool IsMovableFromAnchorPoint() const 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:71
void SetStrokeColor(const COLOR4D &aColor)
Definition: sch_bus_entry.h:88
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_bus_entry.h:82
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool IsDangling() const override
bool IsDanglingStart() const
Definition: sch_bus_entry.h:47
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
wxString GetClass() const override
Return the class name.
void Plot(PLOTTER *aPlotter) const override
Plot the schematic item to aPlotter.
void SetStrokeStyle(PLOT_DASH_TYPE aStyle)
Definition: sch_bus_entry.h:85
PLOT_DASH_TYPE m_lastResolvedLineStyle
bool m_isDanglingStart
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
const EDA_RECT GetBoundingBox() const override
Return 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:259
EDA_UNITS
Definition: eda_units.h:38
Base plotter engine class.
Definition: plotter.h:121
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
wxSize GetSize() const
Definition: sch_bus_entry.h:75
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
int GetPenWidth() const override
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Simple container to manage line stroke parameters.
Definition: sch_item.h:140
Handle the component boundary box.
Definition: eda_rect.h:42
bool m_isDanglingEnd
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
Class for a wire to bus entry.
int m_lastResolvedWidth
void SetColor(const COLOR4D &aColor)
Definition: sch_item.h:159
COLOR4D GetStrokeColor() const
bool operator<(const SCH_ITEM &aItem) const override
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
~SCH_BUS_ENTRY_BASE()
Definition: sch_bus_entry.h:52
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
~SCH_BUS_WIRE_ENTRY()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
int GetPenWidth() const override
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
wxPoint GetEnd() const
static bool ClassOf(const EDA_ITEM *aItem)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
wxPoint GetPosition() const override