bool TupCommandExecutor::insertSymbolIntoFrame(TupLibraryResponse *response) { #ifdef K_DEBUG tFatal() << "TupCommandExecutor::insertSymbolIntoFrame() - Adding symbol to project: " << response->arg().toString(); #endif if (m_project->scenesTotal() > 0) { if (m_project->insertSymbolIntoFrame(response->spaceMode(), response->arg().toString(), response->sceneIndex(), response->layerIndex(), response->frameIndex())) { TupScene *scene = m_project->scene(response->sceneIndex()); if (scene) { TupLayer *layer = scene->layer(response->layerIndex()); if (layer) { TupFrame *frame = layer->frame(response->frameIndex()); if (frame) response->setFrameState(frame->isEmpty()); } } emit responsed(response); return true; } } else { #ifdef K_DEBUG tError() << "TupCommandExecutor::insertSymbolIntoFrame() - No scenes available!"; #endif } return false; }
bool TupCommandExecutor::resetFrame(TupFrameResponse *response) { int scenePos = response->sceneIndex(); int layerPos = response->layerIndex(); int position = response->frameIndex(); TupScene *scene = m_project->scene(scenePos); if (scene) { scene->resetStoryBoardScene(position); TupLayer *layer = scene->layer(layerPos); if (layer) { TupFrame *frame = layer->frame(position); if (frame) { /* QDomDocument doc; doc.appendChild(frame->toXml(doc)); response->setArg(frame->frameName()); */ if (layer->resetFrame(position)) { //response->setState(doc.toString(0)); emit responsed(response); return true; } } } } return false; }
bool TupCommandExecutor::removeSymbolFromFrame(TupLibraryResponse *response) { #ifdef K_DEBUG T_FUNCINFO; #endif if (m_project->scenesTotal() > 0) { if (m_project->removeSymbolFromFrame(response->arg().toString(), response->symbolType())) { TupScene *scene = m_project->scene(response->sceneIndex()); if (scene) { TupLayer *layer = scene->layer(response->layerIndex()); if (layer) { TupFrame *frame = layer->frame(response->frameIndex()); if (frame) response->setFrameState(frame->isEmpty()); } } emit responsed(response); return true; } else { #ifdef K_DEBUG tError() << "TupCommandExecutor::removeSymbolFromFrame() - Error: Symbol can't be removed from project!"; #endif } } else { #ifdef K_DEBUG tError() << "TupCommandExecutor::removeSymbolFromFrame() - No scenes available!"; #endif } return false; }
bool TupCommandExecutor::setFrameVisibility(TupFrameResponse *response) { int scenePos = response->sceneIndex(); int layerPos = response->layerIndex(); int position = response->frameIndex(); bool view = response->arg().toBool(); TupScene *scene = m_project->scene(scenePos); if (!scene) return false; TupLayer *layer = scene->layer(layerPos); if (layer) { TupFrame *frame = layer->frame(position); if (! frame) return false; frame->setVisible(view); emit responsed(response); return true; } return false; }
void TupGraphicsScene::addGraphicObject(TupGraphicObject *object, double opacity) { /* #ifdef K_DEBUG T_FUNCINFO; #endif */ QGraphicsItem *item = object->item(); k->onionSkin.opacityMap.insert(item, opacity); if (TupItemGroup *group = qgraphicsitem_cast<TupItemGroup *>(item)) group->recoverChilds(); if (! qgraphicsitem_cast<TupItemGroup *>(item->parentItem())) { item->setSelected(false); TupLayer *layer = k->scene->layer(k->framePosition.layer); if (layer) { TupFrame *frame = layer->frame(k->framePosition.frame); if (frame) { item->setOpacity(opacity); // k->objectCounter++; addItem(item); } } } }
TupFrame *TupGraphicsScene::currentFrame() { if (k->scene) { if (k->scene->layersTotal() > 0) { if (k->framePosition.layer < k->scene->layersTotal()) { if (k->scene->layers().contains(k->framePosition.layer)) { TupLayer *layer = k->scene->layer(k->framePosition.layer); Q_CHECK_PTR(layer); if (layer) { if (!layer->frames().isEmpty()) return layer->frame(k->framePosition.frame); } else { #ifdef K_DEBUG tFatal() << "TupGraphicsScene::currentFrame - No layer available: " << k->framePosition.frame; #endif } } else { #ifdef K_DEBUG tFatal() << "TupGraphicsScene::currentFrame - Layer index incorrect!"; #endif } } else { TupLayer *layer = k->scene->layer(k->scene->layersTotal() - 1); if (layer) { if (!layer->frames().isEmpty()) return layer->frame(k->framePosition.frame); } } } } return 0; }
bool TupCommandExecutor::selectFrame(TupFrameResponse *response) { #ifdef K_DEBUG #ifdef Q_OS_WIN32 qDebug() << "[TupCommandExecutor::selectFrame()]"; #else T_FUNCINFO; #endif #endif int scenePos = response->sceneIndex(); int layerPos = response->layerIndex(); int position = response->frameIndex(); // bool prioritary = response->arg().toBool(); TupScene *scene = m_project->scene(scenePos); if (!scene || scenePos < 0 || position < 0) return false; TupLayer *layer = scene->layer(layerPos); if (layer) { if (position < layer->framesTotal()) { TupFrame *frame = layer->frame(position); if (! frame) return false; emit responsed(response); return true; } else { #ifdef K_DEBUG QString msg = "TupCommandExecutor::selectFrame() - Invalid frame index -> " + QString::number(position); #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif return false; } } return false; }
bool TupCommandExecutor::renameFrame(TupFrameResponse *response) { #ifdef K_DEBUG #ifdef Q_OS_WIN32 qDebug() << "[TupCommandExecutor::renameFrame()]"; #else T_FUNCINFO; #endif #endif int scenePos = response->sceneIndex(); int layerPos = response->layerIndex(); int position = response->frameIndex(); QString newName= response->arg().toString(); QString oldName; TupScene *scene = m_project->scene(scenePos); if (!scene) return false; TupLayer *layer = scene->layer(layerPos); if (layer) { TupFrame *frame = layer->frame(position); if (! frame) return false; oldName = frame->frameName(); if (oldName.compare(newName) != 0) frame->setFrameName(newName); emit responsed(response); return true; } return false; }
void TupGraphicsScene::addSvgObject(TupSvgItem *svgItem, double opacity) { #ifdef K_DEBUG T_FUNCINFO; #endif if (svgItem) { k->onionSkin.opacityMap.insert(svgItem, opacity); svgItem->setSelected(false); TupLayer *layer = k->scene->layer(k->framePosition.layer); if (layer) { TupFrame *frame = layer->frame(k->framePosition.frame); if (frame) { svgItem->setOpacity(opacity); if (svgItem->symbolName().compare("dollar.svg")==0) connect(svgItem, SIGNAL(enabledChanged()), this, SIGNAL(showInfoWidget())); addItem(svgItem); } else { #ifdef K_DEBUG tFatal() << "TupGraphicsScene::addSvgObject() - Error: Frame #" << k->framePosition.frame << " NO available!"; #endif } } else { #ifdef K_DEBUG tFatal() << "TupGraphicsScene::addSvgObject() - Error: Layer #" << k->framePosition.layer << " NO available!"; #endif } } else { #ifdef K_DEBUG tFatal() << "TupGraphicsScene::addSvgObject() - Error: No SVG item!"; #endif } }
bool TupCommandExecutor::pasteFrame(TupFrameResponse *response) { #ifdef K_DEBUG #ifdef Q_OS_WIN32 qDebug() << "[TupCommandExecutor::pasteFrame()]"; #else T_FUNCINFO; #endif #endif int scenePos = response->sceneIndex(); int layerPos = response->layerIndex(); int position = response->frameIndex(); QString copyFrame = response->arg().toString(); TupScene *scene = m_project->scene(scenePos); if (scene) { TupLayer *layer = scene->layer(layerPos); if (layer) { TupFrame *frame = layer->frame(position); if (frame) { QString name = frame->frameName(); QDomDocument doc; doc.appendChild(frame->toXml(doc)); response->setArg(doc.toString(0)); frame->clear(); frame->fromXml(copyFrame); frame->setFrameName(name); response->setFrameState(frame->isEmpty()); emit responsed(response); return true; } } } return false; }
void TupGraphicsScene::includeObject(QGraphicsItem *object) { if (k->spaceMode == TupProject::FRAMES_EDITION) { TupLayer *layer = k->scene->layer(k->framePosition.layer); if (layer) { TupFrame *frame = layer->frame(k->framePosition.frame); if (frame) { int zLevel = frame->getTopZLevel(); object->setZValue(zLevel); addItem(object); } } } else { TupBackground *bg = k->scene->background(); TupFrame *frame = bg->frame(); if (frame) { int zLevel = frame->getTopZLevel(); object->setZValue(zLevel); addItem(object); } } }
void TupGraphicsScene::drawPhotogram(int photogram) { /* #ifdef K_DEBUG T_FUNCINFO; #endif */ // Q_CHECK_PTR(k->scene); if (photogram < 0 || !k->scene) return; cleanWorkSpace(); bool valid = false; // Drawing frames from another layers for (int i=0; i < k->scene->layersTotal(); i++) { TupLayer *layer = k->scene->layer(i); if (layer->framesTotal() > 0 && photogram < layer->framesTotal()) { TupFrame *mainFrame = layer->frame(photogram); QString currentFrame = ""; if (mainFrame) { currentFrame = mainFrame->frameName(); if (layer) { if (layer->isVisible()) { // Painting the background drawBackground(); // Painting previews frames if (k->onionSkin.previous > 0 && photogram > 0) { double opacity = k->opacity; double opacityFactor = opacity / (double)qMin(layer->frames().count(), k->onionSkin.previous); int limit = photogram - k->onionSkin.previous; if (limit < 0) limit = 0; QString frameBehind = ""; for (int frameIndex = photogram-1; frameIndex >= limit; frameIndex--) { TupFrame *frame = layer->frame(frameIndex); QString previousFrame = frame->frameName(); if (frame && previousFrame.compare(currentFrame) != 0 && frameBehind.compare(previousFrame) != 0) { addFrame(frame, opacity, Preview); } frameBehind = previousFrame; opacity -= opacityFactor; } } // valid = true; // k->layerCounter = i; addFrame(mainFrame, TupGraphicsScene::Current); // Painting next frames if (k->onionSkin.next > 0 && layer->framesTotal() > photogram + 1) { double opacity = k->opacity; double opacityFactor = opacity / (double)qMin(layer->frames().count(), k->onionSkin.next); int limit = photogram + k->onionSkin.next; if (limit >= layer->frames().count()) limit = layer->frames().count() - 1; QString frameLater = ""; for (int frameIndex = photogram+1; frameIndex <= limit; frameIndex++) { TupFrame * frame = layer->frame(frameIndex); QString nextFrame = frame->frameName(); if (frame && nextFrame.compare(currentFrame) != 0 && frameLater.compare(nextFrame) != 0) { addFrame(frame, opacity, Next); } frameLater = nextFrame; opacity -= opacityFactor; } } // SQA: Crashpoint when layers are deleted valid = true; k->layerCounter = i; // addFrame(mainFrame, TupGraphicsScene::Current); } } } } } // Drawing tweening objects if (valid) { addTweeningObjects(photogram); addSvgTweeningObjects(photogram); update(); } if (k->tool) k->tool->updateScene(this); }