def __init__(self, parent=None): super(ElementalAnalysisGui, self).__init__(parent) self.menu = self.menuBar() self.menu.addAction("File") edit_menu = self.menu.addMenu("Edit") edit_menu.addAction("Change Peak Data file", self.select_data_file) self.menu.addAction("Binning") self.menu.addAction("Normalise") self.ptable = PeriodicTablePresenter(PeriodicTableView(), PeriodicTableModel()) self.ptable.register_table_lclicked(self.table_left_clicked) self.ptable.register_table_rclicked(self.table_right_clicked) self.load_widget = LoadPresenter(LoadView(), LoadModel(), CoLoadModel()) self.load_widget.on_loading_finished(self.loading_finished) self.widget_list = QtGui.QVBoxLayout() self.detectors = DetectorsPresenter(DetectorsView()) for detector in self.detectors.detectors: detector.on_checkbox_checked(self.add_plot) detector.on_checkbox_unchecked(self.del_plot) self.peaks = PeaksPresenter(PeaksView()) self.peaks.major.on_checkbox_checked(self.major_peaks_checked) self.peaks.major.on_checkbox_unchecked(self.major_peaks_unchecked) self.peaks.minor.on_checkbox_checked(self.minor_peaks_checked) self.peaks.minor.on_checkbox_unchecked(self.minor_peaks_unchecked) self.peaks.gamma.on_checkbox_checked(self.gammas_checked) self.peaks.gamma.on_checkbox_unchecked(self.gammas_unchecked) self.peaks.electron.on_checkbox_checked(self.electrons_checked) self.peaks.electron.on_checkbox_unchecked(self.electrons_unchecked) self.widget_list.addWidget(self.peaks.view) self.widget_list.addWidget(self.detectors.view) self.widget_list.addWidget(self.load_widget.view) self.plotting = PlotPresenter(PlotView()) self.plotting.view.setMinimumSize(self.plotting.view.sizeHint()) self.box = QtGui.QHBoxLayout() self.box.addWidget(self.ptable.view) self.box.addLayout(self.widget_list) self.setCentralWidget(QtGui.QWidget(self)) self.centralWidget().setLayout(self.box) self.setWindowTitle("Elemental Analysis") self.element_widgets = {} self.element_data = {} self.element_lines = {} self.gamma_lines = [] self.gamma_peaks = self.ptable.peak_data["Gammas"] self.electron_peaks = self._get_electron_peaks() self.electron_lines = [] self._generate_element_widgets() self._generate_element_data() self.line_colours = cycle(["r", "g", "b", "c", "m", "y"])
def _correct_with_peak_data_file(): with open(PeriodicTableModel().get_default_peak_data_file(), 'r') as data_file: data = json.load(data_file) for i, element in enumerate(copy.deepcopy(_elements)): data_element = data.get(element[0], None) if data_element is not None and data_element['A'] is not None: if abs(data_element['A'] - element[5]) > 1e-6: if len(element) > 6: _elements[i] = (element[0], data_element['Z'], element[2], element[3], element[4], data_element['A'], element[6]) else: _elements[i] = (element[0], data_element['Z'], element[2], element[3], element[4], data_element['A'])
def __init__(self, parent=None): super(ElementalAnalysisGui, self).__init__(parent) self.menu = self.menuBar() self.menu.addAction("File") edit_menu = self.menu.addMenu("Edit") edit_menu.addAction("Change Peak Data file", self.select_data_file) self.menu.addAction("Binning") self.menu.addAction("Normalise") self.ptable = PeriodicTablePresenter(PeriodicTableView(), PeriodicTableModel()) self.ptable.register_table_changed(self.table_changed) self.ptable.register_table_lclicked(self.table_left_clicked) self.ptable.register_table_rclicked(self.table_right_clicked) self.load_widget = LoadPresenter(LoadView(), LoadModel(), CoLoadModel()) self.box = QtGui.QHBoxLayout() self.box.addWidget(self.ptable.view) self.box.addWidget(self.load_widget.view) self.setCentralWidget(QtGui.QWidget(self)) self.centralWidget().setLayout(self.box) self.setWindowTitle("Elemental Analysis")
def setUp(self): self.file_name = PeriodicTableModel().get_default_peak_data_file() with open(self.file_name, 'r') as _file: self.data = json.load(_file) self.el_names = [data[0] for data in _elements]
def setUp(self): self.model = PeriodicTableModel() self.model.load_peak_data = mock.Mock()
def __init__(self, parent=None): super(ElementalAnalysisGui, self).__init__(parent) # set menu self.menu = self.menuBar() self.menu.addAction("File") edit_menu = self.menu.addMenu("Edit") edit_menu.addAction("Change Peak Data file", self.select_data_file) self.menu.addAction("Binning") self.menu.addAction("Normalise") # periodic table stuff self.ptable = PeriodicTablePresenter(PeriodicTableView(), PeriodicTableModel()) self.ptable.register_table_lclicked(self.table_left_clicked) self.ptable.register_table_rclicked(self.table_right_clicked) # load stuff self.load_widget = LoadPresenter(LoadView(), LoadModel(), CoLoadModel()) self.load_widget.on_loading_finished(self.loading_finished) # detectors self.detectors = DetectorsPresenter(DetectorsView()) for detector in self.detectors.detectors: detector.on_checkbox_checked(self.add_plot) detector.on_checkbox_unchecked(self.del_plot) # peaks boxes self.peaks = PeaksPresenter(PeaksView()) self.peaks.major.setChecked(True) self.peaks.major.on_checkbox_checked(self.major_peaks_changed) self.peaks.major.on_checkbox_unchecked(self.major_peaks_changed) self.peaks.minor.on_checkbox_checked(self.minor_peaks_changed) self.peaks.minor.on_checkbox_unchecked(self.minor_peaks_changed) self.peaks.gamma.on_checkbox_checked(self.gammas_changed) self.peaks.gamma.on_checkbox_unchecked(self.gammas_changed) self.peaks.electron.on_checkbox_checked(self.electrons_changed) self.peaks.electron.on_checkbox_unchecked(self.electrons_changed) self.peaks.set_deselect_elements_slot(self.deselect_elements) # Line type boxes self.lines = LineSelectorPresenter(LineSelectorView()) self.lines.total.setChecked(True) self.lines.total.on_checkbox_checked(self.line_total_changed) self.lines.total.on_checkbox_unchecked(self.line_total_changed) self.lines.prompt.on_checkbox_checked(self.line_prompt_changed) self.lines.prompt.on_checkbox_unchecked(self.line_prompt_changed) self.lines.delayed.on_checkbox_checked(self.line_delayed_changed) self.lines.delayed.on_checkbox_unchecked(self.line_delayed_changed) # set up self.widget_list = QtWidgets.QVBoxLayout() self.widget_list.addWidget(self.peaks.view) self.widget_list.addWidget(self.lines.view) self.widget_list.addWidget(self.detectors.view) self.widget_list.addWidget(self.load_widget.view) # plotting self.plot_window = None self.num_colors = len(mpl.rcParams['axes.prop_cycle']) self.used_colors = {} # layout self.box = QtWidgets.QHBoxLayout() self.box.addWidget(self.ptable.view) self.box.addLayout(self.widget_list) self.setCentralWidget(QtWidgets.QWidget(self)) self.centralWidget().setLayout(self.box) self.setWindowTitle("Elemental Analysis") self.element_widgets = {} self.element_lines = {} self.electron_peaks = {} self._generate_element_widgets()