1 /***************************************************************************
2 SCED - Schematic Capture Editor
3 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
4 Copyright 1990 Regents of the University of California.  All rights reserved.
5 Authors: 1981 Giles C. Billingsley  (parts of KIC layout editor)
6          1992 Stephen R. Whiteley
7 ****************************************************************************/
8 
9 /*
10  * SCED data structures.
11  *
12  */
13 
14 #include <setjmp.h>
15 #include "cddefs.h"
16 #include "fteinp.h"
17 
18 /*
19  * Environmental data
20  * (this should go somewhere else)
21  */
22 
23 #define DEFAULT_EDIT_FILE  "noname"
24 #define DEFAULT_TERMINAL   NULL
25 #define INIT_FILE          "sced.rc"
26 #define DEFAULT_PATH       "."
27 
28 /* name of device library */
29 #define DeviceLibrary "device.lib"
30 #define ModelLibrary "model.lib"
31 
32 
33 /*
34  * There are 100 data base units per micron
35  */
36 #define RESOLUTION        100
37 #define HALFRESOLUTION    50
38 
39 /*
40  * Size of the storage for polygon vertices
41  */
42 #define POLYGONBUFSIZE        600
43 #define MAXPOLYGONVERTICES    300
44 
45 /*
46  * Viewport control flags
47  */
48 #define SPLITSCREEN           'b'
49 #define FULLSCREEN            'o'
50 #define FINEVIEWPORTONLY      'f'
51 #define COARSEVIEWPORTONLY    'c'
52 
53 /*
54  * Menu names
55  */
56 #define BASICMENU             'B'
57 #define AMBIGUITYMENU         'A'
58 
59 /*
60  * Returns from PointLoop() function.
61  */
62 #define PL_ESC 1
63 #define PL_UND 2
64 #define PL_CMD 3
65 #define PL_PCW 4
66 
67 /* colormap indices */
68 /* Oh, bother.  X likes the highlighting color
69  * to be 1, but Microsoft mouse insists on
70  * color 15 for the cursor, which also
71  * is highlighted.
72  */
73 #define BackgroundColor          0
74 #define HighlightingColor        1
75 #define MenuTextColor            2
76 #define MenuTextPrefixColor      3
77 #define MenuSelectedColor        4
78 #define MenuSelectedPrefixColor  5
79 #define MenuHighlightingColor    6
80 #define PromptTextColor          7
81 #define MoreTextColor            8
82 #define CoarseGridColor          9
83 #define FineGridColor            10
84 #define InstanceBBColor          11
85 #define InstanceNameColor        12
86 #define ExtraColor1              13
87 #define DrawingColor             14
88 #define ExtraColor2              15
89 
90 /* character that terminates most commands */
91 #define ESCAPE 27
92 
93 
94 struct kl {
95       int klR,klG,klB;    /* RGB color */
96 };
97 
98 /*
99  * Cursor desc.
100  */
101 struct kc {
102     long kcPredX,kcPredY,kcX,kcY;
103     long kcRawX,kcRawY;
104     long kcDX,kcDY;
105     int  kcInFine;
106 };
107 
108 /*
109  * Area structure.
110  */
111 struct ka {
112     long kaLeft,kaBottom,kaRight,kaTop;
113     long kaX,kaY;
114     double kaWidth,kaHeight;
115 };
116 
117 /*
118  * Structure to keep current area of interest.
119  */
120 struct a {
121     long aLF,aBF,aRF,aTF;
122     long aLC,aBC,aRC,aTC;
123     int  aInFine;
124     int  aInCoarse;
125 };
126 
127 /*
128  * Structure used to save windows in window stack.
129  */
130 struct kw {
131     long kwLastWindowX;
132     long kwLastWindowY;
133     long kwLastWindowWidth;
134     long kwLastFineWindowX;
135     long kwLastFineWindowY;
136     long kwLastFineWindowWidth;
137     struct kw *kwNext;
138     char kwExpand;
139     char kwExpandFineOnly;
140     char kwName[8];
141 };
142 
143 /*
144  * Layout windows and the viewports they map to.
145  */
146 struct kv {
147     struct ka *kvFineWindow;
148     struct ka *kvFineViewport;
149     struct ka *kvCoarseWindow;
150     struct ka *kvCoarseViewport;
151     struct ka *kvLargeCoarseViewport;
152     struct ka *kvSmallCoarseViewport;
153     /* viewport/window */
154     double kvFineRatio;
155     double kvCoarseRatio;
156     int kvFineViewportOnBottom;
157     char kvControl;
158 };
159 
160 
161 /* definitions for hypertext */
162 
163 #define HY_END  0
164 #define HY_NODE 1
165 #define HY_BRAN 2
166 #define HY_DEVN 4
167 #define HY_ALL  7
168 #define HY_TEXT 8
169 #define HY_BOGUS 16
170 
171 /* structures for keeping track of coordinate reference */
172 struct parent {
173     struct o *pPointer;      /* parent of reference */
174     struct o *pOldPointer;   /* for undo */
175     struct parent *pNext;    /* link */
176 };
177 
178 struct hyEnt {
179     long hyX;                /* coordinate */
180     long hyY;
181     long hyOldX;             /* previous coord for undo */
182     long hyOldY;
183     struct o *hyPointer;     /* device referenced */
184     struct o *hyOldPointer;  /* previous reference for undo */
185     struct parent *hyParent; /* list of parent devices for subckt ref */
186     int hyOrient;            /* orientation of branch current */
187     int hyOldOrient;         /* previous orient for undo */
188     int hyRefType;           /* HY_... NODE, BRAN, DEVN, BOGUS */
189     int hyUndo;              /* true if undone */
190 };
191 
192 /* hypertext string list */
193 struct hprlist {
194     int hlRefType;           /* HY_... NODE, BRAN, DEVN, TEXT */
195     char *hlText;            /* text, if HY_TEXT */
196     struct hyEnt *hlEnt;     /* hyEnt struct if not HY_TEXT */
197     struct hprlist *hlNext;  /* link */
198 };
199 
200 
201 /*
202  * Parameters that control SCED.
203  */
204 struct kp {
205 
206     /* Symbol desc for current cell */
207     struct s *kpCellDesc;
208 
209     /* Symbol name for current cell */
210     char *kpCellName;
211 
212     /* Symbol desc for top level cell */
213     struct s *kpTopDesc;
214 
215     /* Symbol name for top level cell */
216     char *kpTopName;
217 
218     /* Command selected if any from command menu */
219     char *kpCommand;
220 
221     /* Linked list of saved views */
222     struct kw *kpWindowStack;
223 
224     /* current instance array parameters */
225     int kpNumX;
226     int kpNumY;
227     double kpDX;
228     double kpDY;
229 
230     /* True if subcircuits should be expanded */
231     int kpExpandInstances;
232 
233     /* Number of RESOLUTION*lambda between grid points. */
234     long kpGrid;
235 
236     /* grid line pattern */
237     int kpGridLineStyle;
238 
239     /* If True, display grid */
240     int kpGridDisplayed;
241 
242     /* If True, put grid below layout geometries */
243     int kpGridOnTop;
244 
245     /* If True, grid will be shown in large viewport */
246     int kpShowGridInLargeViewport;
247 
248     /* If False then the SelectQ is never redisplayed (for speed) */
249     int kpEnableSelectQRedisplay;
250 
251     /* Current colormap index */
252     int kpColor;
253 
254     /* If true, display subcircuit terminals */
255     int kpShowTerminals;
256 
257     /* If True, user pointed inside coarse viewport and Command[0] == EOS */
258     int kpPointCoarseWindow;
259 
260     /* True if current cell has been modified */
261     int kpModified;
262 
263     /* Debug parameters */
264     int kpNumGeometries;
265 
266     /* If True, user has just pressed the interrupt key */
267     int kpSIGINTERRUPT;
268 
269     /* If true, show connection points */
270     int kpShowDots;
271 
272     /* Which types of object will be selected */
273     char kpSelectTypes[8];
274 
275     /*
276      * PointingThreshold is the minimum value of ViewportWidth/WindowWidth
277      * such that it is still comfortable to point with lambda precision.
278      */
279     int kpPointingThreshold;
280 
281     /* Current transform defined in Selection menu */
282     int kpRotationAngle;    /* 0, 90, 180, or 270 */
283     int kpMX;
284     int kpMY;
285 
286     /* True if making hard copy */
287     int kpDoingHardcopy;
288 
289     /* Factor for scaling text labels for hard copy */
290     int kpHardcopyTextScale;
291 
292     /* Keep track of cursor location */
293     int kpLastCursorColumn;
294 
295     /* Type of cursor chosen */
296     int kpCursorShape;
297 
298     /* True if full screen cursor in use */
299     int kpFullScreenCursor;
300 
301     /* Beep volume */
302     int kpPointBeepVolume;
303 
304     /* Name of X font used */
305     char kpFontName[81];
306 
307     /*
308      * == COARSEVIEWPORTONLY if coarse window-viewport to be redisplayed
309      * == FINEVIEWPORTONLY if fine window-viewport should be redisplayed
310      * == SPLITSCREEN if both should be redisplayed
311      */
312     char kpRedisplayControl;
313 
314     /*
315      * Current command menu
316      *     == BASICMENU denotes basic menu
317      *     == AMBIGUITYMENU denotes ambiguity menu
318      */
319     char kpMenu;
320 };
321 
322 /*
323  * Selection queue.
324  *
325  *
326  * The select Q is a single-linked list of select Q descriptors.
327  * Each desc points to the object descriptor for a selected object.
328  * SelectQHead is the head of the list.
329  * SelectQBB is the BB of ALL of the selected objects.
330  * Move and delete are easily implemented as operations on the Q.
331  */
332 
333 struct ks {
334     struct ks *ksSucc;
335     struct o *ksPointer;
336 };
337 
338 /* Values of Info parameter used to manage objects in SelectQ */
339 
340 /* Previous object not in Q */
341 #define SQ_OLD     0
342 
343 /* Previous object in Q, selected */
344 #define SQ_OLDSEL  1
345 
346 /* Conditionally deleted object */
347 #define SQ_GONE    2
348 
349 /* Newly created object, not selected */
350 #define SQ_NEW     3
351 
352 /* Newly created object, selected */
353 #define SQ_NEWSEL  4
354 
355 /* Partially created object */
356 #define SQ_INCMPLT 5
357 
358 
359 /*
360  * menus.
361  */
362 
363 struct menu {
364     char *mEntry;
365     short mActive;
366     char mPrefix[6];
367 };
368 typedef struct menu MENU;
369 
370 
371 /* coordinate transformation macros */
372 
373 #define CoarseLToP(X,Y,XT,YT) \
374     XT = .5+(X-View->kvCoarseWindow->kaLeft)*View->kvCoarseRatio; \
375     XT += View->kvCoarseViewport->kaLeft; \
376     YT = .5+(Y-View->kvCoarseWindow->kaBottom)*View->kvCoarseRatio; \
377     YT += View->kvCoarseViewport->kaBottom;
378 
379 #define FineLToP(X,Y,XT,YT) \
380     XT = .5+(X-View->kvFineWindow->kaLeft)*View->kvFineRatio; \
381     XT += View->kvFineViewport->kaLeft; \
382     YT = .5+(Y-View->kvFineWindow->kaBottom)*View->kvFineRatio; \
383     YT += View->kvFineViewport->kaBottom;
384 
385 #define ClipVP(Viewport,X,Y) \
386     if(X < Viewport->kaLeft) X = Viewport->kaLeft; \
387     else if(X > Viewport->kaRight) X = Viewport->kaRight; \
388     if(Y < Viewport->kaBottom) Y = Viewport->kaBottom; \
389     else if(Y > Viewport->kaTop) Y = Viewport->kaTop;
390 
391 #include "scedext.h"
392