프로젝트

일반

사용자정보

개정판 afabd84e

IDafabd84e6fbb459b937e153225b4503755bea45d
상위 1df9adbf
하위 d77477f8

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

issue #622:
- change save logic

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
104 104
        self.texts = []
105 105
        self.symbols = []
106 106
        self._colors = None
107
        self._lineNoProperties = None
107 108
        self._lineTypes = None
108 109
        self._lineTypeConfigs = None
109 110
        self._activeDrawing = None
......
738 739
    def getLineProperties(self):
739 740
        from SymbolAttr import SymbolAttr
740 741

  
741
        res = []
742
        try:
743
            # Creates or opens a file called mydb with a SQLite3 DB
744
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
745
            db = sqlite3.connect(dbPath)
746
            # Get a cursor object
747
            cursor = db.cursor()
742
        res = None
743
        if self._lineNoProperties is None:
744
            try:
745
                self._lineNoProperties = []
748 746

  
749
            sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]" 
750
            cursor.execute(sql)
751
            rows = cursor.fetchall()
752
            for row in rows:
753
                attr = SymbolAttr()
754
                attr.UID = row[0]
755
                attr.Attribute = row[1]
756
                attr.DisplayAttribute = row[2]
757
                attr.AttributeType = row[3]
758
                attr.Length = row[4]
759
                res.append(attr)
760
        # Catch the exception
761
        except Exception as ex:
762
            # Roll back any change if something goes wrong
763
            db.rollback()
764
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
765
        finally:
766
            # Close the db connection
767
            db.close()
747
                # Creates or opens a file called mydb with a SQLite3 DB
748
                dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
749
                db = sqlite3.connect(dbPath)
750
                # Get a cursor object
751
                cursor = db.cursor()
752

  
753
                sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]" 
754
                cursor.execute(sql)
755
                rows = cursor.fetchall()
756
                for row in rows:
757
                    attr = SymbolAttr()
758
                    attr.UID = row[0]
759
                    attr.Attribute = row[1]
760
                    attr.DisplayAttribute = row[2]
761
                    attr.AttributeType = row[3]
762
                    attr.Length = row[4]
763
                    self._lineNoProperties.append(attr)
764
                
765
                res = self._lineNoProperties
766
            # Catch the exception
767
            except Exception as ex:
768
                # Roll back any change if something goes wrong
769
                db.rollback()
770
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
771
            finally:
772
                # Close the db connection
773
                db.close()
774
        else:
775
            res = self._lineNoProperties
768 776

  
769 777
        return res
770 778

  
......
1815 1823
                cursor.execute(sql, param)
1816 1824

  
1817 1825
            conn.commit()
1826

  
1827
            self._lineNoProperties = None
1818 1828
            # Catch the exception
1819 1829
        except Exception as ex:
1820 1830
            # Roll back any change if something goes wrong
DTI_PID/DTI_PID/Commands/AreaOcrCommand.py
15 15
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '\\Shapes')
16 16
from EngineeringTextItem import QEngineeringTextItem
17 17
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
18
from QEngineeringNoteItem import QEngineeringNoteItem
18
from EngineeringNoteItem import QEngineeringNoteItem
19 19
from TextItemFactory import TextItemFactory
20 20
from AppDocData import AppDocData
21 21
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
DTI_PID/DTI_PID/ConfigurationDialog.py
213 213
        try:
214 214
            dlg = QSymbolAttrEditorDialog(self)
215 215
            dlg.exec_()
216

  
217 216
        except Exception as ex:
218 217
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
219 218

  
DTI_PID/DTI_PID/ItemDataExportDialog.py
827 827
            text = item.text()
828 828
            self.sceneLineData[text] = item.getLineDataList()
829 829

  
830
        from QEngineeringEquipmentItem import QEngineeringEquipmentItem
830
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
831 831
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringEquipmentItem]
832 832
        for item in items:
833 833
            self.sceneEquipData[str(item.uid)] = item.getEquipmentDataList()
......
842 842
        for item in items:
843 843
            self.sceneInstData[str(item.uid)] = item.getInstrumentDataList()
844 844

  
845
        from QEngineeringNoteItem import QEngineeringNoteItem
845
        from EngineeringNoteItem import QEngineeringNoteItem
846 846
        items = [item for item in self.parent.graphicsView.scene.items() if type(item) is QEngineeringNoteItem]
847 847
        for item in items:
848 848
            loopIndex = 1
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
19 19
from SymbolSvgItem import SymbolSvgItem
20 20
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
21 21
from EngineeringLineItem import QEngineeringLineItem
22
from QEngineeringNoteItem import QEngineeringNoteItem
22
from EngineeringNoteItem import QEngineeringNoteItem
23 23
from EngineeringTextItem import QEngineeringTextItem
24 24
from UserInputAttribute import UserInputAttribute
25 25
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
......
216 216
                widgetItem = QTableWidgetItem("노트번호")
217 217
                self.setItem(0, 0, widgetItem)
218 218
            elif type(item) is QEngineeringLineNoTextItem:
219
                '''
220
                DO NOTHING / initLineNoCell
221
                '''
219
                self.setRowCount(1)
220
                self.setItem(0, 0, QTableWidgetItem("UID"))
222 221
            elif type(item) is QEngineeringLineItem:
223 222
                self.setRowCount(6)
224 223

  
......
434 433
    '''
435 434
    def initLineNoCell(self, lineNoItem):
436 435
        appDocData = AppDocData.instance()
436
        configs = appDocData.getConfigs('Line No', 'Configuration')
437
        configs = configs[0].value.split('"-"')
437 438

  
438 439
        self.attrValueList = []
439 440
        self.stringCell = []
440 441

  
441
        attrItems = lineNoItem.getAttributes()
442
        self.setRowCount(len(attrItems))
442
        item = QTableWidgetItem(str(lineNoItem.uid))
443
        item.setFlags(Qt.ItemIsEnabled)
444
        self.setItem(0, 1, item)
443 445

  
444
        if attrItems is not None:
445
            attrs = list(attrItems.items())
446
            for index in range(len(attrs)):
447
                key = attrs[index][0]
448
                value = attrs[index][1]
446
        row = self.rowCount()
449 447

  
450
                keyStr = appDocData.getLinePropertiesByUID(key)
448
        attrs = lineNoItem.getAttributes()
449
        self.setRowCount(row + len(attrs))
450
        if attrs is not None:
451
            for key in attrs.keys():
452
                item = QTableWidgetItem(key.DisplayAttribute if key.DisplayAttribute else key.Attribute)
453
                item.setFlags(Qt.ItemIsEnabled)
454
                item.setBackground(QColor(220, 220, 220))
455
                item.tag = key
456
                self.setItem(row, 0, item)
451 457

  
452 458
                # value cell
459
                value = attrs[key]
453 460
                valueCell = QTableWidgetItem(value)
454 461

  
455 462
                # UID로 확인
463
                keyStr = appDocData.getLinePropertiesByUID(key.UID)
456 464
                if keyStr:
457 465
                    # editable value cell
458 466
                    if keyStr[0].AttributeType == 'String':
459
                        self.attrValueList.append((valueCell, key))
467
                        self.attrValueList.append((valueCell, key.Attribute))
460 468
                        self.stringCell.append(valueCell)
461
                    key = keyStr[0].DisplayAttribute
469
                    if keyStr[0].UID in configs: valueCell.setFlags(Qt.ItemIsEnabled)
470
                else:
471
                    valueCell.setFlags(Qt.ItemIsEnabled)
462 472
                 
463
                item = QTableWidgetItem(key)
464
                item.setFlags(Qt.ItemIsEnabled)
465
                item.setBackground(QColor(220, 220, 220))
466
                self.setItem(index, 0, item)
467

  
468
                if key == 'Stream No':
473
                if key.Attribute == 'Stream No':
469 474
                    self.streamNoComboBox = QComboBox()
470 475
                    self.streamNoComboBox.tag = lineNoItem
471 476
                    self.streamNoComboBox.currentIndexChanged.connect(self.onStreamNoChanged)
......
473 478
                    streamNos = sorted(list(appDocData.hmbTable.streamNos()))
474 479
                    for streamNo in streamNos:
475 480
                        self.streamNoComboBox.addItem(streamNo)
476
                    self.setCellWidget(index, 1, self.streamNoComboBox)
481
                    self.setCellWidget(row, 1, self.streamNoComboBox)
477 482
                    self.streamNoComboBox.setCurrentText(value)
478 483
                else:
479 484
                    ## 만약 Key 값이 CONN이면
480
                    if key == 'CONN':
485
                    if key.Attribute == 'CONN':
481 486
                        from PyQt5 import QtGui
482 487
                        icon = QtGui.QIcon()
483 488
                        icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
484 489
                        valueCell.setIcon(icon)
485
                    self.setItem(index, 1, valueCell)
490

  
491
                self.setItem(row, 1, valueCell)
492

  
493
                row = row + 1
486 494

  
487 495
    '''
488 496
        @brief  change selected lines' stream no by selected stream no
......
528 536
        @date       2018.08.20
529 537
    '''
530 538
    def cellChangedEvent(self, row, column):
539
        cell = self.item(row, 0)
540
        if not hasattr(cell, 'tag'): return
541

  
542
        key = self.item(row, 0).tag
531 543
        cell = self.item(row, column)
544
        
545
        items = self.mainWindow.graphicsView.scene.selectedItems()
546
        if items is not None and len(items) == 1:
547
            if type(items[0]) is QEngineeringLineNoTextItem:
548
                items[0].setAttribute(key, cell.text())
549
                #param = [param for param in items[0].attrs.keys() if param.UID == key.UID]
550
                #if param:
551
                return
552

  
553
        """
532 554
        for valueCell in self.attrValueList:
533 555
            if valueCell[0] == cell and (self.intCell.count(cell) or self.stringCell.count(cell)):
534 556
                items = self.mainWindow.graphicsView.scene.selectedItems()
......
560 582
                        for attr in items[0].attrs:
561 583
                            if type(attr) is UserInputAttribute and attr.attribute == typeUID:
562 584
                                attr.text = str
563
                                
585
        """
586
                                    
564 587
    '''
565 588
        @brief      Check Number
566 589
        @author     kyouho
......
575 598
        else:
576 599
            return False
577 600

  
578

  
579 601
    '''
580 602
        @brief      resultPropertyTableWidget Cell Double Click Event
581 603
        @author     kyouho
......
592 614
                    cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
593 615
                    cmd.onSuccess.connect(self.onSuccessSelectAttribute)
594 616
                    self.mainWindow.graphicsView.command = cmd
595

  
596 617
                else:
597 618
                    self.editItem(self.item(row, 1))
598

  
599 619
            elif keyCell.text() == 'CONN' and type(items[0]) is QEngineeringLineNoTextItem:
600 620
                from SymbolAttr import SymbolAttr
601 621
                attr = SymbolAttr()
......
603 623
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
604 624
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
605 625
                self.mainWindow.graphicsView.command = cmd
626
            elif Qt.ItemIsEnabled is not self.item(row, column):
627
                self.editItem(self.item(row, column))
606 628

  
607 629
    '''
608 630
        @brief      success select attribute 
DTI_PID/DTI_PID/ItemTreeWidget.py
16 16
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
17 17
from SymbolSvgItem import SymbolSvgItem
18 18
from EngineeringTextItem import QEngineeringTextItem
19
from QEngineeringNoteItem import QEngineeringNoteItem
19
from EngineeringNoteItem import QEngineeringNoteItem
20 20
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
21
from QEngineeringEquipmentItem import QEngineeringEquipmentItem
21
from EngineeringEquipmentItem import QEngineeringEquipmentItem
22 22
from EngineeringInstrumentItem import QEngineeringInstrumentItem
23 23
from QEngineeringTrimLineNoTextItem import QEngineeringTrimLineNoTextItem
24 24
from EngineeringUnknownItem import QEngineeringUnknownItem
DTI_PID/DTI_PID/MainWindow.py
36 36
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
37 37
from EngineeringTextItem import QEngineeringTextItem
38 38
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
39
from QEngineeringNoteItem import QEngineeringNoteItem
39
from EngineeringNoteItem import QEngineeringNoteItem
40 40
from QEngineeringSizeTextItem import QEngineeringSizeTextItem
41 41
from EngineeringUnknownItem import QEngineeringUnknownItem
42
from QEngineeringEquipmentItem import QEngineeringEquipmentItem
42
from EngineeringEquipmentItem import QEngineeringEquipmentItem
43 43
from EngineeringInstrumentItem import QEngineeringInstrumentItem
44 44
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
45 45
from AppDocData import *
......
188 188
        self.actionFindReplaceText.triggered.connect(self.findReplaceTextClicked)
189 189
        self.pushButtonDetectSymbol.clicked.connect(self.onShowDetectSymbol)
190 190
        self.actionOCR_Training.triggered.connect(self.oCRTrainingClicked)
191
        #self.actionOCR_Training_Editor.triggered.connect(self.oCRTrainingEdidorClicked)
192 191

  
193 192
        # removedItems
194 193
        self.removedItems = {}
......
396 395
        for item in items:
397 396
            if type(item) is QEngineeringLineNoTextItem:
398 397
                item.saveLineData()
399
            if type(item) is QEngineeringEquipmentItem:
400
                item.saveEquipData()
401
            if type(item) is QEngineeringNoteItem:
402
                item.saveNoteData()
403
        appDocData.saveToDatabase([item for item in items if type(item) is QEngineeringInstrumentItem])
398

  
399
        appDocData.saveToDatabase([item for item in items if type(item) is QEngineeringInstrumentItem or type(item) is QEngineeringEquipmentItem or\
400
        type(item) is QEngineeringNoteItem])
404 401

  
405 402
        self.saveToXml(True)
406 403

  
......
1176 1173
                    2018.11.05  euisung     add db delete process before save
1177 1174
    '''
1178 1175
    def drawDetectedItems(self, symbolList, textInfoList, otherTextInfoList):
1179
        appDocData = AppDocData.instance()
1180
        appDocData.deleteDataListBeforeSave()
1176
        try:
1177
            appDocData = AppDocData.instance()
1178
            appDocData.deleteDataListBeforeSave()
1181 1179

  
1182
        QApplication.processEvents()
1183
        self.drawDetectedSymbolItem(symbolList)
1184
        QApplication.processEvents()
1185
        self.drawDetectedTextItem(textInfoList)
1186
        QApplication.processEvents()
1187
        self.drawDetectedOtherTextItem(otherTextInfoList)
1180
            QApplication.processEvents()
1181
            self.drawDetectedSymbolItem(symbolList)
1182
            QApplication.processEvents()
1183
            self.drawDetectedTextItem(textInfoList)
1184
            QApplication.processEvents()
1185
            self.drawDetectedOtherTextItem(otherTextInfoList)
1188 1186

  
1189
        # save note item
1190
        items = self.graphicsView.scene.items()
1191
        for item in items:
1192
            if type(item) is QEngineeringNoteItem:
1193
                item.saveNoteData()
1187
            appDocData.deleteDataListBeforeSave()
1188

  
1189
            items = self.graphicsView.scene.items()
1190
            for item in items:
1191
                if type(item) is QEngineeringLineNoTextItem:
1192
                    item.saveLineData()
1194 1193

  
1195
        # Update Scene
1196
        self.graphicsView.scene.update(self.graphicsView.sceneRect())
1194
            appDocData.saveToDatabase([item for item in items if type(item) is QEngineeringInstrumentItem or type(item) is QEngineeringEquipmentItem or\
1195
            type(item) is QEngineeringNoteItem])
1196

  
1197
            self.saveToXml(False)
1198

  
1199
            # update scene
1200
            self.graphicsView.scene.update(self.graphicsView.sceneRect())
1201
        except Exception as ex:
1202
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1203
            self.addMessage.emit(MessageType.Error, message)
1197 1204

  
1198 1205
    '''
1199 1206
        @brief      
......
1262 1269

  
1263 1270
                    svg.transfer.onRemoved.connect(self.itemRemoved)
1264 1271
                    self.addSvgItemToScene(svg)
1265
                    
1266
                    # Equipment Item 경우 저장
1267
                    if type(svg) is QEngineeringEquipmentItem:
1268
                        svg.saveEquipData()
1269

  
1270
                    # Instrument Item 경우 저장
1271
                    if type(svg) is QEngineeringInstrumentItem:
1272
                        svg.saveInstData()
1273 1272
                else:
1274 1273
                    item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1])
1275 1274
                    item.isSymbol = True
......
1312 1311
                    item.transfer.onRemoved.connect(self.itemRemoved)
1313 1312
                    self.addTextItemToScene(item)
1314 1313
                    appDocData.texts.append(item)
1315

  
1316
                    # Line No Text Item 경우 저장
1317
                    if type(item) is QEngineeringLineNoTextItem:
1318
                        item.saveLineData()
1319
                    ## Note Text Item 경우 저장
1320
                    #if type(item) is QEngineeringNoteItem:
1321
                    #    item.saveNoteData()
1322 1314
        except Exception as ex:
1323 1315
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1324 1316
            self.addMessage.emit(MessageType.Error, message)
......
1360 1352
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
1361 1353
            self.addMessage.emit(MessageType.Error, message)
1362 1354

  
1363

  
1364 1355
    '''
1365 1356
        @brief  draw unknown items 
1366 1357
        @author humkyung
......
1568 1559
                    self.addTextItemToScene(item)
1569 1560

  
1570 1561
                    # attr
1562
                    """
1571 1563
                    for userInputAttr in lineNo.iter('USERINPUTATTRIBUTE'):
1572 1564
                        newAttr = UserInputAttribute(userInputAttr.find('TYPEUID').text, userInputAttr.find('TYPEVALUE').text)
1573 1565
                        item.attrs.append(newAttr)
1574 1566
                    for attr in lineNo.iter('ATTRIBUTE'):
1575 1567
                        item.attrs[docData.getLinePropertiesByUID(attr.find('UID').text)[0]] = attr.find('VALUE').text
1576

  
1568
                    """
1577 1569
                connLine = lineNo.find('CONNLINE')
1578 1570
                if connLine is not None:
1579 1571
                    lineUID = connLine.text
DTI_PID/DTI_PID/READ ME.txt
170 170
- EngineeringTextItem ���� �� �ʿ��� �����͸� �����Ͽ�, �ش� �����Ϳ� �´� Ÿ���� �������� ��ȯ
171 171
- ���� ������ ������ ��� (2018.06.28 ����)
172 172

  
173
	[1] QEngineeringNoteItem
173
	[1] EngineeringNoteItem
174 174
	[2] QEngineeringLineNoItem
175 175
	[3] QEngineeringSizeTextItem
176 176
	[4] QEngineeringTagNoTextItem
DTI_PID/DTI_PID/Scripts/INSTRUMENT_DATA_LIST.sql
5 5
	FLOW_RATE TEXT,
6 6
	PRESSURE TEXT,
7 7
	TEMPERATURE TEXT,
8
	TPYE TEXT,
8
	TYPE TEXT,
9 9
	RANGE TEXT,
10 10
	NOR_LEVEL_MM TEXT,
11 11
	NOR_LEVEL_PERCENT TEXT,
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py
1
# coding: utf-8
2

  
3
import sys
4
import os
5
import math
6
from PyQt5.QtGui import *
7
from PyQt5.QtCore import *
8
from PyQt5.QtSvg import *
9
from PyQt5.QtWidgets import (QApplication, QGraphicsItem)
10

  
11
from SymbolSvgItem import SymbolSvgItem
12
from EngineeringConnectorItem import QEngineeringConnectorItem
13
from EngineeringTextItem import QEngineeringTextItem
14
from UserInputAttribute import UserInputAttribute
15

  
16
equipColumnList = ['UID', 'ITEM_NO', 'SERVICE', 'NO_REQ', 'FLUID', 'DESC_OF_PART', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'MATERIAL', 'WEIGHT', 'POWER', 'INSULATION', 'PNID_NO', 'REV']
17

  
18
class QEngineeringEquipmentItem(SymbolSvgItem):
19
    clicked = pyqtSignal(QGraphicsSvgItem)
20
    ZVALUE = 10
21

  
22
    '''
23
    '''
24
    def __init__(self, path, uid=None):
25
        SymbolSvgItem.__init__(self, path, uid)
26
        self.setZValue(QEngineeringEquipmentItem.ZVALUE)
27

  
28
    '''
29
        @brief  connect attribute
30
        @author humkyung
31
        @date   2018.05.03
32
    '''
33
    def connectAttribute(self, attributes):
34
        from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
35

  
36
        self._texts.clear()
37

  
38
        """
39
        rect = self.sceneBoundingRect()
40
        attrs = [attr for attr in attributes if type(attr) is QEngineeringTagNoTextItem]
41
        # check if text locates inside equipment
42
        for attr in attrs:
43
            if rect.contains(attr.center()):
44
                self.attrs.append(attr)
45
                attrs.remove(attr)
46
                break
47
        
48
        if not self.attrs:
49
            minDist = None
50
            selected = None
51
            # get nearest text from equipment
52
            for attr in attrs:
53
                dx = attr.center().x() - rect.center().x()
54
                dy = attr.center().y() - rect.center().y()
55
                dist = math.sqrt(dx*dx + dy*dy)
56
                if (minDist is None) or (dist < minDist):
57
                    minDist = dist
58
                    selected = attr
59
            
60
            if selected is not None: self.attrs.append(selected)
61
        """
62

  
63
        try:
64
            rect = self.sceneBoundingRect()
65
            attrs = [attr for attr in attributes if type(attr) is QEngineeringTagNoTextItem]
66
            for attr in attrs:
67
                if rect.contains(attr.center()):
68
                    self._texts.append(attr)
69

  
70
            if not self._texts:
71
                minDist = None
72
                selected = None
73
                # get nearest text from equipment
74
                for attr in attrs:
75
                    dx = attr.center().x() - rect.center().x()
76
                    dy = attr.center().y() - rect.center().y()
77
                    dist = math.sqrt(dx*dx + dy*dy)
78
                    if (minDist is None) or (dist < minDist):
79
                        minDist = dist
80
                        selected = attr
81
            
82
                if selected is not None: self._texts.append(selected)
83

  
84
            self._texts = sorted(self._texts, key=lambda attr: attr.loc[1])    # sort by y coordinate
85
        except Exception as ex:
86
            from App import App 
87
            from AppDocData import MessageType
88

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

  
92
    '''
93
        @brief      get attributes
94
        @author     humkyung
95
        @date       2018.06.14
96
    '''
97
    def getAttributes(self):
98
        _attrs = {}
99
        try:
100
            from AppDocData import AppDocData
101
            from EngineeringTextItem import QEngineeringTextItem
102

  
103
            # 해당 Type의 attribute setting
104
            docData = AppDocData.instance()
105
            symbolAttrs = docData.getSymbolAttribute(self.type)
106
            for attr in symbolAttrs:
107
                if attr.AttributeType == 'Text Item':
108
                    at = int(attr.AttrAt)
109
                    if len(self._texts) > at:
110
                        item = self._texts[at]
111
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
112
                    else:
113
                        _attrs[attr] = ''
114
                elif attr.AttributeType == 'Symbol Item':
115
                    at = int(attr.AttrAt)
116
                    if len(self._symbols) > at:
117
                        item = self._symbols[at]
118
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
119
                    else:
120
                        _attrs[attr] = ''
121
                else:
122
                    _attrs[attr] = ''#self.attrs[attr[1]] if attr[1] in self.attrs.keys() else ''
123
        except Exception as ex:
124
            from App import App 
125
            from AppDocData import MessageType
126

  
127
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
128
            App.mainWnd().addMessage.emit(MessageType.Error, message)
129
        
130
        return _attrs
131

  
132
    '''
133
        @brief      generate xml code for equipment
134
        @author     humkyung
135
        @date       2018.05.09
136
    '''
137
    def toXml(self):
138
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
139

  
140
        try:
141
            node = SymbolSvgItem.toXml(self)
142
            self.toXmlAsAttribute(node)
143
        except Exception as ex:
144
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
145

  
146
        return node 
147

  
148
    '''
149
        @brief  generate xml code for attribute
150
        @author humkyung
151
        @date   2018.05.03
152
    '''
153
    def toXmlAsAttribute(self, parentNode):
154
        for attr in self._texts:
155
            parentNode.append(attr.toXml(self, None))
156

  
157
    def toSql(self):
158
        """
159
        convert equipment data to sql query
160
        """
161
        from AppDocData import AppDocData
162

  
163
        appDocData = AppDocData.instance()
164

  
165
        cols = ['UID', 'PNID_NO']
166
        values = ['?','?']
167
        param = [str(self.uid), appDocData.activeDrawing.name]
168
        _attrs = self.getAttributes()
169
        for key in _attrs.keys():
170
            cols.append(key.Attribute)
171
            values.append('?')
172
            param.append(_attrs[key])
173

  
174
        sql = 'insert or replace into EQUIPMENT_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
175
        return (sql, tuple(param))
176

  
177
    '''
178
        @brief      return equip Data List
179
        @author     kyouho
180
        @date       2018.08.14
181
    '''
182
    def getEquipmentDataList(self):
183
        dataList = []
184
        try:
185
            from AppDocData import AppDocData
186

  
187
            global equipColumnList
188

  
189
            docData = AppDocData.instance()
190
            attrs = self.attrs
191

  
192
            for index in range(len(equipColumnList)):
193
                dataList.append('')
194

  
195
            dataList[0] = str(self.uid)
196
            dataList[14] = docData.imgName
197

  
198
            for attr in attrs:
199
                attrInfo = docData.getSymbolAttributeByUID(attr.attribute)
200
                attrName = attrInfo[0]
201
                if equipColumnList.count(attrName):
202
                    colIndex = equipColumnList.index(attrName)
203
                    
204
                    if type(attr) is UserInputAttribute:
205
                        dataList[colIndex] = attr.text if attr.text is not None else ''
206
                    elif type(attr) is QEngineeringTextItem:
207
                        dataList[colIndex] = attr.text()
208
                    else:
209
                        dataList[colIndex] = attr.uid
210
            
211
        except Exception as ex:
212
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
213

  
214
        return dataList
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py
274 274
        return (sql, tuple(param))
275 275

  
276 276
    '''
277
        @brief      save inst Data
278
        @author     kyouho
279
        @date       2018.08.16
280
    '''
281
    def saveInstData(self):
282
        try:
283
            from AppDocData import AppDocData
284

  
285
            docData = AppDocData.instance()
286
            docData.setInstrumentDataList([self.getInstrumentDataList()])
287
        except Exception as ex:
288
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
289
            return str(self.uid)
290

  
291
    '''
292 277
        @brief      return inst Data List
293 278
        @author     kyouho
294 279
        @date       2018.08.14
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
28 28
        @history    18.05.14    Jeongwoo    Add variable self.runs
29 29
                    humkyung 2018.07.09 add stream no
30 30
    '''
31
    def __init__(self, parent=None):
32
        QEngineeringTextItem.__init__(self, parent)
31
    def __init__(self, uid=None, parent=None):
32
        QEngineeringTextItem.__init__(self, uid, parent)
33 33
        self._runs = []
34 34

  
35 35
    '''
......
72 72
        @author     humkyung
73 73
        @date       2018.07.20
74 74
    '''
75
    def setAttribute(self, name, value):
76
        matches = [attr for attr in self._attrs if attr[0] == name]
75
    def setAttribute(self, key, value):
76
        matches = [attr for attr in self.attrs if attr.UID == key.UID]
77 77
        if len(matches) == 1:
78
            matches[0][1] = value
78
            self.attrs[matches[0]] = value
79
        else:
80
            self.attrs[key] = value
79 81

  
80 82
    '''
81 83
        @brief      get attribute
......
83 85
        @date       2018.09.06
84 86
    '''
85 87
    def getAttributes(self):
86
        attrs = {}
87
        attrs['Line No'] = self.uid
88
        from SymbolAttr import SymbolAttr
89

  
90
        _attrs = {}
88 91
        try:
89 92
            docData = AppDocData.instance()
90 93
            lineNoconfigs = docData.getConfigs('Line No', 'Configuration')
......
92 95
            item = TextItemFactory.instance().isLineNo(self.text())
93 96
            # Line No 부분
94 97
            if item[0]:
98
                attr = SymbolAttr()
99
                attr.Attribute = 'LINE NO'
100
                attr.DisplayAttribute = 'Line No'
101
                attr.AttributeType = 'String'
102
                _attrs[attr] = self.text()
103

  
95 104
                result = item[1]
96 105
                configs = lineNoconfigs[0].value.split(self.delimiter)
97
                lineAttrs = docData.getLineProperties()
98
                for lineAttr in lineAttrs:
99
                    if lineAttr.AttributeType == 'String':
100
                        find = False
101
                        for attr in self.attrs:
102
                            if type(attr) is UserInputAttribute and attr.attribute == lineAttr.UID:
103
                                find = True
104
                                break
105
                        if not find:
106
                            newAttr = UserInputAttribute(lineAttr.UID, '')
107
                            self.attrs[lineAttr] = ''
108

  
109
                        attrs[lineAttr.UID] = ''
110
                    else:
106
                props = docData.getLineProperties()
107
                for prop in props:
108
                    if prop.UID in configs:
111 109
                        for i in range(len(configs)):
112
                            if lineAttr.UID == configs[i]:
113
                                attrs[lineAttr.UID] = result[i]
110
                            if prop.UID == configs[i]:
111
                                _attrs[prop] = result[i]
114 112
                                break
113
                    else:
114
                        matches = [attr for attr in self.attrs if attr.UID == prop.UID]
115
                        if len(matches) == 1:
116
                            _attrs[matches[0]] = self.attrs[matches[0]]
117
                        else:
118
                            _attrs[prop] = ''
115 119

  
116
            for attr in self.attrs:
117
                if type(attr) is UserInputAttribute:
118
                    attrs[attr.attribute] = attr.text
119

  
120
            attrs['CONN'] = self.conns[0].uid if self.conns else ''
120
#            attrs['CONN'] = self.conns[0].uid if self.conns else ''
121 121
        except Exception as ex:
122 122
            from App import App
123 123
            from AppDocData import MessageType
......
125 125
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
126 126
            App.mainWnd().addMessage.emit(MessageType.Error, message)
127 127
        
128
        return attrs
128
        return _attrs
129 129

  
130 130
    '''
131 131
        @brief      generate xml code
......
179 179
                node.append(run.toXml())
180 180

  
181 181
            for key in self.attrs.keys():
182
                if type(key) is not UserInputAttribute:
183
                    attrNode = Element('ATTRIBUTE')
184

  
185
                    uidNode = Element('UID')
186
                    uidNode.text = str(key.UID)
187
                    attrNode.append(uidNode)
188

  
189
                    nameNode = Element('NAME')
190
                    nameNode.text = str(key.Attribute)
191
                    attrNode.append(nameNode)
192

  
193
                    valueNode = Element('VALUE')
194
                    valueNode.text = str(self.attrs[key])
195
                    attrNode.append(valueNode)
196

  
197
                    node.append(attrNode) 
198
                else:
199
                    node.append(key.toXml())
182
                attrNode = key.toXml()
183
                attrNode.text = str(self.attrs[key])
184
                node.append(attrNode) 
200 185
           
201 186
            if self.conns:
202 187
                connNode = Element('CONNLINE')
......
275 260

  
276 261
            for key in attrs.keys():
277 262
                if type(key) is not UserInputAttribute:
278
                    lineProp = docData.getLinePropertiesByUID(key)
263
                    lineProp = docData.getLinePropertiesByUID(key.UID)
279 264
                    if lineProp:
280 265
                        attrName = lineProp[0].Attribute.upper().replace(' ','')
281 266
                    else:
282
                        attrName = key.upper().replace(' ','')
267
                        attrName = key.Attribute.upper().replace(' ','')
283 268

  
284 269
                    data = attrs[key]
285 270
                    if attrName == 'NOMINALDIAMETER':
DTI_PID/DTI_PID/Shapes/EngineeringNoteItem.py
1
# coding: utf-8
2
import os.path
3
import copy
4
import sys
5
try:
6
    from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect
7
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont
8
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem
9
except ImportError:
10
    try:
11
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect
12
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont
13
    except ImportError:
14
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
15

  
16
from EngineeringPolylineItem import QEngineeringPolylineItem
17
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
18
import OcrResultDialog
19
from AppDocData import AppDocData
20
from EngineeringTextItem import QEngineeringTextItem
21
import re
22

  
23
noteColumnList = ['UID', 'NOTE_NO', 'DESCRIPTION', 'PNID_NO']
24

  
25
class QEngineeringNoteItem(QEngineeringTextItem):
26
    '''
27
        @history    2018.04.30  Jeongwoo    Signal Parameter Changed (QEngineeringTextItem → QGraphicsItem)
28
    '''
29
    #removed = pyqtSignal(QGraphicsItem)
30

  
31
    def __init__(self, parent=None):
32
        QEngineeringTextItem.__init__(self, parent)
33
        
34
        self.title = None
35
        self.conetents = None
36

  
37
    '''
38
        @brief      Find Note Contents by NOTE No.
39
        @author     Jeongwoo
40
        @date       2018.04.27
41
        @history    2018.04.27  Jeongwoo    Append Note contents to list
42
                                            else-statement changed, if text starts with new LineNo header, do break
43
                                            Moved from ResultTreeWidget
44
                    2018.05.02  Jeongwoo    Add if-statement. Append text to list when Regex start position is not 0
45
    '''
46
    def findNoteContents(self, noteNoText):
47
        # Get NoteArea
48
        notesArea = AppDocData.instance().getArea('Note')
49
        # Get all note contents
50
        items = self.scene().items(QRectF(notesArea.x, notesArea.y, notesArea.x + notesArea.width, notesArea.y + notesArea.height))
51
        items = [item for item in items if type(item) is QEngineeringTextItem] # Filtering QEngineeringTextItem
52
        items.sort(key=lambda item:item.loc[1]) # Compare with loc[1] (Y-Coord)
53
        foundNumberStr = None
54
        foundNote = []
55
        numberStr = ''
56
        results = re.findall("\d+", noteNoText)
57
        if results is not None and len(results) > 0:
58
            numberStr = results[0]
59
        for item in items:
60
            if type(item) is QEngineeringTextItem:
61
                text = item.text()
62
                if foundNumberStr is None: # Not found yet
63
                    try:
64
                        # Find NOTE Contents start with header [ex - 1. 1) 2. 2) ...]
65
                        position = re.search(numberStr+"(.|\))", text).start()
66
                        if position == 0: # Start with NOTE No.
67
                            foundNote.append(text)
68
                            foundNumberStr = numberStr
69
                    except Exception as ex:
70
                        '''NOT FOUND, DO NOTHING'''
71
                else:
72
                    try:
73
                        position = re.search("\d+(.|\))", text).start()
74
                        # If NOTE No starts with any number header, break
75
                        if position == 0:
76
                            break
77
                        else:
78
                            foundNote.append(text)
79
                    except Exception as ex:
80
                        foundNote.append(text)
81
        return foundNote
82

  
83
    def toSql(self):
84
        """
85
        convert note no data to sql query
86
        """
87
        from AppDocData import AppDocData
88

  
89
        appDocData = AppDocData.instance()
90

  
91
        cols = ['UID', 'NOTE_NO', 'DESCRIPTION', 'PNID_NO']
92
        values = ['?','?', '?', '?']
93

  
94
        noteContentsList = self.findNoteContents(self.text())
95
        param = [str(self.uid), ''.join(re.findall('\d*', self.text())), ' '.join(noteContentsList), appDocData.activeDrawing.name]
96

  
97
        sql = 'insert or replace into NOTE_DATA_LIST({}) values({})'.format(','.join(cols), ','.join(values))
98
        return (sql, tuple(param))
99

  
100
    '''
101
        @brief      return note Data List
102
        @author     kyouho
103
        @date       2018.10.10
104
    '''
105
    def getNoteDataList(self):
106

  
107
        dataList = []
108
        try:
109
            from AppDocData import AppDocData
110

  
111
            global noteColumnList
112

  
113
            docData = AppDocData.instance()
114

  
115
            noteContentsList = self.findNoteContents(self.text())
116

  
117
            loopIndex = 1
118
            for noteDescription in noteContentsList:
119
                data = []
120
                for index in range(len(noteColumnList)):
121
                    data.append('')
122

  
123
                data[0] = str(self.uid) + "-" + str(loopIndex)
124
                import re
125
                data[1] = ''.join(re.findall('\d*', self.text()))
126
                data[2] = noteDescription
127
                data[3] = docData.imgName
128

  
129
                dataList.append(data)
130

  
131
        except Exception as ex:
132
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
133

  
134
        return dataList
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
378 378
    def fromXml(node):
379 379
        from TextItemFactory import TextItemFactory
380 380
        from AppDocData import AppDocData
381
        from QEngineeringNoteItem import QEngineeringNoteItem
381
        from EngineeringNoteItem import QEngineeringNoteItem
382 382

  
383 383
        item = None
384 384

  
DTI_PID/DTI_PID/Shapes/QEngineeringEquipmentItem.py
1
# coding: utf-8
2

  
3
import sys
4
import os
5
import math
6
from PyQt5.QtGui import *
7
from PyQt5.QtCore import *
8
from PyQt5.QtSvg import *
9
from PyQt5.QtWidgets import (QApplication, QGraphicsItem)
10

  
11
from SymbolSvgItem import SymbolSvgItem
12
from EngineeringConnectorItem import QEngineeringConnectorItem
13
from EngineeringTextItem import QEngineeringTextItem
14
from UserInputAttribute import UserInputAttribute
15

  
16
equipColumnList = ['UID', 'ITEM_NO', 'SERVICE', 'NO_REQ', 'FLUID', 'DESC_OF_PART', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'MATERIAL', 'WEIGHT', 'POWER', 'INSULATION', 'PNID_NO', 'REV']
17

  
18
class QEngineeringEquipmentItem(SymbolSvgItem):
19
    clicked = pyqtSignal(QGraphicsSvgItem)
20
    ZVALUE = 10
21

  
22
    '''
23
    '''
24
    def __init__(self, path, uid=None):
25
        SymbolSvgItem.__init__(self, path, uid)
26
        self.setZValue(QEngineeringEquipmentItem.ZVALUE)
27

  
28
    '''
29
        @brief  connect attribute
30
        @author humkyung
31
        @date   2018.05.03
32
    '''
33
    def connectAttribute(self, attributes):
34
        from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
35

  
36
        self.attrs.clear()
37

  
38
        rect = self.sceneBoundingRect()
39
        attrs = [attr for attr in attributes if type(attr) is QEngineeringTagNoTextItem]
40
        # check if text locates inside equipment
41
        for attr in attrs:
42
            if rect.contains(attr.center()):
43
                self.attrs.append(attr)
44
                attrs.remove(attr)
45
                break
46
        
47
        if not self.attrs:
48
            minDist = None
49
            selected = None
50
            # get nearest text from equipment
51
            for attr in attrs:
52
                dx = attr.center().x() - rect.center().x()
53
                dy = attr.center().y() - rect.center().y()
54
                dist = math.sqrt(dx*dx + dy*dy)
55
                if (minDist is None) or (dist < minDist):
56
                    minDist = dist
57
                    selected = attr
58
            
59
            if selected is not None: self.attrs.append(selected)
60

  
61
    '''
62
        @brief      generate xml code for equipment
63
        @author     humkyung
64
        @date       2018.05.09
65
    '''
66
    def toXml(self):
67
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
68

  
69
        try:
70
            node = SymbolSvgItem.toXml(self)
71
            self.toXmlAsAttribute(node)
72
        except Exception as ex:
73
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
74

  
75
        return node 
76

  
77
    '''
78
        @brief  generate xml code for attribute
79
        @author humkyung
80
        @date   2018.05.03
81
    '''
82
    def toXmlAsAttribute(self, parentNode):
83
        for attr in self.attrs:
84
            parentNode.append(attr.toXml(self, None))
85

  
86
    '''
87
        @brief      save Line Data
88
        @author     kyouho
89
        @date       2018.08.14
90
    '''
91
    def saveEquipData(self):
92
        try:
93
            from AppDocData import AppDocData
94

  
95
            docData = AppDocData.instance()
96
            docData.setEquipmentDataList([self.getEquipmentDataList()])
97
        except Exception as ex:
98
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
99
            return str(self.uid)
100

  
101
    '''
102
        @brief      return equip Data List
103
        @author     kyouho
104
        @date       2018.08.14
105
    '''
106
    def getEquipmentDataList(self):
107
        dataList = []
108
        try:
109
            from AppDocData import AppDocData
110

  
111
            global equipColumnList
112

  
113
            docData = AppDocData.instance()
114
            attrs = self.attrs
115

  
116
            for index in range(len(equipColumnList)):
117
                dataList.append('')
118

  
119
            dataList[0] = str(self.uid)
120
            dataList[14] = docData.imgName
121

  
122
            for attr in attrs:
123
                attrInfo = docData.getSymbolAttributeByUID(attr.attribute)
124
                attrName = attrInfo[0]
125
                if equipColumnList.count(attrName):
126
                    colIndex = equipColumnList.index(attrName)
127
                    
128
                    if type(attr) is UserInputAttribute:
129
                        dataList[colIndex] = attr.text if attr.text is not None else ''
130
                    elif type(attr) is QEngineeringTextItem:
131
                        dataList[colIndex] = attr.text()
132
                    else:
133
                        dataList[colIndex] = attr.uid
134
            
135
        except Exception as ex:
136
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
137

  
138
        return dataList
DTI_PID/DTI_PID/Shapes/QEngineeringNoteItem.py
1
# coding: utf-8
2
import os.path
3
import copy
4
import sys
5
try:
6
    from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect
7
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont
8
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem
9
except ImportError:
10
    try:
11
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect
12
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont
13
    except ImportError:
14
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
15

  
16
from EngineeringPolylineItem import QEngineeringPolylineItem
17
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
18
import OcrResultDialog
19
from AppDocData import AppDocData
20
from EngineeringTextItem import QEngineeringTextItem
21
import re
22

  
23
noteColumnList = ['UID', 'NOTE_NO', 'DESCRIPTION', 'PNID_NO']
24

  
25
class QEngineeringNoteItem(QEngineeringTextItem):
26
    '''
27
        @history    2018.04.30  Jeongwoo    Signal Parameter Changed (QEngineeringTextItem → QGraphicsItem)
28
    '''
29
    #removed = pyqtSignal(QGraphicsItem)
30

  
31
    def __init__(self, parent=None):
32
        QEngineeringTextItem.__init__(self, parent)
33
        
34
        self.title = None
35
        self.conetents = None
36

  
37
    '''
38
        @brief      Find Note Contents by NOTE No.
39
        @author     Jeongwoo
40
        @date       2018.04.27
41
        @history    2018.04.27  Jeongwoo    Append Note contents to list
42
                                            else-statement changed, if text starts with new LineNo header, do break
43
                                            Moved from ResultTreeWidget
44
                    2018.05.02  Jeongwoo    Add if-statement. Append text to list when Regex start position is not 0
45
    '''
46
    def findNoteContents(self, noteNoText):
47
        # Get NoteArea
48
        notesArea = AppDocData.instance().getArea('Note')
49
        # Get all note contents
50
        items = self.scene().items(QRectF(notesArea.x, notesArea.y, notesArea.x + notesArea.width, notesArea.y + notesArea.height))
51
        items = [item for item in items if type(item) is QEngineeringTextItem] # Filtering QEngineeringTextItem
52
        items.sort(key=lambda item:item.loc[1]) # Compare with loc[1] (Y-Coord)
53
        foundNumberStr = None
54
        foundNote = []
55
        numberStr = ''
56
        results = re.findall("\d+", noteNoText)
57
        if results is not None and len(results) > 0:
58
            numberStr = results[0]
59
        for item in items:
60
            if type(item) is QEngineeringTextItem:
61
                text = item.text()
62
                if foundNumberStr is None: # Not found yet
63
                    try:
64
                        # Find NOTE Contents start with header [ex - 1. 1) 2. 2) ...]
65
                        position = re.search(numberStr+"(.|\))", text).start()
66
                        if position == 0: # Start with NOTE No.
67
                            foundNote.append(text)
68
                            foundNumberStr = numberStr
69
                    except Exception as ex:
70
                        '''NOT FOUND, DO NOTHING'''
71
                else:
72
                    try:
73
                        position = re.search("\d+(.|\))", text).start()
74
                        # If NOTE No starts with any number header, break
75
                        if position == 0:
76
                            break
77
                        else:
78
                            foundNote.append(text)
79
                    except Exception as ex:
80
                        foundNote.append(text)
81
        return foundNote
82

  
83

  
84
    '''
85
        @brief      return note Data List
86
        @author     kyouho
87
        @date       2018.10.10
88
    '''
89
    def getNoteDataList(self):
90

  
91
        dataList = []
92
        try:
93
            from AppDocData import AppDocData
94

  
95
            global noteColumnList
96

  
97
            docData = AppDocData.instance()
98

  
99
            noteContentsList = self.findNoteContents(self.text())
100

  
101
            loopIndex = 1
102
            for noteDescription in noteContentsList:
103
                data = []
104
                for index in range(len(noteColumnList)):
105
                    data.append('')
106

  
107
                data[0] = str(self.uid) + "-" + str(loopIndex)
108
                import re
109
                data[1] = ''.join(re.findall('\d*', self.text()))
110
                data[2] = noteDescription
111
                data[3] = docData.imgName
112

  
113
                dataList.append(data)
114

  
115
        except Exception as ex:
116
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
117

  
118
        return dataList
119

  
120

  
121
    '''
122
        @brief      save note Data
123
        @author     kyouho
124
        @date       2018.10.10
125
    '''
126
    def saveNoteData(self):
127
        try:
128
            from AppDocData import AppDocData
129

  
130
            docData = AppDocData.instance()
131
            docData.setNoteDataList(self.getNoteDataList())
132
        except Exception as ex:
133
            return str(self.uid)
134
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
506 506
                        selected = attr
507 507

  
508 508
            if selected is not None:
509
                self.attrs.append(selected)
509
                self._texts.append(selected)
510 510
        except Exception as ex:
511 511
            from App import App 
512 512
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
......
810 810
    @staticmethod
811 811
    def createItem(type, path, uid=None):
812 812
        from QEngineeringOPCItem import QEngineeringOPCItem
813
        from QEngineeringEquipmentItem import QEngineeringEquipmentItem
813
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
814 814
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
815 815
        from EngineeringNozzleItem import QEngineeringNozzleItem
816 816
        from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
DTI_PID/DTI_PID/SmartFEED.nsi
750 750
  File "dist\SmartFEED\Shapes\EngineeringRunItem.py"
751 751
  File "dist\SmartFEED\Shapes\EngineeringUnknownItem.py"
752 752
  File "dist\SmartFEED\Shapes\EngineeringAbstractItem.py"
753
  File "dist\SmartFEED\Shapes\QEngineeringEquipmentItem.py"
753
  File "dist\SmartFEED\Shapes\EngineeringEquipmentItem.py"
754 754
  File "dist\SmartFEED\Shapes\QEngineeringFlowArrowItem.py"
755 755
  File "dist\SmartFEED\Shapes\QEngineeringInstrumentItem.py"
756 756
  File "dist\SmartFEED\Shapes\EngineeringLineNoTextItem.py"
757
  File "dist\SmartFEED\Shapes\QEngineeringNoteItem.py"
757
  File "dist\SmartFEED\Shapes\EngineeringNoteItem.py"
758 758
  File "dist\SmartFEED\Shapes\QEngineeringOPCItem.py"
759 759
  File "dist\SmartFEED\Shapes\QEngineeringSizeTextItem.py"
760 760
  File "dist\SmartFEED\Shapes\QEngineeringTagNoTextItem.py"
......
773 773
  File "dist\SmartFEED\Shapes\__pycache__\GraphicsPolylineItem.cpython-36.pyc"
774 774
  File "dist\SmartFEED\Shapes\__pycache__\EngineeringAbstractItem.cpython-36.pyc"
775 775
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringConnectorItem.cpython-36.pyc"
776
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringEquipmentItem.cpython-36.pyc"
776
  File "dist\SmartFEED\Shapes\__pycache__\EngineeringEquipmentItem.cpython-36.pyc"
777 777
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringFlowArrowItem.cpython-36.pyc"
778 778
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringInstrumentItem.cpython-36.pyc"
779 779
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringLineItem.cpython-36.pyc"
780 780
  File "dist\SmartFEED\Shapes\__pycache__\EngineeringLineNoTextItem.cpython-36.pyc"
781
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringNoteItem.cpython-36.pyc"
781
  File "dist\SmartFEED\Shapes\__pycache__\EngineeringNoteItem.cpython-36.pyc"
782 782
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringNozzleItem.cpython-36.pyc"
783 783
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringOPCItem.cpython-36.pyc"
784 784
  File "dist\SmartFEED\Shapes\__pycache__\QEngineeringRunItem.cpython-36.pyc"
......
3008 3008
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringRunItem.cpython-36.pyc"
3009 3009
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringOPCItem.cpython-36.pyc"
3010 3010
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringNozzleItem.cpython-36.pyc"
3011
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringNoteItem.cpython-36.pyc"
3011
  Delete "$INSTDIR\Shapes\__pycache__\EngineeringNoteItem.cpython-36.pyc"
3012 3012
  Delete "$INSTDIR\Shapes\__pycache__\EngineeringLineNoTextItem.cpython-36.pyc"
3013 3013
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringLineItem.cpython-36.pyc"
3014 3014
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringInstrumentItem.cpython-36.pyc"
3015 3015
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringFlowArrowItem.cpython-36.pyc"
3016
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringEquipmentItem.cpython-36.pyc"
3016
  Delete "$INSTDIR\Shapes\__pycache__\EngineeringEquipmentItem.cpython-36.pyc"
3017 3017
  Delete "$INSTDIR\Shapes\__pycache__\QEngineeringConnectorItem.cpython-36.pyc"
3018 3018
  Delete "$INSTDIR\Shapes\__pycache__\EngineeringAbstractItem.cpython-36.pyc"
3019 3019
  Delete "$INSTDIR\Shapes\__pycache__\GraphicsPolylineItem.cpython-36.pyc"
......
3031 3031
  Delete "$INSTDIR\Shapes\QEngineeringTagNoTextItem.py"
3032 3032
  Delete "$INSTDIR\Shapes\QEngineeringSizeTextItem.py"
3033 3033
  Delete "$INSTDIR\Shapes\QEngineeringOPCItem.py"
3034
  Delete "$INSTDIR\Shapes\QEngineeringNoteItem.py"
3034
  Delete "$INSTDIR\Shapes\EngineeringNoteItem.py"
3035 3035
  Delete "$INSTDIR\Shapes\EngineeringLineNoTextItem.py"
3036 3036
  Delete "$INSTDIR\Shapes\QEngineeringInstrumentItem.py"
3037 3037
  Delete "$INSTDIR\Shapes\QEngineeringFlowArrowItem.py"
3038
  Delete "$INSTDIR\Shapes\QEngineeringEquipmentItem.py"
3038
  Delete "$INSTDIR\Shapes\EngineeringEquipmentItem.py"
3039 3039
  Delete "$INSTDIR\Shapes\EngineeringAbstractItem.py"
3040 3040
  Delete "$INSTDIR\Shapes\EngineeringUnknownItem.py"
3041 3041
  Delete "$INSTDIR\Shapes\EngineeringRunItem.py"
DTI_PID/DTI_PID/SymbolAttr.py
14 14
        self.AttributeType = None
15 15
        self.AttrAt = None
16 16
        self.Expression = None
17
        self.Length = None
17
        self.Length = None
18

  
19
    def toXml(self):
20
        """
21
        generate xml code for symbol attribute
22
        """
23
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
24

  
25
        node = Element('ATTRIBUTE')
26
        node.attrib['UID'] = str(self.UID)
27
        node.attrib['Attribute'] = self.Attribute
28
        node.attrib['DisplayAttribute'] = self.DisplayAttribute
29
        node.attrib['AttributeType'] = self.AttributeType
30
        node.attrib['AttrAt'] = str(self.AttrAt)
31
        node.attrib['Expression'] = self.Expression
32
        node.attrib['Length'] = str(self.Length)
33

  
34
        return node
DTI_PID/DTI_PID/TextDetector.py
201 201
            else:
202 202
                pass
203 203

  
204
            if worker is not None: worker.updateProgress.emit(maxProgressValue, resultTextInfo[0].getText())
204
            if worker is not None: worker.updateProgress.emit(maxProgressValue, resultTextInfo[0].getText() if 1 == len(resultTextInfo) else None)
205 205
        except Exception as ex:
206 206
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
207 207
            worker.displayLog.emit(MessageType.Error, message)
DTI_PID/DTI_PID/TextItemFactory.py
19 19
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes')
20 20
from EngineeringTextItem import QEngineeringTextItem
21 21
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
22
from QEngineeringNoteItem import QEngineeringNoteItem
22
from EngineeringNoteItem import QEngineeringNoteItem
23 23
from QEngineeringSizeTextItem import QEngineeringSizeTextItem
24 24
from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
25 25

  
......
51 51
            result = self.isLineNo(text)
52 52

  
53 53
            if result[0]:
54
                item = QEngineeringLineNoTextItem(text)
54
                item = QEngineeringLineNoTextItem()
55 55
                item.setToolTip(text)
56 56

  
57 57
                # get color option
DTI_PID/DTI_PID/XmlGenerator.py
359 359
                2018.06.14  Jeongwoo    Add if-statement for QEngineeringUnknownItem data node
360 360
'''
361 361
def writeXmlOnScene(pidName, pidWidth, pidHeight, scene):
362
    from QEngineeringNoteItem import QEngineeringNoteItem
362
    from EngineeringNoteItem import QEngineeringNoteItem
363 363
    from EngineeringTextItem import QEngineeringTextItem
364 364
    from EngineeringLineItem import QEngineeringLineItem
365 365
    from EngineeringLineNoTextItem import QEngineeringLineNoTextItem

내보내기 Unified diff

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