def mousePressEvent(self, event): # self.show() if event.button() != Qt.LeftButton: return QGraphicsItemGroup.mousePressEvent(self, event) else: self._drag_enable = True # required to get the itemChanged event to work # correctly for this self.setSelected(True) # self.selectionbox.resetTransform() self.selectionbox.resetPosition() self.selectionbox.refreshPath() # self.selectionbox.resetTransform() self.selectionbox.resetPosition() self.selectionbox.show() # for some reason we need to skip the first mouseMoveEvent self._dragged = False if self._added_to_press_list == False: self._added_to_press_list = True self.scene().views()[0].addToPressList(self) return QGraphicsItemGroup.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. Returns: TYPE: Description """ # self.show() if event.button() != Qt.LeftButton: return QGraphicsItemGroup.mousePressEvent(self, event) else: self._drag_enable = True # required to get the itemChanged event to work # correctly for this self.setSelected(True) # self.selectionbox.resetTransform() self.selectionbox.resetPosition() self.selectionbox.refreshPath() # self.selectionbox.resetTransform() self.selectionbox.resetPosition() self.selectionbox.show() # for some reason we need to skip the first mouseMoveEvent self._dragged = False if self._added_to_press_list is False: self._added_to_press_list = True self.scene().views()[0].addToPressList(self) return QGraphicsItemGroup.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. Returns: TYPE: Description """ tool = self.tool if event.button() != Qt.LeftButton: """ do context menu? """ # slice_graphics_view = self.tool.slice_graphics_view # print(slice_graphics_view) # self.getCustomContextMenu(event.screenPos()) tool.individual_pick = False return QGraphicsItemGroup.mousePressEvent(self, event) else: # print("the right event") modifiers = event.modifiers() is_shift = modifiers == Qt.ShiftModifier print("Is_shift is %s" % is_shift) # check to see if we are clicking on a previously selected item if tool.is_selection_active: # print("clicking the box") pos = event.scenePos() for item in tool.sgv.scene().items(pos): if isinstance(item, GridVirtualHelixItem): doc = tool.manager.document part = item.part() if is_shift: id_num = item.idNum() if doc.isVirtualHelixSelected( part, id_num): # maybe should ask the model? doc.removeVirtualHelicesFromSelection( part, [id_num]) else: origin_id_num = item.idNum() is_alt = modifiers == Qt.AltModifier if (doc.isVirtualHelixSelected( part, origin_id_num) and not is_alt): print("origin", origin_id_num) if tool.snap_origin_item is not None: tool.snap_origin_item.setSnapOrigin(False) tool.snap_origin_item = item item.setSnapOrigin(True) break else: item.mousePressEvent(event) self.drag_start_position = sp = self.pos() self.drag_last_position = sp return QGraphicsItemGroup.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. Returns: TYPE: Description """ tool = self.tool if event.button() != Qt.LeftButton: """ do context menu? """ # sgv = self.tool.sgv # print(sgv) # self.getCustomContextMenu(event.screenPos()) tool.individual_pick = False return QGraphicsItemGroup.mousePressEvent(self, event) else: # print("the right event") modifiers = event.modifiers() is_shift = modifiers == Qt.ShiftModifier # check to see if we are clicking on a previously selected item if tool.is_selection_active: # print("clicking the box") pos = event.scenePos() for item in tool.sgv.scene().items(pos): if isinstance(item, SliceVirtualHelixItem): doc = tool.manager.document part = item.part() if is_shift: id_num = item.idNum() if doc.isVirtualHelixSelected(part, id_num): # maybe should ask the model? doc.removeVirtualHelicesFromSelection(part, [id_num]) else: origin_id_num = item.idNum() is_alt = modifiers == Qt.AltModifier if ( doc.isVirtualHelixSelected(part, origin_id_num) and not is_alt): print("origin", origin_id_num) if tool.snap_origin_item is not None: tool.snap_origin_item.setSnapOrigin(False) tool.snap_origin_item = item item.setSnapOrigin(True) break else: item.mousePressEvent(event) self.drag_start_position = sp = self.pos() self.drag_last_position = sp return QGraphicsItemGroup.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. """ return QGraphicsItemGroup.mousePressEvent(self, event)