From e3a8d55850a9ec17c340737f7ab719c580b8f321 Mon Sep 17 00:00:00 2001 From: bklronin Date: Tue, 23 Jul 2024 15:25:50 +0200 Subject: [PATCH] - intial transit --- Gui.py | 431 ++++++++++++++++++++++-------------------- gui.ui | 566 ++++++++++++++++++++++++++++++-------------------------- main.py | 446 +++++++++++++++++++++++++++----------------- 3 files changed, 806 insertions(+), 637 deletions(-) diff --git a/Gui.py b/Gui.py index c58dfcd..42cd35a 100644 --- a/Gui.py +++ b/Gui.py @@ -11,139 +11,31 @@ from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt) -from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, - QFont, QFontDatabase, QGradient, QIcon, - QImage, QKeySequence, QLinearGradient, QPainter, - QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient, + QCursor, QFont, QFontDatabase, QGradient, + QIcon, QImage, QKeySequence, QLinearGradient, + QPainter, QPalette, QPixmap, QRadialGradient, + QTransform) from PySide6.QtWidgets import (QApplication, QGridLayout, QGroupBox, QHBoxLayout, - QListWidget, QListWidgetItem, QMainWindow, QMenuBar, - QPushButton, QSizePolicy, QStatusBar, QTabWidget, - QTextEdit, QVBoxLayout, QWidget) + QListWidget, QListWidgetItem, QMainWindow, QMenu, + QMenuBar, QPushButton, QSizePolicy, QStatusBar, + QTabWidget, QTextEdit, QVBoxLayout, QWidget) class Ui_fluencyCAD(object): def setupUi(self, fluencyCAD): if not fluencyCAD.objectName(): fluencyCAD.setObjectName(u"fluencyCAD") fluencyCAD.resize(2214, 803) + self.actionNew_Project = QAction(fluencyCAD) + self.actionNew_Project.setObjectName(u"actionNew_Project") + self.actionLoad_Project = QAction(fluencyCAD) + self.actionLoad_Project.setObjectName(u"actionLoad_Project") + self.actionRecent = QAction(fluencyCAD) + self.actionRecent.setObjectName(u"actionRecent") self.centralwidget = QWidget(fluencyCAD) self.centralwidget.setObjectName(u"centralwidget") self.gridLayout = QGridLayout(self.centralwidget) self.gridLayout.setObjectName(u"gridLayout") - 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_revop = QPushButton(self.groupBox) - self.pb_revop.setObjectName(u"pb_revop") - - self.gridLayout_3.addWidget(self.pb_revop, 2, 1, 1, 1) - - 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_arrayop = QPushButton(self.groupBox) - self.pb_arrayop.setObjectName(u"pb_arrayop") - - self.gridLayout_3.addWidget(self.pb_arrayop, 2, 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_combop = QPushButton(self.groupBox) - self.pb_combop.setObjectName(u"pb_combop") - - self.gridLayout_3.addWidget(self.pb_combop, 1, 0, 1, 1) - - self.pb_moveop = QPushButton(self.groupBox) - self.pb_moveop.setObjectName(u"pb_moveop") - - self.gridLayout_3.addWidget(self.pb_moveop, 1, 1, 1, 1) - - - self.gridLayout.addWidget(self.groupBox, 0, 5, 10, 1, Qt.AlignTop) - - self.groupBox_5 = QGroupBox(self.centralwidget) - self.groupBox_5.setObjectName(u"groupBox_5") - sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.groupBox_5.sizePolicy().hasHeightForWidth()) - self.groupBox_5.setSizePolicy(sizePolicy) - 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") - sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy1.setHorizontalStretch(0) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.groupBox_6.sizePolicy().hasHeightForWidth()) - self.groupBox_6.setSizePolicy(sizePolicy1) - 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") - sizePolicy1.setHeightForWidth(self.groupBox_8.sizePolicy().hasHeightForWidth()) - self.groupBox_8.setSizePolicy(sizePolicy1) - 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, 12, 1) - self.groupBox_9 = QGroupBox(self.centralwidget) self.groupBox_9.setObjectName(u"groupBox_9") self.gridLayout_7 = QGridLayout(self.groupBox_9) @@ -173,8 +65,11 @@ class Ui_fluencyCAD(object): self.groupBox_3 = QGroupBox(self.centralwidget) self.groupBox_3.setObjectName(u"groupBox_3") - sizePolicy1.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth()) - self.groupBox_3.setSizePolicy(sizePolicy1) + sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth()) + self.groupBox_3.setSizePolicy(sizePolicy) self.groupBox_3.setMaximumSize(QSize(16777214, 16777213)) self.gridLayout_4 = QGridLayout(self.groupBox_3) self.gridLayout_4.setObjectName(u"gridLayout_4") @@ -236,6 +131,62 @@ class Ui_fluencyCAD(object): self.gridLayout.addWidget(self.groupBox_3, 2, 0, 1, 1) + self.groupBox_2 = QGroupBox(self.centralwidget) + self.groupBox_2.setObjectName(u"groupBox_2") + sizePolicy.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth()) + self.groupBox_2.setSizePolicy(sizePolicy) + self.gridLayout_2 = QGridLayout(self.groupBox_2) + self.gridLayout_2.setObjectName(u"gridLayout_2") + self.pb_rectool = QPushButton(self.groupBox_2) + self.pb_rectool.setObjectName(u"pb_rectool") + self.pb_rectool.setCheckable(True) + self.pb_rectool.setAutoExclusive(False) + + self.gridLayout_2.addWidget(self.pb_rectool, 1, 1, 1, 1, Qt.AlignTop) + + self.pb_circtool = QPushButton(self.groupBox_2) + self.pb_circtool.setObjectName(u"pb_circtool") + self.pb_circtool.setCheckable(True) + self.pb_circtool.setAutoExclusive(False) + + self.gridLayout_2.addWidget(self.pb_circtool, 2, 0, 1, 1, Qt.AlignTop) + + self.pb_slotool = QPushButton(self.groupBox_2) + self.pb_slotool.setObjectName(u"pb_slotool") + self.pb_slotool.setCheckable(True) + self.pb_slotool.setAutoExclusive(False) + + self.gridLayout_2.addWidget(self.pb_slotool, 2, 1, 1, 1, Qt.AlignTop) + + self.pb_linetool = QPushButton(self.groupBox_2) + self.pb_linetool.setObjectName(u"pb_linetool") + self.pb_linetool.setCheckable(True) + self.pb_linetool.setAutoExclusive(False) + + self.gridLayout_2.addWidget(self.pb_linetool, 1, 0, 1, 1) + + + self.gridLayout.addWidget(self.groupBox_2, 1, 0, 1, 1) + + self.gl_box = QGroupBox(self.centralwidget) + self.gl_box.setObjectName(u"gl_box") + sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + sizePolicy1.setHorizontalStretch(0) + sizePolicy1.setVerticalStretch(4) + sizePolicy1.setHeightForWidth(self.gl_box.sizePolicy().hasHeightForWidth()) + self.gl_box.setSizePolicy(sizePolicy1) + font = QFont() + font.setPointSize(12) + self.gl_box.setFont(font) + self.horizontalLayout_4 = QHBoxLayout(self.gl_box) +#ifndef Q_OS_MAC + self.horizontalLayout_4.setSpacing(-1) +#endif + self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") + self.horizontalLayout_4.setContentsMargins(12, -1, -1, -1) + + self.gridLayout.addWidget(self.gl_box, 0, 4, 12, 1) + self.InputTab = QTabWidget(self.centralwidget) self.InputTab.setObjectName(u"InputTab") sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) @@ -288,6 +239,43 @@ class Ui_fluencyCAD(object): self.gridLayout.addWidget(self.InputTab, 0, 2, 12, 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_revop = QPushButton(self.groupBox) + self.pb_revop.setObjectName(u"pb_revop") + + self.gridLayout_3.addWidget(self.pb_revop, 2, 1, 1, 1) + + 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_arrayop = QPushButton(self.groupBox) + self.pb_arrayop.setObjectName(u"pb_arrayop") + + self.gridLayout_3.addWidget(self.pb_arrayop, 2, 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_combop = QPushButton(self.groupBox) + self.pb_combop.setObjectName(u"pb_combop") + + self.gridLayout_3.addWidget(self.pb_combop, 1, 0, 1, 1) + + self.pb_moveop = QPushButton(self.groupBox) + self.pb_moveop.setObjectName(u"pb_moveop") + + self.gridLayout_3.addWidget(self.pb_moveop, 1, 1, 1, 1) + + + self.gridLayout.addWidget(self.groupBox, 0, 5, 10, 1, Qt.AlignTop) + self.groupBox_4 = QGroupBox(self.centralwidget) self.groupBox_4.setObjectName(u"groupBox_4") self.verticalLayout_2 = QVBoxLayout(self.groupBox_4) @@ -300,71 +288,106 @@ class Ui_fluencyCAD(object): self.gridLayout.addWidget(self.groupBox_4, 11, 5, 1, 1) - self.groupBox_2 = QGroupBox(self.centralwidget) - self.groupBox_2.setObjectName(u"groupBox_2") - sizePolicy1.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth()) - self.groupBox_2.setSizePolicy(sizePolicy1) - self.gridLayout_2 = QGridLayout(self.groupBox_2) - self.gridLayout_2.setObjectName(u"gridLayout_2") - self.pb_rectool = QPushButton(self.groupBox_2) - self.pb_rectool.setObjectName(u"pb_rectool") - self.pb_rectool.setCheckable(True) - self.pb_rectool.setAutoExclusive(False) - - self.gridLayout_2.addWidget(self.pb_rectool, 1, 1, 1, 1, Qt.AlignTop) - - self.pb_circtool = QPushButton(self.groupBox_2) - self.pb_circtool.setObjectName(u"pb_circtool") - self.pb_circtool.setCheckable(True) - self.pb_circtool.setAutoExclusive(False) - - self.gridLayout_2.addWidget(self.pb_circtool, 2, 0, 1, 1, Qt.AlignTop) - - self.pb_slotool = QPushButton(self.groupBox_2) - self.pb_slotool.setObjectName(u"pb_slotool") - self.pb_slotool.setCheckable(True) - self.pb_slotool.setAutoExclusive(False) - - self.gridLayout_2.addWidget(self.pb_slotool, 2, 1, 1, 1, Qt.AlignTop) - - self.pb_linetool = QPushButton(self.groupBox_2) - self.pb_linetool.setObjectName(u"pb_linetool") - self.pb_linetool.setCheckable(True) - self.pb_linetool.setAutoExclusive(False) - - self.gridLayout_2.addWidget(self.pb_linetool, 1, 0, 1, 1) - - - self.gridLayout.addWidget(self.groupBox_2, 1, 0, 1, 1) - - self.gl_box = QGroupBox(self.centralwidget) - self.gl_box.setObjectName(u"gl_box") + self.groupBox_5 = QGroupBox(self.centralwidget) + self.groupBox_5.setObjectName(u"groupBox_5") sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy3.setHorizontalStretch(0) - sizePolicy3.setVerticalStretch(4) - sizePolicy3.setHeightForWidth(self.gl_box.sizePolicy().hasHeightForWidth()) - self.gl_box.setSizePolicy(sizePolicy3) - font = QFont() - font.setPointSize(12) - self.gl_box.setFont(font) - self.horizontalLayout_4 = QHBoxLayout(self.gl_box) -#ifndef Q_OS_MAC - self.horizontalLayout_4.setSpacing(-1) -#endif - self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") - self.horizontalLayout_4.setContentsMargins(12, -1, -1, -1) + 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.gridLayout.addWidget(self.gl_box, 0, 4, 12, 1) + self.verticalLayout_3.addWidget(self.sketch_list) + + self.groupBox_6 = QGroupBox(self.groupBox_5) + self.groupBox_6.setObjectName(u"groupBox_6") + sizePolicy.setHeightForWidth(self.groupBox_6.sizePolicy().hasHeightForWidth()) + self.groupBox_6.setSizePolicy(sizePolicy) + 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") + sizePolicy.setHeightForWidth(self.groupBox_8.sizePolicy().hasHeightForWidth()) + self.groupBox_8.setSizePolicy(sizePolicy) + 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, 12, 1) + + self.timeline_box = QGroupBox(self.centralwidget) + self.timeline_box.setObjectName(u"timeline_box") + + self.gridLayout.addWidget(self.timeline_box, 12, 2, 1, 3) fluencyCAD.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(fluencyCAD) self.menubar.setObjectName(u"menubar") self.menubar.setGeometry(QRect(0, 0, 2214, 24)) + self.menuFile = QMenu(self.menubar) + self.menuFile.setObjectName(u"menuFile") + self.menuSettings = QMenu(self.menubar) + self.menuSettings.setObjectName(u"menuSettings") fluencyCAD.setMenuBar(self.menubar) self.statusbar = QStatusBar(fluencyCAD) self.statusbar.setObjectName(u"statusbar") fluencyCAD.setStatusBar(self.statusbar) + self.menubar.addAction(self.menuFile.menuAction()) + self.menubar.addAction(self.menuSettings.menuAction()) + self.menuFile.addAction(self.actionNew_Project) + self.menuFile.addAction(self.actionLoad_Project) + self.menuFile.addAction(self.actionRecent) + self.menuFile.addSeparator() + self.retranslateUi(fluencyCAD) self.InputTab.setCurrentIndex(0) @@ -375,22 +398,9 @@ class Ui_fluencyCAD(object): def retranslateUi(self, fluencyCAD): fluencyCAD.setWindowTitle(QCoreApplication.translate("fluencyCAD", u"fluencyCAD", None)) - self.groupBox.setTitle(QCoreApplication.translate("fluencyCAD", u"Modify", None)) - self.pb_revop.setText(QCoreApplication.translate("fluencyCAD", u"Rev", None)) - self.pb_extrdop.setText(QCoreApplication.translate("fluencyCAD", u"Extrd", None)) - self.pb_arrayop.setText(QCoreApplication.translate("fluencyCAD", u"Arry", None)) - self.pb_cutop.setText(QCoreApplication.translate("fluencyCAD", u"Cut", None)) - self.pb_combop.setText(QCoreApplication.translate("fluencyCAD", u"Comb", None)) - self.pb_moveop.setText(QCoreApplication.translate("fluencyCAD", u"Mve", None)) - self.groupBox_5.setTitle(QCoreApplication.translate("fluencyCAD", u"Sketch", None)) - self.groupBox_6.setTitle(QCoreApplication.translate("fluencyCAD", u"Tools", 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_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.actionNew_Project.setText(QCoreApplication.translate("fluencyCAD", u"New", None)) + self.actionLoad_Project.setText(QCoreApplication.translate("fluencyCAD", u"Load", None)) + self.actionRecent.setText(QCoreApplication.translate("fluencyCAD", u"Recent", None)) self.groupBox_9.setTitle(QCoreApplication.translate("fluencyCAD", u"Workplanes", None)) #if QT_CONFIG(tooltip) self.pb_origin_wp.setToolTip(QCoreApplication.translate("fluencyCAD", u"orking Plane at 0, 0, 0", None)) @@ -450,15 +460,6 @@ class Ui_fluencyCAD(object): self.pb_con_perp.setToolTip(QCoreApplication.translate("fluencyCAD", u"Constrain Line perpendicular to another line.", None)) #endif // QT_CONFIG(tooltip) self.pb_con_perp.setText(QCoreApplication.translate("fluencyCAD", u"Perp_Lne", 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.pushButton_5.setText(QCoreApplication.translate("fluencyCAD", u"Load Code", None)) - self.pushButton_4.setText(QCoreApplication.translate("fluencyCAD", u"Save code", None)) - self.pb_apply_code.setText(QCoreApplication.translate("fluencyCAD", u"Apply Code", None)) - self.pushButton.setText(QCoreApplication.translate("fluencyCAD", u"Delete Code", None)) - self.InputTab.setTabText(self.InputTab.indexOf(self.code_tab), QCoreApplication.translate("fluencyCAD", u"Code", None)) - self.groupBox_4.setTitle(QCoreApplication.translate("fluencyCAD", u"Export", None)) - self.pushButton_2.setText(QCoreApplication.translate("fluencyCAD", u"STL", None)) self.groupBox_2.setTitle(QCoreApplication.translate("fluencyCAD", u"Drawing", None)) self.pb_rectool.setText(QCoreApplication.translate("fluencyCAD", u"Rctgl", None)) self.pb_circtool.setText(QCoreApplication.translate("fluencyCAD", u"Circle", None)) @@ -471,5 +472,33 @@ class Ui_fluencyCAD(object): self.pb_linetool.setShortcut(QCoreApplication.translate("fluencyCAD", u"S", None)) #endif // QT_CONFIG(shortcut) 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.pushButton_5.setText(QCoreApplication.translate("fluencyCAD", u"Load Code", None)) + self.pushButton_4.setText(QCoreApplication.translate("fluencyCAD", u"Save code", None)) + self.pb_apply_code.setText(QCoreApplication.translate("fluencyCAD", u"Apply Code", None)) + self.pushButton.setText(QCoreApplication.translate("fluencyCAD", u"Delete Code", None)) + self.InputTab.setTabText(self.InputTab.indexOf(self.code_tab), QCoreApplication.translate("fluencyCAD", u"Code", None)) + self.groupBox.setTitle(QCoreApplication.translate("fluencyCAD", u"Modify", None)) + self.pb_revop.setText(QCoreApplication.translate("fluencyCAD", u"Rev", None)) + self.pb_extrdop.setText(QCoreApplication.translate("fluencyCAD", u"Extrd", None)) + self.pb_arrayop.setText(QCoreApplication.translate("fluencyCAD", u"Arry", None)) + self.pb_cutop.setText(QCoreApplication.translate("fluencyCAD", u"Cut", None)) + self.pb_combop.setText(QCoreApplication.translate("fluencyCAD", u"Comb", None)) + self.pb_moveop.setText(QCoreApplication.translate("fluencyCAD", u"Mve", None)) + self.groupBox_4.setTitle(QCoreApplication.translate("fluencyCAD", u"Export", None)) + self.pushButton_2.setText(QCoreApplication.translate("fluencyCAD", u"STL", None)) + self.groupBox_5.setTitle(QCoreApplication.translate("fluencyCAD", u"Sketch", None)) + self.groupBox_6.setTitle(QCoreApplication.translate("fluencyCAD", u"Tools", 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_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.timeline_box.setTitle(QCoreApplication.translate("fluencyCAD", u"Timeline", None)) + self.menuFile.setTitle(QCoreApplication.translate("fluencyCAD", u"File", None)) + self.menuSettings.setTitle(QCoreApplication.translate("fluencyCAD", u"Settings", None)) # retranslateUi diff --git a/gui.ui b/gui.ui index fbeea87..c3f03d5 100644 --- a/gui.ui +++ b/gui.ui @@ -15,188 +15,6 @@ - - - - Modify - - - - - - Rev - - - - - - - Extrd - - - - - - - Arry - - - - - - - Cut - - - - - - - Comb - - - - - - - Mve - - - - - - - - - - - 0 - 0 - - - - - 300 - 16777215 - - - - Sketch - - - - - - true - - - - - - - - 0 - 0 - - - - Tools - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - Del sketch - - - - - - - Add Sktch - - - - - - - Edt Sktch - - - - - - - - - - true - - - - - - - - 0 - 0 - - - - Tools - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - Del Bdy - - - - - - - Bdy Upd - - - - - - - Nothing - - - - - - - - - @@ -401,88 +219,6 @@ - - - - - 0 - 0 - - - - 0 - - - - Sketch - - - - - - Code - - - - - - - - - Executive - - - - - - Load Code - - - - - - - Save code - - - - - - - Apply Code - - - - - - - Delete Code - - - - - - - - - - - - - - Export - - - - - - STL - - - - - - @@ -582,6 +318,277 @@ + + + + + 0 + 0 + + + + 0 + + + + Sketch + + + + + + Code + + + + + + + + + Executive + + + + + + Load Code + + + + + + + Save code + + + + + + + Apply Code + + + + + + + Delete Code + + + + + + + + + + + + + + Modify + + + + + + Rev + + + + + + + Extrd + + + + + + + Arry + + + + + + + Cut + + + + + + + Comb + + + + + + + Mve + + + + + + + + + + Export + + + + + + STL + + + + + + + + + + + 0 + 0 + + + + + 300 + 16777215 + + + + Sketch + + + + + + true + + + + + + + + 0 + 0 + + + + Tools + + + + 2 + + + 2 + + + 2 + + + 2 + + + + + Del sketch + + + + + + + Add Sktch + + + + + + + Edt Sktch + + + + + + + + + + true + + + + + + + + 0 + 0 + + + + Tools + + + + 2 + + + 2 + + + 2 + + + 2 + + + + + Del Bdy + + + + + + + Bdy Upd + + + + + + + Nothing + + + + + + + + + + + + + Timeline + + + @@ -593,8 +600,39 @@ 24 + + + File + + + + + + + + + Settings + + + + + + + New + + + + + Load + + + + + Recent + + diff --git a/main.py b/main.py index c069699..86513c8 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ import uuid import names -from PySide6.QtCore import Qt, QPoint, Signal +from PySide6.QtCore import Qt, QPoint, Signal, QSize from PySide6.QtWidgets import QApplication, QMainWindow, QSizePolicy, QInputDialog, QDialog, QVBoxLayout, QHBoxLayout, QLabel, QDoubleSpinBox, QCheckBox, QPushButton from Gui import Ui_fluencyCAD # Import the generated GUI module from drawing_modules.vtk_widget import VTKWidget @@ -138,34 +138,18 @@ class MainWindow(QMainWindow): self.send_command.connect(self.custom_3D_Widget.on_receive_command) + self.ui.actionNew_Project.triggered.connect(self.new_project) + + self.project = Project() + self.new_project() + + """Project -> Timeline -> Component -> Sketch -> Body / Interactor -> Connector -> Assembly -> PB Render""" + + + def on_flip_face(self): self.send_command.emit("flip") - def add_new_sketch_origin(self): - self.sketchWidget.clear_sketch() - self.sketchWidget.create_workplane() - - def add_new_sketch_wp(self): - self.sketchWidget.clear_sketch() - #edges = [((-158.0, -20.0, -25.0), (286.0, -195.0, -25.0)), ((-158.0, -20.0, 25.0), (-158.0, -20.0, -25.0))] - points = self.custom_3D_Widget.project_tosketch_points - normal = self.custom_3D_Widget.selected_normal - selected_lines = self.custom_3D_Widget.project_tosketch_lines - print("Selected lines", selected_lines) - - self.sketchWidget.create_workplane_projected() - self.sketchWidget.create_proj_points(points) - self.sketchWidget.create_proj_lines(selected_lines) - - # CLear all selections after it has been projected - 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) - def act_line_mode(self): if not self.ui.pb_linetool.isChecked(): self.sketchWidget.mouse_mode = 'line' @@ -224,7 +208,7 @@ class MainWindow(QMainWindow): def draw_mesh(self): name = self.ui.body_list.currentItem().text() print("selected_for disp", name) - model = self.model['operation'][name]['sdf_object'] + model = self.project.timeline[-1].body.sdf_body vesta = vesta_mesh model_data = vesta.generate_mesh_from_sdf(model, resolution=64, threshold=0) @@ -239,43 +223,74 @@ class MainWindow(QMainWindow): #self.view_update() print(f"Selected item: {name}") - def convert_points_for_sdf(self): - points_for_sdf = [] - for point_to_poly in self.sketchWidget.slv_points_main: - points_for_sdf.append(self.translate_points_tup(point_to_poly['ui_point'])) + def new_project(self): + print("New project") + timeline = [] + self.project.timeline = timeline + self.new_component() - return points_for_sdf + def new_component(self): + print("Compo") + compo = Component() + compo.id = "New Compo" + compo.descript = "Initial Component" + self.project.timeline.append(compo) - def convert_lines_for_interactor(self): - points_for_interact = [] - for point_to_poly in self.sketchWidget.slv_lines_main: - start, end = point_to_poly['ui_points'] - from_coord_start = self.sketchWidget.from_quadrant_coords_no_center(start) - from_coord_end = self.sketchWidget.from_quadrant_coords_no_center(end) - start_draw = self.translate_points_tup(from_coord_start) - end_draw = self.translate_points_tup(from_coord_end) - line = start_draw, end_draw - points_for_interact.append(line) + # Create a horizontal layout + horizontal_layout = QHBoxLayout() - print("packed_lines", points_for_interact) + # Set the layout for the timeline_box QFrame + self.ui.timeline_box.setLayout(horizontal_layout) - return points_for_interact + # Create the button + button = QPushButton() + + button.setToolTip(compo.id) + button.setText(str(len(self.project.timeline))) + + # Set the button's fixed size + button.setFixedSize(QSize(40, 40)) + + # Add the button to the horizontal layout + horizontal_layout.addWidget(button) + # Set the alignment of the layout to left + horizontal_layout.setAlignment(Qt.AlignLeft) + + def add_new_sketch_origin(self): + self.sketchWidget.clear_sketch() + self.sketchWidget.create_workplane() + + def add_new_sketch_wp(self): + self.sketchWidget.clear_sketch() + #edges = [((-158.0, -20.0, -25.0), (286.0, -195.0, -25.0)), ((-158.0, -20.0, 25.0), (-158.0, -20.0, -25.0))] + points = self.custom_3D_Widget.project_tosketch_points + normal = self.custom_3D_Widget.selected_normal + selected_lines = self.custom_3D_Widget.project_tosketch_lines + print("Selected lines", selected_lines) + + self.sketchWidget.create_workplane_projected() + self.sketchWidget.create_proj_points(points) + self.sketchWidget.create_proj_lines(selected_lines) + + # CLear all selections after it has been projected + 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) def add_sketch(self): name = f"sketch-{str(names.get_first_name())}" - points_for_sdf = self.convert_points_for_sdf() - element = { - 'id': name, - 'type': 'sketch', - 'point_list': self.sketchWidget.slv_points_main, - 'line_list': self.sketchWidget.slv_lines_main, - 'sketch_points': points_for_sdf, - 'solver': self.sketchWidget.solv - } + sketch = Sketch() + sketch.id = name + sketch.slv_points = self.sketchWidget.slv_points_main + sketch.slv_lines = self.sketchWidget.slv_lines_main + sketch.convert_points_for_sdf() - self.model['sketch'][element['id']] = element - print(self.model) + self.project.timeline[-1].sketch = sketch self.ui.sketch_list.addItem(name) self.ui.pb_linetool.setChecked(False) @@ -349,55 +364,18 @@ class MainWindow(QMainWindow): print(f"Removed operation: {item_name}") self.custom_3D_Widget.clear_mesh() - def translate_points_tup(self, point: QPoint): - """QPoints from Display to mesh data - input: Qpoints - output: Tuple X,Y - """ - if isinstance(point, QPoint): - return point.x(), point.y() - - def rotate_point_to_normal(self, centroid, normal): - # Ensure the normal is a unit vector - normal = normal / np.linalg.norm(normal) - - # Initial direction (assuming positive Z-axis) - initial_direction = np.array([0, 0, 1]) - - # Compute rotation axis - rotation_axis = np.cross(initial_direction, normal) - - # If rotation axis is zero (vectors are parallel), no rotation is needed - if np.allclose(rotation_axis, 0): - return centroid - - # Compute rotation angle - rotation_angle = np.arccos(np.dot(initial_direction, normal)) - - # Create rotation matrix using Rodrigues' formula - K = np.array([ - [0, -rotation_axis[2], rotation_axis[1]], - [rotation_axis[2], 0, -rotation_axis[0]], - [-rotation_axis[1], rotation_axis[0], 0] - ]) - rotation_matrix = ( - np.eye(3) + - np.sin(rotation_angle) * K + - (1 - np.cos(rotation_angle)) * np.dot(K, K) - ) - - # Apply rotation to centroid - rotated_centroid = np.dot(rotation_matrix, centroid) - - return rotated_centroid - def send_extrude(self): + # Dialog input is_symmetric = None length = None invert = None + selected = self.ui.sketch_list.currentItem() name = selected.text() - points = self.model['sketch'][name]['sketch_points'] + # TODO: add selected element from timeline + sel_compo = self.project.timeline[-1] + sketch = sel_compo.sketch + points = sketch.sdf_points if points[-1] == points[0]: #detect loop that causes problems in mesh generation @@ -411,7 +389,6 @@ class MainWindow(QMainWindow): length = 0 print("Extrude cancelled") - geo = Geometry() normal = self.custom_3D_Widget.selected_normal #print("Normie enter", normal) @@ -425,31 +402,33 @@ class MainWindow(QMainWindow): centroid = list(centroid) #print("This centroid ", centroid) - f = geo.extrude_shape(points, length, normal, centroid, is_symmetric, invert, 0) + sketch.origin = centroid + sketch.normal = normal + + f = sketch.extrude(length, is_symmetric, invert, 0) name_op = f"extrd-{name}" - element = { - 'id': name_op, - 'type': 'extrude', - 'sdf_object': f, - } + sel_compo.body = Body() + sel_compo.body.sketch = sketch #we add the sketch for reference here + sel_compo.body.id = name_op + sel_compo.body.sdf_body = f ### Interactor - lines = self.convert_lines_for_interactor() + sel_compo.interactor = Interactor() + sel_compo.interactor.add_lines_for_interactor(sketch.slv_lines) if not invert: - edges = interactor_mesh.generate_mesh(lines, 0, length) + edges = interactor_mesh.generate_mesh(sel_compo.interactor.lines, 0, length) else: - edges = interactor_mesh.generate_mesh(lines, 0, -length) + edges = interactor_mesh.generate_mesh(sel_compo.interactor.lines, 0, -length) - offset_vector = geo.vector_to_centroid(None, centroid, normal) + offset_vector = sel_compo.interactor.vector_to_centroid(None, centroid, normal) #print("off_ved", offset_vector) if len(offset_vector) == 0 : offset_vector = [0, 0, 0] self.custom_3D_Widget.load_interactor_mesh(edges, offset_vector) - self.model['operation'][name_op] = element self.ui.body_list.addItem(name_op) items = self.ui.body_list.findItems(name_op, Qt.MatchExactly)[0] self.ui.body_list.setCurrentItem(items) @@ -488,7 +467,114 @@ class MainWindow(QMainWindow): self.custom_3D_Widget.update() -class Geometry: + +@dataclass +class Timeline: + """Timeline """ + timeline: list = None + + """add to time, + remove from time, """ + +class Assembly: + """Connecting Components in 3D space based on slvs solver""" + +@dataclass +class Component: + """The base container combining all related elements + id : The unique ID + sketch : the base sketch, bodys can contain additonal sketches for features + interactor : A smiplified model used as interactor + body : The body class that contains the actual 3d information + connector : Vector and Nomral information for assembly + descript : a basic description + materil : Speicfy a material for pbr rendering + """ + id = None + sketch = None + interactor = None + body = None + connector = None + + # Description + descript = None + + # PBR + material = None + + +class Connector: + """An Element that contains vectors and or normals as connection points. + These connection points can exist independently of bodies and other elements""" + id = None + vector = None + normal = None + + +class Code: + """A class that holds all information from the code based approach""" + command_list = None + + def generate_mesh_from_code(self, code_text: str): + local_vars = {} + + try: + print(code_text) + exec(code_text, globals(), local_vars) + # Retrieve the result from the captured local variables + result = local_vars.get('result') + print("Result:", result) + + except Exception as e: + print("Error executing code:", e) + + +@dataclass +class Sketch: + """All of the 2D Information of a sketch""" + id = None + + # Space Information + origin = None + slv_plane = None + normal = None + + # Points in UI form the sketch widget + ui_points: list = None + ui_lines: list = None + + # Points cartesian coming as result of the solver + slv_points: list = None + slv_lines: list = None + + sdf_points: list = None + + # Points coming back from the 3D-Widget as projection to draw on + proj_points: list = None + proj_lines: list = None + + def translate_points_tup(self, point: QPoint): + """QPoints from Display to mesh data + input: Qpoints + output: Tuple X,Y + """ + if isinstance(point, QPoint): + return point.x(), point.y() + + def vector_to_centroid(self, shape_center, centroid, normal): + + if not shape_center: + # Calculate the current center of the shape + shape_center = [0, 0, 0] + + # Calculate the vector from the shape's center to the centroid + center_to_centroid = np.array(centroid) - np.array(shape_center) + + # Project this vector onto the normal to get the required translation along the normal + translation_along_normal = np.dot(center_to_centroid, normal) * normal + + return translation_along_normal + def angle_between_normals(self, normal1, normal2): # Ensure the vectors are normalized n1 = normal1 / np.linalg.norm(normal1) @@ -519,44 +605,37 @@ class Geometry: print("p2", p2) return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) - def vector_to_centroid(self, shape_center, centroid, normal): + def convert_points_for_sdf(self): + points_for_sdf = [] + for point_to_poly in self.slv_points: + points_for_sdf.append(self.translate_points_tup(point_to_poly['ui_point'])) - if not shape_center: - # Calculate the current center of the shape - shape_center = [0, 0, 0] + self.sdf_points = points_for_sdf - # Calculate the vector from the shape's center to the centroid - center_to_centroid = np.array(centroid) - np.array(shape_center) - - # Project this vector onto the normal to get the required translation along the normal - translation_along_normal = np.dot(center_to_centroid, normal) * normal - - return translation_along_normal - - def extrude_shape(self, points, length: float, normal, centroid, symet: bool = True, invert: bool = False, - offset_length: float = None): + def extrude(self, height: float, symet: bool = True, invert: bool = False, offset_length: float = None): """ Extrude a 2D shape into 3D, orient it along the normal, and position it relative to the centroid. """ + # Normalize the normal vector - normal = np.array(normal) - normal = normal / np.linalg.norm(normal) + normal = np.array(self.normal) + normal = normal / np.linalg.norm(self.normal) # Create the 2D shape - f = polygon(points) + f = polygon(self.sdf_points) # Extrude the shape along the Z-axis - f = f.extrude(length) + f = f.extrude(height) # Center the shape along its extrusion axis - f = f.translate((0, 0, length / 2)) + f = f.translate((0, 0, height / 2)) # Orient the shape along the normal vector f = f.orient(normal) - offset_vector = self.vector_to_centroid(None, centroid, normal) + offset_vector = self.vector_to_centroid(None, self.origin, normal) # Adjust the offset vector by subtracting the inset distance along the normal direction - adjusted_offset = offset_vector - (normal * length) + adjusted_offset = offset_vector - (normal * height) if invert: # Translate the shape along the adjusted offset vector f = f.translate(adjusted_offset) @@ -580,15 +659,73 @@ class Geometry: return f + +@dataclass +class Interactor: + """Helper mesh consisting of edges for selection""" + lines = None + faces = None + body = None + + def translate_points_tup(self, point: QPoint): + """QPoints from Display to mesh data + input: Qpoints + output: Tuple X,Y + """ + if isinstance(point, QPoint): + return point.x(), point.y() + + def vector_to_centroid(self, shape_center, centroid, normal): + + if not shape_center: + # Calculate the current center of the shape + shape_center = [0, 0, 0] + + # Calculate the vector from the shape's center to the centroid + center_to_centroid = np.array(centroid) - np.array(shape_center) + + # Project this vector onto the normal to get the required translation along the normal + translation_along_normal = np.dot(center_to_centroid, normal) * normal + + return translation_along_normal + + def add_lines_for_interactor(self, input_lines: list): + """Expects slvs_lines main list""" + points_for_interact = [] + for point_to_poly in input_lines: + start, end = point_to_poly['ui_points'] + from_coord_start = window.sketchWidget.from_quadrant_coords_no_center(start) + from_coord_end = window.sketchWidget.from_quadrant_coords_no_center(end) + start_draw = self.translate_points_tup(from_coord_start) + end_draw = self.translate_points_tup(from_coord_end) + line = start_draw, end_draw + points_for_interact.append(line) + + print("packed_lines", points_for_interact) + + self.lines = points_for_interact + + +@dataclass +class Body: + """The actual body as sdf3 object""" + id = None + sketch = None + height = None + sdf_body = None + def mirror_body(self, sdf_object3d): f = sdf_object3d.rotate(pi) return f def cut_shapes(self, sdf_object1, sdf_object2): - f = difference(sdf_object1, sdf_object2) # equivalent + f = difference(sdf_object1, sdf_object2) # equivalent + return f + +class Output: def export_mesh(self, sdf_object): """FINAL EXPORT""" result_points = sdf_object.generate() @@ -608,46 +745,11 @@ class Geometry: print("Error executing code:", e) -@dataclass -class Component: - """The base container combinging all related elements""" - id = None - sketch = None - interactor = None - body = None +class Project: + """Project -> Timeline -> Component -> Sketch -> Body / Interactor -> Connector -> Assembly -> PB Render""" + timeline: Timeline = None + assembly: Assembly = 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__":