프로젝트

일반

사용자정보

개정판 a9bb66b8

IDa9bb66b8ef58ed147436e503804744bf35d7abc9
상위 4e426f34
하위 b9334e15

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

fixed issue #610:
- 'c'키를 눌러 시작점, 끝점 바꿈

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
21 21
import shapely
22 22

  
23 23
class QEngineeringLineItem(QGraphicsLineItem, QEngineeringAbstractItem):
24
    ARROW_SIZE = 30
25

  
24 26
    '''
25 27
        @history    2018.05.11  Jeongwoo    Make Comments self.setPen()
26 28
                    2018.05.15  Jeongwoo    Change method to call parent's __init__
......
820 822
        pass
821 823
    
822 824
    '''
823
        @brief  remove item when user press delete key
824
        @author humkyung
825
        @date   2018.04.23
825
        @brief      remove item when user press delete key
826
        @author     humkyung
827
        @date       2018.04.23
828
        @history    swap start, end point when user press 'c' key
826 829
    '''
827 830
    def keyPressEvent(self, event): 
828 831
        if event.key() == Qt.Key_Delete:
829
            #self.removed.emit((QGraphicsPathItem)(self))
830 832
            self.scene().removeItem(self)
833
        elif event.key() == Qt.Key_C:
834
            self.reverse()
835
            rect = self.sceneBoundingRect()
836
            rect.setRect(rect.left() - QEngineeringLineItem.ARROW_SIZE, rect.top() - QEngineeringLineItem.ARROW_SIZE, 
837
                rect.width() + QEngineeringLineItem.ARROW_SIZE*2, rect.height() + QEngineeringLineItem.ARROW_SIZE*2)
838
            self.scene().invalidate(rect)
831 839
    
832 840
    '''
833 841
        @brief  draw rect when item is selected
......
850 858
        QGraphicsLineItem.paint(self, painter, option, widget)
851 859
        
852 860
        ## draw direction mark
853
        SIZE = 30
854

  
855 861
        length = self.length()
856 862
        if length > 0:
857 863
            ptStart = self.startPoint()
......
861 867
            perpendicular = (-_dir[1], _dir[0])
862 868

  
863 869
            polygon = QPolygonF()
864
            polygon.append(QPointF(ptEnd[0] - _dir[0]*SIZE + perpendicular[0]*SIZE*0.25, 
865
                                ptEnd[1] - _dir[1]*SIZE + perpendicular[1]*SIZE*0.25))
866
            polygon.append(QPointF(ptEnd[0] - _dir[0]*SIZE - perpendicular[0]*SIZE*0.25, 
867
                                ptEnd[1] - _dir[1]*SIZE - perpendicular[1]*SIZE*0.25))
870
            polygon.append(QPointF(ptEnd[0] - _dir[0]*QEngineeringLineItem.ARROW_SIZE + perpendicular[0]*QEngineeringLineItem.ARROW_SIZE*0.25, 
871
                                ptEnd[1] - _dir[1]*QEngineeringLineItem.ARROW_SIZE + perpendicular[1]*QEngineeringLineItem.ARROW_SIZE*0.25))
872
            polygon.append(QPointF(ptEnd[0] - _dir[0]*QEngineeringLineItem.ARROW_SIZE - perpendicular[0]*QEngineeringLineItem.ARROW_SIZE*0.25, 
873
                                ptEnd[1] - _dir[1]*QEngineeringLineItem.ARROW_SIZE - perpendicular[1]*QEngineeringLineItem.ARROW_SIZE*0.25))
868 874
            polygon.append(QPointF(ptEnd[0], ptEnd[1]))
869 875
            polygon.append(polygon[0])
870 876

  
......
875 881
            painter.drawConvexPolygon(polygon)
876 882
        ## up to here
877 883

  
878
        '''
879
        if hasattr(self, '_selectedIndex'):
880
            if self._selectedIndex == 0:
881
                pt = self.startPoint()
882
                painter.drawLine(pt[0] - 5, pt[1] - 5, pt[0] + 5, pt[1] + 5)
883
                painter.drawLine(pt[0] + 5, pt[1] - 5, pt[0] - 5, pt[1] + 5)
884
            elif self._selectedIndex == 1:
885
                pt = self.endPoint()
886
                painter.drawLine(pt[0] - 5, pt[1] - 5, pt[0] + 5, pt[1] + 5)
887
                painter.drawLine(pt[0] + 5, pt[1] - 5, pt[0] - 5, pt[1] + 5)
888
        '''
889

  
890 884
        if self.isSelected():
891 885
            self.drawFocusRect(painter)
892 886

  

내보내기 Unified diff

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