프로젝트

일반

사용자정보

개정판 f7987e0e

IDf7987e0e7927984385128f5f86a3e819a83dcade
상위 2497cd1e
하위 1171931c

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

issue #663: package and text on going

Change-Id: I179598aee5e84c36be5580eff6d8161658ef7cee

차이점 보기:

DTI_PID/DTI_PID/Commands/LoadCommand.py
39 39
    def __init__(self):
40 40
        super(LoadCommand, self).__init__(None)
41 41

  
42
    def execute(self, params, symbol=True, text=True, line=True, unknown=True, update=True):
42
    def execute(self, params, symbol=True, text=True, line=True, unknown=True, package=True, update=True):
43 43
        """load data form xml file for database"""
44 44
        from datetime import datetime
45 45
        from App import App
......
70 70
            path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), file_name + '.xml')
71 71
            configs = app_doc_data.getConfigs('Data Load', 'Xml First')
72 72
            if configs and int(configs[0].value) >= 1 and os.path.isfile(path):
73
                value = self.load_data_from_xml(drawing, scene, symbol, text, line, unknown)
73
                value = self.load_data_from_xml(drawing, scene, symbol, text, line, unknown, package)
74 74
            elif configs and int(configs[0].value) <= 1:
75
                value = self.load_data_from_database(drawing, scene, symbol, text, line, unknown)
75
                value = self.load_data_from_database(drawing, scene, symbol, text, line, unknown, package)
76 76

  
77 77
            """update items"""
78 78
            if update:
......
95 95
        finally:
96 96
            app_doc_data.clearTempDBData()
97 97

  
98
    def load_data_from_xml(self, drawing, scene, symbol, text, line, unknown) -> int:
98
    def load_data_from_xml(self, drawing, scene, symbol, text, line, unknown, package) -> int:
99 99
        def find_item(scene, uid):
100 100
            items = [item for item in scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)]
101 101
            return items[0] if items else None
......
292 292

  
293 293
                QApplication.processEvents()
294 294

  
295
            if root.find('VENDORS') is not None:
296
                for vendor in root.find('VENDORS').iter('VENDOR'):
297
                    item = QEngineeringVendorItem.fromXml(vendor)
298
                    scene.addItem(item)
295
            if package:
296
                if root.find('VENDORS') is not None:
297
                    for vendor in root.find('VENDORS').iter('VENDOR'):
298
                        item = QEngineeringVendorItem.fromXml(vendor)
299
                        scene.addItem(item)
299 300

  
300 301
            # connect flow item to line
301 302
            for line in lines:
......
331 332

  
332 333
        return value
333 334

  
334
    def load_data_from_database(self, drawing, scene, symbol, text, line, unknown) -> int:
335
    def load_data_from_database(self, drawing, scene, symbol, text, line, unknown, package) -> int:
335 336
        """load drawing data from database"""
336 337
        from App import App
337 338
        from EngineeringRunItem import QEngineeringRunItem
......
483 484
                    value = value + 1
484 485
                    self.show_progress.emit(value)
485 486

  
486
            for component in [component for component in components if
487
                              component['Name'] == 'VendorPackage' and component['SymbolType_UID'] == -1]:
488
                item = QEngineeringVendorItem.from_database(component)
489
                if item is not None:
490
                    scene.addItem(item)
487
            if package:
488
                for component in [component for component in components if
489
                                component['Name'] == 'VendorPackage' and component['SymbolType_UID'] == -1]:
490
                    item = QEngineeringVendorItem.from_database(component)
491
                    if item is not None:
492
                        scene.addItem(item)
491 493

  
492 494
            # connect flow item to line
493 495
            for line in lines:
DTI_PID/DTI_PID/MainWindow.py
1412 1412
            self.graphicsView.scene().update(self.graphicsView.sceneRect())
1413 1413
            DisplayColors.instance().save_data()
1414 1414

  
1415
    def open_image_drawing(self, drawing):
1415
    def open_image_drawing(self, drawing, force=False):
1416 1416
        """open and display image drawing file"""
1417 1417
        from Drawing import Drawing
1418 1418
        from App import App
......
1441 1441
            if not self.actionSave.isEnabled():
1442 1442
                return
1443 1443

  
1444
            if self.save_drawing_if_necessary():
1444
            if not force and self.save_drawing_if_necessary():
1445 1445
                return
1446 1446

  
1447 1447
            occupied = app_doc_data.set_occupying_drawing(drawing.UID)
......
1492 1492
                    cmd.set_maximum.connect(self.progress.setMaximum)
1493 1493
                    cmd.show_progress.connect(self.progress.setValue)
1494 1494
                    cmd.execute((drawing, self.graphicsView.scene()),
1495
                                symbol=True, text=True, line=True, unknown=True, update=True)
1495
                                symbol=True, text=True, line=True, unknown=True, package=True, update=True)
1496 1496
                    # up to here
1497 1497

  
1498 1498
                    """"update item tree widget"""
......
1525 1525
                    self._scene.update(self._scene.sceneRect())
1526 1526

  
1527 1527
                    """
1528
                    # old open drawing
1528 1529
                    path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), app_doc_data.imgName + '.xml')
1529 1530
                    configs = app_doc_data.getConfigs('Data Load', 'Xml First')
1530 1531
                    if configs and int(configs[0].value) >= 1 and os.path.isfile(path):
......
2175 2176
            dlg.exec_()
2176 2177

  
2177 2178
            if current_drawing and current_drawing in checked_drawings.keys() and dlg.isTreated:
2178
                self.open_image_drawing(current_drawing)
2179
                self.open_image_drawing(current_drawing, force=True)
2179 2180

  
2180 2181
            # save working date-time
2181 2182
            _now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
DTI_PID/DTI_PID/RecognitionDialog.py
85 85
        self.mutex = mutex
86 86
        self.cond = cond
87 87

  
88
        self.pre_data = {'Equipment Package':[], 'Text':[]}
89

  
90 88
    '''
91 89
        @history    2018.05.25  Jeongwoo    Add if-statements by isSymbolTextChecked and isLineChecked variable
92 90
                    2018.05.28  Jeongwoo    Add Parameter 'xmlPath[0]'
......
761 759
        # cv2.waitKey(0)
762 760
        # cv2.destroyAllWindows()
763 761
        return (True, mergedOtherLine)
764
    
765
    def load_recognition_data_from_xml(self, xmlPath):
766
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse
767
        from EngineeringVendorItem import QEngineeringVendorItem
768

  
769
        try:
770
            xml = parse(xmlPath)
771
            root = xml.getroot()
772

  
773
            # load equipment package
774
            if root.find('VENDORS') is not None:
775
                for vendor in root.find('VENDORS').iter('VENDOR'):
776
                    item = QEngineeringVendorItem.fromXml(vendor)
777
                    if item and item.pack_type =='Equipment Package':
778
                        self.pre_data['Equipment Package'].append(item)
779 762

  
780
        except Exception as ex:
781
            from App import App
782
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
783
                                                           sys.exc_info()[-1].tb_lineno)
784
            App.mainWnd().addMessage.emit(MessageType.Error, message)
763
    def load_equipment_package(self, drawing):
764
        from LoadCommand import LoadCommand
785 765

  
786
    def load_recognition_data_from_db(self, drawing):
787
        from EngineeringVendorItem import QEngineeringVendorItem
788
        
789 766
        try:
790
            app_doc_data = AppDocData.instance()
791

  
792
            components = app_doc_data.get_components(drawing.UID)
793

  
794
            # load equipment package
795
            for component in [component for component in components if
796
                              component['Name'] == 'VendorPackage' and component['SymbolType_UID'] == -1]:
797
                item = QEngineeringVendorItem.from_database(component)
798
                if item and item.pack_type =='Equipment Package':
799
                    self.pre_data['Equipment Package'].append(item)
800

  
767
            """load equipment package"""
768
            cmd = LoadCommand()
769
            cmd.execute((drawing, self.scene), symbol=False, text=False, line=False, unknown=False,
770
                        package=True ,update=False)
771
            """up to here"""
801 772
        except Exception as ex:
802 773
            from App import App
803 774
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
......
849 820
                app_doc_data.activeDrawing = drawing # matches[0] if matches else Drawing(None, app_doc_data.imgName, None)
850 821
                app_doc_data.activeDrawing.set_pid_source(Image.open(mainRes))
851 822

  
852
                # Load data from xml or db
853
                path = os.path.join(app_doc_data.getCurrentProject().getTempPath(), app_doc_data.imgName + '.xml')
854
                configs = app_doc_data.getConfigs('Data Load', 'Xml First')
855
                if configs and int(configs[0].value) >= 1 and os.path.isfile(path):
856
                    worker.load_recognition_data_from_xml(path)
857
                elif configs and int(configs[0].value) <= 1:
858
                    worker.load_recognition_data_from_db(app_doc_data.activeDrawing)
823
                # Load equipment package
824
                #worker.load_equipment_package(app_doc_data.activeDrawing)
859 825

  
860 826
                # remove not drawing area
861 827
                configs = app_doc_data.getConfigs('{} Equipment Desc Area'.format(app_doc_data.imgName))
......
1099 1065
                    """load texts"""
1100 1066
                    cmd = LoadCommand()
1101 1067
                    cmd.execute((drawing, worker.scene), symbol=False, text=True, line=False, unknown=False,
1102
                                update=False)
1068
                                package=False, update=False)
1103 1069
                    """up to here"""
1104 1070
                    textItems = [item for item in worker.scene.items() if issubclass(type(item), QEngineeringTextItem)]
1105 1071
                    app_doc_data.texts.extend(textItems)
......
1341 1307
        from EngineeringTextItem import QEngineeringTextItem
1342 1308
        from EngineeringLineItem import QEngineeringLineItem
1343 1309
        from LineDetector import LineDetector
1310
        from EngineeringVendorItem import QEngineeringVendorItem
1344 1311

  
1345 1312
        try:
1346 1313
            listWidget.addItem('Starting line recognition')
......
1356 1323
            if area is not None:
1357 1324
                area.img = app_doc_data.imgSrc[round(area.y + 1):round(area.y + area.height),
1358 1325
                            round(area.x + 1):round(area.x + area.width)]
1326

  
1327
                for item in worker.scene.items():
1328
                    if issubclass(type(item), QEngineeringVendorItem) and item.pack_type =='Equipment Package':
1329
                        points = []
1330
                        for conn in item.connectors:
1331
                            points.append([conn.center()[0] - area.y, conn.center()[1] - area.y])
1332
                        
1333
                        points = np.array(points, np.int32)
1334
                        cv2.fillConvexPoly(area.img, points, 255)
1335
                #cv2.imshow('aa', area.img)
1336
                #cv2.waitKey(0)
1337
                #cv2.destroyAllWindows()
1338

  
1359 1339
            area.img = worker.remove_small_objects(area.img)
1360 1340
            detector = LineDetector(area.img)
1361 1341

  
......
2396 2376
        else:
2397 2377
            self.ui.checkBoxTraining.setVisible(False)
2398 2378

  
2399
        if len(self.path) == 1 and appDocData.activeDrawing and appDocData.activeDrawing.file_path == self.path[0]:
2379
        if False:#len(self.drawings) == 1 and appDocData.activeDrawing and appDocData.activeDrawing == self.drawings[0]:
2400 2380
            self.ui.checkBoxSymbol.setCheckState(Qt.Checked)
2401 2381
            self.ui.lineCheckBox.setCheckState(Qt.Unchecked)
2402 2382
            self.ui.checkBoxText.setCheckState(Qt.Unchecked)
......
2404 2384
            self.ui.checkBoxSymbol.setCheckState(Qt.Checked)
2405 2385
            self.ui.lineCheckBox.setCheckState(Qt.Checked)
2406 2386
            self.ui.checkBoxText.setCheckState(Qt.Checked)
2407
            self.ui.checkBoxSymbol.setEnabled(False)
2408
            self.ui.lineCheckBox.setEnabled(False)
2409
            self.ui.checkBoxText.setEnabled(False)
2387
            #self.ui.checkBoxSymbol.setEnabled(False)
2388
            #self.ui.lineCheckBox.setEnabled(False)
2389
            #self.ui.checkBoxText.setEnabled(False)
2410 2390

  
2411 2391
        self.ui.progressBarBatch.setFormat('{}/{}'.format('0', str(len(self.drawings))))
2412 2392

  
......
2638 2618
        app_doc_data = AppDocData.instance()
2639 2619

  
2640 2620
        try:
2641
            for key, items in self.obj.pre_data.items():
2642
                for item in items:
2643
                    if issubclass(type(item), QEngineeringVendorItem):
2644
                        app_doc_data.symbols.append(item)
2645
                        app_doc_data.allItems.append(item)
2621
            for item in scene.items():
2622
                if issubclass(type(item), QEngineeringVendorItem):
2623
                    app_doc_data.symbols.append(item)
2624
                    app_doc_data.allItems.append(item)
2646 2625

  
2647 2626
            # symbol need to be attached for scene position
2648 2627
            for symbol in app_doc_data.symbols:
......
2665 2644
                rect = symbol.sceneBoundingRect()
2666 2645
                rect.adjust(-10, -10, 10, 10)
2667 2646
                matches = [line for line in app_doc_data.lines if rect.contains(line.line().p1()) and
2668
                           rect.contains(line.line().p2()) and not line.has_connection]
2647
                           rect.contains(line.line().p2())]# and not line.has_connection]
2669 2648
                for line in matches:
2670 2649
                    app_doc_data.allItems.remove(line)
2671 2650
                    app_doc_data.lines.remove(line)
DTI_PID/DTI_PID/TextItemFactory.py
120 120
                            rgb = data.split(',')
121 121
                            item.change_color(QColor(int(rgb[0]), int(rgb[1]), int(rgb[2])).name())
122 122
                    # up to here
123
                docData.tracerLineNos.append(item)
123
                #docData.tracerLineNos.append(item)
124 124
            elif tagResult[0]:
125 125
                item = QEngineeringTagNoTextItem()
126 126
                item.setToolTip('TAG NO = {}'.format(text))
......
152 152
                    item.setToolTip(text)
153 153
                    item.setPlainText(text)
154 154
                    item.special_item_type = SpecialItemTypes.instance().find_match_exactly(item)
155
                docData.texts.append(item)
155
                #docData.texts.append(item)
156 156
        except Exception as ex:
157 157
            from App import App
158 158
            from AppDocData import MessageType

내보내기 Unified diff

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