Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
Takin
mag-core
Commits
44b7c110
Commit
44b7c110
authored
Dec 04, 2019
by
Tobias WEBER
Browse files
continued with moldyn gui
parent
b15ad7ec
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
44b7c110
...
@@ -52,6 +52,7 @@ tools/cif2xml/build/**
...
@@ -52,6 +52,7 @@ tools/cif2xml/build/**
tools/magstructfact/build/**
tools/magstructfact/build/**
tools/magsgbrowser/build/**
tools/magsgbrowser/build/**
tools/pol/build/**
tools/pol/build/**
tools/moldyn/build/**
*.pyc
*.pyc
.DS_Store
.DS_Store
*.csv
*.csv
...
...
tools/moldyn/moldyn-loader.h
View file @
44b7c110
...
@@ -37,6 +37,17 @@ class MolFrame
...
@@ -37,6 +37,17 @@ class MolFrame
m_config
.
push_back
(
config
);
m_config
.
push_back
(
config
);
}
}
std
::
size_t
GetNumAtoms
()
const
{
return
m_config
.
size
();
}
const
std
::
vector
<
t_vec
>&
GetCoords
(
std
::
size_t
atomidx
)
const
{
return
m_config
[
atomidx
];
}
private:
private:
// atoms -> coordinates
// atoms -> coordinates
std
::
vector
<
std
::
vector
<
t_vec
>>
m_config
;
std
::
vector
<
std
::
vector
<
t_vec
>>
m_config
;
...
@@ -105,6 +116,10 @@ class MolDyn
...
@@ -105,6 +116,10 @@ class MolDyn
return
0
;
return
0
;
}
}
// clear old data
Clear
();
std
::
string
strSys
;
std
::
string
strSys
;
std
::
getline
(
ifstr
,
strSys
);
std
::
getline
(
ifstr
,
strSys
);
tl2
::
trim
(
strSys
);
tl2
::
trim
(
strSys
);
...
@@ -231,6 +246,31 @@ class MolDyn
...
@@ -231,6 +246,31 @@ class MolDyn
}
}
void
Clear
()
{
m_vecAtoms
.
clear
();
m_vecAtomNums
.
clear
();
m_frames
.
clear
();
}
std
::
size_t
GetFrameCount
()
const
{
return
m_frames
.
size
();
}
const
MolFrame
<
t_real
,
t_vec
>&
GetFrame
(
std
::
size_t
frame
)
const
{
return
m_frames
[
frame
];
}
const
std
::
string
&
GetAtomName
(
std
::
size_t
idx
)
const
{
return
m_vecAtoms
[
idx
];
}
private:
private:
t_vec
m_baseA
;
t_vec
m_baseA
;
t_vec
m_baseB
;
t_vec
m_baseB
;
...
...
tools/moldyn/moldyn.cpp
View file @
44b7c110
...
@@ -8,8 +8,6 @@
...
@@ -8,8 +8,6 @@
#include "moldyn.h"
#include "moldyn.h"
#include <QtWidgets/QApplication>
#include <QtWidgets/QApplication>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QMessageBox>
...
@@ -45,19 +43,19 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
...
@@ -45,19 +43,19 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
auto
acNew
=
new
QAction
(
"New"
,
menuFile
);
auto
acNew
=
new
QAction
(
"New"
,
menuFile
);
auto
acLoad
=
new
QAction
(
"Load..."
,
menuFile
);
auto
acLoad
=
new
QAction
(
"Load..."
,
menuFile
);
auto
acSave
=
new
QAction
(
"Save..."
,
menuFile
);
//
auto acSave = new QAction("Save...", menuFile);
auto
acExit
=
new
QAction
(
"Exit"
,
menuFile
);
auto
acExit
=
new
QAction
(
"Exit"
,
menuFile
);
menuFile
->
addAction
(
acNew
);
menuFile
->
addAction
(
acNew
);
menuFile
->
addSeparator
();
menuFile
->
addSeparator
();
menuFile
->
addAction
(
acLoad
);
menuFile
->
addAction
(
acLoad
);
menuFile
->
addAction
(
acSave
);
//
menuFile->addAction(acSave);
menuFile
->
addSeparator
();
menuFile
->
addSeparator
();
menuFile
->
addAction
(
acExit
);
menuFile
->
addAction
(
acExit
);
connect
(
acNew
,
&
QAction
::
triggered
,
this
,
&
MolDynDlg
::
New
);
connect
(
acNew
,
&
QAction
::
triggered
,
this
,
&
MolDynDlg
::
New
);
connect
(
acLoad
,
&
QAction
::
triggered
,
this
,
&
MolDynDlg
::
Load
);
connect
(
acLoad
,
&
QAction
::
triggered
,
this
,
&
MolDynDlg
::
Load
);
connect
(
acSave
,
&
QAction
::
triggered
,
this
,
&
MolDynDlg
::
Save
);
//
connect(acSave, &QAction::triggered, this, &MolDynDlg::Save);
connect
(
acExit
,
&
QAction
::
triggered
,
this
,
&
QDialog
::
close
);
connect
(
acExit
,
&
QAction
::
triggered
,
this
,
&
QDialog
::
close
);
m_menu
->
addMenu
(
menuFile
);
m_menu
->
addMenu
(
menuFile
);
...
@@ -70,6 +68,7 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
...
@@ -70,6 +68,7 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
m_plot
=
new
GlPlot
(
this
);
m_plot
=
new
GlPlot
(
this
);
m_plot
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
m_plot
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
m_plot
->
GetImpl
()
->
EnablePicker
(
1
);
m_plot
->
GetImpl
()
->
SetLight
(
0
,
m
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
0
,
m
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
m
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
m
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetCoordMax
(
1.
);
m_plot
->
GetImpl
()
->
SetCoordMax
(
1.
);
...
@@ -100,27 +99,15 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
...
@@ -100,27 +99,15 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
/**
/**
* add 3d object
* add 3d object
*/
*/
void
MolDynDlg
::
Add3DItem
(
int
row
)
void
MolDynDlg
::
Add3DItem
(
const
t_vec
&
vec
,
const
t_vec
&
col
,
t_real
scale
,
const
std
::
string
&
label
)
{
{
if
(
!
m_plot
)
return
;
if
(
!
m_plot
)
return
;
// add all items
auto
obj
=
m_plot
->
GetImpl
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
col
[
0
],
col
[
1
],
col
[
2
],
1
);
if
(
row
<
0
)
//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
));
//for(int row=0; row<m_nuclei->rowCount(); ++row)
m_plot
->
GetImpl
()
->
SetObjectLabel
(
obj
,
label
);
// Add3DItem(row);
m_plot
->
update
();
return
;
}
qreal
r
=
1
,
g
=
1
,
b
=
1
;
QColor
col
;
col
.
getRgbF
(
&
r
,
&
g
,
&
b
);
//auto obj = m_plot->GetImpl()->AddLinkedObject(m_sphere, 0,0,0, r,g,b,1);
//auto obj = m_plot->GetImpl()->AddSphere(0.05, 0,0,0, r,g,b,1);
//m_plot->GetImpl()->SetObjectMatrix(obj, m::hom_translation<t_mat_gl>(posx, posy, posz)*m::hom_scaling<t_mat_gl>(scale,scale,scale));
//m_plot->GetImpl()->SetObjectLabel(obj, itemName->text().toStdString());
//m_plot->update();
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -130,11 +117,56 @@ void MolDynDlg::Add3DItem(int row)
...
@@ -130,11 +117,56 @@ void MolDynDlg::Add3DItem(int row)
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void
MolDynDlg
::
New
()
void
MolDynDlg
::
New
()
{
{
m_mol
.
Clear
();
}
}
void
MolDynDlg
::
Load
()
void
MolDynDlg
::
Load
()
{
{
m_ignoreCalc
=
1
;
try
{
QString
dirLast
=
m_sett
->
value
(
"dir"
,
""
).
toString
();
QString
filename
=
QFileDialog
::
getOpenFileName
(
this
,
"Load File"
,
dirLast
,
"Molecular Dynamics File (*)"
);
if
(
filename
==
""
||
!
QFile
::
exists
(
filename
))
return
;
m_sett
->
setValue
(
"dir"
,
QFileInfo
(
filename
).
path
());
if
(
!
m_mol
.
LoadFile
(
filename
.
toStdString
(),
100
))
{
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
"Error loading file."
);
}
std
::
vector
<
t_vec
>
cols
=
{
m
::
create
<
t_vec
>
({
1
,
0
,
0
}),
m
::
create
<
t_vec
>
({
0
,
0
,
1
}),
m
::
create
<
t_vec
>
({
0
,
0.5
,
0
}),
m
::
create
<
t_vec
>
({
0
,
0.5
,
0.5
}),
m
::
create
<
t_vec
>
({
0.5
,
0.5
,
0
}),
m
::
create
<
t_vec
>
({
0
,
0
,
0
}),
};
if
(
m_mol
.
GetFrameCount
())
{
const
auto
&
frame
=
m_mol
.
GetFrame
(
0
);
for
(
std
::
size_t
atomidx
=
0
;
atomidx
<
frame
.
GetNumAtoms
();
++
atomidx
)
{
const
auto
&
coords
=
frame
.
GetCoords
(
atomidx
);
for
(
const
t_vec
&
vec
:
coords
)
Add3DItem
(
vec
,
cols
[
atomidx
%
cols
.
size
()],
0.5
,
m_mol
.
GetAtomName
(
atomidx
));
}
}
}
catch
(
const
std
::
exception
&
ex
)
{
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
ex
.
what
());
}
m_ignoreCalc
=
0
;
}
}
...
@@ -159,10 +191,12 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
...
@@ -159,10 +191,12 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
if
(
m_curPickedObj
>
0
)
if
(
m_curPickedObj
>
0
)
{
{
// TODO
std
::
cout
<<
m_curPickedObj
<<
std
::
endl
;
}
}
else
else
{
{
Set
3D
StatusMsg
(
""
);
SetStatusMsg
(
""
);
}
}
}
}
...
@@ -171,7 +205,7 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
...
@@ -171,7 +205,7 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
/**
/**
* set status label text in 3d dialog
* set status label text in 3d dialog
*/
*/
void
MolDynDlg
::
Set
3D
StatusMsg
(
const
std
::
string
&
msg
)
void
MolDynDlg
::
SetStatusMsg
(
const
std
::
string
&
msg
)
{
{
if
(
!
m_status
)
return
;
if
(
!
m_status
)
return
;
...
@@ -210,9 +244,6 @@ void MolDynDlg::AfterGLInitialisation()
...
@@ -210,9 +244,6 @@ void MolDynDlg::AfterGLInitialisation()
m_sphere
=
m_plot
->
GetImpl
()
->
AddSphere
(
0.05
,
0.
,
0.
,
0.
,
1.
,
1.
,
1.
,
1.
);
m_sphere
=
m_plot
->
GetImpl
()
->
AddSphere
(
0.05
,
0.
,
0.
,
0.
,
1.
,
1.
,
1.
,
1.
);
m_plot
->
GetImpl
()
->
SetObjectVisible
(
m_sphere
,
false
);
m_plot
->
GetImpl
()
->
SetObjectVisible
(
m_sphere
,
false
);
// add all 3d objects
Add3DItem
(
-
1
);
// GL device info
// GL device info
auto
[
strGlVer
,
strGlShaderVer
,
strGlVendor
,
strGlRenderer
]
auto
[
strGlVer
,
strGlShaderVer
,
strGlVendor
,
strGlRenderer
]
=
m_plot
->
GetImpl
()
->
GetGlDescr
();
=
m_plot
->
GetImpl
()
->
GetGlDescr
();
...
...
tools/moldyn/moldyn.h
View file @
44b7c110
...
@@ -9,19 +9,18 @@
...
@@ -9,19 +9,18 @@
#define __MOLDYN_GUI_H__
#define __MOLDYN_GUI_H__
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/Q
Dialog
>
#include <QtWidgets/Q
Menu
>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QMenu>
#include <QtWidgets/QLabel>
#include <QtCore/QSettings>
#include <QtCore/QSettings>
#include <vector>
#include <vector>
#include <sstream>
#include "libs/_cxx20/glplot.h"
#include "libs/_cxx20/glplot.h"
#include "libs/_cxx20/math_algos.h"
#include "libs/_cxx20/math_algos.h"
#include "moldyn-loader.h"
using
t_real
=
double
;
using
t_real
=
double
;
using
t_vec
=
std
::
vector
<
t_real
>
;
using
t_vec
=
std
::
vector
<
t_real
>
;
...
@@ -35,6 +34,8 @@ public:
...
@@ -35,6 +34,8 @@ public:
~
MolDynDlg
()
=
default
;
~
MolDynDlg
()
=
default
;
protected:
protected:
MolDyn
<
t_real
,
t_vec
>
m_mol
;
QSettings
*
m_sett
=
nullptr
;
QSettings
*
m_sett
=
nullptr
;
QMenuBar
*
m_menu
=
nullptr
;
QMenuBar
*
m_menu
=
nullptr
;
QStatusBar
*
m_status
=
nullptr
;
QStatusBar
*
m_status
=
nullptr
;
...
@@ -44,8 +45,8 @@ protected:
...
@@ -44,8 +45,8 @@ protected:
protected:
protected:
void
Add3DItem
(
int
row
=-
1
);
void
Add3DItem
(
const
t_vec
&
vec
,
const
t_vec
&
col
,
t_real
scale
,
const
std
::
string
&
label
);
void
Set
3D
StatusMsg
(
const
std
::
string
&
msg
);
void
SetStatusMsg
(
const
std
::
string
&
msg
);
void
New
();
void
New
();
void
Load
();
void
Load
();
...
@@ -61,6 +62,7 @@ protected:
...
@@ -61,6 +62,7 @@ protected:
private:
private:
long
m_curPickedObj
=
-
1
;
long
m_curPickedObj
=
-
1
;
bool
m_ignoreChanges
=
1
;
bool
m_ignoreChanges
=
1
;
bool
m_ignoreCalc
=
1
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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