def mouseReleaseEvent(self, event):
        """
        Called when mouse button is released.
        Resets selected handle and mouse press pos
        """
        self.setCursor(Qt.OpenHandCursor)

        self.set_pixmap()

        # update clip position if changed
        if self.x_pos != self.mouse_press_start_pos:
            if self.group_id is None:
                self.__controller.move_timeable(self.view_id,
                                                self.mouse_press_start_pos,
                                                self.x_pos)
            else:
                diff = self.x_pos - self.mouse_press_start_pos
                self.__controller.group_move_operation(self.group_id, diff)

        # trim start or end if resize happened
        if (self.resizable_right != self.infos_on_click["resizable_right"] or
                self.resizable_left != self.infos_on_click["resizable_left"]):
            self.__controller.resize_timeable(self.infos_on_click,
                                              self.get_info_dict())

        self.mouse_press_pos = 0
        self.handle_selected = None
        self.mouse_press_rect = None

        QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 2
0
    def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton:
            if self.m_mouse_down:

                for line_mov in self.m_line_mov_list:
                    item = line_mov
                    canvas.scene.removeItem(item)
                    del item
                self.m_line_mov_list.clear()

                for connection in canvas.connection_list:
                    if CanvasConnectionConcerns(connection, self.m_group_id,
                                                self.m_port_id_list):
                        connection.widget.setLocked(False)

                if self.m_hover_item:
                    if (self.m_last_rclick_item != self.m_hover_item
                            and time.time() > self.m_r_click_time + 0.3):
                        self.ConnectToHover()
                    canvas.scene.clearSelection()

                elif self.m_last_rclick_item:
                    canvas.scene.clearSelection()

            if self.m_cursor_moving:
                self.setCursor(QCursor(Qt.ArrowCursor))

            self.m_hover_item = None
            self.m_mouse_down = False
            self.m_cursor_moving = False
            canvas.is_line_mov = False
        QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 3
0
 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         parent = self.parentItem()
         xTL, yTL, xBR, yBR = self.model_bounds
         ct = self.corner_type
         epos = event.scenePos()
         new_pos = self.item_start + epos - self.event_start_position
         new_x = new_pos.x()
         new_y = new_pos.y()
         hwidth = self.half_width
         if ct == TOP_LEFT:
             new_x_TL = xTL - hwidth if new_x + hwidth > xTL else new_x
             new_y_TL = yTL - hwidth if new_y + hwidth > yTL else new_y
             tl, _ = parent.reconfigureRect(
                 (new_x_TL + hwidth, new_y_TL + hwidth), (), do_grid=True)
             self.alignPos(*tl)
         elif ct == BOTTOM_RIGHT:
             new_x_BR = xBR + hwidth if new_x + hwidth < xBR else new_x
             new_y_BR = yBR + hwidth if new_y + hwidth < yBR else new_y
             _, br = parent.reconfigureRect(
                 (), (new_x_BR + hwidth, new_y_BR + hwidth), do_grid=True)
             self.alignPos(*br)
         else:
             raise NotImplementedError("corner_type %d not supported" %
                                       (ct))
         self.model_bounds = ()
     if self.is_grabbing:
         self.is_grabbing = False
         parent = self.parentItem()
         parent.setMovable(False)
         QGraphicsItem.mouseReleaseEvent(parent, event)
         parent.finishDrag()
Esempio n. 4
0
 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         parent = self.parentItem()
         xTL, yTL, xBR, yBR = self.model_bounds
         ct = self.corner_type
         epos = event.scenePos()
         new_pos = self.item_start + epos - self.event_start_position
         new_x = new_pos.x()
         new_y = new_pos.y()
         hwidth = self.half_width
         if ct == TOP_LEFT:
             new_x_TL = xTL - hwidth if new_x + hwidth > xTL else new_x
             new_y_TL = yTL - hwidth if new_y + hwidth > yTL else new_y
             tl, _ = parent.reconfigureRect((new_x_TL + hwidth, new_y_TL + hwidth), (), do_grid=True)
             self.alignPos(*tl)
         elif ct == BOTTOM_RIGHT:
             new_x_BR = xBR + hwidth if new_x + hwidth < xBR else new_x
             new_y_BR = yBR + hwidth if new_y + hwidth < yBR else new_y
             _, br = parent.reconfigureRect((), (new_x_BR + hwidth, new_y_BR + hwidth), do_grid=True)
             self.alignPos(*br)
         elif ct == TOP_RIGHT:
             pass
         elif ct == BOTTOM_LEFT:
             pass
         else:
             raise NotImplementedError("corner_type %d not supported" % (ct))
         self.model_bounds = ()
     if self.is_grabbing:
         self.is_grabbing = False
         parent = self.parentItem()
         parent.setMovable(False)
         QGraphicsItem.mouseReleaseEvent(parent, event)
         parent.finishDrag()
Esempio n. 5
0
 def mouseReleaseEvent(self, event):
     if self.m_cursor_moving:
         self.unsetCursor()
         QTimer.singleShot(0, self.fixPos)
     self.m_mouse_down = False
     self.m_cursor_moving = False
     QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 6
0
 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         self.model_bounds = ()
     if self.is_grabbing:
         # print("I am released")
         self.is_grabbing = False
         parent = self.parentItem()
         parent.setMovable(False)
         QGraphicsItem.mouseReleaseEvent(parent, event)
         parent.finishDrag()
Esempio n. 7
0
 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         self.model_bounds = ()
     if self.is_grabbing:
         # print("I am released")
         self.is_grabbing = False
         parent = self.parentItem()
         parent.setMovable(False)
         QGraphicsItem.mouseReleaseEvent(parent, event)
         parent.finishDrag()
Esempio n. 8
0
 def mouseReleaseEvent(self, event: 'QGraphicsSceneMouseEvent') -> None:
     """
     :param event:
     :return:
     """
     if self.is_left_mouse_move:
         self._item_has_move = True
         self.item_moved_signal.emit()
         self.is_left_mouse_move = self.is_left_mouse_press = False
     QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 9
0
    def mouseReleaseEvent(self, event):
        """Handle mouse release event.

        Argument(s):
        event (QGraphicsSceneMouseEvent): Graphics scene mouse event
        """
        QGraphicsItem.mouseReleaseEvent(self, event)

        # Construct edge if a semi edge is built
        if self.semiEdge is not None:
            # Remove the semi edge
            self.scene().removeItem(self.semiEdge)
            self.semiEdge = None

            # Filter item on the mouse and only get GraphicsNode
            items = [
                item for item in self.scene().items(event.scenePos()) if isinstance(item, GraphicsNode) and item != self
            ]
            if items:
                # Create edge
                self.graphicsGraphView.controller.onCreateEdge(self.id, items[0].id)
Esempio n. 10
0
    def mouseReleaseEvent(self, event):
        '''Handle mouse release event.

        Argument(s):
        event (QGraphicsSceneMouseEvent): Graphics scene mouse event
        '''
        QGraphicsItem.mouseReleaseEvent(self, event)

        # Construct edge if a semi edge is built
        if self.semiEdge is not None:
            # Remove the semi edge
            self.scene().removeItem(self.semiEdge)
            self.semiEdge = None

            # Filter item on the mouse and only get GraphicsNode
            items = [item for item in self.scene().items(event.scenePos())
                     if isinstance(item, GraphicsNode) and item != self]
            if items:
                # Create edge
                self.graphicsGraphView.controller.onCreateEdge(self.id,
                                                               items[0].id)
Esempio n. 11
0
 def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent):
     """Repeates mouseMove calculation in case any new movement.
     """
     self.setCursor(Qt.ArrowCursor)
     delta = int(floor((self.x()+event.pos().x()) / BASE_WIDTH)) - self._offset_idx
     delta = util.clamp(delta,
                        self._low_drag_bound-self._start_idx_low,
                        self._high_drag_bound-self._start_idx_high+self.width())
     if self._delta != delta:
         self._idx_low = int(self._start_idx_low + delta)
         self._idx_high = int(self._start_idx_high + delta)
         self._delta = delta
         self.reconfigureRect((), ())
     self._high_drag_bound = self._model_part.getProperty('max_vhelix_length')  # reset for handles
     return QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 12
0
 def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent):
     """Repeates mouseMove calculation in case any new movement.
     """
     self.setCursor(Qt.ArrowCursor)
     delta = int(floor(
         (self.x() + event.pos().x()) / BASE_WIDTH)) - self._offset_idx
     delta = util.clamp(
         delta, self._low_drag_bound - self._start_idx_low,
         self._high_drag_bound - self._start_idx_high + self.width())
     if self._delta != delta:
         self._idx_low = int(self._start_idx_low + delta)
         self._idx_high = int(self._start_idx_high + delta)
         self._delta = delta
         self.reconfigureRect((), ())
     self._high_drag_bound = self._model_part.getProperty(
         'max_vhelix_length')  # reset for handles
     return QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 13
0
 def mouseReleaseEvent(self, event):
     self.ungrabMouse()
     QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 14
0
 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         parent = self.parentItem()
         mTLx, mTLy, mBRx, mBRy = self.model_bounds
         poTL = parent.outline.rect().topLeft()
         poBR = parent.outline.rect().bottomRight()
         poTLx, poTLy = poTL.x(), poTL.y()
         poBRx, poBRy = poBR.x(), poBR.y()
         epos = event.scenePos()
         new_pos = self.item_start + epos - self.event_start_position
         h_w = self.half_width
         new_x = new_pos.x() + h_w
         new_y = new_pos.y() + h_w
         ht = self._handle_type
         if ht == HandleEnum.TOP_LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             new_y_TL = mTLy if new_y > mTLy else new_y
             r = parent.reconfigureRect((new_x_TL, new_y_TL), (),
                                        finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.TOP:
             new_y_TL = mTLy if new_y > mTLy else new_y
             r = parent.reconfigureRect((poTLx, new_y_TL), (), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.TOP_RIGHT:
             new_y_TL = mTLy if new_y > mTLy else new_y
             new_x_BR = mBRx if new_x < mBRx else new_x
             r = parent.reconfigureRect((poTLx, new_y_TL),
                                        (new_x_BR, poBRy),
                                        finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.RIGHT:
             new_x_BR = mBRx if new_x < mBRx else new_x
             r = parent.reconfigureRect((), (new_x_BR, poBRy), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM_RIGHT:
             new_x_BR = mBRx if new_x < mBRx else new_x
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((), (new_x_BR, new_y_BR),
                                        finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM:
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((), (poBRx, new_y_BR), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM_LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((new_x_TL, poTLy),
                                        (poBRx, new_y_BR),
                                        finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             r = parent.reconfigureRect((new_x_TL, poTLy), (), finish=True)
             self._group.alignHandles(r)
         self.model_bounds = ()
         parent.showModelMinBoundsHint(self._handle_type, show=False)
     if self._group.is_dragging:
         self._group.is_dragging = False
         parent = self.parentItem()
         parent.setMovable(False)
         parent.finishDrag()
     self.setCursor(Qt.OpenHandCursor)
     # NOTE was QGraphicsItem.mouseReleaseEvent(parent, event) but that errored
     # NC 2018.01.29 so that seemd to fix the error
     return QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 15
0
 def mouseReleaseEvent(self, event):
     if event.button() == Qt.LeftButton:
         self.handleMouseRelease()
     QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 16
0
 def mouseReleaseEvent(self, event):
     self.handleMouseRelease()
     QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 17
0
 def mouseReleaseEvent(self, event):
     if self.model_bounds:
         parent = self.parentItem()
         mTLx, mTLy, mBRx, mBRy = self.model_bounds
         poTL = parent.outline.rect().topLeft()
         poBR = parent.outline.rect().bottomRight()
         poTLx, poTLy = poTL.x(), poTL.y()
         poBRx, poBRy = poBR.x(), poBR.y()
         epos = event.scenePos()
         new_pos = self.item_start + epos - self.event_start_position
         h_w = self.half_width
         new_x = new_pos.x()+h_w
         new_y = new_pos.y()+h_w
         ht = self._handle_type
         if ht == HandleEnum.TOP_LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             new_y_TL = mTLy if new_y > mTLy else new_y
             r = parent.reconfigureRect((new_x_TL, new_y_TL), (), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.TOP:
             new_y_TL = mTLy if new_y > mTLy else new_y
             r = parent.reconfigureRect((poTLx, new_y_TL), (), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.TOP_RIGHT:
             new_y_TL = mTLy if new_y > mTLy else new_y
             new_x_BR = mBRx if new_x < mBRx else new_x
             r = parent.reconfigureRect((poTLx, new_y_TL), (new_x_BR, poBRy), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.RIGHT:
             new_x_BR = mBRx if new_x < mBRx else new_x
             r = parent.reconfigureRect((), (new_x_BR, poBRy), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM_RIGHT:
             new_x_BR = mBRx if new_x < mBRx else new_x
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((), (new_x_BR, new_y_BR), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM:
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((), (poBRx, new_y_BR), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.BOTTOM_LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             new_y_BR = mBRy if new_y < mBRy else new_y
             r = parent.reconfigureRect((new_x_TL, poTLy), (poBRx, new_y_BR), finish=True)
             self._group.alignHandles(r)
         elif ht == HandleEnum.LEFT:
             new_x_TL = mTLx if new_x > mTLx else new_x
             r = parent.reconfigureRect((new_x_TL, poTLy), (), finish=True)
             self._group.alignHandles(r)
         self.model_bounds = ()
         parent.showModelMinBoundsHint(self._handle_type, show=False)
     if self._group.is_dragging:
         self._group.is_dragging = False
         parent = self.parentItem()
         parent.setMovable(False)
         parent.finishDrag()
     self.setCursor(Qt.OpenHandCursor)
     # NOTE was QGraphicsItem.mouseReleaseEvent(parent, event) but that errored
     # NC 2018.01.29 so that seemd to fix the error
     return QGraphicsItem.mouseReleaseEvent(self, event)
Esempio n. 18
0
 def mouseReleaseEvent(self, e):
     QGraphicsItem.mouseReleaseEvent(self, e)