KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_junction.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) 2009 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SCH_JUNCTION_H
22#define SCH_JUNCTION_H
23
24
25#include <sch_item.h>
26#include <gal/color4d.h>
28
29class NETLIST_OBJECT_LIST;
30
31class SCH_JUNCTION : public SCH_ITEM
32{
33public:
34 SCH_JUNCTION( const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), int aDiameter = 0,
36
37 // Do not create a copy constructor. The one generated by the compiler is adequate.
38
40
41 void Serialize( google::protobuf::Any& aContainer ) const override;
42 bool Deserialize( const google::protobuf::Any& aContainer ) override;
43
44 static inline bool ClassOf( const EDA_ITEM* aItem )
45 {
46 return aItem && SCH_JUNCTION_T == aItem->Type();
47 }
48
49 wxString GetClass() const override
50 {
51 return wxT( "SCH_JUNCTION" );
52 }
53
54 void swapData( SCH_ITEM* aItem ) override;
55
56 void SetLastResolvedState( const SCH_ITEM* aItem ) override
57 {
58 const SCH_JUNCTION* aJunction = dynamic_cast<const SCH_JUNCTION*>( aItem );
59
60 if( aJunction )
61 {
64 }
65 }
66
67 std::vector<int> ViewGetLayers() const override;
68
69 const BOX2I GetBoundingBox() const override;
70
71 void Move( const VECTOR2I& aMoveVector ) override
72 {
73 m_pos += aMoveVector;
74 }
75
76 void MirrorHorizontally( int aCenter ) override;
77 void MirrorVertically( int aCenter ) override;
78 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
79
80 void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
81
82 bool IsConnectable() const override { return true; }
83
84 bool HasConnectivityChanges( const SCH_ITEM* aItem,
85 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
86
87 std::vector<VECTOR2I> GetConnectionPoints() const override;
88
89 bool CanConnect( const SCH_ITEM* aItem ) const override
90 {
91 return aItem->IsConnectable() && ( aItem->Type() == SCH_LINE_T
92 || aItem->Type() == SCH_SYMBOL_T
93 || aItem->Type() == SCH_LABEL_T
94 || aItem->Type() == SCH_GLOBAL_LABEL_T
95 || aItem->Type() == SCH_HIER_LABEL_T
96 || aItem->Type() == SCH_DIRECTIVE_LABEL_T );
97 }
98
99 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override
100 {
101 return wxString( _( "Junction" ) );
102 }
103
104 BITMAPS GetMenuImage() const override;
105
106 VECTOR2I GetPosition() const override { return m_pos; }
107 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
108
109 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override { return false; }
110
111 int GetEffectiveDiameter() const;
112
113 int GetDiameter() const { return m_diameter; }
114 void SetDiameter( int aDiameter );
115
117
118 COLOR4D GetColor() const { return m_color; }
119 void SetColor( const COLOR4D& aColor );
120
121 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
122 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
123 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
124
125 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
126 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
127
128 EDA_ITEM* Clone() const override;
129
130 virtual bool operator <( const SCH_ITEM& aItem ) const override;
131
132 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
133
134 double Similarity( const SCH_ITEM& aOther ) const override;
135
136 bool operator==( const SCH_ITEM& aOther ) const override;
137
138#if defined(DEBUG)
139 void Show( int nestLevel, std::ostream& os ) const override;
140#endif
141
142private:
143 bool doIsConnected( const VECTOR2I& aPosition ) const override;
144
146
147private:
151
152 // If real-time connectivity gets disabled (due to being too slow on a particular design),
153 // we can no longer rely on getting the NetClass to find netclass-specific linestyles,
154 // linewidths and colors.
157};
158
159
160#endif // SCH_JUNCTION_H
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
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:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Base plotter engine class.
Definition plotter.h:133
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
virtual bool IsConnectable() const
Definition sch_item.h:524
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
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 m_pos
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
virtual bool operator<(const SCH_ITEM &aItem) const override
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
int GetEffectiveDiameter() const
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
bool CanConnect(const SCH_ITEM *aItem) const override
SHAPE_CIRCLE getEffectiveShape() const
SCH_JUNCTION(const VECTOR2I &aPosition=VECTOR2I(0, 0), int aDiameter=0, SCH_LAYER_ID aLayer=LAYER_JUNCTION)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
COLOR4D m_lastResolvedColor
int m_diameter
Zero is user default.
bool operator==(const SCH_ITEM &aOther) const override
void SetDiameter(int aDiameter)
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
COLOR4D m_color
COLOR4D::UNSPECIFIED is user default.
bool IsConnectable() const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
COLOR4D GetColor() const
int GetDiameter() const
COLOR4D GetJunctionColor() const
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
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 doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void SetLastResolvedState(const SCH_ITEM *aItem) override
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
static bool ClassOf(const EDA_ITEM *aItem)
VECTOR2I GetPosition() const override
void SetPosition(const VECTOR2I &aPosition) override
void SetColor(const COLOR4D &aColor)
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
int m_lastResolvedDiameter
wxString GetClass() const override
Return the class name.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
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...
#define _(s)
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:447
@ LAYER_JUNCTION
Definition layer_ids.h:452
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:168
@ SCH_LABEL_T
Definition typeinfo.h:164
@ SCH_HIER_LABEL_T
Definition typeinfo.h:166
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:165
@ SCH_JUNCTION_T
Definition typeinfo.h:156
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683