Exemplo n.º 1
0
class _CalibrationWidget(_ConditionWidget):

    def _init_ui(self):
        # Widgets
        self._txt_quantity = TextAttributeLineEdit(self.CLASS.quantity)
        self._txt_unit = UnitAttributeLineEdit(self.CLASS.unit)

        # Layouts
        layout = _ConditionWidget._init_ui(self)
        layout.addRow('<i>Quantity</i>', self._txt_quantity)
        layout.addRow('<i>Unit</i>', self._txt_unit)

        # Signals
        self._txt_quantity.textEdited.connect(self.edited)
        self._txt_unit.textEdited.connect(self.edited)

        return layout

    def parameter(self, parameter=None):
        parameter = _ConditionWidget.parameter(self, parameter)
        parameter.quantity = self._txt_quantity.text()
        parameter.unit = self._txt_unit.text()
        return parameter

    def setParameter(self, calibration):
        self._txt_quantity.setText(calibration.quantity)
        self._txt_unit.setText(calibration.unit)

    def setReadOnly(self, state):
        _ConditionWidget.setReadOnly(self, state)
        self._txt_quantity.setReadOnly(state)
        self._txt_unit.setReadOnly(state)

    def isReadOnly(self):
        return _ConditionWidget.isReadOnly(self) and \
            self._txt_quantity.isReadOnly() and \
            self._txt_unit.isReadOnly()

    def hasAcceptableInput(self):
        return _ConditionWidget.hasAcceptableInput(self) and \
            self._txt_quantity.hasAcceptableInput() and \
            self._txt_unit.hasAcceptableInput()

    def calibration(self):
        return self.parameter()

    def setCalibration(self, calibration):
        self.setParameter(calibration)
Exemplo n.º 2
0
class _DetectorWidget(_ConditionWidget):

    def _init_ui(self):
        # Widgets
        self._cb_signal_type = QComboBox()
        self._cb_signal_type.addItems([None] + list(_SIGNAL_TYPES))
        self._txt_manufacturer = TextAttributeLineEdit(self.CLASS.manufacturer)
        self._txt_model = TextAttributeLineEdit(self.CLASS.model)
        self._txt_serial_number = TextAttributeLineEdit(self.CLASS.serial_number)
        self._txt_measurement_unit = UnitAttributeLineEdit(self.CLASS.measurement_unit)
        self._txt_elevation = NumericalAttributeLineEdit(self.CLASS.elevation)
        self._txt_azimuth = NumericalAttributeLineEdit(self.CLASS.azimuth)
        self._txt_distance = NumericalAttributeLineEdit(self.CLASS.distance)
        self._txt_area = NumericalAttributeLineEdit(self.CLASS.area)
        self._txt_solid_angle = NumericalAttributeLineEdit(self.CLASS.solid_angle)
        self._txt_semi_angle = NumericalAttributeLineEdit(self.CLASS.semi_angle)
        self._txt_temperature = NumericalAttributeLineEdit(self.CLASS.temperature)

        # Layout
        layout = _ConditionWidget._init_ui(self)
        layout.addRow('Type of signal', self._cb_signal_type)
        layout.addRow('Manufacturer', self._txt_manufacturer)
        layout.addRow('Model', self._txt_model)
        layout.addRow('Serial number', self._txt_serial_number)
        layout.addRow('Measurement unit', self._txt_measurement_unit)
        layout.addRow('Elevation', self._txt_elevation)
        layout.addRow('Azimuth', self._txt_azimuth)
        layout.addRow('Distance', self._txt_distance)
        layout.addRow('Area', self._txt_area)
        layout.addRow('Solid angle', self._txt_solid_angle)
        layout.addRow('Semi angle', self._txt_semi_angle)
        layout.addRow('Temperature', self._txt_temperature)

        # Signals
        self._cb_signal_type.currentIndexChanged.connect(self.edited)
        self._txt_manufacturer.textEdited.connect(self.edited)
        self._txt_model.textEdited.connect(self.edited)
        self._txt_serial_number.textEdited.connect(self.edited)
        self._txt_measurement_unit.textEdited.connect(self.edited)
        self._txt_elevation.textEdited.connect(self.edited)
        self._txt_azimuth.textEdited.connect(self.edited)
        self._txt_distance.textEdited.connect(self.edited)
        self._txt_area.textEdited.connect(self.edited)
        self._txt_solid_angle.textEdited.connect(self.edited)
        self._txt_semi_angle.textEdited.connect(self.edited)
        self._txt_temperature.textEdited.connect(self.edited)

        return layout

    def parameter(self, parameter=None):
        parameter = _ConditionWidget.parameter(self, parameter)
        parameter.signal_type = self._cb_signal_type.currentText()
        parameter.manufacturer = self._txt_manufacturer.text()
        parameter.model = self._txt_model.text()
        parameter.serial_number = self._txt_serial_number.text()
        parameter.measurement_unit = self._txt_measurement_unit.text()
        parameter.elevation = self._txt_elevation.text()
        parameter.azimuth = self._txt_azimuth.text()
        parameter.distance = self._txt_distance.text()
        parameter.area = self._txt_area.text()
        parameter.solid_angle = self._txt_solid_angle.text()
        parameter.semi_angle = self._txt_semi_angle.text()
        parameter.temperature = self._txt_temperature.text()
        return parameter

    def setParameter(self, condition):
        _ConditionWidget.setParameter(self, condition)
        self._cb_signal_type.setCurrentIndex(self._cb_signal_type.findText(condition.signal_type))
        self._txt_manufacturer.setText(condition.manufacturer)
        self._txt_model.setText(condition.model)
        self._txt_serial_number.setText(condition.serial_number)
        self._txt_measurement_unit.setText(condition.measurement_unit)
        self._txt_elevation.setText(condition.elevation)
        self._txt_azimuth.setText(condition.azimuth)
        self._txt_distance.setText(condition.distance)
        self._txt_area.setText(condition.area)
        self._txt_solid_angle.setText(condition.solid_angle)
        self._txt_semi_angle.setText(condition.semi_angle)
        self._txt_temperature.setText(condition.temperature)

    def setReadOnly(self, state):
        _ConditionWidget.setReadOnly(self, state)
        self._cb_signal_type.setEnabled(not state)
        self._txt_manufacturer.setReadOnly(state)
        self._txt_model.setReadOnly(state)
        self._txt_serial_number.setReadOnly(state)
        self._txt_measurement_unit.setReadOnly(state)
        self._txt_elevation.setReadOnly(state)
        self._txt_azimuth.setReadOnly(state)
        self._txt_distance.setReadOnly(state)
        self._txt_area.setReadOnly(state)
        self._txt_solid_angle.setReadOnly(state)
        self._txt_semi_angle.setReadOnly(state)
        self._txt_temperature.setReadOnly(state)

    def isReadOnly(self):
        return _ConditionWidget.isReadOnly(self) and \
            not self._cb_signal_type.isEnabled() and \
            self._txt_manufacturer.isReadOnly() and \
            self._txt_model.isReadOnly() and \
            self._txt_serial_number.isReadOnly() and \
            self._txt_measurement_unit.isReadOnly() and \
            self._txt_elevation.isReadOnly() and \
            self._txt_azimuth.isReadOnly() and \
            self._txt_distance.isReadOnly() and \
            self._txt_area.isReadOnly() and \
            self._txt_solid_angle.isReadOnly() and \
            self._txt_semi_angle.isReadOnly() and \
            self._txt_temperature.isReadOnly()

    def hasAcceptableInput(self):
        return _ConditionWidget.hasAcceptableInput(self) and \
            self._txt_manufacturer.hasAcceptableInput() and \
            self._txt_model.hasAcceptableInput() and \
            self._txt_serial_number.hasAcceptableInput() and \
            self._txt_measurement_unit.hasAcceptableInput() and \
            self._txt_elevation.hasAcceptableInput() and \
            self._txt_azimuth.hasAcceptableInput() and \
            self._txt_distance.hasAcceptableInput() and \
            self._txt_area.hasAcceptableInput() and \
            self._txt_solid_angle.hasAcceptableInput() and \
            self._txt_semi_angle.hasAcceptableInput() and \
            self._txt_temperature.hasAcceptableInput()