KiCad PCB EDA Suite
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 (C) 1992-2022 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_JUNCTION_H
26#define SCH_JUNCTION_H
27
28
29#include <sch_item.h>
30#include <gal/color4d.h>
32
33class NETLIST_OBJECT_LIST;
34
35class SCH_JUNCTION : public SCH_ITEM
36{
37public:
38 SCH_JUNCTION( const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), int aDiameter = 0,
40
41 // Do not create a copy constructor. The one generated by the compiler is adequate.
42
44
45 static inline bool ClassOf( const EDA_ITEM* aItem )
46 {
47 return aItem && SCH_JUNCTION_T == aItem->Type();
48 }
49
50 wxString GetClass() const override
51 {
52 return wxT( "SCH_JUNCTION" );
53 }
54
55 void SwapData( SCH_ITEM* aItem ) override;
56
57 void SetLastResolvedState( const SCH_ITEM* aItem ) override
58 {
59 const SCH_JUNCTION* aJunction = dynamic_cast<const SCH_JUNCTION*>( aItem );
60
61 if( aJunction )
62 {
65 }
66 }
67
68 void ViewGetLayers( int aLayers[], int& aCount ) const override;
69
70 const BOX2I GetBoundingBox() const override;
71
72 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
73
74 void Move( const VECTOR2I& aMoveVector ) override
75 {
76 m_pos += aMoveVector;
77 }
78
79 void MirrorHorizontally( int aCenter ) override;
80 void MirrorVertically( int aCenter ) override;
81 void Rotate( const VECTOR2I& aCenter ) override;
82
83 void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
84
85 bool IsConnectable() const override { return true; }
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 }
94
95 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override
96 {
97 return wxString( _( "Junction" ) );
98 }
99
100 BITMAPS GetMenuImage() const override;
101
102 VECTOR2I GetPosition() const override { return m_pos; }
103 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
104
105 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override { return false; }
106
107 int GetEffectiveDiameter() const;
108
109 int GetDiameter() const { return m_diameter; }
110 void SetDiameter( int aDiameter );
111
113
114 COLOR4D GetColor() const { return m_color; }
115 void SetColor( const COLOR4D& aColor );
116
117 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
118 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
119
120 void Plot( PLOTTER* aPlotter, bool aBackground ) const override;
121
122 EDA_ITEM* Clone() const override;
123
124 virtual bool operator <( const SCH_ITEM& aItem ) const override;
125
126#if defined(DEBUG)
127 void Show( int nestLevel, std::ostream& os ) const override;
128#endif
129
130private:
131 bool doIsConnected( const VECTOR2I& aPosition ) const override;
132
134
135private:
139
140 // If real-time connectivity gets disabled (due to being too slow on a particular design),
141 // we can no longer rely on getting the NetClass to find netclass-specific linestyles,
142 // linewidths and colors.
145};
146
147
148#endif // SCH_JUNCTION_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual bool IsConnectable() const
Definition: sch_item.h:340
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
VECTOR2I m_pos
Definition: sch_junction.h:136
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_junction.h:95
virtual bool operator<(const SCH_ITEM &aItem) const override
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_junction.h:74
int GetEffectiveDiameter() const
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_junction.h:89
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
SHAPE_CIRCLE getEffectiveShape() const
SCH_JUNCTION(const VECTOR2I &aPosition=VECTOR2I(0, 0), int aDiameter=0, SCH_LAYER_ID aLayer=LAYER_JUNCTION)
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
COLOR4D m_lastResolvedColor
Definition: sch_junction.h:144
int m_diameter
Zero is user default.
Definition: sch_junction.h:137
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.
Definition: sch_junction.h:138
bool IsConnectable() const override
Definition: sch_junction.h:85
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
COLOR4D GetColor() const
Definition: sch_junction.h:114
int GetDiameter() const
Definition: sch_junction.h:109
COLOR4D GetJunctionColor() const
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
Definition: sch_junction.h:105
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
Definition: sch_junction.h:57
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_junction.h:45
VECTOR2I GetPosition() const override
Definition: sch_junction.h:102
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_junction.h:103
void SetColor(const COLOR4D &aColor)
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
int m_lastResolvedDiameter
Definition: sch_junction.h:143
wxString GetClass() const override
Return the class name.
Definition: sch_junction.h:50
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.
#define _(s)
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:341
@ LAYER_JUNCTION
Definition: layer_ids.h:346
@ SCH_LINE_T
Definition: typeinfo.h:145
@ SCH_SYMBOL_T
Definition: typeinfo.h:155
@ SCH_JUNCTION_T
Definition: typeinfo.h:141
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618