Skip to content

Commit 1c0341a

Browse files
committed
code clean
1 parent f4fda99 commit 1c0341a

File tree

3 files changed

+10
-54
lines changed

3 files changed

+10
-54
lines changed

a.out

-13.3 KB
Binary file not shown.

pyqtVisualisation/mainwindow.py

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
from OpenGL.GLU import *
33
from PyQt5.QtWidgets import *
44
from PyQt5.QtCore import *
5-
from PyQt5.QtGui import *
65
from PyQt5.QtOpenGL import *
7-
import numpy as np
8-
from PIL import Image
9-
import math
10-
from PyQt5 import QtCore, QtWidgets
116
import pygame
127

138

@@ -36,21 +31,8 @@ def __init__(self, parent):
3631
'w': [1,0],
3732
's': [-1,0],
3833
}
39-
40-
self.picture = "ozil.png"
4134
QGLWidget.__init__(self, parent)
4235
self.setMinimumSize(640, 480)
43-
main_camera_translation = np.zeros(3)
44-
main_camera_rotation = np.zeros(3)
45-
46-
self.cubeVertices = (
47-
(0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5),
48-
(-0.5, -0.5, -0.5),
49-
(-0.5, -0.5, 0.5), (-0.5, 0.5, -0.5))
50-
self.cubeEdges = (
51-
(0, 1), (0, 3), (0, 4), (1, 2), (1, 7), (2, 5), (2, 3), (3, 6), (4, 6), (4, 7), (5, 6), (5, 7))
52-
self.cubeQuads = ((0, 3, 6, 4), (2, 5, 6, 3), (1, 2, 5, 7), (1, 0, 4, 7), (7, 4, 6, 5), (2, 3, 0, 1))
53-
5436

5537
def image_load(self,lox,loy,loz,picture,rotate):
5638
self.read_texture(picture)
@@ -70,22 +52,21 @@ def image_load(self,lox,loy,loz,picture,rotate):
7052
glPopMatrix()
7153

7254
def keyPressEvent(self, event):
73-
print("pressed",event.text())
74-
# gluLookAt(2,1,1,0,0,0,0,1,0)
75-
self.camera = self.action_keymap.get(event.text())
76-
glRotate(self.camera[0],1,0,0)
77-
glRotate(self.camera[1],0,1,0)
78-
self.update()
55+
try:
56+
self.camera = self.action_keymap.get(event.text())
57+
if event.text() in self.action_keymap.keys():
58+
glRotate(self.camera[0],1,0,0)
59+
glRotate(self.camera[1],0,1,0)
60+
self.update()
61+
except:
62+
pass
7963

8064
def paintGL(self):
8165
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
8266
self.image_load(-1,0,0,"../reconstruction/mon_r.jpg",-20)
8367
self.image_load(1, 0, 0,"../reconstruction/mon_l.jpg",20)
8468
glFlush()
8569

86-
# def drawAxes(self):
87-
88-
8970
def initializeGL(self):
9071
glClearDepth(1.0)
9172
glDepthFunc(GL_LESS)
@@ -112,45 +93,20 @@ def wheelEvent(self, event):
11293
glTranslate(0,0,-1)
11394
self.update()
11495

115-
def mousePressEvent(self, event):
116-
117-
print("pressed")
118-
btns = event.buttons()
119-
x = event.localPos().x()
120-
y = event.localPos().y()
121-
122-
if btns & Qt.LeftButton:
123-
print("left")
124-
125-
elif btns & (Qt.MidButton):
126-
print("middle")
127-
128-
elif btns & (Qt.RightButton):
129-
print("right")
130-
131-
def mouseReleaseEvent(self, event):
132-
# nothing to be done here.
133-
print("released")
134-
pass
135-
13696
def read_texture(self,picture):
13797
textureSurface = pygame.image.load(picture)
13898
textureData = pygame.image.tostring(textureSurface, "RGBA", 1)
13999
width = textureSurface.get_width()
140100
height = textureSurface.get_height()
141-
142101
glEnable(GL_TEXTURE_2D)
143-
texid = glGenTextures(1)
144-
145-
102+
tex_id = glGenTextures(1)
146103
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height,
147104
0, GL_RGBA, GL_UNSIGNED_BYTE, textureData)
148-
149105
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
150106
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
151107
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
152108
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
153-
return texid
109+
return tex_id
154110

155111

156112
if __name__ == '__main__':

test1

-72.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)