-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuiSLMDialog.py
More file actions
46 lines (35 loc) · 1.06 KB
/
Copy pathuiSLMDialog.py
File metadata and controls
46 lines (35 loc) · 1.06 KB
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
#!/usr/bin/python
import sys
from PyQt4 import QtGui
import numpy as np
from matplotlib.cm import get_cmap
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg \
import FigureCanvasQTAgg as FigureCanvas
class SLMDialog(QtGui.QDialog):
def __init__(self, parent=None):
super(SLMDialog, self).__init__(parent)
self.fig = Figure()
self.fc = FigureCanvas(self.fig)
self.axes = self.fig.add_axes([0,0,1,1])
layout = QtGui.QHBoxLayout()
layout.addWidget(self.fc)
layout.setMargin(0)
self.setLayout(layout)
def imshow(self, img):
self.axes.clear()
self.axes.axis('off')
self.axes.imshow(img, cmap=get_cmap('binary'))
self.fc.draw()
if __name__ == '__main__':
import gen_pattern as gp
qApp = QtGui.QApplication(sys.argv)
SLM = SLMDialog()
aux_mat = gp.prepare_aux_matrices(512)
p_lg = gp.gen_lg_pattern(3,3,aux_mat,4)
p_g = gp.gen_blaze_grating(50, aux_mat)
pm = gp.phasemap(p_lg + p_g)
#pm = gp.phasemap(p_lg)
SLM.imshow(pm)
SLM.show()
sys.exit(qApp.exec_())