summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralonrubintec <alonrubintech@gmail.com>2023-02-01 18:06:38 +0200
committeralonrubintec <alonrubintech@gmail.com>2023-02-01 18:06:38 +0200
commitf61c4d284d979c81cfaf1d22c22e09cdb0c7c569 (patch)
tree591a87f55712da50f4e17a50e1c4688b8a5bf2a3
parent633ea19d966b2e8e25b3f39bbb8ea95b90a4ab38 (diff)
Initial commit
-rw-r--r--README.md8
-rw-r--r--arcball.py3
-rw-r--r--engine.py5
-rw-r--r--functions.py6
-rw-r--r--main.py8
-rw-r--r--requirements.txtbin0 -> 184 bytes
6 files changed, 16 insertions, 14 deletions
diff --git a/README.md b/README.md
index e1b3800..a977a55 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
## Qt 3DViewer
-### Qt 3DViewer is a compact tool for viewing 3D models in a user friendly way.
+### Qt 3DViewer is a compact tool for viewing 3D models in a user-friendly way.
<br>This project is a compact and user-friendly application designed to showcase
<br>3D models in a visually appealing manner. With support for a wide range of
<br>file formats including .obj, .stl, .ply, .off, and .om.
Powered by Python the PyQt framework, the app use OpenGL, in combination
-<br>with ModernGL to render the 3D models and scenes in a interactive experience.
+<br>with ModernGL to render the 3D models and scenes in an interactive experience.
<br>Designed and developed by Alon Rubin.
@@ -27,8 +27,8 @@ Powered by Python the PyQt framework, the app use OpenGL, in combination
### How to install:
1. Install Python 3.9
-2. Install PyQt 5
-3. Import all the Libraries
+2. Install requirements
+3. run "main.py" file
## Like this project?
diff --git a/arcball.py b/arcball.py
index be6759e..6222687 100644
--- a/arcball.py
+++ b/arcball.py
@@ -92,7 +92,8 @@ class ArcBallUtil(ArcBall):
self.click(mouse_pt)
return
- def Matrix4fSetRotationFromMatrix3f(self, NewObj, m3x3):
+ @staticmethod
+ def Matrix4fSetRotationFromMatrix3f(NewObj, m3x3):
scale = np.linalg.norm(NewObj[:3, :3], ord='fro') / np.sqrt(3)
NewObj[0:3, 0:3] = m3x3 * scale
scaled_NewObj = NewObj
diff --git a/engine.py b/engine.py
index 4ffb1c9..e1f869d 100644
--- a/engine.py
+++ b/engine.py
@@ -148,14 +148,15 @@ class QGLControllerWidget(QtOpenGL.QGLWidget):
self.grid_alpha_value = (alpha*0.01)
def background_color(self, color):
- self.bg_color = color = color
+ self.bg_color = color
def update_fov(self, num):
self.fov = num
self.camera_zoom = self.camera_distance(num)
self.update()
- def camera_distance(self, num):
+ @staticmethod
+ def camera_distance(num):
return 1 / (math.tan(math.radians(num / 2)))
def update_grid_cell(self, cells):
diff --git a/functions.py b/functions.py
index 043bc16..8d65204 100644
--- a/functions.py
+++ b/functions.py
@@ -5,7 +5,7 @@ import openmesh
import re
-def open_file( opengl_obj, obj_path, obj_name, uv_label, material_label, drawcalls_label, vertices_label, triangles_label, edges_label):
+def open_file(opengl_obj, obj_path, obj_name, uv_label, material_label, drawcalls_label, vertices_label, triangles_label, edges_label):
file_name = QtWidgets.QFileDialog.getOpenFileName(
None, 'Open file', '', "Mesh files (*.obj *.stl *.ply *.off *.om)")
if not file_name[0]:
@@ -59,7 +59,7 @@ def draw_calls(file_path, drawcalls_label):
with open(file_path, "r") as file:
contents = file.read()
draw = tuple(re.findall(r'usemtl (\S+)', contents))
- if len(draw)>1:
+ if len(draw) > 1:
drawcalls_label.setText(str(len(draw)))
else:
drawcalls_label.setText(str(1))
@@ -100,7 +100,7 @@ def change_slider(slider, line, openGL, btn_name=""):
openGL.update_grid_alpha(value)
-def updateSlider(slider, line):
+def update_slider(slider, line):
value = int(line.text())
slider.setValue(value)
diff --git a/main.py b/main.py
index 6d99a3c..5af95fd 100644
--- a/main.py
+++ b/main.py
@@ -41,13 +41,13 @@ class MainWindow(QtWidgets.QMainWindow):
# Settings Sliders
self.fov_slider.valueChanged.connect(lambda: f.change_slider(self.fov_slider, self.fov_slider_value, self.openGL, "fov"))
- self.fov_slider_value.textChanged.connect(lambda: f.updateSlider(self.fov_slider, self.fov_slider_value))
+ self.fov_slider_value.textChanged.connect(lambda: f.update_slider(self.fov_slider, self.fov_slider_value))
self.grid_slider.valueChanged.connect(lambda: f.change_slider(self.grid_slider, self.grid_slider_value, self.openGL, "na"))
- self.grid_slider_value.textChanged.connect(lambda: f.updateSlider(self.grid_slider, self.grid_slider_value))
+ self.grid_slider_value.textChanged.connect(lambda: f.update_slider(self.grid_slider, self.grid_slider_value))
# Settings Sliders
self.wireframe_slider.valueChanged.connect(lambda: f.change_slider(self.wireframe_slider, self.wireframe_slider_value, self.openGL, "wireframe"))
- self.wireframe_slider_value.textChanged.connect(lambda: f.updateSlider(self.wireframe_slider, self.wireframe_slider_value))
+ self.wireframe_slider_value.textChanged.connect(lambda: f.update_slider(self.wireframe_slider, self.wireframe_slider_value))
# Settings radio buttons
self.wireframe_radio.toggled.connect(lambda: self.openGL.make_wireframe())
@@ -57,7 +57,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.grid_cell.textChanged.connect(lambda: f.update_grid_size(self.grid_cell, self.openGL, "cell"))
self.grid_size.textChanged.connect(lambda: f.update_grid_size(self.grid_size, self.openGL, "size"))
self.grid_slider.valueChanged.connect(lambda: f.change_slider(self.grid_slider, self.grid_slider_value, self.openGL, "grid"))
- self.grid_slider_value.textChanged.connect(lambda: f.updateSlider(self.grid_slider, self.grid_slider_value))
+ self.grid_slider_value.textChanged.connect(lambda: f.update_slider(self.grid_slider, self.grid_slider_value))
if __name__ == '__main__':
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..d3c5d6b
--- /dev/null
+++ b/requirements.txt
Binary files differ