def __init__(self, value): super().__init__() self._val = value self._rootLayout = QHBoxLayout() self._xLabel = QLabel("<b>X:</b>") self._rootLayout.addWidget(self._xLabel) self._xSpinBox = EditFloatSpinBox() self._xSpinBox.valueChanged.connect(self._signal_xSpinBox_valueChanged) self._rootLayout.addWidget(self._xSpinBox) self._yLabel = QLabel("<b>Y:</b>") self._rootLayout.addWidget(self._yLabel) self._ySpinBox = EditFloatSpinBox() self._ySpinBox.valueChanged.connect(self._signal_ySpinBox_valueChanged) self._rootLayout.addWidget(self._ySpinBox) self._rootLayout.setContentsMargins(1, 1, 1, 1) self.setLayout(self._rootLayout) self._pull()
class EditFloatValue(QWidget): def __init__(self, value): super().__init__() self._val = value self._rootLayout = QHBoxLayout() self._floatSpinBox = EditFloatSpinBox() self._floatSpinBox.valueChanged.connect( self._signal_floatSpinBox_valueChanged) self._rootLayout.addWidget(self._floatSpinBox) self._rootLayout.setContentsMargins(1, 1, 1, 1) self.setLayout(self._rootLayout) self._pull() def _signal_floatSpinBox_valueChanged(self, newValue): self._push(newValue) SendMessage(MsgOnLogicDataEdited(self._val)) def _push(self, data): self._val.setVal(data) def _pull(self): data = self._val.getVal() self._floatSpinBox.setValue(data)
def __init__(self, value): super().__init__() self._val = value self._rootLayout = QHBoxLayout() self._floatSpinBox = EditFloatSpinBox() self._floatSpinBox.valueChanged.connect( self._signal_floatSpinBox_valueChanged) self._rootLayout.addWidget(self._floatSpinBox) self._rootLayout.setContentsMargins(1, 1, 1, 1) self.setLayout(self._rootLayout) self._pull()
class EditVec2Value(QWidget): def __init__(self, value): super().__init__() self._val = value self._rootLayout = QHBoxLayout() self._xLabel = QLabel("<b>X:</b>") self._rootLayout.addWidget(self._xLabel) self._xSpinBox = EditFloatSpinBox() self._xSpinBox.valueChanged.connect(self._signal_xSpinBox_valueChanged) self._rootLayout.addWidget(self._xSpinBox) self._yLabel = QLabel("<b>Y:</b>") self._rootLayout.addWidget(self._yLabel) self._ySpinBox = EditFloatSpinBox() self._ySpinBox.valueChanged.connect(self._signal_ySpinBox_valueChanged) self._rootLayout.addWidget(self._ySpinBox) self._rootLayout.setContentsMargins(1, 1, 1, 1) self.setLayout(self._rootLayout) self._pull() def _signal_xSpinBox_valueChanged(self, newXVal): x, y = self._val.getVal() self._push(newXVal, y) SendMessage(MsgOnLogicDataEdited(self._val)) def _signal_ySpinBox_valueChanged(self, newYVal): x, y = self._val.getVal() self._push(x, newYVal) SendMessage(MsgOnLogicDataEdited(self._val)) def _pull(self): x, y = self._val.getVal() self._xSpinBox.setValue(x) self._ySpinBox.setValue(y) def _push(self, x, y): self._val.setVal(x, y)
class EditQuatValue(QWidget): def __init__(self, value): super().__init__() self._val = value self._rootLayout = QHBoxLayout() self._xLabel = QLabel("<b>X:</b>") self._rootLayout.addWidget(self._xLabel) self._xSpinBox = EditFloatSpinBox() self._xSpinBox.setSingleStep(1) self._xSpinBox.setMinimum(-180) self._xSpinBox.setMaximum(180) self._xSpinBox.valueChanged.connect(self._signal_xSpinBox_valueChanged) self._rootLayout.addWidget(self._xSpinBox) self._yLabel = QLabel("<b>Y:</b>") self._rootLayout.addWidget(self._yLabel) self._ySpinBox = EditFloatSpinBox() self._ySpinBox.setSingleStep(1) self._ySpinBox.setMinimum(-180) self._ySpinBox.setMaximum(180) self._ySpinBox.valueChanged.connect(self._signal_ySpinBox_valueChanged) self._rootLayout.addWidget(self._ySpinBox) self._zLabel = QLabel("<b>Z:</b>") self._rootLayout.addWidget(self._zLabel) self._zSpinBox = EditFloatSpinBox() self._zSpinBox.setSingleStep(1) self._zSpinBox.setMinimum(-180) self._zSpinBox.setMaximum(180) self._zSpinBox.valueChanged.connect(self._signal_zSpinBox_valueChanged) self._rootLayout.addWidget(self._zSpinBox) self._rootLayout.setContentsMargins(1, 1, 1, 1) self.setLayout(self._rootLayout) self._pull() def _signal_xSpinBox_valueChanged(self, newXVal): yAngle = self._ySpinBox.value() zAngle = self._zSpinBox.value() self._push(newXVal, yAngle, zAngle) SendMessage(MsgOnLogicDataEdited(self._val)) def _signal_ySpinBox_valueChanged(self, newYVal): xAngle = self._xSpinBox.value() zAngle = self._zSpinBox.value() self._push(xAngle, newYVal, zAngle) SendMessage(MsgOnLogicDataEdited(self._val)) def _signal_zSpinBox_valueChanged(self, newZVal): xAngle = self._xSpinBox.value() yAngle = self._ySpinBox.value() self._push(xAngle, yAngle, newZVal) SendMessage(MsgOnLogicDataEdited(self._val)) def _pull(self): x, y, z, w = self._val.getVal() yaw, pitch, roll = _convertToEualerAngles(x, y, z, w) yaw = math.degrees(yaw) pitch = math.degrees(pitch) roll = math.degrees(roll) currXAngle = self._xSpinBox.value() currYAngle = self._ySpinBox.value() currZAngle = self._zSpinBox.value() hasDiff = False if abs(currXAngle - pitch) > 0.001: hasDiff = True if abs(currYAngle - roll) > 0.001: hasDiff = True if abs(currZAngle - yaw) > 0.001: hasDiff = True if not hasDiff: return self._xSpinBox.setValue(pitch) self._ySpinBox.setValue(roll) self._zSpinBox.setValue(yaw) def _push(self, xAngle, yAngle, zAngle): xAngle = math.radians(xAngle) yAngle = math.radians(yAngle) zAngle = math.radians(zAngle) x, y, z, w = _convertFromEualerAngles(zAngle, xAngle, yAngle) self._val.setVal(x, y, z, w)