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, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2021 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>
31 #include <geometry/shape_circle.h>
32 
33 class NETLIST_OBJECT_LIST;
34 
35 class SCH_JUNCTION : public SCH_ITEM
36 {
37 public:
38  SCH_JUNCTION( const wxPoint& aPosition = wxPoint( 0, 0 ), int aDiameter = 0,
39  SCH_LAYER_ID aLayer = LAYER_JUNCTION );
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 ViewGetLayers( int aLayers[], int& aCount ) const override;
58 
59  const EDA_RECT GetBoundingBox() const override;
60 
61  void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
62 
63  void Move( const wxPoint& aMoveVector ) override
64  {
65  m_pos += aMoveVector;
66  }
67 
68  void MirrorHorizontally( int aCenter ) override;
69  void MirrorVertically( int aCenter ) override;
70  void Rotate( const wxPoint& aCenter ) override;
71 
72  void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
73 
74  bool IsConnectable() const override { return true; }
75 
76  std::vector<wxPoint> GetConnectionPoints() const override;
77 
78  bool CanConnect( const SCH_ITEM* aItem ) const override
79  {
80  return ( aItem->Type() == SCH_LINE_T &&
81  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ) ) ||
82  aItem->Type() == SCH_SYMBOL_T;
83  }
84 
85  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
86  {
87  return wxString( _( "Junction" ) );
88  }
89 
90  BITMAPS GetMenuImage() const override;
91 
92  wxPoint GetPosition() const override { return m_pos; }
93  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
94 
95  bool IsPointClickableAnchor( const wxPoint& aPos ) const override { return false; }
96 
97  int GetEffectiveDiameter() const;
98 
99  int GetDiameter() const { return m_diameter; }
100  void SetDiameter( int aDiameter ) { m_diameter = aDiameter; }
101 
102  COLOR4D GetJunctionColor() const;
103 
104  COLOR4D GetColor() const { return m_color; }
105  void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
106 
107  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
108  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
109 
110  void Plot( PLOTTER* aPlotter ) const override;
111 
112  EDA_ITEM* Clone() const override;
113 
114  virtual bool operator <( const SCH_ITEM& aItem ) const override;
115 
116 #if defined(DEBUG)
117  void Show( int nestLevel, std::ostream& os ) const override;
118 #endif
119 
120 private:
121  bool doIsConnected( const wxPoint& aPosition ) const override;
122 
124 
125  wxPoint m_pos;
128 };
129 
130 
131 #endif // _SCH_JUNCTION_H_
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_junction.h:63
wxString GetClass() const override
Return the class name.
Definition: sch_junction.h:50
COLOR4D GetJunctionColor() const
bool IsPointClickableAnchor(const wxPoint &aPos) const override
Definition: sch_junction.h:95
COLOR4D m_color
Color of the junction. #COLOR4D::UNSPECIFIED is user default.
Definition: sch_junction.h:127
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDiameter(int aDiameter)
Definition: sch_junction.h:100
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SetColor(const COLOR4D &aColor)
Definition: sch_junction.h:105
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
int GetDiameter() const
Definition: sch_junction.h:99
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
virtual bool operator<(const SCH_ITEM &aItem) const override
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_junction.h:45
bool doIsConnected(const wxPoint &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
SCH_JUNCTION(const wxPoint &aPosition=wxPoint(0, 0), int aDiameter=0, SCH_LAYER_ID aLayer=LAYER_JUNCTION)
COLOR4D GetColor() const
Definition: sch_junction.h:104
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:324
wxPoint GetPosition() const override
Definition: sch_junction.h:92
void SetPosition(const wxPoint &aPosition) override
Definition: sch_junction.h:93
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_junction.h:78
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
void Plot(PLOTTER *aPlotter) const override
Plot the schematic item to aPlotter.
#define _(s)
void MirrorHorizontally(int aCenter) override
Mirror item horizontally 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)
wxPoint m_pos
Position of the junction.
Definition: sch_junction.h:125
bool IsConnectable() const override
Definition: sch_junction.h:74
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:257
EDA_UNITS
Definition: eda_units.h:38
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Base plotter engine class.
Definition: plotter.h:121
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_junction.h:85
int GetEffectiveDiameter() const
Handle the component boundary box.
Definition: eda_rect.h:42
SHAPE_CIRCLE getEffectiveShape() const
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
int m_diameter
Diameter of the junction. Zero is user default.
Definition: sch_junction.h:126
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103