Esempio n. 1
0
void GenericProcessor::setDestNode(GenericProcessor* dn)
{


//	std::cout << "My name is " << getName() << ". Setting dest node." << std::endl;

	if (!isSink())
	{
	//	std::cout << "  I am not a sink." << std::endl;

		if (dn != 0)
		{
	//		std::cout << "  The dest node is not blank." << std::endl;

			if (!dn->isSource())
			{

		//		std::cout << "  The dest node is not a source." << std::endl;

				if (destNode != dn) 
				{
			//		std::cout << "  The dest node is new and named " << dn->getName() << std::endl;
//
					if (this->isSplitter())
						setSplitterDestNode(dn);
					else
						destNode = dn;

					dn->setSourceNode(this);

				} else {
			//		std::cout << "  The dest node is not new." << std::endl;
				}
			} else {

			//	std::cout << "  The dest node is a source." << std::endl;

				destNode = 0;
			}
		} else {
		//	std::cout << "  The dest node is blank." << std::endl;

			destNode = 0;
		}
	} else {

		//std::cout << "  I am a sink, I can't have a dest node." << std::endl;
		//if (dn != 0)
		//	dn->setSourceNode(this);
	}
}
bool TextureFilter::attachSource(TextureFilterPtr OutputSlotSrc, UInt8 OutputSlot, UInt8 InputSlot)
{
    if(!OutputSlotSrc->isSource())
    {
        SWARNING << "TextureFilter::attachSource(): Cannot attach source filter, because the filter is not a Source." << std::endl;
        return false;
    }
    if(!isSink())
    {
        SWARNING << "TextureFilter::attachSource(): Cannot attach filters to this TextureFilter, because this TextureFilter is not a Sink." << std::endl;
        return false;
    }
    if(getNumInputSlots() > 0 && InputSlot >= getNumInputSlots())
    {
        SWARNING << "TextureFilter::attachSource(): Cannot attach filters to slot " << InputSlot << ", becuase there are only " << getNumInputSlots() << " slots." << std::endl;
        return false;
    }

    if(OutputSlotSrc->getNumOutputSlots() > 0 && OutputSlot >= OutputSlotSrc->getNumOutputSlots())
    {
        SWARNING << "TextureFilter::attachSource(): Cannot attach filter from output slot " << OutputSlot << ", becuase there are only " << OutputSlotSrc->getNumOutputSlots() << " slots on that filter." << std::endl;
        return false;
    }

    if(OutputSlotSrc == NullFC)
    {
        SWARNING << "TextureFilter::attachSource(): Attempting to attach a NullFC TextureFilter." << std::endl;
        return false;
    }


    //Check for Cycles
    if(wouldMakeCyclic(OutputSlotSrc))
    {
        SWARNING << "TextureFilter::attachSource(): Failed to add source filter, because doing so would create a cycle in the filter graph." << std::endl;
        return false;
    }
    TextureFilterInputSlot* InputSlotObj(editInputSlot(InputSlot));
    TextureFilterOutputSlot* OutputSlotObj(OutputSlotSrc->editOutputSlot(OutputSlot));

    //Check if the Input slot is already attach to something else
    if(InputSlotObj->isAttached())
    {
        SWARNING << "TextureFilter::attachSource(): Failed to attach output slot " << OutputSlot << " of the given source Filter to input slot " << InputSlot << " because that slot is already attached to another TextureFilter." << std::endl;
        return false;
    }

    //Check if the Formats for the slots are compatable
    if((InputSlotObj->getTextureFormatClasses() & OutputSlotObj->getTextureFormatClasses()) == 0 )
    {
        SWARNING << "TextureFilter::attachSource(): Failed to attach output slot " << OutputSlot << " of the given source Filter to input slot " << InputSlot << " because the data format of those two slots are not compatable." << std::endl;
        return false;
    }

    //Check if the Data types for the slots are compatable


    //Attach this given filter to the InputSlot
    InputSlotObj->setSourceFilter(OutputSlotSrc);
    InputSlotObj->setSourceFilterOutputSlot(OutputSlot);

    //Attach this Filter to the Output Slot of the given Filter
    OutputSlotSrc->attachOutputSlot(TextureFilterPtr(this), InputSlot);

    //Flag this filter as dirty
    setDirty(true);
    return true;

}