-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisAtomSubSample.h
252 lines (223 loc) · 8.12 KB
/
VisAtomSubSample.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
/* 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 _VISATOMSUBSAMPLE_H
#define _VISATOMSUBSAMPLE_H
#include "GlcObj.h"
#include "QList.h"
#include "VisAtomVisualizingPolicy.h"
class VisAtomDataSheet;
//*********************************************************************
class VisAtomRegionData
{
public:
enum VISATOMREGION
{
UNDEF_REGION = 0,
SPHERE_REGION = 1,
CUBIC_REGION = 2,
DPLANE_REGION = 3,
EQUATION_REGION = 4
};
protected:
int m_type;
QList<double> m_param;
public:
VisAtomRegionData(){ m_type = UNDEF_REGION;}
~VisAtomRegionData(){m_param.clear();}
void SetSphereRegion(double px, double py, double pz, double r)
{
m_type = SPHERE_REGION;
m_param.clear();
m_param<<px<<py<<pz<<r;
}
void SetSphereRegion(double r)
{
m_type = SPHERE_REGION;
m_param.clear();
m_param<<0.0<<0.0<<0.0<<r;
}
void SetCubicRegion(double px, double py, double pz, double sx, double sy, double sz)
{
m_type = CUBIC_REGION;
m_param.clear();
m_param<<px<<py<<pz<<sx<<sy<<sz;
}
void SetCubicRegion(double sx, double sy, double sz)
{
SetCubicRegion(0.0, 0.0, 0.0, sx, sy, sz);
}
void SetCubicRegion(double size)
{
SetCubicRegion(size, size, size);
}
void SetDPleneRegion(double nx, double ny, double nz, double d1, double d2)
{
//nx, ny, nz is the normal direction of the planes,
//d1, d2 is the distance from the origion
m_type = DPLANE_REGION;
m_param.clear();
m_param<<nx<<ny<<nz<<d1<<d2;
}
int GetType() { return m_type;}
int GetParamCount() { return m_param.size();}
void GetRegion(int&type, int &ndat, double param[])
{
//nx, ny, nz is the normal direction of the planes,
//d1, d2 is the distance from the origion
type = m_type;
ndat = m_param.size();
for(int i=0; i<ndat; i++) param[i] = m_param[i];
}
};
//*********************************************************************
//*********************************************************************
class VisAtomSubSample:public GlcObj
{
private:
protected:
VisAtomDataSheet*m_pData;
QString m_name;
int m_statu;
int m_curvispolicy;
QList<int> m_group;
QList<VisAtomRegionData*> m_region; //space region defining the subsample
QList<double> m_dataregion; //data range defining the subsample
QList<int> m_datacol; //colume of data datasheet giving the data region
QList<VisAtomVisualizingPolicy*> m_vispolicy; //visual policies for the subsample
public:
enum VISATOMSUBSTATU
{
SUBSAMPLE_INVISIABLE = 0,
SUBSAMPLE_VISIABLE = 1
};
VisAtomSubSample(int atype);
VisAtomSubSample();
~VisAtomSubSample();
void Clear();
QString GetName(){return m_name;}
void SetName(QString name) { m_name = name;};
void SetDataSheet(VisAtomDataSheet*pdata) {m_pData = pdata;}
void AddGroupID(int type){m_group.append(type);}
int GetNumberofGroup() { return m_group.count();}
int GetGroupID(int i) { return m_group[i];}
VisAtomRegionData*GetRegion(int i){ return m_region[i];}
int GetNumberofRegions(){ return m_region.size();}
int GetNumberofScalarRegions(){ return m_dataregion.count()/2;}
//to check if an atom is in the subgroup
bool CheckMembership(int atype, float x, float y, float z, float scalar=0);
int GetNumberofAtoms();
//properties of the subsample
int IsVisible() {return m_statu;};
void SetVisible(int visible=true) { m_statu = visible;};
void AddVisualPolicy(VisAtomVisualizingPolicy*policy);
int GetNumberofVisualPolicy() { return this->m_vispolicy.count();}
VisAtomVisualizingPolicy*GetVisualPolicy(int i) { return this->m_vispolicy[i];}
VisAtomVisualizingPolicy*GetCurVisualPolicy() { return this->m_vispolicy[m_curvispolicy];}
int GetCurVisualPolicyID() { return m_curvispolicy; }
void SetCurVisualPolicy(int policy) {m_curvispolicy = policy;}
void SetLastVisualPolicyAsCurrent() {SetCurVisualPolicy(m_vispolicy.count()-1);}
//coloring functions..
void SetColor(float R, float G, float B, float A, int policy)
{
VisAtomVisualizingPolicy*p = this->m_vispolicy[policy];
p->SetColor(R, G, B, A);
};
void GetColor(float&R, float&G, float&B, float&A, int policy)
{
VisAtomVisualizingPolicy*p = this->m_vispolicy[policy];
p->GetColor(R, G, B, A);
};
void GetColor(float&R, float&G, float&B, float&A, int index, int policy)
{
VisAtomVisualizingPolicy*p = this->m_vispolicy[policy];
p->GetColor(R, G, B, A, index);
};
void SetCurColor(float R, float G, float B, float A) {SetColor(R, G, B, A, m_curvispolicy);}
void GetCurColor(float&R, float&G, float&B, float&A) {GetColor(R, G, B, A, m_curvispolicy);}
void GetCurColor(float&R, float&G, float&B, float&A, int index) {GetColor(R, G, B, A, index, m_curvispolicy);}
void SetColorStyle(int style,int policy)
{
VisAtomVisualizingPolicy*p = m_vispolicy[policy];
return p->SetColorStyle(style);
}
int GetColorStyle(int policy)
{
VisAtomVisualizingPolicy*p = m_vispolicy[policy];
return p->GetColorStyle();
}
void SetCurColorStyle(int style) { SetColorStyle(style, m_curvispolicy);}
int GetCurColorStyle() { return GetColorStyle(m_curvispolicy);}
//Geometry
void SetAtomShapeStyle(int style, int policy)
{
VisAtomVisualizingPolicy*p = m_vispolicy[policy];
p->SetAtomShapeStyle(style);
return;
};
void SetVectorStyle(int style, int policy)
{
VisAtomVisualizingPolicy*p = m_vispolicy[policy];
p->SetVectorStyle(style);
return;
};
int GetGeometryStyle(int policy)
{
VisAtomVisualizingPolicy*p = m_vispolicy[policy];
return p->GetGeomStyle();
};
void SetCurAtomShapeStyle(int style) { SetAtomShapeStyle(style, m_curvispolicy); }
void SetCurVectorStyle(int style) { SetVectorStyle(style, m_curvispolicy); }
int GetCurGeometryStyle() { return GetGeometryStyle(m_curvispolicy); }
//size functions
void SetAtomSize(float rad, int policy)
{
this->m_vispolicy[policy]->SetAtomSize(rad);
}
void GetAtomSize(float&rad, int policy)
{
rad = this->m_vispolicy[policy]->GetAtomSize();
}
void GetAtomSize(int i, float&rad, int policy)
{
rad = this->m_vispolicy[policy]->GetAtomSize(i);
}
void SetCurAtomSize(float rad){ SetAtomSize(rad, m_curvispolicy);}
void GetCurAtomSize(float&rad){ GetAtomSize(rad, m_curvispolicy);}
void GetCurAtomSize(int i, float&rad){ GetAtomSize(i, rad, m_curvispolicy);}
bool IsAtomHaveUnifiedSize(int policy){ return this->m_vispolicy[policy]->IsAtomHaveUnifiedSize();}
bool IsCurAtomHaveUnifiedSize(){ return IsAtomHaveUnifiedSize(m_curvispolicy);}
void SetAtomHaveUnifiedSize(bool yes, int policy)
{
VisAtomVisualizingPolicy*p = this->m_vispolicy[policy];
p->SetAtomHaveUnifiedSize(yes);
}
void SetCurAtomHaveUnifiedSize(bool yes){this->SetAtomHaveUnifiedSize(yes, m_curvispolicy);};
//trajectory propperty
void SetTrajectoryLinethick(float thick, int policy)
{
this->m_vispolicy[policy]->SetTrajectoryLinethick(thick);
}
void SetTrajectoryLinethick(float thick)
{
for(int i=0; i<this->m_vispolicy.count(); i++)
this->m_vispolicy[i]->SetTrajectoryLinethick(thick);
}
void SetCurTrajectoryLinethick(float thick)
{
SetTrajectoryLinethick(thick, m_curvispolicy);
}
float GetTrajectoryLinethick(int policy)
{
return this->m_vispolicy[policy]->GetTrajectoryLinethick();
}
float GetCurTrajectoryLinethick()
{
return this->m_vispolicy[m_curvispolicy]->GetTrajectoryLinethick();
}
};
#endif