Layered rendering
inverted interactor Befrore fork
This commit is contained in:
82
main.py
82
main.py
@@ -14,6 +14,7 @@ from drawing_modules.draw_widget2d import SketchWidget
|
||||
from sdf import *
|
||||
from python_solvespace import SolverSystem, ResultFlag
|
||||
from mesh_modules import simple_mesh, vesta_mesh, interactor_mesh
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
# main, draw_widget, gl_widget
|
||||
|
||||
@@ -22,6 +23,11 @@ class ExtrudeDialog(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle('Extrude Options')
|
||||
def create_hline():
|
||||
line = QLabel()
|
||||
line.setStyleSheet("border-top: 1px solid #cccccc;") # Light grey line
|
||||
line.setFixedHeight(1)
|
||||
return line
|
||||
|
||||
layout = QVBoxLayout()
|
||||
|
||||
@@ -37,6 +43,11 @@ class ExtrudeDialog(QDialog):
|
||||
# Symmetric checkbox
|
||||
self.symmetric_checkbox = QCheckBox('Symmetric Extrude')
|
||||
self.invert_checkbox = QCheckBox('Invert Extrusion')
|
||||
self.cut_checkbox = QCheckBox('Perform Cut')
|
||||
self.union_checkbox = QCheckBox('Combine')
|
||||
self.rounded_checkbox = QCheckBox('Round Edges')
|
||||
self.seperator = create_hline()
|
||||
|
||||
|
||||
# OK and Cancel buttons
|
||||
button_layout = QHBoxLayout()
|
||||
@@ -49,17 +60,21 @@ class ExtrudeDialog(QDialog):
|
||||
|
||||
# Add all widgets to main layout
|
||||
layout.addLayout(length_layout)
|
||||
layout.addWidget(self.seperator)
|
||||
layout.addWidget(self.cut_checkbox)
|
||||
layout.addWidget(self.union_checkbox)
|
||||
layout.addWidget(self.seperator)
|
||||
layout.addWidget(self.symmetric_checkbox)
|
||||
|
||||
layout.addLayout(length_layout)
|
||||
layout.addWidget(self.invert_checkbox)
|
||||
layout.addWidget(self.seperator)
|
||||
layout.addWidget(self.rounded_checkbox)
|
||||
|
||||
layout.addLayout(button_layout)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
def get_values(self):
|
||||
return self.length_input.value(), self.symmetric_checkbox.isChecked() ,self.invert_checkbox.isChecked()
|
||||
return self.length_input.value(), self.symmetric_checkbox.isChecked() ,self.invert_checkbox.isChecked(), self.cut_checkbox.isChecked(), self.union_checkbox.isChecked(), self.rounded_checkbox.isChecked()
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
send_command = Signal(str)
|
||||
@@ -143,8 +158,11 @@ class MainWindow(QMainWindow):
|
||||
self.sketchWidget.create_proj_lines(selected_lines)
|
||||
|
||||
# CLear all selections after it has been projected
|
||||
#self.custom_3D_Widget.clear_edge_select()
|
||||
self.custom_3D_Widget.project_tosketch_points.clear()
|
||||
self.custom_3D_Widget.project_tosketch_lines.clear()
|
||||
self.custom_3D_Widget.clear_actors_projection()
|
||||
self.custom_3D_Widget.clear_actors_normals()
|
||||
#self.custom_3D_Widget.clear_actors_projection()
|
||||
|
||||
#self.sketchWidget.create_workplane_space(edges, normal)
|
||||
|
||||
@@ -387,7 +405,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
dialog = ExtrudeDialog(self)
|
||||
if dialog.exec():
|
||||
length, is_symmetric, invert = dialog.get_values()
|
||||
length, is_symmetric, invert, cut, union_with, rounded = dialog.get_values()
|
||||
print(f"Extrude length: {length}, Symmetric: {is_symmetric} Invert: {invert}")
|
||||
else:
|
||||
length = 0
|
||||
@@ -396,7 +414,7 @@ class MainWindow(QMainWindow):
|
||||
geo = Geometry()
|
||||
|
||||
normal = self.custom_3D_Widget.selected_normal
|
||||
print("Normie enter", normal)
|
||||
#print("Normie enter", normal)
|
||||
if normal is None:
|
||||
normal = [0, 0, 1]
|
||||
|
||||
@@ -405,7 +423,7 @@ class MainWindow(QMainWindow):
|
||||
centroid = [0, 0, 0]
|
||||
else:
|
||||
centroid = list(centroid)
|
||||
print("This centroid ", centroid)
|
||||
#print("This centroid ", centroid)
|
||||
|
||||
f = geo.extrude_shape(points, length, normal, centroid, is_symmetric, invert, 0)
|
||||
|
||||
@@ -419,7 +437,10 @@ class MainWindow(QMainWindow):
|
||||
### Interactor
|
||||
lines = self.convert_lines_for_interactor()
|
||||
|
||||
edges = interactor_mesh.generate_mesh(lines, 0, length)
|
||||
if not invert:
|
||||
edges = interactor_mesh.generate_mesh(lines, 0, length)
|
||||
else:
|
||||
edges = interactor_mesh.generate_mesh(lines, 0, -length)
|
||||
|
||||
offset_vector = geo.vector_to_centroid(None, centroid, normal)
|
||||
#print("off_ved", offset_vector)
|
||||
@@ -466,8 +487,8 @@ class MainWindow(QMainWindow):
|
||||
self.custom_3D_Widget.load_stl(file)
|
||||
self.custom_3D_Widget.update()
|
||||
|
||||
class Geometry:
|
||||
|
||||
class Geometry:
|
||||
def angle_between_normals(self, normal1, normal2):
|
||||
# Ensure the vectors are normalized
|
||||
n1 = normal1 / np.linalg.norm(normal1)
|
||||
@@ -586,6 +607,49 @@ class Geometry:
|
||||
except Exception as e:
|
||||
print("Error executing code:", e)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Component:
|
||||
"""The base container combinging all related elements"""
|
||||
id = None
|
||||
sketch = None
|
||||
interactor = None
|
||||
body = None
|
||||
|
||||
@dataclass
|
||||
class Sketch:
|
||||
"""All of the 2D Information of a sketch"""
|
||||
origin = None
|
||||
plane = None
|
||||
normal = None
|
||||
ui_points = None
|
||||
ui_lines = None
|
||||
slv_points = None
|
||||
proj_points = None
|
||||
proj_lines = None
|
||||
|
||||
@dataclass
|
||||
class Interactor:
|
||||
"""Helper mesh consisting of edges for selection"""
|
||||
edges = None
|
||||
faces = None
|
||||
|
||||
@dataclass
|
||||
class Body:
|
||||
"""The actual body as sdf3 object"""
|
||||
sketch = None
|
||||
height = None
|
||||
sdf_body = None
|
||||
|
||||
class Boolean:
|
||||
"""Toolkit that contains the boolean operations for sdf3 objects"""
|
||||
def extrude(self, sketch: Sketch):
|
||||
pass
|
||||
|
||||
class Helper:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication([])
|
||||
window = MainWindow()
|
||||
|
||||
Reference in New Issue
Block a user