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
4d06a20b
Commit
4d06a20b
authored
Dec 06, 2019
by
Tobias WEBER
Browse files
small update: added progress dialog
parent
b7db68d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
tools/moldyn/moldyn-loader.h
View file @
4d06a20b
...
...
@@ -14,6 +14,9 @@
#include <vector>
#include <string>
// for progress callback
#include <boost/signals2/signal.hpp>
#include "libs/file.h"
#include "libs/str.h"
...
...
@@ -133,9 +136,6 @@ class MolDyn
return
0
;
}
// clear old data
Clear
();
std
::
size_t
filesize
=
tl2
::
get_file_size
(
ifstr
);
std
::
cout
<<
"File size: "
<<
filesize
/
1024
/
1024
<<
" MB."
<<
std
::
endl
;
...
...
@@ -270,6 +270,11 @@ class MolDyn
std
::
size_t
filepos
=
tl2
::
get_file_pos
(
ifstr
);
percentage
=
t_real
{
filepos
*
100
}
/
t_real
{
filesize
};
if
(
!*
m_sigLoadProgress
(
percentage
))
{
std
::
cerr
<<
"
\n
Loading cancelled."
<<
std
::
endl
;
return
0
;
}
}
std
::
cout
<<
"
\r
Read "
<<
iNumConfigs
<<
" configurations. "
<<
" "
<<
std
::
endl
;
...
...
@@ -277,11 +282,18 @@ class MolDyn
}
template
<
class
subscriber
>
void
SubscribeToLoadProgress
(
const
subscriber
&
subs
)
{
m_sigLoadProgress
.
connect
(
subs
);
}
void
Clear
()
{
m_vecAtoms
.
clear
();
m_vecAtomNums
.
clear
();
m_frames
.
clear
();
m_sigLoadProgress
.
disconnect_all_slots
();
}
...
...
@@ -294,6 +306,8 @@ class MolDyn
std
::
vector
<
unsigned
int
>
m_vecAtomNums
;
std
::
vector
<
MolFrame
<
t_real
,
t_vec
>>
m_frames
;
boost
::
signals2
::
signal
<
bool
(
t_real
)
>
m_sigLoadProgress
;
};
...
...
tools/moldyn/moldyn.cpp
View file @
4d06a20b
...
...
@@ -14,6 +14,7 @@
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QProgressDialog>
#include <iostream>
#include <tuple>
...
...
@@ -278,9 +279,23 @@ void MolDynDlg::Load()
m_sett
->
setValue
(
"dir"
,
QFileInfo
(
filename
).
path
());
New
();
std
::
shared_ptr
<
QProgressDialog
>
dlgProgress
=
std
::
make_shared
<
QProgressDialog
>
(
"Loading
\"
"
+
QFileInfo
(
filename
).
fileName
()
+
"
\"
..."
,
"Cancel"
,
0
,
1000
,
this
);
bool
bCancelled
=
0
;
m_mol
.
SubscribeToLoadProgress
([
dlgProgress
,
&
bCancelled
](
t_real
percentage
)
->
bool
{
dlgProgress
->
setValue
(
int
(
percentage
*
10
));
bCancelled
=
dlgProgress
->
wasCanceled
();
return
!
bCancelled
;
});
dlgProgress
->
setWindowModality
(
Qt
::
WindowModal
);
if
(
!
m_mol
.
LoadFile
(
filename
.
toStdString
(),
filedlg
->
GetFrameSkip
()))
{
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
"Error loading file."
);
// only show error if not explicitely cancelled
if
(
!
bCancelled
)
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
"Error loading file."
);
return
;
}
...
...
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