-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharrows.cc
More file actions
95 lines (67 loc) · 2.13 KB
/
arrows.cc
File metadata and controls
95 lines (67 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
-------------------------------------------------------------------------
OBJECT NAME: arrows.c
FULL NAME: Direction Arrows.
ENTRY POINTS: PlotDirectionArrows()
ToggleArrows()
STATIC FNS: none
DESCRIPTION:
COPYRIGHT: University Corporation for Atmospheric Research, 1997-2022
-------------------------------------------------------------------------
*/
#include "define.h"
#include "ps.h"
#include <Xm/TextF.h>
/* -------------------------------------------------------------------- */
void ToggleArrows(Widget w, XtPointer client, XtPointer call)
{
char *p = XmTextFieldGetString(w);
nDirectionArrows = atoi(p);
XtFree(p);
DrawMainWindow();
} /* END TOGGLEARROWS */
/* -------------------------------------------------------------------- */
void PlotDirectionArrow(PLOT_INFO *plot, int x, int y, int x2, int y2, FILE *fp)
{
float theta;
int x3, y3, x4, y4;
if (fp) /* PostScript */
{
fprintf(fp, "gsave\n");
if (printerSetup.color)
fprintf(fp, "stroke 0 0 0 setrgbcolor\n");
else
fprintf(fp, "stroke [] 0 setdash\n");
x2 = x2 - x;
y2 = y2 - y;
theta = atan2(y2, x2);
x3 = 12; y3 = 12;
x4 = (int)(x3 * cos(theta) - y3 * sin(theta));
y4 = (int)(x3 * sin(theta) + y3 * cos(theta));
fprintf(fp, moveto, x+x4, y+y4);
fprintf(fp, lineto, x, y);
y3 = -12;
x4 = (int)(x3 * cos(theta) - y3 * sin(theta));
y4 = (int)(x3 * sin(theta) + y3 * cos(theta));
fprintf(fp, lineto, x+x4, y+y4);
fprintf(fp, moveto, x, y);
fprintf(fp, "stroke grestore\n");
}
else
{
XSetForeground(plot->dpy, plot->gc, GetColor(0));
x2 = x2 - x;
y2 = y - y2;
theta = atan2(y2, x2);
x3 = 6; y3 = 6;
x4 = (int)(x3 * cos(theta) - y3 * sin(theta));
y4 = (int)(x3 * sin(theta) + y3 * cos(theta));
XDrawLine(plot->dpy, plot->win, plot->gc, x, y, x+x4, y-y4);
y3 = -6;
x4 = (int)(x3 * cos(theta) - y3 * sin(theta));
y4 = (int)(x3 * sin(theta) + y3 * cos(theta));
XDrawLine(plot->dpy, plot->win, plot->gc, x, y, x+x4, y-y4);
XSetForeground(plot->dpy, plot->gc, CurrentColor());
}
} /* END PLOTDIRECTIONARROWS */
/* END ARROWS.C */