프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / DTI_PID / ConfigurationAreaDialog.py @ 478c2510

이력 | 보기 | 이력해설 | 다운로드 (27.2 KB)

1
# coding: utf-8
2
"""
3
    This is area configuration module
4
"""
5
import os
6
import sys
7
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Commands')
8
import FenceCommand
9
from PyQt5.QtCore import *
10
from PyQt5.QtGui import *
11
from PyQt5.QtWidgets import *
12
import sqlite3
13

    
14
from AppDocData import AppDocData, Config
15
from Area import Area
16

    
17
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes')
18
import EngineeringPolylineItem
19
from EngineeringLineItem import QEngineeringLineItem
20
from GraphicsBoundingBoxItem 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
        for index in range(self.ui.tableWidgetEquipmentDescArea.columnCount()):
35
            self.ui.tableWidgetEquipmentDescArea.horizontalHeaderItem(0).setSizeHint(QSize(25, 25))
36
            self.ui.tableWidgetEquipmentDescArea.setColumnWidth(index, len(self.ui.tableWidgetEquipmentDescArea.horizontalHeaderItem(index).text()) * 8 + 10)
37
        self.ui.tableWidgetTitleBlockArea.setColumnCount(3)
38
        self.ui.tableWidgetTitleBlockArea.setHorizontalHeaderLabels(['UID', 'Name', 'Area'])
39
        for index in range(self.ui.tableWidgetTitleBlockArea.columnCount()):
40
            self.ui.tableWidgetTitleBlockArea.horizontalHeaderItem(0).setSizeHint(QSize(25, 25))
41
            self.ui.tableWidgetTitleBlockArea.setColumnWidth(index, len(self.ui.tableWidgetTitleBlockArea.horizontalHeaderItem(index).text()) * 8 + 10)
42
        self.ui.tableWidgetTitleBlockArea.hideColumn(0)
43
        self.isAccepted = False
44
        self._cmd = FenceCommand.FenceCommand(self.parent().graphicsView)
45
        self._cmd.onSuccess.connect(self.onAreaCreated)
46

    
47
        docData = AppDocData.instance()
48
        areas = docData.getAreaList()
49

    
50
        # load area of drawing
51
        matches = [x for x in areas if x.name=='Drawing']
52
        self.ui.lineEditDrawing.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None
53
        if self.ui.lineEditDrawing.tag is not None:
54
            self.ui.lineEditDrawing.tag.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
55
            self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].width), round(matches[0].height)))
56
            self.ui.lineEditDrawing.tag.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
57
            self.parent().graphicsView.scene.addItem(self.ui.lineEditDrawing.tag)
58
        self.ui.pushButtonDrawingArea.setStyleSheet('background-color: red')
59

    
60
        matches = [x for x in areas if x.name=='Note']
61
        self.ui.lineEditNote.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None
62
        if self.ui.lineEditNote.tag is not None:
63
            self.ui.lineEditNote.tag.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
64
            self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].width), round(matches[0].height)))
65
            self.ui.lineEditNote.tag.setPen(QPen(Qt.blue, THICKNESS, Qt.SolidLine))
66
            self.parent().graphicsView.scene.addItem(self.ui.lineEditNote.tag)
67
        self.ui.pushButtonNoteArea.setStyleSheet('background-color: blue')
68

    
69
        matches = [x for x in areas if x.name=='History Data']
70
        self.ui.lineEditHistoryData.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None
71
        if self.ui.lineEditHistoryData.tag is not None:
72
            self.ui.lineEditHistoryData.tag.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
73
            self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].width), round(matches[0].height)))
74
            self.ui.lineEditHistoryData.tag.setPen(QPen(Qt.magenta, THICKNESS, Qt.SolidLine))
75
            self.parent().graphicsView.scene.addItem(self.ui.lineEditHistoryData.tag)
76
        self.ui.pushButtonHistoryDataArea.setStyleSheet('background-color: magenta')
77

    
78
        matches = [x for x in areas if x.name=='Drawing No']
79
        self.ui.lineEditDrawingNo.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None
80
        if self.ui.lineEditDrawingNo.tag is not None:
81
            self.ui.lineEditDrawingNo.tag.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
82
            self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].width), round(matches[0].height)))
83
            self.ui.lineEditDrawingNo.tag.setPen(QPen(Qt.cyan, THICKNESS, Qt.SolidLine))
84
            self.parent().graphicsView.scene.addItem(self.ui.lineEditDrawingNo.tag)
85
        self.ui.pushButtonDrawingNoArea.setStyleSheet('background-color: cyan')
86

    
87
        matches = [x for x in areas if x.name=='Rev No']
88
        self.ui.lineEditRevNo.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None
89
        if self.ui.lineEditRevNo.tag is not None:
90
            self.ui.lineEditRevNo.tag.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
91
            self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].width), round(matches[0].height)))
92
            self.ui.lineEditRevNo.tag.setPen(QPen(Qt.yellow, THICKNESS, Qt.SolidLine))
93
            self.parent().graphicsView.scene.addItem(self.ui.lineEditRevNo.tag)
94
        self.ui.pushButtonRevNoArea.setStyleSheet('background-color: yellow')
95
        
96
        matches = [x for x in areas if x.name=='Unit']
97
        self.ui.lineEditUnitArea.tag = QGraphicsBoundingBoxItem(matches[0].x, matches[0].y, matches[0].width, matches[0].height) if len(matches) == 1 else None
98
        if self.ui.lineEditUnitArea.tag is not None:
99
            self.ui.lineEditUnitArea.tag.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
100
            self.ui.lineEditUnitArea.setText('({},{}),({},{})'.format(round(matches[0].x), round(matches[0].y), round(matches[0].width), round(matches[0].height)))
101
            self.ui.lineEditUnitArea.tag.setPen(QPen(Qt.green, THICKNESS, Qt.SolidLine))
102
            self.parent().graphicsView.scene.addItem(self.ui.lineEditUnitArea.tag)
103
        self.ui.pushButtonUnitArea.setStyleSheet('background-color: green')
104

    
105
        # up to here
106

    
107
        titleBlockProps = docData.getTitleBlockProperties()
108
        self.ui.tableWidgetTitleBlockArea.setRowCount(len(titleBlockProps))
109
        row = 0
110
        for titleBlockProp in titleBlockProps:
111
            area = Area(titleBlockProp[0])
112
            area.parse(titleBlockProp[2])
113

    
114
            boundingBox = QGraphicsBoundingBoxItem(area.x, area.y, area.width, area.height)
115
            boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
116
            boundingBox.setPen(QPen(Qt.darkCyan, THICKNESS, Qt.SolidLine))
117
            self.parent().graphicsView.scene.addItem(boundingBox)
118

    
119
            item = QTableWidgetItem(titleBlockProp[0])
120
            self.ui.tableWidgetTitleBlockArea.setItem(row, 0, item)
121
            item = QTableWidgetItem(titleBlockProp[1])
122
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable)
123
            self.ui.tableWidgetTitleBlockArea.setItem(row, 1, item)
124
            item = QTableWidgetItem('({},{}),({},{})'.format(area.x, area.y, area.width, area.height))
125
            item.setFlags(Qt.ItemIsEnabled)
126
            item.tag = boundingBox
127
            self.ui.tableWidgetTitleBlockArea.setItem(row, 2, item)
128
            row += 1
129

    
130
        #self.ui.pushButtonAdd.setStyleSheet('background-color: darkGray')
131

    
132
        section = '{} Equipment Desc Area'.format(docData.imgName)
133
        configs = docData.getConfigs(section)
134
        self.ui.tableWidgetEquipmentDescArea.setRowCount(len(configs))
135
        row = 0
136
        for config in configs:
137
            area = Area('')
138
            area.parse(config.value)
139

    
140
            boundingBox = QGraphicsBoundingBoxItem(area.x, area.y, area.width, area.height)
141
            boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
142
            boundingBox.setPen(QPen(Qt.darkGray, THICKNESS, Qt.SolidLine))
143
            self.parent().graphicsView.scene.addItem(boundingBox)
144

    
145
            item = QTableWidgetItem(docData.imgName)
146
            item.setFlags(Qt.ItemIsEnabled)
147
            self.ui.tableWidgetEquipmentDescArea.setItem(row, 0, item)
148
            item = QTableWidgetItem('({},{}),({},{})'.format(area.x, area.y, area.width, area.height))
149
            item.setFlags(Qt.ItemIsEnabled)
150
            item.tag = boundingBox
151
            self.ui.tableWidgetEquipmentDescArea.setItem(row, 1, item)
152

    
153
            row += 1
154
        
155
        if self.ui.tableWidgetEquipmentDescArea.rowCount() is not 0: 
156
            self.ui.tableWidgetEquipmentDescArea.resizeColumnsToContents()
157
        if self.ui.tableWidgetTitleBlockArea.rowCount() is not 0: 
158
            self.ui.tableWidgetTitleBlockArea.resizeColumnsToContents()
159

    
160
        self.ui.pushButtonDrawingArea.clicked.connect(self.selectDrawingArea)
161
        self.ui.pushButtonNoteArea.clicked.connect(self.selectNoteArea)
162
        self.ui.pushButtonHistoryDataArea.clicked.connect(self.selectHistoryDataArea)
163
        self.ui.pushButtonDrawingNoArea.clicked.connect(self.selectDrawingNoArea)
164
        self.ui.pushButtonRevNoArea.clicked.connect(self.selectRevNoArea)
165
        self.ui.pushButtonUnitArea.clicked.connect(self.onSelectUnitArea)
166
        self.ui.pushButtonAddTitleBlockProp.clicked.connect(self.onSelectTitleBlockArea)
167
        self.ui.pushButtonDelTitleBlockProp.clicked.connect(self.onDeleteTitleBlockArea)
168
        self.ui.pushButtonAdd.clicked.connect(self.onSelectEquipmentDescArea)
169
        self.ui.pushButtonDel.clicked.connect(self.onDeleteEquipmentDescArea)
170

    
171
    def selectDrawingArea(self):
172
        self._cmd.tag = self.ui.lineEditDrawing
173
        self.parent().graphicsView.command = self._cmd
174

    
175
    def selectNoteArea(self):
176
        self._cmd.tag = self.ui.lineEditNote
177
        self.parent().graphicsView.command = self._cmd
178

    
179
    def selectHistoryDataArea(self):
180
        self._cmd.tag = self.ui.lineEditHistoryData
181
        self.parent().graphicsView.command = self._cmd
182

    
183
    def onSelectUnitArea(self):
184
        self._cmd.tag = self.ui.lineEditUnitArea
185
        self.parent().graphicsView.command = self._cmd
186

    
187
    def selectDrawingNoArea(self):
188
        self._cmd.tag = self.ui.lineEditDrawingNo
189
        self.parent().graphicsView.command = self._cmd
190

    
191
    def selectRevNoArea(self):
192
        self._cmd.tag = self.ui.lineEditRevNo
193
        self.parent().graphicsView.command = self._cmd
194

    
195
    def onSelectTitleBlockArea(self):
196
        '''
197
            @brief  select title block area
198
            @author euisung
199
            @date   2018.11.09
200
        '''
201
        self._cmd.tag = self.ui.tableWidgetTitleBlockArea
202
        self.parent().graphicsView.command = self._cmd
203

    
204
    def onDeleteTitleBlockArea(self):
205
        '''
206
            @brief  delete selected title block area
207
            @author euisung
208
            @date   2018.11.09
209
        '''
210
        try:
211
            row = self.ui.tableWidgetTitleBlockArea.currentRow()
212
            self.removeArea(self.ui.tableWidgetEquipmentDescArea.item(row, 1).tag)
213
            self.ui.tableWidgetTitleBlockArea.removeRow(row)
214
        except Exception as ex:
215
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
216

    
217
    '''
218
        @brief  select equipment desc area
219
        @author humkyung
220
        @date   2018.06.29
221
    '''
222
    def onSelectEquipmentDescArea(self):
223
        self._cmd.tag = self.ui.lineEditEquipmentDescArea
224
        self.parent().graphicsView.command = self._cmd
225

    
226
    '''
227
        @brief  remove equipment desc. area from graphicsview
228
        @author humkyung
229
        @date   2018.06.29
230
        @history    2018.11.09      euisung     change name removeEquipmentDescArea -> removeArea for title block
231
                                                change remove process
232
    '''
233
    def removeArea(self, box):
234
        import re
235

    
236
        try:
237
            self.parent().graphicsView.scene.removeItem(box)
238
        except Exception as ex:
239
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
240

    
241
    '''
242
        @brief  delete selected equipment desc area
243
        @author humkyung
244
        @date   2018.06.29
245
    '''
246
    def onDeleteEquipmentDescArea(self):
247
        try:
248
            row = self.ui.tableWidgetEquipmentDescArea.currentRow()
249
            self.removeArea(self.ui.tableWidgetEquipmentDescArea.item(row, 1).tag)
250
            self.ui.tableWidgetEquipmentDescArea.removeRow(row)
251
        except Exception as ex:
252
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
253

    
254
    '''
255
        @brief      called when area is created
256
        @history    humkyung 2018.06.29 add equipment desc. area
257
    '''
258
    def onAreaCreated(self, x, y , width, height):
259
        import uuid
260
        THICKNESS = 5
261

    
262
        if self._cmd.tag is self.ui.lineEditDrawing:
263
            if self.ui.lineEditDrawing.tag is None:
264
                item = QGraphicsBoundingBoxItem(x, y, width, height)
265
                item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
266
                self.parent().graphicsView.scene.addItem(item)
267

    
268
                self.ui.lineEditDrawing.tag = item
269
            else:
270
                self.ui.lineEditDrawing.tag.setRect(x, y, width, height)
271

    
272
            self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
273
        elif self._cmd.tag is self.ui.lineEditNote:
274
            if self.ui.lineEditNote.tag is None:
275
                item = QGraphicsBoundingBoxItem(x, y, width, height)
276
                item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
277
                self.parent().graphicsView.scene.addItem(item)
278

    
279
                self.ui.lineEditNote.tag = item
280
            else:
281
                self.ui.lineEditNote.tag.setRect(x, y, width, height)
282

    
283
            self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
284
        elif self._cmd.tag is self.ui.lineEditHistoryData:
285
            if self.ui.lineEditHistoryData.tag is None:
286
                item = QGraphicsBoundingBoxItem(x, y, width, height)
287
                item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
288
                self.parent().graphicsView.scene.addItem(item)
289

    
290
                self.ui.lineEditHistoryData.tag = item
291
            else:
292
                self.ui.lineEditHistoryData.tag.setRect(x, y, width, height)
293

    
294
            self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
295
        elif self._cmd.tag is self.ui.lineEditUnitArea:
296
            if self.ui.lineEditUnitArea.tag is None:
297
                item = QGraphicsBoundingBoxItem(x, y, width, height)
298
                item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
299
                self.parent().graphicsView.scene.addItem(item)
300

    
301
                self.ui.lineEditUnitArea.tag = item
302
            else:
303
                self.ui.lineEditUnitArea.tag.setRect(x, y, width, height)
304

    
305
            self.ui.lineEditUnitArea.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
306
        elif self._cmd.tag is self.ui.lineEditDrawingNo:
307
            if self.ui.lineEditDrawingNo.tag is None:
308
                item = QGraphicsBoundingBoxItem(x, y, width, height)
309
                item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
310
                self.parent().graphicsView.scene.addItem(item)
311

    
312
                self.ui.lineEditDrawingNo.tag = item
313
            else:
314
                self.ui.lineEditDrawingNo.tag.setRect(x, y, width, height)
315

    
316
            self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
317
        elif self._cmd.tag is self.ui.lineEditRevNo:
318
            if self.ui.lineEditRevNo.tag is None:
319
                item = QGraphicsBoundingBoxItem(x, y, width, height)
320
                item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine))
321
                self.parent().graphicsView.scene.addItem(item)
322

    
323
                self.ui.lineEditRevNo.tag = item
324
            else:
325
                self.ui.lineEditRevNo.tag.setRect(x, y, width, height)
326

    
327
            self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
328
        elif self._cmd.tag is self.ui.lineEditEquipmentDescArea:
329
            x, y = round(x), round(y)
330
            width, height = round(width), round(height)
331

    
332
            boundingBox = QGraphicsBoundingBoxItem(x, y, width, height)
333
            boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
334
            boundingBox.setPen(QPen(Qt.darkGray, THICKNESS, Qt.SolidLine))
335
            self.parent().graphicsView.scene.addItem(boundingBox)
336

    
337
            strArea = '({},{}),({},{})'.format(x, y, width, height)
338
            self.ui.lineEditEquipmentDescArea.setText(strArea)
339

    
340
            # add item to table widget
341
            docData = AppDocData.instance()
342
            row = self.ui.tableWidgetEquipmentDescArea.rowCount()
343
            self.ui.tableWidgetEquipmentDescArea.setRowCount(row + 1)
344
            item = QTableWidgetItem(docData.imgName)
345
            item.setFlags(Qt.ItemIsEnabled)
346
            self.ui.tableWidgetEquipmentDescArea.setItem(row, 0, item)
347
            item = QTableWidgetItem(strArea)
348
            item.setFlags(Qt.ItemIsEnabled)
349
            item.tag = boundingBox
350
            self.ui.tableWidgetEquipmentDescArea.setItem(row, 1, item)
351
            self.ui.tableWidgetEquipmentDescArea.resizeColumnsToContents()
352
            # up to here
353
        elif self._cmd.tag is self.ui.tableWidgetTitleBlockArea:
354
            x, y = round(x), round(y)
355
            width, height = round(width), round(height)
356

    
357
            boundingBox = QGraphicsBoundingBoxItem(x, y, width, height)
358
            boundingBox.transfer.onSizeChanged.connect(self.onBoundingBoxChanged)
359
            boundingBox.setPen(QPen(Qt.darkCyan, THICKNESS, Qt.SolidLine))
360
            self.parent().graphicsView.scene.addItem(boundingBox)
361

    
362
            # add item to table widget
363
            strArea = '({},{}),({},{})'.format(x, y, width, height)
364
            docData = AppDocData.instance()
365
            row = self.ui.tableWidgetTitleBlockArea.rowCount()
366
            self.ui.tableWidgetTitleBlockArea.setRowCount(row + 1)
367
            item = QTableWidgetItem(str(uuid.uuid4()))
368
            self.ui.tableWidgetTitleBlockArea.setItem(row, 0, item)
369
            item = QTableWidgetItem()
370
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable)
371
            self.ui.tableWidgetTitleBlockArea.setItem(row, 1, item)
372
            item = QTableWidgetItem(strArea)
373
            item.setFlags(Qt.ItemIsEnabled)
374
            item.tag = boundingBox
375
            self.ui.tableWidgetTitleBlockArea.setItem(row, 2, item)
376
            self.ui.tableWidgetTitleBlockArea.resizeColumnsToContents()
377
            # up to here
378

    
379
        self.parent().graphicsView.command = None
380

    
381
    '''
382
        @brief      display boundingbox's coords when boundingbox's size is changed
383
        @author     humkyung
384
        @date       2018.08.30
385
    '''
386
    def onBoundingBoxChanged(self, boundingBox):
387
        x = boundingBox.rect().left()
388
        y = boundingBox.rect().top()
389
        width = boundingBox.rect().width()
390
        height = boundingBox.rect().height()
391
        if boundingBox is self.ui.lineEditDrawing.tag:
392
            self.ui.lineEditDrawing.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
393
        elif boundingBox is self.ui.lineEditNote.tag:
394
            self.ui.lineEditNote.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
395
        elif boundingBox is self.ui.lineEditHistoryData.tag:
396
            self.ui.lineEditHistoryData.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
397
        elif boundingBox is self.ui.lineEditUnitArea.tag:
398
            self.ui.lineEditUnitArea.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
399
        elif boundingBox is self.ui.lineEditDrawingNo.tag:
400
            self.ui.lineEditDrawingNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
401
        elif boundingBox is self.ui.lineEditRevNo.tag:
402
            self.ui.lineEditRevNo.setText('({},{}),({},{})'.format(round(x), round(y), round(width), round(height)))
403
        else:
404
            for row in range(self.ui.tableWidgetEquipmentDescArea.rowCount()):
405
                item = self.ui.tableWidgetEquipmentDescArea.item(row, 1)
406
                if boundingBox == item.tag:
407
                    strArea = '({},{}),({},{})'.format(round(x), round(y), round(width), round(height))
408
                    item.setText(strArea)
409
                    break
410
            for row in range(self.ui.tableWidgetTitleBlockArea.rowCount()):
411
                item = self.ui.tableWidgetTitleBlockArea.item(row, 2)
412
                if boundingBox == item.tag:
413
                    strArea = '({},{}),({},{})'.format(round(x), round(y), round(width), round(height))
414
                    item.setText(strArea)
415
                    break
416

    
417
    '''
418
        @brief  accept dialog
419
    '''
420
    def accept(self):
421
        try:
422
            areas = []
423

    
424
            if self.ui.lineEditDrawing.tag is not None:
425
                area = Area('Drawing')
426
                area.x = self.ui.lineEditDrawing.tag.rect().left()
427
                area.y = self.ui.lineEditDrawing.tag.rect().top() 
428
                area.width = self.ui.lineEditDrawing.tag.rect().width()
429
                area.height = self.ui.lineEditDrawing.tag.rect().height()
430
                areas.append(area)
431
                self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawing.tag)
432
            
433
            if self.ui.lineEditNote.tag is not None:
434
                area = Area('Note')
435
                area.x = self.ui.lineEditNote.tag.rect().left()
436
                area.y = self.ui.lineEditNote.tag.rect().top() 
437
                area.width = self.ui.lineEditNote.tag.rect().width()
438
                area.height = self.ui.lineEditNote.tag.rect().height()
439
                areas.append(area)
440
                self.parent().graphicsView.scene.removeItem(self.ui.lineEditNote.tag)
441

    
442
            if self.ui.lineEditHistoryData.tag is not None:
443
                area = Area('History Data')
444
                area.x = self.ui.lineEditHistoryData.tag.rect().left()
445
                area.y = self.ui.lineEditHistoryData.tag.rect().top() 
446
                area.width = self.ui.lineEditHistoryData.tag.rect().width()
447
                area.height = self.ui.lineEditHistoryData.tag.rect().height()
448
                areas.append(area)
449
                self.parent().graphicsView.scene.removeItem(self.ui.lineEditHistoryData.tag)
450

    
451
            if self.ui.lineEditDrawingNo.tag is not None:
452
                area = Area('Drawing No')
453
                area.x = self.ui.lineEditDrawingNo.tag.rect().left()
454
                area.y = self.ui.lineEditDrawingNo.tag.rect().top() 
455
                area.width = self.ui.lineEditDrawingNo.tag.rect().width()
456
                area.height = self.ui.lineEditDrawingNo.tag.rect().height()
457
                areas.append(area)
458
                self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawingNo.tag)
459

    
460
            if self.ui.lineEditUnitArea.tag is not None:
461
                area = Area('Unit')
462
                area.x = self.ui.lineEditUnitArea.tag.rect().left()
463
                area.y = self.ui.lineEditUnitArea.tag.rect().top() 
464
                area.width = self.ui.lineEditUnitArea.tag.rect().width()
465
                area.height = self.ui.lineEditUnitArea.tag.rect().height()
466
                areas.append(area)
467
                self.parent().graphicsView.scene.removeItem(self.ui.lineEditUnitArea.tag)
468

    
469
            if self.ui.lineEditRevNo.tag is not None:
470
                area = Area('Rev No')
471
                area.x = self.ui.lineEditRevNo.tag.rect().left()
472
                area.y = self.ui.lineEditRevNo.tag.rect().top() 
473
                area.width = self.ui.lineEditRevNo.tag.rect().width()
474
                area.height = self.ui.lineEditRevNo.tag.rect().height()
475
                areas.append(area)
476
                self.parent().graphicsView.scene.removeItem(self.ui.lineEditRevNo.tag)
477

    
478
            docData = AppDocData.instance()
479
            docData.setAreaList(areas)
480

    
481
            # save equipment desc area
482
            section = '{} Equipment Desc Area'.format(docData.imgName)
483
            docData.deleteConfigs(section)
484

    
485
            configs = []
486
            for row in range(self.ui.tableWidgetEquipmentDescArea.rowCount()):
487
                area = Area('Equipment Desc.')
488
                area.parse(self.ui.tableWidgetEquipmentDescArea.item(row, 1).text())
489
                configs.append(Config(section, str(row), area.toString()))
490

    
491
                self.removeArea(self.ui.tableWidgetEquipmentDescArea.item(row, 1).tag)
492
            # up to here
493

    
494
            # update title block area
495
            titleBlockProps = []
496
            for row in range(self.ui.tableWidgetTitleBlockArea.rowCount()):
497
                self.ui.tableWidgetTitleBlockArea.item(row, 2).text()
498
                if self.ui.tableWidgetTitleBlockArea.item(row, 1).text() != '':
499
                    titleBlockProps.append([self.ui.tableWidgetTitleBlockArea.item(row, 0).text(), self.ui.tableWidgetTitleBlockArea.item(row, 1).text(), self.ui.tableWidgetTitleBlockArea.item(row, 2).text()])
500

    
501
                self.removeArea(self.ui.tableWidgetTitleBlockArea.item(row, 2).tag)
502
            docData.updateTitleBlockProperties(titleBlockProps)
503
            # up to here
504
            docData.saveConfigs(configs)
505

    
506
            self.isAccepted = True
507
        except Exception as ex:
508
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
509
        finally:
510
            pass
511

    
512
        QDialog.accept(self)
513

    
514
    '''
515
        @brief  reject dialog
516
    '''
517
    def reject(self):
518
        if self.ui.lineEditDrawing.tag is not None:
519
            self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawing.tag)
520
        
521
        if self.ui.lineEditNote.tag is not None:
522
            self.parent().graphicsView.scene.removeItem(self.ui.lineEditNote.tag)
523

    
524
        if self.ui.lineEditHistoryData.tag is not None:
525
            self.parent().graphicsView.scene.removeItem(self.ui.lineEditHistoryData.tag)
526

    
527
        if self.ui.lineEditDrawingNo.tag is not None:
528
            self.parent().graphicsView.scene.removeItem(self.ui.lineEditDrawingNo.tag)
529

    
530
        if self.ui.lineEditUnitArea.tag is not None:
531
            self.parent().graphicsView.scene.removeItem(self.ui.lineEditUnitArea.tag)
532

    
533
        if self.ui.lineEditRevNo.tag is not None:
534
            self.parent().graphicsView.scene.removeItem(self.ui.lineEditRevNo.tag)
535

    
536
        for row in range(self.ui.tableWidgetEquipmentDescArea.rowCount()):
537
            self.removeArea(self.ui.tableWidgetEquipmentDescArea.item(row, 1).tag)
538

    
539
        for row in range(self.ui.tableWidgetTitleBlockArea.rowCount()):
540
            self.removeArea(self.ui.tableWidgetTitleBlockArea.item(row, 2).tag)
541

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