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-2019 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>
31 
32 class SCH_JUNCTION : public SCH_ITEM
33 {
34  wxPoint m_pos; // Position of the junction.
35 
36 public:
37  static int g_SymbolSize; // diameter of the junction graphic symbol
38 
39 public:
40  SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) );
41 
42  // Do not create a copy constructor. The one generated by the compiler is adequate.
43 
45 
46  static inline bool ClassOf( const EDA_ITEM* aItem )
47  {
48  return aItem && SCH_JUNCTION_T == aItem->Type();
49  }
50 
51  wxString GetClass() const override
52  {
53  return wxT( "SCH_JUNCTION" );
54  }
55 
56  // Return the size the symbol should be drawn at. This is GetSymbolSize() clamped to be
57  // no less than the current wire width.
58  static int GetEffectiveSymbolSize();
59 
60  void SwapData( SCH_ITEM* aItem ) override;
61 
62  void ViewGetLayers( int aLayers[], int& aCount ) const override;
63 
64  const EDA_RECT GetBoundingBox() const override;
65 
66  void Print( wxDC* aDC, const wxPoint& aOffset ) override;
67 
68  void Move( const wxPoint& aMoveVector ) override
69  {
70  m_pos += aMoveVector;
71  }
72 
73  void MirrorY( int aYaxis_position ) override;
74  void MirrorX( int aXaxis_position ) override;
75  void Rotate( wxPoint aPosition ) override;
76 
77  void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
78 
79  bool IsConnectable() const override { return true; }
80 
81  void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
82 
83  bool CanConnect( const SCH_ITEM* aItem ) const override
84  {
85  return ( aItem->Type() == SCH_LINE_T &&
86  ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ) ) ||
87  aItem->Type() == SCH_COMPONENT_T;
88  }
89 
90  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
91  {
92  return wxString( _( "Junction" ) );
93  }
94 
95  BITMAP_DEF GetMenuImage() const override;
96 
97  void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
98 
99  wxPoint GetPosition() const override { return m_pos; }
100  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
101 
102  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
103  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
104 
105  void Plot( PLOTTER* aPlotter ) override;
106 
107  EDA_ITEM* Clone() const override;
108 
109 #if defined(DEBUG)
110  void Show( int nestLevel, std::ostream& os ) const override;
111 #endif
112 
113 private:
114  bool doIsConnected( const wxPoint& aPosition ) const override;
115 };
116 
117 
118 #endif // _SCH_JUNCTION_H_
EDA_UNITS
Definition: common.h:184
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_junction.h:68
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_junction.h:51
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
PNG memory record (file in memory).
Definition: bitmap_def.h:29
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
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
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_junction.h:46
bool doIsConnected(const wxPoint &aPosition) const override
Function doIsConnected provides the object specific test to see if it is connected to aPosition.
NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected items in a...
void GetNetListItem(NETLIST_OBJECT_LIST &aNetListItems, SCH_SHEET_PATH *aSheetPath) override
Function GetNetListItem creates a new NETLIST_OBJECT for the schematic object and adds it to aNetList...
static int g_SymbolSize
Definition: sch_junction.h:37
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:99
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_junction.h:100
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_junction.h:83
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_SHEET_PATH.
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers returns the layers the item is drawn on (which may be more than its "home" lay...
wxPoint m_pos
Definition: sch_junction.h:34
bool IsConnectable() const override
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_junction.h:79
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:224
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points.
Base plotter engine class.
Definition: plotter.h:104
SCH_JUNCTION(const wxPoint &pos=wxPoint(0, 0))
#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:90
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:166
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
static int GetEffectiveSymbolSize()
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212