프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / HYTOS / HYTOS / Valve_Manual.py @ 4211450a

이력 | 보기 | 이력해설 | 다운로드 (3.21 KB)

1
# -*- coding: utf-8 -*-
2

    
3
# Form implementation generated from reading ui file 'ProjectDialog.ui'
4
#
5
# Created by: PyQt5 UI code generator 5.6
6
#
7
# WARNING! All changes made in this file will be lost!
8

    
9
from PyQt5 import QtCore, QtGui, QtWidgets
10
from PyQt5.QtWidgets import *
11
import os
12
from AppDocData import AppDocData
13
import Valve_Manual_UI
14
import math
15

    
16

    
17
def is_not_blank(s):
18
    return bool(s and s.strip())
19

    
20

    
21
class QValve_Manual(QDialog):
22
    def __init__(self):
23
        QDialog.__init__(self)
24

    
25
        self.ui = Valve_Manual_UI.Ui_Valve_ManualDialog()
26
        self.ui.setupUi(self)
27
        self._item = None
28

    
29
        self.ui.lineEdit_Pressure_Drop.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Pressure_Drop))
30
        self.ui.lineEdit_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Elevation))
31
        self.initialize()
32

    
33
    def show_dialog(self, item):
34
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
35
        self._item = item
36

    
37
        self.ui.lineEdit_TagNo.setFocus()
38
        self.set_controls()
39
        self.load_data()
40

    
41
        return self.exec_()
42

    
43
    def initialize(self):
44
        self.ui.label_Img.setVisible(False)
45

    
46
    def set_controls(self):
47
        self.ui.label_Img.setVisible(True)
48

    
49
    def load_data(self):
50
        """ load tag no and nozzle data """
51
        tag_no = self._item.tag_no
52
        if tag_no != 'None' and is_not_blank(tag_no):
53
            self.ui.lineEdit_TagNo.setText(tag_no)
54

    
55
        app_doc_data = AppDocData.instance()
56
        drawing = app_doc_data.activeDrawing
57
        if drawing:
58
            for attr in drawing.attrs:
59
                if attr[0] == 'Units':
60
                    self.ui.label_PressureUnit.setText(attr[1]['Pressure'])
61
                    self.ui.label_ElevationUnit.setText(attr[1]['Length'])
62

    
63
        matches = [connector.data for connector in self._item.connectors if connector.data]
64
        if matches:
65
            pressure_drop = matches[0].pressure_drop
66
            if pressure_drop:
67
                self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop))
68

    
69
            elevation = matches[0].elevation
70
            if elevation:
71
                self.ui.lineEdit_Elevation.setText(str(elevation))
72

    
73
    def accept(self):
74
        """ set tag no and nozzle data """
75
        from EngineeringConnectorItem import NozzleData
76
        tag_no = self.ui.lineEdit_TagNo.text()
77

    
78
        if is_not_blank(tag_no):
79
            self._item.tag_no = tag_no
80
            for connector in self._item.connectors:
81
                if not connector.data:
82
                    connector.data = NozzleData()
83

    
84
                pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
85
                if pressure_drop:
86
                    connector.data.pressure_drop = float(pressure_drop)
87
                else:
88
                    connector.data.pressure_drop = None
89

    
90
                elevation = self.ui.lineEdit_Elevation.text()
91
                if elevation:
92
                    connector.data.elevation = float(elevation)
93
                else:
94
                    connector.data.elevation = None
95

    
96
            QDialog.accept(self)
97
        else:
98
            QMessageBox.warning(self, self.tr('Notice'), self.tr('Please Input [Tag No.]'))
99

    
100
    def reject(self):
101
        QDialog.reject(self)
클립보드 이미지 추가 (최대 크기: 500 MB)