hytos / HYTOS / HYTOS / Fitting_2KDialog.py @ e534f39d
이력 | 보기 | 이력해설 | 다운로드 (17.7 KB)
1 |
# coding: utf-8
|
---|---|
2 |
""" This is Configuratio dialog module """
|
3 |
|
4 |
import os |
5 |
import sys |
6 |
from PyQt5.QtCore import * |
7 |
from PyQt5.QtGui import * |
8 |
from PyQt5.QtWidgets import * |
9 |
import sqlite3 |
10 |
from App import App |
11 |
from AppDocData import AppDocData |
12 |
from AppDocData import Config |
13 |
from AppDocData import Color |
14 |
import Fitting_2K_UI |
15 |
|
16 |
class QFitting_2KDialog(QDialog): |
17 |
|
18 |
def __init__(self, parent = None): |
19 |
QDialog.__init__(self, parent)
|
20 |
|
21 |
self.ui = Fitting_2K_UI.Ui_Dialog()
|
22 |
self.ui.setupUi(self) |
23 |
self.initTableWidgetSelectedFitting()
|
24 |
|
25 |
# 90 Elbow
|
26 |
self.ui.checkBox_90_Elbow_Standard_Screw.stateChanged.connect(self.elbow_90_state_changed) |
27 |
self.ui.checkBox_90_Elbow_Standard_Flange_Weld.stateChanged.connect(self.elbow_90_state_changed) |
28 |
self.ui.checkBox_90_Elbow_Long_Radius_All.stateChanged.connect(self.elbow_90_state_changed) |
29 |
self.ui.checkBox_90_Elbow_1_Weld.stateChanged.connect(self.elbow_90_state_changed) |
30 |
self.ui.checkBox_90_Elbow_2_Weld.stateChanged.connect(self.elbow_90_state_changed) |
31 |
self.ui.checkBox_90_Elbow_3_Weld.stateChanged.connect(self.elbow_90_state_changed) |
32 |
self.ui.checkBox_90_Elbow_4_Weld.stateChanged.connect(self.elbow_90_state_changed) |
33 |
self.ui.checkBox_90_Elbow_5_Weld.stateChanged.connect(self.elbow_90_state_changed) |
34 |
# 45 Elbow
|
35 |
self.ui.checkBox_45_Elbow_Standard_All.stateChanged.connect(self.elbow_45_state_changed) |
36 |
self.ui.checkBox_45_Elbow_Long_Radius_All.stateChanged.connect(self.elbow_45_state_changed) |
37 |
self.ui.checkBox_45_Elbow_1_Weld.stateChanged.connect(self.elbow_45_state_changed) |
38 |
self.ui.checkBox_45_Elbow_2_Weld.stateChanged.connect(self.elbow_45_state_changed) |
39 |
# 180 Elbow
|
40 |
self.ui.checkBox_180_Elbow_Standard_Screw.stateChanged.connect(self.elbow_180_state_changed) |
41 |
self.ui.checkBox_180_Elbow_Standard_Flange_Weld.stateChanged.connect(self.elbow_180_state_changed) |
42 |
self.ui.checkBox_180_Elbow_Long_Radius_All.stateChanged.connect(self.elbow_180_state_changed) |
43 |
# Tees
|
44 |
self.ui.checkBox_Tee_Elbow_Standard_Screw.stateChanged.connect(self.tee_state_changed) |
45 |
self.ui.checkBox_Tee_Elbow_Long_Radius_Screw.stateChanged.connect(self.tee_state_changed) |
46 |
self.ui.checkBox_Tee_Elbow_Standard_Flange_Weld.stateChanged.connect(self.tee_state_changed) |
47 |
self.ui.checkBox_Tee_Elbow_Stub_In_Branch.stateChanged.connect(self.tee_state_changed) |
48 |
self.ui.checkBox_Tee_Through_Screw.stateChanged.connect(self.tee_state_changed) |
49 |
self.ui.checkBox_Tee_Through_Flange_Weld.stateChanged.connect(self.tee_state_changed) |
50 |
self.ui.checkBox_Tee_Through_Stub_In_Branch.stateChanged.connect(self.tee_state_changed) |
51 |
# Valves
|
52 |
self.ui.checkBox_Gate_Ball_Plug_Valve_Full.stateChanged.connect(self.valve_state_changed) |
53 |
self.ui.checkBox_Gate_Ball_Plug_Valve_Reduce_Trim_9.stateChanged.connect(self.valve_state_changed) |
54 |
self.ui.checkBox_Gate_Ball_Plug_Valve_Reduce_Trim_8.stateChanged.connect(self.valve_state_changed) |
55 |
self.ui.checkBox_Globe_Valve_Standard.stateChanged.connect(self.valve_state_changed) |
56 |
self.ui.checkBox_Globe_Valve_Angle_YType.stateChanged.connect(self.valve_state_changed) |
57 |
self.ui.checkBox_Diaphragm_Dam_Valve.stateChanged.connect(self.valve_state_changed) |
58 |
self.ui.checkBox_Butterfly_Valve.stateChanged.connect(self.valve_state_changed) |
59 |
# Pipe
|
60 |
self.ui.checkBox_Pipe_Entrance_Normal.stateChanged.connect(self.pipe_state_changed) |
61 |
self.ui.checkBox_Pipe_Entrance_Borda.stateChanged.connect(self.pipe_state_changed) |
62 |
self.ui.checkBox_Pipe_Exit.stateChanged.connect(self.pipe_state_changed) |
63 |
# Check Valve
|
64 |
self.ui.checkBox_Check_Valve_Lift.stateChanged.connect(self.check_valve_state_changed) |
65 |
self.ui.checkBox_Check_Valve_Swing.stateChanged.connect(self.check_valve_state_changed) |
66 |
self.ui.checkBox_Check_Valve_Tilting.stateChanged.connect(self.check_valve_state_changed) |
67 |
|
68 |
|
69 |
def initTableWidgetSelectedFitting(self): |
70 |
self.ui.tableWidget_SelectedFitting.setColumnCount(7) |
71 |
self.ui.tableWidget_SelectedFitting.setHorizontalHeaderLabels(['Category', 'Type', 'Name', 'Count', 'Size', 'Angle', 'K']) |
72 |
self.ui.tableWidget_SelectedFitting.horizontalHeaderItem(0).setSizeHint(QSize(25, 25)) |
73 |
|
74 |
#self.ui.tableWidget_SelectedFitting.setColumnWidth(0, 30)
|
75 |
#self.ui.tableWidget_SelectedFitting.setColumnWidth(1, 135)
|
76 |
self.ui.tableWidget_SelectedFitting.horizontalHeader().setStretchLastSection(True) |
77 |
|
78 |
self.ui.tableWidget_SelectedFitting.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
79 |
#self.ui.tableWidget_SelectedFitting.resizeColumnsToContents()
|
80 |
|
81 |
self.ui.tableWidget_SelectedFitting.verticalHeader().setVisible(False) |
82 |
|
83 |
def check_valve_state_changed(self, state): |
84 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
85 |
|
86 |
if self.sender() == self.ui.checkBox_Check_Valve_Lift: |
87 |
if state == 2: |
88 |
self.add_fitting_data(rowCount, 'Check Valve', 'Swing Type', 'Lift Check Valve') |
89 |
else:
|
90 |
self.del_fitting_data('Check Valve', 'Swing Type', 'Lift Check Valve') |
91 |
elif self.sender() == self.ui.checkBox_Check_Valve_Swing: |
92 |
if state == 2: |
93 |
self.add_fitting_data(rowCount, 'Check Valve', 'Swing Type', 'Swing Check Valve') |
94 |
else:
|
95 |
self.del_fitting_data('Check Valve', 'Swing Type', 'Swing Check Valve') |
96 |
elif self.sender() == self.ui.checkBox_Check_Valve_Tilting: |
97 |
if state == 2: |
98 |
self.add_fitting_data(rowCount, 'Check Valve', 'Swing Type', 'Tilting-disk Check Valve') |
99 |
else:
|
100 |
self.del_fitting_data('Check Valve', 'Swing Type', 'Tilting-disk Check Valve') |
101 |
|
102 |
def pipe_state_changed(self, state): |
103 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
104 |
|
105 |
if self.sender() == self.ui.checkBox_Pipe_Entrance_Normal: |
106 |
if state == 2: |
107 |
self.add_fitting_data(rowCount, 'Pipe', 'Pipe Type', 'Pipe entrance (Normal)') |
108 |
else:
|
109 |
self.del_fitting_data('Pipe', 'Pipe Type', 'Pipe entrance (Normal)') |
110 |
elif self.sender() == self.ui.checkBox_Pipe_Entrance_Borda: |
111 |
if state == 2: |
112 |
self.add_fitting_data(rowCount, 'Pipe', 'Pipe Type', 'Pipe entrance (Borda)') |
113 |
else:
|
114 |
self.del_fitting_data('Pipe', 'Pipe Type', 'Pipe entrance (Borda)') |
115 |
elif self.sender() == self.ui.checkBox_Pipe_Exit: |
116 |
if state == 2: |
117 |
self.add_fitting_data(rowCount, 'Pipe', 'Pipe Type', 'Pipe exit') |
118 |
else:
|
119 |
self.del_fitting_data('Pipe', 'Pipe Type', 'Pipe exit') |
120 |
|
121 |
|
122 |
def valve_state_changed(self, state): |
123 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
124 |
|
125 |
if self.sender() == self.ui.checkBox_Gate_Ball_Plug_Valve_Full: |
126 |
if state == 2: |
127 |
self.add_fitting_data(rowCount, 'Valves', 'Gate, Ball, Plug Type', 'Full line size, β = 1.0') |
128 |
else:
|
129 |
self.del_fitting_data('Valves', 'Gate, Ball, Plug Type', 'Full line size, β = 1.0') |
130 |
elif self.sender() == self.ui.checkBox_Gate_Ball_Plug_Valve_Reduce_Trim_9: |
131 |
if state == 2: |
132 |
self.add_fitting_data(rowCount, 'Valves', 'Gate, Ball, Plug Type', 'Reduced Trim, β = 0.9') |
133 |
else:
|
134 |
self.del_fitting_data('Valves', 'Gate, Ball, Plug Type', 'Reduced Trim, β = 0.9') |
135 |
elif self.sender() == self.ui.checkBox_Gate_Ball_Plug_Valve_Reduce_Trim_8: |
136 |
if state == 2: |
137 |
self.add_fitting_data(rowCount, 'Valves', 'Gate, Ball, Plug Type', 'Reduced Trim, β = 0.8') |
138 |
else:
|
139 |
self.del_fitting_data('Valves', 'Gate, Ball, Plug Type', 'Reduced Trim, β = 0.8') |
140 |
elif self.sender() == self.ui.checkBox_Globe_Valve_Standard: |
141 |
if state == 2: |
142 |
self.add_fitting_data(rowCount, 'Valves', 'Globe Type', 'Standard') |
143 |
else:
|
144 |
self.del_fitting_data('Valves', 'Globe Type', 'Standard') |
145 |
elif self.sender() == self.ui.checkBox_Globe_Valve_Angle_YType: |
146 |
if state == 2: |
147 |
self.add_fitting_data(rowCount, 'Valves', 'Globe Type', 'Angle or Y-type') |
148 |
else:
|
149 |
self.del_fitting_data('Valves', 'Globe Type', 'Angle or Y-type') |
150 |
elif self.sender() == self.ui.checkBox_Diaphragm_Dam_Valve: |
151 |
if state == 2: |
152 |
self.add_fitting_data(rowCount, 'Valves', 'Others', 'Diaphragm, dam type') |
153 |
else:
|
154 |
self.del_fitting_data('Valves', 'Others', 'Diaphragm, dam type') |
155 |
elif self.sender() == self.ui.checkBox_Butterfly_Valve: |
156 |
if state == 2: |
157 |
self.add_fitting_data(rowCount, 'Valves', 'Others', 'Butterfly') |
158 |
else:
|
159 |
self.del_fitting_data('Valves', 'Others', 'Butterfly') |
160 |
|
161 |
|
162 |
def tee_state_changed(self, state): |
163 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
164 |
|
165 |
if self.sender() == self.ui.checkBox_Tee_Elbow_Standard_Screw: |
166 |
if state == 2: |
167 |
self.add_fitting_data(rowCount, 'Tees', 'Used as Elbow', 'Standard, screwed') |
168 |
else:
|
169 |
self.del_fitting_data('Tees', 'Used as Elbow', 'Standard, screwed') |
170 |
elif self.sender() == self.ui.checkBox_Tee_Elbow_Long_Radius_Screw: |
171 |
if state == 2: |
172 |
self.add_fitting_data(rowCount, 'Tees', 'Used as Elbow', 'Long-radius, screwed') |
173 |
else:
|
174 |
self.del_fitting_data('Tees', 'Used as Elbow', 'Long-radius, screwed') |
175 |
elif self.sender() == self.ui.checkBox_Tee_Elbow_Standard_Flange_Weld: |
176 |
if state == 2: |
177 |
self.add_fitting_data(rowCount, 'Tees', 'Used as Elbow', 'Standard, flanged or welded') |
178 |
else:
|
179 |
self.del_fitting_data('Tees', 'Used as Elbow', 'Standard, flanged or welded') |
180 |
elif self.sender() == self.ui.checkBox_Tee_Elbow_Stub_In_Branch: |
181 |
if state == 2: |
182 |
self.add_fitting_data(rowCount, 'Tees', 'Used as Elbow', 'Stub-in-type branch') |
183 |
else:
|
184 |
self.del_fitting_data('Tees', 'Used as Elbow', 'Stub-in-type branch') |
185 |
elif self.sender() == self.ui.checkBox_Tee_Through_Screw: |
186 |
if state == 2: |
187 |
self.add_fitting_data(rowCount, 'Tees', 'Run through tee', 'Screwed') |
188 |
else:
|
189 |
self.del_fitting_data('Tees', 'Run through tee', 'Screwed') |
190 |
elif self.sender() == self.ui.checkBox_Tee_Through_Flange_Weld: |
191 |
if state == 2: |
192 |
self.add_fitting_data(rowCount, 'Tees', 'Run through tee', 'Flanged or welded') |
193 |
else:
|
194 |
self.del_fitting_data('Tees', 'Run through tee', 'Flanged or welded') |
195 |
elif self.sender() == self.ui.checkBox_Tee_Through_Stub_In_Branch: |
196 |
if state == 2: |
197 |
self.add_fitting_data(rowCount, 'Tees', 'Run through tee', 'Stub-in-type branch') |
198 |
else:
|
199 |
self.del_fitting_data('Tees', 'Run through tee', 'Stub-in-type branch') |
200 |
|
201 |
|
202 |
def elbow_180_state_changed(self, state): |
203 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
204 |
|
205 |
if self.sender() == self.ui.checkBox_180_Elbow_Standard_Screw: |
206 |
if state == 2: |
207 |
self.add_fitting_data(rowCount, '180° Elbow', 'Bend Type', 'Standard (r/d=1), screwed') |
208 |
else:
|
209 |
self.del_fitting_data('180° Elbow', 'Bend Type', 'Standard (r/d=1), screwed') |
210 |
elif self.sender() == self.ui.checkBox_180_Elbow_Standard_Flange_Weld: |
211 |
if state == 2: |
212 |
self.add_fitting_data(rowCount, '180° Elbow', 'Bend Type', 'Standard (r/d=1), flanged/welded') |
213 |
else:
|
214 |
self.del_fitting_data('180° Elbow', 'Bend Type', 'Standard (r/d=1), flanged/welded') |
215 |
elif self.sender() == self.ui.checkBox_180_Elbow_Long_Radius_All: |
216 |
if state == 2: |
217 |
self.add_fitting_data(rowCount, '180° Elbow', 'Bend Type', 'Long-radius (r/d=1.5), all types') |
218 |
else:
|
219 |
self.del_fitting_data('180° Elbow', 'Bend Type', 'Long-radius (r/d=1.5), all types') |
220 |
|
221 |
def elbow_45_state_changed(self, state): |
222 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
223 |
|
224 |
if self.sender() == self.ui.checkBox_45_Elbow_Standard_All: |
225 |
if state == 2: |
226 |
self.add_fitting_data(rowCount, '45° Elbow', 'Bend Type', 'Standard (r/d=1), all types') |
227 |
else:
|
228 |
self.del_fitting_data('45° Elbow', 'Bend Type', 'Standard (r/d=1), all types') |
229 |
elif self.sender() == self.ui.checkBox_45_Elbow_Long_Radius_All: |
230 |
if state == 2: |
231 |
self.add_fitting_data(rowCount, '45° Elbow', 'Bend Type', 'Long-radius (r/d=1.5), all types') |
232 |
else:
|
233 |
self.del_fitting_data('45° Elbow', 'Bend Type', 'Long-radius (r/d=1.5), all types') |
234 |
elif self.sender() == self.ui.checkBox_45_Elbow_1_Weld: |
235 |
if state == 2: |
236 |
self.add_fitting_data(rowCount, '45° Elbow', 'Miter Type', '1 weld (45 angle)') |
237 |
else:
|
238 |
self.del_fitting_data('45° Elbow', 'Miter Type', '1 weld (45 angle)') |
239 |
elif self.sender() == self.ui.checkBox_45_Elbow_2_Weld: |
240 |
if state == 2: |
241 |
self.add_fitting_data(rowCount, '45° Elbow', 'Miter Type', '2 welds (22.5 angle)') |
242 |
else:
|
243 |
self.del_fitting_data('45° Elbow', 'Miter Type', '2 welds (22.5 angle)') |
244 |
|
245 |
|
246 |
def elbow_90_state_changed(self, state): |
247 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
248 |
|
249 |
if self.sender() == self.ui.checkBox_90_Elbow_Standard_Screw: |
250 |
if state == 2: |
251 |
self.add_fitting_data(rowCount, '90° Elbow', 'Bend Type', 'Standard (r/d=1), screwed') |
252 |
else:
|
253 |
self.del_fitting_data('90° Elbow', 'Bend Type', 'Standard (r/d=1), screwed') |
254 |
elif self.sender() == self.ui.checkBox_90_Elbow_Standard_Flange_Weld: |
255 |
if state == 2: |
256 |
self.add_fitting_data(rowCount, '90° Elbow', 'Bend Type', 'Standard (r/d=1), flanged/weled') |
257 |
else:
|
258 |
self.del_fitting_data('90° Elbow', 'Bend Type', 'Standard (r/d=1), flanged/weled') |
259 |
elif self.sender() == self.ui.checkBox_90_Elbow_Long_Radius_All: |
260 |
if state == 2: |
261 |
self.add_fitting_data(rowCount, '90° Elbow', 'Bend Type', 'Long-radius (r/d=1.5), all') |
262 |
else:
|
263 |
self.del_fitting_data('90° Elbow', 'Bend Type', 'Long-radius (r/d=1.5), all') |
264 |
elif self.sender() == self.ui.checkBox_90_Elbow_1_Weld: |
265 |
if state == 2: |
266 |
self.add_fitting_data(rowCount, '90° Elbow', 'Miter Type', '1 weld (90 angle)') |
267 |
else:
|
268 |
self.del_fitting_data('90° Elbow', 'Miter Type', '1 weld (90 angle)') |
269 |
elif self.sender() == self.ui.checkBox_90_Elbow_2_Weld: |
270 |
if state == 2: |
271 |
self.add_fitting_data(rowCount, '90° Elbow', 'Miter Type', '2 welds (45 angle)') |
272 |
else:
|
273 |
self.del_fitting_data('90° Elbow', 'Miter Type', '2 welds (45 angle)') |
274 |
elif self.sender() == self.ui.checkBox_90_Elbow_3_Weld: |
275 |
if state == 2: |
276 |
self.add_fitting_data(rowCount, '90° Elbow', 'Miter Type', '3 welds (30 angle)') |
277 |
else:
|
278 |
self.del_fitting_data('90° Elbow', 'Miter Type', '3 welds (30 angle)') |
279 |
elif self.sender() == self.ui.checkBox_90_Elbow_4_Weld: |
280 |
if state == 2: |
281 |
self.add_fitting_data(rowCount, '90° Elbow', 'Miter Type', '4 welds (22.5 angle)') |
282 |
else:
|
283 |
self.del_fitting_data('90° Elbow', 'Miter Type', '4 welds (22.5 angle)') |
284 |
elif self.sender() == self.ui.checkBox_90_Elbow_5_Weld: |
285 |
if state == 2: |
286 |
self.add_fitting_data(rowCount, '90° Elbow', 'Miter Type', '5 welds (18 angle)') |
287 |
else:
|
288 |
self.del_fitting_data('90° Elbow', 'Miter Type', '5 welds (18 angle)') |
289 |
|
290 |
|
291 |
|
292 |
def del_fitting_data(self, category, type, name): |
293 |
rowCount = self.ui.tableWidget_SelectedFitting.rowCount()
|
294 |
for row in range(rowCount): |
295 |
if self.ui.tableWidget_SelectedFitting.item(row, 0).text() == category and self.ui.tableWidget_SelectedFitting.item(row, 1).text() == type and self.ui.tableWidget_SelectedFitting.item(row, 2).text() == name: |
296 |
self.ui.tableWidget_SelectedFitting.removeRow(row)
|
297 |
break
|
298 |
|
299 |
def add_fitting_data(self, row, category, type, name): |
300 |
self.ui.tableWidget_SelectedFitting.setRowCount(row+1) |
301 |
|
302 |
self.ui.tableWidget_SelectedFitting.setItem(row, 0, self.setTableWidgetItemProperties(category, Qt.AlignLeft | Qt.AlignVCenter)) |
303 |
self.ui.tableWidget_SelectedFitting.setItem(row, 1, self.setTableWidgetItemProperties(type, Qt.AlignLeft | Qt.AlignVCenter)) |
304 |
self.ui.tableWidget_SelectedFitting.setItem(row, 2, self.setTableWidgetItemProperties(name, Qt.AlignLeft | Qt.AlignVCenter)) |
305 |
self.ui.tableWidget_SelectedFitting.setItem(row, 3, self.setTableWidgetItemProperties(1, Qt.AlignHCenter | Qt.AlignVCenter)) |
306 |
|
307 |
|
308 |
def showDialog(self, item): |
309 |
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) |
310 |
self.exec_()
|
311 |
|
312 |
def setTableWidgetItemProperties(self, name, alignment, color = None): |
313 |
|
314 |
item = QTableWidgetItem(str(name))
|
315 |
item.setTextAlignment(alignment) |
316 |
if color:
|
317 |
item.setBackground(color) |
318 |
|
319 |
return item
|
320 |
|
321 |
def accept(self): |
322 |
|
323 |
QDialog.accept(self)
|
324 |
|
325 |
def reject(self): |
326 |
QDialog.reject(self)
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
if __name__ == '__main__': |
332 |
from Fitting_2KDialog import QFitting_2KDialog |
333 |
from App import App |
334 |
app = App(sys.argv) |
335 |
|
336 |
|
337 |
if True: |
338 |
dlg = QFitting_2KDialog() |
339 |
dlg.exec_() |