def retrieveImage(self, frame, frameChanged): """ Computes the node at the frame indicated if the frame has changed (if the time has changed). """ buttleData = ButtleDataSingleton().get() #Get the name of the currentNode of the viewer node = buttleData.getCurrentViewerNodeName() #Get the gloabl hashCode of the node if node is not None: hashMap = tuttle.NodeHashContainer() buttleData.getGraph().getGraphTuttle().computeGlobalHashAtTime( hashMap, frame) node_hashCode = hashMap.getHash(node, frame) #Get the map mapNodeToImage = buttleData.getMapNodeNameToComputedImage() try: self.setNodeError("") for key in mapNodeToImage.keys(): #If the image is already calculated if node_hashCode == key and frameChanged is False: #print "**************************Image already calculated**********************" return mapNodeToImage.get(node_hashCode) #If it is not #print "**************************Image is not already calculated**********************" return self.computeNode(node, frame) except Exception as e: logging.debug("Can't display node : " + node) self.setNodeError(str(e)) raise
def destructionNodes(self): """ Deletes the current node(s). """ buttleData = ButtleDataSingleton().get() # if the params of the current node deleted are display if buttleData.getCurrentParamNodeName() in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentParamNodeName(None) # if the viewer of the current node deleted is display if buttleData.getCurrentViewerNodeName() in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentViewerNodeName(None) # if the viewer display a node affected by the destruction # need something from Tuttle # if at least one node in the graph if len(buttleData.getGraphWrapper().getNodeWrappers()) > 0 and len(buttleData.getGraph().getNodes()) > 0: # if a node is selected if buttleData.getCurrentSelectedNodeNames() != []: buttleData.getGraph().deleteNodes([nodeWrapper.getNode() for nodeWrapper in buttleData.getCurrentSelectedNodeWrappers()]) buttleData.clearCurrentSelectedNodeNames() # emit signals buttleData.currentParamNodeChanged.emit() buttleData.currentViewerNodeChanged.emit() buttleData.currentSelectedNodesChanged.emit() # update undo/redo display self.undoRedoChanged()
def retrieveImage(self, frame, frameChanged): """ Computes the node at the frame indicated if the frame has changed (if the time has changed). """ buttleData = ButtleDataSingleton().get() #Get the name of the currentNode of the viewer node = buttleData.getCurrentViewerNodeName() #Get the gloabl hashCode of the node if node is not None: hashMap = tuttle.NodeHashContainer() buttleData.getGraph().getGraphTuttle().computeGlobalHashAtTime(hashMap, frame) node_hashCode = hashMap.getHash(node, frame) #Get the map mapNodeToImage = buttleData.getMapNodeNameToComputedImage() try: self.setNodeError("") for key in mapNodeToImage.keys(): #If the image is already calculated if node_hashCode == key and frameChanged is False: #print "**************************Image already calculated**********************" return mapNodeToImage.get(node_hashCode) #If it is not #print "**************************Image is not already calculated**********************" return self.computeNode(node, frame) except Exception as e: logging.debug("Can't display node : " + node) self.setNodeError(str(e)) raise
def emitNodeContentChanged(self): """ If necessary, call emitOneParamChangedSignal, to warn buttleEvent that a param just changed (to update the viewer) Also emit nodeContentChanged signal, to warn the node wrapper that a param just changed (for property si secret of other params for example !) """ from buttleofx.data import ButtleDataSingleton buttleData = ButtleDataSingleton().get() if (self._name == buttleData.getCurrentViewerNodeName()): # to buttleEvent buttleEvent = ButtleEventSingleton().get() buttleEvent.emitOneParamChangedSignal() # to the node wrapper self.nodeContentChanged()
def launchProcessGraph(self): buttleData = ButtleDataSingleton().get() #Get the name of the currentNode of the viewer node = buttleData.getCurrentViewerNodeName() # initialization of the process graph graph = buttleData.getGraph().getGraphTuttle() # timeRange between the frames of beginning and end (first frame, last frame, step) timeRange = tuttle.TimeRange(self._frame, self._nbFrames, 1) self._processOptions = tuttle.ComputeOptions(self._frame, self._nbFrames, 1) processGraph = tuttle.ProcessGraph(self._processOptions, graph, [node]) processGraph.setup() processGraph.beginSequence(timeRange) # communicate processGraph to buttleData buttleData.setProcessGraph(processGraph) buttleData.setVideoIsPlaying(True)
def cutNode(self): """ Cuts the current node(s). """ # Call the copyNode function to save the data of the selected nodes self.copyNode() buttleData = ButtleDataSingleton().get() # If we are sure that at least one node is selected if buttleData.getCurrentSelectedNodeWrappers() != []: for node in buttleData.getCurrentSelectedNodeWrappers(): # We precise that we want to cut the node and not only copy it buttleData.getCurrentCopiedNodesInfo()[node.getName()].update({"mode": ""}) # And we delete it self.destructionNodes() # And update the view if necessary if buttleData.getCurrentViewerNodeName() in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentViewerNodeName(None) if buttleData.getCurrentParamNodeName() in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentParamNodeName(None) # Emit the change for the toolbar buttleData.pastePossibilityChanged.emit()
def cutNode(self): """ Cuts the current node(s). """ # Call the copyNode function to save the data of the selected nodes self.copyNode() buttleData = ButtleDataSingleton().get() # If we are sure that at least one node is selected if buttleData.getCurrentSelectedNodeWrappers() != []: for node in buttleData.getCurrentSelectedNodeWrappers(): # We precise that we want to cut the node and not only copy it buttleData.getCurrentCopiedNodesInfo()[node.getName()].update( {"mode": ""}) # And we delete it self.destructionNodes() # And update the view if necessary if buttleData.getCurrentViewerNodeName( ) in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentViewerNodeName(None) if buttleData.getCurrentParamNodeName( ) in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentParamNodeName(None) # Emit the change for the toolbar buttleData.pastePossibilityChanged.emit()
def destructionNodes(self): """ Deletes the current node(s). """ buttleData = ButtleDataSingleton().get() # if the params of the current node deleted are display if buttleData.getCurrentParamNodeName( ) in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentParamNodeName(None) # if the viewer of the current node deleted is display if buttleData.getCurrentViewerNodeName( ) in buttleData.getCurrentSelectedNodeNames(): buttleData.setCurrentViewerNodeName(None) # if the viewer display a node affected by the destruction # need something from Tuttle # if at least one node in the graph if len(buttleData.getGraphWrapper().getNodeWrappers()) > 0 and len( buttleData.getGraph().getNodes()) > 0: # if a node is selected if buttleData.getCurrentSelectedNodeNames() != []: buttleData.getGraph().deleteNodes([ nodeWrapper.getNode() for nodeWrapper in buttleData.getCurrentSelectedNodeWrappers() ]) buttleData.clearCurrentSelectedNodeNames() # emit signals buttleData.currentParamNodeChanged.emit() buttleData.currentViewerNodeChanged.emit() buttleData.currentSelectedNodesChanged.emit() # update undo/redo display self.undoRedoChanged()