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
c599e326
Verified
Commit
c599e326
authored
May 30, 2022
by
Tobias WEBER
Browse files
bz: started with bz cut plot
parent
056276f6
Changes
9
Hide whitespace changes
Inline
Side-by-side
tools/bz/CMakeLists.txt
View file @
c599e326
...
...
@@ -71,7 +71,8 @@ include_directories(
add_executable
(
takin_bz
bz.cpp bz_file.cpp
bz_plot.cpp bz_main.cpp
bz_ops.cpp bz.h
bz_ops.cpp bz.h globals.h
plot_cut.cpp plot_cut.h
../../tlibs2/libs/qt/gl.cpp ../../tlibs2/libs/qt/gl.h
../../tlibs2/libs/qt/glplot.cpp ../../tlibs2/libs/qt/glplot.h
)
...
...
tools/bz/bz.cpp
View file @
c599e326
...
...
@@ -32,6 +32,7 @@
#include
<QtWidgets/QTabWidget>
#include
<QtWidgets/QLabel>
#include
<QtWidgets/QToolButton>
#include
<QtWidgets/QPushButton>
#include
<QtWidgets/QFileDialog>
#include
<QtWidgets/QMessageBox>
...
...
@@ -42,7 +43,6 @@
namespace
algo
=
boost
::
algorithm
;
#include
"../structfact/loadcif.h"
#include
"tlibs2/libs/maths.h"
#include
"tlibs2/libs/phys.h"
#include
"tlibs2/libs/algos.h"
#include
"tlibs2/libs/qt/helper.h"
...
...
@@ -82,24 +82,23 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
m_symops
->
setHorizontalHeaderItem
(
COL_OP
,
new
QTableWidgetItem
{
"Symmetry Operation"
});
m_symops
->
setColumnWidth
(
COL_OP
,
500
);
QToolButton
*
pTabB
tnAdd
=
new
QToolButton
(
symopspanel
);
QToolButton
*
pTabB
tnDel
=
new
QToolButton
(
symopspanel
);
QToolButton
*
pTabB
tnUp
=
new
QToolButton
(
symopspanel
);
QToolButton
*
pTabB
tnDown
=
new
QToolButton
(
symopspanel
);
Q
Tool
Button
*
pTabB
tnSG
=
new
Q
Tool
Button
(
symopspanel
);
QToolButton
*
b
tnAdd
=
new
QToolButton
(
symopspanel
);
QToolButton
*
b
tnDel
=
new
QToolButton
(
symopspanel
);
QToolButton
*
b
tnUp
=
new
QToolButton
(
symopspanel
);
QToolButton
*
b
tnDown
=
new
QToolButton
(
symopspanel
);
Q
Push
Button
*
b
tnSG
=
new
Q
Push
Button
(
"Get SymOps"
,
symopspanel
);
m_symops
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
pTabBtnAdd
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnDel
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnUp
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnDown
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnSG
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnAdd
->
setText
(
"Add SymOp"
);
pTabBtnDel
->
setText
(
"Delete SymOp"
);
pTabBtnUp
->
setText
(
"Move SymOp Up"
);
pTabBtnDown
->
setText
(
"Move SymOp Down"
);
pTabBtnSG
->
setText
(
"Get SymOps"
);
btnAdd
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
btnDel
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
btnUp
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
btnDown
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
btnSG
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
btnAdd
->
setText
(
"Add SymOp"
);
btnDel
->
setText
(
"Delete SymOp"
);
btnUp
->
setText
(
"Move SymOp Up"
);
btnDown
->
setText
(
"Move SymOp Down"
);
m_editA
=
new
QLineEdit
(
"5"
,
symopspanel
);
m_editB
=
new
QLineEdit
(
"5"
,
symopspanel
);
...
...
@@ -127,14 +126,14 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
int
y
=
0
;
//pTabGrid->addWidget(m_plot.get(), y,0,1,4);
pTabGrid
->
addWidget
(
m_symops
,
y
,
0
,
1
,
4
);
pTabGrid
->
addWidget
(
pTabB
tnAdd
,
++
y
,
0
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabB
tnDel
,
y
,
1
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabB
tnUp
,
y
,
2
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabB
tnDown
,
y
,
3
,
1
,
1
);
pTabGrid
->
addWidget
(
b
tnAdd
,
++
y
,
0
,
1
,
1
);
pTabGrid
->
addWidget
(
b
tnDel
,
y
,
1
,
1
,
1
);
pTabGrid
->
addWidget
(
b
tnUp
,
y
,
2
,
1
,
1
);
pTabGrid
->
addWidget
(
b
tnDown
,
y
,
3
,
1
,
1
);
pTabGrid
->
addWidget
(
new
QLabel
(
"Space Group:"
),
++
y
,
0
,
1
,
1
);
pTabGrid
->
addWidget
(
m_comboSG
,
y
,
1
,
1
,
2
);
pTabGrid
->
addWidget
(
pTabB
tnSG
,
y
,
3
,
1
,
1
);
pTabGrid
->
addWidget
(
b
tnSG
,
y
,
3
,
1
,
1
);
auto
sep1
=
new
QFrame
(
symopspanel
);
sep1
->
setFrameStyle
(
QFrame
::
HLine
);
...
...
@@ -169,11 +168,11 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
for
(
auto
*
edit
:
std
::
vector
<
QLineEdit
*>
{{
m_editA
,
m_editB
,
m_editC
,
m_editAlpha
,
m_editBeta
,
m_editGamma
}})
connect
(
edit
,
&
QLineEdit
::
textEdited
,
this
,
[
this
]()
{
this
->
CalcB
();
});
connect
(
pTabB
tnAdd
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
this
->
AddTabItem
(
-
1
);
});
connect
(
pTabB
tnDel
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
BZDlg
::
DelTabItem
();
});
connect
(
pTabB
tnUp
,
&
QToolButton
::
clicked
,
this
,
&
BZDlg
::
MoveTabItemUp
);
connect
(
pTabB
tnDown
,
&
QToolButton
::
clicked
,
this
,
&
BZDlg
::
MoveTabItemDown
);
connect
(
pTabB
tnSG
,
&
Q
Tool
Button
::
clicked
,
this
,
&
BZDlg
::
GetSymOpsFromSG
);
connect
(
b
tnAdd
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
this
->
AddTabItem
(
-
1
);
});
connect
(
b
tnDel
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
BZDlg
::
DelTabItem
();
});
connect
(
b
tnUp
,
&
QToolButton
::
clicked
,
this
,
&
BZDlg
::
MoveTabItemUp
);
connect
(
b
tnDown
,
&
QToolButton
::
clicked
,
this
,
&
BZDlg
::
MoveTabItemDown
);
connect
(
b
tnSG
,
&
Q
Push
Button
::
clicked
,
this
,
&
BZDlg
::
GetSymOpsFromSG
);
connect
(
m_symops
,
&
QTableWidget
::
currentCellChanged
,
this
,
&
BZDlg
::
TableCurCellChanged
);
connect
(
m_symops
,
&
QTableWidget
::
entered
,
this
,
&
BZDlg
::
TableCellEntered
);
...
...
@@ -184,33 +183,71 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
}
{
// brillouin zone cuts panel
auto
cutspanel
=
new
QWidget
(
this
);
auto
pGrid
=
new
QGridLayout
(
cutspanel
);
pGrid
->
setSpacing
(
4
);
pGrid
->
setContentsMargins
(
4
,
4
,
4
,
4
);
m_bzscene
=
new
BZCutScene
(
cutspanel
);
m_bzview
=
new
BZCutView
(
m_bzscene
);
for
(
QDoubleSpinBox
**
const
cut
:
{
&
m_cutX
,
&
m_cutY
,
&
m_cutZ
,
&
m_cutD
})
{
*
cut
=
new
QDoubleSpinBox
(
cutspanel
);
(
*
cut
)
->
setMinimum
(
-
99
);
(
*
cut
)
->
setMaximum
(
99
);
(
*
cut
)
->
setDecimals
(
2
);
(
*
cut
)
->
setSingleStep
(
1
);
(
*
cut
)
->
setValue
(
0
);
}
m_cutZ
->
setValue
(
1
);
pGrid
->
addWidget
(
m_bzview
,
0
,
0
,
1
,
4
);
pGrid
->
addWidget
(
new
QLabel
(
"Plane Normal:"
),
1
,
0
,
1
,
1
);
pGrid
->
addWidget
(
m_cutX
,
1
,
1
,
1
,
1
);
pGrid
->
addWidget
(
m_cutY
,
1
,
2
,
1
,
1
);
pGrid
->
addWidget
(
m_cutZ
,
1
,
3
,
1
,
1
);
pGrid
->
addWidget
(
new
QLabel
(
"Plane Offset:"
),
2
,
0
,
1
,
1
);
pGrid
->
addWidget
(
m_cutD
,
2
,
1
,
1
,
1
);
// signals
// TODO
tabs
->
addTab
(
cutspanel
,
"Cuts"
);
}
{
// brillouin zone panel
auto
sfact
panel
=
new
QWidget
(
this
);
auto
pGrid
=
new
QGridLayout
(
sfact
panel
);
auto
bz
panel
=
new
QWidget
(
this
);
auto
pGrid
=
new
QGridLayout
(
bz
panel
);
pGrid
->
setSpacing
(
4
);
pGrid
->
setContentsMargins
(
4
,
4
,
4
,
4
);
m_bz
=
new
QPlainTextEdit
(
sfact
panel
);
m_bz
=
new
QPlainTextEdit
(
bz
panel
);
m_bz
->
setReadOnly
(
true
);
m_bz
->
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
FixedFont
));
m_maxBZ
=
new
QSpinBox
(
sfact
panel
);
m_maxBZ
=
new
QSpinBox
(
bz
panel
);
m_maxBZ
->
setMinimum
(
1
);
m_maxBZ
->
setMaximum
(
99
);
m_maxBZ
->
setValue
(
4
);
QPushButton
*
btnShowBZ
=
new
QPushButton
(
"3D View..."
,
bzpanel
);
pGrid
->
addWidget
(
m_bz
,
0
,
0
,
1
,
4
);
pGrid
->
addWidget
(
new
QLabel
(
"Max. Order:"
),
1
,
0
,
1
,
1
);
pGrid
->
addWidget
(
m_maxBZ
,
1
,
1
,
1
,
1
);
pGrid
->
addWidget
(
btnShowBZ
,
1
,
3
,
1
,
1
);
// signals
connect
(
m_maxBZ
,
static_cast
<
void
(
QSpinBox
::*
)(
int
)
>
(
&
QSpinBox
::
valueChanged
),
this
,
[
this
]()
{
this
->
CalcBZ
();
});
connect
(
btnShowBZ
,
&
QPushButton
::
clicked
,
this
,
&
BZDlg
::
ShowBZPlot
);
tabs
->
addTab
(
sfact
panel
,
"Brillouin Zone"
);
tabs
->
addTab
(
bz
panel
,
"Brillouin Zone"
);
}
...
...
tools/bz/bz.h
View file @
c599e326
...
...
@@ -33,6 +33,7 @@
#include
<QtWidgets/QPlainTextEdit>
#include
<QtWidgets/QLineEdit>
#include
<QtWidgets/QSpinBox>
#include
<QtWidgets/QDoubleSpinBox>
#include
<QtWidgets/QMenuBar>
#include
<QtWidgets/QMenu>
#include
<QtWidgets/QLabel>
...
...
@@ -43,30 +44,13 @@
#include
<vector>
#include
<sstream>
#include
<boost/math/quaternion.hpp>
namespace
math
=
boost
::
math
;
#include
"globals.h"
#include
"plot_cut.h"
#include
"tlibs2/libs/qt/glplot.h"
#include
"tlibs2/libs/math20.h"
#include
"tlibs2/libs/qt/numerictablewidgetitem.h"
using
t_real
=
double
;
using
t_vec
=
tl2
::
vec
<
t_real
,
std
::
vector
>
;
using
t_mat
=
tl2
::
mat
<
t_real
,
std
::
vector
>
;
using
t_quat
=
math
::
quaternion
<
t_real
>
;
using
t_real_gl
=
tl2
::
t_real_gl
;
using
t_vec2_gl
=
tl2
::
t_vec2_gl
;
using
t_vec3_gl
=
tl2
::
t_vec3_gl
;
using
t_vec_gl
=
tl2
::
t_vec_gl
;
using
t_mat_gl
=
tl2
::
t_mat_gl
;
constexpr
t_real
g_eps
=
1e-6
;
constexpr
int
g_prec
=
6
;
enum
:
int
{
COL_OP
=
0
,
...
...
@@ -86,23 +70,33 @@ protected:
QSettings
*
m_sett
=
nullptr
;
QMenuBar
*
m_menu
=
nullptr
;
// plotter
QDialog
*
m_dlgPlot
=
nullptr
;
std
::
shared_ptr
<
tl2
::
GlPlot
>
m_plot
;
std
::
size_t
m_sphere
=
0
;
QLabel
*
m_labelGlInfos
[
4
]
=
{
nullptr
,
nullptr
,
nullptr
,
nullptr
};
QLabel
*
m_status3D
=
nullptr
;
QTableWidget
*
m_symops
=
nullptr
;
QPlainTextEdit
*
m_bz
=
nullptr
;
// symops panel
QLineEdit
*
m_editA
=
nullptr
;
QLineEdit
*
m_editB
=
nullptr
;
QLineEdit
*
m_editC
=
nullptr
;
QLineEdit
*
m_editAlpha
=
nullptr
;
QLineEdit
*
m_editBeta
=
nullptr
;
QLineEdit
*
m_editGamma
=
nullptr
;
QTableWidget
*
m_symops
=
nullptr
;
QComboBox
*
m_comboSG
=
nullptr
;
// cuts panel
BZCutScene
*
m_bzscene
=
nullptr
;
BZCutView
*
m_bzview
=
nullptr
;
QDoubleSpinBox
*
m_cutX
=
nullptr
;
QDoubleSpinBox
*
m_cutY
=
nullptr
;
QDoubleSpinBox
*
m_cutZ
=
nullptr
;
QDoubleSpinBox
*
m_cutD
=
nullptr
;
// brillouin zone panel
QPlainTextEdit
*
m_bz
=
nullptr
;
QSpinBox
*
m_maxBZ
=
nullptr
;
QMenu
*
m_pTabContextMenu
=
nullptr
;
// menu in case a symop is selected
...
...
tools/bz/bz_file.cpp
View file @
c599e326
...
...
@@ -38,7 +38,6 @@
namespace
pt
=
boost
::
property_tree
;
#include
"../structfact/loadcif.h"
#include
"tlibs2/libs/maths.h"
#include
"tlibs2/libs/algos.h"
using
namespace
tl2_ops
;
...
...
tools/bz/bz_ops.cpp
View file @
c599e326
...
...
@@ -34,7 +34,6 @@
#include
<iostream>
#include
<tuple>
#include
"tlibs2/libs/maths.h"
#include
"tlibs2/libs/phys.h"
#include
"tlibs2/libs/algos.h"
#include
"tlibs2/libs/qt/helper.h"
...
...
tools/bz/bz_plot.cpp
View file @
c599e326
...
...
@@ -29,7 +29,6 @@
#include
"bz.h"
#include
"tlibs2/libs/maths.h"
#include
"tlibs2/libs/phys.h"
#include
"tlibs2/libs/algos.h"
...
...
tools/bz/globals.h
0 → 100644
View file @
c599e326
/**
* brillouin zone tool
* @author Tobias Weber <tweber@ill.fr>
* @date Maz-2022
* @license GPLv3, see 'LICENSE' file
*
* ----------------------------------------------------------------------------
* mag-core (part of the Takin software suite)
* Copyright (C) 2018-2022 Tobias WEBER (Institut Laue-Langevin (ILL),
* Grenoble, France).
* "misc" project
* Copyright (C) 2017-2021 Tobias WEBER (privately developed).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*/
#ifndef __BZTOOL_GLOBALS_H__
#define __BZTOOL_GLOBALS_H__
#include
<boost/math/quaternion.hpp>
namespace
math
=
boost
::
math
;
#include
"tlibs2/libs/maths.h"
#include
"tlibs2/libs/qt/gl.h"
using
t_real
=
double
;
using
t_vec
=
tl2
::
vec
<
t_real
,
std
::
vector
>
;
using
t_mat
=
tl2
::
mat
<
t_real
,
std
::
vector
>
;
using
t_quat
=
math
::
quaternion
<
t_real
>
;
using
t_real_gl
=
tl2
::
t_real_gl
;
using
t_vec2_gl
=
tl2
::
t_vec2_gl
;
using
t_vec3_gl
=
tl2
::
t_vec3_gl
;
using
t_vec_gl
=
tl2
::
t_vec_gl
;
using
t_mat_gl
=
tl2
::
t_mat_gl
;
constexpr
t_real
g_eps
=
1e-6
;
constexpr
int
g_prec
=
6
;
#endif
tools/bz/plot_cut.cpp
0 → 100644
View file @
c599e326
/**
* brillouin zone tool
* @author Tobias Weber <tweber@ill.fr>
* @date May-2022
* @license GPLv3, see 'LICENSE' file
*
* ----------------------------------------------------------------------------
* mag-core (part of the Takin software suite)
* Copyright (C) 2018-2022 Tobias WEBER (Institut Laue-Langevin (ILL),
* Grenoble, France).
* "misc" project
* Copyright (C) 2017-2021 Tobias WEBER (privately developed).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*/
#include
"plot_cut.h"
// --------------------------------------------------------------------------------
BZCutScene
::
BZCutScene
(
QWidget
*
parent
)
:
QGraphicsScene
(
parent
)
{
//addLine(QLineF(0,0, 10,10));
}
BZCutScene
::~
BZCutScene
()
{
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
BZCutView
::
BZCutView
(
BZCutScene
*
scene
)
:
QGraphicsView
(
scene
,
static_cast
<
QWidget
*>
(
scene
->
parent
()))
{
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
TextAntialiasing
);
setDragMode
(
QGraphicsView
::
ScrollHandDrag
);
setInteractive
(
true
);
setMouseTracking
(
true
);
}
BZCutView
::~
BZCutView
()
{
}
void
BZCutView
::
wheelEvent
(
QWheelEvent
*
evt
)
{
t_real
sc
=
std
::
pow
(
2.
,
evt
->
angleDelta
().
y
()
/
8.
*
0.01
);
QGraphicsView
::
scale
(
sc
,
sc
);
}
// --------------------------------------------------------------------------------
tools/bz/plot_cut.h
0 → 100644
View file @
c599e326
/**
* brillouin zone tool
* @author Tobias Weber <tweber@ill.fr>
* @date May-2022
* @license GPLv3, see 'LICENSE' file
*
* ----------------------------------------------------------------------------
* mag-core (part of the Takin software suite)
* Copyright (C) 2018-2022 Tobias WEBER (Institut Laue-Langevin (ILL),
* Grenoble, France).
* "misc" project
* Copyright (C) 2017-2021 Tobias WEBER (privately developed).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*/
#ifndef __BZCUT_H__
#define __BZCUT_H__
#include
<QtWidgets/QGraphicsScene>
#include
<QtWidgets/QGraphicsView>
#include
<QtWidgets/QGraphicsItem>
#include
<QtGui/QWheelEvent>
#include
"globals.h"
class
BZCutScene
:
public
QGraphicsScene
{
public:
BZCutScene
(
QWidget
*
parent
=
nullptr
);
virtual
~
BZCutScene
();
protected:
};
class
BZCutView
:
public
QGraphicsView
{
public:
BZCutView
(
BZCutScene
*
scene
);
virtual
~
BZCutView
();
protected:
virtual
void
wheelEvent
(
QWheelEvent
*
evt
)
override
;
};
#endif
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