프로젝트

일반

사용자정보

개정판 c891962f

IDc891962fd1ddf3545890d8bec24394904eb0a92b
상위 517925eb
하위 48371578

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

issue #1197: 도면 저장 시 component의 index를 저장한다

Change-Id: I7d281233aac27e262f105e44ea5a13929a5896eb

차이점 보기:

HYTOS/HYTOS/AppDocData.py
385 385

  
386 386
        res = None
387 387

  
388
        conn = sqlite3.connect(drawing)
389
        conn.execute('PRAGMA foreign_keys = ON')
390
        with conn:
388
        with sqlite3.connect(drawing) as conn:
389
            conn.execute('PRAGMA foreign_keys = ON')
391 390
            try:
392 391
                conn.row_factory = sqlite3.Row
393 392
                # Get a cursor object
......
1133 1132

  
1134 1133
    def saveToDatabase(self, item, index):
1135 1134
        """ save given items to database """
1136
        conn = sqlite3.connect(self.activeDrawing.path, isolation_level=None)
1137
        conn.execute('PRAGMA foreign_keys = ON')
1138
        with conn:
1135
        with sqlite3.connect(self.activeDrawing.path, isolation_level=None) as conn:
1136
            conn.execute('PRAGMA foreign_keys = ON')
1139 1137
            try:
1140 1138
                # Get a cursor object
1141 1139
                cursor = conn.cursor()
......
1302 1300
        return SymbolCategoryList
1303 1301

  
1304 1302
    def getComponentByComponentUID(self, uid):
1305
        ComponentList = []
1306 1303

  
1307
        conn = sqlite3.connect(self.activeDrawing.path)
1308
        conn.execute('PRAGMA foreign_keys = ON')
1309
        with conn:
1304
        with sqlite3.connect(self.activeDrawing.path) as conn:
1305
            conn.execute('PRAGMA foreign_keys = ON')
1310 1306
            try:
1311 1307
                conn.row_factory = sqlite3.Row
1312 1308
                cursor = conn.cursor()
1313 1309

  
1314
                sql = """select c.uid
1310
                sql = """select c.UID as Comp_UID
1315 1311
                                , c.Name
1312
                                , c.[Index] as Comp_Index
1316 1313
                                , c.Symbols_UID
1317 1314
                                , t.Category
1318 1315
                                , t.type
1319
                                , s.Name
1316
                                , s.Name as Symbol_Name
1320 1317
                                , s.OriginalPoint
1321
                                , c.X
1322
                                , c.Y
1318
                                , c.X as Comp_X
1319
                                , c.Y as Comp_Y
1323 1320
                                , c.Rotation
1324 1321
                                , c.Scale
1325
                                , p.uid
1322
                                , p.UID as Point_UID
1326 1323
                                , p.[Index]
1327
                                , p.x
1328
                                , p.y
1324
                                , p.X
1325
                                , p.Y
1329 1326
                                , p.ConnectedItem_UID
1330 1327
                            from points p
1331 1328
                            left join components c
......
1338 1335
                            order by p.[Index]"""
1339 1336
                param = (uid,)
1340 1337
                cursor.execute(sql, param)
1341
                rows = cursor.fetchall()
1342
                for row in rows:
1343
                    data = []
1344
                    for index in range(len(cursor.description)):
1345
                        data.append(row[index])
1346
                    ComponentList.append(data)  # Components_UID
1338
                return cursor.fetchall()
1347 1339
            except Exception as ex:
1348 1340
                from App import App
1349 1341

  
......
1351 1343
                                                               sys.exc_info()[-1].tb_lineno)
1352 1344
                App.mainWnd().addMessage.emit(MessageType.Error, message)
1353 1345

  
1354
        return ComponentList
1346
        return None
1355 1347

  
1356 1348
    def get_nozzle_data(self, uid):
1357 1349
        """ get nozzle data of given uid """
HYTOS/HYTOS/Commands/HydroCalculationCommand.py
48 48
                    queue.append(QEngineeringLoopItem([match]))
49 49

  
50 50
            while queue:
51
                loop = queue.pop()
51
                loop = queue.pop(0)
52 52
                queue.extend(self.make_loop(loop))
53 53

  
54 54
            for loop in self.loops:
HYTOS/HYTOS/MainWindow.py
1927 1927
            for componentUID in componentsUID:
1928 1928
                componentInfos = app_doc_data.getComponentByComponentUID(componentUID)
1929 1929
                if (len(componentInfos)) > 0:
1930
                    category = componentInfos[0][3]  # Category@SymbolType
1930
                    category = componentInfos[0]['Category']  # Category@SymbolType
1931 1931

  
1932 1932
                    if category == 'Stream Line':
1933 1933
                        item = QEngineeringStreamlineItem.fromDatabase(componentInfos)
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py
937 937
        try:
938 938
            app_doc_data = AppDocData.instance()
939 939

  
940
            uid = componentInfos[0][0]  # uid@Components
940
            uid = componentInfos[0]['Comp_UID']  # uid@Components
941 941

  
942 942
            item = QEngineeringStreamlineItem(uid)
943 943
            hmb_data = app_doc_data.activeDrawing.hmbTable.get_hmb_data(uid)
......
945 945

  
946 946
            pointsUids = []
947 947
            for componentInfo in componentInfos:
948
                pointsUid = componentInfo[11]  # uid@Points
949
                x = componentInfo[13]  # X@Points
950
                y = componentInfo[14]  # Y@Points
948
                pointsUid = componentInfo['Point_UID']  # uid@Points
949
                x = componentInfo['X']  # X@Points
950
                y = componentInfo['Y']  # Y@Points
951 951

  
952 952
                pointsUids.append(pointsUid)
953 953
                item._vertices.append((x, y))
954 954

  
955
            connectorItems = [componentInfos[0][15], componentInfos[-1][15]]
955
            connectorItems = [componentInfos[0]['ConnectedItem_UID'], componentInfos[-1]['ConnectedItem_UID']]
956 956

  
957 957
            item.setVisible(False)
958 958
            item.build_connectors(connectorItems, pointsUids)
HYTOS/HYTOS/Shapes/SymbolSvgItem.py
231 231
        try:
232 232
            rect = self.sceneBoundingRect()
233 233

  
234
            cols = ['UID', 'Symbols_UID', 'Name', 'X', 'Y', 'Rotation', 'Scale']
235
            values = ['?', '?', '?', '?', '?', '?', '?']
236
            param = [str(self.uid), str(self.dbUid), str(self.tag_no), rect.left(), rect.top(), str(self.angle), self.transform().m11()]
234
            cols = ['UID', 'Symbols_UID', 'Name', '[Index]', 'X', 'Y', 'Rotation', 'Scale']
235
            values = ['?', '?', '?', '?', '?', '?', '?', '?']
236
            param = [str(self.uid), str(self.dbUid), str(self.tag_no), self.index, rect.left(), rect.top(),
237
                     str(self.angle), self.transform().m11()]
237 238
            sql = 'insert or replace into Components({}) values({})'.format(','.join(cols), ','.join(values))
238 239
            res.append((sql, tuple(param)))
239 240

  
......
253 254

  
254 255
        return res
255 256

  
256
    '''
257
        @brief  build symbol item
258
        @author humkyung
259
        @date   2018.05.02
260
        @history    2018.05.09  Jeongwoo    Clear self.connectors
261
                    2018.05.30  Jeongwoo    Add parameters (parentSymbol, childSymbol)
262
    '''
257
    def buildItem(self, name, _type, angle, scale, loc, origin, connPts, dbUid=None, pointsUids=None, index=None):
258
        """build symbol item"""
259

  
260
        from App import App
263 261

  
264
    def buildItem(self, name, _type, angle, scale, loc, origin, connPts, dbUid=None, pointsUids=None):
265 262
        try:
266
            if name in SymbolSvgItem.COUNTERS:
267
                SymbolSvgItem.COUNTERS[name] += 1
268
            else:
269
                SymbolSvgItem.COUNTERS[name] = 1
263
            if not index:
264
                matches = [item for item in App.mainWnd().graphicsView.scene.items()
265
                           if type(item) is SymbolSvgItem and item.name == name]
266
                if matches:
267
                    matches.sort(key=lambda item: item.index)
268
                    index = matches[-1].index + 1
270 269

  
271 270
            self.name = name
272
            self.index = SymbolSvgItem.COUNTERS[name]
271
            self.index = index
273 272
            self.type = _type
274 273
            self.angle = angle
275 274
            self._scale = scale
......
319 318
                self.connectors[index].setPos((x, y))
320 319
                self.connectors[index].connectPoint = (x, y)
321 320

  
322
            tooltip = '<b>{}</b><br>{}={}'.format(str(self.uid), self.type, self.name)
321
            tooltip = f"<b>{self.uid}</b><br>{self.type}={self.name}_{self.index}"
323 322
            self.setToolTip(tooltip)
324 323

  
325 324
            self.build_label()
......
998 997
        item = None
999 998

  
1000 999
        try:
1001
            uid = componentInfos[0][0]  # uid@Components
1002
            tag_no = componentInfos[0][1]  # name@Components
1003
            dbUid = componentInfos[0][2]  # Symbol_UID@Components
1004
            category = componentInfos[0][3]  # Category@SymbolType
1005
            _type = componentInfos[0][4]  # Type@SymbolType
1006
            name = componentInfos[0][5]  # Name@Symbols
1007
            originalPoint = componentInfos[0][6]  # OriginalPoint@Symbols
1008
            x = componentInfos[0][7]  # X@Components
1009
            y = componentInfos[0][8]  # Y@Components
1010
            angle = componentInfos[0][9]  # Rotation@Components
1011
            scale = componentInfos[0][10]  # Scale@Components
1000
            uid = componentInfos[0]['Comp_UID']  # uid@Components
1001
            tag_no = componentInfos[0]['Name']  # name@Components
1002
            index = componentInfos[0]['Comp_Index']
1003
            dbUid = componentInfos[0]['Symbols_UID']  # Symbol_UID@Components
1004
            category = componentInfos[0]['Category']  # Category@SymbolType
1005
            _type = componentInfos[0]['Type']  # Type@SymbolType
1006
            name = componentInfos[0]['Symbol_Name']  # Name@Symbols
1007
            originalPoint = componentInfos[0]['OriginalPoint']  # OriginalPoint@Symbols
1008
            x = componentInfos[0]['Comp_X']  # X@Components
1009
            y = componentInfos[0]['Comp_Y']  # Y@Components
1010
            angle = componentInfos[0]['Rotation']  # Rotation@Components
1011
            scale = componentInfos[0]['Scale']  # Scale@Components
1012 1012

  
1013 1013
            pt = []
1014 1014
            pt.append(float(x))
......
1020 1020

  
1021 1021
            pointsUids = []
1022 1022
            for componentInfo in componentInfos:
1023
                pointsUid = componentInfo[11]  # uid@Points
1023
                pointsUid = componentInfo['Point_UID']  # uid@Points
1024 1024
                pointsUids.append(pointsUid)
1025 1025

  
1026 1026
            app_doc_data = AppDocData.instance()
......
1029 1029
            if os.path.isfile(svgFilePath):
1030 1030
                item = SymbolSvgItem.createItem(_type, svgFilePath, uid, None, 0, dbUid)
1031 1031
                item.setVisible(False)
1032
                item.buildItem(name, _type, float(angle), float(scale), pt, origin, connPts, dbUid, pointsUids)
1032
                item.buildItem(name, _type, float(angle), float(scale), pt, origin, connPts, dbUid, pointsUids, index)
1033 1033
                item.tag_no = tag_no
1034 1034
        except Exception as ex:
1035 1035
            from App import App

내보내기 Unified diff

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