프로젝트

일반

사용자정보

개정판 5da1fdfd

ID5da1fdfd10557f8c3fbc5c0b5edfc6dbed051525
상위 bb942cdc
하위 48592752

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

dev issue #622: save connection logic 수정

차이점 보기:

DTI_PID/DTI_PID/Commands/DefaultCommand.py
38 38
        @brief      Scroll / Pan / Zoom with Wheel Button
39 39
        @author     Jeongwoo
40 40
        @date       18.04.10
41
        @history    .
41
        @history    kyouho  2018.07.31  add copy symbol logic
42 42
    '''
43 43
    def execute(self, param):
44 44
        event = param[1]
......
109 109

  
110 110
    def redo(self):
111 111
        pass
112

  
112
    
113
    '''
114
        @brief      xml to ElementTree and ElementTree to Symbol
115
        @author     kyouho
116
        @date       18.07.31
117
    '''
113 118
    def copySymbol(self, xmlStr):
114 119
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse, fromstring
115 120
        sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '\\Shapes')
DTI_PID/DTI_PID/MainWindow.py
937 937
                    item[0].owner = matches[0][0]
938 938
            # up to here
939 939
            
940
            # set symbol's connectItem
941
            symbols = [symbol for symbol in self.graphicsView.scene.items() if issubclass(type(symbol), SymbolSvgItem)]
942
            for symbol in symbols:
943
                connectors = symbol.connectors
944
                for connector in connectors:
945
                    if connector.connectedItem is not None:
946
                        pass
947

  
948
            # up to here
949

  
940 950
            for item in symbols:
941 951
                self.addSvgItemToScene(item[0])
942 952

  
DTI_PID/DTI_PID/QtImageViewer.py
4 4
try:
5 5
    from PyQt5.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QPointF
6 6
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QPainter, QCursor, QPen, QBrush, QColor, QTransform
7
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QApplication
7
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QApplication, QMessageBox
8 8
except ImportError:
9 9
    try:
10 10
        from PyQt4.QtCore import *
......
372 372
                    xmlStr = QApplication.clipboard().text()
373 373
                    if xmlStr.find('<SYMBOL>') > -1 and xmlStr.find('</SYMBOL>') > -1:
374 374
                        self.command.copySymbol(QApplication.clipboard().text())
375
            elif event.key() == Qt.Key_S and self.isPressCtrl:
376
                import XmlGenerator as xg
377
                from AppDocData import AppDocData
378
                docData = AppDocData.instance()
379
                xg.writeXmlOnScene(docData.imgName, docData.imgWidth, docData.imgHeight, self.scene)
380
                QMessageBox.about(self, "알림", "정상적으로 저장되었습니다.")
375 381

  
376 382
            QGraphicsView.keyPressEvent(self, event)
377 383
        except Exception as ex:
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
536 536
                    yecheol  2018.07.11 add attribute of symbol (hasInstrumentLabel)
537 537
                    humkyung 2018.07.20 write owner's uid to xml
538 538
                    humkyung 2018.07.23 write connected item's uid to xml
539
                    kyouho  2018.07.31 
539 540
    '''
540 541
    def toXml(self):
541 542
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
......
565 566
            originNode.text = '{},{}'.format(self.origin[0], self.origin[1])
566 567
            node.append(originNode)
567 568

  
568
            # write conected items' uid to xml
569
            connsNode = Element('CONNS')
570
            connsNode.text = ','.join([str(connector.connectedItem.uid) if connector.connectedItem is not None else 'None' for connector in self.connectors])
571
            node.append(connsNode)
572
            # up to here
569
            connectorsNode = Element('CONNECTORS')
570
            for connector in self.connectors:
571
                connectorNode = Element('CONNECTOR')
572
                connectedItemNode = Element('CONNECTEDITEM')
573
                connectedItemNode.text = str(connector.connectedItem.uid) if connector.connectedItem is not None else 'None'
574
                connectPointNode = Element('CONNECTPOINT')
575
                connectPointNode.text = str(connector.connectPoint[0]) + ',' + str(connector.connectPoint[1])
576
                sceneConnectPointNode = Element('SCENECONNECTPOINT')
577
                sceneConnectPointNode.text = str(connector.sceneConnectPoint[0]) + ',' + str(connector.sceneConnectPoint[1])
578

  
579
                connectorNode.append(connectedItemNode)
580
                connectorNode.append(connectPointNode)
581
                connectorNode.append(sceneConnectPointNode)
582
                connectorsNode.append(connectorNode)
583
            node.append(connectorsNode)
573 584

  
574 585
            connectionNode = Element('CONNECTIONPOINT')
575 586
            connectionPoint = ''
......
626 637
        @date       2018.07.20
627 638
        @history    humkyung 2018.07.20 parse uid from xml node
628 639
                    humkyung 2018.07.23 parse connected item's uid from xml node
640
                    kyouho  2018.07.31 
629 641
    '''
630 642
    @staticmethod 
631 643
    def fromXml(node):
......
654 666
            ownerNode = node.find('OWNER')
655 667
            owner = ownerNode.text if ownerNode is not None else None
656 668

  
657
            connsNode = node.find('CONNS')
658
            conns = [uuid.UUID(conn) if conn != 'None' else None for conn in connsNode.text.split(',')] if connsNode is not None and connsNode.text is not None else []
659

  
660 669
            hasInstrumentLabelNode = node.find('HASINSTRUMENTLABEL')
661 670
            hasInstrumentLabel = hasInstrumentLabelNode.text if hasInstrumentLabelNode is not None else 'False'
662 671

  
......
665 674
            if os.path.isfile(svgFilePath):
666 675
                item[0] = SymbolSvgItem.createItem(type, svgFilePath, uid)
667 676
                item[0].buildItem(name, type, angle, pt, size, origin, connPts, baseSymbol, childSymbol, hasInstrumentLabel)
668
                for connIndex in range(len(conns)):
669
                    item[0].connectors[connIndex].connectedItem = conns[connIndex]
677
                
678
                connectors = node.find('CONNECTORS')
679
                if connectors is not None:
680
                    iterIndex = 0
681
                    for connector in connectors.iter('CONNECTOR'):
682
                        connectedItemStr = connector.find('CONNECTEDITEM').text
683
                        connectPointStr = connector.find('CONNECTPOINT').text.split(',')
684
                        sceneConnectPointStr = connector.find('SCENECONNECTPOINT').text.split(',')
685

  
686
                        item[0].connectors[iterIndex].connectedItem = connectedItemStr if connectedItemStr != 'None' else None
687
                        item[0].connectors[iterIndex].connectPoint = (float(connectPointStr[0]), float(connectPointStr[1]))
688
                        item[0].connectors[iterIndex].sceneConnectPoint = (float(sceneConnectPointStr[0]), float(sceneConnectPointStr[1]))
689

  
690
                        iterIndex += 1
691
                
670 692
                item[1] = owner
671 693
        except Exception as ex:
672 694
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))

내보내기 Unified diff

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