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
a89247da
Commit
a89247da
authored
Dec 11, 2019
by
Tobias WEBER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
continued with deletion menu
parent
e374ea0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
10 deletions
+72
-10
tools/moldyn/moldyn-loader.h
tools/moldyn/moldyn-loader.h
+24
-0
tools/moldyn/moldyn.cpp
tools/moldyn/moldyn.cpp
+48
-10
No files found.
tools/moldyn/moldyn-loader.h
View file @
a89247da
...
...
@@ -45,6 +45,15 @@ class MolFrame
{
return
m_config
[
atomidx
];
}
/**
* removes one atoms of type idxType and index idxSubType
*/
void
RemoveAtom
(
std
::
size_t
idxType
,
std
::
size_t
idxSubType
)
{
m_config
[
idxType
].
erase
(
m_config
[
idxType
].
begin
()
+
idxSubType
);
}
/**
* removes all atoms at index idx
*/
...
...
@@ -132,6 +141,21 @@ class MolDyn
}
/**
* removes one atoms of type idxType and index idxSubType
*/
void
RemoveAtom
(
std
::
size_t
idxType
,
std
::
size_t
idxSubType
)
{
if
(
!
m_vecAtomNums
[
idxType
])
return
;
for
(
MolFrame
<
t_real
,
t_vec
>&
frame
:
m_frames
)
frame
.
RemoveAtom
(
idxType
,
idxSubType
);
--
m_vecAtomNums
[
idxType
];
}
/**
* removes all atoms at index idx
*/
...
...
tools/moldyn/moldyn.cpp
View file @
a89247da
...
...
@@ -34,7 +34,6 @@ constexpr int g_prec = 6;
/**
* File dialog with options
*/
class
MolDynFileDlg
:
public
QFileDialog
{
public:
...
...
@@ -544,10 +543,55 @@ void MolDynDlg::SliderValueChanged(int val)
}
/**
* delete one atom
*/
void
MolDynDlg
::
DeleteAtomUnderCursor
()
{
// nothing under cursor
if
(
m_curPickedObj
<=
0
)
return
;
// atom type to be deleted
const
std
::
string
&
atomLabel
=
m_plot
->
GetImpl
()
->
GetObjectDataString
(
m_curPickedObj
);
// find handle in sphere handle vector
auto
iter
=
std
::
find
(
m_sphereHandles
.
begin
(),
m_sphereHandles
.
end
(),
m_curPickedObj
);
if
(
iter
==
m_sphereHandles
.
end
())
{
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
"Atom handle not found, data is corrupted."
);
return
;
}
std
::
size_t
sphereIdx
=
iter
-
m_sphereHandles
.
begin
();
std
::
size_t
atomCountsSoFar
=
0
;
std
::
size_t
atomTypeIdx
=
0
;
for
(
atomTypeIdx
=
0
;
atomTypeIdx
<
m_mol
.
GetAtomCount
();
++
atomTypeIdx
)
{
std
::
size_t
numAtoms
=
m_mol
.
GetAtomNum
(
atomTypeIdx
);
if
(
atomCountsSoFar
+
numAtoms
>
sphereIdx
)
break
;
atomCountsSoFar
+=
numAtoms
;
}
if
(
m_mol
.
GetAtomName
(
atomTypeIdx
)
!=
atomLabel
)
{
QMessageBox
::
critical
(
this
,
"Molecular Dynamics"
,
"Mismatch in atom type, data is corrupted."
);
return
;
}
// remove 3d objects
m_plot
->
GetImpl
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_sphereHandles
.
erase
(
m_sphereHandles
.
begin
()
+
sphereIdx
);
// remove atom
std
::
size_t
atomSubTypeIdx
=
sphereIdx
-
atomCountsSoFar
;
m_mol
.
RemoveAtom
(
atomTypeIdx
,
atomSubTypeIdx
);
SetStatusMsg
(
"1 atom removed."
);
m_plot
->
update
();
}
...
...
@@ -573,10 +617,7 @@ void MolDynDlg::DeleteAllAtomsOfSameType()
{
// remove 3d objects
for
(
std
::
size_t
sphereIdx
=
startIdx
;
sphereIdx
<
startIdx
+
numAtoms
;
++
sphereIdx
)
{
const
auto
&
obj
=
m_sphereHandles
[
sphereIdx
];
m_plot
->
GetImpl
()
->
RemoveObject
(
obj
);
}
m_plot
->
GetImpl
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_sphereHandles
.
erase
(
m_sphereHandles
.
begin
()
+
startIdx
,
m_sphereHandles
.
begin
()
+
startIdx
+
numAtoms
);
// remove atoms
...
...
@@ -618,10 +659,7 @@ void MolDynDlg::KeepAtomsOfSameType()
{
// remove 3d objects
for
(
std
::
size_t
sphereIdx
=
startIdx
;
sphereIdx
<
startIdx
+
numAtoms
;
++
sphereIdx
)
{
const
auto
&
obj
=
m_sphereHandles
[
sphereIdx
];
m_plot
->
GetImpl
()
->
RemoveObject
(
obj
);
}
m_plot
->
GetImpl
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_sphereHandles
.
erase
(
m_sphereHandles
.
begin
()
+
startIdx
,
m_sphereHandles
.
begin
()
+
startIdx
+
numAtoms
);
// remove atoms
...
...
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