def setBeam(self, beam):
        if ShadowGui.checkEmptyBeam(beam):
            proceed = True

            if not ShadowGui.checkGoodBeam(beam):
                if not ConfirmDialog.confirmed(parent=self, message="Beam contains bad values, skip it?"):
                    proceed = False

            if proceed:
                go = numpy.where(beam.beam.rays[:, 9] == 1)

                self.current_number_of_rays = self.current_number_of_rays + len(beam.beam.rays[go])

                if self.current_number_of_rays <= self.number_of_accumulated_rays:
                    if self.keep_go_rays == 1:
                        beam.beam.rays = copy.deepcopy(beam.beam.rays[go])

                    if not self.input_beam is None:
                        self.input_beam = ShadowBeam.mergeBeams(self.input_beam, beam)
                    else:
                        self.input_beam = beam

                    self.send("Trigger", ShadowTriggerIn(new_beam=True))
                else:
                    if self.is_automatic_run:
                        self.sendSignal()

                        self.current_number_of_rays = 0
                        self.input_beam = None
                    else:
                        QtGui.QMessageBox.critical(self, "QMessageBox.critical()",
                                                   "Number of Accumulated Rays reached, please push \'Send Signal\' button",
                                                   QtGui.QMessageBox.Ok)
Exemplo n.º 2
0
 def call_reset_settings(self):
     if ConfirmDialog.confirmed(parent=self, message="Confirm Reset of the Fields?"):
         try:
             self.resetSettings()
             self.reload_harmonics_table()
         except:
             pass
Exemplo n.º 3
0
    def crl_insert_before(self):
        current_index = self.tab_crls.currentIndex()

        if ConfirmDialog.confirmed(parent=self, message="Confirm Insertion of a new element before " + self.tab_crls.tabText(current_index) + "?"):
            tab_crl = ShadowGui.widgetBox(self.tab_crls, addToLayout=0, margin=4)
            crl_box = CRLBox(transfocator=self, parent=tab_crl)

            self.tab_crls.insertTab(current_index, tab_crl, "TEMP")
            self.crl_box_array.insert(current_index, crl_box)
            self.dumpSettings()

            for index in range(current_index, self.tab_crls.count()):
                self.tab_crls.setTabText(index, "C.R.L " + str(index + 1))

            self.tab_crls.setCurrentIndex(current_index)
Exemplo n.º 4
0
    def crl_remove(self):
        if self.tab_crls.count() <= 1:
            QtGui.QMessageBox.critical(self, "QMessageBox.critical()",
                                       "Remove not possible, transfocator needs at least 1 element",
                                       QtGui.QMessageBox.Ok)
        else:
            current_index = self.tab_crls.currentIndex()

            if ConfirmDialog.confirmed(parent=self, message="Confirm Removal of " + self.tab_crls.tabText(current_index) + "?"):
                self.tab_crls.removeTab(current_index)
                self.crl_box_array.pop(current_index)
                self.dumpSettings()

                for index in range(current_index, self.tab_crls.count()):
                    self.tab_crls.setTabText(index, "C.R.L " + str(index + 1))

                self.tab_crls.setCurrentIndex(current_index)
Exemplo n.º 5
0
    def callResetSettings(self):
        if ConfirmDialog.confirmed(parent=self, message="Confirm Reset of the Fields?\n\nWarning: C.R.L. stack will be regenerated"):
            self.resetSettings()

            while self.tab_crls.count() > 0:
                self.tab_crls.removeTab(0)

            self.crl_box_array = []

            for index in range(len(self.p)):
                tab_crl = ShadowGui.widgetBox(self.tab_crls, addToLayout=0, margin=4)
                crl_box = CRLBox(transfocator=self,
                                 parent=tab_crl,
                                 nlenses=self.nlenses[index],
                                 slots_empty=self.slots_empty[index],
                                 thickness=self.thickness[index],
                                 p=self.p[index],
                                 q=self.q[index],
                                 surface_shape=self.surface_shape[index],
                                 convex_to_the_beam=self.convex_to_the_beam[index],
                                 has_finite_diameter=self.has_finite_diameter[index],
                                 diameter=self.diameter[index],
                                 is_cylinder=self.is_cylinder[index],
                                 cylinder_angle=self.cylinder_angle[index],
                                 ri_calculation_mode=self.ri_calculation_mode[index],
                                 prerefl_file=self.prerefl_file[index],
                                 refraction_index=self.refraction_index[index],
                                 attenuation_coefficient=self.attenuation_coefficient[index],
                                 radius=self.radius[index],
                                 interthickness=self.interthickness[index],
                                 use_ccc=self.use_ccc[index])

                self.tab_crls.addTab(tab_crl, "C.R.L " + str(index + 1))
                self.crl_box_array.append(crl_box)

            self.setupUI()
Exemplo n.º 6
0
    def callResetSettings(self):
        if ConfirmDialog.confirmed(parent=self, message="Confirm Reset of the Fields?"):
            self.resetSettings()

            while self.tab_crystals.count() > 0:
                self.tab_crystals.removeTab(0)

            tab_first_crystal = ShadowGui.widgetBox(self.tab_crystals, addToLayout=0, margin=4)
            tab_second_crystal = ShadowGui.widgetBox(self.tab_crystals, addToLayout=0, margin=4)

            self.crystal_1_box = CrystalBox(dcm=self,
                                            parent=tab_first_crystal,
                                            has_finite_dimensions=self.has_finite_dimensions[0],
                                            dimensions=self.dimensions[0])

            self.crystal_2_box = CrystalBox(dcm=self,
                                            parent=tab_second_crystal,
                                            has_finite_dimensions=self.has_finite_dimensions[1],
                                            dimensions=self.dimensions[1])

            self.tab_crystals.addTab(tab_first_crystal, "First Crystal")
            self.tab_crystals.addTab(tab_second_crystal, "Second Crystal")

            self.setupUI()
Exemplo n.º 7
0
    def callResetSettings(self):
        if ConfirmDialog.confirmed(parent=self, message="Confirm Reset of the Fields?"):
            self.resetSettings()

            while self.tab_mirrors.count() > 0:
                self.tab_mirrors.removeTab(0)

            tab_vertical = ShadowGui.widgetBox(self.tab_mirrors, addToLayout=0, margin=4)
            tab_horizontal = ShadowGui.widgetBox(self.tab_mirrors, addToLayout=0, margin=4)

            self.v_box = MirrorBox(kb=self,
                                   parent=tab_vertical,
                                   grazing_angles_mrad=self.grazing_angles_mrad[0],
                                   shape=self.shape[0],
                                   has_finite_dimensions=self.has_finite_dimensions[0],
                                   dimensions=self.dimensions[0],
                                   reflectivity_kind=self.reflectivity_kind[0],
                                   reflectivity_files=self.reflectivity_files[0],
                                   has_surface_error=self.has_surface_error[0],
                                   surface_error_files=self.surface_error_files[0])

            self.h_box = MirrorBox(kb=self,
                                   parent=tab_horizontal,
                                   grazing_angles_mrad=self.grazing_angles_mrad[1],
                                   shape=self.shape[1],
                                   has_finite_dimensions=self.has_finite_dimensions[1],
                                   dimensions=self.dimensions[1],
                                   reflectivity_kind=self.reflectivity_kind[1],
                                   reflectivity_files=self.reflectivity_files[1],
                                   has_surface_error=self.has_surface_error[1],
                                   surface_error_files=self.surface_error_files[1])

            self.tab_mirrors.addTab(tab_vertical, "Vertical Focusing Mirror")
            self.tab_mirrors.addTab(tab_horizontal, "Horizontal Focusing Mirror")

            self.setupUI()
 def callResetSettings(self):
     if ConfirmDialog.confirmed(parent=self, message="Confirm Reset of the accumulated beam"):
         self.current_number_of_rays = 0
         self.input_beam = None
Exemplo n.º 9
0
 def clearResults(self):
     if ConfirmDialog.confirmed(parent=self):
         self.input_beam = None
         self.plot_canvas.clear()
Exemplo n.º 10
0
 def callResetSettings(self):
     if ConfirmDialog.confirmed(parent=self, message="Confirm Reset of the Fields?"):
         try:
             self.resetSettings()
         except:
             pass
Exemplo n.º 11
0
 def stopLoop(self):
     if ConfirmDialog.confirmed(parent=self, message="Confirm Interruption of the Loop?"):
         self.run_loop = False
         self.setStatusMessage("Interrupted by user")
         self.warning("Interrupted by user")