프로젝트

일반

사용자정보

개정판 31958dce

ID31958dce7d8ef4a6e6a5d4ea07e6a958bef7456b
상위 1d33681d
하위 bb23850e, 783c7845

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

issue #503: db save, bug fixed

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
734 734
        
735 735
        return prjDatabaseFilePath
736 736

  
737
    '''
738
        @brief  return title block properties
739
        @author euisung
740
        @date   2018.11.09
741
    '''
737
    def updateTitleBlockProperties(self, titleBlockProps):
738
        '''
739
            @brief  update title block properties
740
            @author euisung
741
            @date   2018.11.09
742
        '''
743
        try:
744
            originTitleBlockProps = self.getTitleBlockProperties()
745
            deletedTitleBlockProps = []
746
            for originTitleBlockProp in originTitleBlockProps:
747
                for titleBlockProp in titleBlockProps:
748
                    # uid compare for determine delete props
749
                    if originTitleBlockProp[0] == titleBlockProp[0]:
750
                        break
751
                deletedTitleBlockProps.append(originTitleBlockProp[0])
752
            
753
            # Creates or opens a file called mydb with a SQLite3 DB
754
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db")
755
            conn = sqlite3.connect(dbPath)
756
            # Get a cursor object
757
            cursor = conn.cursor()
758

  
759
            for deletedTitleBlockProp in deletedTitleBlockProps:
760
                sql = "delete from TitleBlockProperties where UID='{}'".format(deletedTitleBlockProp)
761
                cursor.execute(sql)
762

  
763
            for titleBlockProp in titleBlockProps:
764
                sql = "insert or replace into TitleBlockProperties values(?,?,?)"
765
                param = (titleBlockProp[0], titleBlockProp[1], titleBlockProp[2]) # uid, name, area
766
                cursor.execute(sql, param)
767
            conn.commit()
768
        # Catch the exception
769
        except Exception as ex:
770
            # Roll back any change if something goes wrong
771
            conn.rollback()
772
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
773
        finally:
774
            # Close the db connection
775
            conn.close()
776

  
777
        self._titleBlockProperties = None
778
    
742 779
    def getTitleBlockProperties(self):
780
        '''
781
            @brief  return title block properties
782
            @author euisung
783
            @date   2018.11.09
784
        '''
743 785
        res = None
744 786
        if self._titleBlockProperties is None:
745 787
            try:
......
756 798
                rows = cursor.fetchall()
757 799
                for row in rows:
758 800
                    attr = []
759
                    attr[0] = row[0] # uid
760
                    attr[1] = row[1] # name
761
                    attr[2] = row[2] # area
801
                    attr.append(row[0]) # uid
802
                    attr.append(row[1]) # name
803
                    attr.append(row[2]) # area
762 804
                    self._titleBlockProperties.append(attr)
763 805
                
764 806
                res = self._titleBlockProperties
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('')
111
            area = Area('Title Block')
112 112
            area.parse(titleBlockProp[2])
113 113

  
114 114
            boundingBox = QGraphicsBoundingBoxItem(area.x, area.y, area.width, area.height)
......
194 194

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

  
204 204
    def onDeleteTitleBlockArea(self):
205 205
        '''
206
        @brief  delete selected title block area
207
        @author euisung
208
        @date   2018.11.09
206
            @brief  delete selected title block area
207
            @author euisung
208
            @date   2018.11.09
209 209
        '''
210 210
        try:
211 211
            row = self.ui.tableWidgetTitleBlockArea.currentRow()
......
228 228
        @author humkyung
229 229
        @date   2018.06.29
230 230
        @history    2018.11.09      euisung     change name removeEquipmentDescArea -> removeArea for title block
231
                                                change remove process
231 232
    '''
232 233
    def removeArea(self, box):
233 234
        import re
......
329 330
            width, height = round(width), round(height)
330 331

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

  
......
354 355
            width, height = round(width), round(height)
355 356

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

  
361 362
            # add item to table widget
......
406 407
                    strArea = '({},{}),({},{})'.format(round(x), round(y), round(width), round(height))
407 408
                    item.setText(strArea)
408 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
409 416

  
410 417
    '''
411 418
        @brief  accept dialog
......
483 490

  
484 491
                self.removeArea(self.ui.tableWidgetEquipmentDescArea.item(row, 1).tag)
485 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
486 504
            docData.saveConfigs(configs)
487 505

  
488 506
            self.isAccepted = True
......
518 536
        for row in range(self.ui.tableWidgetEquipmentDescArea.rowCount()):
519 537
            self.removeArea(self.ui.tableWidgetEquipmentDescArea.item(row, 1).tag)
520 538

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

  
521 542
        QDialog.reject(self)
DTI_PID/DTI_PID/MainWindow.py
734 734
    '''
735 735
    def areaConfiguration(self):
736 736
        from ConfigurationAreaDialog import QConfigurationAreaDialog
737

  
737
        if not self.graphicsView.hasImage():
738
            self.showImageSelectionMessageBox()
739
            return
738 740
        self.dlgConfigurationArea = QConfigurationAreaDialog(self)
739 741
        self.dlgConfigurationArea.show()
740 742
        self.dlgConfigurationArea.exec_()

내보내기 Unified diff