Source code for vdat.gui.mainwidget
# Virus Data Analysis Tool: a data reduction GUI for HETDEX/VIRUS data
# Copyright (C) 2016, 2017 "The HETDEX collaboration"
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Create the main central widget of the VDAT GUI
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from qtpy import QtCore, QtWidgets
from vdat.gui import treeview_model
from vdat.gui.central import VDATCentral
from vdat.gui.logger_widget import LoggerWidget
from vdat.gui.progress import VDATProgressBar
from vdat.gui.utils import run_wait_func_qthread
import vdat.config as vdatconfig
[docs]class VDATMainWidget(QtWidgets.QWidget):
'''Central widget containing the focal plane, splitter etc.
'''
sig_selectAllIFUs = QtCore.Signal()
sig_deselectAllIFUs = QtCore.Signal()
def __init__(self, parent=None):
super(VDATMainWidget, self).__init__(parent=parent)
[docs] def setup(self):
self.central = VDATCentral(parent=self)
self.tree_view = treeview_model.ReductionQTreeView(parent=self)
self.hsplit = QtWidgets.QSplitter(QtCore.Qt.Horizontal, parent=self)
self.hsplit.addWidget(self.tree_view)
self.hsplit.addWidget(self.central)
self.hsplit.setSizes([200, 500])
self.hsplit.setStretchFactor(self.hsplit.indexOf(self.central), 1)
self.hsplit.setStretchFactor(self.hsplit.indexOf(self.tree_view), 0)
self.tree_view.sig_selectionChanged.connect(self.central.change_target)
self.sig_selectAllIFUs.connect(self.central.selectAllIFUs)
self.sig_deselectAllIFUs.connect(self.central.deselectAllIFUs)
# create the log panel
self.log_panel = LoggerWidget(self)
# create the vertical split
self.vsplit = QtWidgets.QSplitter(QtCore.Qt.Vertical, parent=self)
# add the widgets to it
self.vsplit.addWidget(self.hsplit)
self.vsplit.addWidget(self.log_panel)
self.vsplit.setSizes([400, 100])
self.vsplit.setStretchFactor(self.vsplit.indexOf(self.hsplit), 1)
self.vsplit.setStretchFactor(self.vsplit.indexOf(self.log_panel), 0)
# create a vertical box layout, add the above vertical split and the
# progress bar; then add the layout to self
self.layout = QtWidgets.QVBoxLayout(self)
self.layout.setObjectName("main_layout")
self.layout.addWidget(self.vsplit)
# create the progress bar
self.prog_bar = VDATProgressBar(parent=self)
self.layout.addWidget(self.prog_bar)
# and the progress bar and put them into a
# Setup the main layout
self.setLayout(self.layout)
[docs] @QtCore.Slot()
def selectAllIFUs(self):
self.sig_selectAllIFUs.emit()
[docs] @QtCore.Slot()
def deselectAllIFUs(self):
self.sig_deselectAllIFUs.emit()
[docs] @QtCore.Slot()
def redoSymlink(self):
"""Redo the symlinking, create a new model, plug into the tree view and
trigger the redraw"""
run_wait_func_qthread(self._redo_symlink, parent=self, msecs=100)
self.tree_view.set_model()
self.central.change_target(None, None)
[docs] def _redo_symlink(self):
'''Function to execute in a thread when :meth:`redoSymlink` is
triggered'''
import vdat.libvdat.symlink as vsym
conf = vdatconfig.get_config('main')
# redo the symlinking
vsym.do_symlink(conf.get_list('general', 'rawdir'),
conf.get('general', 'redux_dir'))
vsym.db_create_references()