Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
XRD
darfix
Commits
e3c897b5
Commit
e3c897b5
authored
Jul 06, 2021
by
Julia Garriga Ferrer
Browse files
[gui][shift] Add ShiftCorrectionDialog
parent
b3f9a797
Changes
1
Hide whitespace changes
Inline
Side-by-side
darfix/gui/shiftCorrectionWidget.py
View file @
e3c897b5
...
...
@@ -26,7 +26,7 @@
__authors__
=
[
"J. Garriga"
]
__license__
=
"MIT"
__date__
=
"
22/12
/202
0
"
__date__
=
"
05/07
/202
1
"
# import os
import
numpy
...
...
@@ -41,13 +41,46 @@ from darfix.core.dataset import Operation
from
.operationThread
import
OperationThread
from
.utils
import
ChooseDimensionDock
class
ShiftCorrectionDialog
(
qt
.
QDialog
):
"""
Dialog with `ShiftCorrectionWidget` as main window and standard buttons.
"""
okSignal
=
qt
.
Signal
()
def
__init__
(
self
,
parent
=
None
):
qt
.
QDialog
.
__init__
(
self
,
parent
)
self
.
setWindowFlags
(
qt
.
Qt
.
Widget
)
types
=
qt
.
QDialogButtonBox
.
Ok
self
.
_buttons
=
qt
.
QDialogButtonBox
(
parent
=
self
)
self
.
_buttons
.
setStandardButtons
(
types
)
self
.
_buttons
.
setEnabled
(
False
)
resetB
=
self
.
_buttons
.
addButton
(
self
.
_buttons
.
Reset
)
self
.
mainWindow
=
ShiftCorrectionWidget
(
parent
=
self
)
self
.
mainWindow
.
setAttribute
(
qt
.
Qt
.
WA_DeleteOnClose
)
self
.
setLayout
(
qt
.
QVBoxLayout
())
self
.
layout
().
addWidget
(
self
.
mainWindow
)
self
.
layout
().
addWidget
(
self
.
_buttons
)
self
.
_buttons
.
accepted
.
connect
(
self
.
okSignal
.
emit
)
resetB
.
clicked
.
connect
(
self
.
mainWindow
.
resetStack
)
self
.
mainWindow
.
computingSignal
.
connect
(
self
.
_toggleButton
)
def
setDataset
(
self
,
dataset
,
indices
=
None
,
bg_indices
=
None
,
bg_dataset
=
None
):
if
dataset
is
not
None
:
self
.
_buttons
.
setEnabled
(
True
)
self
.
mainWindow
.
setDataset
(
dataset
,
indices
,
bg_indices
,
bg_dataset
)
def
_toggleButton
(
self
,
state
):
self
.
_buttons
.
button
(
qt
.
QDialogButtonBox
.
Ok
).
setEnabled
(
not
state
)
class
ShiftCorrectionWidget
(
qt
.
QMainWindow
):
"""
A widget to apply shift correction to a stack of images
"""
sigComputed
=
qt
.
Signal
()
sigProgressChanged
=
qt
.
Signal
(
int
)
computingSignal
=
qt
.
Signal
()
def
__init__
(
self
,
parent
=
None
):
qt
.
QMainWindow
.
__init__
(
self
,
parent
)
...
...
@@ -124,11 +157,15 @@ class ShiftCorrectionWidget(qt.QMainWindow):
self
.
_inputDock
.
widget
.
correctionB
.
setEnabled
(
False
)
self
.
_inputDock
.
widget
.
abortB
.
show
()
self
.
thread_correction
.
start
()
self
.
computingSignal
.
emit
()
def
abort
(
self
):
self
.
_inputDock
.
widget
.
abortB
.
setEnabled
(
False
)
self
.
_update_dataset
.
stop_operation
(
Operation
.
SHIFT
)
def
resetStack
(
self
):
self
.
_update_dataset
=
self
.
dataset
self
.
setStack
()
def
updateProgress
(
self
,
progress
):
self
.
sigProgressChanged
.
emit
(
progress
)
...
...
@@ -138,11 +175,13 @@ class ShiftCorrectionWidget(qt.QMainWindow):
self
.
thread_detection
.
setArgs
(
self
.
_dimension
,
indices
=
self
.
indices
)
self
.
thread_detection
.
finished
.
connect
(
self
.
_updateShift
)
self
.
thread_detection
.
start
()
self
.
computingSignal
.
emit
()
def
_updateShift
(
self
):
self
.
_inputDock
.
widget
.
_findShiftB
.
setEnabled
(
True
)
self
.
thread_detection
.
finished
.
disconnect
(
self
.
_updateShift
)
self
.
shift
=
numpy
.
round
(
self
.
thread_detection
.
data
[:,
1
],
5
)
self
.
computingSignal
.
emit
()
def
_updateData
(
self
):
"""
...
...
@@ -152,13 +191,13 @@ class ShiftCorrectionWidget(qt.QMainWindow):
self
.
_inputDock
.
widget
.
abortB
.
hide
()
self
.
_inputDock
.
widget
.
abortB
.
setEnabled
(
True
)
self
.
_inputDock
.
widget
.
correctionB
.
setEnabled
(
True
)
self
.
computingSignal
.
emit
()
if
self
.
thread_correction
.
data
:
self
.
_update_dataset
=
self
.
thread_correction
.
data
assert
self
.
_update_dataset
is
not
None
if
self
.
_inputDock
.
widget
.
checkbox
.
isChecked
():
self
.
_chooseDimensionDock
.
widget
.
_checkbox
.
setChecked
(
False
)
self
.
setStack
(
self
.
_update_dataset
)
self
.
sigComputed
.
emit
()
else
:
print
(
"
\n
Correction aborted"
)
...
...
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