def __init__(self, settings, database): QWidget.__init__(self) last_files_list = LastFilesList(settings) self.settings = settings self.database = database self.ui = Ui_HomePage() self.ui.setupUi(self) self.toolbar = QToolBar() welcome_text = "{} {}".format(QApplication.instance().applicationName(), QApplication.instance().applicationVersion()) self.ui.welcome_label.setText(self.ui.welcome_label.text().format(welcome_text)) file_action = QtCommons.addToolbarPopup(self.toolbar, 'File', icon_file=':/file_20') project_action = QtCommons.addToolbarPopup(self.toolbar, 'Project', icon_file=':/project_20') #file_action.menu().addAction(QIcon(':/stack_20'), 'Stack Images', lambda: open_file_sticky('Open Reference FITS Image',FITS_IMG_EXTS, lambda f: self.stack_images.emit(f[0]), settings, IMPORT_IMG )) import_image_action = lambda: ImportImage.pick(lambda f: self.import_image.emit(f[0]), settings) file_action.menu().addAction(ImportImage.icon(), ImportImage.ACTION_TEXT, import_image_action) self.ui.import_image.clicked.connect(import_image_action) file_action.menu().addAction(QIcon(':/plot_20'), 'Calibrate Spectrum', lambda: open_file_sticky('Open raw FITS Spectrum',FITS_EXTS, lambda f: self.calibrate.emit(f[0]), settings, RAW_PROFILE, [IMPORT_IMG] )) file_action.menu().addAction(QIcon(':/math_20'), 'Spectra Math', lambda: self.math.emit(None) ) file_action.menu().addAction(QIcon(':/done_20'), 'Finish Spectrum', lambda: open_file_sticky('Open FITS Spectrum',FITS_EXTS, lambda f: self.finish.emit(f[0]), settings, CALIBRATED_PROFILE, [RAW_PROFILE,IMPORT_IMG] )) project_action.menu().addAction(QIcon(':/project_new_20'), 'New', lambda: self.new_project.emit()) pick_project = lambda: open_directory_sticky('Open Project', self.__project_picked, settings, PROJECTS) self.ui.pick_project.clicked.connect(pick_project) project_action.menu().addAction(QIcon(':/new_open_20'), 'Open...', pick_project) self.recent_raw_model = QStandardItemModel() self.recent_calibrated_model = QStandardItemModel() self.recent_projects_model = QStandardItemModel() self.ui.recent_raw_list.setModel(self.recent_raw_model) self.ui.recent_calibrated_list.setModel(self.recent_calibrated_model) self.ui.recent_projects.setModel(self.recent_projects_model) for widget in [self.ui.recent_raw_list, self.ui.recent_calibrated_list, self.ui.recent_projects]: widget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) LastFilesList.instance().files_changed.connect(self.__populate_lists) selected_path = lambda model, view: model.item(view.selectionModel().selectedRows()[0].row()).data() button_enable = lambda view, button: view.selectionModel().selectionChanged.connect(lambda sel, desel: button.setEnabled(len(sel.indexes() )) ) button_enable(self.ui.recent_raw_list, self.ui.calibrate) button_enable(self.ui.recent_calibrated_list, self.ui.math) button_enable(self.ui.recent_calibrated_list, self.ui.finish) button_enable(self.ui.recent_projects, self.ui.open_recent_project) self.ui.calibrate.clicked.connect(lambda: self.calibrate.emit(selected_path(self.recent_raw_model, self.ui.recent_raw_list))) self.ui.math.clicked.connect(lambda: self.math.emit(selected_path(self.recent_calibrated_model, self.ui.recent_calibrated_list))) self.ui.finish.clicked.connect(lambda: self.finish.emit(selected_path(self.recent_calibrated_model, self.ui.recent_calibrated_list))) self.ui.open_recent_project.clicked.connect(lambda: self.open_project.emit(selected_path(self.recent_projects_model, self.ui.recent_projects))) self.ui.new_project.clicked.connect(self.new_project.emit) self.reference_catalogues = ReferenceCatalogues(database) self.ui.download_catalogs.clicked.connect(self.download_catalogs) self.__populate_lists()
def __init__(self, settings, database, project=None): super(PlotsMath, self).__init__() self.ui = Ui_PlotsMath() self.ui.setupUi(self) self.settings = settings self.project=project self.plot = QtCommons.nestWidget(self.ui.plot, QMathPlotWidget()) self.reference_dialog = ReferenceSpectraDialog(database) self.reference_dialog.fits_picked.connect(self.open_fits) self.toolbar = QToolBar('Instrument Response Toolbar') open_btn = QtCommons.addToolbarPopup(self.toolbar, text="Open...", icon_file=':/new_open_20') open_file_action = open_btn.menu().addAction('FITS file') open_btn.menu().addAction('Reference library', self.reference_dialog.show) self.blackbody_menu = blackbody.BlackBodyAction(self.blackbody, open_btn.menu()) if project: save_result = QtCommons.addToolbarPopup(self.toolbar, text='Save', icon_file=':/save_20') save_result.menu().addAction('As File', lambda: QtCommons.save_file('Save Operation Result...', FITS_EXTS, lambda f: self.save(f[0]), project.path)) save_result.menu().addAction('As Instrument Response', self.save_project_instrument_response) open_file_action.triggered.connect(lambda: QtCommons.open_file('Open FITS Spectrum',FITS_EXTS, lambda f: self.open_fits(f[0]), project.path)) else: open_file_action.triggered.connect(lambda: open_file_sticky('Open FITS Spectrum',FITS_EXTS, lambda f: self.open_fits(f[0]), self.settings, CALIBRATED_PROFILE, [RAW_PROFILE])) self.toolbar.addAction(QIcon(':/save_20'), 'Save', lambda: save_file_sticky('Save Operation Result...', 'FITS file (.fit)', lambda f: self.save(f[0]), self.settings, MATH_OPERATION, [CALIBRATED_PROFILE])) self.toolbar.addAction('Set operand', self.set_operand) self.toolbar.addSeparator() self.toolbar.addAction(self.ui.actionZoom) self.ui.actionZoom.triggered.connect(self.start_zoom) self.toolbar.addAction(self.ui.actionReset_Zoom) self.ui.actionReset_Zoom.triggered.connect(self.reset_zoom) self.toolbar.addSeparator() self.operands_model = QStandardItemModel() self.ui.operands_listview.setModel(self.operands_model) remove_btn = QtCommons.addToolbarPopup(self.toolbar, text='Remove...') remove_btn.menu().addAction(self.ui.actionSelectPointsToRemove) remove_btn.menu().addAction("Before point", lambda: spectrum_trim_dialog(self.spectrum, 'before', self.plot.axes, lambda: self.draw(), self, before_removal=self.undo.save_undo)) remove_btn.menu().addAction("After point", lambda: spectrum_trim_dialog(self.spectrum, 'after', self.plot.axes, lambda: self.draw(), self, before_removal=self.undo.save_undo)) self.ui.clear_operands.clicked.connect(self.operands_model.clear) self.ui.remove_operand.clicked.connect(lambda: self.operands_model.removeRows(self.ui.operands_listview.selectionModel().selectedRows()[0].row(), 1)) self.operands_model.rowsInserted.connect(lambda: self.ui.clear_operands.setEnabled(self.operands_model.rowCount() > 0) ) self.operands_model.rowsRemoved.connect(lambda: self.ui.clear_operands.setEnabled(self.operands_model.rowCount() > 0) ) self.ui.operands_listview.selectionModel().selectionChanged.connect(lambda s, u: self.ui.remove_operand.setEnabled(len(s))) self.ui.actionSelectPointsToRemove.triggered.connect(self.pick_rm_points) self.undo = Undo(None, self.draw) self.undo.add_actions(self.toolbar) self.ui.spline_factor.valueChanged.connect(self.factor_valueChanged) self.ui.spline_degrees.valueChanged.connect(lambda v: self.draw()) self.ui.spline_factor_auto.toggled.connect(lambda v: self.draw()) self.ui.spline_factor_auto.toggled.connect(lambda v: self.ui.spline_factor.setEnabled(not v)) self.ui.execute.clicked.connect(self.execute_operation) self.plot.figure.tight_layout()
def __init__(self): Instances.MainWindow = self font = QApplication.instance().font() rc('font', **{'family':'serif','serif':[font.defaultFamily()]}) super(PySpectrumMainWindow, self).__init__() self.ui = Ui_PySpectrumMainWindow() self.database = sqlite3.connect(os.path.join('data', 'pyspectrum.db')) self.ui.setupUi(self) self.settings = QSettings("GuLinux", "PySpectrum") self.homepage = HomePage(self.settings, self.database) self.ui.stackedWidget.addWidget(self.homepage) self.windows_menu = QtCommons.addToolbarPopup(self.ui.toolBar, 'Windows', icon_file=':/bullet_list_20') self.actionClose = self.ui.toolBar.addAction(QIcon(':/close_20'), "Close") self.actionClose.setEnabled(False) self.actionClose.triggered.connect(self.close_widget) self.homepage.import_image.connect(self.open_image) self.homepage.calibrate.connect(self.calibrate) self.homepage.math.connect(self.plots_math) self.homepage.finish.connect(self.finish_spectrum) self.homepage.new_project.connect(self.__new_project) self.homepage.stack_images.connect(self.__stack_images) self.homepage.open_project.connect(self.__open_project) self.ui.stackedWidget.currentChanged.connect(self.current_changed) self.current_widget_toolbar = None self.restoreGeometry(self.settings.value('window_geometry', QByteArray())) self.widgets = [(self.homepage, "Home")] self.current_changed(self.ui.stackedWidget.indexOf(self.homepage)) def action_checked(actions, action): for a in actions: a.setChecked(a == action) self.windows_menu.menu().triggered.connect(lambda a: action_checked(self.windows_menu.menu().actions(), a)) self.__rebuild_windows_menu()
def __init__(self): Instances.MainWindow = self font = QApplication.instance().font() rc('font', **{'family': 'serif', 'serif': [font.defaultFamily()]}) super(PySpectrumMainWindow, self).__init__() self.ui = Ui_PySpectrumMainWindow() self.database = sqlite3.connect(os.path.join('data', 'pyspectrum.db')) self.ui.setupUi(self) self.settings = QSettings("GuLinux", "PySpectrum") self.homepage = HomePage(self.settings, self.database) self.ui.stackedWidget.addWidget(self.homepage) self.windows_menu = QtCommons.addToolbarPopup( self.ui.toolBar, 'Windows', icon_file=':/bullet_list_20') self.actionClose = self.ui.toolBar.addAction(QIcon(':/close_20'), "Close") self.actionClose.setEnabled(False) self.actionClose.triggered.connect(self.close_widget) self.homepage.import_image.connect(self.open_image) self.homepage.calibrate.connect(self.calibrate) self.homepage.math.connect(self.plots_math) self.homepage.finish.connect(self.finish_spectrum) self.homepage.new_project.connect(self.__new_project) self.homepage.stack_images.connect(self.__stack_images) self.homepage.open_project.connect(self.__open_project) self.ui.stackedWidget.currentChanged.connect(self.current_changed) self.current_widget_toolbar = None self.restoreGeometry( self.settings.value('window_geometry', QByteArray())) self.widgets = [(self.homepage, "Home")] self.current_changed(self.ui.stackedWidget.indexOf(self.homepage)) def action_checked(actions, action): for a in actions: a.setChecked(a == action) self.windows_menu.menu().triggered.connect( lambda a: action_checked(self.windows_menu.menu().actions(), a)) self.__rebuild_windows_menu()
def __init__(self, settings, database): QWidget.__init__(self) last_files_list = LastFilesList(settings) self.settings = settings self.database = database self.ui = Ui_HomePage() self.ui.setupUi(self) self.toolbar = QToolBar() welcome_text = "{} {}".format( QApplication.instance().applicationName(), QApplication.instance().applicationVersion()) self.ui.welcome_label.setText( self.ui.welcome_label.text().format(welcome_text)) file_action = QtCommons.addToolbarPopup(self.toolbar, 'File', icon_file=':/file_20') project_action = QtCommons.addToolbarPopup(self.toolbar, 'Project', icon_file=':/project_20') #file_action.menu().addAction(QIcon(':/stack_20'), 'Stack Images', lambda: open_file_sticky('Open Reference FITS Image',FITS_IMG_EXTS, lambda f: self.stack_images.emit(f[0]), settings, IMPORT_IMG )) import_image_action = lambda: ImportImage.pick( lambda f: self.import_image.emit(f[0]), settings) file_action.menu().addAction(ImportImage.icon(), ImportImage.ACTION_TEXT, import_image_action) self.ui.import_image.clicked.connect(import_image_action) file_action.menu().addAction( QIcon(':/plot_20'), 'Calibrate Spectrum', lambda: open_file_sticky( 'Open raw FITS Spectrum', FITS_EXTS, lambda f: self.calibrate. emit(f[0]), settings, RAW_PROFILE, [IMPORT_IMG])) file_action.menu().addAction(QIcon(':/math_20'), 'Spectra Math', lambda: self.math.emit(None)) file_action.menu().addAction( QIcon(':/done_20'), 'Finish Spectrum', lambda: open_file_sticky( 'Open FITS Spectrum', FITS_EXTS, lambda f: self.finish.emit(f[ 0]), settings, CALIBRATED_PROFILE, [RAW_PROFILE, IMPORT_IMG])) project_action.menu().addAction(QIcon(':/project_new_20'), 'New', lambda: self.new_project.emit()) pick_project = lambda: open_directory_sticky( 'Open Project', self.__project_picked, settings, PROJECTS) self.ui.pick_project.clicked.connect(pick_project) project_action.menu().addAction(QIcon(':/new_open_20'), 'Open...', pick_project) self.recent_raw_model = QStandardItemModel() self.recent_calibrated_model = QStandardItemModel() self.recent_projects_model = QStandardItemModel() self.ui.recent_raw_list.setModel(self.recent_raw_model) self.ui.recent_calibrated_list.setModel(self.recent_calibrated_model) self.ui.recent_projects.setModel(self.recent_projects_model) for widget in [ self.ui.recent_raw_list, self.ui.recent_calibrated_list, self.ui.recent_projects ]: widget.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) LastFilesList.instance().files_changed.connect(self.__populate_lists) selected_path = lambda model, view: model.item(view.selectionModel( ).selectedRows()[0].row()).data() button_enable = lambda view, button: view.selectionModel( ).selectionChanged.connect(lambda sel, desel: button.setEnabled( len(sel.indexes()))) button_enable(self.ui.recent_raw_list, self.ui.calibrate) button_enable(self.ui.recent_calibrated_list, self.ui.math) button_enable(self.ui.recent_calibrated_list, self.ui.finish) button_enable(self.ui.recent_projects, self.ui.open_recent_project) self.ui.calibrate.clicked.connect(lambda: self.calibrate.emit( selected_path(self.recent_raw_model, self.ui.recent_raw_list))) self.ui.math.clicked.connect(lambda: self.math.emit( selected_path(self.recent_calibrated_model, self.ui. recent_calibrated_list))) self.ui.finish.clicked.connect(lambda: self.finish.emit( selected_path(self.recent_calibrated_model, self.ui. recent_calibrated_list))) self.ui.open_recent_project.clicked.connect( lambda: self.open_project.emit( selected_path(self.recent_projects_model, self.ui. recent_projects))) self.ui.new_project.clicked.connect(self.new_project.emit) self.reference_catalogues = ReferenceCatalogues(database) self.ui.download_catalogs.clicked.connect(self.download_catalogs) self.__populate_lists()