1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
# coding: utf-8
# /*##########################################################################
#
# Copyright (C) 2016-2018 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.
#
# ###########################################################################*/
__authors__ = ["V. Valls"]
__license__ = "MIT"
__date__ = "16/10/2020"
from .AbstractModel import AbstractModel
from .ConstraintModel import ConstraintModel
class GeometryConstraintsModel(AbstractModel):
def __init__(self, parent=None):
super(GeometryConstraintsModel, self).__init__(parent)
self.__distance = ConstraintModel(self)
self.__wavelength = ConstraintModel(self)
self.__poni1 = ConstraintModel(self)
self.__poni2 = ConstraintModel(self)
self.__rotation1 = ConstraintModel(self)
self.__rotation2 = ConstraintModel(self)
self.__rotation3 = ConstraintModel(self)
self.__distance.changed.connect(self.wasChanged)
self.__wavelength.changed.connect(self.wasChanged)
self.__poni1.changed.connect(self.wasChanged)
self.__poni2.changed.connect(self.wasChanged)
self.__rotation1.changed.connect(self.wasChanged)
self.__rotation2.changed.connect(self.wasChanged)
self.__rotation3.changed.connect(self.wasChanged)
def isValid(self):
if not self.__distance.isValid():
return False
if not self.__wavelength.isValid():
return False
if not self.__poni1.isValid():
return False
if not self.__poni2.isValid():
return False
if not self.__rotation1.isValid():
return False
if not self.__rotation2.isValid():
return False
if not self.__rotation3.isValid():
return False
return True
def distance(self):
return self.__distance
def wavelength(self):
return self.__wavelength
def poni1(self):
return self.__poni1
def poni2(self):
return self.__poni2
def rotation1(self):
return self.__rotation1
def rotation2(self):
return self.__rotation2
def rotation3(self):
return self.__rotation3
def copy(self, parent=None):
"""
Copy this model to a new model
:param qt.QObject parent: Parent of the copyed model
:rtype: GeometryConstraintsModel
"""
model = GeometryConstraintsModel(parent=parent)
model.distance().set(self.__distance)
model.wavelength().set(self.__wavelength)
model.poni1().set(self.__poni1)
model.poni2().set(self.__poni2)
model.rotation1().set(self.__rotation1)
model.rotation2().set(self.__rotation2)
model.rotation3().set(self.__rotation3)
return model
def set(self, other):
"""Set this geometry constraints with the other informations.
:param GeometryConstraintsModel other:
"""
self.lockSignals()
self.distance().set(other.distance())
self.wavelength().set(other.wavelength())
self.poni1().set(other.poni1())
self.poni2().set(other.poni2())
self.rotation1().set(other.rotation1())
self.rotation2().set(other.rotation2())
self.rotation3().set(other.rotation3())
self.unlockSignals()
def fillDefault(self, other):
"""Fill unset values of this model with the other model
:param GeometryConstraintsModel other:
"""
self.lockSignals()
self.distance().fillDefault(other.distance())
self.wavelength().fillDefault(other.wavelength())
self.poni1().fillDefault(other.poni1())
self.poni2().fillDefault(other.poni2())
self.rotation1().fillDefault(other.rotation1())
self.rotation2().fillDefault(other.rotation2())
self.rotation3().fillDefault(other.rotation3())
self.unlockSignals()
def __str__(self):
template = "GeometryConstraintsModel(d:%s, w:%s, p1:%s, p2:%s, r1:%s, r2:%s, r3:%s)"
data = self.distance(), self.wavelength(), self.poni1(), self.poni2(), self.rotation1(), self.rotation2(), self.rotation3()
return template % data
|