프로젝트

일반

사용자정보

개정판 77a35abf

ID77a35abfee2bd538590b665121fca1dd2e3c337a
상위 777f0b87
하위 9b0bec95

백흠경이(가) 6년 이상 전에 추가함

fixed issue #641:
- 프로그래스바 표기

차이점 보기:

DTI_PID/DTI_PID/MainWindow.py
626 626
                appDocData.setCurrentPidSource(Image.open(self.path))
627 627
                self.resultTreeWidget.setCurrentPID(appDocData.activeDrawing.name)
628 628

  
629
                self.progress = QProgressDialog("잠시만 기다려주세요", "Cancel", 0, 100, self)
630
                self.progress.setWindowModality(Qt.WindowModal)
631
                self.progress.setAutoReset(True)
632
                self.progress.setAutoClose(True)
633
                self.progress.setMinimum(0)
634
                self.progress.resize(600,100)
635
                self.progress.setWindowTitle("파일 읽는 중...")
636
                self.progress.show()
637

  
629 638
                ## Load data on xml
630
                path = os.path.join(appDocData.getCurrentProject().getTempPath(), appDocData.imgName + '.xml')
631
                if os.path.isfile(path): self.loadRecognitionResultFromXml(path)
639
                try:
640
                    path = os.path.join(appDocData.getCurrentProject().getTempPath(), appDocData.imgName + '.xml')
641
                    if os.path.isfile(path): self.loadRecognitionResultFromXml(path)
642
                finally:
643
                    self.progress.setValue(100)
644
                    self.progress.hide()
632 645
        except Exception as ex:
633 646
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
634 647
            self.addMessage.emit(MessageType.Error, message)
......
1148 1161
                                        Add connect on unknown item
1149 1162
                                        Add [transfer] for using pyqtSignal
1150 1163
                    kyouho  2018.07.12  Add line property logic
1164
                    humkyung 2018.08.22 show progress while loading xml file
1151 1165
    '''
1152 1166
    def loadRecognitionResultFromXml(self, xmlPath):
1153 1167
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse
......
1157 1171

  
1158 1172
            xml = parse(xmlPath)
1159 1173
            root = xml.getroot()
1174
            
1175
            maxValue = 0
1176
            maxValue = maxValue + len(list(root.iter('SYMBOL')))
1177
            maxValue = maxValue + len(list(root.iter('ATTRIBUTE')))
1178
            maxValue = maxValue + len(list(root.iter('LINE_NO')))
1179
            maxValue = maxValue + len(list(root.iter('LINE')))
1180
            maxValue = maxValue + len(list(root.iter('UNKNOWN')))
1181
            self.progress.setMaximum(maxValue)
1182

  
1160 1183
            for symbol in root.iter('SYMBOL'):
1161 1184
                item = SymbolSvgItem.fromXml(symbol)
1162 1185
                if item[0] is not None:
......
1172 1195
                    item.setPen(QPen(Qt.red, 5, Qt.SolidLine))
1173 1196
                    self.graphicsView.scene.addItem(item)
1174 1197

  
1198
                self.progress.setValue(self.progress.value() + 1)
1199
                
1200
            QApplication.processEvents()
1201

  
1175 1202
            # set symbol's owner
1176 1203
            childItems = [item for item in symbols if item[1] is not None]
1177 1204
            for item in childItems:
......
1233 1260
                        self.addTextItemToScene(item)
1234 1261
                        if uid is not None:
1235 1262
                            item.uid = uid.text
1263

  
1264
                self.progress.setValue(self.progress.value() + 1)
1236 1265
                
1266
            QApplication.processEvents()
1237 1267

  
1238 1268
            for lineNo in root.iter('LINE_NO'):
1239 1269
                location = lineNo.find('LOCATION').text if lineNo.find('LOCATION') is not None else '0,0'
......
1253 1283
                    item.transfer.onRemoved.connect(self.itemRemoved)
1254 1284
                    self.addTextItemToScene(item)
1255 1285

  
1286
                self.progress.setValue(self.progress.value() + 1)
1287
                
1288
            QApplication.processEvents()
1289

  
1256 1290
            for line in root.iter('LINE'):
1257 1291
                item = QEngineeringLineItem.fromXml(line)
1258 1292
                item.transfer.onRemoved.connect(self.itemRemoved)
1259 1293
                if item: self.addLineItemToScene(item)
1260 1294

  
1295
                self.progress.setValue(self.progress.value() + 1)
1296
                
1297
            QApplication.processEvents()
1298

  
1261 1299
            for unknown in root.iter('UNKNOWN'):
1262 1300
                item = QEngineeringUnknownItem.fromXml(unknown)
1263 1301
                item.transfer.onRemoved.connect(self.itemRemoved)
1264 1302
                if item is not None:
1265 1303
                    item.transfer.onRemoved.connect(self.itemRemoved)
1266 1304
                    self.addUnknownItemToScene(item)
1267
            # up to here
1268 1305

  
1306
                self.progress.setValue(self.progress.value() + 1)
1307
                
1308
            QApplication.processEvents()
1309
            # up to here
1269 1310

  
1270 1311
            # set symbol's connectItem
1271 1312
            from EngineeringConnectorItem import QEngineeringConnectorItem
......
1281 1322
                    if type(symbol.attrs[index]) is not UserInputAttribute:
1282 1323
                        symbol.attrs[index] = self.graphicsView.findItemByUid(symbol.attrs[index])
1283 1324
                        
1284

  
1285 1325
            # Update Scene
1286 1326
            self.graphicsView.scene.update(self.graphicsView.sceneRect())
1287 1327
        except Exception as ex:
......
1318 1358
                    2018.06.18  Jeongwoo    Set Z-index
1319 1359
    '''
1320 1360
    def addTextItemToScene(self, textItem):
1321
        textRect = textItem.boundingRectOnScene()
1322
        items = self.graphicsView.scene.items(textRect)
1323
        if items is not None:
1324
            for item in items:
1325
                if issubclass(type(item), QEngineeringTextItem):
1326
                    itemRect = item.boundingRectOnScene()
1327
                    if itemRect.topLeft() == textRect.topLeft() and item.text() == textItem.text(): # Equal
1328
                        item.deleteTextItemFromScene()
1329
        textItem.setZValue(10)
1330 1361
        textItem.addTextItemToScene(self.graphicsView.scene)
1331 1362
        
1332 1363
    '''
......
1336 1367
        @history    2018.06.18  Jeongwoo    Set Z-index
1337 1368
    '''
1338 1369
    def addLineItemToScene(self, lineItem):
1339
        '''
1340
        lineRect = lineItem.boundingRectOnScene()
1341
        items = self.graphicsView.scene.items(lineRect)
1342
        if items is not None:
1343
            for item in items:
1344
                if issubclass(type(item), QEngineeringLineItem):
1345
                    itemRect = item.boundingRectOnScene()
1346
                    if item.startPoint() == lineItem.startPoint() and item.endPoint() == lineItem.endPoint(): # Equal
1347
                        item.deleteLineItemFromScene()
1348
        lineItem.setZValue(10)
1349
        '''
1350 1370
        lineItem.addLineItemToScene(self.graphicsView.scene)
1351 1371

  
1352 1372
    '''

내보내기 Unified diff