프로젝트

일반

사용자정보

통계
| 개정판:

hytos / HYTOS / HYTOS / Valve_Manual.py @ 5ddf3ffe

이력 | 보기 | 이력해설 | 다운로드 (2.86 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
class QValve_Manual(QDialog):
17
    def __init__(self):
18
        QDialog.__init__(self)
19

    
20
        self.ui = Valve_Manual_UI.Ui_Valve_ManualDialog()
21
        self.ui.setupUi(self)
22
        self.ui.lineEdit_Pressure_Drop.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Pressure_Drop))
23
        self.ui.lineEdit_Elevation.setValidator(QtGui.QDoubleValidator(self.ui.lineEdit_Elevation))
24
        self.initialize()
25
        
26
    def showDialog(self, item):
27
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
28
        self._item = item
29

    
30
        self.ui.lineEdit_TagNo.setFocus()
31
        self.set_controls(item)
32
        self.load_data()
33

    
34
        self.exec_()
35

    
36
    def initialize(self):
37
        self.ui.label_Img.setVisible(False)
38

    
39
    def set_controls(self, item):    
40
        self.ui.label_Img.setVisible(True)
41

    
42
    def load_data(self):
43
        """ load tag no and nozzle data """
44
        from Drawing import Drawing
45

    
46
        app_doc_data = AppDocData.instance()
47
        drawing = app_doc_data.activeDrawing    
48
        if drawing:
49
            for attr in drawing.attrs:
50
                if attr[0] == 'Units':
51
                    self.ui.label_PressureUnit.setText(attr[1]['Pressure'])
52
                    self.ui.label_ElevationUnit.setText(attr[1]['Length'])
53

    
54
        matches = [connector.nozzle_data for connector in self._item.connectors if connector.nozzle_data]
55
        if matches:
56
            pressure_drop = matches[0].pressure_drop
57
            if pressure_drop:                
58
                self.ui.lineEdit_Pressure_Drop.setText(str(pressure_drop))
59

    
60
            elevation = matches[0].elevation
61
            if elevation:
62
                self.ui.lineEdit_Elevation.setText(str(elevation))
63

    
64
                 
65
    def accept(self):
66
        """ set tag no and nozzle data """
67
        from EngineeringConnectorItem import NozzleData
68

    
69
        for connector in self._item.connectors:
70
            if not connector.nozzle_data: 
71
                connector.nozzle_data = NozzleData()
72

    
73
            pressure_drop = self.ui.lineEdit_Pressure_Drop.text()
74
            if pressure_drop:
75
                connector.nozzle_data.pressure_drop = float(pressure_drop)    
76
            else: 
77
                connector.nozzle_data.pressure_drop = None
78

    
79
            elevation = self.ui.lineEdit_Elevation.text()
80
            if elevation:
81
                connector.nozzle_data.elevation = float(elevation)  
82
            else:
83
                connector.nozzle_data.elevation = None
84

    
85
        QDialog.accept(self)
86

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