- Fixed redraw when component changed

This commit is contained in:
bklronin 2025-04-13 16:40:54 +02:00
parent 4d7b2cdbad
commit 6cf70b9ae2
2 changed files with 20 additions and 18 deletions

View File

@ -32,4 +32,4 @@ So far these are the elements:
- Code: A special type that directly builds bodys from sdfCAD code. - Code: A special type that directly builds bodys from sdfCAD code.
- Body: The 3D meshed result from sdfCAD - Body: The 3D meshed result from sdfCAD
- Sketch: The base to draw new entities. - Sketch: The base to draw new entities.
- Interactor: A special component mesh that is used to manipulate the bodys in 3d view. - Interactor (edges): A special component mesh that is used to manipulate the bodys in 3d view.

18
main.py
View File

@ -285,7 +285,7 @@ class MainWindow(QMainWindow):
# Register sketch to timeline # Register sketch to timeline
### Add selection compo here ### Add selection compo here
compo_id = self.get_activated_compo() compo_id = self.get_activated_compo()
print("newsketch_name", sketch.id) #print("newsketch_name", sketch.id)
self.project.timeline[compo_id].sketches[sketch.id] = sketch self.project.timeline[compo_id].sketches[sketch.id] = sketch
# Add Item to slection menu # Add Item to slection menu
@ -299,6 +299,7 @@ class MainWindow(QMainWindow):
self.ui.sketch_list.setCurrentItem(items) self.ui.sketch_list.setCurrentItem(items)
def on_compo_change(self): def on_compo_change(self):
'''This function redraws the sdf and helper mesh from available bodies and adds the names back to the list entries'''
self.custom_3D_Widget.clear_body_actors() self.custom_3D_Widget.clear_body_actors()
self.custom_3D_Widget.clear_actors_interactor() self.custom_3D_Widget.clear_actors_interactor()
self.custom_3D_Widget.clear_actors_projection() self.custom_3D_Widget.clear_actors_projection()
@ -308,11 +309,11 @@ class MainWindow(QMainWindow):
self.ui.sketch_list.clear() self.ui.sketch_list.clear()
self.ui.body_list.clear() self.ui.body_list.clear()
print("id", compo_id) #print("id", compo_id)
print("sketch_registry", self.project.timeline[compo_id].sketches) #print("sketch_registry", self.project.timeline[compo_id].sketches)
for sketch in self.project.timeline[compo_id].sketches: for sketch in self.project.timeline[compo_id].sketches:
print(sketch) #print(sketch)
self.ui.sketch_list.addItem(sketch) self.ui.sketch_list.addItem(sketch)
for body in self.project.timeline[compo_id].bodies: for body in self.project.timeline[compo_id].bodies:
@ -382,7 +383,7 @@ class MainWindow(QMainWindow):
model_data = vesta.generate_mesh_from_sdf(model, resolution=64, threshold=0) model_data = vesta.generate_mesh_from_sdf(model, resolution=64, threshold=0)
vertices, faces = model_data vertices, faces = model_data
vesta.save_mesh_as_stl(vertices, faces, 'test.stl') #vesta.save_mesh_as_stl(vertices, faces, 'test.stl')
self.custom_3D_Widget.render_from_points_direct_with_faces(vertices, faces) self.custom_3D_Widget.render_from_points_direct_with_faces(vertices, faces)
def on_item_changed(self, current_item, previous_item): def on_item_changed(self, current_item, previous_item):
@ -426,8 +427,9 @@ class MainWindow(QMainWindow):
#print(sketch) #print(sketch)
points = sketch.sdf_points points = sketch.sdf_points
# detect loop that causes problems in mesh generation
if points[-1] == points[0]: if points[-1] == points[0]:
#detect loop that causes problems in mesh generation print("overlap")
del points[-1] del points[-1]
dialog = ExtrudeDialog(self) dialog = ExtrudeDialog(self)
@ -446,8 +448,8 @@ class MainWindow(QMainWindow):
centroid = self.custom_3D_Widget.centroid centroid = self.custom_3D_Widget.centroid
if centroid is None: if centroid is None:
centroid = [0, 0, 0] centroid = [0, 0, 0]
else: """else:
centroid = list(centroid) centroid = list(centroid)"""
#print("This centroid ", centroid) #print("This centroid ", centroid)
sketch.origin = centroid sketch.origin = centroid