Checkpoint before solvespace integration

This commit is contained in:
bklronin 2024-06-18 09:53:39 +02:00
parent 92a870e834
commit a64971e0fe
5 changed files with 525 additions and 355 deletions

355
Gui.py
View File

@ -29,13 +29,92 @@ class Ui_fluencyCAD(object):
self.centralwidget.setObjectName(u"centralwidget") self.centralwidget.setObjectName(u"centralwidget")
self.gridLayout = QGridLayout(self.centralwidget) self.gridLayout = QGridLayout(self.centralwidget)
self.gridLayout.setObjectName(u"gridLayout") self.gridLayout.setObjectName(u"gridLayout")
self.InputTab = QTabWidget(self.centralwidget)
self.InputTab.setObjectName(u"InputTab")
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.InputTab.sizePolicy().hasHeightForWidth())
self.InputTab.setSizePolicy(sizePolicy)
self.sketch_tab = QWidget()
self.sketch_tab.setObjectName(u"sketch_tab")
self.verticalLayout_4 = QVBoxLayout(self.sketch_tab)
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
self.InputTab.addTab(self.sketch_tab, "")
self.code_tab = QWidget()
self.code_tab.setObjectName(u"code_tab")
self.verticalLayout = QVBoxLayout(self.code_tab)
self.verticalLayout.setObjectName(u"verticalLayout")
self.textEdit = QTextEdit(self.code_tab)
self.textEdit.setObjectName(u"textEdit")
self.verticalLayout.addWidget(self.textEdit)
self.groupBox_7 = QGroupBox(self.code_tab)
self.groupBox_7.setObjectName(u"groupBox_7")
self.gridLayout_5 = QGridLayout(self.groupBox_7)
self.gridLayout_5.setObjectName(u"gridLayout_5")
self.pushButton_5 = QPushButton(self.groupBox_7)
self.pushButton_5.setObjectName(u"pushButton_5")
self.gridLayout_5.addWidget(self.pushButton_5, 2, 0, 1, 1)
self.pushButton_4 = QPushButton(self.groupBox_7)
self.pushButton_4.setObjectName(u"pushButton_4")
self.gridLayout_5.addWidget(self.pushButton_4, 2, 1, 1, 1)
self.pb_apply_code = QPushButton(self.groupBox_7)
self.pb_apply_code.setObjectName(u"pb_apply_code")
self.gridLayout_5.addWidget(self.pb_apply_code, 1, 0, 1, 1)
self.pushButton = QPushButton(self.groupBox_7)
self.pushButton.setObjectName(u"pushButton")
self.gridLayout_5.addWidget(self.pushButton, 1, 1, 1, 1)
self.verticalLayout.addWidget(self.groupBox_7)
self.InputTab.addTab(self.code_tab, "")
self.gridLayout.addWidget(self.InputTab, 0, 2, 8, 1)
self.groupBox = QGroupBox(self.centralwidget)
self.groupBox.setObjectName(u"groupBox")
self.gridLayout_3 = QGridLayout(self.groupBox)
self.gridLayout_3.setObjectName(u"gridLayout_3")
self.pb_extrdop = QPushButton(self.groupBox)
self.pb_extrdop.setObjectName(u"pb_extrdop")
self.gridLayout_3.addWidget(self.pb_extrdop, 0, 0, 1, 1)
self.pb_cutop = QPushButton(self.groupBox)
self.pb_cutop.setObjectName(u"pb_cutop")
self.gridLayout_3.addWidget(self.pb_cutop, 0, 1, 1, 1)
self.pb_arrayop = QPushButton(self.groupBox)
self.pb_arrayop.setObjectName(u"pb_arrayop")
self.gridLayout_3.addWidget(self.pb_arrayop, 1, 0, 1, 1)
self.pb_revop = QPushButton(self.groupBox)
self.pb_revop.setObjectName(u"pb_revop")
self.gridLayout_3.addWidget(self.pb_revop, 1, 1, 1, 1)
self.gridLayout.addWidget(self.groupBox, 0, 5, 7, 1, Qt.AlignTop)
self.gl_box = QGroupBox(self.centralwidget) self.gl_box = QGroupBox(self.centralwidget)
self.gl_box.setObjectName(u"gl_box") self.gl_box.setObjectName(u"gl_box")
sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) sizePolicy1 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0) sizePolicy1.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(4) sizePolicy1.setVerticalStretch(4)
sizePolicy.setHeightForWidth(self.gl_box.sizePolicy().hasHeightForWidth()) sizePolicy1.setHeightForWidth(self.gl_box.sizePolicy().hasHeightForWidth())
self.gl_box.setSizePolicy(sizePolicy) self.gl_box.setSizePolicy(sizePolicy1)
font = QFont() font = QFont()
font.setPointSize(12) font.setPointSize(12)
self.gl_box.setFont(font) self.gl_box.setFont(font)
@ -46,47 +125,15 @@ class Ui_fluencyCAD(object):
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
self.horizontalLayout_4.setContentsMargins(12, -1, -1, -1) self.horizontalLayout_4.setContentsMargins(12, -1, -1, -1)
self.gridLayout.addWidget(self.gl_box, 0, 4, 7, 1) self.gridLayout.addWidget(self.gl_box, 0, 4, 8, 1)
self.groupBox_7 = QGroupBox(self.centralwidget)
self.groupBox_7.setObjectName(u"groupBox_7")
self.gridLayout_5 = QGridLayout(self.groupBox_7)
self.gridLayout_5.setObjectName(u"gridLayout_5")
self.pb_apply_code = QPushButton(self.groupBox_7)
self.pb_apply_code.setObjectName(u"pb_apply_code")
self.gridLayout_5.addWidget(self.pb_apply_code, 0, 0, 1, 1)
self.pushButton_5 = QPushButton(self.groupBox_7)
self.pushButton_5.setObjectName(u"pushButton_5")
self.gridLayout_5.addWidget(self.pushButton_5, 2, 0, 1, 1)
self.pushButton_2 = QPushButton(self.groupBox_7)
self.pushButton_2.setObjectName(u"pushButton_2")
self.gridLayout_5.addWidget(self.pushButton_2, 4, 0, 1, 1)
self.pushButton = QPushButton(self.groupBox_7)
self.pushButton.setObjectName(u"pushButton")
self.gridLayout_5.addWidget(self.pushButton, 0, 1, 1, 1)
self.pushButton_4 = QPushButton(self.groupBox_7)
self.pushButton_4.setObjectName(u"pushButton_4")
self.gridLayout_5.addWidget(self.pushButton_4, 2, 1, 1, 1)
self.gridLayout.addWidget(self.groupBox_7, 6, 5, 1, 1, Qt.AlignBottom)
self.groupBox_2 = QGroupBox(self.centralwidget) self.groupBox_2 = QGroupBox(self.centralwidget)
self.groupBox_2.setObjectName(u"groupBox_2") self.groupBox_2.setObjectName(u"groupBox_2")
sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy1.setHorizontalStretch(0) sizePolicy2.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0) sizePolicy2.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth()) sizePolicy2.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth())
self.groupBox_2.setSizePolicy(sizePolicy1) self.groupBox_2.setSizePolicy(sizePolicy2)
self.gridLayout_2 = QGridLayout(self.groupBox_2) self.gridLayout_2 = QGridLayout(self.groupBox_2)
self.gridLayout_2.setObjectName(u"gridLayout_2") self.gridLayout_2.setObjectName(u"gridLayout_2")
self.pb_rectool = QPushButton(self.groupBox_2) self.pb_rectool = QPushButton(self.groupBox_2)
@ -114,10 +161,85 @@ class Ui_fluencyCAD(object):
self.gridLayout.addWidget(self.groupBox_2, 0, 0, 1, 1) self.gridLayout.addWidget(self.groupBox_2, 0, 0, 1, 1)
self.groupBox_5 = QGroupBox(self.centralwidget)
self.groupBox_5.setObjectName(u"groupBox_5")
sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(0)
sizePolicy3.setHeightForWidth(self.groupBox_5.sizePolicy().hasHeightForWidth())
self.groupBox_5.setSizePolicy(sizePolicy3)
self.groupBox_5.setMaximumSize(QSize(300, 16777215))
self.verticalLayout_3 = QVBoxLayout(self.groupBox_5)
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
self.sketch_list = QListWidget(self.groupBox_5)
self.sketch_list.setObjectName(u"sketch_list")
self.sketch_list.setSelectionRectVisible(True)
self.verticalLayout_3.addWidget(self.sketch_list)
self.groupBox_6 = QGroupBox(self.groupBox_5)
self.groupBox_6.setObjectName(u"groupBox_6")
sizePolicy2.setHeightForWidth(self.groupBox_6.sizePolicy().hasHeightForWidth())
self.groupBox_6.setSizePolicy(sizePolicy2)
self.gridLayout_6 = QGridLayout(self.groupBox_6)
self.gridLayout_6.setObjectName(u"gridLayout_6")
self.gridLayout_6.setContentsMargins(2, 2, 2, 2)
self.pb_del_sketch = QPushButton(self.groupBox_6)
self.pb_del_sketch.setObjectName(u"pb_del_sketch")
self.gridLayout_6.addWidget(self.pb_del_sketch, 0, 2, 1, 1)
self.pb_nw_sktch = QPushButton(self.groupBox_6)
self.pb_nw_sktch.setObjectName(u"pb_nw_sktch")
self.gridLayout_6.addWidget(self.pb_nw_sktch, 0, 0, 1, 1)
self.pb_edt_sktch = QPushButton(self.groupBox_6)
self.pb_edt_sktch.setObjectName(u"pb_edt_sktch")
self.gridLayout_6.addWidget(self.pb_edt_sktch, 0, 1, 1, 1)
self.verticalLayout_3.addWidget(self.groupBox_6)
self.body_list = QListWidget(self.groupBox_5)
self.body_list.setObjectName(u"body_list")
self.body_list.setSelectionRectVisible(True)
self.verticalLayout_3.addWidget(self.body_list)
self.groupBox_8 = QGroupBox(self.groupBox_5)
self.groupBox_8.setObjectName(u"groupBox_8")
sizePolicy2.setHeightForWidth(self.groupBox_8.sizePolicy().hasHeightForWidth())
self.groupBox_8.setSizePolicy(sizePolicy2)
self.gridLayout_8 = QGridLayout(self.groupBox_8)
self.gridLayout_8.setObjectName(u"gridLayout_8")
self.gridLayout_8.setContentsMargins(2, 2, 2, 2)
self.pb_del_body = QPushButton(self.groupBox_8)
self.pb_del_body.setObjectName(u"pb_del_body")
self.gridLayout_8.addWidget(self.pb_del_body, 0, 2, 1, 1)
self.pb_update_body = QPushButton(self.groupBox_8)
self.pb_update_body.setObjectName(u"pb_update_body")
self.gridLayout_8.addWidget(self.pb_update_body, 0, 0, 1, 1)
self.pb_edt_sktch_3 = QPushButton(self.groupBox_8)
self.pb_edt_sktch_3.setObjectName(u"pb_edt_sktch_3")
self.gridLayout_8.addWidget(self.pb_edt_sktch_3, 0, 1, 1, 1)
self.verticalLayout_3.addWidget(self.groupBox_8)
self.gridLayout.addWidget(self.groupBox_5, 0, 3, 8, 1)
self.groupBox_3 = QGroupBox(self.centralwidget) self.groupBox_3 = QGroupBox(self.centralwidget)
self.groupBox_3.setObjectName(u"groupBox_3") self.groupBox_3.setObjectName(u"groupBox_3")
sizePolicy1.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth()) sizePolicy2.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth())
self.groupBox_3.setSizePolicy(sizePolicy1) self.groupBox_3.setSizePolicy(sizePolicy2)
self.gridLayout_4 = QGridLayout(self.groupBox_3) self.gridLayout_4 = QGridLayout(self.groupBox_3)
self.gridLayout_4.setObjectName(u"gridLayout_4") self.gridLayout_4.setObjectName(u"gridLayout_4")
self.pb_con_line = QPushButton(self.groupBox_3) self.pb_con_line = QPushButton(self.groupBox_3)
@ -143,103 +265,17 @@ class Ui_fluencyCAD(object):
self.gridLayout.addWidget(self.groupBox_3, 1, 0, 1, 1) self.gridLayout.addWidget(self.groupBox_3, 1, 0, 1, 1)
self.groupBox = QGroupBox(self.centralwidget) self.groupBox_4 = QGroupBox(self.centralwidget)
self.groupBox.setObjectName(u"groupBox") self.groupBox_4.setObjectName(u"groupBox_4")
self.gridLayout_3 = QGridLayout(self.groupBox) self.verticalLayout_2 = QVBoxLayout(self.groupBox_4)
self.gridLayout_3.setObjectName(u"gridLayout_3") self.verticalLayout_2.setObjectName(u"verticalLayout_2")
self.pb_extrdop = QPushButton(self.groupBox) self.pushButton_2 = QPushButton(self.groupBox_4)
self.pb_extrdop.setObjectName(u"pb_extrdop") self.pushButton_2.setObjectName(u"pushButton_2")
self.gridLayout_3.addWidget(self.pb_extrdop, 0, 0, 1, 1) self.verticalLayout_2.addWidget(self.pushButton_2)
self.pb_cutop = QPushButton(self.groupBox)
self.pb_cutop.setObjectName(u"pb_cutop")
self.gridLayout_3.addWidget(self.pb_cutop, 0, 1, 1, 1)
self.pb_arrayop = QPushButton(self.groupBox)
self.pb_arrayop.setObjectName(u"pb_arrayop")
self.gridLayout_3.addWidget(self.pb_arrayop, 1, 0, 1, 1)
self.pb_revop = QPushButton(self.groupBox)
self.pb_revop.setObjectName(u"pb_revop")
self.gridLayout_3.addWidget(self.pb_revop, 1, 1, 1, 1)
self.gridLayout.addWidget(self.groupBox, 0, 5, 6, 1, Qt.AlignTop) self.gridLayout.addWidget(self.groupBox_4, 7, 5, 1, 1)
self.InputTab = QTabWidget(self.centralwidget)
self.InputTab.setObjectName(u"InputTab")
sizePolicy2 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
sizePolicy2.setHeightForWidth(self.InputTab.sizePolicy().hasHeightForWidth())
self.InputTab.setSizePolicy(sizePolicy2)
self.sketch_tab = QWidget()
self.sketch_tab.setObjectName(u"sketch_tab")
self.verticalLayout_4 = QVBoxLayout(self.sketch_tab)
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
self.InputTab.addTab(self.sketch_tab, "")
self.code_tab = QWidget()
self.code_tab.setObjectName(u"code_tab")
self.verticalLayout = QVBoxLayout(self.code_tab)
self.verticalLayout.setObjectName(u"verticalLayout")
self.textEdit = QTextEdit(self.code_tab)
self.textEdit.setObjectName(u"textEdit")
self.verticalLayout.addWidget(self.textEdit)
self.InputTab.addTab(self.code_tab, "")
self.gridLayout.addWidget(self.InputTab, 0, 2, 7, 1)
self.groupBox_5 = QGroupBox(self.centralwidget)
self.groupBox_5.setObjectName(u"groupBox_5")
sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(0)
sizePolicy3.setHeightForWidth(self.groupBox_5.sizePolicy().hasHeightForWidth())
self.groupBox_5.setSizePolicy(sizePolicy3)
self.groupBox_5.setMaximumSize(QSize(300, 16777215))
self.verticalLayout_3 = QVBoxLayout(self.groupBox_5)
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
self.element_list = QListWidget(self.groupBox_5)
self.element_list.setObjectName(u"element_list")
self.element_list.setSelectionRectVisible(True)
self.verticalLayout_3.addWidget(self.element_list)
self.groupBox_6 = QGroupBox(self.groupBox_5)
self.groupBox_6.setObjectName(u"groupBox_6")
sizePolicy4 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy4.setHorizontalStretch(0)
sizePolicy4.setVerticalStretch(0)
sizePolicy4.setHeightForWidth(self.groupBox_6.sizePolicy().hasHeightForWidth())
self.groupBox_6.setSizePolicy(sizePolicy4)
self.gridLayout_6 = QGridLayout(self.groupBox_6)
self.gridLayout_6.setObjectName(u"gridLayout_6")
self.pb_del_sketch = QPushButton(self.groupBox_6)
self.pb_del_sketch.setObjectName(u"pb_del_sketch")
self.gridLayout_6.addWidget(self.pb_del_sketch, 0, 2, 1, 1)
self.pb_nw_sktch = QPushButton(self.groupBox_6)
self.pb_nw_sktch.setObjectName(u"pb_nw_sktch")
self.gridLayout_6.addWidget(self.pb_nw_sktch, 0, 0, 1, 1)
self.pb_edt_sktch = QPushButton(self.groupBox_6)
self.pb_edt_sktch.setObjectName(u"pb_edt_sktch")
self.gridLayout_6.addWidget(self.pb_edt_sktch, 0, 1, 1, 1)
self.verticalLayout_3.addWidget(self.groupBox_6)
self.gridLayout.addWidget(self.groupBox_5, 0, 3, 7, 1)
fluencyCAD.setCentralWidget(self.centralwidget) fluencyCAD.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(fluencyCAD) self.menubar = QMenuBar(fluencyCAD)
@ -260,34 +296,39 @@ class Ui_fluencyCAD(object):
def retranslateUi(self, fluencyCAD): def retranslateUi(self, fluencyCAD):
fluencyCAD.setWindowTitle(QCoreApplication.translate("fluencyCAD", u"fluencyCAD", None)) fluencyCAD.setWindowTitle(QCoreApplication.translate("fluencyCAD", u"fluencyCAD", None))
self.gl_box.setTitle(QCoreApplication.translate("fluencyCAD", u"Model Viewer", None)) self.InputTab.setTabText(self.InputTab.indexOf(self.sketch_tab), QCoreApplication.translate("fluencyCAD", u"Sketch", None))
self.groupBox_7.setTitle(QCoreApplication.translate("fluencyCAD", u"Executive", None)) self.groupBox_7.setTitle(QCoreApplication.translate("fluencyCAD", u"Executive", None))
self.pb_apply_code.setText(QCoreApplication.translate("fluencyCAD", u"Apply Code", None))
self.pushButton_5.setText(QCoreApplication.translate("fluencyCAD", u"Load Code", None)) self.pushButton_5.setText(QCoreApplication.translate("fluencyCAD", u"Load Code", None))
self.pushButton_2.setText(QCoreApplication.translate("fluencyCAD", u"Export STL", None))
self.pushButton.setText(QCoreApplication.translate("fluencyCAD", u"Delete Code", None))
self.pushButton_4.setText(QCoreApplication.translate("fluencyCAD", u"Save code", None)) self.pushButton_4.setText(QCoreApplication.translate("fluencyCAD", u"Save code", None))
self.groupBox_2.setTitle(QCoreApplication.translate("fluencyCAD", u"Drawing", None)) self.pb_apply_code.setText(QCoreApplication.translate("fluencyCAD", u"Apply Code", None))
self.pb_rectool.setText(QCoreApplication.translate("fluencyCAD", u"Rctgl", None)) self.pushButton.setText(QCoreApplication.translate("fluencyCAD", u"Delete Code", None))
self.pb_linetool.setText(QCoreApplication.translate("fluencyCAD", u"Line", None)) self.InputTab.setTabText(self.InputTab.indexOf(self.code_tab), QCoreApplication.translate("fluencyCAD", u"Code", None))
self.pb_circtool.setText(QCoreApplication.translate("fluencyCAD", u"Circle", None))
self.pb_slotool.setText(QCoreApplication.translate("fluencyCAD", u"Slot", None))
self.groupBox_3.setTitle(QCoreApplication.translate("fluencyCAD", u"Constrain", None))
self.pb_con_line.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Line", None))
self.pb_con_ptpt.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Pt", None))
self.pb_con_horiz.setText(QCoreApplication.translate("fluencyCAD", u"Horiz", None))
self.pb_con_vert.setText(QCoreApplication.translate("fluencyCAD", u"Vert", None))
self.groupBox.setTitle(QCoreApplication.translate("fluencyCAD", u"Modify", None)) self.groupBox.setTitle(QCoreApplication.translate("fluencyCAD", u"Modify", None))
self.pb_extrdop.setText(QCoreApplication.translate("fluencyCAD", u"Extrd", None)) self.pb_extrdop.setText(QCoreApplication.translate("fluencyCAD", u"Extrd", None))
self.pb_cutop.setText(QCoreApplication.translate("fluencyCAD", u"Cut", None)) self.pb_cutop.setText(QCoreApplication.translate("fluencyCAD", u"Cut", None))
self.pb_arrayop.setText(QCoreApplication.translate("fluencyCAD", u"Arry", None)) self.pb_arrayop.setText(QCoreApplication.translate("fluencyCAD", u"Arry", None))
self.pb_revop.setText(QCoreApplication.translate("fluencyCAD", u"Rev", None)) self.pb_revop.setText(QCoreApplication.translate("fluencyCAD", u"Rev", None))
self.InputTab.setTabText(self.InputTab.indexOf(self.sketch_tab), QCoreApplication.translate("fluencyCAD", u"Sketch", None)) self.gl_box.setTitle(QCoreApplication.translate("fluencyCAD", u"Model Viewer", None))
self.InputTab.setTabText(self.InputTab.indexOf(self.code_tab), QCoreApplication.translate("fluencyCAD", u"Code", None)) self.groupBox_2.setTitle(QCoreApplication.translate("fluencyCAD", u"Drawing", None))
self.groupBox_5.setTitle(QCoreApplication.translate("fluencyCAD", u"Components", None)) self.pb_rectool.setText(QCoreApplication.translate("fluencyCAD", u"Rctgl", None))
self.pb_linetool.setText(QCoreApplication.translate("fluencyCAD", u"Line", None))
self.pb_circtool.setText(QCoreApplication.translate("fluencyCAD", u"Circle", None))
self.pb_slotool.setText(QCoreApplication.translate("fluencyCAD", u"Slot", None))
self.groupBox_5.setTitle(QCoreApplication.translate("fluencyCAD", u"Sketch", None))
self.groupBox_6.setTitle(QCoreApplication.translate("fluencyCAD", u"Tools", None)) self.groupBox_6.setTitle(QCoreApplication.translate("fluencyCAD", u"Tools", None))
self.pb_del_sketch.setText(QCoreApplication.translate("fluencyCAD", u"Del Elmt", None)) self.pb_del_sketch.setText(QCoreApplication.translate("fluencyCAD", u"Del sketch", None))
self.pb_nw_sktch.setText(QCoreApplication.translate("fluencyCAD", u"Add Sktch", None)) self.pb_nw_sktch.setText(QCoreApplication.translate("fluencyCAD", u"Add Sktch", None))
self.pb_edt_sktch.setText(QCoreApplication.translate("fluencyCAD", u"Edt Sktch", None)) self.pb_edt_sktch.setText(QCoreApplication.translate("fluencyCAD", u"Edt Sktch", None))
self.groupBox_8.setTitle(QCoreApplication.translate("fluencyCAD", u"Tools", None))
self.pb_del_body.setText(QCoreApplication.translate("fluencyCAD", u"Del Bdy", None))
self.pb_update_body.setText(QCoreApplication.translate("fluencyCAD", u"Bdy Upd", None))
self.pb_edt_sktch_3.setText(QCoreApplication.translate("fluencyCAD", u"Nothing", None))
self.groupBox_3.setTitle(QCoreApplication.translate("fluencyCAD", u"Constrain", None))
self.pb_con_line.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Line", None))
self.pb_con_ptpt.setText(QCoreApplication.translate("fluencyCAD", u"Pt_Pt", None))
self.pb_con_horiz.setText(QCoreApplication.translate("fluencyCAD", u"Horiz", None))
self.pb_con_vert.setText(QCoreApplication.translate("fluencyCAD", u"Vert", None))
self.groupBox_4.setTitle(QCoreApplication.translate("fluencyCAD", u"Export", None))
self.pushButton_2.setText(QCoreApplication.translate("fluencyCAD", u"STL", None))
# retranslateUi # retranslateUi

View File

@ -1,20 +1,47 @@
from PySide6.QtWidgets import QApplication, QWidget, QMessageBox from PySide6.QtWidgets import QApplication, QWidget, QMessageBox
from PySide6.QtGui import QPainter, QPen, QColor from PySide6.QtGui import QPainter, QPen, QColor
from PySide6.QtCore import Qt, QPoint from PySide6.QtCore import Qt, QPoint
from python_solvespace import SolverSystem, ResultFlag
class SketchWidget(QWidget):
class SnapLineWidget(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.points = [] self.points = []
self.selected_line = None self.selected_line = None
self.snapping_range = 20 # Range in pixels for snapping self.snapping_range = 20 # Range in pixels for snapping
self.line_mode = False self.line_mode = False
self.solv = SolverSystem()
def solve_constraint(self):
solv = SolverSystem()
wp = solv.create_2d_base() # Workplane (Entity)
p0 = solv.add_point_2d(0, 0, wp) # Entity
solv.dragged(p0, wp) # Make a constraint with the entity
...
line0 = solv.add_line_2d(p0, p1, wp) # Create entity with others
...
line1 = solv.add_line_2d(p0, p3, wp)
solv.angle(line0, line1, 45, wp) # Constrain two entities
line1 = solv.entity(-1) # Entity handle can be re-generated and negatively indexed
...
if solv.solve() == ResultFlag.OKAY:
# Get the result (unpack from the entity or parameters)
# x and y are actually float type
dof = solv.dof()
x, y = solv.params(p2.params)
...
else:
# Error!
# Get the list of all constraints
failures = solv.failures()
...
def set_points(self, points: list): def set_points(self, points: list):
self.points = points self.points = points
#self.update() #self.update()
def mousePressEvent(self, event): def mousePressEvent(self, event):
if event.button() == Qt.LeftButton and self.line_mode: if event.button() == Qt.LeftButton and self.line_mode:
self.points.append(event.pos()) self.points.append(event.pos())
@ -53,10 +80,10 @@ class SnapLineWidget(QWidget):
painter = QPainter(self) painter = QPainter(self)
# Set the background color # Set the background color
painter.fillRect(self.rect(), QColor('white')) painter.fillRect(self.rect(), QColor('black'))
pen = QPen(Qt.black) pen = QPen(Qt.gray)
pen.setWidth(1) pen.setWidth(2)
painter.setPen(pen) painter.setPen(pen)
for i in range(len(self.points) - 1): for i in range(len(self.points) - 1):
@ -83,7 +110,7 @@ if __name__ == "__main__":
import sys import sys
app = QApplication(sys.argv) app = QApplication(sys.argv)
window = SnapLineWidget() window = SketchWidget()
window.setWindowTitle("Snap Line Widget") window.setWindowTitle("Snap Line Widget")
window.resize(800, 600) window.resize(800, 600)
window.show() window.show()

View File

@ -73,6 +73,9 @@ class OpenGLWidget(QOpenGLWidget):
except Exception as e: except Exception as e:
print(e) print(e)
def clear_mesh(self):
self.mesh_loaded = None
def initializeGL(self): def initializeGL(self):
glClearColor(0, 0, 0, 1) glClearColor(0, 0, 0, 1)
@ -113,6 +116,9 @@ class OpenGLWidget(QOpenGLWidget):
gluLookAt(cx, cy, cz + 100, cx, cy, cz, 0, 1, 0) gluLookAt(cx, cy, cz + 100, cx, cy, cz, 0, 1, 0)
self.draw_mesh_direct(self.mesh_loaded) self.draw_mesh_direct(self.mesh_loaded)
else:
glClearColor(0.0, 0.0, 0.0, 1.0) # Set the clear color (black with full opacity)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Clear the color and depth buffers
def draw_stl(self, vertices): def draw_stl(self, vertices):

410
gui.ui
View File

@ -15,7 +15,110 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="4" rowspan="7"> <item row="0" column="2" rowspan="8">
<widget class="QTabWidget" name="InputTab">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="sketch_tab">
<attribute name="title">
<string>Sketch</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4"/>
</widget>
<widget class="QWidget" name="code_tab">
<attribute name="title">
<string>Code</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Executive</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>Load Code</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Save code</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_apply_code">
<property name="text">
<string>Apply Code</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Delete Code</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="5" rowspan="7" alignment="Qt::AlignTop">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Modify</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="pb_extrdop">
<property name="text">
<string>Extrd</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_cutop">
<property name="text">
<string extracomment="1. Bigger obj 2. smaller object">Cut</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_arrayop">
<property name="text">
<string>Arry</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pb_revop">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="4" rowspan="8">
<widget class="QGroupBox" name="gl_box"> <widget class="QGroupBox" name="gl_box">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -41,54 +144,10 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="6" column="5" alignment="Qt::AlignBottom">
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Executive</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QPushButton" name="pb_apply_code">
<property name="text">
<string>Apply Code</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>Load Code</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Export STL</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Delete Code</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Save code</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -134,10 +193,141 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="3" rowspan="8">
<widget class="QGroupBox" name="groupBox_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Sketch</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="sketch_list">
<property name="selectionRectVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Tools</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="pb_del_sketch">
<property name="text">
<string>Del sketch</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pb_nw_sktch">
<property name="text">
<string>Add Sktch</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_edt_sktch">
<property name="text">
<string>Edt Sktch</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QListWidget" name="body_list">
<property name="selectionRectVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Tools</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item row="0" column="2">
<widget class="QPushButton" name="pb_del_body">
<property name="text">
<string>Del Bdy</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pb_update_body">
<property name="text">
<string>Bdy Upd</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_edt_sktch_3">
<property name="text">
<string>Nothing</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -177,133 +367,19 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="5" rowspan="6" alignment="Qt::AlignTop"> <item row="7" column="5">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox_4">
<property name="title"> <property name="title">
<string>Modify</string> <string>Export</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="pb_extrdop">
<property name="text">
<string>Extrd</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_cutop">
<property name="text">
<string extracomment="1. Bigger obj 2. smaller object">Cut</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pb_arrayop">
<property name="text">
<string>Arry</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pb_revop">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="2" rowspan="7">
<widget class="QTabWidget" name="InputTab">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="sketch_tab">
<attribute name="title">
<string>Sketch</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4"/>
</widget>
<widget class="QWidget" name="code_tab">
<attribute name="title">
<string>Code</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QTextEdit" name="textEdit"/> <widget class="QPushButton" name="pushButton_2">
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="3" rowspan="7">
<widget class="QGroupBox" name="groupBox_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Components</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="element_list">
<property name="selectionRectVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Tools</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="2">
<widget class="QPushButton" name="pb_del_sketch">
<property name="text"> <property name="text">
<string>Del Elmt</string> <string>STL</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QPushButton" name="pb_nw_sktch">
<property name="text">
<string>Add Sktch</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_edt_sktch">
<property name="text">
<string>Edt Sktch</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

68
main.py
View File

@ -5,9 +5,9 @@ from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QMainWindow, QSizePolicy, QInputDialog from PySide6.QtWidgets import QApplication, QMainWindow, QSizePolicy, QInputDialog
from Gui import Ui_fluencyCAD # Import the generated GUI module from Gui import Ui_fluencyCAD # Import the generated GUI module
from drawing_modules.gl_widget import OpenGLWidget from drawing_modules.gl_widget import OpenGLWidget
from drawing_modules.draw_widget2d import SnapLineWidget from drawing_modules.draw_widget2d import SketchWidget
from sdf import * from sdf import *
import python_solvespace from python_solvespace import SolverSystem, ResultFlag
# main, draw_widget, gl_widget # main, draw_widget, gl_widget
@ -26,7 +26,7 @@ class MainWindow(QMainWindow):
size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
#self.openGLWidget.setSizePolicy(size_policy) #self.openGLWidget.setSizePolicy(size_policy)
self.sketchWidget = SnapLineWidget() self.sketchWidget = SketchWidget()
layout2 = self.ui.sketch_tab.layout() # Get the layout of self.ui.gl_canvas layout2 = self.ui.sketch_tab.layout() # Get the layout of self.ui.gl_canvas
layout2.addWidget(self.sketchWidget) layout2.addWidget(self.sketchWidget)
size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) size_policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
@ -40,8 +40,8 @@ class MainWindow(QMainWindow):
self.list_selected = [] self.list_selected = []
#self.ui.pb_apply_code.pressed.connect(self.check_current_tab) #self.ui.pb_apply_code.pressed.connect(self.check_current_tab)
self.ui.element_list.currentItemChanged.connect(self.on_item_changed) self.ui.sketch_list.currentItemChanged.connect(self.on_item_changed)
self.ui.element_list.itemChanged.connect(self.view_update) self.ui.sketch_list.itemChanged.connect(self.view_update)
### Sketches ### Sketches
self.ui.pb_nw_sktch.pressed.connect(self.add_sketch) self.ui.pb_nw_sktch.pressed.connect(self.add_sketch)
@ -50,10 +50,10 @@ class MainWindow(QMainWindow):
self.ui.pb_linetool.pressed.connect(self.act_line_mode) self.ui.pb_linetool.pressed.connect(self.act_line_mode)
### Operations ### Operations
self.ui.pb_extrdop.pressed.connect(self.send_extrude) self.ui.pb_extrdop.pressed.connect(self.send_extrude)
self.ui.pb_cutop.pressed.connect(self.send_cut) self.ui.pb_cutop.pressed.connect(self.send_cut)
self.ui.pb_del_body.pressed.connect(self.del_body)
def act_line_mode(self): def act_line_mode(self):
if not self.ui.pb_linetool.isChecked(): if not self.ui.pb_linetool.isChecked():
@ -64,9 +64,10 @@ class MainWindow(QMainWindow):
def view_update(self): def view_update(self):
print("Update") print("Update")
name = self.ui.element_list.currentItem().text() name = self.ui.body_list.currentItem().text()
print("selected_for disp", name) print("selected_for disp", name)
model = self.model['operation'][name]['sdf_object'] model = self.model['operation'][name]['sdf_object']
mesh = model.generate(samples=2**12) mesh = model.generate(samples=2**12)
@ -91,15 +92,15 @@ class MainWindow(QMainWindow):
self.model['sketch'][element['id']] = element self.model['sketch'][element['id']] = element
print(self.model) print(self.model)
self.ui.element_list.addItem(name) self.ui.sketch_list.addItem(name)
self.ui.pb_linetool.setChecked(False) self.ui.pb_linetool.setChecked(False)
self.sketchWidget.line_mode = False self.sketchWidget.line_mode = False
items = self.ui.element_list.findItems(name, Qt.MatchExactly)[0] items = self.ui.sketch_list.findItems(name, Qt.MatchExactly)[0]
self.ui.element_list.setCurrentItem(items) self.ui.sketch_list.setCurrentItem(items)
def edit_sketch(self): def edit_sketch(self):
name = self.ui.element_list.currentItem().text() name = self.ui.sketch_list.currentItem().text()
self.sketchWidget.clear_sketch() self.sketchWidget.clear_sketch()
points = self.model['sketch'][name]['sketch_points'] points = self.model['sketch'][name]['sketch_points']
print("points", points) print("points", points)
@ -107,7 +108,7 @@ class MainWindow(QMainWindow):
def del_sketch(self): def del_sketch(self):
print("Deleting") print("Deleting")
name = self.ui.element_list.currentItem() # Get the current item name = self.ui.sketch_list.currentItem() # Get the current item
print(self.model) print(self.model)
@ -118,8 +119,8 @@ class MainWindow(QMainWindow):
# Check if the 'sketch' key exists in the model dictionary # Check if the 'sketch' key exists in the model dictionary
if 'sketch' in self.model and item_name in self.model['sketch']: if 'sketch' in self.model and item_name in self.model['sketch']:
if self.model['sketch'][item_name]['id'] == item_name: if self.model['sketch'][item_name]['id'] == item_name:
row = self.ui.element_list.row(name) # Get the row of the current item row = self.ui.sketch_list.row(name) # Get the row of the current item
self.ui.element_list.takeItem(row) # Remove the item from the list widget self.ui.sketch_list.takeItem(row) # Remove the item from the list widget
self.sketchWidget.clear_sketch() self.sketchWidget.clear_sketch()
self.model['sketch'].pop(item_name) # Remove the item from the sketch dictionary self.model['sketch'].pop(item_name) # Remove the item from the sketch dictionary
print(f"Removed sketch: {item_name}") print(f"Removed sketch: {item_name}")
@ -127,8 +128,8 @@ class MainWindow(QMainWindow):
# Check if the 'operation' key exists in the model dictionary # Check if the 'operation' key exists in the model dictionary
elif 'operation' in self.model and item_name in self.model['operation']: elif 'operation' in self.model and item_name in self.model['operation']:
if self.model['operation'][item_name]['id'] == item_name: if self.model['operation'][item_name]['id'] == item_name:
row = self.ui.element_list.row(name) # Get the row of the current item row = self.ui.sketch_list.row(name) # Get the row of the current item
self.ui.element_list.takeItem(row) # Remove the item from the list widget self.ui.sketch_list.takeItem(row) # Remove the item from the list widget
self.sketchWidget.clear_sketch() self.sketchWidget.clear_sketch()
self.model['operation'].pop(item_name) # Remove the item from the operation dictionary self.model['operation'].pop(item_name) # Remove the item from the operation dictionary
print(f"Removed operation: {item_name}") print(f"Removed operation: {item_name}")
@ -137,6 +138,25 @@ class MainWindow(QMainWindow):
print(f"Item '{item_name}' not found in either 'sketch' or 'operation' dictionary.") print(f"Item '{item_name}' not found in either 'sketch' or 'operation' dictionary.")
else: else:
print("No item selected.") print("No item selected.")
def update_body(self):
pass
def del_body(self):
print("Deleting")
name = self.ui.body_list.currentItem() # Get the current item
if name is not None:
item_name = name.text()
print("obj_name", item_name)
# Check if the 'operation' key exists in the model dictionary
if 'operation' in self.model and item_name in self.model['operation']:
if self.model['operation'][item_name]['id'] == item_name:
row = self.ui.body_list.row(name) # Get the row of the current item
self.ui.body_list.takeItem(row) # Remove the item from the list widget
self.model['operation'].pop(item_name) # Remove the item from the operation dictionary
print(f"Removed operation: {item_name}")
self.openGLWidget.clear_mesh()
def translate_points_tup(self, points): def translate_points_tup(self, points):
"""QPoints from Display to mesh data """QPoints from Display to mesh data
@ -152,7 +172,7 @@ class MainWindow(QMainWindow):
def send_extrude(self): def send_extrude(self):
selected = self.ui.element_list.currentItem() selected = self.ui.sketch_list.currentItem()
name = selected.text() name = selected.text()
points = self.model['sketch'][name]['sketch_points'] points = self.model['sketch'][name]['sketch_points']
@ -175,14 +195,14 @@ class MainWindow(QMainWindow):
self.model['operation'][name_op] = element self.model['operation'][name_op] = element
self.ui.element_list.addItem(name_op) self.ui.body_list.addItem(name_op)
items = self.ui.element_list.findItems(name_op, Qt.MatchExactly)[0] items = self.ui.body_list.findItems(name_op, Qt.MatchExactly)[0]
self.ui.element_list.setCurrentItem(items) self.ui.body_list.setCurrentItem(items)
self.view_update() self.view_update()
def send_cut(self): def send_cut(self):
name = self.ui.element_list.currentItem().text() name = self.ui.sketch_list.currentItem().text()
points = self.model['operation'][name]['sdf_object'] points = self.model['operation'][name]['sdf_object']
self.list_selected.append(points) self.list_selected.append(points)
print(self.list_selected) print(self.list_selected)
@ -199,9 +219,9 @@ class MainWindow(QMainWindow):
name_op = f"cut-{name}" name_op = f"cut-{name}"
self.model['operation'][name_op] = element self.model['operation'][name_op] = element
self.ui.element_list.addItem(name_op) self.ui.body_list.addItem(name_op)
items = self.ui.element_list.findItems(name_op, Qt.MatchExactly) items = self.ui.sketch_list.findItems(name_op, Qt.MatchExactly)
self.ui.element_list.setCurrentItem(items[0]) self.ui.body_list.setCurrentItem(items[0])
self.view_update() self.view_update()
else: else: