Exemplo n.º 1
0
    def __init__(self,
                 plots=None,
                 las_header=None,
                 axes_on=False,
                 app=None,
                 background=(.2, .3, .4)):
        """
        :param plots: list of VTKPointClouds to plot
        :param las_header: a las_header that is optionally supplied if reading from a las file, helpful for saving
        :param axes_on: flag for turning axes on/off
        :param app: the main QApplication driving the GUI
        :param background: tuple of 0-1's for background color
        """
        super().__init__()
        self.plots = plots
        self.las_header = las_header
        self.background = background
        self.default_viewup = (0.0, 1.0, 0.0)
        self.axes_on = axes_on
        # self.app = Qt.QApplication(sys.argv)
        self.app = app
        self.main = Qt.QMainWindow()
        self.main.__init__()
        self.frame = Qt.QFrame()
        self.hl = Qt.QHBoxLayout()
        self.bl = Qt.QVBoxLayout()

        self.widgets = []
        self.widget_defaults = []
        self.widget_point_actors = []
        self.axes_actors = []
        if self.plots is not None:
            for i in range(len(plots)):
                vtk_widget = QVTKRenderWindowInteractor(self.frame)
                self.widgets.append(vtk_widget)
                self.hl.addWidget(vtk_widget)
                self.axes_actors.append(vtk.vtkCubeAxesActor2D())
                self.plot_point_cloud_qt(plots[i], vtk_widget)

            for w in self.widgets:
                position = w.GetRenderWindow().GetInteractor(
                ).GetInteractorStyle().camera.GetPosition()
                focus = w.GetRenderWindow().GetInteractor().GetInteractorStyle(
                ).camera.GetFocalPoint()
                viewup = w.GetRenderWindow().GetInteractor(
                ).GetInteractorStyle().camera.GetViewUp()
                self.widget_defaults.append((position, focus, viewup))

        self.hl.addLayout(self.bl)
        self.add_buttons()
        self.frame.setLayout(self.hl)
        self.main.setCentralWidget(self.frame)
        self.main.show()
        for w in self.widgets:
            w.GetRenderWindow().GetInteractor().Initialize()
            w.GetRenderWindow().GetInteractor().Start()
Exemplo n.º 2
0
    def loadUI(self):

        self.win = Qt.QMainWindow()

        self.win.setWindowFlags(self.win.windowFlags() | Qt.Qt.Tool
                                | Qt.Qt.FramelessWindowHint | Qt.Qt.Popup)
        #self.win.keyPressEvent = self.keyEventCatcher

        self.mainWidget = Qt.QWidget()
        self.layout = Qt.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        self.mainWidget.setContentsMargins(0, 0, 0, 0)
        self.win.setContentsMargins(0, 0, 0, 0)

        self.timer = Qt.QTimer()
        self.timer.setSingleShot(True)
        self.timer.timeout.connect(self.filterSuggestions)

        # The timer provides a delay of 200ms between user typing and list filtering

        self.entry = QEventCatcherEntry(catcher_fn=self.keyEventCatcher)
        self.entry.textEdited.connect(self.textEdited)
        self.layout.addWidget(self.entry)

        self.suggestion_list = Qt.QListWidget()
        self.suggestion_list.setSortingEnabled(False)
        self.layout.addWidget(self.suggestion_list)

        self.currentlySelectedIndex = Index(0, maxval=0)

        self.layout.setSizeConstraint(Qt.QLayout.SetFixedSize)
        self.mainWidget.setLayout(self.layout)
        self.win.setCentralWidget(self.mainWidget)

        self.adjustSizes()
Exemplo n.º 3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'ipetrash'

from PyQt5 import Qt

app = Qt.QApplication([])

button = Qt.QToolButton()
button.setIcon(Qt.QIcon('img.png'))
button.setAutoRaise(True)
button.setMinimumSize(40, 50)
button.setIconSize(button.minimumSize())

layout = Qt.QVBoxLayout()
layout.addWidget(Qt.QLabel('Example:'))
layout.addWidget(button)

central = Qt.QWidget()
central.setStyleSheet('background-color: green;')
central.setLayout(layout)

mw = Qt.QMainWindow()
mw.setCentralWidget(central)
mw.show()

app.exec()
Exemplo n.º 4
0
def load_gui(widget=None, camera=None, source=None):
    if widget is None:
        widget = Qt.QMainWindow()

    def on_update_freq(v):
        exposure = widget.exposure_time.value()
        latency = widget.latency.value()
        period = exposure + latency
        freq = float("inf") if not period else 1 / period
        widget.freq_value.setText("{:.3f} Hz".format(freq))

    def on_reset_roi():
        widget.x_spin.setValue(0)
        widget.y_spin.setValue(0)
        widget.w_spin.setValue(camera.WidthMax.Value)
        widget.h_spin.setValue(camera.HeightMax.Value)

    def on_start():
        logging.info("on start")
        nb_frames = widget.nb_frames.value()
        exposure = widget.exposure_time.value()
        latency = widget.latency.value()
        roi = (
            widget.x_spin.value(),
            widget.y_spin.value(),
            widget.w_spin.value(),
            widget.h_spin.value(),
        )
        if widget.h_bin_spin.isEnabled():
            binning = (widget.h_bin_spin.value(), widget.v_bin_spin.value())
        else:
            binning = None

        def acq_loop():
            for frame in iter_acq(camera, nb_frames, exposure, latency, roi,
                                  binning):
                source.newFrame.emit(frame)

        nonlocal task
        task = threading.Thread(target=acq_loop)
        task.daemon = True
        task.start()

    def on_stop():
        camera.StopGrabbing()
        if task:
            task.join()

    task = None
    widget.on_update_freq = on_update_freq
    widget.on_reset_roi = on_reset_roi
    widget.on_start = on_start
    widget.on_stop = on_stop

    def on_frame(frame):
        try:
            if frame.GrabSucceeded():
                image_item.setImage(frame.Array)
        except Exception:
            pass
        finally:
            frame.Release()

    uic.loadUi(UI, baseinstance=widget)

    if source is None:
        source = QFrameSource()
    vb = widget.canvas.addViewBox()
    image_item = pyqtgraph.ImageItem()
    vb.addItem(image_item)

    source.newFrame.connect(on_frame)

    if camera:
        widget.setWindowTitle("{} - {}".format(
            widget.windowTitle(), camera.device_info.GetFullName()))
    widget.nb_frames.setValue(0)
    widget.exposure_time.setValue(0.01)
    widget.latency.setValue(0.1 - widget.exposure_time.value())

    widget.x_spin.setValue(camera.OffsetX.Value)
    widget.y_spin.setValue(camera.OffsetY.Value)
    widget.w_spin.setValue(camera.Width.Value)
    widget.h_spin.setValue(camera.Height.Value)
    try:
        widget.h_bin_spin.setValue(camera.BinningHorizontal.Value)
        widget.v_bin_spin.setValue(camera.BinningVertical.Value)
    except genicam.LogicalErrorException:
        widget.h_bin_spin.setEnabled(False)
        widget.v_bin_spin.setEnabled(False)

    return widget
Exemplo n.º 5
0
from dataserver_helpers import run_dataserver, dataserver_client, DATA_DIRECTORY
import time
from PyQt5 import Qt
import sys

app = Qt.QApplication([])
win = Qt.QMainWindow()
contents = Qt.QWidget()
contents.setLayout(Qt.QVBoxLayout())
status_label = Qt.QLabel('Not Running')
start_button = Qt.QPushButton('Start')
exit_button = Qt.QPushButton('Quit')
exit_button.setEnabled(False)
contents.layout().addWidget(status_label)
contents.layout().addWidget(start_button)
contents.layout().addWidget(exit_button)
win.setCentralWidget(contents)
client = None
alive_poll = None
alive_time = 500

def start():
    run_dataserver(qt=True)
    time.sleep(1)
    global client, alive_poll, start_button, exit_button
    client = dataserver_client()
    alive_poll = Qt.QTimer()
    alive_poll.timeout.connect(check_alive)
    alive_poll.start(alive_time)
    start_button.setEnabled(False)
    exit_button.setEnabled(True)
Exemplo n.º 6
0
from PyQt5 import Qt
import serial


def update():
    res = port.read_until('z')
    if res:
        label.setText('%d rpm' %
                      (float(res.strip().decode()[:-2].strip()) * 60))


port = serial.Serial('/dev/ttyACM0', baudrate=115200, timeout=0.1)
port.flushInput()

app = Qt.QApplication([])
window = Qt.QMainWindow(windowTitle='Frequency Counter')

font = Qt.QFont()
font.setPixelSize(64)
font.setFamily('Monospace')

label = Qt.QLabel(window, font=font, alignment=Qt.Qt.AlignRight)

timer = Qt.QTimer(window, interval=100)
timer.timeout.connect(update)
timer.start()

pal = label.palette()
pal.setColor(Qt.QPalette.Window, Qt.QColor('black'))
pal.setColor(Qt.QPalette.WindowText, Qt.QColor('#55ff55'))
window.setPalette(pal)