KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The KiCad Developers, see AUTHORS.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 void Serialize( google::protobuf::Any& aContainer ) const override;
44 bool Deserialize( const google::protobuf::Any& aContainer ) override;
45
46 bool IsStartDangling() const { return m_isStartDangling; }
47 bool IsEndDangling() const { return m_isEndDangling; }
48
49 void SetEndDangling( bool aDanglingState ) { m_isEndDangling = aDanglingState; }
50
51 // Do not create a copy constructor. The one generated by the compiler is adequate.
52
54
55 void SetLastResolvedState( const SCH_ITEM* aItem ) override
56 {
57 const SCH_BUS_ENTRY_BASE* aEntry = dynamic_cast<const SCH_BUS_ENTRY_BASE*>( aItem );
58
59 if( aEntry )
60 {
64 }
65 }
66
72 bool IsMovableFromAnchorPoint() const override { return false; }
73
74 VECTOR2I GetEnd() const;
75
76 VECTOR2I GetSize() const { return m_size; }
77 void SetSize( const VECTOR2I& aSize ) { m_size = aSize; }
78
79 // Base class getter unused; necessary for property to compile
80 int GetPenWidth() const override;
81 void SetPenWidth( int aWidth );
82
83 virtual bool HasLineStroke() const override { return true; }
84 virtual STROKE_PARAMS GetStroke() const override { return m_stroke; }
85 virtual void SetStroke( const STROKE_PARAMS& aStroke ) override { m_stroke = aStroke; }
86
87 void SetLineStyle( LINE_STYLE aStyle );
89
90 // Special Getter/Setters for properties panel. Required because it uses WIRE_STYLE instead
91 // of LINE_STYLE. (The two enums are identical, but we expose "default" in the WIRE_STYLE
92 // property while we don't with the LINE_STYLE property.)
93 void SetWireStyle( WIRE_STYLE aStyle ) { SetLineStyle( (LINE_STYLE) aStyle ); }
95
97 void SetBusEntryColor( const COLOR4D& aColor );
98
99 void swapData( SCH_ITEM* aItem ) override;
100
101 std::vector<int> ViewGetLayers() const override;
102
103 const BOX2I GetBoundingBox() const override;
104
105 void Move( const VECTOR2I& aMoveVector ) override
106 {
107 m_pos += aMoveVector;
108 }
109
110 void MirrorHorizontally( int aCenter ) override;
111 void MirrorVertically( int aCenter ) override;
112 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
113
114 bool IsDangling() const override;
115
116 bool IsConnectable() const override { return true; }
117
118 bool HasConnectivityChanges( const SCH_ITEM* aItem,
119 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
120
121 std::vector<VECTOR2I> GetConnectionPoints() const override;
122
123 VECTOR2I GetPosition() const override { return m_pos; }
124 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
125
126 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
127 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override
128 {
129 return ( GetPosition() == aPos && IsStartDangling() )
130 || ( GetEnd() == aPos && IsEndDangling() );
131 }
132
133 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
134 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
135
136 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
137 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
138
139 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
140
141 bool operator <( const SCH_ITEM& aItem ) const override;
142
143 double Similarity( const SCH_ITEM& aItem ) const override;
144
145 bool operator==( const SCH_ITEM& aItem ) const override;
146
147#if defined(DEBUG)
148 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
149#endif
150
151private:
152 bool doIsConnected( const VECTOR2I& aPosition ) const override;
153
154protected:
160
161 // If real-time connectivity gets disabled (due to being too slow on a particular
162 // design), we can no longer rely on getting the NetClass to find netclass-specific
163 // linestyles, linewidths and colors.
167};
168
173{
174public:
175 SCH_BUS_WIRE_ENTRY( const VECTOR2I& pos = VECTOR2I( 0, 0 ), bool aFlipY = false );
176
177 SCH_BUS_WIRE_ENTRY( const VECTOR2I& pos, int aQuadrant );
178
180
181 static inline bool ClassOf( const EDA_ITEM* aItem )
182 {
183 return aItem && SCH_BUS_WIRE_ENTRY_T == aItem->Type();
184 }
185
186 wxString GetClass() const override
187 {
188 return wxT( "SCH_BUS_WIRE_ENTRY" );
189 }
190
191 int GetPenWidth() const override;
192
193 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
194
195 bool CanConnect( const SCH_ITEM* aItem ) const override
196 {
197 return aItem->Type() == SCH_LINE_T &&
198 ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS );
199 }
200
201 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
202
203 EDA_ITEM* Clone() const override;
204
205 virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const override;
206
207 BITMAPS GetMenuImage() const override;
208
209 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
210 std::vector<DANGLING_END_ITEM>& aItemListByPos,
211 const SCH_SHEET_PATH* aPath = nullptr ) override;
212
218};
219
224{
225public:
226 SCH_BUS_BUS_ENTRY( const VECTOR2I& pos = VECTOR2I( 0, 0 ), bool aFlipY = false );
227
229
230 static inline bool ClassOf( const EDA_ITEM* aItem )
231 {
232 return aItem && SCH_BUS_BUS_ENTRY_T == aItem->Type();
233 }
234
235 wxString GetClass() const override
236 {
237 return wxT( "SCH_BUS_BUS_ENTRY" );
238 }
239
240 int GetPenWidth() const override;
241
242 void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;
243
244 bool CanConnect( const SCH_ITEM* aItem ) const override
245 {
246 return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS;
247 }
248
249 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
250
251 EDA_ITEM* Clone() const override;
252
253 BITMAPS GetMenuImage() const override;
254
255 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
256 std::vector<DANGLING_END_ITEM>& aItemListByPos,
257 const SCH_SHEET_PATH* aPath = nullptr ) override;
258
264};
265
266#endif // _SCH_BUS_ENTRY_H_
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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:100
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
Base plotter engine class.
Definition plotter.h:136
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
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
~SCH_BUS_BUS_ENTRY()
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
wxString GetClass() const override
Return the class name.
SCH_BUS_BUS_ENTRY(const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
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...
VECTOR2I GetSize() const
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
void SetLastResolvedState(const SCH_ITEM *aItem) override
VECTOR2I m_pos
virtual bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
LINE_STYLE m_lastResolvedLineStyle
COLOR4D GetBusEntryColor() const
void SetSize(const VECTOR2I &aSize)
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
void SetBusEntryColor(const COLOR4D &aColor)
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
bool IsStartDangling() const
VECTOR2I GetPosition() const override
bool m_isEndDangling
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool IsEndDangling() const
virtual STROKE_PARAMS GetStroke() const override
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...
void SetWireStyle(WIRE_STYLE aStyle)
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
~SCH_BUS_ENTRY_BASE()
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
bool operator==(const SCH_ITEM &aItem) const override
int m_lastResolvedWidth
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
void SetLineStyle(LINE_STYLE aStyle)
bool IsConnectable() const override
void SetEndDangling(bool aDanglingState)
int GetPenWidth() const override
WIRE_STYLE GetWireStyle() const
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
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.
VECTOR2I m_size
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
SCH_BUS_ENTRY_BASE(KICAD_T aType, const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
LINE_STYLE GetEffectiveLineStyle() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool m_isStartDangling
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.
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 GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
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.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetPenWidth() const override
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
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:168
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:344
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Simple container to manage line stroke parameters.
LINE_STYLE GetLineStyle() const
@ LAYER_WIRE
Definition layer_ids.h:454
@ LAYER_BUS
Definition layer_ids.h:455
LINE_STYLE
Dashed line types.
WIRE_STYLE
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:75
@ SCH_LINE_T
Definition typeinfo.h:164
@ SCH_BUS_BUS_ENTRY_T
Definition typeinfo.h:163
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:162
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687