コード例 #1
0
ファイル: WorkArea.py プロジェクト: theomission/meShaderEd
 def addGfxNode(self, node, pos=None):
     #
     #print ( ">> WorkArea: addGfxNode %s" % node.label )
     if node.type == 'connector':
         gfxNode = GfxNodeConnector(node.inputParams[0], node=node)
     elif node.type == 'note':
         gfxNode = GfxNote(node)
     elif node.type == 'swatch':
         gfxNode = GfxSwatchNode(node)
     else:
         gfxNode = GfxNode(node)
     scene = self.scene()
     if pos != None: gfxNode.moveBy(pos.x(), pos.y())
     #for item in scene.selectedItems (): item.setSelected ( False )
     scene.addItem(gfxNode)
     gfxNode.setSelected(True)
     if usePyQt4:
         self.emit(QtCore.SIGNAL('gfxNodeAdded'), gfxNode)
     else:
         self.gfxNodeAdded.emit(gfxNode)
コード例 #2
0
ファイル: WorkArea.py プロジェクト: theomission/meShaderEd
	def addGfxNode ( self, node, pos = None ) :
		#
		#print ( ">> WorkArea: addGfxNode %s" % node.label )
		if node.type == 'connector' :
			gfxNode = GfxNodeConnector ( node.inputParams [ 0 ], node = node )
		elif node.type == 'note' :
			gfxNode = GfxNote ( node )
		elif node.type == 'swatch' :
			gfxNode = GfxSwatchNode ( node )
		else :
			gfxNode = GfxNode ( node )
		scene = self.scene ()
		if pos != None : gfxNode.moveBy ( pos.x(), pos.y() )
		#for item in scene.selectedItems (): item.setSelected ( False )
		scene.addItem ( gfxNode )
		gfxNode.setSelected ( True )
		if usePyQt4 :
			self.emit ( QtCore.SIGNAL ( 'gfxNodeAdded' ), gfxNode )
		else :
			self.gfxNodeAdded.emit ( gfxNode )
コード例 #3
0
ファイル: WorkArea.py プロジェクト: theomission/meShaderEd
    def onStartNodeConnector(self, connector, scenePos):
        #
        if DEBUG_MODE: print '>> WorkArea::onStartNodeConnector'
        self.state = 'traceNodeConnector'

        newNode = ConnectorNode()
        self.nodeNet.addNode(newNode)

        newParam = connector.param.copy()
        newParam.isInput = False
        newInParam = newParam.copy()
        newOutParam = newParam.copy()

        newNode.addInputParam(newInParam)
        newNode.addOutputParam(newOutParam)

        newConnector = GfxNodeConnector(newParam,
                                        connector.radius,
                                        node=newNode)
        newConnector.brush = connector.brush
        newConnector.setPos(scenePos)
        newConnector.moveBy(-connector.radius, -connector.radius)

        self.lastConnectCandidate = newConnector
        self.scene().addItem(newConnector)
        newConnector.hilite(True)

        srcNode = connector.getNode()
        srcParam = connector.getOutputParam()
        dstNode = newConnector.getNode()
        dstParam = newConnector.getInputParam()

        #
        # swap link direction only for connectors
        # in open chain connected to input node parameter
        #
        swappedLink = False
        if connector.isConnectedToInput(
        ) and not connector.isConnectedToOutput():
            if DEBUG_MODE: print '*** swap link direction ***'
            swappedLink = True
            srcNode = newConnector.getNode()
            srcParam = newConnector.getOutputParam()
            dstNode = connector.getNode()
            dstParam = connector.getInputParam()

        link = NodeLink.build(srcNode, dstNode, srcParam, dstParam)
        # if swappedLink : link.swapNodes ()
        self.nodeNet.addLink(link)

        #if DEBUG_MODE : self.nodeNet.printInfo ()

        # preserve existing links for parameter connectors
        if connector.isLinked() and not connector.isNode():
            if connector.isInput():
                #print '*** preserve input ***'
                # TODO!!!
                # This is very rough code -- needs to be wrapped in functions
                gfxLinks = connector.getInputGfxLinks()

                for gfxLink in gfxLinks:
                    gfxLink.setDstConnector(newConnector)

                    # remove gfxLink from previouse connector
                    connector.removeGfxLink(gfxLink)

                    # adjust destination for node link
                    newConnector.getNode().attachInputParamToLink(
                        newConnector.getInputParam(), gfxLink.link)
                    newConnector.getNode().addChild(gfxLink.link.srcNode)
                    connector.getNode().removeChild(gfxLink.link.srcNode)

                    gfxLink.link.dstNode = newConnector.getNode()
                    gfxLink.link.dstParam = newConnector.getInputParam()
            else:
                #print '*** preserve output ***'
                gfxLinks = connector.getOutputGfxLinks()

                for gfxLink in gfxLinks:
                    gfxLink.setSrcConnector(newConnector)

                    # remove gfxLink from previouse connector
                    connector.removeGfxLink(gfxLink)

                    # adjust source for node link
                    connector.getNode().detachOutputParamFromLink(
                        gfxLink.link.srcParam, gfxLink.link)
                    newConnector.getNode().attachOutputParamToLink(
                        newConnector.getOutputParam(), gfxLink.link)
                    #newConnector.getNode ().childs.add ( connector.getNode () )
                    gfxLink.link.dstNode.addChild(newConnector.getNode())
                    gfxLink.link.dstNode.removeChild(connector.getNode())

                    gfxLink.link.srcNode = newConnector.getNode()
                    gfxLink.link.srcParam = newConnector.getOutputParam()

            #if DEBUG_MODE : self.nodeNet.printInfo ()

        gfxLink = GfxLink(link, connector, newConnector)
        self.scene().addItem(gfxLink)
コード例 #4
0
ファイル: WorkArea.py プロジェクト: theomission/meShaderEd
	def onStartNodeConnector ( self, connector, scenePos  ) :
		#
		if DEBUG_MODE : print '>> WorkArea::onStartNodeConnector'
		self.state = 'traceNodeConnector'

		newNode = ConnectorNode ()
		self.nodeNet.addNode ( newNode )

		newParam = connector.param.copy ()
		newParam.isInput = False
		newInParam = newParam.copy ()
		newOutParam = newParam.copy ()

		newNode.addInputParam ( newInParam )
		newNode.addOutputParam ( newOutParam )

		newConnector = GfxNodeConnector ( newParam, connector.radius, node = newNode )
		newConnector.brush = connector.brush
		newConnector.setPos ( scenePos )
		newConnector.moveBy ( -connector.radius, -connector.radius )

		self.lastConnectCandidate = newConnector
		self.scene ().addItem ( newConnector )
		newConnector.hilite ( True )

		srcNode = connector.getNode ()
		srcParam = connector.getOutputParam ()
		dstNode = newConnector.getNode ()
		dstParam = newConnector.getInputParam ()

		#
		# swap link direction only for connectors
		# in open chain connected to input node parameter
		#
		swappedLink = False
		if connector.isConnectedToInput () and not connector.isConnectedToOutput () :
			if DEBUG_MODE : print '*** swap link direction ***'
			swappedLink = True
			srcNode = newConnector.getNode ()
			srcParam = newConnector.getOutputParam ()
			dstNode = connector.getNode ()
			dstParam = connector.getInputParam ()

		link = NodeLink.build ( srcNode, dstNode, srcParam, dstParam )
		# if swappedLink : link.swapNodes ()
		self.nodeNet.addLink ( link )

		#if DEBUG_MODE : self.nodeNet.printInfo ()

		# preserve existing links for parameter connectors
		if connector.isLinked () and not connector.isNode () :
			if connector.isInput () :
				#print '*** preserve input ***'
				# TODO!!!
				# This is very rough code -- needs to be wrapped in functions
				gfxLinks = connector.getInputGfxLinks ()
				
				for gfxLink in gfxLinks :
					gfxLink.setDstConnector ( newConnector )

					# remove gfxLink from previouse connector
					connector.removeGfxLink ( gfxLink )

					# adjust destination for node link
					newConnector.getNode ().attachInputParamToLink ( newConnector.getInputParam (), gfxLink.link )
					newConnector.getNode ().addChild ( gfxLink.link.srcNode )
					connector.getNode ().removeChild ( gfxLink.link.srcNode )

					gfxLink.link.dstNode = newConnector.getNode ()
					gfxLink.link.dstParam = newConnector.getInputParam ()
			else :
				#print '*** preserve output ***'
				gfxLinks = connector.getOutputGfxLinks ()
				
				for gfxLink in gfxLinks :
					gfxLink.setSrcConnector ( newConnector )

					# remove gfxLink from previouse connector
					connector.removeGfxLink ( gfxLink )

					# adjust source for node link
					connector.getNode ().detachOutputParamFromLink ( gfxLink.link.srcParam, gfxLink.link )
					newConnector.getNode ().attachOutputParamToLink ( newConnector.getOutputParam (), gfxLink.link )
					#newConnector.getNode ().childs.add ( connector.getNode () )
					gfxLink.link.dstNode.addChild ( newConnector.getNode () )
					gfxLink.link.dstNode.removeChild ( connector.getNode () )

					gfxLink.link.srcNode = newConnector.getNode ()
					gfxLink.link.srcParam = newConnector.getOutputParam ()

			#if DEBUG_MODE : self.nodeNet.printInfo ()

		gfxLink = GfxLink ( link, connector, newConnector  )
		self.scene ().addItem ( gfxLink )