getOffset.py 1.59 KB
Newer Older
Hackmet's avatar
Hackmet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 14:33:22 2019

@author: brandt
"""
from PyQt5 import QtWidgets, QtCore
import numpy as np
import sys

class GetOffset(QtWidgets.QWidget):
    def __init__(self, parent, ramanctrl):
        super(GetOffset, self).__init__()
        self.setWindowTitle('Get Coordinate Offset')
        self.ramanctrl = ramanctrl
        self.parent = parent
        
        layout = QtWidgets.QVBoxLayout()
        self.setLayout(layout)
        
        layout.addWidget(QtWidgets.QLabel('Position of points'))
        
        numPoints = 5
        self.pointBtns = []
        self.coordLabels = []
        self.old_coords = []
        self.new_coords = []
        
        coordGroup = QtWidgets.QGroupBox()
        coordLayout = QtWidgets.QGridLayout()
        
        for i in range(numPoints):
            self.coordLabels.append(QtWidgets.QLabel())
            self.coordLabels[-1].setFixedWidth(200)
            coordLayout.addWidget(i, 0, QtCore.Qt.AlignLeft)
            
            self.pointBtns.append(QtWidgets.QPushButton('Point'+str(i+1)))
            coordLayout.addWidget(i, )
    
    def connectButtonAndLabel(self, btn, lbl, index):
        btn.released.connect(lambda: self.readPoint(lbl, index))
        
    def readPoint(self, lbl):
        x, y, z = self.ramanctrl.getPosition()
        z = self.ramanctrl.getUserZ()
        lbl.setText(f'x = {np.round(x)} µm, y = {np.round(y)} µm, z = {np.round(z)} µm')
        
    
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    offset = GetOffset(None)
    offset.show()
    sys.exit(app.exec_())