-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
134 lines (115 loc) · 4.99 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
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QMainWindow
from create_figure import *
from pyqtui import Ui_MainWindow
if __name__ == "__main__":
app = QApplication(sys.argv)
window = QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(window)
window.show()
def radio_signal():
figures = []
ui.combo_figures.clear()
ui.combo_operations.clear()
if ui.radioButton_2D.isChecked():
figures = flat_figures.keys()
ui.combo_operations.addItem("S - площадь фигуры")
CreateFigure.set_type("2D")
elif ui.radioButton_3D.isChecked():
figures = volume_figures.keys()
ui.combo_operations.addItem("S - площадь фигуры")
ui.combo_operations.addItem("V - обьем фигуры")
CreateFigure.set_type("3D")
for item in figures:
ui.combo_figures.addItem(item)
def button_signal():
args = []
all_figures = {**flat_figures, **volume_figures}
selected_figure = all_figures[ui.combo_figures.currentText()]
CreateFigure.set_figure(ui.combo_figures.currentText())
CreateFigure.set_operation(ui.combo_operations.currentText())
i = 0
for item in FIELD_TUPLE:
if item.text() and item.text().isdigit():
if CreateFigure.get_figure() == "пирамида":
if int(item.text()) == 3 or int(item.text()) == 4 and i == 1:
args.append(int(item.text()))
item.setStyleSheet("color: black")
elif item.text() and item.text().isdigit():
args.append(int(item.text()))
item.setStyleSheet("color: black")
else:
item.setStyleSheet("color: red")
else:
args.append(int(item.text()))
item.setStyleSheet("color: black")
else:
item.setStyleSheet("color: red")
i += 1
CreateFigure.set_params(args)
if selected_figure._param_len == len(args):
ui.output.setText(str(CreateFigure.get_result()))
figure = CreateFigure.get_figure()
params = CreateFigure.get_params()
ui.MatPlotWidgetWindow.update_screen(figure, params)
def combo_figures_signal():
layout_cleared()
if ui.combo_figures.currentText() in {"прямоугольник", "ромб", "цилиндр", "конус"}:
ui.field_a.setHidden(False)
ui.label_a.setHidden(False)
ui.field_b.setHidden(False)
ui.label_b.setHidden(False)
if ui.combo_figures.currentText() in {"цилиндр", "конус"}:
ui.label_a.setText("радиус R, мм:")
ui.label_b.setText("высота h, мм:")
elif ui.combo_figures.currentText() in {"прямоугольник"}:
ui.label_a.setText("сторона a, мм:")
ui.label_b.setText("сторона b, мм:")
elif ui.combo_figures.currentText() in {"ромб"}:
ui.label_a.setText("сторона a, мм:")
ui.label_b.setText("угол, º:")
elif ui.combo_figures.currentText() in {"круг", "сфера", "квадрат", "куб"}:
ui.field_a.setHidden(False)
ui.label_a.setHidden(False)
if ui.combo_figures.currentText() in {"круг", "сфера"}:
ui.label_a.setText("радиус R, мм:")
else:
ui.label_a.setText("сторона a, мм:")
elif ui.combo_figures.currentText() in {
"треугольник",
"трапеция",
"параллелепипед",
"пирамида",
}:
ui.field_a.setHidden(False)
ui.label_a.setHidden(False)
ui.field_b.setHidden(False)
ui.label_b.setHidden(False)
ui.field_c.setHidden(False)
ui.label_c.setHidden(False)
if ui.combo_figures.currentText() in {"параллелепипед", "трапеция"}:
ui.label_a.setText("сторона a, мм:")
ui.label_b.setText("сторона b, мм:")
ui.label_c.setText("высота h, мм:")
elif ui.combo_figures.currentText() == "треугольник":
ui.label_a.setText("сторона a, мм:")
ui.label_b.setText("сторона b, мм:")
ui.label_c.setText("угол, º:")
elif ui.combo_figures.currentText() == "пирамида":
ui.label_a.setText("сторона a, мм:")
ui.label_b.setText("кол-во граней, шт:")
ui.label_c.setText("высота, мм:")
ui.radioButton_2D.toggled.connect(radio_signal)
ui.radioButton_3D.toggled.connect(radio_signal)
ui.combo_figures.currentTextChanged.connect(combo_figures_signal)
ui.pushButton.clicked.connect(button_signal)
FIELD_TUPLE = (ui.field_a, ui.field_b, ui.field_c)
LABLE_TUPLE = (ui.label_a, ui.label_b, ui.label_c)
def layout_cleared(pol=FIELD_TUPLE, lab=LABLE_TUPLE):
for i in pol + lab:
i.setHidden(True)
i.setText("")
layout_cleared()
app.exec()