프로젝트

일반

사용자정보

개정판 0d6d3734

ID0d6d373451f9384afe1ed031581ef4f8194dde17
상위 14540282
하위 df0c7400, 2e65c2a7

백흠경이(가) 약 5년 전에 추가함

issue #1221: 프로젝트 폴더 아래에 Datasheets 폴더를 생성한다.

Change-Id: I8b5aaa61f4bbef2ae883c044c53e3aaa4efd6460

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
17 17
except ImportError:
18 18
    from PyQt4.QtCore import *
19 19
    from PyQt4.QtGui import *
20
import numpy as np
21 20

  
22 21
from SingletonInstance import SingletonInstane
23 22
import symbol
......
743 742

  
744 743
    def setCurrentProject(self, project):
745 744
        self.project = project
746
        self.makeChildDir()
745
        project.make_sub_directories()
747 746
        try:
748 747
            if self.project.database.db_type == 'SQLite':
749 748
                # Creates or opens a file called mydb with a SQLite3 DB
......
785 784
            pass
786 785

  
787 786
    '''
788
        @brief      Make Directory
789
        @author     Jeongwoo
790
        @date       18.05.08
791
        @history    humkyung 2018.06.19 make 'Tile' directory
792
                    humkyung 2018.07.09 make drawing folder if not exists
793
                    euisung 2018.09.28 make training folder if not exists
794
    '''
795

  
796
    def makeChildDir(self):
797
        project = AppDocData.instance().getCurrentProject()
798
        dbDir = project.getDbFilePath()
799
        if not os.path.exists(dbDir):
800
            os.makedirs(dbDir)
801
        imgDir = project.getImageFilePath()
802
        if not os.path.exists(imgDir):
803
            os.makedirs(imgDir)
804
        svgDir = project.getSvgFilePath()
805
        if not os.path.exists(svgDir):
806
            os.makedirs(svgDir)
807
        outputDir = project.getOutputPath()
808
        if not os.path.exists(outputDir):
809
            os.makedirs(outputDir)
810
        tempDir = project.getTempPath()
811
        if not os.path.exists(tempDir):
812
            os.makedirs(tempDir)
813
        drawingPath = project.getDrawingFilePath()
814
        if not os.path.exists(drawingPath):
815
            os.makedirs(drawingPath)
816
        trainingPath = project.getTrainingFilePath()
817
        if not os.path.exists(trainingPath):
818
            os.makedirs(trainingPath)
819

  
820
        path = os.path.join(tempDir, 'Tile')
821
        if not os.path.exists(path):
822
            os.makedirs(path)
823
        path = os.path.join(drawingPath, 'Native')
824
        if not os.path.exists(path):
825
            os.makedirs(path)
826

  
827
    '''
828 787
        @brief  Get current Project
829 788
    '''
830 789

  
......
3264 3223
                conn.rollback()
3265 3224

  
3266 3225
                from App import App
3267
                message = 'error occurred({}\\n{}) in {}:{}'.format(ex, sql,
3226
                message = 'error occurred({}\\n{}) in {}:{}'.format(repr(ex), sql,
3268 3227
                                                                    sys.exc_info()[-1].tb_frame.f_code.co_filename,
3269 3228
                                                                    sys.exc_info()[-1].tb_lineno)
3270 3229
                App.mainWnd().addMessage.emit(MessageType.Error, message)
DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py
104 104
                            if key.Attribute == self._attr.Attribute:
105 105
                                key.AssocItem = item
106 106
                                # auto freeze when manually attribute setting
107
                                self._item.getAttributes() # attr rebinding so old key is not valid
107
                                self._item.getAttributes()  # attr rebinding so old key is not valid
108 108
                                for neyKey in self._item.attrs.keys():
109 109
                                    if neyKey.Attribute == self._attr.Attribute:
110 110
                                        neyKey.Freeze = True
DTI_PID/DTI_PID/EqpDatasheetExportDialog.py
26 26
        pass
27 27

  
28 28
    def accept(self):
29
        """ export selected drawing to xml file """
30
        from AppDocData import Config
31
        from AppDatabase import AppDatabase
29
        """ export selected equipments to excel file """
32 30

  
33 31
        try:
32
            types = []
33
            for index in range(self.ui.listWidgetEquipmentType.count()):
34
                if self.ui.listWidgetEquipmentType.item(index).checkState() == Qt.Checked:
35
                    types.append(self.ui.listWidgetEquipmentType.item(index).text())
36

  
37
            if types:
38
                app_doc_data = AppDocData.instance()
39
                equipments = app_doc_data.get_equipment_data_list()
40
                for _type in types:
41
                    equipment = [attrs for attrs in equipments if [attr for attr in attrs if attr[0] == 'Type' and
42
                                                                   attr[1] == _type]]
43
                    if equipment:
44
                        self.export_equipment_data_sheet(equipment, _type)
45

  
34 46
            QDialog.accept(self)
35 47
        except Exception as ex:
36 48
            from App import App
37 49
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
38
            App.mainWnd().addMessage.emit(MessageType.Error, message)
50
            App.mainWnd().addMessage.emit(MessageType.Error, message)
51

  
52
    def export_equipment_data_sheet(self, equipments, _type):
53
        """ export given equipments to data sheet """
54

  
55
        pass
DTI_PID/DTI_PID/ItemDataExportDialog.py
6 6
from PyQt5.QtCore import *
7 7
from PyQt5.QtGui import *
8 8
from PyQt5.QtWidgets import *
9
import sqlite3
10 9
from AppDocData import AppDocData, Config
11 10
from openpyxl import *
12 11
from openpyxl.styles import *
......
416 415

  
417 416
            for key in self.viewTables.keys():
418 417
                config = docData.getConfigs('Order', key)
419
                if not config: continue
418
                if not config:
419
                    continue
420 420

  
421 421
                orders = docData.getConfigs('Order', key)[0].value.split(self.delimiter)
422 422
                headers = []
......
429 429
                    matches = [index for index in range(self.viewTables[key].columnCount()) if
430 430
                               header[0] == self.viewTables[key].horizontalHeaderItem(index).text()]
431 431
                    if matches:
432
                        self.viewTables[key].horizontalHeaderItem(matches[0]).setText(
433
                            header[1])  # display user column name
432
                        self.viewTables[key].horizontalHeaderItem(matches[0]).setText(header[1])  # display user column name
434 433
                        _from = self.viewTables[key].horizontalHeader().visualIndex(matches[0])
435 434
                        self.viewTables[key].horizontalHeader().moveSection(_from, col)
435

  
436 436
                    col = col + 1
437

  
438
                # hide unselected columns by user
439
                for col in range(self.viewTables[key].columnCount()):
440
                    matches = [col for header in headers if
441
                               header[0] == self.viewTables[key].horizontalHeaderItem(col).text()]
442
                    if not matches:
443
                        self.viewTables[key].hideColumn(col)
444

  
437 445
        except Exception as ex:
438 446
            from App import App
439 447
            from AppDocData import MessageType
......
476 484
        @date       2018.08.14
477 485
    '''
478 486

  
479
    def settingEquipmentData(self):
487
    def set_equipment_data(self):
480 488
        try:
481 489
            equipTable = self.ui.tableWidgetEquipmentDataList
482 490
            app_doc_data = AppDocData.instance()
......
490 498
            equipTable.setRowCount(len(dataList))
491 499
            row = 0
492 500
            for data in dataList:
493
                col = 0
494
                for key in data:
495
                    item = QTableWidgetItem(data[key] if data[key] is not None else '')
496
                    item.setFlags(Qt.ItemIsEnabled)
497
                    equipTable.setItem(row, col, item)
498
                    col += 1
501
                for col in range(equipTable.columnCount()):
502
                    col_name = equipTable.horizontalHeaderItem(col).text()
503
                    matches = [value for value in data if value[0] == col_name]
504
                    if matches:
505
                        item = QTableWidgetItem(matches[0][1] if matches[0][1] is not None else '')
506
                        item.setFlags(Qt.ItemIsEnabled)
507
                        equipTable.setItem(row, col, item)
499 508

  
500 509
                row += 1
501 510
        except Exception as ex:
......
640 649

  
641 650
        from ItemDataFormatDialog import QItemDataFormatDialog
642 651

  
643
        item_data_format_dialog = QItemDataFormatDialog(self, self.columnListAll, self.columnOrder)
644
        item_data_format_dialog.exec_()
645

  
646
        self.initTableWidget()
652
        dlg = QItemDataFormatDialog(self, self.columnListAll, self.columnOrder)
653
        if dlg.exec_():
654
            self.initTableWidget()
647 655

  
648 656
    '''
649 657
        @brief      doc name change event
......
654 662

  
655 663
    def docNameChanged(self, text):
656 664
        self.settingLineData()
657
        #self.settingEquipmentData()
665
        self.set_equipment_data()
658 666
        self.set_valve_data()
659 667
        self.set_instrument_data()
660 668
        self.set_note_data()
661

  
662
    '''
663
        @brief      save Line Data
664
        @author     kyouho
665
        @date       2018.08.13
666
    '''
667

  
668
    def saveLineDataList(self):
669
        import uuid
670

  
671
        lineTable = self.ui.tableWidgetLineDataList
672
        docData = AppDocData.instance()
673

  
674
        dataLists = []
675
        for rowIndex in range(lineTable.rowCount()):
676
            dataList = []
677
            for columnIndex in range(lineTable.columnCount()):
678
                if columnIndex in self.lineNoTableComboBoxDic:
679
                    widgetItem = lineTable.cellWidget(rowIndex, columnIndex)
680
                    if widgetItem.currentIndex() >= 0:
681
                        dataList.append(widgetItem.currentText())
682
                    else:
683
                        dataList.append('')
684

  
685
                else:
686
                    widgetItem = lineTable.item(rowIndex, columnIndex)
687
                    if widgetItem is not None:
688
                        dataList.append(widgetItem.text())
689
                    else:
690
                        dataList.append('')
691

  
692
            if dataList[0] is None or dataList[0] == '':
693
                dataList[0] = str(uuid.uuid4())
694
            dataLists.append(dataList)
695

  
696
        docData.setLineDataList(dataLists)
697

  
698
    '''
699
        @brief      save Equip Data
700
        @author     kyouho
701
        @date       2018.08.13
702
    '''
703

  
704
    def saveEquipmentDataList(self):
705
        import uuid
706

  
707
        equipTable = self.ui.tableWidgetEquipmentDataList
708
        docData = AppDocData.instance()
709

  
710
        dataLists = []
711
        for rowIndex in range(equipTable.rowCount()):
712
            dataList = []
713
            for columnIndex in range(equipTable.columnCount()):
714
                widgetItem = equipTable.item(rowIndex, columnIndex)
715

  
716
                if widgetItem is not None:
717
                    dataList.append(widgetItem.text())
718
                else:
719
                    dataList.append('')
720

  
721
            dataLists.append(dataList)
722

  
723
        docData.setEquipmentDataList(dataLists)
724

  
725
    '''
726
        @brief      save inst Data
727
        @author     kyouho
728
        @date       2018.08.13
729
    '''
730

  
731
    def saveInstrumentDataList(self):
732

  
733
        instTable = self.ui.tableWidgetInstrumentDataList
734
        docData = AppDocData.instance()
735

  
736
        dataLists = []
737
        for rowIndex in range(instTable.rowCount()):
738
            dataList = []
739
            for columnIndex in range(instTable.columnCount()):
740
                widgetItem = instTable.item(rowIndex, columnIndex)
741

  
742
                if widgetItem is not None:
743
                    dataList.append(widgetItem.text())
744
                else:
745
                    dataList.append('')
746

  
747
            dataLists.append(dataList)
748

  
749
        docData.setInstrumentDataList(dataLists)
750

  
751
    '''
752
        @brief      key press event
753
        @author     kyouho
754
        @date       2018.08.13
755
    '''
756
    """
757
    def keyPressEvent(self, e):
758
        if e.key() == Qt.Key_Delete:
759
            _tabWidget = self.ui.tabWidget
760
            currentTabIndex = _tabWidget.currentIndex()
761
            tableName = ''
762
            if currentTabIndex == 0:
763
                tableName = 'tableWidgetLineDataList'
764
            elif currentTabIndex == 1:
765
                tableName = 'tableWidgetEquipmentDataList'
766
            elif currentTabIndex == 2:
767
                tableName = 'tableWidgetValveList'
768
            elif currentTabIndex == 3:
769
                tableName = 'tableWidgetInstrumentDataList'
770
            else:
771
                tableName = 'tableWidgetNoteDataList'
772
            table = self.findChild(QTableWidget, tableName)
773

  
774
            if table:
775
                selectedIndexes = table.selectedIndexes()
776
                selectedRows = [item.row() for item in selectedIndexes]
777
                model = table.model()
778

  
779
                rowsIndex = []
780
                for row in selectedRows:
781
                    rowsIndex.append(row)
782
        
783
                #중복 제거
784
                rowsIndex = list(set(rowsIndex))
785
                rowsIndex.reverse()
786
                
787
                for row in rowsIndex:
788
                    uidCell = table.item(row, 0)
789
                    if uidCell is not None:
790
                        uid = table.item(row, 0).text()
791
                        self.removeUID[currentTabIndex].append(uid)
792
                    model.removeRow(row)
793
    """
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
819 819
        if event.key() == Qt.Key_Delete:
820 820
            items = self.mainWindow.graphicsView.scene.selectedItems()
821 821
            selectedIndexes = self.selectedIndexes()
822
            if selectedIndexes[0].column() == 3 and self.item(selectedIndexes[0].row(), 1).text() == 'OWNER':
822
            if selectedIndexes and selectedIndexes[0].column() == 3 and self.item(selectedIndexes[0].row(), 1).text() == 'OWNER':
823 823
                items[0].owner = None
824 824
                self.show_item_property(items[0])
825
            #elif len(items) == 1 and len(selectedIndexes) == 1 and type(items[0]) is not QEngineeringLineItem and type(items[0]) is not QEngineeringSpecBreakItem and self.item(selectedIndexes[0].row(), 1).text().find('CONN') is not 0:
826
            #    if selectedIndexes[0].column() == 3:
827
            #        attributeStr = self.item(selectedIndexes[0].row(), 1).text()
828
            #        items[0].removeSelfAttr(attributeStr)
829
            #        self.mainWindow.refreshResultPropertyTableWidget()
830 825
            elif len(items) == 1 and len(selectedIndexes) == 1 and (type(items[0]) is QEngineeringLineItem or issubclass(type(items[0]), SymbolSvgItem)):
831 826
                key_cell = self.item(selectedIndexes[0].row(), 1)
832 827
                data = key_cell.data(Qt.UserRole)
DTI_PID/DTI_PID/Project.py
2 2
""" This is project module """
3 3

  
4 4
import os
5
from shutil import copyfile
5 6
from AppDatabase import AppDatabase
6 7

  
7 8
class Project:
......
89 90
        @date   2018.04.10
90 91
    '''
91 92
    def getDbFilePath(self):
92
        return os.path.join(self.getPath(),'db')
93
        return os.path.join(self.getPath(), 'db')
93 94

  
94 95
    '''
95 96
        @brief  return svg file path
......
97 98
        @date   2018.04.08
98 99
    '''
99 100
    def getSvgFilePath(self):
100
        return os.path.join(self.getPath(),'svg')
101
        return os.path.join(self.getPath(), 'svg')
101 102
    
102 103
    '''
103 104
        @brief  return temporary path
......
105 106
        @date   2018.04.10
106 107
    '''
107 108
    def getTempPath(self):
108
        return self.getPath() + '/Temp'
109
        return os.path.join(self.getPath(), 'Temp')
109 110

  
110 111
    '''
111 112
        @brief  return training path
......
113 114
        @date   2018.09.28
114 115
    '''
115 116
    def getTrainingFilePath(self):
116
        return self.getPath() + '/Training'
117
        return os.path.join(self.getPath(), 'Training')
118

  
119
    def get_data_sheet_path(self):
120
        """ return data sheet path """
121

  
122
        return os.path.join(self.getPath(), 'Datasheets')
117 123

  
118 124
    def setCreateDate(self, createDate):
119 125
        self.createDate = createDate
......
140 146
        configs = docData.getConfigs('Line No', 'Size Unit')
141 147
        if 1 == len(configs): res = configs[0].value
142 148

  
143
        return res
149
        return res
150

  
151
    def make_sub_directories(self):
152
        """ make directories for project """
153

  
154
        dbDir = self.getDbFilePath()
155
        if not os.path.exists(dbDir):
156
            os.makedirs(dbDir)
157
        imgDir = self.getImageFilePath()
158
        if not os.path.exists(imgDir):
159
            os.makedirs(imgDir)
160
        svgDir = self.getSvgFilePath()
161
        if not os.path.exists(svgDir):
162
            os.makedirs(svgDir)
163
        outputDir = self.getOutputPath()
164
        if not os.path.exists(outputDir):
165
            os.makedirs(outputDir)
166
        tempDir = self.getTempPath()
167
        if not os.path.exists(tempDir):
168
            os.makedirs(tempDir)
169
        drawingPath = self.getDrawingFilePath()
170
        if not os.path.exists(drawingPath):
171
            os.makedirs(drawingPath)
172
        trainingPath = self.getTrainingFilePath()
173
        if not os.path.exists(trainingPath):
174
            os.makedirs(trainingPath)
175

  
176
        path = os.path.join(tempDir, 'Tile')
177
        if not os.path.exists(path):
178
            os.makedirs(path)
179
        path = os.path.join(drawingPath, 'Native')
180
        if not os.path.exists(path):
181
            os.makedirs(path)
182

  
183
        # create folder and copy data sheet files
184
        path = self.get_data_sheet_path()
185
        if not os.path.exists(path):
186
            os.makedirs(path)
187

  
188
            source_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Datasheets')
189
            data_sheet_files = [f for f in os.listdir(source_path) if os.path.isfile(os.path.join(source_path, f))
190
                                and (os.path.splitext(f)[1].upper() == '.XLSX')]
191
            for data_sheet in data_sheet_files:
192
                copyfile(os.path.join(source_path, data_sheet), os.path.join(path, data_sheet))
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
244 244
            for attr in targetAttrs:
245 245
                matches = [_attr for _attr,_ in self.attrs.items() if _attr.UID == attr.UID]
246 246
                if matches:
247
                    attr.Freeze = matches[0].Freeze         ### update freeze value
247
                    attr.Freeze = matches[0].Freeze         # update freeze value
248 248
                    attr.AssocItem = matches[0].AssocItem
249
                    _attrs[attr] = self.attrs[matches[0]]   ### copy attribute value
249
                    _attrs[attr] = self.attrs[matches[0]]   # copy attribute value
250 250
                else:
251 251
                    _attrs[attr] = ''
252 252
 
253
                if attr.Freeze: continue    ### do not evalulate value if attribute is frozen
253
                # if attr.Freeze: continue    # do not evaluate value if attribute is frozen
254 254
                if attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
255 255
                    at = int(attr.AttrAt)
256 256

  
......
290 290
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
291 291
                    else:
292 292
                        _attrs[attr] = ''
293
                elif attr.AttributeType == 'Tag No':
294
                    _attrs[attr] = eval(attr.Expression) if attr.Expression and not _attrs[attr] else _attrs[attr]
293 295
                elif attr.AttributeType == 'String':
294 296
                    _attrs[attr] = attr.Expression if attr.Expression and not _attrs[attr] else _attrs[attr]
295 297

  
......
297 299
                if _value is None or _value == '':
298 300
                    _attr.AssocItem = None
299 301

  
300
            self.attrs = _attrs ### assign self.attrs
302
            self.attrs = _attrs
301 303
        except Exception as ex:
302 304
            from App import App 
303 305
            from AppDocData import MessageType
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py
10 10
from PyQt5.QtWidgets import (QApplication, QGraphicsItem)
11 11

  
12 12
from SymbolSvgItem import SymbolSvgItem
13
from EngineeringConnectorItem import QEngineeringConnectorItem
14 13
from EngineeringAbstractItem import QEngineeringAbstractItem
15
from EngineeringTextItem import QEngineeringTextItem
16 14
from UserInputAttribute import UserInputAttribute
17 15

  
16

  
18 17
class QEngineeringEquipmentItem(SymbolSvgItem):
19 18
    """ This is engineering equipment item class """
20 19

  
......
31 30

  
32 31
        self._properties = \
33 32
            { \
34
                SymbolProp(None, 'ITEM_NO', 'Tag No', Expression="self.tag_no"):None,
35
                SymbolProp(None, 'Desc', 'String', Expression="self.desc"):None
33
                SymbolProp(None, 'Desc', 'String', Expression="self.desc"): None
36 34
            }
37 35

  
38 36
        if QEngineeringEquipmentItem.EQUIP_COLUMN_LIST is None:
......
45 43
        """ return text type of labels """
46 44
        from EngineeringTextItem import QEngineeringTextItem
47 45

  
48
        return sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)], key=lambda attr: attr.loc[1])
46
        return sorted([x for x in self.associations() if issubclass(type(x), QEngineeringTextItem)],
47
                      key=lambda attr: attr.loc[1])
49 48

  
50 49
    @property
51 50
    def tag_no(self):
......
65 64
                matches = [value for value in CodeTable.instance('EqpTagNames').values if value[1] == self.tag_no]
66 65
                if matches: return matches[0][2]
67 66
        except Exception as ex:
68
            from App import App 
67
            from App import App
69 68
            from AppDocData import MessageType
70 69

  
71
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
70
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
71
                                                           sys.exc_info()[-1].tb_lineno)
72 72
            App.mainWnd().addMessage.emit(MessageType.Error, message)
73 73

  
74 74
        return ''
......
78 78
        @author humkyung
79 79
        @date   2018.05.03
80 80
    '''
81

  
81 82
    def connectAttribute(self, attributes, clear=True):
82 83
        from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
83 84

  
......
126 127
        from EngineeringAbstractItem import QEngineeringAbstractItem
127 128
        from EngineeringLineItem import QEngineeringLineItem
128 129

  
129
        #if DisplayOptions.DisplayByLineType == DisplayColors.instance().option:
130
        # if DisplayOptions.DisplayByLineType == DisplayColors.instance().option:
130 131
        if self.hover:
131 132
            return SymbolSvgItem.HOVER_COLOR
132 133
        elif not QEngineeringEquipmentItem.EQUIP_COLOR:
133 134
            app_doc_data = AppDocData.instance()
134 135
            configs = app_doc_data.getConfigs('Equipment', 'Color')
135
            QEngineeringEquipmentItem.EQUIP_COLOR = configs[0].value if configs else QEngineeringAbstractItem.DEFAULT_COLOR
136
            QEngineeringEquipmentItem.EQUIP_COLOR = configs[
137
                0].value if configs else QEngineeringAbstractItem.DEFAULT_COLOR
136 138

  
137 139
        return QEngineeringEquipmentItem.EQUIP_COLOR
138
        #else:
140
        # else:
139 141
        #    return SymbolSvgItem.getColor(self)
140 142

  
141
    '''
142
        @brief      get attributes
143
        @author     humkyung
144
        @date       2018.06.14
145
    '''
146
    '''
147
    def getAttributes(self):
148
        _attrs = {}
149
        try:
150
            from AppDocData import AppDocData
151
            from EngineeringAbstractItem import QEngineeringAbstractItem
152
            from EngineeringTextItem import QEngineeringTextItem
153

  
154
            # 해당 Type의 attribute setting
155
            docData = AppDocData.instance()
156
            symbolAttrs = docData.getSymbolAttribute(self.type)
157
            
158
            _texts = self.texts()
159
            _symbols = self.symbols()
160
            for attr in symbolAttrs:
161
                if attr.AttributeType == 'Tag No' or attr.AttributeType == 'Size Text Item' or attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
162
                    at = int(attr.AttrAt)
163
                    items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType]
164
                    if len(items) > at:
165
                        item = items[at]
166
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
167
                    else:
168
                        _attrs[attr] = ''
169
                elif attr.AttributeType == 'Symbol Item':
170
                    at = int(attr.AttrAt)
171
                    if len(_symbols) > at:
172
                        item = _symbols[at]
173
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
174
                    else:
175
                        _attrs[attr] = ''
176
                else:
177
                    matches = [prop for prop in self.attrs if prop.UID == attr.UID]
178
                    if len(matches) == 1:
179
                        _attrs[matches[0]] = self.attrs[matches[0]]
180
                    else:
181
                        _attrs[attr] = ''
182
        except Exception as ex:
183
            from App import App 
184
            from AppDocData import MessageType
185

  
186
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
187
            App.mainWnd().addMessage.emit(MessageType.Error, message)
188
        
189
        return _attrs
190
        '''
191

  
192 143
    def highlight(self, flag):
193 144
        """ highlight/unhighlight the equpment """
194 145

  
195 146
        try:
196
            self.hover = flag 
147
            self.hover = flag
197 148
            self.update()
198 149

  
199 150
            for assoc in self.associations():
......
201 152

  
202 153
            for connector in self.connectors:
203 154
                connector.highlight(flag)
204
        except Exception as ex: 
205
            from App import App 
155
        except Exception as ex:
156
            from App import App
206 157
            from AppDocData import MessageType
207 158

  
208
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
159
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
160
                                                           sys.exc_info()[-1].tb_lineno)
209 161
            App.mainWnd().addMessage.emit(MessageType.Error, message)
210 162

  
211 163
    '''
......
213 165
        @author     humkyung
214 166
        @date       2018.05.09
215 167
    '''
168

  
216 169
    def toXml(self):
217 170
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
218 171

  
219 172
        try:
220 173
            node = SymbolSvgItem.toXml(self)
221 174
        except Exception as ex:
222
            from App import App 
175
            from App import App
223 176
            from AppDocData import MessageType
224 177

  
225
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
178
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
179
                                                           sys.exc_info()[-1].tb_lineno)
226 180
            App.mainWnd().addMessage.emit(MessageType.Error, message)
227 181

  
228 182
            return None
229 183

  
230
        return node 
184
        return node
231 185

  
232 186
    def toSql_return_separately(self):
233 187
        """ convert equipment data to sql query """
234 188
        import uuid
235
        from AppDocData import AppDocData
236 189
        res = []
237 190
        resLater = []
238 191

  
239 192
        res.append(self.toSql_Components())
240
        
193

  
241 194
        _attrs = self.getAttributes()
242 195
        if _attrs:
243 196
            cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value']
......
253 206
            values = ['?', '?', '?', '?']
254 207
            params = []
255 208
            for assoc in self.associations():
256
                param = [str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid)]
257
                sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values))
258
                resLater.append((sql, tuple(param)))
209
                params.append(
210
                    (str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid)))
211
            sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values))
212
            resLater.append((sql, tuple(params)))
259 213

  
260 214
        # save connectors to database
261 215
        if self.connectors:
262 216
            cols = ['Components_UID', '[Index]', 'X', 'Y', 'Connected', 'Connected_At']
263 217
            values = ['?', '?', '?', '?', '?', '?']
264 218
            params = []
265
            index = 1 
219
            index = 1
266 220
            for connector in self.connectors:
267
                params.append(\
268
                    (#str(connector.uid),
269
                    str(self.uid), index, connector.connectPoint[0], connector.connectPoint[1],\
270
                    str(connector.connectedItem.uid) if connector.connectedItem else None,\
271
                    str(connector._connected_at))\
272
                        )
221
                params.append( \
222
                    (
223
                        str(self.uid), index, connector.connectPoint[0], connector.connectPoint[1], \
224
                        str(connector.connectedItem.uid) if connector.connectedItem else None, \
225
                        str(connector._connected_at)) \
226
                    )
227
                index += 1
228

  
273 229
            sql = 'insert into Points({}) values({})'.format(','.join(cols), ','.join(values))
274 230
            resLater.append((sql, tuple(params)))
275 231
        # up to here
276
        
232

  
277 233
        return res, resLater
DTI_PID/DTI_PID/SymbolAttr.py
129 129
        self.Target = None
130 130
        self.Length = None
131 131
        self.AssocItem = None
132
        self.IsProp = None
132
        self.IsProp = 0  # default value is 0
133 133

  
134 134
    @staticmethod
135 135
    def from_record(record):
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py
32 32
        if symbolType is not None:
33 33
            self.ui.labelLineNo.setVisible(False)
34 34
            self.currentTypeId = 0
35
            ## insert QTableWidgetEx
35
            # insert QTableWidgetEx
36 36
            self.ui.tableWidgetAttr = QTableWidgetEx(self.ui.groupBox)
37 37
            self.ui.tableWidgetAttr.setColumnCount(7)
38 38
            self.ui.tableWidgetAttr.setObjectName("tableWidgetAttr")
39 39
            self.ui.tableWidgetAttr.setRowCount(0)
40 40
            self.ui.tableWidgetAttr.verticalHeader().setVisible(False)
41 41
            self.ui.horizontalLayout_2.addWidget(self.ui.tableWidgetAttr)
42
            ## up to here
43
            ## combobox logic
42
            # up to here
43
            # combobox logic
44 44
            self.settingComboBoxSymbolType(symbolType[2])
45 45
            self.ui.comboBoxSymbolType.currentTextChanged.connect(self.changeSymbolType)
46
            ## up to here
46
            # up to here
47 47
            self.ui.pushButtonAddAttr.clicked.connect(self.onAddAttr)
48 48
            self.ui.pushButtonDelAttr.clicked.connect(self.onDelAttr)
49
            self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Attr At', 'Expression', 'Target'])
49
            self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Attr At',
50
                                                               'Expression', 'Target'])
50 51
            self.ui.tableWidgetAttr.horizontalHeaderItem(1).setSizeHint(QSize(25, 25))
51 52
            self.ui.tableWidgetAttr.setColumnWidth(3, 130)
52 53
            self.ui.tableWidgetAttr.hideColumn(0)
......
54 55
            self.ui.tableWidgetAttr.cellDoubleClicked.connect(self.cell_double_clicked)
55 56
        else:
56 57
            self.ui.comboBoxSymbolType.setVisible(False)
57
            ## insert QTableWidgetEx
58
            # insert QTableWidgetEx
58 59
            self.ui.tableWidgetAttr = QTableWidgetEx(self.ui.groupBox)
59 60
            self.ui.tableWidgetAttr.setColumnCount(5)
60 61
            self.ui.tableWidgetAttr.setObjectName("tableWidgetAttr")
61 62
            self.ui.tableWidgetAttr.setRowCount(0)
62 63
            self.ui.tableWidgetAttr.verticalHeader().setVisible(False)
63 64
            self.ui.horizontalLayout_2.addWidget(self.ui.tableWidgetAttr)
64
            ## up to here
65
            self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Length', 'Expression'])
65
            # up to here
66
            self.ui.tableWidgetAttr.setHorizontalHeaderLabels(['UID', 'Name', 'Display Name', 'Type', 'Length',
67
                                                               'Expression'])
66 68
            self.ui.tableWidgetAttr.horizontalHeaderItem(1).setSizeHint(QSize(25, 25))
67 69
            self.ui.tableWidgetAttr.hideColumn(0)
68 70

  
......
219 221
        @date   2018.08.13
220 222
    '''
221 223
    def onAddAttr(self):
224
        import uuid
225
        from SymbolAttr import SymbolAttr
226

  
222 227
        rows = self.ui.tableWidgetAttr.rowCount()
223 228
        self.ui.tableWidgetAttr.setRowCount(rows + 1)
224 229

  
......
234 239
        item.setFlags(Qt.ItemIsEnabled)
235 240
        self.ui.tableWidgetAttr.setItem(rows, 6, item)
236 241

  
237
        import uuid
238
        self.ui.tableWidgetAttr.setItem(rows, 0, QTableWidgetItem(str(uuid.uuid4())))
242
        attr = SymbolAttr()
243
        item = QTableWidgetItem(str(attr.UID))
244
        item.tag = attr
245
        self.ui.tableWidgetAttr.setItem(rows, 0, item)
239 246

  
240 247
    '''
241 248
        @brief  delete selected attribute 
DTI_PID/DTI_PID/UI/EqpDatasheetExport.ui
24 24
       <widget class="QListWidget" name="listWidgetEquipmentType">
25 25
        <item>
26 26
         <property name="text">
27
          <string>Column</string>
28
         </property>
29
         <property name="checkState">
30
          <enum>Unchecked</enum>
31
         </property>
32
         <property name="flags">
33
          <set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled</set>
34
         </property>
35
        </item>
36
        <item>
37
         <property name="text">
38 27
          <string>Filter</string>
39 28
         </property>
40 29
         <property name="checkState">
......
67 56
        </item>
68 57
        <item>
69 58
         <property name="text">
70
          <string>Cooler</string>
59
          <string>Other Equipment</string>
71 60
         </property>
72 61
         <property name="checkState">
73 62
          <enum>Unchecked</enum>
DTI_PID/DTI_PID/UI/EqpDatasheetExport_UI.py
23 23
        self.listWidgetEquipmentType = QtWidgets.QListWidget(self.groupBox)
24 24
        self.listWidgetEquipmentType.setObjectName("listWidgetEquipmentType")
25 25
        item = QtWidgets.QListWidgetItem()
26
        item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsUserCheckable|QtCore.Qt.ItemIsEnabled)
27
        item.setCheckState(QtCore.Qt.Unchecked)
28
        self.listWidgetEquipmentType.addItem(item)
29
        item = QtWidgets.QListWidgetItem()
30 26
        item.setCheckState(QtCore.Qt.Unchecked)
31 27
        self.listWidgetEquipmentType.addItem(item)
32 28
        item = QtWidgets.QListWidgetItem()
......
61 57
        __sortingEnabled = self.listWidgetEquipmentType.isSortingEnabled()
62 58
        self.listWidgetEquipmentType.setSortingEnabled(False)
63 59
        item = self.listWidgetEquipmentType.item(0)
64
        item.setText(_translate("EqpDatasheetExportDialog", "Column"))
65
        item = self.listWidgetEquipmentType.item(1)
66 60
        item.setText(_translate("EqpDatasheetExportDialog", "Filter"))
67
        item = self.listWidgetEquipmentType.item(2)
61
        item = self.listWidgetEquipmentType.item(1)
68 62
        item.setText(_translate("EqpDatasheetExportDialog", "Heat Transfer Equipment"))
69
        item = self.listWidgetEquipmentType.item(3)
63
        item = self.listWidgetEquipmentType.item(2)
70 64
        item.setText(_translate("EqpDatasheetExportDialog", "Mechanical"))
71
        item = self.listWidgetEquipmentType.item(4)
65
        item = self.listWidgetEquipmentType.item(3)
72 66
        item.setText(_translate("EqpDatasheetExportDialog", "Vessels"))
73
        item = self.listWidgetEquipmentType.item(5)
74
        item.setText(_translate("EqpDatasheetExportDialog", "Cooler"))
67
        item = self.listWidgetEquipmentType.item(4)
68
        item.setText(_translate("EqpDatasheetExportDialog", "Other Equipment"))
75 69
        self.listWidgetEquipmentType.setSortingEnabled(__sortingEnabled)
ID2.wxs
608 608
              <File Id="fil97E0A469BD5AA86EA05873674AF1C766" KeyPath="yes" Source=".\dist\App\Scripts\MSSQL\ID2.sql" />
609 609
          </Component>
610 610
		  <Component Id="cmp439BB5983015D28EA0DE25A3B2B03716" Directory="INSTALLFOLDER" Guid="5F043F54-83E4-48AF-88F9-A30744CB458D" Win64='yes'>
611
			<File Id="fil1CD57697CB0FAAA6CC0A6D606D8C7E07" KeyPath="yes" Source=".\dist\App\Datasheets\Column.xlsx" />
611
			<File Id="fil1CD57697CB0FAAA6CC0A6D606D8C7E07" KeyPath="yes" Source=".\dist\App\Datasheets\Other&#x20;Equipment.xlsx" />
612 612
		  </Component>
613 613
		  <Component Id="cmp8C8D579C85E402A293AC654F120CB9D9" Directory="INSTALLFOLDER" Guid="344055D2-7D87-4E8F-9243-9FA2002CEF69" Win64='yes'>
614 614
			<File Id="fil951521F488F0756BC4AF6E4D3FEFCE83" KeyPath="yes" Source=".\dist\App\Datasheets\Filter.xlsx" />

내보내기 Unified diff

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