Пример #1
0
    def __init__(self, hardware, parameters, parent):
        QtGui.QDialog.__init__(self, parent)
        halModule.HalModule.__init__(self)
        self.channels = False
        self.exp_channels = False
        self.linear_channels = False
        self.file_channels = False
        self.parameters = parameters
        self.use_was_checked = False
        self.which_checked = []

        if parent:
            self.have_parent = 1
        else:
            self.have_parent = 0

        # UI setup
        self.ui = progressionUi.Ui_Dialog()
        self.ui.setupUi(self)
        self.setWindowTitle(
            parameters.get("setup_name") + " Progression Control")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # connect signals
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)
        self.ui.progressionsCheckBox.stateChanged.connect(self.handleProgCheck)
        self.ui.loadFileButton.clicked.connect(self.newPowerFile)

        # set modeless
        self.setModal(False)
Пример #2
0
    def __init__(self, hardware, parameters, parent):
        QtGui.QMainWindow.__init__(self, parent)
        halModule.HalModule.__init__(self)

        # Define default values
        self.x_offset = 0.0
        self.y_offset = 0.0
        self.x_amp = 1.0
        self.y_amp = 1.0
        self.x_freq = 1000.0  # In Hz
        self.y_freq = 1000.0  # In Hz
        self.running = False
        self.run_during_film = False

        self.home_voltage = [0.0, 0.0]

        self.output_limits = [-10.0, 10.0]
        self.sampleRate = 2500.0  # In Hz

        self.ni_task = False

        # Initialize waveform
        self.waveform = False

        # update parameters
        self.parameters = parameters

        if parent:
            self.have_parent = True
        else:
            self.have_parent = False

        # UI setup
        self.ui = galvoUi.Ui_Dialog()
        self.ui.setupUi(self)
        self.setWindowTitle(parameters.get("setup_name") + " Galvo Control")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # Connect signals.
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)

        self.ui.activateButton.setText("Run")
        self.ui.activateButton.clicked.connect(self.handleActivate)

        # set modeless
        self.setModal(False)

        # Update display
        self.updateDisplay()

        # Initialize to home voltage
        nicontrol.setAnalogLine("USB-6002", 0, self.home_voltage[0])
        nicontrol.setAnalogLine("USB-6002", 1, self.home_voltage[1])
Пример #3
0
    def __init__(self, parameters, parent = None):
        QtGui.QDialog.__init__(self, parent)
        halModule.HalModule.__init__(self)
        
        self.parameters = parameters

        if parent:
            self.have_parent = True
        else:
            self.have_parent = False

        self.setWindowIcon(qtAppIcon.QAppIcon())
Пример #4
0
    def __init__(self, hardware, parameters, parent=None):
        QtGui.QDialog.__init__(self, parent)
        halModule.HalModule.__init__(self)

        self.channels = []
        self.hardware_modules = {}
        self.fp = False
        self.parameters = parameters
        self.running_shutters = False
        self.spacing = 3

        if parent:
            self.have_parent = True
        else:
            self.have_parent = False

        # UI setup.
        self.ui = illuminationUi.Ui_Dialog()
        self.ui.setupUi(self)
        self.setWindowTitle(
            parameters.get("setup_name") + " Illumination Control")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # Parse XML that describes the hardware.
        hardware = xmlParser.parseHardwareXML("illumination/" +
                                              hardware.settings_xml)

        # Hardware modules setup.
        for module in hardware.modules:
            m_name = module.module_name
            a_module = __import__(m_name, globals(), locals(), [m_name], -1)
            a_class = getattr(a_module, module.class_name)
            a_instance = a_class(module.parameters, self)
            if a_instance.isBuffered():
                a_instance.start(QtCore.QThread.NormalPriority)
            self.hardware_modules[module.name] = a_instance

        # Illumination channels setup.
        x = 7
        for i, channel in enumerate(hardware.channels):
            a_instance = illuminationChannel.Channel(i, channel, parameters,
                                                     self.hardware_modules,
                                                     self.ui.powerControlBox)
            x += a_instance.setPosition(x, 14) + self.spacing
            self.channels.append(a_instance)

        # Connect signals.
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)
Пример #5
0
    def configureUI(self):
        parameters = self.parameters

        # UI setup
        self.setWindowTitle(parameters.get("setup_name") + " Focus Lock")
        self.setWindowIcon(qtAppIcon.QAppIcon())
        self.ui.lockLabel.setStyleSheet("QLabel { color: green }")
        self.toggleLockButtonDisplay(
            self.lock_display1.shouldDisplayLockButton())
        self.toggleLockLabelDisplay(
            self.lock_display1.shouldDisplayLockLabel())

        # Setup mode radio buttons.
        vbox_layout = QtGui.QVBoxLayout(self.ui.modeWidget)
        self.ui.modeWidget.setLayout(vbox_layout)
        lock_modes = self.lock_display1.getLockModes()
        self.buttons = []
        for i, mode in enumerate(lock_modes):
            button = QtGui.QRadioButton(mode.getName(), self.ui.modeWidget)
            vbox_layout.addWidget(button)
            self.buttons.append(button)

        self.buttons[parameters.get("qpd_mode")].setChecked(True)

        for button in self.buttons:
            button.clicked.connect(self.handleRadioButtons)

        # Connect signals
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)

        self.ui.lockButton.clicked.connect(self.handleLockButton)
        self.ui.jumpPButton.clicked.connect(self.handleJumpPButton)
        self.ui.jumpNButton.clicked.connect(self.handleJumpNButton)
        self.ui.jumpSpinBox.valueChanged.connect(self.handleJumpSpinBox)

        # set modeless
        self.setModal(False)
Пример #6
0
    def __init__(self, hardware, parameters, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        # General (alphabetically ordered)
        self.current_directory = False
        self.current_length = 0
        self.directory = False
        self.directory_test_mode = False
        self.filename = ""
        self.filming = False
        self.logfile_fp = open(parameters.get("film.logfile"), "a")
        self.modules = []
        self.old_shutters_file = ""
        self.parameters = parameters
        self.parameters_test_mode = False
        self.settings = QtCore.QSettings(
            "Zhuang Lab", "hal-4000_" + parameters.get("setup_name").lower())
        self.tcp_message = None
        self.tcp_requested_movie = False
        self.ui_mode = ""
        self.will_overwrite = False
        self.writer = False
        self.xml_directory = ""

        # Logfile setup
        self.logfile_fp.write("\r\n")
        self.logfile_fp.flush()

        setup_name = parameters.get("setup_name").lower()

        #
        # UI setup, this is one of:
        #
        # 1. single: single window (the classic look).
        # 2. detached: detached camera window.
        #
        self.ui_mode = hardware.ui_mode
        if (self.ui_mode == "single"):
            import qtdesigner.hal4000_ui as hal4000Ui
        elif (self.ui_mode == "detached"):
            import qtdesigner.hal4000_detached_ui as hal4000Ui
        else:
            print "unrecognized mode:", self.ui_mode
            print " mode should be either single or detached"
            exit()

        # Load the ui
        self.ui = hal4000Ui.Ui_MainWindow()
        self.ui.setupUi(self)

        title = self.parameters.get("setup_name")
        if (hgit.getBranch().lower() != "master"):
            title += " (" + hgit.getBranch() + ")"
        self.setWindowTitle(title)

        self.setWindowIcon(qtAppIcon.QAppIcon())

        self.parameters_box = qtParametersBox.QParametersBox(
            self.ui.settingsScrollArea)
        self.ui.settingsScrollArea.setWidget(self.parameters_box)
        self.ui.settingsScrollArea.setWidgetResizable(True)
        self.parameters_box.addParameters(self.parameters)

        file_types = writers.availableFileFormats(self.ui_mode)
        for type in file_types:
            self.ui.filetypeComboBox.addItem(type)

        self.ui.framesText.setText("")
        self.ui.sizeText.setText("")

        #
        # Camera control & signals.
        #
        self.camera = control.Camera(hardware.get("control"), parameters)
        self.camera.reachedMaxFrames.connect(self.stopFilm)
        self.camera.newFrames.connect(self.newFrames)

        #
        # Camera display.
        #
        if (self.ui_mode == "single"):
            n_cameras = 1
        else:
            n_cameras = self.camera.getNumberOfCameras()

        camera_displays = []
        for i in range(n_cameras):
            which_camera = "camera" + str(i + 1)
            camera_displays.append(
                cameraDisplay.CameraDisplay(self.ui, self.ui_mode,
                                            which_camera,
                                            hardware.get("display"),
                                            parameters, self))

        # This is the classic single-window HAL display. To work properly, the camera
        # controls UI elements that "belong" to the main window and vice-versa.
        if (self.ui_mode == "single"):
            self.ui.recordButton = camera_displays[0].getRecordButton()

        # Insert additional menu items for the camera display(s) as necessary
        else:
            for camera_display in camera_displays:
                a_action = QtGui.QAction(self.tr(camera_display.getMenuName()),
                                         self)
                self.ui.menuFile.insertAction(self.ui.actionQuit, a_action)
                a_action.triggered.connect(camera_display.show)

        # Camera display modules are also standard HAL modules.
        self.modules += camera_displays

        #
        # Other hardware control modules
        #

        # Load the requested modules.
        #
        add_separator = False
        for module in hardware.get("modules").getSubXMLObjects():
            hdebug.logText("Loading: " + module.get("hal_type"))
            a_module = halImport(module.get("module_name"))
            a_class = getattr(a_module, module.get("class_name"))
            instance = a_class(module.get("parameters", False), parameters,
                               self)
            instance.hal_type = module.get("hal_type")
            instance.hal_gui = module.get("hal_gui")
            if module.get("hal_gui"):
                add_separator = True
                a_action = QtGui.QAction(self.tr(module.get("menu_item")),
                                         self)
                self.ui.menuFile.insertAction(self.ui.actionQuit, a_action)
                a_action.triggered.connect(instance.show)
            self.modules.append(instance)

        # Insert a separator into the file menu if necessary.
        if add_separator:
            self.ui.menuFile.insertSeparator(self.ui.actionQuit)

        # Connect signals between modules, HAL and the camera.
        everything = self.modules + [self] + [self.camera]
        for from_module in everything:
            signals = from_module.getSignals()

            for to_module in everything:
                to_module.connectSignals(signals)

        # Finish module initialization
        everything = self.modules + [self.camera]
        for module in everything:
            module.moduleInit()

        #
        # More ui stuff
        #

        # handling file drops
        self.ui.centralwidget.__class__.dragEnterEvent = self.dragEnterEvent
        self.ui.centralwidget.__class__.dropEvent = self.dropEvent

        # ui signals
        self.ui.actionDirectory.triggered.connect(self.newDirectory)
        self.ui.actionSettings.triggered.connect(self.newSettingsFile)
        self.ui.actionShutter.triggered.connect(self.newShuttersFile)
        self.ui.actionQuit.triggered.connect(self.handleClose)
        self.ui.autoIncCheckBox.stateChanged.connect(self.handleAutoInc)
        self.ui.autoShuttersCheckBox.stateChanged.connect(
            self.handleAutoShutters)
        self.ui.extensionComboBox.currentIndexChanged.connect(
            self.updateFilenameLabel)
        self.ui.filenameEdit.textChanged.connect(self.updateFilenameLabel)
        self.ui.filetypeComboBox.currentIndexChanged.connect(
            self.updateFilenameLabel)
        self.ui.indexSpinBox.valueChanged.connect(self.updateFilenameLabel)
        self.ui.lengthSpinBox.valueChanged.connect(self.updateLength)
        self.ui.modeComboBox.currentIndexChanged.connect(
            self.handleModeComboBox)
        self.ui.notesEdit.textChanged.connect(self.updateNotes)
        self.ui.recordButton.clicked.connect(self.toggleFilm)

        # other signals
        self.parameters_box.settingsToggled.connect(self.toggleSettings)

        #
        # Load GUI settings
        #

        # HAL GUI settings.
        self.move(
            self.settings.value("main_pos", QtCore.QPoint(100, 100)).toPoint())
        self.resize(self.settings.value("main_size", self.size()).toSize())
        self.xml_directory = str(
            self.settings.value("xml_directory", "").toString())

        # Module GUI settings.
        for module in self.modules:
            module.loadGUISettings(self.settings)

        #
        # start the camera
        #
        self.camera.cameraInit()
Пример #7
0
    def __init__(self, hardware, parameters, parent):
        QtGui.QDialog.__init__(self, parent)
        halModule.HalModule.__init__(self)
        self.channels = False
        self.exp_channels = False
        self.linear_channels = False
        self.file_channels = False
        self.parameters = parameters
        self.use_was_checked = False
        self.which_checked = []

        # Add progression parameters.
        self.parameters.add(
            "progressions.use_progressions",
            params.ParameterSetBoolean("",
                                       "use_progressions",
                                       False,
                                       is_mutable=False))
        self.parameters.add(
            "progressions.pstart_value",
            params.ParameterRangeFloat("",
                                       "pstart_value",
                                       0.1,
                                       0.0,
                                       1.0,
                                       is_mutable=False,
                                       is_saved=False))
        self.parameters.add(
            "progressions.pinc_value",
            params.ParameterRangeFloat("",
                                       "pinc_value",
                                       0.01,
                                       0.0,
                                       1.0,
                                       is_mutable=False,
                                       is_saved=False))
        self.parameters.add(
            "progressions.pfile_name",
            params.ParameterStringFilename("Progression file name",
                                           "pfile_name", "", False))
        self.parameters.add(
            "progressions.pframe_value",
            params.ParameterRangeInt("",
                                     "pframe_value",
                                     1000,
                                     100,
                                     100000,
                                     is_mutable=False,
                                     is_saved=False))

        if parent:
            self.have_parent = 1
        else:
            self.have_parent = 0

        # UI setup
        self.ui = progressionUi.Ui_Dialog()
        self.ui.setupUi(self)
        self.setWindowTitle(
            parameters.get("setup_name") + " Progression Control")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # connect signals
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)
        self.ui.progressionsCheckBox.stateChanged.connect(self.handleProgCheck)
        self.ui.loadFileButton.clicked.connect(self.newPowerFile)

        # set modeless
        self.setModal(False)
Пример #8
0
    def __init__(self, parameters, parent=None):
        QtGui.QDialog.__init__(self, parent)
        halModule.HalModule.__init__(self)

        self.counters = [False, False]
        self.filming = 0
        self.filenames = [False, False]
        self.frame_interval = parameters.get("spotcounter.interval", 1)
        self.image_graphs = [False, False]
        self.parameters = parameters
        self.spot_counter = False
        self.spot_graphs = [False, False]

        if parent:
            self.have_parent = True
        else:
            self.have_parent = False

        # Add spot counter specific parameters.
        #
        # FIXME: We should just use a pixel length scale bar and drop the nm stuff, or
        #        we should get the nm_per_pixel from the mosaic settings and the current
        #        objective.
        #
        spotc_params = self.parameters.addSubSection("spotcounter")
        spotc_params.add(
            "cell_size",
            params.ParameterRangeInt("Cell size for background subtraction",
                                     "cell_size",
                                     32,
                                     8,
                                     128,
                                     is_mutable=False,
                                     is_saved=False))

        spotc_params.add(
            "max_spots",
            params.ParameterRangeInt(
                "Maximum counts for the spotcounter graph",
                "max_spots",
                500,
                0,
                1000,
                is_mutable=False,
                is_saved=False))

        spotc_params.add(
            "min_spots",
            params.ParameterRangeInt(
                "Minimum counts for the spotcounter graph",
                "min_spots",
                0,
                0,
                1000,
                is_mutable=False,
                is_saved=False))

        spotc_params.add(
            "nm_per_pixel",
            params.ParameterRangeFloat("Camera pixel size in nanometers",
                                       "nm_per_pixel", 160, 10, 1000))

        spotc_params.add(
            "scale_bar_len",
            params.ParameterRangeFloat("Scale bar length in nm",
                                       "scale_bar_len", 1000, 100, 10000))

        spotc_params.add(
            "threshold",
            params.ParameterRangeInt(
                "Spot detection threshold (camera counts)", "threshold", 250,
                1, 10000))

        # UI setup.
        self.ui.setupUi(self)
        self.setWindowTitle(parameters.get("setup_name") + " Spot Counter")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # Setup Counter objects.
        if (self.number_cameras == 1):
            self.counters = [
                Counter(self.ui.countsLabel1, self.ui.countsLabel2)
            ]
        else:
            self.counters = [
                Counter(self.ui.countsLabel1, self.ui.countsLabel2),
                Counter(self.ui.countsLabel3, self.ui.countsLabel4)
            ]

        # Setup spot counter.
        self.spot_counter = qtSpotCounter.QObjectCounter(
            parameters.get("spotcounter"))
        self.spot_counter.imageProcessed.connect(self.updateCounts)

        # Setup spot counts graph(s).
        if (self.number_cameras == 1):
            parents = [self.ui.graphFrame]
        else:
            parents = [self.ui.graphFrame, self.ui.graphFrame2]

        for i in range(self.number_cameras):
            graph_w = parents[i].width() - 4
            graph_h = parents[i].height() - 4
            self.spot_graphs[i] = QSpotGraph(
                graph_w,
                graph_h,
                parameters.get("spotcounter.min_spots"),
                parameters.get("spotcounter.max_spots"),
                parent=parents[i])
            self.spot_graphs[i].setGeometry(2, 2, graph_w, graph_h)
            self.spot_graphs[i].show()

        # Setup STORM image(s).
        if (self.number_cameras == 1):
            parents = [self.ui.imageFrame]
        else:
            parents = [self.ui.imageFrame, self.ui.imageFrame2]

        for i in range(self.number_cameras):
            image_w = parents[i].width() - 4
            image_h = parents[i].height() - 4

            self.image_graphs[i] = QImageGraph(image_w,
                                               image_h,
                                               parent=parents[i])
            self.image_graphs[i].setGeometry(2, 2, image_w, image_h)
            self.image_graphs[i].blank()
            self.image_graphs[i].show()

        # Connect signals.
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)
        self.ui.maxSpinBox.valueChanged.connect(self.handleMaxChange)
        self.ui.minSpinBox.valueChanged.connect(self.handleMinChange)

        # Set modeless.
        self.setModal(False)
Пример #9
0
    def __init__(self, hardware, parameters, parent=None):
        QtGui.QDialog.__init__(self, parent)
        halModule.HalModule.__init__(self)

        self.channels = []
        self.hardware_modules = {}
        self.fp = False
        self.parameters = parameters
        self.running_shutters = False
        self.spacing = 3

        if parent:
            self.have_parent = True
        else:
            self.have_parent = False

        # UI setup.
        self.ui = illuminationUi.Ui_Dialog()
        self.ui.setupUi(self)
        self.setWindowTitle(
            parameters.get("setup_name") + " Illumination Control")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # Parse XML that describes the hardware.
        hardware = xmlParser.parseHardwareXML("illumination/" +
                                              hardware.get("settings_xml"))

        # Add illumination specific settings.
        #
        # FIXME: These used to be customizable.
        #
        default_power = []
        on_off_state = []
        for i in range(len(hardware.channels)):
            default_power.append(1.0)
            on_off_state.append(False)
        self.parameters.set("illumination.default_power", default_power)
        self.parameters.set("illumination.on_off_state", on_off_state)

        # Check for button settings, use defaults if they do not exist.
        #
        buttons = []
        for i in range(len(hardware.channels)):
            buttons.append([["Max", 1.0], ["Low", 0.1]])
        power_buttons = params.ParameterCustom("Illumination power buttons",
                                               "power_buttons",
                                               buttons,
                                               1,
                                               is_mutable=True,
                                               is_saved=True)
        power_buttons.editor = buttonEditor.ParametersTablePowerButtonEditor
        self.parameters.add("illumination.power_buttons", power_buttons)

        # This parameter is used to be able to tell when the shutters file
        # has been changed for a given set of parameters.
        self.parameters.add(
            "illumination.last_shutters",
            params.ParameterString("Last shutters file name",
                                   "last_shutters",
                                   "",
                                   is_mutable=False,
                                   is_saved=False))

        # Default camera parameters.
        self.parameters.add(
            "illumination.shutters",
            params.ParameterStringFilename("Shutters file name", "shutters",
                                           "shutters_default.xml", False))

        # Hardware modules setup.
        for module in hardware.modules:
            m_name = module.module_name
            a_module = __import__(m_name, globals(), locals(), [m_name], -1)
            a_class = getattr(a_module, module.class_name)
            a_instance = a_class(module.parameters, self)
            if a_instance.isBuffered():
                a_instance.start(QtCore.QThread.NormalPriority)
            self.hardware_modules[module.name] = a_instance

        # Illumination channels setup.
        x = 7
        names = []
        for i, channel in enumerate(hardware.channels):
            a_instance = illuminationChannel.Channel(
                i, channel, parameters.get("illumination"),
                self.hardware_modules, self.ui.powerControlBox)
            x += a_instance.setPosition(x, 14) + self.spacing
            self.channels.append(a_instance)
            names.append(a_instance.getName())

        power_buttons.channel_names = names

        # Connect signals.
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)
Пример #10
0
    def __init__(self, hardware, parameters, parent = None):
        QtGui.QMainWindow.__init__(self, parent)

        # General (alphabetically ordered)
        self.current_directory = False
        self.current_length = 0
        self.directory = False
        self.directory_test_mode = False
        self.filename = ""
        self.filming = False
        self.logfile_fp = open(parameters.get("logfile"), "a")
        self.modules = []
        self.old_shutters_file = ""
        self.parameters = parameters
        self.parameters_test_mode = False
        self.settings = QtCore.QSettings("Zhuang Lab", "hal-4000_" + parameters.get("setup_name").lower())
        self.tcp_message = None
        self.tcp_requested_movie = False
        self.ui_mode = ""
        self.will_overwrite = False
        self.writer = False
        self.xml_directory = ""

        # Logfile setup
        self.logfile_fp.write("\r\n")
        self.logfile_fp.flush()

        
        setup_name = parameters.get("setup_name").lower()

        #
        # Load the camera module
        #
        # The camera module defines (to some extent) what the HAL UI
        # will look like.
        #
        the_camera = halImport('camera.' + hardware.camera.module)
        self.ui_mode = the_camera.getMode()

        #
        # UI setup, this is one of:
        #
        # 1. single: single window, single camera
        # 2. detached: detached camera window, single camera
        # 3. dual: detached camera windows, dual camera
        #
        if (self.ui_mode == "single"):
            import qtdesigner.hal4000_ui as hal4000Ui
        elif (self.ui_mode == "detached"):
            import qtdesigner.hal4000_detached_ui as hal4000Ui
        elif (self.ui_mode == "dual"):
            import qtdesigner.hal4000_detached_ui as hal4000Ui
        else:
            print "unrecognized mode:", self.ui_mode
            print " mode should be one of: single, detached or dual"
            exit()

        # Load the ui
        self.ui = hal4000Ui.Ui_MainWindow()
        self.ui.setupUi(self)
        
        title = self.parameters.get("setup_name")
        if (title.lower() != hgit.getBranch().lower()):
            title += " (" + hgit.getBranch() + ")"
        self.setWindowTitle(title)

        self.setWindowIcon(qtAppIcon.QAppIcon())

        self.parameters_box = qtParametersBox.QParametersBox(self.ui.settingsScrollArea)
        self.ui.settingsScrollArea.setWidget(self.parameters_box)
        self.ui.settingsScrollArea.setWidgetResizable(True)
        self.parameters_box.addParameters(self.parameters)

        file_types = writers.availableFileFormats(self.ui_mode)
        for type in file_types:
            self.ui.filetypeComboBox.addItem(type)

        #
        # Camera
        #

        # This is the classic single-window HAL display. To work properly, the camera 
        # controls UI elements that "belong" to the main window and vice-versa.
        if (self.ui_mode == "single"):
            self.camera = the_camera.ACamera(hardware.camera.parameters,
                                             parameters,
                                             self.ui.cameraFrame,
                                             self.ui.cameraParamsFrame,
                                             parent = self)
            self.ui.recordButton = self.camera.getRecordButton()

        # Both detached and dual-modes have the proper separation of UI elements
        else:
            self.camera = the_camera.ACamera(hardware.camera.parameters,
                                             parameters,
                                             parent = self)

        # Insert additional menu items for the camera(s) as necessary
        if (self.ui_mode == "detached"):
            self.ui.actionCamera1 = QtGui.QAction(self.tr("Camera"), self)
            self.ui.menuFile.insertAction(self.ui.actionQuit, self.ui.actionCamera1)
            self.ui.actionCamera1.triggered.connect(self.camera.showCamera1)
        elif (self.ui_mode == "dual"):
            self.ui.actionCamera1 = QtGui.QAction(self.tr("Camera1"), self)
            self.ui.menuFile.insertAction(self.ui.actionQuit, self.ui.actionCamera1)
            self.ui.actionCamera1.triggered.connect(self.camera.showCamera1)

            self.ui.actionCamera2 = QtGui.QAction(self.tr("Camera2"), self)
            self.ui.menuFile.insertAction(self.ui.actionQuit, self.ui.actionCamera2)
            self.ui.actionCamera2.triggered.connect(self.camera.showCamera2)

        # camera signals
        self.camera.reachedMaxFrames.connect(self.stopFilm)
        self.camera.newFrames.connect(self.newFrames)

        #
        # Hardware control modules
        #

        # Load the requested modules.
        add_separator = False
        for module in hardware.modules:
            hdebug.logText("Loading: " + module.hal_type)
            a_module = halImport(module.module_name)
            a_class = getattr(a_module, module.class_name)
            instance = a_class(module.parameters, parameters, self)
            instance.hal_type = module.hal_type
            instance.hal_gui = module.hal_gui
            if module.hal_gui:
                add_separator = True
                a_action = QtGui.QAction(self.tr(module.menu_item), self)
                self.ui.menuFile.insertAction(self.ui.actionQuit, a_action)
                a_action.triggered.connect(instance.show)
            self.modules.append(instance)

        # Insert a separator into the file menu if necessary.
        if add_separator:
            self.ui.menuFile.insertSeparator(self.ui.actionQuit)

        # Connect signals between modules, HAL and the camera.
        everything = self.modules + [self] + [self.camera]
        for from_module in everything:
            signals = from_module.getSignals()

            for to_module in everything:
                to_module.connectSignals(signals)

        # Finish module initialization
        for module in self.modules:
            module.moduleInit()

        #
        # More ui stuff
        #

        # handling file drops
        self.ui.centralwidget.__class__.dragEnterEvent = self.dragEnterEvent
        self.ui.centralwidget.__class__.dropEvent = self.dropEvent

        # ui signals
        self.ui.actionDirectory.triggered.connect(self.newDirectory)
        self.ui.actionSettings.triggered.connect(self.newSettingsFile)
        self.ui.actionShutter.triggered.connect(self.newShuttersFile)
        self.ui.actionQuit.triggered.connect(self.handleClose)
        self.ui.autoIncCheckBox.stateChanged.connect(self.handleAutoInc)
        self.ui.autoShuttersCheckBox.stateChanged.connect(self.handleAutoShutters)
        self.ui.extensionComboBox.currentIndexChanged.connect(self.updateFilenameLabel)
        self.ui.filenameEdit.textChanged.connect(self.updateFilenameLabel)
        self.ui.filetypeComboBox.currentIndexChanged.connect(self.updateFilenameLabel)
        self.ui.indexSpinBox.valueChanged.connect(self.updateFilenameLabel)
        self.ui.lengthSpinBox.valueChanged.connect(self.updateLength)
        self.ui.modeComboBox.currentIndexChanged.connect(self.handleModeComboBox)
        self.ui.notesEdit.textChanged.connect(self.updateNotes)
        self.ui.recordButton.clicked.connect(self.toggleFilm)

        # other signals
        self.parameters_box.settingsToggled.connect(self.toggleSettings)

        #
        # Load GUI settings
        #

        # HAL GUI settings.
        self.gui_settings = []
        self.move(self.settings.value("main_pos", QtCore.QPoint(100, 100)).toPoint())
        self.xml_directory = str(self.settings.value("xml_directory", "").toString())

        if (self.ui_mode == "single"):
            self.resize(self.settings.value("main_size", self.size()).toSize())

        elif (self.ui_mode == "detached"):
            self.camera.resize(self.settings.value("camera_size", self.camera.size()).toSize())
            self.gui_settings.append([self.camera, "camera1"])

        elif (self.ui_mode == "dual"):
            self.camera.camera1.resize(self.settings.value("camera1_size", self.camera.camera1.size()).toSize())
            self.camera.camera2.resize(self.settings.value("camera2_size", self.camera.camera2.size()).toSize())
            self.gui_settings.append([self.camera.camera1, "camera1"])
            self.gui_settings.append([self.camera.camera2, "camera2"])

        for [an_object, name] in self.gui_settings:
            if an_object:
                an_object.move(self.settings.value(name + "_pos", QtCore.QPoint(200, 200)).toPoint())
                if self.settings.value(name + "_visible", False).toBool():
                    an_object.show()

        # Module GUI settings.
        for module in self.modules:
            module.loadGUISettings(self.settings)

        #
        # start the camera
        #
        self.camera.cameraInit()
Пример #11
0
    def __init__(self, parameters, parent):
        QtGui.QMainWindow.__init__(self, parent)
        halModule.HalModule.__init__(self)
        #self.setFocusPolicy(QtCore.Qt.ClickFocus)

        self.directory = ""
        self.drag_start_x = 0
        self.drag_start_y = 0
        self.move_timer = QtCore.QTimer()
        self.stage_speed = parameters.get("stage_speed")
        self.stage_x = 0
        self.stage_y = 0
        self.stage_z = 0
        self.tcp_message = False
        self.translator = Translator()

        if parent:
            self.have_parent = True
        else:
            self.have_parent = False

        # UI setup
        self.ui = stageUi.Ui_Dialog()
        self.ui.setupUi(self)
        self.setWindowTitle(parameters.get("setup_name") + " Stage Control")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # UI motion buttons.
        icon_path = "./icons/"
        self.motion_buttons = [MotionButton(self.ui.leftSButton, icon_path + "1leftarrow-128.png", "small", 1, 0),
                               MotionButton(self.ui.leftLButton, icon_path + "2leftarrow-128.png", "large", 1, 0),
                               MotionButton(self.ui.rightSButton, icon_path + "1rightarrow-128.png", "small", -1, 0),
                               MotionButton(self.ui.rightLButton, icon_path + "2rightarrow-128.png", "large", -1, 0),
                               MotionButton(self.ui.upSButton, icon_path + "1uparrow-128.png", "small", 0, 1),
                               MotionButton(self.ui.upLButton, icon_path + "2uparrow-128.png", "large", 0, 1),
                               MotionButton(self.ui.downSButton, icon_path + "1downarrow1-128.png", "small", 0, -1),
                               MotionButton(self.ui.downLButton,  icon_path + "2dowarrow-128.png", "large", 0, -1)]

        for button in self.motion_buttons:
            button.buttonClicked.connect(self.moveRelative)

        # Configure timer.
        self.move_timer.setSingleShot(True)
        self.move_timer.timeout.connect(self.handleMoveTimer)

        # Connect signals.
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)

        self.ui.addButton.clicked.connect(self.handleAdd)
        self.ui.clearButton.clicked.connect(self.handleClear)
        self.ui.goButton.clicked.connect(self.handleGo)
        self.ui.homeButton.clicked.connect(self.handleHome)
        self.ui.loadButton.clicked.connect(self.handleLoad)
        self.ui.saveButton.clicked.connect(self.handleSave)
        self.ui.saveComboBox.activated.connect(self.handleSaveIndexChange)
        self.ui.zeroButton.clicked.connect(self.zero)

        # set modeless
        self.setModal(False)

        # open connection to the stage
        if not(self.stage.getStatus()):
            print "Failed to connect to the microscope stage. Perhaps it is turned off?"
            self.stage.shutDown()
            self.stage = False
        else:
            self.stage.updatePosition.connect(self.handleUpdatePosition)
            self.stage.setVelocity(parameters.get("stage_speed"), parameters.get("stage_speed"))
Пример #12
0
    def __init__(self, parameters, parent=None):
        QtGui.QDialog.__init__(self, parent)
        halModule.HalModule.__init__(self)

        self.counters = [False, False]
        self.filming = 0
        self.filenames = [False, False]
        self.frame_interval = parameters.get("spotcounter.interval", 1)
        self.image_graphs = [False, False]
        self.parameters = parameters
        self.spot_counter = False
        self.spot_graphs = [False, False]

        if parent:
            self.have_parent = True
        else:
            self.have_parent = False

        # UI setup.
        self.ui.setupUi(self)
        self.setWindowTitle(parameters.get("setup_name") + " Spot Counter")
        self.setWindowIcon(qtAppIcon.QAppIcon())

        # Setup Counter objects.
        if (self.number_cameras == 1):
            self.counters = [
                Counter(self.ui.countsLabel1, self.ui.countsLabel2)
            ]
        else:
            self.counters = [
                Counter(self.ui.countsLabel1, self.ui.countsLabel2),
                Counter(self.ui.countsLabel3, self.ui.countsLabel4)
            ]

        # Setup spot counter.
        self.spot_counter = qtSpotCounter.QObjectCounter(
            parameters.get("spotcounter"))
        self.spot_counter.imageProcessed.connect(self.updateCounts)

        # Setup spot counts graph(s).
        if (self.number_cameras == 1):
            parents = [self.ui.graphFrame]
        else:
            parents = [self.ui.graphFrame, self.ui.graphFrame2]

        for i in range(self.number_cameras):
            graph_w = parents[i].width() - 4
            graph_h = parents[i].height() - 4
            self.spot_graphs[i] = QSpotGraph(
                graph_w,
                graph_h,
                parameters.get("spotcounter.min_spots"),
                parameters.get("spotcounter.max_spots"),
                parent=parents[i])
            self.spot_graphs[i].setGeometry(2, 2, graph_w, graph_h)
            self.spot_graphs[i].show()

        # Setup STORM image(s).
        if (self.number_cameras == 1):
            parents = [self.ui.imageFrame]
        else:
            parents = [self.ui.imageFrame, self.ui.imageFrame2]

        for i in range(self.number_cameras):
            image_w = parents[i].width() - 4
            image_h = parents[i].height() - 4

            self.image_graphs[i] = QImageGraph(image_w,
                                               image_h,
                                               parent=parents[i])
            self.image_graphs[i].setGeometry(2, 2, image_w, image_h)
            self.image_graphs[i].blank()
            self.image_graphs[i].show()

        # Connect signals.
        if self.have_parent:
            self.ui.okButton.setText("Close")
            self.ui.okButton.clicked.connect(self.handleOk)
        else:
            self.ui.okButton.setText("Quit")
            self.ui.okButton.clicked.connect(self.handleQuit)
        self.ui.maxSpinBox.valueChanged.connect(self.handleMaxChange)
        self.ui.minSpinBox.valueChanged.connect(self.handleMinChange)

        # Set modeless.
        self.setModal(False)