def __init__(self): super(MaskTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-mask.ui"), self) self.initNextStep() self.__plot = self.__createPlot() self.__maskPanel = silx.gui.plot.MaskToolsWidget.MaskToolsWidget( parent=self._toolHolder, plot=self.__plot) self.__maskPanel.setDirection(qt.QBoxLayout.TopToBottom) self.__maskPanel.setMultipleMasks("single") layout = qt.QVBoxLayout(self._toolHolder) layout.addWidget(self.__maskPanel) layout.setContentsMargins(0, 0, 0, 0) self._toolHolder.setLayout(layout) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) # FIXME ask for a stable API self.__maskPanel._mask.sigChanged.connect(self.__maskFromPlotChanged) self.widgetShow.connect(self.__widgetShow) self.widgetHide.connect(self.__widgetHide) self.__plotMaskChanged = False self.__modelMaskChanged = False
def __init__(self, parent=None): super(IntegrationMethodWidget, self).__init__(parent) qt.loadUi(pyFAI.utils.get_ui_file("integration-method.ui"), self) self._implementationModel = self._createImplementationModel() self._implView.setModel(self._implementationModel) selection = self._implView.selectionModel() selection.selectionChanged.connect(self.__implementationChanged) self._implView.setSelectionMode(qt.QAbstractItemView.SingleSelection) self._algoModel = self._createAlgorithmModel() self._algoView.setModel(self._algoModel) selection = self._algoView.selectionModel() selection.selectionChanged.connect(self.__algorithmChanged) self._algoView.setSelectionMode(qt.QAbstractItemView.SingleSelection) self._splittingModel = self._createSplittingModel() self._splitView.setModel(self._splittingModel) selection = self._splitView.selectionModel() selection.selectionChanged.connect(self.__splittingChanged) self._splitView.setSelectionMode(qt.QAbstractItemView.SingleSelection) self._implView.entered.connect(self.__mouseEntered) self._implView.setMouseTracking(True) self._algoView.entered.connect(self.__mouseEntered) self._algoView.setMouseTracking(True) self._splitView.entered.connect(self.__mouseEntered) self._splitView.setMouseTracking(True) self.setTupleMethod(("*", "*", "*")) self.__updateFeedback() self.sigMethodChanged.connect(self.__updateFeedback)
def __init__(self): super(PeakPickingTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-peakpicking.ui"), self) self.initNextStep() self.__dialogState = None layout = qt.QVBoxLayout(self._imageHolder) self.__plot = _PeakPickingPlot(parent=self._imageHolder) toolBar = self.__createPlotToolBar(self.__plot) self.__plot.addToolBar(toolBar) statusBar = self.__createPlotStatusBar(self.__plot) self.__plot.setStatusBar(statusBar) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._ringSelectionMode.setIcon(icons.getQIcon("pyfai:gui/icons/search-ring")) self._peakSelectionMode.setIcon(icons.getQIcon("pyfai:gui/icons/search-peak")) self.__peakSelectionView = None self.__plot.sigPlotSignal.connect(self.__onPlotEvent) self.__undoStack = qt.QUndoStack(self) self._undoButton.setDefaultAction(self.__undoStack.createUndoAction(self, "Undo")) self._redoButton.setDefaultAction(self.__undoStack.createRedoAction(self, "Redo")) self.__mode = qt.QButtonGroup() self.__mode.setExclusive(True) self.__mode.addButton(self._peakSelectionMode) self.__mode.addButton(self._ringSelectionMode) self._ringSelectionMode.setChecked(True) self._extract.clicked.connect(self.__autoExtractRings)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-result.ui"), self) icon = silx.gui.icons.getQIcon("pyfai:gui/icons/task-cake") self.setWindowIcon(icon) self.initNextStep() self._methodLabel.setLabelTemplate("{split}") self._warning.setVisible(False) self.__integrationUpToDate = True self.__integrationResetZoomPolicy = None method = method_registry.Method(666, "bbox", "csr", "cython", None) self.__setMethod(method) positiveValidator = validators.IntegerAndEmptyValidator(self) positiveValidator.setBottom(1) self._radialPoints.setValidator(positiveValidator) self._azimuthalPoints.setValidator(positiveValidator) self._radialUnit.setUnits(pyFAI.units.RADIAL_UNITS.values()) self.__polarizationModel = None self._polarizationFactorCheck.clicked[bool].connect( self.__polarizationFactorChecked) self.widgetShow.connect(self.__widgetShow) self._displayMask.clicked[bool].connect(self.__displayMaskChecked) self._integrateButton.beforeExecuting.connect(self.__integrate) self._integrateButton.setDisabledWhenWaiting(True) self._integrateButton.finished.connect(self.__integratingFinished) self._customMethodButton.clicked.connect( self.__customIntegrationMethod) self._savePoniButton.clicked.connect(self.__saveAsPoni)
def __init__(self): super(IntegrationTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-result.ui"), self) self.initNextStep() self.__integrationUpToDate = True self.__integrationResetZoomPolicy = None positiveValidator = validators.IntegerAndEmptyValidator(self) positiveValidator.setBottom(1) self._radialPoints.setValidator(positiveValidator) self._azimuthalPoints.setValidator(positiveValidator) self._radialUnit.setUnits(pyFAI.units.RADIAL_UNITS.values()) self.__polarizationModel = None self._polarizationFactorCheck.clicked[bool].connect( self.__polarizationFactorChecked) self.widgetShow.connect(self.__widgetShow) self._integrateButton.beforeExecuting.connect(self.__integrate) self._integrateButton.setDisabledWhenWaiting(True) self._integrateButton.finished.connect(self.__integratingFinished) self._savePoniButton.clicked.connect(self.__saveAsPoni) self._saveJsonButton.clicked.connect(self.__saveAsJson)
def __init__(self, input_data=None, output_path=None, json_file=".azimint.json", context=None): qt.QWidget.__init__(self) filename = get_ui_file("integration-dialog.ui") qt.loadUi(filename, self) pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) self.__context = context if context is not None: context.restoreWindowLocationSettings("main-window", self) self.__workerConfigurator = WorkerConfigurator(self._holder) self.__content = qt.QWidget(self) layout = qt.QVBoxLayout(self.__content) layout.addWidget(self.__workerConfigurator) self._holder.setWidget(self.__content) self._holder.minimumSizeHint = self.__minimumScrollbarSizeHint size = self.__content.minimumSizeHint() self._holder.setMaximumHeight(size.height() + 2) size = self.minimumSizeHint() - self._holder.minimumSizeHint() + size self.setMaximumHeight(size.height() + 2) self.input_data = input_data self.output_path = output_path self.json_file = json_file self.batch_processing.clicked.connect(self.__fireBatchProcess) self.save_json_button.clicked.connect(self.save_config) self.quit_button.clicked.connect(self.die) if self.json_file is not None: self.restore(self.json_file)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-result.ui"), self) icon = silx.gui.icons.getQIcon("pyfai:gui/icons/task-cake") self.setWindowIcon(icon) self.initNextStep() self._methodLabel.setLabelTemplate("{split}") self.__integrationUpToDate = True self.__integrationResetZoomPolicy = None method = method_registry.Method(666, "bbox", "csr", "cython", None) self.__setMethod(method) positiveValidator = validators.IntegerAndEmptyValidator(self) positiveValidator.setBottom(1) self._radialPoints.setValidator(positiveValidator) self._azimuthalPoints.setValidator(positiveValidator) self._radialUnit.setUnits(pyFAI.units.RADIAL_UNITS.values()) self.__polarizationModel = None self._polarizationFactorCheck.clicked[bool].connect(self.__polarizationFactorChecked) self.widgetShow.connect(self.__widgetShow) self._displayMask.clicked[bool].connect(self.__displayMaskChecked) self._integrateButton.beforeExecuting.connect(self.__integrate) self._integrateButton.setDisabledWhenWaiting(True) self._integrateButton.finished.connect(self.__integratingFinished) self._customMethodButton.clicked.connect(self.__customIntegrationMethod) self._savePoniButton.clicked.connect(self.__saveAsPoni)
def __init__(self, input_data=None, output_path=None, json_file=".azimint.json", context=None): qt.QWidget.__init__(self) filename = get_ui_file("integration-dialog.ui") qt.loadUi(filename, self) pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) self.__context = context if context is not None: context.restoreWindowLocationSettings("main-window", self) self.__workerConfigurator = WorkerConfigurator(self._holder) layout = qt.QVBoxLayout(self._holder) layout.addWidget(self.__workerConfigurator) layout.setContentsMargins(0, 0, 0, 0) self._holder.setLayout(layout) self.input_data = input_data self.output_path = output_path self.json_file = json_file self.batch_processing.clicked.connect(self.__fireBatchProcess) self.save_json_button.clicked.connect(self.save_config) self.quit_button.clicked.connect(self.die) self.progressBar.setVisible(False) self.progressBar.setValue(0) if self.json_file is not None: self.restore(self.json_file)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-experiment.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-settings") self.setWindowIcon(icon) self.initNextStep() self._imageLoader.clicked.connect(self.loadImage) self._maskLoader.clicked.connect(self.loadMask) self._darkLoader.clicked.connect(self.loadDark) self._customDetector.clicked.connect(self.__customDetector) self.__plot = self.__createPlot(parent=self._imageHolder) self.__plot.setObjectName("plot-experiment") self.__plotBackground = SynchronizePlotBackground(self.__plot) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._detectorFileDescription.setElideMode(qt.Qt.ElideMiddle) self._calibrant.setFileLoadable(True) self._calibrant.sigLoadFileRequested.connect(self.loadCalibrant) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __init__(self): super(ExperimentTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-experiment.ui"), self) self.initNextStep() self.__dialogState = None self._imageLoader.clicked.connect(self.loadImage) self._maskLoader.clicked.connect(self.loadMask) self._darkLoader.clicked.connect(self.loadDark) self._splineLoader.clicked.connect(self.loadSpline) self.__plot2D = silx.gui.plot.Plot2D(parent=self._imageHolder) self.__plot2D.setKeepDataAspectRatio(True) self.__plot2D.getMaskAction().setVisible(False) self.__plot2D.getProfileToolbar().setVisible(False) self.__plot2D.setDataMargins(0.1, 0.1, 0.1, 0.1) self.__plot2D.setGraphXLabel("Y") self.__plot2D.setGraphYLabel("X") colormap = { 'name': "inferno", 'normalization': 'log', 'autoscale': True, } self.__plot2D.setDefaultColormap(colormap) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot2D) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-experiment.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-settings") self.setWindowIcon(icon) self.initNextStep() self._detectorLabel.setAcceptDrops(True) self._image.setAcceptDrops(True) self._mask.setAcceptDrops(True) self._imageLoader.setDialogTitle("Load calibration image") self._maskLoader.setDialogTitle("Load mask image") self._darkLoader.setDialogTitle("Load dark image") self._customDetector.clicked.connect(self.__customDetector) self.__plot = self.__createPlot(parent=self._imageHolder) self.__plot.setObjectName("plot-experiment") self.__plotBackground = SynchronizePlotBackground(self.__plot) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._detectorFileDescription.setElideMode(qt.Qt.ElideMiddle) self._calibrant.setFileLoadable(True) self._calibrant.sigLoadFileRequested.connect(self.loadCalibrant) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-geometry.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-fit-geometry") self.setWindowIcon(icon) self.initNextStep() self.widgetShow.connect(self.__widgetShow) self.__plot = self.__createPlot() self.__plot.sigMouseMove.connect(self.__mouseMoved) self.__plot.sigMouseLeave.connect(self.__mouseLeft) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) userAngleUnit = CalibrationContext.instance().getAngleUnit() userLengthUnit = CalibrationContext.instance().getLengthUnit() userWavelengthUnit = CalibrationContext.instance().getWavelengthUnit() layout = qt.QGridLayout(self._settings) self.__wavelength = FitParamView(self, "Wavelength:", units.Unit.METER_WL, userWavelengthUnit) self.addParameterToLayout(layout, self.__wavelength) layout = qt.QGridLayout(self._geometry) self.__distance = FitParamView(self, "Distance:", units.Unit.METER, userLengthUnit) self.__poni1 = FitParamView(self, "PONI1:", units.Unit.METER, userLengthUnit) self.__poni2 = FitParamView(self, "PONI2:", units.Unit.METER, userLengthUnit) self.__rotation1 = FitParamView(self, "Rotation 1:", units.Unit.RADIAN, userAngleUnit) self.__rotation2 = FitParamView(self, "Rotation 2:", units.Unit.RADIAN, userAngleUnit) self.__rotation3 = FitParamView(self, "Rotation 3:", units.Unit.RADIAN, userAngleUnit) self.addParameterToLayout(layout, self.__distance) self.addParameterToLayout(layout, self.__poni1) self.addParameterToLayout(layout, self.__poni2) self.addParameterToLayout(layout, self.__rotation1) self.addParameterToLayout(layout, self.__rotation2) self.addParameterToLayout(layout, self.__rotation3) self._fitButton.clicked.connect(self.__fitGeometryLater) self._fitButton.setDisabledWhenWaiting(True) self._resetButton.clicked.connect(self.__resetGeometryLater) self.__calibration = None self.__peaksInvalidated = False self.__fitting = False self.__wavelengthInvalidated = False self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __init__(self, input_data=None, output_path=None, output_format=None, slow_dim=None, fast_dim=None, json_file=".azimint.json"): self.units = {} self.input_data = input_data self.output_path = output_path self.output_format = output_format self.slow_dim = slow_dim self.fast_dim = fast_dim self.name = None self._sem = threading.Semaphore() self.json_file = json_file qt.QWidget.__init__(self) try: qt.loadUi(UIC, self) except AttributeError as _error: logger.error( "I looks like your installation suffers from this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697348" ) raise RuntimeError( "Please upgrade your installation of PyQt (or apply the patch)" ) self.all_detectors = list(ALL_DETECTORS.keys()) self.all_detectors.sort() self.detector.addItems([i.capitalize() for i in self.all_detectors]) self.detector.setCurrentIndex(self.all_detectors.index("detector")) # connect file selection windows self.file_poni.clicked.connect(self.select_ponifile) self.file_splinefile.clicked.connect(self.select_splinefile) self.file_mask_file.clicked.connect(self.select_maskfile) self.file_dark_current.clicked.connect(self.select_darkcurrent) self.file_flat_field.clicked.connect(self.select_flatfield) # connect button bar self.okButton = self.buttonBox.button(qt.QDialogButtonBox.Ok) self.saveButton = self.buttonBox.button(qt.QDialogButtonBox.Save) self.resetButton = self.buttonBox.button(qt.QDialogButtonBox.Reset) self.cancelButton = self.buttonBox.button(qt.QDialogButtonBox.Cancel) self.okButton.clicked.connect(self.proceed) self.saveButton.clicked.connect(self.save_config) self.buttonBox.helpRequested.connect(self.help) self.cancelButton.clicked.connect(self.die) self.resetButton.clicked.connect(self.restore) self.detector.currentIndexChanged.connect(self.detector_changed) self.do_OpenCL.clicked.connect(self.openCL_changed) self.platform.currentIndexChanged.connect(self.platform_changed) self.set_validators() self.assign_unit() if self.json_file is not None: self.restore(self.json_file) self.progressBar.setValue(0) self.hdf5_path = None
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) filename = get_ui_file("worker-configurator.ui") qt.loadUi(filename, self) self.__openclDevice = None self.__method = None self.__geometryModel = GeometryModel() self.__detector = None self.__only1dIntegration = False self.geometry_label.setGeometryModel(self.__geometryModel) # Connect widget to edit the wavelength wavelengthUnit = DataModel() wavelengthUnit.setValue(units.Unit.ENERGY) self.wavelengthEdit.setModel(self.__geometryModel.wavelength()) self.wavelengthEdit.setDisplayedUnitModel(wavelengthUnit) self.wavelengthEdit.setModelUnit(units.Unit.METER_WL) self.wavelengthUnit.setUnitModel(wavelengthUnit) self.wavelengthUnit.setUnitEditable(True) self.load_detector.clicked.connect(self.selectDetector) self.opencl_config_button.clicked.connect(self.selectOpenclDevice) self.method_config_button.clicked.connect(self.selectMethod) self.show_geometry.clicked.connect(self.showGeometry) # connect file selection windows self.file_import.clicked.connect(self.__selectFile) self.file_mask_file.clicked.connect(self.__selectMaskFile) self.file_dark_current.clicked.connect(self.__selectDarkCurrent) self.file_flat_field.clicked.connect(self.__selectFlatField) self.do_2D.toggled.connect(self.__dimChanged) npt_validator = qt.QIntValidator() npt_validator.setBottom(1) self.nbpt_rad.setValidator(npt_validator) self.nbpt_azim.setValidator(npt_validator) self.radial_unit.setUnits(RADIAL_UNITS.values()) self.radial_unit.model().setValue(RADIAL_UNITS["2th_deg"]) self.radial_unit.setShortNameDisplay(True) self.radial_unit.model().changed.connect(self.__radialUnitUpdated) self.__radialUnitUpdated() doubleOrEmptyValidator = validators.DoubleAndEmptyValidator() self.normalization_factor.setValidator(doubleOrEmptyValidator) self.normalization_factor.setText("1.0") self.__configureDisabledStates() self.setDetector(None) self.__setMethod(None)
def __init__(self): super(PeakPickingTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-peakpicking.ui"), self) self.initNextStep() # Insert the plot on the layout holder = self._plotHolder self.__plot = _PeakPickingPlot(parent=holder) holderLayout = qt.QVBoxLayout(holder) holderLayout.setContentsMargins(1, 1, 1, 1) holderLayout.addWidget(self.__plot) # Insert the peak view on the layout holder = self._peakSelectionDummy.parent() self.__peakSelectionView = _PeakSelectionTableView(holder) holderLayout = holder.layout() holderLayout.replaceWidget(self._peakSelectionDummy, self.__peakSelectionView) self.__createPlotToolBar(self.__plot) statusBar = self.__createPlotStatusBar(self.__plot) self.__plot.setStatusBar(statusBar) self._ringSelectionMode.setIcon( icons.getQIcon("pyfai:gui/icons/search-ring")) self._peakSelectionMode.setIcon( icons.getQIcon("pyfai:gui/icons/search-peak")) self.__plot.sigPlotSignal.connect(self.__onPlotEvent) self.__undoStack = qt.QUndoStack(self) undoAction = CustomProxyAction( self, self.__undoStack.createUndoAction(self, "Undo")) undoAction.forceText("Undo") undoAction.forceIconText("Undo") redoAction = CustomProxyAction( self, self.__undoStack.createRedoAction(self, "Redo")) redoAction.forceText("Redo") redoAction.forceIconText("Redo") self._undoButton.setDefaultAction(undoAction) self._redoButton.setDefaultAction(redoAction) self.__mode = qt.QButtonGroup() self.__mode.setExclusive(True) self.__mode.addButton(self._peakSelectionMode) self.__mode.addButton(self._ringSelectionMode) self._ringSelectionMode.setChecked(True) self._extract.clicked.connect(self.__autoExtractRingsLater) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-mask.ui"), self) icon = silx.gui.icons.getQIcon("pyfai:gui/icons/task-mask") self.setWindowIcon(icon) self.initNextStep() self.__plot = None self.__plot = self.__createPlot(self._imageHolder) self.__plot.setObjectName("plot-mask") self.__plotBackground = SynchronizePlotBackground(self.__plot) markerModel = CalibrationContext.instance().getCalibrationModel( ).markerModel() self.__markerManager = MarkerManager(self.__plot, markerModel, pixelBasedPlot=True) handle = self.__plot.getWidgetHandle() handle.setContextMenuPolicy(qt.Qt.CustomContextMenu) handle.customContextMenuRequested.connect(self.__plotContextMenu) self.__maskPanel = _MaskToolsWidget(parent=self._toolHolder, plot=self.__plot) self.__maskPanel.setDirection(qt.QBoxLayout.TopToBottom) self.__maskPanel.setMultipleMasks("single") layout = self.__maskPanel.layout() layout.setContentsMargins(0, 0, 0, 0) layout = qt.QVBoxLayout(self._toolHolder) layout.addWidget(self.__maskPanel) layout.setContentsMargins(0, 0, 0, 0) self._toolHolder.setLayout(layout) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self.__maskPanel.sigUserMaskChanged.connect(self.__maskFromPlotChanged) self.widgetShow.connect(self.__widgetShow) self.widgetHide.connect(self.__widgetHide) self.__plotMaskChanged = False self.__modelMaskChanged = False self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot) super()._initGui()
def __init__(self): super(CalibrationWindow, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-main.ui"), self) self.__model = CalibrationModel() self.__tasks = self.createTasks() for task in self.__tasks: task.setModel(self.__model) task.nextTaskRequested.connect(self.nextTask) self._list.addItem(task.windowTitle()) self._stack.addWidget(task) if len(self.__tasks) > 0: self._list.setCurrentRow(0)
def __init__(self): qt.QWidget.__init__(self) self.integration_config = {} self.list_dataset = ListDataSet( ) # Contains all datasets to be treated. try: qt.loadUi(get_ui_file(self.uif), self) except AttributeError as _error: logger.error( "It looks like your installation suffers from this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697348" ) raise RuntimeError( "Please upgrade your installation of PyQt (or apply the patch)" ) pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) self.aborted = False self.progressBar.setValue(0) self.list_model = TreeModel(self, self.list_dataset.as_tree()) self.listFiles.setModel(self.list_model) self.listFiles.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self.listFiles.setSelectionMode(qt.QAbstractItemView.ExtendedSelection) self.create_connections() self.set_validator() self.update_number_of_frames() self.update_number_of_points() self.processing_thread = None self.processing_sem = threading.Semaphore() self.update_sem = threading.Semaphore() # disable some widgets: self.multiframe.setVisible(False) self.label_10.setVisible(False) self.frameShape.setVisible(False) # Online visualization self.fig = None self.axplt = None self.aximg = None self.img = None self.plot = None self.radial_data = None self.azimuthal_data = None self.data_h5 = None # one in hdf5 dataset while processing. self.data_np = None # The numpy one is used only at the end. self.last_idx = -1 self.slice = slice(0, -1, 1) # Default slicing self._menu_file()
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-peakpicking.ui"), self) icon = silx.gui.icons.getQIcon("pyfai:gui/icons/task-identify-rings") self.setWindowIcon(icon) self.initNextStep() # Insert the plot on the layout holder = self._plotHolder self.__plot = _PeakPickingPlot(parent=holder) self.__plot.setObjectName("plot-picking") holderLayout = qt.QVBoxLayout(holder) holderLayout.setContentsMargins(1, 1, 1, 1) holderLayout.addWidget(self.__plot) # Insert the peak view on the layout holder = self._peakSelectionDummy.parent() self.__peakSelectionView = _PeakSelectionTableView(holder) holderLayout = holder.layout() holderLayout.replaceWidget(self._peakSelectionDummy, self.__peakSelectionView) self.__undoStack = qt.QUndoStack(self) layout = qt.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self._ringToolBarHolder.setLayout(layout) toolBar = self.__createRingToolBar() layout.addWidget(toolBar) self.__createPlotToolBar(self.__plot) statusBar = self.__createPlotStatusBar(self.__plot) self.__plot.setStatusBar(statusBar) self.__plot.sigPlotSignal.connect(self.__onPlotEvent) self._extract.setEnabled(False) self._extract.clicked.connect(self.__autoExtractRingsLater) validator = validators.DoubleValidator(self) self._numberOfPeakPerDegree.lineEdit().setValidator(validator) locale = qt.QLocale(qt.QLocale.C) self._numberOfPeakPerDegree.setLocale(locale) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot) self.__massif = None self.__massifReconstructed = None
def __init__(self, parent=None): qt.QDialog.__init__(self, parent=parent) filename = get_ui_file("integration-process.ui") qt.loadUi(filename, self) integrate.IntegrationObserver.__init__(self) self.setWindowTitle("Processing...") self.__undisplayedResult = None self._displayResult.toggled.connect(self.__displayResultUpdated) self._plot.setDataMargins(0.05, 0.05, 0.05, 0.05) self.__firstPlot = True self.__lastDisplay = None self._progressBar.setFormat("Preprocessing...") self._cancelButton.clicked.connect(self.__interruptionRequested)
def __init__(self, parent=None): super(ConstraintsPopup, self).__init__(parent=parent) qt.loadUi(pyFAI.utils.get_ui_file("constraint-drop.ui"), self) validator = validators.DoubleAndEmptyValidator(self) self.__useDefaultMin = False self.__useDefaultMax = False self.__min = DataModel(self) self.__max = DataModel(self) self._minEdit.setValidator(validator) self._minEdit.setModel(self.__min) self._maxEdit.setValidator(validator) self._maxEdit.setModel(self.__max) self.__defaultConstraints = None self._resetMin.clicked.connect(self.__resetMin) self._resetMax.clicked.connect(self.__resetMax) self._slider.sigValueChanged.connect(self.__sliderValuesChanged)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-mask.ui"), self) icon = silx.gui.icons.getQIcon("pyfai:gui/icons/task-mask") self.setWindowIcon(icon) self.initNextStep() self.__plot = None self.__plot = self.__createPlot(self._imageHolder) self.__plot.setObjectName("plot-mask") self.__plotBackground = SynchronizePlotBackground(self.__plot) markerModel = CalibrationContext.instance().getCalibrationModel().markerModel() self.__markerManager = MarkerManager(self.__plot, markerModel, pixelBasedPlot=True) handle = self.__plot.getWidgetHandle() handle.setContextMenuPolicy(qt.Qt.CustomContextMenu) handle.customContextMenuRequested.connect(self.__plotContextMenu) self.__maskPanel = _MaskToolsWidget(parent=self._toolHolder, plot=self.__plot) self.__maskPanel.setDirection(qt.QBoxLayout.TopToBottom) self.__maskPanel.setMultipleMasks("single") layout = self.__maskPanel.layout() layout.setContentsMargins(0, 0, 0, 0) layout = qt.QVBoxLayout(self._toolHolder) layout.addWidget(self.__maskPanel) layout.setContentsMargins(0, 0, 0, 0) self._toolHolder.setLayout(layout) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self.__maskPanel.sigUserMaskChanged.connect(self.__maskFromPlotChanged) self.widgetShow.connect(self.__widgetShow) self.widgetHide.connect(self.__widgetHide) self.__plotMaskChanged = False self.__modelMaskChanged = False self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __init__(self): qt.QWidget.__init__(self) self.integration_config = {} self.list_dataset = ListDataSet() # Contains all datasets to be treated. try: qt.loadUi(get_ui_file(self.uif), self) except AttributeError as _error: logger.error("I looks like your installation suffers from this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697348") raise RuntimeError("Please upgrade your installation of PyQt (or apply the patch)") pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) self.aborted = False self.progressBar.setValue(0) self.list_model = TreeModel(self, self.list_dataset.as_tree()) self.listFiles.setModel(self.list_model) self.listFiles.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self.listFiles.setSelectionMode(qt.QAbstractItemView.ExtendedSelection) self.create_connections() self.set_validator() self.update_number_of_frames() self.update_number_of_points() self.processing_thread = None self.processing_sem = threading.Semaphore() self.update_sem = threading.Semaphore() # disable some widgets: self.multiframe.setVisible(False) self.label_10.setVisible(False) self.frameShape.setVisible(False) # Online visualization self.fig = None self.axplt = None self.aximg = None self.img = None self.plot = None self.radial_data = None self.data_h5 = None # one in hdf5 dataset while processing. self.data_np = None # The numpy one is used only at the end. self.last_idx = -1 self.slice = slice(0, -1, 1) # Default slicing self._menu_file()
def __init__(self, context): super(CalibrationWindow, self).__init__() context.setParent(self) qt.loadUi(pyFAI.utils.get_ui_file("calibration-main.ui"), self) self.__context = context model = context.getCalibrationModel() context.restoreWindowLocationSettings("main-window", self) self.__tasks = self.createTasks() for task in self.__tasks: task.nextTaskRequested.connect(self.nextTask) self._list.addItem(task.windowTitle()) self._stack.addWidget(task) if len(self.__tasks) > 0: self._list.setCurrentRow(0) self.setModel(model)
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): super(MaskTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-mask.ui"), self) self.initNextStep() self.__plot = self.__createPlot(self._imageHolder) markerModel = CalibrationContext.instance().getCalibrationModel().markerModel() self.__markerManager = MarkerManager(self.__plot, markerModel, pixelBasedPlot=True) handle = self.__plot.getWidgetHandle() handle.setContextMenuPolicy(qt.Qt.CustomContextMenu) handle.customContextMenuRequested.connect(self.__plotContextMenu) self.__maskPanel = silx.gui.plot.MaskToolsWidget.MaskToolsWidget(parent=self._toolHolder, plot=self.__plot) self.__maskPanel.setDirection(qt.QBoxLayout.TopToBottom) self.__maskPanel.setMultipleMasks("single") layout = self.__maskPanel.layout() layout.setContentsMargins(0, 0, 0, 0) layout = qt.QVBoxLayout(self._toolHolder) layout.addWidget(self.__maskPanel) layout.setContentsMargins(0, 0, 0, 0) self._toolHolder.setLayout(layout) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) # FIXME ask for a stable API self.__maskPanel._mask.sigChanged.connect(self.__maskFromPlotChanged) self.widgetShow.connect(self.__widgetShow) self.widgetHide.connect(self.__widgetHide) self.__plotMaskChanged = False self.__modelMaskChanged = False self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-experiment.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-settings") self.setWindowIcon(icon) self.initNextStep() self._detectorLabel.setAcceptDrops(True) self._image.setAcceptDrops(True) self._mask.setAcceptDrops(True) self._imageLoader.setDialogTitle("Load calibration image") self._maskLoader.setDialogTitle("Load mask image") self._customDetector.clicked.connect(self.__customDetector) self.__plot = self.__createPlot(parent=self._imageHolder) self.__plot.setObjectName("plot-experiment") self.__plotBackground = SynchronizePlotBackground(self.__plot) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._detectorFileDescription.setElideMode(qt.Qt.ElideMiddle) self._calibrant.setFileLoadable(True) self._calibrant.sigLoadFileRequested.connect(self.loadCalibrant) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot) validator = validators.AdvancedDoubleValidator(self) validator.setBottom(0) validator.setIncludedBound(False, True) validator.setAllowEmpty(True) self._energy.setValidator(validator) self._wavelength.setValidator(validator) super()._initGui()
def __init__(self, context): super(CalibrationWindow, self).__init__() context.setParent(self) qt.loadUi(pyFAI.utils.get_ui_file("calibration-main.ui"), self) self.__context = context model = context.getCalibrationModel() pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) context.restoreWindowLocationSettings("main-window", self) self.__listMode = MenuItem.TextMode self.__tasks = self.createTasks() for task in self.__tasks: task.nextTaskRequested.connect(self.nextTask) item = MenuItem(self._list) item.setText(task.windowTitle()) item.setIcon(task.windowIcon()) self._stack.addWidget(task) task.warningUpdated.connect( functools.partial(self.__updateTaskState, task, item)) if len(self.__tasks) > 0: self._list.setCurrentRow(0) # Hide the nextStep button of the last task task.setNextStepVisible(False) self._list.sizeHint = self._listSizeHint self._list.minimumSizeHint = self._listMinimumSizeHint self.setModel(model) url = projecturl.get_documentation_url("") if url.startswith("http"): self._help.setText("Online help...") self._helpText = self._help.text() self._help.clicked.connect(self.__displayHelp)
def __init__(self): super(IntegrationTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-result.ui"), self) self.initNextStep() self.__integrationUpToDate = True self.__ringLegends = [] self.__plot1d = silx.gui.plot.Plot1D(self) self.__plot1d.setGraphXLabel("Radial") self.__plot1d.setGraphYLabel("Intensity") self.__plot1d.setGraphGrid(True) self.__plot2d = silx.gui.plot.Plot2D(self) self.__plot2d.setGraphXLabel("Radial") self.__plot2d.setGraphYLabel("Azimuthal") self.__defaultColorMap = { 'name': "inferno", 'normalization': 'log', 'autoscale': True, } self.__plot2d.setDefaultColormap(self.__defaultColorMap) layout = qt.QVBoxLayout(self._imageHolder) layout.setContentsMargins(1, 1, 1, 1) layout.addWidget(self.__plot2d) layout.addWidget(self.__plot1d) self._radialUnit.setUnits(pyFAI.units.RADIAL_UNITS.values()) self.__polarizationModel = None self._polarizationFactorCheck.clicked[bool].connect( self.__polarizationFactorChecked) self.widgetShow.connect(self.__widgetShow) self._integrateButton.beforeExecuting.connect(self.__integrate) self._integrateButton.setDisabledWhenWaiting(True) self._integrateButton.finished.connect(self.__integratingFinished) self._savePoniButton.clicked.connect(self.__saveAsPoni) self._saveJsonButton.clicked.connect(self.__saveAsJson)
def __init__(self): super(GeometryTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-geometry.ui"), self) self.initNextStep() self.widgetShow.connect(self.__widgetShow) self.__plot = self.__createPlot() layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) layout = qt.QGridLayout(self._settings) self.__wavelength = FitParamView(self, "Wavelength:", u"Å") self.addParameterToLayout(layout, self.__wavelength) layout = qt.QGridLayout(self._geometry) self.__distance = FitParamView(self, "Distance:", "m") self.__poni1 = FitParamView(self, "PONI1:", u"m") self.__poni2 = FitParamView(self, "PONI2:", u"m") self.__rotation1 = FitParamView(self, "Rotation 1:", u"rad") self.__rotation2 = FitParamView(self, "Rotation 2:", u"rad") self.__rotation3 = FitParamView(self, "Rotation 3:", u"rad") self.addParameterToLayout(layout, self.__distance) self.addParameterToLayout(layout, self.__poni1) self.addParameterToLayout(layout, self.__poni2) self.addParameterToLayout(layout, self.__rotation1) self.addParameterToLayout(layout, self.__rotation2) self.addParameterToLayout(layout, self.__rotation3) self._fitButton.clicked.connect(self.__fitGeometry) self._fitButton.setDisabledWhenWaiting(True) self._resetButton.clicked.connect(self.__resetGeometry) self.__calibration = None self.__peaksInvalidated = False self.__fitting = False
def __init__(self): super(ExperimentTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-experiment.ui"), self) self.initNextStep() self._imageLoader.clicked.connect(self.loadImage) self._maskLoader.clicked.connect(self.loadMask) self._darkLoader.clicked.connect(self.loadDark) self._customDetector.clicked.connect(self.__customDetector) self.__plot = self.__createPlot(parent=self._imageHolder) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._detectorFileDescription.setElideMode(qt.Qt.ElideMiddle) self._calibrant.setFileLoadable(True) self._calibrant.sigLoadFileRequested.connect(self.loadCalibrant) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) filename = get_ui_file("worker-configurator.ui") qt.loadUi(filename, self) self.__model = _WorkerModel() self.__openclDevice = None self.__method = None self.__geometryModel = GeometryModel() self.__detector = None self.__only1dIntegration = False self.geometry_label.setGeometryModel(self.__geometryModel) # Connect widget to edit the wavelength wavelengthUnit = DataModel() wavelengthUnit.setValue(units.Unit.ENERGY) self.wavelengthEdit.setModel(self.__geometryModel.wavelength()) self.wavelengthEdit.setDisplayedUnitModel(wavelengthUnit) self.wavelengthEdit.setModelUnit(units.Unit.METER_WL) self.wavelengthUnit.setUnitModel(wavelengthUnit) self.wavelengthUnit.setUnitEditable(True) self.load_detector.clicked.connect(self.selectDetector) self.opencl_config_button.clicked.connect(self.selectOpenclDevice) self.method_config_button.clicked.connect(self.selectMethod) self.show_geometry.clicked.connect(self.selectGeometry) # Connect file selection windows self.file_import.clicked.connect(self.__selectFile) # Connect mask/dark/flat self.mask_file.setModel(self.__model.maskFileModel) self.file_mask_file.setDialogTitle("Open a mask image") self.file_mask_file.setModel(self.__model.maskFileModel) self.__model.maskFileModel.changed.connect(self.__maskFileChanged) self.dark_current.setModel(self.__model.darkFileModel) self.file_dark_current.setDialogTitle("Open a dark image") self.file_dark_current.setModel(self.__model.darkFileModel) self.__model.darkFileModel.changed.connect(self.__darkFileChanged) self.flat_field.setModel(self.__model.flatFileModel) self.file_flat_field.setDialogTitle("Open a flatfield image") self.file_flat_field.setModel(self.__model.flatFileModel) self.__model.flatFileModel.changed.connect(self.__flatFileChanged) self.do_2D.toggled.connect(self.__dimChanged) npt_validator = qt.QIntValidator() npt_validator.setBottom(1) self.nbpt_rad.setValidator(npt_validator) self.nbpt_azim.setValidator(npt_validator) self.radial_unit.setUnits(RADIAL_UNITS.values()) self.radial_unit.model().setValue(RADIAL_UNITS["2th_deg"]) self.radial_unit.setShortNameDisplay(True) self.radial_unit.model().changed.connect(self.__radialUnitUpdated) self.__radialUnitUpdated() doubleOrEmptyValidator = validators.DoubleAndEmptyValidator() self.normalization_factor.setValidator(doubleOrEmptyValidator) self.normalization_factor.setText("1.0") self.__configureDisabledStates() self.setDetector(None) self.__setMethod(None)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-geometry.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-fit-geometry") self.setWindowIcon(icon) self.initNextStep() self.widgetShow.connect(self.__widgetShow) self.__plot = self.__createPlot() self.__plot.setObjectName("plot-fit") self.__plot.sigMouseMove.connect(self.__mouseMoved) self.__plot.sigMouseLeave.connect(self.__mouseLeft) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self.__defaultConstraints = GeometryConstraintsModel() userAngleUnit = CalibrationContext.instance().getAngleUnit() userLengthUnit = CalibrationContext.instance().getLengthUnit() userWavelengthUnit = CalibrationContext.instance().getWavelengthUnit() layout = qt.QGridLayout(self._settings) self.__wavelength = FitParamView(self, "Wavelength", units.Unit.METER_WL, userWavelengthUnit) self.addParameterToLayout(layout, self.__wavelength) layout = qt.QGridLayout(self._geometry) self.__distance = FitParamView(self, "Distance", units.Unit.METER, userLengthUnit) self.__poni1 = FitParamView(self, "PONI1", units.Unit.METER, userLengthUnit) self.__poni2 = FitParamView(self, "PONI2", units.Unit.METER, userLengthUnit) self.__rotation1 = FitParamView(self, "Rotation 1", units.Unit.RADIAN, userAngleUnit) self.__rotation2 = FitParamView(self, "Rotation 2", units.Unit.RADIAN, userAngleUnit) self.__rotation3 = FitParamView(self, "Rotation 3", units.Unit.RADIAN, userAngleUnit) self.__distance.setDefaultConstraintsModel(self.__defaultConstraints.distance()) self.__wavelength.setDefaultConstraintsModel(self.__defaultConstraints.wavelength()) self.__poni1.setDefaultConstraintsModel(self.__defaultConstraints.poni1()) self.__poni2.setDefaultConstraintsModel(self.__defaultConstraints.poni2()) self.__rotation1.setDefaultConstraintsModel(self.__defaultConstraints.rotation1()) self.__rotation2.setDefaultConstraintsModel(self.__defaultConstraints.rotation2()) self.__rotation3.setDefaultConstraintsModel(self.__defaultConstraints.rotation3()) self.addParameterToLayout(layout, self.__distance) self.addParameterToLayout(layout, self.__poni1) self.addParameterToLayout(layout, self.__poni2) self.addParameterToLayout(layout, self.__rotation1) self.addParameterToLayout(layout, self.__rotation2) self.addParameterToLayout(layout, self.__rotation3) self._fitButton.clicked.connect(self.__fitGeometryLater) self._fitButton.setDisabledWhenWaiting(True) self._resetButton.clicked.connect(self.__resetGeometryLater) self.__calibration = None self.__peaksInvalidated = False self.__fitting = False self.__wavelengthInvalidated = False self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot) constraintLayout = qt.QHBoxLayout() defaultConstraintsButton = qt.QPushButton("Default contraints", self) defaultConstraintsButton.setToolTip("Remove all the custom constraints.") saxsConstraintsButton = qt.QPushButton("SAXS contraints", self) saxsConstraintsButton.setToolTip("Force all the rotations to zero.") constraintLayout.addWidget(defaultConstraintsButton) constraintLayout.addWidget(saxsConstraintsButton) layout.addLayout(constraintLayout, layout.rowCount(), 0, 1, -1) defaultConstraintsButton.clicked.connect(self.__setDefaultConstraints) saxsConstraintsButton.clicked.connect(self.__setSaxsConstraints)
def __init__(self, parent=None): super(TestMainWindow, self).__init__(parent) qt.loadUi(uifile, self)
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 _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-geometry.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-fit-geometry") self.setWindowIcon(icon) self.__calibrationState = CalibrationState(self) self.__calibration = None self.__peaksInvalidated = False self.__fitting = False self.__wavelengthInvalidated = False self.initNextStep() self.widgetShow.connect(self.__widgetShow) self.__plot = self.__createPlot() self.__plot.setObjectName("plot-fit") self.__plot.sigMouseMove.connect(self.__mouseMoved) self.__plot.sigMouseLeave.connect(self.__mouseLeft) self.__plot.setCalibrationState(self.__calibrationState) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self.__defaultConstraints = GeometryConstraintsModel() userAngleUnit = CalibrationContext.instance().getAngleUnit() userLengthUnit = CalibrationContext.instance().getLengthUnit() userWavelengthUnit = CalibrationContext.instance().getWavelengthUnit() layout = qt.QGridLayout(self._settings) self.__wavelength = FitParamView(self, "Wavelength", units.Unit.METER_WL, userWavelengthUnit) self.addParameterToLayout(layout, self.__wavelength) layout = qt.QGridLayout(self._geometry) self.__distance = FitParamView(self, "Distance", units.Unit.METER, userLengthUnit) self.__poni1 = FitParamView(self, "PONI1", units.Unit.METER, userLengthUnit) self.__poni2 = FitParamView(self, "PONI2", units.Unit.METER, userLengthUnit) self.__rotation1 = FitParamView(self, "Rotation 1", units.Unit.RADIAN, userAngleUnit) self.__rotation2 = FitParamView(self, "Rotation 2", units.Unit.RADIAN, userAngleUnit) self.__rotation3 = FitParamView(self, "Rotation 3", units.Unit.RADIAN, userAngleUnit) self.__wavelength.sigValueAccepted.connect(self.__geometryCustomed) self.__distance.sigValueAccepted.connect(self.__geometryCustomed) self.__poni1.sigValueAccepted.connect(self.__geometryCustomed) self.__poni2.sigValueAccepted.connect(self.__geometryCustomed) self.__rotation1.sigValueAccepted.connect(self.__geometryCustomed) self.__rotation2.sigValueAccepted.connect(self.__geometryCustomed) self.__rotation3.sigValueAccepted.connect(self.__geometryCustomed) self.__distance.setDefaultConstraintsModel( self.__defaultConstraints.distance()) self.__wavelength.setDefaultConstraintsModel( self.__defaultConstraints.wavelength()) self.__poni1.setDefaultConstraintsModel( self.__defaultConstraints.poni1()) self.__poni2.setDefaultConstraintsModel( self.__defaultConstraints.poni2()) self.__rotation1.setDefaultConstraintsModel( self.__defaultConstraints.rotation1()) self.__rotation2.setDefaultConstraintsModel( self.__defaultConstraints.rotation2()) self.__rotation3.setDefaultConstraintsModel( self.__defaultConstraints.rotation3()) self.addParameterToLayout(layout, self.__distance) self.addParameterToLayout(layout, self.__poni1) self.addParameterToLayout(layout, self.__poni2) self.addParameterToLayout(layout, self.__rotation1) self.addParameterToLayout(layout, self.__rotation2) self.addParameterToLayout(layout, self.__rotation3) self._fitButton.clicked.connect(self.__fitGeometryLater) self._fitButton.setDisabledWhenWaiting(True) self._resetButton.clicked.connect(self.__resetGeometryLater) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot) constraintLayout = qt.QHBoxLayout() defaultConstraintsButton = qt.QPushButton("Default contraints", self) defaultConstraintsButton.setToolTip( "Remove all the custom constraints.") saxsConstraintsButton = qt.QPushButton("SAXS contraints", self) saxsConstraintsButton.setToolTip("Force all the rotations to zero.") constraintLayout.addWidget(defaultConstraintsButton) constraintLayout.addWidget(saxsConstraintsButton) layout.addLayout(constraintLayout, layout.rowCount(), 0, 1, -1) defaultConstraintsButton.clicked.connect(self.__setDefaultConstraints) saxsConstraintsButton.clicked.connect(self.__setSaxsConstraints) self._geometryHistoryCombo.activated.connect( self.__geometryPickedFromHistory) self._geometryHistoryCombo.setAngleUnit(userAngleUnit) self.__calibrationState.changed.connect(self.__updateResidual) self.__updateResidual()
def __init__(self, parent): super(DetectorSelectorDrop, self).__init__(parent) qt.loadUi(pyFAI.utils.get_ui_file("detector-selection-drop.ui"), self) self.__detector = None self.__dialogState = None model = self.__createManufacturerModel() self._manufacturerList.setModel(model) selection = self._manufacturerList.selectionModel() selection.selectionChanged.connect(self.__manufacturerChanged) model = AllDetectorModel(self) modelFilter = DetectorFilter(self) modelFilter.setSourceModel(model) self._modelList.setModel(modelFilter) selection = self._modelList.selectionModel() selection.selectionChanged.connect(self.__modelChanged) customModel = qt.QStandardItemModel(self) item = qt.QStandardItem("From file") item.setData("FILE", role=self._CustomDetectorRole) customModel.appendRow(item) item = qt.QStandardItem("Manual definition") item.setData("MANUAL", role=self._CustomDetectorRole) customModel.appendRow(item) self._customList.setModel(customModel) self._customList.setFixedHeight(self._customList.sizeHintForRow(0) * 2) selection = self._customList.selectionModel() selection.selectionChanged.connect(self.__customSelectionChanged) self.__splineFile = DataModel() self._splineFile.setModel(self.__splineFile) self._splineLoader.clicked.connect(self.loadSplineFile) self.__splineFile.changed.connect(self.__splineFileChanged) self._splineError.setVisible(False) self.__descriptionFile = DataModel() self.__descriptionFile.changed.connect(self.__descriptionFileChanged) self._fileSelection.setModel(self.__descriptionFile) self._fileLoader.clicked.connect(self.__loadDetectorFormFile) self._fileResult.setVisible(False) self._fileError.setVisible(False) self._splinePanel.setVisible(False) validator = validators.IntegerAndEmptyValidator() validator.setBottom(0) self._detectorWidth.setValidator(validator) self._detectorHeight.setValidator(validator) self.__detectorWidth = DataModel() self.__detectorHeight = DataModel() self.__pixelWidth = DataModel() self.__pixelHeight = DataModel() self._detectorWidth.setModel(self.__detectorWidth) self._detectorHeight.setModel(self.__detectorHeight) self._pixelWidth.setModel(self.__pixelWidth) self._pixelHeight.setModel(self.__pixelHeight) self._customResult.setVisible(False) self._customError.setVisible(False) self.__detectorWidth.changed.connect(self.__customDetectorChanged) self.__detectorHeight.changed.connect(self.__customDetectorChanged) self.__pixelWidth.changed.connect(self.__customDetectorChanged) self.__pixelHeight.changed.connect(self.__customDetectorChanged) self.__customDetector = None
def __init__(self, parent=None): super(DetectorSelectorDrop, self).__init__(parent) qt.loadUi(pyFAI.utils.get_ui_file("detector-selection-drop.ui"), self) self.__detector = None self.__dialogState = None model = self.__createManufacturerModel() self._manufacturerList.setModel(model) selection = self._manufacturerList.selectionModel() selection.selectionChanged.connect(self.__manufacturerChanged) model = AllDetectorModel(self) modelFilter = DetectorFilter(self) modelFilter.setSourceModel(model) self._detectorView.setModel(modelFilter) self._detectorView.setSelectionMode(qt.QAbstractItemView.SingleSelection) self._detectorView.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self._detectorView.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self._detectorView.setWordWrap(False) header = self._detectorView.horizontalHeader() # Manufacturer first self.MANUFACTURER_COLUMN = 1 header.moveSection(self.MANUFACTURER_COLUMN, 0) if qt.qVersion() < "5.0": header.setSectionResizeMode = self.setResizeMode header.setSectionResizeMode(0, qt.QHeaderView.ResizeToContents) header.setSectionResizeMode(1, qt.QHeaderView.ResizeToContents) header.setStretchLastSection(True) selection = self._detectorView.selectionModel() selection.selectionChanged.connect(self.__modelChanged) self._detectorView.doubleClicked.connect(self.__selectAndAccept) customModel = qt.QStandardItemModel(self) item = qt.QStandardItem("From file") item.setData("FILE", role=self._CustomDetectorRole) customModel.appendRow(item) item = qt.QStandardItem("Manual definition") item.setData("MANUAL", role=self._CustomDetectorRole) customModel.appendRow(item) self._customList.setModel(customModel) self._customList.setFixedHeight(self._customList.sizeHintForRow(0) * 2) selection = self._customList.selectionModel() selection.selectionChanged.connect(self.__customSelectionChanged) self.__splineFile = DataModel() self._splineFile.setModel(self.__splineFile) self._splineLoader.clicked.connect(self.loadSplineFile) self.__splineFile.changed.connect(self.__splineFileChanged) self._splineError.setVisible(False) self.__descriptionFile = DataModel() self.__descriptionFile.changed.connect(self.__descriptionFileChanged) self._fileSelection.setModel(self.__descriptionFile) self._fileLoader.clicked.connect(self.__loadDetectorFormFile) self._fileResult.setVisible(False) self._fileError.setVisible(False) self._splinePanel.setVisible(False) validator = validators.IntegerAndEmptyValidator() validator.setBottom(0) self._detectorWidth.setValidator(validator) self._detectorHeight.setValidator(validator) self.__detectorWidth = DataModel() self.__detectorHeight = DataModel() self.__pixelWidth = DataModel() self.__pixelHeight = DataModel() self._detectorWidth.setModel(self.__detectorWidth) self._detectorHeight.setModel(self.__detectorHeight) self._pixelWidth.setModel(self.__pixelWidth) self._pixelHeight.setModel(self.__pixelHeight) self._customResult.setVisible(False) self._customError.setVisible(False) self.__detectorWidth.changed.connect(self.__customDetectorChanged) self.__detectorHeight.changed.connect(self.__customDetectorChanged) self.__pixelWidth.changed.connect(self.__customDetectorChanged) self.__pixelHeight.changed.connect(self.__customDetectorChanged) self.__customDetector = None # By default select all the manufacturers self.__selectAllRegistreredDetector()