개정판 1deb99ec
issue #1245 : Hagen-Williams Equation 추가
Change-Id: Ib18cf753a0289002d80cd87eed277adfbd0c36af
HYTOS/HYTOS/Roughness_HagenDialog.py | ||
---|---|---|
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 |
import Roughness_Hagen_UI |
|
14 |
|
|
15 |
|
|
16 |
def set_table_widget_item_properties(name, alignment, color=None): |
|
17 |
if name is None: |
|
18 |
name = '' |
|
19 |
|
|
20 |
item = QTableWidgetItem(str(name)) |
|
21 |
item.setTextAlignment(alignment) |
|
22 |
if color: |
|
23 |
item.setBackground(color) |
|
24 |
|
|
25 |
return item |
|
26 |
|
|
27 |
|
|
28 |
class QRoughness_HagenDialog(QDialog): |
|
29 |
|
|
30 |
def __init__(self): |
|
31 |
QDialog.__init__(self) |
|
32 |
self.ui = Roughness_Hagen_UI.Ui_RoughnessDialog() |
|
33 |
self.ui.setupUi(self) |
|
34 |
self.unit = None |
|
35 |
|
|
36 |
self.ui.tableWidget_Roughness.cellDoubleClicked.connect(self.double_clicked) |
|
37 |
|
|
38 |
def double_clicked(self, row): |
|
39 |
QDialog.accept(self) |
|
40 |
|
|
41 |
def show_dialog(self): |
|
42 |
self.init_roughness() |
|
43 |
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) |
|
44 |
self.exec_() |
|
45 |
|
|
46 |
return self.get_selected_item() |
|
47 |
|
|
48 |
def get_selected_item(self): |
|
49 |
return self.ui.tableWidget_Roughness.item(self.ui.tableWidget_Roughness.currentRow(), 1).text() |
|
50 |
|
|
51 |
def init_roughness(self): |
|
52 |
from AppDocData import AppDocData |
|
53 |
|
|
54 |
self.ui.tableWidget_Roughness.setColumnCount(2) |
|
55 |
self.ui.tableWidget_Roughness.setHorizontalHeaderLabels(['Material', 'Roughness']) |
|
56 |
self.ui.tableWidget_Roughness.horizontalHeaderItem(0).setSizeHint(QSize(25, 25)) |
|
57 |
self.ui.tableWidget_Roughness.horizontalHeader().setStretchLastSection(True) |
|
58 |
self.ui.tableWidget_Roughness.setEditTriggers(QAbstractItemView.NoEditTriggers) |
|
59 |
self.ui.tableWidget_Roughness.verticalHeader().setVisible(False) |
|
60 |
self.ui.tableWidget_Roughness.setSelectionMode(QAbstractItemView.SingleSelection) |
|
61 |
self.ui.tableWidget_Roughness.setSelectionBehavior(QAbstractItemView.SelectRows) |
|
62 |
|
|
63 |
dic_roughness = {'Cement (Asbestos)': 130, |
|
64 |
'Cement (Lined iron or steel)': 130, |
|
65 |
'Cement (Lined iron or steel)': 130, |
|
66 |
'Cast Iron (5 years old)': 120, |
|
67 |
'Cast Iron (10 years old)': 110, |
|
68 |
'Cast Iron (20 years old)': 100, |
|
69 |
'Cast Iron (30 years old)': 90, |
|
70 |
'Steel': 120, |
|
71 |
'Steel (Galvanized)': 130, |
|
72 |
'PE (Polyethylene)': 150, |
|
73 |
'PVC (Polyvinyl Chloride)': 150, |
|
74 |
'FRP (Fibre-reinforced plastic)': 150 |
|
75 |
} |
|
76 |
|
|
77 |
for roughness in dic_roughness: |
|
78 |
row_count = self.ui.tableWidget_Roughness.rowCount() |
|
79 |
self.ui.tableWidget_Roughness.setRowCount(row_count + 1) |
|
80 |
|
|
81 |
self.ui.tableWidget_Roughness.setItem(row_count, 0, set_table_widget_item_properties(roughness, |
|
82 |
Qt.AlignLeft | Qt.AlignVCenter)) |
|
83 |
self.ui.tableWidget_Roughness.setItem(row_count, 1, |
|
84 |
set_table_widget_item_properties(dic_roughness[roughness], |
|
85 |
Qt.AlignRight | Qt.AlignVCenter)) |
|
86 |
|
|
87 |
self.ui.tableWidget_Roughness.resizeColumnToContents(0) |
|
88 |
|
|
89 |
def accept(self): |
|
90 |
QDialog.accept(self) |
|
91 |
|
|
92 |
def reject(self): |
|
93 |
QDialog.reject(self) |
|
94 |
|
|
95 |
if __name__ == '__main__': |
|
96 |
from RoughnessDialog import QRoughnessDialog |
|
97 |
from App import App |
|
98 |
app = App(sys.argv) |
|
99 |
|
|
100 |
if True: |
|
101 |
dlg = QRoughnessDialog() |
|
102 |
dlg.exec_() |
HYTOS/HYTOS/Roughness_Hagen_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file '.\UI\Roughness_Hagen.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.13.0 |
|
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_RoughnessDialog(object): |
|
14 |
def setupUi(self, RoughnessDialog): |
|
15 |
RoughnessDialog.setObjectName("RoughnessDialog") |
|
16 |
RoughnessDialog.resize(317, 403) |
|
17 |
font = QtGui.QFont() |
|
18 |
font.setFamily("맑은 고딕") |
|
19 |
RoughnessDialog.setFont(font) |
|
20 |
icon = QtGui.QIcon() |
|
21 |
icon.addPixmap(QtGui.QPixmap(":/images/HYTOS.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
22 |
RoughnessDialog.setWindowIcon(icon) |
|
23 |
self.gridLayout_2 = QtWidgets.QGridLayout(RoughnessDialog) |
|
24 |
self.gridLayout_2.setObjectName("gridLayout_2") |
|
25 |
self.gridLayout = QtWidgets.QGridLayout() |
|
26 |
self.gridLayout.setObjectName("gridLayout") |
|
27 |
self.tableWidget_Roughness = QtWidgets.QTableWidget(RoughnessDialog) |
|
28 |
self.tableWidget_Roughness.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) |
|
29 |
self.tableWidget_Roughness.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems) |
|
30 |
self.tableWidget_Roughness.setObjectName("tableWidget_Roughness") |
|
31 |
self.tableWidget_Roughness.setColumnCount(0) |
|
32 |
self.tableWidget_Roughness.setRowCount(0) |
|
33 |
self.gridLayout.addWidget(self.tableWidget_Roughness, 1, 0, 1, 1) |
|
34 |
self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1) |
|
35 |
self.buttonBox = QtWidgets.QDialogButtonBox(RoughnessDialog) |
|
36 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
37 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
38 |
self.buttonBox.setObjectName("buttonBox") |
|
39 |
self.gridLayout_2.addWidget(self.buttonBox, 2, 0, 1, 1) |
|
40 |
|
|
41 |
self.retranslateUi(RoughnessDialog) |
|
42 |
self.buttonBox.accepted.connect(RoughnessDialog.accept) |
|
43 |
self.buttonBox.rejected.connect(RoughnessDialog.reject) |
|
44 |
QtCore.QMetaObject.connectSlotsByName(RoughnessDialog) |
|
45 |
|
|
46 |
def retranslateUi(self, RoughnessDialog): |
|
47 |
_translate = QtCore.QCoreApplication.translate |
|
48 |
RoughnessDialog.setWindowTitle(_translate("RoughnessDialog", "Select Material (Hagen Williams Eq.)")) |
|
49 |
import Resource_rc |
HYTOS/HYTOS/UI/Roughness_Hagen.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>RoughnessDialog</class> |
|
4 |
<widget class="QDialog" name="RoughnessDialog"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>317</width> |
|
10 |
<height>403</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="font"> |
|
14 |
<font> |
|
15 |
<family>맑은 고딕</family> |
|
16 |
</font> |
|
17 |
</property> |
|
18 |
<property name="windowTitle"> |
|
19 |
<string>Select Material (Hagen Williams Eq.)</string> |
|
20 |
</property> |
|
21 |
<property name="windowIcon"> |
|
22 |
<iconset resource="../res/Resource.qrc"> |
|
23 |
<normaloff>:/images/HYTOS.png</normaloff>:/images/HYTOS.png</iconset> |
|
24 |
</property> |
|
25 |
<layout class="QGridLayout" name="gridLayout_2"> |
|
26 |
<item row="1" column="0"> |
|
27 |
<layout class="QGridLayout" name="gridLayout"> |
|
28 |
<item row="1" column="0"> |
|
29 |
<widget class="QTableWidget" name="tableWidget_Roughness"> |
|
30 |
<property name="selectionMode"> |
|
31 |
<enum>QAbstractItemView::ExtendedSelection</enum> |
|
32 |
</property> |
|
33 |
<property name="selectionBehavior"> |
|
34 |
<enum>QAbstractItemView::SelectItems</enum> |
|
35 |
</property> |
|
36 |
</widget> |
|
37 |
</item> |
|
38 |
</layout> |
|
39 |
</item> |
|
40 |
<item row="2" column="0"> |
|
41 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
42 |
<property name="orientation"> |
|
43 |
<enum>Qt::Horizontal</enum> |
|
44 |
</property> |
|
45 |
<property name="standardButtons"> |
|
46 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
47 |
</property> |
|
48 |
</widget> |
|
49 |
</item> |
|
50 |
</layout> |
|
51 |
</widget> |
|
52 |
<tabstops> |
|
53 |
<tabstop>tableWidget_Roughness</tabstop> |
|
54 |
</tabstops> |
|
55 |
<resources> |
|
56 |
<include location="../res/Resource.qrc"/> |
|
57 |
</resources> |
|
58 |
<connections> |
|
59 |
<connection> |
|
60 |
<sender>buttonBox</sender> |
|
61 |
<signal>accepted()</signal> |
|
62 |
<receiver>RoughnessDialog</receiver> |
|
63 |
<slot>accept()</slot> |
|
64 |
<hints> |
|
65 |
<hint type="sourcelabel"> |
|
66 |
<x>248</x> |
|
67 |
<y>254</y> |
|
68 |
</hint> |
|
69 |
<hint type="destinationlabel"> |
|
70 |
<x>157</x> |
|
71 |
<y>274</y> |
|
72 |
</hint> |
|
73 |
</hints> |
|
74 |
</connection> |
|
75 |
<connection> |
|
76 |
<sender>buttonBox</sender> |
|
77 |
<signal>rejected()</signal> |
|
78 |
<receiver>RoughnessDialog</receiver> |
|
79 |
<slot>reject()</slot> |
|
80 |
<hints> |
|
81 |
<hint type="sourcelabel"> |
|
82 |
<x>316</x> |
|
83 |
<y>260</y> |
|
84 |
</hint> |
|
85 |
<hint type="destinationlabel"> |
|
86 |
<x>286</x> |
|
87 |
<y>274</y> |
|
88 |
</hint> |
|
89 |
</hints> |
|
90 |
</connection> |
|
91 |
</connections> |
|
92 |
</ui> |
내보내기 Unified diff