Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xsocs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kmap
xsocs
Commits
0917dfdd
Commit
0917dfdd
authored
Nov 23, 2016
by
Damien Naudet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
8a72d061
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
292 additions
and
410 deletions
+292
-410
kmap/gui/XsocsGui.py
kmap/gui/XsocsGui.py
+21
-7
kmap/gui/model/Model.py
kmap/gui/model/Model.py
+0
-1
kmap/gui/model/TreeView.py
kmap/gui/model/TreeView.py
+1
-0
kmap/gui/project/Hdf5Nodes.py
kmap/gui/project/Hdf5Nodes.py
+2
-0
kmap/gui/project/ProjectNodes.py
kmap/gui/project/ProjectNodes.py
+29
-0
kmap/gui/project/QSpaceGroup.py
kmap/gui/project/QSpaceGroup.py
+24
-1
kmap/gui/view/IntensityView.py
kmap/gui/view/IntensityView.py
+2
-0
kmap/gui/view/QspaceView.py
kmap/gui/view/QspaceView.py
+213
-0
kmap/gui/view/QspaceViewWidget.py
kmap/gui/view/QspaceViewWidget.py
+0
-401
No files found.
kmap/gui/XsocsGui.py
View file @
0917dfdd
...
...
@@ -37,10 +37,12 @@ from .Widgets import (AcqParamsWidget,
# processDoneEvent)
from
.process.RecipSpaceWidget
import
RecipSpaceWidget
from
.view.IntensityView
import
IntensityView
from
.view.QspaceView
import
QSpaceView
from
.project.XsocsProject
import
XsocsProject
from
.model.TreeView
import
TreeView
from
.model.Model
import
Model
from
.project.IntensityGroup
import
IntensityGroup
,
IntensityItem
from
.project.IntensityGroup
import
IntensityGroup
from
.project.QSpaceGroup
import
QSpaceItem
from
.project.XsocsH5Factory
import
XsocsH5Factory
,
h5NodeToProjectItem
from
.project.Hdf5Nodes
import
setH5NodeFactory
,
H5File
from
.Utils
import
nextFileName
...
...
@@ -70,7 +72,7 @@ class XsocsGui(Qt.QMainWindow):
setH5NodeFactory
(
XsocsH5Factory
)
self
.
__intensityView
=
None
self
.
__qspaceView
=
None
self
.
__qspaceView
s
=
{}
mdiArea
=
Qt
.
QMdiArea
()
self
.
setCentralWidget
(
mdiArea
)
...
...
@@ -100,9 +102,12 @@ class XsocsGui(Qt.QMainWindow):
raise
ValueError
(
'Unknwown event for node {0} : {1}.'
''
.
format
(
node
,
event
))
if
isinstance
(
projectItem
,
(
IntensityGroup
,
IntensityItem
)
)
\
if
isinstance
(
projectItem
,
IntensityGroup
)
\
and
event
[
'event'
]
==
'scatter'
:
self
.
__showIntensity
(
node
)
elif
isinstance
(
projectItem
,
QSpaceItem
)
\
and
event
[
'event'
]
==
'qspace'
:
self
.
__showQSpace
(
node
)
else
:
ValueError
(
'Unknwown event for item {0} : {1}.'
''
.
format
(
projectItem
,
event
))
...
...
@@ -130,12 +135,21 @@ class XsocsGui(Qt.QMainWindow):
widget
.
exec_
()
if
widget
.
status
==
RecipSpaceWidget
.
StatusCompleted
:
qspaceF
=
widget
.
qspaceH5
qspaceGroup
=
self
.
__project
.
qspaceGroup
()
qspaceGroup
.
addQSpace
(
qspaceF
)
self
.
model
().
refresh
()
qspaceGroup
=
self
.
__project
.
qspaceGroup
()
qspaceGroup
.
addQSpace
(
qspaceF
)
self
.
model
().
reset
()
def
__showQSpace
(
self
,
node
):
print
node
view
=
self
.
__qspaceViews
.
get
(
node
)
if
not
view
:
view
=
QSpaceView
(
self
,
model
=
node
.
model
,
node
=
node
)
self
.
__qspaceViews
[
node
]
=
view
# view.sigProcessApplied.connect(self.__intensityRoiApplied)
view
.
show
()
def
model
(
self
):
self
.
centralWidget
().
model
()
return
self
.
centralWidget
().
model
()
def
showEvent
(
self
,
event
):
super
(
XsocsGui
,
self
).
showEvent
(
event
)
...
...
kmap/gui/model/Model.py
View file @
0917dfdd
...
...
@@ -202,7 +202,6 @@ class Model(Qt.QAbstractItemModel):
for
child
in
children
:
child
.
clear
()
print
'adding'
,
child
self
.
__root
.
appendChild
(
child
)
def
rowCount
(
self
,
parent
=
Qt
.
QModelIndex
(),
**
kwargs
):
...
...
kmap/gui/model/TreeView.py
View file @
0917dfdd
...
...
@@ -178,6 +178,7 @@ class TreeView(Qt.QTreeView):
else
:
self
.
__userRoot
=
False
self
.
__updateUniqueGroupVisibility
()
self
.
__setHiddenNodes
(
self
.
rootIndex
())
self
.
__openPersistentEditors
(
self
.
rootIndex
(),
True
)
def
setModel
(
self
,
model
):
...
...
kmap/gui/project/Hdf5Nodes.py
View file @
0917dfdd
...
...
@@ -254,6 +254,8 @@ class H5DatasetNode(H5Base):
text
=
data
.
replace
(
'
\n
'
,
' '
)
else
:
text
=
str
(
data
)
elif
ndims
==
1
and
item
.
shape
[
0
]
<
5
:
text
=
str
(
item
[:])
else
:
text
=
'...'
del
item
...
...
kmap/gui/project/ProjectNodes.py
View file @
0917dfdd
...
...
@@ -61,6 +61,29 @@ class ScatterPlotButton(EditorMixin, Qt.QWidget):
self
.
notifyView
(
event
)
class
QSpaceButton
(
EditorMixin
,
Qt
.
QWidget
):
persistent
=
True
sigValueChanged
=
Qt
.
Signal
()
def
__init__
(
self
,
parent
,
option
,
index
):
super
(
QSpaceButton
,
self
).
__init__
(
parent
,
option
,
index
)
layout
=
Qt
.
QHBoxLayout
(
self
)
layout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
icon
=
icons
.
getQIcon
(
'item-ndim'
)
button
=
Qt
.
QToolButton
()
button
.
setIcon
(
icon
)
layout
.
addWidget
(
button
)
layout
.
addStretch
(
1
)
button
.
clicked
.
connect
(
self
.
__clicked
)
def
__clicked
(
self
):
# node = self.node
event
=
{
'event'
:
'qspace'
}
self
.
notifyView
(
event
)
@
H5NodeClassDef
(
'IntensityGroupNode'
,
attribute
=
(
'XsocsClass'
,
'IntensityGroup'
))
class
IntensityGroupNode
(
H5GroupNode
):
...
...
@@ -77,3 +100,9 @@ class IntensityNode(H5DatasetNode):
self
.
setData
(
ModelColumns
.
NameColumn
,
str
(
item
.
projectRoot
().
shortName
(
item
.
entry
)),
Qt
.
Qt
.
DisplayRole
)
@
H5NodeClassDef
(
'QSpaceItem'
,
attribute
=
(
'XsocsClass'
,
'QSpaceItem'
))
class
QSpaceItemNode
(
H5GroupNode
):
editors
=
QSpaceButton
kmap/gui/project/QSpaceGroup.py
View file @
0917dfdd
...
...
@@ -31,6 +31,8 @@ __date__ = "15/09/2016"
import
os
import
numpy
as
np
# from .ProjectDef import ProcessId
# from .HybridItem import HybridItem
from
...io.QSpaceH5
import
QSpaceH5
...
...
@@ -45,6 +47,7 @@ class QSpaceGroup(ProjectItem):
itemPath
=
self
.
path
+
'/'
+
itemName
item
=
QSpaceItem
(
self
.
filename
,
itemPath
,
mode
=
'a'
)
item
.
qspaceFile
=
qspaceFile
return
item
@
ItemClassDef
(
'QSpaceItem'
)
...
...
@@ -85,11 +88,31 @@ class QSpaceItem(ProjectItem):
self
.
_createItem
()
def
_createItem
(
self
):
print
'CREATE'
,
self
.
qspaceFile
qspaceFile
=
self
.
qspaceFile
if
qspaceFile
is
None
:
return
with
QSpaceH5
(
qspaceFile
)
as
qspaceH5
:
with
self
:
pathTpl
=
self
.
path
+
'/info/{0}'
with
qspaceH5
.
qspace_dset_ctx
()
as
ctx
:
shape
=
np
.
array
(
ctx
.
shape
)
itemPath
=
pathTpl
.
format
(
'#'
)
self
.
_set_scalar_data
(
itemPath
,
shape
[
0
])
itemPath
=
pathTpl
.
format
(
'shape'
)
self
.
_set_array_data
(
itemPath
,
shape
[
1
:])
qx
=
qspaceH5
.
qx
qy
=
qspaceH5
.
qy
qz
=
qspaceH5
.
qz
itemPath
=
pathTpl
.
format
(
'qx range'
)
self
.
_set_array_data
(
itemPath
,
np
.
array
([
qx
[
0
],
qx
[
-
1
]]))
itemPath
=
pathTpl
.
format
(
'qy range'
)
self
.
_set_array_data
(
itemPath
,
np
.
array
([
qy
[
0
],
qy
[
-
1
]]))
itemPath
=
pathTpl
.
format
(
'qz range'
)
self
.
_set_array_data
(
itemPath
,
np
.
array
([
qz
[
0
],
qz
[
-
1
]]))
# @ItemClassDef('QSpaceItem')
# class QSpaceItem(ProjectItem):
# QSpaceFilePath = 'File'
...
...
kmap/gui/view/IntensityView.py
View file @
0917dfdd
...
...
@@ -197,6 +197,8 @@ class IntensityView(Qt.QMainWindow):
tree
.
setRootIndex
(
index
)
tree
.
sigCurrentChanged
.
connect
(
self
.
__itemSelected
)
dock
.
setWidget
(
tree
)
features
=
dock
.
features
()
^
Qt
.
QDockWidget
.
DockWidgetClosable
dock
.
setFeatures
(
features
)
self
.
addDockWidget
(
Qt
.
Qt
.
LeftDockWidgetArea
,
dock
)
self
.
__roiManager
=
roiManager
=
ImageRoiManager
(
plotWindow
)
...
...
kmap/gui/view/QspaceView.py
0 → 100644
View file @
0917dfdd
# 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
numpy
as
np
from
matplotlib
import
cm
from
silx.gui
import
qt
as
Qt
from
silx.gui.plot
import
PlotWindow
from
plot3d.ScalarFieldView
import
ScalarFieldView
from
...io.QSpaceH5
import
QSpaceH5
from
..model.ModelDef
import
ModelRoles
# from ..project.HybridItem import HybridItem
from
..project.QSpaceGroup
import
QSpaceItem
from
..model.TreeView
import
TreeView
class
QSpaceTree
(
TreeView
):
pass
# sigCurrentChanged = Qt.Signal(object)
# def __init__(self, *args, **kwargs):
# super(IntensityTree, self).__init__(*args, **kwargs)
# self.disableDelegateForColumn(1, True)
# for col in range(ModelColumns.ColumnMax):
# if col != ModelColumns.NameColumn:
# self.setColumnHidden(col, True)
#
# def currentChanged(self, current, previous):
# node = current.data(ModelRoles.InternalDataRole)
# if not node:
# return
# projectItem = h5NodeToProjectItem(node)
# self.sigCurrentChanged.emit(projectItem)
class
QSpaceView
(
Qt
.
QMainWindow
):
sigProcessApplied
=
Qt
.
Signal
(
object
)
plot
=
property
(
lambda
self
:
self
.
__plotWindow
)
def
__init__
(
self
,
parent
,
model
,
node
,
**
kwargs
):
super
(
QSpaceView
,
self
).
__init__
(
parent
)
self
.
__plotWindow
=
plotWindow
=
PlotWindow
(
aspectRatio
=
True
,
curveStyle
=
False
,
mask
=
False
,
roi
=
False
,
**
kwargs
)
plotWindow
.
sigPlotSignal
.
connect
(
self
.
__plotSignal
)
plotWindow
.
setKeepDataAspectRatio
(
True
)
plotWindow
.
setActiveCurveHandling
(
False
)
# self.setCentralWidget(plotWindow)
self
.
__isoView
=
None
self
.
__isoPosition
=
None
self
.
__plotType
=
None
treeDock
=
Qt
.
QDockWidget
(
self
)
tree
=
TreeView
(
self
,
model
=
model
)
index
=
node
.
index
()
tree
.
setRootIndex
(
index
)
# tree.sigCurrentChanged.connect(self.__itemSelected)
treeDock
.
setWidget
(
tree
)
features
=
treeDock
.
features
()
^
Qt
.
QDockWidget
.
DockWidgetClosable
treeDock
.
setFeatures
(
features
)
self
.
addDockWidget
(
Qt
.
Qt
.
LeftDockWidgetArea
,
treeDock
)
plotDock
=
Qt
.
QDockWidget
(
self
)
# tree.sigCurrentChanged.connect(self.__itemSelected)
plotDock
.
setWidget
(
plotWindow
)
features
=
plotDock
.
features
()
^
Qt
.
QDockWidget
.
DockWidgetClosable
plotDock
.
setFeatures
(
features
)
self
.
addDockWidget
(
Qt
.
Qt
.
RightDockWidgetArea
,
plotDock
)
# self.splitDockWidget(treeDock, plotDock, Qt.Qt.Vertical)
def
_emitEvent
(
self
,
event
):
self
.
sigProcessApplied
.
emit
(
event
)
# TODO : refactor this in a common base with RealSpaceViewWidget
def
setPlotData
(
self
,
x
,
y
,
data
):
plot
=
self
.
__plotWindow
if
data
.
ndim
==
1
:
# scatter
min_
,
max_
=
data
.
min
(),
data
.
max
()
colormap
=
cm
.
jet
colors
=
colormap
((
data
.
astype
(
np
.
float64
)
-
min_
)
/
(
max_
-
min_
))
plot
.
addCurve
(
x
,
y
,
color
=
colors
,
symbol
=
's'
,
linestyle
=
''
)
self
.
__plotType
=
'scatter'
elif
data
.
ndim
==
2
:
# image
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
)
plot
.
addImage
(
data
,
origin
=
origin
,
scale
=
scale
,
colormap
=
colormap
)
self
.
__plotType
=
'image'
else
:
raise
ValueError
(
'data has {0} dimensions, expected 1 or 2.'
''
.
format
(
data
.
ndim
))
def
__plotSignal
(
self
,
event
):
if
event
[
'event'
]
not
in
(
'curveClicked'
,):
# , 'mouseClicked'):
return
x
,
y
=
event
[
'xdata'
],
event
[
'ydata'
]
self
.
__showIsoView
(
x
,
y
)
def
__showIsoView
(
self
,
x
,
y
):
print
'SHOW'
# if self.__isoPosition is not None:
# if self.__isoPosition[0] == x and self.__isoPosition[1] == y:
# return
# isoView = self.__isoView
# if isoView is None:
# isoView = IsoViewMainWindow(parent=self)
# if isinstance(self.parent(), Qt.QMdiSubWindow):
# self.parent().mdiArea().addSubWindow(isoView)
# node = self.index.data(ModelRoles.InternalDataRole)
# item = HybridItem(node.projectFile, node.path)
# if item.hasScatter():
# xPos, yPos, _ = item.getScatter()
# elif item.hasImage():
# xPos, yPos, _ = item.getImage()
# else:
# return None
# # TODO : this wont work with images
# try:
# xIdx = (np.abs(xPos - x)).argmin()
# except:
# print x
# xIdx = (np.abs(xPos - x[0])).argmin()
#
# # TODO : this is not robust at all
# qspaceNode = node.parent()
# qspaceItem = QSpaceItem(qspaceNode.projectFile, qspaceNode.path)
# qspaceH5 = QSpaceH5(qspaceItem.qspaceFile)
#
# qspace = qspaceH5.qspace_slice(xIdx)
#
# isoView.setData(qspace)
# self.__isoView = isoView
# isoView.show()
#
# class IsoViewMainWindow(ScalarFieldView):
# """Window displaying an isosurface and some controls."""
#
# def __init__(self, *args, **kwargs):
# super(IsoViewMainWindow, self).__init__(*args, **kwargs)
# self.setAttribute(Qt.Qt.WA_DeleteOnClose)
#
# # Adjust lighting
# self.plot3D.viewport.light.direction = 0., 0., -1.
# self.plot3D.viewport.light.shininess = 32
# self.plot3D.viewport.bgColor = 0.2, 0.2, 0.2, 1.
#
# # Add controller dock widget
# self._control = _Controller(viewer=self)
# self._control.setWindowTitle('Isosurface')
# self.addDockWidget(Qt.Qt.RightDockWidgetArea, self._control)
#
# def setData(self, data, copy=True):
# data = np.asarray(data)
# self._control.setRange(data.min(), data.max())
# super(IsoViewMainWindow, self).setData(data, copy)
\ No newline at end of file
kmap/gui/view/QspaceViewWidget.py
deleted
100644 → 0
View file @
8a72d061
This diff is collapsed.
Click to expand it.
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