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
644b8730
Commit
644b8730
authored
Jan 29, 2019
by
Tobias WEBER
Browse files
added taz file exporting
parent
68385eb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
tools/in20/mainwnd.cpp
View file @
644b8730
...
...
@@ -88,7 +88,7 @@ MainWnd::MainWnd(QSettings* pSettings)
if
(
m_plugin_dlgs
.
size
())
m_pMenu
->
addMenu
(
m_pmenuPluginTools
);
m_pMenu
->
addMenu
(
menuHelp
);
m_pMenu
->
setNativeMenuBar
(
false
);
m_pMenu
->
setNativeMenuBar
(
m_pSettings
?
m_pSettings
->
value
(
"mainwnd/native_gui"
,
false
).
toBool
()
:
false
);
this
->
setMenuBar
(
m_pMenu
);
// ------------------------------------------------------------------------
...
...
tools/structfact/structfact.cpp
View file @
644b8730
...
...
@@ -74,7 +74,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
setSizeGripEnabled
(
true
);
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
GeneralFont
));
auto
tabs
=
new
QTabWidget
(
this
);
{
m_nucleipanel
=
new
QWidget
(
this
);
...
...
@@ -113,10 +113,6 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
QToolButton
*
pTabBtnDel
=
new
QToolButton
(
m_nucleipanel
);
QToolButton
*
pTabBtnUp
=
new
QToolButton
(
m_nucleipanel
);
QToolButton
*
pTabBtnDown
=
new
QToolButton
(
m_nucleipanel
);
QToolButton
*
pTabBtnLoad
=
new
QToolButton
(
m_nucleipanel
);
QToolButton
*
pTabBtnSave
=
new
QToolButton
(
m_nucleipanel
);
QToolButton
*
pTabBtnImportCIF
=
new
QToolButton
(
m_nucleipanel
);
QToolButton
*
pTabBtn3DView
=
new
QToolButton
(
m_nucleipanel
);
QToolButton
*
pTabBtnSG
=
new
QToolButton
(
m_nucleipanel
);
m_nuclei
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
...
...
@@ -124,23 +120,14 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
pTabBtnDel
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnUp
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnDown
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnLoad
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnSave
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnImportCIF
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtn3DView
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnSG
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
});
pTabBtnAdd
->
setText
(
"Add Nucleus"
);
pTabBtnDel
->
setText
(
"Delete Nuclei"
);
pTabBtnUp
->
setText
(
"Move Nuclei Up"
);
pTabBtnDown
->
setText
(
"Move Nuclei Down"
);
pTabBtnLoad
->
setText
(
"Load..."
);
pTabBtnSave
->
setText
(
"Save..."
);
pTabBtnImportCIF
->
setText
(
"Import CIF..."
);
pTabBtn3DView
->
setText
(
"3D View..."
);
pTabBtnSG
->
setText
(
"Generate"
);
m_editA
=
new
QLineEdit
(
"5"
,
m_nucleipanel
);
m_editB
=
new
QLineEdit
(
"5"
,
m_nucleipanel
);
m_editC
=
new
QLineEdit
(
"5"
,
m_nucleipanel
);
...
...
@@ -169,10 +156,6 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
pTabGrid
->
addWidget
(
pTabBtnDel
,
y
,
1
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabBtnUp
,
y
,
2
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabBtnDown
,
y
,
3
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabBtnLoad
,
++
y
,
0
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabBtnSave
,
y
,
1
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabBtnImportCIF
,
y
,
2
,
1
,
1
);
pTabGrid
->
addWidget
(
pTabBtn3DView
,
y
,
3
,
1
,
1
);
pTabGrid
->
addWidget
(
new
QLabel
(
"Space Groups:"
),
++
y
,
0
,
1
,
1
);
pTabGrid
->
addWidget
(
m_comboSG
,
y
,
1
,
1
,
2
);
...
...
@@ -215,67 +198,7 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
connect
(
pTabBtnDel
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
StructFactDlg
::
DelTabItem
();
});
connect
(
pTabBtnUp
,
&
QToolButton
::
clicked
,
this
,
&
StructFactDlg
::
MoveTabItemUp
);
connect
(
pTabBtnDown
,
&
QToolButton
::
clicked
,
this
,
&
StructFactDlg
::
MoveTabItemDown
);
connect
(
pTabBtnLoad
,
&
QToolButton
::
clicked
,
this
,
&
StructFactDlg
::
Load
);
connect
(
pTabBtnSave
,
&
QToolButton
::
clicked
,
this
,
&
StructFactDlg
::
Save
);
connect
(
pTabBtnImportCIF
,
&
QToolButton
::
clicked
,
this
,
&
StructFactDlg
::
ImportCIF
);
connect
(
pTabBtnSG
,
&
QToolButton
::
clicked
,
this
,
&
StructFactDlg
::
GenerateFromSG
);
connect
(
pTabBtn3DView
,
&
QToolButton
::
clicked
,
this
,
[
this
]()
{
// plot widget
if
(
!
m_dlgPlot
)
{
m_dlgPlot
=
new
QDialog
(
this
);
m_dlgPlot
->
setWindowTitle
(
"Unit Cell - 3D View"
);
m_plot
=
std
::
make_shared
<
GlPlot
>
(
this
);
m_plot
->
GetImpl
()
->
SetLight
(
0
,
m
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
m
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetCoordMax
(
1.
);
m_plot
->
GetImpl
()
->
SetCamBase
(
m
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
auto
labCoordSys
=
new
QLabel
(
"Coordinate System:"
,
/*m_dlgPlot*/
this
);
auto
comboCoordSys
=
new
QComboBox
(
/*m_dlgPlot*/
this
);
m_status3D
=
new
QLabel
(
/*m_dlgPlot*/
this
);
comboCoordSys
->
addItem
(
"Fractional Units (rlu)"
);
comboCoordSys
->
addItem
(
"Lab Units (A)"
);
m_plot
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
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
(
m_status3D
,
2
,
0
,
1
,
2
);
connect
(
m_plot
.
get
(),
&
GlPlot
::
AfterGLInitialisation
,
this
,
&
StructFactDlg
::
AfterGLInitialisation
);
connect
(
m_plot
->
GetImpl
(),
&
GlPlot_impl
::
PickerIntersection
,
this
,
&
StructFactDlg
::
PickerIntersection
);
connect
(
m_plot
.
get
(),
&
GlPlot
::
MouseDown
,
this
,
&
StructFactDlg
::
PlotMouseDown
);
connect
(
m_plot
.
get
(),
&
GlPlot
::
MouseUp
,
this
,
&
StructFactDlg
::
PlotMouseUp
);
connect
(
comboCoordSys
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
[
this
](
int
val
)
{
if
(
this
->
m_plot
)
this
->
m_plot
->
GetImpl
()
->
SetCoordSys
(
val
);
});
if
(
m_sett
&&
m_sett
->
contains
(
"geo_3dview"
))
m_dlgPlot
->
restoreGeometry
(
m_sett
->
value
(
"geo_3dview"
).
toByteArray
());
else
m_dlgPlot
->
resize
(
500
,
500
);
}
m_dlgPlot
->
show
();
m_dlgPlot
->
raise
();
m_dlgPlot
->
focusWidget
();
});
connect
(
m_nuclei
,
&
QTableWidget
::
currentCellChanged
,
this
,
&
StructFactDlg
::
TableCurCellChanged
);
connect
(
m_nuclei
,
&
QTableWidget
::
entered
,
this
,
&
StructFactDlg
::
TableCellEntered
);
...
...
@@ -389,6 +312,99 @@ StructFactDlg::StructFactDlg(QWidget* pParent) : QDialog{pParent},
pmainGrid
->
addWidget
(
tabs
,
0
,
0
,
1
,
1
);
// menu bar
{
m_menu
=
new
QMenuBar
(
this
);
m_menu
->
setNativeMenuBar
(
m_sett
?
m_sett
->
value
(
"native_gui"
,
false
).
toBool
()
:
false
);
auto
menuFile
=
new
QMenu
(
"File"
,
m_menu
);
auto
menuView
=
new
QMenu
(
"View"
,
m_menu
);
auto
acLoad
=
new
QAction
(
"Load..."
,
menuFile
);
auto
acSave
=
new
QAction
(
"Save..."
,
menuFile
);
auto
acImportCIF
=
new
QAction
(
"Import CIF..."
,
menuFile
);
auto
acExportTAZ
=
new
QAction
(
"Export TAZ..."
,
menuFile
);
auto
acExit
=
new
QAction
(
"Exit"
,
menuFile
);
auto
ac3DView
=
new
QAction
(
"3D View..."
,
menuFile
);
menuFile
->
addAction
(
acLoad
);
menuFile
->
addAction
(
acSave
);
menuFile
->
addSeparator
();
menuFile
->
addAction
(
acImportCIF
);
menuFile
->
addAction
(
acExportTAZ
);
menuFile
->
addSeparator
();
menuFile
->
addAction
(
acExit
);
menuView
->
addAction
(
ac3DView
);
connect
(
acLoad
,
&
QAction
::
triggered
,
this
,
&
StructFactDlg
::
Load
);
connect
(
acSave
,
&
QAction
::
triggered
,
this
,
&
StructFactDlg
::
Save
);
connect
(
acImportCIF
,
&
QAction
::
triggered
,
this
,
&
StructFactDlg
::
ImportCIF
);
connect
(
acExportTAZ
,
&
QAction
::
triggered
,
this
,
&
StructFactDlg
::
ExportTAZ
);
connect
(
acExit
,
&
QAction
::
triggered
,
this
,
&
QDialog
::
close
);
connect
(
ac3DView
,
&
QAction
::
triggered
,
this
,
[
this
]()
{
// plot widget
if
(
!
m_dlgPlot
)
{
m_dlgPlot
=
new
QDialog
(
this
);
m_dlgPlot
->
setWindowTitle
(
"Unit Cell - 3D View"
);
m_plot
=
std
::
make_shared
<
GlPlot
>
(
this
);
m_plot
->
GetImpl
()
->
SetLight
(
0
,
m
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
m
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetCoordMax
(
1.
);
m_plot
->
GetImpl
()
->
SetCamBase
(
m
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
auto
labCoordSys
=
new
QLabel
(
"Coordinate System:"
,
/*m_dlgPlot*/
this
);
auto
comboCoordSys
=
new
QComboBox
(
/*m_dlgPlot*/
this
);
m_status3D
=
new
QLabel
(
/*m_dlgPlot*/
this
);
comboCoordSys
->
addItem
(
"Fractional Units (rlu)"
);
comboCoordSys
->
addItem
(
"Lab Units (A)"
);
m_plot
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
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
(
m_status3D
,
2
,
0
,
1
,
2
);
connect
(
m_plot
.
get
(),
&
GlPlot
::
AfterGLInitialisation
,
this
,
&
StructFactDlg
::
AfterGLInitialisation
);
connect
(
m_plot
->
GetImpl
(),
&
GlPlot_impl
::
PickerIntersection
,
this
,
&
StructFactDlg
::
PickerIntersection
);
connect
(
m_plot
.
get
(),
&
GlPlot
::
MouseDown
,
this
,
&
StructFactDlg
::
PlotMouseDown
);
connect
(
m_plot
.
get
(),
&
GlPlot
::
MouseUp
,
this
,
&
StructFactDlg
::
PlotMouseUp
);
connect
(
comboCoordSys
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
[
this
](
int
val
)
{
if
(
this
->
m_plot
)
this
->
m_plot
->
GetImpl
()
->
SetCoordSys
(
val
);
});
if
(
m_sett
&&
m_sett
->
contains
(
"geo_3dview"
))
m_dlgPlot
->
restoreGeometry
(
m_sett
->
value
(
"geo_3dview"
).
toByteArray
());
else
m_dlgPlot
->
resize
(
500
,
500
);
}
m_dlgPlot
->
show
();
m_dlgPlot
->
raise
();
m_dlgPlot
->
focusWidget
();
});
m_menu
->
addMenu
(
menuFile
);
m_menu
->
addMenu
(
menuView
);
pmainGrid
->
setMenuBar
(
m_menu
);
}
// restory window size and position
if
(
m_sett
&&
m_sett
->
contains
(
"geo"
))
restoreGeometry
(
m_sett
->
value
(
"geo"
).
toByteArray
());
...
...
@@ -872,17 +888,80 @@ void StructFactDlg::Save()
}
std
::
ofstream
ofstr
{
filename
.
toStdString
()};
if
(
!
ofstr
)
{
QMessageBox
::
critical
(
this
,
"Structure Factors"
,
"Cannot open file for writing."
);
return
;
}
ofstr
.
precision
(
g_prec
);
pt
::
write_xml
(
ofstr
,
node
,
pt
::
xml_writer_make_settings
(
'\t'
,
1
,
std
::
string
{
"utf-8"
}));
}
/**
* save a TAZ file
*/
void
StructFactDlg
::
ExportTAZ
()
{
QString
dirLast
=
m_sett
->
value
(
"dir_taz"
,
""
).
toString
();
QString
filename
=
QFileDialog
::
getSaveFileName
(
this
,
"Export TAZ"
,
dirLast
,
"TAZ Files (*.taz *.TAZ)"
);
if
(
filename
==
""
||
!
QFile
::
exists
(
filename
))
return
;
m_sett
->
setValue
(
"dir_taz"
,
QFileInfo
(
filename
).
path
());
std
::
ofstream
ofstr
{
filename
.
toStdString
()};
if
(
!
ofstr
)
{
QMessageBox
::
critical
(
this
,
"Structure Factors"
,
"Cannot open file for writing."
);
return
;
}
ofstr
.
precision
(
g_prec
);
ofstr
<<
"<taz>
\n
"
;
ofstr
<<
"
\t
<meta><info>Exported from IN20Tools/Structfact.</info></meta>
\n
"
;
// sample infos
ofstr
<<
"
\t
<sample>
\n
"
;
ofstr
<<
"
\t\t
<a>"
<<
m_editA
->
text
().
toStdString
()
<<
"</a>
\n
"
;
ofstr
<<
"
\t\t
<b>"
<<
m_editB
->
text
().
toStdString
()
<<
"</b>
\n
"
;
ofstr
<<
"
\t\t
<c>"
<<
m_editC
->
text
().
toStdString
()
<<
"</c>
\n
"
;
ofstr
<<
"
\t\t
<alpha>"
<<
m_editAlpha
->
text
().
toStdString
()
<<
"</alpha>
\n
"
;
ofstr
<<
"
\t\t
<beta>"
<<
m_editBeta
->
text
().
toStdString
()
<<
"</beta>
\n
"
;
ofstr
<<
"
\t\t
<gamma>"
<<
m_editGamma
->
text
().
toStdString
()
<<
"</gamma>
\n
"
;
// P1 only has the identity trafo, so we can directly output all raw nucleus positions
ofstr
<<
"
\t\t
<spacegroup>P1</spacegroup>
\n
"
;
// nucleus list
ofstr
<<
"
\t\t
<atoms>
\n
"
;
ofstr
<<
"
\t\t\t
<num>"
<<
m_nuclei
->
rowCount
()
<<
"</num>
\n
"
;
for
(
int
row
=
0
;
row
<
m_nuclei
->
rowCount
();
++
row
)
{
ofstr
<<
"
\t\t\t
<"
<<
row
<<
">
\n
"
;
ofstr
<<
"
\t\t\t\t
<name>"
<<
m_nuclei
->
item
(
row
,
COL_NAME
)
->
text
().
toStdString
()
<<
"</name>
\n
"
;
ofstr
<<
"
\t\t\t\t
<x>"
<<
m_nuclei
->
item
(
row
,
COL_X
)
->
text
().
toStdString
()
<<
"</x>
\n
"
;
ofstr
<<
"
\t\t\t\t
<y>"
<<
m_nuclei
->
item
(
row
,
COL_Y
)
->
text
().
toStdString
()
<<
"</y>
\n
"
;
ofstr
<<
"
\t\t\t\t
<z>"
<<
m_nuclei
->
item
(
row
,
COL_Z
)
->
text
().
toStdString
()
<<
"</z>
\n
"
;
ofstr
<<
"
\t\t\t
</"
<<
row
<<
">
\n
"
;
}
ofstr
<<
"
\t\t
</atoms>
\n
"
;
ofstr
<<
"
\t
</sample>
\n
"
;
ofstr
<<
"</taz>
\n
"
;
}
/**
* load a CIF
*/
void
StructFactDlg
::
ImportCIF
()
{
QString
dirLast
=
m_sett
->
value
(
"dir"
,
""
).
toString
();
QString
dirLast
=
m_sett
->
value
(
"dir
_cif
"
,
""
).
toString
();
QString
filename
=
QFileDialog
::
getOpenFileName
(
this
,
"Import CIF"
,
dirLast
,
"CIF Files (*.cif *.CIF)"
);
if
(
filename
==
""
||
!
QFile
::
exists
(
filename
))
return
;
m_sett
->
setValue
(
"dir"
,
QFileInfo
(
filename
).
path
());
m_sett
->
setValue
(
"dir
_cif
"
,
QFileInfo
(
filename
).
path
());
auto
[
errstr
,
atoms
,
generatedatoms
,
atomnames
,
lattice
]
=
load_cif
<
t_vec
,
t_mat
>
(
filename
.
toStdString
(),
g_eps
);
if
(
errstr
)
...
...
tools/structfact/structfact.h
View file @
644b8730
...
...
@@ -14,6 +14,7 @@
#include <QtWidgets/QPlainTextEdit>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QMenu>
#include <QtWidgets/QLabel>
#include <QtWidgets/QComboBox>
...
...
@@ -84,6 +85,7 @@ public:
protected:
QSettings
*
m_sett
=
nullptr
;
QMenuBar
*
m_menu
=
nullptr
;
QDialog
*
m_dlgPlot
=
nullptr
;
std
::
shared_ptr
<
GlPlot
>
m_plot
;
...
...
@@ -132,6 +134,7 @@ protected:
void
Load
();
void
Save
();
void
ImportCIF
();
void
ExportTAZ
();
void
GenerateFromSG
();
std
::
vector
<
NuclPos
>
GetNuclei
()
const
;
...
...
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