프로젝트

일반

사용자정보

개정판 b2c42200

IDb2c422008dbdd7349ee7f01590918ba695f35862
상위 76eaa3f7
하위 2f394152

김연진이(가) 5년 이상 전에 추가함

issue #000:

Change-Id: I6c8451f8f0f154ed145ada528075bf6f42344c3a

차이점 보기:

HYTOS/HYTOS/AppDocData.py
1446 1446
            # Close the db connection
1447 1447
            conn.close()
1448 1448

  
1449
    def deleteDrawingByUID(self, uid):
1450
        try:
1451
            # Creates or opens a file called mydb with a SQLite3 DB
1452
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
1453
            conn = sqlite3.connect(dbPath)
1454
            # Get a cursor object
1455
            cursor = conn.cursor()
1456

  
1457
            # 1. Delete Components
1458
            sql = "delete from Components where Drawings_UID='{}'".format(uid)
1459
            cursor.execute(sql)
1460
            # 2. Delete DrawingsUnits
1461
            sql = "delete from DrawingsUnits where Drawings_UID='{}'".format(uid)
1462
            cursor.execute(sql)
1463
            # 3. Delete Drawings
1464
            sql = "delete from Drawings where UID='{}'".format(uid)
1465
            cursor.execute(sql)
1466
            
1467
            conn.commit()
1468
        # Catch the exception
1469
        except Exception as ex:
1470
            # Roll back any change if something goes wrong
1471
            conn.rollback()
1472
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1473
        finally:
1474
            # Close the db connection
1475
            conn.close()
1476

  
1449 1477
    '''
1450 1478
        @brief  delete configurations
1451 1479
        @author humkyung
......
3000 3028
            conn = sqlite3.connect(dbPath)
3001 3029
            # Get a cursor object
3002 3030
            cursor = conn.cursor()
3003
            sql = "select name from Drawings where name = '" + drawingName + "'"
3031
            sql = "select name from Drawings where upper(name) = '" + drawingName.upper() + "'"
3004 3032
            cursor.execute(sql)
3005 3033
            rows = cursor.fetchall()
3006 3034
        # Catch the exception
......
3051 3079

  
3052 3080
        return res
3053 3081

  
3054
    def saveDrawings(self, drawings):
3055
        """
3082
    '''
3083
        @brief      update drawings
3084
        @author     yeonjin
3085
        @date       2019.08.07
3086
    '''
3087
    def updateDrawing(self, drawing):
3088
        import uuid
3089
        
3090
        try:
3091
            # Creates or opens a file called mydb with a SQLite3 DB
3092
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
3093
            conn = sqlite3.connect(dbPath)
3094
            # Get a cursor object
3095
            cursor = conn.cursor()
3096
              
3097
            sql = """update Drawings
3098
                        set Name = ?
3099
                          , DateTime = ?
3100
                      where uid = ?"""
3101
            param = (drawing[0][1], drawing[0][2], drawing[0][0])
3102
            cursor.execute(sql, param)
3103

  
3104
            conn.commit()
3105

  
3106
        # Catch the exception
3107
        except Exception as ex:
3108
            # Roll back any change if something goes wrong
3109
            conn.rollback()
3110
            from App import App
3111

  
3112
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
3113
            App.mainWnd().addMessage.emit(MessageType.Error, message)
3114
        finally:
3115
            # Close the db connection
3116
            conn.close()
3117
    '''
3056 3118
        @brief      save drawings
3057 3119
        @author     humkyung
3058 3120
        @date       2018.11.03
3059
        """
3121
    '''
3122
    def saveDrawing(self, drawing):
3123
        import uuid
3124
        
3060 3125
        try:
3061 3126
            # Creates or opens a file called mydb with a SQLite3 DB
3062 3127
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
3063 3128
            conn = sqlite3.connect(dbPath)
3064 3129
            # Get a cursor object
3065 3130
            cursor = conn.cursor()
3131
              
3132
            sql = 'insert or replace into Drawings(UID, [NAME], [DATETIME]) values(?, ?, ?)'
3133
            param = (drawing[0][0], drawing[0][1], drawing[0][2])
3134
            cursor.execute(sql, param)
3066 3135

  
3067
            for drawing in drawings:                
3068
                sql = 'insert or replace into Drawings(UID, [NAME], [DATETIME]) values(?, ?, ?)'
3069
                param = tuple(drawing)
3070

  
3136
            sql = "select Table_Name, Column_Name, Units_UID from DrawingsUnits where drawings_UID = '00000000-0000-0000-0000-000000000000'"
3137
            cursor.execute(sql)
3138
            rows = cursor.fetchall()
3139
            for row in rows:
3140
                sql = """insert or replace into DrawingsUnits
3141
                            (
3142
                                UID
3143
                                , Drawings_UID
3144
                                , Table_Name
3145
                                , Column_Name
3146
                                , Units_UID
3147
                             )
3148
                             values 
3149
                             (
3150
                                ?
3151
                                , ?
3152
                                , ?
3153
                                , ?
3154
                                , ?
3155
                             )"""
3156
                param = (str(uuid.uuid4()), drawing[0][0], row[0], row[1], row[2])
3071 3157
                cursor.execute(sql, param)
3072 3158

  
3073 3159
            conn.commit()
......
3159 3245
                         on s.symboltype_uid = t.uid
3160 3246
                      where c.uid = ?
3161 3247
                      order by p.[Index]"""
3248
            param = (uid,)                      
3162 3249
            try:
3163
                cursor.execute(sql, (uid,))
3250
                cursor.execute(sql, param)
3164 3251
                rows = cursor.fetchall()
3165 3252
                for row in rows:
3166 3253
                    data = []
......
3235 3322

  
3236 3323
        return symbolTypeList
3237 3324

  
3325
    def getUnitsByDrawingName(self, drawingName):
3326
        unitsList = []
3327

  
3328
        try:
3329
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
3330

  
3331
            conn = sqlite3.connect(dbPath)
3332
            cursor = conn.cursor()
3333
            sql = """select ifnull(d.display_name, u.column_name)
3334
                          , u.UNIT
3335
                       from units u
3336
                       left join displayNames d
3337
                         on u.TABLE_NAME = d.TABLE_NAME and u.COLUMN_NAME = d.COLUMN_NAME    
3338
                      where u.uid in (
3339
                                        select distinct du.units_uid
3340
                                          from drawings d
3341
                                         inner join drawingsunits du
3342
                                            on d.uid = du.drawings_uid
3343
                                         where d.name = ?
3344
                                     )
3345
                        and u.table_name = 'HMB'"""
3346
            param = (drawingName, )
3347
            try:
3348
                cursor.execute(sql, param)
3349
                rows = cursor.fetchall()
3350
                for row in rows:
3351
                    unitsList.append((row[0], row[1])) 
3352
            except Exception as ex:
3353
                from App import App
3354

  
3355
                message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
3356
                App.mainWnd().addMessage.emit(MessageType.Error, message)
3357
        finally:
3358
            conn.close()
3238 3359

  
3360
        return unitsList
3239 3361

  
3240 3362
    def getColumnDisplayNames(self):
3241 3363
        columnDisplayNameList = []
HYTOS/HYTOS/Commands/SaveWorkCommand.py
39 39
            drawing = [drawing for drawing in drawings if appDocData.imgName == os.path.splitext(drawing[1])[0]]
40 40
            if drawing[0]:
41 41
                drawing[0][2] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
42
                appDocData.saveDrawings(drawing)
42
                appDocData.updateDrawing(drawing)
43 43
        except Exception as ex:
44 44
            from AppDocData import MessageType
45 45

  
HYTOS/HYTOS/HMBTable.py
13 13
        self._uid = None
14 14
        self._drawing_uid = None
15 15
        self._stream_no = None
16
        self._display_no = None
17
       
16
        self._tag_no = None
17
        self._phase_type = None
18 18
        self.isDeleted = False
19 19

  
20 20
    '''
......
50 50
    def drawing_uid(self, value):
51 51
        self._drawing_uid = value
52 52

  
53

  
54 53
    '''
55 54
        @author humkyung
56 55
        @date   2018.07.12
57 56
    '''
58 57
    @property
59
    def display_no(self):
60
        return self._display_no
58
    def stream_no(self):
59
        return self._stream_no
61 60

  
62 61
    '''
63 62
        @author humkyung
64 63
        @date   2018.07.12
65 64
    '''
66
    @display_no.setter
67
    def display_no(self, value):
68
        self._display_no = value
65
    @stream_no.setter
66
    def stream_no(self, value):
67
        self._stream_no = value
69 68

  
70 69
    '''
71 70
        @author humkyung
72 71
        @date   2018.07.12
73 72
    '''
74 73
    @property
75
    def stream_no(self):
76
        return self._stream_no
74
    def tag_no(self):
75
        return self._tag_no
77 76

  
78 77
    '''
79 78
        @author humkyung
80 79
        @date   2018.07.12
81 80
    '''
82
    @stream_no.setter
83
    def stream_no(self, value):
84
        self._stream_no = value
81
    @tag_no.setter
82
    def tag_no(self, value):
83
        self._tag_no = value
84

  
85 85

  
86
    @property
87
    def phase_type(self):
88
        return self._phase_type
86 89

  
90
    @phase_type.setter
91
    def phase_type(self, value):
92
        self._phase_type = value
87 93

  
88 94
class HMBTable:
89 95
    '''
HYTOS/HYTOS/ItemPropertyTableWidget.py
15 15
import sys
16 16
import math
17 17
import re
18

  
18 19
import SelectAttributeCommand
19 20

  
20 21
from EngineeringAbstractItem import QEngineeringAbstractItem
......
90 91
    def __init__(self, mainWindow):
91 92
        QTableWidget.__init__(self)
92 93
        self._item = None
93
        self.initResultPropertyTableWidget()
94 94
        self.mainWindow = mainWindow
95 95

  
96 96
        self.cellChanged.connect(self.cellChangedEvent)
97 97
        self.cellDoubleClicked.connect(self.cellDoubleClickedEvent)
98 98

  
99 99
    '''
100
        @brief      Initialize TableWidget
101
        @author     Jeongwoo
102
        @date       18.04.13
103
        @history    humkyung 2018.07.08 show column header
104
    '''
105
    def initItemPropertyTableWidget(self, item=None):
106

  
107
        if item is None:
108
            self.horizontalHeader().hide()
109
            return
110

  
111
        self.horizontalHeader().show()
112

  
113
        category = item.category
114

  
115
        if category == 'Equipment - [ Pressure Drop ]':
116
            self.setColumnCount(2)
117
            self.setHorizontalHeaderLabels(['P. Drop', 'Elevation'])
118
            self.setColumnWidth(0, 80)
119
            self.setColumnWidth(1, 80)
120
        elif category == 'Equipment - [ Pressurized ]':
121
            self.setColumnCount(3)
122
            self.setHorizontalHeaderLabels(['Index', 'P. Drop', 'Elevation'])
123
            self.setColumnWidth(0, 70)
124
            self.setColumnWidth(1, 70)
125
            self.setColumnWidth(2, 10)
126
        elif category == 'Equipment - [ Rotating ]':
127
            self.setColumnCount(2)
128
            self.setHorizontalHeaderLabels(['P. Drop', 'Elevation'])
129
            self.setColumnWidth(0, 80)
130
            self.setColumnWidth(1, 80)
131
        elif category == 'Instrument':
132
            self.setColumnCount(2)
133
            self.setHorizontalHeaderLabels(['P. Drop', 'Elevation'])
134
            self.setColumnWidth(0, 80)
135
            self.setColumnWidth(1, 80)
136

  
137
        self.verticalHeader().hide()
138
        self.horizontalHeader().setStretchLastSection(True)
139
        #self.verticallHeader().setDefaultSectionSize(50)
140

  
141
    '''
100 142
        @brief  show item's property
101 143
        @author humkyung
102 144
        @date   2018.07.03
......
106 148
        try:
107 149
            from PyQt5 import QtGui
108 150
            from SymbolAttr import SymbolAttr
151
            from EngineeringStreamlineItem import QEngineeringStreamlineItem
109 152

  
110 153
            self._item = item
111 154

  
112 155
            self.blockSignals(True)
113 156

  
114
            if type(item) is QEngineeringLineItem:
157
            if type(item) is QEngineeringStreamlineItem:
158
                self.initItemPropertyTableWidget()
115 159
                self.initTitleCell(item)
116 160
                self.initContentsCell()
117
            elif issubclass(type(item), SymbolSvgItem):
161
            elif issubclass(type(item), SymbolSvgItem):                
118 162
                self.onSymbolClicked(item)
119 163
            elif type(item) is QEngineeringLineNoTextItem:
120 164
                self.onLineNoClicked(item)
......
135 179
        finally:
136 180
            self.blockSignals(False)
137 181

  
138
    '''
139
        @brief      Initialize TableWidget
140
        @author     Jeongwoo
141
        @date       18.04.13
142
        @history    humkyung 2018.07.08 show column header
143
    '''
144
    def initResultPropertyTableWidget(self):
145
        self.setColumnCount(4)
146
        self.setHorizontalHeaderLabels(['', self.tr('Name'), '', self.tr('Value')])
147
        self.setColumnWidth(0, 10)
148
        self.setColumnWidth(1, 20)
149
        self.setColumnWidth(2, 10)
150
        self.setRowCount(13)
151
        self.verticalHeader().hide()
152
        self.horizontalHeader().setStretchLastSection(True)
182
    
153 183
        
154 184
    '''
155 185
        @brief      Slot to accept item click event
......
269 299
        @history    .
270 300
    '''
271 301
    def symbolChanged(self, item):
272
        self.initTitleCell(item)
302
        self.initItemPropertyTableWidget(item)
303
        #self.initTitleCell(item)
273 304
        self.initContentsCell()
274 305

  
275 306
    '''
......
310 341
    '''
311 342
    def initTitleCell(self, item):
312 343
        from LineTypeConditions import LineTypeConditions
344
        from EngineeringStreamlineItem import QEngineeringStreamlineItem
313 345

  
314 346
        try:
315
            self.clear()
316
            self.setHorizontalHeaderLabels(['', self.tr('Name'), '', self.tr('Value')])
317
            self.setColumnWidth(0, 20)
318
            self.setColumnWidth(1, 80)
319
            self.setColumnWidth(2, 20)
320
            if type(item) is QEngineeringSpecBreakItem:
347

  
348
            #self.clear()
349
            #self.setHorizontalHeaderLabels(['', self.tr('Name'), '', self.tr('Value')])
350
            #self.setColumnWidth(0, 20)
351
            #self.setColumnWidth(1, 80)
352
            #self.setColumnWidth(2, 20)
353
            if type(item) is QEngineeringStreamlineItem:
321 354
                self.setRowCount(7)
322 355
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
323 356
                self.setItem(1, 1, QTableWidgetItem(self.tr("Name")))
......
367 400
            elif type(item) is QEngineeringVendorItem:
368 401
                self.setRowCount(1)
369 402
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
370
            else:
371
                self.setRowCount(4)
372
                self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
373
                self.setItem(1, 1, QTableWidgetItem(self.tr("OWNER")))
374
                self.setItem(2, 1, QTableWidgetItem(self.tr("Type")))
375
                self.setItem(3, 1, QTableWidgetItem(self.tr("Text")))
403
            #else:
404
            #    self.setRowCount(4)
405
            #    self.setItem(0, 1, QTableWidgetItem(self.tr("UID")))
406
            #    self.setItem(1, 1, QTableWidgetItem(self.tr("OWNER")))
407
            #    self.setItem(2, 1, QTableWidgetItem(self.tr("Type")))
408
            #    self.setItem(3, 1, QTableWidgetItem(self.tr("Text")))
376 409

  
377 410
            for index in range(self.rowCount()):
378 411
                item = self.item(index, 1)
......
535 568
        from PyQt5 import QtGui
536 569
        from SymbolAttr import SymbolAttr
537 570

  
538
        row = self.rowCount()
571
        row = 0 #self.rowCount()
539 572
        self.setRowCount(row + len(item.connectors))
540

  
573
        
541 574
        count = 1
542 575
        for connector in item.connectors:
543
            connector_item = QTableWidgetItem('CONN{}'.format(count))
576
            connector_item = QTableWidgetItem('{}'.format(count))
544 577
            connector_item.setFlags(Qt.ItemIsEnabled)
545 578
            connector_item.setBackground(Qt.lightGray)
546
            self.setItem(row, 1, connector_item)
579
            connector_item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
580
            self.setItem(row, 0, connector_item)
547 581

  
548
            attr = SymbolAttr()
549
            attr.AttributeType = "CONN"
550
            attr.AttrAt = count
551
            connector_item.setData(Qt.UserRole, attr)
582
            #attr = SymbolAttr()
583
            #attr.AttributeType = "CONN"
584
            #attr.AttrAt = count
585
            #connector_item.setData(Qt.UserRole, attr)
552 586

  
553 587
            """ show icon item """
554
            self.show_icon_item(row, 2, attr)
588
            #self.show_icon_item(row, 2, attr)
555 589

  
556
            connector_item = QTableWidgetItem('{}'.format('None' if connector.connectedItem is None else str(connector.connectedItem)))
557
            connector_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
558
            self.setItem(row, 3, connector_item)
590
            #connector_item = QTableWidgetItem('{}'.format('None' if connector.connectedItem is None else str(connector.connectedItem)))
591
            #connector_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
592
            #self.setItem(row, 3, connector_item)
559 593
            
560 594
            row = row + 1
561 595
            count = count + 1
......
576 610
            if self._item is not None and issubclass(type(self._item), SymbolSvgItem):
577 611
                docData = AppDocData.instance()
578 612

  
613
                '''
579 614
                self.setItem(0, 3, QTableWidgetItem(str(self._item.uid)))
580 615
                self.setItem(1, 3, QTableWidgetItem(self._item.name))
581 616
                self.setItem(2, 3, QTableWidgetItem(self._item.type))
......
595 630
                self.show_icon_item(5, 2, attr)
596 631
                self.item(5, 1).setData(Qt.UserRole, attr)
597 632

  
598
                if type(self._item) is not QEngineeringSpecBreakItem and type(self._item) is not QEngineeringErrorItem:
599
                    self.show_item_properties(self._item)
633
                #if type(self._item) is not QEngineeringSpecBreakItem and type(self._item) is not QEngineeringErrorItem:
634
                    #self.show_item_properties(self._item)
600 635

  
601 636
                if type(self._item) is QEngineeringSpecBreakItem:
602 637
                    row = self.rowCount()
......
617 652
                    self.setItem(6, 3, QTableWidgetItem(self._item.msg))
618 653

  
619 654
                self.show_item_attributes(self._item)
655
                '''
620 656
                self.show_item_connectors(self._item)
621 657
                
622 658
                for index in range(self.rowCount()):
HYTOS/HYTOS/ItemTreeWidget.py
67 67
        self.imageViewer = imageViewer
68 68
        self.scene = imageViewer.scene
69 69
        self.root = None
70
        self.setContextMenuPolicy(Qt.CustomContextMenu)
71
        self.customContextMenuRequested.connect(self.openContextMenu)
72 70

  
73 71
    '''
74 72
        @brief      delete selected symbol
......
119 117
        except Exception as ex:
120 118
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
121 119
    
122
    '''
123
        @brief      Show Context Menu
124
        @author     Jeongwoo
125
        @date       18.05.11
126
        @history    18.06.14    Jeongwoo    Add item None check
127
                    humkyung 2018.06.27 add menu of run item for selecting line type
128
    '''
129
    def openContextMenu(self, position):
130
        from EngineeringRunItem import QEngineeringRunItem
131

  
132
        indexes = self.selectedIndexes()
133
        itemPosition = self.mapTo(self, position)
134
        item = self.itemAt(itemPosition)
135
        if item is not None:
136
            if item is self.LineNoTreeItem:
137
                menu = QMenu()
138
                explode_action = QAction(self.tr("Explode"))
139
                explode_action.triggered.connect(lambda : self.explode_all_line_nos(item))
140
                menu.addAction(explode_action)
141
                explodeKeepFromTo_action = QAction(self.tr("Explode (keep from, to)"))
142
                explodeKeepFromTo_action.triggered.connect(lambda : self.explode_all_line_nos(item, True))
143
                menu.addAction(explodeKeepFromTo_action)
144
                menu.exec_(self.viewport().mapToGlobal(position))
145
            else:
146
                data = item.data(0, self.TREE_DATA_ROLE)
147
                if len(indexes) > 0 and data is not None and issubclass(type(data), QEngineeringLineNoTextItem):
148
                    menu = QMenu()
149
                    pickColorAction = QAction(self.tr("Select Line Color"))
150
                    pickColorAction.triggered.connect(lambda : self.pickColorClickEvent(item))
151
                    menu.addAction(pickColorAction)
152
                    explode_action = QAction(self.tr("Explode"))
153
                    freeze = data.prop('Freeze')
154
                    explode_action.setEnabled(not freeze)
155
                    explode_action.triggered.connect(lambda : self.explode_line_no(item))
156
                    menu.addAction(explode_action)
157
                    if type(data) is QEngineeringLineNoTextItem:
158
                        explodeKeepFromTo_action = QAction(self.tr("Explode (keep from, to)"))
159
                        explodeKeepFromTo_action.setEnabled(not freeze)
160
                        explodeKeepFromTo_action.triggered.connect(lambda : self.explode_line_no(item, True))
161
                        menu.addAction(explodeKeepFromTo_action)
162
                    reverse_flow_action = QAction(self.tr("Reverse Flow"))
163
                    reverse_flow_action.triggered.connect(lambda : self.reverse_line_flow(item))
164
                    menu.addAction(reverse_flow_action)
165
                    menu.exec_(self.viewport().mapToGlobal(position))
166
                elif len(indexes) > 0 and data is not None and issubclass(type(data), QEngineeringRunItem):
167
                    menu = QMenu()
168
                    lineTypeAction = QAction(self.tr("Select Line Type"))
169
                    lineTypeAction.triggered.connect(lambda : self.lineTypeClickEvent(item))
170
                    menu.addAction(lineTypeAction)
171
                    line_no = item.parent().data(0, self.TREE_DATA_ROLE)
172
                    freeze = line_no.prop('Freeze')
173
                    explode_action = QAction(self.tr("Explode"))
174
                    explode_action.setEnabled(not freeze)
175
                    explode_action.triggered.connect(lambda : self.explode_line_run(item))
176
                    menu.addAction(explode_action)
177
                    reverse_flow_action = QAction(self.tr("Reverse Flow"))
178
                    reverse_flow_action.triggered.connect(lambda : self.reverse_line_flow(item))
179
                    menu.addAction(reverse_flow_action)
180
                    menu.exec_(self.viewport().mapToGlobal(position))
181

  
182
            self.SymbolsTreeItem.sortChildren(0, Qt.AscendingOrder)
183
            self.EqpTreeItem.sortChildren(0, Qt.AscendingOrder) 
184

  
120
    
185 121
    '''
186 122
        @brief      Pick Color for Line No
187 123
        @author     Jeongwoo
......
293 229
        self.root = QTreeWidgetItem(self, [drawingName])
294 230
        self.root.setIcon(0, QIcon(':newPrefix/objects.png'))
295 231
        self.root.setData(0, self.TREE_DATA_ROLE, appDocData.activeDrawing)
296
        child = self.root.addChild(QTreeWidgetItem(['LINE NO']))
232
        #child = self.root.addChild(QTreeWidgetItem(['LINE NO']))
233
        #self.LineNoTreeItem = self.root.child(self.root.childCount() - 1)
234
        #self.LineNoTreeItem.setFlags(self.root.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
235

  
236
        self.root.addChild(QTreeWidgetItem(['Line No']))
297 237
        self.LineNoTreeItem = self.root.child(self.root.childCount() - 1)
298
        self.LineNoTreeItem.setFlags(self.root.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
299
        #self.LineNoTreeItem.setCheckState(0, Qt.Checked)
300
        self.root.addChild(QTreeWidgetItem(['EQUIPMENTS']))
301
        self.EqpTreeItem = self.root.child(self.root.childCount() - 1)
302
        self.root.addChild(QTreeWidgetItem(['SYMBOLS']))
238

  
239
        self.root.addChild(QTreeWidgetItem(['Symbols']))
303 240
        self.SymbolsTreeItem = self.root.child(self.root.childCount() - 1)
304
        self.root.addChild(QTreeWidgetItem(['NOTES']))
305
        self.NotesTreeItem = self.root.child(self.root.childCount() - 1)
306
        self.root.addChild(QTreeWidgetItem(['UNKNOWN']))
307
        self.UnknownTreeItem = self.root.child(self.root.childCount() - 1)
241

  
242
        self.root.addChild(QTreeWidgetItem(['Units']))
243
        self.UnitsTreeItem = self.root.child(self.root.childCount() - 1)
308 244

  
309 245
        for idx in range(self.root.childCount()):
310 246
            child = self.root.child(idx)
311 247
            child.setIcon(0, QIcon(':newPrefix/folder-black.png'))
312 248

  
249
        self.load_units(drawingName)
250
        self.update_item_count()
251
        self.expandAll()
313 252
    '''
314 253
        @brief  create tree item for pipe run if need
315 254
        @author humkyung
......
521 460
            else:
522 461
                self.addTreeItem(self.root, item)
523 462
                    
524
        if self.NotesTreeItem is not None:
525
            self.NotesTreeItem.sortChildren(0, Qt.AscendingOrder)
463
        #if self.NotesTreeItem is not None:
464
        #    self.NotesTreeItem.sortChildren(0, Qt.AscendingOrder)
526 465

  
527 466
        self.expandAll()
528 467
        
......
770 709
        finally:
771 710
            self.update_item_count()
772 711

  
712

  
713
    def load_units(self, drawingName):        
714

  
715
        unitsList = AppDocData.instance().getUnitsByDrawingName(drawingName)
716
        for units in unitsList:
717
            item =  "{0} : [ {1} ]".format(units[0], units[1]) 
718
            QTreeWidgetItem(self.UnitsTreeItem, [item])
719
        
720

  
721

  
773 722
    def update_item_count(self):
774 723
        """
775 724
        update items count
776 725
        """
777 726
        if hasattr(self, 'LineNoTreeItem'):
778
            self.LineNoTreeItem.setText(0, 'LINE NO({})'.format(self.LineNoTreeItem.childCount()))
779
        if hasattr(self, 'EqpTreeItem'):
780
            self.EqpTreeItem.setText(0, 'EQUIPMENTS({})'.format(self.EqpTreeItem.childCount()))
727
            self.LineNoTreeItem.setText(0, 'Line No({})'.format(self.LineNoTreeItem.childCount()))        
781 728
        if hasattr(self, 'SymbolsTreeItem'):
782
            self.SymbolsTreeItem.setText(0, 'SYMBOLS({})'.format(self.SymbolsTreeItem.childCount()))
783
        if hasattr(self, 'NotesTreeItem'):
784
            self.NotesTreeItem.setText(0, 'NOTES({})'.format(self.NotesTreeItem.childCount()))
785
        if hasattr(self, 'UnknownTreeItem'):
786
            self.UnknownTreeItem.setText(0, 'UNKNOWN({})'.format(self.UnknownTreeItem.childCount()))
729
            self.SymbolsTreeItem.setText(0, 'Symbols({})'.format(self.SymbolsTreeItem.childCount()))        
730
        if hasattr(self, 'UnitsTreeItem'):
731
            self.UnitsTreeItem.setText(0, 'Units({})'.format(self.UnitsTreeItem.childCount()))                    
HYTOS/HYTOS/MainWindow.py
51 51
import SymbolTreeWidget, SymbolPropertyTableWidget
52 52
import SymbolEditorDialog
53 53
import ItemTreeWidget
54
import DrawingUnitTableWidget
54 55
import ItemPropertyTableWidget
55 56
from UserInputAttribute import UserInputAttribute
56 57
from TextItemFactory import TextItemFactory
......
112 113

  
113 114
        self.verticalLayout.addWidget(self.graphicsView)
114 115

  
115
        # Add Custom TreeWidget
116
        # Add Symbol TreeWidget
116 117
        self.symbolTreeWidget = SymbolTreeWidget.QSymbolTreeWidget()
117 118
        self.symbolTreeWidget.header().hide()
118 119
        self.verticalLayoutSymbolList.addWidget(self.symbolTreeWidget)
119 120

  
121
        # Add property TreeWidget
122
        self.itemPropertyTableWidget = ItemPropertyTableWidget.QItemPropertyTableWidget(self)
123
        self.verticalLayoutProperty.addWidget(self.itemPropertyTableWidget)
124

  
125
        # tabifyDockWidget 
126
        self.tabifyDockWidget(self.dockWidgetSymbolExplorer, self.dockWidgetPropertyExplorer)
127
        self.dockWidgetSymbolExplorer.setVisible (True)
128
        self.dockWidgetSymbolExplorer.setFocus ()
129
        self.dockWidgetSymbolExplorer.raise_ ()
130

  
131

  
132

  
120 133
        # Add Custom Result Tree Widget (Symbol Explorer)
121
        self.itemTreeWidget = ItemTreeWidget.QItemTreeWidget(self.graphicsView)
122
        self.itemTreeWidget.header().hide()
134
        #self.itemTreeWidget = ItemTreeWidget.QItemTreeWidget(self.graphicsView)
135
        #self.itemTreeWidget.header().hide()
123 136
        
137
        self.drawingUnitTableWidget = DrawingUnitTableWidget.QDrawingUnitTableWidget(self.graphicsView)        
138

  
124 139
        self.treeWidgetDrawingList.setHeaderHidden(False)
125 140
        self.treeWidgetDrawingList.header().setStretchLastSection(True)
141
        self.treeWidgetDrawingList.header().setDefaultAlignment(Qt.AlignCenter)
126 142
        self.treeWidgetDrawingList.setHeaderLabels([self.tr('Name'), self.tr('DateTime'), self.tr('Uid')])
127 143
        self.treeWidgetDrawingList.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
128 144
        self.treeWidgetDrawingList.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
129 145
        self.treeWidgetDrawingList.header().setSectionResizeMode(2, QHeaderView.ResizeToContents)
130 146
        self.treeWidgetDrawingList.hideColumn(2)
147
        
131 148
        self.treeWidgetDrawingList.itemDoubleClicked.connect(self.open_selected_drawing)
149
        
150
        
132 151

  
133 152
        # add splitter widget
134 153
        splitter = QSplitter(Qt.Vertical)
135
        splitter.addWidget(self.treeWidgetDrawingList)
136
        splitter.addWidget(self.itemTreeWidget)
154
        splitter.addWidget(self.treeWidgetDrawingList)                
155
        splitter.addWidget(self.drawingUnitTableWidget)        
137 156
        self.verticalLayoutDrawingList.addWidget(splitter)
138 157
        # up to here
139 158

  
......
196 215
            action.triggered.connect(partial(self.load_language, file))
197 216
        # up to here
198 217

  
218
        self.treeWidgetDrawingList.setContextMenuPolicy(Qt.CustomContextMenu)
219
        self.treeWidgetDrawingList.customContextMenuRequested.connect(self.openContextMenu)
220

  
221
        
222

  
223

  
224
    def openContextMenu(self, position):
225
        indexes = self.treeWidgetDrawingList.selectedIndexes()
226
        if len(indexes) > 0:
227
            level = 0
228
            index = indexes[0]
229
            while index.parent().isValid():
230
                index = index.parent()
231
                level += 1
232

  
233
            menu = QMenu()
234

  
235
            itemPosition = self.mapTo(self, position)
236
            item = self.treeWidgetDrawingList.itemAt(itemPosition)
237

  
238
            if level == 0:            
239
                newDrawingAction = menu.addAction(self.tr('New Drawing'))
240
                newDrawingAction.triggered.connect(lambda: self.newDrawingActionClickEvent(item))
241
                menu.addAction(newDrawingAction)
242
            elif level == 1:            
243
                editDrawingAction = menu.addAction(self.tr("Edit Drawing"))
244
                editDrawingAction.triggered.connect(lambda: self.editDrawingActionClickEvent(item))
245
                menu.addAction(editDrawingAction)
246

  
247
                deleteDrawingAction = menu.addAction(self.tr("Delete Drawing"))
248
                deleteDrawingAction.triggered.connect(lambda: self.deleteDrawingActionClickEvent(item))
249
                menu.addAction(deleteDrawingAction)
250

  
251
            menu.exec_(self.treeWidgetDrawingList.viewport().mapToGlobal(position))
252

  
253

  
254
    def newDrawingActionClickEvent(self, item):
255
        self.new_drawing()
256

  
257
    def editDrawingActionClickEvent(self, item):
258
        from QDrawingDialog import QDrawingDialog
259

  
260
        uid = item.text(2)
261

  
262
        dlg = QDrawingDialog(self)
263
        drawingName = dlg.showDialog(uid)
264
        if drawingName:
265
            self.load_drawing_list()
266

  
267

  
268
    def deleteDrawingActionClickEvent(self, item):
269
        try:
270
            msg = QMessageBox()
271
            msg.setIcon(QMessageBox.Critical)
272
            msg.setText(self.tr('Do you want to delete drawing?\nThis work cannot be recovered.'))
273
            msg.setWindowTitle(self.tr("Delete Drawing"))
274
            msg.setStandardButtons(QMessageBox.Ok|QMessageBox.Cancel)
275

  
276
            if QMessageBox.Ok == msg.exec_():
277
                uid = item.text(2)
278
                appDocData = AppDocData.instance()
279
                
280
                if appDocData.activeDrawing is not None:                    
281
                    appDocData.activeDrawing = None
282

  
283
                if self.graphicsView.hasImage():
284
                    self.graphicsView.clearImage()
285
                    self.graphicsView.scene.clear()
286

  
287
                appDocData.deleteDrawingByUID(uid)
288

  
289
                self.clear_data()
290
                self.load_drawing_list()                
291

  
292
        except Exception as ex:
293
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
294
            self.addMessage.emit(MessageType.Error, message)
199 295

  
296
    def clear_data(self):
297
        self.clear_HMB()
298
        self.drawingUnitTableWidget.clear_units()
299
        
200 300
    def eventFilter(self, source, event):
201 301
        """
202 302
        display mouse position of graphics view
......
281 381
        load language file and then apply selected language 
282 382
        """
283 383
        try:
384
        
284 385
            qm_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'translate', '{0}.qm'.format(file))
285 386
            QtWidgets.qApp.load_language(qm_file)
286 387

  
......
310 411
        self._headers.append('Uid')    
311 412
        self._headers.append('Drawing_Uid')    
312 413
        self._headers.append('Stream No.')
414
        self._headers.append('Tag No.')
313 415
        self._headers.append('Phase')
314 416
        self._headers.append('Flowrate (Mass)')
315 417
        self._headers.append('Flowrate (Volume)')
......
330 432

  
331 433
        self.tableWidgetHMB.setColumnCount(len(self._headers))
332 434
        self.tableWidgetHMB.setHorizontalHeaderLabels(self._headers)                
435
        #self.tableWidgetHMB.horizontalHeaderItem(0).setSizeHint(QSize(0, 30))
436
        self.tableWidgetHMB.horizontalHeaderItem(0).setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) # header 정렬 방식 
437

  
333 438
        self.tableWidgetHMB.setEditTriggers(QAbstractItemView.NoEditTriggers)
334 439
        
335
        self.tableWidgetHMB.setColumnHidden(0, True)
336
        self.tableWidgetHMB.setColumnHidden(1, True)
440
        #self.tableWidgetHMB.setColumnHidden(0, True)
441
        #self.tableWidgetHMB.setColumnHidden(1, True)
337 442
        
338 443
        self.tableWidgetHMB.resizeColumnsToContents()
444
        self.tableWidgetHMB.resizeRowsToContents()
445
        #self.tableWidgetHMB.horizontalHeader().setStretchLastSection(True)
446
        
447
        self.tableWidgetHMB.verticalHeader().setVisible(False)
448

  
339 449

  
340 450
    '''
341 451
        @brief      Clear TreeWidget and Set Current PID
......
358 468

  
359 469
            self.treeWidgetDrawingList.clear()
360 470
            self.treeWidgetDrawingList.root = QTreeWidgetItem(self.treeWidgetDrawingList, [self.tr('Drawings'), ''])
361
            self.treeWidgetDrawingList.root.setFlags(self.treeWidgetDrawingList.root.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
362
            #self.treeWidgetDrawingList.root.setCheckState(0, Qt.Unchecked)
363
                        
471
                      
364 472
            for drawing in drawings:               
365 473
                if drawing[1] == 'Template':
366 474
                    continue
367
                item = QTreeWidgetItem(self.treeWidgetDrawingList.root, [drawing[1], drawing[2], drawing[0] if drawing and drawing[0] else ''])
368
                #item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
369
                #item.setCheckState(0, Qt.Unchecked)
370
            
475
                QTreeWidgetItem(self.treeWidgetDrawingList.root, [drawing[1], drawing[2], drawing[0] if drawing and drawing[0] else ''])
476
                            
371 477
            self.treeWidgetDrawingList.root.setText(0, self.tr('Drawings')+'({})'.format(self.treeWidgetDrawingList.root.childCount()))
372 478
            self.treeWidgetDrawingList.expandItem(self.treeWidgetDrawingList.root)
373 479
            self.treeWidgetDrawingList.sortByColumn(1, Qt.DescendingOrder)
......
409 515
        items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)]
410 516
        self.labelTextStatus.setText("<font color='blue'>" + self.tr('Text') + " : {}</font>".format(len(items)))
411 517

  
412
        self.itemTreeWidget.sceneChanged(self.graphicsView.scene.items())
518
        #self.itemTreeWidget.sceneChanged(self.graphicsView.scene.items())
413 519

  
414 520
    def dbUpdate(self):
415 521
        '''
......
460 566

  
461 567
        try:
462 568
            appDocData = AppDocData.instance()
463
            if appDocData.imgName is None:
569
            if appDocData.imgName is None or appDocData.activeDrawing is None:
464 570
                self.showImageSelectionMessageBox()
465 571
                return
466 572

  
......
511 617
        QMessageBox.about(self.graphicsView, self.tr('Notice'), self._save_work_cmd.resultStr)
512 618
        self.load_drawing_list()
513 619

  
620

  
621

  
514 622
    '''
515 623
        @brief  add message listwidget
516 624
        @author humkyung
......
564 672
    def fitWindow(self, action):
565 673
        self.graphicsView.useDefaultCommand()
566 674
        self.graphicsView.zoomImageInit()
567

  
675
 
568 676
    '''
569 677
        @brief      selection changed
570 678
        @author     humkyung
......
572 680
        @history    humkung 2018.07.08 call tree widget's findItem
573 681
    '''
574 682
    def onSelectionChanged(self):
575
        items = [item for item in self.graphicsView.scene.selectedItems() if issubclass(type(item), SymbolSvgItem) or \
576
            type(item) is QEngineeringLineItem or issubclass(type(item), QEngineeringTextItem) or type(item) is QEngineeringUnknownItem or type(item) is QEngineeringVendorItem]
683
        from EngineeringStreamlineItem import QEngineeringStreamlineItem
684
        
685
        items = [item for item in self.graphicsView.scene.selectedItems() if issubclass(type(item), SymbolSvgItem) or type(item) is QEngineeringStreamlineItem ]
577 686
        if items:
578 687
            item = items[-1]
579
            self.itemTreeWidget.findItem(item)
580
            #self.resultPropertyTableWidget.show_item_property(item)
688
            #self.itemTreeWidget.findItem(item)
689
            self.itemPropertyTableWidget.show_item_property(item)
581 690
            if type(item) is QEngineeringErrorItem:
582 691
                for index in range(self.tableWidgetHMB.rowCount()):
692

  
583 693
                    if self.tableWidgetHMB.item(index, 1).tag is item:
584 694
                        self.tableWidgetHMB.selectRow(index)
585 695
                        break
586 696
        
697

  
587 698
        
588 699
    '''
589 700
        @brief      Initialize scene and itemTreeWidget
590 701
        @author     Jeongwoo
702

  
591 703
        @date       2018.06.14
592 704
        @history    humkyung 2018.08.16 ask to delete recognized items before remove
593 705
    '''
594 706
    def onInitializeScene(self, action):
707

  
595 708
        if not self.graphicsView.hasImage():
596 709
            self.actionEquipment.setChecked(False)
597 710
            self.showImageSelectionMessageBox()
......
608 721

  
609 722
                appDocData = AppDocData.instance()
610 723
                appDocData.activeDrawing.hmbTable.reset()
611
                appDocData.clearItemList(True)
612
                
724
                appDocData.clearItemList(True)                
613 725

  
614 726
                items = self.graphicsView.scene.items()
615 727
                for item in items:
616 728
                    if type(item) is not QGraphicsPixmapItem and item.scene() is not None:
617
                        #if hasattr(item, 'tranfer'):
618
                        #    item.tranfer.onRemoved.emit(item)
619
                        #else:
620
                        #    self.graphicsView.scene.removeItem(item)
621 729
                        self.graphicsView.scene.removeItem(item)
622 730

  
623
                        '''
624
                        if type(item) is QEngineeringLineNoTextItem:
625
                            self.removedItems['LINE'].append(str(item.uid))
626
                        elif type(item) is QEngineeringInstrumentItem:
627
                            self.removedItems['INST'].append(str(item.uid))
628
                        elif type(item) is QEngineeringEquipmentItem:
629
                            self.removedItems['EQUIP'].append(str(item.uid))
630
                        elif type(item) is QEngineeringNoteItem:
631
                            self.removedItems['NOTE'].append(str(item.uid))
632
                        '''
633
                    
634
                if self.path is not None:
635
                    baseName = os.path.basename(self.path)
636
                    self.itemTreeWidget.setCurrentDrawing(baseName)
637

  
638 731
                self.load_HMB()
639 732

  
640 733
        except Exception as ex:
......
797 890
        img = Image.new('RGBA', (1189, 841), (255, 255, 255))
798 891
        img.save(border)
799 892

  
800

  
801

  
802 893
    def load_data(self, drawing):
803 894
        from Drawing import Drawing
804 895
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse
......
814 905
            self.path = os.path.join(project.getDrawingFilePath(), drawing + '.png')
815 906
            appDocData.setImgFilePath(self.path)
816 907
            appDocData.activeDrawing = Drawing(appDocData.imgName)
817
            self.itemTreeWidget.setCurrentDrawing(appDocData.activeDrawing.name)
908
            self.drawingUnitTableWidget.load_units(drawing)
909
            #self.itemTreeWidget.setCurrentDrawing(appDocData.activeDrawing.name)
818 910

  
819 911
            ## Load data on database     
912

  
820 913
            components = appDocData.getComponentListByDrawingUID(appDocData.activeDrawing.UID)
821 914
            count = len(components)
822 915

  
......
828 921
        except Exception as ex:
829 922
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
830 923
            self.addMessage.emit(MessageType.Error, message)
924

  
925

  
831 926
    '''
832 927
        @brief      create new drawing
833 928
        @author     yeonjin
......
985 1080
                        svg = SymbolSvgItem(svgPath)
986 1081
                        svg.buildItem(newSym.getName(), newSym.getType(), 0, [offsetX, offsetY], [w, h], [float(x) for x in newSym.getOriginalPoint().split(',')], [(float(x.split(',')[0]), float(x.split(',')[1])) for x in newSym.getConnectionPoint().split('/')], newSym.getBaseSymbol(), newSym.getAdditionalSymbol(), newSym.getHasInstrumentLabel)
987 1082

  
988
                        svg.transfer.onRemoved.connect(self.itemTreeWidget.itemRemoved)
1083
                        #svg.transfer.onRemoved.connect(self.itemTreeWidget.itemRemoved)
989 1084
                        svg.addSvgItemToScene(self.graphicsView.scene)
990 1085
                        for connector in svg.connectors:
991 1086
                            self.graphicsView.scene.addItem(connector)
......
1025 1120
                hmb = HMBTable.new_data()                
1026 1121
                hmb.drawing_uid = drawing.UID
1027 1122
                hmb.stream_no = len(streamNos) + 1
1028
                hmb.display_no = hmb.stream_no
1123
                hmb.tag_no = hmb.stream_no
1029 1124
                
1030
                #self.actionLine.tag.streamline.
1031

  
1032 1125
                drawing.hmbTable.append(hmb)
1033 1126
                
1034 1127
                self.load_HMB()
......
1036 1129
        finally:
1037 1130
            self.actionLine.tag.reset()
1038 1131

  
1039

  
1040
    def load_HMB(self):
1132
    def clear_HMB(self):
1041 1133
        self.tableWidgetHMB.clearContents()
1042 1134
        self.tableWidgetHMB.setRowCount(0)
1043 1135

  
1136
    def load_HMB(self):        
1137
        self.clear_HMB()
1138

  
1044 1139
        drawing = AppDocData.instance().activeDrawing
1140
        if drawing is None:
1141
            return
1045 1142

  
1046 1143
        hmbs = drawing.hmbTable._hmbs
1047 1144
        if hmbs is not None:
......
1050 1147
            
1051 1148
            rowIndex = 0
1052 1149
            for hmb in hmbs:            
1053
                self.tableWidgetHMB.setItem(rowIndex, 0, QTableWidgetItem(str(hmb.uid)))
1054
                self.tableWidgetHMB.setItem(rowIndex, 1, QTableWidgetItem(str(hmb.drawing_uid)))
1055
                self.tableWidgetHMB.setItem(rowIndex, 2, QTableWidgetItem(str(hmb.stream_no)))
1150
                uid = QTableWidgetItem(str(hmb.uid))
1151
                uid.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
1152

  
1153
                drawing_uid = QTableWidgetItem(str(hmb.drawing_uid))
1154
                drawing_uid.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
1155

  
1156
                stream_no = QTableWidgetItem(str(hmb.stream_no))
1157
                stream_no.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
1158

  
1159
                tag_no = QTableWidgetItem(str(hmb.tag_no))
1160
                tag_no.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
1161

  
1162
                phase_type = QTableWidgetItem(str(hmb.phase_type))
1163
                phase_type.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
1164

  
1165

  
1166

  
1167
                self.tableWidgetHMB.setItem(rowIndex, 0, uid)
1168
                self.tableWidgetHMB.setItem(rowIndex, 1, drawing_uid)
1169
                self.tableWidgetHMB.setItem(rowIndex, 2, stream_no)
1170
                self.tableWidgetHMB.setItem(rowIndex, 3, tag_no)
1171
                self.tableWidgetHMB.setItem(rowIndex, 4, phase_type)
1056 1172

  
1057 1173
                rowIndex += 1
1058 1174
            
1059
        
1175
            
1060 1176
        
1061 1177

  
1062 1178
    '''
......
1170 1286
    '''
1171 1287
    def itemRemoved(self, item):
1172 1288
        try:
1173
            self.itemTreeWidget.itemRemoved(item)
1289
            #self.itemTreeWidget.itemRemoved(item)
1174 1290

  
1175 1291
            matches = [_item for _item in self.graphicsView.scene.items() if hasattr(_item, 'connectors') and \
1176 1292
            [connector for connector in _item.connectors if connector.connectedItem is not None and connector.connectedItem.parentItem() is item]]
HYTOS/HYTOS/MainWindow_UI.py
11 11
class Ui_MainWindow(object):
12 12
    def setupUi(self, MainWindow):
13 13
        MainWindow.setObjectName("MainWindow")
14
        MainWindow.resize(1169, 744)
14
        MainWindow.resize(905, 787)
15 15
        font = QtGui.QFont()
16 16
        font.setFamily("맑은 고딕")
17 17
        font.setBold(True)
......
32 32
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
33 33
        MainWindow.setCentralWidget(self.centralwidget)
34 34
        self.menubar = QtWidgets.QMenuBar(MainWindow)
35
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1169, 21))
35
        self.menubar.setGeometry(QtCore.QRect(0, 0, 905, 21))
36 36
        self.menubar.setObjectName("menubar")
37 37
        self.menu = QtWidgets.QMenu(self.menubar)
38 38
        self.menu.setObjectName("menu")
......
89 89
        self.gridLayout_5 = QtWidgets.QGridLayout(self.dockWidgetContents_3)
90 90
        self.gridLayout_5.setObjectName("gridLayout_5")
91 91
        self.horizontalLayout = QtWidgets.QHBoxLayout()
92
        self.horizontalLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
93
        self.horizontalLayout.setSpacing(6)
92 94
        self.horizontalLayout.setObjectName("horizontalLayout")
93 95
        self.tableWidgetHMB = QtWidgets.QTableWidget(self.dockWidgetContents_3)
94 96
        self.tableWidgetHMB.setObjectName("tableWidgetHMB")
95 97
        self.tableWidgetHMB.setColumnCount(0)
96 98
        self.tableWidgetHMB.setRowCount(0)
97 99
        self.horizontalLayout.addWidget(self.tableWidgetHMB)
98
        self.gridLayout_5.addLayout(self.horizontalLayout, 0, 0, 1, 1)
100
        self.horizontalLayout.setStretch(0, 88)
101
        self.gridLayout_5.addLayout(self.horizontalLayout, 0, 1, 1, 1)
99 102
        self.dockWidgetHMBList.setWidget(self.dockWidgetContents_3)
100 103
        MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(8), self.dockWidgetHMBList)
101 104
        self.toolBar = QtWidgets.QToolBar(MainWindow)
......
107 110
        self.toolBar.setIconSize(QtCore.QSize(32, 32))
108 111
        self.toolBar.setObjectName("toolBar")
109 112
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
113
        self.dockWidgetPropertyExplorer = QtWidgets.QDockWidget(MainWindow)
114
        self.dockWidgetPropertyExplorer.setObjectName("dockWidgetPropertyExplorer")
115
        self.dockWidgetContents_4 = QtWidgets.QWidget()
116
        self.dockWidgetContents_4.setObjectName("dockWidgetContents_4")
117
        self.gridLayout_3 = QtWidgets.QGridLayout(self.dockWidgetContents_4)
118
        self.gridLayout_3.setObjectName("gridLayout_3")
119
        self.verticalLayoutProperty = QtWidgets.QVBoxLayout()
120
        self.verticalLayoutProperty.setObjectName("verticalLayoutProperty")
121
        self.gridLayout_3.addLayout(self.verticalLayoutProperty, 1, 0, 1, 1)
122
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
123
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
124
        self.label = QtWidgets.QLabel(self.dockWidgetContents_4)
125
        font = QtGui.QFont()
126
        font.setBold(False)
127
        font.setWeight(50)
128
        self.label.setFont(font)
129
        self.label.setObjectName("label")
130
        self.horizontalLayout_2.addWidget(self.label)
131
        self.lineEdit = QtWidgets.QLineEdit(self.dockWidgetContents_4)
132
        font = QtGui.QFont()
133
        font.setBold(False)
134
        font.setWeight(50)
135
        self.lineEdit.setFont(font)
136
        self.lineEdit.setText("")
137
        self.lineEdit.setAlignment(QtCore.Qt.AlignCenter)
138
        self.lineEdit.setObjectName("lineEdit")
139
        self.horizontalLayout_2.addWidget(self.lineEdit)
140
        self.gridLayout_3.addLayout(self.horizontalLayout_2, 0, 0, 1, 1)
141
        self.gridLayout_3.setRowStretch(0, 20)
142
        self.gridLayout_3.setRowStretch(1, 80)
143
        self.dockWidgetPropertyExplorer.setWidget(self.dockWidgetContents_4)
144
        MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidgetPropertyExplorer)
110 145
        self.actionOpen = QtWidgets.QAction(MainWindow)
111 146
        icon = QtGui.QIcon()
112 147
        icon.addPixmap(QtGui.QPixmap(":/newPrefix/file.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
......
406 441
        self.treeWidgetDrawingList.setSortingEnabled(True)
407 442
        self.dockWidgetHMBList.setWindowTitle(_translate("MainWindow", "HMB List"))
408 443
        self.toolBar.setWindowTitle(_translate("MainWindow", "Main Toolbar"))
444
        self.dockWidgetPropertyExplorer.setWindowTitle(_translate("MainWindow", "Property Explorer"))
445
        self.label.setText(_translate("MainWindow", "Tag No. "))
409 446
        self.actionOpen.setText(_translate("MainWindow", "Open"))
410 447
        self.actionOpen.setToolTip(_translate("MainWindow", "Open(Ctrl + O)"))
411 448
        self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O"))
HYTOS/HYTOS/PhaseTypeDialog_UI.py
11 11
class Ui_PhaseTypeDialog(object):
12 12
    def setupUi(self, PhaseTypeDialog):
13 13
        PhaseTypeDialog.setObjectName("PhaseTypeDialog")
14
        PhaseTypeDialog.resize(350, 105)
14
        PhaseTypeDialog.resize(350, 130)
15 15
        PhaseTypeDialog.setMinimumSize(QtCore.QSize(350, 0))
16 16
        PhaseTypeDialog.setMaximumSize(QtCore.QSize(350, 350))
17 17
        font = QtGui.QFont()
......
33 33
        self.StreamNo.setObjectName("StreamNo")
34 34
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.StreamNo)
35 35
        self.lineEditSteamNo = QtWidgets.QLineEdit(PhaseTypeDialog)
36
        self.lineEditSteamNo.setEnabled(False)
37
        font = QtGui.QFont()
38
        font.setBold(False)
39
        font.setWeight(50)
40
        self.lineEditSteamNo.setFont(font)
41
        self.lineEditSteamNo.setText("")
42
        self.lineEditSteamNo.setAlignment(QtCore.Qt.AlignCenter)
36 43
        self.lineEditSteamNo.setObjectName("lineEditSteamNo")
37 44
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.lineEditSteamNo)
45
        self.PhaseType = QtWidgets.QLabel(PhaseTypeDialog)
46
        font = QtGui.QFont()
47
        font.setFamily("맑은 고딕")
48
        font.setPointSize(9)
49
        font.setBold(False)
50
        font.setWeight(50)
51
        self.PhaseType.setFont(font)
52
        self.PhaseType.setObjectName("PhaseType")
53
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.PhaseType)
38 54
        self.comboBoxPhaseType = QtWidgets.QComboBox(PhaseTypeDialog)
39 55
        font = QtGui.QFont()
40 56
        font.setBold(False)
41 57
        font.setWeight(50)
42 58
        self.comboBoxPhaseType.setFont(font)
43 59
        self.comboBoxPhaseType.setObjectName("comboBoxPhaseType")
44
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.comboBoxPhaseType)
45
        self.PhaseType = QtWidgets.QLabel(PhaseTypeDialog)
60
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.comboBoxPhaseType)
61
        self.TagNo = QtWidgets.QLabel(PhaseTypeDialog)
46 62
        font = QtGui.QFont()
47 63
        font.setFamily("맑은 고딕")
48 64
        font.setPointSize(9)
49 65
        font.setBold(False)
50 66
        font.setWeight(50)
51
        self.PhaseType.setFont(font)
52
        self.PhaseType.setObjectName("PhaseType")
53
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.PhaseType)
67
        self.TagNo.setFont(font)
68
        self.TagNo.setObjectName("TagNo")
69
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.TagNo)
70
        self.lineEditTagNo = QtWidgets.QLineEdit(PhaseTypeDialog)
71
        font = QtGui.QFont()
72
        font.setBold(False)
73
        font.setWeight(50)
74
        self.lineEditTagNo.setFont(font)
75
        self.lineEditTagNo.setCursorPosition(0)
76
        self.lineEditTagNo.setAlignment(QtCore.Qt.AlignCenter)
77
        self.lineEditTagNo.setObjectName("lineEditTagNo")
78
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEditTagNo)
54 79
        self.verticalLayout.addLayout(self.formLayout)
55 80
        self.errorLabel = QtWidgets.QLabel(PhaseTypeDialog)
56 81
        self.errorLabel.setMaximumSize(QtCore.QSize(16777215, 0))
......
79 104
        PhaseTypeDialog.setWindowTitle(_translate("PhaseTypeDialog", "Select Phase Type"))
80 105
        self.StreamNo.setText(_translate("PhaseTypeDialog", "Stream No."))
81 106
        self.PhaseType.setText(_translate("PhaseTypeDialog", "Phase Type"))
107
        self.TagNo.setText(_translate("PhaseTypeDialog", "Tag No."))
82 108

  
HYTOS/HYTOS/QDrawingDialog.py
11 11
import Drawing_UI
12 12

  
13 13
class QDrawingDialog(QDialog):    
14
    def __init__(self, parent):        
15
        QDialog.__init__(self, parent)
16
        _translate = QtCore.QCoreApplication.translate
14
    def __init__(self, uid = None):        
15
        QDialog.__init__(self, uid)
16
        #_translate = QtCore.QCoreApplication.translate
17 17

  
18
        self.uid = uid
18 19
        self.result = None
19 20
        self.ui = Drawing_UI.Ui_DrawingDialog()
20 21
        self.ui.setupUi(self)    
21 22
        self.ui.lineEditName.setFocus()
22
        self.setWindowTitle(_translate('New Drawing Dialog', 'New Drawing'))
23
        #self.setWindowTitle(_translate('New Drawing Dialog', 'New Drawing'))
23 24
        
24
    def showDialog(self):
25
    def showDialog(self, uid=None):
26
        _translate = QtCore.QCoreApplication.translate
27

  
28
        self.uid = uid
25 29
        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint)
26 30
        self.ui.lineEditName.setFocus()
31
        if self.uid is None:
32
            self.setWindowTitle(_translate('New Drawing Dialog', 'New Drawing'))
33
        else:
34
            self.setWindowTitle(_translate('Edit Drawing Dialog', 'Edit Drawing'))
27 35
        self.exec_()
28 36
    
29 37
        return self.result
......
36 44
            self.ui.lineEditName.setFocus()
37 45
            return
38 46
        
39
        if self.exists_drawing(drawingName):
40
            QMessageBox.warning(self, self.tr('Notice'), self.tr('Name already exists.'))      
41
            self.ui.lineEditName.setFocus()      
42
            return
43

  
47
        if self.uid is None:
48
            if self.exists_drawing(drawingName):
49
                QMessageBox.warning(self, self.tr('Notice'), self.tr('Name already exists.'))      
50
                self.ui.lineEditName.setFocus()      
51
                return
52
        
44 53
        self.saveDrawing(drawingName)
45

  
54
        
46 55
        self.result = drawingName
56

  
47 57
        QDialog.accept(self)
48 58

  
49 59
    def reject(self):
......
61 71
        return AppDocData.instance().exists_drawing(drawingName)
62 72

  
63 73
    def saveDrawing(self, drawingName):                
64
        drawings = []
65
        drawings.append([str(uuid.uuid4()), drawingName, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))])
74
        drawing = []
66 75

  
67
        AppDocData.instance().saveDrawings(drawings)
76
        if self.uid is None:
77
            drawing.append([str(uuid.uuid4()), drawingName, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))])
78
            AppDocData.instance().saveDrawing(drawing)
79
        else:
80
            drawing.append([str(self.uid), drawingName, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))])
81
            AppDocData.instance().updateDrawing(drawing)
68 82

  
69 83
    if __name__ == '__main__':
70 84
        from AppDocData import AppDocData
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py
42 42
            self.setAcceptTouchEvents(True)
43 43

  
44 44
            self.uid = uuid.uuid4() if uid is None else uid
45
            self.parent = parent
45 46
            self._vertices = []
46 47
            self.isCreated = False
47 48
            self._pt = None
......
342 343
        self.update()
343 344

  
344 345
    def mouseDoubleClickEvent(self, event):
346
        from AppDocData import AppDocData
347
        from MainWindow import MainWindow
345 348
        from PhaseTypeDialog import QPhaseTypeDialog
349
        from HMBTable import HMBTable
350

  
346 351
        dialog = QPhaseTypeDialog(None)
347 352
        selectedPhaseType = dialog.showDialog()
348 353

  
349
        #if selectedPhaseType:
350
            
351
            
354
        if selectedPhaseType:
355
            drawing = AppDocData.instance().activeDrawing
356
             
357
            hmbs = drawing.hmbTable._hmbs
358
            if hmbs is not None:
359
                for hmb in hmbs:
360
                    hmb.phase_type = selectedPhaseType
361
                
352 362
            
363

  
353 364
    def toSql(self):
354 365
        """ convert valve data to sql query """
355 366
        import uuid
......
386 397

  
387 398
    @staticmethod 
388 399
    def fromDatabase(componentInfos):
400
        from EngineeringConnectorItem import QEngineeringConnectorItem
389 401
        #from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
390 402
        #from EngineeringEndBreakItem import QEngineeringEndBreakItem
391 403
        #from SymbolAttr import SymbolAttr
......
399 411
                item._vertices.append((componentInfo[12], componentInfo[13]))
400 412
            
401 413
            connectorItems = []
414
            start_connector = QEngineeringConnectorItem()
415
            start_connector.setPos((componentInfos[0][12],componentInfos[0][13]))
416
            
417
            end_connector = QEngineeringConnectorItem()
418
            end_connector.setPos((componentInfos[-1][12],componentInfos[-1][13]))
419

  
420
            connectorItems.append(start_connector)
421
            connectorItems.append(end_connector)
402 422

  
403 423
            item.setVisible(False)
404 424
            item.__buildItem()
405 425
            item.build_connectors(connectorItems)
406 426
            item.update_arrow()
407
            
427
            item.update()
428

  
408 429
        except Exception as ex:
409 430
            from App import App 
410 431
            from AppDocData import MessageType
HYTOS/HYTOS/UI/MainWindow.ui
6 6
   <rect>
7 7
    <x>0</x>
8 8
    <y>0</y>
9
    <width>1169</width>
10
    <height>744</height>
9
    <width>905</width>
10
    <height>787</height>
11 11
   </rect>
12 12
  </property>
13 13
  <property name="font">
......
46 46
    <rect>
47 47
     <x>0</x>
48 48
     <y>0</y>
49
     <width>1169</width>
49
     <width>905</width>
50 50
     <height>21</height>
51 51
    </rect>
52 52
   </property>
......
176 176
   </attribute>
177 177
   <widget class="QWidget" name="dockWidgetContents_3">
178 178
    <layout class="QGridLayout" name="gridLayout_5">
179
     <item row="0" column="0">
180
      <layout class="QHBoxLayout" name="horizontalLayout">
179
     <item row="0" column="1">
180
      <layout class="QHBoxLayout" name="horizontalLayout" stretch="88">
181
       <property name="spacing">
182
        <number>6</number>
183
       </property>
184
       <property name="sizeConstraint">
185
        <enum>QLayout::SetDefaultConstraint</enum>
186
       </property>
181 187
       <item>
182 188
        <widget class="QTableWidget" name="tableWidgetHMB"/>
183 189
       </item>
......
218 224
   <addaction name="actionZoom"/>
219 225
   <addaction name="actionFitWindow"/>
220 226
  </widget>
227
  <widget class="QDockWidget" name="dockWidgetPropertyExplorer">
228
   <property name="windowTitle">
229
    <string>Property Explorer</string>
230
   </property>
231
   <attribute name="dockWidgetArea">
232
    <number>1</number>
233
   </attribute>
234
   <widget class="QWidget" name="dockWidgetContents_4">
235
    <layout class="QGridLayout" name="gridLayout_3" rowstretch="20,80">
236
     <item row="1" column="0">
237
      <layout class="QVBoxLayout" name="verticalLayoutProperty"/>
238
     </item>
239
     <item row="0" column="0">
240
      <layout class="QHBoxLayout" name="horizontalLayout_2">
241
       <item>
242
        <widget class="QLabel" name="label">
243
         <property name="font">
244
          <font>
245
           <weight>50</weight>
246
           <bold>false</bold>
247
          </font>
248
         </property>
249
         <property name="text">
250
          <string>Tag No. </string>
251
         </property>
252
        </widget>
253
       </item>
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

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