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.

159 lines
5.3 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. || aItem->Type() == SCH_LABEL_T
  73. || aItem->Type() == SCH_GLOBAL_LABEL_T
  74. || aItem->Type() == SCH_HIER_LABEL_T
  75. || aItem->Type() == SCH_DIRECTIVE_LABEL_T );
  76. }
  77. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
  78. {
  79. return wxString( _( "Junction" ) );
  80. }
  81. BITMAPS GetMenuImage() const override;
  82. VECTOR2I GetPosition() const override { return m_pos; }
  83. void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
  84. bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override { return false; }
  85. int GetEffectiveDiameter() const;
  86. int GetDiameter() const { return m_diameter; }
  87. void SetDiameter( int aDiameter );
  88. COLOR4D GetJunctionColor() const;
  89. COLOR4D GetColor() const { return m_color; }
  90. void SetColor( const COLOR4D& aColor );
  91. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  92. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  93. void Plot( PLOTTER* aPlotter, bool aBackground,
  94. const SCH_PLOT_SETTINGS& aPlotSettings ) const override;
  95. EDA_ITEM* Clone() const override;
  96. virtual bool operator <( const SCH_ITEM& aItem ) const override;
  97. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  98. double Similarity( const SCH_ITEM& aOther ) const override;
  99. bool operator==( const SCH_ITEM& aOther ) const override;
  100. #if defined(DEBUG)
  101. void Show( int nestLevel, std::ostream& os ) const override;
  102. #endif
  103. private:
  104. bool doIsConnected( const VECTOR2I& aPosition ) const override;
  105. SHAPE_CIRCLE getEffectiveShape() const;
  106. private:
  107. VECTOR2I m_pos;
  108. int m_diameter; ///< Zero is user default.
  109. COLOR4D m_color; ///< #COLOR4D::UNSPECIFIED is user default.
  110. // If real-time connectivity gets disabled (due to being too slow on a particular design),
  111. // we can no longer rely on getting the NetClass to find netclass-specific linestyles,
  112. // linewidths and colors.
  113. mutable int m_lastResolvedDiameter;
  114. mutable COLOR4D m_lastResolvedColor;
  115. };
  116. #endif // SCH_JUNCTION_H