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
25#ifndef _SCH_BUS_ENTRY_H_
26#define _SCH_BUS_ENTRY_H_
27
28#include <gal/color4d.h>
29#include <sch_item.h>
30
31#define TARGET_BUSENTRY_RADIUS schIUScale.MilsToIU( 12 ) // Circle diameter drawn at the ends
32
33
38{
39public:
40 SCH_BUS_ENTRY_BASE( KICAD_T aType, const VECTOR2I& pos = VECTOR2I( 0, 0 ),
41 bool aFlipY = false );
42
43 bool IsDanglingStart() const { return m_isDanglingStart; }
44 bool IsDanglingEnd() const { return m_isDanglingEnd; }
45
46 // Do not create a copy constructor. The one generated by the compiler is adequate.
47
49
50 void SetLastResolvedState( const SCH_ITEM* aItem ) override
51 {
52 const SCH_BUS_ENTRY_BASE* aEntry = dynamic_cast<const SCH_BUS_ENTRY_BASE*>( aItem );
53
54 if( aEntry )
55 {
59 }
60 }
61
67 bool IsMovableFromAnchorPoint() const override { return false; }
68
69 VECTOR2I GetEnd() const;
70
71 wxSize GetSize() const { return m_size; }
72 void SetSize( const wxSize& aSize ) { m_size = aSize; }
73
74 void SetPenWidth( int 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 SetLineStyle( PLOT_DASH_TYPE aStyle );
82
84 void SetBusEntryColor( const COLOR4D& aColor );
85
86 void SwapData( SCH_ITEM* aItem ) override;
87
88 void ViewGetLayers( int aLayers[], int& aCount ) const override;
89
90 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
91
92 const BOX2I GetBoundingBox() const override;
93
94 void Move( const VECTOR2I& aMoveVector ) override
95 {
96 m_pos += aMoveVector;
97 }
98
99 void MirrorHorizontally( int aCenter ) override;
100 void MirrorVertically( int aCenter ) override;
101 void Rotate( const VECTOR2I& aCenter ) override;
102
103 bool IsDangling() const override;
104
105 bool IsConnectable() const override { return true; }
106
107 std::vector<VECTOR2I> GetConnectionPoints() const override;
108
109 VECTOR2I GetPosition() const override { return m_pos; }
110 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
111
112 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
113 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
114 {
115 return ( GetPosition() == aPos && IsDanglingStart() )
116 || ( GetEnd() == aPos && IsDanglingEnd() );
117 }
118
119 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
120
121 void Plot( PLOTTER* aPlotter, bool aBackground ) const override;
122
123 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
124
125 bool operator <( const SCH_ITEM& aItem ) const override;
126
127#if defined(DEBUG)
128 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
129#endif
130
131private:
132 bool doIsConnected( const VECTOR2I& aPosition ) const override;
133
134protected:
136 wxSize m_size;
140
141 // If real-time connectivity gets disabled (due to being too slow on a particular
142 // design), we can no longer rely on getting the NetClass to find netclass-specific
143 // linestyles, linewidths and colors.
147};
148
153{
154public:
155 SCH_BUS_WIRE_ENTRY( const VECTOR2I& pos = VECTOR2I( 0, 0 ), bool aFlipY = false );
156
157 SCH_BUS_WIRE_ENTRY( const VECTOR2I& pos, int aQuadrant );
158
160
161 static inline bool ClassOf( const EDA_ITEM* aItem )
162 {
163 return aItem && SCH_BUS_WIRE_ENTRY_T == aItem->Type();
164 }
165
166 wxString GetClass() const override
167 {
168 return wxT( "SCH_BUS_WIRE_ENTRY" );
169 }
170
171 int GetPenWidth() const override;
172
173 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
174
175 bool CanConnect( const SCH_ITEM* aItem ) const override
176 {
177 return aItem->Type() == SCH_LINE_T &&
178 ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
179 }
180
181 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
182
183 EDA_ITEM* Clone() const override;
184
185 virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
186
187 BITMAPS GetMenuImage() const override;
188
189 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
190 const SCH_SHEET_PATH* aPath = nullptr ) override;
191
197};
198
203{
204public:
205 SCH_BUS_BUS_ENTRY( const VECTOR2I& pos = VECTOR2I( 0, 0 ), bool aFlipY = false );
206
208
209 static inline bool ClassOf( const EDA_ITEM* aItem )
210 {
211 return aItem && SCH_BUS_BUS_ENTRY_T == aItem->Type();
212 }
213
214 wxString GetClass() const override
215 {
216 return wxT( "SCH_BUS_BUS_ENTRY" );
217 }
218
219 int GetPenWidth() const override;
220
221 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
222
223 bool CanConnect( const SCH_ITEM* aItem ) const override
224 {
225 return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
226 }
227
228 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
229
230 EDA_ITEM* Clone() const override;
231
232 BITMAPS GetMenuImage() const override;
233
234 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
235 const SCH_SHEET_PATH* aPath = nullptr ) override;
236
242};
243
244#endif // _SCH_BUS_ENTRY_H_
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition: plotter.h:110
Class for a bus to bus entry.
int GetPenWidth() const override
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
static bool ClassOf(const EDA_ITEM *aItem)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool CanConnect(const SCH_ITEM *aItem) const override
~SCH_BUS_BUS_ENTRY()
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
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.
wxString GetClass() const override
Return the class name.
SCH_BUS_BUS_ENTRY(const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
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...
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition: sch_bus_entry.h:50
PLOT_DASH_TYPE GetLineStyle() const
VECTOR2I m_pos
virtual bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition: sch_bus_entry.h:76
bool m_isDanglingStart
COLOR4D GetBusEntryColor() const
bool m_isDanglingEnd
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_bus_entry.h:78
void SetBusEntryColor(const COLOR4D &aColor)
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
VECTOR2I GetPosition() const override
bool IsDanglingStart() const
Definition: sch_bus_entry.h:43
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:77
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
void SetPosition(const VECTOR2I &aPosition) override
void SetPenWidth(int aWidth)
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.
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:67
~SCH_BUS_ENTRY_BASE()
Definition: sch_bus_entry.h:48
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:44
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
int m_lastResolvedWidth
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
bool IsConnectable() const override
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
VECTOR2I GetEnd() const
bool IsDangling() const override
COLOR4D m_lastResolvedColor
STROKE_PARAMS m_stroke
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
wxSize GetSize() const
Definition: sch_bus_entry.h:71
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bus_entry.h:94
void SetLineStyle(PLOT_DASH_TYPE aStyle)
wxSize m_size
SCH_BUS_ENTRY_BASE(KICAD_T aType, const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
void SetSize(const wxSize &aSize)
Definition: sch_bus_entry.h:72
PLOT_DASH_TYPE m_lastResolvedLineStyle
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool operator<(const SCH_ITEM &aItem) const override
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Class for a wire to bus entry.
wxString GetClass() const override
Return the class name.
SCH_BUS_WIRE_ENTRY(const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
~SCH_BUS_WIRE_ENTRY()
bool CanConnect(const SCH_ITEM *aItem) const override
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
static bool ClassOf(const EDA_ITEM *aItem)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
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.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetPenWidth() const override
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
virtual bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
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 ...
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:246
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
@ LAYER_WIRE
Definition: layer_ids.h:344
@ LAYER_BUS
Definition: layer_ids.h:345
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LINE_T
Definition: typeinfo.h:145
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:144
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:143
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618