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.

170 lines
4.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2004-2011 KiCad Developers, see change_log.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. * @file sch_bus_entry.h
  26. *
  27. */
  28. #ifndef _SCH_BUS_ENTRY_H_
  29. #define _SCH_BUS_ENTRY_H_
  30. #include <sch_item_struct.h>
  31. /**
  32. * Class SCH_BUS_ENTRY_BASE
  33. *
  34. * Base class for a bus or wire entry.
  35. */
  36. class SCH_BUS_ENTRY_BASE : public SCH_ITEM
  37. {
  38. protected:
  39. wxPoint m_pos;
  40. wxSize m_size;
  41. public:
  42. SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
  43. // Do not create a copy constructor. The one generated by the compiler is adequate.
  44. ~SCH_BUS_ENTRY_BASE() { }
  45. wxPoint m_End() const;
  46. /**
  47. * function GetBusEntryShape
  48. * @return the shape of the bus entry, as an ascii code '/' or '\'
  49. */
  50. char GetBusEntryShape() const;
  51. /**
  52. * function SetBusEntryShape
  53. * @param aShape = the shape of the bus entry, as an ascii code '/' or '\'
  54. */
  55. void SetBusEntryShape( char aShape );
  56. wxSize GetSize() const { return m_size; }
  57. void SetSize( const wxSize& aSize ) { m_size = aSize; }
  58. void SwapData( SCH_ITEM* aItem );
  59. void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
  60. GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
  61. static bool Load( LINE_READER& aLine, wxString& aErrorMsg, SCH_ITEM **out );
  62. const EDA_RECT GetBoundingBox() const; // Virtual
  63. void Move( const wxPoint& aMoveVector )
  64. {
  65. m_pos += aMoveVector;
  66. }
  67. void MirrorY( int aYaxis_position );
  68. void MirrorX( int aXaxis_position );
  69. void Rotate( wxPoint aPosition );
  70. void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
  71. bool IsSelectStateChanged( const wxRect& aRect );
  72. bool IsConnectable() const { return true; }
  73. void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
  74. BITMAP_DEF GetMenuImage() const { return add_entry_xpm; }
  75. wxPoint GetPosition() const { return m_pos; }
  76. void SetPosition( const wxPoint& aPosition ) { m_pos = aPosition; }
  77. bool HitTest( const wxPoint& aPosition, int aAccuracy ) const;
  78. bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const;
  79. void Plot( PLOTTER* aPlotter );
  80. #if defined(DEBUG)
  81. void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
  82. #endif
  83. };
  84. /**
  85. * Class SCH_BUS_WIRE_ENTRY
  86. *
  87. * Class for a wire to bus entry.
  88. */
  89. class SCH_BUS_WIRE_ENTRY : public SCH_BUS_ENTRY_BASE
  90. {
  91. public:
  92. SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
  93. ~SCH_BUS_WIRE_ENTRY() { }
  94. wxString GetClass() const
  95. {
  96. return wxT( "SCH_BUS_WIRE_ENTRY" );
  97. }
  98. bool Save( FILE* aFile ) const;
  99. int GetPenSize() const;
  100. wxString GetSelectMenuText() const;
  101. EDA_ITEM* Clone() const;
  102. };
  103. /**
  104. * Class SCH_BUS_WIRE_ENTRY
  105. *
  106. * Class for a bus to bus entry.
  107. */
  108. class SCH_BUS_BUS_ENTRY : public SCH_BUS_ENTRY_BASE
  109. {
  110. public:
  111. SCH_BUS_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
  112. ~SCH_BUS_BUS_ENTRY() { }
  113. wxString GetClass() const
  114. {
  115. return wxT( "SCH_BUS_BUS_ENTRY" );
  116. }
  117. bool Save( FILE* aFile ) const;
  118. int GetPenSize() const;
  119. wxString GetSelectMenuText() const;
  120. EDA_ITEM* Clone() const;
  121. };
  122. #endif // _SCH_BUS_ENTRY_H_