Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mag-core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Scientific Software
Takin
mag-core
Commits
4d06a20b
Commit
4d06a20b
authored
Dec 06, 2019
by
Tobias WEBER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small update: added progress dialog
parent
b7db68d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
tools/moldyn/moldyn-loader.h
tools/moldyn/moldyn-loader.h
+17
-3
tools/moldyn/moldyn.cpp
tools/moldyn/moldyn.cpp
+16
-1
No files found.
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