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
kmap
xsocs
Commits
fd9c53bf
Commit
fd9c53bf
authored
Oct 17, 2016
by
Damien Naudet
Browse files
More work on the model.
parent
22b2b6a0
Changes
19
Hide whitespace changes
Inline
Side-by-side
kmap/gui/MergeWidget.py
View file @
fd9c53bf
...
...
@@ -7,9 +7,9 @@ from collections import namedtuple
from
..util.id01_spec
import
Id01DataMerger
from
.Widgets
import
(
AcqParamsWidget
,
_
AdjustedLabel
,
_
AdjustedLineEdit
,
_
AdjustedPushButton
)
AdjustedLabel
,
AdjustedLineEdit
,
AdjustedPushButton
)
from
silx.gui
import
qt
as
Qt
...
...
@@ -131,7 +131,7 @@ class _ScansSelectDialog(Qt.QDialog):
table_widget
.
setColumnHidden
(
self
.
M1_END_COL
,
True
)
table_widget
.
setColumnHidden
(
self
.
M1_STEP_COL
,
True
)
more_bn
=
_
AdjustedPushButton
(
'More'
)
more_bn
=
AdjustedPushButton
(
'More'
)
layout
.
addWidget
(
more_bn
,
1
,
0
,
Qt
.
Qt
.
AlignRight
)
bn_box
=
Qt
.
QDialogButtonBox
(
Qt
.
QDialogButtonBox
.
Ok
|
...
...
@@ -412,7 +412,7 @@ class MergeWidget(Qt.QDialog):
spec_file_edit
=
Qt
.
QLineEdit
()
fm
=
spec_file_edit
.
fontMetrics
()
spec_file_edit
.
setMinimumWidth
(
fm
.
width
(
' '
*
100
))
spec_file_bn
=
_
AdjustedPushButton
(
'...'
)
spec_file_bn
=
AdjustedPushButton
(
'...'
)
layout
.
addWidget
(
lab
,
spec_row
,
label_col
,
Qt
.
Qt
.
AlignLeft
)
...
...
@@ -429,7 +429,7 @@ class MergeWidget(Qt.QDialog):
img_dir_edit
=
Qt
.
QLineEdit
()
fm
=
img_dir_edit
.
fontMetrics
()
img_dir_edit
.
setMinimumWidth
(
fm
.
width
(
' '
*
100
))
img_dir_bn
=
_
AdjustedPushButton
(
'...'
)
img_dir_bn
=
AdjustedPushButton
(
'...'
)
layout
.
addWidget
(
lab
,
img_path_row
,
label_col
,
Qt
.
Qt
.
AlignLeft
)
...
...
@@ -465,7 +465,7 @@ class MergeWidget(Qt.QDialog):
Qt
.
QSizePolicy
.
Expanding
))
# last row : apply button
parse_bn
=
_
AdjustedPushButton
(
'Parse file'
)
parse_bn
=
AdjustedPushButton
(
'Parse file'
)
layout
.
addWidget
(
parse_bn
,
apply_bn_row
,
0
,
1
,
last_col
-
first_col
,
...
...
@@ -490,7 +490,7 @@ class MergeWidget(Qt.QDialog):
label
=
Qt
.
QLabel
(
'<span style=" font-weight:600; color:#00916a;">'
'Matched scans</span>'
)
label
.
setTextFormat
(
Qt
.
Qt
.
RichText
)
edit_scans_bn
=
_
AdjustedPushButton
(
'Edit'
)
edit_scans_bn
=
AdjustedPushButton
(
'Edit'
)
h_layout
.
addWidget
(
label
)
h_layout
.
addWidget
(
edit_scans_bn
)
scan_layout
.
addLayout
(
h_layout
,
0
,
0
,
1
,
2
)
...
...
@@ -538,7 +538,7 @@ class MergeWidget(Qt.QDialog):
h_layout
=
Qt
.
QHBoxLayout
()
label
=
Qt
.
QLabel
(
'<span style=" font-weight:600; color:#ff6600;">'
'Other scans</span>'
)
other_scans_bn
=
_
AdjustedPushButton
(
'View'
)
other_scans_bn
=
AdjustedPushButton
(
'View'
)
h_layout
.
addWidget
(
label
)
h_layout
.
addWidget
(
other_scans_bn
)
...
...
@@ -609,7 +609,7 @@ class MergeWidget(Qt.QDialog):
master_edit
.
setMinimumWidth
(
fm
.
width
(
' '
*
50
))
h_layout
=
Qt
.
QHBoxLayout
()
layout
.
addLayout
(
h_layout
,
0
,
1
,
Qt
.
Qt
.
AlignLeft
)
reset_bn
=
_
AdjustedPushButton
(
'R'
)
reset_bn
=
AdjustedPushButton
(
'R'
)
layout
.
addWidget
(
lab
,
0
,
0
,
Qt
.
Qt
.
AlignLeft
)
...
...
@@ -627,7 +627,7 @@ class MergeWidget(Qt.QDialog):
outdir_edit
=
Qt
.
QLineEdit
()
fm
=
outdir_edit
.
fontMetrics
()
outdir_edit
.
setMinimumWidth
(
fm
.
width
(
' '
*
100
))
outdir_bn
=
_
AdjustedPushButton
(
'...'
)
outdir_bn
=
AdjustedPushButton
(
'...'
)
layout
.
addWidget
(
lab
,
1
,
0
,
Qt
.
Qt
.
AlignLeft
)
...
...
kmap/gui/Utils.py
0 → 100644
View file @
fd9c53bf
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
from
__future__
import
absolute_import
__authors__
=
[
"D. Naudet"
]
__license__
=
"MIT"
__date__
=
"15/09/2016"
import
os
from
.view.RealSpaceWidget
import
RealSpaceWidget
,
RealSpaceWidgetEvent
from
.process.RecipSpaceWidget
import
RecipSpaceWidget
from
.project.XsocsProject
import
XsocsProject
def
viewWidgetFromProjectEvent
(
project
,
event
):
item
=
event
.
item
index
=
event
.
index
processLevel
=
item
.
processLevel
widget
=
None
if
processLevel
==
XsocsProject
.
XsocsInput
:
# show raw data
plotData
=
event
.
plotData
()
x
,
y
,
data
=
plotData
widget
=
RealSpaceWidget
(
index
)
widget
.
setPlotData
(
x
,
y
,
data
)
elif
processLevel
==
XsocsProject
.
XsocsQSpace
:
# show qspace data
pass
else
:
raise
ValueError
(
'Unknown process level {0}.'
.
format
(
processLevel
))
return
widget
# TODO : something better!
def
nextFileName
(
root
,
template
,
cntMax
=
10000
):
template
=
os
.
path
.
join
(
root
,
template
)
for
fIdx
in
range
(
cntMax
):
nextFile
=
template
.
format
(
fIdx
)
if
not
os
.
path
.
exists
(
nextFile
):
return
nextFile
else
:
raise
ValueError
(
'No available file names.'
)
# TODO : cache the widget to reuse previous parameters?
def
processWidgetFromViewEvent
(
project
,
event
,
parent
=
None
):
widget
=
None
index
=
event
.
index
if
isinstance
(
event
,
RealSpaceWidgetEvent
):
xsocsPrefix
=
os
.
path
.
basename
(
project
.
xsocsFile
).
rpartition
(
'.'
)[
0
]
template
=
'{0}_qspace_{{0:>04}}.h5'
.
format
(
xsocsPrefix
)
output_f
=
nextFileName
(
project
.
workdir
,
template
)
widget
=
RecipSpaceWidget
(
parent
=
parent
,
index
=
index
,
data_h5f
=
project
.
xsocsFile
,
output_f
=
output_f
,
qspace_size
=
None
,
image_binning
=
None
,
rect_roi
=
event
.
data
)
return
widget
kmap/gui/Widgets.py
View file @
fd9c53bf
...
...
@@ -5,6 +5,7 @@ _MU_LOWER = u'\u03BC'
_PHI_LOWER
=
u
'
\u03C6
'
_ETA_LOWER
=
u
'
\u03B7
'
class
AcqParamsWidget
(
Qt
.
QWidget
):
def
__init__
(
self
,
...
...
@@ -33,12 +34,12 @@ class AcqParamsWidget(Qt.QWidget):
return
super
(
DblValidator
,
self
).
validate
(
text
,
pos
)
def
dblLineEditWidget
(
width
):
wid
=
_
AdjustedLineEdit
(
width
,
validator_cls
=
DblValidator
,
read_only
=
read_only
,
reset_on_empty
=
True
,
highlight_change
=
highlight_change
,
field_type
=
float
)
wid
=
AdjustedLineEdit
(
width
,
validator_cls
=
DblValidator
,
read_only
=
read_only
,
reset_on_empty
=
True
,
highlight_change
=
highlight_change
,
field_type
=
float
)
wid
.
setReadOnly
(
read_only
)
return
wid
...
...
@@ -153,7 +154,7 @@ class AcqParamsWidget(Qt.QWidget):
det_mu_rb
=
Qt
.
QRadioButton
(
u
'Width is {0}.'
.
format
(
_MU_LOWER
))
h_layout
.
addWidget
(
det_mu_rb
)
else
:
det_orient_edit
=
_
AdjustedLineEdit
(
5
,
read_only
=
True
)
det_orient_edit
=
AdjustedLineEdit
(
5
,
read_only
=
True
)
det_orient_edit
.
setAlignment
(
Qt
.
Qt
.
AlignCenter
)
h_layout
.
addWidget
(
det_orient_edit
,
alignment
=
Qt
.
Qt
.
AlignLeft
)
layout
.
addLayout
(
h_layout
,
row
,
1
)
...
...
@@ -304,14 +305,14 @@ class AcqParamsWidget(Qt.QWidget):
self
.
__detector_orient
=
detector_orient
class
_
AdjustedPushButton
(
Qt
.
QPushButton
):
class
AdjustedPushButton
(
Qt
.
QPushButton
):
"""
It seems that by default QPushButtons minimum width is 75.
This is a workaround.
For _AdjustedPushButton to work text has to be set at creation time.
"""
def
__init__
(
self
,
text
,
padding
=
None
,
**
kwargs
):
super
(
_
AdjustedPushButton
,
self
).
__init__
(
text
,
**
kwargs
)
def
__init__
(
self
,
text
,
pa
rent
=
None
,
pa
dding
=
None
):
super
(
AdjustedPushButton
,
self
).
__init__
(
text
,
parent
)
fm
=
self
.
fontMetrics
()
...
...
@@ -322,27 +323,26 @@ class _AdjustedPushButton(Qt.QPushButton):
self
.
setMaximumWidth
(
width
)
class
_
AdjustedLineEdit
(
Qt
.
QLineEdit
):
class
AdjustedLineEdit
(
Qt
.
QLineEdit
):
"""
"""
def
__init__
(
self
,
width
=
None
,
parent
=
None
,
padding
=
None
,
alignment
=
Qt
.
Qt
.
AlignRight
,
validator_cls
=
None
,
field_type
=
None
,
read_only
=
False
,
reset_on_empty
=
False
,
highlight_change
=
False
,
**
kwargs
):
super
(
_AdjustedLineEdit
,
self
).
__init__
(
**
kwargs
)
highlight_change
=
False
):
super
(
AdjustedLineEdit
,
self
).
__init__
(
parent
)
self
.
__defaultText
=
self
.
text
()
self
.
__highlightChange
=
highlight_change
self
.
__resetOnEmpty
=
reset_on_empty
self
.
__fieldType
=
field_type
if
width
is
not
None
:
fm
=
self
.
fontMetrics
()
...
...
@@ -385,6 +385,8 @@ class _AdjustedLineEdit(Qt.QLineEdit):
else
:
pass
same_txt
=
False
if
len
(
value
)
==
0
:
if
len
(
self
.
__defaultText
)
==
0
:
same_txt
=
True
...
...
@@ -398,6 +400,7 @@ class _AdjustedLineEdit(Qt.QLineEdit):
value
=
self
.
__fieldType
(
value
)
default_value
=
self
.
__fieldType
(
self
.
__defaultText
)
except
:
# TODO : filter specific exception
same_txt
=
False
else
:
default_value
=
self
.
__defaultText
...
...
@@ -439,10 +442,10 @@ class _AdjustedLineEdit(Qt.QLineEdit):
if
ev
.
type
()
==
Qt
.
QEvent
.
EnabledChange
:
self
.
style
().
unpolish
(
self
)
self
.
style
().
polish
(
self
)
return
super
(
_
AdjustedLineEdit
,
self
).
event
(
ev
)
return
super
(
AdjustedLineEdit
,
self
).
event
(
ev
)
class
_
AdjustedLabel
(
Qt
.
QLabel
):
class
AdjustedLabel
(
Qt
.
QLabel
):
"""
"""
def
__init__
(
self
,
...
...
@@ -450,7 +453,7 @@ class _AdjustedLabel(Qt.QLabel):
padding
=
None
,
alignment
=
Qt
.
Qt
.
AlignRight
,
**
kwargs
):
super
(
_
AdjustedLabel
,
self
).
__init__
(
**
kwargs
)
super
(
AdjustedLabel
,
self
).
__init__
(
**
kwargs
)
self
.
setFrameStyle
(
Qt
.
QFrame
.
Panel
|
Qt
.
QFrame
.
Sunken
)
...
...
kmap/gui/XsocsGui.py
View file @
fd9c53bf
...
...
@@ -27,20 +27,16 @@ from __future__ import absolute_import
import
os
import
numpy
as
np
from
matplotlib
import
cm
from
silx.gui
import
qt
as
Qt
from
plot3d.IsosurfaceView
import
IsosurfaceView
from
..io
import
XsocsH5
from
.Utils
import
(
viewWidgetFromProjectEvent
,
processWidgetFromViewEvent
)
from
.MergeWidget
import
MergeWidget
from
.RecipSpaceWidget
import
RecipSpaceWidget
from
.Widgets
import
(
AcqParamsWidget
,
_
AdjustedLineEdit
,
_
AdjustedPushButton
)
AdjustedLineEdit
,
AdjustedPushButton
)
from
.project.XsocsProject
import
XsocsProject
from
.PlotWidgets
import
IntensityWindow
from
..io
import
XsocsH5
_COMPANY_NAME
=
'ESRF'
...
...
@@ -71,58 +67,28 @@ class XsocsGui(Qt.QMainWindow):
self
.
__greeterDiag
=
None
self
.
__readSettings
()
def
__
dataDock
Slot
(
self
,
event
):
def
__
projectView
Slot
(
self
,
event
):
# TODO : store the plot window in a dictionary + weakref w delete
# callback when object is destroyed
type
=
event
.
type
plotData
=
event
.
plotData
()
x
,
y
,
data
=
plotData
if
type
==
'scatter'
:
self
.
showScatterPlot
(
x
,
y
,
data
)
elif
type
==
'image'
:
self
.
showImage
(
x
,
y
,
data
)
def
showScatterPlot
(
self
,
x
,
y
,
data
):
mdi
=
self
.
centralWidget
()
min_
,
max_
=
data
.
min
(),
data
.
max
()
colormap
=
cm
.
jet
colors
=
colormap
((
data
.
astype
(
np
.
float64
)
-
min_
)
/
(
max_
-
min_
))
plotWin
=
IntensityWindow
(
aspectRatio
=
True
)
plotWin
=
viewWidgetFromProjectEvent
(
self
.
__project
,
event
)
plotWin
.
setAttribute
(
Qt
.
Qt
.
WA_DeleteOnClose
)
plotWin
.
plot
.
addCurve
(
x
,
y
,
color
=
colors
,
symbol
=
's'
,
linestyle
=
''
)
plotWin
.
sigRoiApplied
.
connect
(
self
.
__roiApplied
)
plotWin
.
sigProcessApplied
.
connect
(
self
.
__processApplied
)
mdi
.
addSubWindow
(
plotWin
)
plotWin
.
show
()
return
plotWin
def
showImage
(
self
,
x
,
y
,
data
):
def
__processApplied
(
self
,
event
):
mdi
=
self
.
centralWidget
()
plotWin
=
IntensityWindow
(
aspectRatio
=
True
)
plotWin
.
setAttribute
(
Qt
.
Qt
.
WA_DeleteOnClose
)
min_
,
max_
=
data
.
min
(),
data
.
max
()
colormap
=
{
'name'
:
'temperature'
,
'normalization'
:
'linear'
,
'autoscale'
:
True
,
'vmin'
:
min_
,
'vmax'
:
max_
}
origin
=
x
[
0
],
y
[
0
]
scale
=
(
x
[
-
1
]
-
x
[
0
])
/
len
(
x
),
(
y
[
-
1
]
-
y
[
0
])
/
len
(
y
)
plotWin
.
plot
.
addImage
(
data
,
origin
=
origin
,
scale
=
scale
,
colormap
=
colormap
)
plotWin
.
sigRoiApplied
.
connect
(
self
.
__roiApplied
)
mdi
.
addSubWindow
(
plotWin
)
plotWin
.
show
()
return
plotWin
def
__roiApplied
(
self
,
roiData
):
widget
=
RecipSpaceWidget
(
data_h5f
=
self
.
__workspace
.
xsocsFile
,
output_f
=
None
,
qspace_size
=
None
,
image_binning
=
None
,
rect_roi
=
roiData
)
widget
.
exec_
()
if
widget
.
result
()
==
Qt
.
QDialog
.
Accepted
:
self
.
__workspace
.
addQSpaceH5
(
widget
.
qspaceH5
)
widget
=
processWidgetFromViewEvent
(
self
.
__project
,
event
,
parent
=
self
)
widget
.
setWindowFlags
(
Qt
.
Qt
.
Dialog
)
widget
.
setWindowModality
(
Qt
.
Qt
.
WindowModal
)
widget
.
sigProcessDone
.
connect
(
self
.
__processDone
)
widget
.
setAttribute
(
Qt
.
Qt
.
WA_DeleteOnClose
)
widget
.
show
()
def
__processDone
(
self
,
event
):
print
'event'
,
event
def
showEvent
(
self
,
event
):
super
(
XsocsGui
,
self
).
showEvent
(
event
)
...
...
@@ -187,7 +153,7 @@ class XsocsGui(Qt.QMainWindow):
wkSpace
.
xsocsFile
=
xsocsH5
self
.
__sessionDock
.
widget
().
setXsocsWorkspace
(
wkSpace
)
self
.
__dataDock
.
widget
().
setXsocsWorkspace
(
wkSpace
)
self
.
__
workspace
=
wkSpace
self
.
__
project
=
wkSpace
self
.
__closeGreeter
()
...
...
@@ -292,7 +258,7 @@ class XsocsGui(Qt.QMainWindow):
plotDataDock
.
setWidget
(
PlotDataWidget
())
plotDataDock
.
setObjectName
(
'DataDock'
)
self
.
addDockWidget
(
Qt
.
Qt
.
LeftDockWidgetArea
,
plotDataDock
)
plotDataDock
.
widget
().
sig
Item
Event
.
connect
(
self
.
__
dataDock
Slot
,
plotDataDock
.
widget
().
sig
View
Event
.
connect
(
self
.
__
projectView
Slot
,
Qt
.
Qt
.
QueuedConnection
)
def
__writeSettings
(
self
):
...
...
@@ -347,7 +313,7 @@ class XsocsGui(Qt.QMainWindow):
class
PlotDataWidget
(
Qt
.
QWidget
):
sig
Item
Event
=
Qt
.
Signal
(
object
)
sig
View
Event
=
Qt
.
Signal
(
object
)
def
__init__
(
self
,
parent
=
None
):
super
(
PlotDataWidget
,
self
).
__init__
(
parent
)
...
...
@@ -369,7 +335,7 @@ class PlotDataWidget(Qt.QWidget):
self
.
__treeView
.
deleteLater
()
self
.
__treeView
=
None
view
=
self
.
__xsocsProject
.
view
(
parent
=
self
)
view
.
sigItemEvent
.
connect
(
self
.
sig
Item
Event
)
view
.
sigItemEvent
.
connect
(
self
.
sig
View
Event
)
self
.
layout
().
addWidget
(
view
)
self
.
__treeView
=
view
...
...
@@ -392,7 +358,7 @@ class SessionWidget(Qt.QWidget):
# #########
gbox
=
Qt
.
QGroupBox
(
'XSocs file'
)
boxLayout
=
Qt
.
QVBoxLayout
(
gbox
)
self
.
__fileLabel
=
fileLabel
=
_
AdjustedLineEdit
(
read_only
=
True
)
self
.
__fileLabel
=
fileLabel
=
AdjustedLineEdit
(
read_only
=
True
)
fileLabel
.
setAlignment
(
Qt
.
Qt
.
AlignLeft
)
boxLayout
.
addWidget
(
fileLabel
)
...
...
@@ -406,18 +372,18 @@ class SessionWidget(Qt.QWidget):
# number of angles
rowIdx
=
0
self
.
__anglesText
=
anglesText
=
_
AdjustedLineEdit
(
3
,
read_only
=
True
)
self
.
__anglesText
=
anglesText
=
AdjustedLineEdit
(
3
,
read_only
=
True
)
gridLayout
.
addWidget
(
Qt
.
QLabel
(
'# angles :'
),
rowIdx
,
0
,
alignment
=
Qt
.
Qt
.
AlignLeft
)
gridLayout
.
addWidget
(
anglesText
,
rowIdx
,
1
,
alignment
=
Qt
.
Qt
.
AlignLeft
)
rowIdx
+=
1
self
.
__nImgText
=
nImgText
=
_
AdjustedLineEdit
(
5
,
read_only
=
True
)
self
.
__nImgText
=
nImgText
=
AdjustedLineEdit
(
5
,
read_only
=
True
)
gridLayout
.
addWidget
(
Qt
.
QLabel
(
'Images :'
),
rowIdx
,
0
,
alignment
=
Qt
.
Qt
.
AlignLeft
)
gridLayout
.
addWidget
(
nImgText
,
rowIdx
,
1
,
alignment
=
Qt
.
Qt
.
AlignLeft
)
self
.
__imgSizeText
=
imgSizeText
=
_
AdjustedLineEdit
(
10
,
read_only
=
True
)
self
.
__imgSizeText
=
imgSizeText
=
AdjustedLineEdit
(
10
,
read_only
=
True
)
gridLayout
.
addWidget
(
Qt
.
QLabel
(
'Size :'
),
rowIdx
,
2
,
alignment
=
Qt
.
Qt
.
AlignLeft
)
gridLayout
.
addWidget
(
imgSizeText
,
rowIdx
,
3
,
alignment
=
Qt
.
Qt
.
AlignLeft
)
...
...
@@ -528,9 +494,9 @@ class _WorkspaceDirDialog(Qt.QDialog):
layout
=
Qt
.
QGridLayout
(
self
)
label
=
Qt
.
QLabel
(
'Workspace :'
)
lineEdit
=
_
AdjustedLineEdit
(
40
)
lineEdit
=
AdjustedLineEdit
(
40
)
lineEdit
.
setAlignment
(
Qt
.
Qt
.
AlignLeft
)
pickButton
=
_
AdjustedPushButton
(
'...'
)
pickButton
=
AdjustedPushButton
(
'...'
)
layout
.
addWidget
(
label
,
0
,
0
,
Qt
.
Qt
.
AlignLeft
)
...
...
kmap/gui/gui.py
View file @
fd9c53bf
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
from
__future__
import
absolute_import
__authors__
=
[
"D. Naudet"
]
__license__
=
"MIT"
__date__
=
"15/09/2016"
import
sys
from
silx.gui
import
qt
as
Qt
print
(
'Using Qt {0}'
.
format
(
Qt
.
qVersion
()))
from
XsocsGui
import
XsocsGui
from
.
XsocsGui
import
XsocsGui
from
.MergeWidget
import
MergeWidget
from
.RecipSpaceWidget
import
RecipSpaceWidget
from
.process.RecipSpaceWidget
import
RecipSpaceWidget
def
merge_window
(
*
args
,
**
kwargs
):
app
=
Qt
.
QApplication
(
sys
.
argv
)
...
...
@@ -13,12 +45,14 @@ def merge_window(*args, **kwargs):
mw
.
show
()
app
.
exec_
()
def
conversion_window
(
*
args
,
**
kwargs
):
app
=
Qt
.
QApplication
(
sys
.
argv
)
mw
=
RecipSpaceWidget
(
*
args
,
**
kwargs
)
mw
.
show
()
app
.
exec_
()
def
xsocs_main
(
*
args
,
**
kwargs
):
app
=
Qt
.
QApplication
(
sys
.
argv
)
mw
=
XsocsGui
(
*
args
,
**
kwargs
)
...
...
kmap/gui/process/ProcessWidget.py
0 → 100644
View file @
fd9c53bf
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
from
__future__
import
absolute_import
__authors__
=
[
"D. Naudet"
]
__license__
=
"MIT"
__date__
=
"15/09/2016"
from
collections
import
namedtuple
from
silx.gui
import
qt
as
Qt
ProcessResult
=
namedtuple
(
'ProcessResult'
,
[
'status'
,
'data'
])
class
ProcessWidget
(
Qt
.
QMainWindow
):
sigProcessDone
=
Qt
.
Signal
(
object
)
(
StatusUnknown
,
StatusInit
,
StatusRunning
,
StatusCompleted
,
StatusAborted
,
StatusCanceled
)
=
StatusList
=
range
(
6
)
def
__init__
(
self
,
index
=
None
,
parent
=
None
,
**
kwargs
):
super
(
ProcessWidget
,
self
).
__init__
(
parent
,
**
kwargs
)
self
.
__index
=
index
self
.
__status
=
ProcessWidget
.
StatusInit
status
=
property
(
lambda
self
:
self
.
__status
)
def
_setStatus
(
self
,
status
):
if
status
not
in
ProcessWidget
.
StatusList
:
raise
ValueError
(
'Unknown status value : {0}.'
''
.
format
(
status
))
self
.
__status
=
status
def
processResult
(
self
):
return
ProcessResult
(
status
=
self
.
status
,
data
=
self
.
_processData
())
def
_processData
(
self
):
return
None
def
_emitEvent
(
self
,
event
):
self
.
sigProcessDone
.
emit
(
event
)
index
=
property
(
lambda
self
:
self
.
__index
)
class
ProcessWidgetEvent
(
object
):
def
__init__
(
self
,
widget
,
data
=
None
):
super
(
ProcessWidgetEvent
,
self
).
__init__
()
self
.
__index
=
widget
.
index
self
.
__data
=
data
data
=
property
(
lambda
self
:
self
.
__data
)
index
=
property
(
lambda
self
:
self
.
__index
)
kmap/gui/RecipSpaceWidget.py
→
kmap/gui/
process/
RecipSpaceWidget.py
View file @
fd9c53bf
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#