프로젝트

일반

사용자정보

개정판 61a7cd2d

ID61a7cd2d3abf9ca4bca55009c33f80a7c7bdec99
상위 55814098
하위 05851873

함의성이(가) 5년 이상 전에 추가함

issue #538: add symbol for detection and graphic

Change-Id: I33b77eddacaa79000d52053331ca7b953c015437

차이점 보기:

DTI_PID/DTI_PID/SymbolEditorDialog.py
31 31
                                            Remove self.dbHelper variable
32 32
                    2018.07.03  Yecheol     Rename File, Is Instrument Label added
33 33
    '''
34
    def __init__(self, parent, image, project, selectedSymbol = None):
34
    def __init__(self, parent, image, project, selectedSymbol = None, display = False):
35 35
        QDialog.__init__(self, parent)
36 36

  
37 37
        try:
38 38
            self.setWindowFlag(Qt.WindowMinMaxButtonsHint)
39 39
            self.image = image
40
            self.display = display
41

  
40 42
            self.selectedSymbol = selectedSymbol
41 43
            self.project = project
42 44
            self.ui = SymbolEditor_UI.Ui_Dialog()
......
55 57
            self.offsetY = 0
56 58
            self.newSym = None
57 59

  
58
            #self.setWindowTitle(self.tr('심볼 편집기'))
59
            if self.selectedSymbol is None:
60
                self.ui.checkBoxChange.setEnabled(False)
61
                self.ui.pushButtonChange.setEnabled(False)
62

  
60
            # for display image
61
            if display:
62
                self.ui.nameLineEdit.setEnabled(False)
63
                self.ui.thresholdLineEdit.setEnabled(False)
64
                self.ui.rotationCountSpinBox.setEnabled(False)
65
                self.ui.isContainChildCheckBox.setEnabled(False)
66
                self.ui.typeComboBox.setEnabled(False)
67
                self.ui.baseSymbolComboBox.setEnabled(False)
68
                self.ui.spinBoxParent.setEnabled(False)
69
                self.ui.defaultSymbolDirectionComboBox.setEnabled(False)
70
                self.ui.additionalSymbolComboBox.setEnabled(False)
71
                self.ui.addAdditionalSymbolButton.setEnabled(False)
72
                self.ui.additionalSymbolListWidget.setEnabled(False)
73
                self.ui.originalPointLineEdit.setEnabled(False)
74
                self.ui.addOriginalPointButton.setEnabled(False)
75
                self.ui.connectionPointLineEdit.setEnabled(False)
76
                self.ui.addConnectionPointButton.setEnabled(False)
77
                self.ui.pushButtonDelConnPt.setEnabled(False)
78
                self.ui.tableWidgetConnList.setEnabled(False)
79
                self.ui.isExceptDetectCheckBox.setEnabled(False)
80
                self.ui.makeFlipCheckBox.setEnabled(False)
81
                self.ui.cropButton.setEnabled(False)
82
                self.ui.fitImageButton.setEnabled(False)
83
                self.ui.rotateLeftButton.setEnabled(False)
84
                self.ui.rotateRightButton.setEnabled(False)
85
                self.ui.flipHorizontalButton.setEnabled(False)
86
                self.ui.flipVerticalButton.setEnabled(False)
87

  
88
            # unused function
63 89
            self.ui.hasInstrumentLabel.setHidden(True)
64 90
            self.ui.hasInstrumentLabelCheckBox.setHidden(True)
65 91
            self.ui.immediateInsertLabel.setHidden(True)
......
96 122
            symbol.parentSymbol = newBase
97 123
            symbol.childSymbol = newAddition
98 124

  
99

  
100 125
    ''' 
101 126
        @brief      hilight pressed connector item
102 127
        @author     humkyung
......
490 515
            else:
491 516
                isSuccess, fileType, fileName, imagePath = appDocData.updateSymbol(self.makeSymbolData(self.ui.imageView.image().width(), self.ui.imageView.image().height()))
492 517

  
493
            if isSuccess:
518
            if isSuccess and not self.display:
494 519
                try:
495 520
                    image = self.ui.imageView.image()
496 521
                    #imageFlip = self.ui.imageView.image().mirrored(horizontal = True, vertical = False)
......
525 550
                        self.resetUpdateSymbol(imagePath, fileName) ### update roll back 으로 변경해야함
526 551
                    self.isAccepted = False
527 552
                    QMessageBox.about(self.ui.buttonBox, self.tr('Error'), self.tr('Error occurs during saving symbol, please check data.'))
553
            elif self.display:
554
                try:
555
                    image = self.ui.imageView.image()
556
                    if image is not None:
557
                        self.deleteImageAndSvg(self.selectedSymbol.getImageFileFullPath(), self.selectedSymbol.getSvgFileFullPath(), self.display)
558
                        imageLocation = os.path.join(self.project.getImageFilePath(), fileType)
559
                        
560
                        path = os.path.splitext(imagePath)
561
                        path = path[0] + '_display' + path[1]
562
                        image.save(path, 'PNG')
563

  
564
                        svgLocation = os.path.join(self.project.getSvgFilePath(), fileType)
565
                        if not os.path.exists(svgLocation):
566
                            os.makedirs(svgLocation)
567

  
568
                        normal_color = self.ui.comboBoxNormalColor.itemData(self.ui.comboBoxNormalColor.currentIndex())
569
                        hover_color = self.ui.comboBoxHoverColor.itemData(self.ui.comboBoxHoverColor.currentIndex())
570
                        potrace.convertImageToSvg(path, os.path.join(svgLocation, fileName + ".svg"), normalColor=normal_color, hoverColor=hover_color)
571
                        
572
                        QDialog.accept(self)
573
                except:
574
                    self.resetUpdateSymbol(imagePath, fileName, self.display) ### update roll back 으로 변경해야함
575
                    self.isAccepted = False
576
                    QMessageBox.about(self.ui.buttonBox, self.tr('Error'), self.tr('Error occurs during saving symbol, please check data.'))
577

  
528 578
            else:
529 579
                QMessageBox.about(self.ui.buttonBox, self.tr('Error'), self.tr('Error occurs during saving symbol, please check data.'))
530 580
        else:
......
541 591
    '''
542 592
        @history    2018.05.03  Jeongwoo    Change Parameters (imagePath, type, name → imagePath, svgPath)
543 593
    '''
544
    def deleteImageAndSvg(self, imagePath, svgPath):
545
        if os.path.exists(imagePath):
594
    def deleteImageAndSvg(self, imagePath, svgPath, display = False):
595
        if not display and os.path.exists(imagePath):
546 596
            os.remove(imagePath)
547 597

  
598
        path = os.path.splitext(imagePath)
599
        path = path[0] + '_display' + path[1]
600
        if os.path.exists(path):
601
            os.remove(path)
602

  
548 603
        if os.path.exists(svgPath):
549 604
            os.remove(svgPath)
550 605
        
......
563 618
        @history    2018.05.03  Jeongwoo    Change Parameters
564 619
                                            Change self.dbHelper to AppDocData
565 620
    '''
566
    def resetUpdateSymbol(self, imagePath, svgPath):
567
        self.deleteImageAndSvg(imagePath, svgPath)
621
    def resetUpdateSymbol(self, imagePath, svgPath, display = False):
622
        self.deleteImageAndSvg(imagePath, svgPath, display)
568 623

  
569 624
        AppDocData.instance().updateSymbol(self.selectedSymbol)
570 625

  
DTI_PID/DTI_PID/SymbolTreeWidget.py
60 60
                editSymbolAction = QAction(self.tr("Edit Symbol"))
61 61
                editSymbolAction.triggered.connect(lambda: self.editSymbolActionClickEvent(item, 0))
62 62
                menu.addAction(editSymbolAction)
63
                editDisplaySymbolAction = QAction(self.tr("Edit Symbol for Dispay"))
64
                editDisplaySymbolAction.triggered.connect(lambda: self.editDisplaySymbolActionClickEvent(item, 0))
65
                menu.addAction(editDisplaySymbolAction)
63 66
                displaySymbolAction = QAction(self.tr("Display Symbol"))
64
                displaySymbolAction.triggered.connect(lambda: self.displaySymbolActionClickEvent(sym.getType(), text))
67
                displaySymbolAction.triggered.connect(lambda: self.displaySymbolActionClickEvent(item, 0))
65 68
                menu.addAction(displaySymbolAction)
66 69
                deleteSymbolAction = QAction(self.tr("Delete Symbol"))
67 70
                deleteSymbolAction.triggered.connect(lambda: self.deleteSymbolActionClickEvent(sym.getType(), text))
......
77 80
    def editSymbolActionClickEvent(self, item, columNo):
78 81
        self.showSymbolEditorDialog(item, columNo)
79 82

  
83
    def editDisplaySymbolActionClickEvent(self, item, columNo):
84
        self.showSymbolEditorDialog(item, columNo, True)
85

  
80 86
    '''
81 87
        @brief      popup attribute editor dialog
82 88
        @author     humkyung
......
96 102
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
97 103
            App.mainWnd().addMessage.emit(MessageType.Error, message)
98 104

  
99
    def displaySymbolActionClickEvent(self, itemType, itemName):
100
        project = AppDocData.instance().getCurrentProject()
101
        image = QImage(os.path.join(project.getImageFilePath(), itemType, itemName, "PNG")) #itemName includes ".png"
102
        dialog = QSymbolDisplayDialog.QSymbolDisplayDialog(image)
103
        dialog.showDialog()
105
    def displaySymbolActionClickEvent(self, item, columnNo):
106
        # project = AppDocData.instance().getCurrentProject()
107
        # image = QImage(os.path.join(project.getImageFilePath(), itemType, itemName, "PNG")) #itemName includes ".png"
108
        try:
109
            sym = self.getSymbolByItemName(item, columnNo)
110
            if sym is not None:
111
                path = sym.getPath()
112
                image = QImage(path, "PNG")
113
                dialog = QSymbolDisplayDialog.QSymbolDisplayDialog(image)
114
                dialog.showDialog()
115
            else:
116
                QMessageBox.about(self, self.tr('Error'), self.tr('Error occurs during loading symbol data.'))
117
        except Exception as ex:
118
            from App import App
119
            from AppDocData import MessageType
120

  
121
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
122
            App.mainWnd().addMessage.emit(MessageType.Error, message)
104 123

  
105 124
    def deleteSymbolActionClickEvent(self, itemType, itemName):
106 125
        msg = QMessageBox()
......
197 216
        if not os.path.exists(tempDir):
198 217
            os.makedirs(tempDir)
199 218

  
200
    def showSymbolEditorDialog(self, item, columnNo):
219
    def showSymbolEditorDialog(self, item, columnNo, display = False):
201 220
        try:
202 221
            sym = self.getSymbolByItemName(item, columnNo)
203
            if sym is not None:
222
            if sym and display:
223
                # for symbol image for display
224
                path = os.path.splitext(sym.getPath())
225
                path = path[0] + '_display' + path[1]
226
                if os.path.exists(path):
227
                    image = QImage(path, "PNG")
228
                else:
229
                    path = sym.getPath()
230
                    image = QImage(path, "PNG")
231
                symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, image, AppDocData.instance().getCurrentProject(), sym, True)
232
                (isAccepted, isImmediateInsert, offsetX, offsetY, newSym) = symbolEditorDialog.showDialog()
233
                self.initDirTreeWidget()
234
            elif sym:
235
                # for symbol data and detection image
204 236
                path = sym.getPath()
205 237
                image = QImage(path, "PNG")
206
                symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, image, AppDocData.instance().getCurrentProject(), sym)
238
                symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, image, AppDocData.instance().getCurrentProject(), sym, False)
207 239
                (isAccepted, isImmediateInsert, offsetX, offsetY, newSym) = symbolEditorDialog.showDialog()
208 240
                self.initDirTreeWidget()
209 241
            else:
210 242
                QMessageBox.about(self, self.tr('Error'), self.tr('Error occurs during loading symbol data.'))
211 243
        except Exception as ex:
212 244
            from App import App
245
            from AppDocData import MessageType
213 246

  
214 247
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
215 248
            App.mainWnd().addMessage.emit(MessageType.Error, message)

내보내기 Unified diff

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