def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent): """ mouseMoveEvent Parameters ---------- event : QGraphicsSceneMouseEvent """ geom = self._node.geometry state = self._node.state if state.resizing: diff = event.pos() - event.lastPos() w = self._node.model.embedded_widget() if w: self.prepareGeometryChange() old_size = w.size() + QSize(diff.x(), diff.y()) w.setFixedSize(old_size) old_size_f = QSizeF(old_size) self._proxy_widget.setMinimumSize(old_size_f) self._proxy_widget.setMaximumSize(old_size_f) self._proxy_widget.setPos(geom.widget_position) geom.recalculate_size() self.update() self.move_connections() event.accept() else: super().mouseMoveEvent(event) if event.lastPos() != event.pos(): self.move_connections() event.ignore() bounding = self.mapToScene(self.boundingRect()).boundingRect() r = self.scene().sceneRect().united(bounding) self.scene().setSceneRect(r)
def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent): """ mouseMoveEvent Parameters ---------- event : QGraphicsSceneMouseEvent """ self.prepareGeometryChange() # view = event.widget() # TODO/BUG: widget is returning QWidget(), not QGraphicsView... view = self._scene.views()[0] node = self._scene.locate_node_at(event.scenePos(), view.transform()) self._connection.interact_with_node(node) state_required = self._connection.required_port if node: node.react_to_possible_connection( state_required, self._connection.data_type(opposite_port(state_required)), event.scenePos() ) # ------------------- offset = event.pos() - event.lastPos() required_port = self._connection.required_port if required_port != PortType.none: self._geometry.move_end_point(required_port, offset) # ------------------- self.update() event.accept()