프로젝트

일반

사용자정보

개정판 265a1e83

ID265a1e83b1ff94dff198adba35696f8ffbabe251
상위 1e67c5f1
하위 628ad62c

함의성이(가) 6년 이상 전에 추가함

issue #655: train ui

차이점 보기:

DTI_PID/DTI_PID/Shapes/TrainingBoxItem.py
32 32
        self.angle = 0  # angle in radian
33 33
        self.conns = []
34 34
        self._owner = None
35
        self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable|QGraphicsItem.ItemIsMovable)
35
        self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)#|QGraphicsItem.ItemIsMovable)
36 36
        self.setAcceptHoverEvents(True)
37 37
        self.setAcceptTouchEvents(True)
38 38

  
......
49 49
        self.transfer = Transfer()
50 50
 
51 51
    def mouseReleaseEvent(self, event):
52
        QGraphicsRectItem.mouseReleaseEvent(self, event)
53
        x, y = round(event.pos().x()), round(event.pos().y())
52
        """
53
        
54
        self.setRect(QRectF(self.scenePos().x(), self.scenePos().y(), self.rect().width(), self.rect().height()))
55
        print(self.rect().x())
56
        print(self.rect().y())
57
       
58
        x, y = round(self.pos().x()), round(self.pos().y())
54 59
        print(x)
55 60
        print(y)
56

  
57

  
58

  
61
        rect = self.rect()
62
        self.setRect(QRectF(rect.x() + x, rect.y() + y, rect.width(), rect.height()))
63
        self.setSelected(False)
64
        """
65
        QGraphicsRectItem.mouseReleaseEvent(self, event)
66
        bouding_rect = self.rect()
67
        self.setRect(QRectF(bouding_rect.x(), bouding_rect.y(), bouding_rect.width(), bouding_rect.height()))
68
        print(self.rect())
69
        print(self.sceneBoundingRect())
70
        self.scene.update()
59 71
    #    pen = QPen(Qt.SolidLine)
60 72
    #    pen.setColor(Qt.blue)
61 73
    #    pen.setWidthF(1)
......
80 92
        #transform.scale(1, 1)
81 93

  
82 94
        #self.setTransform(transform)
83
        #print(self.boundingRect().x())
84
        #print(self.boundingRect().y())
85 95

  
86
        self.scene.update()
96
        #self.scene.update()
87 97
        #QGraphicsRectItem.mouseReleaseEvent(self, event)
88 98

  
89 99
    def mousePressEvent(self, event):
90
        QGraphicsRectItem.mouseReleaseEvent(self, event)
91
        x, y = round(event.pos().x()), round(event.pos().y())
92
        print(x)
93
        print(y)
100
        self.scene.clearSelection()
101
        #QGraphicsRectItem.mouseReleaseEvent(self, event)
102
        #x, y = round(self.pos().x()), round(self.pos().y())
103
        #print(x)
104
        #print(y)
105
        
94 106
        #print('box')
95 107
        #x, y = round(event.pos().x()), round(event.pos().y())
96 108
        #print(x)
97
        #print(self.boundingRect().x())
98
        #print(self.boundingRect().y())
99
        #QGraphicsRectItem.mousePressEvent(self, event)
109
        print(self.sceneBoundingRect().x())
110
        print(self.sceneBoundingRect().y())
111
        QGraphicsRectItem.mousePressEvent(self, event)
100 112
     #   pen = QPen(Qt.SolidLine)
101 113
     #   pen.setColor(Qt.red)
102 114
     #   pen.setWidthF(1)
......
129 141

  
130 142
        QGraphicsRectItem.keyPressEvent(self, event)
131 143

  
144
    '''
145
        @brief  override paint
146
    '''
147
    def paint(self, painter, options=None, widget=None):
148
        QGraphicsRectItem.paint(self, painter, options, widget)
149

  
150
        painter.setPen(self.pen())
151
        painter.drawEllipse(QPointF(self.rect().x() , self.rect().y()), 3, 3)
152

  
132 153
    def addTextItemToScene(self, view):
133 154
        try:
134 155
            self.view = view

내보내기 Unified diff

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