def on_change_beam_size(self):
     """
         Change beam size
     """
     #Change x coordinate
     x_beam_size = self.x_beam_size_tcl.GetValue().lstrip().rstrip()
     if x_beam_size == "" or x_beam_size == str(None):
         x_beam_size = None
     else:
         if check_float(self.x_beam_size_tcl):
             if self._source.beam_size.x != float(x_beam_size) :
                 self._notes += "Change x of beam size from "
                 self._notes += "%s to %s \n" % (self._source.beam_size.x,
                                                  x_beam_size)
                 self._source.beam_size.x = float(x_beam_size)
         else:
             self._notes += "Error: Expected a float for the beam size 's x "
             self._notes += "won't changes x beam size from "
             self._notes += "%s to %s" % (self._source.beam_size.x,
                                         x_beam_size)
     #Change y coordinate
     y_beam_size = self.y_beam_size_tcl.GetValue().lstrip().rstrip()
     if y_beam_size == "" or y_beam_size == str(None):
         y_beam_size = None
         self._source.beam_size.y = y_beam_size
     else:
         if check_float(self.y_beam_size_tcl):
             if self._source.beam_size.y != float(y_beam_size):
                 self._notes += "Change y of beam size from "
                 self._notes += "%s to %s \n" % (self._source.beam_size.y,
                                                  y_beam_size)
                 self._source.beam_size.y = float(y_beam_size)
         else:
             self._notes += "Error: Expected a float for the beam size's y "
             self._notes += "won't changes y beam size from "
             self._notes += "%s to %s" % (self._source.beam_size.y,
                                           y_beam_size)
     #Change z coordinate
     z_beam_size = self.z_beam_size_tcl.GetValue().lstrip().rstrip()
     if z_beam_size == "" or z_beam_size == str(None):
         z_beam_size = None
         self._source.beam_size.z = z_beam_size
     else:
         if check_float(self.z_beam_size_tcl):
             if self._source.beam_size.z != float(z_beam_size):
                 self._notes += "Change z of beam size from "
                 self._notes += "%s to %s \n" % (self._source.beam_size.z,
                                                  z_beam_size)
                 self._source.beam_size.z = float(z_beam_size)
         else:
             self._notes += "Error: Expected a float for the beam size 's z "
             self._notes += "won't changes z beam size from "
             self._notes += "%s to %s" % (self._source.beam_size.z,
                                           z_beam_size)
     #change the beam center unit
     unit = self.beam_size_unit_tcl.GetValue().lstrip().rstrip()
     if self._source.beam_size_unit != unit:
         self._notes += " Change beam size's unit from "
         self._notes += "%s to %s" % (self._source.beam_size_unit, unit)
         self._source.beam_size_unit = unit
Exemple #2
0
 def on_change_beam_size(self):
     """
         Change beam size
     """
     #Change x coordinate
     x_beam_size = self.x_beam_size_tcl.GetValue().lstrip().rstrip()
     if x_beam_size == "" or x_beam_size == str(None):
         x_beam_size = None
     else:
         if check_float(self.x_beam_size_tcl):
             if self._source.beam_size.x != float(x_beam_size):
                 self._notes += "Change x of beam size from "
                 self._notes += "%s to %s \n" % (self._source.beam_size.x,
                                                 x_beam_size)
                 self._source.beam_size.x = float(x_beam_size)
         else:
             self._notes += "Error: Expected a float for the beam size 's x "
             self._notes += "won't changes x beam size from "
             self._notes += "%s to %s" % (self._source.beam_size.x,
                                          x_beam_size)
     #Change y coordinate
     y_beam_size = self.y_beam_size_tcl.GetValue().lstrip().rstrip()
     if y_beam_size == "" or y_beam_size == str(None):
         y_beam_size = None
         self._source.beam_size.y = y_beam_size
     else:
         if check_float(self.y_beam_size_tcl):
             if self._source.beam_size.y != float(y_beam_size):
                 self._notes += "Change y of beam size from "
                 self._notes += "%s to %s \n" % (self._source.beam_size.y,
                                                 y_beam_size)
                 self._source.beam_size.y = float(y_beam_size)
         else:
             self._notes += "Error: Expected a float for the beam size's y "
             self._notes += "won't changes y beam size from "
             self._notes += "%s to %s" % (self._source.beam_size.y,
                                          y_beam_size)
     #Change z coordinate
     z_beam_size = self.z_beam_size_tcl.GetValue().lstrip().rstrip()
     if z_beam_size == "" or z_beam_size == str(None):
         z_beam_size = None
         self._source.beam_size.z = z_beam_size
     else:
         if check_float(self.z_beam_size_tcl):
             if self._source.beam_size.z != float(z_beam_size):
                 self._notes += "Change z of beam size from "
                 self._notes += "%s to %s \n" % (self._source.beam_size.z,
                                                 z_beam_size)
                 self._source.beam_size.z = float(z_beam_size)
         else:
             self._notes += "Error: Expected a float for the beam size 's z "
             self._notes += "won't changes z beam size from "
             self._notes += "%s to %s" % (self._source.beam_size.z,
                                          z_beam_size)
     #change the beam center unit
     unit = self.beam_size_unit_tcl.GetValue().lstrip().rstrip()
     if self._source.beam_size_unit != unit:
         self._notes += " Change beam size's unit from "
         self._notes += "%s to %s" % (self._source.beam_size_unit, unit)
         self._source.beam_size_unit = unit
Exemple #3
0
 def on_change_orientation(self):
     """
         Change orientation
     """
     #Change x coordinate
     x_orientation = self.x_orientation_tcl.GetValue().lstrip().rstrip()
     if x_orientation == "" or x_orientation == str(None):
         x_orientation = None
     else:
         if check_float(self.x_orientation_tcl):
             if self._sample.orientation.x != float(x_orientation) :
                 self._notes += "Change x of orientation from "
                 self._notes += "%s to %s \n" % (self._sample.orientation.x,
                                                x_orientation)
                 self._sample.orientation.x = float(x_orientation)
         else:
             self._notes += "Error: Expected a float for orientation 's x "
             self._notes += "won't changes x orientation from "
             self._notes += "%s to %s" % (self._sample.orientation.x,
                                           x_orientation)
     #Change y coordinate
     y_orientation = self.y_orientation_tcl.GetValue().lstrip().rstrip()
     if y_orientation == "" or y_orientation == str(None):
         y_orientation = None
         self._sample.orientation.y = y_orientation
     else:
         if check_float(self.y_orientation_tcl):
             if self._sample.orientation.y != float(y_orientation):
                 self._notes += "Change y of orientation from "
                 self._notes += "%s to %s \n" % (self._sample.orientation.y,
                                                  y_orientation)
                 self._sample.orientation.y = float(y_orientation)
         else:
             self._notes += "Error: Expected a float for orientation's y "
             self._notes += "won't changes y orientation from "
             self._notes += "%s to %s" % (self._sample.orientation.y,
                                         y_orientation)
     #Change z coordinate
     z_orientation = self.z_orientation_tcl.GetValue().lstrip().rstrip()
     if z_orientation == "" or z_orientation == str(None):
         z_orientation = None
         self._sample.orientation.z = z_orientation
     else:
         if check_float(self.z_orientation_tcl):
             if self._sample.orientation.z != float(z_orientation):
                 self._notes += "Change z of orientation from "
                 self._notes += "%s to %s \n" % (self._sample.orientation.z,
                                                  z_orientation)
                 self._sample.orientation.z = float(z_orientation)
         else:
             self._notes += "Error: Expected a float for orientation 's x "
             self._notes += "won't changes z orientation from "
             self._notes += "%s to %s" % (self._sample.orientation.z,
                                           z_orientation)
     #change the beam center unit
     unit = self.orientation_unit_tcl.GetValue().lstrip().rstrip()
     if self._sample.orientation_unit != unit:
         self._notes += " Change orientation's unit from "
         self._notes += "%s to %s" % (self._sample.orientation_unit, unit)
Exemple #4
0
 def on_change_orientation(self):
     """
         Change orientation
     """
     #Change x coordinate
     x_orientation = self.x_orientation_tcl.GetValue().lstrip().rstrip()
     if x_orientation == "" or x_orientation == str(None):
         x_orientation = None
     else:
         if check_float(self.x_orientation_tcl):
             if self._sample.orientation.x != float(x_orientation):
                 self._notes += "Change x of orientation from "
                 self._notes += "%s to %s \n" % (self._sample.orientation.x,
                                                 x_orientation)
                 self._sample.orientation.x = float(x_orientation)
         else:
             self._notes += "Error: Expected a float for orientation 's x "
             self._notes += "won't changes x orientation from "
             self._notes += "%s to %s" % (self._sample.orientation.x,
                                          x_orientation)
     #Change y coordinate
     y_orientation = self.y_orientation_tcl.GetValue().lstrip().rstrip()
     if y_orientation == "" or y_orientation == str(None):
         y_orientation = None
         self._sample.orientation.y = y_orientation
     else:
         if check_float(self.y_orientation_tcl):
             if self._sample.orientation.y != float(y_orientation):
                 self._notes += "Change y of orientation from "
                 self._notes += "%s to %s \n" % (self._sample.orientation.y,
                                                 y_orientation)
                 self._sample.orientation.y = float(y_orientation)
         else:
             self._notes += "Error: Expected a float for orientation's y "
             self._notes += "won't changes y orientation from "
             self._notes += "%s to %s" % (self._sample.orientation.y,
                                          y_orientation)
     #Change z coordinate
     z_orientation = self.z_orientation_tcl.GetValue().lstrip().rstrip()
     if z_orientation == "" or z_orientation == str(None):
         z_orientation = None
         self._sample.orientation.z = z_orientation
     else:
         if check_float(self.z_orientation_tcl):
             if self._sample.orientation.z != float(z_orientation):
                 self._notes += "Change z of orientation from "
                 self._notes += "%s to %s \n" % (self._sample.orientation.z,
                                                 z_orientation)
                 self._sample.orientation.z = float(z_orientation)
         else:
             self._notes += "Error: Expected a float for orientation 's x "
             self._notes += "won't changes z orientation from "
             self._notes += "%s to %s" % (self._sample.orientation.z,
                                          z_orientation)
     #change the beam center unit
     unit = self.orientation_unit_tcl.GetValue().lstrip().rstrip()
     if self._sample.orientation_unit != unit:
         self._notes += " Change orientation's unit from "
         self._notes += "%s to %s" % (self._sample.orientation_unit, unit)
Exemple #5
0
 def on_change_size(self):
     """
     Change aperture size
     """
     #Change x coordinate
     x_aperture_size = self.x_aperture_size_tcl.GetValue().lstrip().rstrip()
     if x_aperture_size == "" or x_aperture_size == str(None):
         x_aperture_size = None
     else:
         if check_float(self.x_aperture_size_tcl):
             if self._aperture.size.x != float(x_aperture_size):
                 self._notes += "Change x of aperture size from "
                 self._notes += "%s to %s \n" % (self._aperture.size.x, x_aperture_size)
                 self._aperture.aperture_size.x = float(x_aperture_size)
         else:
             self._notes += "Error: Expected a"
             self._notes += " float for the aperture size 's x "
             self._notes += "won't changes x aperture size from "
             self._notes += "%s to %s" % (self._aperture.size.x, x_aperture_size)
     #Change y coordinate
     y_aperture_size = self.y_aperture_size_tcl.GetValue().lstrip().rstrip()
     if y_aperture_size == "" or y_aperture_size == str(None):
         y_aperture_size = None
         self._aperture.size.y = y_aperture_size
     else:
         if check_float(self.y_aperture_size_tcl):
             if self._aperture.size.y != float(y_aperture_size):
                 self._notes += "Change y of aperture size from "
                 self._notes += "%s to %s \n" % (self._aperture.size.y, y_aperture_size)
                 self._aperture.size.y = float(y_aperture_size)
         else:
             self._notes += "Error: Expected a float for the"
             self._notes += " aperture size's y "
             self._notes += "won't changes y aperture size from "
             self._notes += "%s to %s" % (self._aperture.size.y, y_aperture_size)
     #Change z coordinate
     z_aperture_size = self.z_aperture_size_tcl.GetValue().lstrip().rstrip()
     if z_aperture_size == "" or z_aperture_size == str(None):
         z_aperture_size = None
         self._aperture.size.z = z_aperture_size
     else:
         if check_float(self.z_aperture_size_tcl):
             if self._aperture.size.z != float(z_aperture_size):
                 self._notes += "Change z of aperture size from "
                 self._notes += "%s to %s \n" % (self._aperture.size.z, z_aperture_size)
                 self._aperture.size.z = float(z_aperture_size)
         else:
             self._notes += "Error: Expected a float for the offset 's x "
             self._notes += "won't changes z aperture size from "
             self._notes += "%s to %s" % (self._aperture.size.z, z_aperture_size)
     #change the aperture center unit
     unit = self.aperture_size_unit_tcl.GetValue().lstrip().rstrip()
     if self._aperture.size_unit != unit:
         self._notes += " Change aperture size's unit from "
         self._notes += "%s to %s" % (self._aperture.size_unit, unit)
         self._aperture.size_unit = unit
 def _validate_inputs(self):
     """
     Check that the values for qmin and qmax in the input boxes are valid
     """
     if self._data is None:
         return False
     qmin_valid = check_float(self._qmin_input)
     qmax1_valid = check_float(self._qmax1_input)
     qmax2_valid = check_float(self._qmax2_input)
     qmax_valid = qmax1_valid and qmax2_valid
     background_valid = check_float(self._background_input)
     msg = ""
     if (qmin_valid and qmax_valid and background_valid):
         qmin = float(self._qmin_input.GetValue())
         qmax1 = float(self._qmax1_input.GetValue())
         qmax2 = float(self._qmax2_input.GetValue())
         background = float(self._background_input.GetValue())
         if not qmin > self._data.x.min():
             msg = "qmin must be greater than the lowest q value"
             qmin_valid = False
         elif qmax2 < qmax1:
             msg = "qmax1 must be less than qmax2"
             qmax_valid = False
         elif qmin > qmax1:
             msg = "qmin must be less than qmax"
             qmin_valid = False
         elif background > self._data.y.max():
             msg = "background must be less than highest I"
             background_valid = False
     if not qmin_valid:
         self._qmin_input.SetBackgroundColour('pink')
     if not qmax_valid:
         self._qmax1_input.SetBackgroundColour('pink')
         self._qmax2_input.SetBackgroundColour('pink')
     if not background_valid:
         self._background_input.SetBackgroundColour('pink')
         if msg != "":
             wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
     if (qmin_valid and qmax_valid and background_valid):
         self._qmin_input.SetBackgroundColour(wx.WHITE)
         self._qmax1_input.SetBackgroundColour(wx.WHITE)
         self._qmax2_input.SetBackgroundColour(wx.WHITE)
         self._background_input.SetBackgroundColour(wx.WHITE)
     self._qmin_input.Refresh()
     self._qmax1_input.Refresh()
     self._qmax2_input.Refresh()
     self._background_input.Refresh()
     return (qmin_valid and qmax_valid and background_valid)
Exemple #7
0
 def _validate_inputs(self):
     """
     Check that the values for qmin and qmax in the input boxes are valid
     """
     if self._data is None:
         return False
     qmin_valid = check_float(self._qmin_input)
     qmax1_valid = check_float(self._qmax1_input)
     qmax2_valid = check_float(self._qmax2_input)
     qmax_valid = qmax1_valid and qmax2_valid
     background_valid = check_float(self._background_input)
     msg = ""
     if (qmin_valid and qmax_valid and background_valid):
         qmin = float(self._qmin_input.GetValue())
         qmax1 = float(self._qmax1_input.GetValue())
         qmax2 = float(self._qmax2_input.GetValue())
         background = float(self._background_input.GetValue())
         if not qmin > self._data.x.min():
             msg = "qmin must be greater than the lowest q value"
             qmin_valid = False
         elif qmax2 < qmax1:
             msg = "qmax1 must be less than qmax2"
             qmax_valid = False
         elif qmin > qmax1:
             msg = "qmin must be less than qmax"
             qmin_valid = False
         elif background > self._data.y.max():
             msg = "background must be less than highest I"
             background_valid = False
     if not qmin_valid:
         self._qmin_input.SetBackgroundColour('pink')
     if not qmax_valid:
         self._qmax1_input.SetBackgroundColour('pink')
         self._qmax2_input.SetBackgroundColour('pink')
     if not background_valid:
         self._background_input.SetBackgroundColour('pink')
         if msg != "":
             wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
     if (qmin_valid and qmax_valid and background_valid):
         self._qmin_input.SetBackgroundColour(wx.WHITE)
         self._qmax1_input.SetBackgroundColour(wx.WHITE)
         self._qmax2_input.SetBackgroundColour(wx.WHITE)
         self._background_input.SetBackgroundColour(wx.WHITE)
     self._qmin_input.Refresh()
     self._qmax1_input.Refresh()
     self._qmax2_input.Refresh()
     self._background_input.Refresh()
     return (qmin_valid and qmax_valid and background_valid)
Exemple #8
0
 def on_change_distance(self):
     """
     Change distance of the aperture
     """
     #Change distance
     distance = self.distance_tcl.GetValue().lstrip().rstrip()
     if distance == "" or distance == str(None):
         distance = None
         self._aperture.distance = distance
     else:
         if check_float(self.distance_tcl):
             if self._aperture.distance != float(distance):
                 self._notes += "Change distance from "
                 self._notes += "%s to %s \n" % (self._aperture.distance,
                                                 distance)
                 self._aperture.distance = float(distance)
         else:
             self._notes += "Error: Expected a float for distance  "
             self._notes += "won't changes distance from "
             self._notes += "%s to %s" % (self._aperture.distance, distance)
     #change the distance unit
     unit = self.distance_unit_tcl.GetValue().lstrip().rstrip()
     if self._aperture.distance_unit != unit:
         self._notes += " Change distance 's unit from "
         self._notes += "%s to %s" % (self._aperture.distance_unit, unit)
Exemple #9
0
    def on_change_distance(self):
        """
            Change distance of the sample to the detector
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change the distance
        distance = self.distance_tcl.GetValue().lstrip().rstrip()
        if distance == "" or distance == str(None):
            distance = None
            detector.distance = distance
        else:
            if check_float(self.distance_tcl):
                if detector.distance != float(distance):
                    self._notes += " Change Distance from"
                    self._notes += " %s to %s \n" % (detector.distance, distance)
                    detector.distance = float(distance)
            else:
                self._notes += "Error: Expected a float for "
                self._notes += " the distance won't changes "
                self._notes += "%s to %s" % (detector.distance, distance)
        #change the distance unit
        unit = self.distance_unit_tcl.GetValue().lstrip().rstrip()
        if detector.distance_unit != unit:
            self._notes += " Change distance's unit from "
            self._notes += "%s to %s" % (detector.distance_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #10
0
    def check_inputs(self):
        """
        Check validity user inputs
        """
        flag = True
        msg = ""
        if check_float(self.input_ctl):
            self.input = float(self.input_ctl.GetValue())
        else:
            flag = False
            input_type = str(self.input_cb.GetValue())
            msg += "Error for %s value :expect float" % input_type

        self.compound = self.compound_ctl.GetValue().lstrip().rstrip()
        if self.compound != "":
            try :
                Formula(self.compound)
                self.compound_ctl.SetBackgroundColour(wx.WHITE)
                self.compound_ctl.Refresh()
            except:
                self.compound_ctl.SetBackgroundColour("pink")
                self.compound_ctl.Refresh()
                flag = False
                msg += "Enter correct formula"
        else:
            self.compound_ctl.SetBackgroundColour("pink")
            self.compound_ctl.Refresh()
            flag = False
            msg += "Enter Formula"
        return flag, msg
Exemple #11
0
    def check_inputs(self):
        """
        Check validity user inputs
        """
        flag = True
        msg = ""
        if check_float(self.input_ctl):
            self.input = float(self.input_ctl.GetValue())
        else:
            flag = False
            input_type = str(self.input_cb.GetValue())
            msg += "Error for %s value :expect float" % input_type

        self.compound = self.compound_ctl.GetValue().lstrip().rstrip()
        if self.compound != "":
            try:
                Formula(self.compound)
                self.compound_ctl.SetBackgroundColour(wx.WHITE)
                self.compound_ctl.Refresh()
            except:
                self.compound_ctl.SetBackgroundColour("pink")
                self.compound_ctl.Refresh()
                flag = False
                msg += "Enter correct formula"
        else:
            self.compound_ctl.SetBackgroundColour("pink")
            self.compound_ctl.Refresh()
            flag = False
            msg += "Enter Formula"
        return flag, msg
Exemple #12
0
    def on_change_slit_length(self):
        """
            Change slit length of the detector
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change the distance
        slit_length = self.slit_length_tcl.GetValue().lstrip().rstrip()
        if slit_length == "" or slit_length == str(None):
            slit_length = None
            detector.slit_length = slit_length
        else:
            if check_float(self.slit_length_tcl):
                if detector.slit_length != float(slit_length):
                    self._notes += " Change slit length from"
                    self._notes += " %s to %s \n" % (detector.slit_length,
                                                    slit_length)
                    detector.slit_length = float(slit_length)
            else:
                self._notes += "Error: Expected a float"
                self._notes += " for the slit length won't changes "
                self._notes += "%s to %s" % (detector.slit_length, slit_length)
        #change the distance unit
        unit = self.slit_length_unit_tcl.GetValue().lstrip().rstrip()
        if detector.slit_length_unit != unit:
            self._notes += " Change slit length's unit from "
            self._notes += "%s to %s" % (detector.slit_length_unit_tcl, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #13
0
    def on_change_distance(self):
        """
            Change distance of the sample to the detector
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change the distance
        distance = self.distance_tcl.GetValue().lstrip().rstrip()
        if distance == "" or distance == str(None):
            distance = None
            detector.distance = distance
        else:
            if check_float(self.distance_tcl):
                if detector.distance != float(distance):
                    self._notes += " Change Distance from"
                    self._notes += " %s to %s \n" % (detector.distance, distance)
                    detector.distance = float(distance)
            else:
                self._notes += "Error: Expected a float for "
                self._notes += " the distance won't changes "
                self._notes += "%s to %s" % (detector.distance, distance)
        #change the distance unit
        unit = self.distance_unit_tcl.GetValue().lstrip().rstrip()
        if detector.distance_unit != unit:
            self._notes += " Change distance's unit from "
            self._notes += "%s to %s" % (detector.distance_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
 def on_change_length(self):
     """
     Change the length
     """
     collimation, collimation_name, position = self.get_current_collimation(
     )
     if collimation is None:
         return
     #Change length
     length = self.length_tcl.GetValue().lstrip().rstrip()
     if length == "" or length == str(None):
         length = None
         collimation.length = length
     else:
         if check_float(self.length_tcl):
             if collimation.length != float(length):
                 self._notes += "Change Collimation length from "
                 self._notes += "%s to %s \n" % (collimation.length, length)
                 collimation.length = float(length)
         else:
             self._notes += "Error: Expected a float for collimation length"
             self._notes += " won't changes length from "
             self._notes += "%s to %s" % (collimation.length, length)
     #change length  unit
     unit = self.length_unit_tcl.GetValue().lstrip().rstrip()
     if collimation.length_unit != unit:
         self._notes += " Change length's unit from "
         self._notes += "%s to %s" % (collimation.length_unit, unit)
         collimation.length_unit = unit
Exemple #15
0
    def on_change_slit_length(self):
        """
            Change slit length of the detector
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change the distance
        slit_length = self.slit_length_tcl.GetValue().lstrip().rstrip()
        if slit_length == "" or slit_length == str(None):
            slit_length = None
            detector.slit_length = slit_length
        else:
            if check_float(self.slit_length_tcl):
                if detector.slit_length != float(slit_length):
                    self._notes += " Change slit length from"
                    self._notes += " %s to %s \n" % (detector.slit_length,
                                                    slit_length)
                    detector.slit_length = float(slit_length)
            else:
                self._notes += "Error: Expected a float"
                self._notes += " for the slit length won't changes "
                self._notes += "%s to %s" % (detector.slit_length, slit_length)
        #change the distance unit
        unit = self.slit_length_unit_tcl.GetValue().lstrip().rstrip()
        if detector.slit_length_unit != unit:
            self._notes += " Change slit length's unit from "
            self._notes += "%s to %s" % (detector.slit_length_unit_tcl, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #16
0
    def check_inputs(self):
        """Check validity user inputs"""
        flag = True
        msg = ""
        if check_float(self.density_ctl):
            self.density = float(self.density_ctl.GetValue())
        else:
            flag = False
            msg += "Error for Density value :expect float"

        self.wavelength = self.wavelength_ctl.GetValue()
        if str(self.wavelength).lstrip().rstrip() == "":
            self.wavelength = WAVELENGTH
            self.wavelength_ctl.SetValue(str(WAVELENGTH))
            self.wavelength_ctl.SetBackgroundColour(wx.WHITE)
            self.wavelength_ctl.Refresh()
            msg += "Default value for wavelength is 6.0"
        else:
            if check_float(self.wavelength_ctl):
                self.wavelength = float(self.wavelength)
            else:
                flag = False
                msg += "Error for wavelength value :expect float"

        self.compound = self.compound_ctl.GetValue().lstrip().rstrip()
        if self.compound != "":
            try :
                formula(self.compound)
                self.compound_ctl.SetBackgroundColour(wx.WHITE)
                self.compound_ctl.Refresh()
            except:
                self.compound_ctl.SetBackgroundColour("pink")
                self.compound_ctl.Refresh()
                flag = False
                msg += "Enter correct formula"
        else:
            self.compound_ctl.SetBackgroundColour("pink")
            self.compound_ctl.Refresh()
            flag = False
            msg += "Enter a formula"
        return flag, msg
    def Validate(self):
        """
        Validate the contents of the inputs

        :return all_valid: Whether or not the inputs are valid
        :return invalid_ctrl: A control that is not valid
            (or None if all are valid)
        """
        all_valid = True
        invalid_ctrl = None
        for control in self._inputs.values():
            if control.GetValue() == '': continue
            control.SetBackgroundColour(wx.WHITE)
            control_valid = check_float(control)
            if not control_valid:
                all_valid = False
                invalid_ctrl = control
        return all_valid, invalid_ctrl
Exemple #18
0
    def Validate(self):
        """
        Validate the contents of the inputs

        :return all_valid: Whether or not the inputs are valid
        :return invalid_ctrl: A control that is not valid
            (or None if all are valid)
        """
        all_valid = True
        invalid_ctrl = None
        for control in self._inputs.values():
            if control.GetValue() == '': continue
            control.SetBackgroundColour(wx.WHITE)
            control_valid = check_float(control)
            if not control_valid:
                all_valid = False
                invalid_ctrl = control
        return all_valid, invalid_ctrl
Exemple #19
0
 def on_close(self, event=None):
     for ctrl in self._to_validate:
         ctrl.SetBackgroundColour(wx.WHITE)
         if ctrl.GetValue() == '': continue
         if not check_float(ctrl):
             msg = "{} must be a valid float".format(
                 ctrl.GetName().replace("_", " "))
             wx.PostEvent(self.parent.manager.parent.manager.parent,
                 StatusEvent(status=msg, info='error'))
             return False
     for vector_in in self._vectors:
         is_valid, invalid_ctrl = vector_in.Validate()
         if not is_valid:
             msg = "{} must be a valid float".format(
                 invalid_ctrl.GetName().replace("_", " "))
             wx.PostEvent(self.parent.manager.parent.manager.parent,
                 StatusEvent(status=msg, info='error'))
             return False
         setattr(self.metadata, vector_in.GetName(), vector_in.GetValue())
     return True
Exemple #20
0
 def on_close(self, event=None):
     for ctrl in self._to_validate:
         ctrl.SetBackgroundColour(wx.WHITE)
         if ctrl.GetValue() == '': continue
         if not check_float(ctrl):
             msg = "{} must be a valid float".format(ctrl.GetName().replace(
                 "_", " "))
             wx.PostEvent(self.parent.manager.parent.manager.parent,
                          StatusEvent(status=msg, info='error'))
             return False
     for vector_in in self._vectors:
         is_valid, invalid_ctrl = vector_in.Validate()
         if not is_valid:
             msg = "{} must be a valid float".format(
                 invalid_ctrl.GetName().replace("_", " "))
             wx.PostEvent(self.parent.manager.parent.manager.parent,
                          StatusEvent(status=msg, info='error'))
             return False
         setattr(self.metadata, vector_in.GetName(), vector_in.GetValue())
     return True
Exemple #21
0
 def on_change_distance(self):
     """
     Change distance of the aperture
     """
     #Change distance
     distance = self.distance_tcl.GetValue().lstrip().rstrip()
     if distance == "" or distance == str(None):
         distance = None
         self._aperture.distance = distance
     else:
         if check_float(self.distance_tcl):
             if self._aperture.distance != float(distance):
                 self._notes += "Change distance from "
                 self._notes += "%s to %s \n" % (self._aperture.distance, distance)
                 self._aperture.distance = float(distance)
         else:
             self._notes += "Error: Expected a float for distance  "
             self._notes += "won't changes distance from "
             self._notes += "%s to %s" % (self._aperture.distance, distance)
     #change the distance unit
     unit = self.distance_unit_tcl.GetValue().lstrip().rstrip()
     if self._aperture.distance_unit != unit:
         self._notes += " Change distance 's unit from "
         self._notes += "%s to %s" % (self._aperture.distance_unit, unit)
Exemple #22
0
    def on_change_orientation(self):
        """
            Change the detector orientation
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change x coordinate
        x_orientation = self.x_orientation_tcl.GetValue().lstrip().rstrip()
        if x_orientation == "" or x_orientation == str(None):
            x_orientation = None
            detector.orientation.x = x_orientation
        else:
            if check_float(self.x_orientation_tcl):
                if detector.orientation.x != float(x_orientation):
                    self._notes += "Change x of orientation from "
                    self._notes += "%s to %s \n" % (detector.orientation.x,
                                                   x_orientation)
                    detector.orientation.x = float(x_orientation)
            else:
                self._notes += "Error: Expected a float for the orientation "
                self._notes += "'s x  won't changes x orientation from "
                self._notes += "%s to %s" % (detector.orientation.x,
                                              x_orientation)
        #Change y coordinate
        y_orientation = self.y_orientation_tcl.GetValue().lstrip().rstrip()
        if y_orientation == "" or y_orientation == str(None):
            y_orientation = None
            detector.orientation.y = y_orientation
        else:
            if check_float(self.y_orientation_tcl):
                if detector.orientation.y != float(y_orientation):
                    self._notes += "Change y of orientation from "
                    self._notes += "%s to %s \n" % (detector.orientation.y,
                                                     y_orientation)
                    detector.orientation.y = float(y_orientation)
            else:
                self._notes += "Error: Expected a float for the orientation's "
                self._notes += " y won't changes y orientation from "
                self._notes += "%s to %s" % (detector.orientation.y,
                                            y_orientation)
        #Change z coordinate
        z_orientation = self.z_orientation_tcl.GetValue().lstrip().rstrip()
        if z_orientation == "" or z_orientation == str(None):
            z_orientation = None
            detector.orientation.z = z_orientation
        else:
            if check_float(self.z_orientation_tcl):
                if detector.orientation.z != float(z_orientation):
                    self._notes += "Change z of offset from "
                    self._notes += "%s to %s \n" % (detector.orientation.z,
                                                   z_orientation)
                    detector.orientation.z = float(z_orientation)
            else:
                self._notes += "Error: Expected a float for the orientation 's"
                self._notes += " x won't changes z orientation from "
                self._notes += "%s to %s" % (detector.orientation.z,
                                              z_orientation)
        #change the orientation unit
        unit = self.orientation_unit_tcl.GetValue().lstrip().rstrip()
        if detector.orientation_unit != unit:
            self._notes += " Change orientation's unit from "
            self._notes += "%s to %s" % (detector.orientation_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #23
0
    def check_inputs(self):
        """Check validity user inputs"""
        flag = True
        msg = ""
        if check_float(self.density_ctl):
            self.density = float(self.density_ctl.GetValue())
        else:
            flag = False
            msg += "Error for Density value :expect float"

        self.neutron_wavelength = self.neutron_wavelength_ctl.GetValue()
        self.xray_source_input = self.xray_source_input_ctl.GetValue()

        if str(self.neutron_wavelength).lstrip().rstrip() == "":
            self.neutron_wavelength = WAVELENGTH
            self.neutron_wavelength_ctl.SetValue(str(WAVELENGTH))
            self.neutron_wavelength_ctl.SetBackgroundColour(wx.WHITE)
            self.neutron_wavelength_ctl.Refresh()
            msg += "Default value for wavelength is 6.0"
        else:
            if check_float(self.neutron_wavelength_ctl):
                self.neutron_wavelength = float(self.neutron_wavelength)
            else:
                flag = False
                msg += "Error for wavelength value :expect float"

        if str(self.xray_source_input).lstrip().rstrip() == "":
            self.xray_source_input = WAVELENGTH
            self.xray_source_input_ctl.SetValue(str(WAVELENGTH))
            self.xray_source_input_ctl.SetBackgroundColour(wx.WHITE)
            self.xray_source_input_ctl.Refresh()
            msg += "Default value for wavelength is 6.0"
        else:
            if (self.xray_source == '[A]') or (self.xray_source == '[keV]'):
                if check_float(self.xray_source_input_ctl):
                    self.xray_source_input = float(self.xray_source_input)
                else:
                    flag = False
                    msg += "Error for wavelength value :expect float"
            elif (self.xray_source == 'Element'):
                try:
                    import periodictable
                    exec("periodictable." + self.xray_source_input)
                except AttributeError:
                    flag = False
                    msg += "X-ray element supplied isn't in the database"

        self.compound = self.compound_ctl.GetValue().lstrip().rstrip()
        if self.compound != "":
            try:
                formula(self.compound)
                self.compound_ctl.SetBackgroundColour(wx.WHITE)
                self.compound_ctl.Refresh()
            except:
                self.compound_ctl.SetBackgroundColour("pink")
                self.compound_ctl.Refresh()
                flag = False
                msg += "Enter correct formula"
        else:
            self.compound_ctl.SetBackgroundColour("pink")
            self.compound_ctl.Refresh()
            flag = False
            msg += "Enter a formula"
        return flag, msg
Exemple #24
0
    def on_change_pixel_size(self):
        """
            Change the detector pixel size
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change x coordinate
        x_pixel_size = self.x_pixel_size_tcl.GetValue().lstrip().rstrip()
        if x_pixel_size == "" or x_pixel_size == str(None):
            x_pixel_size = None
        else:
            if check_float(self.x_pixel_size_tcl):
                if detector.pixel_size.x != float(x_pixel_size) :
                    self._notes += "Change x of pixel size from "
                    self._notes += "%s to %s \n" % (detector.pixel_size.x,
                                                   x_pixel_size)
                    detector.pixel_size.x = float(x_pixel_size)
            else:
                self._notes += "Error: Expected a float for the pixel"
                self._notes += " size 's x  won't changes x pixel size from "
                self._notes += "%s to %s" % (detector.pixel_size.x,
                                             x_pixel_size)
        #Change y coordinate
        y_pixel_size = self.y_pixel_size_tcl.GetValue().lstrip().rstrip()
        if y_pixel_size == "" or y_pixel_size == str(None):
            y_pixel_size = None
            detector.pixel_size.y = y_pixel_size
        else:
            if check_float(self.y_pixel_size_tcl):
                if detector.pixel_size.y != float(y_pixel_size):
                    self._notes += "Change y of pixel size from "
                    self._notes += "%s to %s \n" % (detector.pixel_size.y,
                                                   y_pixel_size)
                    detector.pixel_size.y = float(y_pixel_size)
            else:
                self._notes += "Error: Expected a float for the pixel "
                self._notes += "size's y  won't changes y pixel size from "
                self._notes += "%s to %s" % (detector.pixel_size.y,
                                              y_pixel_size)
        #Change z coordinate
        z_pixel_size = self.z_pixel_size_tcl.GetValue().lstrip().rstrip()
        if z_pixel_size == "" or z_pixel_size == str(None):
            z_pixel_size = None
            detector.pixel_size.z = z_pixel_size
        else:
            if check_float(self.z_pixel_size_tcl):
                if detector.pixel_size.z != float(z_pixel_size):
                    self._notes += "Change z of pixel size from "
                    self._notes += "%s to %s \n" % (detector.pixel_size.z,
                                                   z_pixel_size)
                    detector.pixel_size.z = float(z_pixel_size)
            else:
                self._notes += "Error: Expected a float for the offset 's x "
                self._notes += "won't changes z pixel size from "
                self._notes += "%s to %s" % (detector.pixel_size.z, z_pixel_size)
        #change the beam center unit
        unit = self.pixel_size_unit_tcl.GetValue().lstrip().rstrip()
        if detector.pixel_size_unit != unit:
            self._notes += " Change pixel size's unit from "
            self._notes += "%s to %s" % (detector.pixel_size_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #25
0
    def check_inputs(self):
        """Check validity user inputs"""
        flag = True
        msg = ""
        if check_float(self.density_ctl):
            self.density = float(self.density_ctl.GetValue())
        else:
            flag = False
            msg += "Error for Density value :expect float"

        self.neutron_wavelength = self.neutron_wavelength_ctl.GetValue()
        self.xray_source_input = self.xray_source_input_ctl.GetValue()

        if str(self.neutron_wavelength).lstrip().rstrip() == "":
            self.neutron_wavelength = WAVELENGTH
            self.neutron_wavelength_ctl.SetValue(str(WAVELENGTH))
            self.neutron_wavelength_ctl.SetBackgroundColour(wx.WHITE)
            self.neutron_wavelength_ctl.Refresh()
            msg += "Default value for wavelength is 6.0"
        else:
            if check_float(self.neutron_wavelength_ctl):
                self.neutron_wavelength = float(self.neutron_wavelength)
            else:
                flag = False
                msg += "Error for wavelength value :expect float"

        if str(self.xray_source_input).lstrip().rstrip() == "":
            self.xray_source_input = WAVELENGTH
            self.xray_source_input_ctl.SetValue(str(WAVELENGTH))
            self.xray_source_input_ctl.SetBackgroundColour(wx.WHITE)
            self.xray_source_input_ctl.Refresh()
            msg += "Default value for wavelength is 6.0"
        else:
            if (self.xray_source == '[A]') or (self.xray_source == '[keV]'):
                if check_float(self.xray_source_input_ctl):
                    self.xray_source_input = float(self.xray_source_input)
                else:
                    flag = False
                    msg += "Error for wavelength value :expect float"
            elif (self.xray_source == 'Element'):
                try:
                    import periodictable
                    exec("periodictable." + self.xray_source_input)
                except AttributeError:
                    flag = False
                    msg += "X-ray element supplied isn't in the database"



        self.compound = self.compound_ctl.GetValue().lstrip().rstrip()
        if self.compound != "":
            try :
                formula(self.compound)
                self.compound_ctl.SetBackgroundColour(wx.WHITE)
                self.compound_ctl.Refresh()
            except:
                self.compound_ctl.SetBackgroundColour("pink")
                self.compound_ctl.Refresh()
                flag = False
                msg += "Enter correct formula"
        else:
            self.compound_ctl.SetBackgroundColour("pink")
            self.compound_ctl.Refresh()
            flag = False
            msg += "Enter a formula"
        return flag, msg
Exemple #26
0
    def on_change_beam_center(self):
        """
            Change the detector beam center
        """

        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change x coordinate
        x_beam_center = self.x_beam_center_tcl.GetValue().lstrip().rstrip()
        if x_beam_center == "" or x_beam_center == str(None):
            x_beam_center = None
            detector.beam_center.x = x_beam_center
        else:
            if check_float(self.x_beam_center_tcl):
                if detector.beam_center.x != float(x_beam_center):
                    self._notes += "Change x of offset from "
                    self._notes += "%s to %s \n" % (detector.beam_center.x,
                                                     x_beam_center)
                    detector.beam_center.x = float(x_beam_center)
            else:
                self._notes += "Error: Expected a float for the beam "
                self._notes += "center 's x won't changes x beam center from "
                self._notes += "%s to %s" % (detector.beam_center.x,
                                            x_beam_center)
        #Change y coordinate
        y_beam_center = self.y_beam_center_tcl.GetValue().lstrip().rstrip()
        if y_beam_center == "" or y_beam_center == str(None):
            y_beam_center = None
            detector.beam_center.y = y_beam_center
        else:
            if check_float(self.y_beam_center_tcl):
                if detector.beam_center.y != float(y_beam_center):
                    self._notes += "Change y of beam center from "
                    self._notes += "%s to %s \n" % (detector.beam_center.y,
                                                     y_beam_center)
                    detector.beam_center.y = float(y_beam_center)
            else:
                self._notes += "Error: Expected a float for the beam "
                self._notes += "center 's y won't changes y beam center from "
                self._notes += "%s to %s" % (detector.beam_center.y,
                                              y_beam_center)
        #Change z coordinate
        z_beam_center = self.z_beam_center_tcl.GetValue().lstrip().rstrip()
        if z_beam_center == "" or z_beam_center == str(None):
            z_beam_center = None
            detector.beam_center.z = z_beam_center
        else:
            if check_float(self.z_beam_center_tcl):
                if detector.beam_center.z != float(z_beam_center):
                    self._notes += "Change z of beam center from "
                    self._notes += "%s to %s \n" % (detector.beam_center.z,
                                                     z_beam_center)
                    detector.beam_center.z = float(z_beam_center)
            else:
                self._notes += "Error: Expected a float for the offset 's x "
                self._notes += "won't changes z beam center from "
                self._notes += "%s to %s" % (detector.beam_center.z,
                                            z_beam_center)
        #change the beam center unit
        unit = self.beam_center_unit_tcl.GetValue().lstrip().rstrip()
        if detector.beam_center_unit != unit:
            self._notes += " Change beam center's unit from "
            self._notes += "%s to %s" % (detector.beam_center_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #27
0
    def on_change_pixel_size(self):
        """
            Change the detector pixel size
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change x coordinate
        x_pixel_size = self.x_pixel_size_tcl.GetValue().lstrip().rstrip()
        if x_pixel_size == "" or x_pixel_size == str(None):
            x_pixel_size = None
        else:
            if check_float(self.x_pixel_size_tcl):
                if detector.pixel_size.x != float(x_pixel_size) :
                    self._notes += "Change x of pixel size from "
                    self._notes += "%s to %s \n" % (detector.pixel_size.x,
                                                   x_pixel_size)
                    detector.pixel_size.x = float(x_pixel_size)
            else:
                self._notes += "Error: Expected a float for the pixel"
                self._notes += " size 's x  won't changes x pixel size from "
                self._notes += "%s to %s" % (detector.pixel_size.x,
                                             x_pixel_size)
        #Change y coordinate
        y_pixel_size = self.y_pixel_size_tcl.GetValue().lstrip().rstrip()
        if y_pixel_size == "" or y_pixel_size == str(None):
            y_pixel_size = None
            detector.pixel_size.y = y_pixel_size
        else:
            if check_float(self.y_pixel_size_tcl):
                if detector.pixel_size.y != float(y_pixel_size):
                    self._notes += "Change y of pixel size from "
                    self._notes += "%s to %s \n" % (detector.pixel_size.y,
                                                   y_pixel_size)
                    detector.pixel_size.y = float(y_pixel_size)
            else:
                self._notes += "Error: Expected a float for the pixel "
                self._notes += "size's y  won't changes y pixel size from "
                self._notes += "%s to %s" % (detector.pixel_size.y,
                                              y_pixel_size)
        #Change z coordinate
        z_pixel_size = self.z_pixel_size_tcl.GetValue().lstrip().rstrip()
        if z_pixel_size == "" or z_pixel_size == str(None):
            z_pixel_size = None
            detector.pixel_size.z = z_pixel_size
        else:
            if check_float(self.z_pixel_size_tcl):
                if detector.pixel_size.z != float(z_pixel_size):
                    self._notes += "Change z of pixel size from "
                    self._notes += "%s to %s \n" % (detector.pixel_size.z,
                                                   z_pixel_size)
                    detector.pixel_size.z = float(z_pixel_size)
            else:
                self._notes += "Error: Expected a float for the offset 's x "
                self._notes += "won't changes z pixel size from "
                self._notes += "%s to %s" % (detector.pixel_size.z, z_pixel_size)
        #change the beam center unit
        unit = self.pixel_size_unit_tcl.GetValue().lstrip().rstrip()
        if detector.pixel_size_unit != unit:
            self._notes += " Change pixel size's unit from "
            self._notes += "%s to %s" % (detector.pixel_size_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #28
0
    def on_change_beam_center(self):
        """
            Change the detector beam center
        """

        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change x coordinate
        x_beam_center = self.x_beam_center_tcl.GetValue().lstrip().rstrip()
        if x_beam_center == "" or x_beam_center == str(None):
            x_beam_center = None
            detector.beam_center.x = x_beam_center
        else:
            if check_float(self.x_beam_center_tcl):
                if detector.beam_center.x != float(x_beam_center):
                    self._notes += "Change x of offset from "
                    self._notes += "%s to %s \n" % (detector.beam_center.x,
                                                     x_beam_center)
                    detector.beam_center.x = float(x_beam_center)
            else:
                self._notes += "Error: Expected a float for the beam "
                self._notes += "center 's x won't changes x beam center from "
                self._notes += "%s to %s" % (detector.beam_center.x,
                                            x_beam_center)
        #Change y coordinate
        y_beam_center = self.y_beam_center_tcl.GetValue().lstrip().rstrip()
        if y_beam_center == "" or y_beam_center == str(None):
            y_beam_center = None
            detector.beam_center.y = y_beam_center
        else:
            if check_float(self.y_beam_center_tcl):
                if detector.beam_center.y != float(y_beam_center):
                    self._notes += "Change y of beam center from "
                    self._notes += "%s to %s \n" % (detector.beam_center.y,
                                                     y_beam_center)
                    detector.beam_center.y = float(y_beam_center)
            else:
                self._notes += "Error: Expected a float for the beam "
                self._notes += "center 's y won't changes y beam center from "
                self._notes += "%s to %s" % (detector.beam_center.y,
                                              y_beam_center)
        #Change z coordinate
        z_beam_center = self.z_beam_center_tcl.GetValue().lstrip().rstrip()
        if z_beam_center == "" or z_beam_center == str(None):
            z_beam_center = None
            detector.beam_center.z = z_beam_center
        else:
            if check_float(self.z_beam_center_tcl):
                if detector.beam_center.z != float(z_beam_center):
                    self._notes += "Change z of beam center from "
                    self._notes += "%s to %s \n" % (detector.beam_center.z,
                                                     z_beam_center)
                    detector.beam_center.z = float(z_beam_center)
            else:
                self._notes += "Error: Expected a float for the offset 's x "
                self._notes += "won't changes z beam center from "
                self._notes += "%s to %s" % (detector.beam_center.z,
                                            z_beam_center)
        #change the beam center unit
        unit = self.beam_center_unit_tcl.GetValue().lstrip().rstrip()
        if detector.beam_center_unit != unit:
            self._notes += " Change beam center's unit from "
            self._notes += "%s to %s" % (detector.beam_center_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))
Exemple #29
0
    def on_change_orientation(self):
        """
            Change the detector orientation
        """
        detector, _, position = self.get_current_detector()
        if detector is None:
            return
        #Change x coordinate
        x_orientation = self.x_orientation_tcl.GetValue().lstrip().rstrip()
        if x_orientation == "" or x_orientation == str(None):
            x_orientation = None
            detector.orientation.x = x_orientation
        else:
            if check_float(self.x_orientation_tcl):
                if detector.orientation.x != float(x_orientation):
                    self._notes += "Change x of orientation from "
                    self._notes += "%s to %s \n" % (detector.orientation.x,
                                                   x_orientation)
                    detector.orientation.x = float(x_orientation)
            else:
                self._notes += "Error: Expected a float for the orientation "
                self._notes += "'s x  won't changes x orientation from "
                self._notes += "%s to %s" % (detector.orientation.x,
                                              x_orientation)
        #Change y coordinate
        y_orientation = self.y_orientation_tcl.GetValue().lstrip().rstrip()
        if y_orientation == "" or y_orientation == str(None):
            y_orientation = None
            detector.orientation.y = y_orientation
        else:
            if check_float(self.y_orientation_tcl):
                if detector.orientation.y != float(y_orientation):
                    self._notes += "Change y of orientation from "
                    self._notes += "%s to %s \n" % (detector.orientation.y,
                                                     y_orientation)
                    detector.orientation.y = float(y_orientation)
            else:
                self._notes += "Error: Expected a float for the orientation's "
                self._notes += " y won't changes y orientation from "
                self._notes += "%s to %s" % (detector.orientation.y,
                                            y_orientation)
        #Change z coordinate
        z_orientation = self.z_orientation_tcl.GetValue().lstrip().rstrip()
        if z_orientation == "" or z_orientation == str(None):
            z_orientation = None
            detector.orientation.z = z_orientation
        else:
            if check_float(self.z_orientation_tcl):
                if detector.orientation.z != float(z_orientation):
                    self._notes += "Change z of offset from "
                    self._notes += "%s to %s \n" % (detector.orientation.z,
                                                   z_orientation)
                    detector.orientation.z = float(z_orientation)
            else:
                self._notes += "Error: Expected a float for the orientation 's"
                self._notes += " x won't changes z orientation from "
                self._notes += "%s to %s" % (detector.orientation.z,
                                              z_orientation)
        #change the orientation unit
        unit = self.orientation_unit_tcl.GetValue().lstrip().rstrip()
        if detector.orientation_unit != unit:
            self._notes += " Change orientation's unit from "
            self._notes += "%s to %s" % (detector.orientation_unit, unit)

        self.detector_cbox.SetString(position, str(detector.name))
        self.detector_cbox.SetClientData(position, detector)
        self.detector_cbox.SetStringSelection(str(detector.name))