const TXshCell &TXsheet::getCell(int row, int col) const { static const TXshCell emptyCell; TXshColumnP column = m_imp->m_columnSet.getColumn(col); if (!column) return emptyCell; TXshCellColumn *xshColumn = column->getCellColumn(); if (!xshColumn) return emptyCell; return xshColumn->getCell(row); }
int TXsheet::getCellRange(int col, int &r0, int &r1) const { r0 = 0; r1 = -1; TXshColumnP column = m_imp->m_columnSet.getColumn(col); if (!column) return 0; TXshCellColumn *cellColumn = column->getCellColumn(); if (!cellColumn) return 0; return cellColumn->getRange(r0, r1); }
void TXsheet::updateFrameCount() { m_imp->m_frameCount = 0; for (int i = 0; i < m_imp->m_columnSet.getColumnCount(); ++i) { TXshColumnP cc = m_imp->m_columnSet.getColumn(i); if (cc && !cc->isEmpty()) m_imp->m_frameCount = std::max(m_imp->m_frameCount, cc->getMaxFrame() + 1); } }
void TXsheet::insertCells(int row, int col, int rowCount) { TXshColumnP column = m_imp->m_columnSet.getColumn(col); if (!column || column->isLocked()) return; TXshCellColumn *xshColumn = column->getCellColumn(); if (!xshColumn) return; xshColumn->insertEmptyCells(row, rowCount); // aggiorno il frame count int fc = xshColumn->getMaxFrame() + 1; if (fc > m_imp->m_frameCount) m_imp->m_frameCount = fc; }
void StageBuilder::addFrame(PlayerSet &players, ToonzScene *scene, TXsheet *xsh, int row, int level, bool includeUnvisible, bool checkPreviewVisibility) { int columnCount = xsh->getColumnCount(); unsigned int maskCount = m_masks.size(); std::vector<std::pair<double, int>> shuffle; for (int c = 0; c < columnCount; c++) { TXshColumnP column = xsh->getColumn(c); assert(column); TStageObject *pegbar = xsh->getStageObject(TStageObjectId::ColumnId(c)); double columnSO = pegbar->getSO(row); shuffle.push_back(std::make_pair(columnSO, c)); } std::stable_sort(shuffle.begin(), shuffle.end(), StackingOrder()); for (int i = 0; i < columnCount; i++) { int c = shuffle[i].second; if (CameraTestCheck::instance()->isEnabled() && c != m_currentColumnIndex) continue; if (level == 0) { // m_isCurrentColumn = (c == m_currentColumnIndex); m_ancestorColumnIndex = c; } TXshColumn *column = xsh->getColumn(c); bool isMask = false; if (column && !column->isEmpty()) { if (!column->isPreviewVisible() && checkPreviewVisibility) continue; if (column->isCamstandVisible() || includeUnvisible) // se l'"occhietto" non e' chiuso { if (column->isMask()) // se e' una maschera (usate solo in tab pro) { isMask = true; std::vector<int> saveMasks; saveMasks.swap(m_masks); int maskIndex = m_maskPool.size(); PlayerSet *mask = new PlayerSet(); m_maskPool.push_back(mask); addCellWithOnionSkin(*mask, scene, xsh, row, c, level); std::stable_sort(mask->begin(), mask->end(), PlayerLt()); saveMasks.swap(m_masks); m_masks.push_back(maskIndex); } else addCellWithOnionSkin(players, scene, xsh, row, c, level); } } if (!isMask) { while (m_masks.size() > maskCount) m_masks.pop_back(); } } if (level == 0) std::stable_sort(players.begin(), players.end(), PlayerLt()); }
void TXsheet::removeCells(int row, int col, int rowCount) { TXshColumnP column = m_imp->m_columnSet.getColumn(col); if (!column || column->isLocked()) return; TXshCellColumn *xshCellColumn = column->getCellColumn(); if (!xshCellColumn) return; int oldColRowCount = xshCellColumn->getMaxFrame() + 1; xshCellColumn->removeCells(row, rowCount); // aggiornamento framecount if (oldColRowCount == m_imp->m_frameCount) updateFrameCount(); TNotifier::instance()->notify(TXsheetChange()); }
void TXsheet::getCells(int row, int col, int rowCount, TXshCell cells[]) const { static const TXshCell emptyCell; int i; TXshColumnP column = m_imp->m_columnSet.getColumn(col); if (!column) { for (i = 0; i < rowCount; i++) cells[i] = emptyCell; return; } TXshCellColumn *xshColumn = column->getCellColumn(); if (!xshColumn) { for (i = 0; i < rowCount; i++) cells[i] = emptyCell; return; } xshColumn->getCells(row, rowCount, cells); }
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); } } } } } } }
TStageObjectId TColumnDataElement::restoreColumn(TXsheet *xsh, int index, int fxFlags, bool copyPosition) const { bool doClone = (fxFlags & eDoClone); bool resetFxDagPositions = (fxFlags & eResetFxDagPositions); TXshColumn *column = m_column.getPointer(); // The xsheet 'changes' if a new column is inserted. If it was already there, no. bool xsheetChange = false; if (column && column->getXsheet() && column->getXsheet() != xsh) xsheetChange = true; // Insert a column at the specified index. If a column was stored, insert that one. TPointD dagPos = TConst::nowhere; if (column) { if (column->getFx()) dagPos = column->getFx()->getAttributes()->getDagNodePos(); if (doClone) column = column->clone(); xsh->insertColumn(index, column); } else xsh->insertColumn(index); // Create a new one otherwise if (!resetFxDagPositions && dagPos != TConst::nowhere) { // Don't accept the default position (fx object) TXshColumn *restoredColumn = xsh->getColumn(index); restoredColumn->getFx()->getAttributes()->setDagNodePos(dagPos); } // Retrieve the newly inserted column stage object TStageObject *obj = xsh->getStageObject(TStageObjectId::ColumnId(index)); assert(obj); obj->assignParams(m_params, doClone); // Assign the stored params if (copyPosition) obj->setDagNodePos(m_dagPos); // Clone the associated curve if any if (xsheetChange && obj->getSpline()) { TStageObjectSpline *srcSpl = obj->getSpline(); TStageObjectSpline *dstSpl = xsh->getStageObjectTree()->createSpline(); dstSpl->addRef(); dstSpl->setStroke(new TStroke(*srcSpl->getStroke())); obj->setSpline(dstSpl); } int gridType = xsh->getStageObjectTree()->getDagGridDimension(); obj->setIsOpened(gridType == 0); // gridType is 0 if the node is opened, 1 if closed // see StageSchematicScene::GridDimension // TODO: Should be made PUBLIC!! xsh->updateFrameCount(); return obj->getId(); }
(parentCol != vs->m_plasticVisualSettings.m_showOriginalColumn); } return false; } //----------------------------------------------------------------------------- static inline bool applyPlasticDeform( TXshColumn *col, const ImagePainter::VisualSettings *vs) { const PlasticVisualSettings &pvs = vs->m_plasticVisualSettings; return pvs.m_applyPlasticDeformation && (col != pvs.m_showOriginalColumn); } }; // locals TXshColumnP column = xsh->getColumn(col); assert(column); TStageObject *pegbar = xsh->getStageObject(TStageObjectId::ColumnId(col)); // Build affine placements TAffine columnAff = pegbar->getPlacement(row); double columnZ = pegbar->getZ(row); double columnNoScaleZ = pegbar->getGlobalNoScaleZ(); TXshCell cell = xsh->getCell(row, col); TXshLevel *xl = cell.m_level.getPointer(); if (!xl) return; ZPlacement cameraPlacement;
bool TXsheet::isColumnEmpty(int col) const { TXshColumnP column = m_imp->m_columnSet.getColumn(col); return column ? column->isEmpty() : true; }
int TXsheet::getMaxFrame(int col) const { TXshColumnP column = m_imp->m_columnSet.getColumn(col); if (!column) return 0; return column->getMaxFrame(); }