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 
32 class NETLIST_OBJECT_LIST;
33 
34 class SCH_JUNCTION : public SCH_ITEM
35 {
36  wxPoint m_pos; // Position of the junction.
37  int m_diameter; // Diameter of the junction. Zero is user default.
38  COLOR4D m_color; // Color of the junction. #COLOR4D::UNSPECIFIED is user default.
39 
40 public:
41  SCH_JUNCTION( const wxPoint& aPosition = wxPoint( 0, 0 ), int aDiameter = 0,
42  SCH_LAYER_ID aLayer = LAYER_JUNCTION );
43 
44  // Do not create a copy constructor. The one generated by the compiler is adequate.
45 
47 
48  static inline bool ClassOf( const EDA_ITEM* aItem )
49  {
50  return aItem && SCH_JUNCTION_T == aItem->Type();
51  }
52 
53  wxString GetClass() const override
54  {
55  return wxT( "SCH_JUNCTION" );
56  }
57 
58  void SwapData( SCH_ITEM* aItem ) override;
59 
60  void ViewGetLayers( int aLayers[], int& aCount ) const override;
61 
62  const EDA_RECT GetBoundingBox() const override;
63 
64  void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
65 
66  void Move( const wxPoint& aMoveVector ) override
67  {
68  m_pos += aMoveVector;
69  }
70 
71  void MirrorY( int aYaxis_position ) override;
72  void MirrorX( int aXaxis_position ) override;
73  void Rotate( wxPoint aPosition ) override;
74 
75  void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
76 
77  bool IsConnectable() const override { return true; }
78 
79  std::vector<wxPoint> GetConnectionPoints() const override;
80 
81  bool CanConnect( const SCH_ITEM* aItem ) const override
82  {
83  return ( aItem->Type() == SCH_LINE_T &&
84  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ) ) ||
85  aItem->Type() == SCH_COMPONENT_T;
86  }
87 
88  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
89  {
90  return wxString( _( "Junction" ) );
91  }
92 
93  BITMAP_DEF GetMenuImage() const override;
94 
95  wxPoint GetPosition() const override { return m_pos; }
96  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
97 
98  int GetDiameter() const;
99  void SetDiameter( int aDiameter ) { m_diameter = aDiameter; }
100 
101  COLOR4D GetColor() const;
102  void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
103 
104  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
105  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
106 
107  void Plot( PLOTTER* aPlotter ) override;
108 
109  EDA_ITEM* Clone() const override;
110 
111  virtual bool operator <( const SCH_ITEM& aItem ) const override;
112 
113 #if defined(DEBUG)
114  void Show( int nestLevel, std::ostream& os ) const override;
115 #endif
116 
117 private:
118  bool doIsConnected( const wxPoint& aPosition ) const override;
119 };
120 
121 
122 #endif // _SCH_JUNCTION_H_
EDA_UNITS
Definition: common.h:198
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_junction.h:66
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_junction.h:53
COLOR4D m_color
Definition: sch_junction.h:38
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:99
void SetColor(const COLOR4D &aColor)
Definition: sch_junction.h:102
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:48
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
wxPoint GetPosition() const override
Definition: sch_junction.h:95
void SetPosition(const wxPoint &aPosition) override
Definition: sch_junction.h:96
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_junction.h:81
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:36
bool IsConnectable() const override
Definition: sch_junction.h:77
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:279
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:114
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:88
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
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
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: base_struct.h:193
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99