def itemChange(self, change, value): return QGraphicsItem.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": viewroot = self._viewroot current_filter_dict = viewroot.selectionFilterDict() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out is_normal_select = selection_group.isNormalSelect() if value == True and (self._filter_name in current_filter_dict or not is_normal_select): if self._strand_filter in current_filter_dict: if self.group() != selection_group: self.setSelectedColor(True) # This should always be the case, but... if is_normal_select: selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) selection_group.pendToAdd(self._low_cap) selection_group.pendToAdd(self._high_cap) # this else will capture the error. Basically, the # strandItem should be member of the group before this # ever gets fired else: selection_group.addToGroup(self) return True else: return False # end if elif value == True: # Don't select return False # end elif else: # Deselect # print "Deselecting strand" selection_group.pendToRemove(self) self.setSelectedColor(False) selection_group.pendToRemove(self._low_cap) selection_group.pendToRemove(self._high_cap) return False # end else # end if elif active_tool.methodPrefix() == "paintTool": viewroot = self._viewroot current_filter_dict = viewroot.selectionFilterDict() if self._strand_filter in current_filter_dict: if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress(None, None) # end elif return False # end if return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): #pass #if change == QGraphicsItem.ItemPositionChange: #print "itemChange ---->",self.mobj # self.emit(QtCore.SIGNAL("qgtextPositionChange(PyQt_PyObject)"),self.mobj) if change == QGraphicsItem.ItemSelectedChange and value == True: self.qgtextPositionChange.emit(moose.element(self.mobj)) # self.emit(QtCore.SIGNAL("qgtextItemSelectedChange(PyQt_PyObject)"), # moose.element(self.mobj)) return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange: self.cmptEmitter.emit( QtCore.SIGNAL("qgtextPositionChange(PyQt_PyObject)"), self.mobj) if change == QGraphicsItem.ItemSelectedChange and value == True: self.qgtextPositionChange.emit(self.mobj) # self.cmptEmitter.emit( # QtCore.SIGNAL("qgtextItemSelectedChange(PyQt_PyObject)"), # self.mobj) return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemSelectedChange: self.setBrush(QColor("#1976D2") if value else self.brush_color) self.text.setDefaultTextColor( QColor("#1976D2") if value else self.brush_color) for i in range(len(self.edges)): self.edges[i].focus() if value else self.edges[i].defocus() if change == QGraphicsItem.ItemPositionHasChanged: for edge in self.edges: edge.adjust() return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): """Overload QGraphicsItem method.""" if 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 QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): """Overload QGraphicsEllipseItem.""" # 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.ItemPositionChange): 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 ((not self.ignore_move_restrictions) and 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 # move if self.relative: self.signal_moved.emit(current_dx, current_dy) self.scene().move_id += 1 value = old_pos + QPointF(current_dx, current_dy) elif change == QGraphicsItem.ItemScenePositionHasChanged: new_pos = value #print "abs: ", new_pos self.signal_moved.emit(new_pos.x(), new_pos.y()) # don't do that here, ItemSceneChange is not raised for children... #elif change == QGraphicsItem.ItemSceneChange: # print "scene change" # old_scene = self.scene() # new_scene = value # if old_scene: # old_scene.signal_reset_move.disconnect(self.reset_move) # new_scene.signal_reset_move.connect(self.reset_move) elif change == QGraphicsItem.ItemSelectedChange: self.signal_selected_change.emit(value) # forward event return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionHasChanged: for socket_row in self._socketRows.values(): socket_row.socket().updateConnectionPositions() # Move node if not self._busy: self._busy = True self.view().guiOnMoved(self) self._busy = False elif change == QGraphicsItem.ItemSelectedHasChanged: self.onSelected() return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change: QGraphicsItem.GraphicsItemChange, new_pos: Any) -> Any: if change == QGraphicsItem.ItemPositionChange and self.scene(): scene_rect = self.scene().sceneRect() # Keep the item inside the scene rect if not scene_rect.contains(new_pos): new_pos.setX(min(scene_rect.right(), max(new_pos.x(), scene_rect.left()))) new_pos.setY(min(scene_rect.bottom(), max(new_pos.y(), scene_rect.top()))) # Snap item to grid grid_snap_increment = self.scene().grid_snap_increment() x = round(new_pos.x() / grid_snap_increment) * grid_snap_increment y = round(new_pos.y() / grid_snap_increment) * grid_snap_increment return QPointF(x, y) elif change == QGraphicsItem.ItemPositionHasChanged and self.scene(): # FIXME Why is `autoRoute()` still seeing the original component positions? for wire in self._wiring_in: wire.autoRoute() for wire in self._wiring_out: wire.autoRoute() else: return QGraphicsItem.itemChange(self, change, new_pos)
def itemChange(self, change, value): """ Public method called when an items state changes. @param change the item's change (QGraphicsItem.GraphicsItemChange) @param value the value of the change @return adjusted values """ if change == QGraphicsItem.ItemPositionChange: # 1. remember to adjust associations self.shouldAdjustAssociations = True # 2. ensure the new position is inside the scene rect = self.scene().sceneRect() if not rect.contains(value): # keep the item inside the scene value.setX(min(rect.right(), max(value.x(), rect.left()))) value.setY(min(rect.bottom(), max(value.y(), rect.top()))) return value return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, variant): if change == QGraphicsItem.ItemPositionChange: return variant if change != QGraphicsItem.ItemSelectedChange: pass return QGraphicsItem.itemChange(self, change, variant)
def itemChange(self, change, value): if change == QGraphicsItem.ItemSelectedHasChanged: self.setPortSelected(value) return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change: QGraphicsItem.GraphicsItemChange, value: Any) -> bool: """Used for selection of the :class:`StrandItem` 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:`QGraphicsItem.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": viewroot = self._viewroot current_filter_set = viewroot.selectionFilterSet() selection_group = viewroot.strandItemSelectionGroup() # only add if the selection_group is not locked out is_normal_select = selection_group.isNormalSelect() if value == True and (self.FILTER_NAME in current_filter_set or not is_normal_select): if all(f in current_filter_set for f in self.strandFilter()): if self.group() != selection_group: self.setSelectedColor(True) # This should always be the case, but... if is_normal_select: selection_group.pendToAdd(self) selection_group.setSelectionLock(selection_group) selection_group.pendToAdd(self._low_cap) selection_group.pendToAdd(self._high_cap) # this else will capture the error. Basically, the # strandItem should be member of the group before this # ever gets fired else: selection_group.addToGroup(self) return True else: return False # end if elif value == True: # noqa value resolves to int from QVariant, must use == # Don't select return False # end elif else: # Deselect # print("Deselecting strand") selection_group.pendToRemove(self) self.setSelectedColor(False) selection_group.pendToRemove(self._low_cap) selection_group.pendToRemove(self._high_cap) return False # end else # end if elif active_tool.methodPrefix() == "paintTool": viewroot = self._viewroot current_filter_set = viewroot.selectionFilterSet() if all(f in current_filter_set for f in self.strandFilter()): if not active_tool.isMacrod(): active_tool.setMacrod() self.paintToolMousePress(None, None) # end elif return False # end if return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange: point = value.toPointF() pos[self.node] = [point.x(), point.y()] scene.update() return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange: self.parentItem().textBoxChanged() return QGraphicsItem.itemChange(self, change, value)
def itemChange(self, change, value): if change == QGraphicsItem.ItemPositionChange: if self.graph != None: self.graph.itemMoved() return QGraphicsItem.itemChange(self, change, value)