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-2020 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  wxPoint m_pos; // Position of the junction.
38  int m_diameter; // Diameter of the junction. Zero is user default.
39  COLOR4D m_color; // Color of the junction. #COLOR4D::UNSPECIFIED is user default.
40 
41 public:
42  SCH_JUNCTION( const wxPoint& aPosition = wxPoint( 0, 0 ), int aDiameter = 0,
43  SCH_LAYER_ID aLayer = LAYER_JUNCTION );
44 
45  // Do not create a copy constructor. The one generated by the compiler is adequate.
46 
48 
49  static inline bool ClassOf( const EDA_ITEM* aItem )
50  {
51  return aItem && SCH_JUNCTION_T == aItem->Type();
52  }
53 
54  wxString GetClass() const override
55  {
56  return wxT( "SCH_JUNCTION" );
57  }
58 
59  void SwapData( SCH_ITEM* aItem ) override;
60 
61  void ViewGetLayers( int aLayers[], int& aCount ) const override;
62 
63  const EDA_RECT GetBoundingBox() const override;
64 
65  void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
66 
67  void Move( const wxPoint& aMoveVector ) override
68  {
69  m_pos += aMoveVector;
70  }
71 
72  void MirrorY( int aYaxis_position ) override;
73  void MirrorX( int aXaxis_position ) override;
74  void Rotate( wxPoint aPosition ) override;
75 
76  void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
77 
78  bool IsConnectable() const override { return true; }
79 
80  std::vector<wxPoint> GetConnectionPoints() const override;
81 
82  bool CanConnect( const SCH_ITEM* aItem ) const override
83  {
84  return ( aItem->Type() == SCH_LINE_T &&
85  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ) ) ||
86  aItem->Type() == SCH_COMPONENT_T;
87  }
88 
89  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
90  {
91  return wxString( _( "Junction" ) );
92  }
93 
94  BITMAP_DEF GetMenuImage() const override;
95 
96  wxPoint GetPosition() const override { return m_pos; }
97  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
98 
99  bool IsPointClickableAnchor( const wxPoint& aPos ) const override { return false; }
100 
101  int GetDiameter() const;
102  void SetDiameter( int aDiameter ) { m_diameter = aDiameter; }
103 
104  COLOR4D GetJunctionColor() const;
105 
106  COLOR4D GetColor() const { return m_color; }
107  void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
108 
109  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
110  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
111 
112  void Plot( PLOTTER* aPlotter ) override;
113 
114  EDA_ITEM* Clone() const override;
115 
116  virtual bool operator <( const SCH_ITEM& aItem ) const override;
117 
118 #if defined(DEBUG)
119  void Show( int nestLevel, std::ostream& os ) const override;
120 #endif
121 
122 private:
123  bool doIsConnected( const wxPoint& aPosition ) const override;
124 
126 };
127 
128 
129 #endif // _SCH_JUNCTION_H_
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_junction.h:67
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_junction.h:54
COLOR4D GetJunctionColor() const
bool IsPointClickableAnchor(const wxPoint &aPos) const override
Definition: sch_junction.h:99
COLOR4D m_color
Definition: sch_junction.h:39
void MirrorY(int aYaxis_position) override
Mirror item relative to the Y axis about aYaxis_position.
PNG memory record (file in memory).
Definition: bitmap_def.h:29
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
void MirrorX(int aXaxis_position) override
Mirror item relative to the X axis about aXaxis_position.
void SetDiameter(int aDiameter)
Definition: sch_junction.h:102
void SetColor(const COLOR4D &aColor)
Definition: sch_junction.h:107
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 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
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:49
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:106
wxPoint GetPosition() const override
Definition: sch_junction.h:96
void SetPosition(const wxPoint &aPosition) override
Definition: sch_junction.h:97
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_junction.h:82
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
SCH_LAYER_ID
Eeschema drawing layers.
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
Definition: sch_junction.h:37
bool IsConnectable() const override
Definition: sch_junction.h:78
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:285
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.
Base plotter engine class.
Definition: plotter.h:131
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
#define _(s)
Definition: 3d_actions.cpp:33
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_junction.h:89
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
SHAPE_CIRCLE getEffectiveShape() const
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
void Plot(PLOTTER *aPlotter) override
Plot the schematic item to aPlotter.
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100