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.

148 lines
4.7 KiB

4 years ago
4 years ago
17 years ago
7 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
4 years ago
17 years ago
17 years ago
4 years ago
17 years ago
4 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-2022 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. #include <geometry/shape_circle.h>
  29. class NETLIST_OBJECT_LIST;
  30. class SCH_JUNCTION : public SCH_ITEM
  31. {
  32. public:
  33. SCH_JUNCTION( const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), int aDiameter = 0,
  34. SCH_LAYER_ID aLayer = LAYER_JUNCTION );
  35. // Do not create a copy constructor. The one generated by the compiler is adequate.
  36. ~SCH_JUNCTION() { }
  37. static inline bool ClassOf( const EDA_ITEM* aItem )
  38. {
  39. return aItem && SCH_JUNCTION_T == aItem->Type();
  40. }
  41. wxString GetClass() const override
  42. {
  43. return wxT( "SCH_JUNCTION" );
  44. }
  45. void SwapData( SCH_ITEM* aItem ) override;
  46. void SetLastResolvedState( const SCH_ITEM* aItem ) override
  47. {
  48. const SCH_JUNCTION* aJunction = dynamic_cast<const SCH_JUNCTION*>( aItem );
  49. if( aJunction )
  50. {
  51. m_lastResolvedDiameter = aJunction->m_lastResolvedDiameter;
  52. m_lastResolvedColor = aJunction->m_lastResolvedColor;
  53. }
  54. }
  55. void ViewGetLayers( int aLayers[], int& aCount ) const override;
  56. const BOX2I GetBoundingBox() const override;
  57. void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
  58. void Move( const VECTOR2I& aMoveVector ) override
  59. {
  60. m_pos += aMoveVector;
  61. }
  62. void MirrorHorizontally( int aCenter ) override;
  63. void MirrorVertically( int aCenter ) override;
  64. void Rotate( const VECTOR2I& aCenter ) override;
  65. void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
  66. bool IsConnectable() const override { return true; }
  67. std::vector<VECTOR2I> GetConnectionPoints() const override;
  68. bool CanConnect( const SCH_ITEM* aItem ) const override
  69. {
  70. return aItem->IsConnectable() && ( aItem->Type() == SCH_LINE_T
  71. || aItem->Type() == SCH_SYMBOL_T );
  72. }
  73. wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override
  74. {
  75. return wxString( _( "Junction" ) );
  76. }
  77. BITMAPS GetMenuImage() const override;
  78. VECTOR2I GetPosition() const override { return m_pos; }
  79. void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
  80. bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override { return false; }
  81. int GetEffectiveDiameter() const;
  82. int GetDiameter() const { return m_diameter; }
  83. void SetDiameter( int aDiameter );
  84. COLOR4D GetJunctionColor() const;
  85. COLOR4D GetColor() const { return m_color; }
  86. void SetColor( const COLOR4D& aColor );
  87. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  88. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  89. void Plot( PLOTTER* aPlotter, bool aBackground ) const override;
  90. EDA_ITEM* Clone() const override;
  91. virtual bool operator <( const SCH_ITEM& aItem ) const override;
  92. #if defined(DEBUG)
  93. void Show( int nestLevel, std::ostream& os ) const override;
  94. #endif
  95. private:
  96. bool doIsConnected( const VECTOR2I& aPosition ) const override;
  97. SHAPE_CIRCLE getEffectiveShape() const;
  98. private:
  99. VECTOR2I m_pos;
  100. int m_diameter; ///< Zero is user default.
  101. COLOR4D m_color; ///< #COLOR4D::UNSPECIFIED is user default.
  102. // If real-time connectivity gets disabled (due to being too slow on a particular design),
  103. // we can no longer rely on getting the NetClass to find netclass-specific linestyles,
  104. // linewidths and colors.
  105. mutable int m_lastResolvedDiameter;
  106. mutable COLOR4D m_lastResolvedColor;
  107. };
  108. #endif // SCH_JUNCTION_H