void TXsheet::getUsedLevels(set<TXshLevel *> &levels) const { set<const TXsheet *> visitedXshs; vector<const TXsheet *> todoXshs; visitedXshs.insert(this); todoXshs.push_back(this); while (!todoXshs.empty()) { const TXsheet *xsh = todoXshs.back(); todoXshs.pop_back(); int c0 = 0, c1 = xsh->getColumnCount() - 1; for (int c = c0; c <= c1; ++c) { TXshColumnP column = const_cast<TXsheet *>(xsh)->getColumn(c); if (!column) continue; TXshCellColumn *cellColumn = column->getCellColumn(); if (!cellColumn) continue; int r0, r1; if (!cellColumn->getRange(r0, r1)) continue; TXshLevel *level = 0; for (int r = r0; r <= r1; r++) { TXshCell cell = cellColumn->getCell(r); if (cell.isEmpty() || !cell.m_level) continue; if (level != cell.m_level.getPointer()) { level = cell.m_level.getPointer(); levels.insert(level); if (level->getChildLevel()) { TXsheet *childXsh = level->getChildLevel()->getXsheet(); if (visitedXshs.count(childXsh) == 0) { visitedXshs.insert(childXsh); todoXshs.push_back(childXsh); } } } } } } }
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; }
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; }