def mouseMoveEvent(self, event): ''' GxBlock.mouseMoveEvent(QGraphicsSceneMouseEvent) -> NoneType ''' GxBlock.mouseMoveEvent(self, event) if not self.mouse_active: return self._checkNotchCollisions()
def mouseReleaseEvent(self, event): ''' GxBlock.mouseReleaseEvent(QGraphicsSceneMouseEvent) -> NoneType ''' GxBlock.mouseReleaseEvent(self, event) if not self.mouse_active or not self.scene(): return if event.button() == Qt.LeftButton: self._checkNotchCollisions() if self.io_male_colliding and not self.parent_io: self.plugIo(self.io_male_colliding.parentItem()) self._endInsertionEffect('io', 'M') if self.vf_female_colliding and not self.parent_vf: self.plugVfFemale(self.vf_female_colliding.parentItem()) self._endInsertionEffect('vf', 'F') # if self.vf_male_colliding: # self.plugVfMale(self.vf_male_colliding.parentItem()) # self._endInsertionEffect('vf', 'M') if not self.io_male_start: self.setFlag(QGraphicsItem.ItemIsSelectable, True) if self.snippet_id: self.getTopParentVf().updateMySnippetPos()
def __init__(self, scene, parent=None): ''' (GxSceneBlocks) ''' GxBlock.__init__(self, scene, parent) self.mouse_active = True for x in self.NOTCHES: setattr(self, x + '_start', None) setattr(self, x + '_colli_path', None) self.io_male_insertion_marker = None self.io_male_colliding = None self.vf_male_insertion_marker = None self.vf_male_colliding = None self.vf_female_insertion_marker = None self.vf_female_colliding = None self.parent_io = None self.parent_vf = None self.child_io = None self.child_vf = None self.bottom_child_vf = None self._element = None self.snippet_id = None self.sketch = None
def mousePressEvent(self, event): ''' GxBlock.mousePressEvent(QGraphicsSceneMouseEvent) -> NoneType ''' if self.mouse_active and not self.isSelected(): self.setFlag(QGraphicsItem.ItemIsSelectable, False) self.scene().clearSelection() GxBlock.mousePressEvent(self, event) if not self.mouse_active: return if event.button() == Qt.LeftButton: self.unplugIo() if not self.isSelected(): self.unplugVf() else: parent = self.parent_vf if parent and not parent.isSelected(): self.unplugVf() last_sel_child = self.getFirstNonSelectedBottomChildVf() if last_sel_child and not last_sel_child.isSelected(): last_sel_child.unplugVf() if parent: last_sel_child.plugVfFemale(parent) self._checkNotchCollisions() if self.io_male_start: self._checkNotchCollisions()
def removeFromScene(self): ''' GxBlock.removeFromScene() -> NoneType Before removing itself, take cares of its childs by calling removeFromScene() on them too. Eventually, one of those childs will gonna be GxColliPath objects, which MUST be assured to be deleted from the scene by calling its removeFromScene() method. ''' if self.snippet_id: self.sketch.removeSnippet(self.snippet_id) self._cleanInsertionMarkers() GxBlock.removeFromScene(self)