Jspice3
gridline.c File Reference
#include "spice.h"
#include "sced.h"
Include dependency graph for gridline.c:

Go to the source code of this file.

Functions

void ShowGrid ()
 
void ShowLine (int Color, long X1, long Y1, long X2, long Y2)
 
void ShowManhattanLine (int Color, long X1, long Y1, long X2, long Y2)
 

Function Documentation

void ShowGrid ( )

Definition at line 18 of file gridline.c.

20 {
21  /*
22  * Show grid for Window within AOI.
23  * Window maps to Viewport.
24  */
25  long YInL,XInL;
26  long XInP,YInP;
27  long Left,Top,Right,Bottom;
28  long Step;
29 
31  return;
32 
34  DevSetLinestyle(1);
35 
36  /*
37  *
38  * The grid is computed relative to (0,0).
39  *
40  */
41  Step = Parameters.kpGrid*5;
42 
43  if (
47  And
50 
51  Top = View->kvCoarseWindow->kaTop -
52  (View->kvCoarseWindow->kaTop % Step);
53 
54  if (View->kvCoarseWindow->kaTop >= 0)
55  Top += Step;
56 
57  Bottom = View->kvCoarseWindow->kaBottom;
58 
59  Left = View->kvCoarseWindow->kaLeft -
60  (View->kvCoarseWindow->kaLeft % Step);
61 
62  if (View->kvCoarseWindow->kaLeft < 0)
63  Left -= Step;
64 
65  Right = View->kvCoarseWindow->kaRight;
66 
67  if (Parameters.kpGridLineStyle == 0) {
68 
69  /* point grid */
70  for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
71  YInP = .5+(YInL - View->kvCoarseWindow->kaBottom)*
73  YInP += View->kvCoarseViewport->kaBottom;
74  if (YInP < CurrentAOI.aBC) break;
75  if (YInP > CurrentAOI.aTC) continue;
76  for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid) {
77  XInP = .5+(XInL - View->kvCoarseWindow->kaLeft)*
79  XInP += View->kvCoarseViewport->kaLeft;
80  if (XInP > CurrentAOI.aRC) break;
81  if (XInP < CurrentAOI.aLC) continue;
82  if ((Top-YInL) % Step == 0 || (XInL-Left) % Step == 0)
84  else
86 
87  DevPixel((int)XInP,(int)YInP);
88  }
89  }
90  }
91  else {
92 
93  /* Horizontal grid lines */
94  for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
95 
96  YInP = .5+(YInL - View->kvCoarseWindow->kaBottom)*
98  YInP += View->kvCoarseViewport->kaBottom;
99  if (YInP < CurrentAOI.aBC) break;
100  if (YInP > CurrentAOI.aTC) continue;
101 
102  if ((Top-YInL) % Step == 0)
104  else
106 
107  DevLine((int)CurrentAOI.aLC,(int)YInP,
108  (int)CurrentAOI.aRC,(int)YInP);
109 
110  }
111 
112  /* Vertical grid lines */
113  for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid) {
114 
115  XInP = .5+(XInL - View->kvCoarseWindow->kaLeft)*
117  XInP += View->kvCoarseViewport->kaLeft;
118  if (XInP > CurrentAOI.aRC) break;
119  if (XInP < CurrentAOI.aLC) continue;
120 
121  if ((XInL-Left) % Step == 0)
123  else
125 
126  DevLine((int)XInP,(int)CurrentAOI.aBC,
127  (int)XInP,(int)CurrentAOI.aTC);
128 
129  }
130  }
131  }
132 
136 
137 
138  Top = View->kvFineWindow->kaTop -
139  (View->kvFineWindow->kaTop % Step);
140 
141  if (View->kvFineWindow->kaTop >= 0)
142  Top += Step;
143 
144  Bottom = View->kvFineWindow->kaBottom;
145 
146  Left = View->kvFineWindow->kaLeft -
147  (View->kvFineWindow->kaLeft % Step);
148 
149  if (View->kvFineWindow->kaLeft < 0)
150  Left -= Step;
151 
152  Right = View->kvFineWindow->kaRight;
153 
154  if (Parameters.kpGridLineStyle == 0) {
155 
156  /* point grid */
157  for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
158  YInP = .5+(YInL - View->kvFineWindow->kaBottom)*
159  View->kvFineRatio;
160  YInP += View->kvFineViewport->kaBottom;
161  if (YInP < CurrentAOI.aBF) break;
162  if (YInP > CurrentAOI.aTF) continue;
163  for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid) {
164  XInP = .5+(XInL - View->kvFineWindow->kaLeft)*
165  View->kvFineRatio;
166  XInP += View->kvFineViewport->kaLeft;
167  if (XInP > CurrentAOI.aRF) break;
168  if (XInP < CurrentAOI.aLF) continue;
169  if ((Top-YInL) % Step == 0 || (XInL-Left) % Step == 0)
171  else
173 
174  DevPixel((int)XInP,(int)YInP);
175  }
176  }
177  }
178  else {
179  /* Horizontal grid lines */
180  for (YInL = Top; YInL >= Bottom; YInL -= Parameters.kpGrid) {
181 
182  YInP = .5+(YInL - View->kvFineWindow->kaBottom)*
183  View->kvFineRatio;
184  YInP += View->kvFineViewport->kaBottom;
185  if (YInP < CurrentAOI.aBF) break;
186  if (YInP > CurrentAOI.aTF) continue;
187 
188  if ((Top-YInL) % Step == 0)
190  else
192  DevLine((int)CurrentAOI.aLF,(int)YInP,
193  (int)CurrentAOI.aRF,(int)YInP);
194  }
195 
196  /* Vertical grid lines */
197  for (XInL = Left; XInL <= Right; XInL += Parameters.kpGrid){
198 
199  XInP = .5+(XInL - View->kvFineWindow->kaLeft)*
200  View->kvFineRatio;
201  XInP += View->kvFineViewport->kaLeft;
202  if (XInP > CurrentAOI.aRF) break;
203  if (XInP < CurrentAOI.aLF) continue;
204 
205  if ((XInL-Left) % Step == 0)
207  else
209  DevLine((int)XInP,(int)CurrentAOI.aBF,
210  (int)XInP,(int)CurrentAOI.aTF);
211  }
212  }
213  }
214  DevSetLinestyle(0);
215 }
long aTF
Definition: sced.h:121
int kpPointingThreshold
Definition: sced.h:279
#define Or
Definition: cdmacs.h:15
struct ka * kvCoarseWindow
Definition: sced.h:149
long kaRight
Definition: sced.h:112
double kvFineRatio
Definition: sced.h:154
void DevSetColor()
if(TDesc==NULL)
Definition: cd.c:1326
long kaBottom
Definition: sced.h:112
double kvCoarseRatio
Definition: sced.h:155
#define COARSEVIEWPORTONLY
Definition: sced.h:51
long aBF
Definition: sced.h:121
#define CoarseGridColor
Definition: sced.h:82
long aTC
Definition: sced.h:122
#define FineGridColor
Definition: sced.h:83
void DevSetLinestyle()
void DevDefineLinestyle()
int kpGridDisplayed
Definition: sced.h:240
char kpRedisplayControl
Definition: sced.h:312
long aLC
Definition: sced.h:122
struct a CurrentAOI
Definition: init.c:22
struct ka * kvFineViewport
Definition: sced.h:148
struct ka * kvLargeCoarseViewport
Definition: sced.h:151
#define FINEVIEWPORTONLY
Definition: sced.h:50
int kpGridLineStyle
Definition: sced.h:237
long * Left
Definition: cd.c:1907
long aLF
Definition: sced.h:121
int kpShowGridInLargeViewport
Definition: sced.h:246
struct ka * kvCoarseViewport
Definition: sced.h:150
struct kp Parameters
Definition: init.c:19
int aInFine
Definition: sced.h:123
long kaTop
Definition: sced.h:112
long * Top
Definition: cd.c:1907
long * Right
Definition: cd.c:1907
struct ka * kvFineWindow
Definition: sced.h:147
void DevPixel()
void DevLine()
long aRC
Definition: sced.h:122
struct kv * View
Definition: init.c:17
long kaLeft
Definition: sced.h:112
long * Bottom
Definition: cd.c:1907
long aBC
Definition: sced.h:122
#define And
Definition: cdmacs.h:14
long kpGrid
Definition: sced.h:234
long aRF
Definition: sced.h:121
int aInCoarse
Definition: sced.h:124
void ShowLine ( int  Color,
long  X1,
long  Y1,
long  X2,
long  Y2 
)

Definition at line 219 of file gridline.c.

223 {
224  long X1P,Y1P,X2P,Y2P;
225 
226  TPoint(&X1,&Y1);
227  TPoint(&X2,&Y2);
228 
230 
233 
234  CoarseLToP(X1,Y1,X1P,Y1P);
235  CoarseLToP(X2,Y2,X2P,Y2P);
236  if (Not clip_line(&X1P,&Y1P,&X2P,&Y2P,CurrentAOI.aLC,
238 
239  DevLine((int)X1P,(int)Y1P,(int)X2P,(int)Y2P);
240  }
241  }
242 
245 
246  FineLToP(X1,Y1,X1P,Y1P);
247  FineLToP(X2,Y2,X2P,Y2P);
248  if (Not clip_line(&X1P,&Y1P,&X2P,&Y2P,CurrentAOI.aLF,
250 
251  DevLine((int)X1P,(int)Y1P,(int)X2P,(int)Y2P);
252  }
253  }
254 }
long aTF
Definition: sced.h:121
void TPoint()
void DevSetColor()
#define COARSEVIEWPORTONLY
Definition: sced.h:51
#define Not
Definition: cdmacs.h:16
long aBF
Definition: sced.h:121
long aTC
Definition: sced.h:122
#define FineLToP(X, Y, XT, YT)
Definition: sced.h:379
char kpRedisplayControl
Definition: sced.h:312
long aLC
Definition: sced.h:122
struct a CurrentAOI
Definition: init.c:22
#define FINEVIEWPORTONLY
Definition: sced.h:50
long aLF
Definition: sced.h:121
struct kp Parameters
Definition: init.c:19
int aInFine
Definition: sced.h:123
void Color()
void DevLine()
long aRC
Definition: sced.h:122
bool clip_line()
long aBC
Definition: sced.h:122
#define CoarseLToP(X, Y, XT, YT)
Definition: sced.h:373
#define And
Definition: cdmacs.h:14
long aRF
Definition: sced.h:121
int aInCoarse
Definition: sced.h:124
void ShowManhattanLine ( int  Color,
long  X1,
long  Y1,
long  X2,
long  Y2 
)

Definition at line 258 of file gridline.c.

262 {
263  long X1P,Y1P,X2P,Y2P;
264 
266 
269 
270  CoarseLToP(X1,Y1,X1P,Y1P);
271  CoarseLToP(X2,Y2,X2P,Y2P);
272 
273  if (X1P == X2P) {
274  if (X1P < CurrentAOI.aLC Or X1P > CurrentAOI.aRC) return;
275  if (Y1P > Y2P) SwapInts(Y1P,Y2P);
276  if (Y1P > CurrentAOI.aTC Or Y2P < CurrentAOI.aBC) return;
277  if (Y1P < CurrentAOI.aBC) Y1P = CurrentAOI.aBC;
278  if (Y2P > CurrentAOI.aTC) Y2P = CurrentAOI.aTC;
279  }
280  elif (Y1P == Y2P) {
281  if (Y1P < CurrentAOI.aBC Or Y1P > CurrentAOI.aTC) return;
282  if (X1P > X2P) SwapInts(X1P,X2P);
283  if (X1P > CurrentAOI.aRC Or X2P < CurrentAOI.aLC) return;
284  if (X1P < CurrentAOI.aLC) X1P = CurrentAOI.aLC;
285  if (X2P > CurrentAOI.aRC) X2P = CurrentAOI.aRC;
286  }
287  else return;
288 
289  DevLine((int)X1P,(int)Y1P,(int)X2P,(int)Y2P);
290  }
293 
294  FineLToP(X1,Y1,X1P,Y1P);
295  FineLToP(X2,Y2,X2P,Y2P);
296 
297  if (X1P == X2P) {
298  if (X1P < CurrentAOI.aLF Or X1P > CurrentAOI.aRF) return;
299  if (Y1P > Y2P) SwapInts(Y1P,Y2P);
300  if (Y1P > CurrentAOI.aTF Or Y2P < CurrentAOI.aBF) return;
301  if (Y1P < CurrentAOI.aBF) Y1P = CurrentAOI.aBF;
302  if (Y2P > CurrentAOI.aTF) Y2P = CurrentAOI.aTF;
303  }
304  elif (Y1P == Y2P) {
305  if (Y1P < CurrentAOI.aBF Or Y1P > CurrentAOI.aTF) return;
306  if (X1P > X2P) SwapInts(X1P,X2P);
307  if (X1P > CurrentAOI.aRF Or X2P < CurrentAOI.aLF) return;
308  if (X1P < CurrentAOI.aLF) X1P = CurrentAOI.aLF;
309  if (X2P > CurrentAOI.aRF) X2P = CurrentAOI.aRF;
310  }
311  else return;
312 
313  DevLine((int)X1P,(int)Y1P,(int)X2P,(int)Y2P);
314  }
315 }
long aTF
Definition: sced.h:121
#define Or
Definition: cdmacs.h:15
void DevSetColor()
#define COARSEVIEWPORTONLY
Definition: sced.h:51
long aBF
Definition: sced.h:121
long aTC
Definition: sced.h:122
#define FineLToP(X, Y, XT, YT)
Definition: sced.h:379
char kpRedisplayControl
Definition: sced.h:312
long aLC
Definition: sced.h:122
struct a CurrentAOI
Definition: init.c:22
#define FINEVIEWPORTONLY
Definition: sced.h:50
long aLF
Definition: sced.h:121
struct kp Parameters
Definition: init.c:19
int aInFine
Definition: sced.h:123
void Color()
#define elif
Definition: cdmacs.h:10
void DevLine()
long aRC
Definition: sced.h:122
long aBC
Definition: sced.h:122
#define CoarseLToP(X, Y, XT, YT)
Definition: sced.h:373
#define And
Definition: cdmacs.h:14
long aRF
Definition: sced.h:121
#define SwapInts(Dragon, Eagle)
Definition: cdmacs.h:20
int aInCoarse
Definition: sced.h:124