프로젝트

일반

사용자정보

개정판 25e0cacb

ID25e0cacbd48a204852740429ad7a267624d06e77
상위 dbf809df
하위 efb69f20

Gyusu 이(가) 6년 이상 전에 추가함

update

차이점 보기:

DTI_PID/DTI_PID.sln
1 1

2 2
Microsoft Visual Studio Solution File, Format Version 12.00
3 3
# Visual Studio 15
4
VisualStudioVersion = 15.0.26430.14
4
VisualStudioVersion = 15.0.27130.2027
5 5
MinimumVisualStudioVersion = 10.0.40219.1
6 6
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "DTI_PID", "DTI_PID\DTI_PID.pyproj", "{7C2E55A3-2B16-4B4F-867F-F16E2EF6F2F0}"
7 7
EndProject
......
31 31
		{60285A68-977E-4CBE-BD3E-5224BFA9D799}.Release|x64.Build.0 = Release|Any CPU
32 32
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 33
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Debug|Any CPU.Build.0 = Debug|Any CPU
34
<<<<<<< HEAD
34 35
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Debug|x64.ActiveCfg = Debug|Any CPU
35 36
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Debug|x64.Build.0 = Debug|Any CPU
37
=======
38
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Debug|x64.ActiveCfg = Debug|x64
39
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Debug|x64.Build.0 = Debug|x64
40
>>>>>>> ca32c11aca77cf342b602a9cca577d5a8dd0584c
36 41
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 42
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Release|Any CPU.Build.0 = Release|Any CPU
38 43
		{B7B8B0AE-9F03-4543-BC05-813A25E9D584}.Release|x64.ActiveCfg = Release|x64
DTI_PID/DTI_PID/App.py
41 41
'''
42 42
if __name__ == '__main__':
43 43
    import cv2
44
    import DTI_PID_UI
45 44
    from ProjectDialog import Ui_Dialog
46 45
    from MainWindow import MainWindow
47 46

  
DTI_PID/DTI_PID/AppDocData.py
139 139
        self._lineTypes = None
140 140
        self._lineTypeConfigs = None
141 141
        self._activeDrawing = None
142
        self._hmbTable = None
142 143

  
143 144
    '''
144 145
        @brief      Get DB file path in ProgramData
......
165 166

  
166 167
                conn = sqlite3.connect(dbPath)
167 168
                cursor = conn.cursor()
168
                sql = 'SELECT UID,RED,GREEN,BLUE,PROPERTY,VALUE FROM Colors WHERE PROPERTY IS NULL'
169
                sql = 'SELECT UID,RED,GREEN,BLUE FROM Colors'
169 170
                cursor.execute(sql)
170 171
                rows = cursor.fetchall()
171 172
                for row in rows:
172
                    self._colors.append(Color(int(row[0]), int(row[1]), int(row[2]), int(row[3]), row[4], row[5]))
173
                    self._colors.append(Color(int(row[0]), int(row[1]), int(row[2]), int(row[3])))
173 174
            # Catch the exception
174 175
            except Exception as ex:
175 176
                # Roll back any change if something goes wrong
......
223 224
        self._lineTypeConfigs = value
224 225

  
225 226
    '''
227
        @brief      getter of hmb table
228
        @author     humkyung
229
        @date       2018.07.16
230
    '''
231
    @property
232
    def hmbTable(self):
233
        from HMBTable import HMBTable
234

  
235
        if self._hmbTable is None:
236
            self._hmbTable = HMBTable()
237
            self._hmbTable.loadData()
238
        
239
        return self._hmbTable
240

  
241
    '''
242
        @brief      setter of hmb table
243
        @author     humkyung
244
        @date       2018.07.16
245
    '''
246
    @hmbTable.setter
247
    def hmbTable(self, value):
248
        self._hmbTable = value
249

  
250
    '''
226 251
        @brief  get line type config of given line type
227 252
        @author humkyung
228 253
        @date   2018.06.28
......
552 577
        @author     Jeongwoo
553 578
        @date       18.05.08
554 579
        @history    humkyung 2018.06.19 make 'Tile' directory
580
                    humkyung 2018.07.09 make drawing folder if not exists
555 581
    '''
556 582
    def makeChildDir(self):
557 583
        project = AppDocData.instance().getCurrentProject()
......
570 596
        tempDir = project.getTempPath()
571 597
        if not os.path.exists(tempDir):
572 598
            os.makedirs(tempDir)
599
        drawingPath = project.getDrawingFilePath()
600
        if not os.path.exists(drawingPath):
601
            os.makedirs(drawingPath)
573 602
        
574 603
        path = os.path.join(tempDir, 'Tile')
575 604
        if not os.path.exists(path):
......
1129 1158
        return ret
1130 1159

  
1131 1160
    '''
1132
        @brief      get nominal pipe size
1161
        @brief      get NominalDiameter
1133 1162
        @author     humkyung
1134 1163
        @date       2018.04.20
1135 1164
        @history    humkyung 2018.04.24 read MetricStr column and set size unit
1136 1165
                    kyouho 2018.07.04 forCheckLineNumber get only inch or metric
1166
                    kyouho 2018.07.16 edit query order by code
1137 1167
    '''
1138
    def getNomialPipeSizeData(self, forCheckLineNumber = False):
1168
    def getNomialPipeSizeData(self, forCheckLineNumber = False, orderStr = "CODE"):
1139 1169
        res = []
1140 1170
        try:
1141 1171
            configs = self.getConfigs('Line No', 'Size Unit')
......
1147 1177
            # Get a cursor object
1148 1178
            cursor = conn.cursor()
1149 1179

  
1150
            sql = "select Code,Metric,Inch,InchStr,MetricStr from 'NOMINAL PIPE SIZE' ORDER BY METRIC ASC"
1180
            sql = "select Code,Metric,Inch,InchStr,MetricStr from NominalDiameter ORDER BY {} ASC".format(orderStr)
1151 1181
            cursor.execute(sql)
1152 1182
            rows = cursor.fetchall()
1153 1183
            for row in rows:
1154
                pipeSize = NominalPipeSize(row[0], float(row[1]) if row[1] is not None else -1, float(row[2]) if row[2] is not None else -1, row[3], row[4])
1184
                pipeSize = NominalPipeSize(row[0], float(row[1]) if row[1] is not None else None, float(row[2]) if row[2] is not None else None, row[3], row[4])
1155 1185
                pipeSize.sizeUnit = sizeUnit
1156 1186
                if forCheckLineNumber:
1157 1187
                    if sizeUnit == 'Inch' and pipeSize.inchStr:
......
1171 1201
            conn.close()
1172 1202

  
1173 1203
        return res
1174
    
1204

  
1175 1205
    '''
1176
        @brief      get Color
1206
        @brief      insert NominalDiameter table
1177 1207
        @author     kyouho
1178
        @date       2018.07.03
1208
        @date       2018.07.16
1179 1209
    '''
1180
    def getPropertyColor(self, property):
1181
        result = []
1182

  
1210
    def insertNomialPipeSize(self, pipeSizes):
1183 1211
        try:
1184 1212
            # Creates or opens a file called mydb with a SQLite3 DB
1185 1213
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1186 1214
            conn = sqlite3.connect(dbPath)
1187 1215
            # Get a cursor object
1188 1216
            cursor = conn.cursor()
1189

  
1190
            sql = "select UID,RED,GREEN,BLUE,PROPERTY,VALUE from Colors WHERE PROPERTY = '{}'".format(property)
1191
            cursor.execute(sql)
1192
            rows = cursor.fetchall()
1193
            for row in rows:
1194
                result.append(Color(int(row[0]), int(row[1]), int(row[2]), int(row[3]), row[4], row[5]))
1217
            sql = "INSERT INTO NominalDiameter(Code, Metric, Inch, InchStr, MetricStr) VALUES(?,?,?,?,?)"
1218
            for pipeSize in pipeSizes:
1219
                param = (pipeSize.code, pipeSize.metric, pipeSize.inch, pipeSize.inchStr, pipeSize.metricStr)
1220
                cursor.execute(sql, param)
1221
            conn.commit()
1195 1222
            # Catch the exception
1196 1223
        except Exception as ex:
1197 1224
            # Roll back any change if something goes wrong
......
1201 1228
            # Close the db connection
1202 1229
            conn.close()
1203 1230

  
1204
        return result
1205 1231

  
1206 1232
    '''
1207
        @brief      convert inch to metric
1233
        @brief      delete NominalDiameter table
1208 1234
        @author     kyouho
1209
        @date       2018.07.09
1235
        @date       2018.07.16
1210 1236
    '''
1211
    def convertInchToMetric(self, inch):
1212
        result = ''
1237
    def deleteNomialPipeSize(self):
1213 1238
        try:
1214
            # Creates or opens a file called mydb with a SQLite3 DB
1215
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1239
            dbPath = self.getCurrentProject().getPath() + "/db/ITI_PID.db"
1216 1240
            conn = sqlite3.connect(dbPath)
1217
            # Get a cursor object
1218 1241
            cursor = conn.cursor()
1219
            
1220
            sql = "select MetricStr from 'NOMINAL PIPE SIZE' WHERE InchStr = '{}'".format(inch)
1221
            cursor.execute(sql)
1222
            rows = cursor.fetchall()
1223

  
1224
            if rows:
1225
                result = rows[0][0]
1226
            # Catch the exception
1227
        except Exception as ex:
1228
            # Roll back any change if something goes wrong
1229
            conn.rollback()
1230
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1242
            sql = "DELETE FROM NominalDiameter"
1243
            try:
1244
                cursor.execute(sql)
1245
                conn.commit()
1246
            except Exception as ex:
1247
                print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1231 1248
        finally:
1232
            # Close the db connection
1233 1249
            conn.close()
1250
    
1251

  
1234 1252

  
1235
        return result
1236 1253

  
1237 1254
    '''
1238
        @brief      get one color
1255
        @brief      convert inch to metric
1239 1256
        @author     kyouho
1240 1257
        @date       2018.07.09
1241 1258
    '''
1242
    def getColor(self, property, value):
1243
        result = None
1244

  
1259
    def convertInchToMetric(self, inch):
1260
        result = ''
1245 1261
        try:
1246 1262
            # Creates or opens a file called mydb with a SQLite3 DB
1247 1263
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1248 1264
            conn = sqlite3.connect(dbPath)
1249 1265
            # Get a cursor object
1250 1266
            cursor = conn.cursor()
1267
            
1268
            sql = "select MetricStr from NominalDiameter WHERE InchStr = ?"
1269
            param = (inch,)
1270
            cursor.execute(sql, param)
1271
            rows = cursor.fetchall()
1251 1272

  
1252
            sql = "select UID,RED,GREEN,BLUE,PROPERTY,VALUE from Colors WHERE PROPERTY = '{}' AND VALUE = '{}'".format(property, value)
1253
            cursor.execute(sql)
1254
            row = cursor.fetchall()
1255
            if row:
1256
                result = Color(int(row[0][0]), int(row[0][1]), int(row[0][2]), int(row[0][3]), row[0][4], row[0][5])
1273
            if rows:
1274
                result = rows[0][0]
1257 1275
            # Catch the exception
1258 1276
        except Exception as ex:
1259 1277
            # Roll back any change if something goes wrong
......
1264 1282
            conn.close()
1265 1283

  
1266 1284
        return result
1285

  
1267 1286
    '''
1268 1287
        @brief      get Color MaxUID
1269 1288
        @author     kyouho
......
1383 1402
        return result
1384 1403

  
1385 1404
    '''
1386
        @brief      set Fluid Code
1405
        @brief      get Symbol Attribute
1387 1406
        @author     kyouho
1388
        @date       2018.07.03
1407
        @date       2018.07.18
1389 1408
    '''
1390
    def setFluidCodeData(self, addDataList, removeDataList):
1409
    def checkAttribute(self, attr):
1391 1410
        try:
1392 1411
            # Creates or opens a file called mydb with a SQLite3 DB
1393 1412
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
......
1395 1414
            # Get a cursor object
1396 1415
            cursor = conn.cursor()
1397 1416

  
1398
            for data in addDataList:
1399
                uid = data.uid
1417
            sql = 'select attribute from SymbolAttribute where Attribute = ?'
1418
            param = (attr,)
1419
            cursor.execute(sql, param)
1420
            rows = cursor.fetchall()
1421
            if len(rows):
1422
                return True
1423
            else:
1424
                return False
1425
            # Catch the exception
1426
        except Exception as ex:
1427
            # Roll back any change if something goes wrong
1428
            conn.rollback()
1429
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1430
        finally:
1431
            # Close the db connection
1432
            conn.close()
1433

  
1434
        return False
1435

  
1436
    '''
1437
        @brief      get Symbol Attribute
1438
        @author     kyouho
1439
        @date       2018.07.18
1440
    '''
1441
    def getSymbolAttribute(self, _type):
1442
        result = []
1443

  
1444
        try:
1445
            # Creates or opens a file called mydb with a SQLite3 DB
1446
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1447
            conn = sqlite3.connect(dbPath)
1448
            # Get a cursor object
1449
            cursor = conn.cursor()
1450

  
1451
            sql = 'select a.attribute from SymbolAttribute a inner join SymbolType t on a.SymbolType = t.id and t.type = ? order by attribute'
1452
            param = (_type,)
1453
            cursor.execute(sql, param)
1454
            rows = cursor.fetchall()
1455
            for row in rows:
1456
                result.append(row[0])
1457
            # Catch the exception
1458
        except Exception as ex:
1459
            # Roll back any change if something goes wrong
1460
            conn.rollback()
1461
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1462
        finally:
1463
            # Close the db connection
1464
            conn.close()
1465

  
1466
        return result
1467

  
1468
    '''
1469
        @brief      get Code Table Data
1470
        @author     kyouho
1471
        @date       2018.07.10
1472
    '''
1473
    def getCodeTable(self, property, forCheckLineNumber = False):
1474
        result = []
1475
        try:
1476
            # Creates or opens a file called mydb with a SQLite3 DB
1477
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1478
            conn = sqlite3.connect(dbPath)
1479
            # Get a cursor object
1480
            cursor = conn.cursor()
1481

  
1482
            sql = 'select uid, code, description from {} order by length(code) DESC'.format(property)
1483
            cursor.execute(sql)
1484
            rows = cursor.fetchall()
1485
            for row in rows:
1486
                if forCheckLineNumber:
1487
                    data = row[1]
1488
                else:
1489
                    data = (row[0], row[1], row[2])
1490
                result.append(data)
1491
            # Catch the exception
1492
        except Exception as ex:
1493
            # Roll back any change if something goes wrong
1494
            conn.rollback()
1495
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1496
        finally:
1497
            # Close the db connection
1498
            conn.close()
1499

  
1500
        return result
1501

  
1502
    '''
1503
        @brief      Set Common Code Data
1504
        @author     kyouho
1505
        @date       2018.07.12
1506
    '''
1507
    def setCommonCodeData(self, tableName, datas):
1508
        try:
1509
            # Creates or opens a file called mydb with a SQLite3 DB
1510
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1511
            conn = sqlite3.connect(dbPath)
1512
            # Get a cursor object
1513
            cursor = conn.cursor()
1514

  
1515
            for data in datas:
1516
                uid = data[0]
1400 1517
                if not uid:
1401
                    sql = "insert or replace into FluidCode(UID, CODE, DESCRIPTION) values(lower(hex(randomblob(16))), ?, ?)"
1402
                    param = (data.code, data.description)
1518
                    sql = "insert or replace into {}(UID, CODE, DESCRIPTION) values(lower(hex(randomblob(16))), ?, ?)".format(tableName)
1519
                    param = (data[1], data[2])
1403 1520
                else:
1404
                    sql = "update FluidCode SET CODE=?, DESCRIPTION=? WHERE UID = ?"
1405
                    param = (data.code, data.description, data.uid)
1521
                    sql = "update {} SET CODE=?, DESCRIPTION=? WHERE UID = ?".format(tableName)
1522
                    param = (data[1], data[2], data[0])
1406 1523
                cursor.execute(sql, param)
1407 1524

  
1408
            for data in removeDataList:
1409
                uid = data.uid
1525
            conn.commit()
1526
        
1527
        # Catch the exception
1528
        except Exception as ex:
1529
            # Roll back any change if something goes wrong
1530
            conn.rollback()
1531
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1532
        finally:
1533
            # Close the db connection
1534
            conn.close()
1535

  
1536
    '''
1537
        @brief      Set Common Code Data
1538
        @author     kyouho
1539
        @date       2018.07.12
1540
    '''
1541
    def deleteCommonCodeData(self, datas):
1542
        try:
1543
            # Creates or opens a file called mydb with a SQLite3 DB
1544
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1545
            conn = sqlite3.connect(dbPath)
1546
            # Get a cursor object
1547
            cursor = conn.cursor()
1548

  
1549
            for data in datas:
1550
                uid = data[0]
1551
                tableName = data[1]
1552

  
1410 1553
                if uid:
1411
                    sql = "delete from FluidCode where UID = ?"
1554
                    sql = "delete from {} where UID = ?".format(tableName)
1412 1555
                    param = (uid,)
1413 1556
                    cursor.execute(sql, param)
1414 1557

  
1558
                cursor.execute(sql, param)
1559

  
1415 1560
            conn.commit()
1416 1561
        
1417 1562
        # Catch the exception
DTI_PID/DTI_PID/CodeTableDialog.py
1
# coding: utf-8
2
import os
3
import sys
4
from PyQt5.QtCore import *
5
from PyQt5.QtGui import *
6
from PyQt5.QtWidgets import *
7
import sqlite3
8
from AppDocData import AppDocData
9
from AppDocData import Config
10
import CodeTable_UI
11

  
12
class QCodeTableDialog(QDialog):
13
    def __init__(self, parent):
14
        QDialog.__init__(self, parent)
15

  
16
        self.removeUID = {}
17
        self.currentCode = {}
18

  
19
        self.ui = CodeTable_UI.Ui_CodeTableDialog()
20
        self.ui.setupUi(self)
21

  
22
        #DB Table명 기준으로 작성
23
        self.settingTable("Nominal Diameter")
24
        self.settingTable("Fluid Code")
25
        self.settingTable("Insulation Purpose")
26
        self.settingTable("PnID Number")
27
        self.settingTable("Piping Materials Class")
28
        self.settingTable("Unit Number")
29
        
30

  
31

  
32
    '''
33
        @brief      Setting Table
34
        @author     kyouho
35
        @date       2018.07.10
36
    '''
37
    def settingTable(self, tableName):
38
        try:
39
            tableName = self.replaceText(tableName)
40
            docData = AppDocData.instance()
41
            table = self.findTableWidget(tableName)
42
            if tableName == "NominalDiameter":
43
                tableDatas = docData.getNomialPipeSizeData()
44
            else:
45
                tableDatas = docData.getCodeTable(tableName)
46

  
47
            if tableName == "NominalDiameter":
48
                self.insertTableWidgetNominalPipeSizeRow(tableDatas)
49

  
50
                table.cellChanged.connect(self.cellValueChanged)
51
                self.checkRowAndAddRow(tableName, table)
52
            else:
53
                table.setColumnCount(3)
54
                table.setHorizontalHeaderLabels(['uid', 'Code', 'Desc.'])
55
                table.hideColumn(0)
56

  
57
                self.insertTableWidgetCommonRow(table, tableDatas)
58
                
59
                table.horizontalHeaderItem(1).setSizeHint(QSize(30, 30))
60
                table.cellChanged.connect(self.cellValueChanged)
61
                self.checkRowAndAddRow(tableName, table)
62
                self.setCurrentCode(table, tableName)
63
        except Exception as ex:
64
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
65

  
66

  
67
    '''
68
        @brief      Insert row NominalPipeSzie Tablewidget
69
        @author     kyouho
70
        @date       2018.07.10
71
    '''
72
    def insertTableWidgetNominalPipeSizeRow(self, pipeSizes):
73
        try:
74
            self.ui.tableWidgetNominalDiameter.setColumnCount(5)
75
            self.ui.tableWidgetNominalDiameter.setHorizontalHeaderLabels(['Code', 'Metric', 'Inch', 'InchStr', 'MetricStr'])
76
            self.ui.tableWidgetNominalDiameter.setRowCount(len(pipeSizes))
77
            row = 0
78
            for pipeSize in pipeSizes:
79
                self.ui.tableWidgetNominalDiameter.setItem(row, 0, QTableWidgetItem(pipeSize.code))
80
                self.ui.tableWidgetNominalDiameter.setItem(row, 1, QTableWidgetItem('' if pipeSize.metric is None else str(pipeSize.metric)))
81
                self.ui.tableWidgetNominalDiameter.setItem(row, 2, QTableWidgetItem('' if pipeSize.inch is None else str(pipeSize.inch)))
82
                self.ui.tableWidgetNominalDiameter.setItem(row, 3, QTableWidgetItem('' if pipeSize.inchStr is None else pipeSize.inchStr))
83
                self.ui.tableWidgetNominalDiameter.setItem(row, 4, QTableWidgetItem('' if pipeSize.metricStr is None else pipeSize.metricStr))
84
                row += 1
85

  
86
            self.ui.tableWidgetNominalDiameter.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
87
        except Exception as ex:
88
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
89

  
90

  
91

  
92
    '''
93
        @brief      Insert row Common Tablewidget
94
        @author     kyouho
95
        @date       2018.07.10
96
    '''
97
    def insertTableWidgetCommonRow(self, table, tableDatas):
98
        try:
99
            table.setRowCount(len(tableDatas))
100
            row = 0
101
            for tableData in tableDatas:
102
                table.setItem(row, 0, QTableWidgetItem(tableData[0]))
103
                table.setItem(row, 1, QTableWidgetItem(tableData[1]))
104
                table.setItem(row, 2, QTableWidgetItem(tableData[2]))
105
                row += 1
106
        except Exception as ex:
107
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
108

  
109

  
110
    '''
111
        @brief      Find TableWidget with Name
112
        @author     kyouhokyouho
113
        @date       2018.07.10
114
    '''
115
    def findTableWidget(self, tableName):
116
        tableName = self.replaceText(tableName)
117
        return self.findChild(QTableWidget, 'tableWidget' + tableName)
118

  
119
    '''
120
        @brief      key press event
121
        @author     kyouho
122
        @date       2018.07.10
123
    '''
124
    def keyPressEvent(self, e):
125
        try:
126
            if e.key() == Qt.Key_Delete:
127
                _tabWidget = self.ui.tabWidget
128
                currentTabIndex = _tabWidget.currentIndex()
129
                tabText = self.replaceText(_tabWidget.tabText(currentTabIndex))
130
                table = self.findTableWidget(tabText)
131
                if table:
132
                    selectedIndexes = table.selectedIndexes()
133
                    selectedRows = [item.row() for item in selectedIndexes]
134
                    model = table.model()
135

  
136
                    rowsIndex = []
137
                    for row in selectedRows:
138
                        rowsIndex.append(row)
139
            
140
                    #중복 제거
141
                    rowsIndex = list(set(rowsIndex))
142
                    rowsIndex.reverse()
143
                    
144
                    if tabText != "NominalDiameter":
145
                        for row in rowsIndex:
146
                            uid = table.item(row, 0).text()
147
                            self.removeUID[uid] = tabText
148
                            model.removeRow(row)
149

  
150
                        self.checkRowAndAddRow(tabText, table)
151
                    
152
                         
153
        except Exception as ex:
154
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
155

  
156
    '''
157
        @brief      Add new row
158
        @author     kyouho
159
        @date       2018.07.10
160
    '''
161
    def checkRowAndAddRow(self, tableName, table):
162
        try:
163
            rowCount = table.rowCount()
164
            result = True
165
            if tableName != "NominalDiameter":
166
                for row in range(rowCount):
167
                    code = table.item(row, 1).text()
168
                    if not code:
169
                        result = False
170
                if result:
171
                    table.cellChanged.disconnect(self.cellValueChanged)
172
                    table.setRowCount(rowCount + 1)
173
                    table.setItem(rowCount, 0, QTableWidgetItem(''))
174
                    table.setItem(rowCount, 1, QTableWidgetItem(''))
175
                    table.setItem(rowCount, 2, QTableWidgetItem(''))
176
                    table.cellChanged.connect(self.cellValueChanged)
177
            else:
178
                columnCount = table.columnCount()
179

  
180
                for row in range(rowCount):
181
                    if not result:
182
                        break
183
                    for columnIndex in range(columnCount):
184
                        if not table.item(row, columnIndex).text():
185
                            result = False
186
                            break
187
 
188
                if result:
189
                    table.setRowCount(rowCount + 1)
190
                    table.cellChanged.disconnect(self.cellValueChanged)
191
                    for columnIndex in range(columnCount):
192
                        table.setItem(rowCount, columnIndex, QTableWidgetItem(''))    
193
                    table.cellChanged.connect(self.cellValueChanged)
194
            
195
        except Exception as ex:
196
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
197

  
198
    '''
199
        @brief      cellValueChange event
200
        @author     kyouho
201
        @date       2018.07.10
202
    '''
203
    def cellValueChanged(self, row, column):
204
        try:
205
            _tabWidget = self.ui.tabWidget
206
            currentTabIndex = _tabWidget.currentIndex()
207
            tabText = self.replaceText(_tabWidget.tabText(currentTabIndex))
208
            table = self.findTableWidget(tabText)
209

  
210
            if tabText != "NominalDiameter":
211
                item = table.item(row, 1)
212
                code = item.text()
213
                if column == 1:
214
                    result = self.isExistCode(table, code)
215
                    if result:
216
                        self.checkRowAndAddRow(tabText, table)
217
                        self.setCurrentCode(table, tabText)
218
                    else:
219
                        item.setText(self.currentCode[tabText][row])
220
                else:
221
                    table.resizeColumnToContents(2)
222
            else:
223
                self.checkRowAndAddRow(tabText, table)
224

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

  
228
    '''
229
        @brief      Check  Duplicate Code 
230
        @author     kyouho
231
        @date       2018.07.10
232
    '''
233
    def isExistCode(self, table, editCode):
234
        try:
235
            if not editCode:
236
                return False
237

  
238
            rowCount = table.rowCount()
239
            codes = []
240
            for row in range(rowCount):
241
                code = table.item(row, 1).text()
242
                codes.append(code)
243

  
244
            count = codes.count(editCode)
245
            
246
            if count >=2:
247
                return False
248
            else:
249
                return True
250

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

  
254
    '''
255
        @brief      save current Code (self.currentCode)
256
        @author     kyouho
257
        @date       2018.07.10
258
    '''
259
    def setCurrentCode(self, table, tabText):
260
        try:
261
            self.currentCode[tabText] = {}
262
            rowCount = table.rowCount()
263

  
264
            res = {}
265
            for row in range(rowCount):
266
                code = table.item(row, 1).text()
267
                res[row] = code
268

  
269
            self.currentCode[tabText] = res
270

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

  
274
    
275
    '''
276
        @brief      replaceTextForCodeTable
277
        @author     kyouho
278
        @date       2018.07.12
279
    '''
280
    def replaceText(self, text):
281
        return text.replace(' ','').replace('&&', 'n')
282

  
283

  
284
    '''
285
        @brief      save codes
286
        @author     kyouho
287
        @date       2018.07.12
288
    '''
289
    def accept(self):
290

  
291
        self.saveCommonCodeData("Fluid Code")
292
        self.saveCommonCodeData("Insulation Purpose")
293
        self.saveCommonCodeData("PnID Number")
294
        self.saveCommonCodeData("Piping Materials Class")
295
        self.saveCommonCodeData("Unit Number")
296
        self.deleteCommonCodeData()
297

  
298
        self.saveNomialPipeSize()
299

  
300
        QDialog.accept(self)
301

  
302
    '''
303
        @brief      save common code data
304
        @author     kyouho
305
        @date       2018.07.12
306
    '''
307
    def saveCommonCodeData(self, tableName):
308
        datas = []
309
        try:
310
            tableName = self.replaceText(tableName)
311
            table = self.findTableWidget(tableName)
312
            rowCount = table.rowCount()
313
            for row in range(rowCount):
314
                uid = table.item(row, 0).text()
315
                code = table.item(row, 1).text()
316
                description = table.item(row, 2).text()
317

  
318
                if code:
319
                    datas.append((uid, code, description))
320

  
321
            docData = AppDocData.instance()
322
            docData.setCommonCodeData(tableName, datas)
323

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

  
327
    '''
328
        @brief      save common code data
329
        @author     kyouho
330
        @date       2018.07.12
331
    '''
332
    def deleteCommonCodeData(self):
333
        try:
334
            datas = self.removeUID.items()
335
            docData = AppDocData.instance()
336
            docData.deleteCommonCodeData(datas)
337
        except Exception as ex:
338
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
339

  
340
    '''
341
        @brief      save common code data
342
        @author     kyouho
343
        @date       2018.07.16
344
    '''
345
    def saveNomialPipeSize(self):
346
        pipeSizes = []
347
        try:
348
            docData = AppDocData.instance()
349
            self.deleteNomialPipeSize()
350

  
351
            from AppDocData import NominalPipeSize
352
            
353
            table = self.ui.tableWidgetNominalDiameter
354
            rowCount = table.rowCount()
355
            for row in range(rowCount):
356
                code = table.item(row, 0).text()
357
                metric = table.item(row, 1).text()
358
                inch = table.item(row, 2).text()
359
                inchStr = table.item(row, 3).text()
360
                metricStr = table.item(row, 4).text()
361

  
362
                pipeSize = NominalPipeSize(code, float(metric) if metric != '' else None, float(inch) if inch != '' else None, inchStr, metricStr)
363
                pipeSizes.append(pipeSize)
364

  
365
            docData.insertNomialPipeSize(pipeSizes)
366

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

  
370

  
371

  
372

  
373

  
374

  
375

  
376

  
377

  
378

  
379
    '''
380
        @brief      save common code data
381
        @author     kyouho
382
        @date       2018.07.16
383
    '''
384
    def deleteNomialPipeSize(self):
385
        docData = AppDocData.instance()
386
        docData.deleteNomialPipeSize()
387

  
388

  
389

  
390

  
391
        
392

  
393

  
394

  
DTI_PID/DTI_PID/CodeTable_UI.py
1
# -*- coding: utf-8 -*-
2

  
3
# Form implementation generated from reading ui file './UI/CodeTable.ui'
4
#
5
# Created by: PyQt5 UI code generator 5.9.2
6
#
7
# WARNING! All changes made in this file will be lost!
8

  
9
from PyQt5 import QtCore, QtGui, QtWidgets
10

  
11
class Ui_CodeTableDialog(object):
12
    def setupUi(self, CodeTableDialog):
13
        CodeTableDialog.setObjectName("CodeTableDialog")
14
        CodeTableDialog.resize(550, 589)
15
        font = QtGui.QFont()
16
        font.setFamily("맑은 고딕")
17
        CodeTableDialog.setFont(font)
18
        CodeTableDialog.setModal(True)
19
        self.gridLayout = QtWidgets.QGridLayout(CodeTableDialog)
20
        self.gridLayout.setObjectName("gridLayout")
21
        self.buttonBox = QtWidgets.QDialogButtonBox(CodeTableDialog)
22
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
23
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
24
        self.buttonBox.setObjectName("buttonBox")
25
        self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1)
26
        self.tabWidget = QtWidgets.QTabWidget(CodeTableDialog)
27
        self.tabWidget.setObjectName("tabWidget")
28
        self.tabNominalDiameter = QtWidgets.QWidget()
29
        self.tabNominalDiameter.setObjectName("tabNominalDiameter")
30
        self.gridLayout_4 = QtWidgets.QGridLayout(self.tabNominalDiameter)
31
        self.gridLayout_4.setObjectName("gridLayout_4")
32
        self.verticalLayout = QtWidgets.QVBoxLayout()
33
        self.verticalLayout.setObjectName("verticalLayout")
34
        self.groupBox = QtWidgets.QGroupBox(self.tabNominalDiameter)
35
        self.groupBox.setObjectName("groupBox")
36
        self.gridLayout_13 = QtWidgets.QGridLayout(self.groupBox)
37
        self.gridLayout_13.setObjectName("gridLayout_13")
38
        self.tableWidgetNominalDiameter = QtWidgets.QTableWidget(self.groupBox)
39
        self.tableWidgetNominalDiameter.setColumnCount(4)
40
        self.tableWidgetNominalDiameter.setObjectName("tableWidgetNominalDiameter")
41
        self.tableWidgetNominalDiameter.setRowCount(0)
42
        self.tableWidgetNominalDiameter.verticalHeader().setVisible(False)
43
        self.gridLayout_13.addWidget(self.tableWidgetNominalDiameter, 0, 0, 1, 1)
44
        self.verticalLayout.addWidget(self.groupBox)
45
        self.gridLayout_4.addLayout(self.verticalLayout, 0, 0, 1, 1)
46
        self.tabWidget.addTab(self.tabNominalDiameter, "")
47
        self.tabFluidCode = QtWidgets.QWidget()
48
        self.tabFluidCode.setObjectName("tabFluidCode")
49
        self.gridLayout_3 = QtWidgets.QGridLayout(self.tabFluidCode)
50
        self.gridLayout_3.setObjectName("gridLayout_3")
51
        self.gridLayout_2 = QtWidgets.QGridLayout()
52
        self.gridLayout_2.setObjectName("gridLayout_2")
53
        self.groupBox_2 = QtWidgets.QGroupBox(self.tabFluidCode)
54
        self.groupBox_2.setObjectName("groupBox_2")
55
        self.gridLayout_14 = QtWidgets.QGridLayout(self.groupBox_2)
56
        self.gridLayout_14.setObjectName("gridLayout_14")
57
        self.tableWidgetFluidCode = QtWidgets.QTableWidget(self.groupBox_2)
58
        self.tableWidgetFluidCode.setColumnCount(3)
59
        self.tableWidgetFluidCode.setObjectName("tableWidgetFluidCode")
60
        self.tableWidgetFluidCode.setRowCount(0)
61
        self.tableWidgetFluidCode.verticalHeader().setVisible(False)
62
        self.gridLayout_14.addWidget(self.tableWidgetFluidCode, 0, 0, 1, 1)
63
        self.gridLayout_2.addWidget(self.groupBox_2, 0, 0, 1, 1)
64
        self.gridLayout_3.addLayout(self.gridLayout_2, 0, 0, 1, 1)
65
        self.tabWidget.addTab(self.tabFluidCode, "")
66
        self.tabInsulationPurpose = QtWidgets.QWidget()
67
        self.tabInsulationPurpose.setObjectName("tabInsulationPurpose")
68
        self.gridLayout_6 = QtWidgets.QGridLayout(self.tabInsulationPurpose)
69
        self.gridLayout_6.setObjectName("gridLayout_6")
70
        self.gridLayout_5 = QtWidgets.QGridLayout()
71
        self.gridLayout_5.setObjectName("gridLayout_5")
72
        self.groupBox_3 = QtWidgets.QGroupBox(self.tabInsulationPurpose)
73
        self.groupBox_3.setObjectName("groupBox_3")
74
        self.gridLayout_15 = QtWidgets.QGridLayout(self.groupBox_3)
75
        self.gridLayout_15.setObjectName("gridLayout_15")
76
        self.tableWidgetInsulationPurpose = QtWidgets.QTableWidget(self.groupBox_3)
77
        self.tableWidgetInsulationPurpose.setColumnCount(3)
78
        self.tableWidgetInsulationPurpose.setObjectName("tableWidgetInsulationPurpose")
79
        self.tableWidgetInsulationPurpose.setRowCount(0)
80
        self.tableWidgetInsulationPurpose.verticalHeader().setVisible(False)
81
        self.gridLayout_15.addWidget(self.tableWidgetInsulationPurpose, 0, 0, 1, 1)
82
        self.gridLayout_5.addWidget(self.groupBox_3, 0, 0, 1, 1)
83
        self.gridLayout_6.addLayout(self.gridLayout_5, 0, 0, 1, 1)
84
        self.tabWidget.addTab(self.tabInsulationPurpose, "")
85
        self.tabPnIDNumber = QtWidgets.QWidget()
86
        self.tabPnIDNumber.setObjectName("tabPnIDNumber")
87
        self.gridLayout_10 = QtWidgets.QGridLayout(self.tabPnIDNumber)
88
        self.gridLayout_10.setObjectName("gridLayout_10")
89
        self.gridLayout_9 = QtWidgets.QGridLayout()
90
        self.gridLayout_9.setObjectName("gridLayout_9")
91
        self.groupBox_4 = QtWidgets.QGroupBox(self.tabPnIDNumber)
92
        self.groupBox_4.setObjectName("groupBox_4")
93
        self.gridLayout_16 = QtWidgets.QGridLayout(self.groupBox_4)
94
        self.gridLayout_16.setObjectName("gridLayout_16")
95
        self.tableWidgetPnIDNumber = QtWidgets.QTableWidget(self.groupBox_4)
96
        self.tableWidgetPnIDNumber.setColumnCount(3)
97
        self.tableWidgetPnIDNumber.setObjectName("tableWidgetPnIDNumber")
98
        self.tableWidgetPnIDNumber.setRowCount(0)
99
        self.tableWidgetPnIDNumber.verticalHeader().setVisible(False)
100
        self.gridLayout_16.addWidget(self.tableWidgetPnIDNumber, 0, 0, 1, 1)
101
        self.gridLayout_9.addWidget(self.groupBox_4, 0, 0, 1, 1)
102
        self.gridLayout_10.addLayout(self.gridLayout_9, 0, 0, 1, 1)
103
        self.tabWidget.addTab(self.tabPnIDNumber, "")
104
        self.tabPipingMaterialsClass = QtWidgets.QWidget()
105
        self.tabPipingMaterialsClass.setObjectName("tabPipingMaterialsClass")
106
        self.gridLayout_8 = QtWidgets.QGridLayout(self.tabPipingMaterialsClass)
107
        self.gridLayout_8.setObjectName("gridLayout_8")
108
        self.gridLayout_7 = QtWidgets.QGridLayout()
109
        self.gridLayout_7.setObjectName("gridLayout_7")
110
        self.groupBox_5 = QtWidgets.QGroupBox(self.tabPipingMaterialsClass)
111
        self.groupBox_5.setObjectName("groupBox_5")
112
        self.gridLayout_17 = QtWidgets.QGridLayout(self.groupBox_5)
113
        self.gridLayout_17.setObjectName("gridLayout_17")
114
        self.tableWidgetPipingMaterialsClass = QtWidgets.QTableWidget(self.groupBox_5)
115
        self.tableWidgetPipingMaterialsClass.setColumnCount(3)
116
        self.tableWidgetPipingMaterialsClass.setObjectName("tableWidgetPipingMaterialsClass")
117
        self.tableWidgetPipingMaterialsClass.setRowCount(0)
118
        self.tableWidgetPipingMaterialsClass.verticalHeader().setVisible(False)
119
        self.gridLayout_17.addWidget(self.tableWidgetPipingMaterialsClass, 0, 0, 1, 1)
120
        self.gridLayout_7.addWidget(self.groupBox_5, 0, 0, 1, 1)
121
        self.gridLayout_8.addLayout(self.gridLayout_7, 0, 0, 1, 1)
122
        self.tabWidget.addTab(self.tabPipingMaterialsClass, "")
123
        self.tabUnitNumber = QtWidgets.QWidget()
124
        self.tabUnitNumber.setObjectName("tabUnitNumber")
125
        self.gridLayout_12 = QtWidgets.QGridLayout(self.tabUnitNumber)
126
        self.gridLayout_12.setObjectName("gridLayout_12")
127
        self.gridLayout_11 = QtWidgets.QGridLayout()
128
        self.gridLayout_11.setObjectName("gridLayout_11")
129
        self.groupBox_6 = QtWidgets.QGroupBox(self.tabUnitNumber)
130
        self.groupBox_6.setObjectName("groupBox_6")
131
        self.gridLayout_18 = QtWidgets.QGridLayout(self.groupBox_6)
132
        self.gridLayout_18.setObjectName("gridLayout_18")
133
        self.tableWidgetUnitNumber = QtWidgets.QTableWidget(self.groupBox_6)
134
        self.tableWidgetUnitNumber.setColumnCount(3)
135
        self.tableWidgetUnitNumber.setObjectName("tableWidgetUnitNumber")
136
        self.tableWidgetUnitNumber.setRowCount(0)
137
        self.tableWidgetUnitNumber.verticalHeader().setVisible(False)
138
        self.gridLayout_18.addWidget(self.tableWidgetUnitNumber, 0, 0, 1, 1)
139
        self.gridLayout_11.addWidget(self.groupBox_6, 0, 0, 1, 1)
140
        self.gridLayout_12.addLayout(self.gridLayout_11, 0, 0, 1, 1)
141
        self.tabWidget.addTab(self.tabUnitNumber, "")
142
        self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
143

  
144
        self.retranslateUi(CodeTableDialog)
145
        self.tabWidget.setCurrentIndex(0)
146
        self.buttonBox.accepted.connect(CodeTableDialog.accept)
147
        self.buttonBox.rejected.connect(CodeTableDialog.reject)
148
        QtCore.QMetaObject.connectSlotsByName(CodeTableDialog)
149

  
150
    def retranslateUi(self, CodeTableDialog):
151
        _translate = QtCore.QCoreApplication.translate
152
        CodeTableDialog.setWindowTitle(_translate("CodeTableDialog", "Code Table"))
153
        self.groupBox.setTitle(_translate("CodeTableDialog", "Nominal Diameter"))
154
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabNominalDiameter), _translate("CodeTableDialog", "Nominal Diameter"))
155
        self.groupBox_2.setTitle(_translate("CodeTableDialog", "Fluid Code"))
156
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabFluidCode), _translate("CodeTableDialog", "Fluid Code"))
157
        self.groupBox_3.setTitle(_translate("CodeTableDialog", "Insulation Purpose"))
158
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabInsulationPurpose), _translate("CodeTableDialog", "Insulation Purpose"))
159
        self.groupBox_4.setTitle(_translate("CodeTableDialog", "P&&ID Number"))
160
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabPnIDNumber), _translate("CodeTableDialog", "P&&ID Number"))
161
        self.groupBox_5.setTitle(_translate("CodeTableDialog", "Piping Materials Class"))
162
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabPipingMaterialsClass), _translate("CodeTableDialog", "Piping Materials Class"))
163
        self.groupBox_6.setTitle(_translate("CodeTableDialog", "Unit Number"))
164
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabUnitNumber), _translate("CodeTableDialog", "Unit Number"))
165

  
166

  
167
if __name__ == "__main__":
168
    import sys
169
    app = QtWidgets.QApplication(sys.argv)
170
    CodeTableDialog = QtWidgets.QDialog()
171
    ui = Ui_CodeTableDialog()
172
    ui.setupUi(CodeTableDialog)
173
    CodeTableDialog.show()
174
    sys.exit(app.exec_())
175

  
DTI_PID/DTI_PID/Commands/CopySymbolCommand.py
1
import sys
2
import os.path
3
import AbstractCommand
4
try:
5
    from PyQt5.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QEvent
6
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QCursor, QMouseEvent, QTransform
7
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QApplication
8
except ImportError:
9
    try:
10
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QEvent
11
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImge, QPixmap, QPainterPath, QFileDialog, QCursor, QMouseEvent
12
    except ImportError:
13
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
14

  
15
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '\\Shapes')
16
from SymbolSvgItem import SymbolSvgItem
17
from AppDocData import AppDocData
18
import symbol
19
'''
20
    @brief      QtImageViewer Copy Symbol Command
21
    @author     kyouho
22
    @date       18.07.27
23
'''
24
class CopySymbolCommand(AbstractCommand.AbstractCommand):
25

  
26
    def __init__(self, imageViewer):
27
        super(CopySymbolCommand, self).__init__(imageViewer)
28
        self.name = 'CopySymbol'
29
        QApplication.instance().setOverrideCursor(QCursor(Qt.DragCopyCursor))
30
        
31
        # create symbol
32
        svgFileName = self.imageViewer.copySymbol.name
33
        self.symbol = self.imageViewer.createSymbolObject(svgFileName)
34
        self.imageViewer.scene.addItem(self.symbol)
35
        
36
    '''
37
        @brief      Select Attribuew
38
        @author     kyouho
39
        @date       18.07.19
40
    '''
41
    def execute(self, param):
42
        event = param[1]
43
        scenePos = param[2]
44

  
45
        if 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton:
46
            transform = QTransform()
47
            transform.translate(scenePos.x(), scenePos.y())
48
            self.symbol.setTransform(transform)
49

  
50
            self.imageViewer.scene.removeItem(self.symbol)
51
            self.imageViewer.matchSymbolToLine(self.symbol, scenePos)
52
        elif 'mouseMoveEvent' == param[0]:
53
            transform = QTransform()
54
            transform.translate(scenePos.x() - self.symbol.symbolOrigin[0], scenePos.y() - self.symbol.symbolOrigin[1])
55
            self.symbol.setTransform(transform)
56

  
57
        self.isTreated = True
58

  
59
    def undo(self):
60
        pass
61

  
62
    def redo(self):
63
        pass
64

  
65
    '''
66
        @brief      Find TextItem contain Point
67
        @author     kyouho
68
        @date       18.07.19
69
    '''
70
    def findTextItemInPoint(self, point):
71
        from QEngineeringTextItem import QEngineeringTextItem
72
        
73
        for item in self.imageViewer.items():
74
            if type(item) is QEngineeringTextItem:
75
                if self.isOverlapItemAndPoint(item, point):
76
                    return (True, item)
77

  
78
        return (False,)
79

  
80
    '''
81
        @brief      Check Overlap
82
        @author     kyouho
83
        @date       18.07.17
84
    '''
85
    def isOverlapItemAndPoint(self, item, point):
86
        x = point.x()
87
        y = point.y()
88
        loc = item.loc
89
        size = item.size
90

  
91
        if loc[0] <= x and loc[0] + size[0] >= x and loc[1] <= y and loc[1] + size[1] >= y:
92
            return True
93
        else:
94
            return False
DTI_PID/DTI_PID/Commands/CreateSymbolCommand.py
69 69
                            #### lambda param=svg : bind 'svg' object to lambda('param')
70 70
                            #### If case of 'lambda svg=svg:', function uses the 'svg' value bound to lambda
71 71
                            svg.clicked.connect(lambda param=svg: self.resultTreeWidget.findItem(param))
72
                            svg.removed.connect(self.resultTreeWidget.itemRemoved)
72
                            svg.transfer.onRemoved.connect(self.resultTreeWidget.itemRemoved)
73 73
                            svg.addSvgItemToScene(self.imageViewer.scene)
74 74
                            for connector in svg.connectors:
75 75
                                self.imageViewer.scene.addItem(connector)
DTI_PID/DTI_PID/Commands/DefaultCommand.py
18 18
    @history    2018.05.02  Jeongwoo    Change mouse cursor
19 19
'''
20 20
class DefaultCommand(AbstractCommand.AbstractCommand):
21
    onSuccess = pyqtSignal(float, float, float, float)
22

  
21 23
    def __init__(self, imageViewer):
22 24
        super(DefaultCommand, self).__init__(imageViewer)
23 25
        self.name = 'Default'
24 26
        self.imageViewer.setCursor(QCursor(Qt.ArrowCursor))
27
        
28
        self._vertices = []
29
        self.startX = 0
30
        self.startY = 0
31
        self.isClicked = False
25 32
    
26 33
    '''
27 34
        @brief      Scroll / Pan / Zoom with Wheel Button
......
41 48
            finally:
42 49
                QGraphicsView.mouseReleaseEvent(self.imageViewer, QMouseEvent(QEvent.MouseButtonRelease, event.pos(), Qt.LeftButton, event.buttons(), Qt.NoModifier))
43 50
                pass
51
        elif 'mousePressEvent' == param[0] and event.button() == Qt.LeftButton:
52
            self.imageViewer.setDragMode(QGraphicsView.RubberBandDrag)
53
            self.startX = scenePos.x()
54
            self.startY = scenePos.y()
55
            self._vertices.clear()
56
            self._vertices.append(param[2])
57
            self.isClicked = True
58
        elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton:
59
            try:
60
                QGraphicsView.mouseReleaseEvent(self.imageViewer, event)
61
                self._vertices.append(param[2])
62
            finally:
63
                self.imageViewer.setDragMode(QGraphicsView.NoDrag)
64
                x = min(self._vertices[0].x(), self._vertices[1].x())
65
                y = min(self._vertices[0].y(), self._vertices[1].y())
66
                width = abs(self._vertices[0].x() - self._vertices[1].x())
67
                height = abs(self._vertices[0].y() - self._vertices[1].y())
68
                self.onSuccess.emit(x, y, width, height)
69
                self.isClicked = False
70
                pass
71
        elif self.isClicked and 'mouseMoveEvent' == param[0]:
72
            endX = scenePos.x()
73
            endY = scenePos.y()
74

  
75
            if self.startX > endX and self.startY > endY:
76
                self.imageViewer.setRubberBandSelectionMode(Qt.ContainsItemShape)
77
            else:
78
                self.imageViewer.setRubberBandSelectionMode(Qt.IntersectsItemShape)
79
                
44 80
        self.isTreated = False
45 81

  
46 82
    def undo(self):
DTI_PID/DTI_PID/Commands/PlaceLineCommand.py
1
import os.path
2
import AbstractCommand
3
try:
4
    from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR
5
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QCursor, QTransform
6
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog
7
except ImportError:
8
    try:
9
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR
10
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QCursor
11
    except ImportError:
12
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
13

  
14
class PlaceLineCommand(AbstractCommand.AbstractCommand):
15
    onSuccess = pyqtSignal()
16
    onRejected = pyqtSignal(AbstractCommand.AbstractCommand)
17

  
18
    def __init__(self, imageViewer):
19
        super(PlaceLineCommand, self).__init__(imageViewer)
20
        self.name = 'PlaceLine' 
21
        self.imageViewer.setCursor(QCursor(Qt.CrossCursor))
22

  
23
        self._polyline = None
24
    
25
    '''
26
        @brief      reset command status
27
        @author     humkyung
28
        @date       2018.07.23
29
    '''
30
    def reset(self):
31
        self._polyline = None
32

  
33
    '''
34
        @brief      place a line
35
        @author     humkyung
36
        @date       2018.07.23
37
    '''
38
    def execute(self, param):
39
        import shapely
40
        from EngineeringConnectorItem import QEngineeringConnectorItem
41
        from SymbolSvgItem import SymbolSvgItem
42
        from EngineeringPolylineItem import QEngineeringPolylineItem
43
        from EngineeringLineItem import QEngineeringLineItem
44

  
45
        event = param[1]
46
        if 'mousePressEvent' == param[0] and event.button() == Qt.LeftButton:
47
            if self._polyline is None:
48
                selected = self.imageViewer.scene.itemAt(param[2], QTransform())
49
                if selected is not None and type(selected) is QEngineeringConnectorItem:
50
                    self._polyline = QEngineeringPolylineItem()
51
                    self._polyline._vertices.append(selected.center())
52
                    self.imageViewer.scene.addItem(self._polyline)
53
                    self.imageViewer.scene.setFocusItem(self._polyline)
54
                elif selected is not None and type(selected) is QEngineeringLineItem:
55
                    length = selected.length()*0.5
56
                    dir = selected.perpendicular()
57
                    start = [param[2].x() - dir[0]*length, param[2].y() - dir[1]*length]
58
                    end = [param[2].x() + dir[0]*length, param[2].y() + dir[1]*length]
59
                    pt = selected.intersection([start, end])
60
                    if (pt is not None) and (type(pt) == shapely.geometry.point.Point):
61
                        self._polyline = QEngineeringPolylineItem()
62
                        self._polyline._vertices.append([pt.x, pt.y])
63
                        self.imageViewer.scene.addItem(self._polyline)
64
                        self.imageViewer.scene.setFocusItem(self._polyline)
65
            else:
66
                try:
67
                    QGraphicsView.mouseReleaseEvent(self.imageViewer, event)
68
                    self._polyline._vertices.append(self._polyline._pt)
69
                    self._polyline.update()
70
                finally:
71
                    pass
72
        elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.RightButton and self._polyline is not None:
73
            self.onSuccess.emit()
74
        elif 'mouseMoveEvent' == param[0] and self._polyline is not None:
75
            self._polyline.onMouseMoved(event, param[2])
76
        elif 'keyPressEvent' == param[0]:
77
            if event.key() == Qt.Key_Escape:
78
                self.onRejected.emit(self)
79

  
80
        self.isTreated = False
81

  
82
    def undo(self):
83
        pass
84

  
85
    def redo(self):
86
        pass
DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py
1
import os.path
2
import AbstractCommand
3
try:
4
    from PyQt5.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QEvent
5
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QCursor, QMouseEvent
6
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog
7
except ImportError:
8
    try:
9
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QEvent
10
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImge, QPixmap, QPainterPath, QFileDialog, QCursor, QMouseEvent
11
    except ImportError:
12
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
13

  
14
'''
15
    @brief      QtImageViewer Select Attribute Command
16
    @author     kyouho
17
    @date       18.04.10
18
'''
19
class SelectAttributeCommand(AbstractCommand.AbstractCommand):
20

  
21
    def __init__(self, imageViewer):
22
        super(SelectAttributeCommand, self).__init__(imageViewer)
23
        self.name = 'SelectAttribute'
24
        self.imageViewer.setCursor(QCursor(Qt.ArrowCursor))
25
        
26
        self.resultItem = None
27
    '''
28
        @brief      Select Attribuew
29
        @author     kyouho
30
        @date       18.07.19
31
    '''
32
    def execute(self, param):
33
        event = param[1]
34
        scenePos = param[2]
35

  
36
        if 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton:
37
            result = self.findTextItemInPoint(scenePos)
38
            if result[0]:
39
                self.resultItem = result[1]
40

  
41
        self.isTreated = True
42

  
43
    def undo(self):
44
        pass
45

  
46
    def redo(self):
47
        pass
48

  
49
    '''
50
        @brief      Find TextItem contain Point
51
        @author     kyouho
52
        @date       18.07.19
53
    '''
54
    def findTextItemInPoint(self, point):
55
        from QEngineeringTextItem import QEngineeringTextItem
56
        
57
        for item in self.imageViewer.items():
58
            if type(item) is QEngineeringTextItem:
59
                if self.isOverlapItemAndPoint(item, point):
60
                    return (True, item)
61

  
62
        return (False,)
63

  
64
    '''
65
        @brief      Check Overlap
66
        @author     kyouho
67
        @date       18.07.17
68
    '''
69
    def isOverlapItemAndPoint(self, item, point):
70
        x = point.x()
71
        y = point.y()
72
        loc = item.loc
73
        size = item.size
74

  
75
        if loc[0] <= x and loc[0] + size[0] >= x and loc[1] <= y and loc[1] + size[1] >= y:
76
            return True
77
        else:
78
            return False
DTI_PID/DTI_PID/ConfigurationAreaDialog.py
15 15
import FenceCommand
16 16

  
17 17
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes')
18
import QGraphicsPolylineItem
19
from QEngineeringLineItem import QEngineeringLineItem
18
import EngineeringPolylineItem
19
from EngineeringLineItem import QEngineeringLineItem
20 20
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
21 21
import Configuration_Area_UI
22 22

  
DTI_PID/DTI_PID/ConfigurationDialog.py
123 123
        properties = docData.getLineProperties()
124 124
        for prop in properties:
125 125
            self.ui.comboBoxProperties.addItem(prop)
126
            self.ui.comboBoxColorOption.addItem(prop)
126
            if prop != "Tag Seq No":
127
                self.ui.comboBoxColorOption.addItem(prop)
127 128

  
128 129
        configs = docData.getConfigs('Line No', 'Configuration')
129
        if len(configs) == 1:
130
        if len(configs) == 1 and configs[0].value is not None:
130 131
            for value in configs[0].value.split(self.delimiter):
131 132
            #for value in configs[0].value.split(self.ui.lineEdit.text()):
132 133
                self.itemModel.appendRow(QStandardItem(value))
......
196 197
            self.ui.spinBoxFontSize.setValue(10)
197 198
            self.ui.spinBoxFontSize.setEnabled(self.ui.radioButtonFixedSize.isChecked())
198 199
        
199
        # default Color 
200
        defaultColor = docData.getPropertyColor('default')
201
        if defaultColor:
202
            self.defaultColor = defaultColor[0]
203

  
204 200
        # Line Color Visible Option 가져옴
205 201
        configs = docData.getConfigs('Line Color', 'Visible Option')
206 202
        if configs:
......
217 213
        selectedOption = configs[0].value if configs and self.ui.comboBoxColorOption.findText(configs[0].value) >= 0 else 'Nominal Diameter'
218 214
        self.ui.tableWidgetColorProperty.setHorizontalHeaderLabels(['Value', 'Color', 'ref', 'colorStr'])
219 215
        
220
        # 기본 테이블 셋팅
221
        self.settingDefaultColorTable(selectedOption)
222
        # 설정된 색상 가져옴
223
        self.settingColorStringCell(selectedOption)
224
        #Table Color Setting
225
        self.settingColorCell()
226

  
227 216
        index = self.ui.comboBoxColorOption.findText(selectedOption)
228 217
        self.ui.comboBoxColorOption.setCurrentIndex(index)
229 218
        self.currentIndex = index
......
233 222
        #Column Header Size
234 223
        self.ui.tableWidgetColorProperty.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
235 224

  
225
        self.setPropertyToggle(self.ui.radioButtonProperty.isChecked())
236 226

  
237 227
        # connect signals and slots
238 228
        self.ui.pushButtonAddProperty.clicked.connect(self.addLineProperty)
......
240 230
        self.ui.pushButtonAddDelimiter.clicked.connect(self.addDelimiter)
241 231
        self.ui.tableWidgetColorProperty.cellDoubleClicked.connect(self.cellDoubleClick)
242 232
        self.ui.comboBoxColorOption.currentIndexChanged.connect(self.currentIndexChanged)
233
        self.ui.radioButtonRandom.toggled.connect(self.onPropertyToggled)
243 234

  
235
    '''
236
        @brief  Clear Table
237
        @author kyouho
238
        @date   2018.07.10
239
    '''
240
    def clearColorPropertyTable(self):
241
        table = self.ui.tableWidgetColorProperty
242
        model = table.model()
243

  
244
        while table.rowCount():
245
            model.removeRow(table.rowCount() - 1)
244 246

  
245 247
    '''
246 248
        @brief  setting default table
......
250 252
    def settingDefaultColorTable(self, property):
251 253
        docData = AppDocData.instance()
252 254
        table = self.ui.tableWidgetColorProperty
253
        model = table.model()
254

  
255
        while table.rowCount():
256
            model.removeRow(table.rowCount() - 1)
255
        self.clearColorPropertyTable()
257 256

  
258 257
        dic = {}
259 258

  
......
263 262
            # Size 표기 가져옴
264 263
            configs = docData.getConfigs('Line No', 'Size Unit')
265 264
            # Size 관련 Table 가져옴
266
            result = docData.getNomialPipeSizeData()
265
            result = docData.getNomialPipeSizeData(False, "Metric")
267 266
            
268
            for i in result:
269
                if not i.inchStr or not i.metricStr:
267
            for pipeSize in result:
268
                if not pipeSize.inchStr or not pipeSize.metricStr:
270 269
                    continue
271 270
                else:
272
                    replaceInchStr = i.inchStr.replace("'", '"')
271
                    replaceInchStr = pipeSize.inchStr.replace("'", '"')
273 272
                    if checkRepeat.count(replaceInchStr):
274 273
                        continue
275 274
                    else:
276 275
                        checkRepeat.append(replaceInchStr)
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

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