프로젝트

일반

사용자정보

개정판 7611e7bc

ID7611e7bc9f2ac21465ff39cb2603d5c728bd69ed
상위 12ee48dc
하위 4505e227, 36cf5a45

gaqhf 이(가) 6년 이상 전에 추가함

dev issue #632: xml로 저장시 결과를 확인하기 위하여 저장 실패시 해당 uid return

차이점 보기:

DTI_PID/DTI_PID/Commands/DefaultCommand.py
96 96
                if xmlStr.find('<SYMBOL>') > -1 and xmlStr.find('</SYMBOL>') > -1:
97 97
                    self.copySymbol(QApplication.clipboard().text())
98 98
            elif 'keyPressEvent' == param[0] and (event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_S):
99
                import XmlGenerator as xg
100
                from AppDocData import AppDocData
101
                docData = AppDocData.instance()
102
                xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.imageViewer.scene)
103
                QMessageBox.about(self.imageViewer, "알림", "정상적으로 저장되었습니다.")
99
                self.imageViewer.mainWindow.saveToXml(True)
100
                #import XmlGenerator as xg
101
                #from AppDocData import AppDocData
102
                #docData = AppDocData.instance()
103
                #xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.imageViewer.scene)
104
                #QMessageBox.about(self.imageViewer, "알림", "정상적으로 저장되었습니다.")
104 105

  
105 106
            self.isTreated = False
106 107
        else:
DTI_PID/DTI_PID/MainWindow.py
163 163
        @author     kyouho
164 164
        @date       2018.07.31
165 165
    '''
166
    def saveToXml(self):
166
    def saveToXml(self, alert = True):
167 167
        import XmlGenerator as xg
168 168
        from AppDocData import AppDocData
169 169
        docData = AppDocData.instance()
170 170
        if docData.imgName is None:
171 171
            self.showImageSelectionMessageBox()
172 172
            return
173
        xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.graphicsView.scene)
174
        QMessageBox.about(self.graphicsView, "알림", "정상적으로 저장되었습니다.")
173
        result = xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.graphicsView.scene)
174
        
175
        if alert:
176
            resultStr = '[저장 결과]'
177

  
178
            for item in result.items():
179
                itemName = str(item[0])
180
                itemSuccessCount = str(item[1][0])
181
                itemFailUidList = item[1][1]
182
                resultStr += "\r\n" + itemName + " Save Count : " + itemSuccessCount
183
                if len(itemFailUidList) > 0:
184
                    resultStr += "\r\n" + itemName + " Error List(UID)"
185
                    for uid in itemFailUidList:
186
                        resultStr += "\r\n" + uid
187

  
188
            QMessageBox.about(self.graphicsView, "알림", resultStr)
175 189

  
176 190

  
177 191
    '''
DTI_PID/DTI_PID/QRecognitionDialog.py
184 184

  
185 185
            self.parent.drawUnknownItems()
186 186

  
187
            xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.graphicsView.scene)
187
            self.parent.saveToXml(False)
188
            #xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.graphicsView.scene)
188 189
        except Exception as ex:
189 190
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
190 191
        finally:
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
959 959

  
960 960
            # up to here
961 961
        except Exception as ex:
962
            return str(self.uid)
962 963
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
963 964

  
964 965
        return node
DTI_PID/DTI_PID/Shapes/QEngineeringLineNoTextItem.py
188 188

  
189 189
                node.append(attrNode) 
190 190
        except Exception as ex:
191
            return str(self.uid)
191 192
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
192 193

  
193 194
        return node 
DTI_PID/DTI_PID/Shapes/QEngineeringTextItem.py
306 306
            heightNode.text = str(self.size[1])
307 307
            node.append(heightNode)
308 308
        except Exception as ex:
309
            return str(self.uid)
309 310
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
310 311

  
311 312
        return node 
DTI_PID/DTI_PID/Shapes/QEngineeringUnknownItem.py
120 120
            ptNode.text = points
121 121
            node.append(ptNode)
122 122
        except Exception as ex:
123
            return str(self.uid)
123 124
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
124 125

  
125 126
        return node 
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
628 628
            node.append(currentPointModeIndexNode)
629 629

  
630 630
        except Exception as ex:
631
            return str(self.uid)
631 632
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
632 633

  
633 634
        return node 
DTI_PID/DTI_PID/XmlGenerator.py
374 374
    unknownListNode = Element(UNKNOWNS_NODE_NAME)
375 375
    
376 376
    try:
377
        resultDic = {}
378
        resultDic["Symbol Item"] = [0, []]
379
        resultDic["Line Item"] = [0, []]
380
        resultDic["Line No Text Item"] = [0, []]
381
        resultDic["Text Item"] = [0, []]
382
        resultDic["Note Item"] = [0, []]
383
        resultDic["Unknown Item"] = [0, []]
384

  
377 385
        items = scene.items()
378 386
        if items is not None:
379 387
            for item in items:
380 388
                if issubclass(type(item), SymbolSvgItem):
381 389
                    symbolNode = item.toXml()
382
                    symbolListNode.append(symbolNode)
383
                elif type(item) is QEngineeringTextItem:
384
                    textNode = item.toXml()
385
                    textInfoListNode.append(textNode)
386
                elif type(item) is QEngineeringNoteItem:
387
                    noteNode = item.toXml(name = 'NOTE')
388
                    noteTextInfoListNode.append(noteNode)
390
                    if type(symbolNode) is str:
391
                        resultDic["Symbol Item"][1].append(symbolNode)
392
                    else:
393
                        resultDic["Symbol Item"][0] += 1
394
                        symbolListNode.append(symbolNode)
389 395
                elif type(item) is QEngineeringLineItem:
390 396
                    lineNode = item.toXml()
391
                    lineListNode.append(lineNode)
397
                    if type(lineNode) is str:
398
                        resultDic["Line Item"][1].append(lineNode)
399
                    else:
400
                        resultDic["Line Item"][0] += 1
401
                        lineListNode.append(lineNode)
392 402
                elif type(item) is QEngineeringLineNoTextItem:
393 403
                    lineNoNode = item.toXml()
394
                    lineNoListNode.append(lineNoNode)
404
                    if type(lineNoNode) is str:
405
                        resultDic["Line No Text Item"][1].append(lineNoNode)
406
                    else:
407
                        resultDic["Line No Text Item"][0] += 1
408
                        lineNoListNode.append(lineNoNode)
409
                elif type(item) is QEngineeringTextItem:
410
                    textNode = item.toXml()
411
                    if type(textNode) is str:
412
                        resultDic["Text Item"][1].append(textNode)
413
                    else:
414
                        resultDic["Text Item"][0] += 1
415
                        textInfoListNode.append(textNode)
416
                elif type(item) is QEngineeringNoteItem:
417
                    noteNode = item.toXml(name = 'NOTE')
418
                    if type(noteNode) is str:
419
                        resultDic["Note Item"][1].append(noteNode)
420
                    else:
421
                        resultDic["Note Item"][0] += 1
422
                        noteTextInfoListNode.append(noteNode)
395 423
                elif type(item) is QEngineeringUnknownItem:
396 424
                    unknownNode = item.toXml()
397
                    unknownListNode.append(unknownNode)
425
                    if type(unknownNode) is str:
426
                        resultDic["Unknown Item"][1].append(unknownNode)
427
                    else:
428
                        resultDic["Unknown Item"][0] += 1
429
                        unknownListNode.append(unknownNode)
430

  
398 431
    except Exception as ex:
399 432
        print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
400 433
    finally:
......
406 439
        xml.append(unknownListNode)
407 440
        ElementTree(xml).write(path)
408 441

  
409
    return path
442
    return resultDic
410 443

  
411 444
def indent(elem, level=0):
412 445
    i = "\n" + level*"  "

내보내기 Unified diff

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