프로젝트

일반

사용자정보

개정판 e44ea38a

IDe44ea38a4c6244436a11015fb10811af7d8e02f9
상위 df4661c5
하위 6b99de54, 26195784

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

issue #492: 사용자가 라인의 From-To를 설정할 수 있다

Change-Id: Id73156730848959abef3288c1befc9a28e8f3773

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
2085 2085
        @date       2018.07.12
2086 2086
    '''
2087 2087
    def saveCommonCodeData(self, tableName, datas):
2088
        import uuid
2089

  
2088 2090
        try:
2089 2091
            # Creates or opens a file called mydb with a SQLite3 DB
2090 2092
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
......
2095 2097
            for data in datas:
2096 2098
                uid,code,description,allowables = data[0],data[1],data[2],data[3]
2097 2099
                if not uid:
2098
                    sql = "insert or replace into {}(UID, CODE, DESCRIPTION, ALLOWABLES) values(lower(hex(randomblob(16))), ?, ?, ?)".format(tableName)
2099
                    param = (data[1], data[2], data[3])
2100
                    sql = "insert or replace into {}(UID, CODE, DESCRIPTION, ALLOWABLES) values(?, ?, ?, ?)".format(tableName)
2101
                    param = (str(uuid.uuid4()), data[1], data[2], data[3])
2100 2102
                elif uid == '-1':
2101 2103
                    sql = 'delete from {} where uid=?'.format(tableName) 
2102 2104
                    param = (data[-1],)
......
2849 2851
        @date       2018.11.03
2850 2852
        """
2851 2853

  
2854
        import uuid
2855

  
2852 2856
        try:
2853 2857
            # Creates or opens a file called mydb with a SQLite3 DB
2854 2858
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
......
2858 2862

  
2859 2863
            for drawing in drawings:
2860 2864
                if not drawing[0]:
2861
                    sql = 'insert or replace into Drawings(UID, [NAME], [DATETIME]) values(lower(hex(randomblob(16))), ?, ?)'
2862
                    param = tuple([drawing[1], ''])
2865
                    sql = 'insert or replace into Drawings(UID, [NAME], [DATETIME]) values(?, ?, ?)'
2866
                    param = tuple([str(uuid.uuid4()), drawing[1], ''])
2863 2867
                else:
2864 2868
                    sql = 'insert or replace into Drawings(UID, [NAME], [DATETIME]) values(?, ?, ?)'
2865 2869
                    param = tuple(drawing)
DTI_PID/DTI_PID/ConnectAttrDialog.py
18 18

  
19 19
'''
20 20
'''
21
class Worker(QObject):
22
    from PyQt5.QtCore import QThread
21
class Worker(QThread):
22
    """ This is Worker class """
23 23
    from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QGridLayout, QListWidget
24 24
    from QtImageViewer import QtImageViewer
25 25
    import sys
......
31 31
    displayMessage = pyqtSignal(str)
32 32
    updateProgress = pyqtSignal(int)
33 33

  
34
    def __init__(self, graphicsView):
35
        QThread.__init__(self)
36
        self.graphicsView = graphicsView
37

  
34 38
    '''
35 39
        @brief  execute connecting attributes
36 40
        @author humkyung
37 41
        @date   2018.06.17
38 42
    '''
39
    def procCounter(self): # A slot takes no params
43
    def run(self): # A slot takes no params
40 44
        from LineNoTracer import connectAttrImpl
41 45

  
42 46
        try:
43 47
            connectAttrImpl(self)
44 48
        except Exception as ex:
45
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
49
            from App import App 
50
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
51
            App.mainWnd().addMessage.emit(MessageType.Error, message)
46 52

  
47
'''
48
'''
49 53
class QConnectAttrDialog(QDialog):
50 54
    """ This is connect attr dialog class """
51 55

  
......
127 131
            self.ui.buttonBox.setDisabled(True)
128 132

  
129 133
            # 1 - create Worker and Thread inside the Form
130
            self.obj = Worker()  # no parent!
131
            self.obj.graphicsView = self.graphicsView
132
            self.thread = QThread()  # no parent!
134
            self.obj = Worker(self.graphicsView)  # no parent!
135
            #self.obj.graphicsView = self.graphicsView
136
            #self.thread = QThread()  # no parent!
133 137

  
134 138
            # 2 - Move the Worker object to the Thread object
135
            self.obj.moveToThread(self.thread)
139
            #self.obj.moveToThread(self.thread)
136 140

  
137 141
            # 3 - Connect Worker Signals to the Thread slots
138
            self.obj.finished.connect(self.thread.quit)
142
            #self.obj.finished.connect(self.obj.quit)
139 143
            self.obj.displayMessage.connect(self.addListItem)
140 144
            self.obj.updateProgress.connect(self.updateProgress)
141 145

  
142 146
            # 4 - Connect Thread started signal to Worker operational slot method
143
            self.thread.started.connect(self.obj.procCounter)
147
            #self.thread.started.connect(self.obj.procCounter)
144 148
        
145 149
            # 5 - Thread finished signal will close the app if you want!
146
            self.thread.finished.connect(self.dlgExit)
150
            self.obj.finished.connect(self.dlgExit)
147 151

  
148 152
            # 6 - Start the thread
149
            self.thread.start()
153
            self.obj.start()
150 154

  
151 155
            self.tmStart = timeit.default_timer()
152 156
        except Exception as ex:
153 157
            from App import App 
154 158
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
155 159
            App.mainWnd().addMessage.emit(MessageType.Error, message)
160
        finally:
161
            self.ui.buttonBox.setDisabled(False)
156 162

  
157 163
    '''
158 164
        @brief      set buttonbox's enabled flag
DTI_PID/DTI_PID/HMBTable.py
163 163
        @date       2018.07.12
164 164
    '''
165 165
    def saveData(self):
166
        import uuid
166 167
        from AppDocData import AppDocData
167 168

  
168 169
        try:
......
177 178
                for data in self._hmbs:
178 179
                    if data.isDeleted == False:
179 180
                        if data.uid is None:
180
                            sql = "insert or replace into HMB values(lower(hex(randomblob(16))),?,?,?,?)"
181
                            param = (data.streamNo, data.name, data.unit, data.value)
181
                            sql = "insert or replace into HMB values(?,?,?,?,?)"
182
                            param = (str(uuid.uuid4()), data.streamNo, data.name, data.unit, data.value)
182 183
                            cursor.execute(sql, param)
183 184
                        else:
184 185
                            sql = "update HMB set STREAM_NO=?,NAME=?,UNIT=?,VALUE=? where UID=?"
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
670 670
                    items[0].removeSelfAttr(attributeStr)
671 671
                    self.mainWindow.refreshResultPropertyTableWidget()
672 672
            elif len(items) == 1 and len(selectedIndexes) == 1 and (type(items[0]) is QEngineeringLineItem or issubclass(type(items[0]), SymbolSvgItem)):
673
                keyCell = self.item(selectedIndexes[0].row(), 0)
674
                if selectedIndexes[0].column() == 1 and keyCell.text().find('CONN') is 0:
673
                key_cell = self.item(selectedIndexes[0].row(), 0)
674
                if selectedIndexes[0].column() == 1 and key_cell.text() == 'OWNER':
675
                    items[0].owner = None
676
                elif selectedIndexes[0].column() == 1 and key_cell.text().find('CONN') is 0:
675 677
                    selectedUID = self.item(selectedIndexes[0].row(), 1).text()
676
                    connNum = int(keyCell.text().replace('CONN', ''))
678
                    connNum = int(key_cell.text().replace('CONN', ''))
677 679
                    items[0].connectors[connNum - 1].connectedItem = None
678 680
                    self.show_item_property(items[0])
679 681

  
......
737 739
        """
738 740

  
739 741
    '''
740
        @brief      Check Number
741
        @author     kyouho
742
        @date       2018.08.20
743
    '''
744
    def isNumber(self, num):
745
        p = re.compile('(^[0-9]+$)')
746
        result = p.match(num)
747

  
748
        if result:
749
            return True
750
        else:
751
            return False
752

  
753
    '''
754 742
        @brief      resultPropertyTableWidget Cell Double Click Event
755 743
        @author     kyouho
756 744
        @date       2018.07.19
DTI_PID/DTI_PID/LineNoTracer.py
62 62
        _to = lineno.get_property('To')
63 63
        if _from and _to and lineno.empty():
64 64
            connected_items = self.find_connected_objects(_from, to=_to)
65
            if _from in connected_items and _to in connected_items:
66
                start = connected_items.index(_from)
67
                end = connected_items.index(_to)
68
                if start < end:
69
                    connected_items = connected_items[start:end+1]
70
                else:
71
                    connected_items = connected_items[end:start+1]
72
                    connected_items.reverse()
65 73
        elif (not _from or not _to) and (1 == len(lineno.conns)):
66 74
            connected_items = self.find_connected_objects(lineno.conns[0])
67 75

  
......
150 158
                for lineno in self._lineNos:
151 159
                    _from = lineno.get_property('From')
152 160
                    _to = lineno.get_property('To')
153
                    if _from and _to: continue
161
                    if _from and _to:
162
                        _from.owner = lineno
163
                        _to.owner = lineno
164
                        continue
154 165

  
155 166
                    lineno.conns.clear()
156 167
                    minDist = None
......
335 346
                matches = [spec_break for spec_break in self._spec_breaks if spec_break.is_connected(obj)]
336 347
                if matches or issubclass(type(obj), QEngineeringEquipmentItem): continue
337 348
                """ end loop if obj is to """
338
                if str(obj.uid) is str(to): break
349
                if to is not None and str(obj.uid) == str(to.uid): break
339 350

  
340 351
                if type(obj) is QEngineeringLineItem:
341
                    symbolMatches = [x for x in self._symbols if (x.owner is None) and (x not in visited) and obj.is_connected(x)]
342
                    lineMatches = [x for x in self._lines if (x.owner is None) and (x is not obj) and (x not in visited) and obj.is_connected(x)]
352
                    symbolMatches = [x for x in self._symbols if (x.owner is None or x.owner == start.owner) and (x not in visited) and obj.is_connected(x)]
353
                    lineMatches = [x for x in self._lines if (x.owner is None or x.owner == start.owner) and (x is not obj) and (x not in visited) and obj.is_connected(x)]
343 354

  
344 355
                elif issubclass(type(obj), SymbolSvgItem):
345
                    lineMatches = [x for x in self._lines if (x.owner is None) and (x not in visited) and obj.is_connected(x)]
356
                    lineMatches = [x for x in self._lines if (x.owner is None or x.owner == start.owner) and (x not in visited) and obj.is_connected(x)]
346 357

  
347 358
                    if len(lineMatches) > 1: # choose one if connected lines are more than 2
348 359
                        matches = [x for x in [visited[0], visited[-1]] if obj.is_connected(x)]
......
350 361
                            next_connected = [x for x in lineMatches if obj.next_connected(x, matches[0])]
351 362
                            if next_connected: lineMatches = next_connected
352 363

  
353
                    symbolMatches = [x for x in self._symbols if (x.owner is None) and (x is not obj) and (x not in visited) and obj.is_connected(x, None)]
364
                    symbolMatches = [x for x in self._symbols if (x.owner is None or x.owner == start.owner) and (x is not obj) and (x not in visited) and obj.is_connected(x, None)]
354 365

  
355 366
                # order connected objects
356 367
                matches = []
DTI_PID/DTI_PID/NominalPipeSize.py
97 97

  
98 98
    def toSql(self):
99 99
        """ generate sql string to insert database """
100
        import uuid
101

  
100 102
        res = []
101 103

  
102 104
        if not self.uid is None:
......
104 106
            param = (self.uid, self.code, self.metric, self.inch, self.inchStr, self.allowable_inch_str, self.metricStr, self.allowable_metric_str)
105 107
            res.append((sql, param))
106 108
        else:
107
            sql = "insert into NominalDiameter(UID, Code, Metric, Inch, InchStr, AllowableInchStr, MetricStr, AllowableMetricStr) VALUES(lower(hex(randomblob(16))),?,?,?,?,?,?,?)"
108
            param = (self.code, self.metric, self.inch, self.inchStr, self.allowable_inch_str, self.metricStr, self.allow_metric_str)
109
            sql = "insert into NominalDiameter(UID, Code, Metric, Inch, InchStr, AllowableInchStr, MetricStr, AllowableMetricStr) VALUES(?,?,?,?,?,?,?,?)"
110
            param = (str(uuid.uuid4()), self.code, self.metric, self.inch, self.inchStr, self.allowable_inch_str, self.metricStr, self.allow_metric_str)
109 111
            res.append((sql, param))
110 112

  
111 113
        return res
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
240 240
                    matches = [prop for prop in item._properties.keys() if prop.Attribute == prop_node.attrib['Attribute']]
241 241
                    if matches:
242 242
                        matches[0].parse_xml(prop_node)
243
                        item._properties[matches[0]] = uuid.UUID(prop_node.text) if prop_node.text and matches[0].is_selectable else prop_node.text if prop_node.text else ''
243
                        item._properties[matches[0]] = uuid.UUID(prop_node.text, version=4) if prop_node.text and matches[0].is_selectable else prop_node.text if prop_node.text else ''
244 244
                    
245 245
                for attr_node in node.iter('ATTRIBUTE'):
246 246
                    attr = SymbolAttr.fromXml(attr_node)
......
350 350
        visited = []
351 351

  
352 352
        try:
353
            if self.runs is not None:
354
                for run in self.runs:
355
                    items = run.items
356
                    if items is not None:
357
                        for item in items:
358
                            pool = []
359
                            pool.append(item)
360
                            while len(pool) > 0:
361
                                it = pool.pop()
362
                                visited.append(it)
363
                                for connector in it.connectors:
364
                                    if (connector.connectedItem is not None) and (connector.connectedItem not in visited): pool.append(connector.connectedItem)
353
            for run in self.runs:
354
                visited.extend(run.items)
365 355
        except Exception as ex:
366 356
            from App import App
367 357
            from AppDocData import MessageType
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
531 531
    def mouseReleaseEvent(self, event):
532 532
        super().mouseReleaseEvent(event)
533 533

  
534
    #def dropEvent(self, event):
535
    #    '''
536
    #        @brief      Mouse Drop Event
537
    #        @author     euisung
538
    #        @date       2019.04.01
539
    #    '''
540
    #    print('d')
541
    #    super().dropEvent(event)
542
    
543
    #def dragLeaveEvent(self, event):
544
    #    print('l')
545

  
546 534
    def removeSelfAttr(self, attributeName):
547 535
        for attr in self.attrs:
548 536
            if attr.Attribute == attributeName:

내보내기 Unified diff

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