프로젝트

일반

사용자정보

개정판 2c3a5133

ID2c3a5133cda05b07d0a123e22a8af0876f2a8e75
상위 7e5c0b5c
하위 4c4e7f0b

함의성이(가) 7달 전에 추가함

fix library, add line b

Change-Id: I63fcdc7d99a54bfac525c4c9547d4adadb482d63

차이점 보기:

DTI_PID/DTI_PID/LibraryItem.py
192 192

  
193 193
        mime = QMimeData()
194 194
        mime.setText(self._symbol.getName())
195
        mime.tag = self._symbol
195 196

  
196 197
        drag = QDrag(self)
197 198
        drag.setMimeData(mime)
DTI_PID/DTI_PID/QtImageViewerScene.py
161 161
                        item.keyPressEvent(event)
162 162
                event.accept()
163 163
                return
164
            elif event.key() == Qt.Key_B or event.key() == Qt.Key_N or event.key() == Qt.Key_Insert:
164
            elif event.key() == Qt.Key_N or event.key() == Qt.Key_Insert:
165 165
                items = [item for item in self.selectedItems() if issubclass(type(item), SymbolSvgItem)]
166 166
                if items:
167 167
                    for item in items:
......
171 171
                                break
172 172
                event.accept()
173 173
                return
174

  
174
            elif event.key() == Qt.Key_B:
175
                lines = [item for item in self.selectedItems() if type(item) == QEngineeringLineItem]
176
                symbols = [item for item in self.selectedItems() if issubclass(type(item), SymbolSvgItem)]
177
                if not lines and symbols:
178
                    for symbol in symbols:
179
                        item.keyPressEvent(event)
180
                elif lines:
181
                    for line in lines:
182
                        line.keyPressEvent(event)
183
                event.accept()
184
                return
175 185
            elif event.key() == Qt.Key_C and event.modifiers() & Qt.ControlModifier:
176 186
                from xml.etree import ElementTree
177 187
                from xml.etree.ElementTree import SubElement
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
1513 1513
            from App import App
1514 1514

  
1515 1515
            App.mainWnd().keyPressEvent(event)
1516
        elif event.key() == Qt.Key_B:
1517
            self.bind_close_items()
1518

  
1519
    def bind_close_items(self):
1520
        """ connect close item by pressing B """
1521
        from SymbolSvgItem import SymbolSvgItem
1522
        from EngineeringNozzleItem import QEngineeringNozzleItem
1523
        from EngineeringEquipmentItem import QEngineeringEquipmentItem
1524
        from shapely.geometry import Point
1525
        from AppDocData import AppDocData
1526

  
1527
        scene = self.scene()
1528
        app_doc_data = AppDocData.instance()
1529
        if scene:
1530
            configs = app_doc_data.getConfigs('Line Detector', 'Length to connect line')
1531
            toler = int(configs[0].value) if configs else 20
1532

  
1533
            if self.length() < 2 * toler:
1534
                return
1535

  
1536
            items = [item for item in scene.selectedItems() if issubclass(type(item), SymbolSvgItem)]
1537

  
1538
            for l_connector in self.connectors:
1539
                if l_connector.connectedItem:
1540
                    continue
1541

  
1542
                _pt1 = Point(l_connector.center()[0], l_connector.center()[1])
1543
                dist = sys.maxsize
1544
                selected = None
1545
                dx = 0
1546
                dy = 0
1547

  
1548
                for item in items:
1549
                    for i_connector in item.connectors:
1550
                        if i_connector.connectedItem:
1551
                            continue
1552

  
1553
                        _pt2 = Point(i_connector.center()[0], i_connector.center()[1])
1554
                        length = _pt1.distance(_pt2)
1555
                        if length < toler and length < dist:
1556
                            selected = item
1557
                            dx = _pt1.x - _pt2.x
1558
                            dy = _pt1.y - _pt2.y
1559

  
1560
                if selected:
1561
                    res = self.connect_if_possible(selected, toler)
1562
                    if res:
1563
                        selected.moveBy(dx, dy)
1516 1564

  
1517 1565
    def freeze_attriute(self, flag=None):
1518 1566
        from App import App

내보내기 Unified diff

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