61 |
61 |
except Exception as ex:
|
62 |
62 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
|
63 |
63 |
|
64 |
|
'''
|
65 |
|
@brief select equipment desc area
|
66 |
|
@author humkyung
|
67 |
|
@date 2018.06.29
|
68 |
|
'''
|
69 |
|
def onSelectEquipmentDescArea(self):
|
70 |
|
self._cmd.tag = self.ui.lineEditEquipmentDescArea
|
71 |
|
self.parent().graphicsView.command = self._cmd
|
72 |
|
|
73 |
|
def onSelectTypicalArea(self):
|
74 |
|
'''
|
75 |
|
@brief select typical area
|
76 |
|
@author humkyung
|
77 |
|
@date 2018.12.14
|
78 |
|
'''
|
79 |
|
self._cmd.tag = self.ui.lineEditTypicalArea
|
80 |
|
self.parent().graphicsView.command = self._cmd
|
81 |
|
|
82 |
|
'''
|
83 |
|
@brief remove box area from scene
|
84 |
|
@author humkyung
|
85 |
|
@date 2018.06.29
|
86 |
|
@history 2018.11.09 euisung change name removeEquipmentDescArea -> removeArea for title block
|
87 |
|
change remove process
|
88 |
|
2018.11.20 euisung change brief remove equipment desc. area from graphicsview ->
|
89 |
|
'''
|
90 |
|
def removeArea(self, box):
|
91 |
|
import re
|
92 |
|
try:
|
93 |
|
self.parent().graphicsView.scene.removeItem(box)
|
94 |
|
except Exception as ex:
|
95 |
|
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
|
96 |
|
|
97 |
|
'''
|
98 |
|
@brief delete selected equipment desc area
|
99 |
|
@author humkyung
|
100 |
|
@date 2018.06.29
|
101 |
|
'''
|
102 |
|
def onDeleteEquipmentDescArea(self):
|
103 |
|
try:
|
104 |
|
row = self.ui.tableWidgetSpec.currentRow()
|
105 |
|
if row is -1:
|
106 |
|
return
|
107 |
|
self.removeArea(self.ui.tableWidgetSpec.item(row, 1).tag)
|
108 |
|
self.ui.tableWidgetSpec.removeRow(row)
|
109 |
|
except Exception as ex:
|
110 |
|
from App import App
|
111 |
|
from AppDocData import MessageType
|
112 |
|
|
113 |
|
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
|
114 |
|
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
115 |
|
|
116 |
|
def onDeleteTypicalArea(self):
|
117 |
|
'''
|
118 |
|
@brief delete selected typical area
|
119 |
|
@author humkyung
|
120 |
|
@date 2018.12.14
|
121 |
|
'''
|
122 |
|
try:
|
123 |
|
row = self.ui.tableWidgetTypicalArea.currentRow()
|
124 |
|
if row is -1:
|
125 |
|
return
|
126 |
|
self.removeArea(self.ui.tableWidgetTypicalArea.item(row, 1).tag)
|
127 |
|
self.ui.tableWidgetTypicalArea.removeRow(row)
|
128 |
|
except Exception as ex:
|
129 |
|
from App import App
|
130 |
|
from AppDocData import MessageType
|
131 |
|
|
132 |
|
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
|
133 |
|
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
134 |
|
|
135 |
|
'''
|
136 |
|
@brief called when area is created
|
137 |
|
@history humkyung 2018.06.29 add equipment desc. area
|
138 |
|
'''
|
139 |
|
def onAreaCreated(self, x, y , width, height):
|
140 |
|
import uuid
|
141 |
|
THICKNESS = 5
|
142 |
|
|
143 |
|
if self._cmd.tag is self.ui.lineEditDrawing:
|
144 |
|
if self.ui.lineEditDrawing.tag is None:
|
145 |
|
item = QGraphicsBoundingBoxItem(x, y, width, height)
|
146 |
|
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
|
147 |
|
self.parent().graphicsView.scene.addItem(item)
|
148 |
|
|
149 |
|
self.ui.lineEditDrawing.tag = item
|
150 |
|
else:
|
151 |
|
self.ui.lineEditDrawing.tag.setRect(x, y, width, height)
|
152 |
|
|
153 |
|
self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
154 |
|
elif self._cmd.tag is self.ui.lineEditNote:
|
155 |
|
if self.ui.lineEditNote.tag is None:
|
156 |
|
item = QGraphicsBoundingBoxItem(x, y, width, height)
|
157 |
|
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
|
158 |
|
self.parent().graphicsView.scene.addItem(item)
|
159 |
|
|
160 |
|
self.ui.lineEditNote.tag = item
|
161 |
|
else:
|
162 |
|
self.ui.lineEditNote.tag.setRect(x, y, width, height)
|
163 |
|
|
164 |
|
self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
165 |
|
elif self._cmd.tag is self.ui.lineEditHistoryData:
|
166 |
|
if self.ui.lineEditHistoryData.tag is None:
|
167 |
|
item = QGraphicsBoundingBoxItem(x, y, width, height)
|
168 |
|
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
|
169 |
|
self.parent().graphicsView.scene.addItem(item)
|
170 |
|
|
171 |
|
self.ui.lineEditHistoryData.tag = item
|
172 |
|
else:
|
173 |
|
self.ui.lineEditHistoryData.tag.setRect(x, y, width, height)
|
174 |
|
|
175 |
|
self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
176 |
|
elif self._cmd.tag is self.ui.lineEditUnitArea:
|
177 |
|
if self.ui.lineEditUnitArea.tag is None:
|
178 |
|
item = QGraphicsBoundingBoxItem(x, y, width, height)
|
179 |
|
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
|
180 |
|
self.parent().graphicsView.scene.addItem(item)
|
181 |
|
|
182 |
|
self.ui.lineEditUnitArea.tag = item
|
183 |
|
else:
|
184 |
|
self.ui.lineEditUnitArea.tag.setRect(x, y, width, height)
|
185 |
|
|
186 |
|
self.ui.lineEditUnitArea.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
187 |
|
elif self._cmd.tag is self.ui.lineEditDrawingNo:
|
188 |
|
if self.ui.lineEditDrawingNo.tag is None:
|
189 |
|
item = QGraphicsBoundingBoxItem(x, y, width, height)
|
190 |
|
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
|
191 |
|
self.parent().graphicsView.scene.addItem(item)
|
192 |
|
|
193 |
|
self.ui.lineEditDrawingNo.tag = item
|
194 |
|
else:
|
195 |
|
self.ui.lineEditDrawingNo.tag.setRect(x, y, width, height)
|
196 |
|
|
197 |
|
self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
198 |
|
elif self._cmd.tag is self.ui.lineEditRevNo:
|
199 |
|
if self.ui.lineEditRevNo.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.lineEditRevNo.tag = item
|
205 |
|
else:
|
206 |
|
self.ui.lineEditRevNo.tag.setRect(x, y, width, height)
|
207 |
|
|
208 |
|
self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
209 |
|
elif self._cmd.tag is self.ui.lineEditEquipmentDescArea:
|
210 |
|
x, y = round(x), round(y)
|
211 |
|
width, height = round(width), round(height)
|
212 |
|
|
213 |
|
boundingBox = QGraphicsBoundingBoxItem(x, y, width, height)
|
214 |
|
boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
|
215 |
|
boundingBox.setPen(QPen(Qt.darkGray, THICKNESS, Qt.SolidLine))
|
216 |
|
self.parent().graphicsView.scene.addItem(boundingBox)
|
217 |
|
|
218 |
|
strArea = '({},{}),({},{})'.format(x, y, width, height)
|
219 |
|
self.ui.lineEditEquipmentDescArea.setText(strArea)
|
220 |
|
|
221 |
|
# add item to table widget
|
222 |
|
docData = AppDocData.instance()
|
223 |
|
row = self.ui.tableWidgetSpec.rowCount()
|
224 |
|
self.ui.tableWidgetSpec.setRowCount(row + 1)
|
225 |
|
item = QTableWidgetItem(docData.imgName)
|
226 |
|
item.setFlags(Qt.ItemIsEnabled)
|
227 |
|
self.ui.tableWidgetSpec.setItem(row, 0, item)
|
228 |
|
item = QTableWidgetItem(strArea)
|
229 |
|
item.setFlags(Qt.ItemIsEnabled)
|
230 |
|
item.tag = boundingBox
|
231 |
|
self.ui.tableWidgetSpec.setItem(row, 1, item)
|
232 |
|
self.ui.tableWidgetSpec.resizeColumnsToContents()
|
233 |
|
# up to here
|
234 |
|
elif self._cmd.tag is self.ui.tableWidgetTitleBlockArea:
|
235 |
|
x, y = round(x), round(y)
|
236 |
|
width, height = round(width), round(height)
|
237 |
|
|
238 |
|
boundingBox = QGraphicsBoundingBoxItem(x, y, width, height)
|
239 |
|
boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
|
240 |
|
boundingBox.setPen(QPen(Qt.darkCyan, THICKNESS, Qt.SolidLine))
|
241 |
|
self.parent().graphicsView.scene.addItem(boundingBox)
|
242 |
|
|
243 |
|
# add item to table widget
|
244 |
|
strArea = '({},{}),({},{})'.format(x, y, width, height)
|
245 |
|
docData = AppDocData.instance()
|
246 |
|
row = self.ui.tableWidgetTitleBlockArea.rowCount()
|
247 |
|
self.ui.tableWidgetTitleBlockArea.setRowCount(row + 1)
|
248 |
|
item = QTableWidgetItem(str(uuid.uuid4()))
|
249 |
|
self.ui.tableWidgetTitleBlockArea.setItem(row, 0, item)
|
250 |
|
item = QTableWidgetItem()
|
251 |
|
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable)
|
252 |
|
self.ui.tableWidgetTitleBlockArea.setItem(row, 1, item)
|
253 |
|
item = QTableWidgetItem(strArea)
|
254 |
|
item.setFlags(Qt.ItemIsEnabled)
|
255 |
|
item.tag = boundingBox
|
256 |
|
self.ui.tableWidgetTitleBlockArea.setItem(row, 2, item)
|
257 |
|
self.ui.tableWidgetTitleBlockArea.resizeColumnsToContents()
|
258 |
|
# up to here
|
259 |
|
elif self._cmd.tag is self.ui.lineEditTypicalArea:
|
260 |
|
x, y = round(x), round(y)
|
261 |
|
width, height = round(width), round(height)
|
262 |
|
|
263 |
|
boundingBox = QGraphicsBoundingBoxItem(x, y, width, height)
|
264 |
|
boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
|
265 |
|
boundingBox.setPen(QPen(Qt.darkCyan, THICKNESS, Qt.SolidLine))
|
266 |
|
self.parent().graphicsView.scene.addItem(boundingBox)
|
267 |
|
|
268 |
|
# add item to table widget
|
269 |
|
docData = AppDocData.instance()
|
270 |
|
row = self.ui.tableWidgetTypicalArea.rowCount()
|
271 |
|
self.ui.tableWidgetTypicalArea.setRowCount(row + 1)
|
272 |
|
item = QTableWidgetItem(docData.imgName)
|
273 |
|
self.ui.tableWidgetTypicalArea.setItem(row, 0, item)
|
274 |
|
item = QTableWidgetItem(str(uuid.uuid4()))
|
275 |
|
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable)
|
276 |
|
self.ui.tableWidgetTypicalArea.setItem(row, 1, item)
|
277 |
|
strArea = '({},{}),({},{})'.format(x, y, width, height)
|
278 |
|
item = QTableWidgetItem(strArea)
|
279 |
|
item.setFlags(Qt.ItemIsEnabled)
|
280 |
|
item.tag = boundingBox
|
281 |
|
self.ui.tableWidgetTypicalArea.setItem(row, 2, item)
|
282 |
|
self.ui.tableWidgetTypicalArea.resizeColumnsToContents()
|
283 |
|
# up to here
|
284 |
|
|
285 |
|
self.parent().graphicsView.command = None
|
286 |
|
|
287 |
|
'''
|
288 |
|
@brief display boundingbox's coords when boundingbox's size is changed
|
289 |
|
@author humkyung
|
290 |
|
@date 2018.08.30
|
291 |
|
'''
|
292 |
|
def onBoundingBoxChanged(self, boundingBox):
|
293 |
|
x = boundingBox.rect().left()
|
294 |
|
y = boundingBox.rect().top()
|
295 |
|
width = boundingBox.rect().width()
|
296 |
|
height = boundingBox.rect().height()
|
297 |
|
if boundingBox is self.ui.lineEditDrawing.tag:
|
298 |
|
self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
299 |
|
elif boundingBox is self.ui.lineEditNote.tag:
|
300 |
|
self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
301 |
|
elif boundingBox is self.ui.lineEditHistoryData.tag:
|
302 |
|
self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
303 |
|
elif boundingBox is self.ui.lineEditUnitArea.tag:
|
304 |
|
self.ui.lineEditUnitArea.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
305 |
|
elif boundingBox is self.ui.lineEditDrawingNo.tag:
|
306 |
|
self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
307 |
|
elif boundingBox is self.ui.lineEditRevNo.tag:
|
308 |
|
self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
|
309 |
|
else:
|
310 |
|
for row in range(self.ui.tableWidgetSpec.rowCount()):
|
311 |
|
item = self.ui.tableWidgetSpec.item(row, 1)
|
312 |
|
if boundingBox == item.tag:
|
313 |
|
strArea = '({},{}),({},{})'.format(round(x), round(y), round(width), round(height))
|
314 |
|
item.setText(strArea)
|
315 |
|
break
|
316 |
|
for row in range(self.ui.tableWidgetTitleBlockArea.rowCount()):
|
317 |
|
item = self.ui.tableWidgetTitleBlockArea.item(row, 2)
|
318 |
|
if boundingBox == item.tag:
|
319 |
|
strArea = '({},{}),({},{})'.format(round(x), round(y), round(width), round(height))
|
320 |
|
item.setText(strArea)
|
321 |
|
break
|
322 |
|
|
|
64 |
|
323 |
65 |
'''
|
324 |
66 |
@brief accept dialog
|
325 |
67 |
'''
|