Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
Takin
mag-core
Commits
87888950
Commit
87888950
authored
Dec 05, 2019
by
Tobias WEBER
Browse files
started visualisation of dynamics
parent
92980904
Changes
2
Hide whitespace changes
Inline
Side-by-side
tools/moldyn/moldyn.cpp
View file @
87888950
...
@@ -121,15 +121,16 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
...
@@ -121,15 +121,16 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
/**
/**
* add 3d object
* add 3d object
*/
*/
void
MolDynDlg
::
Add3DItem
(
const
t_vec
&
vec
,
const
t_vec
&
col
,
t_real
scale
,
const
std
::
string
&
label
)
std
::
size_t
MolDynDlg
::
Add3DItem
(
const
t_vec
&
vec
,
const
t_vec
&
col
,
t_real
scale
,
const
std
::
string
&
label
)
{
{
if
(
!
m_plot
)
return
;
auto
obj
=
m_plot
->
GetImpl
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
col
[
0
],
col
[
1
],
col
[
2
],
1
);
auto
obj
=
m_plot
->
GetImpl
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
col
[
0
],
col
[
1
],
col
[
2
],
1
);
//auto obj = m_plot->GetImpl()->AddSphere(0.05, 0,0,0, col[0],col[1],col[2],1);
//auto obj = m_plot->GetImpl()->AddSphere(0.05, 0,0,0, col[0],col[1],col[2],1);
m_plot
->
GetImpl
()
->
SetObjectMatrix
(
obj
,
m
::
hom_translation
<
t_mat_gl
>
(
vec
[
0
],
vec
[
1
],
vec
[
2
])
*
m
::
hom_scaling
<
t_mat_gl
>
(
scale
,
scale
,
scale
));
m_plot
->
GetImpl
()
->
SetObjectMatrix
(
obj
,
m
::
hom_translation
<
t_mat_gl
>
(
vec
[
0
],
vec
[
1
],
vec
[
2
])
*
m
::
hom_scaling
<
t_mat_gl
>
(
scale
,
scale
,
scale
));
m_plot
->
GetImpl
()
->
SetObjectLabel
(
obj
,
label
);
m_plot
->
GetImpl
()
->
SetObjectLabel
(
obj
,
label
);
m_plot
->
GetImpl
()
->
SetObjectDataString
(
obj
,
label
);
m_plot
->
update
();
m_plot
->
update
();
return
obj
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -140,11 +141,15 @@ void MolDynDlg::Add3DItem(const t_vec& vec, const t_vec& col, t_real scale, cons
...
@@ -140,11 +141,15 @@ void MolDynDlg::Add3DItem(const t_vec& vec, const t_vec& col, t_real scale, cons
void
MolDynDlg
::
New
()
void
MolDynDlg
::
New
()
{
{
m_mol
.
Clear
();
m_mol
.
Clear
();
m_sphereHandles
.
clear
();
// TODO: clear 3d objects
}
}
void
MolDynDlg
::
Load
()
void
MolDynDlg
::
Load
()
{
{
if
(
!
m_plot
)
return
;
m_ignoreCalc
=
1
;
m_ignoreCalc
=
1
;
try
try
...
@@ -155,7 +160,8 @@ void MolDynDlg::Load()
...
@@ -155,7 +160,8 @@ void MolDynDlg::Load()
return
;
return
;
m_sett
->
setValue
(
"dir"
,
QFileInfo
(
filename
).
path
());
m_sett
->
setValue
(
"dir"
,
QFileInfo
(
filename
).
path
());
if
(
!
m_mol
.
LoadFile
(
filename
.
toStdString
(),
100
))
unsigned
int
frameskip
=
10
;
if
(
!
m_mol
.
LoadFile
(
filename
.
toStdString
(),
frameskip
))
{
{
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
"Error loading file."
);
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
"Error loading file."
);
return
;
return
;
...
@@ -179,12 +185,16 @@ void MolDynDlg::Load()
...
@@ -179,12 +185,16 @@ void MolDynDlg::Load()
if
(
m_mol
.
GetFrameCount
())
if
(
m_mol
.
GetFrameCount
())
{
{
const
auto
&
frame
=
m_mol
.
GetFrame
(
0
);
const
auto
&
frame
=
m_mol
.
GetFrame
(
0
);
m_sphereHandles
.
reserve
(
frame
.
GetNumAtoms
());
for
(
std
::
size_t
atomidx
=
0
;
atomidx
<
frame
.
GetNumAtoms
();
++
atomidx
)
for
(
std
::
size_t
atomidx
=
0
;
atomidx
<
frame
.
GetNumAtoms
();
++
atomidx
)
{
{
const
auto
&
coords
=
frame
.
GetCoords
(
atomidx
);
const
auto
&
coords
=
frame
.
GetCoords
(
atomidx
);
for
(
const
t_vec
&
vec
:
coords
)
for
(
const
t_vec
&
vec
:
coords
)
Add3DItem
(
vec
,
cols
[
atomidx
%
cols
.
size
()],
0.5
,
m_mol
.
GetAtomName
(
atomidx
));
{
std
::
size_t
handle
=
Add3DItem
(
vec
,
cols
[
atomidx
%
cols
.
size
()],
0.5
,
m_mol
.
GetAtomName
(
atomidx
));
m_sphereHandles
.
push_back
(
handle
);
}
}
}
}
}
}
}
...
@@ -210,6 +220,8 @@ void MolDynDlg::Save()
...
@@ -210,6 +220,8 @@ void MolDynDlg::Save()
*/
*/
void
MolDynDlg
::
PickerIntersection
(
const
t_vec3_gl
*
pos
,
std
::
size_t
objIdx
,
const
t_vec3_gl
*
posSphere
)
void
MolDynDlg
::
PickerIntersection
(
const
t_vec3_gl
*
pos
,
std
::
size_t
objIdx
,
const
t_vec3_gl
*
posSphere
)
{
{
if
(
!
m_plot
)
return
;
if
(
pos
)
if
(
pos
)
m_curPickedObj
=
long
(
objIdx
);
m_curPickedObj
=
long
(
objIdx
);
else
else
...
@@ -218,8 +230,8 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
...
@@ -218,8 +230,8 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
if
(
m_curPickedObj
>
0
)
if
(
m_curPickedObj
>
0
)
{
{
// TODO
const
std
::
string
&
label
=
m_plot
->
GetImpl
()
->
GetObjectDataString
(
m_curPickedObj
);
std
::
cout
<<
m_curPickedObj
<<
std
::
endl
;
SetStatusMsg
(
label
)
;
}
}
else
else
{
{
...
@@ -264,6 +276,30 @@ void MolDynDlg::PlotMouseUp(bool left, bool mid, bool right)
...
@@ -264,6 +276,30 @@ void MolDynDlg::PlotMouseUp(bool left, bool mid, bool right)
void
MolDynDlg
::
SliderValueChanged
(
int
val
)
void
MolDynDlg
::
SliderValueChanged
(
int
val
)
{
{
if
(
!
m_plot
)
return
;
if
(
val
<
0
||
val
>=
m_mol
.
GetFrameCount
())
return
;
// update atom position with selected frame
const
auto
&
frame
=
m_mol
.
GetFrame
(
val
);
std
::
size_t
counter
=
0
;
for
(
std
::
size_t
atomidx
=
0
;
atomidx
<
frame
.
GetNumAtoms
();
++
atomidx
)
{
const
auto
&
coords
=
frame
.
GetCoords
(
atomidx
);
for
(
const
t_vec
&
vec
:
coords
)
{
std
::
size_t
obj
=
m_sphereHandles
[
counter
];
t_real
scale
=
0.5
;
m_plot
->
GetImpl
()
->
SetObjectMatrix
(
obj
,
m
::
hom_translation
<
t_mat_gl
>
(
vec
[
0
],
vec
[
1
],
vec
[
2
])
*
m
::
hom_scaling
<
t_mat_gl
>
(
scale
,
scale
,
scale
));
++
counter
;
}
}
m_plot
->
update
();
}
}
...
...
tools/moldyn/moldyn.h
View file @
87888950
...
@@ -35,19 +35,7 @@ public:
...
@@ -35,19 +35,7 @@ public:
~
MolDynDlg
()
=
default
;
~
MolDynDlg
()
=
default
;
protected:
protected:
MolDyn
<
t_real
,
t_vec
>
m_mol
;
std
::
size_t
Add3DItem
(
const
t_vec
&
vec
,
const
t_vec
&
col
,
t_real
scale
,
const
std
::
string
&
label
);
QSettings
*
m_sett
=
nullptr
;
QMenuBar
*
m_menu
=
nullptr
;
QStatusBar
*
m_status
=
nullptr
;
QSlider
*
m_slider
=
nullptr
;
GlPlot
*
m_plot
=
nullptr
;
std
::
size_t
m_sphere
=
0
;
protected:
void
Add3DItem
(
const
t_vec
&
vec
,
const
t_vec
&
col
,
t_real
scale
,
const
std
::
string
&
label
);
void
SetStatusMsg
(
const
std
::
string
&
msg
);
void
SetStatusMsg
(
const
std
::
string
&
msg
);
void
New
();
void
New
();
...
@@ -63,6 +51,20 @@ protected:
...
@@ -63,6 +51,20 @@ protected:
virtual
void
closeEvent
(
QCloseEvent
*
evt
)
override
;
virtual
void
closeEvent
(
QCloseEvent
*
evt
)
override
;
protected:
MolDyn
<
t_real
,
t_vec
>
m_mol
;
QSettings
*
m_sett
=
nullptr
;
QMenuBar
*
m_menu
=
nullptr
;
QStatusBar
*
m_status
=
nullptr
;
QSlider
*
m_slider
=
nullptr
;
GlPlot
*
m_plot
=
nullptr
;
std
::
size_t
m_sphere
=
0
;
std
::
vector
<
std
::
size_t
>
m_sphereHandles
;
private:
private:
long
m_curPickedObj
=
-
1
;
long
m_curPickedObj
=
-
1
;
bool
m_ignoreChanges
=
1
;
bool
m_ignoreChanges
=
1
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment