개정판 47604221
fixed issue #577: Equipment Desc. 영역 설정
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
854 | 854 |
def saveConfigs(self, configs): |
855 | 855 |
try: |
856 | 856 |
# Creates or opens a file called mydb with a SQLite3 DB |
857 |
dbPath = self.getCurrentProject().getDbFilePath() + "/ITI_PID.db"
|
|
857 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db")
|
|
858 | 858 |
conn = sqlite3.connect(dbPath) |
859 | 859 |
# Get a cursor object |
860 | 860 |
cursor = conn.cursor() |
... | ... | |
873 | 873 |
conn.close() |
874 | 874 |
|
875 | 875 |
''' |
876 |
@brief delete configurations |
|
877 |
@author humkyung |
|
878 |
@date 2018.06.29 |
|
879 |
''' |
|
880 |
def deleteConfigs(self, section, key=None): |
|
881 |
try: |
|
882 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
883 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db") |
|
884 |
conn = sqlite3.connect(dbPath) |
|
885 |
# Get a cursor object |
|
886 |
cursor = conn.cursor() |
|
887 |
|
|
888 |
if key is not None: |
|
889 |
sql = "delete from configuration where section='{}' and key='{}'".format(section, key) |
|
890 |
else: |
|
891 |
sql = "delete from configuration where section='{}'".format(section) |
|
892 |
cursor.execute(sql) |
|
893 |
|
|
894 |
conn.commit() |
|
895 |
# Catch the exception |
|
896 |
except Exception as ex: |
|
897 |
# Roll back any change if something goes wrong |
|
898 |
conn.rollback() |
|
899 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
900 |
finally: |
|
901 |
# Close the db connection |
|
902 |
conn.close() |
|
903 |
|
|
904 |
''' |
|
876 | 905 |
@brief set area list |
877 | 906 |
@history humkyung 2018.05.18 round area coordinate and dimension before saving |
878 | 907 |
''' |
DTI_PID/DTI_PID/ConfigurationAreaDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
import os |
|
3 |
import sys |
|
4 |
from PyQt5.QtCore import * |
|
5 |
from PyQt5.QtGui import * |
|
6 |
from PyQt5.QtWidgets import * |
|
7 |
import sqlite3 |
|
8 |
|
|
9 |
from AppDocData import AppDocData, Config |
|
10 |
from AppDocData import Area |
|
11 |
|
|
12 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands') |
|
13 |
import CreateCommand |
|
14 |
import CropCommand |
|
15 |
import FenceCommand |
|
16 |
|
|
17 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes') |
|
18 |
import QGraphicsPolylineItem |
|
19 |
from QEngineeringLineItem import QEngineeringLineItem |
|
20 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
21 |
import Configuration_Area_UI |
|
22 |
|
|
23 |
class QConfigurationAreaDialog(QDialog): |
|
24 |
def __init__(self, parent): |
|
25 |
import re |
|
26 |
THICKNESS = 5 |
|
27 |
|
|
28 |
QDialog.__init__(self, parent) |
|
29 |
|
|
30 |
self.ui = Configuration_Area_UI.Ui_AreaDialog() |
|
31 |
self.ui.setupUi(self) |
|
32 |
self.ui.tableWidgetEquipmentDescArea.setColumnCount(2) |
|
33 |
self.ui.tableWidgetEquipmentDescArea.setHorizontalHeaderLabels(['Drawing Name', 'Area']) |
|
34 |
self.ui.tableWidgetEquipmentDescArea.horizontalHeaderItem(0).setSizeHint(QSize(30, 30)) |
|
35 |
self.isAccepted = False |
|
36 |
self._cmd = FenceCommand.FenceCommand(self.parent().graphicsView) |
|
37 |
self._cmd.onSuccess.connect(self.areaCreated) |
|
38 |
|
|
39 |
docData = AppDocData.instance() |
|
40 |
areas = docData.getAreaList() |
|
41 |
|
|
42 |
# load area of drawing |
|
43 |
matches = [x for x in areas if x.name=='Drawing'] |
|
44 |
self.ui.lineEditDrawing.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
45 |
if self.ui.lineEditDrawing.tag is not None: |
|
46 |
self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
47 |
self.ui.lineEditDrawing.tag.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
48 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditDrawing.tag) |
|
49 |
self.ui.pushButtonDrawingArea.setStyleSheet('background-color: red') |
|
50 |
|
|
51 |
matches = [x for x in areas if x.name=='Note'] |
|
52 |
self.ui.lineEditNote.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
53 |
if self.ui.lineEditNote.tag is not None: |
|
54 |
self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
55 |
self.ui.lineEditNote.tag.setPen(QPen(Qt.blue, THICKNESS, Qt.SolidLine)) |
|
56 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditNote.tag) |
|
57 |
self.ui.pushButtonNoteArea.setStyleSheet('background-color: blue') |
|
58 |
|
|
59 |
matches = [x for x in areas if x.name=='History Data'] |
|
60 |
self.ui.lineEditHistoryData.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
61 |
if self.ui.lineEditHistoryData.tag is not None: |
|
62 |
self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
63 |
self.ui.lineEditHistoryData.tag.setPen(QPen(Qt.magenta, THICKNESS, Qt.SolidLine)) |
|
64 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditHistoryData.tag) |
|
65 |
self.ui.pushButtonHistoryDataArea.setStyleSheet('background-color: magenta') |
|
66 |
|
|
67 |
matches = [x for x in areas if x.name=='Area'] |
|
68 |
self.ui.lineEditArea.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
69 |
if self.ui.lineEditArea.tag is not None: |
|
70 |
self.ui.lineEditArea.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
71 |
self.ui.lineEditArea.tag.setPen(QPen(Qt.green, THICKNESS, Qt.SolidLine)) |
|
72 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditArea.tag) |
|
73 |
self.ui.pushButtonAreaArea.setStyleSheet('background-color: green') |
|
74 |
|
|
75 |
matches = [x for x in areas if x.name=='Drawing No'] |
|
76 |
self.ui.lineEditDrawingNo.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
77 |
if self.ui.lineEditDrawingNo.tag is not None: |
|
78 |
self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
79 |
self.ui.lineEditDrawingNo.tag.setPen(QPen(Qt.cyan, THICKNESS, Qt.SolidLine)) |
|
80 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditDrawingNo.tag) |
|
81 |
self.ui.pushButtonDrawingNoArea.setStyleSheet('background-color: cyan') |
|
82 |
|
|
83 |
matches = [x for x in areas if x.name=='Rev No'] |
|
84 |
self.ui.lineEditRevNo.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
85 |
if self.ui.lineEditRevNo.tag is not None: |
|
86 |
self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
87 |
self.ui.lineEditRevNo.tag.setPen(QPen(Qt.yellow, THICKNESS, Qt.SolidLine)) |
|
88 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditRevNo.tag) |
|
89 |
self.ui.pushButtonRevNoArea.setStyleSheet('background-color: yellow') |
|
90 |
# up to here |
|
91 |
|
|
92 |
self.ui.pushButtonAdd.setStyleSheet('background-color: darkGray') |
|
93 |
|
|
94 |
section = '{} Equipment Desc Area'.format(docData.imgName) |
|
95 |
configs = docData.getConfigs(section) |
|
96 |
self.ui.tableWidgetEquipmentDescArea.setRowCount(len(configs)) |
|
97 |
row = 0 |
|
98 |
for config in configs: |
|
99 |
item = QTableWidgetItem(docData.imgName) |
|
100 |
item.setFlags(Qt.ItemIsEnabled) |
|
101 |
self.ui.tableWidgetEquipmentDescArea.setItem(row, 0, item) |
|
102 |
item = QTableWidgetItem(config.value) |
|
103 |
item.setFlags(Qt.ItemIsEnabled) |
|
104 |
self.ui.tableWidgetEquipmentDescArea.setItem(row, 1, item) |
|
105 |
|
|
106 |
found = re.findall('\d+', config.value) |
|
107 |
if len(found) == 4: |
|
108 |
x = float(int(found[0])) |
|
109 |
y = float(int(found[1])) |
|
110 |
width = float(int(found[2])) - x |
|
111 |
height = float(int(found[3])) - y |
|
112 |
boundingBox = QGraphicsBoundingBoxItem(x, y, width, height) |
|
113 |
boundingBox.setPen(QPen(Qt.darkGray, THICKNESS, Qt.SolidLine)) |
|
114 |
self.parent().graphicsView.scene.addItem(boundingBox) |
|
115 |
|
|
116 |
row += 1 |
|
117 |
self.ui.tableWidgetEquipmentDescArea.resizeColumnsToContents() |
|
118 |
|
|
119 |
self.ui.pushButtonDrawingArea.clicked.connect(self.selectDrawingArea) |
|
120 |
self.ui.pushButtonNoteArea.clicked.connect(self.selectNoteArea) |
|
121 |
self.ui.pushButtonHistoryDataArea.clicked.connect(self.selectHistoryDataArea) |
|
122 |
self.ui.pushButtonAreaArea.clicked.connect(self.selectAreaArea) |
|
123 |
self.ui.pushButtonDrawingNoArea.clicked.connect(self.selectDrawingNoArea) |
|
124 |
self.ui.pushButtonRevNoArea.clicked.connect(self.selectRevNoArea) |
|
125 |
self.ui.pushButtonAdd.clicked.connect(self.onSelectEquipmentDescArea) |
|
126 |
self.ui.pushButtonDel.clicked.connect(self.onDeleteEquipmentDescArea) |
|
127 |
|
|
128 |
def selectDrawingArea(self): |
|
129 |
self._cmd.tag = self.ui.lineEditDrawing |
|
130 |
self.parent().graphicsView.command = self._cmd |
|
131 |
|
|
132 |
def selectNoteArea(self): |
|
133 |
self._cmd.tag = self.ui.lineEditNote |
|
134 |
self.parent().graphicsView.command = self._cmd |
|
135 |
|
|
136 |
def selectHistoryDataArea(self): |
|
137 |
self._cmd.tag = self.ui.lineEditHistoryData |
|
138 |
self.parent().graphicsView.command = self._cmd |
|
139 |
|
|
140 |
def selectAreaArea(self): |
|
141 |
self._cmd.tag = self.ui.lineEditArea |
|
142 |
self.parent().graphicsView.command = self._cmd |
|
143 |
|
|
144 |
def selectDrawingNoArea(self): |
|
145 |
self._cmd.tag = self.ui.lineEditDrawingNo |
|
146 |
self.parent().graphicsView.command = self._cmd |
|
147 |
|
|
148 |
def selectRevNoArea(self): |
|
149 |
self._cmd.tag = self.ui.lineEditRevNo |
|
150 |
self.parent().graphicsView.command = self._cmd |
|
151 |
|
|
152 |
''' |
|
153 |
@brief select equipment desc area |
|
154 |
@author humkyung |
|
155 |
@date 2018.06.29 |
|
156 |
''' |
|
157 |
def onSelectEquipmentDescArea(self): |
|
158 |
self._cmd.tag = self.ui.lineEditEquipmentDescArea |
|
159 |
self.parent().graphicsView.command = self._cmd |
|
160 |
|
|
161 |
''' |
|
162 |
@brief remove equipment desc. area from graphicsview |
|
163 |
@author humkyung |
|
164 |
@date 2018.06.29 |
|
165 |
''' |
|
166 |
def removeEquipmentDescArea(self, area): |
|
167 |
import re |
|
168 |
|
|
169 |
try: |
|
170 |
found = re.findall('\d+',area) |
|
171 |
item = self.parent().graphicsView.scene.itemAt(float(int(found[0])), float(int(found[1])), QTransform()) |
|
172 |
if item is not None: |
|
173 |
self.parent().graphicsView.scene.removeItem(item) |
|
174 |
except Exception as ex: |
|
175 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
176 |
|
|
177 |
''' |
|
178 |
@brief delete selected equipment desc area |
|
179 |
@author humkyung |
|
180 |
@date 2018.06.29 |
|
181 |
''' |
|
182 |
def onDeleteEquipmentDescArea(self): |
|
183 |
try: |
|
184 |
row = self.ui.tableWidgetEquipmentDescArea.currentRow() |
|
185 |
area = self.ui.tableWidgetEquipmentDescArea.item(row, 1).text() |
|
186 |
self.removeEquipmentDescArea(area) |
|
187 |
self.ui.tableWidgetEquipmentDescArea.removeRow(row) |
|
188 |
except Exception as ex: |
|
189 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
190 |
|
|
191 |
''' |
|
192 |
@brief called when area is created |
|
193 |
@history humkyung 2018.06.29 add equipment desc. area |
|
194 |
''' |
|
195 |
def areaCreated(self, x, y , width, height): |
|
196 |
THICKNESS = 5 |
|
197 |
|
|
198 |
if self._cmd.tag is self.ui.lineEditDrawing: |
|
199 |
if self.ui.lineEditDrawing.tag is None: |
|
200 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
201 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
202 |
self.parent().graphicsView.scene.addItem(item) |
|
203 |
|
|
204 |
self.ui.lineEditDrawing.tag = item |
|
205 |
else: |
|
206 |
self.ui.lineEditDrawing.tag.setRect(x, y, width, height) |
|
207 |
|
|
208 |
self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
209 |
elif self._cmd.tag is self.ui.lineEditNote: |
|
210 |
if self.ui.lineEditNote.tag is None: |
|
211 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
212 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
213 |
self.parent().graphicsView.scene.addItem(item) |
|
214 |
|
|
215 |
self.ui.lineEditNote.tag = item |
|
216 |
else: |
|
217 |
self.ui.lineEditNote.tag.setRect(x, y, width, height) |
|
218 |
|
|
219 |
self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
220 |
elif self._cmd.tag is self.ui.lineEditHistoryData: |
|
221 |
if self.ui.lineEditHistoryData.tag is None: |
|
222 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
223 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
224 |
self.parent().graphicsView.scene.addItem(item) |
|
225 |
|
|
226 |
self.ui.lineEditHistoryData.tag = item |
|
227 |
else: |
|
228 |
self.ui.lineEditHistoryData.tag.setRect(x, y, width, height) |
|
229 |
|
|
230 |
self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
231 |
elif self._cmd.tag is self.ui.lineEditArea: |
|
232 |
if self.ui.lineEditArea.tag is None: |
|
233 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
234 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
235 |
self.parent().graphicsView.scene.addItem(item) |
|
236 |
|
|
237 |
self.ui.lineEditArea.tag = item |
|
238 |
else: |
|
239 |
self.ui.lineEditArea.tag.setRect(x, y, width, height) |
|
240 |
|
|
241 |
self.ui.lineEditArea.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
242 |
elif self._cmd.tag is self.ui.lineEditDrawingNo: |
|
243 |
if self.ui.lineEditDrawingNo.tag is None: |
|
244 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
245 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
246 |
self.parent().graphicsView.scene.addItem(item) |
|
247 |
|
|
248 |
self.ui.lineEditDrawingNo.tag = item |
|
249 |
else: |
|
250 |
self.ui.lineEditDrawingNo.tag.setRect(x, y, width, height) |
|
251 |
|
|
252 |
self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
253 |
elif self._cmd.tag is self.ui.lineEditRevNo: |
|
254 |
if self.ui.lineEditRevNo.tag is None: |
|
255 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
256 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
257 |
self.parent().graphicsView.scene.addItem(item) |
|
258 |
|
|
259 |
self.ui.lineEditRevNo.tag = item |
|
260 |
else: |
|
261 |
self.ui.lineEditRevNo.tag.setRect(x, y, width, height) |
|
262 |
|
|
263 |
self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
264 |
elif self._cmd.tag is self.ui.lineEditEquipmentDescArea: |
|
265 |
x, y = round(x), round(y) |
|
266 |
width, height = round(width), round(height) |
|
267 |
|
|
268 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
269 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
270 |
self.parent().graphicsView.scene.addItem(item) |
|
271 |
|
|
272 |
strArea = '({},{}),({},{})'.format(x, y, x + width, y + height) |
|
273 |
self.ui.lineEditEquipmentDescArea.setText(strArea) |
|
274 |
|
|
275 |
# add item to table widget |
|
276 |
docData = AppDocData.instance() |
|
277 |
row = self.ui.tableWidgetEquipmentDescArea.rowCount() |
|
278 |
self.ui.tableWidgetEquipmentDescArea.setRowCount(row + 1) |
|
279 |
item = QTableWidgetItem(docData.imgName) |
|
280 |
item.setFlags(Qt.ItemIsEnabled) |
|
281 |
self.ui.tableWidgetEquipmentDescArea.setItem(row, 0, item) |
|
282 |
item = QTableWidgetItem(strArea) |
|
283 |
item.setFlags(Qt.ItemIsEnabled) |
|
284 |
self.ui.tableWidgetEquipmentDescArea.setItem(row, 1, item) |
|
285 |
self.ui.tableWidgetEquipmentDescArea.resizeColumnsToContents() |
|
286 |
# up to here |
|
287 |
|
|
288 |
self.parent().graphicsView.command = None |
|
289 |
|
|
290 |
''' |
|
291 |
@brief accept dialog |
|
292 |
''' |
|
293 |
def accept(self): |
|
294 |
try: |
|
295 |
areas = [] |
|
296 |
|
|
297 |
if self.ui.lineEditDrawing.tag is not None: |
|
298 |
area = Area() |
|
299 |
area.name = 'Drawing' |
|
300 |
area.x = self.ui.lineEditDrawing.tag.rect().left() |
|
301 |
area.y = self.ui.lineEditDrawing.tag.rect().top() |
|
302 |
area.width = self.ui.lineEditDrawing.tag.rect().width() |
|
303 |
area.height = self.ui.lineEditDrawing.tag.rect().height() |
|
304 |
areas.append(area) |
|
305 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawing.tag) |
|
306 |
|
|
307 |
if self.ui.lineEditNote.tag is not None: |
|
308 |
area = Area() |
|
309 |
area.name = 'Note' |
|
310 |
area.x = self.ui.lineEditNote.tag.rect().left() |
|
311 |
area.y = self.ui.lineEditNote.tag.rect().top() |
|
312 |
area.width = self.ui.lineEditNote.tag.rect().width() |
|
313 |
area.height = self.ui.lineEditNote.tag.rect().height() |
|
314 |
areas.append(area) |
|
315 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditNote.tag) |
|
316 |
|
|
317 |
if self.ui.lineEditHistoryData.tag is not None: |
|
318 |
area = Area() |
|
319 |
area.name = 'History Data' |
|
320 |
area.x = self.ui.lineEditHistoryData.tag.rect().left() |
|
321 |
area.y = self.ui.lineEditHistoryData.tag.rect().top() |
|
322 |
area.width = self.ui.lineEditHistoryData.tag.rect().width() |
|
323 |
area.height = self.ui.lineEditHistoryData.tag.rect().height() |
|
324 |
areas.append(area) |
|
325 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditHistoryData.tag) |
|
326 |
|
|
327 |
if self.ui.lineEditDrawingNo.tag is not None: |
|
328 |
area = Area() |
|
329 |
area.name = 'Drawing No' |
|
330 |
area.x = self.ui.lineEditDrawingNo.tag.rect().left() |
|
331 |
area.y = self.ui.lineEditDrawingNo.tag.rect().top() |
|
332 |
area.width = self.ui.lineEditDrawingNo.tag.rect().width() |
|
333 |
area.height = self.ui.lineEditDrawingNo.tag.rect().height() |
|
334 |
areas.append(area) |
|
335 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawingNo.tag) |
|
336 |
|
|
337 |
if self.ui.lineEditArea.tag is not None: |
|
338 |
area = Area() |
|
339 |
area.name = 'Area' |
|
340 |
area.x = self.ui.lineEditArea.tag.rect().left() |
|
341 |
area.y = self.ui.lineEditArea.tag.rect().top() |
|
342 |
area.width = self.ui.lineEditArea.tag.rect().width() |
|
343 |
area.height = self.ui.lineEditArea.tag.rect().height() |
|
344 |
areas.append(area) |
|
345 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditArea.tag) |
|
346 |
|
|
347 |
if self.ui.lineEditRevNo.tag is not None: |
|
348 |
area = Area() |
|
349 |
area.name = 'Rev No' |
|
350 |
area.x = self.ui.lineEditRevNo.tag.rect().left() |
|
351 |
area.y = self.ui.lineEditRevNo.tag.rect().top() |
|
352 |
area.width = self.ui.lineEditRevNo.tag.rect().width() |
|
353 |
area.height = self.ui.lineEditRevNo.tag.rect().height() |
|
354 |
areas.append(area) |
|
355 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditRevNo.tag) |
|
356 |
|
|
357 |
docData = AppDocData.instance() |
|
358 |
docData.setAreaList(areas) |
|
359 |
|
|
360 |
# save equipment desc area |
|
361 |
section = '{} Equipment Desc Area'.format(docData.imgName) |
|
362 |
docData.deleteConfigs(section) |
|
363 |
|
|
364 |
configs = [] |
|
365 |
for row in range(self.ui.tableWidgetEquipmentDescArea.rowCount()): |
|
366 |
area = self.ui.tableWidgetEquipmentDescArea.item(row, 1).text() |
|
367 |
configs.append(Config(section, str(row), area)) |
|
368 |
|
|
369 |
self.removeEquipmentDescArea(area) |
|
370 |
# up to here |
|
371 |
docData.saveConfigs(configs) |
|
372 |
|
|
373 |
self.isAccepted = True |
|
374 |
except Exception as ex: |
|
375 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
376 |
finally: |
|
377 |
pass |
|
378 |
|
|
379 |
QDialog.accept(self) |
|
380 |
|
|
381 |
''' |
|
382 |
@brief reject dialog |
|
383 |
''' |
|
384 |
def reject(self): |
|
385 |
if self.ui.lineEditDrawing.tag is not None: |
|
386 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawing.tag) |
|
387 |
|
|
388 |
if self.ui.lineEditNote.tag is not None: |
|
389 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditNote.tag) |
|
390 |
|
|
391 |
if self.ui.lineEditHistoryData.tag is not None: |
|
392 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditHistoryData.tag) |
|
393 |
|
|
394 |
if self.ui.lineEditDrawingNo.tag is not None: |
|
395 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawingNo.tag) |
|
396 |
|
|
397 |
if self.ui.lineEditArea.tag is not None: |
|
398 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditArea.tag) |
|
399 |
|
|
400 |
if self.ui.lineEditRevNo.tag is not None: |
|
401 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditRevNo.tag) |
|
402 |
|
|
403 |
for row in range(self.ui.tableWidgetEquipmentDescArea.rowCount()): |
|
404 |
area = self.ui.tableWidgetEquipmentDescArea.item(row, 1).text() |
|
405 |
self.removeEquipmentDescArea(area) |
|
406 |
|
|
407 |
QDialog.reject(self) |
DTI_PID/DTI_PID/Configuration_Area_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file 'ui/Configuration_Area.ui'
|
|
3 |
# Form implementation generated from reading ui file '.\ui\Configuration_Area.ui'
|
|
4 | 4 |
# |
5 | 5 |
# Created by: PyQt5 UI code generator 5.10.1 |
6 | 6 |
# |
... | ... | |
11 | 11 |
class Ui_AreaDialog(object): |
12 | 12 |
def setupUi(self, AreaDialog): |
13 | 13 |
AreaDialog.setObjectName("AreaDialog") |
14 |
AreaDialog.resize(400, 300)
|
|
14 |
AreaDialog.resize(400, 446)
|
|
15 | 15 |
font = QtGui.QFont() |
16 | 16 |
font.setFamily("맑은 고딕") |
17 | 17 |
AreaDialog.setFont(font) |
... | ... | |
21 | 21 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
22 | 22 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
23 | 23 |
self.buttonBox.setObjectName("buttonBox") |
24 |
self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1)
|
|
24 |
self.gridLayout.addWidget(self.buttonBox, 3, 0, 1, 1)
|
|
25 | 25 |
self.groupBox = QtWidgets.QGroupBox(AreaDialog) |
26 | 26 |
self.groupBox.setObjectName("groupBox") |
27 | 27 |
self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox) |
... | ... | |
92 | 92 |
self.pushButtonDrawingArea.setObjectName("pushButtonDrawingArea") |
93 | 93 |
self.gridLayout_2.addWidget(self.pushButtonDrawingArea, 0, 4, 1, 1) |
94 | 94 |
self.gridLayout.addWidget(self.groupBox, 1, 0, 1, 1) |
95 |
self.groupBoxEquipmentDesc = QtWidgets.QGroupBox(AreaDialog) |
|
96 |
self.groupBoxEquipmentDesc.setObjectName("groupBoxEquipmentDesc") |
|
97 |
self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBoxEquipmentDesc) |
|
98 |
self.gridLayout_3.setObjectName("gridLayout_3") |
|
99 |
self.verticalLayout = QtWidgets.QVBoxLayout() |
|
100 |
self.verticalLayout.setObjectName("verticalLayout") |
|
101 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
102 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
103 |
self.lineEditEquipmentDescArea = QtWidgets.QLineEdit(self.groupBoxEquipmentDesc) |
|
104 |
self.lineEditEquipmentDescArea.setObjectName("lineEditEquipmentDescArea") |
|
105 |
self.horizontalLayout.addWidget(self.lineEditEquipmentDescArea) |
|
106 |
self.pushButtonAdd = QtWidgets.QPushButton(self.groupBoxEquipmentDesc) |
|
107 |
self.pushButtonAdd.setMaximumSize(QtCore.QSize(22, 16777215)) |
|
108 |
self.pushButtonAdd.setObjectName("pushButtonAdd") |
|
109 |
self.horizontalLayout.addWidget(self.pushButtonAdd) |
|
110 |
self.pushButtonDel = QtWidgets.QPushButton(self.groupBoxEquipmentDesc) |
|
111 |
self.pushButtonDel.setMaximumSize(QtCore.QSize(22, 16777215)) |
|
112 |
self.pushButtonDel.setObjectName("pushButtonDel") |
|
113 |
self.horizontalLayout.addWidget(self.pushButtonDel) |
|
114 |
self.verticalLayout.addLayout(self.horizontalLayout) |
|
115 |
self.horizontalLayout_2 = QtWidgets.QHBoxLayout() |
|
116 |
self.horizontalLayout_2.setObjectName("horizontalLayout_2") |
|
117 |
self.tableWidgetEquipmentDescArea = QtWidgets.QTableWidget(self.groupBoxEquipmentDesc) |
|
118 |
self.tableWidgetEquipmentDescArea.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) |
|
119 |
self.tableWidgetEquipmentDescArea.setColumnCount(2) |
|
120 |
self.tableWidgetEquipmentDescArea.setObjectName("tableWidgetEquipmentDescArea") |
|
121 |
self.tableWidgetEquipmentDescArea.setRowCount(0) |
|
122 |
self.tableWidgetEquipmentDescArea.verticalHeader().setVisible(False) |
|
123 |
self.horizontalLayout_2.addWidget(self.tableWidgetEquipmentDescArea) |
|
124 |
self.verticalLayout.addLayout(self.horizontalLayout_2) |
|
125 |
self.gridLayout_3.addLayout(self.verticalLayout, 0, 0, 1, 1) |
|
126 |
self.gridLayout.addWidget(self.groupBoxEquipmentDesc, 2, 0, 1, 1) |
|
95 | 127 |
|
96 | 128 |
self.retranslateUi(AreaDialog) |
97 | 129 |
self.buttonBox.accepted.connect(AreaDialog.accept) |
... | ... | |
114 | 146 |
self.pushButtonAreaArea.setText(_translate("AreaDialog", "...")) |
115 | 147 |
self.label_6.setText(_translate("AreaDialog", "Drawing")) |
116 | 148 |
self.pushButtonDrawingArea.setText(_translate("AreaDialog", "...")) |
149 |
self.groupBoxEquipmentDesc.setTitle(_translate("AreaDialog", "Equipment Desc. 영역")) |
|
150 |
self.pushButtonAdd.setText(_translate("AreaDialog", "+")) |
|
151 |
self.pushButtonDel.setText(_translate("AreaDialog", "-")) |
|
117 | 152 |
|
118 | 153 |
|
119 | 154 |
if __name__ == "__main__": |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
275 | 275 |
@brief area configuration |
276 | 276 |
''' |
277 | 277 |
def areaConfiguration(self): |
278 |
from QAreaConfigurationDialog import QAreaConfigurationDialog
|
|
278 |
from ConfigurationAreaDialog import QConfigurationAreaDialog
|
|
279 | 279 |
|
280 |
self.dlgAreaConfiguration = QAreaConfigurationDialog(self)
|
|
281 |
self.dlgAreaConfiguration.show()
|
|
282 |
self.dlgAreaConfiguration.exec_()
|
|
280 |
self.dlgConfigurationArea = QConfigurationAreaDialog(self)
|
|
281 |
self.dlgConfigurationArea.show()
|
|
282 |
self.dlgConfigurationArea.exec_()
|
|
283 | 283 |
|
284 | 284 |
''' |
285 | 285 |
@brief configuration |
DTI_PID/DTI_PID/QAreaConfigurationDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
import os |
|
3 |
import sys |
|
4 |
from PyQt5.QtCore import * |
|
5 |
from PyQt5.QtGui import * |
|
6 |
from PyQt5.QtWidgets import * |
|
7 |
import sqlite3 |
|
8 |
|
|
9 |
from AppDocData import AppDocData |
|
10 |
from AppDocData import Area |
|
11 |
|
|
12 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands') |
|
13 |
import CreateCommand |
|
14 |
import CropCommand |
|
15 |
import FenceCommand |
|
16 |
|
|
17 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes') |
|
18 |
import QGraphicsPolylineItem |
|
19 |
from QEngineeringLineItem import QEngineeringLineItem |
|
20 |
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
21 |
import Configuration_Area_UI |
|
22 |
|
|
23 |
class QAreaConfigurationDialog(QDialog): |
|
24 |
def __init__(self, parent): |
|
25 |
THICKNESS = 5 |
|
26 |
|
|
27 |
QDialog.__init__(self, parent) |
|
28 |
|
|
29 |
self.ui = Configuration_Area_UI.Ui_AreaDialog() |
|
30 |
self.ui.setupUi(self) |
|
31 |
self.isAccepted = False |
|
32 |
self._cmd = FenceCommand.FenceCommand(self.parent().graphicsView) |
|
33 |
self._cmd.onSuccess.connect(self.areaCreated) |
|
34 |
|
|
35 |
appDocData = AppDocData.instance() |
|
36 |
areas = appDocData.getAreaList() |
|
37 |
|
|
38 |
# load area of drawing |
|
39 |
matches = [x for x in areas if x.name=='Drawing'] |
|
40 |
self.ui.lineEditDrawing.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
41 |
if self.ui.lineEditDrawing.tag is not None: |
|
42 |
self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
43 |
self.ui.lineEditDrawing.tag.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
44 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditDrawing.tag) |
|
45 |
self.ui.pushButtonDrawingArea.setStyleSheet('background-color: red') |
|
46 |
|
|
47 |
matches = [x for x in areas if x.name=='Note'] |
|
48 |
self.ui.lineEditNote.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
49 |
if self.ui.lineEditNote.tag is not None: |
|
50 |
self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
51 |
self.ui.lineEditNote.tag.setPen(QPen(Qt.blue, THICKNESS, Qt.SolidLine)) |
|
52 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditNote.tag) |
|
53 |
self.ui.pushButtonNoteArea.setStyleSheet('background-color: blue') |
|
54 |
|
|
55 |
matches = [x for x in areas if x.name=='History Data'] |
|
56 |
self.ui.lineEditHistoryData.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
57 |
if self.ui.lineEditHistoryData.tag is not None: |
|
58 |
self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
59 |
self.ui.lineEditHistoryData.tag.setPen(QPen(Qt.magenta, THICKNESS, Qt.SolidLine)) |
|
60 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditHistoryData.tag) |
|
61 |
self.ui.pushButtonHistoryDataArea.setStyleSheet('background-color: magenta') |
|
62 |
|
|
63 |
matches = [x for x in areas if x.name=='Area'] |
|
64 |
self.ui.lineEditArea.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
65 |
if self.ui.lineEditArea.tag is not None: |
|
66 |
self.ui.lineEditArea.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
67 |
self.ui.lineEditArea.tag.setPen(QPen(Qt.green, THICKNESS, Qt.SolidLine)) |
|
68 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditArea.tag) |
|
69 |
self.ui.pushButtonAreaArea.setStyleSheet('background-color: green') |
|
70 |
|
|
71 |
matches = [x for x in areas if x.name=='Drawing No'] |
|
72 |
self.ui.lineEditDrawingNo.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
73 |
if self.ui.lineEditDrawingNo.tag is not None: |
|
74 |
self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
75 |
self.ui.lineEditDrawingNo.tag.setPen(QPen(Qt.cyan, THICKNESS, Qt.SolidLine)) |
|
76 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditDrawingNo.tag) |
|
77 |
self.ui.pushButtonDrawingNoArea.setStyleSheet('background-color: cyan') |
|
78 |
|
|
79 |
matches = [x for x in areas if x.name=='Rev No'] |
|
80 |
self.ui.lineEditRevNo.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None |
|
81 |
if self.ui.lineEditRevNo.tag is not None: |
|
82 |
self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].x + matches[0].width), round(matches[0].y + matches[0].height))) |
|
83 |
self.ui.lineEditRevNo.tag.setPen(QPen(Qt.yellow, THICKNESS, Qt.SolidLine)) |
|
84 |
self.parent().graphicsView.scene.addItem(self.ui.lineEditRevNo.tag) |
|
85 |
self.ui.pushButtonRevNoArea.setStyleSheet('background-color: yellow') |
|
86 |
# up to here |
|
87 |
|
|
88 |
self.ui.pushButtonDrawingArea.clicked.connect(self.selectDrawingArea) |
|
89 |
self.ui.pushButtonNoteArea.clicked.connect(self.selectNoteArea) |
|
90 |
self.ui.pushButtonHistoryDataArea.clicked.connect(self.selectHistoryDataArea) |
|
91 |
self.ui.pushButtonAreaArea.clicked.connect(self.selectAreaArea) |
|
92 |
self.ui.pushButtonDrawingNoArea.clicked.connect(self.selectDrawingNoArea) |
|
93 |
self.ui.pushButtonRevNoArea.clicked.connect(self.selectRevNoArea) |
|
94 |
|
|
95 |
def selectDrawingArea(self): |
|
96 |
self._cmd.tag = self.ui.lineEditDrawing |
|
97 |
self.parent().graphicsView.command = self._cmd |
|
98 |
|
|
99 |
def selectNoteArea(self): |
|
100 |
self._cmd.tag = self.ui.lineEditNote |
|
101 |
self.parent().graphicsView.command = self._cmd |
|
102 |
|
|
103 |
def selectHistoryDataArea(self): |
|
104 |
self._cmd.tag = self.ui.lineEditHistoryData |
|
105 |
self.parent().graphicsView.command = self._cmd |
|
106 |
|
|
107 |
def selectAreaArea(self): |
|
108 |
self._cmd.tag = self.ui.lineEditArea |
|
109 |
self.parent().graphicsView.command = self._cmd |
|
110 |
|
|
111 |
def selectDrawingNoArea(self): |
|
112 |
self._cmd.tag = self.ui.lineEditDrawingNo |
|
113 |
self.parent().graphicsView.command = self._cmd |
|
114 |
|
|
115 |
def selectRevNoArea(self): |
|
116 |
self._cmd.tag = self.ui.lineEditRevNo |
|
117 |
self.parent().graphicsView.command = self._cmd |
|
118 |
|
|
119 |
''' |
|
120 |
@brief called when area is created |
|
121 |
''' |
|
122 |
def areaCreated(self, x, y , width, height): |
|
123 |
THICKNESS = 5 |
|
124 |
|
|
125 |
if self._cmd.tag is self.ui.lineEditDrawing: |
|
126 |
if self.ui.lineEditDrawing.tag is None: |
|
127 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
128 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
129 |
self.parent().graphicsView.scene.addItem(item) |
|
130 |
|
|
131 |
self.ui.lineEditDrawing.tag = item |
|
132 |
else: |
|
133 |
self.ui.lineEditDrawing.tag.setRect(x, y, width, height) |
|
134 |
|
|
135 |
self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
136 |
elif self._cmd.tag is self.ui.lineEditNote: |
|
137 |
if self.ui.lineEditNote.tag is None: |
|
138 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
139 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
140 |
self.parent().graphicsView.scene.addItem(item) |
|
141 |
|
|
142 |
self.ui.lineEditNote.tag = item |
|
143 |
else: |
|
144 |
self.ui.lineEditNote.tag.setRect(x, y, width, height) |
|
145 |
|
|
146 |
self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
147 |
elif self._cmd.tag is self.ui.lineEditHistoryData: |
|
148 |
if self.ui.lineEditHistoryData.tag is None: |
|
149 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
150 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
151 |
self.parent().graphicsView.scene.addItem(item) |
|
152 |
|
|
153 |
self.ui.lineEditHistoryData.tag = item |
|
154 |
else: |
|
155 |
self.ui.lineEditHistoryData.tag.setRect(x, y, width, height) |
|
156 |
|
|
157 |
self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
158 |
elif self._cmd.tag is self.ui.lineEditArea: |
|
159 |
if self.ui.lineEditArea.tag is None: |
|
160 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
161 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
162 |
self.parent().graphicsView.scene.addItem(item) |
|
163 |
|
|
164 |
self.ui.lineEditArea.tag = item |
|
165 |
else: |
|
166 |
self.ui.lineEditArea.tag.setRect(x, y, width, height) |
|
167 |
|
|
168 |
self.ui.lineEditArea.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
169 |
elif self._cmd.tag is self.ui.lineEditDrawingNo: |
|
170 |
if self.ui.lineEditDrawingNo.tag is None: |
|
171 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
172 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
173 |
self.parent().graphicsView.scene.addItem(item) |
|
174 |
|
|
175 |
self.ui.lineEditDrawingNo.tag = item |
|
176 |
else: |
|
177 |
self.ui.lineEditDrawingNo.tag.setRect(x, y, width, height) |
|
178 |
|
|
179 |
self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
180 |
elif self._cmd.tag is self.ui.lineEditRevNo: |
|
181 |
if self.ui.lineEditRevNo.tag is None: |
|
182 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
|
183 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
|
184 |
self.parent().graphicsView.scene.addItem(item) |
|
185 |
|
|
186 |
self.ui.lineEditRevNo.tag = item |
|
187 |
else: |
|
188 |
self.ui.lineEditRevNo.tag.setRect(x, y, width, height) |
|
189 |
|
|
190 |
self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(x), round(y), round(x + width), round(y + height))) |
|
191 |
|
|
192 |
self.parent().graphicsView.command = None |
|
193 |
|
|
194 |
''' |
|
195 |
@brief accept dialog |
|
196 |
''' |
|
197 |
def accept(self): |
|
198 |
try: |
|
199 |
areas = [] |
|
200 |
|
|
201 |
if self.ui.lineEditDrawing.tag is not None: |
|
202 |
area = Area() |
|
203 |
area.name = 'Drawing' |
|
204 |
area.x = self.ui.lineEditDrawing.tag.rect().left() |
|
205 |
area.y = self.ui.lineEditDrawing.tag.rect().top() |
|
206 |
area.width = self.ui.lineEditDrawing.tag.rect().width() |
|
207 |
area.height = self.ui.lineEditDrawing.tag.rect().height() |
|
208 |
areas.append(area) |
|
209 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawing.tag) |
|
210 |
|
|
211 |
if self.ui.lineEditNote.tag is not None: |
|
212 |
area = Area() |
|
213 |
area.name = 'Note' |
|
214 |
area.x = self.ui.lineEditNote.tag.rect().left() |
|
215 |
area.y = self.ui.lineEditNote.tag.rect().top() |
|
216 |
area.width = self.ui.lineEditNote.tag.rect().width() |
|
217 |
area.height = self.ui.lineEditNote.tag.rect().height() |
|
218 |
areas.append(area) |
|
219 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditNote.tag) |
|
220 |
|
|
221 |
if self.ui.lineEditHistoryData.tag is not None: |
|
222 |
area = Area() |
|
223 |
area.name = 'History Data' |
|
224 |
area.x = self.ui.lineEditHistoryData.tag.rect().left() |
|
225 |
area.y = self.ui.lineEditHistoryData.tag.rect().top() |
|
226 |
area.width = self.ui.lineEditHistoryData.tag.rect().width() |
|
227 |
area.height = self.ui.lineEditHistoryData.tag.rect().height() |
|
228 |
areas.append(area) |
|
229 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditHistoryData.tag) |
|
230 |
|
|
231 |
if self.ui.lineEditDrawingNo.tag is not None: |
|
232 |
area = Area() |
|
233 |
area.name = 'Drawing No' |
|
234 |
area.x = self.ui.lineEditDrawingNo.tag.rect().left() |
|
235 |
area.y = self.ui.lineEditDrawingNo.tag.rect().top() |
|
236 |
area.width = self.ui.lineEditDrawingNo.tag.rect().width() |
|
237 |
area.height = self.ui.lineEditDrawingNo.tag.rect().height() |
|
238 |
areas.append(area) |
|
239 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawingNo.tag) |
|
240 |
|
|
241 |
if self.ui.lineEditArea.tag is not None: |
|
242 |
area = Area() |
|
243 |
area.name = 'Area' |
|
244 |
area.x = self.ui.lineEditArea.tag.rect().left() |
|
245 |
area.y = self.ui.lineEditArea.tag.rect().top() |
|
246 |
area.width = self.ui.lineEditArea.tag.rect().width() |
|
247 |
area.height = self.ui.lineEditArea.tag.rect().height() |
|
248 |
areas.append(area) |
|
249 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditArea.tag) |
|
250 |
|
|
251 |
if self.ui.lineEditRevNo.tag is not None: |
|
252 |
area = Area() |
|
253 |
area.name = 'Rev No' |
|
254 |
area.x = self.ui.lineEditRevNo.tag.rect().left() |
|
255 |
area.y = self.ui.lineEditRevNo.tag.rect().top() |
|
256 |
area.width = self.ui.lineEditRevNo.tag.rect().width() |
|
257 |
area.height = self.ui.lineEditRevNo.tag.rect().height() |
|
258 |
areas.append(area) |
|
259 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditRevNo.tag) |
|
260 |
|
|
261 |
AppDocData.instance().setAreaList(areas) |
|
262 |
|
|
263 |
self.isAccepted = True |
|
264 |
except Exception as e: |
|
265 |
pass |
|
266 |
finally: |
|
267 |
pass |
|
268 |
|
|
269 |
QDialog.accept(self) |
|
270 |
|
|
271 |
''' |
|
272 |
@brief reject dialog |
|
273 |
''' |
|
274 |
def reject(self): |
|
275 |
if self.ui.lineEditDrawing.tag is not None: |
|
276 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawing.tag) |
|
277 |
|
|
278 |
if self.ui.lineEditNote.tag is not None: |
|
279 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditNote.tag) |
|
280 |
|
|
281 |
if self.ui.lineEditHistoryData.tag is not None: |
|
282 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditHistoryData.tag) |
|
283 |
|
|
284 |
if self.ui.lineEditDrawingNo.tag is not None: |
|
285 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawingNo.tag) |
|
286 |
|
|
287 |
if self.ui.lineEditArea.tag is not None: |
|
288 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditArea.tag) |
|
289 |
|
|
290 |
if self.ui.lineEditRevNo.tag is not None: |
|
291 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditRevNo.tag) |
|
292 |
|
|
293 |
QDialog.reject(self) |
DTI_PID/DTI_PID/UI/Configuration_Area.ui | ||
---|---|---|
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 | 9 |
<width>400</width> |
10 |
<height>300</height>
|
|
10 |
<height>446</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="font"> |
... | ... | |
19 | 19 |
<string>Area</string> |
20 | 20 |
</property> |
21 | 21 |
<layout class="QGridLayout" name="gridLayout"> |
22 |
<item row="2" column="0">
|
|
22 |
<item row="3" column="0">
|
|
23 | 23 |
<widget class="QDialogButtonBox" name="buttonBox"> |
24 | 24 |
<property name="orientation"> |
25 | 25 |
<enum>Qt::Horizontal</enum> |
... | ... | |
188 | 188 |
</layout> |
189 | 189 |
</widget> |
190 | 190 |
</item> |
191 |
<item row="2" column="0"> |
|
192 |
<widget class="QGroupBox" name="groupBoxEquipmentDesc"> |
|
193 |
<property name="title"> |
|
194 |
<string>Equipment Desc. 영역</string> |
|
195 |
</property> |
|
196 |
<layout class="QGridLayout" name="gridLayout_3"> |
|
197 |
<item row="0" column="0"> |
|
198 |
<layout class="QVBoxLayout" name="verticalLayout"> |
|
199 |
<item> |
|
200 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
201 |
<item> |
|
202 |
<widget class="QLineEdit" name="lineEditEquipmentDescArea"/> |
|
203 |
</item> |
|
204 |
<item> |
|
205 |
<widget class="QPushButton" name="pushButtonAdd"> |
|
206 |
<property name="maximumSize"> |
|
207 |
<size> |
|
208 |
<width>22</width> |
|
209 |
<height>16777215</height> |
|
210 |
</size> |
|
211 |
</property> |
|
212 |
<property name="text"> |
|
213 |
<string>+</string> |
|
214 |
</property> |
|
215 |
</widget> |
|
216 |
</item> |
|
217 |
<item> |
|
218 |
<widget class="QPushButton" name="pushButtonDel"> |
|
219 |
<property name="maximumSize"> |
|
220 |
<size> |
|
221 |
<width>22</width> |
|
222 |
<height>16777215</height> |
|
223 |
</size> |
|
224 |
</property> |
|
225 |
<property name="text"> |
|
226 |
<string>-</string> |
|
227 |
</property> |
|
228 |
</widget> |
|
229 |
</item> |
|
230 |
</layout> |
|
231 |
</item> |
|
232 |
<item> |
|
233 |
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
234 |
<item> |
|
235 |
<widget class="QTableWidget" name="tableWidgetEquipmentDescArea"> |
|
236 |
<property name="selectionMode"> |
|
237 |
<enum>QAbstractItemView::SingleSelection</enum> |
|
238 |
</property> |
|
239 |
<property name="columnCount"> |
|
240 |
<number>2</number> |
|
241 |
</property> |
|
242 |
<attribute name="verticalHeaderVisible"> |
|
243 |
<bool>false</bool> |
|
244 |
</attribute> |
|
245 |
<column/> |
|
246 |
<column/> |
|
247 |
</widget> |
|
248 |
</item> |
|
249 |
</layout> |
|
250 |
</item> |
|
251 |
</layout> |
|
252 |
</item> |
|
253 |
</layout> |
|
254 |
</widget> |
|
255 |
</item> |
|
191 | 256 |
</layout> |
192 | 257 |
</widget> |
193 | 258 |
<resources/> |
내보내기 Unified diff