-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
80 lines (48 loc) · 1.4 KB
/
main.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import snap
from PySide2 import QtWidgets
import sys
from threading import Thread
import OpenGL
from OpenGL.GL import *
from OpenGL.GLU import *
from snap import gl
import numpy as np
import snap.viewer
from snap.math import *
class Viewer(snap.viewer.Viewer):
def draw_cross(self):
glColor(0.7, 0.7, 0.7)
with gl.push_matrix():
glScale(0.2, 0.2, 0.2)
with gl.disable(GL_LIGHTING), gl.begin(GL_LINES):
glVertex(-1, 0, 0)
glVertex(1, 0, 0)
glVertex(0, -1, 0)
glVertex(0, 1, 0)
glVertex(0, 0, -1)
glVertex(0, 0, 1)
def init(self):
pass
def animate(self):
import time
print('animate', time.time())
def draw(self):
with gl.push_matrix():
glTranslate(*self.camera.pivot)
self.draw_cross()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
def console(local):
import code
code.interact(local = local)
app.quit()
thread = Thread(target = console, args = (locals(), ))
thread.daemon = True
thread.start()
w = Viewer()
w.show()
def cleanup():
import os
os.system('stty sane')
app.aboutToQuit.connect( cleanup )
sys.exit(app.exec_())