개정판 3eb3c614
issue #0000 Export To PAP 수정사항.
Combobox - Calculation Case 에 데이터 추가.
TableView - Hytos SymbolSvgItem 표시
Change-Id: Ifdba536026cc7db991ee15620ffbb82200b7f361
HYTOS/HYTOS/Export_To_PAP.py | ||
---|---|---|
4 | 4 |
from PyQt5 import QtCore, QtGui, QtWidgets |
5 | 5 |
from PyQt5.QtWidgets import * |
6 | 6 |
from PyQt5.QtGui import QMovie |
7 |
from PyQt5.QtCore import * |
|
8 |
from SymbolSvgItem import SymbolSvgItem |
|
7 | 9 |
import os |
8 |
|
|
10 |
import asyncio |
|
11 |
import aiohttp |
|
12 |
from App import App |
|
9 | 13 |
import Export_To_PAP_UI |
10 | 14 |
import math |
11 | 15 |
import requests |
... | ... | |
21 | 25 |
except ValueError: |
22 | 26 |
return False |
23 | 27 |
|
28 |
def strToBool(s): |
|
29 |
return s.upper() == "TRUE" |
|
24 | 30 |
|
25 | 31 |
def is_blank(s): |
26 | 32 |
return not (s and s.strip()) |
... | ... | |
46 | 52 |
return value |
47 | 53 |
|
48 | 54 |
|
55 |
class MappingsDelegate(QStyledItemDelegate): |
|
56 |
def __init__(self, parent=None): |
|
57 |
QStyledItemDelegate.__init__(self, parent) |
|
58 |
|
|
59 |
|
|
60 |
def createEditor(self, parent, option, index): |
|
61 |
editor = None |
|
62 |
#Categoy |
|
63 |
if index.column() == 2: |
|
64 |
phases = ["Maximum Flowrate Case", "Normal Flowrate Case", "Minimum Flowrate Case"] |
|
65 |
editor = QComboBox(parent) |
|
66 |
editor.addItems([str(phases[_index]) for _index in range(len(phases))]) |
|
67 |
|
|
68 |
return editor if editor else super(MappingsDelegate, self).createEditor(parent, option, index) |
|
69 |
|
|
49 | 70 |
class QExport_To_PAP(QDialog): |
50 | 71 |
def __init__(self): |
51 | 72 |
QDialog.__init__(self) |
... | ... | |
56 | 77 |
self.load_movie = QMovie(":/images/loader.gif") |
57 | 78 |
self.close_movie = QMovie(":/images/close.png") |
58 | 79 |
self.done_movie = QMovie(":/images/done.png") |
59 |
self.send_api("/api/Projects", "GET") |
|
80 |
self.ui.comboBox_select_PAP_Project.currentIndexChanged.connect(self.connect_api) |
|
81 |
self.send_api(end_point = "/api/Projects", method= "GET") |
|
82 |
self.data_load() |
|
83 |
#self.ui.tableView_upload_item_list.resizeColumnsToContents() |
|
84 |
#self.ui.tableView_upload_item_list.horizontalHeader().setSectionResizeMode( |
|
85 |
# self.ui.tableView_upload_item_list.horizontalHeader().count() - 1, QtWidgets.QHeaderView.Stretch) |
|
86 |
#self.ui.tableView_upload_item_list.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents); |
|
87 |
self.ui.tableView_upload_item_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) |
|
88 |
|
|
89 |
def data_load(self): |
|
90 |
self.calculation_calse = ["Maximum Flowrate Case", "Normal Flowrate Case", "Minimum Flowrate Case"] |
|
91 |
self.ui.comboBox_Calculation_Case.addItems(self.calculation_calse) |
|
92 |
self.graphicsView = App.mainWnd().graphicsView |
|
93 |
items = [item for item in self.graphicsView.scene.items() if type(item) is SymbolSvgItem] |
|
94 |
if items: |
|
95 |
self.data_frame_to_ui_configuration(items) |
|
96 |
|
|
97 |
def data_frame_to_ui_configuration(self, items): |
|
98 |
headerColumn = ["Item Type.", "Item Tag No." ,"Data Case"] |
|
99 |
# for the table model |
|
100 |
value_model = QtGui.QStandardItemModel() |
|
101 |
# set table headers |
|
102 |
value_model.setColumnCount(len(headerColumn)) |
|
103 |
value_model.setHorizontalHeaderLabels(headerColumn) |
|
104 |
|
|
105 |
# fill table model data |
|
106 |
for row_idx in range(0, len(items)): # len(data_frame.values) |
|
107 |
row = list() |
|
108 |
for col_idx in range(len(headerColumn)): |
|
109 |
if headerColumn[col_idx] == headerColumn[0] : |
|
110 |
value = items[row_idx].type |
|
111 |
if headerColumn[col_idx] == headerColumn[1] : |
|
112 |
value = items[row_idx].tag_no |
|
113 |
val = QtGui.QStandardItem(value) |
|
114 |
val.setEditable(True) |
|
115 |
row.append(val) |
|
116 |
value_model.appendRow(row) |
|
117 |
|
|
118 |
# Sort Filter Proxy Set Model |
|
119 |
self.ui.tableView_upload_item_list.setModel(value_model) |
|
120 |
self.model = value_model |
|
121 |
# Sort Filter Proxy Set Model |
|
122 |
# Set Selection Model |
|
123 |
self.selection_model = self.ui.tableView_upload_item_list.selectionModel() |
|
124 |
# Set Selection Model |
|
125 |
self.ui.tableView_upload_item_list.setSortingEnabled(True) |
|
126 |
self.ui.tableView_upload_item_list.setItemDelegate(MappingsDelegate(self.ui.tableView_upload_item_list)) |
|
60 | 127 |
|
61 | 128 |
def startAnimation(self): |
62 | 129 |
self.close_movie.stop() |
... | ... | |
77 | 144 |
self.ui.label_loading.setMovie(self.close_movie) |
78 | 145 |
self.close_movie.start() |
79 | 146 |
|
80 |
def send_api(self, path, method):
|
|
147 |
def send_api(self, end_point, method):
|
|
81 | 148 |
app_doc_data = AppDocData.instance() |
82 |
url = app_doc_data.API_HOST + path
|
|
149 |
url = app_doc_data.API_HOST + end_point
|
|
83 | 150 |
headers = {'Content-Type': 'application/json', 'charset': 'UTF-8', 'Accept': '*/*'} |
84 | 151 |
try: |
85 | 152 |
if method == 'GET': |
... | ... | |
96 | 163 |
sys.exc_info()[-1].tb_lineno) |
97 | 164 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
98 | 165 |
|
166 |
def connect_api(self, index): |
|
167 |
#self.ui.comboBox_select_PAP_Project.setEnabled(False) |
|
168 |
self.startAnimation() |
|
169 |
QTimer.singleShot(500, self.connections) |
|
170 |
|
|
171 |
def connections(self): |
|
172 |
result = "false" |
|
173 |
projectNo = self.ui.comboBox_select_PAP_Project.currentText() |
|
174 |
try: |
|
175 |
asyncio.run(self.run_connection(projectNo)) |
|
176 |
except Exception as ex: |
|
177 |
from App import App |
|
178 |
from AppDocData import MessageType |
|
179 |
|
|
180 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
181 |
sys.exc_info()[-1].tb_lineno) |
|
182 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
183 |
|
|
184 |
|
|
185 |
async def run_connection(self, projectNo): |
|
186 |
task = asyncio.create_task(self.connection(projectNo)) |
|
187 |
result = await task |
|
188 |
self.ui.comboBox_select_PAP_Project.setEnabled(True) |
|
189 |
if strToBool(str(result)): |
|
190 |
QTimer.singleShot(500, self.doneAnimation) |
|
191 |
else: |
|
192 |
QTimer.singleShot(500, self.closeAnimation) |
|
193 |
|
|
194 |
@asyncio.coroutine |
|
195 |
async def connection(self,projectNo): |
|
196 |
app_doc_data = AppDocData.instance() |
|
197 |
end_point = f"{app_doc_data.API_HOST}/api/Projects/Connection?ProjectName={projectNo}" |
|
198 |
async with aiohttp.ClientSession() as session: |
|
199 |
async with session.get(f'{end_point}') as resp: |
|
200 |
return await resp.json() |
|
201 |
|
|
99 | 202 |
def accept(self): |
100 | 203 |
QDialog.accept(self) |
101 | 204 |
|
내보내기 Unified diff