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
1980f599
Commit
1980f599
authored
Jan 29, 2019
by
Tobias WEBER
Browse files
started with magnetic structure factors (not yet correct)
parent
644b8730
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
1980f599
...
...
@@ -47,6 +47,7 @@ tmp/**
!tmp/.dir
build/**
tools/structfact/build/**
tools/magstructfact/build/**
tools/pol/build/**
*.pyc
...
...
tools/magstructfact/CMakeLists.txt
0 → 100644
View file @
1980f599
#
# @author Tobias Weber
# @date jan-2019
# @license GPLv3, see 'LICENSE' file
#
cmake_minimum_required
(
VERSION 3.0
)
project
(
magstructfact
)
set
(
CMAKE_VERBOSE_MAKEFILE TRUE
)
set
(
BUILD_LIB FALSE
)
find_package
(
Boost REQUIRED
)
find_package
(
Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL
)
set
(
CMAKE_AUTOUIC TRUE
)
set
(
CMAKE_AUTOMOC TRUE
)
set
(
CMAKE_CXX_STANDARD 17
)
add_definitions
(
-std=c++17 -fconcepts
)
add_definitions
(
${
Boost_CXX_FLAGS
}
)
include_directories
(
"
${
PROJECT_SOURCE_DIR
}
"
"
${
Boost_INCLUDE_DIRS
}
/.."
"../.."
"../../ext/gemmi/include"
"../../ext/gemmi/third_party"
)
if
(
BUILD_LIB
)
set
(
CMAKE_POSITION_INDEPENDENT_CODE TRUE
)
add_definitions
(
-DBUILD_LIB
)
add_library
(
magstructfact SHARED
magstructfact.cpp magstructfact.h
../../libs/_cxx20/glplot.cpp ../../libs/_cxx20/glplot.h
)
else
()
add_executable
(
magstructfact
magstructfact.cpp magstructfact.h
../../libs/_cxx20/glplot.cpp ../../libs/_cxx20/glplot.h
)
endif
()
target_link_libraries
(
magstructfact
${
Boost_LIBRARIES
}
)
qt5_use_modules
(
magstructfact Core Gui Widgets OpenGL
)
tools/magstructfact/magstructfact.cpp
0 → 100644
View file @
1980f599
This diff is collapsed.
Click to expand it.
tools/magstructfact/magstructfact.h
0 → 100644
View file @
1980f599
/**
* magnetic structure factor tool
* @author Tobias Weber <tweber@ill.fr>
* @date Jan-2019
* @license GPLv3, see 'LICENSE' file
* @desc The present version was forked on 28-Dec-2018 from the privately developed "misc" project (https://github.com/t-weber/misc).
*/
#ifndef __MAG_SFACT_H__
#define __MAG_SFACT_H__
#include <QtWidgets/QDialog>
#include <QtWidgets/QTableWidget>
#include <QtWidgets/QPlainTextEdit>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QMenu>
#include <QtWidgets/QLabel>
#include <QtWidgets/QComboBox>
#include <QtCore/QSettings>
#include <vector>
#include <sstream>
#include <complex>
#include "libs/_cxx20/glplot.h"
#include "libs/_cxx20/math_algos.h"
#include "../structfact/numerictablewidgetitem.h"
using
t_real
=
double
;
using
t_cplx
=
std
::
complex
<
t_real
>
;
using
t_vec
=
std
::
vector
<
t_real
>
;
using
t_vec_cplx
=
std
::
vector
<
t_cplx
>
;
using
t_mat
=
m
::
mat
<
t_real
,
std
::
vector
>
;
using
t_mat_cplx
=
m
::
mat
<
t_cplx
,
std
::
vector
>
;
struct
NuclPos
{
std
::
string
name
;
t_cplx
MAbs
;
t_real
pos
[
3
];
t_real
ReM
[
3
];
t_real
ImM
[
3
];
};
class
MagStructFactDlg
:
public
QDialog
{
public:
MagStructFactDlg
(
QWidget
*
pParent
=
nullptr
);
~
MagStructFactDlg
()
=
default
;
protected:
QSettings
*
m_sett
=
nullptr
;
QMenuBar
*
m_menu
=
nullptr
;
QDialog
*
m_dlgPlot
=
nullptr
;
std
::
shared_ptr
<
GlPlot
>
m_plot
;
std
::
size_t
m_sphere
=
0
;
QLabel
*
m_labelGlInfos
[
4
]
=
{
nullptr
,
nullptr
,
nullptr
,
nullptr
};
QLabel
*
m_status3D
=
nullptr
;
QWidget
*
m_nucleipanel
=
nullptr
;
QTableWidget
*
m_nuclei
=
nullptr
;
QPlainTextEdit
*
m_structfacts
=
nullptr
;
QPlainTextEdit
*
m_powderlines
=
nullptr
;
QLineEdit
*
m_editA
=
nullptr
;
QLineEdit
*
m_editB
=
nullptr
;
QLineEdit
*
m_editC
=
nullptr
;
QLineEdit
*
m_editAlpha
=
nullptr
;
QLineEdit
*
m_editBeta
=
nullptr
;
QLineEdit
*
m_editGamma
=
nullptr
;
QComboBox
*
m_comboSG
=
nullptr
;
std
::
vector
<
std
::
vector
<
t_mat
>>
m_SGops
;
QSpinBox
*
m_maxBZ
=
nullptr
;
QMenu
*
m_pTabContextMenu
=
nullptr
;
// menu in case a nucleus is selected
QMenu
*
m_pTabContextMenuNoItem
=
nullptr
;
// menu if nothing is selected
t_mat
m_crystA
=
m
::
unit
<
t_mat
>
(
3
);
t_mat
m_crystB
=
m
::
unit
<
t_mat
>
(
3
);
protected:
void
AddTabItem
(
int
row
=-
1
,
const
std
::
string
&
name
=
"n/a"
,
t_real
MMag
=
1.
,
t_real
x
=
0.
,
t_real
y
=
0.
,
t_real
z
=
0.
,
t_real
ReMx
=
0.
,
t_real
ReMy
=
0.
,
t_real
ReMz
=
1.
,
t_real
ImMx
=
0.
,
t_real
ImMy
=
0.
,
t_real
ImMz
=
0.
,
t_real
scale
=
1.
,
const
std
::
string
&
col
=
"#ff0000"
);
void
DelTabItem
(
int
begin
=-
2
,
int
end
=-
2
);
void
MoveTabItemUp
();
void
MoveTabItemDown
();
void
Add3DItem
(
int
row
=-
1
);
void
Set3DStatusMsg
(
const
std
::
string
&
msg
);
void
TableCurCellChanged
(
int
rowNew
,
int
colNew
,
int
rowOld
,
int
colOld
);
void
TableCellEntered
(
const
QModelIndex
&
idx
);
void
TableItemChanged
(
QTableWidgetItem
*
item
);
void
ShowTableContextMenu
(
const
QPoint
&
pt
);
void
Load
();
void
Save
();
void
ImportCIF
();
void
GenerateFromSG
();
std
::
vector
<
NuclPos
>
GetNuclei
()
const
;
void
CalcB
(
bool
bFullRecalc
=
true
);
void
Calc
();
void
PlotMouseDown
(
bool
left
,
bool
mid
,
bool
right
);
void
PlotMouseUp
(
bool
left
,
bool
mid
,
bool
right
);
void
PickerIntersection
(
const
t_vec3_gl
*
pos
,
std
::
size_t
objIdx
,
const
t_vec3_gl
*
posSphere
);
void
AfterGLInitialisation
();
virtual
void
closeEvent
(
QCloseEvent
*
evt
)
override
;
private:
int
m_iCursorRow
=
-
1
;
bool
m_ignoreChanges
=
1
;
long
m_curPickedObj
=
-
1
;
private:
std
::
vector
<
int
>
GetSelectedRows
(
bool
sort_reversed
=
false
)
const
;
};
#endif
tools/structfact/numerictablewidgetitem.h
0 → 100644
View file @
1980f599
/**
* numeric table widget item
* @author Tobias Weber <tweber@ill.fr>
* @date Dec-2018
* @license GPLv3, see 'LICENSE' file
* @desc The present version was forked on 28-Dec-2018 from the privately developed "misc" project (https://github.com/t-weber/misc).
*/
#ifndef __NUM_TABWIDGETITEM_H__
#define __NUM_TABWIDGETITEM_H__
#include <QtWidgets/QTableWidget>
#include <sstream>
#include <string>
template
<
class
T
=
double
>
class
NumericTableWidgetItem
:
public
QTableWidgetItem
{
public:
NumericTableWidgetItem
(
T
&&
val
)
:
QTableWidgetItem
(
std
::
to_string
(
std
::
forward
<
T
>
(
val
)).
c_str
())
{}
NumericTableWidgetItem
(
const
T
&
val
)
:
QTableWidgetItem
(
std
::
to_string
(
val
).
c_str
())
{}
NumericTableWidgetItem
(
const
QString
&
val
)
:
QTableWidgetItem
(
val
)
{}
virtual
bool
operator
<
(
const
QTableWidgetItem
&
item
)
const
override
{
T
val1
{},
val2
{};
std
::
istringstream
{
text
().
toStdString
()}
>>
val1
;
std
::
istringstream
{
item
.
text
().
toStdString
()}
>>
val2
;
return
val1
<
val2
;
}
virtual
QTableWidgetItem
*
clone
()
const
override
{
auto
item
=
new
NumericTableWidgetItem
<
T
>
(
this
->
text
());
item
->
setData
(
Qt
::
UserRole
,
this
->
data
(
Qt
::
UserRole
));
return
item
;
};
};
#endif
tools/structfact/structfact.cpp
View file @
1980f599
...
...
@@ -70,7 +70,7 @@ struct PowderLine
StructFactDlg
::
StructFactDlg
(
QWidget
*
pParent
)
:
QDialog
{
pParent
},
m_sett
{
new
QSettings
{
"tobis_stuff"
,
"structfact"
}}
{
setWindowTitle
(
"Structure Factors"
);
setWindowTitle
(
"
Nuclear
Structure Factors"
);
setSizeGripEnabled
(
true
);
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
GeneralFont
));
...
...
@@ -272,7 +272,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
std
::
string
strBoost
=
BOOST_LIB_VERSION
;
algo
::
replace_all
(
strBoost
,
"_"
,
"."
);
auto
labelTitle
=
new
QLabel
(
"Structure Factor Calculator"
,
infopanel
);
auto
labelTitle
=
new
QLabel
(
"
Nuclear
Structure Factor Calculator"
,
infopanel
);
auto
fontTitle
=
labelTitle
->
font
();
fontTitle
.
setBold
(
true
);
labelTitle
->
setFont
(
fontTitle
);
...
...
tools/structfact/structfact.h
View file @
1980f599
...
...
@@ -27,6 +27,8 @@
#include "libs/_cxx20/glplot.h"
#include "libs/_cxx20/math_algos.h"
#include "numerictablewidgetitem.h"
using
t_real
=
double
;
using
t_cplx
=
std
::
complex
<
t_real
>
;
...
...
@@ -36,39 +38,6 @@ using t_mat = m::mat<t_real, std::vector>;
using
t_mat_cplx
=
m
::
mat
<
t_cplx
,
std
::
vector
>
;
template
<
class
T
=
t_real
>
class
NumericTableWidgetItem
:
public
QTableWidgetItem
{
public:
NumericTableWidgetItem
(
T
&&
val
)
:
QTableWidgetItem
(
std
::
to_string
(
std
::
forward
<
T
>
(
val
)).
c_str
())
{}
NumericTableWidgetItem
(
const
T
&
val
)
:
QTableWidgetItem
(
std
::
to_string
(
val
).
c_str
())
{}
NumericTableWidgetItem
(
const
QString
&
val
)
:
QTableWidgetItem
(
val
)
{}
virtual
bool
operator
<
(
const
QTableWidgetItem
&
item
)
const
override
{
T
val1
{},
val2
{};
std
::
istringstream
{
text
().
toStdString
()}
>>
val1
;
std
::
istringstream
{
item
.
text
().
toStdString
()}
>>
val2
;
return
val1
<
val2
;
}
virtual
QTableWidgetItem
*
clone
()
const
override
{
auto
item
=
new
NumericTableWidgetItem
<
T
>
(
this
->
text
());
item
->
setData
(
Qt
::
UserRole
,
this
->
data
(
Qt
::
UserRole
));
return
item
;
};
};
struct
NuclPos
{
std
::
string
name
;
...
...
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