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.

176 lines
5.5 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. /* Flags for BUS ENTRY (bus to bus or wire to bus */
  32. #define WIRE_TO_BUS 0
  33. #define BUS_TO_BUS 1
  34. /**
  35. * Class SCH_BUS_ENTRY
  36. *
  37. * Defines a bus or wire entry.
  38. */
  39. class SCH_BUS_ENTRY : public SCH_ITEM
  40. {
  41. wxPoint m_pos;
  42. int m_width;
  43. wxSize m_size;
  44. public:
  45. SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS );
  46. // Do not create a copy constructor. The one generated by the compiler is adequate.
  47. ~SCH_BUS_ENTRY() { }
  48. virtual wxString GetClass() const
  49. {
  50. return wxT( "SCH_BUS_ENTRY" );
  51. }
  52. wxPoint m_End() const;
  53. /**
  54. * function GetBusEntryShape
  55. * @return the shape of the bus entry, as an ascii code '/' or '\'
  56. */
  57. int GetBusEntryShape() const;
  58. /**
  59. * function SetBusEntryShape
  60. * @param aShape = the shape of the bus entry, as an ascii code '/' or '\'
  61. */
  62. void SetBusEntryShape( int aShape );
  63. int GetWidth() const { return m_width; }
  64. void SetWidth( int aWidth ) { m_width = aWidth; }
  65. wxSize GetSize() const { return m_size; }
  66. void SetSize( const wxSize& aSize ) { m_size = aSize; }
  67. virtual void SwapData( SCH_ITEM* aItem );
  68. virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
  69. int aDrawMode, int aColor = -1 );
  70. /**
  71. * Function Save
  72. * writes the data structures for this object out to a FILE in "*.sch"
  73. * format.
  74. * @param aFile The FILE to write to.
  75. * @return bool - true if success writing else false.
  76. */
  77. bool Save( FILE* aFile ) const;
  78. /**
  79. * Load schematic bus entry from \a aLine in a .sch file.
  80. *
  81. * @param aLine - Essentially this is file to read schematic bus entry from.
  82. * @param aErrorMsg - Description of the error if an error occurs while loading the
  83. * schematic bus entry.
  84. * @return True if the schematic bus entry loaded successfully.
  85. */
  86. virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg );
  87. /**
  88. * Function GetBoundingBox
  89. * returns the orthogonal, bounding box of this object for display
  90. * purposes. This box should be an enclosing perimeter for visible
  91. * components of this object, and the units should be in the pcb or
  92. * schematic coordinate system. It is OK to overestimate the size
  93. * by a few counts.
  94. */
  95. EDA_RECT GetBoundingBox() const;
  96. /**
  97. * Function GetPenSize
  98. * @return the size of the "pen" that be used to draw or plot this item
  99. */
  100. virtual int GetPenSize() const;
  101. /**
  102. * Function Move
  103. * moves and item to a new position by \a aMoveVector.
  104. * @param aMoveVector The displacement vector.
  105. */
  106. virtual void Move( const wxPoint& aMoveVector )
  107. {
  108. m_pos += aMoveVector;
  109. }
  110. /**
  111. * Function Mirror_Y
  112. * mirrors the item relative to \a aYaxis_position.
  113. * @param aYaxis_position The Y axis coordinate to mirror around.
  114. */
  115. virtual void Mirror_Y( int aYaxis_position );
  116. virtual void Mirror_X( int aXaxis_position );
  117. virtual void Rotate( wxPoint rotationPoint );
  118. virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
  119. virtual bool IsSelectStateChanged( const wxRect& aRect );
  120. /**
  121. * @copydoc SCH_ITEM::IsConnectable()
  122. */
  123. virtual bool IsConnectable() const { return true; }
  124. virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
  125. virtual wxString GetSelectMenuText() const;
  126. virtual BITMAP_DEF GetMenuImage() const { return add_entry_xpm; }
  127. #if defined(DEBUG)
  128. void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
  129. #endif
  130. private:
  131. virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
  132. virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
  133. virtual EDA_ITEM* doClone() const;
  134. virtual void doPlot( PLOTTER* aPlotter );
  135. virtual wxPoint doGetPosition() const { return m_pos; }
  136. virtual void doSetPosition( const wxPoint& aPosition ) { m_pos = aPosition; }
  137. };
  138. #endif // _SCH_BUS_ENTRY_H_