void getConnectedColumns(std::set<int> &connectedColumns, TXsheet *xsh, int col) { TStageObjectId id; // insert col and all column ancestors id = TStageObjectId::ColumnId(col); do { connectedColumns.insert(id.getIndex()); id = xsh->getStageObjectParent(id); } while (id.isColumn()); // for each column for (int i = 0; i < xsh->getColumnCount(); i++) { id = TStageObjectId::ColumnId(i); std::vector<TStageObjectId> stack; // find a column ancestor already connected; put all the column ancestors in stack while (id.isColumn() && connectedColumns.count(id.getIndex()) == 0) { stack.push_back(id); id = xsh->getStageObjectParent(id); } if (id.isColumn()) { // the stack is connected for (int j = 0; j < (int)stack.size(); j++) connectedColumns.insert(stack[j].getIndex()); } } }
bool canShowBone(Skeleton::Bone *bone, TXsheet *xsh, int row) { TStageObjectId id = bone->getStageObject()->getId(); if (!xsh->getCell(row, id.getIndex()).isEmpty() && xsh->getColumn(id.getIndex())->isCamstandVisible()) return true; int i; for (i = 0; i < bone->getChildCount(); i++) { if (canShowBone(bone->getChild(i), xsh, row)) return true; } return false; }
void SchematicScenePanel::onExplodeChild(QList<TStageObjectId> ids) { int i; for (i = 0; i < ids.size(); i++) { TStageObjectId id = ids[i]; if (id.isColumn()) SubsceneCmd::explode(id.getIndex()); } }
void SceneViewerContextMenu::onSetCurrent() { TStageObjectId id; id.setCode(qobject_cast<QAction *>(sender())->data().toUInt()); TApp *app = TApp::instance(); if (id.isColumn()) { app->getCurrentColumn()->setColumnIndex(id.getIndex()); app->getCurrentObject()->setObjectId(id); } else { app->getCurrentObject()->setObjectId(id); app->getCurrentTool()->setTool(T_Edit); } }
TStageObject *ViewerKeyframeNavigator::getStageObject() const { if (!m_xsheetHandle || !m_objectHandle) return 0; TStageObjectId objectId = m_objectHandle->getObjectId(); TXsheet *xsh = m_xsheetHandle->getXsheet(); // Se e' una colonna sound non posso settare chiavi if (objectId.isColumn()) { TXshColumn *column = xsh->getColumn(objectId.getIndex()); if (column && column->getSoundColumn()) return 0; } return xsh->getStageObject(objectId); }
bool SkeletonTool::doesApply() const { TTool::Application *app = TTool::getApplication(); TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); assert(xsh); TStageObjectId objId = app->getCurrentObject()->getObjectId(); if (objId.isColumn()) { TXshColumn *column = xsh->getColumn(objId.getIndex()); if (column && column->getSoundColumn()) return false; } return true; }
void onShowHideSelectObject(QAction *action) { TApp *app = TApp::instance(); TStageObjectId id; id.setCode(action->data().toInt()); if (id == TStageObjectId::NoneId) return; if (action->text().startsWith("Show ") || action->text().startsWith("Hide ")) { if (id.isColumn()) { app->getCurrentXsheet() ->getXsheet() ->getColumn(id.getIndex()) ->setCamstandVisible(action->text().startsWith("Show ")); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); } } else if (action->text().startsWith("Select ")) { if (id.isColumn()) { app->getCurrentColumn()->setColumnIndex(id.getIndex()); app->getCurrentObject()->setObjectId(id); } else { app->getCurrentObject()->setObjectId(id); app->getCurrentTool()->setTool(T_Edit); } } }
void SchematicViewer::updateScenes() { TStageObjectId id = m_stageScene->getCurrentObject(); if (id.isColumn()) { m_stageScene->update(); TXsheet *xsh = m_stageScene->getXsheetHandle()->getXsheet(); if (!xsh) return; TXshColumn *column = xsh->getColumn(id.getIndex()); if (!column) { m_fxScene->getFxHandle()->setFx(0, false); return; } TFx *fx = column->getFx(); m_fxScene->getFxHandle()->setFx(fx, false); m_fxScene->update(); } }
void SkeletonTool::draw() { // parent object reference system //glColor3d(1,0,0); //tglDrawRect(0,0,100,100); if (m_label != "") ToolUtils::drawBalloon(m_labelPos, m_label, TPixel32::Red, TPoint(20, -20), false); bool ikEnabled = m_mode.getValue() == INVERSE_KINEMATICS; assert(glGetError() == GL_NO_ERROR); // l'xsheet, oggetto (e relativo placement), frame corrente TTool::Application *app = TTool::getApplication(); TXsheet *xsh = getXsheet(); assert(xsh); TStageObjectId objId = app->getCurrentObject()->getObjectId(); // se l'oggetto corrente non e' una colonna non disegno nulla if (!objId.isColumn()) return; TStageObject *pegbar = xsh->getStageObject(objId); int col = objId.getIndex(); int frame = app->getCurrentFrame()->getFrame(); if (m_currentFrame != frame) m_temporaryPinnedColumns.clear(); TAffine aff = getMatrix(); // puo' suggere che il placement degeneri (es.: c'e' uno h-scale = 0%) if (fabs(aff.det()) < 0.00001) return; // m_unit = getPixelSize() * sqrt(fabs(aff.det())); if (!ikEnabled) drawLevelBoundingBox(frame, col); glPushMatrix(); tglMultMatrix(aff.inv()); // camera stand reference system //glColor3d(0,1,0); //tglDrawRect(0,0,100,100); bool changingParent = dynamic_cast<ParentChangeTool *>(m_dragTool) != 0; // !changingParent && if (m_mode.getValue() == BUILD_SKELETON && !xsh->getStageObjectParent(objId).isColumn()) { if (!changingParent) drawHooks(); } Skeleton skeleton; buildSkeleton(skeleton, col); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); drawSkeleton(skeleton, frame); glDisable(GL_BLEND); TXshCell cell = xsh->getCell(frame, objId.getIndex()); Skeleton::Bone *rootBone = skeleton.getRootBone(); for (int i = 0; i < skeleton.getBoneCount(); i++) { Skeleton::Bone *bone = skeleton.getBone(i); TStageObjectId currentId = bone->getStageObject()->getId(); bool isCurrent = (currentId == objId); TPointD pos = bone->getCenter(); if (isCurrent && m_mode.getValue() != BUILD_SKELETON) { drawDrawingBrowser(cell, pos); } bool isActiveChain = bone->isSelected(); glColor3d(0, 1, 0); if (ikEnabled) { drawIKJoint(bone); } else { TPointD pos = bone->getCenter(); if (isCurrent && m_mode.getValue() == ANIMATE) { drawMainGadget(pos); } } } m_currentFrame = frame; if (m_dragTool) m_dragTool->draw(); glPopMatrix(); }
void StageObjectsData::storeObjects(const std::vector<TStageObjectId> &ids, TXsheet *xsh, int fxFlags) { assert(m_fxTable.empty()); // Should be enforced OUTSIDE. Track implicit uses. m_fxTable.clear(); // TO BE REMOVED int i, objCount = ids.size(); // Discriminate sensible stage object types (ie cameras and columns from the rest). // Store them in a map, ordered by object index. std::map<int, TStageObjectId> cameraIds, columnIds, pegbarIds; for (i = 0; i < objCount; ++i) { TStageObjectId id = ids[i]; if (id.isColumn()) columnIds[id.getIndex()] = id; else if (id.isPegbar()) pegbarIds[id.getIndex()] = id; else if (id.isCamera()) cameraIds[id.getIndex()] = id; } // Store a suitable object for each std::map<int, TStageObjectId>::iterator it; for (it = cameraIds.begin(); it != cameraIds.end(); ++it) { // Cameras TCameraDataElement *cameraElement = new TCameraDataElement(); cameraElement->storeCamera(it->second, xsh); m_elements.append(cameraElement); } for (it = pegbarIds.begin(); it != pegbarIds.end(); ++it) { // Pegbars (includes curves) TStageObjectDataElement *objElement = new TStageObjectDataElement(); objElement->storeObject(it->second, xsh); m_elements.append(objElement); } for (it = columnIds.begin(); it != columnIds.end(); ++it) { // Columns int colIndex = it->second.getIndex(); TXshColumn *column = xsh->getColumn(colIndex); if (!column) continue; TColumnDataElement *columnElement = new TColumnDataElement(); columnElement->storeColumn(xsh, colIndex, fxFlags); m_elements.append(columnElement); TXshColumn *copiedColumn = columnElement->m_column.getPointer(); if (column->getFx() && copiedColumn->getFx()) { // Store column fx pairings (even if the originals are not cloned) m_fxTable[column->getFx()] = copiedColumn->getFx(); m_originalColumnFxs.insert(column->getFx()); } } // Insert terminal fxs set<TFx *>::iterator jt; for (jt = m_originalColumnFxs.begin(); jt != m_originalColumnFxs.end(); ++jt) { if (isColumnSelectionTerminalFx( *jt, xsh->getFxDag()->getTerminalFxs(), m_originalColumnFxs)) { TFx *fx = m_fxTable[*jt]; fx->addRef(); m_terminalFxs.insert(fx); } } }
TPointD XshHandleManager::getHandlePos(const TStageObjectId &id, const std::string &handle, int row) const { static const double unit = 8.0; assert(m_xsh->getScene()); if (handle == "") return TPointD(); else if (handle[0] == 'H' && handle.length() > 1) { // Hook port case if (!id.isColumn()) return TPointD(); int hookIndex = 0; { int h, hLength = handle.length(); for (h = 1; h != hLength; ++h) hookIndex = hookIndex * 10 + (handle[h] - '0'); } TStageObject *obj = m_xsh->getStageObject(id); if (const PlasticSkeletonDeformationP &def = obj->getPlasticSkeletonDeformation()) { int skelId = def->skeletonId(row); PlasticSkeleton skel; def->storeDeformedSkeleton(skelId, row, skel); int v = def->vertexIndex(hookIndex, skelId); return (v >= 0) ? TScale(1.0 / Stage::inch) * skel.vertex(v).P() : TPointD(); } --hookIndex; int col = id.getIndex(); TXshCell cell(m_xsh->getCell(row, col)); TXshLevel *xl = cell.m_level.getPointer(); if (!xl) return TPointD(); TXshSimpleLevel *sl = xl->getSimpleLevel(); if (!sl) return TPointD(); Hook *hook = sl->getHookSet()->getHook(hookIndex); if (!hook) return TPointD(); TFrameId fid(cell.m_frameId); TPointD pos = hook->getAPos(fid) * (1.0 / Stage::inch); TPointD delta; for (int r = row - 1; r >= 0; --r) { cell = m_xsh->getCell(r, col); if (cell.m_level.getPointer() != xl) break; const TFrameId &precFid = cell.m_frameId; delta += computePassHook(fid, precFid, sl, hook); fid = precFid; } pos += delta * (1.0 / Stage::inch); pos = getDpiAffine(sl, cell.m_frameId, true) * pos; return pos; } else if ('A' <= handle[0] && handle[0] <= 'Z') return TPointD(unit * (handle[0] - 'B'), 0); else if ('a' <= handle[0] && handle[0] <= 'z') return TPointD(0.5 * unit * (handle[0] - 'b'), 0); else return TPointD(); }
void SceneViewerContextMenu::addLevelCommands(std::vector<int> &indices) { addSeparator(); TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TStageObjectId currentId = TApp::instance()->getCurrentObject()->getObjectId(); /*- Xsheet内の、空でないColumnを登録 -*/ std::vector<TXshColumn *> columns; for (int i = 0; i < (int)indices.size(); i++) { if (xsh->isColumnEmpty(indices[i])) continue; TXshColumn *column = xsh->getColumn(indices[i]); if (column) { columns.push_back(column); } } if (!columns.empty()) { // show/hide if (columns.size() > 1) { QMenu *subMenu = addMenu("Show / Hide"); for (int i = 0; i < (int)columns.size(); i++) addShowHideCommand(subMenu, columns[i]); } else addShowHideCommand(this, columns[0]); addSeparator(); } // selection /* if(selectableColumns.size()==1) { addSelectCommand(this, TStageObjectId::ColumnId(selectableColumns[0]->getIndex())); } else */ /*-- Scene内の全Objectを選択可能にする --*/ TStageObjectId id; QMenu *cameraMenu = addMenu(tr("Select Camera")); QMenu *pegbarMenu = addMenu(tr("Select Pegbar")); QMenu *columnMenu = addMenu(tr("Select Column")); bool flag = false; for (int i = 0; i < xsh->getStageObjectTree()->getStageObjectCount(); i++) { id = xsh->getStageObjectTree()->getStageObject(i)->getId(); if (id.isColumn()) { int columnIndex = id.getIndex(); if (xsh->isColumnEmpty(columnIndex)) continue; else { addSelectCommand(columnMenu, id); flag = true; } } else if (id.isTable()) addSelectCommand(this, id); else if (id.isCamera()) addSelectCommand(cameraMenu, id); else if (id.isPegbar()) addSelectCommand(pegbarMenu, id); } /*- カラムがひとつも無かったらDisable -*/ if (!flag) columnMenu->setEnabled(false); }