- changing compos including sketches and bodies
This commit is contained in:
parent
6c8462a7f3
commit
601121dc15
24
main.py
24
main.py
@ -177,10 +177,10 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
# Create and initialize a new Component
|
# Create and initialize a new Component
|
||||||
compo = Component()
|
compo = Component()
|
||||||
compo.id = f"Component {len(self.project.timeline) + 1}"
|
compo.id = f"Component {len(self.project.timeline)}"
|
||||||
compo.descript = "Initial Component"
|
compo.descript = "Initial Component"
|
||||||
compo.sketches = {}
|
compo.sketches = {}
|
||||||
compo.body = {}
|
compo.bodies = {}
|
||||||
self.project.timeline.append(compo)
|
self.project.timeline.append(compo)
|
||||||
|
|
||||||
# Create a button for the new component
|
# Create a button for the new component
|
||||||
@ -201,7 +201,7 @@ class MainWindow(QMainWindow):
|
|||||||
def get_activated_compo(self):
|
def get_activated_compo(self):
|
||||||
# Iterate through all items in the layout
|
# Iterate through all items in the layout
|
||||||
total_elements = self.compo_layout.count()
|
total_elements = self.compo_layout.count()
|
||||||
print(total_elements)
|
#print(total_elements)
|
||||||
for i in range(total_elements):
|
for i in range(total_elements):
|
||||||
widget = self.compo_layout.itemAt(i).widget() # Get the widget at the index
|
widget = self.compo_layout.itemAt(i).widget() # Get the widget at the index
|
||||||
if widget: # Check if the widget is not None
|
if widget: # Check if the widget is not None
|
||||||
@ -280,8 +280,10 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def on_compo_change(self):
|
def on_compo_change(self):
|
||||||
compo_id = self.get_activated_compo()
|
compo_id = self.get_activated_compo()
|
||||||
if compo_id:
|
if compo_id is not None:
|
||||||
self.ui.sketch_list.clear()
|
self.ui.sketch_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)
|
||||||
|
|
||||||
@ -289,6 +291,9 @@ class MainWindow(QMainWindow):
|
|||||||
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:
|
||||||
|
self.ui.body_list.addItem(body)
|
||||||
|
|
||||||
def edit_sketch(self):
|
def edit_sketch(self):
|
||||||
name = self.ui.sketch_list.currentItem().text()
|
name = self.ui.sketch_list.currentItem().text()
|
||||||
|
|
||||||
@ -398,7 +403,9 @@ class MainWindow(QMainWindow):
|
|||||||
def draw_mesh(self):
|
def draw_mesh(self):
|
||||||
name = self.ui.body_list.currentItem().text()
|
name = self.ui.body_list.currentItem().text()
|
||||||
print("selected_for disp", name)
|
print("selected_for disp", name)
|
||||||
model = self.project.timeline[-1].body[name].sdf_body
|
|
||||||
|
compo_id = self.get_activated_compo()
|
||||||
|
model = self.project.timeline[compo_id].bodies[name].sdf_body
|
||||||
|
|
||||||
vesta = vesta_mesh
|
vesta = vesta_mesh
|
||||||
model_data = vesta.generate_mesh_from_sdf(model, resolution=64, threshold=0)
|
model_data = vesta.generate_mesh_from_sdf(model, resolution=64, threshold=0)
|
||||||
@ -442,7 +449,6 @@ class MainWindow(QMainWindow):
|
|||||||
selected = self.ui.sketch_list.currentItem()
|
selected = self.ui.sketch_list.currentItem()
|
||||||
name = selected.text()
|
name = selected.text()
|
||||||
|
|
||||||
# TODO: add selected element from timeline
|
|
||||||
sel_compo = self.project.timeline[self.get_activated_compo()]
|
sel_compo = self.project.timeline[self.get_activated_compo()]
|
||||||
#print(sel_compo)
|
#print(sel_compo)
|
||||||
sketch = sel_compo.sketches[name]
|
sketch = sel_compo.sketches[name]
|
||||||
@ -480,7 +486,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
# Create body element and assign known stuff
|
# Create body element and assign known stuff
|
||||||
name_op = f"extrd-{name}"
|
name_op = f"extrd-{name}"
|
||||||
sel_compo.body
|
|
||||||
body = Body()
|
body = Body()
|
||||||
body.sketch = sketch #we add the sketches for reference here
|
body.sketch = sketch #we add the sketches for reference here
|
||||||
body.id = name_op
|
body.id = name_op
|
||||||
@ -496,7 +502,7 @@ class MainWindow(QMainWindow):
|
|||||||
edges = interactor_mesh.generate_mesh(interactor.lines, 0, -length)
|
edges = interactor_mesh.generate_mesh(interactor.lines, 0, -length)
|
||||||
|
|
||||||
body.interactor = interactor
|
body.interactor = interactor
|
||||||
sel_compo.body[name_op] = body
|
sel_compo.bodies[name_op] = body
|
||||||
|
|
||||||
offset_vector = interactor.vector_to_centroid(None, centroid, normal)
|
offset_vector = interactor.vector_to_centroid(None, centroid, normal)
|
||||||
#print("off_ved", offset_vector)
|
#print("off_ved", offset_vector)
|
||||||
@ -567,7 +573,7 @@ class Component:
|
|||||||
"""
|
"""
|
||||||
id = None
|
id = None
|
||||||
sketches: dict = None
|
sketches: dict = None
|
||||||
body: dict = None
|
bodies: dict = None
|
||||||
connector = None
|
connector = None
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
Loading…
x
Reference in New Issue
Block a user