def __init__(self, parent=None): super(OpenClDeviceDialog, self).__init__(parent) filename = get_ui_file("opencl-device-dialog.ui") qt.loadUi(filename, self) self.__availableIds = {} model = self.__createModel() self._deviceView.setModel(model) self._deviceView.setSelectionMode(qt.QAbstractItemView.SingleSelection) self._deviceView.setSelectionBehavior(qt.QAbstractItemView.SelectRows) header = self._deviceView.horizontalHeader() if qt.qVersion() < "5.0": header.setClickable(True) header.setMovable(True) header.setSectionResizeMode = self.setResizeMode else: header.setSectionsClickable(True) header.setSectionsMovable(True) header.setStretchLastSection(False) header.setSectionResizeMode(0, qt.QHeaderView.Stretch) header.setSectionResizeMode(1, qt.QHeaderView.Interactive) header.setSectionResizeMode(2, qt.QHeaderView.ResizeToContents) header.setSectionResizeMode(3, qt.QHeaderView.ResizeToContents) header.setSectionResizeMode(4, qt.QHeaderView.ResizeToContents) self._buttonBox.accepted.connect(self.accept) self._buttonBox.rejected.connect(self.reject) self._group = qt.QButtonGroup(self) self._group.setExclusive(True) self._group.addButton(self._anyDeviceButton) self._group.addButton(self._anyGpuButton) self._group.addButton(self._anyCpuButton) self._group.addButton(self._availableButton) self._group.addButton(self._customButton) self._group.buttonClicked.connect(self.__modeChanged) self._anyDeviceButton.setChecked(True) self.__modeChanged() if pyopencl is None: self._availableButton.setEnabled(False) self._availableButton.setToolTip( "PyOpenCL have to be installed to display available devices.")
def __init__(self, parent=None): super(GeometryDialog, self).__init__(parent) filename = get_ui_file("geometry-dialog.ui") qt.loadUi(filename, self) self.__geometry = GeometryModel() self.__fit2dGeometry = Fit2dGeometryModel() self.__detector = None self.__originalGeometry = None self.__updatingModel = False # Connect buttons self._buttonBox.rejected.connect(self.reject) self._buttonBox.accepted.connect(self.accept) # Create shared units angleUnit = DataModel() angleUnit.setValue(units.Unit.RADIAN) lengthUnit = DataModel() lengthUnit.setValue(units.Unit.METER) pixelUnit = DataModel() pixelUnit.setValue(units.Unit.PIXEL) # Connect pyFAI widgets to units self._pyfaiDistance.setDisplayedUnitModel(lengthUnit) self._pyfaiDistance.setModelUnit(units.Unit.METER) self._pyfaiDistanceUnit.setUnitModel(lengthUnit) self._pyfaiDistanceUnit.setUnitEditable(True) self._pyfaiPoni1.setDisplayedUnitModel(lengthUnit) self._pyfaiPoni1.setModelUnit(units.Unit.METER) self._pyfaiPoni1Unit.setUnitModel(lengthUnit) self._pyfaiPoni1Unit.setUnitEditable(True) self._pyfaiPoni2.setDisplayedUnitModel(lengthUnit) self._pyfaiPoni2.setModelUnit(units.Unit.METER) self._pyfaiPoni2Unit.setUnitModel(lengthUnit) self._pyfaiPoni2Unit.setUnitEditable(True) self._pyfaiRotation1.setDisplayedUnitModel(angleUnit) self._pyfaiRotation1.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation1Unit.setUnitModel(angleUnit) self._pyfaiRotation1Unit.setUnitEditable(True) self._pyfaiRotation2.setDisplayedUnitModel(angleUnit) self._pyfaiRotation2.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation2Unit.setUnitModel(angleUnit) self._pyfaiRotation2Unit.setUnitEditable(True) self._pyfaiRotation3.setDisplayedUnitModel(angleUnit) self._pyfaiRotation3.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation3Unit.setUnitModel(angleUnit) self._pyfaiRotation3Unit.setUnitEditable(True) # Connect fit2d widgets to units self._fit2dDistance.setDisplayedUnitModel(lengthUnit) self._fit2dDistance.setModelUnit(units.Unit.MILLIMETER) self._fit2dDistanceUnit.setUnit(units.Unit.MILLIMETER) # self._fit2dDistanceUnit.setUnitModel(lengthUnit) # self._fit2dDistanceUnit.setUnitEditable(True) self._fit2dCenterX.setDisplayedUnitModel(pixelUnit) self._fit2dCenterX.setModelUnit(units.Unit.PIXEL) self._fit2dCenterXUnit.setUnit(units.Unit.PIXEL) # self._fit2dCenterXUnit.setUnitModel(pixelUnit) # self._fit2dCenterXUnit.setUnitEditable(True) self._fit2dCenterY.setDisplayedUnitModel(pixelUnit) self._fit2dCenterY.setModelUnit(units.Unit.PIXEL) self._fit2dCenterYUnit.setUnit(units.Unit.PIXEL) # self._fit2dCenterYUnit.setUnitModel(pixelUnit) # self._fit2dCenterYUnit.setUnitEditable(True) self._fit2dTilt.setDisplayedUnitModel(angleUnit) self._fit2dTilt.setModelUnit(units.Unit.DEGREE) self._fit2dTiltUnit.setUnit(units.Unit.DEGREE) # self._fit2dTiltUnit.setUnitModel(angleUnit) # self._fit2dTiltUnit.setUnitEditable(True) self._fit2dTiltPlan.setDisplayedUnitModel(angleUnit) self._fit2dTiltPlan.setModelUnit(units.Unit.DEGREE) self._fit2dTiltPlanUnit.setUnit(units.Unit.DEGREE) # self._fit2dTiltPlanUnit.setUnitModel(angleUnit) # self._fit2dTiltPlanUnit.setUnitEditable(True) # Connect fit2d model-widget self._fit2dDistance.setModel(self.__fit2dGeometry.distance()) self._fit2dCenterX.setModel(self.__fit2dGeometry.centerX()) self._fit2dCenterY.setModel(self.__fit2dGeometry.centerY()) self._fit2dTilt.setModel(self.__fit2dGeometry.tilt()) self._fit2dTiltPlan.setModel(self.__fit2dGeometry.tiltPlan()) self._pyfaiDistance.setModel(self.__geometry.distance()) self._pyfaiPoni1.setModel(self.__geometry.poni1()) self._pyfaiPoni2.setModel(self.__geometry.poni2()) self._pyfaiRotation1.setModel(self.__geometry.rotation1()) self._pyfaiRotation2.setModel(self.__geometry.rotation2()) self._pyfaiRotation3.setModel(self.__geometry.rotation3()) self.__geometry.changed.connect(self.__updateFit2dFromPyfai) self.__fit2dGeometry.changed.connect(self.__updatePyfaiFromFit2d) self.__geometry.changed.connect(self.__updateButtons) # NOTE: All the buttons have to be create here. # Changing available buttons on the focus event create a segfault types = (qt.QDialogButtonBox.Ok | qt.QDialogButtonBox.Cancel | qt.QDialogButtonBox.Reset | qt.QDialogButtonBox.Close) self._buttonBox.setStandardButtons(types) resetButton = self._buttonBox.button(qt.QDialogButtonBox.Reset) resetButton.clicked.connect(self.__resetToOriginalGeometry) self.__updateButtons()
def __init__(self, parent=None): super(GeometryDialog, self).__init__(parent) filename = get_ui_file("geometry-dialog.ui") qt.loadUi(filename, self) self.__geometry = None self.__detector = None # Connect close button self._buttonBox.rejected.connect(self.reject) # Create shared units angleUnit = DataModel() angleUnit.setValue(units.Unit.RADIAN) lengthUnit = DataModel() lengthUnit.setValue(units.Unit.METER) pixelUnit = DataModel() pixelUnit.setValue(units.Unit.PIXEL) # Connect pyFAI widgets to units self._pyfaiDistance.setDisplayedUnitModel(lengthUnit) self._pyfaiDistance.setModelUnit(units.Unit.METER) self._pyfaiDistanceUnit.setUnitModel(lengthUnit) self._pyfaiDistanceUnit.setUnitEditable(True) self._pyfaiPoni1.setDisplayedUnitModel(lengthUnit) self._pyfaiPoni1.setModelUnit(units.Unit.METER) self._pyfaiPoni1Unit.setUnitModel(lengthUnit) self._pyfaiPoni1Unit.setUnitEditable(True) self._pyfaiPoni2.setDisplayedUnitModel(lengthUnit) self._pyfaiPoni2.setModelUnit(units.Unit.METER) self._pyfaiPoni2Unit.setUnitModel(lengthUnit) self._pyfaiPoni2Unit.setUnitEditable(True) self._pyfaiRotation1.setDisplayedUnitModel(angleUnit) self._pyfaiRotation1.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation1Unit.setUnitModel(angleUnit) self._pyfaiRotation1Unit.setUnitEditable(True) self._pyfaiRotation2.setDisplayedUnitModel(angleUnit) self._pyfaiRotation2.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation2Unit.setUnitModel(angleUnit) self._pyfaiRotation2Unit.setUnitEditable(True) self._pyfaiRotation3.setDisplayedUnitModel(angleUnit) self._pyfaiRotation3.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation3Unit.setUnitModel(angleUnit) self._pyfaiRotation3Unit.setUnitEditable(True) # Connect fit2d widgets to units self._fit2dDistance.setDisplayedUnitModel(lengthUnit) self._fit2dDistance.setModelUnit(units.Unit.MILLIMETER) self._fit2dDistanceUnit.setUnit(units.Unit.MILLIMETER) # self._fit2dDistanceUnit.setUnitModel(lengthUnit) # self._fit2dDistanceUnit.setUnitEditable(True) self._fit2dCenterX.setDisplayedUnitModel(pixelUnit) self._fit2dCenterX.setModelUnit(units.Unit.PIXEL) self._fit2dCenterXUnit.setUnit(units.Unit.PIXEL) # self._fit2dCenterXUnit.setUnitModel(pixelUnit) # self._fit2dCenterXUnit.setUnitEditable(True) self._fit2dCenterY.setDisplayedUnitModel(pixelUnit) self._fit2dCenterY.setModelUnit(units.Unit.PIXEL) self._fit2dCenterYUnit.setUnit(units.Unit.PIXEL) # self._fit2dCenterYUnit.setUnitModel(pixelUnit) # self._fit2dCenterYUnit.setUnitEditable(True) self._fit2dTilt.setDisplayedUnitModel(angleUnit) self._fit2dTilt.setModelUnit(units.Unit.DEGREE) self._fit2dTiltUnit.setUnit(units.Unit.DEGREE) # self._fit2dTiltUnit.setUnitModel(angleUnit) # self._fit2dTiltUnit.setUnitEditable(True) self._fit2dTiltPlan.setDisplayedUnitModel(angleUnit) self._fit2dTiltPlan.setModelUnit(units.Unit.DEGREE) self._fit2dTiltPlanUnit.setUnit(units.Unit.DEGREE) # self._fit2dTiltPlanUnit.setUnitModel(angleUnit) # self._fit2dTiltPlanUnit.setUnitEditable(True) # Connect fit2d model-widget self.__fit2dDistance = DataModel() self.__fit2dCenterX = DataModel() self.__fit2dCenterY = DataModel() self.__fit2dTilt = DataModel() self.__fit2dTiltPlan = DataModel() self._fit2dDistance.setModel(self.__fit2dDistance) self._fit2dCenterX.setModel(self.__fit2dCenterX) self._fit2dCenterY.setModel(self.__fit2dCenterY) self._fit2dTilt.setModel(self.__fit2dTilt) self._fit2dTiltPlan.setModel(self.__fit2dTiltPlan)
def __init__(self, parent=None): super(GeometryDialog, self).__init__(parent) filename = get_ui_file("geometry-dialog.ui") qt.loadUi(filename, self) self.__geometry = GeometryModel() self.__fit2dGeometry = Fit2dGeometryModel() self.__detector = None self.__originalGeometry = None self.__updatingModel = False # Connect buttons self._buttonBox.rejected.connect(self.reject) self._buttonBox.accepted.connect(self.accept) # Create shared units angleUnit = DataModel() angleUnit.setValue(units.Unit.RADIAN) lengthUnit = DataModel() lengthUnit.setValue(units.Unit.METER) pixelUnit = DataModel() pixelUnit.setValue(units.Unit.PIXEL) # Connect pyFAI widgets to units self._pyfaiDistance.setDisplayedUnitModel(lengthUnit) self._pyfaiDistance.setModelUnit(units.Unit.METER) self._pyfaiDistanceUnit.setUnitModel(lengthUnit) self._pyfaiDistanceUnit.setUnitEditable(True) self._pyfaiPoni1.setDisplayedUnitModel(lengthUnit) self._pyfaiPoni1.setModelUnit(units.Unit.METER) self._pyfaiPoni1Unit.setUnitModel(lengthUnit) self._pyfaiPoni1Unit.setUnitEditable(True) self._pyfaiPoni2.setDisplayedUnitModel(lengthUnit) self._pyfaiPoni2.setModelUnit(units.Unit.METER) self._pyfaiPoni2Unit.setUnitModel(lengthUnit) self._pyfaiPoni2Unit.setUnitEditable(True) self._pyfaiRotation1.setDisplayedUnitModel(angleUnit) self._pyfaiRotation1.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation1Unit.setUnitModel(angleUnit) self._pyfaiRotation1Unit.setUnitEditable(True) self._pyfaiRotation2.setDisplayedUnitModel(angleUnit) self._pyfaiRotation2.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation2Unit.setUnitModel(angleUnit) self._pyfaiRotation2Unit.setUnitEditable(True) self._pyfaiRotation3.setDisplayedUnitModel(angleUnit) self._pyfaiRotation3.setModelUnit(units.Unit.RADIAN) self._pyfaiRotation3Unit.setUnitModel(angleUnit) self._pyfaiRotation3Unit.setUnitEditable(True) # Connect fit2d widgets to units self._fit2dDistance.setDisplayedUnit(units.Unit.MILLIMETER) self._fit2dDistance.setModelUnit(units.Unit.MILLIMETER) self._fit2dDistanceUnit.setUnit(units.Unit.MILLIMETER) self._fit2dCenterX.setDisplayedUnitModel(pixelUnit) self._fit2dCenterX.setModelUnit(units.Unit.PIXEL) self._fit2dCenterXUnit.setUnit(units.Unit.PIXEL) self._fit2dCenterY.setDisplayedUnitModel(pixelUnit) self._fit2dCenterY.setModelUnit(units.Unit.PIXEL) self._fit2dCenterYUnit.setUnit(units.Unit.PIXEL) self._fit2dTilt.setDisplayedUnit(units.Unit.DEGREE) self._fit2dTilt.setModelUnit(units.Unit.DEGREE) self._fit2dTiltUnit.setUnit(units.Unit.DEGREE) self._fit2dTiltPlan.setDisplayedUnit(units.Unit.DEGREE) self._fit2dTiltPlan.setModelUnit(units.Unit.DEGREE) self._fit2dTiltPlanUnit.setUnit(units.Unit.DEGREE) # Connect fit2d model-widget self._fit2dDistance.setModel(self.__fit2dGeometry.distance()) self._fit2dCenterX.setModel(self.__fit2dGeometry.centerX()) self._fit2dCenterY.setModel(self.__fit2dGeometry.centerY()) self._fit2dTilt.setModel(self.__fit2dGeometry.tilt()) self._fit2dTiltPlan.setModel(self.__fit2dGeometry.tiltPlan()) self._pyfaiDistance.setModel(self.__geometry.distance()) self._pyfaiPoni1.setModel(self.__geometry.poni1()) self._pyfaiPoni2.setModel(self.__geometry.poni2()) self._pyfaiRotation1.setModel(self.__geometry.rotation1()) self._pyfaiRotation2.setModel(self.__geometry.rotation2()) self._pyfaiRotation3.setModel(self.__geometry.rotation3()) self.__geometry.changed.connect(self.__updateFit2dFromPyfai) self.__fit2dGeometry.changed.connect(self.__updatePyfaiFromFit2d) self.__geometry.changed.connect(self.__updateButtons) # NOTE: All the buttons have to be create here. # Changing available buttons on the focus event create a segfault types = (qt.QDialogButtonBox.Ok | qt.QDialogButtonBox.Cancel | qt.QDialogButtonBox.Reset | qt.QDialogButtonBox.Close) self._buttonBox.setStandardButtons(types) resetButton = self._buttonBox.button(qt.QDialogButtonBox.Reset) resetButton.clicked.connect(self.__resetToOriginalGeometry) self.__updateButtons()
__license__ = "GPLv3+" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" __date__ = "21/03/2013" __satus__ = "development" import sys, logging, json, os, time, types, threading import os.path as op import numpy logging.basicConfig(level=logging.INFO) logger = logging.getLogger("pyFAI.integrate_widget") from PyQt4 import QtCore, QtGui, uic from PyQt4.QtCore import SIGNAL import pyFAI, fabio from pyFAI.opencl import ocl from pyFAI.utils import float_, int_, str_, get_ui_file UIC = get_ui_file("integration.ui") FROM_PYMCA = "From PyMca" class AIWidget(QtGui.QWidget): """ """ def __init__(self, input_data=None): self.ai = pyFAI.AzimuthalIntegrator() self.input_data = input_data self.output_path = None self.output_format = None self.slow_dim = None self.fast_dim = None self.name = None
__license__ = "GPLv3+" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" __date__ = "21/03/2013" __satus__ = "development" import sys, logging, json, os, time, types, threading import os.path as op import numpy logging.basicConfig(level=logging.INFO) logger = logging.getLogger("pyFAI.integrate_widget") from PyQt4 import QtCore, QtGui, uic from PyQt4.QtCore import SIGNAL import pyFAI, fabio from pyFAI.opencl import ocl from pyFAI.utils import float_, int_, str_, get_ui_file UIC = get_ui_file("integration.ui") FROM_PYMCA = "From PyMca" class AIWidget(QtGui.QWidget): """ """ def __init__(self, input_data=None): self.ai = pyFAI.AzimuthalIntegrator() self.input_data = input_data self.output_path = None self.output_format = None self.slow_dim = None self.fast_dim = None self.name = None self._sem = threading.Semaphore()