-
Notifications
You must be signed in to change notification settings - Fork 16
/
XYPlotWin.H
214 lines (182 loc) · 7.19 KB
/
XYPlotWin.H
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// ---------------------------------------------------------------
// XYPlotWin.H
// ---------------------------------------------------------------
#ifndef _XYPLOTWIN_H_
#define _XYPLOTWIN_H_
#include <Xm/Xm.h>
#undef index
#include <list>
using std::list;
#include <AMReX_AmrvisConstants.H>
#include <XYPlotDataList.H>
#include <XYPlotParam.H>
#include <xgout.H>
class PltApp;
class GraphicsAttributes;
class XYPlotParameters;
#define LEFT_CODE 0x01
#define RIGHT_CODE 0x02
#define BOTTOM_CODE 0x04
#define TOP_CODE 0x08
#define BORDER_PADDING 5
#define AXIS_PADDING 5
#define NUM_INIT_XSEGS 1000
#define PADDING 2
#define SPACE 10
#define TICKLENGTH 5
#define MAXLS 50
typedef struct attr_typ {
char lineStyle[MAXLS];
int lineStyleLen;
Pixel pixelValue;
Pixmap markStyle;
} AttrSet;
class XYPlotWin;
typedef void (XYPlotWin::*memberXYCB)(Widget, XtPointer, XtPointer);
typedef struct {
::XYPlotDataList *XYPLIlist;
Widget wid; // For legend item drawingarea
Widget frame; // For drawingarea frame
Widget menu; // Popup menu for this item
bool drawQ;
int style, color;
Pixel pixel;
#if (BL_SPACEDIM == 2)
amrex::Array<::XYPlotDataList *> *anim_lists;
amrex::Array<char> *ready_list;
#endif
} XYPlotLegendItem;
class XYPlotWin {
public:
XYPlotWin(char *title, XtAppContext app, Widget w,
PltApp *parent, int type, int curr_frame = 0);
~XYPlotWin();
void AddDataList(::XYPlotDataList *new_list,
XYPlotLegendItem *insert_after = NULL);
#if (BL_SPACEDIM == 2)
void InitializeAnimation(int curr_frame, int num_frames);
void UpdateFrame(int frame);
void StopAnimation();
#endif
void PopUp() { XtPopup(wXYPlotTopLevel, XtGrabNone); }
void SetPalette();
void DoASCIIDump(FILE *fs, const char *plotname);
private:
XtAppContext appContext;
Widget wTopLevel;
PltApp *pltParent;
char *pltTitle;
XYPlotParameters *parameters;
int whichType;
Widget wXYPlotTopLevel;
GraphicsAttributes *gaPtr;
Display *disp;
Visual *vis;
Cursor cursor, zoomCursor;
XFontStruct *labeltextFont, *titletextFont;
GC titletextGC, labeltextGC, rbGC, segGC, dotGC;
// Other important numbers.
bool zoomedInQ;
XYPlotLegendItem *colorChangeItem;
list<XYPlotLegendItem *> legendList;
unsigned int numDrawnItems, numItems;
unsigned char lineFormats[8];
unsigned int numXsegs;
XSegment *Xsegs[2];
// parameters.
unsigned char markQ, tickQ, axisQ, boundBoxQ;
unsigned char plotLinesQ, saveDefaultQ, dispHintsQ;
bool animatingQ;
unsigned char tbool[7];
int lineW, gridW, dotW;
char *XUnitText, *YUnitText, *formatX, *formatY;
Pixel foregroundPix, backgroundPix, gridPix, textPix;
param_style gridStyle;
AttrSet AllAttrs[8];
xgOut devInfo;
Widget wLegendMenu, wLegendButtons, wPlotWin, wScrollArea;
Widget wOptionsDialog, wExportFileDialog, wOptionsWidgets[13];
Window pWindow;
Atom WM_DELETE_WINDOW;
double dGridBase, dGridStep;
double lloX, lloY, hhiX, hhiY; // Global bounding box of window
double loX, loY, hiX, hiY; // Local bounding box of window
double dUsrOrgX, dUsrOrgY; // Origin of bounding box in user space
double dUsrOppX, dUsrOppY; // Other point of bounding box
double dXUnitsPerPixel; // X Axis scale factor
double dYUnitsPerPixel; // Y Axis scale factor
int iXOrgX, iXOrgY; // Origin of bounding box on screen
int iXOppX, iXOppY; // Other point defining bounding box
int iXLocWinX, iXLocWinY, iCurrHint;
#if (BL_SPACEDIM == 2)
int numFrames;
#endif
int currFrame;
void ReattachLegendFrames();
void DoError(char *error_str) { fprintf(stderr, "%s\n", error_str); }
void AddStaticCallback(Widget w, String cbtype,
memberXYCB cbf, void *data = NULL);
void AddStaticWMCallback(Widget w, Atom cbtype,
memberXYCB cbf, void *data = NULL);
void AddStaticEventHandler(Widget w, EventMask mask,
memberXYCB cbf, void *data = NULL);
static void StaticCallback(Widget, XtPointer, XtPointer);
static void StaticEvent(Widget w, XtPointer client_data,
XEvent *event, char*);
void SetBoundingBox(double lowX = 1.0, double lowY = 1.0,
double highX = 0.0, double highY = 0.0);
void UpdateBoundingBox(::XYPlotDataList *list);
void textX (Widget win, int x, int y, char *text, int just, int style);
void segX(Widget win, int ns, XSegment *segs, int width,
int style, int lappr, Pixel color);
void dotX(Widget win, int x, int y, int style, int color);
double InitGrid(double low, double high, double step);
double roundUp(double val);
void writeValue(char *str, char *fmt, double val, int expv);
void CalculateBox();
void drawGridAndAxis();
void clearData();
void drawData();
void drawHint();
void CBdoInitializeListColorChange(Widget, XtPointer, XtPointer);
void CBdoSetListColor(Widget, XtPointer, XtPointer);
void CBdoExportFileDialog(Widget, XtPointer, XtPointer);
void CBdoExportFile(Widget, XtPointer, XtPointer data);
void CBdoDrawPlot(Widget, XtPointer, XtPointer);
void CBdoRedrawPlot(Widget, XtPointer, XtPointer);
void CBdoDrawLegendItem(Widget, XtPointer data, XtPointer);
void CBdoOptions(Widget, XtPointer, XtPointer);
void CBdoOptionsToggleButton(Widget, XtPointer data, XtPointer);
void CBdoOptionsOKButton(Widget, XtPointer data, XtPointer);
void CBdoSelectDataList(Widget, XtPointer data, XtPointer);
void CBdoClearData(Widget, XtPointer, XtPointer);
void CBdoSelectAllData(Widget, XtPointer, XtPointer);
void CBdoDeselectAllData(Widget, XtPointer, XtPointer);
void CBdoRubberBanding(Widget, XtPointer, XtPointer);
void CBdoSetListLevel(Widget w, XtPointer data, XtPointer);
void CBdoCopyDataList(Widget, XtPointer data, XtPointer);
void CBdoRemoveDataList(Widget, XtPointer data, XtPointer);
void CBdoDrawLocation(Widget, XtPointer, XtPointer);
void CBdoASCIIDump(Widget, XtPointer, XtPointer data);
class XYCBData { // callback data
public:
XYCBData(XYPlotWin *p, void *d, memberXYCB mcb)
: instance(p), data(d), cbFunc(mcb) { }
~XYCBData() { }
XYPlotWin *instance;
void *data;
memberXYCB cbFunc;
};
amrex::Array<XYCBData *> xycbdPtrs;
class XYMenuCBData {
public:
XYMenuCBData(XYPlotLegendItem *_item, int _which)
: item(_item), which(_which) { }
~XYMenuCBData() { }
XYPlotLegendItem *item;
int which;
};
amrex::Array<XYMenuCBData *> xymenucbdPtrs;
};
void CBcloseXYPlotWin(Widget, XtPointer, XtPointer);
#endif