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.

169 lines
4.7 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2013-2015 CERN
  5. * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  6. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * 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 __PNS_MEANDER_PLACER_BASE_H
  22. #define __PNS_MEANDER_PLACER_BASE_H
  23. #include <math/vector2d.h>
  24. #include <geometry/shape.h>
  25. #include <geometry/shape_line_chain.h>
  26. #include "pns_node.h"
  27. #include "pns_via.h"
  28. #include "pns_line.h"
  29. #include "pns_placement_algo.h"
  30. #include "pns_meander.h"
  31. namespace PNS {
  32. class ROUTER;
  33. class SHOVE;
  34. class OPTIMIZER;
  35. /**
  36. * Class MEANDER_PLACER_BASE
  37. *
  38. * Base class for Single trace & Differenial pair meandering tools, as
  39. * both of them share a lot of code.
  40. */
  41. class MEANDER_PLACER_BASE : public PLACEMENT_ALGO
  42. {
  43. public:
  44. ///> Result of the length tuning operation
  45. enum TUNING_STATUS {
  46. TOO_SHORT = 0,
  47. TOO_LONG,
  48. TUNED
  49. };
  50. MEANDER_PLACER_BASE( ROUTER* aRouter );
  51. virtual ~MEANDER_PLACER_BASE();
  52. /**
  53. * Function TuningInfo()
  54. *
  55. * Returns a string describing the status and length of the
  56. * tuned traces.
  57. */
  58. virtual const wxString TuningInfo() const = 0;
  59. /**
  60. * Function TuningStatus()
  61. *
  62. * Returns the tuning status (too short, too long, etc.)
  63. * of the trace(s) being tuned.
  64. */
  65. virtual TUNING_STATUS TuningStatus() const = 0;
  66. /**
  67. * Function AmplitudeStep()
  68. *
  69. * Increases/decreases the current meandering amplitude by one step.
  70. * @param aSign direction (negative = decrease, positive = increase).
  71. */
  72. virtual void AmplitudeStep( int aSign );
  73. /**
  74. * Function SpacingStep()
  75. *
  76. * Increases/decreases the current meandering spcing by one step.
  77. * @param aSign direction (negative = decrease, positive = increase).
  78. */
  79. virtual void SpacingStep( int aSign );
  80. /**
  81. * Function MeanderSettings()
  82. *
  83. * Returns the current meandering configuration.
  84. * @return the settings
  85. */
  86. virtual const MEANDER_SETTINGS& MeanderSettings() const;
  87. /*
  88. * Function UpdateSettings()
  89. *
  90. * Sets the current meandering configuration.
  91. * @param aSettings the settings
  92. */
  93. virtual void UpdateSettings( const MEANDER_SETTINGS& aSettings);
  94. /**
  95. * Function CheckFit()
  96. *
  97. * Checks if it's ok to place the shape aShape (i.e.
  98. * if it doesn't cause DRC violations or collide with
  99. * other meanders).
  100. * @param aShape the shape to check
  101. * @return true if the shape fits
  102. */
  103. virtual bool CheckFit( MEANDER_SHAPE* aShape )
  104. {
  105. return false;
  106. }
  107. protected:
  108. /**
  109. * Function cutTunedLine()
  110. *
  111. * Extracts the part of a track to be meandered, depending on the
  112. * starting point and the cursor position.
  113. * @param aOrigin the original line
  114. * @param aTuneStart point where we start meandering (start click coorinates)
  115. * @param aCursorPos current cursor position
  116. * @param aPre part before the beginning of meanders
  117. * @param aTuned part to be meandered
  118. * @param aPost part after the end of meanders
  119. */
  120. void cutTunedLine( const SHAPE_LINE_CHAIN& aOrigin,
  121. const VECTOR2I& aTuneStart,
  122. const VECTOR2I& aCursorPos,
  123. SHAPE_LINE_CHAIN& aPre,
  124. SHAPE_LINE_CHAIN& aTuned,
  125. SHAPE_LINE_CHAIN& aPost );
  126. /**
  127. * Function tuneLineLength()
  128. *
  129. * Takes a set of meanders in aTuned and tunes their length to
  130. * extend the original line length by aElongation.
  131. */
  132. void tuneLineLength( MEANDERED_LINE& aTuned, int aElongation );
  133. /**
  134. * Function compareWithTolerance()
  135. *
  136. * Compares aValue against aExpected with given tolerance.
  137. */
  138. int compareWithTolerance ( int aValue, int aExpected, int aTolerance = 0 ) const;
  139. ///> width of the meandered trace(s)
  140. int m_currentWidth;
  141. ///> meandering settings
  142. MEANDER_SETTINGS m_settings;
  143. ///> current end point
  144. VECTOR2I m_currentEnd;
  145. };
  146. }
  147. #endif // __PNS_MEANDER_PLACER_BASE_H