개정판 a30ff17d
issue #1062: 계산전에 입력 데이타 확인
Change-Id: Ic50e9043392eea2330af29783876adec2c4f3615
HYTOS/HYTOS/Commands/HydroCalculationCommand.py | ||
---|---|---|
31 | 31 |
"""check given item is possible of start of loop""" |
32 | 32 |
|
33 | 33 |
if self.is_loop_end_item(item): |
34 |
matches = [conn for conn in item.connectors if conn.connectedItem and int(conn.connectedItem._conn_index) == 1] |
|
34 |
matches = [conn for conn in item.connectors if |
|
35 |
conn.connectedItem and int(conn.connectedItem._conn_index) == 1] |
|
35 | 36 |
if matches: |
36 | 37 |
return True |
37 | 38 |
|
... | ... | |
61 | 62 |
for i in range(len(matches)): |
62 | 63 |
loop.pressures[matches[i]] = 0 |
63 | 64 |
|
64 |
|
|
65 |
|
|
66 | 65 |
''' |
67 | 66 |
items = loop.items |
68 | 67 |
for item in items: |
... | ... | |
71 | 70 |
loop.pressures[item] = 0 |
72 | 71 |
''' |
73 | 72 |
|
74 |
|
|
75 | 73 |
def search_cv_calc(self): |
76 | 74 |
|
77 | 75 |
control_valves = [] |
... | ... | |
135 | 133 |
if name[:3] == 'CV_': |
136 | 134 |
if name in names: |
137 | 135 |
loop.extras[item] = cvdp_final / ( |
138 |
cvdp_final + loop.total_device_loss + loop.line_total_friction_loss)
|
|
136 |
cvdp_final + loop.total_device_loss + loop.line_total_friction_loss) |
|
139 | 137 |
continue |
140 | 138 |
else: |
141 | 139 |
names.append(name) |
142 | 140 |
loop.pressure_drops[item] = cvdp_final |
143 | 141 |
|
144 |
|
|
145 | 142 |
def search_pump_calc(self): |
146 | 143 |
|
147 | 144 |
pumps = [] |
... | ... | |
149 | 146 |
for item in loop.items: |
150 | 147 |
parent = item.parent |
151 | 148 |
if parent: |
152 |
if str(item)[:3] == 'R_P' or str(item)[:3] == 'L_P' or str(item)[:3] == 'V_P' or str(item)[:3] == 'R_K' or str(item)[:3] == 'L_P': |
|
149 |
if str(item)[:3] == 'R_P' or str(item)[:3] == 'L_P' or str(item)[:3] == 'V_P' or str(item)[ |
|
150 |
:3] == 'R_K' or str( |
|
151 |
item)[:3] == 'L_P': |
|
153 | 152 |
name = str(item).replace('_{}'.format(str(item).split('_')[len(str(item).split('_')) - 1]), '') |
154 | 153 |
if name in pumps: |
155 | 154 |
continue |
... | ... | |
162 | 161 |
# (1) 펌프 헤드 결정 |
163 | 162 |
for loop in self.loops: |
164 | 163 |
for i in range(1, len(loop.items) - 1, 3): |
165 |
name = str(loop.items[i + 1]).replace('_{}'.format(str(loop.items[i + 1]).split('_')[len(str(loop.items[i + 1]).split('_')) - 1]), '') |
|
164 |
name = str(loop.items[i + 1]).replace( |
|
165 |
'_{}'.format(str(loop.items[i + 1]).split('_')[len(str(loop.items[i + 1]).split('_')) - 1]), '') |
|
166 | 166 |
if pump == name: |
167 | 167 |
if loop.items[i + 1] in loop.pressure_drops: |
168 | 168 |
pumpdp.append(loop.pressure_drops[loop.items[i + 1]]) |
... | ... | |
172 | 172 |
# (2) 펌프 헤드를 각 루프에 새로 씀 |
173 | 173 |
for loop in self.loops: |
174 | 174 |
for i in range(1, len(loop.items) - 1, 3): |
175 |
name = str(loop.items[i + 1]).replace('_{}'.format(str(loop.items[i + 1]).split('_')[len(str(loop.items[i + 1]).split('_')) - 1]), '') |
|
175 |
name = str(loop.items[i + 1]).replace( |
|
176 |
'_{}'.format(str(loop.items[i + 1]).split('_')[len(str(loop.items[i + 1]).split('_')) - 1]), '') |
|
176 | 177 |
if pump == name: |
177 | 178 |
loop.pressure_drops[loop.items[i + 1]] = pumpdp_final |
178 | 179 |
|
... | ... | |
181 | 182 |
loop.suction_cal(2) |
182 | 183 |
loop.discharge_cal(2) |
183 | 184 |
|
184 |
|
|
185 | 185 |
return |
186 | 186 |
|
187 |
|
|
188 | 187 |
pumpdp = [] |
189 | 188 |
pumpdp.append(0.00000001) |
190 | 189 |
|
... | ... | |
234 | 233 |
items_count = len(loop.items) |
235 | 234 |
|
236 | 235 |
deviation = loop.pressures[loop.items[items_count - 2]] - loop.pressures[loop.items[items_count - 1]] - \ |
237 |
loop.pressure_drops[loop.items[items_count - 2]] |
|
236 |
loop.pressure_drops[loop.items[items_count - 2]]
|
|
238 | 237 |
|
239 | 238 |
loop.deviation = deviation |
240 | 239 |
|
... | ... | |
271 | 270 |
if item in loop.pressure_drops: |
272 | 271 |
item.pressure_drop = loop.pressure_drops[item] |
273 | 272 |
|
274 |
#self.init_units() |
|
275 |
#self.loop_result() |
|
273 |
# self.init_units()
|
|
274 |
# self.loop_result()
|
|
276 | 275 |
|
277 | 276 |
except Exception as ex: |
278 | 277 |
from App import App |
... | ... | |
308 | 307 |
if hmb.phase_type == 'Vapor': |
309 | 308 |
hmb.pressure_drop_friction = matches[0].pressure_drops[matches[0].items[indices[0]]] |
310 | 309 |
hmb.density = matches[0].density_elevations[matches[0].items[indices[0]]] |
311 |
hmb.pressure_drop = matches[0].pressure_drops[matches[0].items[indices[0]]] / hmb.equivalent_length * 100 |
|
310 |
hmb.pressure_drop = matches[0].pressure_drops[ |
|
311 |
matches[0].items[indices[0]]] / hmb.equivalent_length * 100 |
|
312 | 312 |
|
313 | 313 |
except Exception as ex: |
314 | 314 |
from App import App |
... | ... | |
354 | 354 |
suct_p = loop.pressures[loop.items[indices[0]]] |
355 | 355 |
disc_p = loop.pressures[loop.items[indices[1]]] |
356 | 356 |
diff_p = loop.pressure_drops[loop.items[indices[0]]] |
357 |
dp_ratio = loop.extras[loop.items[indices[1]]] if not loop.extras[loop.items[indices[1]]] is None else 0 |
|
357 |
dp_ratio = loop.extras[loop.items[indices[1]]] if not loop.extras[ |
|
358 |
loop.items[indices[1]]] is None else 0 |
|
358 | 359 |
|
359 | 360 |
attribute['Tag_No'] = tag_no |
360 | 361 |
attribute['Suct.P'] = suct_p |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
716 | 716 |
self.graphicsView.useDefaultCommand() |
717 | 717 |
self.graphicsView.zoomImageInit() |
718 | 718 |
|
719 |
def on_view_connector(self, action):
|
|
719 |
def on_view_connector(self, checked):
|
|
720 | 720 |
"""turn on/off connector""" |
721 | 721 |
for item in self.graphicsView.scene.items(): |
722 | 722 |
if not hasattr(item, 'connectors'): |
723 | 723 |
continue |
724 | 724 |
for connector in item.connectors: |
725 |
connector.setVisible(True) if action else connector.hide()
|
|
725 |
connector.setVisible(True) if checked else connector.hide()
|
|
726 | 726 |
|
727 | 727 |
def scene_changed(self): |
728 | 728 |
"""update modified flag""" |
... | ... | |
881 | 881 |
self.addMessage.emit(MessageType.Error, message) |
882 | 882 |
|
883 | 883 |
def calculation(self): |
884 |
""" execute hydro calculation """
|
|
884 |
"""execute hydro calculation"""
|
|
885 | 885 |
from AppDocData import AppDocData |
886 | 886 |
from Calculation import Calculation |
887 | 887 |
from HydroCalculationCommand import HydroCalculationCommand |
888 |
from ValidationDialog import QValidationDialog |
|
888 | 889 |
|
889 | 890 |
try: |
890 | 891 |
app_doc_data = AppDocData.instance() |
... | ... | |
895 | 896 |
hmbs = app_doc_data.activeDrawing.hmbTable._hmbs |
896 | 897 |
if hmbs is not None: |
897 | 898 |
try: |
898 |
self.progress = QProgressDialog(self.tr("Please wait for a while"), self.tr("Cancel"), 0, 100, self) \ |
|
899 |
if not hasattr(self, 'progress') else self.progress |
|
900 |
self.progress.setWindowModality(Qt.WindowModal) |
|
901 |
self.progress.setAutoReset(True) |
|
902 |
self.progress.setAutoClose(True) |
|
903 |
self.progress.setMinimum(0) |
|
904 |
self.progress.resize(600, 100) |
|
905 |
self.progress.setWindowTitle(self.tr("Calculate data...")) |
|
906 |
self.progress.show() |
|
907 |
|
|
908 |
maxValue = len(hmbs) |
|
909 |
self.progress.setMaximum(maxValue) |
|
899 |
errors = [] |
|
900 |
items = [item for item in self.graphicsView.scene.items() if type(item) is SymbolSvgItem or |
|
901 |
type(item) is QEngineeringStreamlineItem] |
|
902 |
for item in items: |
|
903 |
error = item.validate() |
|
904 |
if error: errors.extend(error) |
|
905 |
|
|
906 |
if errors: |
|
907 |
dlg = QValidationDialog(self, errors) |
|
908 |
dlg.show() |
|
909 |
else: |
|
910 |
self.progress = QProgressDialog(self.tr("Please wait for a while"), self.tr("Cancel"), 0, 100, self) \ |
|
911 |
if not hasattr(self, 'progress') else self.progress |
|
912 |
self.progress.setWindowModality(Qt.WindowModal) |
|
913 |
self.progress.setAutoReset(True) |
|
914 |
self.progress.setAutoClose(True) |
|
915 |
self.progress.setMinimum(0) |
|
916 |
self.progress.resize(600, 100) |
|
917 |
self.progress.setWindowTitle(self.tr("Calculate data...")) |
|
918 |
self.progress.show() |
|
919 |
|
|
920 |
maxValue = len(hmbs) |
|
921 |
self.progress.setMaximum(maxValue) |
|
910 | 922 |
|
911 |
for hmb in hmbs: |
|
912 |
self.progress.setValue(self.progress.value() + 1) |
|
923 |
for hmb in hmbs:
|
|
924 |
self.progress.setValue(self.progress.value() + 1)
|
|
913 | 925 |
|
914 |
if hmb.phase_type: |
|
915 |
Calculation(hmb) |
|
926 |
if hmb.phase_type:
|
|
927 |
Calculation(hmb)
|
|
916 | 928 |
|
917 |
QApplication.processEvents() |
|
929 |
QApplication.processEvents()
|
|
918 | 930 |
|
919 |
""" generate loop """ |
|
920 |
cmd = HydroCalculationCommand(self.graphicsView) |
|
921 |
cmd.execute(None) |
|
922 |
cmd.execute_second(None) |
|
931 |
""" generate loop """
|
|
932 |
cmd = HydroCalculationCommand(self.graphicsView)
|
|
933 |
cmd.execute(None)
|
|
934 |
cmd.execute_second(None)
|
|
923 | 935 |
|
924 |
app_doc_data.activeDrawing.loops = cmd.loops |
|
936 |
app_doc_data.activeDrawing.loops = cmd.loops
|
|
925 | 937 |
|
926 |
self.display_loops() |
|
927 |
self.display_output() |
|
938 |
self.display_loops()
|
|
939 |
self.display_output()
|
|
928 | 940 |
|
929 |
self.load_HMB() |
|
941 |
self.load_HMB()
|
|
930 | 942 |
|
931 |
app_doc_data.save_sheet_history('Calculation') |
|
943 |
app_doc_data.save_sheet_history('Calculation')
|
|
932 | 944 |
finally: |
933 | 945 |
self.progress.setValue(self.progress.maximum()) |
934 | 946 |
self.progress.hide() |
HYTOS/HYTOS/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
18 | 18 |
HOVER_ZVALUE = 200 |
19 | 19 |
|
20 | 20 |
def __init__(self, parent=None): |
21 |
self._color = self.DEFAULT_COLOR # default color |
|
21 |
self._color = self.DEFAULT_COLOR # default color
|
|
22 | 22 |
self._owner = None |
23 | 23 |
self._hover = False |
24 | 24 |
self._area = None |
HYTOS/HYTOS/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
186 | 186 |
""" setter of symbol_idx """ |
187 | 187 |
self._symbol_idx = value |
188 | 188 |
|
189 |
@property |
|
190 |
def spec_break(self): |
|
191 |
""" getter of spec break """ |
|
192 |
return self._spec_break |
|
189 |
def validate(self): |
|
190 |
"""validate connector's data""" |
|
191 |
from SymbolSvgItem import SymbolSvgItem |
|
192 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
|
193 |
|
|
194 |
res = [] |
|
195 |
|
|
196 |
parent = self.parentItem() |
|
197 |
if type(parent) is SymbolSvgItem: |
|
198 |
if parent.category == 'Equipment - [ Pressurized ]': |
|
199 |
if self.connectedItem and (self.data.pressure is None or self.data.elevation is None): |
|
200 |
res.extend([self, 'pressure or elevation is invalid']) |
|
201 |
elif parent.category == 'Equipment - [ Pressure Drop ]' or parent.type == 'Flowmeter': |
|
202 |
if self.connectedItem and (self.data.pressure_drop is None or self.data.elevation is None): |
|
203 |
res.extend([self, 'pressure drop or elevation is invalid']) |
|
204 |
elif parent.category == 'Equipment - [ Rotating ]': |
|
205 |
if self.connectedItem and (self.data.over_design_cv is None is None or self.data.elevation is None): |
|
206 |
res.extend([self, 'over_design_cv or elevation is invalid']) |
|
207 |
elif parent.name == 'Line Splitter': # set default value for line splitter |
|
208 |
if self.connectedItem: |
|
209 |
if self.data.pressure_drop is None: |
|
210 |
self.data.pressure_drop = 0 |
|
211 |
if self.data.elevation is None: |
|
212 |
self.data.elevation = 0 |
|
213 |
elif type(parent) is QEngineeringStreamlineItem: |
|
214 |
pass |
|
215 |
|
|
216 |
return res |
|
193 | 217 |
|
194 | 218 |
''' |
195 | 219 |
@brief return direction vector |
... | ... | |
209 | 233 |
|
210 | 234 |
return None |
211 | 235 |
|
212 |
''' |
|
213 |
@brief build connector item |
|
214 |
@author humkyung |
|
215 |
@date 2018.05.02 |
|
216 |
''' |
|
217 |
|
|
218 | 236 |
def buildItem(self): |
237 |
"""build connector item""" |
|
219 | 238 |
color = Qt.blue |
220 | 239 |
self.setBrush(color) |
221 | 240 |
if self.parent is not None: |
... | ... | |
257 | 276 |
else: |
258 | 277 |
self.connectedItem = None |
259 | 278 |
|
260 |
self.setBrush(Qt.yellow) if self.connectedItem else self.setBrush(Qt.blue) |
|
279 |
if self.connectedItem: |
|
280 |
self.setBrush(Qt.red) if self.validate() else self.setBrush(Qt.yellow) |
|
281 |
else: |
|
282 |
self.setBrush(Qt.blue) |
|
261 | 283 |
|
262 | 284 |
def hoverEnterEvent(self, event): |
263 | 285 |
"""highlight connector""" |
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py | ||
---|---|---|
144 | 144 |
|
145 | 145 |
return hmb_data.pressure_drop if hmb_data else 0 |
146 | 146 |
|
147 |
def validate(self): |
|
148 |
"""validate stream line data""" |
|
149 |
|
|
150 |
# TODO: need to implement this function |
|
151 |
return [[self, 'check the data of mixed type']] if self.data.phase_type == 'Mixed' else None |
|
152 |
|
|
147 | 153 |
def build_connectors(self, connected, pointsUids=None): |
148 | 154 |
""" build connectors for stream line |
149 | 155 |
connected is target connector |
... | ... | |
313 | 319 |
|
314 | 320 |
self.fittings = fittings |
315 | 321 |
|
316 |
''' |
|
317 |
@build build path |
|
318 |
@author humkyung |
|
319 |
@date 2018.04.23 |
|
320 |
''' |
|
321 |
|
|
322 | 322 |
def build_path(self): |
323 |
"""build path""" |
|
323 | 324 |
if not self._vertices or len(self._vertices) < 2: |
324 | 325 |
return |
325 | 326 |
|
... | ... | |
795 | 796 |
painter.setPen(focuspen) |
796 | 797 |
painter.drawPath(self.path()) |
797 | 798 |
else: |
798 |
color = self.getColor() |
|
799 |
color = '#FF0000' if self.validate() else self.getColor()
|
|
799 | 800 |
self.setColor(color) |
800 | 801 |
QGraphicsPathItem.paint(self, painter, option, widget) |
801 | 802 |
|
... | ... | |
829 | 830 |
|
830 | 831 |
def on_symbol_pos_changed(self, symbol): |
831 | 832 |
""" rebuild stream line because symbol position is changed """ |
832 |
if self.connectors[0].connectedItem is not None: self.connectors[0].setPos(
|
|
833 |
self.connectors[0].connectedItem.center()) |
|
834 |
if self.connectors[-1].connectedItem is not None: self.connectors[-1].setPos(
|
|
835 |
self.connectors[-1].connectedItem.center()) |
|
833 |
if self.connectors[0].connectedItem is not None: |
|
834 |
self.connectors[0].setPos(self.connectors[0].connectedItem.center())
|
|
835 |
if self.connectors[-1].connectedItem is not None: |
|
836 |
self.connectors[-1].setPos(self.connectors[-1].connectedItem.center())
|
|
836 | 837 |
self.on_connector_pos_changed(None) |
837 | 838 |
|
838 | 839 |
def on_connector_pos_changed(self, connector): |
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
141 | 141 |
def tag_no(self, value): |
142 | 142 |
self._tag_no = value |
143 | 143 |
|
144 |
''' |
|
145 |
@breif getter owner |
|
146 |
@author humkyung |
|
147 |
@date 2018.05.10 |
|
148 |
''' |
|
149 |
|
|
150 | 144 |
@property |
151 | 145 |
def owner(self): |
146 |
"""getter owner""" |
|
152 | 147 |
import uuid |
153 | 148 |
|
154 | 149 |
if self._owner and type(self._owner) is uuid.UUID: |
... | ... | |
161 | 156 |
self._owner = None |
162 | 157 |
return None |
163 | 158 |
|
164 |
''' |
|
165 |
@brief setter owner |
|
166 |
@author humkyung |
|
167 |
@date 2018.05.10 |
|
168 |
@history 2018.05.17 Jeongwoo Add Calling setColor if self._owner is None or not |
|
169 |
''' |
|
170 |
|
|
171 | 159 |
@owner.setter |
172 | 160 |
def owner(self, value): |
161 |
"""setter owner""" |
|
173 | 162 |
self._owner = value |
174 | 163 |
|
175 | 164 |
if self._owner is None: |
... | ... | |
223 | 212 |
|
224 | 213 |
return self._desc_label |
225 | 214 |
|
226 |
@property |
|
227 |
def Size(self): |
|
228 |
""" return valve's size """ |
|
229 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
|
215 |
def validate(self): |
|
216 |
"""validate symbol data""" |
|
230 | 217 |
|
231 |
matches = [assoc for assoc in self.associations() if type(assoc) is QEngineeringSizeTextItem] |
|
232 |
if matches: |
|
233 |
return matches[0].text() |
|
234 |
else: |
|
235 |
return None |
|
218 |
res = [] |
|
219 |
|
|
220 |
for conn in self.connectors: |
|
221 |
error = conn.validate() |
|
222 |
if error: |
|
223 |
res.append(error) |
|
224 |
|
|
225 |
return res |
|
236 | 226 |
|
237 | 227 |
def includes(self, pt, margin=0): |
238 | 228 |
""" return True if symbol contains given point else return False """ |
HYTOS/HYTOS/UI/Validation.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>ValidationDialog</class> |
|
4 |
<widget class="QDialog" name="ValidationDialog"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>451</width> |
|
10 |
<height>325</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="windowTitle"> |
|
14 |
<string>Validation</string> |
|
15 |
</property> |
|
16 |
<layout class="QGridLayout" name="gridLayout"> |
|
17 |
<item row="0" column="0"> |
|
18 |
<widget class="QTableWidget" name="tableWidgetValidation"> |
|
19 |
<property name="columnCount"> |
|
20 |
<number>2</number> |
|
21 |
</property> |
|
22 |
<column> |
|
23 |
<property name="text"> |
|
24 |
<string>Item</string> |
|
25 |
</property> |
|
26 |
</column> |
|
27 |
<column> |
|
28 |
<property name="text"> |
|
29 |
<string>Message</string> |
|
30 |
</property> |
|
31 |
</column> |
|
32 |
</widget> |
|
33 |
</item> |
|
34 |
<item row="1" column="0"> |
|
35 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
36 |
<property name="orientation"> |
|
37 |
<enum>Qt::Horizontal</enum> |
|
38 |
</property> |
|
39 |
<property name="standardButtons"> |
|
40 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
41 |
</property> |
|
42 |
</widget> |
|
43 |
</item> |
|
44 |
</layout> |
|
45 |
</widget> |
|
46 |
<resources/> |
|
47 |
<connections> |
|
48 |
<connection> |
|
49 |
<sender>buttonBox</sender> |
|
50 |
<signal>accepted()</signal> |
|
51 |
<receiver>ValidationDialog</receiver> |
|
52 |
<slot>accept()</slot> |
|
53 |
<hints> |
|
54 |
<hint type="sourcelabel"> |
|
55 |
<x>248</x> |
|
56 |
<y>254</y> |
|
57 |
</hint> |
|
58 |
<hint type="destinationlabel"> |
|
59 |
<x>157</x> |
|
60 |
<y>274</y> |
|
61 |
</hint> |
|
62 |
</hints> |
|
63 |
</connection> |
|
64 |
<connection> |
|
65 |
<sender>buttonBox</sender> |
|
66 |
<signal>rejected()</signal> |
|
67 |
<receiver>ValidationDialog</receiver> |
|
68 |
<slot>reject()</slot> |
|
69 |
<hints> |
|
70 |
<hint type="sourcelabel"> |
|
71 |
<x>316</x> |
|
72 |
<y>260</y> |
|
73 |
</hint> |
|
74 |
<hint type="destinationlabel"> |
|
75 |
<x>286</x> |
|
76 |
<y>274</y> |
|
77 |
</hint> |
|
78 |
</hints> |
|
79 |
</connection> |
|
80 |
</connections> |
|
81 |
</ui> |
HYTOS/HYTOS/UI/Validation_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file '.\UI\Validation.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.13.2 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
|
|
9 |
|
|
10 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
11 |
|
|
12 |
|
|
13 |
class Ui_ValidationDialog(object): |
|
14 |
def setupUi(self, ValidationDialog): |
|
15 |
ValidationDialog.setObjectName("ValidationDialog") |
|
16 |
ValidationDialog.resize(451, 325) |
|
17 |
self.gridLayout = QtWidgets.QGridLayout(ValidationDialog) |
|
18 |
self.gridLayout.setObjectName("gridLayout") |
|
19 |
self.tableWidgetValidation = QtWidgets.QTableWidget(ValidationDialog) |
|
20 |
self.tableWidgetValidation.setColumnCount(2) |
|
21 |
self.tableWidgetValidation.setObjectName("tableWidgetValidation") |
|
22 |
self.tableWidgetValidation.setRowCount(0) |
|
23 |
item = QtWidgets.QTableWidgetItem() |
|
24 |
self.tableWidgetValidation.setHorizontalHeaderItem(0, item) |
|
25 |
item = QtWidgets.QTableWidgetItem() |
|
26 |
self.tableWidgetValidation.setHorizontalHeaderItem(1, item) |
|
27 |
self.gridLayout.addWidget(self.tableWidgetValidation, 0, 0, 1, 1) |
|
28 |
self.buttonBox = QtWidgets.QDialogButtonBox(ValidationDialog) |
|
29 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
30 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
31 |
self.buttonBox.setObjectName("buttonBox") |
|
32 |
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) |
|
33 |
|
|
34 |
self.retranslateUi(ValidationDialog) |
|
35 |
self.buttonBox.accepted.connect(ValidationDialog.accept) |
|
36 |
self.buttonBox.rejected.connect(ValidationDialog.reject) |
|
37 |
QtCore.QMetaObject.connectSlotsByName(ValidationDialog) |
|
38 |
|
|
39 |
def retranslateUi(self, ValidationDialog): |
|
40 |
_translate = QtCore.QCoreApplication.translate |
|
41 |
ValidationDialog.setWindowTitle(_translate("ValidationDialog", "Validation")) |
|
42 |
item = self.tableWidgetValidation.horizontalHeaderItem(0) |
|
43 |
item.setText(_translate("ValidationDialog", "Item")) |
|
44 |
item = self.tableWidgetValidation.horizontalHeaderItem(1) |
|
45 |
item.setText(_translate("ValidationDialog", "Message")) |
HYTOS/HYTOS/ValidationDialog.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
from PyQt5.QtCore import * |
|
4 |
from PyQt5.QtGui import * |
|
5 |
from PyQt5.QtWidgets import * |
|
6 |
import os |
|
7 |
import sys |
|
8 |
import socket |
|
9 |
import platform |
|
10 |
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), 'UI')) |
|
11 |
from AppDocData import AppDocData, Config |
|
12 |
import Validation_UI |
|
13 |
import math |
|
14 |
|
|
15 |
|
|
16 |
class QValidationDialog(QDialog): |
|
17 |
def __init__(self, parent, errors): |
|
18 |
QDialog.__init__(self, parent) |
|
19 |
|
|
20 |
self.ui = Validation_UI.Ui_ValidationDialog() |
|
21 |
self.ui.setupUi(self) |
|
22 |
|
|
23 |
self.ui.tableWidgetValidation.setRowCount(len(errors)) |
|
24 |
|
|
25 |
row = 0 |
|
26 |
for error in errors: |
|
27 |
item = QTableWidgetItem(repr(error[0])) |
|
28 |
item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
29 |
self.ui.tableWidgetValidation.setItem(row, 0, item) |
|
30 |
|
|
31 |
item = QTableWidgetItem(error[1]) |
|
32 |
item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
|
33 |
self.ui.tableWidgetValidation.setItem(row, 1, item) |
|
34 |
|
|
35 |
row += 1 |
|
36 |
|
|
37 |
def accept(self): |
|
38 |
QDialog.accept(self) |
|
39 |
|
|
40 |
def reject(self): |
|
41 |
QDialog.reject(self) |
내보내기 Unified diff