PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/alliance-5.0/dreal/src/GMX_grid.c

#
C | 316 lines | 173 code | 51 blank | 92 comment | 21 complexity | 4c56102a95dac6a3bd093ec8ed380105 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0
  1. /*------------------------------------------------------------\
  2. | |
  3. | This file is part of the Alliance CAD System Copyright |
  4. | (C) Laboratoire LIP6 - D├ępartement ASIM Universite P&M Curie|
  5. | |
  6. | Home page : http://www-asim.lip6.fr/alliance/ |
  7. | E-mail : mailto:alliance-users@asim.lip6.fr |
  8. | |
  9. | This progam is free software; you can redistribute it |
  10. | and/or modify it under the terms of the GNU General Public |
  11. | License as published by the Free Software Foundation; |
  12. | either version 2 of the License, or (at your option) any |
  13. | later version. |
  14. | |
  15. | Alliance VLSI CAD System is distributed in the hope that |
  16. | it will be useful, but WITHOUT ANY WARRANTY; |
  17. | without even the implied warranty of MERCHANTABILITY or |
  18. | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
  19. | Public License for more details. |
  20. | |
  21. | You should have received a copy of the GNU General Public |
  22. | License along with the GNU C Library; see the file COPYING. |
  23. | If not, write to the Free Software Foundation, Inc., |
  24. | 675 Mass Ave, Cambridge, MA 02139, USA. |
  25. | |
  26. \------------------------------------------------------------*/
  27. /*------------------------------------------------------------\
  28. | |
  29. | Tool : DREAL |
  30. | |
  31. | File : Grid.c |
  32. | |
  33. | Authors : Jacomme Ludovic |
  34. | |
  35. | Date : 28.03.95 |
  36. | |
  37. \------------------------------------------------------------*/
  38. /*------------------------------------------------------------\
  39. | |
  40. | Include Files |
  41. | |
  42. \------------------------------------------------------------*/
  43. # include <stdio.h>
  44. # include <Xm/Xm.h>
  45. # include "mut.h"
  46. # include "mph.h"
  47. # include "rds.h"
  48. # include "rpr.h"
  49. # include "GSB.h"
  50. # include "GRD.h"
  51. # include "GMX.h"
  52. # include "GMX_grid.h"
  53. /*------------------------------------------------------------\
  54. | |
  55. | Constants |
  56. | |
  57. \------------------------------------------------------------*/
  58. /*------------------------------------------------------------\
  59. | |
  60. | Types |
  61. | |
  62. \------------------------------------------------------------*/
  63. /*------------------------------------------------------------\
  64. | |
  65. | Variables |
  66. | |
  67. \------------------------------------------------------------*/
  68. /*------------------------------------------------------------\
  69. | |
  70. | Lambda Grid |
  71. | |
  72. \------------------------------------------------------------*/
  73. float DrealLambdaGridStep;
  74. long DrealLambdaGridX;
  75. long DrealLambdaGridY;
  76. long DrealLambdaGridDx;
  77. long DrealLambdaGridDy;
  78. long DrealPixelGridX;
  79. long DrealPixelGridY;
  80. /*------------------------------------------------------------\
  81. | |
  82. | User Lambda Grid |
  83. | |
  84. \------------------------------------------------------------*/
  85. long DrealLambdaUserGridDx;
  86. long DrealLambdaUserGridDy;
  87. char DrealLambdaUserGrid;
  88. /*------------------------------------------------------------\
  89. | |
  90. | Functions |
  91. | |
  92. \------------------------------------------------------------*/
  93. /*------------------------------------------------------------\
  94. | |
  95. | DrealInitializeLambdaGrid |
  96. | |
  97. \------------------------------------------------------------*/
  98. void DrealInitializeLambdaGrid()
  99. {
  100. rdsbegin();
  101. DrealLambdaGridX = DREAL_DEFAULT_GRID_X;
  102. DrealLambdaGridY = DREAL_DEFAULT_GRID_Y;
  103. DrealLambdaGridDx = DREAL_DEFAULT_GRID_DX;
  104. DrealLambdaGridDy = DREAL_DEFAULT_GRID_DY;
  105. DrealLambdaUserGridDx = 4;
  106. DrealLambdaUserGridDy = 4;
  107. DrealLambdaUserGrid = DREAL_FALSE;
  108. DrealComputeLambdaGrid();
  109. rdsend();
  110. }
  111. /*------------------------------------------------------------\
  112. | |
  113. | DrealComputeLambdaGrid |
  114. | |
  115. \------------------------------------------------------------*/
  116. void DrealComputeLambdaGrid()
  117. {
  118. float StepX;
  119. float StepY;
  120. rdsbegin();
  121. StepX = (float)(DrealGraphicDx) / (float)(DrealLambdaGridDx);
  122. StepY = (float)(DrealGraphicDy) / (float)(DrealLambdaGridDy);
  123. if ( StepX < StepY )
  124. {
  125. DrealLambdaGridStep = StepX;
  126. DrealLambdaGridDy = 1 + ( DrealGraphicDy / StepX );
  127. }
  128. else
  129. {
  130. DrealLambdaGridStep = StepY;
  131. DrealLambdaGridDx = 1 + ( DrealGraphicDx / StepY );
  132. }
  133. DrealPixelGridX = (float)(DrealLambdaGridX) * DrealLambdaGridStep;
  134. DrealPixelGridY = (float)(DrealLambdaGridY) * DrealLambdaGridStep;
  135. rdsend();
  136. }
  137. /*------------------------------------------------------------\
  138. | |
  139. | DrealResizeLambdaGrid |
  140. | |
  141. \------------------------------------------------------------*/
  142. void DrealResizeLambdaGrid()
  143. {
  144. rdsbegin();
  145. DrealLambdaGridDx = 1 + ( DrealGraphicDx / DrealLambdaGridStep );
  146. DrealLambdaGridDy = 1 + ( DrealGraphicDy / DrealLambdaGridStep );
  147. rdsend();
  148. }
  149. /*------------------------------------------------------------\
  150. | |
  151. | DrealDisplayLambdaGrid |
  152. | |
  153. \------------------------------------------------------------*/
  154. char DrealDisplayLambdaGrid( GraphicX1, GraphicY1, GraphicX2, GraphicY2 )
  155. Dimension GraphicX1;
  156. Dimension GraphicY1;
  157. Dimension GraphicX2;
  158. Dimension GraphicY2;
  159. {
  160. long X;
  161. long Y;
  162. long MaxGridX;
  163. long MaxGridY;
  164. long PixelX;
  165. long PixelY;
  166. long Xmin;
  167. long Ymin;
  168. char UserGrid;
  169. char LambdaGrid;
  170. char TraceCroix;
  171. char TracePoint;
  172. float Check;
  173. rdsbegin();
  174. if ( DrealLambdaGridStep < DREAL_LOWER_GRID_STEP )
  175. {
  176. LambdaGrid = 0;
  177. }
  178. else
  179. {
  180. LambdaGrid = 1;
  181. }
  182. if ( DrealLambdaUserGrid == 1 )
  183. {
  184. if ( DrealLambdaUserGridDx > DrealLambdaUserGridDy )
  185. {
  186. Check = ( DREAL_LOWER_GRID_STEP * 2 / DrealLambdaUserGridDy );
  187. }
  188. else
  189. {
  190. Check = ( DREAL_LOWER_GRID_STEP * 2 / DrealLambdaUserGridDy );
  191. }
  192. if ( DrealLambdaGridStep < Check ) UserGrid = 0;
  193. else UserGrid = 1;
  194. }
  195. else
  196. {
  197. UserGrid = 0;
  198. }
  199. if ( ( UserGrid == 0 ) &&
  200. ( LambdaGrid == 0 ) )
  201. {
  202. rdsend();
  203. return( DREAL_FALSE );
  204. }
  205. MaxGridX = DrealLambdaGridX + DrealLambdaGridDx;
  206. MaxGridY = DrealLambdaGridY + DrealLambdaGridDy;
  207. if ( LambdaGrid )
  208. {
  209. for ( X = DrealLambdaGridX; X < MaxGridX; X = X + 1 )
  210. {
  211. PixelX = ((float)(X) * DrealLambdaGridStep);
  212. PixelX = PixelX - DrealPixelGridX;
  213. if ( ( PixelX <= GraphicX2 ) &&
  214. ( PixelX >= GraphicX1 ) )
  215. for ( Y = DrealLambdaGridY; Y < MaxGridY; Y = Y + 1 )
  216. {
  217. PixelY = ((float)(Y) * DrealLambdaGridStep);
  218. PixelY = PixelY - DrealPixelGridY;
  219. PixelY = DrealGraphicDy - PixelY;
  220. if ( ( PixelY <= GraphicY2 ) &&
  221. ( PixelY >= GraphicY1 ) )
  222. {
  223. XDrawPoint( DrealGraphicDisplay,
  224. XtWindow( DrealGraphicWindow ),
  225. DrealGridGC,
  226. PixelX, PixelY );
  227. }
  228. }
  229. }
  230. }
  231. if ( UserGrid )
  232. {
  233. Xmin = ( DrealLambdaGridX / DrealLambdaUserGridDx ) * DrealLambdaUserGridDx;
  234. Ymin = ( DrealLambdaGridY / DrealLambdaUserGridDy ) * DrealLambdaUserGridDy;
  235. for ( X = Xmin; X < MaxGridX ; X = X + DrealLambdaUserGridDx )
  236. {
  237. PixelX = ((float)(X) * DrealLambdaGridStep);
  238. PixelX = PixelX - DrealPixelGridX;
  239. if ( ( PixelX <= GraphicX2 ) &&
  240. ( PixelX >= GraphicX1 ) )
  241. for ( Y = Ymin; Y < MaxGridY; Y = Y + DrealLambdaUserGridDy )
  242. {
  243. PixelY = ((float)(Y) * DrealLambdaGridStep);
  244. PixelY = PixelY - DrealPixelGridY;
  245. PixelY = DrealGraphicDy - PixelY;
  246. if ( ( PixelY <= GraphicY2 ) &&
  247. ( PixelY >= GraphicY1 ) )
  248. {
  249. XDrawLine( DrealGraphicDisplay,
  250. XtWindow( DrealGraphicWindow ),
  251. DrealGridGC,
  252. PixelX - 2, PixelY,
  253. PixelX + 2, PixelY );
  254. XDrawLine( DrealGraphicDisplay,
  255. XtWindow( DrealGraphicWindow ),
  256. DrealGridGC,
  257. PixelX, PixelY + 2,
  258. PixelX, PixelY - 2 );
  259. }
  260. }
  261. }
  262. }
  263. rdsend();
  264. return( DREAL_TRUE );
  265. }