def itemChange(self, change, value): return QGraphicsPathItem.itemChange(self, change, value) # for selection changes test against QGraphicsItem.ItemSelectedChange # intercept the change instead of the has changed to enable features. if change == QGraphicsItem.ItemSelectedChange and self.scene(): active_tool = self._getActiveTool() if active_tool.methodPrefix() == "selectTool": sI = self._strand_item viewroot = sI.viewroot() current_filter_dict = viewroot.selectionFilterDict() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out if value == True and (self._filterName in current_filter_dict or not selection_group.isNormalSelect()): if sI.strandFilter() in current_filter_dict: # print "might add a xoi" if self.group() != selection_group and selection_group.isNormalSelect(): # print "adding an xoi" selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) self.setSelectedColor(True) return True else: # print "Doh" return False # end if elif value == True: # print "DOink" return False else: # Deselect # Check if the strand is being added to the selection group still if not selection_group.isPending(self._strand_item): selection_group.pendToRemove(self) self.tempReparent() self.setSelectedColor(False) return False else: # don't deselect it, because the strand is selected still return True # end else # end if elif str(active_tool) == "paint_tool": sI = self._strand_item viewroot = sI.viewroot() current_filter_dict = viewroot.selectionFilterDict() if sI.strandFilter() in current_filter_dict: if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress() return False # end if return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change, value): """Summary Args: change (TYPE): Description value (TYPE): Description Returns: TYPE: Description """ # for selection changes test against QGraphicsItem.ItemSelectedChange # intercept the change instead of the has changed to enable features. if change == QGraphicsItem.ItemSelectedChange and self.scene(): active_tool = self._getActiveTool() if active_tool.methodPrefix() == "selectTool": sI = self._strand_item viewroot = sI.viewroot() current_filter_set = viewroot.selectionFilterSet() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out if value == True and (self.FILTER_NAME in current_filter_set or not selection_group.isNormalSelect()): # noqa if sI.strandFilter() in current_filter_set: # print("might add a xoi") if self.group() != selection_group and selection_group.isNormalSelect(): # print("adding an xoi") selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) self.setSelectedColor(True) return True else: # print("Doh") return False # end if elif value == True: # noqa # print("DOink") return False else: # Deselect # Check if the strand is being added to the selection group still if not selection_group.isPending(self._strand_item): selection_group.pendToRemove(self) self.tempReparent() self.setSelectedColor(False) return False else: # don't deselect it, because the strand is selected still return True # end else # end if elif str(active_tool) == "paint_tool": sI = self._strand_item viewroot = sI.viewroot() current_filter_set = viewroot.selectionFilterSet() if sI.strandFilter() in current_filter_set: if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress() return False # end if return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange and self.scene(): # If the position changes then do so with an redo/undo command command = CommandMoveItem(self, value) # Push the command onto the stack. self.scene().undoStack.push(command) # Exec the parent class change command. return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change, value): # for selection changes test against QGraphicsItem.ItemSelectedChange # intercept the change instead of the has changed to enable features. if change == QGraphicsItem.ItemSelectedChange and self.scene(): active_tool = self._getActiveTool() if str(active_tool) == "select_tool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out if value == True and self.FILTER_NAME in current_filter_set: # if (self.group() != selection_group and # s_i.strandFilter() in current_filter_set): if s_i.strandFilter() in current_filter_set: if self.group( ) != selection_group or not self.isSelected(): # print("select ep") selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) self.setSelectedColor(True) # print("select2 ep") return True else: return False # end if elif value == True: # don't select return False else: # Deselect # print("deselect ep") # Check if strand is being added to the selection group still if not selection_group.isPending(self._strand_item): selection_group.pendToRemove(self) self.tempReparent() self.setSelectedColor(False) return False else: # don't deselect, because the strand is still selected return True # end else # end if elif str(active_tool) == "paint_tool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() if s_i.strandFilter() in current_filter_set: if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress(None, None, None) # end elif return False # end if return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change, value): # for selection changes test against QGraphicsItem.ItemSelectedChange # intercept the change instead of the has changed to enable features. if change == QGraphicsItem.ItemSelectedChange and self.scene(): active_tool = self._getActiveTool() if str(active_tool) == "select_tool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out if value == True and self.FILTER_NAME in current_filter_set: # if (self.group() != selection_group and # s_i.strandFilter() in current_filter_set): if s_i.strandFilter() in current_filter_set: if self.group() != selection_group or not self.isSelected(): # print("select ep") selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) self.setSelectedColor(True) # print("select2 ep") return True else: return False # end if elif value == True: # don't select return False else: # Deselect # print("deselect ep") # Check if strand is being added to the selection group still if not selection_group.isPending(self._strand_item): selection_group.pendToRemove(self) self.tempReparent() self.setSelectedColor(False) return False else: # don't deselect, because the strand is still selected return True # end else # end if elif str(active_tool) == "paint_tool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() if s_i.strandFilter() in current_filter_set: if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress(None, None, None) # end elif return False # end if return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change, value): """Overload QGraphicsPathItem method.""" if (change == QGraphicsItem.ItemSelectedChange): # usually setSelected should not be called here, but # setSelected has been overriden and does not call the base method self.setSelected(value) # return False to avoid the deselection of the pointhandle # (multiple selection seems impossible without holding ctrl) return False # forward event return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change, value): """Overload QGraphicsPathItem.""" # noqa see file:///usr/share/doc/packages/python-qt4-devel/doc/html/qgraphicsitem.html#itemChange # they add && scene() to the condition. To check # the example shows also how to keep the item in the scene area if change == QGraphicsItem.ItemSelectedChange: # reset, since not in a move self.position_before_move = None elif change == QGraphicsItem.ItemPositionChange: #print "pos changed to: ", value new_pos = value old_pos = self.pos() if self.position_before_move is None: # beginning move => keep the original position self.position_before_move = old_pos # total displacement since the beginning of the move total_dx = new_pos.x() - self.position_before_move.x() total_dy = new_pos.y() - self.position_before_move.y() if self.scene().move_restrictions_on: if abs(total_dx) >= abs(total_dy): # move along x only new_pos.setY(self.position_before_move.y()) else: # move along y only new_pos.setX(self.position_before_move.x()) # displacement for this elementary move current_dx = new_pos.x() - old_pos.x() current_dy = new_pos.y() - old_pos.y() #print "dx = ", current_dx, "dy = ", current_dy, self # move # the Qt item will be translated by Qt, based on "value" # the listener will move the element elements.regions.Polycurve.translate(self.e, dx=current_dx, dy=current_dy) self.scene().move_id += 1 value = old_pos + QPointF(current_dx, current_dy) elif change == QGraphicsItem.ItemSceneChange: old_scene = self.scene() new_scene = value if old_scene: old_scene.signal_set_all_selected.disconnect(self.setSelected) old_scene.signal_reset_move.disconnect(self.reset_move) if new_scene: new_scene.signal_set_all_selected.connect(self.setSelected) new_scene.signal_reset_move.connect(self.reset_move) # forward event return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change: QGraphicsItem.GraphicsItemChange, value: Any) -> bool: """Used for selection of the :class:`XoverItem` Args: change: parameter that is changing value : new value whose type depends on the ``change`` argument Returns: If the change is a ``QGraphicsItem.ItemSelectedChange``:: ``True`` if selected, other ``False`` Otherwise default to :meth:`QGraphicsPathItem.itemChange()` result """ # for selection changes test against QGraphicsItem.ItemSelectedChange # intercept the change instead of the has changed to enable features. if change == QGraphicsItem.ItemSelectedChange and self.scene(): active_tool = self._getActiveTool() if active_tool.methodPrefix() == "selectTool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out if value == True and ( self.FILTER_NAME in current_filter_set or not selection_group.isNormalSelect()): # noqa if all(f in current_filter_set for f in s_i.strandFilter()): # print("might add a xoi") if self.group( ) != selection_group and selection_group.isNormalSelect( ): # print("adding an xoi") selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) self.setSelectedColor(True) return True else: # print("Doh") return False # end if elif value == True: # noqa # print("Doink") return False else: # Deselect # Check if the strand is being added to the selection group still if not selection_group.isPending(self._strand_item): selection_group.pendToRemove(self) self.tempReparent() self.setSelectedColor(False) return False else: # don't deselect it, because the strand is selected still return True # end else # end if elif str(active_tool) == "paint_tool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() if all(f in current_filter_set for f in s_i.strandFilter()): if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress() return False # end if return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange and self.scene(): command = CommandMoveItem(self, value) self.scene().undoStack.push(command) return QGraphicsPathItem.itemChange(self, change, value)
def itemChange(self, change: QGraphicsItem.GraphicsItemChange, value: Any) -> bool: """Used for selection of the :class:`EndpointItem` Args: change: parameter that is changing value : new value whose type depends on the ``change`` argument Returns: If the change is a ``QGraphicsItem.ItemSelectedChange``:: ``True`` if selected, other ``False`` Otherwise default to :meth:`QGraphicsPathItem.itemChange()` result """ # for selection changes test against QGraphicsItem.ItemSelectedChange # intercept the change instead of the has changed to enable features. if change == QGraphicsItem.ItemSelectedChange and self.scene(): active_tool = self._getActiveTool() if str(active_tool) == "select_tool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out if value == True and self.FILTER_NAME in current_filter_set: if all(f in current_filter_set for f in s_i.strandFilter()): if self.group() != selection_group or not self.isSelected(): selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) self.setSelectedColor(True) return True else: return False # end if elif value == True: # don't select return False else: # Deselect # print("deselect ep") # Check if strand is being added to the selection group still if not selection_group.isPending(self._strand_item): selection_group.pendToRemove(self) self.tempReparent() self.setSelectedColor(False) return False else: # don't deselect, because the strand is still selected return True # end else # end if elif str(active_tool) == "paint_tool": s_i = self._strand_item viewroot = s_i.viewroot() current_filter_set = viewroot.selectionFilterSet() if all(f in current_filter_set for f in s_i.strandFilter()): if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress(None, None, None) # end elif return False # end if return QGraphicsPathItem.itemChange(self, change, value)