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
612626b7
Verified
Commit
612626b7
authored
Feb 25, 2021
by
Tobias WEBER
Browse files
adapted to tlibs2 changes
parent
6469c34b
Changes
4
Hide whitespace changes
Inline
Side-by-side
tools/magstructfact/magstructfact.cpp
View file @
612626b7
...
...
@@ -536,10 +536,10 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
m_dlgPlot
->
setWindowTitle
(
"Unit Cell"
);
m_plot
=
std
::
make_shared
<
GlPlot
>
(
this
);
m_plot
->
Get
Impl
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
Get
Impl
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
Get
Impl
()
->
SetCoordMax
(
1.
);
m_plot
->
Get
Impl
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m_plot
->
Get
Renderer
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
Get
Renderer
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
Get
Renderer
()
->
SetCoordMax
(
1.
);
m_plot
->
Get
Renderer
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
tl2
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
...
...
@@ -564,13 +564,13 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
connect
(
m_plot
.
get
(),
&
GlPlot
::
AfterGLInitialisation
,
this
,
&
MagStructFactDlg
::
AfterGLInitialisation
);
connect
(
m_plot
->
Get
Impl
(),
&
GlPlot
_impl
::
PickerIntersection
,
this
,
&
MagStructFactDlg
::
PickerIntersection
);
connect
(
m_plot
->
Get
Renderer
(),
&
GlPlot
Renderer
::
PickerIntersection
,
this
,
&
MagStructFactDlg
::
PickerIntersection
);
connect
(
m_plot
.
get
(),
&
GlPlot
::
MouseDown
,
this
,
&
MagStructFactDlg
::
PlotMouseDown
);
//connect(m_plot.get(), &GlPlot::MouseUp, this, [this](bool left, bool mid, bool right) {});
connect
(
comboCoordSys
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
[
this
](
int
val
)
{
if
(
this
->
m_plot
)
this
->
m_plot
->
Get
Impl
()
->
SetCoordSys
(
val
);
this
->
m_plot
->
Get
Renderer
()
->
SetCoordSys
(
val
);
});
...
...
@@ -596,10 +596,10 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
m_dlgPlotSC
->
setWindowTitle
(
"Super Cell"
);
m_plotSC
=
std
::
make_shared
<
GlPlot
>
(
this
);
m_plotSC
->
Get
Impl
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plotSC
->
Get
Impl
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plotSC
->
Get
Impl
()
->
SetCoordMax
(
1.
);
m_plotSC
->
Get
Impl
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m_plotSC
->
Get
Renderer
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plotSC
->
Get
Renderer
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plotSC
->
Get
Renderer
()
->
SetCoordMax
(
1.
);
m_plotSC
->
Get
Renderer
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
tl2
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
...
...
@@ -624,13 +624,13 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
connect
(
m_plotSC
.
get
(),
&
GlPlot
::
AfterGLInitialisation
,
this
,
&
MagStructFactDlg
::
AfterGLInitialisationSC
);
connect
(
m_plotSC
->
Get
Impl
(),
&
GlPlot
_impl
::
PickerIntersection
,
this
,
&
MagStructFactDlg
::
PickerIntersectionSC
);
connect
(
m_plotSC
->
Get
Renderer
(),
&
GlPlot
Renderer
::
PickerIntersection
,
this
,
&
MagStructFactDlg
::
PickerIntersectionSC
);
//connect(m_plotSC.get(), &GlPlot::MouseDown, this, [this](bool left, bool mid, bool right) {});
//connect(m_plotSC.get(), &GlPlot::MouseUp, this, [this](bool left, bool mid, bool right) {});
connect
(
comboCoordSys
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
[
this
](
int
val
)
{
if
(
this
->
m_plotSC
)
this
->
m_plotSC
->
Get
Impl
()
->
SetCoordSys
(
val
);
this
->
m_plotSC
->
Get
Renderer
()
->
SetCoordSys
(
val
);
});
...
...
@@ -737,10 +737,10 @@ void MagStructFactDlg::Add3DItem(int row)
return
;
}
auto
objSphere
=
m_plot
->
Get
Impl
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
//auto obj = m_plot->Get
Impl
()->AddSphere(0.05, 0,0,0, 1,1,1,1);
auto
objArrowRe
=
m_plot
->
Get
Impl
()
->
AddLinkedObject
(
m_arrow
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
objArrowIm
=
m_plot
->
Get
Impl
()
->
AddLinkedObject
(
m_arrow
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
objSphere
=
m_plot
->
Get
Renderer
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
//auto obj = m_plot->Get
Renderer
()->AddSphere(0.05, 0,0,0, 1,1,1,1);
auto
objArrowRe
=
m_plot
->
Get
Renderer
()
->
AddLinkedObject
(
m_arrow
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
objArrowIm
=
m_plot
->
Get
Renderer
()
->
AddLinkedObject
(
m_arrow
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
m_nuclei
->
item
(
row
,
COL_NAME
)
->
setData
(
Qt
::
UserRole
+
0
,
unsigned
(
objSphere
));
// atomic position
m_nuclei
->
item
(
row
,
COL_NAME
)
->
setData
(
Qt
::
UserRole
+
1
,
unsigned
(
objArrowRe
));
// real part of Fourier comp
...
...
@@ -810,7 +810,7 @@ void MagStructFactDlg::Sync3DItem(int row)
auto
normReM
=
tl2
::
norm
<
t_vec_gl
>
(
vecReM
);
auto
normImM
=
tl2
::
norm
<
t_vec_gl
>
(
vecImM
);
t_mat_gl
matArrowRe
=
GlPlot
_impl
::
GetArrowMatrix
(
t_mat_gl
matArrowRe
=
GlPlot
Renderer
::
GetArrowMatrix
(
vecReM
,
// to
1
,
// post-scale
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
...
...
@@ -819,7 +819,7 @@ void MagStructFactDlg::Sync3DItem(int row)
tl2
::
create
<
t_vec_gl
>
({
posx
,
posy
,
posz
})
// pre-translate
);
t_mat_gl
matArrowIm
=
GlPlot
_impl
::
GetArrowMatrix
(
t_mat_gl
matArrowIm
=
GlPlot
Renderer
::
GetArrowMatrix
(
vecImM
,
// to
1
,
// post-scale
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
...
...
@@ -828,15 +828,15 @@ void MagStructFactDlg::Sync3DItem(int row)
tl2
::
create
<
t_vec_gl
>
({
posx
,
posy
,
posz
})
// pre-translate
);
m_plot
->
Get
Impl
()
->
SetObjectMatrix
(
objSphere
,
matSphere
);
m_plot
->
Get
Impl
()
->
SetObjectMatrix
(
objArrowRe
,
matArrowRe
);
m_plot
->
Get
Impl
()
->
SetObjectMatrix
(
objArrowIm
,
matArrowIm
);
m_plot
->
Get
Impl
()
->
SetObjectLabel
(
objSphere
,
itemName
->
text
().
toStdString
());
m_plot
->
Get
Impl
()
->
SetObjectCol
(
objSphere
,
r
,
g
,
b
,
1
);
m_plot
->
Get
Impl
()
->
SetObjectCol
(
objArrowRe
,
r
,
g
,
b
,
1
);
m_plot
->
Get
Impl
()
->
SetObjectCol
(
objArrowIm
,
1.
-
r
,
1.
-
g
,
1.
-
b
,
1
);
m_plot
->
Get
Impl
()
->
SetObjectVisible
(
objArrowRe
,
!
tl2
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plot
->
Get
Impl
()
->
SetObjectVisible
(
objArrowIm
,
!
tl2
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_plot
->
Get
Renderer
()
->
SetObjectMatrix
(
objSphere
,
matSphere
);
m_plot
->
Get
Renderer
()
->
SetObjectMatrix
(
objArrowRe
,
matArrowRe
);
m_plot
->
Get
Renderer
()
->
SetObjectMatrix
(
objArrowIm
,
matArrowIm
);
m_plot
->
Get
Renderer
()
->
SetObjectLabel
(
objSphere
,
itemName
->
text
().
toStdString
());
m_plot
->
Get
Renderer
()
->
SetObjectCol
(
objSphere
,
r
,
g
,
b
,
1
);
m_plot
->
Get
Renderer
()
->
SetObjectCol
(
objArrowRe
,
r
,
g
,
b
,
1
);
m_plot
->
Get
Renderer
()
->
SetObjectCol
(
objArrowIm
,
1.
-
r
,
1.
-
g
,
1.
-
b
,
1
);
m_plot
->
Get
Renderer
()
->
SetObjectVisible
(
objArrowRe
,
!
tl2
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plot
->
Get
Renderer
()
->
SetObjectVisible
(
objArrowIm
,
!
tl2
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_plot
->
update
();
}
...
...
@@ -853,11 +853,11 @@ void MagStructFactDlg::DelTabItem(int begin, int end)
for
(
int
row
=
0
;
row
<
m_nuclei
->
rowCount
();
++
row
)
{
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
0
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
1
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
2
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
}
m_plot
->
update
();
}
...
...
@@ -873,11 +873,11 @@ void MagStructFactDlg::DelTabItem(int begin, int end)
if
(
m_plot
)
{
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
0
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
1
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
2
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
m_plot
->
update
();
}
...
...
@@ -892,11 +892,11 @@ void MagStructFactDlg::DelTabItem(int begin, int end)
if
(
m_plot
)
{
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
0
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
1
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
if
(
std
::
size_t
obj
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
data
(
Qt
::
UserRole
+
2
).
toUInt
();
obj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
m_plot
->
update
();
}
...
...
@@ -1624,12 +1624,12 @@ void MagStructFactDlg::CalcB(bool bFullRecalc)
if
(
m_plot
)
{
t_mat_gl
matA
{
m_crystA
};
m_plot
->
Get
Impl
()
->
SetBTrafo
(
m_crystB
,
&
matA
);
m_plot
->
Get
Renderer
()
->
SetBTrafo
(
m_crystB
,
&
matA
);
}
if
(
m_plotSC
)
{
t_mat_gl
matA
{
m_crystA
};
m_plotSC
->
Get
Impl
()
->
SetBTrafo
(
m_crystB
,
&
matA
);
m_plotSC
->
Get
Renderer
()
->
SetBTrafo
(
m_crystB
,
&
matA
);
}
if
(
bFullRecalc
)
...
...
@@ -1853,7 +1853,7 @@ void MagStructFactDlg::Calc()
if
(
m_plotSC
)
{
for
(
auto
obj
:
m_3dobjsSC
)
m_plotSC
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plotSC
->
Get
Renderer
()
->
RemoveObject
(
obj
);
m_3dobjsSC
.
clear
();
}
...
...
@@ -1920,8 +1920,8 @@ void MagStructFactDlg::Calc()
// add 3d objs to super cell view
if
(
m_plotSC
)
{
auto
objArrowRe
=
m_plotSC
->
Get
Impl
()
->
AddLinkedObject
(
m_arrowSC
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
objArrowIm
=
m_plotSC
->
Get
Impl
()
->
AddLinkedObject
(
m_arrowSC
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
objArrowRe
=
m_plotSC
->
Get
Renderer
()
->
AddLinkedObject
(
m_arrowSC
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
objArrowIm
=
m_plotSC
->
Get
Renderer
()
->
AddLinkedObject
(
m_arrowSC
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
[
_vecReM
,
_vecImM
]
=
tl2
::
split_cplx
<
t_vec_cplx
,
t_vec
>
(
moment
);
auto
vecReM
=
tl2
::
convert
<
t_vec_gl
>
(
_vecReM
);
...
...
@@ -1930,7 +1930,7 @@ void MagStructFactDlg::Calc()
auto
normReM
=
tl2
::
norm
<
t_vec_gl
>
(
vecReM
);
auto
normImM
=
tl2
::
norm
<
t_vec_gl
>
(
vecImM
);
t_mat_gl
matArrowRe
=
GlPlot
_impl
::
GetArrowMatrix
(
t_mat_gl
matArrowRe
=
GlPlot
Renderer
::
GetArrowMatrix
(
vecReM
,
// to
1
,
// post-scale
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
...
...
@@ -1939,7 +1939,7 @@ void MagStructFactDlg::Calc()
posGL
// pre-translate
);
t_mat_gl
matArrowIm
=
GlPlot
_impl
::
GetArrowMatrix
(
t_mat_gl
matArrowIm
=
GlPlot
Renderer
::
GetArrowMatrix
(
vecImM
,
// to
1
,
// post-scale
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
...
...
@@ -1956,16 +1956,16 @@ void MagStructFactDlg::Calc()
<<
"Im{M} = ("
<<
moment
[
0
].
imag
()
<<
" "
<<
moment
[
1
].
imag
()
<<
" "
<<
moment
[
2
].
imag
()
<<
"); "
<<
"r = ("
<<
thepos
[
0
]
<<
" "
<<
thepos
[
1
]
<<
" "
<<
thepos
[
2
]
<<
")"
;
m_plotSC
->
Get
Impl
()
->
SetObjectMatrix
(
objArrowRe
,
matArrowRe
);
m_plotSC
->
Get
Impl
()
->
SetObjectMatrix
(
objArrowIm
,
matArrowIm
);
m_plotSC
->
Get
Impl
()
->
SetObjectCol
(
objArrowRe
,
r
,
g
,
b
,
1.
);
m_plotSC
->
Get
Impl
()
->
SetObjectCol
(
objArrowIm
,
1.
-
r
,
1.
-
g
,
1.
-
b
,
1.
);
//m_plotSC->Get
Impl
()->SetObjectLabel(objArrowRe, name + " (real)");
//m_plotSC->Get
Impl
()->SetObjectLabel(objArrowIm, name + " (imag)");
m_plotSC
->
Get
Impl
()
->
SetObjectDataString
(
objArrowRe
,
name
+
" (real); "
+
ostrMom
.
str
());
m_plotSC
->
Get
Impl
()
->
SetObjectDataString
(
objArrowIm
,
name
+
" (imag); "
+
ostrMom
.
str
());
m_plotSC
->
Get
Impl
()
->
SetObjectVisible
(
objArrowRe
,
!
tl2
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plotSC
->
Get
Impl
()
->
SetObjectVisible
(
objArrowIm
,
!
tl2
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_plotSC
->
Get
Renderer
()
->
SetObjectMatrix
(
objArrowRe
,
matArrowRe
);
m_plotSC
->
Get
Renderer
()
->
SetObjectMatrix
(
objArrowIm
,
matArrowIm
);
m_plotSC
->
Get
Renderer
()
->
SetObjectCol
(
objArrowRe
,
r
,
g
,
b
,
1.
);
m_plotSC
->
Get
Renderer
()
->
SetObjectCol
(
objArrowIm
,
1.
-
r
,
1.
-
g
,
1.
-
b
,
1.
);
//m_plotSC->Get
Renderer
()->SetObjectLabel(objArrowRe, name + " (real)");
//m_plotSC->Get
Renderer
()->SetObjectLabel(objArrowIm, name + " (imag)");
m_plotSC
->
Get
Renderer
()
->
SetObjectDataString
(
objArrowRe
,
name
+
" (real); "
+
ostrMom
.
str
());
m_plotSC
->
Get
Renderer
()
->
SetObjectDataString
(
objArrowIm
,
name
+
" (imag); "
+
ostrMom
.
str
());
m_plotSC
->
Get
Renderer
()
->
SetObjectVisible
(
objArrowRe
,
!
tl2
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plotSC
->
Get
Renderer
()
->
SetObjectVisible
(
objArrowIm
,
!
tl2
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_3dobjsSC
.
push_back
(
objArrowRe
);
m_3dobjsSC
.
push_back
(
objArrowIm
);
...
...
@@ -2055,7 +2055,7 @@ void MagStructFactDlg::PickerIntersectionSC(const t_vec3_gl* pos, std::size_t ob
{
if
(
pos
&&
m_plotSC
)
{
const
std
::
string
&
str
=
m_plotSC
->
Get
Impl
()
->
GetObjectDataString
(
objIdx
);
const
std
::
string
&
str
=
m_plotSC
->
Get
Renderer
()
->
GetObjectDataString
(
objIdx
);
m_status3DSC
->
setText
(
str
.
c_str
());
}
else
...
...
@@ -2099,13 +2099,13 @@ void MagStructFactDlg::AfterGLInitialisation()
SetGLInfos
();
// reference sphere and arrow for linked objects
m_sphere
=
m_plot
->
Get
Impl
()
->
AddSphere
(
0.05
,
0.
,
0.
,
0.
,
1.
,
1.
,
1.
,
1.
);
m_arrow
=
m_plot
->
Get
Impl
()
->
AddArrow
(
0.015
,
0.25
,
0.
,
0.
,
0.5
,
1.
,
1.
,
1.
,
1.
);
m_plot
->
Get
Impl
()
->
SetObjectVisible
(
m_sphere
,
false
);
m_plot
->
Get
Impl
()
->
SetObjectVisible
(
m_arrow
,
false
);
m_sphere
=
m_plot
->
Get
Renderer
()
->
AddSphere
(
0.05
,
0.
,
0.
,
0.
,
1.
,
1.
,
1.
,
1.
);
m_arrow
=
m_plot
->
Get
Renderer
()
->
AddArrow
(
0.015
,
0.25
,
0.
,
0.
,
0.5
,
1.
,
1.
,
1.
,
1.
);
m_plot
->
Get
Renderer
()
->
SetObjectVisible
(
m_sphere
,
false
);
m_plot
->
Get
Renderer
()
->
SetObjectVisible
(
m_arrow
,
false
);
// B matrix
m_plot
->
Get
Impl
()
->
SetBTrafo
(
m_crystB
);
m_plot
->
Get
Renderer
()
->
SetBTrafo
(
m_crystB
);
// add all 3d objects
Add3DItem
(
-
1
);
...
...
@@ -2121,13 +2121,13 @@ void MagStructFactDlg::AfterGLInitialisationSC()
SetGLInfos
();
// reference sphere and arrow for linked objects
m_sphereSC
=
m_plotSC
->
Get
Impl
()
->
AddSphere
(
0.05
,
0.
,
0.
,
0.
,
1.
,
1.
,
1.
,
1.
);
m_arrowSC
=
m_plotSC
->
Get
Impl
()
->
AddArrow
(
0.015
,
0.25
,
0.
,
0.
,
0.5
,
1.
,
1.
,
1.
,
1.
);
m_plotSC
->
Get
Impl
()
->
SetObjectVisible
(
m_sphereSC
,
false
);
m_plotSC
->
Get
Impl
()
->
SetObjectVisible
(
m_arrowSC
,
false
);
m_sphereSC
=
m_plotSC
->
Get
Renderer
()
->
AddSphere
(
0.05
,
0.
,
0.
,
0.
,
1.
,
1.
,
1.
,
1.
);
m_arrowSC
=
m_plotSC
->
Get
Renderer
()
->
AddArrow
(
0.015
,
0.25
,
0.
,
0.
,
0.5
,
1.
,
1.
,
1.
,
1.
);
m_plotSC
->
Get
Renderer
()
->
SetObjectVisible
(
m_sphereSC
,
false
);
m_plotSC
->
Get
Renderer
()
->
SetObjectVisible
(
m_arrowSC
,
false
);
// B matrix
m_plotSC
->
Get
Impl
()
->
SetBTrafo
(
m_crystB
);
m_plotSC
->
Get
Renderer
()
->
SetBTrafo
(
m_crystB
);
// add all 3d objects (generated in calc)
Calc
();
...
...
@@ -2147,7 +2147,7 @@ void MagStructFactDlg::SetGLInfos()
{
if
(
!
plot
)
continue
;
auto
[
strGlVer
,
strGlShaderVer
,
strGlVendor
,
strGlRenderer
]
=
plot
->
Get
Impl
()
->
GetGlDescr
();
auto
[
strGlVer
,
strGlShaderVer
,
strGlVendor
,
strGlRenderer
]
=
plot
->
Get
Renderer
()
->
GetGlDescr
();
m_labelGlInfos
[
0
]
->
setText
(
QString
(
"GL Version: "
)
+
strGlVer
.
c_str
()
+
QString
(
"."
));
m_labelGlInfos
[
1
]
->
setText
(
QString
(
"GL Shader Version: "
)
+
strGlShaderVer
.
c_str
()
+
QString
(
"."
));
m_labelGlInfos
[
2
]
->
setText
(
QString
(
"GL Vendor: "
)
+
strGlVendor
.
c_str
()
+
QString
(
"."
));
...
...
tools/moldyn/moldyn.cpp
View file @
612626b7
...
...
@@ -222,16 +222,16 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
m_plot
=
new
GlPlot
(
this
);
m_plot
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
m_plot
->
Get
Impl
()
->
EnablePicker
(
1
);
m_plot
->
Get
Impl
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
Get
Impl
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
Get
Impl
()
->
SetCoordMax
(
1.
);
m_plot
->
Get
Impl
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m_plot
->
Get
Renderer
()
->
EnablePicker
(
1
);
m_plot
->
Get
Renderer
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
Get
Renderer
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
Get
Renderer
()
->
SetCoordMax
(
1.
);
m_plot
->
Get
Renderer
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
tl2
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
connect
(
m_plot
,
&
GlPlot
::
AfterGLInitialisation
,
this
,
&
MolDynDlg
::
AfterGLInitialisation
);
connect
(
m_plot
,
&
GlPlot
::
GLInitialisationFailed
,
this
,
&
MolDynDlg
::
GLInitialisationFailed
);
connect
(
m_plot
->
Get
Impl
(),
&
GlPlot
_impl
::
PickerIntersection
,
this
,
&
MolDynDlg
::
PickerIntersection
);
connect
(
m_plot
->
Get
Renderer
(),
&
GlPlot
Renderer
::
PickerIntersection
,
this
,
&
MolDynDlg
::
PickerIntersection
);
connect
(
m_plot
,
&
GlPlot
::
MouseDown
,
this
,
&
MolDynDlg
::
PlotMouseDown
);
connect
(
m_plot
,
&
GlPlot
::
MouseUp
,
this
,
&
MolDynDlg
::
PlotMouseUp
);
connect
(
m_plot
,
&
GlPlot
::
MouseClick
,
this
,
&
MolDynDlg
::
PlotMouseClick
);
...
...
@@ -274,7 +274,7 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
connect
(
comboCoordSys
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
[
this
](
int
val
)
{
if
(
this
->
m_plot
)
this
->
m_plot
->
Get
Impl
()
->
SetCoordSys
(
val
);
this
->
m_plot
->
Get
Renderer
()
->
SetCoordSys
(
val
);
});
connect
(
m_spinScale
,
static_cast
<
void
(
QDoubleSpinBox
::*
)(
double
)
>
(
&
QDoubleSpinBox
::
valueChanged
),
this
,
[
this
](
double
val
)
{
...
...
@@ -310,7 +310,7 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
*/
std
::
size_t
MolDynDlg
::
Add3DAtom
(
const
t_vec
&
vec
,
const
t_vec
&
col
,
t_real
scale
,
const
std
::
string
&
typelabel
,
int
atomindex
)
{
auto
obj
=
m_plot
->
Get
Impl
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
col
[
0
],
col
[
1
],
col
[
2
],
1
);
auto
obj
=
m_plot
->
Get
Renderer
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
col
[
0
],
col
[
1
],
col
[
2
],
1
);
Change3DAtom
(
obj
,
&
vec
,
&
col
,
&
scale
,
&
typelabel
,
atomindex
);
return
obj
;
}
...
...
@@ -328,17 +328,17 @@ void MolDynDlg::Change3DAtom(std::size_t obj, const t_vec *vec, const t_vec *col
t_real_gl
((
*
vec
)[
0
]),
t_real_gl
((
*
vec
)[
1
]),
t_real_gl
((
*
vec
)[
2
]));
if
(
scale
)
mat
*=
tl2
::
hom_scaling
<
t_mat_gl
>
(
t_real_gl
(
*
scale
),
t_real_gl
(
*
scale
),
t_real_gl
(
*
scale
));
m_plot
->
Get
Impl
()
->
SetObjectMatrix
(
obj
,
mat
);
m_plot
->
Get
Renderer
()
->
SetObjectMatrix
(
obj
,
mat
);
}
if
(
col
)
m_plot
->
Get
Impl
()
->
SetObjectCol
(
obj
,
(
*
col
)[
0
],
(
*
col
)[
1
],
(
*
col
)[
2
],
1
);
if
(
col
)
m_plot
->
Get
Renderer
()
->
SetObjectCol
(
obj
,
(
*
col
)[
0
],
(
*
col
)[
1
],
(
*
col
)[
2
],
1
);
if
(
label
)
{
std
::
ostringstream
ostrData
;
ostrData
<<
*
label
<<
DATA_SEP
<<
atomindex
;
m_plot
->
Get
Impl
()
->
SetObjectLabel
(
obj
,
*
label
);
m_plot
->
Get
Impl
()
->
SetObjectDataString
(
obj
,
ostrData
.
str
());
m_plot
->
Get
Renderer
()
->
SetObjectLabel
(
obj
,
*
label
);
m_plot
->
Get
Renderer
()
->
SetObjectDataString
(
obj
,
ostrData
.
str
());
}
}
// ----------------------------------------------------------------------------
...
...
@@ -355,10 +355,10 @@ std::vector<std::tuple<std::size_t, std::size_t>> MolDynDlg::GetSelectedAtoms()
for
(
const
auto
&
obj
:
m_sphereHandles
)
{
// continue if object isn't selected
if
(
!
m_plot
->
Get
Impl
()
->
GetObjectHighlight
(
obj
))
if
(
!
m_plot
->
Get
Renderer
()
->
GetObjectHighlight
(
obj
))
continue
;
//const auto [typelabel, _atomSubTypeIdx] = SplitDataString(m_plot->Get
Impl
()->GetObjectDataString(obj));
//const auto [typelabel, _atomSubTypeIdx] = SplitDataString(m_plot->Get
Renderer
()->GetObjectDataString(obj));
// get indices for selected atoms
const
auto
[
bOk
,
atomTypeIdx
,
atomSubTypeIdx
,
sphereIdx
]
=
GetAtomIndexFromHandle
(
obj
);
...
...
@@ -675,7 +675,7 @@ void MolDynDlg::CalculateConvexHulls()
// remove old plot object
if
(
hull
.
plotObj
)
{
m_plot
->
Get
Impl
()
->
RemoveObject
(
*
hull
.
plotObj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
*
hull
.
plotObj
);
hull
.
plotObj
.
reset
();
}
...
...
@@ -705,7 +705,7 @@ void MolDynDlg::CalculateConvexHulls()
glnormals
.
emplace_back
(
tl2
::
convert
<
t_vec3_gl
,
t_vec
>
(
normal
));
}
hull
.
plotObj
=
m_plot
->
Get
Impl
()
->
AddTriangleObject
(
glvertices
,
glnormals
,
0
,
0
,
1
,
0.5
);
hull
.
plotObj
=
m_plot
->
Get
Renderer
()
->
AddTriangleObject
(
glvertices
,
glnormals
,
0
,
0
,
1
,
0.5
);
// TODO
}
...
...
@@ -727,13 +727,13 @@ void MolDynDlg::New()
for
(
auto
&
hull
:
m_hulls
)
{
if
(
hull
.
plotObj
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
*
hull
.
plotObj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
*
hull
.
plotObj
);
}
m_hulls
.
clear
();
for
(
const
auto
&
obj
:
m_sphereHandles
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
obj
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
obj
);
m_sphereHandles
.
clear
();
m_sliderFrame
->
setValue
(
0
);
...
...
@@ -810,7 +810,7 @@ void MolDynDlg::Load()
m_crystB
/=
t_real_gl
(
2
)
*
tl2
::
pi
<
t_real_gl
>
;
t_mat_gl
matA
{
m_crystA
};
m_plot
->
Get
Impl
()
->
SetBTrafo
(
m_crystB
,
&
matA
);
m_plot
->
Get
Renderer
()
->
SetBTrafo
(
m_crystB
,
&
matA
);
std
::
cout
<<
"A matrix: "
<<
m_crystA
<<
",
\n
"
<<
"B matrix: "
<<
m_crystB
<<
"."
<<
std
::
endl
;
...
...
@@ -919,7 +919,7 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
if
(
m_curPickedObj
>
0
)
{
const
auto
[
typelabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Impl
()
->
GetObjectDataString
(
m_curPickedObj
));
const
auto
[
typelabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Renderer
()
->
GetObjectDataString
(
m_curPickedObj
));
std
::
ostringstream
ostrLabel
;
ostrLabel
<<
"Current Atom: "
<<
typelabel
<<
" #"
<<
(
atomidx
+
1
);
...
...
@@ -961,7 +961,7 @@ void MolDynDlg::UpdateAtomsStatusMsg()
for
(
auto
handle
:
m_sphereHandles
)
{
if
(
m_plot
->
Get
Impl
()
->
GetObjectHighlight
(
handle
))
if
(
m_plot
->
Get
Renderer
()
->
GetObjectHighlight
(
handle
))
++
numSelected
;
}
...
...
@@ -985,7 +985,7 @@ void MolDynDlg::PlotMouseDown(bool left, bool mid, bool right)
if
(
left
&&
m_curPickedObj
>
0
)
{
m_plot
->
Get
Impl
()
->
SetObjectHighlight
(
m_curPickedObj
,
!
m_plot
->
Get
Impl
()
->
GetObjectHighlight
(
m_curPickedObj
));
m_plot
->
Get
Renderer
()
->
SetObjectHighlight
(
m_curPickedObj
,
!
m_plot
->
Get
Renderer
()
->
GetObjectHighlight
(
m_curPickedObj
));
UpdateAtomsStatusMsg
();
m_plot
->
update
();
}
...
...
@@ -1008,7 +1008,7 @@ void MolDynDlg::PlotMouseClick(bool left, bool mid, bool right)
// show context menu
if
(
right
&&
m_curPickedObj
>
0
)
{
const
auto
[
typelabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Impl
()
->
GetObjectDataString
(
m_curPickedObj
));
const
auto
[
typelabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Renderer
()
->
GetObjectDataString
(
m_curPickedObj
));
QString
atomLabel
=
typelabel
.
c_str
();
m_atomContextMenu
->
actions
()[
0
]
->
setText
(
"Delete This
\"
"
+
atomLabel
+
"
\"
Atom"
);
...
...
@@ -1034,7 +1034,7 @@ void MolDynDlg::SelectAll()
if
(
!
m_plot
)
return
;
for
(
auto
handle
:
m_sphereHandles
)
m_plot
->
Get
Impl
()
->
SetObjectHighlight
(
handle
,
1
);
m_plot
->
Get
Renderer
()
->
SetObjectHighlight
(
handle
,
1
);
UpdateAtomsStatusMsg
();
m_plot
->
update
();
...
...
@@ -1049,7 +1049,7 @@ void MolDynDlg::SelectNone()
if
(
!
m_plot
)
return
;
for
(
auto
handle
:
m_sphereHandles
)
m_plot
->
Get
Impl
()
->
SetObjectHighlight
(
handle
,
0
);
m_plot
->
Get
Renderer
()
->
SetObjectHighlight
(
handle
,
0
);
UpdateAtomsStatusMsg
();
m_plot
->
update
();
...
...
@@ -1084,7 +1084,9 @@ void MolDynDlg::SliderValueChanged(int val)
}
}
#ifdef USE_QHULL
CalculateConvexHulls
();
#endif
UpdateAtomsStatusMsg
();
m_plot
->
update
();
}
...
...
@@ -1152,13 +1154,13 @@ void MolDynDlg::SelectAtomsOfSameType()
return
;
// atom type to be selected
const
auto
[
atomLabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Impl
()
->
GetObjectDataString
(
m_curPickedObj
));
const
auto
[
atomLabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Renderer
()
->
GetObjectDataString
(
m_curPickedObj
));
for
(
auto
handle
:
m_sphereHandles
)
{
const
auto
[
typelabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Impl
()
->
GetObjectDataString
(
handle
));
const
auto
[
typelabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Renderer
()
->
GetObjectDataString
(
handle
));
if
(
typelabel
==
atomLabel
)
m_plot
->
Get
Impl
()
->
SetObjectHighlight
(
handle
,
1
);
m_plot
->
Get
Renderer
()
->
SetObjectHighlight
(
handle
,
1
);
}
UpdateAtomsStatusMsg
();
...
...
@@ -1176,7 +1178,7 @@ void MolDynDlg::DeleteSelectedAtoms()
for
(
auto
iter
=
m_sphereHandles
.
begin
();
iter
!=
m_sphereHandles
.
end
();)
{
auto
handle
=
*
iter
;
if
(
m_plot
->
Get
Impl
()
->
GetObjectHighlight
(
handle
))
if
(
m_plot
->
Get
Renderer
()
->
GetObjectHighlight
(
handle
))
{
const
auto
[
bOk
,
atomTypeIdx
,
atomSubTypeIdx
,
sphereIdx
]
=
GetAtomIndexFromHandle
(
handle
);
if
(
!
bOk
)
...
...
@@ -1186,7 +1188,7 @@ void MolDynDlg::DeleteSelectedAtoms()
}
// remove 3d objects
m_plot
->
Get
Impl
()
->
RemoveObject
(
handle
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
handle
);
iter
=
m_sphereHandles
.
erase
(
iter
);
// remove atom
...
...
@@ -1215,7 +1217,7 @@ void MolDynDlg::OnlyKeepSelectedAtoms()
for
(
auto
iter
=
m_sphereHandles
.
begin
();
iter
!=
m_sphereHandles
.
end
();)
{
auto
handle
=
*
iter
;
if
(
!
m_plot
->
Get
Impl
()
->
GetObjectHighlight
(
handle
))
if
(
!
m_plot
->
Get
Renderer
()
->
GetObjectHighlight
(
handle
))
{
const
auto
[
bOk
,
atomTypeIdx
,
atomSubTypeIdx
,
sphereIdx
]
=
GetAtomIndexFromHandle
(
handle
);
if
(
!
bOk
)
...
...
@@ -1225,7 +1227,7 @@ void MolDynDlg::OnlyKeepSelectedAtoms()
}
// remove 3d objects
m_plot
->
Get
Impl
()
->
RemoveObject
(
handle
);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
handle
);
iter
=
m_sphereHandles
.
erase
(
iter
);
// remove atom
...
...
@@ -1254,7 +1256,7 @@ void MolDynDlg::DeleteAtomUnderCursor()
return
;
// atom type to be deleted
const
auto
[
atomLabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Impl
()
->
GetObjectDataString
(
m_curPickedObj
));
const
auto
[
atomLabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Renderer
()
->
GetObjectDataString
(
m_curPickedObj
));
const
auto
[
bOk
,
atomTypeIdx
,
atomSubTypeIdx
,
sphereIdx
]
=
GetAtomIndexFromHandle
(
m_curPickedObj
);
if
(
!
bOk
)
{
...
...
@@ -1269,7 +1271,7 @@ void MolDynDlg::DeleteAtomUnderCursor()
}
// remove 3d objects
m_plot
->
Get
Impl
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_sphereHandles
.
erase
(
m_sphereHandles
.
begin
()
+
sphereIdx
);
// remove atom
...
...
@@ -1291,7 +1293,7 @@ void MolDynDlg::DeleteAllAtomsOfSameType()
return
;
// atom type to be deleted
const
auto
[
atomLabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Impl
()
->
GetObjectDataString
(
m_curPickedObj
));
const
auto
[
atomLabel
,
atomidx
]
=
SplitDataString
(
m_plot
->
Get
Renderer
()
->
GetObjectDataString
(
m_curPickedObj
));
std
::
size_t
startIdx
=
0
;
std
::
size_t
totalRemoved
=
0
;
...
...
@@ -1303,7 +1305,7 @@ void MolDynDlg::DeleteAllAtomsOfSameType()
{
// remove 3d objects
for
(
std
::
size_t
sphereIdx
=
startIdx
;
sphereIdx
<
startIdx
+
numAtoms
;
++
sphereIdx
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_sphereHandles
.
erase
(
m_sphereHandles
.
begin
()
+
startIdx
,
m_sphereHandles
.
begin
()
+
startIdx
+
numAtoms
);
// remove atoms
...
...
@@ -1334,7 +1336,7 @@ void MolDynDlg::KeepAtomsOfSameType()
return
;
// atom type to be deleted
const
std
::
string
&
atomLabel
=
m_plot
->
Get
Impl
()
->
GetObjectDataString
(
m_curPickedObj
);
const
std
::
string
&
atomLabel
=
m_plot
->
Get
Renderer
()
->
GetObjectDataString
(
m_curPickedObj
);
std
::
size_t
startIdx
=
0
;
std
::
size_t
totalRemoved
=
0
;
...
...
@@ -1346,7 +1348,7 @@ void MolDynDlg::KeepAtomsOfSameType()
{
// remove 3d objects
for
(
std
::
size_t
sphereIdx
=
startIdx
;
sphereIdx
<
startIdx
+
numAtoms
;
++
sphereIdx
)
m_plot
->
Get
Impl
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_plot
->
Get
Renderer
()
->
RemoveObject
(
m_sphereHandles
[
sphereIdx
]);
m_sphereHandles
.
erase
(
m_sphereHandles
.
begin
()
+
startIdx
,
m_sphereHandles
.
begin
()
+
startIdx
+
numAtoms
);
// remove atoms
...
...
@@ -1374,16 +1376,16 @@ void MolDynDlg::AfterGLInitialisation()
if
(
!
m_plot
)
return
;
// reference sphere for linked objects
m_sphere
=
m_plot
->
Get
Impl
()
->
AddSphere
(
0.05
,
0.
,
0.
,
0.
,
1.
,
1.
,
1.
,
1.
);