Commit 63fbc7da authored by Martin Drechsler's avatar Martin Drechsler

camera parameters now in a layout with a grid, which includes the tree

parent 00659812
...@@ -14,8 +14,8 @@ from pyqtgraph import console ...@@ -14,8 +14,8 @@ from pyqtgraph import console
from subclasses.pyqtgraph_subclasses import CustomRectangularROI from subclasses.pyqtgraph_subclasses import CustomRectangularROI
from zylaCameraWorker import CameraWorker from zylaCameraWorker import CameraWorker
from subclasses.cameraParameterTree import CameraParameterTree
from subclasses.controllayouts import LaserControlLayout, LaserScanLayout from subclasses.controllayouts import LaserControlLayout, LaserScanLayout
from subclasses.cameraParameterFrame import CameraParameterFrame
from resources.scanFunctions import create_measurement_array from resources.scanFunctions import create_measurement_array
from measurement import MeasurementFrame from measurement import MeasurementFrame
import sys import sys
...@@ -76,9 +76,10 @@ class CameraGuiMainWindow(QMainWindow): ...@@ -76,9 +76,10 @@ class CameraGuiMainWindow(QMainWindow):
self.label = QLabel("Counter of frames") self.label = QLabel("Counter of frames")
self.dCameraView.addWidget(self.label) self.dCameraView.addWidget(self.label)
self.param_tree = CameraParameterTree(self.win) #self.param_tree = CameraParameterTree()
self.param_tree.load() self.cameraParamFrame = CameraParameterFrame()
self.dCameraControl.addWidget(self.param_tree.t) self.cameraParamFrame.paramTree.load()
self.dCameraControl.addWidget(self.cameraParamFrame)
# layouts and viewboxes # layouts and viewboxes
self.ImageLayout = pg.GraphicsLayoutWidget() self.ImageLayout = pg.GraphicsLayoutWidget()
...@@ -136,7 +137,7 @@ class CameraGuiMainWindow(QMainWindow): ...@@ -136,7 +137,7 @@ class CameraGuiMainWindow(QMainWindow):
self.console = console.ConsoleWidget( self.console = console.ConsoleWidget(
namespace = {'np': np, 'cam': backend.cam, 'roi': self.rois[0], namespace = {'np': np, 'cam': backend.cam, 'roi': self.rois[0],
'storage': backend.storage, 'param_tree': self.param_tree 'storage': backend.storage, 'param_tree': self.cameraParamFrame.paramTree
} }
) )
self.dConsole.addWidget(self.console) self.dConsole.addWidget(self.console)
...@@ -201,7 +202,7 @@ class CameraGuiMainWindow(QMainWindow): ...@@ -201,7 +202,7 @@ class CameraGuiMainWindow(QMainWindow):
old_size = self.current_image_size old_size = self.current_image_size
aux_dict = {'1x1': 2048, '2x2': 1024, '4x4': 512, '8x8': 256} aux_dict = {'1x1': 2048, '2x2': 1024, '4x4': 512, '8x8': 256}
new_size = aux_dict[ new_size = aux_dict[
self.param_tree.p.child('Basic acq parameters') self.cameraParamFrame.paramTree.p.child('Basic acq parameters')
.child('Pixel Binning').value() .child('Pixel Binning').value()
] ]
print('sizes:', old_size, new_size) print('sizes:', old_size, new_size)
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat May 11 11:22:27 2019
@author: martindrech
"""
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from subclasses.cameraParameterTree import CameraParameterTree
import pyqtgraph as pg
class CameraParameterFrame(QtWidgets.QFrame):
def __init__(self):
super().__init__()
self.grid = QtWidgets.QGridLayout()
self.setLayout(self.grid)
self.paramTree = CameraParameterTree()
self.grid.addWidget(self.paramTree.t, 0, 0, 1, 2)
self.saveButton = QtWidgets.QPushButton('Save')
self.loadButton = QtWidgets.QPushButton('Load')
self.saveToButton = QtWidgets.QPushButton('Save To')
self.loadFromButton = QtWidgets.QPushButton('Load From')
self.grid.addWidget(self.saveButton, 1, 0)
self.grid.addWidget(self.loadButton, 1, 1)
self.grid.addWidget(self.saveToButton, 2, 0)
self.grid.addWidget(self.loadFromButton, 2, 1)
self.grid.addWidget(QtWidgets.QLabel(
'Roi X Position'), 3, 0)
self.grid.addWidget(QtWidgets.QLabel(
'Roi Y Position'), 3, 1)
self.RoiXPosSb = pg.SpinBox()
self.RoiYPosSb = pg.SpinBox()
self.grid.addWidget(self.RoiXPosSb, 4, 0)
self.grid.addWidget(self.RoiYPosSb, 4, 1)
self.grid.addWidget(QtWidgets.QLabel(
'Roi X Size'), 5, 0)
self.grid.addWidget(QtWidgets.QLabel(
'Roi Y Size'), 5, 1)
self.RoiXPosSb = pg.SpinBox()
self.RoiYPosSb = pg.SpinBox()
self.grid.addWidget(self.RoiXPosSb, 6, 0)
self.grid.addWidget(self.RoiYPosSb, 6, 1)
self.make_connections()
self.show()
def make_connections(self):
self.saveButton.clicked.connect(self.paramTree.save)
self.loadButton.clicked.connect(self.paramTree.load)
self.saveToButton.clicked.connect(self.paramTree.save_to)
self.loadFromButton.clicked.connect(self.paramTree.load_from)
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication([])
frame = CameraParameterFrame()
frame.resize(300, 600)
sys.exit(app.exec_())
\ No newline at end of file
...@@ -56,25 +56,22 @@ class BasicActionParameters(pTypes.GroupParameter): ...@@ -56,25 +56,22 @@ class BasicActionParameters(pTypes.GroupParameter):
class CameraParameterTree(ParameterTree): class CameraParameterTree(ParameterTree):
def __init__(self, win): def __init__(self):
super().__init__() super().__init__()
self.win = win
self.params = [ self.params = [
BasicAcquisitonParameters(name = 'Basic acq parameters'), BasicAcquisitonParameters(name = 'Basic acq parameters')]
BasicActionParameters(name = 'Actions')
]
self.p = Parameter.create(name='params', type='group', children=self.params) self.p = Parameter.create(name='params', type='group', children=self.params)
#self.p.sigTreeStateChanged.connect(self.change) #self.p.sigTreeStateChanged.connect(self.change)
self.t = ParameterTree() self.t = ParameterTree()
self.t.setParameters(self.p, showTop=False) self.t.setParameters(self.p, showTop=False)
self.t.setWindowTitle('Parameter Tree') self.t.setWindowTitle('Parameter Tree')
self.p.param('Actions', 'Save State').sigActivated.connect(lambda: self.save()) # self.p.param('Actions', 'Save State').sigActivated.connect(lambda: self.save())
self.p.param('Actions', 'Load State').sigActivated.connect(lambda: self.load()) # self.p.param('Actions', 'Load State').sigActivated.connect(lambda: self.load())
self.p.param('Actions', 'Save State To').sigActivated.connect(lambda: self.save_to()) # self.p.param('Actions', 'Save State To').sigActivated.connect(lambda: self.save_to())
self.p.param('Actions', 'Load State From').sigActivated.connect(lambda: self.load_from()) # self.p.param('Actions', 'Load State From').sigActivated.connect(lambda: self.load_from())
self.p.param('Actions', 'Update State').sigActivated.connect(self.print_params) # self.p.param('Actions', 'Update State').sigActivated.connect(self.print_params)
# self.save() # # self.save()
def change(self, param, changes): def change(self, param, changes):
print("tree changes:") print("tree changes:")
...@@ -114,7 +111,7 @@ class CameraParameterTree(ParameterTree): ...@@ -114,7 +111,7 @@ class CameraParameterTree(ParameterTree):
settings.endGroup() settings.endGroup()
def save_to(self): def save_to(self):
name = QFileDialog.getSaveFileName(self.win, 'Save File') name = QFileDialog.getSaveFileName(self, 'Save File')
if not name[0]: if not name[0]:
print('Saving was canceled') print('Saving was canceled')
return 0 return 0
...@@ -124,7 +121,7 @@ class CameraParameterTree(ParameterTree): ...@@ -124,7 +121,7 @@ class CameraParameterTree(ParameterTree):
self.save( filename ) self.save( filename )
def load_from(self): def load_from(self):
name = QFileDialog.getOpenFileName(self.win, 'Open File') name = QFileDialog.getOpenFileName(self, 'Open File')
if not name[0]: if not name[0]:
print('Opening was canceled') print('Opening was canceled')
return 0 return 0
...@@ -140,7 +137,7 @@ if __name__ == '__main__': ...@@ -140,7 +137,7 @@ if __name__ == '__main__':
win = QtGui.QWidget() win = QtGui.QWidget()
layout = QtGui.QGridLayout() layout = QtGui.QGridLayout()
win.setLayout(layout) win.setLayout(layout)
param_tree = CameraParameterTree(win) param_tree = CameraParameterTree()
layout.addWidget(QtGui.QLabel("Explanation of parameter tree."), 0, 0, 1, 2) layout.addWidget(QtGui.QLabel("Explanation of parameter tree."), 0, 0, 1, 2)
layout.addWidget(param_tree.t) layout.addWidget(param_tree.t)
win.show() win.show()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment