Jspice3
init.c
Go to the documentation of this file.
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  * Initialize SCED.
11  */
12 
13 #include "spice.h"
14 #include "sced.h"
15 #include "scedmacs.h"
16 
17 struct kv *View;
19 struct kp Parameters;
20 struct kl *ColorTable;
21 struct kc SCursor;
22 struct a CurrentAOI;
23 char TypeOut[200];
24 
25 #ifdef __STDC__
26 static void correct_cell_view(long*,long*,long*,long*);
27 static int get_window_coords(long*,long*,int);
28 #else
29 static void correct_cell_view();
30 static int get_window_coords();
31 #endif
32 
33 
34 char *
36 
37 {
38  GRAPH *graph;
39 
40  /*
41  * Initialize for default values
42  */
43  if (ColorTable == NULL) {
44 
46 
52 
53  ColorTable = (struct kl *)malloc(16*sizeof(struct kl));
54  if (ColorTable == NULL)
55  MallocFailed();
56 
57  ColorTable[BackgroundColor].klR = 0;
58  ColorTable[BackgroundColor].klG = 0;
59  ColorTable[BackgroundColor].klB = 0;
60 
61  ColorTable[HighlightingColor].klR = 255;
62  ColorTable[HighlightingColor].klG = 255;
63  ColorTable[HighlightingColor].klB = 255;
64 
65  ColorTable[MenuTextColor].klR = 175;
66  ColorTable[MenuTextColor].klG = 200;
67  ColorTable[MenuTextColor].klB = 210;
68 
69  ColorTable[MenuTextPrefixColor].klR = 125;
70  ColorTable[MenuTextPrefixColor].klG = 255;
71  ColorTable[MenuTextPrefixColor].klB = 85;
72 
73  ColorTable[MenuSelectedColor].klR = 170;
74  ColorTable[MenuSelectedColor].klG = 210;
75  ColorTable[MenuSelectedColor].klB = 200;
76 
77  ColorTable[MenuSelectedPrefixColor].klR = 240;
78  ColorTable[MenuSelectedPrefixColor].klG = 240;
79  ColorTable[MenuSelectedPrefixColor].klB = 155;
80 
81  ColorTable[MenuHighlightingColor].klR = 50;
82  ColorTable[MenuHighlightingColor].klG = 90;
83  ColorTable[MenuHighlightingColor].klB = 200;
84 
85  ColorTable[PromptTextColor].klR = 255;
86  ColorTable[PromptTextColor].klG = 230;
87  ColorTable[PromptTextColor].klB = 145;
88 
89  ColorTable[MoreTextColor].klR = 220;
90  ColorTable[MoreTextColor].klG = 210;
91  ColorTable[MoreTextColor].klB = 215;
92 
93  ColorTable[CoarseGridColor].klR = 150;
94  ColorTable[CoarseGridColor].klG = 205;
95  ColorTable[CoarseGridColor].klB = 245;
96 
97  ColorTable[FineGridColor].klR = 65;
98  ColorTable[FineGridColor].klG = 125;
99  ColorTable[FineGridColor].klB = 205;
100 
101  ColorTable[InstanceBBColor].klR = 200;
102  ColorTable[InstanceBBColor].klG = 200;
103  ColorTable[InstanceBBColor].klB = 200;
104 
105  ColorTable[InstanceNameColor].klR = 240;
106  ColorTable[InstanceNameColor].klG = 240;
107  ColorTable[InstanceNameColor].klB = 155;
108 
109  ColorTable[ExtraColor1].klR = 255;
110  ColorTable[ExtraColor1].klG = 255;
111  ColorTable[ExtraColor1].klB = 255;
112 
113  ColorTable[DrawingColor].klR = 180;
114  ColorTable[DrawingColor].klG = 60;
115  ColorTable[DrawingColor].klB = 0;
116 
117  ColorTable[ExtraColor2].klR = 255;
118  ColorTable[ExtraColor2].klG = 255;
119  ColorTable[ExtraColor2].klB = 255;
120 
121 
122  if (CDInit()) {
123  /* can't call MallocFailed() yet */
124  fprintf(stderr,"CD memory allocation failure.\n");
125  return (NULL);
126  }
127  Readin();
128  CDSetLayer(1,'S',"CED");
129  }
130 
131  if (!(graph = NewGraph())) {
132  return (NULL);
133  }
134  graph->graphtype = GR_SCED;
135 
136  if (DevNewViewport(graph) == 1) {
137  DestroyGraph(graph->graphid);
138  return (NULL);
139  }
140  /* don't draw until later */
141  graph->redraw = RedisplaySCED;
142 
143  /* remember to pop on leaving sced */
144  PushGraphContext(graph);
145 
146  DevClear();
147 
148  InitParameters();
149  InitSignals();
150  return ((char*)graph);
151 }
152 
153 
154 void
156 
157 {
158  int i;
159  double R,G,B;
160  double M = FBMAXINTENSITY;
161 
162  for (i = 0; i < 16; i++) {
163  R = ColorTable[i].klR/M;
164  G = ColorTable[i].klG/M;
165  B = ColorTable[i].klB/M;
166  DevDefineColor(i,R,G,B);
167  }
168 }
169 
170 
171 void
173 
174 {
175  if (Parameters.kpCellName == NULL) {
193  Parameters.kpNumX = 1;
194  Parameters.kpNumY = 1;
195  Parameters.kpDX = 0;
196  Parameters.kpDY = 0;
198 
199  /*
200  * The fine window has a FIXED width and height.
201  * What should it be?
202  * PointingThreshold is the minimum value of ViewportWidth/WindowWidth
203  * such that it is still comfortable to point with lambda precision.
204  * If PointingThreshold == 7 and FineViewportWidth ~ 467 pixels,
205  * FineWindowWidth ~ 60 lambda.
206  * Most people have prefered 6 or 7.
207  */
209 
210  View = alloc(kv);
211  if (View == NULL) MallocFailed();
212  View->kvFineWindow = alloc(ka);
213  if (View->kvFineWindow == NULL) MallocFailed();
214  View->kvFineViewport = alloc(ka);
215  if (View->kvFineViewport == NULL) MallocFailed();
216  View->kvLargeCoarseViewport = alloc(ka);
217  if (View->kvLargeCoarseViewport == NULL) MallocFailed();
218  View->kvSmallCoarseViewport = alloc(ka);
219  if (View->kvSmallCoarseViewport == NULL) MallocFailed();
220  View->kvCoarseWindow = alloc(ka);
221  if (View->kvCoarseWindow == NULL) MallocFailed();
222 
225  }
226  SCursor.kcX = SCursor.kcPredX = 0;
227  SCursor.kcY = SCursor.kcPredY = 0;
228  /* can start out in FULLSCREEN or SPLITSCREEN mode */
229  View->kvControl = FULLSCREEN;
230  TInit();
231  TStore();
232  InitViewport();
233  DefaultWindows();
234  SQInit();
235 }
236 
237 
238 void
240 
241 {
242  int DefWidth;
243 
245  if (View->kvControl == FULLSCREEN)
246  DefWidth = 100;
247  else
248  DefWidth = 1000;
249  InitCoarseWindow((long)0,(long)0,(long)DefWidth*RESOLUTION);
250 
251  /* default fine window */
252  View->kvFineWindow->kaWidth = View->kvFineViewport->kaWidth/
254 
255  View->kvFineWindow->kaHeight = View->kvFineWindow->kaWidth*
257 
258 
259  SetPositioning();
260  SaveLastView();
261 }
262 
263 
264 void
266 
267 long X,Y,Width;
268 {
269  long diff;
270  int Layer;
271  double Wid2;
272  struct ka *Cw;
273 
274  Wid2 = Width/2;
275  diff = (long)((Wid2*View->kvCoarseViewport->kaHeight)/
276  View->kvCoarseViewport->kaWidth);
277 
278  Cw = View->kvCoarseWindow;
279  Cw->kaX = X;
280  Cw->kaY = Y;
281  Cw->kaLeft = Cw->kaX - Wid2;
282  Cw->kaRight = Cw->kaX + Wid2;
283  Cw->kaBottom = Cw->kaY - diff;
284  Cw->kaTop = Cw->kaY + diff;
285  Cw->kaWidth = Cw->kaRight - Cw->kaLeft;
286  Cw->kaHeight = Cw->kaTop - Cw->kaBottom;
287 
288  View->kvCoarseRatio = View->kvCoarseViewport->kaWidth/Cw->kaWidth;
289 }
290 
291 
292 void
294 
295 long X,Y;
296 {
297  /* Width and height are fixed. */
298  long diff;
299  int Layer;
300  double Wid2;
301  struct ka *Fw;
302 
303  Wid2 = View->kvFineWindow->kaWidth/2;
304  diff = (long)((Wid2*View->kvFineViewport->kaHeight)/
305  View->kvFineViewport->kaWidth);
306 
307  Fw = View->kvFineWindow;
308  Fw->kaX = X;
309  Fw->kaY = Y;
310  Fw->kaLeft = Fw->kaX - Wid2;
311  Fw->kaRight = Fw->kaX + Wid2;
312  Fw->kaBottom = Fw->kaY - diff;
313  Fw->kaTop = Fw->kaY + diff;
314  Fw->kaWidth = Fw->kaRight - Fw->kaLeft;
315  Fw->kaHeight = Fw->kaTop - Fw->kaBottom;
316 
317  View->kvFineRatio = View->kvFineViewport->kaWidth/Fw->kaWidth;
318 }
319 
320 
321 void
323 
324 {
325  long X,Y,Width;
326 
327  if (View->kvControl != FULLSCREEN And
329  /*
330  * Split--enable fine positioning.
331  */
334  }
335  else {
336  /*
337  * Don't split--don't enable fine positioning.
338  */
341  }
342  Width = View->kvCoarseWindow->kaWidth;
343  X = View->kvCoarseWindow->kaX;
344  Y = View->kvCoarseWindow->kaY;
345  InitCoarseWindow(X,Y,Width);
346 
347  /* it is enough to just check the width */
348  if (Width <= View->kvFineWindow->kaWidth) {
349  View->kvFineWindow->kaWidth = Width - Width/4;
350  View->kvFineWindow->kaHeight = View->kvFineWindow->kaWidth*
352  }
353  InitFineWindow(X,Y);
354 }
355 
356 
357 void
359 
360 {
361  struct ka *Vl, *Vs, *Vf;
362 
363  MenuViewport.kaLeft = 1;
365  MenuViewport.kaRight = 11;
366  MenuViewport.kaTop = 1;
367  /* save column width and height in X,Y integer fields */
368  MenuViewport.kaX = 5;
370  MenuViewport.kaTop + 1;
371 
372  /*
373  * The COARSE viewport is LARGE if fine-positioning isn't enabled.
374  * If it is, the LARGE COARSE viewport is split into a SMALL COARSE
375  * viewport and the FINE viewport.
376  */
377  if (View->kvFineViewportOnBottom) {
378 
379  Vl = View->kvLargeCoarseViewport;
381  Vl->kaBottom = 2*gi_fntheight;
382  Vl->kaRight = gi_maxx;
383  Vl->kaTop = gi_maxy;
384  Vl->kaWidth = Vl->kaRight - Vl->kaLeft;
385  Vl->kaHeight = Vl->kaTop - Vl->kaBottom;
386 
387  Vs = View->kvSmallCoarseViewport;
388  Vs->kaLeft = Vl->kaLeft;
389  Vs->kaBottom = Vl->kaBottom + ((Vl->kaTop - Vl->kaBottom)*5)/12;
390  Vs->kaRight = Vl->kaRight;
391  Vs->kaTop = Vl->kaTop;
392  Vs->kaWidth = Vs->kaRight - Vs->kaLeft;
393  Vs->kaHeight = Vs->kaTop - Vs->kaBottom;
394 
395  Vf = View->kvFineViewport;
396  Vf->kaLeft = Vs->kaLeft;
397  Vf->kaBottom = Vl->kaBottom;
398  Vf->kaRight = Vs->kaRight;
399  Vf->kaTop = Vs->kaBottom - 1;
400  Vf->kaWidth = Vf->kaRight - Vf->kaLeft;
401  Vf->kaHeight = Vf->kaTop - Vf->kaBottom;
402  }
403  else {
404 
405  Vl = View->kvLargeCoarseViewport;
407  Vl->kaBottom = 2*gi_fntheight;
408  Vl->kaRight = gi_maxx;
409  Vl->kaTop = gi_maxy;
410  Vl->kaWidth = Vl->kaRight - Vl->kaLeft;
411  Vl->kaHeight = Vl->kaTop - Vl->kaBottom;
412 
413  Vs = View->kvSmallCoarseViewport;
414  Vs->kaLeft = Vl->kaLeft;
415  Vs->kaBottom = Vl->kaBottom;
416  Vs->kaRight = (gi_maxx - Vl->kaLeft)/2 + Vl->kaLeft;
417  Vs->kaTop = Vl->kaTop;
418  Vs->kaWidth = Vs->kaRight - Vs->kaLeft;
419  Vs->kaHeight = Vs->kaTop - Vs->kaBottom;
420 
421  Vf = View->kvFineViewport;
422  Vf->kaLeft = Vs->kaRight + 1;
423  Vf->kaBottom = Vl->kaBottom;
424  Vf->kaRight = Vl->kaRight;
425  Vf->kaTop = Vs->kaTop;
426  Vf->kaWidth = Vf->kaRight - Vf->kaLeft;
427  Vf->kaHeight = Vf->kaTop - Vf->kaBottom;
428  }
429 }
430 
431 
432 void
434 
435 struct ka *Window;
436 {
437  CoarseLToP(Window->kaLeft,Window->kaBottom,CurrentAOI.aLC,CurrentAOI.aBC);
438  CoarseLToP(Window->kaRight,Window->kaTop,CurrentAOI.aRC,CurrentAOI.aTC);
446  }
447  else
449 
450  FineLToP(Window->kaLeft,Window->kaBottom,CurrentAOI.aLF,CurrentAOI.aBF);
451  FineLToP(Window->kaRight,Window->kaTop,CurrentAOI.aRF,CurrentAOI.aTF);
452  if (CurrentAOI.aLF <= View->kvFineViewport->kaRight And
459  }
460  else
462 }
463 
464 
465 void
467 
468 {
469  long L,B,R,T;
470  long X,Y,Width,Height;
471  double Cratio,Vratio;
472 
473  if (Not CDBB(Parameters.kpCellDesc,(struct o *)NULL,&L,&B,&R,&T))
474  MallocFailed();
475  /*
476  * Window cell automatically. How slick.
477  * Leave some white space around the perimeter.
478  * Check for a null (empty) cell.
479  */
480  if (L == R Or B == T Or (L == CDINFINITY And B == CDINFINITY)) {
481  DefaultWindows();
482  return;
483  }
484  Vratio = View->kvCoarseViewport->kaWidth/View->kvCoarseViewport->kaHeight;
485 
486  Width = R - L;
487  Height = T - B;
488  X = L + Width/2;
489  Y = B + Height/2;
490  Cratio = (double) Width/Height;
491 
492  if (Cratio < Vratio)
493  Width = Height*Vratio;
494  else
495  Height = Width/Vratio;
496 
497  InitCoarseWindow(X,Y,Width);
498  L = X - Width/2;
499  R = X + Width/2;
500  B = Y - Height/2;
501  T = Y + Height/2;
502 /*
503  correct_cell_view(&L,&B,&R,&T);
504 */
505 
506  Width = R - L;
507  Height = T - B;
508  X = L + Width/2;
509  Y = B + Height/2;
510  Cratio = (double) Width/Height;
511  if (Cratio > Vratio)
512  Width *= 1.1;
513  else
514  Width = 1.1*Height*Vratio;
515 
516  InitCoarseWindow(X,Y,Width);
517 
518  SetPositioning();
519 }
520 
521 
522 static void
524 
525 /* Take into account labels that may extend beyond geometries. */
526 long *L,*B,*R,*T;
527 {
528  struct g *GenDesc;
529  struct o *Pointer;
530  struct ka LBB;
531  int Info;
532  char Type;
533  long Width,Height;
534 
535  Width = *R - *L;
536  Height = *T - *B;
537  if (Not CDInitGen(Parameters.kpCellDesc,1,*L,*B,
538  *R,*T,&GenDesc)) MallocFailed();
539 
540  loop {
541  CDGen(Parameters.kpCellDesc,GenDesc,&Pointer);
542  if (Pointer == NULL) break;
543 
544  if (Pointer->oType != CDLABEL) continue;
545  if (Pointer->oInfo == SQ_GONE) continue;
546 
547  BBLabel(View->kvCoarseWindow,Pointer,&LBB);
548 
549  if (LBB.kaLeft < *L) {
550  Width *= (double)(LBB.kaRight - LBB.kaLeft)/(LBB.kaRight - *L);
551  *L = *R - Width;
552  }
553  if (LBB.kaRight > *R) {
554  Width *= (double)(LBB.kaRight - LBB.kaLeft)/(*R - LBB.kaLeft);
555  *R = *L + Width;
556  }
557  if (LBB.kaBottom < *B) {
558  Height *= (double)(LBB.kaTop - LBB.kaBottom)/(LBB.kaTop - *B);
559  *B = *T - Height;
560  }
561  if (LBB.kaTop > *T) {
562  Height *= (double)(LBB.kaTop - LBB.kaBottom)/(*T - LBB.kaBottom);
563  *T = *B + Height;
564  }
565  }
566 }
567 
568 
569 void
571 
572 {
573  FILE *fp;
574  int i;
575  char *c;
576  extern char *MenuUPDAT;
577 
578  MenuSelect(MenuUPDAT);
579  fp = fopen(INIT_FILE,"w");
580  if (fp == NULL) {
581  ShowPrompt("Can't open file.");
582  return;
583  }
584  fprintf(fp,"SCED init file\n");
585  for (i = 0; i < 16; i++) {
586  fprintf(fp,"%d %3d %3d %3d\n",i,
587  ColorTable[i].klR,ColorTable[i].klG,ColorTable[i].klB);
588  }
589  fprintf(fp,"%d %d %d %d\n",Parameters.kpGridDisplayed,
593  c = PGetPath();
594  if (c && *c)
595  fprintf(fp,"%s\n",c);
596  fclose(fp);
597  ShowPrompt("Init file has been saved.");
598  MenuDeselect(MenuUPDAT);
599 }
600 
601 
602 void
604 
605 {
606  FILE *fp;
607  int i,d1,d2,d3,d4;
608 
609  fp = POpen(INIT_FILE,"r",(char**)NULL);
610  if (fp == NULL)
611  return;
612  (void)fgets(TypeOut,80,fp);
613  if (TypeOut[0] != 'S'|| TypeOut[1] != 'C')
614  goto error;
615  for (i = 0; i < 16; i++) {
616  if (fscanf(fp,"%d %d %d %d\n",&d1,&d2,&d3,&d4) != 4)
617  goto error;
618  if (d1 < 0 || d1 > 15)
619  goto error;
620  if (d2 < 0 || d2 > 255)
621  goto error;
622  if (d3 < 0 || d3 > 255)
623  goto error;
624  if (d4 < 0 || d4 > 255)
625  goto error;
626  ColorTable[d1].klR = d2;
627  ColorTable[d1].klG = d3;
628  ColorTable[d1].klB = d4;
629  }
630  if (fscanf(fp,"%d %d %d %d\n",&d1,&d2,&d3,&d4) != 4)
631  goto error;
633  Parameters.kpGridOnTop = d2;
636  if (fgets(TypeOut,80,fp) != NULL)
638 error:
639  fclose(fp);
640  return;
641 }
642 
643 
644 void
646 
647 /* Redisplay what is on the screen.
648  * This is called after a resizing, or after the screen has been
649  * seriously messed with. We reinititialize everything, as the
650  * parameters may have changed. RedrawPrompt should take care of
651  * anything on the prompt line, including a return from FBGetchar()
652  * in the DISPLAY mode. KbRepaint() redraws the editing input
653  * if there was any.
654  */
655 GRAPH* graph;
656 {
657  /* establish current graph so default graphic calls will work right */
658  PushGraphContext(graph);
659 
660  DevClear();
661 
662  InitViewport();
664  (long)View->kvCoarseWindow->kaWidth);
666  InitVLT();
667  ShowCommandMenu();
668  if (!RepaintMore())
669  Redisplay(View->kvCoarseWindow);
670  RedrawPrompt();
673  PopGraphContext();
674 }
675 
676 
677 /* ARGSUSED */
678 void
680 
681 GRAPH* graph;
682 {
683  /* do nothing */
684 }
685 
686 
687 
688 /********************************************************************
689  *
690  * Some rendering interfaces
691  *
692  ********************************************************************/
693 
694 #ifdef __STDC__
695 static void ghost_line(int,int,int,int);
696 static void ghost_line_snap(int,int,int,int);
697 static void ghost_box(int,int,int,int);
698 static void ghost_box_snap(int,int,int,int);
699 static void ghost_wires(int,int,int,int);
700 static void ghost_move(int,int,int,int);
701 static void ghost_place(int,int,int,int);
702 #else
703 static void ghost_line();
704 static void ghost_line_snap();
705 static void ghost_box();
706 static void ghost_box_snap();
707 static void ghost_wires();
708 static void ghost_move();
709 static void ghost_place();
710 #endif
711 
712 
713 
714 short
715 FBGetchar(DisplayOrErase)
716 
717 int DisplayOrErase;
718 {
719  int x,y;
720  short c;
721  char s[2];
722 
723  if (DisplayOrErase == ERASE)
724  return ((short)DevGetchar(NULL));
725 
729  KbCursor(x,y);
730  c = (short)DevGetchar(NULL);
731  s[0] = (char)(c & 0xff);
732  s[1] = '\0';
734  DevText(s,x,y);
735  AppendToOldPrompt(s[0]);
737  KbCursor(x,y);
738  return (c);
739 }
740 
741 
742 char *
743 FBEdit(string)
744 
745 char *string;
746 {
747  int x,y;
748 
751  return (KbEdit(string,x,y,BackgroundColor,PromptTextColor,
753 }
754 
755 
756 struct hprlist *
757 FBHyEdit(htxt)
758 
759 struct hprlist *htxt;
760 {
761  int x,y;
762 
765  return (HYedit(htxt,x,y,BackgroundColor,PromptTextColor,
767 }
768 
769 
770 void
771 FBText(Mode,RowOrX,ColumnOrY,String)
772 
773 char Mode;
774 int RowOrX,ColumnOrY;
775 char *String;
776 {
777  int i;
778  if(Mode == ROW_COLUMN) {
779  i = gi_maxy - RowOrX * gi_fntheight;
780  RowOrX = (ColumnOrY - 1) * gi_fntwidth;
781  ColumnOrY = i;
782  }
783  DevText(String,RowOrX,ColumnOrY);
784 }
785 
786 
787 void
788 FBPolygon(Pixel,Type,xy,n)
789 
790 long *xy;
791 int Pixel,n;
792 char Type;
793 {
794  /*
795  * Type == FILL means fill
796  * Type == OUTLINE means outline
797  */
798  int j,n2,X,Y,Z,T;
799  POLYGON poly;
800 
801  DevSetColor(Pixel);
802 
803  poly.xy = xy;
804  while (NextPolygon(&poly)) {
805  n = poly.nvertices;
806 
807  if (Type == OUTLINE) {
808  n2 = n + n;
809  j = 2;
810  X = xy[0];
811  Y = xy[1];
812  while (j < n2) {
813  Z = xy[j++];
814  T = xy[j++];
815  DevLine(X,Y,Z,T);
816  X = Z;
817  Y = T;
818  }
819  }
820  else {
821  if (n < 2) return;
822  DevPolygon(&poly);
823  }
824  }
825 }
826 
827 
828 void
829 FBPolygonClip(coord,n,window)
830 
831 long *coord;
832 int *n;
833 struct ka *window;
834 {
835  POLYGON poly;
836 
837  poly.nvertices = *n;
838  if (*n < 3) return;
839  poly.xy = coord;
840  PolygonClip(&poly,window->kaLeft,window->kaBottom,
841  window->kaRight,window->kaTop);
842 }
843 
844 
845 /* Warning: 16 bit ints will not work below */
846 void
848 
849 /* if mode is lower case will clip to grid point */
850 char mode;
851 {
852  /* need some hokum for button 3 box */
853 #ifdef __STDC__
854  static void (*func)(int,int,int,int);
855 #else
856  static void (*func)();
857 #endif
858  static int X, Y;
859  static int lastR;
860 
861  switch (mode) {
862  case 'l':
864  X = (int)SCursor.kcX;
865  Y = (int)SCursor.kcY;
866  DevSetGhost(func,X,Y);
867  return;
868 
869  case 'L':
870  func = ghost_line;
871  X = (int)SCursor.kcRawX;
872  Y = (int)SCursor.kcRawY;
873  DevSetGhost(func,X,Y);
874  return;
875 
876  case 'r':
878  X = (int)SCursor.kcX;
879  Y = (int)SCursor.kcY;
880  DevSetGhost(func,X,Y);
881  return;
882 
883  case 'R':
884  if (func) {
885  lastR = True;
887  (int)SCursor.kcRawX,(int)SCursor.kcRawY);
888  return;
889  }
890  func = ghost_box;
891  X = (int)SCursor.kcRawX;
892  Y = (int)SCursor.kcRawY;
893  DevSetGhost(func,X,Y);
894  return;
895 
896  case 's':
897  func = ghost_wires;
898  X = (int)SCursor.kcX;
899  Y = (int)SCursor.kcY;
900  DevSetGhost(func,X,Y);
901  return;
902 
903  case 'm':
904  func = ghost_move;
905  X = (int)SCursor.kcX;
906  Y = (int)SCursor.kcY;
907  DevSetGhost(func,X,Y);
908  return;
909 
910  case 'p':
911  func = ghost_place;
912  X = (int)SCursor.kcX;
913  Y = (int)SCursor.kcY;
914  DevSetGhost(func,X,Y);
915  return;
916 
917  case 0:
918  if (lastR) {
919  DevSetGhost(func,X,Y);
920  }
921  else {
922  DevSetGhost(NULL,0,0);
923 #ifdef __STDC__
924  func = (void(*)(int,int,int,int))NULL;
925 #else
926  func = (void(*)())NULL;
927 #endif
928  }
929  lastR = False;
930  return;
931  }
932 }
933 
934 
935 static void
936 ghost_line(x,y,refx,refy)
937 
938 int x, y, refx, refy;
939 {
940  if (!get_window_coords((long*)&x,(long*)&y,False))
941  return;
942  ShowLine(HighlightingColor,refx,refy,x,y);
944 }
945 
946 
947 static void
948 ghost_line_snap(x,y,refx,refy)
949 
950 int x, y, refx, refy;
951 {
952  if (!get_window_coords((long*)&x,(long*)&y,True))
953  return;
954  ShowLine(HighlightingColor,refx,refy,x,y);
956 }
957 
958 
959 static void
960 ghost_box(x,y,refx,refy)
961 
962 int x, y, refx, refy;
963 {
964  struct ka BB;
965 
966  if (!get_window_coords((long*)&x,(long*)&y,False))
967  return;
968  BB.kaLeft = refx;
969  BB.kaBottom = refy;
970  BB.kaRight = x;
971  BB.kaTop = y;
974 }
975 
976 
977 static void
978 ghost_box_snap(x,y,refx,refy)
979 
980 int x, y, refx, refy;
981 {
982  struct ka BB;
983 
984  if (!get_window_coords((long*)&x,(long*)&y,True))
985  return;
986  BB.kaLeft = refx;
987  BB.kaBottom = refy;
988  BB.kaRight = x;
989  BB.kaTop = y;
992 }
993 
994 
995 static void
996 ghost_wires(x,y,refx,refy)
997 
998 int x, y, refx, refy;
999 {
1000  if (!get_window_coords((long*)&x,(long*)&y,True))
1001  return;
1002  ShowStretch(x,y,refx,refy);
1004 }
1005 
1006 
1007 static void
1008 ghost_move(x,y,refx,refy)
1009 
1010 int x, y, refx, refy;
1011 {
1012  if (!get_window_coords((long*)&x,(long*)&y,True))
1013  return;
1014  ShowGhost(x,y,refx,refy);
1016 }
1017 
1018 
1019 static void
1020 ghost_place(x,y,refx,refy)
1021 
1022 int x, y, refx, refy;
1023 {
1024  if (!get_window_coords((long*)&x,(long*)&y,True))
1025  return;
1026  ShowNewInstance(x,y,refx,refy);
1028 }
1029 
1030 
1031 static int
1033 
1034 /* replace X,Y (in pixel coords) with the window coords if pointing
1035  * in the Coarse or Fine viewports, and return True. Otherwise
1036  * return False. Clip to grid if Clip is True.
1037  */
1038 long *X,*Y;
1039 int Clip;
1040 {
1041  if (InBox(*X,*Y,View->kvCoarseViewport)) {
1042  PToL(View->kvCoarseWindow,X,Y);
1043  if (Clip)
1044  ClipToGridPoint(X,Y);
1045  return (True);
1046  }
1047  if (InBox(*X,*Y,View->kvFineViewport)) {
1048  PToL(View->kvFineWindow,X,Y);
1049  if (Clip)
1050  ClipToGridPoint(X,Y);
1051  return (True);
1052  }
1053  return (False);
1054 }
char * FBEdit(char *string)
Definition: init.c:743
long aTF
Definition: sced.h:121
void InitParameters()
Definition: init.c:172
#define PromptTextColor
Definition: sced.h:80
int kvFineViewportOnBottom
Definition: sced.h:156
static void correct_cell_view()
long kaY
Definition: sced.h:113
#define loop
Definition: cdmacs.h:11
void DevDefineColor()
void Redisplay()
int struct o * Pointer
Definition: cd.c:1311
int kpPointingThreshold
Definition: sced.h:279
char kvControl
Definition: sced.h:157
#define Or
Definition: cdmacs.h:15
#define SPLITSCREEN
Definition: sced.h:48
#define SQ_GONE
Definition: sced.h:347
long kcRawY
Definition: sced.h:103
struct ka * kvCoarseWindow
Definition: sced.h:149
void ShowStretch()
int kpModified
Definition: sced.h:261
long kaRight
Definition: sced.h:112
struct ka * kvSmallCoarseViewport
Definition: sced.h:152
#define CDINFINITY
Definition: cddefs.h:70
void PToL()
long * xy
Definition: plotdev.h:16
long kcRawX
Definition: sced.h:103
void SetPositioning()
Definition: init.c:322
void CDSetLayer()
struct kv * View
Definition: init.c:17
#define InstanceBBColor
Definition: sced.h:84
Definition: cddefs.h:119
#define INIT_FILE
Definition: sced.h:25
double kvFineRatio
Definition: sced.h:154
void DevSetColor()
char oType
Definition: cddefs.h:148
long kaBottom
Definition: sced.h:112
double kvCoarseRatio
Definition: sced.h:155
#define COARSEVIEWPORTONLY
Definition: sced.h:51
void DevText()
#define ERASE
Definition: scedmacs.h:11
#define Not
Definition: cdmacs.h:16
struct s * kpCellDesc
Definition: sced.h:207
static void ghost_box_snap()
long aBF
Definition: sced.h:121
char * kpCellName
Definition: sced.h:210
#define CoarseGridColor
Definition: sced.h:82
static void ghost_line_snap()
#define ExtraColor2
Definition: sced.h:88
#define InstanceNameColor
Definition: sced.h:85
long aTC
Definition: sced.h:122
#define FineLToP(X, Y, XT, YT)
Definition: sced.h:379
#define FineGridColor
Definition: sced.h:83
void BBLabel()
char * malloc()
#define DrawingColor
Definition: sced.h:87
struct kc SCursor
Definition: init.c:21
struct s * kpTopDesc
Definition: sced.h:213
void CDGen()
void ShowNewInstance()
int InBox()
Definition: sced.h:111
int kpGridDisplayed
Definition: sced.h:240
#define MenuSelectedColor
Definition: sced.h:77
char kpRedisplayControl
Definition: sced.h:312
void RedrawPrompt()
Definition: viewport.c:512
long aLC
Definition: sced.h:122
void Readin()
Definition: init.c:603
long kcY
Definition: sced.h:102
void RedisplaySCED(GRAPH *graph)
Definition: init.c:645
int DevNewViewport()
#define L
Definition: parse.c:442
struct ka * kvFineViewport
Definition: sced.h:148
Definition: sced.h:193
void DevClear()
Definition: display.c:234
void KbRepaint()
#define alloc(type)
Definition: cdmacs.h:21
struct ka * kvLargeCoarseViewport
Definition: sced.h:151
char * Init()
Definition: init.c:35
double kpDY
Definition: sced.h:228
int nvertices
Definition: plotdev.h:15
Definition: plotdev.h:14
int kpGridLineStyle
Definition: sced.h:237
#define gi_fntheight
Definition: scedmacs.h:57
void TInit()
Definition: xforms.c:23
char TypeOut[200]
Definition: init.c:23
void InitFineWindow(long X, long Y)
Definition: init.c:293
void ShowGhost()
void ShowCommandMenu()
Definition: viewport.c:121
void KbCursor()
#define GR_SCED
Definition: ftegraph.h:23
int CDInit()
Definition: cd.c:114
long aLF
Definition: sced.h:121
void TStore()
Definition: xforms.c:331
void MallocFailed()
Definition: scedintr.c:857
Definition: sced.h:204
#define CDSYMBOLCALL
Definition: cddefs.h:43
char * kpCommand
Definition: sced.h:219
long X
Definition: actions.c:450
int klR
Definition: sced.h:95
Definition: sced.h:101
Definition: sced.h:146
struct hprlist * FBHyEdit(struct hprlist *htxt)
Definition: init.c:757
struct kp Parameters
Definition: init.c:19
void MenuDeselect()
#define G
Definition: parse.c:441
void InitVLT()
Definition: init.c:155
int kpShowGridInLargeViewport
Definition: sced.h:246
#define gi_maxx
Definition: scedmacs.h:58
#define OUTLINE
Definition: scedmacs.h:14
Definition: sced.h:94
int CDInitGen()
#define R
Definition: parse.c:444
void InitViewport()
Definition: init.c:358
#define ROW_COLUMN
Definition: scedmacs.h:15
void PushGraphContext()
#define NULL
Definition: spdefs.h:121
int graphtype
Definition: ftegraph.h:31
int graphid
Definition: ftegraph.h:30
void FBPolygonClip(long *coord, int *n, struct ka *window)
Definition: init.c:829
void ResizeSCED(GRAPH *graph)
Definition: init.c:679
#define CDROUNDFLASH
Definition: cddefs.h:45
struct ka * kvCoarseViewport
Definition: sced.h:150
int aInFine
Definition: sced.h:123
#define MenuHighlightingColor
Definition: sced.h:79
static int get_window_coords()
long kaTop
Definition: sced.h:112
void ShowEmptyBox()
struct ka * kvFineWindow
Definition: sced.h:147
Definition: sced.h:120
#define True
Definition: scedstub.c:16
#define ExtraColor1
Definition: sced.h:86
char * MenuUPDAT
Definition: scedintr.c:109
short FBGetchar(int DisplayOrErase)
Definition: init.c:715
long kcPredY
Definition: sced.h:102
Definition: ftegraph.h:29
int kpNumY
Definition: sced.h:226
char * kpTopName
Definition: sced.h:216
void DevLine()
void FBPolygon(int Pixel, char Type, long *xy, int n)
Definition: init.c:788
long aRC
Definition: sced.h:122
#define RESOLUTION
Definition: sced.h:36
double kaHeight
Definition: sced.h:114
static void ghost_place()
static double c
Definition: vectors.c:16
void CenterFullView()
Definition: init.c:466
#define FULLSCREEN
Definition: sced.h:49
char * KbEdit(char *s, int x, int y, int bg, int fg, int cc)
Definition: main.c:280
int kpRotationAngle
Definition: sced.h:282
void DevSetGhost()
void ClipToGridPoint()
int NextPolygon(POLYGON *p)
Definition: polyclip.c:135
long kaLeft
Definition: sced.h:112
Definition: cddefs.h:142
int RepaintMore()
Definition: moretext.c:222
struct hprlist * HYedit()
struct kl * ColorTable
Definition: init.c:20
#define MenuSelectedPrefixColor
Definition: sced.h:78
Definition: fteparse.h:37
void SetCDPath()
void PopGraphContext()
Definition: graphdb.c:270
int DestroyGraph()
int DevGetchar()
void SaveLastView()
Definition: display.c:297
int Layer
Definition: cd.c:1908
void SQInit()
Definition: choose.c:682
#define MenuTextColor
Definition: sced.h:75
static void ghost_box()
#define CDWIRE
Definition: cddefs.h:47
void SetCurrentAOI(struct ka *Window)
Definition: init.c:433
int klB
Definition: sced.h:95
int kpEnableSelectQRedisplay
Definition: sced.h:249
long aBC
Definition: sced.h:122
#define MenuTextPrefixColor
Definition: sced.h:76
#define CoarseLToP(X, Y, XT, YT)
Definition: sced.h:373
#define EOS
Definition: cdmacs.h:9
static void ghost_line()
long kcX
Definition: sced.h:102
void FBText(char Mode, int RowOrX, int ColumnOrY, char *String)
Definition: init.c:771
int kpNumX
Definition: sced.h:225
#define FBMAXINTENSITY
Definition: scedmacs.h:48
#define ClipVP(Viewport, X, Y)
Definition: sced.h:385
#define And
Definition: cdmacs.h:14
long kpGrid
Definition: sced.h:234
struct ka MenuViewport
Definition: init.c:18
int klG
Definition: sced.h:95
double kpDX
Definition: sced.h:227
static void ghost_move()
#define gi_fntwidth
Definition: scedmacs.h:56
int CDBB()
#define BackgroundColor
Definition: sced.h:73
void ShowLine()
long kcPredX
Definition: sced.h:102
Definition: cddefs.h:227
#define gi_numtextrows
Definition: scedmacs.h:60
struct a CurrentAOI
Definition: init.c:22
double kaWidth
Definition: sced.h:114
void(* redraw)()
Definition: ftegraph.h:70
int kpCursorShape
Definition: sced.h:296
int char Type
Definition: actions.c:449
int kpGridOnTop
Definition: sced.h:243
#define False
Definition: scedstub.c:15
#define MoreTextColor
Definition: sced.h:81
char * PGetPath()
Definition: paths.c:67
void DefaultWindows()
Definition: init.c:239
static void ghost_wires()
void FBSetRubberBanding(char mode)
Definition: init.c:847
int kpLastCursorColumn
Definition: sced.h:293
long aRF
Definition: sced.h:121
FILE * POpen()
void InitCoarseWindow(long X, long Y, long Width)
Definition: init.c:265
void InitSignals()
Definition: scedintr.c:845
void UpdateSCED()
Definition: init.c:570
void MenuSelect()
long Y
Definition: actions.c:450
void ShowPrompt(char *str)
Definition: scedstub.c:71
#define CDPOLYGON
Definition: cddefs.h:44
short oInfo
Definition: cddefs.h:147
void PolygonClip(POLYGON *poly, long left, long bottom, long right, long top)
Definition: polyclip.c:71
GRAPH * NewGraph()
Definition: graphdb.c:59
char kpSelectTypes[8]
Definition: sced.h:273
#define HighlightingColor
Definition: sced.h:74
#define CDLABEL
Definition: cddefs.h:46
long kaX
Definition: sced.h:113
#define gi_maxy
Definition: scedmacs.h:59
void AppendToOldPrompt()
void DevPolygon()
int aInCoarse
Definition: sced.h:124
#define CDBOX
Definition: cddefs.h:48