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 
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  void GetConnectionPoints( std::vector< wxPoint >& aPoints ) 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  void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
96 
97  const wxPoint GetPosition() const override { return m_pos; }
98  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
99 
100  int GetDiameter() const { return m_diameter; }
101  void SetDiameter( int aDiameter ) { m_diameter = aDiameter; }
102 
103  COLOR4D GetColor() const { return m_color; }
104  void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
105 
106  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
107  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
108 
109  void Plot( PLOTTER* aPlotter ) override;
110 
111  EDA_ITEM* Clone() const override;
112 
113  virtual bool operator <( const SCH_ITEM& aItem ) const override;
114 
115 #if defined(DEBUG)
116  void Show( int nestLevel, std::ostream& os ) const override;
117 #endif
118 
119 private:
120  bool doIsConnected( const wxPoint& aPosition ) const override;
121 };
122 
123 
124 #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:101
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Add all the connection points for this item to aPoints.
void SetColor(const COLOR4D &aColor)
Definition: sch_junction.h:104
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
Definition: sch_junction.h:100
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.
NETLIST_OBJECT_LIST is a container holding and owning NETLIST_OBJECTs, which are connected items in a...
SCH_JUNCTION(const wxPoint &aPosition=wxPoint(0, 0), int aDiameter=0, SCH_LAYER_ID aLayer=LAYER_JUNCTION)
COLOR4D GetColor() const
Definition: sch_junction.h:103
void GetNetListItem(NETLIST_OBJECT_LIST &aNetListItems, SCH_SHEET_PATH *aSheetPath) override
Create a new NETLIST_OBJECT for the schematic object and adds it to aNetListItems.
void SetPosition(const wxPoint &aPosition) override
Set the schematic item position to aPosition.
Definition: sch_junction.h:98
const wxPoint GetPosition() const override
Definition: sch_junction.h:97
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.
SCH_SHEET_PATH.
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:271
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:186
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