-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathAmrPicture.H
177 lines (158 loc) · 6.56 KB
/
AmrPicture.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
// ---------------------------------------------------------------
// AmrPicture.H
// ---------------------------------------------------------------
#ifndef _AMRPICTURE_H
#define _AMRPICTURE_H
#include <cstdio>
#include <AMReX_REAL.H>
#include <AMReX_Box.H>
#include <AMReX_AmrvisConstants.H>
#include <GlobalUtilities.H>
#include <GridPicture.H>
#include <AMReX_Array.H>
#include <AMReX_FArrayBox.H>
#include <AMReX_DataServices.H>
#include <string>
using std::string;
using amrex::Real;
#include <X11/X.h>
#include <X11/Intrinsic.h>
class PltApp;
class PltAppState;
class GraphicsAttributes;
class Palette;
struct GridBoxes {
int xbox, ybox, wbox, hbox;
};
enum VectorDerived { enVelocity, enMomentum, enNoneFound };
class AmrPicture {
public:
AmrPicture(GraphicsAttributes *gaptr,
PltApp *pltappptr, PltAppState *pltappstateptr,
amrex::DataServices *dataservicesptr,
bool bcartgridsmoothing);
// construct an AmrPicture using data from filename
// 3D: called by first XY view
AmrPicture(int view,
GraphicsAttributes *gaptr, const amrex::Box ®ion,
PltApp *parentPltAppPtr, PltApp *pltappptr,
PltAppState *pltappstateptr,
bool bcartgridsmoothing);
// construct an AmrPicture using pointer to data & box
~AmrPicture();
void DoFrameUpdate();
void DoContourSweep();
void DoStop(); // removes TimeOutCallback, updates GridPictures
void SetRegion(int, int, int, int);
void CreatePicture(Window drawPictureHere, Palette *palptr);
void APDraw(int fromLevel, int toLevel);
void DrawSlice(int);
void DoExposePicture();
void APMakeImages(Palette *palptr);
void APChangeScale(int newScale, int previousScale);
void APChangeLevel();
XImage *GetPictureXImage(const bool bdrawboxesintoimage = true);
void APChangeSlice(int here);
void SetSubCut(int, int, int, int);
void ToggleShowSubCut();
void DrawDatasetPoint(int hplot, int vplot, int size);
void UnDrawDatasetPoint();
void Sweep(amrex::Amrvis::AnimDirection direction);
void SetHVLine(int scale);
void SetHLine(int hl) { hLine = hl; }
void SetVLine(int vl) { vLine = vl; }
int GetHLine() const { return hLine; }
int GetVLine() const { return vLine; }
int GetSlice() const { return slice; }
unsigned int ImageSizeH() const { return imageSizeH; }
unsigned int ImageSizeV() const { return imageSizeV; }
void SetDataServicesPtr(amrex::DataServices *tothis) { dataServicesPtr = tothis; }
void SetHColor(int c) { hColor = c; }
void SetVColor(int c) { vColor = c; }
const amrex::Box &GetSliceBox(int level) const { return sliceBox[level]; }
int GetMyView() const { return myView; }
const amrex::Array<amrex::Box> &GetSubDomain() const { return subDomain; }
void SetFrameSpeed(int toThis) { frameSpeed = toThis; }
Window PictureWindow() { return pictureWindow; }
void SetCartGridSmoothing(bool tf) { bCartGridSmoothing = tf; }
void APChangeContour(amrex::Amrvis::ContourType prevCType);
void GetGridBoxes(amrex::Array< amrex::Array<GridBoxes> > &gb,
const int minlev, const int maxlev);
private:
Window pictureWindow;
int numberOfLevels;
amrex::Array<unsigned long> dataSize, dataSizeH, dataSizeV;
unsigned int imageSize, imageSizeH, imageSizeV;
int hdspoint, vdspoint, dsBoxSize;
int datasetPointShowing, datasetPointColor;
Pixmap pixMap;
amrex::Array< amrex::Array<GridPicture> > gpArray;
amrex::Array< amrex::Array< amrex::Array<GridPicture> > > frameGrids;
int regionX, regionY, region2ndX, region2ndY;
int subCutShowing;
int subcutX, subcutY, subcut2ndX, subcut2ndY;
amrex::Array<amrex::Box> subDomain;
amrex::Array<amrex::Box> sliceBox;
amrex::Array<XImage *> frameBuffer;
bool framesMade;
int frameSpeed;
amrex::Amrvis::AnimDirection sweepDirection;
XtIntervalId pendingTimeOut;
Palette *palPtr;
amrex::Array<amrex::FArrayBox *> sliceFab;
amrex::Array<amrex::FArrayBox *> vfSliceFab;
amrex::Array<unsigned char *> imageData, scaledImageData;
amrex::Array<unsigned char> scaledImageDataBodyMask;
amrex::Array<XImage *> xImageArray;
amrex::Array<bool> xImageCreated;
GraphicsAttributes *gaPtr;
PltApp *pltAppPtr;
PltAppState *pltAppStatePtr;
amrex::DataServices *dataServicesPtr;
Display *display;
GC xgc;
int myView, hLine, vLine;
int maxLevelWithGrids;
int hColor, vColor, myColor, slice, sliceDir;
bool bCartGridSmoothing;
bool pixMapCreated, isSubDomain, findSubRange;
amrex::Array< amrex::Array<string> > vecNames;
// private functions
void SetSlice(int view, int here);
void CoarsenSliceBox();
void ShowFrameImage(int iSlice);
void CreateFrames(amrex::Amrvis::AnimDirection direction);
void AmrPictureInit();
void DrawBoxes(amrex::Array< amrex::Array<GridPicture> > &gp, Drawable &drawable);
void DrawTerrBoxes(int level, bool bIsWindow, bool bIsPixmap);
void CreateImage(const amrex::FArrayBox &fab, unsigned char *imagedata,
int datasizeh, int datasizev,
Real globalMin, Real globalMax, Palette *palptr,
const amrex::FArrayBox *vfracFab, const Real vfeps);
void CreateScaledImage(XImage **ximage, int scale,
unsigned char *imagedata,
unsigned char *scaledimagedata,
int datasizeh, int datasizev,
int imagesizeh, int imagesizev, int level,
bool bCreateMask);
void DrawContour(amrex::Array<amrex::FArrayBox *> slicefab, Display *display,
Drawable &drawable, const GC &gc);
bool DrawContour(const amrex::FArrayBox &fab, Real value,
bool has_mask, const bool *mask,
Display *display, Drawable &drawable, const GC &gc, int FGColor,
int xLength, int yLength,
Real leftEdge, Real bottomEdge, Real rightEdge, Real topEdge);
inline bool Between(Real a, Real b, Real c) {
return ( ((a <= b) && (b <= c)) || ((a >= b) && (b >= c)) );
}
void DrawVectorField(Display *display, Drawable &drawable, const GC &gc);
void DrawVectorField(Display *display, Drawable &drawable, const GC &gc,
int hDir, int vDir, int maxLength,
const Real *hdat, const Real *vdat,
const Real velocityMax,
const amrex::Box &dvfSliceBox, int dvfFactor);
VectorDerived FindVectorDerived(amrex::Array<string> &aVectorDeriveNames);
static void CBFrameTimeOut(XtPointer, XtIntervalId *);
static void CBContourSweep(XtPointer, XtIntervalId *);
};
#endif