basic_proto
This commit is contained in:
parent
36db883433
commit
c11f47a2b6
8
Gui.py
8
Gui.py
@ -80,10 +80,10 @@ class Ui_fluencyCAD(object):
|
||||
self.groupBox_4.setObjectName(u"groupBox_4")
|
||||
self.horizontalLayout = QHBoxLayout(self.groupBox_4)
|
||||
self.horizontalLayout.setObjectName(u"horizontalLayout")
|
||||
self.pushButton_3 = QPushButton(self.groupBox_4)
|
||||
self.pushButton_3.setObjectName(u"pushButton_3")
|
||||
self.pb_apply_code = QPushButton(self.groupBox_4)
|
||||
self.pb_apply_code.setObjectName(u"pb_apply_code")
|
||||
|
||||
self.horizontalLayout.addWidget(self.pushButton_3)
|
||||
self.horizontalLayout.addWidget(self.pb_apply_code)
|
||||
|
||||
self.pushButton = QPushButton(self.groupBox_4)
|
||||
self.pushButton.setObjectName(u"pushButton")
|
||||
@ -144,7 +144,7 @@ class Ui_fluencyCAD(object):
|
||||
self.gl_box.setTitle(QCoreApplication.translate("fluencyCAD", u"Model Viewer", None))
|
||||
self.groupBox_3.setTitle(QCoreApplication.translate("fluencyCAD", u"Code Editor", None))
|
||||
self.groupBox_4.setTitle(QCoreApplication.translate("fluencyCAD", u"Code Tools", None))
|
||||
self.pushButton_3.setText(QCoreApplication.translate("fluencyCAD", u"Apply 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.pushButton_2.setText(QCoreApplication.translate("fluencyCAD", u"Export STL", None))
|
||||
self.pushButton_4.setText(QCoreApplication.translate("fluencyCAD", u"Save code", None))
|
||||
|
2
gui.ui
2
gui.ui
@ -76,7 +76,7 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<widget class="QPushButton" name="pb_apply_code">
|
||||
<property name="text">
|
||||
<string>Apply Code</string>
|
||||
</property>
|
||||
|
24
main.py
24
main.py
@ -1,6 +1,7 @@
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow, QSizePolicy
|
||||
from Gui import Ui_fluencyCAD # Import the generated GUI module
|
||||
from modules.gl_widget import OpenGLWidget
|
||||
from sdf import *
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
@ -16,13 +17,34 @@ class MainWindow(QMainWindow):
|
||||
# Connect the resizeEvent of the parent widget to a function
|
||||
self.ui.gl_canvas.resizeEvent = self.glCanvasResized
|
||||
|
||||
self.ui.pb_apply_code.pressed.connect(self.generate_mesh)
|
||||
|
||||
def generate_mesh(self):
|
||||
code_bytes = self.ui.textEdit.toPlainText().encode('utf-8')
|
||||
code_text = code_bytes.decode('utf-8')
|
||||
save_string = "\nf.save('out.stl', samples=2**10)"
|
||||
code_text += save_string
|
||||
|
||||
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)
|
||||
mesh = self.openGLWidget.load_stl("out.stl")
|
||||
self.openGLWidget.draw_stl(mesh)
|
||||
except Exception as e:
|
||||
print("Error executing code:", e)
|
||||
|
||||
|
||||
def glCanvasResized(self, event):
|
||||
# Get the size of the gl_canvas
|
||||
canvas_size = self.ui.gl_canvas.size()
|
||||
# Resize the OpenGL widget to match the size of the gl_canvas
|
||||
self.openGLWidget.resize(canvas_size)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication([])
|
||||
window = MainWindow()
|
||||
|
Loading…
x
Reference in New Issue
Block a user