-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
155 lines (123 loc) · 4.62 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
from PySide2.QtWidgets import QApplication, QMainWindow, QDialog, QWidget, QPushButton
from PySide2 import QtCore
import sys
from ui.mainwindow import Ui_MainWindow
from cylinderwindow import CylinderWindow
from spherewindow import SphereWindow
from ui.cyldialog import Ui_cyldialog
from ui.sphdialog import Ui_sphdialog
from ui.lotsofspheres import Ui_LotsOfSpheresDialog
from ui.lotsofcylinders import Ui_Dialog
class MainWindow(Ui_MainWindow):
def __init__(self):
super().__init__()
def setupUi(self, MainWindow):
super().setupUi(MainWindow)
self.cylinderdialog = QDialog()
self.spheredialog = QDialog()
self.lotsofcylindersdialog = QDialog()
self.lotsofspheresdialog = QDialog()
self.cylinderdialog.ui = CylinderDialog()
self.cylinderdialog.ui.setupUi(self.cylinderdialog)
self.lotsofcylindersdialog.ui = LotsOfCylindersDialog()
self.lotsofcylindersdialog.ui.setupUi(self.lotsofcylindersdialog)
self.spheredialog.ui = SphereDialog()
self.spheredialog.ui.setupUi(self.spheredialog)
self.lotsofspheresdialog.ui = LotsOfSpheresDialog()
self.lotsofspheresdialog.ui.setupUi(self.lotsofspheresdialog)
self.cylindersbutton.clicked.connect(self.cylinderdialog.show)
self.spheres.clicked.connect(self.spheredialog.show)
self.lotsofcylindersbutton.clicked.connect(self.lotsofcylindersdialog.show)
self.lotsofspheresButton.clicked.connect(self.lotsofspheresdialog.show)
class CylinderDialog(Ui_cyldialog):
def __init__(self):
super().__init__()
self.window = CylinderWindow()
def setupUi(self, CylinderDialog):
super().setupUi(CylinderDialog)
self.horizontalLayout.replaceWidget(
self.widget, QWidget.createWindowContainer(self.window)
)
self.pushButton.clicked.connect(self.add_cylinder)
def add_cylinder(self):
self.window.add_cylinder(
self.radiusLineEdit.value(),
self.radiusLineEdit.value(),
self.xLineEdit.value(),
self.yLineEdit.value(),
self.zLineEdit.value(),
)
print("Cylinder added.")
class SphereDialog(Ui_sphdialog):
def __init__(self):
super().__init__()
self.window = SphereWindow()
def setupUi(self, SphereDialog):
super().setupUi(SphereDialog)
self.horizontalLayout.replaceWidget(
self.widget, QWidget.createWindowContainer(self.window)
)
self.pushButton.clicked.connect(self.add_sphere)
def add_sphere(self):
self.window.add_sphere(
self.radiusLineEdit.value(),
self.xLineEdit.value(),
self.yLineEdit.value(),
self.zLineEdit.value(),
)
class LotsOfCylindersDialog(Ui_Dialog):
def __init__(self):
super().__init__()
self.window = CylinderWindow()
def setupUi(self, CylinderDialog):
super().setupUi(CylinderDialog)
self.horizontalLayout.replaceWidget(
self.widget, QWidget.createWindowContainer(self.window)
)
self.pushButton.clicked.connect(self.add_cylinder)
def add_cylinder(self):
x = 20
y = 256
radius = 0.5
length = 0.5
translation_distance = 1
for i in range(x):
for j in range(y):
self.window.add_cylinder(
radius,
length,
i * translation_distance * 2,
j * translation_distance,
0,
self.ringslineedit.value(),
self.sliceslineedit.value(),
)
print("Cylinder added.")
class LotsOfSpheresDialog(Ui_LotsOfSpheresDialog):
def __init__(self):
super().__init__()
self.window = SphereWindow()
def setupUi(self, LotsOfSpheresDialog):
super().setupUi(LotsOfSpheresDialog)
self.horizontalLayout.replaceWidget(
self.widget, QWidget.createWindowContainer(self.window)
)
self.pushButton.clicked.connect(self.add_spheres)
def add_spheres(self):
x = 64
y = 256
radius = 0.5
translation_distance = 1
for i in range(x):
for j in range(y):
self.window.add_sphere(
radius, i * translation_distance * 2, j * translation_distance, 0
)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
window = QMainWindow()
ui = MainWindow()
ui.setupUi(window)
window.show()
sys.exit(app.exec_())