개정판 b0085449
issue #1060: 계산 오류 처리 방법 수정
Change-Id: If048e0e780d08c408877660975ecf6a894bd3466
HYTOS/HYTOS/CalculationValidation.py | ||
---|---|---|
18 | 18 |
ERRORS = 0 |
19 | 19 |
|
20 | 20 |
def __init__(self): |
21 |
from HydroCalculationCommand import HydroCalculationCommand |
|
22 |
|
|
21 | 23 |
QDialog.__init__(self) |
22 | 24 |
self.ui = CalculationValidation_UI.Ui_Dialog() |
23 | 25 |
self.ui.setupUi(self) |
24 |
QCalculationValidation.ERRORS += 1
|
|
26 |
HydroCalculationCommand.ERRORS += 1
|
|
25 | 27 |
|
26 | 28 |
def show_dialog(self, cause, detail): |
27 | 29 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) |
HYTOS/HYTOS/Commands/HydroCalculationCommand.py | ||
---|---|---|
19 | 19 |
""" Hydro Calculation class """ |
20 | 20 |
|
21 | 21 |
onSuccess = pyqtSignal(QGraphicsItem) |
22 |
ERRORS = 0 |
|
22 | 23 |
|
23 | 24 |
def __init__(self, imageViewer): |
24 |
from CalculationValidation import QCalculationValidation |
|
25 |
|
|
26 | 25 |
super(HydroCalculationCommand, self).__init__(imageViewer) |
27 | 26 |
self.name = 'HydroCalculation' |
28 | 27 |
|
29 | 28 |
self.units = {} |
30 | 29 |
self.loops = [] |
31 |
QCalculationValidation.ERRORS = 0 |
|
32 | 30 |
|
33 | 31 |
def is_loop_start_item(self, item): |
34 | 32 |
"""check given item is possible of start of loop""" |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
131 | 131 |
self.actionSave_As.triggered.connect(self.on_save_as) |
132 | 132 |
self.actionUndo.triggered.connect(self.on_undo) |
133 | 133 |
self.actionRedo.triggered.connect(self.on_redo) |
134 |
self.actionCalculation.triggered.connect(self.calculation)
|
|
134 |
self.actionCalculation.triggered.connect(partial(self.calculation, True))
|
|
135 | 135 |
self.actionGenerateReport.triggered.connect(self.generate_report) |
136 | 136 |
self.actionLine.triggered.connect(self.onPlaceLine) |
137 | 137 |
self.actionConfiguration.triggered.connect(self.configuration) |
... | ... | |
1077 | 1077 |
sys.exc_info()[-1].tb_lineno) |
1078 | 1078 |
self.addMessage.emit(MessageType.Error, message) |
1079 | 1079 |
|
1080 |
def calculation(self): |
|
1080 |
def calculation(self, saving=False):
|
|
1081 | 1081 |
"""execute hydro calculation""" |
1082 | 1082 |
from AppDocData import AppDocData |
1083 | 1083 |
from Calculation import Calculation |
... | ... | |
1098 | 1098 |
type(item) is QEngineeringStreamlineItem] |
1099 | 1099 |
for item in items: |
1100 | 1100 |
error = item.validate() |
1101 |
if error: errors.extend(error) |
|
1101 |
if error: |
|
1102 |
errors.extend(error) |
|
1102 | 1103 |
|
1104 |
HydroCalculationCommand.ERRORS = 0 |
|
1103 | 1105 |
if errors: |
1104 | 1106 |
dlg = QValidationDialog(self, errors) |
1105 | 1107 |
dlg.show() |
1108 |
HydroCalculationCommand.ERRORS = len(errors) |
|
1106 | 1109 |
else: |
1107 | 1110 |
self.progress = QProgressDialog(self.tr("Please wait for a while"), self.tr("Cancel"), 0, 100, self) \ |
1108 | 1111 |
if not hasattr(self, 'progress') else self.progress |
... | ... | |
1137 | 1140 |
|
1138 | 1141 |
self.load_HMB() |
1139 | 1142 |
|
1140 |
app_doc_data.save_sheet_history('Calculation') |
|
1143 |
if saving: |
|
1144 |
app_doc_data.save_sheet_history('Calculation') |
|
1141 | 1145 |
finally: |
1142 | 1146 |
self.progress.setValue(self.progress.maximum()) |
1143 | 1147 |
self.progress.hide() |
... | ... | |
2176 | 2180 |
|
2177 | 2181 |
self.load_components(components) |
2178 | 2182 |
|
2183 |
""" TODO: 확인 필요 |
|
2179 | 2184 |
# Loops 와 Output 을 만들기 위해 Calculation 을 한다 |
2180 | 2185 |
for hmb in app_doc_data.activeDrawing.hmbTable._hmbs: |
2181 | 2186 |
if hmb.phase_type: |
... | ... | |
2190 | 2195 |
self.display_output() |
2191 | 2196 |
|
2192 | 2197 |
self.load_HMB() |
2198 |
""" |
|
2199 |
self.calculation() |
|
2193 | 2200 |
finally: |
2194 | 2201 |
self.progress.setValue(self.progress.maximum()) |
2195 | 2202 |
self.progress.hide() |
HYTOS/HYTOS/QtImageViewer.py | ||
---|---|---|
413 | 413 |
@date 2018.07.23 |
414 | 414 |
''' |
415 | 415 |
def drawBackground(self, painter, rect): |
416 |
from CalculationValidation import QCalculationValidation
|
|
416 |
from HydroCalculationCommand import HydroCalculationCommand
|
|
417 | 417 |
|
418 | 418 |
QGraphicsView.drawBackground(self, painter, rect) |
419 | 419 |
|
... | ... | |
430 | 430 |
rect.setTop(rect.top() - 5) |
431 | 431 |
rect.setRight(rect.right() - 5) |
432 | 432 |
rect.setBottom(rect.bottom() - 5) |
433 |
painter.fillRect(rect, QBrush(Qt.white)) |
|
433 |
if not HydroCalculationCommand.ERRORS: |
|
434 |
painter.fillRect(rect, QBrush(Qt.white)) |
|
435 |
else: |
|
436 |
painter.fillRect(rect, QBrush(Qt.lightGray)) |
|
434 | 437 |
|
435 |
if QCalculationValidation.ERRORS:
|
|
436 |
_pixmap = QPixmap(':/images/error.svg')
|
|
437 |
painter.drawPixmap(self.sceneRect(), _pixmap, QRectF(_pixmap.rect()))
|
|
438 |
painter.setPen(Qt.red)
|
|
439 |
painter.drawLine(rect.left(), rect.top(), rect.right(), rect.bottom())
|
|
440 |
painter.drawLine(rect.right(), rect.top(), rect.left(), rect.bottom())
|
|
438 | 441 |
|
439 | 442 |
''' |
440 | 443 |
@history 2018.06.11 Jeongwoo Change method to manage guideline items |
내보내기 Unified diff