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.

156 lines
4.5 KiB

  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-2011 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. /**
  25. * @file sch_line.h
  26. */
  27. #ifndef _SCH_LINE_H_
  28. #define _SCH_LINE_H_
  29. #include <sch_item_struct.h>
  30. /**
  31. * Class SCH_LINE
  32. * is a segment description base class to describe items which have 2 end
  33. * points (track, wire, draw line ...)
  34. */
  35. class SCH_LINE : public SCH_ITEM
  36. {
  37. bool m_startIsDangling; ///< True if start point is not connected.
  38. bool m_endIsDangling; ///< True if end point is not connected.
  39. wxPoint m_start; ///< Line start point
  40. wxPoint m_end; ///< Line end point
  41. public:
  42. SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
  43. SCH_LINE( const SCH_LINE& aLine );
  44. ~SCH_LINE() { }
  45. SCH_LINE* Next() const { return (SCH_LINE*) Pnext; }
  46. SCH_LINE* Back() const { return (SCH_LINE*) Pback; }
  47. wxString GetClass() const
  48. {
  49. return wxT( "SCH_LINE" );
  50. }
  51. bool IsEndPoint( const wxPoint& aPoint ) const
  52. {
  53. return aPoint == m_start || aPoint == m_end;
  54. }
  55. bool IsNull() const { return m_start == m_end; }
  56. wxPoint GetStartPoint() const { return m_start; }
  57. void SetStartPoint( const wxPoint& aPosition ) { m_start = aPosition; }
  58. wxPoint GetEndPoint() const { return m_end; }
  59. void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
  60. EDA_RECT GetBoundingBox() const;
  61. /**
  62. * Function GetLength
  63. * @return The length of the line segment.
  64. */
  65. double GetLength() const;
  66. void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
  67. GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
  68. bool Save( FILE* aFile ) const;
  69. bool Load( LINE_READER& aLine, wxString& aErrorMsg );
  70. int GetPenSize() const;
  71. void Move( const wxPoint& aMoveVector );
  72. void MirrorX( int aXaxis_position );
  73. void MirrorY( int aYaxis_position );
  74. void Rotate( wxPoint aPosition );
  75. /**
  76. * Check line against \a aLine to see if it overlaps and merge if it does.
  77. *
  78. * This method will change the line to be equivalent of the line and \a aLine if the
  79. * two lines overlap. This method is used to merge multiple line segments into a single
  80. * line.
  81. *
  82. * @param aLine - Line to compare.
  83. * @return True if lines overlap and the line was merged with \a aLine.
  84. */
  85. bool MergeOverlap( SCH_LINE* aLine );
  86. void GetEndPoints( vector <DANGLING_END_ITEM>& aItemList );
  87. bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList );
  88. bool IsDangling() const { return m_startIsDangling || m_endIsDangling; }
  89. bool IsSelectStateChanged( const wxRect& aRect );
  90. bool IsConnectable() const;
  91. void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
  92. wxString GetSelectMenuText() const;
  93. BITMAP_DEF GetMenuImage() const;
  94. void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, SCH_SHEET_PATH* aSheetPath );
  95. bool operator <( const SCH_ITEM& aItem ) const;
  96. wxPoint GetPosition() const { return m_start; }
  97. void SetPosition( const wxPoint& aPosition );
  98. bool HitTest( const wxPoint& aPosition, int aAccuracy ) const;
  99. bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const;
  100. void Plot( PLOTTER* aPlotter );
  101. EDA_ITEM* Clone() const;
  102. #if defined(DEBUG)
  103. void Show( int nestLevel, std::ostream& os ) const; // override
  104. #endif
  105. private:
  106. bool doIsConnected( const wxPoint& aPosition ) const;
  107. };
  108. #endif // _SCH_LINE_H_