예제 #1
0
void GraphComponent::updateDisplayPlugins ()
{
    DBG ("GraphComponent::updateDisplayPlugins");

    jassert (host != 0);

    cleanInternalGraph ();

    // rebuild nodes !
    for (int i = 0; i < host->getPluginsCount (); i++)
    {
        createPluginNode (host->getPluginByIndex (i));
    }

    // update audio / midi connection links !
    ProcessingGraph* audioGraph = host->getAudioGraph ();

    for (int i = 0; i < audioGraph->getNodeCount (); i++)
    {
        ProcessingNode* source = audioGraph->getNode (i);
        BasePlugin* sourceData = (BasePlugin*) source->getData ();
        GraphNodeComponent* sourceNode = findNodeByUserData (sourceData);

        if (sourceNode != 0)
        {
            for (int j = source->getLinksCount (JOST_LINKTYPE_AUDIO); --j >= 0;)
            {
                ProcessingLink* link = source->getLink (JOST_LINKTYPE_AUDIO, j);
                BasePlugin* destData = (BasePlugin*) link->destination->getData ();
                GraphNodeComponent* destNode = findNodeByUserData (destData);

                if (destNode != 0)
                {
                    sourceNode->connectToNode (link->sourcePort,
                                               destNode,
                                               link->destinationPort,
                                               false);
                }
            }
        }
    }

    for (int i = 0; i < audioGraph->getNodeCount (); i++)
    {
        ProcessingNode* source = audioGraph->getNode (i);
        BasePlugin* sourceData = (BasePlugin*) source->getData ();
        GraphNodeComponent* sourceNode = findNodeByUserData (sourceData);

        if (sourceNode != 0)
        {
            for (int j = source->getLinksCount (JOST_LINKTYPE_MIDI); --j >= 0;)
            {
                ProcessingLink* link = source->getLink (JOST_LINKTYPE_MIDI, j);
                BasePlugin* destData = (BasePlugin*) link->destination->getData ();
                GraphNodeComponent* destNode = findNodeByUserData (destData);

                if (destNode != 0)
                {
                    sourceNode->connectToNode (link->sourcePort + sourceNode->getFirstOutputOfType (JOST_LINKTYPE_MIDI),
                                               destNode,
                                               link->destinationPort + destNode->getFirstInputOfType (JOST_LINKTYPE_MIDI),
                                               false);
                }
            }
        }
    }

    // update connectors
    graphChanged ();

    // update fixed node size and position
    resized ();
}
예제 #2
0
//==============================================================================
void GraphComponent::recalculateConnectionsRecursive (GraphNodeComponent* node,
                                                      ProcessingGraph* graph,
                                                      const int insertIndex,
//                                                      const int connectorType,
                                                      const bool createConnection)
{
    BasePlugin* source = (BasePlugin*) node->getUserData ();

    if (source != 0 && ! graph->contains (source))
    {
        graph->insertNode (insertIndex, source);
        int currentIndex = insertIndex + 1;

        for (int i = 0; i < node->getOutputConnectorCount (); i++)
        {
            int sourceOutputMidiOffset = node->getFirstOutputOfType (JOST_LINKTYPE_MIDI);
            int destOutputMidiOffset = 0;

            GraphConnectorComponent* connector = node->getOutputConnector (i);
//            if (connector->getType () == connectorType)
            {
                // we are the same type, get linked connectors
                Array <GraphConnectorComponent*> linked;
                connector->getLinkedConnectors (linked);

                for (int j = 0; j < linked.size (); j++)
                {
                    GraphConnectorComponent* other = linked.getUnchecked (j);
                    GraphNodeComponent* otherNode = other->getParentGraphComponent();

                    // breath first
                    recalculateConnectionsRecursive (otherNode,
                                                     graph,
                                                     currentIndex,
//                                                     connectorType,
                                                     createConnection);

                    // create link here !
                    if (createConnection)
                    {
                        BasePlugin* destination = (BasePlugin*) otherNode->getUserData ();
                        if (destination != 0)
                        {
                            if (connector->getType () == JOST_LINKTYPE_AUDIO)
                            {
                                graph->connectTo (source,
                                                  connector->getConnectorID(),
                                                  destination,
                                                  other->getConnectorID(),
                                                  JOST_LINKTYPE_AUDIO);
                            }
                            else if (connector->getType () == JOST_LINKTYPE_MIDI)
                            {
                                destOutputMidiOffset = otherNode->getFirstInputOfType (JOST_LINKTYPE_MIDI);

                                graph->connectTo (source,
                                                  connector->getConnectorID() - sourceOutputMidiOffset,
                                                  destination,
                                                  other->getConnectorID() - destOutputMidiOffset,
                                                  JOST_LINKTYPE_MIDI);
                            }
                        }
                    }
                    // end create link !
                }
          }
        }
    }

}