コード例 #1
0
    def traceOpticalElement(self):
        try:
            self.error(self.error_id)
            self.setStatusMessage("")
            self.progressBarInit()

            if ShadowGui.checkEmptyBeam(self.input_beam):
                if ShadowGui.checkGoodBeam(self.input_beam):
                    sys.stdout = EmittingStream(textWritten=self.writeStdOut)

                    self.checkFields()

                    shadow_oe = ShadowCompoundOpticalElement.create_compound_oe()

                    self.populateFields(shadow_oe)

                    self.doSpecificSetting(shadow_oe)

                    self.progressBarSet(10)

                    self.completeOperations(shadow_oe)
                else:
                    raise Exception("Input Beam with no good rays")
            else:
                raise Exception("Empty Input Beam")

        except Exception as exception:
            QtGui.QMessageBox.critical(self, "QMessageBox.critical()",
                                       str(exception),
                                       QtGui.QMessageBox.Ok)

            self.error_id = self.error_id + 1
            self.error(self.error_id, "Exception occurred: " + str(exception))

        self.progressBarFinished()
コード例 #2
0
    def traceOpticalElement(self):
        try:
            #self.error(self.error_id)
            self.setStatusMessage("")
            self.progressBarInit()

            if ShadowCongruence.checkEmptyBeam(self.input_beam):
                if ShadowCongruence.checkGoodBeam(self.input_beam):
                    sys.stdout = EmittingStream(textWritten=self.writeStdOut)

                    self.checkFields()

                    shadow_oe = ShadowCompoundOpticalElement.create_compound_oe(
                        workspace_units_to_cm=self.workspace_units_to_cm)

                    self.populateFields(shadow_oe)

                    self.doSpecificSetting(shadow_oe)

                    self.progressBarSet(10)

                    self.completeOperations(shadow_oe)
                else:
                    if self.not_interactive: self.sendEmptyBeam()
                    else: raise Exception("Input Beam with no good rays")
            else:
                if self.not_interactive: self.sendEmptyBeam()
                else: raise Exception("Empty Input Beam")

        except Exception as exception:
            QtWidgets.QMessageBox.critical(self, "Error", str(exception),
                                           QtWidgets.QMessageBox.Ok)

            #self.error_id = self.error_id + 1
            #self.error(self.error_id, "Exception occurred: " + str(exception))

            if self.IS_DEVELOP: raise exception

        self.progressBarFinished()
コード例 #3
0
    def setBeam(self, beam):
        if ShadowCongruence.checkEmptyBeam(beam):
            if ShadowCongruence.checkGoodBeam(beam):
                sys.stdout = EmittingStream(textWritten=self.writeStdOut)

                self.input_beam = beam

                optical_element_list_start = []
                optical_element_list_end = []

                self.sysInfo.setText("")
                self.mirInfo.setText("")
                self.sourceInfo.setText("")
                self.distancesSummary.setText("")
                self.pythonScript.setText("")

                for history_element in self.input_beam.getOEHistory():
                    if not history_element._shadow_source_start is None:
                        optical_element_list_start.append(
                            history_element._shadow_source_start.src)
                    elif not history_element._shadow_oe_start is None:
                        optical_element_list_start.append(
                            history_element._shadow_oe_start._oe)

                    if not history_element._shadow_source_end is None:
                        optical_element_list_end.append(
                            history_element._shadow_source_end.src)
                    elif not history_element._shadow_oe_end is None:
                        optical_element_list_end.append(
                            history_element._shadow_oe_end._oe)

                    if not history_element._shadow_source_end is None:
                        try:
                            self.sourceInfo.append(
                                history_element._shadow_source_end.src.
                                sourcinfo())
                        except:
                            self.sourceInfo.append(
                                "Problem in calculating Source Info:\n" +
                                str(sys.exc_info()[0]) + ": " +
                                str(sys.exc_info()[1]))
                    elif not history_element._shadow_oe_end is None:
                        try:
                            if isinstance(history_element._shadow_oe_end._oe,
                                          CompoundOE):
                                self.mirInfo.append(
                                    history_element._shadow_oe_end._oe.mirinfo(
                                    ))
                            else:
                                self.mirInfo.append(
                                    history_element._shadow_oe_end._oe.mirinfo(
                                        title="O.E. #" +
                                        str(history_element._oe_number)))
                        except:
                            self.sourceInfo.append(
                                "Problem in calculating Mir Info for O.E. #:" +
                                str(history_element._oe_number) + "\n" +
                                str(sys.exc_info()[0]) + ": " +
                                str(sys.exc_info()[1]))

                coe_end = ShadowCompoundOpticalElement.create_compound_oe(
                    workspace_units_to_cm=self.workspace_units_to_cm)
                for oe in optical_element_list_end:
                    coe_end._oe.append(oe)

                try:
                    self.sysInfo.setText(coe_end._oe.sysinfo())
                except:
                    self.distancesSummary.setText(
                        "Problem in calculating SysInfo:\n" +
                        str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))

                try:
                    dic = coe_end._oe.syspositions()

                    self.sysPlotSide.addCurve(dic["optical_axis_y"],
                                              dic["optical_axis_z"],
                                              symbol='o',
                                              replace=True)
                    self.sysPlotSide.setGraphXLabel("Y [%s]" %
                                                    self.workspace_units_label)
                    self.sysPlotSide.setGraphYLabel("Z [%s]" %
                                                    self.workspace_units_label)
                    self.sysPlotSide.setGraphTitle("Side View of optical axis")
                    self.sysPlotSide.replot()

                    self.sysPlotTop.addCurve(dic["optical_axis_y"],
                                             dic["optical_axis_x"],
                                             symbol='o',
                                             replace=True)
                    self.sysPlotTop.setGraphXLabel("Y [%s]" %
                                                   self.workspace_units_label)
                    self.sysPlotTop.setGraphYLabel("X [%s]" %
                                                   self.workspace_units_label)
                    self.sysPlotTop.setGraphTitle("Top View of optical axis")
                    self.sysPlotTop.replot()

                except:
                    self.distancesSummary.setText(
                        "Problem in calculating SysPlot:\n" +
                        str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))

                try:
                    self.distancesSummary.setText(coe_end._oe.info())
                except:
                    self.distancesSummary.setText(
                        "Problem in calculating Distance Summary:\n" +
                        str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))

                try:
                    self.pythonScript.setText(
                        ST.make_python_script_from_list(
                            optical_element_list_start))
                except:
                    self.pythonScript.setText(
                        "Problem in writing python script:\n" +
                        str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))
            else:
                QtWidgets.QMessageBox.critical(
                    self, "Error",
                    "Data not displayable: No good rays or bad content",
                    QtWidgets.QMessageBox.Ok)
コード例 #4
0
ファイル: ow_info.py プロジェクト: lucarebuffi/ShadowOui
    def setBeam(self, beam):
        if ShadowCongruence.checkEmptyBeam(beam):
            if ShadowCongruence.checkGoodBeam(beam):
                sys.stdout = EmittingStream(textWritten=self.writeStdOut)

                self.input_beam = beam

                optical_element_list_start = []
                optical_element_list_end = []

                self.sysInfo.setText("")
                self.mirInfo.setText("")
                self.sourceInfo.setText("")
                self.distancesSummary.setText("")
                self.pythonScript.setText("")

                for history_element in self.input_beam.getOEHistory():
                    if not history_element._shadow_source_start is None:
                        optical_element_list_start.append(history_element._shadow_source_start.src)
                    elif not history_element._shadow_oe_start is None:
                        optical_element_list_start.append(history_element._shadow_oe_start._oe)

                    if not history_element._shadow_source_end is None:
                        optical_element_list_end.append(history_element._shadow_source_end.src)
                    elif not history_element._shadow_oe_end is None:
                        optical_element_list_end.append(history_element._shadow_oe_end._oe)


                    if not history_element._shadow_source_end is None:
                        try:
                            self.sourceInfo.append(history_element._shadow_source_end.src.sourcinfo())
                        except:
                            self.sourceInfo.append("Problem in calculating Source Info:\n" + str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))
                    elif not history_element._shadow_oe_end is None:
                        try:
                            if isinstance(history_element._shadow_oe_end._oe, CompoundOE):
                                self.mirInfo.append(history_element._shadow_oe_end._oe.mirinfo())
                            else:
                                self.mirInfo.append(history_element._shadow_oe_end._oe.mirinfo(title="O.E. #" + str(history_element._oe_number)))
                        except:
                            self.sourceInfo.append("Problem in calculating Mir Info for O.E. #:" + str(history_element._oe_number) + "\n" + str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))

                coe_end = ShadowCompoundOpticalElement.create_compound_oe(workspace_units_to_cm=self.workspace_units_to_cm)
                for oe in optical_element_list_end:
                    coe_end._oe.append(oe)

                try:
                    self.sysInfo.setText(coe_end._oe.sysinfo())
                except:
                    self.distancesSummary.setText("Problem in calculating SysInfo:\n" + str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))

                try:
                    self.distancesSummary.setText(coe_end._oe.info())
                except:
                    self.distancesSummary.setText("Problem in calculating Distance Summary:\n" + str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))

                try:
                    self.pythonScript.setText(ST.make_python_script_from_list(optical_element_list_start))
                except:
                    self.pythonScript.setText("Problem in writing python script:\n" + str(sys.exc_info()[0]) + ": " + str(sys.exc_info()[1]))
            else:
                QtGui.QMessageBox.critical(self, "Error",
                                           "Data not displayable: No good rays or bad content",
                                           QtGui.QMessageBox.Ok)