- Added new componnt controls
This commit is contained in:
58
main.py
58
main.py
@@ -99,11 +99,11 @@ class MainWindow(QMainWindow):
|
||||
size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
|
||||
self.sketchWidget.setSizePolicy(size_policy)
|
||||
|
||||
### Main Model
|
||||
self.model = {
|
||||
### Main Model -OLD ?
|
||||
"""self.model = {
|
||||
'sketches': {},
|
||||
'operation': {},
|
||||
}
|
||||
}"""
|
||||
self.list_selected = []
|
||||
|
||||
#self.ui.pb_apply_code.pressed.connect(self.check_current_tab)
|
||||
@@ -144,7 +144,13 @@ class MainWindow(QMainWindow):
|
||||
self.project = Project()
|
||||
self.new_project()
|
||||
|
||||
"""Project -> Timeline -> Component -> Sketch -> Body / Interactor -> Connector -> Assembly -> PB Render"""
|
||||
### COMPOS
|
||||
### COMPOS
|
||||
|
||||
self.ui.new_compo.pressed.connect(self.new_component)
|
||||
|
||||
|
||||
"""Project -> (Timeline) -> Component -> Sketch -> Body / Interactor -> Connector -> Assembly -> PB Render"""
|
||||
|
||||
def on_flip_face(self):
|
||||
self.send_command.emit("flip")
|
||||
@@ -229,33 +235,41 @@ class MainWindow(QMainWindow):
|
||||
self.new_component()
|
||||
|
||||
def new_component(self):
|
||||
print("Compo")
|
||||
print("Creating a new component...")
|
||||
|
||||
# Lazily initialize self.compo_layout if it doesn't exist
|
||||
if not hasattr(self, 'compo_layout'):
|
||||
print("Initializing compo_layout...")
|
||||
self.compo_layout = QHBoxLayout()
|
||||
|
||||
# Ensure the QGroupBox has a layout
|
||||
if not self.ui.compo_box.layout():
|
||||
self.ui.compo_box.setLayout(QVBoxLayout()) # Set a default layout for QGroupBox
|
||||
|
||||
# Add the horizontal layout to the QGroupBox's layout
|
||||
self.ui.compo_box.layout().addLayout(self.compo_layout)
|
||||
|
||||
# Align the layout to the left
|
||||
self.compo_layout.setAlignment(Qt.AlignLeft)
|
||||
|
||||
# Create and initialize a new Component
|
||||
compo = Component()
|
||||
compo.id = "New Compo"
|
||||
compo.id = f"Component {len(self.project.timeline) + 1}"
|
||||
compo.descript = "Initial Component"
|
||||
compo.sketches = {}
|
||||
compo.body = {}
|
||||
self.project.timeline.append(compo)
|
||||
|
||||
# Create a horizontal layout
|
||||
horizontal_layout = QHBoxLayout()
|
||||
|
||||
# Set the layout for the timeline_box QFrame
|
||||
self.ui.timeline_box.setLayout(horizontal_layout)
|
||||
|
||||
# Create the button
|
||||
# Create a button for the new component
|
||||
button = QPushButton()
|
||||
|
||||
button.setToolTip(compo.id)
|
||||
button.setText(str(len(self.project.timeline)))
|
||||
button.setFixedSize(QSize(40, 40)) # Set button size
|
||||
|
||||
# Set the button's fixed size
|
||||
button.setFixedSize(QSize(40, 40))
|
||||
# Add the button to the layout
|
||||
self.compo_layout.addWidget(button)
|
||||
|
||||
# Add the button to the horizontal layout
|
||||
horizontal_layout.addWidget(button)
|
||||
# Set the alignment of the layout to left
|
||||
horizontal_layout.setAlignment(Qt.AlignLeft)
|
||||
print(f"Added component {compo.id} to the layout.")
|
||||
|
||||
def add_new_sketch_origin(self):
|
||||
name = f"sketches-{str(names.get_first_name())}"
|
||||
@@ -281,8 +295,10 @@ class MainWindow(QMainWindow):
|
||||
self.sketchWidget.reset_buffers()
|
||||
self.sketchWidget.create_sketch(sketch)
|
||||
self.sketchWidget.create_workplane_projected()
|
||||
|
||||
if not sketch.proj_lines:
|
||||
self.sketchWidget.convert_proj_points(sketch.proj_points)
|
||||
|
||||
self.sketchWidget.convert_proj_lines(sketch.proj_lines)
|
||||
self.sketchWidget.update()
|
||||
|
||||
@@ -792,7 +808,7 @@ class Project:
|
||||
assembly: Assembly = None
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication([])
|
||||
app = QApplication()
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
app.exec()
|
||||
|
||||
Reference in New Issue
Block a user