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

Go to the source code of this file.

Functions

static void redisplay_label ()
 
static void delete_label ()
 
static char get_current_xform ()
 
void Label (int *LookedAhead)
 
void BBLabel (struct ka *Window, struct o *Pointer, struct ka *BB)
 
void CDLabelBB (struct o *Pointer, long *L, long *B, long *R, long *T)
 
void ShowLabel (int Color, char *Label, long X, long Y, char Xform, int Flag)
 
static void redisplay_label (struct o *Pointer)
 
static void delete_label (struct o *Pointer)
 
char SetXform (long *TF)
 

Variables

char * MenuLABEL
 
char * MenuUNDO
 

Function Documentation

void BBLabel ( struct ka Window,
struct o Pointer,
struct ka BB 
)

Definition at line 87 of file labels.c.

93 {
94  struct la *LDesc;
95  long Len,Hei;
96  char Xform;
97 
98  LDesc = (struct la *)Pointer->oRep;
99  Xform = LDesc->laXform;
100  ScaledTextBB(LDesc->laLabel,&Len,&Hei);
101 
105  }
106  if (Window == View->kvCoarseWindow) {
107  Len /= View->kvCoarseRatio;
108  Hei /= View->kvCoarseRatio;
109  }
110  else {
111  Len /= View->kvFineRatio;
112  Hei /= View->kvFineRatio;
113  }
114  BB->kaLeft = LDesc->laX;
115  BB->kaBottom = LDesc->laY;
116 
117  if (Xform & 1) {
118  if (Xform & 2) {
119  if (!(Xform & 4))
120  BB->kaBottom -= Len;
121  if (Xform & 8)
122  BB->kaLeft -= Hei;
123  }
124  else {
125  if (!(Xform & 8))
126  BB->kaLeft -= Hei;
127  if (Xform & 4)
128  BB->kaBottom -= Len;
129  }
130  BB->kaRight = BB->kaLeft + Hei;
131  BB->kaTop = BB->kaBottom + Len;
132  }
133  else {
134  if (Xform & 2) {
135  if (!(Xform & 8))
136  BB->kaLeft -= Len;
137  if (!(Xform & 4))
138  BB->kaBottom -= Hei;
139  }
140  else {
141  if (Xform & 8)
142  BB->kaLeft -= Len;
143  if (Xform & 4)
144  BB->kaBottom -= Hei;
145  }
146  BB->kaRight = BB->kaLeft + Len;
147  BB->kaTop = BB->kaBottom + Hei;
148  }
149 }
long laY
Definition: cddefs.h:202
struct ka * kvCoarseWindow
Definition: sced.h:149
long kaRight
Definition: sced.h:112
double kvFineRatio
Definition: sced.h:154
if(TDesc==NULL)
Definition: cd.c:1326
long kaBottom
Definition: sced.h:112
double kvCoarseRatio
Definition: sced.h:155
int kpHardcopyTextScale
Definition: sced.h:290
int kpDoingHardcopy
Definition: sced.h:287
struct kp Parameters
Definition: init.c:19
long kaTop
Definition: sced.h:112
struct kv * View
Definition: init.c:17
struct o * oRep
Definition: cddefs.h:144
long kaLeft
Definition: sced.h:112
Definition: cddefs.h:201
char laXform
Definition: cddefs.h:204
void ScaledTextBB(char *string, int *wid, int *hei)
Definition: labeltxt.c:144
char * laLabel
Definition: cddefs.h:203
long laX
Definition: cddefs.h:202
void CDLabelBB ( struct o Pointer,
long *  L,
long*  B,
long*  R,
long*  T 
)

Definition at line 153 of file labels.c.

158 {
159  struct ka BB;
160 
161  BBLabel(View->kvCoarseWindow,Pointer,&BB);
162  *L = BB.kaLeft;
163  *B = BB.kaBottom;
164  *R = BB.kaRight;
165  *T = BB.kaTop;
166 }
struct ka * kvCoarseWindow
Definition: sced.h:149
Definition: sced.h:111
#define L
Definition: parse.c:442
void BBLabel(struct ka *Window, struct o *Pointer, struct ka *BB)
Definition: labels.c:87
#define R
Definition: parse.c:444
struct kv * View
Definition: init.c:17
static void delete_label ( )
static
static void delete_label ( struct o Pointer)
static

Definition at line 263 of file labels.c.

266 {
267 
268  struct ka BBC,BBF;
269  char OldRd;
270 
271  if (Pointer->oType != CDLABEL) return;
273 
274  if (OldRd != FINEVIEWPORTONLY) {
276 
277  BBLabel(View->kvCoarseWindow,Pointer,&BBC);
278 
279  TPoint(&BBC.kaLeft,&BBC.kaBottom);
280  TPoint(&BBC.kaRight,&BBC.kaTop);
281 
282  EraseBox(&BBC);
283  }
284  if (OldRd != COARSEVIEWPORTONLY) {
286 
287  BBLabel(View->kvFineWindow,Pointer,&BBF);
288 
289  TPoint(&BBF.kaLeft,&BBF.kaBottom);
290  TPoint(&BBF.kaRight,&BBF.kaTop);
291 
292  EraseBox(&BBF);
293  }
294 
295  CDDelete(Parameters.kpCellDesc,Pointer);
296 
297  if (OldRd != FINEVIEWPORTONLY) {
299  Redisplay(&BBC);
300  }
301  if (OldRd != COARSEVIEWPORTONLY) {
303  Redisplay(&BBF);
304  }
306 }
void TPoint()
void Redisplay()
struct ka * kvCoarseWindow
Definition: sced.h:149
char oType
Definition: cddefs.h:148
#define COARSEVIEWPORTONLY
Definition: sced.h:51
struct s * kpCellDesc
Definition: sced.h:207
#define CDDelete
Definition: cddefs.h:19
Definition: sced.h:111
char kpRedisplayControl
Definition: sced.h:312
#define FINEVIEWPORTONLY
Definition: sced.h:50
void BBLabel(struct ka *Window, struct o *Pointer, struct ka *BB)
Definition: labels.c:87
struct kp Parameters
Definition: init.c:19
struct ka * kvFineWindow
Definition: sced.h:147
struct kv * View
Definition: init.c:17
void EraseBox()
#define CDLABEL
Definition: cddefs.h:46
static char get_current_xform ( )
static

Definition at line 310 of file labels.c.

312 {
313  char c;
314 
315  c = (char)0;
316  c += Parameters.kpRotationAngle/90;
317  if (Parameters.kpMY) c |= 4;
318  if (Parameters.kpMX) c |= 8;
319  return (c);
320 }
int kpMY
Definition: sced.h:284
struct kp Parameters
Definition: init.c:19
static double c
Definition: vectors.c:16
int kpRotationAngle
Definition: sced.h:282
int kpMX
Definition: sced.h:283
void Label ( int *  LookedAhead)

Definition at line 38 of file labels.c.

41 {
42  struct o *Pointer;
43  char *c,*Label = NULL;
44  int NumLabelsMade = 0;
45  long X = 0,Y = 0;
46 
48  ShowPrompt("Enter label: ");
49  Label = FBEdit(NULL);
50  if (Label == NULL Or *Label == '\0')
51  goto quit;
52 
53  for (c = Label; *c; c++)
54  if (isspace(*c)) *c = '_';
55  loop {
56  ShowPrompt("Point to where you want the label.");
57  switch (PointLoop(LookedAhead)) {
58  case PL_ESC:
59  case PL_CMD:
60  goto quit;
61  case PL_UND:
62  if (NumLabelsMade == 0)
63  goto quit;
65  delete_label(Pointer);
66  NumLabelsMade--;
68  continue;
69  case PL_PCW:
70  X = SCursor.kcX;
71  Y = SCursor.kcY;
73  Label,X,Y,get_current_xform(),&Pointer)) MallocFailed();
74  redisplay_label(Pointer);
75  NumLabelsMade++;
76  }
77  }
78 quit:
79  if (NumLabelsMade > 0)
82  ErasePrompt();
83 }
#define PL_ESC
Definition: sced.h:62
void ErasePrompt()
Definition: viewport.c:538
#define loop
Definition: cdmacs.h:11
int struct o * Pointer
Definition: cd.c:1311
#define Or
Definition: cdmacs.h:15
#define PL_UND
Definition: sced.h:63
int kpModified
Definition: sced.h:261
int CDMakeLabel()
int PointLoop()
struct kc SCursor
Definition: init.c:21
struct s * kpCellDesc
Definition: sced.h:207
#define Not
Definition: cdmacs.h:16
#define PL_PCW
Definition: sced.h:65
long kcY
Definition: sced.h:102
static void delete_label()
void MallocFailed()
Definition: scedintr.c:857
static char get_current_xform()
Definition: labels.c:310
long X
Definition: actions.c:450
void MenuDeselect()
#define NULL
Definition: spdefs.h:121
struct kp Parameters
Definition: init.c:19
#define True
Definition: scedstub.c:16
static double c
Definition: vectors.c:16
static void redisplay_label()
char * MenuLABEL
Definition: scedintr.c:84
Definition: cddefs.h:142
void Label(int *LookedAhead)
Definition: labels.c:38
long kcX
Definition: sced.h:102
char * FBEdit()
#define PL_CMD
Definition: sced.h:64
void MenuSelect()
long Y
Definition: actions.c:450
void ShowPrompt(char *str)
Definition: scedstub.c:71
char * MenuUNDO
Definition: scedintr.c:108
static void redisplay_label ( )
static
static void redisplay_label ( struct o Pointer)
static

Definition at line 237 of file labels.c.

240 {
241  struct ka BB;
242  int OldRD;
243 
244  if (Pointer->oType != CDLABEL) return;
245 
247 
248  if (OldRD != FINEVIEWPORTONLY) {
250  BBLabel(View->kvCoarseWindow,Pointer,&BB);
251  Redisplay(&BB);
252  }
253  if (OldRD != COARSEVIEWPORTONLY) {
255  BBLabel(View->kvFineWindow,Pointer,&BB);
256  Redisplay(&BB);
257  }
259 }
void Redisplay()
struct ka * kvCoarseWindow
Definition: sced.h:149
char oType
Definition: cddefs.h:148
#define COARSEVIEWPORTONLY
Definition: sced.h:51
Definition: sced.h:111
char kpRedisplayControl
Definition: sced.h:312
#define FINEVIEWPORTONLY
Definition: sced.h:50
void BBLabel(struct ka *Window, struct o *Pointer, struct ka *BB)
Definition: labels.c:87
struct kp Parameters
Definition: init.c:19
struct ka * kvFineWindow
Definition: sced.h:147
struct kv * View
Definition: init.c:17
#define CDLABEL
Definition: cddefs.h:46
char SetXform ( long *  TF)

Definition at line 324 of file labels.c.

327 {
328  long A,B,C,D;
329 
330  /*
331  * Take the transformation defined in TF and set
332  * the returned bit field accordingly.
333  *
334  * | a c 0 |
335  * Transform = TM = | b d 0 |
336  * | TX TY 1 |
337  *
338  * A = TM[0][0] = TF[0];
339  * B = TM[1][0] = TF[3];
340  * C = TM[0][1] = TF[1];
341  * D = TM[1][1] = TF[4];
342  * TX = TM[2][0] = TF[6];
343  * TY = TM[2][1] = TF[7];
344  */
345 
346  A = TF[0]; B = TF[3]; C = TF[1]; D = TF[4];
347 
348  if (A == 0 && D == 0) {
349  if (B == 1 && C == 1) /* MX R 0 -1 */
350  return (11);
351 
352  if (B == -1 && C == -1) /* MX R 0 1 */
353  return (9);
354 
355  if (B == 1 && C == -1) /* R 0 -1 */
356  return (3);
357 
358  if (B == -1 && C == 1) /* R 0 1 */
359  return (1);
360  }
361  if (B == 0 && C == 0) {
362 
363  if (A == 1 && D == 1) /* translate only */
364  return (0);
365 
366  if (A == -1 && D == -1) /* R -1 0 */
367  return (2);
368 
369  if (A == -1 && D == 1) /* MX */
370  return (8);
371  }
372 
373  /* MY */
374  return (4);
375 }
#define TF
Definition: ifeval.c:65
void ShowLabel ( int  Color,
char *  Label,
long  X,
long  Y,
char  Xform,
int  Flag 
)

Definition at line 170 of file labels.c.

177 {
178 
179  long TF[9],XT,YT;
180  char *c;
181 
182  TPoint(&X,&Y);
183 
184  /* have to fix transform */
185  TPush();
186  TIdentity();
187  if (Xform & 4) TMY();
188  if (Xform & 8) TMX();
189  Xform &= 3;
190  if (Xform != 0) {
191  if (Xform == 1) TRotate(0L,1L);
192  elif (Xform == 2) TRotate(-1L,0L);
193  elif (Xform == 3) TRotate(0L,-1L);
194  }
195  TPremultiply();
196  TCurrent(TF);
197  Xform = SetXform(TF);
198  TPop();
199 
201  c = TypeOut;
202  while ((c = strchr(c,'_')) != NULL) *c = ' ';
203 
205  if ((Flag Or 1/View->kvCoarseRatio < HALFRESOLUTION) And
206  Parameters.kpRedisplayControl != FINEVIEWPORTONLY) {
207 
208  CoarseLToP(X,Y,XT,YT);
213  (int)View->kvCoarseViewport->kaTop);
214 
216  ScaledText(TypeOut,(int)XT,(int)YT,Xform,
218  else
219  ScaledText(TypeOut,(int)XT,(int)YT,Xform,1);
220  }
222 
223  FineLToP(X,Y,XT,YT);
225  (int)View->kvFineViewport->kaLeft,
227  (int)View->kvFineViewport->kaRight,
228  (int)View->kvFineViewport->kaTop);
229 
230  ScaledText(TypeOut,(int)XT,(int)YT,Xform,1);
231  }
233 }
#define TF
Definition: ifeval.c:65
void TPoint()
#define HALFRESOLUTION
Definition: sced.h:37
#define Or
Definition: cdmacs.h:15
int ScaledText(char *text, int x, int y, int degrees, int scale)
Definition: labeltxt.c:160
long kaRight
Definition: sced.h:112
char * strcpy()
void SetScaledTextClip(int xl, int yl, int xu, int yu)
Definition: labeltxt.c:131
void DevSetColor()
if(TDesc==NULL)
Definition: cd.c:1326
long kaBottom
Definition: sced.h:112
#define COARSEVIEWPORTONLY
Definition: sced.h:51
#define FineLToP(X, Y, XT, YT)
Definition: sced.h:379
void TCurrent()
char kpRedisplayControl
Definition: sced.h:312
#define L
Definition: parse.c:442
struct ka * kvFineViewport
Definition: sced.h:148
int kpHardcopyTextScale
Definition: sced.h:290
#define FINEVIEWPORTONLY
Definition: sced.h:50
long X
Definition: actions.c:450
int kpDoingHardcopy
Definition: sced.h:287
#define gi_maxx
Definition: scedmacs.h:58
#define NULL
Definition: spdefs.h:121
char TypeOut[200]
Definition: init.c:23
struct ka * kvCoarseViewport
Definition: sced.h:150
struct kp Parameters
Definition: init.c:19
void Color()
long kaTop
Definition: sced.h:112
#define elif
Definition: cdmacs.h:10
void TMX()
Definition: xforms.c:112
void TPremultiply()
Definition: xforms.c:216
void TRotate()
struct kv * View
Definition: init.c:17
char SetXform(long *TF)
Definition: labels.c:324
static double c
Definition: vectors.c:16
long kaLeft
Definition: sced.h:112
while(TDesc->tSucc!=NULL)
Definition: cd.c:1335
void Label(int *LookedAhead)
Definition: labels.c:38
#define CoarseLToP(X, Y, XT, YT)
Definition: sced.h:373
#define And
Definition: cdmacs.h:14
void TIdentity()
Definition: xforms.c:189
void TPop()
Definition: xforms.c:64
void TMY()
Definition: xforms.c:104
long Y
Definition: actions.c:450
void TPush()
Definition: xforms.c:53
#define gi_maxy
Definition: scedmacs.h:59

Variable Documentation

char* MenuLABEL

Definition at line 84 of file scedintr.c.

char* MenuUNDO

Definition at line 108 of file scedintr.c.