-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisAtomCliper.h
307 lines (280 loc) · 7.4 KB
/
VisAtomCliper.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
/* 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 _VISATOMCLIPER_H
#define _VISATOMCLIPER_H
#include "GlcObj.h"
#include "QList.h"
class Scene;
//************************************************************
class VisAtomCliper
{
public:
enum VISATOMCLIPERSTYLE
{
CLIPPING_STYLE_OR = 0,
CLIPPING_STYLE_AND = 1,
CLIPPING_STYLE_ANYDIR = 2,
CLIPPING_STYLE_NUM = 3
};
protected:
enum VISCLIPERSTATU
{
CLIPPING_DISABLE = 0,
CLIPPING_ENABLE1 = 1,
CLIPPING_ENABLE2 = 2,
};
Scene* m_Scene;
int m_Style;
int m_ClipStatu[3];
int m_Inv[3];
double m_Axsis[3]; //in style 1-3, when the value -1.e-6< and <1.e-6, no clipping is enabled, corresponding to style
// CLIPPING_NONE. otherwise clipping is enabled. The sign of Axsis determing the direction
// of the clipping planes
//in style CLIPPING_ANYDIR, m_Axsis represent the direction of the clipping plane.
double m_Pos[3]; //position of the clipping planes, in style 1-3, the postions are the
//section point of clipping planes with three axsis.
double m_CStep[3]; //step size ot thickness for clipping planes, in unit of the minima size of scene volumn
int m_ShowFrontface[3];
int m_ShowBackface[3];
double m_Opacity;
//to get the intersect of the clip plane with SCEN cubic:
void GetClipPlaneContour(double x0, double y0, double z0, double x1,double y1,double z1,
double vnx, double vny, double vnz, double r, int&npt, double ppt[12][3]);
public:
VisAtomCliper();
~VisAtomCliper();
void PaintEdge();
void PaintFace();
void AttachScene(Scene*pScene)
{
m_Scene = pScene;
};
Scene* GetAttachedScene()
{
return m_Scene;
};
void SetStyle(int style)
{
m_Style = style;
};
int GetStyle()
{
return m_Style;
};
void EnableClip(bool enabled, int i)
{
int old = m_ClipStatu[i] & VISCLIPERSTATU::CLIPPING_ENABLE2;
if (enabled)
{
m_ClipStatu[i] = VISCLIPERSTATU::CLIPPING_ENABLE1 + old;
}
else
{
m_ClipStatu[i] = VISCLIPERSTATU::CLIPPING_DISABLE + old;
}
}
void EnableClipX(bool enabled = true)
{
//if (enabled) m_Axsis[0] = 1; else m_Axsis[0] = 0;
EnableClip(enabled, 0);
};
void EnableClipY(bool enabled = true)
{
//if (enabled) m_Axsis[1] = 1; else m_Axsis[1] = 0;
EnableClip(enabled, 1);
};
void EnableClipZ(bool enabled = true)
{
//if (enabled) m_Axsis[2] = 1; else m_Axsis[2] = 0;
EnableClip(enabled, 2);
};
void EnableClip(bool enabled = true)
{
EnableClip(enabled, 0);
EnableClip(enabled, 1);
EnableClip(enabled, 2);
}
bool IsEnabledClip(int i)
{
return (m_ClipStatu[i] & VisAtomCliper::CLIPPING_ENABLE1) > 0;
}
bool IsEnabledClipX()
{
return IsEnabledClip(0);
};
bool IsEnabledClipY()
{
return IsEnabledClip(1);
};
bool IsEnabledClipZ()
{
return IsEnabledClip(2);
};
bool IsEnabledClip()
{
return IsEnabledClipX() || IsEnabledClipY() || IsEnabledClipZ();
};
void EnableDClip(bool enabled, int i)
{
int old = m_ClipStatu[i] & VISCLIPERSTATU::CLIPPING_ENABLE1;
if (enabled)
{
m_ClipStatu[i] = VISCLIPERSTATU::CLIPPING_ENABLE2 + old;
}
else
{
m_ClipStatu[i] = VISCLIPERSTATU::CLIPPING_DISABLE + old;
}
}
void EnableDClip(bool enabled = true)
{
EnableDClip(enabled, 0);
EnableDClip(enabled, 1);
EnableDClip(enabled, 2);
};
void EnableDClipX(bool enabled = true)
{
EnableDClip(enabled, 0);
//m_DClip[0] = enabled;
};
void EnableDClipY(bool enabled = true)
{
EnableDClip(enabled, 1);
//m_DClip[1] = enabled;
};
void EnableDClipZ(bool enabled = true)
{
EnableDClip(enabled, 2);
//m_DClip[2] = enabled;
};
bool IsEnabledDClip(int i)
{
return (m_ClipStatu[i] & VisAtomCliper::CLIPPING_ENABLE2) > 0;
}
bool IsEnabledDClipX()
{
return IsEnabledDClip(0); //return m_DClip[0];
};
bool IsEnabledDClipY()
{
return IsEnabledDClip(1); //return m_DClip[1];
};
bool IsEnabledDClipZ()
{
return IsEnabledDClip(2); //return m_DClip[2];
};
bool IsEnabledDClip()
{
return IsEnabledDClipX() || IsEnabledDClipY() || IsEnabledDClipZ();
}
void SetInverseClipX(bool enabled = true)
{
m_Inv[0] = enabled;
};
void SetInverseClipY(bool enabled = true)
{
m_Inv[1] = enabled;
};
void SetInverseClipZ(bool enabled = true)
{
m_Inv[2] = enabled;
};
bool IsInverseClipX()
{
return m_Inv[0];
};
bool IsInverseClipY()
{
return m_Inv[1];
};
bool IsInverseClipZ()
{
return m_Inv[2];
};
void SetClipPos(double pos)
{
m_Pos[0] = m_Pos[1] = m_Pos[2] = pos;
};
void SetClipPos(double pos[])
{
m_Pos[0] = pos[0]; m_Pos[1] = pos[1]; m_Pos[2] = pos[2];
};
void GetClipPos(double pos[])
{
pos[0] = m_Pos[0]; pos[1] = m_Pos[1]; pos[2] = m_Pos[2];
};
void GetClipPos(double&x, double&y, double&z)
{
x = m_Pos[0]; y = m_Pos[1]; z = m_Pos[2];
};
//get the position multiplied by box side
void GetClipAbsolutePos(double pos[]);
void SetClipStep(double step[])
{
m_CStep[0] = step[0]; m_CStep[1] = step[1]; m_CStep[2] = step[2];
};
void GetClipStep(double step[])
{
step[0] = m_CStep[0]; step[1] = m_CStep[1]; step[2] = m_CStep[2];
};
void GetClipThickness(double thickness[]);
double GetClipThickness()
{
return m_CStep[0];
};
//used in style of anydirection clipping
void SetClipAxsis(double axsis[])
{
m_Axsis[0] = axsis[0]; m_Axsis[1] = axsis[1]; m_Axsis[2] = axsis[2];
};
void GetClipAxsis(double axsis[])
{
axsis[0] = m_Axsis[0]; axsis[1] = m_Axsis[1]; axsis[2] = m_Axsis[2];
};
void GetClipAxsis(double&x, double&y, double&z)
{
x = m_Axsis[0]; y = m_Axsis[1]; z = m_Axsis[2];
};
void SetParameters(VisAtomCliper*sor);
bool IsParameterChanged(VisAtomCliper*sor);
//used for set visualization parameters
void ShowFronFace(int show[])
{
m_ShowFrontface[0] = show[0]; m_ShowFrontface[1] = show[1]; m_ShowFrontface[2] = show[2];
};
void ShowFronFace(int show)
{
m_ShowFrontface[0] = m_ShowFrontface[1] = m_ShowFrontface[2] = show;
};
int IsShowFronFace()
{
return m_ShowFrontface[0];
};
void ShowBackFace(int show[])
{
m_ShowBackface[0] = show[0]; m_ShowBackface[1] = show[1]; m_ShowBackface[2] = show[2];
};
void ShowBackFace(int show)
{
m_ShowBackface[0] = m_ShowBackface[1] = m_ShowBackface[2] = show;
};
int IsShowBackFace()
{
return m_ShowBackface[0];
};
void SetFaceOpacity(double opacity)
{
m_Opacity = opacity;
};
double GetFaceOpacity()
{
return m_Opacity;
};
};
//************************************************************
#endif