void undo() const { FxDag *fxDag = TApp::instance()->getCurrentXsheet()->getXsheet()->getFxDag(); int i, j; for (i = 0; i < (int)m_fxs.size(); i++) { TApp::instance()->getCurrentFx()->setFx(m_fxs[i].m_fx.getPointer()); TFxCommand::addFx(m_fxs[i].m_fx.getPointer()); } for (i = 0; i < (int)m_fxs.size(); i++) { const Node &node = m_fxs[i]; TFx *fx = node.m_fx.getPointer(); if (node.m_xsheetConnected) fxDag->addToXsheet(fx); for (j = 0; j < (int)node.m_inputLinks.size(); j++) fx->getInputPort(j)->setFx(node.m_inputLinks[j].getPointer()); for (j = 0; j < (int)node.m_outputLinks.size(); j++) { TFx *outFx = node.m_outputLinks[j].second.getPointer(); outFx->getInputPort(node.m_outputLinks[j].first)->setFx(fx); } } for (i = 0; i < (int)m_inputConnectedToXsheet.size(); i++) { TFx *inputFx = m_inputConnectedToXsheet[i].getPointer(); fxDag->getTerminalFxs()->removeFx(inputFx); } TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); }
//!Build the scene fx for each node below the xsheet one. //!Remember that left xsheet ports must not be expanded. void MultimediaRenderer::Imp::scanSceneForLayers() { //Retrieve the terminal fxs (ie, fxs which are implicitly //connected to the xsheet one) TXsheet *xsh = m_scene->getXsheet(); TFxSet *fxs = xsh->getFxDag()->getTerminalFxs(); //Examine all of them and - eventually - expand left xsheet //ports (ie fx nodes who allow implicit overlaying) for (int i = 0; i < fxs->getFxCount(); ++i) { TFx *fx = fxs->getFx(i); TFxPort *leftXSheetPort; retry: if (!fx) continue; leftXSheetPort = fx->getXsheetPort(); if (!leftXSheetPort) { m_fxsToRender.addFx(fx); continue; } //If the leftXSheetPort is not connected, retry on port 0 if (leftXSheetPort->isConnected()) m_fxsToRender.addFx(fx); else { fx = fx->getInputPort(0)->getFx(); goto retry; } } }
TFx *TMacroFx::clone(bool recursive) const { int n = m_fxs.size(); vector<TFxP> clones(n); std::map<TFx *, int> table; std::map<TFx *, int>::iterator it; int i, rootIndex = -1; // nodi for (i = 0; i < n; ++i) { TFx *fx = m_fxs[i].getPointer(); assert(fx); clones[i] = fx->clone(false); assert(table.count(fx) == 0); table[fx] = i; if (fx == m_root.getPointer()) rootIndex = i; TFx *linkedFx = fx->getLinkedFx(); if (linkedFx && table.find(linkedFx) != table.end()) clones[i]->linkParams(clones[table[linkedFx]].getPointer()); } assert(rootIndex >= 0); // connessioni for (i = 0; i < n; i++) { TFx *fx = m_fxs[i].getPointer(); for (int j = 0; j < fx->getInputPortCount(); j++) { TFxPort *port = fx->getInputPort(j); TFx *inputFx = port->getFx(); if (!inputFx) continue; it = table.find(inputFx); if (it == table.end()) { // il j-esimo input di fx e' esterno alla macro if (recursive) clones[i]->connect(fx->getInputPortName(j), inputFx->clone(true)); } else { // il j-esimo input di fx e' interno alla macro clones[i]->connect(fx->getInputPortName(j), clones[it->second].getPointer()); } } } //TFx *rootClone = // const_cast<TMacroFx*>(this)-> // clone(m_root.getPointer(), recursive, visited, clones); TMacroFx *clone = TMacroFx::create(clones); clone->setName(getName()); clone->setFxId(getFxId()); //Copy the index of the passive cache manager. clone->getAttributes()->passiveCacheDataIdx() = getAttributes()->passiveCacheDataIdx(); assert(clone->getRoot() == clones[rootIndex].getPointer()); return clone; }
DeleteFxsUndo(const QList<TFx *> &fxs) { TApp *app = TApp::instance(); FxDag *fxDag = app->getCurrentXsheet()->getXsheet()->getFxDag(); for (int i = 0; i < (int)fxs.size(); i++) { TFx *fx = fxs[i]; TZeraryColumnFx *zfx = dynamic_cast<TZeraryColumnFx *>(fx); if (zfx) fx = zfx->getZeraryFx(); Node node; node.m_fx = fx; node.m_xsheetConnected = fxDag->getTerminalFxs()->containsFx(fx); int j; for (j = 0; j < fx->getInputPortCount(); j++) { TFxP inputFx(fx->getInputPort(j)->getFx()); int i; if (inputFx && !fxDag->getTerminalFxs()->containsFx(inputFx.getPointer())) { for (i = 0; i < (int)m_inputConnectedToXsheet.size(); i++) if (m_inputConnectedToXsheet[i].getPointer() == inputFx.getPointer()) break; if (i == (int)m_inputConnectedToXsheet.size()) m_inputConnectedToXsheet.push_back(inputFx); } node.m_inputLinks.push_back(inputFx); } for (j = 0; j < fx->getOutputConnectionCount(); j++) { TFxPort *port = fx->getOutputConnection(j); TFx *outFx = port->getOwnerFx(); if (outFx) { int k; for (k = 0; k < outFx->getInputPortCount(); k++) if (outFx->getInputPort(k)->getFx() == fx) break; if (k < outFx->getInputPortCount()) node.m_outputLinks.push_back(std::make_pair(k, TFxP(outFx))); } } m_fxs.push_back(node); } }
TColumnFx *MultimediaRenderer::Imp::searchColumn(TFxP fx) { //Descend ports 0 until a TColumnFx is found. Then, output its number. TFx *currFx = fx.getPointer(); TColumnFx *colFx = dynamic_cast<TColumnFx *>(currFx); while (!colFx) { if (fx->getInputPortCount() <= 0) break; currFx = currFx->getInputPort(0)->getFx(); if (!currFx) break; colFx = dynamic_cast<TColumnFx *>(currFx); } return colFx; }
Link FxSelection::getBoundingFxs(SchematicPort *inputPort, SchematicPort *outputPort) { Link boundingFxs; FxSchematicNode *inputNode = dynamic_cast<FxSchematicNode *>(outputPort->getNode()); FxSchematicNode *outputNode = dynamic_cast<FxSchematicNode *>(inputPort->getNode()); FxGroupNode *groupNode = dynamic_cast<FxGroupNode *>(inputNode); if (!inputNode || !outputNode || (groupNode && groupNode->getOutputConnectionsCount() != 1)) return boundingFxs; if (dynamic_cast<TXsheetFx *>(outputNode->getFx())) { if (!groupNode) boundingFxs.m_inputFx = inputNode->getFx(); else { TFxSet *terminals = m_xshHandle->getXsheet()->getFxDag()->getTerminalFxs(); QList<TFxP> roots = groupNode->getRootFxs(); int i; for (i = 0; i < roots.size(); i++) if (terminals->containsFx(roots[i].getPointer())) { boundingFxs.m_inputFx = roots[i]; break; } } boundingFxs.m_outputFx = outputNode->getFx(); return boundingFxs; } if (outputNode->isA(eGroupedFx)) { // devo prima trovare l'effetto interno al gruppo al quale inputNode e' // linkato. FxGroupNode *groupNode = dynamic_cast<FxGroupNode *>(outputNode); assert(groupNode); QList<TFx *> fxs; TFx *inputFx = inputNode->getFx(); int i; for (i = 0; i < inputFx->getOutputConnectionCount(); i++) { TFx *outputFx = inputFx->getOutputConnection(i)->getOwnerFx(); if (!outputFx) continue; if (groupNode->contains(outputFx)) fxs.push_back(outputFx); } if (fxs.size() != 1) // un nodo esterno al gruppo puo' essere linkato a // piu' nodi interni al gruppo return boundingFxs; TFx *outputFx = fxs[0]; // ho tovato l'effetto, ora devo trovare l'indice della porta a cui e' // linkato l'effetto in input for (i = 0; i < outputFx->getInputPortCount(); i++) { TFxPort *inputPort = outputFx->getInputPort(i); TFx *fx = inputPort->getFx(); if (fx == inputFx) break; } if (i >= outputFx->getInputPortCount()) return boundingFxs; boundingFxs.m_inputFx = inputFx; boundingFxs.m_outputFx = outputFx; boundingFxs.m_index = i; return boundingFxs; } else { bool found = false; int i, index = -1; for (i = 0; i < outputNode->getInputPortCount() && !found; i++) { FxSchematicPort *inputAppPort = outputNode->getInputPort(i); int j; for (j = 0; j < inputAppPort->getLinkCount(); j++) { FxSchematicNode *outputAppNode = dynamic_cast<FxSchematicNode *>(inputAppPort->getLinkedNode(j)); if (!outputAppNode) continue; FxSchematicPort *outputAppPort = outputAppNode->getOutputPort(); if (inputAppPort == inputPort && outputPort == outputAppPort) { found = true; index = i; break; } } } if (index == -1) return boundingFxs; TFx *inputFx = inputNode->getFx(); TFx *outputFx = outputNode->getFx(); boundingFxs.m_inputFx = inputFx; boundingFxs.m_outputFx = outputFx; boundingFxs.m_index = index; return boundingFxs; } }