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.

108 lines
3.3 KiB

7 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 CERN
  5. * Copyright (C) 2019 KiCad Developers, see change_log.txt for contributors.
  6. * @author Jon Evans <jon@craftyjon.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef _SCH_PIN_CONNECTION_H
  22. #define _SCH_PIN_CONNECTION_H
  23. #include <sch_item.h>
  24. #include <sch_sheet_path.h>
  25. #include <lib_pin.h>
  26. #include <mutex>
  27. #include <map>
  28. class SCH_COMPONENT;
  29. class SCH_PIN : public SCH_ITEM
  30. {
  31. LIB_PIN* m_libPin;
  32. wxPoint m_position;
  33. bool m_isDangling;
  34. /// The name that this pin connection will drive onto a net
  35. std::mutex m_netmap_mutex;
  36. std::map<const SCH_SHEET_PATH, wxString> m_net_name_map;
  37. public:
  38. SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent );
  39. SCH_PIN( const SCH_PIN& aPin );
  40. SCH_PIN& operator=( const SCH_PIN& aPin );
  41. wxString GetClass() const override
  42. {
  43. return wxT( "SCH_PIN" );
  44. }
  45. SCH_COMPONENT* GetParentComponent() const;
  46. LIB_PIN* GetLibPin() const { return m_libPin; }
  47. wxString GetDefaultNetName( const SCH_SHEET_PATH aPath );
  48. wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
  49. void GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) override;
  50. void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override {}
  51. void Move( const wxPoint& aMoveVector ) override {}
  52. void MirrorY( int aYaxis_position ) override {}
  53. void MirrorX( int aXaxis_position ) override {}
  54. void Rotate( wxPoint aPosition ) override {}
  55. wxPoint GetPosition() const override { return m_position; }
  56. void SetPosition( const wxPoint& aPosition ) override { m_position = aPosition; }
  57. const EDA_RECT GetBoundingBox() const override;
  58. bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
  59. bool IsDangling() const override { return m_isDangling; }
  60. void SetIsDangling( bool isDangling ) { m_isDangling = isDangling; }
  61. /// Returns the pin's position in global coordinates
  62. wxPoint GetTransformedPosition() const;
  63. /*
  64. * While many of these are currently simply covers for the equivalent LIB_PIN methods,
  65. * the new EESchema file format will soon allow us to override them at the SCH level.
  66. */
  67. bool IsVisible() const { return m_libPin->IsVisible(); }
  68. const wxString& GetName() const { return m_libPin->GetName(); }
  69. const wxString& GetNumber() const { return m_libPin->GetNumber(); }
  70. ELECTRICAL_PINTYPE GetType() const { return m_libPin->GetType(); }
  71. bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); }
  72. #if defined(DEBUG)
  73. void Show( int nestLevel, std::ostream& os ) const override {}
  74. #endif
  75. };
  76. #endif