프로젝트

일반

사용자정보

개정판 478c2510

ID478c25100785e1deefb169c37e837497efd13bb3
상위 47377669
하위 390b2ca6

함의성이(가) 약 6년 전에 추가함

issue #622: title block db update

차이점 보기:

DTI_PID/DTI_PID/ConfigurationAreaDialog.py
108 108
        self.ui.tableWidgetTitleBlockArea.setRowCount(len(titleBlockProps))
109 109
        row = 0
110 110
        for titleBlockProp in titleBlockProps:
111
            area = Area('Title Block')
111
            area = Area(titleBlockProp[0])
112 112
            area.parse(titleBlockProp[2])
113 113

  
114 114
            boundingBox = QGraphicsBoundingBoxItem(area.x, area.y, area.width, area.height)
DTI_PID/DTI_PID/MainWindow.py
36 36
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
37 37
from EngineeringTextItem import QEngineeringTextItem
38 38
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
39
from EngineeringTextItem import QEngineeringTextItem
39 40
from EngineeringNoteItem import QEngineeringNoteItem
40 41
from QEngineeringSizeTextItem import QEngineeringSizeTextItem
41 42
from EngineeringUnknownItem import QEngineeringUnknownItem
......
367 368
        items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)]
368 369
        self.labelTextStatus.setText("<font color='blue'>텍스트 : {}</font>".format(len(items)))
369 370

  
371
    def dbUpdate(self):
372
        '''
373
            @brief      db update when save or recognition
374
            @author     euisung
375
            @date       2018.11.12
376
        '''
377
        from AppDocData import AppDocData
378

  
379
        appDocData = AppDocData.instance()
380

  
381
        appDocData.deleteDataListBeforeSave()
382
        
383
        titleBlockProps = appDocData.getTitleBlockProperties()
384
        items = self.graphicsView.scene.items()
385
        titleBlockItems = []
386
        for item in items:
387
            if type(item) is QEngineeringLineNoTextItem:
388
                item.saveLineData()
389

  
390
            elif type(item) is QEngineeringTextItem:
391
                for titleBlockProp in titleBlockProps:
392
                    if item.area == titleBlockProp[0]:
393
                        titleBlockItems.append(item)
394

  
395
        dbItems = [item for item in items if type(item) is QEngineeringInstrumentItem or type(item) is QEngineeringEquipmentItem or\
396
        type(item) is QEngineeringNoteItem] + titleBlockItems
397
        appDocData.saveToDatabase(dbItems)
398

  
370 399
    '''
371 400
        @brief      action save click event
372 401
        @author     kyouho
......
375 404
                    humkyung save saved time to database
376 405
                    2018.11.05      euisung     add note data list db update
377 406
                    2018.11.05      euisung     add db delete process before save
407
                    2018.11.12      euisung     db part move new method to dbUpdate
378 408
    '''
379 409
    def actionSaveCliked(self):
380 410
        from datetime import datetime
......
384 414
        if appDocData.imgName is None:
385 415
            self.showImageSelectionMessageBox()
386 416
            return
387
        appDocData.deleteDataListBeforeSave()
388 417

  
389 418
        appDocData.equipments.clear()
390 419
        appDocData.symbols.clear()
391 420
        appDocData.lineNos.clear()
392 421
        appDocData.texts.clear()
393 422

  
394
        items = self.graphicsView.scene.items()
395
        for item in items:
396
            if type(item) is QEngineeringLineNoTextItem:
397
                item.saveLineData()
398

  
399
        appDocData.saveToDatabase([item for item in items if type(item) is QEngineeringInstrumentItem or type(item) is QEngineeringEquipmentItem or\
400
        type(item) is QEngineeringNoteItem])
401

  
423
        self.dbUpdate()
402 424
        self.saveToXml(True)
403 425

  
404 426
        drawings = appDocData.getDrawings()
......
1174 1196
                    2018.11.05  euisung     add save note item because of dependency
1175 1197
                    2018.11.05  euisung     add db delete process before save
1176 1198
                    2018.11.12  euisung     add title block properties
1199
                    2018.11.12  euisung     db part move new method to dbUpdate
1177 1200
    '''
1178 1201
    def drawDetectedItems(self, symbolList, textInfoList, otherTextInfoList, titleBlockTextInfoList):
1179 1202
        try:
......
1186 1209
            self.drawDetectedTextItem(textInfoList)
1187 1210
            QApplication.processEvents()
1188 1211
            self.drawDetectedOtherTextItem(otherTextInfoList)
1189
            #QApplication.processEvents()
1190
            #self.drawDetectedTitleBlockTextItem(titleBlockTextInfoList)
1191

  
1192
            appDocData.deleteDataListBeforeSave()
1193

  
1194
            items = self.graphicsView.scene.items()
1195
            for item in items:
1196
                if type(item) is QEngineeringLineNoTextItem:
1197
                    item.saveLineData()
1198

  
1199
            appDocData.saveToDatabase([item for item in items if type(item) is QEngineeringInstrumentItem or type(item) is QEngineeringEquipmentItem or\
1200
            type(item) is QEngineeringNoteItem])
1212
            QApplication.processEvents()
1213
            self.drawDetectedTitleBlockTextItem(titleBlockTextInfoList)
1201 1214

  
1215
            self.dbUpdate()
1202 1216
            self.saveToXml(False)
1203 1217

  
1204 1218
            # update scene
......
1221 1235

  
1222 1236
            # parse texts
1223 1237
            for textInfo in textInfoList:
1224
                x = textInfo.getX()
1225
                y = textInfo.getY()
1226
                width = textInfo.getW()
1227
                height = textInfo.getH()
1228
                angle = round(math.radians(textInfo.getAngle()), 2)
1229
                text = textInfo.getText()
1238
                x = textInfo[1][0].getX()
1239
                y = textInfo[1][0].getY()
1240
                width = textInfo[1][0].getW()
1241
                height = textInfo[1][0].getH()
1242
                angle = round(math.radians(textInfo[1][0].getAngle()), 2)
1243
                text = textInfo[1][0].getText()
1230 1244
                item = TextItemFactory.instance().createTextItem(text)
1231 1245

  
1232 1246
                if item is not None:
......
1234 1248
                    item.size = (width, height)
1235 1249
                    item.angle = angle
1236 1250
                    item.setPlainText(text)
1237
                    item.area = 'Title Block'
1251
                    item.area = textInfo[0]
1238 1252
                    self.addTextItemToScene(item)
1239 1253
                    appDocData.texts.append(item)
1240 1254
        except Exception as ex:
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
228 228
                    item.size = (width, height)
229 229
                    item.angle = angle
230 230
                    item.setPlainText(text)
231
                    items.area = self.area
231 232
                    item.addTextItemToScene(scene)
232 233
                    item.transfer.onRemoved.connect(scene.parent().parent().parent().itemRemoved)
233 234

  
......
518 519
    def getColor(self):
519 520
        return self._color
520 521

  
522
    def toSql(self):
523
        """
524
        convert instrument data to sql query for title block now on
525
        """
526
        from AppDocData import AppDocData
527

  
528
        appDocData = AppDocData.instance()
529
        titleBlockProps = appDocData.getTitleBlockProperties()
530
        for titleBlockProp in titleBlockProps:
531
            if self.area == titleBlockProp[0]:
532
                cols = ['UID', 'Drawing_UID', 'TitleBlockProperties_UID', 'VALUE']
533
                values = ['?','?','?','?']
534
                param = [str(self.uid), appDocData.activeDrawing.name, self.area, self.text()]
535

  
536
                sql = 'insert or replace into TitleBlockValues values({})'.format(','.join(values))
537
                return (sql, tuple(param))
538

  
539
        return None
540

  
541

  
521 542
'''
522 543
    @brief      The class transfer pyqtSignal Event. Cause Subclass of QGraphicsRectItem can't use pyqtSignal
523 544
    @author     Jeongwoo
DTI_PID/DTI_PID/TextDetector.py
276 276

  
277 277
            titleBlockProps = appDocData.getTitleBlockProperties()
278 278
            for titleBlockProp in titleBlockProps:
279
                area = Area(titleBlockProp[1])
279
                area = Area(titleBlockProp[0])
280 280
                area.parse(titleBlockProp[2])
281 281
                img = imgSrc[round(area.y):round(area.y+area.height), round(area.x):round(area.x+area.width)]
282 282
                if len(whiteCharList) is 0:

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)