You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.0 KiB

17 years ago
7 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
  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. #ifndef _SCH_JUNCTION_H_
  25. #define _SCH_JUNCTION_H_
  26. #include <sch_item.h>
  27. #include <gal/color4d.h>
  28. class NETLIST_OBJECT_LIST;
  29. class SCH_JUNCTION : public SCH_ITEM
  30. {
  31. wxPoint m_pos; // Position of the junction.
  32. int m_diameter; // Diameter of the junction. Zero is user default.
  33. COLOR4D m_color; // Color of the junction. #COLOR4D::UNSPECIFIED is user default.
  34. public:
  35. SCH_JUNCTION( const wxPoint& aPosition = wxPoint( 0, 0 ), int aDiameter = 0,
  36. SCH_LAYER_ID aLayer = LAYER_JUNCTION );
  37. // Do not create a copy constructor. The one generated by the compiler is adequate.
  38. ~SCH_JUNCTION() { }
  39. static inline bool ClassOf( const EDA_ITEM* aItem )
  40. {
  41. return aItem && SCH_JUNCTION_T == aItem->Type();
  42. }
  43. wxString GetClass() const override
  44. {
  45. return wxT( "SCH_JUNCTION" );
  46. }
  47. void SwapData( SCH_ITEM* aItem ) override;
  48. void ViewGetLayers( int aLayers[], int& aCount ) const override;
  49. const EDA_RECT GetBoundingBox() const override;
  50. void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
  51. void Move( const wxPoint& aMoveVector ) override
  52. {
  53. m_pos += aMoveVector;
  54. }
  55. void MirrorY( int aYaxis_position ) override;
  56. void MirrorX( int aXaxis_position ) override;
  57. void Rotate( wxPoint aPosition ) override;
  58. void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
  59. bool IsConnectable() const override { return true; }
  60. void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override;
  61. bool CanConnect( const SCH_ITEM* aItem ) const override
  62. {
  63. return ( aItem->Type() == SCH_LINE_T &&
  64. ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ) ) ||
  65. aItem->Type() == SCH_COMPONENT_T;
  66. }
  67. wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
  68. {
  69. return wxString( _( "Junction" ) );
  70. }
  71. BITMAP_DEF GetMenuImage() const override;
  72. void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override;
  73. wxPoint GetPosition() const override { return m_pos; }
  74. void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
  75. int GetDiameter() const;
  76. void SetDiameter( int aDiameter ) { m_diameter = aDiameter; }
  77. COLOR4D GetColor() const;
  78. void SetColor( const COLOR4D& aColor ) { m_color = aColor; }
  79. bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
  80. bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
  81. void Plot( PLOTTER* aPlotter ) override;
  82. EDA_ITEM* Clone() const override;
  83. virtual bool operator <( const SCH_ITEM& aItem ) const override;
  84. #if defined(DEBUG)
  85. void Show( int nestLevel, std::ostream& os ) const override;
  86. #endif
  87. private:
  88. bool doIsConnected( const wxPoint& aPosition ) const override;
  89. };
  90. #endif // _SCH_JUNCTION_H_