Exemple #1
0
bool TXsheet::setCell(int row, int col, const TXshCell &cell) {
  if (row < 0 || col < 0) return false;

  bool wasColumnEmpty = isColumnEmpty(col);
  TXshCellColumn *cellColumn;

  if (!cell.isEmpty()) {
    TXshLevel *level = cell.m_level.getPointer();
    assert(level);

    int levelType               = level->getType();
    TXshColumn::ColumnType type = TXshColumn::eLevelType;

    if (levelType == SND_XSHLEVEL)
      type = TXshColumn::eSoundType;
    else if (levelType == SND_TXT_XSHLEVEL)
      type = TXshColumn::eSoundTextType;
    else if (levelType == PLT_XSHLEVEL)
      type = TXshColumn::ePaletteType;
    else if (levelType == ZERARYFX_XSHLEVEL)
      type = TXshColumn::eZeraryFxType;
    else if (levelType == MESH_XSHLEVEL)
      type = TXshColumn::eMeshType;

    cellColumn = touchColumn(col, type)->getCellColumn();
  } else {
    TXshColumn *column = getColumn(col);
    cellColumn         = column ? column->getCellColumn() : 0;
  }

  if (!cellColumn || cellColumn->isLocked()) return false;

  cellColumn->setXsheet(this);

  if (!cellColumn->setCell(row, cell)) {
    if (wasColumnEmpty) {
      removeColumn(col);
      insertColumn(col);
    }

    return false;
  }

  TFx *fx = cellColumn->getFx();
  if (wasColumnEmpty && fx && fx->getOutputConnectionCount() == 0 &&
      cellColumn->getPaletteColumn() == 0)
    getFxDag()->addToXsheet(fx);

  if (cell.isEmpty())
    updateFrameCount();
  else if (row >= m_imp->m_frameCount)
    m_imp->m_frameCount = row + 1;

  TNotifier::instance()->notify(TXsheetChange());

  return true;
}
 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);
   }
 }
Exemple #3
0
bool TXsheet::setCells(int row, int col, int rowCount, const TXshCell cells[]) {
  static const TXshCell emptyCell;
  int i = 0;
  while (i < rowCount && cells[i].isEmpty()) i++;

  // inserito da Elisa verso novembre 2009.
  // cosi' ha il difetto che se assegno celle vuote non fa nulla
  // per ora lo commento. bisogna indagare se questo rompe qualcosa

  // ho modificato il seguito per gestire il caso in cui i>=rowCount
  // => niente livelli dentro cells

  // if(i>=rowCount)
  //  return false;

  TXshColumn::ColumnType type = TXshColumn::eLevelType;
  if (i < rowCount) {
    TXshLevel *level = cells[i].m_level.getPointer();
    int levelType    = level->getType();

    if (levelType == SND_XSHLEVEL)
      type = TXshColumn::eSoundType;
    else if (levelType == SND_TXT_XSHLEVEL)
      type = TXshColumn::eSoundTextType;
    else if (levelType == PLT_XSHLEVEL)
      type = TXshColumn::ePaletteType;
    else if (levelType == ZERARYFX_XSHLEVEL)
      type = TXshColumn::eZeraryFxType;
    else if (levelType == MESH_XSHLEVEL)
      type = TXshColumn::eMeshType;
  }
  bool wasColumnEmpty    = isColumnEmpty(col);
  TXshCellColumn *column = touchColumn(col, type)->getCellColumn();
  if (!column) return false;

  int oldColRowCount = column->getMaxFrame() + 1;
  bool ret           = column->setCells(row, rowCount, cells);
  if (!ret || column->isLocked()) {
    if (wasColumnEmpty) {
      removeColumn(col);
      insertColumn(col);
    }
    return false;
  }
  int newColRowCount = column->getMaxFrame() + 1;

  TFx *fx = column->getFx();
  if (wasColumnEmpty && fx && fx->getOutputConnectionCount() == 0)
    getFxDag()->addToXsheet(fx);
  column->setXsheet(this);

  if (newColRowCount > m_imp->m_frameCount)
    m_imp->m_frameCount = newColRowCount;
  else {
    if (oldColRowCount == m_imp->m_frameCount &&
        newColRowCount < m_imp->m_frameCount)
      updateFrameCount();
  }

  return true;
}
void StageObjectsData::storeFxs(const std::set<TFx *> &fxs, TXsheet *xsh, int fxFlags)
{
	bool doClone = (fxFlags & eDoClone);
	bool resetFxDagPositions = (fxFlags & eResetFxDagPositions);

	TFxSet *terminalFxs = xsh->getFxDag()->getTerminalFxs();

	// Traverse specified fxs
	std::set<TFx *>::const_iterator it;
	for (it = fxs.begin(); it != fxs.end(); ++it) {
		TFx *fxOrig = *it, *fx = fxOrig;

		if (doClone) {
			// If required, clone them
			fx = fxOrig->clone(false);

			fx->setName(fxOrig->getName());
			fx->getAttributes()->setId(fxOrig->getAttributes()->getId());
			fx->getAttributes()->passiveCacheDataIdx() = -1;

			if (resetFxDagPositions)
				fx->getAttributes()->setDagNodePos(TConst::nowhere);
		}

		// Store them (and the original/clone pairing even if not cloning)
		m_fxTable[fxOrig] = fx;
		fx->addRef();
		m_fxs.insert(fx);

		// Find out if the fx is a terminal one in the selection. If so, store it there too.
		bool isTerminal = true;
		if (!terminalFxs->containsFx(fxOrig)) // If it's terminal in the xsheet, no doubt
		{
			// Otherwise, check terminality with respect to the selection
			int i, outputConnectionsCount = fxOrig->getOutputConnectionCount();
			for (i = 0; i < outputConnectionsCount; ++i) {
				TFx *outputFx = fxOrig->getOutputConnection(i)->getOwnerFx();
				if (outputFx && fxs.count(outputFx) > 0) {
					isTerminal = false;
					break;
				}
			}
		}

		// Well, excluding true TOutputFxs...
		TOutputFx *outFx = dynamic_cast<TOutputFx *>(fx);
		if (isTerminal && !outFx) {
			fx->addRef();
			m_terminalFxs.insert(fx);
		}
	}

	// Updating terminality of the column fxs too!
	// WARNING: This requires that storeObjects() is invoked BEFORE this !
	for (it = m_originalColumnFxs.begin(); it != m_originalColumnFxs.end(); ++it) {
		TFx *fxOrig = *it;

		bool isTerminal = true;
		if (!terminalFxs->containsFx(fxOrig)) {
			int i, outputConnectionsCount = fxOrig->getOutputConnectionCount();
			for (i = 0; i < outputConnectionsCount; ++i) {
				TFx *outputFx = fxOrig->getOutputConnection(i)->getOwnerFx();
				if (outputFx && fxs.count(outputFx) > 0) {
					isTerminal = false;
					break;
				}
			}
		}

		if (isTerminal) {
			TFx *fx = m_fxTable[fxOrig];

			fx->addRef();
			m_terminalFxs.insert(fx);
		}
	}

	if (!m_fxTable.empty() && doClone)
		updateFxLinks(m_fxTable); // Apply original/clone pairings
								  // to fx relatives
}
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;
  }
}