Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
Takin
mag-core
Commits
6f14e98e
Verified
Commit
6f14e98e
authored
May 28, 2022
by
Tobias WEBER
Browse files
continued with bz tool
parent
8980c018
Changes
6
Hide whitespace changes
Inline
Side-by-side
tools/bz/bz.cpp
View file @
6f14e98e
...
...
@@ -376,26 +376,42 @@ void BZDlg::CalcB(bool bFullRecalc)
std
::
istringstream
{
m_editBeta
->
text
().
toStdString
()}
>>
beta
;
std
::
istringstream
{
m_editGamma
->
text
().
toStdString
()}
>>
gamma
;
m_crystB
=
tl2
::
B_matrix
<
t_mat
>
(
a
,
b
,
c
,
alpha
/
180.
*
tl2
::
pi
<
t_real
>
,
beta
/
180.
*
tl2
::
pi
<
t_real
>
,
gamma
/
180.
*
tl2
::
pi
<
t_real
>
);
if
(
tl2
::
equals
<
t_real
>
(
a
,
0.
,
g_eps
)
||
a
<=
0.
||
tl2
::
equals
<
t_real
>
(
b
,
0.
,
g_eps
)
||
b
<=
0.
||
tl2
::
equals
<
t_real
>
(
c
,
0.
,
g_eps
)
||
c
<=
0.
||
tl2
::
equals
<
t_real
>
(
alpha
,
0.
,
g_eps
)
||
alpha
<=
0.
||
tl2
::
equals
<
t_real
>
(
beta
,
0.
,
g_eps
)
||
beta
<=
0.
||
tl2
::
equals
<
t_real
>
(
gamma
,
0.
,
g_eps
)
||
gamma
<=
0.
)
{
QMessageBox
::
critical
(
this
,
"Brillouin Zones"
,
"Error: Invalid lattice."
);
return
;
}
t_mat
crystB
=
tl2
::
B_matrix
<
t_mat
>
(
a
,
b
,
c
,
alpha
/
180.
*
tl2
::
pi
<
t_real
>
,
beta
/
180.
*
tl2
::
pi
<
t_real
>
,
gamma
/
180.
*
tl2
::
pi
<
t_real
>
);
bool
ok
=
true
;
std
::
tie
(
m_crystA
,
ok
)
=
tl2
::
inv
(
m_crystB
);
t_mat
crystA
=
tl2
::
unit
<
t_mat
>
(
3
);
std
::
tie
(
crystA
,
ok
)
=
tl2
::
inv
(
crystB
);
if
(
!
ok
)
{
m_crystA
=
tl2
::
unit
<
t_mat
>
();
std
::
cerr
<<
"Error: Cannot invert B matrix."
<<
std
::
endl
;
}
else
{
m_crystA
*=
t_real
(
2
)
*
tl2
::
pi
<
t_real
>
;
QMessageBox
::
critical
(
this
,
"Brillouin Zones"
,
"Error: Cannot invert B matrix."
);
return
;
}
m_crystA
=
crystA
*
t_real
(
2
)
*
tl2
::
pi
<
t_real
>
;
m_crystB
=
crystB
;
if
(
m_plot
)
{
t_mat_gl
matA
{
m_crystA
};
m_plot
->
GetRenderer
()
->
SetBTrafo
(
m_crystB
,
&
matA
);
}
if
(
bFullRecalc
)
CalcBZ
();
}
...
...
@@ -444,13 +460,19 @@ void BZDlg::CalcBZ()
// calculate voronoi diagram
auto
[
voronoi
,
triags
,
neighbours
]
=
geo
::
calc_delaunay
(
3
,
Qs_invA
,
false
);
std
::
cout
<<
voronoi
.
size
()
<<
" "
<<
triags
.
size
()
<<
" "
<<
neighbours
.
size
()
<<
std
::
endl
;
ostr
<<
"
\n
# Brillouin zone"
<<
std
::
endl
;
ClearPlot
();
//for(const t_vec& Q : Qs_invA)
// PlotAddBraggPeak(Q);
for
(
std
::
size_t
idx
=
0
;
idx
<
voronoi
.
size
();
++
idx
)
{
t_vec
voro
=
voronoi
[
idx
];
tl2
::
set_eps_0
(
voro
,
g_eps
);
PlotAddVoronoiVertex
(
voro
);
ostr
<<
"vertex "
<<
idx
<<
": "
<<
voro
<<
std
::
endl
;
for
(
std
::
size_t
nidx
:
neighbours
[
idx
])
ostr
<<
"
\t
neighbour index: "
<<
nidx
<<
std
::
endl
;
...
...
tools/bz/bz.h
View file @
6f14e98e
...
...
@@ -131,7 +131,9 @@ protected:
void
CalcB
(
bool
bFullRecalc
=
true
);
void
CalcBZ
();
void
Add3DItem
(
int
row
=-
1
);
void
ClearPlot
();
void
PlotAddVoronoiVertex
(
const
t_vec
&
pos
);
void
PlotAddBraggPeak
(
const
t_vec
&
pos
);
void
Set3DStatusMsg
(
const
std
::
string
&
msg
);
void
ShowBZPlot
();
...
...
@@ -154,6 +156,7 @@ private:
bool
m_ignoreCalc
=
0
;
long
m_curPickedObj
=
-
1
;
std
::
vector
<
std
::
size_t
>
m_plotObjs
;
private:
...
...
tools/bz/bz_ops.cpp
View file @
6f14e98e
...
...
@@ -114,8 +114,6 @@ void BZDlg::AddTabItem(int row, const t_mat& op)
new
QTableWidgetItem
(
OpToStr
(
op
).
c_str
()));
}
Add3DItem
(
row
);
m_symops
->
scrollToItem
(
m_symops
->
item
(
row
,
0
));
m_symops
->
setCurrentCell
(
row
,
0
);
...
...
@@ -133,15 +131,6 @@ void BZDlg::DelTabItem(int begin, int end)
// if nothing is selected, clear all items
if
(
begin
==
-
1
||
m_symops
->
selectedItems
().
count
()
==
0
)
{
if
(
m_plot
)
{
for
(
int
row
=
0
;
row
<
m_symops
->
rowCount
();
++
row
)
if
(
std
::
size_t
obj
=
m_symops
->
item
(
row
,
COL_OP
)
->
data
(
Qt
::
UserRole
).
toUInt
();
obj
)
m_plot
->
GetRenderer
()
->
RemoveObject
(
obj
);
m_plot
->
update
();
}
m_symops
->
clearContents
();
m_symops
->
setRowCount
(
0
);
}
...
...
@@ -149,15 +138,6 @@ void BZDlg::DelTabItem(int begin, int end)
{
for
(
int
row
:
GetSelectedRows
(
true
))
{
// remove 3d object
if
(
m_plot
)
{
if
(
std
::
size_t
obj
=
m_symops
->
item
(
row
,
COL_OP
)
->
data
(
Qt
::
UserRole
).
toUInt
();
obj
)
m_plot
->
GetRenderer
()
->
RemoveObject
(
obj
);
m_plot
->
update
();
}
m_symops
->
removeRow
(
row
);
}
}
...
...
@@ -165,15 +145,6 @@ void BZDlg::DelTabItem(int begin, int end)
{
for
(
int
row
=
end
-
1
;
row
>=
begin
;
--
row
)
{
// remove 3d object
if
(
m_plot
)
{
if
(
std
::
size_t
obj
=
m_symops
->
item
(
row
,
COL_OP
)
->
data
(
Qt
::
UserRole
).
toUInt
();
obj
)
m_plot
->
GetRenderer
()
->
RemoveObject
(
obj
);
m_plot
->
update
();
}
m_symops
->
removeRow
(
row
);
}
}
...
...
tools/bz/bz_plot.cpp
View file @
6f14e98e
...
...
@@ -51,33 +51,33 @@ void BZDlg::ShowBZPlot()
m_plot
->
GetRenderer
()
->
GetCamera
().
SetDist
(
1.5
);
m_plot
->
GetRenderer
()
->
GetCamera
().
UpdateTransformation
();
auto
labCoordSys
=
new
QLabel
(
"Coordinate System:"
,
/*m_dlgPlot*/
this
);
auto
comboCoordSys
=
new
QComboBox
(
/*m_dlgPlot*/
this
);
m_status3D
=
new
QLabel
(
/*m_dlgPlot*/
this
);
//auto labCoordSys = new QLabel("Coordinate System:", this);
//auto comboCoordSys = new QComboBox(this);
//comboCoordSys->addItem("Fractional Units (rlu)");
//comboCoordSys->addItem("Lab Units (A)");
comboCoordSys
->
addItem
(
"Fractional Units (rlu)"
);
comboCoordSys
->
addItem
(
"Lab Units (A)"
);
m_status3D
=
new
QLabel
(
this
);
m_plot
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
labCoordSys
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Fixed
,
QSizePolicy
::
Fixed
});
//
labCoordSys->setSizePolicy(QSizePolicy{QSizePolicy::Fixed, QSizePolicy::Fixed});
auto
grid
=
new
QGridLayout
(
m_dlgPlot
);
grid
->
setSpacing
(
2
);
grid
->
setContentsMargins
(
4
,
4
,
4
,
4
);
grid
->
addWidget
(
m_plot
.
get
(),
0
,
0
,
1
,
2
);
grid
->
addWidget
(
labCoordSys
,
1
,
0
,
1
,
1
);
grid
->
addWidget
(
comboCoordSys
,
1
,
1
,
1
,
1
);
//
grid->addWidget(labCoordSys, 1,0,1,1);
//
grid->addWidget(comboCoordSys, 1,1,1,1);
grid
->
addWidget
(
m_status3D
,
2
,
0
,
1
,
2
);
connect
(
m_plot
.
get
(),
&
tl2
::
GlPlot
::
AfterGLInitialisation
,
this
,
&
BZDlg
::
AfterGLInitialisation
);
connect
(
m_plot
->
GetRenderer
(),
&
tl2
::
GlPlotRenderer
::
PickerIntersection
,
this
,
&
BZDlg
::
PickerIntersection
);
connect
(
m_plot
.
get
(),
&
tl2
::
GlPlot
::
MouseDown
,
this
,
&
BZDlg
::
PlotMouseDown
);
connect
(
m_plot
.
get
(),
&
tl2
::
GlPlot
::
MouseUp
,
this
,
&
BZDlg
::
PlotMouseUp
);
connect
(
comboCoordSys
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
[
this
](
int
val
)
/*
connect(comboCoordSys, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this](int val)
{
if(this->m_plot)
this->m_plot->GetRenderer()->SetCoordSys(val);
});
});
*/
if
(
m_sett
&&
m_sett
->
contains
(
"geo_3dview"
))
...
...
@@ -93,22 +93,64 @@ void BZDlg::ShowBZPlot()
/**
* add
3d objec
t
* add
a voronoi vertex to the plo
t
*/
void
BZDlg
::
Add3DItem
(
int
row
)
void
BZDlg
::
PlotAddVoronoiVertex
(
const
t_vec
&
pos
)
{
if
(
!
m_plot
)
return
;
// TODO
/*qreal r=1, g=1, b=1;
t_real_gl
r
=
0
,
g
=
0
,
b
=
1
;
t_real_gl
scale
=
1
;
t_real_gl
posx
=
static_cast
<
t_real_gl
>
(
pos
[
0
]);
t_real_gl
posy
=
static_cast
<
t_real_gl
>
(
pos
[
1
]);
t_real_gl
posz
=
static_cast
<
t_real_gl
>
(
pos
[
2
]);
auto
obj
=
m_plot
->
GetRenderer
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
r
,
g
,
b
,
1
);
//auto obj = m_plot->GetRenderer()->AddSphere(0.05, 0,0,0, r,g,b,1);
m_plot
->
GetRenderer
()
->
SetObjectMatrix
(
obj
,
tl2
::
hom_translation
<
t_mat_gl
>
(
posx
,
posy
,
posz
)
*
tl2::hom_scaling<t_mat_gl>(scale,scale,scale));
//m_plot->GetRenderer()->SetObjectLabel(obj, "");
m_plot->update();*/
tl2
::
hom_scaling
<
t_mat_gl
>
(
scale
,
scale
,
scale
));
//m_plot->GetRenderer()->SetObjectLabel(obj, "Voronoi Vertex");
m_plotObjs
.
push_back
(
obj
);
m_plot
->
update
();
}
/**
* add a bragg peak to the plot
*/
void
BZDlg
::
PlotAddBraggPeak
(
const
t_vec
&
pos
)
{
if
(
!
m_plot
)
return
;
t_real_gl
r
=
1
,
g
=
0
,
b
=
0
;
t_real_gl
scale
=
1
;
t_real_gl
posx
=
static_cast
<
t_real_gl
>
(
pos
[
0
]);
t_real_gl
posy
=
static_cast
<
t_real_gl
>
(
pos
[
1
]);
t_real_gl
posz
=
static_cast
<
t_real_gl
>
(
pos
[
2
]);
auto
obj
=
m_plot
->
GetRenderer
()
->
AddLinkedObject
(
m_sphere
,
0
,
0
,
0
,
r
,
g
,
b
,
1
);
//auto obj = m_plot->GetRenderer()->AddSphere(0.05, 0,0,0, r,g,b,1);
m_plot
->
GetRenderer
()
->
SetObjectMatrix
(
obj
,
tl2
::
hom_translation
<
t_mat_gl
>
(
posx
,
posy
,
posz
)
*
tl2
::
hom_scaling
<
t_mat_gl
>
(
scale
,
scale
,
scale
));
//m_plot->GetRenderer()->SetObjectLabel(obj, "Voronoi Vertex");
m_plotObjs
.
push_back
(
obj
);
m_plot
->
update
();
}
void
BZDlg
::
ClearPlot
()
{
if
(
!
m_plot
)
return
;
for
(
std
::
size_t
obj
:
m_plotObjs
)
m_plot
->
GetRenderer
()
->
RemoveObject
(
obj
);
m_plotObjs
.
clear
();
m_plot
->
update
();
}
...
...
@@ -182,10 +224,7 @@ void BZDlg::AfterGLInitialisation()
m_plot
->
GetRenderer
()
->
SetObjectVisible
(
m_sphere
,
false
);
// B matrix
m_plot
->
GetRenderer
()
->
SetBTrafo
(
m_crystB
);
// add all 3d objects
Add3DItem
(
-
1
);
//m_plot->GetRenderer()->SetBTrafo(m_crystB);
// GL device info
auto
[
strGlVer
,
strGlShaderVer
,
strGlVendor
,
strGlRenderer
]
...
...
tools/structfact/CMakeLists.txt
View file @
6f14e98e
...
...
@@ -68,7 +68,7 @@ if(BUILD_LIB)
add_definitions
(
-DBUILD_LIB
)
add_library
(
takin_structfact SHARED
structfact.cpp structfact_file.cpp
structfact_
struct
plot.cpp structfact_main.cpp
structfact_plot.cpp structfact_main.cpp
structfact_findsg.cpp structfact_nuclei.cpp
structfact.h
../../tlibs2/libs/qt/gl.cpp ../../tlibs2/libs/qt/gl.h
...
...
@@ -76,7 +76,7 @@ if(BUILD_LIB)
else
()
add_executable
(
takin_structfact
structfact.cpp structfact_file.cpp
structfact_
struct
plot.cpp structfact_main.cpp
structfact_plot.cpp structfact_main.cpp
structfact_findsg.cpp structfact_nuclei.cpp
structfact.h
../../tlibs2/libs/qt/gl.cpp ../../tlibs2/libs/qt/gl.h
...
...
tools/structfact/structfact_
struct
plot.cpp
→
tools/structfact/structfact_plot.cpp
View file @
6f14e98e
File moved
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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