프로젝트

일반

사용자정보

개정판 292c8a79

ID292c8a792fc9bacf798550135875957900bd4e58
상위 23437d5d
하위 197f2dbc, 34967f95

함의성이(가) 약 5년 전에 추가함

issue #637: spec break line labeling on going and add line attribute on db

Change-Id: I66c2b81ae55d0fe3a27b2b4403053db4fe825f5b

차이점 보기:

DTI_PID/DTI_PID/LineNoTracer.py
34 34
            self._spec_breaks = specBreaks
35 35
            self._lineIndicator = lineIndicators
36 36
            self._end_breaks = end_breaks
37
            self.maxValue
37 38
            
38 39
            """
39 40
            for spec in self._specBreak:
......
185 186
                        lineno.set_property('To', None)
186 187
                        lineno._fixed = False
187 188

  
188
                maxValue = len(self._lineNos) + 1   ## line no's count + secondary line
189
                self.maxValue = len(self._lineNos) + 1   ## line no's count + secondary line
189 190

  
190 191
                # find primary lines
191 192
                # sort line no with from,to value
......
193 194
                for lineno in self._lineNos:
194 195
                    if displayMessage: displayMessage.emit('{} {}'.format(lineno.text(), 'Topology Construction'))
195 196
                    self.find_primary_lines(lineno)
196
                    if updateProgress: updateProgress.emit(maxValue)
197
                    if updateProgress: updateProgress.emit(self.maxValue)
197 198

  
198 199
                # find secondary lines
199 200
                lines_and_symbols = self._lines + self._symbols
......
214 215
                    if (startLine is not None):# and (minDist < toler):
215 216
                        lineno.conns.append(startLine)
216 217

  
217
                if updateProgress: updateProgress.emit(maxValue)
218
                if updateProgress: updateProgress.emit(self.maxValue)
218 219

  
219 220
            # make trim lines
220 221
            updateProgress.emit(-1) # reset progressbar
......
222 223
            orphanLines = [line for line in self._lines if line.owner is None]
223 224
            orphanSymbols = [symbol for symbol in self._symbols if symbol.owner is None]
224 225
            if orphanLines + orphanSymbols:
225
                maxValue = len(orphanLines)
226
                self.maxValue = len(orphanLines + 1)
226 227
                orphanLines = sorted(orphanLines, key=lambda param:param.length(), reverse=True)
227 228
                orphans = orphanLines + orphanSymbols
228 229
                while len(orphans) > 0:
......
235 236
                    for item in connectedItems:
236 237
                        if item in orphans:
237 238
                            orphans.remove(item)
238
                            updateProgress.emit(maxValue)
239
                            updateProgress.emit(self.maxValue)
239 240

  
240 241
                    self.find_secondary_lines(orphans)
241 242
                    for item in orphans:
242 243
                        if item.owner is not None:
243 244
                            orphans.remove(item)
244
                            updateProgress.emit(maxValue)
245
                            updateProgress.emit(self.maxValue)
245 246

  
246 247
                    docData.tracerLineNos.append(trimLineNo)
247 248

  
248
            if updateProgress: updateProgress.emit(maxValue)
249
            if updateProgress: updateProgress.emit(self.maxValue)
249 250
        except Exception as ex:
250 251
            from App import App 
251 252

  
......
612 613
            for spec_break in spec_breaks:
613 614
                spec_break.transfer.onRemoved.emit(spec_break)
614 615

  
616
            for line in lines:
617
                line.clear_labels()
618

  
615 619
            spec_break_names = docdata.getSymbolListByType('type', 'Segment Breaks')
616 620
            if len(spec_break_names) is not 0:
621
                configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio')
622
                ratio = float(configs[0].value) if 1 == len(configs) else 1.5
623
                ratio *= 2
624

  
617 625
                svgFileName = spec_break_names[0].sName
618 626
                symbol = docdata.getSymbolByQuery('name', svgFileName)
619 627
                svgFilePath = os.path.join(docdata.getCurrentProject().getSvgFilePath(), symbol.getType(), svgFileName + '.svg')
......
666 674
                    dupl.sort(reverse=True)
667 675
                    for index in dupl:
668 676
                        spec_breaks.pop(index)
669

  
677
                    # up to here
670 678

  
671 679
                    spec_break_items = []
672 680
                    for spec in spec_breaks:
......
694 702
                                        if full.Attribute == attr:
695 703
                                            attrs[full] = [value, value2]
696 704

  
705
                                # find label text for spec break line
706
                                stream_line = [spec[0], spec[1]]
707
                                stream_track = [spec[1], spec[0]]
708
                                stream_res = [False, False]
709
                                for index in range(len(stream_line)):
710
                                    while True:
711
                                        if type(stream_line[index]) is QEngineeringLineItem:
712
                                            stream_res[index] = True
713
                                            break
714
                                        else:
715
                                            find_next = False
716
                                            connected_count = 0
717
                                            for connectorr in stream_line[index].connectors:
718
                                                connected_count += 1
719
                                                if connectorr.connectedItem and stream_track[index] is not connectorr.connectedItem and stream_line[index].next_connected(stream_track[index], connectorr.connectedItem):
720
                                                    stream_track[index] = stream_line[index]
721
                                                    stream_line[index] = connectorr.connectedItem
722
                                                    find_next = True
723
                                                    break
724

  
725
                                            if not find_next:
726
                                                # prevent infinite loop
727
                                                if connected_count == 2:
728
                                                    for connectorr in stream_line[index].connectors:
729
                                                        if connectorr.connectedItem and not connectorr.connectedItem is stream_track[index]:
730
                                                            stream_line[index] = connectorr.connectedItem
731
                                                            stream_track[index] = stream_line[index]
732
                                                            find_next = True
733
                                                            break
734
                                                    if not find_next:
735
                                                        break
736
                                                else:
737
                                                    break
738

  
739
                                if stream_res[0] and stream_res[1]:
740
                                    texts = [item for item in worker.graphicsView.scene.items() if type(item) is QEngineeringTextItem and item.owner is None]
741
                                    
742
                                    for attr, value, value2 in spec[2:]:
743
                                        up_texts = [text for text in texts if text.text() == value]
744
                                        down_texts = [text for text in texts if text.text() == value2]
745
                                        up_down_texts = [up_texts, down_texts]
746
                                        up_down_find = [None, None]
747

  
748
                                        for index in range(len(up_down_texts)):
749
                                            minDist = sys.maxsize
750

  
751
                                            for up_down_text in up_down_texts[index]:
752
                                                dx = connector.center()[0] - up_down_text.center().x()
753
                                                dy = connector.center()[1] - up_down_text.center().y()
754
                                                dist = (up_down_text.sceneBoundingRect().height() + up_down_text.sceneBoundingRect().width()) * ratio / 2
755
                                                length = math.sqrt(dx*dx + dy*dy)
756
                                                if length < dist and length < minDist:
757
                                                    up_down_find[index] = up_down_text
758

  
759
                                        if up_down_find[0] and up_down_find[1]:
760
                                            for index in range(len(stream_line)):
761
                                                attrs = stream_line[index].getAttributes()
762
                                                for key in attrs.keys():
763
                                                    if key.Attribute == attr:
764
                                                        attrs[key] = up_down_find[index].text()
765
                                                        key.AssocItem = up_down_find[index]
766
                                                        stream_line[index].add_assoc_item(up_down_find[index], key.AttrAt, force=True)
767
                                                        up_down_find[index].owner = stream_line[index]
768
                                                        break
769
                                        
697 770
                                spec_break_items.append(spec_break)
698 771

  
699 772
                    for spec_break_item in spec_break_items:
700 773
                        spec_break_item.transfer.onRemoved.connect(App.mainWnd().itemRemoved)
701 774
                        spec_break_item.addSvgItemToScene(worker.graphicsView.scene)
775
                        
776
        worker.updateProgress.emit(tracer.maxValue)
702 777

  
703 778
        # trace special item
704 779
        worker.displayMessage.emit('Find line for special item...')
DTI_PID/DTI_PID/Scripts/MSSQL/ID2.sql
1330 1330
('61190fa0-8074-4f25-8b47-8b0b686e1ede',-1,'Freeze','Freeze','Int',NULL,0,NULL,'ALL',0,6),
1331 1331
('3329313c-cd06-4b89-a10b-795dcdf5830f',-1,'To','To','String',NULL,0,NULL,'ALL',0,5),
1332 1332
('3e073331-0faf-4fc1-8853-2db6291b9161',33,'UpStream','UpStream','Comp Item','item',0,NULL,'ALL',3,0),
1333
('ee40b309-517f-45b8-9a1c-f56072fa5be2',33,'DownStream','DownStream','Comp Item','item',1,NULL,'ALL',3,1);
1333
('ee40b309-517f-45b8-9a1c-f56072fa5be2',33,'DownStream','DownStream','Comp Item','item',1,NULL,'ALL',3,1),
1334
('aa8f1cab-de52-41da-8905-553bcf6513c5',0, 'NominalDiameter', 'NominalDiameter', 'Text Item', 'item.text()',0, null ,'ALL',3,0),
1335
('7c7ba284-af5b-4e51-8905-e774ff3f1cfc',0, 'FluidCode', 'FluidCode', 'Text Item', 'item.text()',1, null ,'ALL',3,1),
1336
('a7c8ebd7-8241-4e4a-8729-0c37717bfcf4',0, 'InsulationPurpose', 'InsulationPurpose', 'Text Item', 'item.text()',2, null ,'ALL',3,2),
1337
('c9af746e-f8a8-4319-884a-3354dcc7f6ea',0, 'PnIDNumber', 'PnIDNumber', 'Text Item', 'item.text()',3, null ,'ALL',3,3),
1338
('1f65e4b7-ef2d-4121-b30a-9bbada20b16b',0, 'PipingMaterialsClass', 'PipingMaterialsClass', 'Text Item', 'item.text()',4, null ,'ALL',3,4),
1339
('0b37b3a1-ae56-4f4a-b7e5-587f36469802',0, 'UnitNumber', 'UnitNumber', 'Text Item', 'item.text()',5, null ,'ALL',3,5);
1334 1340

  
1335 1341

  
1336 1342
CREATE TABLE Attributes (
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
59 59

  
60 60
            self._properties = \
61 61
                { \
62
                    SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'): None, \
63
                    SymbolProp(None, 'Flow Mark', 'Size Text Item', Expression='self.EvaluatedSize'): None
62
                    SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'): None
64 63
                }
65 64

  
66 65
            self.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable)
......
1634 1633
        _pen.setColor(c)
1635 1634
        self.setPen(_pen)
1636 1635
        self.update()
1636

  
1637
    def clear_labels(self):
1638
        """ clrear spec labels """
1639
        attrs = self.getAttributes()
1640
        index = 0
1641
        for key in attrs.keys():
1642
            if index >= 6:
1643
                break
1644
            if key.AssocItem:
1645
                self.remove_assoc_item(key.AssocItem)
1646
                key.AssocItem = None
1647
            attrs[key] = ''
1648
            index += 1
1637 1649
    
1638 1650
    def update_flow_mark(self, position, length):
1639 1651
        """ update flow mark for flow arrow """

내보내기 Unified diff

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