-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisAtomVisualizingPolicy.h
383 lines (324 loc) · 13.1 KB
/
VisAtomVisualizingPolicy.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/* This is a class used for in VisAtom, a visualiztion tool for
atomistic simulations.
AUTHOR: Qing HOU
INSTITUTION: Institute of Nuclear Science and Technology, Sichuan University
HISTROTY: First version: 1998
LAST MODIFICATION: 2013
*/
#ifndef _VISATOMVISUALIZINGPOLICY_H
#define _VISATOMVISUALIZINGPOLICY_H
#include "GlcObj.h"
#include "VisAtomDataSheet.h"
//*********************************************************************
class VisAtomVisualizingPolicy:public GlcObj
{
private:
protected:
//
int m_geomStyle;
//display property of atoms in the subsample
int m_shapeStyle;
float m_radius; //sphere and circle parameter
int m_unifyradiu;
//the static variable used when atoms have variable radiaa
static int m_radcol;
static float m_radscal;
static float*m_raddata;
//static parameter for vectors
//should be the same for all atoms
int m_vectorStyle;
static float m_vlenscal, m_vrad, m_arrowl, m_arrowr; //vector parameter
static int m_vcol[3]; //identification for vector data if has vector
//parameters for coloring
int m_colorStyle; //color style
float m_red, m_green, m_blue, m_alpha; //color parameter for single color
//static color-mapping paramters, should be
//same for all atoms
static int m_scalarcol; //indification for scarlar data, used if using scalar data for coloring
static int m_colormap; //index for color mapping table
static float m_scalarmin, m_scalarmax, m_scalarrange; //
//static float m_wscalarmin, m_wscalarmax, m_wscalarrange; //
static float*m_mappingdata;
static float m_wscalartab[6]; //scalar table mapping to color maping tbale
static VisAtomDataSheet*m_datasheet; //datasheet used for colr mapping
//trajectory style
int m_trajectoryStyle;
float m_tLinethick; //line for drawing trajectory
float m_tRadiusscal; //the scal relative to m_radius for drawing of sites
//projection style
static int m_autoBox;
static float m_projectionBox[6]; //the box on its side faces, the sample would be projected on,
int m_projectionStyle; //the style of projection, determine which side faces the subsample will be projetec on
//3D scene style
int m_3dStyle;
public:
static const int CORLOR_MAP_SIZE = 6;
enum VISATOMGEOMETRYSTYLE
{
GEOM_STYLE_ATOM = 1,
GEOM_STYLE_VECTOR = 2,
GEOM_STYLE_TRAJECT = 4,
GEOM_STYLE_PROJECT = 8,
GEOM_STYLE_3D = 16
};
enum VISATOMGEOMSTYLE
{
SHAPE_STYLE_DOT = 1,
SHAPE_STYLE_LINE = 2,
SHAPE_STYLE_WIRE = 4,
SHAPE_STYLE_SOLID= 8,
SHAPE_STYLE_MASK = 0x0000000F,
};
enum VISATOMCOLORSTYLE
{
COLOR_STYLE_SINGLE = 0,
COLOR_STYLE_MAP = 1
};
enum VISATOMVECTORSTYLE
{
VECTOR_STYLE_ENDATOM = 32, //line vector
VECTOR_STYLE_LINE = 64, //line vector
VECTOR_STYLE_SOLID = 128, //3D vector
VECTOR_STYLE_ARROW = 256, //has arrow
VECTOR_STYLE_MASK = 0x000000F0,
};
enum VISATOMP3DSTYLE
{
D3_STYLE_INBOX = 1048576, //8192*64*2
D3_STYLE_OUTBOX = 1048576 * 2,
D3_STYLE_MASK = D3_STYLE_INBOX + D3_STYLE_OUTBOX,
};
enum VISATOMTRAJECTORYSTYLE
{
TRAJECTORY_STYLE_STARTSITE = 1024, //has start site
TRAJECTORY_STYLE_ENDSITE = 2048, //has endsite
TRAJECTORY_STYLE_HASLINE = 4096, //line
TRAJECTORY_STYLE_HASPOINT = 8192, //line
TRAJECTORY_STYLE_MASK = 0x0000FC00,
};
enum VISATOMPROJECTIONSTYLE
{
PROJECTION_STYLE_X0 = 8192*2,
PROJECTION_STYLE_X1 = 8192*4,
PROJECTION_STYLE_Y0 = 8192*8,
PROJECTION_STYLE_Y1 = 8192*16,
PROJECTION_STYLE_Z0 = 8192*32,
PROJECTION_STYLE_Z1 = 8192*64,
PROJECTION_STYLE_MASK = 8192*(2+4+8+16+32+64),
};
VisAtomVisualizingPolicy();
VisAtomVisualizingPolicy(VisAtomVisualizingPolicy*sor);
~VisAtomVisualizingPolicy();
void Paste(VisAtomVisualizingPolicy*sor);
//********** color functions
void SetColorByDefaultTable(int index);
void SetColor(float R, float G, float B, float A)
{ m_red = R; m_green = G; m_blue = B; m_alpha = A;}
//get color of atoms in single-color style
void GetColor(float&R, float&G, float&B, float&A)
{ R = m_red; G = m_green; B = m_blue; A = m_alpha; return;}
//get color of atoms in mapping-color style
//index : the id of the atom
void GetColor(float&R, float&G, float&B, float&A, int index);
//get color of atoms in mapping-color style, with given scalar data sheet
//index : the id of the atom
static void GetColor(float&R, float&G, float&B, float&A, int index, float*exscalar);
void SetColorStyle(int colorstyle){ m_colorStyle = colorstyle;};
int GetColorStyle(){ return m_colorStyle;};
//size functions for atoms
void SetAtomShapeStyle(int geom){ m_shapeStyle = geom;};
int GetAtomShapeStyle(){ return m_shapeStyle;};
void SetAtomSize(float r){m_radius = r;};
float GetAtomSize(){ return m_radius; };
float GetAtomSize(int i)
{
if(m_unifyradiu) return m_radius;
else return m_raddata[i];
};
void SetAtomHaveUnifiedSize(bool yes){ m_unifyradiu = yes;};
bool IsAtomHaveUnifiedSize(){return m_unifyradiu;};
static void SetAtomSizeCol(int col) { m_radcol = col; m_raddata = m_datasheet->GetData(col);}
static int GetAtomSizeCol() { return m_radcol;}
//*** functions concerning geometry style
int GetGeomStyle()
{ int style = 0;
if(m_geomStyle&GEOM_STYLE_ATOM) style = style|m_shapeStyle;
if(m_geomStyle&GEOM_STYLE_VECTOR) style = style|m_vectorStyle;
if(m_geomStyle&GEOM_STYLE_TRAJECT) style = style|m_trajectoryStyle;
if (m_geomStyle&GEOM_STYLE_PROJECT) style = style|m_projectionStyle;
if (m_geomStyle&GEOM_STYLE_3D) style = style|m_3dStyle;
return style;
};
void SetGeomStyleAtomVisible(bool visible)
{ int style = 0;
//if(m_geomStyle&GEOM_STYLE_VECTOR) style = style| GEOM_STYLE_VECTOR;
//if(visible) style = style | GEOM_STYLE_ATOM;
style = style|(m_geomStyle&GEOM_STYLE_VECTOR);
style = style|(m_geomStyle&GEOM_STYLE_TRAJECT);
style = style|(m_geomStyle&GEOM_STYLE_PROJECT);
style = style|(m_geomStyle&GEOM_STYLE_3D);
if(visible) style = style | GEOM_STYLE_ATOM;
m_geomStyle = style;
}
bool IsGeomStyleAtomVisible(){ return m_geomStyle&GEOM_STYLE_ATOM;}
//vector functions
void SetVectorStyle(int style) { m_vectorStyle = style;}
int GetVectorStyle() { return m_vectorStyle;}
void SetGeomStyleVectorVisible(bool visible)
{ int style = 0;
//if(m_geomStyle&GEOM_STYLE_ATOM) style = style| GEOM_STYLE_ATOM;
//if(visible) style = style | GEOM_STYLE_VECTOR;
style = style|(m_geomStyle&GEOM_STYLE_TRAJECT);
style = style|(m_geomStyle&GEOM_STYLE_ATOM);
style = style|(m_geomStyle&GEOM_STYLE_PROJECT);
style = style|(m_geomStyle&GEOM_STYLE_3D);
if(visible) style = style | GEOM_STYLE_VECTOR;
m_geomStyle = style;
}
bool IsGeomStyleVectorVisible(){return m_geomStyle&GEOM_STYLE_VECTOR;}
//trjectory functions
void SetTrajectoryStyle(int style) { m_trajectoryStyle = style;}
int GetTrajectoryStyle() { return m_trajectoryStyle;}
void SetGeomStyleTrajectoryVisible(bool visible)
{ int style = 0;
style = style|(m_geomStyle&GEOM_STYLE_ATOM);
style = style|(m_geomStyle&GEOM_STYLE_VECTOR);
style = style|(m_geomStyle&GEOM_STYLE_PROJECT);
style = style|(m_geomStyle&GEOM_STYLE_3D);
if(visible) style = style | GEOM_STYLE_TRAJECT;
m_geomStyle = style;
}
bool IsGeomStyleTrajectoryVisible(){return m_geomStyle&GEOM_STYLE_TRAJECT;}
void SetTrajectoryLinethick(float thick){ m_tLinethick = thick;}
float GetTrajectoryLinethick(){ return m_tLinethick;}
void SetTrajectorySitescal(float scal){ m_tRadiusscal = scal;}
float GetTrajectorySitescal(){ return m_tRadiusscal;}
float GetTrajectorySitesize(){ return m_tRadiusscal*m_radius;}
//projecction functions
void SetProjectionStyle(int style) { m_projectionStyle = style;}
int GetProjectionStyle() { return m_projectionStyle;}
void SetGeomStyleProjectionVisible(bool visible)
{ int style = 0;
style = style|(m_geomStyle&GEOM_STYLE_ATOM);
style = style|(m_geomStyle&GEOM_STYLE_VECTOR);
style = style|(m_geomStyle&GEOM_STYLE_TRAJECT);
style = style|(m_geomStyle&GEOM_STYLE_3D);
if(visible) style = style | GEOM_STYLE_PROJECT;
m_geomStyle = style;
}
bool IsGeomStyleProjectionVisible(){return m_geomStyle&GEOM_STYLE_PROJECT;}
//3d functions
void Set3DStyle(int style) { m_3dStyle = style; }
int Get3DStyle() { return m_3dStyle; }
void SetGeomStyle3DVisible(bool visible)
{
int style = 0;
style = style | (m_geomStyle&GEOM_STYLE_ATOM);
style = style | (m_geomStyle&GEOM_STYLE_VECTOR);
style = style | (m_geomStyle&GEOM_STYLE_TRAJECT);
style = style | (m_geomStyle&GEOM_STYLE_PROJECT);
if (visible) style = style | GEOM_STYLE_3D;
m_geomStyle = style;
}
bool IsGeomStyle3DVisible() { return m_geomStyle & GEOM_STYLE_3D; }
//static functions:
static void SetDataSheet(VisAtomDataSheet*datasheet)
{
m_datasheet = datasheet;
if(m_scalarcol >=0 && m_scalarcol < datasheet->GetNumCol()) m_mappingdata = m_datasheet->GetData(m_scalarcol);
else {m_scalarcol = -1; m_mappingdata = NULL;}
if(m_radcol>=0 && m_radcol < datasheet->GetNumCol()) m_raddata = m_datasheet->GetData(m_radcol);
else {m_radcol = -1; m_raddata = NULL;}
}
//static functions concerning color mapping
static void SetScalarCol(int col) {m_scalarcol = col; m_mappingdata = m_datasheet->GetData(m_scalarcol); }
static int GetScalarCol() { return m_scalarcol;}
static void SetScalarRange(float min, float max) { m_scalarmin = min; m_scalarmax = max; m_scalarrange = m_scalarmax - m_scalarmin;}
static void GetScalarRange(float&min, float&max) { min = m_scalarmin; max = m_scalarmax;}
static int GetColorMappingNumBar();
static void GetColorMappingBar(int index, float&R, float&G, float&B);
static void VisAtomVisualizingPolicy::SetScalarMappingTab(int index, float value)
{
VisAtomVisualizingPolicy::m_wscalartab[index] = value;
}
static float VisAtomVisualizingPolicy::GetScalarMappingTabValue(int index)
{
return VisAtomVisualizingPolicy::m_wscalartab[index];
}
static float VisAtomVisualizingPolicy::GetScalarMappingTabMinValue()
{
return VisAtomVisualizingPolicy::m_wscalartab[0];
}
static float VisAtomVisualizingPolicy::GetScalarMappingTabMaxValue()
{
return VisAtomVisualizingPolicy::m_wscalartab[sizeof(m_wscalartab)/sizeof(float)-1];
}
static void SetScalarMappingTab(float smin, float smax);
//static functions concerning vector visualization
static bool HasVectorData()
{
bool yes = false;
if(m_datasheet &&
(m_vcol[0] >= 0 && m_vcol[0] < m_datasheet->GetNumCol()) &&
(m_vcol[1] >= 0 && m_vcol[1] < m_datasheet->GetNumCol()) &&
(m_vcol[2] >= 0 && m_vcol[2] < m_datasheet->GetNumCol()) )
yes = true;
return yes;
}
static void SetVectorCol(int vcol[3])
{
m_vcol[0] = vcol[0];
m_vcol[1] = vcol[1];
m_vcol[2] = vcol[2];
}
static void GetVectorCol(int vcol[3])
{
vcol[0] = m_vcol[0];
vcol[1] = m_vcol[1];
vcol[2] = m_vcol[2];
}
static void SetVectorSize(float vlenscal, float vrad, float arrowl, float arrowr)
{
m_vlenscal = vlenscal;
m_vrad = vrad;
m_arrowl = arrowl;
m_arrowr = arrowr;
}
static void SetVectorSize(float vrad, float vlenscal){ m_vrad = vrad; m_vlenscal = vlenscal;}
static void GetVectorSize(float&vlenscal, float&vrad, float&arrowl, float&arrowr)
{
vlenscal = m_vlenscal;
vrad = m_vrad;
arrowl = m_arrowl;
arrowr = m_arrowr;
}
static void GetVectorSize(float&vrad, float&vlenscal){ vrad = m_vrad; vlenscal = m_vlenscal;}
//static function concerning projection
static int IsAutoProjectionBox()
{
return m_autoBox;
}
static void SetAutoProjectionBox(bool autobox)
{
m_autoBox = autobox;
}
static void SetProjectionBox(float x0, float x1, float y0, float y1, float z0, float z1)
{
m_projectionBox[0] = x0;
m_projectionBox[1] = x1;
m_projectionBox[2] = y0;
m_projectionBox[3] = y1;
m_projectionBox[4] = z0;
m_projectionBox[5] = z1;
}
static void GetProjectionBox(float& x0, float& x1, float& y0, float& y1, float& z0, float& z1)
{
x0 = m_projectionBox[0];
x1 = m_projectionBox[1];
y0 = m_projectionBox[2];
y1 = m_projectionBox[3];
z0 = m_projectionBox[4];
z1 = m_projectionBox[5];
}
};
#endif