-
Notifications
You must be signed in to change notification settings - Fork 1
/
diffX.c
137 lines (96 loc) · 3.98 KB
/
diffX.c
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
-------------------------------------------------------------------------
OBJECT NAME: diffX.c
FULL NAME: Plot Graph in X window
ENTRY POINTS: PlotDifference()
STATIC FNS: plotLines()
DESCRIPTION: This is the Expose event procedure to regenerate the
whole image.
INPUT: none
OUTPUT: none
COPYRIGHT: University Corporation for Atmospheric Research, 1992-8
-------------------------------------------------------------------------
*/
#include "define.h"
#include <X11/Xutil.h>
#include <Xm/DrawingA.h>
static int fontOffset;
static void plotDiffLines(PLOT_INFO *plot, XFontStruct *fontInfo);
/* -------------------------------------------------------------------- */
void ResizeDiffWindow(Widget w, XtPointer client, XtPointer call)
{
int n, depth;
Arg args[5];
n = 0;
XtSetArg(args[n], XmNwidth, &diffPlot.x.windowWidth); ++n;
XtSetArg(args[n], XmNheight, &diffPlot.x.windowHeight); ++n;
XtSetArg(args[n], XmNdepth, &depth); ++n;
XtGetValues(diffPlot.canvas, args, n);
NewPixmap(&diffPlot, diffPlot.x.windowWidth, diffPlot.x.windowHeight, depth);
diffPlot.x.HD = (int)(diffPlot.x.windowWidth * 0.83);
diffPlot.x.VD = (int)(diffPlot.x.windowHeight * 0.691);
diffPlot.x.LV = (int)(diffPlot.x.windowWidth * 0.104);
diffPlot.x.TH = (int)(diffPlot.x.windowHeight * 0.09);
diffPlot.x.RV = diffPlot.x.LV + diffPlot.x.HD;
diffPlot.x.BH = diffPlot.x.TH + diffPlot.x.VD;
diffPlot.x.ticLength = diffPlot.x.HD > 400 ? 10 : 5;
diffPlot.x.yLabelOffset = 10;
diffPlot.x.yTicLabelOffset = 5;
diffPlot.x.xTicLabelOffset = 20;
diffPlot.x.xLegendText = 55;
fontOffset = (diffPlot.x.windowWidth < 400) ? 1 : 0;
} /* END RESIZEDIFFWINDOW */
/* -------------------------------------------------------------------- */
void PlotDifference(Widget w, XtPointer client,
XmDrawingAreaCallbackStruct *call)
{
XFontStruct *fontInfo;
/* If there are more Expose Events on the queue, then ignore this
* one.
*/
if (diffPlot.windowOpen == false ||
(call && call->event && call->reason == XmCR_EXPOSE && ((XExposeEvent *)call->event)->count > 0))
return;
if (DataChanged)
ComputeDiff();
XSetClipMask(diffPlot.dpy, diffPlot.gc, None);
ClearPixmap(&diffPlot);
XDrawRectangle( diffPlot.dpy, diffPlot.win, diffPlot.gc,
diffPlot.x.LV, diffPlot.x.TH, diffPlot.x.HD, diffPlot.x.VD);
if (dataFile[dataSet[0].fileIndex].ShowPrelimDataWarning ||
dataFile[dataSet[1].fileIndex].ShowPrelimDataWarning)
plotWarningX(&diffPlot, fontOffset);
plotLabelsX(&diffPlot, fontOffset);
fontInfo = diffPlot.fontInfo[3+fontOffset];
XSetFont(diffPlot.dpy, diffPlot.gc, fontInfo->fid);
if (NumberDataFiles > 0 && NumberDataSets >= 2)
{
yTicsLabelsX(&diffPlot, fontInfo, LEFT_SIDE, true);
xTicsLabelsX(&diffPlot, fontInfo, true);
plotDiffLines(&diffPlot, fontInfo);
}
XCopyArea(diffPlot.dpy, diffPlot.win, XtWindow(diffPlot.canvas), diffPlot.gc,
0, 0, diffPlot.x.windowWidth, diffPlot.x.windowHeight, 0, 0);
} /* END PLOTDIFFERENCE */
/* -------------------------------------------------------------------- */
static void plotDiffLines(PLOT_INFO *plot, XFontStruct *fontInfo)
{
if (Color)
{
ResetColors();
XSetForeground(plot->dpy, plot->gc, NextColor());
}
XSetLineAttributes(plot->dpy, plot->gc, LineThickness, LineSolid, CapButt, JoinMiter);
plotTimeSeries(plot, &diffSet, fontInfo);
if (Color)
XSetForeground(plot->dpy, plot->gc, GetColor(0));
snprintf(buffer, BUFFSIZE, "%10.2f%10.2f%10.2f%10.2f%10.2f",
diffSet.stats.mean, diffSet.stats.sigma, diffSet.stats.variance,
diffSet.stats.min, diffSet.stats.max);
XDrawString(plot->dpy, plot->win, plot->gc, plot->x.xLegendText+100,
yLegendX(plot, 0)+3, buffer, strlen(buffer));
strcpy(buffer, " mean sigma var min max");
XDrawString(plot->dpy, plot->win, plot->gc, plot->x.xLegendText+100,
yLegendX(plot, 2)+12, buffer, strlen(buffer));
} /* END PLOTDIFFLINES */
/* END DIFFX.C */