def mousePressEvent(self, event): if canvas.scene.get_zoom_scale() <= 0.4: # prefer move box if zoom is too low event.ignore() return if event.button() == Qt.LeftButton: self.m_hover_item = None self.m_mouse_down = True self.m_cursor_moving = False for connection in canvas.connection_list: if CanvasConnectionConcerns(connection, self.m_group_id, self.m_port_id_list): self.m_has_connections = True break else: self.m_has_connections = False elif event.button() == Qt.RightButton: if canvas.is_line_mov: if self.m_hover_item: self.ConnectToHover() self.m_last_rclick_item = self.m_hover_item self.m_r_click_time = time.time() for line_mov in self.m_line_mov_list: line_mov.toggleReadyToDisc() line_mov.updateLinePos(event.scenePos()) QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): canvas.last_z_value += 1 self.setZValue(canvas.last_z_value) self.resetLinesZValue() self.m_cursor_moving = False if event.button() == Qt.RightButton: event.accept() canvas.scene.clearSelection() self.setSelected(True) self.m_mouse_down = False return elif event.button() == Qt.LeftButton: if self.sceneBoundingRect().contains(event.scenePos()): self.m_mouse_down = True else: # FIXME: Check if still valid: Fix a weird Qt behaviour with right-click mouseMove self.m_mouse_down = False event.ignore() return else: self.m_mouse_down = False QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): if self.flag_points_wall: if event.button() == Qt.LeftButton: calc = self.tree.rootItem.childItems[1].itemData[0][1] text = calc.lineEdit_points_wall.text() if text: if self.name not in text: calc.lineEdit_points_wall.setText(f'{text}, {self.name}') calc.points_wall_list.append(self) else: calc.lineEdit_points_wall.setText(self.name) calc.points_wall_list.append(self) QGraphicsItem.mousePressEvent(self, event) elif self.flag_points_geom_barell: if event.button() == Qt.LeftButton: calc = self.tree.rootItem.childItems[1].itemData[0][1] text = calc.lineEdit_points_geom_barell.text() if text: if self.name not in text: calc.lineEdit_points_geom_barell.setText(f'{text}, {self.name}') calc.points_geom_barell_list.append(self) else: calc.lineEdit_points_geom_barell.setText(self.name) calc.points_geom_barell_list.append(self) QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): """Event handler for when the mouse button is pressed inside this item. If a tool-specific mouse press method is defined, it will be called for the currently active tool. Otherwise, the default QGraphicsItem.mousePressEvent will be called. Note: Only applies the event if the clicked item is in the part item's active filter set. Args: event (QMouseEvent): contains parameters that describe the mouse event. """ if self.FILTER_NAME not in self._part_item.getFilterSet(): self._doc_controller.showFilterHints(True, filter_name=self.FILTER_NAME) return if event.button() == Qt.RightButton: return part_item = self._part_item tool = part_item._getActiveTool() tool_method_name = tool.methodPrefix() + "MousePress" if hasattr(self, tool_method_name): getattr(self, tool_method_name)(tool, part_item, event) else: QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): """Handler for user mouse press. Args: event (QGraphicsSceneMouseEvent): Contains item, scene, and screen coordinates of the the event, and previous event. Args: event (QMouseEvent): contains parameters that describe a mouse event. """ if event.button() == Qt.RightButton: return part = self._model_part part.setSelected(True) if self.isMovable(): return QGraphicsItem.mousePressEvent(self, event) tool = self._getActiveTool() if tool.FILTER_NAME not in part.document().filter_set: return tool_method_name = tool.methodPrefix() + "MousePress" if tool_method_name == 'createToolMousePress': return elif hasattr(self, tool_method_name): getattr(self, tool_method_name)(tool, event) else: event.setaccepted(False) QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): if self.m_mouse_down: self.handleMouseRelease() self.m_hover_item = None self.m_mouse_down = bool(event.button() == Qt.LeftButton) self.m_cursor_moving = False QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): QGraphicsItem.mousePressEvent(self, event) if event.button() == Qt.LeftButton: self.scene().prevent_mouse_release_deselect = True signals.navpointClick.emit(self.navpoint) if event.modifiers() & Qt.ShiftModifier: self.scene().addRemoveRouteNavpoint.emit(self.navpoint) event.accept()
def mousePressEvent(self, event): """ All mousePressEvents are passed to the group if it's in a group """ selection_group = self.group() if selection_group != None: selection_group.mousePressEvent(event) else: QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): if event.button() == Qt.LeftButton: selection.selectAircraft(self.radar_contact) elif event.button() == Qt.MiddleButton: if event.modifiers() & Qt.ShiftModifier: selection.unlinkAircraft(self.radar_contact) else: selection.linkAircraft(self.radar_contact) event.accept() QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): '''Handle mouse press event. Argument(s): event (QGraphicsSceneMouseEvent): Graphics scene mouse event ''' QGraphicsItem.mousePressEvent(self, event) # Get the focus if event.buttons() == Qt.LeftButton: self.getFocus(self.id)
def mousePressEvent(self, event: 'QGraphicsSceneMouseEvent') -> None: """ :param event: :return: """ self.scene().clearSelection() self.setSelected(True) if event.button() == Qt.LeftButton: self.is_left_mouse_press = True self.old_position = self.pos() QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): if event.button() == Qt.MiddleButton or event.source( ) == Qt.MouseEventSynthesizedByApplication: event.ignore() return if self.m_mouse_down: self.handleMouseRelease() self.m_hover_item = None self.m_mouse_down = bool(event.button() == Qt.LeftButton) self.m_cursor_moving = False QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): """ called when mouse is pressed on a timeable, sets the selected handle, sets the position where the mouse was pressed (important for moving and resizing) """ self.handle_selected = self.handle_at(event.pos()) self.mouse_press_pos = int(event.pos().x()) self.mouse_press_start_pos = self.x_pos self.mouse_press_rect = self.rect() self.infos_on_click = self.get_info_dict() QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): '''Handle mouse press event. Argument(s): event (QGraphicsSceneMouseEvent): Graphics scene mouse event ''' QGraphicsItem.mousePressEvent(self, event) # Create the semi-edge and get the focus if event.buttons() == Qt.LeftButton: self.getFocus(self.id) self.semiEdge = GraphicsSemiEdge(event.scenePos(), self) self.scene().addItem(self.semiEdge) elif event.buttons() == Qt.RightButton: self.contextMenu.popup(event.screenPos())
def mousePressEvent(self, event): """ Parses a mousePressEvent, calling the approproate tool method as necessary. Stores _move_idx for future comparison. """ if event.button() != Qt.LeftButton: event.ignore() QGraphicsItem.mousePressEvent(self, event) return self.scene().views()[0].addToPressList(self) self._move_idx = int(floor((self.x() + event.pos().x()) / _BASE_WIDTH)) tool_method_name = self._getActiveTool().methodPrefix() + "MousePress" if hasattr(self, tool_method_name): # if the tool method exists modifiers = event.modifiers() getattr(self, tool_method_name)(modifiers) # call tool method
def mousePressEvent(self, event): """Handle mouse press event. Argument(s): event (QGraphicsSceneMouseEvent): Graphics scene mouse event """ QGraphicsItem.mousePressEvent(self, event) # Create the semi-edge and get the focus if event.buttons() == Qt.LeftButton: self.getFocus(self.id) self.semiEdge = GraphicsSemiEdge(event.scenePos(), self) self.scene().addItem(self.semiEdge) elif event.buttons() == Qt.RightButton: self.contextMenu.popup(event.screenPos())
def selectToolMousePress(self, tool: AbstractGridToolT, event: QGraphicsSceneMouseEvent): """ Args: tool: Description event: Description """ tool.setPartItem(self) pt = tool.eventToPosition(self, event) part_pt_tuple = self.getModelPos(pt) part = self._model_part if part.isVirtualHelixNearPoint(part_pt_tuple): id_num = part.getVirtualHelixAtPoint(part_pt_tuple) if id_num >= 0: print(id_num) loc = part.getCoordinate(id_num, 0) print("VirtualHelix #{} at ({:.3f}, {:.3f})".format( id_num, loc[0], loc[1])) else: # tool.deselectItems() tool.modelClearSelected() else: # tool.deselectItems() tool.modelClearSelected() return QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): if event.button() == Qt.RightButton: return parent = self.parentItem() if self._group.is_resizable and event.modifiers() & Qt.ShiftModifier: self.setCursor(self._resize_cursor) self.model_bounds = parent.getModelMinBounds( handle_type=self._handle_type) self.event_start_position = event.scenePos() self.item_start = self.pos() parent.showModelMinBoundsHint(self._handle_type, show=True) event.setAccepted(True) # don't propagate return else: self.setCursor(Qt.ClosedHandCursor) parent = self.parentItem() self._group.is_dragging = True self.event_start_position = event.pos() parent.setMovable(True) # ensure we handle window toggling during moves qApp.focusWindowChanged.connect(self.focusWindowChangedSlot) res = QGraphicsItem.mousePressEvent(parent, event) event.setAccepted(True) # don't propagate return res
def selectToolMousePress(self, tool, event): """ Args: tool (TYPE): Description event (TYPE): Description """ if tool.clipboard is not None: self.pasteClipboard(tool, event) tool.setPartItem(self) pt = tool.eventToPosition(self, event) part_pt_tuple = self.getModelPos(pt) part = self._model_part if part.isVirtualHelixNearPoint(part_pt_tuple): id_num = part.getVirtualHelixAtPoint(part_pt_tuple) if id_num is not None: pass # loc = part.getCoordinate(id_num, 0) # print("VirtualHelix #{} at ({:.3f}, {:.3f})".format(id_num, loc[0], loc[1])) else: # tool.deselectItems() tool.modelClear() else: # tool.deselectItems() tool.modelClear() return QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event: QGraphicsSceneMouseEvent): """All mousePressEvents are passed to the group if it's in a group Args: event: Description """ selection_group = self.group() if selection_group is not None: selection_group.mousePressEvent(event) elif event.button() == Qt.RightButton: current_filter_set = self._viewroot.selectionFilterSet() if self.FILTER_NAME in current_filter_set and self.part().isZEditable(): self._right_mouse_move = True self.drag_last_position = event.scenePos() self.handle_start = self.pos() else: QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): """Handler for user mouse press. Args: event (QGraphicsSceneMouseEvent): Contains item, scene, and screen coordinates of the the event, and previous event. """ self._viewroot.clearSelectionsIfActiveTool() return QGraphicsItem.mousePressEvent(self, event)
def createToolMousePress(self, tool, event, alt_event=None): """Summary Args: tool (TYPE): Description event (TYPE): Description alt_event (None, optional): Description Returns: TYPE: Description """ # 1. get point in model coordinates: part = self._model_part if alt_event is None: # print() pt = tool.eventToPosition(self, event) # print("reg_event", pt) else: # pt = alt_event.scenePos() # pt = self.mapFromScene(pt) pt = alt_event.pos() # print("alt_event", pt) if pt is None: tool.deactivate() return QGraphicsItem.mousePressEvent(self, event) part_pt_tuple = self.getModelPos(pt) mod = Qt.MetaModifier if not (event.modifiers() & mod): pass # don't create a new VirtualHelix if the click overlaps with existing # VirtualHelix current_id_num = tool.idNum() check = part.isVirtualHelixNearPoint(part_pt_tuple, current_id_num) # print("current_id_num", current_id_num, check) # print(part_pt_tuple) tool.setPartItem(self) if check: id_num = part.getVirtualHelixAtPoint(part_pt_tuple) # print("got a check", id_num) if id_num is not None: # print("restart", id_num) vhi = self._virtual_helix_item_hash[id_num] tool.setVirtualHelixItem(vhi) tool.startCreation() else: # print("creating", part_pt_tuple) part.createVirtualHelix(*part_pt_tuple) id_num = part.getVirtualHelixAtPoint(part_pt_tuple) vhi = self._virtual_helix_item_hash[id_num] tool.setVirtualHelixItem(vhi) tool.startCreation()
def mousePressEvent(self, event: QGraphicsSceneMouseEvent): """Handler for user mouse press. Args: event: Contains item, scene, and screen coordinates of the event, and previous event. """ self._viewroot.clearSelectionsIfActiveTool() self.unsetActiveVirtualHelixItem() return QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event: QGraphicsSceneMouseEvent): """Handler for user mouse press. Args: event: Contains item, scene, and screen coordinates of the the event, and previous event. """ if event.button() == Qt.RightButton: return part = self._model_part part.setSelected(True) if self.isMovable(): return QGraphicsItem.mousePressEvent(self, event) tool = self._getActiveTool() if tool.FILTER_NAME not in part.document().filter_set: return tool_method_name = tool.methodPrefix() + "MousePress" if hasattr(self, tool_method_name): getattr(self, tool_method_name)(tool, event) else: event.setAccepted(False) QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event: QGraphicsSceneMouseEvent): """Parses a mousePressEvent. Stores _move_idx and _offset_idx for future comparison. """ self._high_drag_bound = self._model_part.getProperty('max_vhelix_length') - self.width() if event.modifiers() & Qt.ShiftModifier or self._moving_via_handle: self.setCursor(Qt.ClosedHandCursor) self._start_idx_low = self._idx_low self._start_idx_high = self._idx_high self._delta = 0 self._move_idx = int(floor((self.x()+event.pos().x()) / BASE_WIDTH)) self._offset_idx = int(floor(event.pos().x()) / BASE_WIDTH) else: return QGraphicsItem.mousePressEvent(self, event)
def createToolMousePress(self, tool: AbstractGridToolT, event: QGraphicsSceneMouseEvent, alt_event=None): """Summary Args: tool: Description event: Description alt_event (None, optional): Description """ # 1. get point in model coordinates: part = self._model_part if alt_event is None: pt = tool.eventToPosition(self, event) else: pt = alt_event.pos() if pt is None: tool.deactivate() return QGraphicsItem.mousePressEvent(self, event) part_pt_tuple: Vec3T = self.getModelPos(pt) mod = Qt.MetaModifier if not (event.modifiers() & mod): pass # don't create a new VirtualHelix if the click overlaps with existing # VirtualHelix current_id_num = tool.idNum() check = part.isVirtualHelixNearPoint(part_pt_tuple, current_id_num) # print("current_id_num", current_id_num, check) # print(part_pt_tuple) tool.setPartItem(self) if check: id_num = part.getVirtualHelixAtPoint(part_pt_tuple) # print("got a check", id_num) if id_num >= 0: # print("restart", id_num) vhi = self._virtual_helix_item_hash[id_num] tool.setVirtualHelixItem(vhi) tool.startCreation() else: # print("creating", part_pt_tuple) part.createVirtualHelix(*part_pt_tuple) id_num = part.getVirtualHelixAtPoint(part_pt_tuple) vhi = self._virtual_helix_item_hash[id_num] tool.setVirtualHelixItem(vhi) tool.startCreation()
def mousePressEvent(self, event: QGraphicsSceneMouseEvent): """Event handler for when the mouse button is pressed inside this item. If a tool-specific mouse press method is defined, it will be called for the currently active tool. Otherwise, the default :meth:`QGraphicsItem.mousePressEvent` will be called. Note: Only applies the event if the clicked item is in the part item's active filter set. Args: event: contains parameters that describe the mouse event. """ if self.FILTER_NAME not in self._part_item.getFilterSet(): return if event.button() == Qt.RightButton: return part_item = self._part_item tool = part_item._getActiveTool() tool_method_name = tool.methodPrefix() + "MousePress" if hasattr(self, tool_method_name): getattr(self, tool_method_name)(tool, part_item, event) else: QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event: QGraphicsSceneMouseEvent): """Parses a mousePressEvent. Stores _move_idx and _offset_idx for future comparison. """ self._high_drag_bound = self._model_part.getProperty( 'max_vhelix_length') - self.width() if event.modifiers() & Qt.ShiftModifier or self._moving_via_handle: self.setCursor(Qt.ClosedHandCursor) self._start_idx_low = self._idx_low self._start_idx_high = self._idx_high self._delta = 0 self._move_idx = int( floor((self.x() + event.pos().x()) / BASE_WIDTH)) self._offset_idx = int(floor(event.pos().x()) / BASE_WIDTH) else: return QGraphicsItem.mousePressEvent(self, event)
def createToolMousePress(self, tool, event, alt_event=None): """Creates individual or groups of VHs in Part on user input. Shift modifier enables multi-helix addition. Args: event (TYPE): Description alt_event (None, optional): Description """ mapped_position = self.griditem.mapFromScene(event.scenePos().x(), event.scenePos().y()) position = (mapped_position.x(), mapped_position.y()) # 1. get point in model coordinates: part = self._model_part if alt_event is None: pt = tool.eventToPosition(self, event) else: pt = alt_event.pos() if pt is None: tool.deactivate() return QGraphicsItem.mousePressEvent(self, event) part_pt_tuple = self.getModelPos(pt) modifiers = event.modifiers() is_spa_mode = modifiers == Qt.AltModifier last_added_spa_vhi_id = self._handleShortestPathMousePress(tool=tool, position=position, is_spa_mode=is_spa_mode) if last_added_spa_vhi_id is not None: return row, column = self.getLastHoveredCoordinates() parity = self._getCoordinateParity(row, column) part.createVirtualHelix(x=part_pt_tuple[0], y=part_pt_tuple[1], parity=parity) id_num = part.getVirtualHelixAtPoint(part_pt_tuple) vhi = self._virtual_helix_item_hash[id_num] tool.setVirtualHelixItem(vhi) tool.startCreation() if is_spa_mode: self._highlightSpaVH(id_num)
def mousePressEvent(self, event): if event.button() == Qt.RightButton: return parent = self.parentItem() if self.is_resizable and event.modifiers() & Qt.ShiftModifier: self.model_bounds = parent.getModelMinBounds() self.event_start_position = event.scenePos() self.item_start = self.pos() return else: parent = self.parentItem() self.is_grabbing = True self.event_start_position = event.pos() parent.setMovable(True) # ensure we handle window toggling during moves qApp.focusWindowChanged.connect(self.focusWindowChangedSlot) res = QGraphicsItem.mousePressEvent(parent, event) return res
def mousePressEvent(self, event): if event.button() == Qt.RightButton: return parent = self.parentItem() if self._group.is_resizable and event.modifiers() & Qt.ShiftModifier: self.setCursor(self._resize_cursor) self.model_bounds = parent.getModelMinBounds(handle_type=self._handle_type) self.event_start_position = event.scenePos() self.item_start = self.pos() parent.showModelMinBoundsHint(self._handle_type, show=True) event.setAccepted(True) # don't propagate return else: self.setCursor(Qt.ClosedHandCursor) parent = self.parentItem() self._group.is_dragging = True self.event_start_position = event.pos() parent.setMovable(True) # ensure we handle window toggling during moves qApp.focusWindowChanged.connect(self.focusWindowChangedSlot) res = QGraphicsItem.mousePressEvent(parent, event) event.setAccepted(True) # don't propagate return res
def selectToolMousePress(self, tool: AbstractGridToolT, event: QGraphicsSceneMouseEvent): """ Args: tool: Description event: Description """ tool.setPartItem(self) pt = tool.eventToPosition(self, event) part_pt_tuple: Vec3T = self.getModelPos(pt) part = self._model_part if part.isVirtualHelixNearPoint(part_pt_tuple): id_num = part.getVirtualHelixAtPoint(part_pt_tuple) if id_num >= 0: print(id_num) loc = part.getCoordinate(id_num, 0) print("VirtualHelix #{} at ({:.3f}, {:.3f})".format(id_num, loc[0], loc[1])) else: # tool.deselectItems() tool.modelClearSelected() else: # tool.deselectItems() tool.modelClearSelected() return QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): # self.createOrAddBasesToVirtualHelix() QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, ev): if self.mode == MODE_MOVE: # call directly QGraphicsItem to bypass QGraphicsProxyWidget return QGraphicsItem.mousePressEvent(self, ev) self.origin = ev.pos()
def mousePressEvent(self, event): QGraphicsItem.mousePressEvent(event) print('mouseMoveEvent: pos {}'.format(event.pos()))
def mousePressEvent(self, event): # select object # set item as topmost in stack self.setZValue(self.scene().items()[0].zValue() + 1) self.setSelected(True) QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): self._pos_at_mouse_press = self.pos() strip_mouse_press(self.strip, event) QGraphicsItem.mousePressEvent(self, event)
def mousePressEvent(self, event): if event.button() == Qt.LeftButton: signals.pkPosClick.emit(self.name) QGraphicsItem.mousePressEvent(self, event)